nvme-tcp.h 4.4 KB

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