1 /* SPDX-License-Identifier: GPL-2.0 */
3 * NVMe over Fabrics TCP protocol header.
4 * Copyright (c) 2018 Lightbits Labs. All rights reserved.
7 #ifndef _LINUX_NVME_TCP_H
8 #define _LINUX_NVME_TCP_H
10 #include <linux/nvme.h>
12 #define NVME_TCP_DISC_PORT 8009
13 #define NVME_TCP_ADMIN_CCSZ SZ_8K
14 #define NVME_TCP_DIGEST_LENGTH 4
15 #define NVME_TCP_MIN_MAXH2CDATA 4096
18 NVME_TCP_PFV_1_0
= 0x0,
21 enum nvme_tcp_tls_cipher
{
22 NVME_TCP_TLS_CIPHER_INVALID
= 0,
23 NVME_TCP_TLS_CIPHER_SHA256
= 1,
24 NVME_TCP_TLS_CIPHER_SHA384
= 2,
27 enum nvme_tcp_fatal_error_status
{
28 NVME_TCP_FES_INVALID_PDU_HDR
= 0x01,
29 NVME_TCP_FES_PDU_SEQ_ERR
= 0x02,
30 NVME_TCP_FES_HDR_DIGEST_ERR
= 0x03,
31 NVME_TCP_FES_DATA_OUT_OF_RANGE
= 0x04,
32 NVME_TCP_FES_R2T_LIMIT_EXCEEDED
= 0x05,
33 NVME_TCP_FES_DATA_LIMIT_EXCEEDED
= 0x05,
34 NVME_TCP_FES_UNSUPPORTED_PARAM
= 0x06,
37 enum nvme_tcp_digest_option
{
38 NVME_TCP_HDR_DIGEST_ENABLE
= (1 << 0),
39 NVME_TCP_DATA_DIGEST_ENABLE
= (1 << 1),
42 enum nvme_tcp_pdu_type
{
44 nvme_tcp_icresp
= 0x1,
45 nvme_tcp_h2c_term
= 0x2,
46 nvme_tcp_c2h_term
= 0x3,
49 nvme_tcp_h2c_data
= 0x6,
50 nvme_tcp_c2h_data
= 0x7,
54 enum nvme_tcp_pdu_flags
{
55 NVME_TCP_F_HDGST
= (1 << 0),
56 NVME_TCP_F_DDGST
= (1 << 1),
57 NVME_TCP_F_DATA_LAST
= (1 << 2),
58 NVME_TCP_F_DATA_SUCCESS
= (1 << 3),
62 * struct nvme_tcp_hdr - nvme tcp pdu common header
65 * @flags: pdu specific flags
66 * @hlen: pdu header length
67 * @pdo: pdu data offset
68 * @plen: pdu wire byte length
79 * struct nvme_tcp_icreq_pdu - nvme tcp initialize connection request pdu
81 * @hdr: pdu generic header
82 * @pfv: pdu version format
83 * @hpda: host pdu data alignment (dwords, 0's based)
84 * @digest: digest types enabled
85 * @maxr2t: maximum r2ts per request supported
87 struct nvme_tcp_icreq_pdu
{
88 struct nvme_tcp_hdr hdr
;
97 * struct nvme_tcp_icresp_pdu - nvme tcp initialize connection response pdu
99 * @hdr: pdu common header
100 * @pfv: pdu version format
101 * @cpda: controller pdu data alignment (dowrds, 0's based)
102 * @digest: digest types enabled
103 * @maxdata: maximum data capsules per r2t supported
105 struct nvme_tcp_icresp_pdu
{
106 struct nvme_tcp_hdr hdr
;
115 * struct nvme_tcp_term_pdu - nvme tcp terminate connection pdu
117 * @hdr: pdu common header
118 * @fes: fatal error status
119 * @fei: fatal error information
121 struct nvme_tcp_term_pdu
{
122 struct nvme_tcp_hdr hdr
;
130 * struct nvme_tcp_cmd_pdu - nvme tcp command capsule pdu
132 * @hdr: pdu common header
135 struct nvme_tcp_cmd_pdu
{
136 struct nvme_tcp_hdr hdr
;
137 struct nvme_command cmd
;
141 * struct nvme_tcp_rsp_pdu - nvme tcp response capsule pdu
143 * @hdr: pdu common header
144 * @hdr: nvme-tcp generic header
145 * @cqe: nvme completion queue entry
147 struct nvme_tcp_rsp_pdu
{
148 struct nvme_tcp_hdr hdr
;
149 struct nvme_completion cqe
;
153 * struct nvme_tcp_r2t_pdu - nvme tcp ready-to-transfer pdu
155 * @hdr: pdu common header
156 * @command_id: nvme command identifier which this relates to
157 * @ttag: transfer tag (controller generated)
158 * @r2t_offset: offset from the start of the command data
159 * @r2t_length: length the host is allowed to send
161 struct nvme_tcp_r2t_pdu
{
162 struct nvme_tcp_hdr hdr
;
171 * struct nvme_tcp_data_pdu - nvme tcp data pdu
173 * @hdr: pdu common header
174 * @command_id: nvme command identifier which this relates to
175 * @ttag: transfer tag (controller generated)
176 * @data_offset: offset from the start of the command data
177 * @data_length: length of the data stream
179 struct nvme_tcp_data_pdu
{
180 struct nvme_tcp_hdr hdr
;
189 struct nvme_tcp_icreq_pdu icreq
;
190 struct nvme_tcp_icresp_pdu icresp
;
191 struct nvme_tcp_cmd_pdu cmd
;
192 struct nvme_tcp_rsp_pdu rsp
;
193 struct nvme_tcp_r2t_pdu r2t
;
194 struct nvme_tcp_data_pdu data
;
197 #endif /* _LINUX_NVME_TCP_H */