Linux kernel mirror (for testing)
git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel
os
linux
1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * NVMe over Fabrics TCP protocol header.
4 * Copyright (c) 2018 Lightbits Labs. All rights reserved.
5 */
6
7#ifndef _LINUX_NVME_TCP_H
8#define _LINUX_NVME_TCP_H
9
10#include <linux/nvme.h>
11
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
16#define NVME_TCP_MIN_C2HTERM_PLEN 24
17#define NVME_TCP_MAX_C2HTERM_PLEN 152
18
19enum nvme_tcp_pfv {
20 NVME_TCP_PFV_1_0 = 0x0,
21};
22
23enum nvme_tcp_tls_cipher {
24 NVME_TCP_TLS_CIPHER_INVALID = 0,
25 NVME_TCP_TLS_CIPHER_SHA256 = 1,
26 NVME_TCP_TLS_CIPHER_SHA384 = 2,
27};
28
29enum nvme_tcp_fatal_error_status {
30 NVME_TCP_FES_INVALID_PDU_HDR = 0x01,
31 NVME_TCP_FES_PDU_SEQ_ERR = 0x02,
32 NVME_TCP_FES_HDR_DIGEST_ERR = 0x03,
33 NVME_TCP_FES_DATA_OUT_OF_RANGE = 0x04,
34 NVME_TCP_FES_R2T_LIMIT_EXCEEDED = 0x05,
35 NVME_TCP_FES_DATA_LIMIT_EXCEEDED = 0x05,
36 NVME_TCP_FES_UNSUPPORTED_PARAM = 0x06,
37};
38
39enum nvme_tcp_digest_option {
40 NVME_TCP_HDR_DIGEST_ENABLE = (1 << 0),
41 NVME_TCP_DATA_DIGEST_ENABLE = (1 << 1),
42};
43
44enum nvme_tcp_pdu_type {
45 nvme_tcp_icreq = 0x0,
46 nvme_tcp_icresp = 0x1,
47 nvme_tcp_h2c_term = 0x2,
48 nvme_tcp_c2h_term = 0x3,
49 nvme_tcp_cmd = 0x4,
50 nvme_tcp_rsp = 0x5,
51 nvme_tcp_h2c_data = 0x6,
52 nvme_tcp_c2h_data = 0x7,
53 nvme_tcp_r2t = 0x9,
54};
55
56enum nvme_tcp_pdu_flags {
57 NVME_TCP_F_HDGST = (1 << 0),
58 NVME_TCP_F_DDGST = (1 << 1),
59 NVME_TCP_F_DATA_LAST = (1 << 2),
60 NVME_TCP_F_DATA_SUCCESS = (1 << 3),
61};
62
63/**
64 * struct nvme_tcp_hdr - nvme tcp pdu common header
65 *
66 * @type: pdu type
67 * @flags: pdu specific flags
68 * @hlen: pdu header length
69 * @pdo: pdu data offset
70 * @plen: pdu wire byte length
71 */
72struct nvme_tcp_hdr {
73 __u8 type;
74 __u8 flags;
75 __u8 hlen;
76 __u8 pdo;
77 __le32 plen;
78};
79
80/**
81 * struct nvme_tcp_icreq_pdu - nvme tcp initialize connection request pdu
82 *
83 * @hdr: pdu generic header
84 * @pfv: pdu version format
85 * @hpda: host pdu data alignment (dwords, 0's based)
86 * @digest: digest types enabled
87 * @maxr2t: maximum r2ts per request supported
88 */
89struct nvme_tcp_icreq_pdu {
90 struct nvme_tcp_hdr hdr;
91 __le16 pfv;
92 __u8 hpda;
93 __u8 digest;
94 __le32 maxr2t;
95 __u8 rsvd2[112];
96};
97
98/**
99 * struct nvme_tcp_icresp_pdu - nvme tcp initialize connection response pdu
100 *
101 * @hdr: pdu common header
102 * @pfv: pdu version format
103 * @cpda: controller pdu data alignment (dowrds, 0's based)
104 * @digest: digest types enabled
105 * @maxdata: maximum data capsules per r2t supported
106 */
107struct nvme_tcp_icresp_pdu {
108 struct nvme_tcp_hdr hdr;
109 __le16 pfv;
110 __u8 cpda;
111 __u8 digest;
112 __le32 maxdata;
113 __u8 rsvd[112];
114};
115
116/**
117 * struct nvme_tcp_term_pdu - nvme tcp terminate connection pdu
118 *
119 * @hdr: pdu common header
120 * @fes: fatal error status
121 * @fei: fatal error information
122 */
123struct nvme_tcp_term_pdu {
124 struct nvme_tcp_hdr hdr;
125 __le16 fes;
126 __le16 feil;
127 __le16 feiu;
128 __u8 rsvd[10];
129};
130
131/**
132 * struct nvme_tcp_cmd_pdu - nvme tcp command capsule pdu
133 *
134 * @hdr: pdu common header
135 * @cmd: nvme command
136 */
137struct nvme_tcp_cmd_pdu {
138 struct nvme_tcp_hdr hdr;
139 struct nvme_command cmd;
140};
141
142/**
143 * struct nvme_tcp_rsp_pdu - nvme tcp response capsule pdu
144 *
145 * @hdr: pdu common header
146 * @hdr: nvme-tcp generic header
147 * @cqe: nvme completion queue entry
148 */
149struct nvme_tcp_rsp_pdu {
150 struct nvme_tcp_hdr hdr;
151 struct nvme_completion cqe;
152};
153
154/**
155 * struct nvme_tcp_r2t_pdu - nvme tcp ready-to-transfer pdu
156 *
157 * @hdr: pdu common header
158 * @command_id: nvme command identifier which this relates to
159 * @ttag: transfer tag (controller generated)
160 * @r2t_offset: offset from the start of the command data
161 * @r2t_length: length the host is allowed to send
162 */
163struct nvme_tcp_r2t_pdu {
164 struct nvme_tcp_hdr hdr;
165 __u16 command_id;
166 __u16 ttag;
167 __le32 r2t_offset;
168 __le32 r2t_length;
169 __u8 rsvd[4];
170};
171
172/**
173 * struct nvme_tcp_data_pdu - nvme tcp data pdu
174 *
175 * @hdr: pdu common header
176 * @command_id: nvme command identifier which this relates to
177 * @ttag: transfer tag (controller generated)
178 * @data_offset: offset from the start of the command data
179 * @data_length: length of the data stream
180 */
181struct nvme_tcp_data_pdu {
182 struct nvme_tcp_hdr hdr;
183 __u16 command_id;
184 __u16 ttag;
185 __le32 data_offset;
186 __le32 data_length;
187 __u8 rsvd[4];
188};
189
190union nvme_tcp_pdu {
191 struct nvme_tcp_icreq_pdu icreq;
192 struct nvme_tcp_icresp_pdu icresp;
193 struct nvme_tcp_cmd_pdu cmd;
194 struct nvme_tcp_rsp_pdu rsp;
195 struct nvme_tcp_r2t_pdu r2t;
196 struct nvme_tcp_data_pdu data;
197};
198
199#endif /* _LINUX_NVME_TCP_H */