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