Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause) */
0002 /* QLogic qed NIC Driver
0003  * Copyright (c) 2015-2017  QLogic Corporation
0004  * Copyright (c) 2019-2020 Marvell International Ltd.
0005  */
0006 
0007 #ifndef _QED_IWARP_H
0008 #define _QED_IWARP_H
0009 
0010 enum qed_iwarp_qp_state {
0011     QED_IWARP_QP_STATE_IDLE,
0012     QED_IWARP_QP_STATE_RTS,
0013     QED_IWARP_QP_STATE_TERMINATE,
0014     QED_IWARP_QP_STATE_CLOSING,
0015     QED_IWARP_QP_STATE_ERROR,
0016 };
0017 
0018 enum qed_iwarp_qp_state qed_roce2iwarp_state(enum qed_roce_qp_state state);
0019 
0020 #define QED_IWARP_PREALLOC_CNT  (256)
0021 
0022 #define QED_IWARP_LL2_SYN_TX_SIZE       (128)
0023 #define QED_IWARP_LL2_SYN_RX_SIZE       (256)
0024 
0025 #define QED_IWARP_LL2_OOO_DEF_TX_SIZE   (256)
0026 #define QED_IWARP_MAX_OOO       (16)
0027 #define QED_IWARP_LL2_OOO_MAX_RX_SIZE   (16384)
0028 
0029 #define QED_IWARP_HANDLE_INVAL      (0xff)
0030 
0031 struct qed_iwarp_ll2_buff {
0032     struct qed_iwarp_ll2_buff *piggy_buf;
0033     void *data;
0034     dma_addr_t data_phys_addr;
0035     u32 buff_size;
0036 };
0037 
0038 struct qed_iwarp_ll2_mpa_buf {
0039     struct list_head list_entry;
0040     struct qed_iwarp_ll2_buff *ll2_buf;
0041     struct unaligned_opaque_data data;
0042     u16 tcp_payload_len;
0043     u8 placement_offset;
0044 };
0045 
0046 /* In some cases a fpdu will arrive with only one byte of the header, in this
0047  * case the fpdu_length will be partial (contain only higher byte and
0048  * incomplete bytes will contain the invalid value
0049  */
0050 #define QED_IWARP_INVALID_INCOMPLETE_BYTES 0xffff
0051 
0052 struct qed_iwarp_fpdu {
0053     struct qed_iwarp_ll2_buff *mpa_buf;
0054     void *mpa_frag_virt;
0055     dma_addr_t mpa_frag;
0056     dma_addr_t pkt_hdr;
0057     u16 mpa_frag_len;
0058     u16 fpdu_length;
0059     u16 incomplete_bytes;
0060     u8 pkt_hdr_size;
0061 };
0062 
0063 struct qed_iwarp_info {
0064     struct list_head listen_list;   /* qed_iwarp_listener */
0065     struct list_head ep_list;   /* qed_iwarp_ep */
0066     struct list_head ep_free_list;  /* pre-allocated ep's */
0067     struct list_head mpa_buf_list;  /* list of mpa_bufs */
0068     struct list_head mpa_buf_pending_list;
0069     spinlock_t iw_lock; /* for iwarp resources */
0070     spinlock_t qp_lock; /* for teardown races */
0071     u32 rcv_wnd_scale;
0072     u16 rcv_wnd_size;
0073     u16 max_mtu;
0074     u8 mac_addr[ETH_ALEN];
0075     u8 crc_needed;
0076     u8 tcp_flags;
0077     u8 ll2_syn_handle;
0078     u8 ll2_ooo_handle;
0079     u8 ll2_mpa_handle;
0080     u8 peer2peer;
0081     enum mpa_negotiation_mode mpa_rev;
0082     enum mpa_rtr_type rtr_type;
0083     struct qed_iwarp_fpdu *partial_fpdus;
0084     struct qed_iwarp_ll2_mpa_buf *mpa_bufs;
0085     u8 *mpa_intermediate_buf;
0086     u16 max_num_partial_fpdus;
0087 };
0088 
0089 enum qed_iwarp_ep_state {
0090     QED_IWARP_EP_INIT,
0091     QED_IWARP_EP_MPA_REQ_RCVD,
0092     QED_IWARP_EP_MPA_OFFLOADED,
0093     QED_IWARP_EP_ESTABLISHED,
0094     QED_IWARP_EP_CLOSED
0095 };
0096 
0097 union async_output {
0098     struct iwarp_eqe_data_mpa_async_completion mpa_response;
0099     struct iwarp_eqe_data_tcp_async_completion mpa_request;
0100 };
0101 
0102 #define QED_MAX_PRIV_DATA_LEN (512)
0103 struct qed_iwarp_ep_memory {
0104     u8 in_pdata[QED_MAX_PRIV_DATA_LEN];
0105     u8 out_pdata[QED_MAX_PRIV_DATA_LEN];
0106     union async_output async_output;
0107 };
0108 
0109 /* Endpoint structure represents a TCP connection. This connection can be
0110  * associated with a QP or not (in which case QP==NULL)
0111  */
0112 struct qed_iwarp_ep {
0113     struct list_head list_entry;
0114     struct qed_rdma_qp *qp;
0115     struct qed_iwarp_ep_memory *ep_buffer_virt;
0116     dma_addr_t ep_buffer_phys;
0117     enum qed_iwarp_ep_state state;
0118     int sig;
0119     struct qed_iwarp_cm_info cm_info;
0120     enum tcp_connect_mode connect_mode;
0121     enum mpa_rtr_type rtr_type;
0122     enum mpa_negotiation_mode mpa_rev;
0123     u32 tcp_cid;
0124     u32 cid;
0125     u16 mss;
0126     u8 remote_mac_addr[6];
0127     u8 local_mac_addr[6];
0128     bool mpa_reply_processed;
0129 
0130     /* For Passive side - syn packet related data */
0131     u16 syn_ip_payload_length;
0132     struct qed_iwarp_ll2_buff *syn;
0133     dma_addr_t syn_phy_addr;
0134 
0135     /* The event_cb function is called for asynchrounous events associated
0136      * with the ep. It is initialized at different entry points depending
0137      * on whether the ep is the tcp connection active side or passive side
0138      * The cb_context is passed to the event_cb function.
0139      */
0140     iwarp_event_handler event_cb;
0141     void *cb_context;
0142 };
0143 
0144 struct qed_iwarp_listener {
0145     struct list_head list_entry;
0146 
0147     /* The event_cb function is called for connection requests.
0148      * The cb_context is passed to the event_cb function.
0149      */
0150     iwarp_event_handler event_cb;
0151     void *cb_context;
0152     u32 max_backlog;
0153     u32 ip_addr[4];
0154     u16 port;
0155     u16 vlan;
0156     u8 ip_version;
0157 };
0158 
0159 int qed_iwarp_alloc(struct qed_hwfn *p_hwfn);
0160 
0161 int qed_iwarp_setup(struct qed_hwfn *p_hwfn,
0162             struct qed_rdma_start_in_params *params);
0163 
0164 void qed_iwarp_init_fw_ramrod(struct qed_hwfn *p_hwfn,
0165                   struct iwarp_init_func_ramrod_data *p_ramrod);
0166 
0167 int qed_iwarp_stop(struct qed_hwfn *p_hwfn);
0168 
0169 void qed_iwarp_resc_free(struct qed_hwfn *p_hwfn);
0170 
0171 void qed_iwarp_init_devinfo(struct qed_hwfn *p_hwfn);
0172 
0173 void qed_iwarp_init_hw(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt);
0174 
0175 int qed_iwarp_create_qp(struct qed_hwfn *p_hwfn,
0176             struct qed_rdma_qp *qp,
0177             struct qed_rdma_create_qp_out_params *out_params);
0178 
0179 int qed_iwarp_modify_qp(struct qed_hwfn *p_hwfn, struct qed_rdma_qp *qp,
0180             enum qed_iwarp_qp_state new_state, bool internal);
0181 
0182 int qed_iwarp_destroy_qp(struct qed_hwfn *p_hwfn, struct qed_rdma_qp *qp);
0183 
0184 int qed_iwarp_fw_destroy(struct qed_hwfn *p_hwfn, struct qed_rdma_qp *qp);
0185 
0186 void qed_iwarp_query_qp(struct qed_rdma_qp *qp,
0187             struct qed_rdma_query_qp_out_params *out_params);
0188 
0189 int
0190 qed_iwarp_connect(void *rdma_cxt,
0191           struct qed_iwarp_connect_in *iparams,
0192           struct qed_iwarp_connect_out *oparams);
0193 
0194 int
0195 qed_iwarp_create_listen(void *rdma_cxt,
0196             struct qed_iwarp_listen_in *iparams,
0197             struct qed_iwarp_listen_out *oparams);
0198 
0199 int qed_iwarp_accept(void *rdma_cxt, struct qed_iwarp_accept_in *iparams);
0200 
0201 int qed_iwarp_reject(void *rdma_cxt, struct qed_iwarp_reject_in *iparams);
0202 int qed_iwarp_destroy_listen(void *rdma_cxt, void *handle);
0203 
0204 int qed_iwarp_send_rtr(void *rdma_cxt, struct qed_iwarp_send_rtr_in *iparams);
0205 
0206 #endif