1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2 /* Copyright (c) 2015 - 2020 Intel Corporation */
6 #define IRDMA_IEQ_MPA_FRAMING 6
7 #define IRDMA_TCP_OFFSET 40
8 #define IRDMA_IPV4_PAD 20
9 #define IRDMA_MRK_BLK_SZ 512
12 IRDMA_PUDA_RSRC_TYPE_ILQ
= 1,
13 IRDMA_PUDA_RSRC_TYPE_IEQ
,
14 IRDMA_PUDA_RSRC_TYPE_MAX
, /* Must be last entry */
17 enum puda_rsrc_complete
{
22 PUDA_HASH_CRC_COMPLETE
,
29 struct irdma_puda_cmpl_info
{
30 struct irdma_qp_uk
*qp
;
36 u32 compl_error
; /* No_err=0, else major and minor err code */
45 struct irdma_puda_send_info
{
46 u64 paddr
; /* Physical address */
56 struct irdma_puda_buf
{
57 struct list_head list
; /* MUST be first entry */
58 struct irdma_dma_mem mem
; /* DMA memory for the buffer */
59 struct irdma_puda_buf
*next
; /* for alloclist in rsrc struct */
60 struct irdma_virt_mem buf_mem
; /* Buffer memory for this buffer */
67 u8 tcphlen
; /* tcp length in bytes */
68 u8 maclen
; /* mac length in bytes */
69 u32 totallen
; /* machlen+iphlen+tcphlen+datalen */
74 bool do_lpb
:1; /* Loopback buffer */
79 struct irdma_sc_vsi
*vsi
;
82 struct irdma_puda_rsrc_info
{
83 void (*receive
)(struct irdma_sc_vsi
*vsi
, struct irdma_puda_buf
*buf
);
84 void (*xmit_complete
)(struct irdma_sc_vsi
*vsi
, void *sqwrid
);
85 enum puda_rsrc_type type
; /* ILQ or IEQ */
92 u32 tx_buf_cnt
; /* total bufs allocated will be rq_size + tx_buf_cnt */
95 bool stats_idx_valid
:1;
99 struct irdma_puda_rsrc
{
100 struct irdma_sc_cq cq
;
101 struct irdma_sc_qp qp
;
102 struct irdma_sc_pd sc_pd
;
103 struct irdma_sc_dev
*dev
;
104 struct irdma_sc_vsi
*vsi
;
105 struct irdma_dma_mem cqmem
;
106 struct irdma_dma_mem qpmem
;
107 struct irdma_virt_mem ilq_mem
;
108 enum puda_rsrc_complete cmpl
;
109 enum puda_rsrc_type type
;
110 u16 buf_size
; /*buf must be max datalen + tcpip hdr + mac */
116 struct irdma_sq_uk_wr_trk_info
*sq_wrtrk_array
;
121 u32 tx_wqe_avail_cnt
;
122 struct shash_desc
*hash_desc
;
123 struct list_head txpend
;
124 struct list_head bufpool
; /* free buffers pool list for recv and xmit */
126 u32 avail_buf_count
; /* snapshot of currently available buffers */
127 spinlock_t bufpool_lock
;
128 struct irdma_puda_buf
*alloclist
;
129 void (*receive
)(struct irdma_sc_vsi
*vsi
, struct irdma_puda_buf
*buf
);
130 void (*xmit_complete
)(struct irdma_sc_vsi
*vsi
, void *sqwrid
);
132 u64 stats_buf_alloc_fail
;
135 u64 stats_rcvd_pkt_err
;
136 u64 stats_sent_pkt_q
;
143 u64 partials_handled
;
146 bool stats_idx_valid
:1;
149 struct irdma_puda_buf
*irdma_puda_get_bufpool(struct irdma_puda_rsrc
*rsrc
);
150 void irdma_puda_ret_bufpool(struct irdma_puda_rsrc
*rsrc
,
151 struct irdma_puda_buf
*buf
);
152 void irdma_puda_send_buf(struct irdma_puda_rsrc
*rsrc
,
153 struct irdma_puda_buf
*buf
);
154 int irdma_puda_send(struct irdma_sc_qp
*qp
, struct irdma_puda_send_info
*info
);
155 int irdma_puda_create_rsrc(struct irdma_sc_vsi
*vsi
,
156 struct irdma_puda_rsrc_info
*info
);
157 void irdma_puda_dele_rsrc(struct irdma_sc_vsi
*vsi
, enum puda_rsrc_type type
,
159 int irdma_puda_poll_cmpl(struct irdma_sc_dev
*dev
, struct irdma_sc_cq
*cq
,
162 struct irdma_sc_qp
*irdma_ieq_get_qp(struct irdma_sc_dev
*dev
,
163 struct irdma_puda_buf
*buf
);
164 int irdma_puda_get_tcpip_info(struct irdma_puda_cmpl_info
*info
,
165 struct irdma_puda_buf
*buf
);
166 int irdma_ieq_check_mpacrc(struct shash_desc
*desc
, void *addr
, u32 len
, u32 val
);
167 int irdma_init_hash_desc(struct shash_desc
**desc
);
168 void irdma_ieq_mpa_crc_ae(struct irdma_sc_dev
*dev
, struct irdma_sc_qp
*qp
);
169 void irdma_free_hash_desc(struct shash_desc
*desc
);
170 void irdma_ieq_update_tcpip_info(struct irdma_puda_buf
*buf
, u16 len
, u32 seqnum
);
171 int irdma_cqp_qp_create_cmd(struct irdma_sc_dev
*dev
, struct irdma_sc_qp
*qp
);
172 int irdma_cqp_cq_create_cmd(struct irdma_sc_dev
*dev
, struct irdma_sc_cq
*cq
);
173 int irdma_cqp_qp_destroy_cmd(struct irdma_sc_dev
*dev
, struct irdma_sc_qp
*qp
);
174 void irdma_cqp_cq_destroy_cmd(struct irdma_sc_dev
*dev
, struct irdma_sc_cq
*cq
);
175 void irdma_puda_ieq_get_ah_info(struct irdma_sc_qp
*qp
,
176 struct irdma_ah_info
*ah_info
);
177 int irdma_puda_create_ah(struct irdma_sc_dev
*dev
,
178 struct irdma_ah_info
*ah_info
, bool wait
,
179 enum puda_rsrc_type type
, void *cb_param
,
180 struct irdma_sc_ah
**ah
);
181 void irdma_puda_free_ah(struct irdma_sc_dev
*dev
, struct irdma_sc_ah
*ah
);
182 void irdma_ieq_process_fpdus(struct irdma_sc_qp
*qp
,
183 struct irdma_puda_rsrc
*ieq
);
184 void irdma_ieq_cleanup_qp(struct irdma_puda_rsrc
*ieq
, struct irdma_sc_qp
*qp
);
185 #endif /*IRDMA_PROTOS_H */