qed_nvmetcp_if.h 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
  2. /* Copyright 2021 Marvell. All rights reserved. */
  3. #ifndef _QED_NVMETCP_IF_H
  4. #define _QED_NVMETCP_IF_H
  5. #include <linux/types.h>
  6. #include <linux/qed/qed_if.h>
  7. #include <linux/qed/storage_common.h>
  8. #include <linux/qed/nvmetcp_common.h>
  9. #define QED_NVMETCP_MAX_IO_SIZE 0x800000
  10. #define QED_NVMETCP_CMN_HDR_SIZE (sizeof(struct nvme_tcp_hdr))
  11. #define QED_NVMETCP_CMD_HDR_SIZE (sizeof(struct nvme_tcp_cmd_pdu))
  12. #define QED_NVMETCP_NON_IO_HDR_SIZE ((QED_NVMETCP_CMN_HDR_SIZE + 16))
  13. typedef int (*nvmetcp_event_cb_t) (void *context,
  14. u8 fw_event_code, void *fw_handle);
  15. struct qed_dev_nvmetcp_info {
  16. struct qed_dev_info common;
  17. u8 port_id; /* Physical port */
  18. u8 num_cqs;
  19. };
  20. #define MAX_TID_BLOCKS_NVMETCP (512)
  21. struct qed_nvmetcp_tid {
  22. u32 size; /* In bytes per task */
  23. u32 num_tids_per_block;
  24. u8 *blocks[MAX_TID_BLOCKS_NVMETCP];
  25. };
  26. struct qed_nvmetcp_id_params {
  27. u8 mac[ETH_ALEN];
  28. u32 ip[4];
  29. u16 port;
  30. };
  31. struct qed_nvmetcp_params_offload {
  32. /* FW initializations */
  33. dma_addr_t sq_pbl_addr;
  34. dma_addr_t nvmetcp_cccid_itid_table_addr;
  35. u16 nvmetcp_cccid_max_range;
  36. u8 default_cq;
  37. /* Networking and TCP stack initializations */
  38. struct qed_nvmetcp_id_params src;
  39. struct qed_nvmetcp_id_params dst;
  40. u32 ka_timeout;
  41. u32 ka_interval;
  42. u32 max_rt_time;
  43. u32 cwnd;
  44. u16 mss;
  45. u16 vlan_id;
  46. bool timestamp_en;
  47. bool delayed_ack_en;
  48. bool tcp_keep_alive_en;
  49. bool ecn_en;
  50. u8 ip_version;
  51. u8 ka_max_probe_cnt;
  52. u8 ttl;
  53. u8 tos_or_tc;
  54. u8 rcv_wnd_scale;
  55. };
  56. struct qed_nvmetcp_params_update {
  57. u32 max_io_size;
  58. u32 max_recv_pdu_length;
  59. u32 max_send_pdu_length;
  60. /* Placeholder: pfv, cpda, hpda */
  61. bool hdr_digest_en;
  62. bool data_digest_en;
  63. };
  64. struct qed_nvmetcp_cb_ops {
  65. struct qed_common_cb_ops common;
  66. };
  67. struct nvmetcp_sge {
  68. struct regpair sge_addr; /* SGE address */
  69. __le32 sge_len; /* SGE length */
  70. __le32 reserved;
  71. };
  72. /* IO path HSI function SGL params */
  73. struct storage_sgl_task_params {
  74. struct nvmetcp_sge *sgl;
  75. struct regpair sgl_phys_addr;
  76. u32 total_buffer_size;
  77. u16 num_sges;
  78. bool small_mid_sge;
  79. };
  80. /* IO path HSI function FW task context params */
  81. struct nvmetcp_task_params {
  82. void *context; /* Output parameter - set/filled by the HSI function */
  83. struct nvmetcp_wqe *sqe;
  84. u32 tx_io_size; /* in bytes (Without DIF, if exists) */
  85. u32 rx_io_size; /* in bytes (Without DIF, if exists) */
  86. u16 conn_icid;
  87. u16 itid;
  88. struct regpair opq; /* qedn_task_ctx address */
  89. u16 host_cccid;
  90. u8 cq_rss_number;
  91. bool send_write_incapsule;
  92. };
  93. /**
  94. * struct qed_nvmetcp_ops - qed NVMeTCP operations.
  95. * @common: common operations pointer
  96. * @ll2: light L2 operations pointer
  97. * @fill_dev_info: fills NVMeTCP specific information
  98. * @param cdev
  99. * @param info
  100. * @return 0 on success, otherwise error value.
  101. * @register_ops: register nvmetcp operations
  102. * @param cdev
  103. * @param ops - specified using qed_nvmetcp_cb_ops
  104. * @param cookie - driver private
  105. * @start: nvmetcp in FW
  106. * @param cdev
  107. * @param tasks - qed will fill information about tasks
  108. * return 0 on success, otherwise error value.
  109. * @stop: nvmetcp in FW
  110. * @param cdev
  111. * return 0 on success, otherwise error value.
  112. * @acquire_conn: acquire a new nvmetcp connection
  113. * @param cdev
  114. * @param handle - qed will fill handle that should be
  115. * used henceforth as identifier of the
  116. * connection.
  117. * @param p_doorbell - qed will fill the address of the
  118. * doorbell.
  119. * @return 0 on success, otherwise error value.
  120. * @release_conn: release a previously acquired nvmetcp connection
  121. * @param cdev
  122. * @param handle - the connection handle.
  123. * @return 0 on success, otherwise error value.
  124. * @offload_conn: configures an offloaded connection
  125. * @param cdev
  126. * @param handle - the connection handle.
  127. * @param conn_info - the configuration to use for the
  128. * offload.
  129. * @return 0 on success, otherwise error value.
  130. * @update_conn: updates an offloaded connection
  131. * @param cdev
  132. * @param handle - the connection handle.
  133. * @param conn_info - the configuration to use for the
  134. * offload.
  135. * @return 0 on success, otherwise error value.
  136. * @destroy_conn: stops an offloaded connection
  137. * @param cdev
  138. * @param handle - the connection handle.
  139. * @return 0 on success, otherwise error value.
  140. * @clear_sq: clear all task in sq
  141. * @param cdev
  142. * @param handle - the connection handle.
  143. * @return 0 on success, otherwise error value.
  144. * @add_src_tcp_port_filter: Add source tcp port filter
  145. * @param cdev
  146. * @param src_port
  147. * @remove_src_tcp_port_filter: Remove source tcp port filter
  148. * @param cdev
  149. * @param src_port
  150. * @add_dst_tcp_port_filter: Add destination tcp port filter
  151. * @param cdev
  152. * @param dest_port
  153. * @remove_dst_tcp_port_filter: Remove destination tcp port filter
  154. * @param cdev
  155. * @param dest_port
  156. * @clear_all_filters: Clear all filters.
  157. * @param cdev
  158. * @init_read_io: Init read IO.
  159. * @task_params
  160. * @cmd_pdu_header
  161. * @nvme_cmd
  162. * @sgl_task_params
  163. * @init_write_io: Init write IO.
  164. * @task_params
  165. * @cmd_pdu_header
  166. * @nvme_cmd
  167. * @sgl_task_params
  168. * @init_icreq_exchange: Exchange ICReq.
  169. * @task_params
  170. * @init_conn_req_pdu_hdr
  171. * @tx_sgl_task_params
  172. * @rx_sgl_task_params
  173. * @init_task_cleanup: Init task cleanup.
  174. * @task_params
  175. */
  176. struct qed_nvmetcp_ops {
  177. const struct qed_common_ops *common;
  178. const struct qed_ll2_ops *ll2;
  179. int (*fill_dev_info)(struct qed_dev *cdev,
  180. struct qed_dev_nvmetcp_info *info);
  181. void (*register_ops)(struct qed_dev *cdev,
  182. struct qed_nvmetcp_cb_ops *ops, void *cookie);
  183. int (*start)(struct qed_dev *cdev,
  184. struct qed_nvmetcp_tid *tasks,
  185. void *event_context, nvmetcp_event_cb_t async_event_cb);
  186. int (*stop)(struct qed_dev *cdev);
  187. int (*acquire_conn)(struct qed_dev *cdev,
  188. u32 *handle,
  189. u32 *fw_cid, void __iomem **p_doorbell);
  190. int (*release_conn)(struct qed_dev *cdev, u32 handle);
  191. int (*offload_conn)(struct qed_dev *cdev,
  192. u32 handle,
  193. struct qed_nvmetcp_params_offload *conn_info);
  194. int (*update_conn)(struct qed_dev *cdev,
  195. u32 handle,
  196. struct qed_nvmetcp_params_update *conn_info);
  197. int (*destroy_conn)(struct qed_dev *cdev, u32 handle, u8 abrt_conn);
  198. int (*clear_sq)(struct qed_dev *cdev, u32 handle);
  199. int (*add_src_tcp_port_filter)(struct qed_dev *cdev, u16 src_port);
  200. void (*remove_src_tcp_port_filter)(struct qed_dev *cdev, u16 src_port);
  201. int (*add_dst_tcp_port_filter)(struct qed_dev *cdev, u16 dest_port);
  202. void (*remove_dst_tcp_port_filter)(struct qed_dev *cdev, u16 dest_port);
  203. void (*clear_all_filters)(struct qed_dev *cdev);
  204. void (*init_read_io)(struct nvmetcp_task_params *task_params,
  205. struct nvme_tcp_cmd_pdu *cmd_pdu_header,
  206. struct nvme_command *nvme_cmd,
  207. struct storage_sgl_task_params *sgl_task_params);
  208. void (*init_write_io)(struct nvmetcp_task_params *task_params,
  209. struct nvme_tcp_cmd_pdu *cmd_pdu_header,
  210. struct nvme_command *nvme_cmd,
  211. struct storage_sgl_task_params *sgl_task_params);
  212. void (*init_icreq_exchange)(struct nvmetcp_task_params *task_params,
  213. struct nvme_tcp_icreq_pdu *init_conn_req_pdu_hdr,
  214. struct storage_sgl_task_params *tx_sgl_task_params,
  215. struct storage_sgl_task_params *rx_sgl_task_params);
  216. void (*init_task_cleanup)(struct nvmetcp_task_params *task_params);
  217. };
  218. const struct qed_nvmetcp_ops *qed_get_nvmetcp_ops(void);
  219. void qed_put_nvmetcp_ops(void);
  220. #endif