Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 */
0002 /*
0003  * NVMe over Fabrics TCP protocol header.
0004  * Copyright (c) 2018 Lightbits Labs. All rights reserved.
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  * struct nvme_tcp_hdr - nvme tcp pdu common header
0057  *
0058  * @type:          pdu type
0059  * @flags:         pdu specific flags
0060  * @hlen:          pdu header length
0061  * @pdo:           pdu data offset
0062  * @plen:          pdu wire byte length
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  * struct nvme_tcp_icreq_pdu - nvme tcp initialize connection request pdu
0074  *
0075  * @hdr:           pdu generic header
0076  * @pfv:           pdu version format
0077  * @hpda:          host pdu data alignment (dwords, 0's based)
0078  * @digest:        digest types enabled
0079  * @maxr2t:        maximum r2ts per request supported
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  * struct nvme_tcp_icresp_pdu - nvme tcp initialize connection response pdu
0092  *
0093  * @hdr:           pdu common header
0094  * @pfv:           pdu version format
0095  * @cpda:          controller pdu data alignment (dowrds, 0's based)
0096  * @digest:        digest types enabled
0097  * @maxdata:       maximum data capsules per r2t supported
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  * struct nvme_tcp_term_pdu - nvme tcp terminate connection pdu
0110  *
0111  * @hdr:           pdu common header
0112  * @fes:           fatal error status
0113  * @fei:           fatal error information
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  * struct nvme_tcp_cmd_pdu - nvme tcp command capsule pdu
0124  *
0125  * @hdr:           pdu common header
0126  * @cmd:           nvme command
0127  */
0128 struct nvme_tcp_cmd_pdu {
0129     struct nvme_tcp_hdr hdr;
0130     struct nvme_command cmd;
0131 };
0132 
0133 /**
0134  * struct nvme_tcp_rsp_pdu - nvme tcp response capsule pdu
0135  *
0136  * @hdr:           pdu common header
0137  * @hdr:           nvme-tcp generic header
0138  * @cqe:           nvme completion queue entry
0139  */
0140 struct nvme_tcp_rsp_pdu {
0141     struct nvme_tcp_hdr hdr;
0142     struct nvme_completion  cqe;
0143 };
0144 
0145 /**
0146  * struct nvme_tcp_r2t_pdu - nvme tcp ready-to-transfer pdu
0147  *
0148  * @hdr:           pdu common header
0149  * @command_id:    nvme command identifier which this relates to
0150  * @ttag:          transfer tag (controller generated)
0151  * @r2t_offset:    offset from the start of the command data
0152  * @r2t_length:    length the host is allowed to send
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  * struct nvme_tcp_data_pdu - nvme tcp data pdu
0165  *
0166  * @hdr:           pdu common header
0167  * @command_id:    nvme command identifier which this relates to
0168  * @ttag:          transfer tag (controller generated)
0169  * @data_offset:   offset from the start of the command data
0170  * @data_length:   length of the data stream
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 /* _LINUX_NVME_TCP_H */