Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
0002 /* Copyright 2021 Marvell. All rights reserved. */
0003 
0004 #ifndef _QED_NVMETCP_IF_H
0005 #define _QED_NVMETCP_IF_H
0006 #include <linux/types.h>
0007 #include <linux/qed/qed_if.h>
0008 #include <linux/qed/storage_common.h>
0009 #include <linux/qed/nvmetcp_common.h>
0010 
0011 #define QED_NVMETCP_MAX_IO_SIZE 0x800000
0012 #define QED_NVMETCP_CMN_HDR_SIZE (sizeof(struct nvme_tcp_hdr))
0013 #define QED_NVMETCP_CMD_HDR_SIZE (sizeof(struct nvme_tcp_cmd_pdu))
0014 #define QED_NVMETCP_NON_IO_HDR_SIZE ((QED_NVMETCP_CMN_HDR_SIZE + 16))
0015 
0016 typedef int (*nvmetcp_event_cb_t) (void *context,
0017                    u8 fw_event_code, void *fw_handle);
0018 
0019 struct qed_dev_nvmetcp_info {
0020     struct qed_dev_info common;
0021     u8 port_id;  /* Physical port */
0022     u8 num_cqs;
0023 };
0024 
0025 #define MAX_TID_BLOCKS_NVMETCP (512)
0026 struct qed_nvmetcp_tid {
0027     u32 size;       /* In bytes per task */
0028     u32 num_tids_per_block;
0029     u8 *blocks[MAX_TID_BLOCKS_NVMETCP];
0030 };
0031 
0032 struct qed_nvmetcp_id_params {
0033     u8 mac[ETH_ALEN];
0034     u32 ip[4];
0035     u16 port;
0036 };
0037 
0038 struct qed_nvmetcp_params_offload {
0039     /* FW initializations */
0040     dma_addr_t sq_pbl_addr;
0041     dma_addr_t nvmetcp_cccid_itid_table_addr;
0042     u16 nvmetcp_cccid_max_range;
0043     u8 default_cq;
0044 
0045     /* Networking and TCP stack initializations */
0046     struct qed_nvmetcp_id_params src;
0047     struct qed_nvmetcp_id_params dst;
0048     u32 ka_timeout;
0049     u32 ka_interval;
0050     u32 max_rt_time;
0051     u32 cwnd;
0052     u16 mss;
0053     u16 vlan_id;
0054     bool timestamp_en;
0055     bool delayed_ack_en;
0056     bool tcp_keep_alive_en;
0057     bool ecn_en;
0058     u8 ip_version;
0059     u8 ka_max_probe_cnt;
0060     u8 ttl;
0061     u8 tos_or_tc;
0062     u8 rcv_wnd_scale;
0063 };
0064 
0065 struct qed_nvmetcp_params_update {
0066     u32 max_io_size;
0067     u32 max_recv_pdu_length;
0068     u32 max_send_pdu_length;
0069 
0070     /* Placeholder: pfv, cpda, hpda */
0071 
0072     bool hdr_digest_en;
0073     bool data_digest_en;
0074 };
0075 
0076 struct qed_nvmetcp_cb_ops {
0077     struct qed_common_cb_ops common;
0078 };
0079 
0080 struct nvmetcp_sge {
0081     struct regpair sge_addr; /* SGE address */
0082     __le32 sge_len; /* SGE length */
0083     __le32 reserved;
0084 };
0085 
0086 /* IO path HSI function SGL params */
0087 struct storage_sgl_task_params {
0088     struct nvmetcp_sge *sgl;
0089     struct regpair sgl_phys_addr;
0090     u32 total_buffer_size;
0091     u16 num_sges;
0092     bool small_mid_sge;
0093 };
0094 
0095 /* IO path HSI function FW task context params */
0096 struct nvmetcp_task_params {
0097     void *context; /* Output parameter - set/filled by the HSI function */
0098     struct nvmetcp_wqe *sqe;
0099     u32 tx_io_size; /* in bytes (Without DIF, if exists) */
0100     u32 rx_io_size; /* in bytes (Without DIF, if exists) */
0101     u16 conn_icid;
0102     u16 itid;
0103     struct regpair opq; /* qedn_task_ctx address */
0104     u16 host_cccid;
0105     u8 cq_rss_number;
0106     bool send_write_incapsule;
0107 };
0108 
0109 /**
0110  * struct qed_nvmetcp_ops - qed NVMeTCP operations.
0111  * @common:     common operations pointer
0112  * @ll2:        light L2 operations pointer
0113  * @fill_dev_info:  fills NVMeTCP specific information
0114  *          @param cdev
0115  *          @param info
0116  *          @return 0 on success, otherwise error value.
0117  * @register_ops:   register nvmetcp operations
0118  *          @param cdev
0119  *          @param ops - specified using qed_nvmetcp_cb_ops
0120  *          @param cookie - driver private
0121  * @start:      nvmetcp in FW
0122  *          @param cdev
0123  *          @param tasks - qed will fill information about tasks
0124  *          return 0 on success, otherwise error value.
0125  * @stop:       nvmetcp in FW
0126  *          @param cdev
0127  *          return 0 on success, otherwise error value.
0128  * @acquire_conn:   acquire a new nvmetcp connection
0129  *          @param cdev
0130  *          @param handle - qed will fill handle that should be
0131  *              used henceforth as identifier of the
0132  *              connection.
0133  *          @param p_doorbell - qed will fill the address of the
0134  *              doorbell.
0135  *          @return 0 on success, otherwise error value.
0136  * @release_conn:   release a previously acquired nvmetcp connection
0137  *          @param cdev
0138  *          @param handle - the connection handle.
0139  *          @return 0 on success, otherwise error value.
0140  * @offload_conn:   configures an offloaded connection
0141  *          @param cdev
0142  *          @param handle - the connection handle.
0143  *          @param conn_info - the configuration to use for the
0144  *              offload.
0145  *          @return 0 on success, otherwise error value.
0146  * @update_conn:    updates an offloaded connection
0147  *          @param cdev
0148  *          @param handle - the connection handle.
0149  *          @param conn_info - the configuration to use for the
0150  *              offload.
0151  *          @return 0 on success, otherwise error value.
0152  * @destroy_conn:   stops an offloaded connection
0153  *          @param cdev
0154  *          @param handle - the connection handle.
0155  *          @return 0 on success, otherwise error value.
0156  * @clear_sq:       clear all task in sq
0157  *          @param cdev
0158  *          @param handle - the connection handle.
0159  *          @return 0 on success, otherwise error value.
0160  * @add_src_tcp_port_filter: Add source tcp port filter
0161  *          @param cdev
0162  *          @param src_port
0163  * @remove_src_tcp_port_filter: Remove source tcp port filter
0164  *          @param cdev
0165  *          @param src_port
0166  * @add_dst_tcp_port_filter: Add destination tcp port filter
0167  *          @param cdev
0168  *          @param dest_port
0169  * @remove_dst_tcp_port_filter: Remove destination tcp port filter
0170  *          @param cdev
0171  *          @param dest_port
0172  * @clear_all_filters: Clear all filters.
0173  *          @param cdev
0174  * @init_read_io: Init read IO.
0175  *          @task_params
0176  *          @cmd_pdu_header
0177  *          @nvme_cmd
0178  *          @sgl_task_params
0179  * @init_write_io: Init write IO.
0180  *          @task_params
0181  *          @cmd_pdu_header
0182  *          @nvme_cmd
0183  *          @sgl_task_params
0184  * @init_icreq_exchange: Exchange ICReq.
0185  *          @task_params
0186  *          @init_conn_req_pdu_hdr
0187  *          @tx_sgl_task_params
0188  *          @rx_sgl_task_params
0189  * @init_task_cleanup: Init task cleanup.
0190  *          @task_params
0191  */
0192 struct qed_nvmetcp_ops {
0193     const struct qed_common_ops *common;
0194 
0195     const struct qed_ll2_ops *ll2;
0196 
0197     int (*fill_dev_info)(struct qed_dev *cdev,
0198                  struct qed_dev_nvmetcp_info *info);
0199 
0200     void (*register_ops)(struct qed_dev *cdev,
0201                  struct qed_nvmetcp_cb_ops *ops, void *cookie);
0202 
0203     int (*start)(struct qed_dev *cdev,
0204              struct qed_nvmetcp_tid *tasks,
0205              void *event_context, nvmetcp_event_cb_t async_event_cb);
0206 
0207     int (*stop)(struct qed_dev *cdev);
0208 
0209     int (*acquire_conn)(struct qed_dev *cdev,
0210                 u32 *handle,
0211                 u32 *fw_cid, void __iomem **p_doorbell);
0212 
0213     int (*release_conn)(struct qed_dev *cdev, u32 handle);
0214 
0215     int (*offload_conn)(struct qed_dev *cdev,
0216                 u32 handle,
0217                 struct qed_nvmetcp_params_offload *conn_info);
0218 
0219     int (*update_conn)(struct qed_dev *cdev,
0220                u32 handle,
0221                struct qed_nvmetcp_params_update *conn_info);
0222 
0223     int (*destroy_conn)(struct qed_dev *cdev, u32 handle, u8 abrt_conn);
0224 
0225     int (*clear_sq)(struct qed_dev *cdev, u32 handle);
0226 
0227     int (*add_src_tcp_port_filter)(struct qed_dev *cdev, u16 src_port);
0228 
0229     void (*remove_src_tcp_port_filter)(struct qed_dev *cdev, u16 src_port);
0230 
0231     int (*add_dst_tcp_port_filter)(struct qed_dev *cdev, u16 dest_port);
0232 
0233     void (*remove_dst_tcp_port_filter)(struct qed_dev *cdev, u16 dest_port);
0234 
0235     void (*clear_all_filters)(struct qed_dev *cdev);
0236 
0237     void (*init_read_io)(struct nvmetcp_task_params *task_params,
0238                  struct nvme_tcp_cmd_pdu *cmd_pdu_header,
0239                  struct nvme_command *nvme_cmd,
0240                  struct storage_sgl_task_params *sgl_task_params);
0241 
0242     void (*init_write_io)(struct nvmetcp_task_params *task_params,
0243                   struct nvme_tcp_cmd_pdu *cmd_pdu_header,
0244                   struct nvme_command *nvme_cmd,
0245                   struct storage_sgl_task_params *sgl_task_params);
0246 
0247     void (*init_icreq_exchange)(struct nvmetcp_task_params *task_params,
0248                     struct nvme_tcp_icreq_pdu *init_conn_req_pdu_hdr,
0249                     struct storage_sgl_task_params *tx_sgl_task_params,
0250                     struct storage_sgl_task_params *rx_sgl_task_params);
0251 
0252     void (*init_task_cleanup)(struct nvmetcp_task_params *task_params);
0253 };
0254 
0255 const struct qed_nvmetcp_ops *qed_get_nvmetcp_ops(void);
0256 void qed_put_nvmetcp_ops(void);
0257 #endif