0001
0002
0003
0004
0005
0006
0007 #ifndef _LINUX_NVME_TCP_H
0008 #define _LINUX_NVME_TCP_H
0009
0010 #include <linux/nvme.h>
0011
0012 #define NVME_TCP_DISC_PORT 8009
0013 #define NVME_TCP_ADMIN_CCSZ SZ_8K
0014 #define NVME_TCP_DIGEST_LENGTH 4
0015 #define NVME_TCP_MIN_MAXH2CDATA 4096
0016
0017 enum nvme_tcp_pfv {
0018 NVME_TCP_PFV_1_0 = 0x0,
0019 };
0020
0021 enum nvme_tcp_fatal_error_status {
0022 NVME_TCP_FES_INVALID_PDU_HDR = 0x01,
0023 NVME_TCP_FES_PDU_SEQ_ERR = 0x02,
0024 NVME_TCP_FES_HDR_DIGEST_ERR = 0x03,
0025 NVME_TCP_FES_DATA_OUT_OF_RANGE = 0x04,
0026 NVME_TCP_FES_R2T_LIMIT_EXCEEDED = 0x05,
0027 NVME_TCP_FES_DATA_LIMIT_EXCEEDED = 0x05,
0028 NVME_TCP_FES_UNSUPPORTED_PARAM = 0x06,
0029 };
0030
0031 enum nvme_tcp_digest_option {
0032 NVME_TCP_HDR_DIGEST_ENABLE = (1 << 0),
0033 NVME_TCP_DATA_DIGEST_ENABLE = (1 << 1),
0034 };
0035
0036 enum nvme_tcp_pdu_type {
0037 nvme_tcp_icreq = 0x0,
0038 nvme_tcp_icresp = 0x1,
0039 nvme_tcp_h2c_term = 0x2,
0040 nvme_tcp_c2h_term = 0x3,
0041 nvme_tcp_cmd = 0x4,
0042 nvme_tcp_rsp = 0x5,
0043 nvme_tcp_h2c_data = 0x6,
0044 nvme_tcp_c2h_data = 0x7,
0045 nvme_tcp_r2t = 0x9,
0046 };
0047
0048 enum nvme_tcp_pdu_flags {
0049 NVME_TCP_F_HDGST = (1 << 0),
0050 NVME_TCP_F_DDGST = (1 << 1),
0051 NVME_TCP_F_DATA_LAST = (1 << 2),
0052 NVME_TCP_F_DATA_SUCCESS = (1 << 3),
0053 };
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064 struct nvme_tcp_hdr {
0065 __u8 type;
0066 __u8 flags;
0067 __u8 hlen;
0068 __u8 pdo;
0069 __le32 plen;
0070 };
0071
0072
0073
0074
0075
0076
0077
0078
0079
0080
0081 struct nvme_tcp_icreq_pdu {
0082 struct nvme_tcp_hdr hdr;
0083 __le16 pfv;
0084 __u8 hpda;
0085 __u8 digest;
0086 __le32 maxr2t;
0087 __u8 rsvd2[112];
0088 };
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099 struct nvme_tcp_icresp_pdu {
0100 struct nvme_tcp_hdr hdr;
0101 __le16 pfv;
0102 __u8 cpda;
0103 __u8 digest;
0104 __le32 maxdata;
0105 __u8 rsvd[112];
0106 };
0107
0108
0109
0110
0111
0112
0113
0114
0115 struct nvme_tcp_term_pdu {
0116 struct nvme_tcp_hdr hdr;
0117 __le16 fes;
0118 __le32 fei;
0119 __u8 rsvd[8];
0120 };
0121
0122
0123
0124
0125
0126
0127
0128 struct nvme_tcp_cmd_pdu {
0129 struct nvme_tcp_hdr hdr;
0130 struct nvme_command cmd;
0131 };
0132
0133
0134
0135
0136
0137
0138
0139
0140 struct nvme_tcp_rsp_pdu {
0141 struct nvme_tcp_hdr hdr;
0142 struct nvme_completion cqe;
0143 };
0144
0145
0146
0147
0148
0149
0150
0151
0152
0153
0154 struct nvme_tcp_r2t_pdu {
0155 struct nvme_tcp_hdr hdr;
0156 __u16 command_id;
0157 __u16 ttag;
0158 __le32 r2t_offset;
0159 __le32 r2t_length;
0160 __u8 rsvd[4];
0161 };
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172 struct nvme_tcp_data_pdu {
0173 struct nvme_tcp_hdr hdr;
0174 __u16 command_id;
0175 __u16 ttag;
0176 __le32 data_offset;
0177 __le32 data_length;
0178 __u8 rsvd[4];
0179 };
0180
0181 union nvme_tcp_pdu {
0182 struct nvme_tcp_icreq_pdu icreq;
0183 struct nvme_tcp_icresp_pdu icresp;
0184 struct nvme_tcp_cmd_pdu cmd;
0185 struct nvme_tcp_rsp_pdu rsp;
0186 struct nvme_tcp_r2t_pdu r2t;
0187 struct nvme_tcp_data_pdu data;
0188 };
0189
0190 #endif