Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(C) 2024 Marvell.
3 : : */
4 : : #ifndef __CN20K_RX_H__
5 : : #define __CN20K_RX_H__
6 : :
7 : : #include "cn20k_rxtx.h"
8 : : #include <rte_ethdev.h>
9 : : #include <rte_security_driver.h>
10 : : #include <rte_vect.h>
11 : :
12 : : #define NSEC_PER_SEC 1000000000L
13 : :
14 : : #define NIX_RX_OFFLOAD_NONE (0)
15 : : #define NIX_RX_OFFLOAD_RSS_F BIT(0)
16 : : #define NIX_RX_OFFLOAD_PTYPE_F BIT(1)
17 : : #define NIX_RX_OFFLOAD_CHECKSUM_F BIT(2)
18 : : #define NIX_RX_OFFLOAD_MARK_UPDATE_F BIT(3)
19 : : #define NIX_RX_OFFLOAD_TSTAMP_F BIT(4)
20 : : #define NIX_RX_OFFLOAD_VLAN_STRIP_F BIT(5)
21 : : #define NIX_RX_OFFLOAD_SECURITY_F BIT(6)
22 : : #define NIX_RX_OFFLOAD_MAX (NIX_RX_OFFLOAD_SECURITY_F << 1)
23 : :
24 : : /* Flags to control cqe_to_mbuf conversion function.
25 : : * Defining it from backwards to denote its been
26 : : * not used as offload flags to pick function
27 : : */
28 : : #define NIX_RX_REAS_F BIT(12)
29 : : #define NIX_RX_VWQE_F BIT(13)
30 : : #define NIX_RX_MULTI_SEG_F BIT(14)
31 : :
32 : : #define CNXK_NIX_CQ_ENTRY_SZ 128
33 : : #define NIX_DESCS_PER_LOOP 4
34 : : #define CQE_CAST(x) ((struct nix_cqe_hdr_s *)(x))
35 : : #define CQE_SZ(x) ((x) * CNXK_NIX_CQ_ENTRY_SZ)
36 : :
37 : : #define CQE_PTR_OFF(b, i, o, f) \
38 : : (((f) & NIX_RX_VWQE_F) ? (uint64_t *)(((uintptr_t)((uint64_t *)(b))[i]) + (o)) : \
39 : : (uint64_t *)(((uintptr_t)(b)) + CQE_SZ(i) + (o)))
40 : : #define CQE_PTR_DIFF(b, i, o, f) \
41 : : (((f) & NIX_RX_VWQE_F) ? (uint64_t *)(((uintptr_t)((uint64_t *)(b))[i]) - (o)) : \
42 : : (uint64_t *)(((uintptr_t)(b)) + CQE_SZ(i) - (o)))
43 : :
44 : : #define NIX_RX_SEC_UCC_CONST \
45 : : ((RTE_MBUF_F_RX_IP_CKSUM_BAD >> 1) | \
46 : : ((RTE_MBUF_F_RX_IP_CKSUM_GOOD | RTE_MBUF_F_RX_L4_CKSUM_GOOD) >> 1) << 8 | \
47 : : ((RTE_MBUF_F_RX_IP_CKSUM_GOOD | RTE_MBUF_F_RX_L4_CKSUM_BAD) >> 1) << 16 | \
48 : : ((RTE_MBUF_F_RX_IP_CKSUM_GOOD | RTE_MBUF_F_RX_L4_CKSUM_GOOD) >> 1) << 32 | \
49 : : ((RTE_MBUF_F_RX_IP_CKSUM_GOOD | RTE_MBUF_F_RX_L4_CKSUM_GOOD) >> 1) << 48)
50 : :
51 : : #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
52 : : static inline void
53 : : nix_mbuf_validate_next(struct rte_mbuf *m)
54 : : {
55 : : if (m->nb_segs == 1 && m->next)
56 : : rte_panic("mbuf->next[%p] valid when mbuf->nb_segs is %d", m->next, m->nb_segs);
57 : : }
58 : : #else
59 : : static inline void
60 : : nix_mbuf_validate_next(struct rte_mbuf *m)
61 : : {
62 : : RTE_SET_USED(m);
63 : : }
64 : : #endif
65 : :
66 : : #define NIX_RX_SEC_REASSEMBLY_F (NIX_RX_REAS_F | NIX_RX_OFFLOAD_SECURITY_F)
67 : :
68 : : static inline rte_eth_ip_reassembly_dynfield_t *
69 : : cnxk_ip_reassembly_dynfield(struct rte_mbuf *mbuf, int ip_reassembly_dynfield_offset)
70 : : {
71 : : return RTE_MBUF_DYNFIELD(mbuf, ip_reassembly_dynfield_offset,
72 : : rte_eth_ip_reassembly_dynfield_t *);
73 : : }
74 : :
75 : : union mbuf_initializer {
76 : : struct {
77 : : uint16_t data_off;
78 : : uint16_t refcnt;
79 : : uint16_t nb_segs;
80 : : uint16_t port;
81 : : } fields;
82 : : uint64_t value;
83 : : };
84 : :
85 : : static __rte_always_inline void
86 : : nix_sec_flush_meta_burst(uint16_t lmt_id, uint64_t data, uint16_t lnum, uintptr_t aura_handle)
87 : : {
88 : : uint64_t pa;
89 : :
90 : : /* Prepare PA and Data */
91 : : pa = roc_npa_aura_handle_to_base(aura_handle) + NPA_LF_AURA_BATCH_FREE0;
92 : : pa |= ((data & 0x7) << 4);
93 : :
94 : : data >>= 3;
95 : : data <<= 19;
96 : : data |= (uint64_t)lmt_id;
97 : : data |= (uint64_t)(lnum - 1) << 12;
98 : :
99 : : roc_lmt_submit_steorl(data, pa);
100 : : }
101 : :
102 : : static __rte_always_inline void
103 : : nix_sec_flush_meta(uintptr_t laddr, uint16_t lmt_id, uint8_t loff, uintptr_t aura_handle)
104 : : {
105 : : uint64_t pa;
106 : :
107 : : /* laddr is pointing to first pointer */
108 : 0 : laddr -= 8;
109 : :
110 : : /* Trigger free either on lmtline full or different aura handle */
111 : : pa = roc_npa_aura_handle_to_base(aura_handle) + NPA_LF_AURA_BATCH_FREE0;
112 : :
113 : : /* Update aura handle */
114 : 0 : *(uint64_t *)laddr =
115 : 0 : (((uint64_t)(loff & 0x3) << 32) | roc_npa_aura_handle_to_aura(aura_handle));
116 : :
117 : : pa |= ((uint64_t)(loff >> 1) << 4);
118 : : roc_lmt_submit_steorl(lmt_id, pa);
119 : 0 : }
120 : :
121 : : static __rte_always_inline uint64_t
122 : : nix_clear_data_off(uint64_t oldval)
123 : : {
124 : : union mbuf_initializer mbuf_init = {.value = oldval};
125 : :
126 : : mbuf_init.fields.data_off = 0;
127 : : return mbuf_init.value;
128 : : }
129 : :
130 : : static __rte_always_inline struct rte_mbuf *
131 : : nix_get_mbuf_from_cqe(void *cq, const uint64_t data_off)
132 : : {
133 : : rte_iova_t buff;
134 : :
135 : : /* Skip CQE, NIX_RX_PARSE_S and SG HDR(9 DWORDs) and peek buff addr */
136 : 0 : buff = *((rte_iova_t *)((uint64_t *)cq + 9));
137 : 0 : return (struct rte_mbuf *)(buff - data_off);
138 : : }
139 : :
140 : : static __rte_always_inline void
141 : : nix_sec_reass_first_frag_update(struct rte_mbuf *head, const rte_iova_t *iova_list, uintptr_t cpth,
142 : : uint64_t cq_w1, uint64_t cq_w5, uint16_t rlen)
143 : : {
144 : : uint8_t *m_ipptr, *ipptr;
145 : : uint16_t tot_len;
146 : : uint32_t cksum;
147 : : uint8_t lc_ptr;
148 : : uint8_t lc_off;
149 : :
150 : : lc_ptr = (cq_w5 >> 16) & 0xFF;
151 : : lc_off = lc_ptr - (cq_w5 & 0xFF);
152 : : ipptr = (uint8_t *)*iova_list + lc_off;
153 : : m_ipptr = (uint8_t *)cpth + lc_ptr;
154 : :
155 : : /* Find the L3 header length and update inner pkt based on meta lc type */
156 : : if (((cq_w1 >> 40) & 0xF) == NPC_LT_LC_IP) {
157 : : const struct rte_ipv4_hdr *m_hdr = (const struct rte_ipv4_hdr *)m_ipptr;
158 : : struct rte_ipv4_hdr *ip_hdr = (struct rte_ipv4_hdr *)ipptr;
159 : :
160 : : ip_hdr->fragment_offset = 0;
161 : : tot_len = rte_cpu_to_be_16(rlen);
162 : : ip_hdr->total_length = tot_len;
163 : : /* Perform incremental checksum based on meta pkt ip hdr */
164 : : cksum = m_hdr->hdr_checksum;
165 : : cksum += m_hdr->fragment_offset;
166 : : cksum += 0xFFFF;
167 : : cksum += m_hdr->total_length;
168 : : cksum += (uint16_t)(~tot_len);
169 : : cksum = (cksum & 0xFFFF) + ((cksum & 0xFFFF0000) >> 16);
170 : : ip_hdr->hdr_checksum = cksum;
171 : : return;
172 : : }
173 : :
174 : : /* Assuming IPv6 packet update */
175 : : struct rte_ipv6_hdr *ipv6_hdr = (struct rte_ipv6_hdr *)ipptr;
176 : : size_t ext_len = sizeof(struct rte_ipv6_hdr);
177 : : uint8_t *nxt_hdr = (uint8_t *)ipv6_hdr;
178 : : uint8_t *nxt_proto = &ipv6_hdr->proto;
179 : : int nh = ipv6_hdr->proto;
180 : :
181 : : tot_len = 0;
182 : : while (nh != -EINVAL) {
183 : : nxt_hdr += ext_len;
184 : : tot_len += ext_len;
185 : : if (nh == IPPROTO_FRAGMENT) {
186 : : *nxt_proto = *nxt_hdr;
187 : : break;
188 : : }
189 : : nh = rte_ipv6_get_next_ext(nxt_hdr, nh, &ext_len);
190 : : nxt_proto = nxt_hdr;
191 : : }
192 : :
193 : : /* Remove the frag header by moving header 8 bytes forward */
194 : : ipv6_hdr->payload_len = rte_cpu_to_be_16(rlen - sizeof(struct rte_ipv6_hdr));
195 : :
196 : : /* tot_len is sum of all IP header's length before fragment header */
197 : : rte_memcpy(rte_pktmbuf_mtod_offset(head, void *, 8), rte_pktmbuf_mtod(head, void *),
198 : : lc_off + tot_len);
199 : :
200 : : head->data_off += 8;
201 : : }
202 : :
203 : : static __rte_always_inline struct rte_mbuf *
204 : : nix_sec_oop_process(uintptr_t cpth, uint64_t buf_sz)
205 : : {
206 : 0 : const struct cpt_parse_hdr_s *hdr = (const struct cpt_parse_hdr_s *)cpth;
207 : 0 : uint32_t offset = hdr->w2.ptr_offset;
208 : : struct rte_mbuf *inner, *mbuf;
209 : : union nix_rx_parse_u *rx;
210 : : rte_iova_t *iova_list;
211 : : uint64_t addr;
212 : :
213 [ # # # # : 0 : iova_list = (rte_iova_t *)(cpth + (offset ? (offset << 5) : 256)) + 1;
# # # # #
# # # # #
# # ]
214 : 0 : addr = *iova_list;
215 : 0 : offset = addr % (buf_sz & 0xFFFFFFFF);
216 : 0 : mbuf = (struct rte_mbuf *)(addr - offset + (buf_sz >> 32));
217 : :
218 : 0 : rx = (union nix_rx_parse_u *)(((uintptr_t)(mbuf + 1)) + 8);
219 : 0 : mbuf->pkt_len = rx->pkt_lenm1 + 1;
220 : 0 : mbuf->data_len = rx->pkt_lenm1 + 1;
221 : 0 : mbuf->data_off = addr - (uint64_t)mbuf->buf_addr;
222 : :
223 : : /* Pointers will be alternate encrypted-decrypted in gather list */
224 : : iova_list++;
225 : 0 : addr = *iova_list;
226 : 0 : inner = (struct rte_mbuf *)(addr - offset + (buf_sz >> 32));
227 : :
228 : : /* Mark original mbuf as get */
229 : : RTE_MEMPOOL_CHECK_COOKIES(inner->pool, (void **)&mbuf, 1, 1);
230 : :
231 : 0 : *rte_security_oop_dynfield(inner) = mbuf;
232 : : return inner;
233 : : }
234 : :
235 : : static __rte_always_inline uint64_t
236 : : nix_sec_meta_to_mbuf_sc(uint64_t cq_w5, uint64_t cpth, const uint64_t sa_base,
237 : : struct rte_mbuf *mbuf, uint16_t *len, uint64_t *mbuf_init,
238 : : const uint16_t flags)
239 : : {
240 : 0 : const struct cpt_parse_hdr_s *hdr = (const struct cpt_parse_hdr_s *)cpth;
241 : : struct cn20k_inb_priv_data *inb_priv;
242 : 0 : uint64_t ol_flags, w3 = hdr->w3.u64;
243 : : uint32_t sa_idx;
244 : : uint16_t ucc;
245 : : void *inb_sa;
246 : :
247 : : /* Get SPI from CPT_PARSE_S's cookie(already swapped) */
248 : 0 : sa_idx = hdr->w0.cookie;
249 : 0 : inb_sa = roc_nix_inl_ow_ipsec_inb_sa(sa_base, sa_idx);
250 : : inb_priv = roc_nix_inl_ow_ipsec_inb_sa_sw_rsvd(inb_sa);
251 : :
252 : : /* Cryptodev injected packet can be identified from SA IDX 0xFFFFFFFF, and
253 : : * Ethdev injected packet can be identified with match ID 0xFFFF.
254 : : */
255 [ # # # # : 0 : if (flags & NIX_RX_REAS_F && !hdr->w2.pkt_inline) {
# # # # #
# # # # #
# # # # #
# # # #
# ]
256 : 0 : *mbuf_init = (*mbuf_init & ~(BIT_ULL(16) - 1)) | mbuf->data_off;
257 [ # # # # : 0 : if (hdr->w0.match_id == 0xFFFFU)
# # # # #
# # # # #
# # ]
258 : 0 : *rte_security_dynfield(mbuf) = (uint64_t)inb_priv->userdata;
259 : : } else {
260 : : /* Update dynamic field with userdata */
261 : 0 : *rte_security_dynfield(mbuf) = (uint64_t)inb_priv->userdata;
262 : : }
263 : :
264 : 0 : *len = ((w3 >> 48) & 0xFFFF) + ((cq_w5 >> 16) & 0xFF) - (cq_w5 & 0xFF);
265 : :
266 : : /* Get ucc from cpt parse header */
267 : 0 : ucc = w3 & 0xFF;
268 : 0 : ol_flags = ((CPT_COMP_HWGOOD_MASK & (1U << ucc)) ?
269 [ # # # # : 0 : RTE_MBUF_F_RX_SEC_OFFLOAD :
# # # # #
# # # # #
# # ]
270 : : RTE_MBUF_F_RX_SEC_OFFLOAD | RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED);
271 : :
272 : 0 : ucc = (w3 >> 8) & 0xFF;
273 [ # # # # : 0 : if (ucc && ucc < ROC_IE_OW_UCC_SUCCESS_PKT_IP_BADCSUM) {
# # # # #
# # # # #
# # ]
274 : : ol_flags |= RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED;
275 : : } else {
276 : 0 : ucc += 3; /* To make codes in 0xFx series except 0 */
277 : 0 : ol_flags |= ((ucc & 0xF0) == 0xF0) ?
278 [ # # # # : 0 : ((NIX_RX_SEC_UCC_CONST >> ((ucc & 0xF) << 3)) & 0xFF) << 1 :
# # # # #
# # # # #
# # ]
279 : : RTE_MBUF_F_RX_IP_CKSUM_GOOD;
280 : : }
281 : :
282 : : return ol_flags;
283 : : }
284 : :
285 : : static __rte_always_inline uint32_t
286 : : nix_ptype_get(const void *const lookup_mem, const uint64_t in)
287 : : {
288 : : const uint16_t *const ptype = lookup_mem;
289 : 0 : const uint16_t lh_lg_lf = (in & 0xFFF0000000000000) >> 52;
290 : 0 : const uint16_t tu_l2 = ptype[(in & 0x000FFFF000000000) >> 36];
291 : 0 : const uint16_t il4_tu = ptype[PTYPE_NON_TUNNEL_ARRAY_SZ + lh_lg_lf];
292 : :
293 : 0 : return (il4_tu << PTYPE_NON_TUNNEL_WIDTH) | tu_l2;
294 : : }
295 : :
296 : : static __rte_always_inline uint32_t
297 : : nix_rx_olflags_get(const void *const lookup_mem, const uint64_t in)
298 : : {
299 : : const uint32_t *const ol_flags =
300 : : (const uint32_t *)((const uint8_t *)lookup_mem + PTYPE_ARRAY_SZ);
301 : :
302 : 0 : return ol_flags[(in & 0xfff00000) >> 20];
303 : : }
304 : :
305 : : static inline uint64_t
306 : 0 : nix_update_match_id(const uint16_t match_id, uint64_t ol_flags, struct rte_mbuf *mbuf)
307 : : {
308 : : /* There is no separate bit to check match_id
309 : : * is valid or not? and no flag to identify it is an
310 : : * RTE_FLOW_ACTION_TYPE_FLAG vs RTE_FLOW_ACTION_TYPE_MARK
311 : : * action. The former case addressed through 0 being invalid
312 : : * value and inc/dec match_id pair when MARK is activated.
313 : : * The later case addressed through defining
314 : : * CNXK_FLOW_MARK_DEFAULT as value for
315 : : * RTE_FLOW_ACTION_TYPE_MARK.
316 : : * This would translate to not use
317 : : * CNXK_FLOW_ACTION_FLAG_DEFAULT - 1 and
318 : : * CNXK_FLOW_ACTION_FLAG_DEFAULT for match_id.
319 : : * i.e valid mark_id's are from
320 : : * 0 to CNXK_FLOW_ACTION_FLAG_DEFAULT - 2
321 : : */
322 [ # # ]: 0 : if (likely(match_id)) {
323 : 0 : ol_flags |= RTE_MBUF_F_RX_FDIR;
324 [ # # # # : 0 : if (match_id != CNXK_FLOW_ACTION_FLAG_DEFAULT) {
# # # # #
# # # # #
# # ]
325 : 0 : ol_flags |= RTE_MBUF_F_RX_FDIR_ID;
326 : 0 : mbuf->hash.fdir.hi = match_id - 1;
327 : : }
328 : : }
329 : :
330 : 0 : return ol_flags;
331 : : }
332 : :
333 : : #if defined(RTE_ARCH_ARM64)
334 : : static __rte_always_inline void
335 : : nix_cqe_xtract_mseg(const union nix_rx_parse_u *rx, struct rte_mbuf *mbuf, uint64_t rearm,
336 : : uintptr_t cpth, uintptr_t sa_base, const uint64_t buf_sz, const uint16_t flags)
337 : : {
338 : : const struct cpt_parse_hdr_s *hdr = (const struct cpt_parse_hdr_s *)cpth;
339 : : struct cn20k_inb_priv_data *inb_priv = NULL;
340 : : const struct cpt_frag_info_s *finfo = NULL;
341 : : uint64_t fsz_w1 = 0, cq_w1, cq_w5 = 0, sg;
342 : : uint32_t offset = hdr->w2.ptr_offset;
343 : : uint8_t num_frags = 0, nxt_frag = 0;
344 : : struct rte_mbuf *head, *last_mbuf;
345 : : uint16_t rlen = hdr->w3.rlen;
346 : : const rte_iova_t *iova_list;
347 : : uint8_t sg_cnt = 1, nb_segs;
348 : : uint16_t sg_len, data_len;
349 : : uint16x4_t fsz, sg_swap;
350 : : uint16_t later_skip = 0;
351 : : bool reas_fail = false;
352 : : bool first_frag = true;
353 : : const rte_iova_t *eol;
354 : : uint16_t data_off = 0;
355 : : bool is_oop = false;
356 : : uint16_t l4_off = 0;
357 : : uint8_t ts_rx_off;
358 : : int dyn_off = 0;
359 : : int64_t len;
360 : : uintptr_t p;
361 : :
362 : : cq_w1 = *(const uint64_t *)rx;
363 : : ts_rx_off = (flags & NIX_RX_OFFLOAD_TSTAMP_F) ? CNXK_NIX_TIMESYNC_RX_OFFSET : 0;
364 : :
365 : : if ((flags & NIX_RX_SEC_REASSEMBLY_F) && (cq_w1 & BIT(11))) {
366 : : uint64_t sg_base;
367 : :
368 : : /* Check if there are no SG's */
369 : : if (!hdr->w4.gthr_size)
370 : : return;
371 : :
372 : : cq_w5 = *((const uint64_t *)rx + 4);
373 : : len = rlen + ((cq_w5 >> 16) & 0xFF) - (cq_w5 & 0xFF);
374 : : num_frags = hdr->w0.num_frags;
375 : : sg_base = cpth + (offset ? (offset << 5) : 256);
376 : : finfo = (const struct cpt_frag_info_s *)sg_base;
377 : : sg_base += num_frags ? (num_frags > 4 ? 32 : 16) : 0;
378 : : sg = *(uint64_t *)sg_base;
379 : :
380 : : is_oop = (hdr->w4.l4_chksum_type == 0) && (hdr->w4.l4_chksum == 1);
381 : : nb_segs = (sg >> 14) & 0x3;
382 : : if (is_oop && nb_segs <= 2)
383 : : return;
384 : :
385 : : iova_list = (rte_iova_t *)(sg_base);
386 : : eol = iova_list + (hdr->w4.gthr_size << 2);
387 : : iova_list += 2;
388 : :
389 : : if ((flags & NIX_RX_REAS_F) && num_frags) {
390 : : void *inb_sa;
391 : :
392 : : inb_sa = roc_nix_inl_ow_ipsec_inb_sa(sa_base, hdr->w0.cookie);
393 : : inb_priv = roc_nix_inl_ow_ipsec_inb_sa_sw_rsvd(inb_sa);
394 : : dyn_off = inb_priv->reass_dynfield_off;
395 : : num_frags -= 1;
396 : :
397 : : if (hdr->w0.reas_sts ||
398 : : (hdr->w0.err_sum && !roc_ie_ow_ucc_is_success(hdr->w3.uc_ccode))) {
399 : : reas_fail = true;
400 : : nxt_frag = (sg >> 11) & 0x3;
401 : : nxt_frag = ((nxt_frag << 1) | (nxt_frag >> 1)) & 0x3;
402 : :
403 : : /* Reverse the order of fragment sizes */
404 : : fsz = vreinterpret_u16_u64(vdup_n_u64(finfo->w1.u64));
405 : : fsz = vrev64_u16(fsz);
406 : : fsz_w1 = vget_lane_u64(vreinterpret_u64_u16(fsz), 0);
407 : : finfo++;
408 : : l4_off = ((cq_w5 >> 24) & 0xFF) - (cq_w5 & 0xFF);
409 : : mbuf->pkt_len = l4_off + (fsz_w1 & 0xFFFF) - ts_rx_off;
410 : : fsz_w1 >>= 16;
411 : : }
412 : : }
413 : :
414 : : /* sg byte swap */
415 : : sg_swap = vreinterpret_u16_u64(vdup_n_u64(sg));
416 : : sg_swap = vrev64_u16(sg_swap);
417 : : sg = vget_lane_u64(vreinterpret_u64_u16(sg_swap), 0);
418 : :
419 : : /* For Non inplace, first SG pointer will be original encrypted,
420 : : * whereas input mbuf is decrypted one. So need to update mbuf pointer
421 : : * in order to process SG list accordingly.
422 : : */
423 : : mbuf = is_oop ? *rte_security_oop_dynfield(mbuf) : mbuf;
424 : : } else {
425 : : sg = *(const uint64_t *)(rx + 1);
426 : : nb_segs = (sg >> 48) & 0x3;
427 : :
428 : : if (nb_segs == 1)
429 : : return;
430 : :
431 : : len = rx->pkt_lenm1 + 1;
432 : : mbuf->pkt_len = len;
433 : :
434 : : /* Skip SG_S and first IOVA */
435 : : eol = ((const rte_iova_t *)(rx + 1) + ((rx->desc_sizem1 + 1) << 1));
436 : : iova_list = ((const rte_iova_t *)(rx + 1)) + 2;
437 : : }
438 : :
439 : : sg_len = sg & 0xFFFF;
440 : : data_len = sg_len;
441 : : sg = sg >> 16;
442 : :
443 : : /* Update data len as per the segment size */
444 : : mbuf->data_len = sg_len;
445 : : mbuf->nb_segs = nb_segs;
446 : : head = mbuf;
447 : :
448 : : /* Update IP header */
449 : : if ((flags & NIX_RX_REAS_F) && num_frags && !reas_fail && !is_oop)
450 : : nix_sec_reass_first_frag_update(mbuf, iova_list - 1, cpth, cq_w1, cq_w5, rlen);
451 : :
452 : : len -= is_oop ? 0 : sg_len;
453 : : nb_segs--;
454 : :
455 : : later_skip = (uintptr_t)mbuf->buf_addr - (uintptr_t)mbuf;
456 : :
457 : : while (nb_segs) {
458 : : last_mbuf = mbuf;
459 : : if ((flags & NIX_RX_REAS_F) && (num_frags || is_oop)) {
460 : : offset = (*iova_list) % (buf_sz & 0xFFFFFFFF);
461 : : mbuf->next = (struct rte_mbuf *)((*iova_list) - offset + (buf_sz >> 32));
462 : : } else {
463 : : mbuf->next = (struct rte_mbuf *)((*iova_list) - later_skip);
464 : : }
465 : : mbuf = mbuf->next;
466 : :
467 : : RTE_MEMPOOL_CHECK_COOKIES(mbuf->pool, (void **)&mbuf, 1, 1);
468 : :
469 : : sg_len = sg & 0xFFFF;
470 : : sg = sg >> 16;
471 : :
472 : : /* Process reassembly failure case */
473 : : if ((flags & NIX_RX_REAS_F) && unlikely(reas_fail && (nxt_frag & 1))) {
474 : : head->ol_flags |=
475 : : BIT_ULL(inb_priv->reass_dynflag_bit) | RTE_MBUF_F_RX_SEC_OFFLOAD;
476 : :
477 : : cnxk_ip_reassembly_dynfield(head, dyn_off)->next_frag = mbuf;
478 : : cnxk_ip_reassembly_dynfield(head, dyn_off)->nb_frags = num_frags;
479 : :
480 : : /* Update dynamic field with userdata from prev head */
481 : : *rte_security_dynfield(mbuf) = *rte_security_dynfield(head);
482 : :
483 : : /* Reset last mbuf next and start new mbuf chain */
484 : : last_mbuf->next = NULL;
485 : : head->nb_segs = sg_cnt;
486 : : head->data_len =
487 : : (!first_frag && (sg_cnt == 1)) ? data_len + l4_off : data_len;
488 : : head = mbuf;
489 : : len = fsz_w1 & 0xFFFF;
490 : : head->pkt_len = l4_off + len - ts_rx_off;
491 : : data_len = sg_len;
492 : : data_off = rearm & 0xFFFF;
493 : : sg_cnt = 0;
494 : : first_frag = false;
495 : : nxt_frag = nxt_frag >> 1;
496 : : fsz_w1 = fsz_w1 >> 16;
497 : : if (--num_frags == 4) {
498 : : /* Reverse the order of fragment sizes */
499 : : fsz = vreinterpret_u16_u64(vdup_n_u64(finfo->w1.u64));
500 : : fsz = vrev64_u16(fsz);
501 : : fsz_w1 = vget_lane_u64(vreinterpret_u64_u16(fsz), 0);
502 : : }
503 : : }
504 : :
505 : : if ((flags & NIX_RX_REAS_F) && ((num_frags && !reas_fail) || is_oop))
506 : : data_off = *iova_list - (uint64_t)mbuf->buf_addr;
507 : :
508 : : if (((flags & NIX_RX_OFFLOAD_SECURITY_F) && !(flags & NIX_RX_REAS_F)) ||
509 : : (is_oop && (sg_cnt % 2))) {
510 : : /* Adjust last mbuf data length with negative offset for
511 : : * security pkts if needed.
512 : : * For OOP, will correct mbuf length of decrypted pkt.
513 : : */
514 : : len -= sg_len;
515 : : sg_len = (len > 0) ? sg_len : (sg_len + len);
516 : : len = (len > 0) ? len : 0;
517 : : }
518 : :
519 : : mbuf->data_len = sg_len;
520 : : p = (uintptr_t)&mbuf->rearm_data;
521 : : *(uint64_t *)p = (rearm & ~0xFFFF) | data_off;
522 : :
523 : : sg_cnt++;
524 : : nb_segs--;
525 : : iova_list++;
526 : : data_off = 0;
527 : :
528 : : if (!nb_segs && (iova_list + 1 < eol)) {
529 : : sg = *(const uint64_t *)(iova_list);
530 : :
531 : : if ((flags & NIX_RX_SEC_REASSEMBLY_F) && (cq_w1 & BIT(11))) {
532 : : nb_segs = (sg >> 14) & 0x3;
533 : :
534 : : if (unlikely(reas_fail)) {
535 : : nxt_frag = (sg >> 11) & 7;
536 : : nxt_frag = ((nxt_frag << 2) | (nxt_frag & 2) |
537 : : (nxt_frag >> 2)) & 0x7;
538 : : }
539 : :
540 : : sg_swap = vreinterpret_u16_u64(vdup_n_u64(sg));
541 : : sg_swap = vrev64_u16(sg_swap);
542 : : sg = vget_lane_u64(vreinterpret_u64_u16(sg_swap), 0);
543 : : } else {
544 : : nb_segs = (sg >> 48) & 0x3;
545 : : }
546 : :
547 : : iova_list++;
548 : : head->nb_segs += nb_segs;
549 : : }
550 : : }
551 : :
552 : : if (unlikely(is_oop)) {
553 : : struct rte_mbuf *o_mbuf;
554 : :
555 : : /* mbuf chain will have all pointers of encrypted + decrypted
556 : : * alternatively. So will need to sort it.
557 : : */
558 : : mbuf = head;
559 : : o_mbuf = head->next;
560 : : nb_segs = head->nb_segs;
561 : : mbuf->nb_segs = nb_segs / 2;
562 : : o_mbuf->nb_segs = nb_segs / 2;
563 : : nb_segs -= 2;
564 : : while (unlikely(nb_segs && (nb_segs % 2 == 0))) {
565 : : mbuf->next = o_mbuf->next;
566 : : o_mbuf->next = o_mbuf->next->next;
567 : : mbuf = mbuf->next;
568 : : o_mbuf = o_mbuf->next;
569 : : nb_segs -= 2;
570 : : }
571 : : mbuf->next = NULL;
572 : : o_mbuf->next = NULL;
573 : : }
574 : :
575 : : /* Update for last failure fragment */
576 : : if ((flags & NIX_RX_REAS_F) && reas_fail) {
577 : : head->data_len = (!first_frag && (sg_cnt == 1)) ? data_len + l4_off : data_len;
578 : : cnxk_ip_reassembly_dynfield(head, dyn_off)->next_frag = NULL;
579 : : cnxk_ip_reassembly_dynfield(head, dyn_off)->nb_frags = 0;
580 : : }
581 : : }
582 : : #else
583 : : static __rte_always_inline void
584 : : nix_cqe_xtract_mseg(const union nix_rx_parse_u *rx, struct rte_mbuf *mbuf, uint64_t rearm,
585 : : uintptr_t cpth, uintptr_t sa_base, const uint64_t buf_sz, const uint16_t flags)
586 : : {
587 : : RTE_SET_USED(rx);
588 : : RTE_SET_USED(mbuf);
589 : : RTE_SET_USED(rearm);
590 : : RTE_SET_USED(cpth);
591 : : RTE_SET_USED(sa_base);
592 : : RTE_SET_USED(buf_sz);
593 : : RTE_SET_USED(flags);
594 : : }
595 : : #endif
596 : :
597 : : static __rte_always_inline void
598 : : cn20k_nix_cqe_to_mbuf(const struct nix_cqe_hdr_s *cq, const uint32_t tag, struct rte_mbuf *mbuf,
599 : : const void *lookup_mem, uint64_t val, const uintptr_t cpth,
600 : : const uintptr_t sa_base, const uint64_t buf_sz, const uint16_t flag)
601 : : {
602 : : const union nix_rx_parse_u *rx = (const union nix_rx_parse_u *)((const uint64_t *)cq + 1);
603 : 0 : const uint64_t w1 = *(const uint64_t *)rx;
604 : 0 : uint16_t len = rx->pkt_lenm1 + 1;
605 : : uint64_t ol_flags = 0;
606 : : uintptr_t p;
607 : :
608 [ # # # # : 0 : if (flag & NIX_RX_OFFLOAD_PTYPE_F)
# # # # #
# # # ]
609 : 0 : mbuf->packet_type = nix_ptype_get(lookup_mem, w1);
610 : : else
611 : 0 : mbuf->packet_type = 0;
612 : :
613 [ # # # # : 0 : if (flag & NIX_RX_OFFLOAD_RSS_F) {
# # # # #
# # # ]
614 : 0 : mbuf->hash.rss = tag;
615 : : ol_flags |= RTE_MBUF_F_RX_RSS_HASH;
616 : : }
617 : :
618 : 0 : ol_flags |= (uint64_t)nix_rx_olflags_get(lookup_mem, w1);
619 : :
620 [ # # # # : 0 : if (flag & NIX_RX_OFFLOAD_VLAN_STRIP_F) {
# # # # #
# # # ]
621 [ # # # # : 0 : if (rx->vtag0_gone) {
# # # # #
# # # # #
# # ]
622 : 0 : ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
623 : 0 : mbuf->vlan_tci = rx->vtag0_tci;
624 : : }
625 [ # # # # : 0 : if (rx->vtag1_gone) {
# # # # #
# # # # #
# # ]
626 : 0 : ol_flags |= RTE_MBUF_F_RX_QINQ | RTE_MBUF_F_RX_QINQ_STRIPPED;
627 : 0 : mbuf->vlan_tci_outer = rx->vtag1_tci;
628 : : }
629 : : }
630 : :
631 [ # # # # : 0 : if (flag & NIX_RX_OFFLOAD_MARK_UPDATE_F)
# # # # #
# # # ]
632 [ # # # # : 0 : ol_flags = nix_update_match_id(rx->match_id, ol_flags, mbuf);
# # # # #
# # # # #
# # ]
633 : :
634 [ # # # # : 0 : if (flag & NIX_RX_OFFLOAD_SECURITY_F && w1 & BIT_ULL(11)) {
# # # # #
# # # # #
# # # # #
# # # #
# ]
635 [ # # # # : 0 : const uint64_t cq_w5 = *((const uint64_t *)cq + 5);
# # # # #
# # # # #
# # ]
636 : :
637 : 0 : ol_flags |= nix_sec_meta_to_mbuf_sc(cq_w5, cpth, sa_base, mbuf, &len, &val, flag);
638 : : }
639 : :
640 : : p = (uintptr_t)&mbuf->rearm_data;
641 : 0 : *(uint64_t *)p = val;
642 : :
643 : 0 : mbuf->ol_flags = ol_flags;
644 : 0 : mbuf->pkt_len = len;
645 [ # # # # : 0 : mbuf->data_len = len;
# # # # #
# # # ]
646 : :
647 : : if ((flag & NIX_RX_MULTI_SEG_F) || (flag & NIX_RX_REAS_F))
648 : : nix_cqe_xtract_mseg(rx, mbuf, val, cpth, sa_base, buf_sz, flag);
649 : : }
650 : :
651 : : static inline uint16_t
652 : : nix_rx_nb_pkts(struct cn20k_eth_rxq *rxq, const uint64_t wdata, const uint16_t pkts,
653 : : const uint32_t qmask)
654 : : {
655 : 0 : uint32_t available = rxq->available;
656 : :
657 : : /* Update the available count if cached value is not enough */
658 : 0 : if (unlikely(available < pkts)) {
659 : : uint64_t reg, head, tail;
660 : :
661 : : /* Use LDADDA version to avoid reorder */
662 : : reg = roc_atomic64_add_sync(wdata, rxq->cq_status);
663 : : /* CQ_OP_STATUS operation error */
664 : : if (reg & BIT_ULL(NIX_CQ_OP_STAT_OP_ERR) || reg & BIT_ULL(NIX_CQ_OP_STAT_CQ_ERR))
665 : : return 0;
666 : :
667 : : tail = reg & 0xFFFFF;
668 : : head = (reg >> 20) & 0xFFFFF;
669 : : if (tail < head)
670 : : available = tail - head + qmask + 1;
671 : : else
672 : : available = tail - head;
673 : :
674 : 0 : rxq->available = available;
675 : : }
676 : :
677 : 0 : return RTE_MIN(pkts, available);
678 : : }
679 : :
680 : : static __rte_always_inline void
681 : : cn20k_nix_mbuf_to_tstamp(struct rte_mbuf *mbuf, struct cnxk_timesync_info *tstamp,
682 : : const uint8_t ts_enable, uint64_t *tstamp_ptr)
683 : : {
684 : : if (ts_enable) {
685 : 0 : mbuf->pkt_len -= CNXK_NIX_TIMESYNC_RX_OFFSET;
686 : 0 : mbuf->data_len -= CNXK_NIX_TIMESYNC_RX_OFFSET;
687 : :
688 : : /* Reading the rx timestamp inserted by CGX, viz at
689 : : * starting of the packet data.
690 : : */
691 : 0 : *tstamp_ptr = ((*tstamp_ptr >> 32) * NSEC_PER_SEC) + (*tstamp_ptr & 0xFFFFFFFFUL);
692 [ # # ]: 0 : *cnxk_nix_timestamp_dynfield(mbuf, tstamp) = rte_be_to_cpu_64(*tstamp_ptr);
693 : : /* RTE_MBUF_F_RX_IEEE1588_TMST flag needs to be set only in case
694 : : * PTP packets are received.
695 : : */
696 [ # # ]: 0 : if (mbuf->packet_type == RTE_PTYPE_L2_ETHER_TIMESYNC) {
697 : 0 : tstamp->rx_tstamp = *cnxk_nix_timestamp_dynfield(mbuf, tstamp);
698 : 0 : tstamp->rx_ready = 1;
699 : 0 : mbuf->ol_flags |= RTE_MBUF_F_RX_IEEE1588_PTP | RTE_MBUF_F_RX_IEEE1588_TMST |
700 : 0 : tstamp->rx_tstamp_dynflag;
701 : : }
702 : : }
703 : : }
704 : :
705 : : static __rte_always_inline uint16_t
706 : : cn20k_nix_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t pkts, const uint16_t flags)
707 : : {
708 : : struct cn20k_eth_rxq *rxq = rx_queue;
709 : 0 : uint64_t mbuf_init = rxq->mbuf_initializer;
710 : 0 : const void *lookup_mem = rxq->lookup_mem;
711 : 0 : const uint64_t data_off = rxq->data_off;
712 : : const uint32_t m_sz = sizeof(struct rte_mbuf);
713 : 0 : const uint64_t wdata = rxq->wdata;
714 : 0 : const uint32_t qmask = rxq->qmask;
715 : 0 : const uintptr_t desc = rxq->desc;
716 : 0 : uint64_t buf_sz = rxq->mp_buf_sz;
717 : 0 : uint64_t lbase = rxq->lmt_base;
718 : : uint16_t packets = 0, nb_pkts;
719 : : uint8_t loff = 0, lnum = 0;
720 [ # # # # ]: 0 : uint32_t head = rxq->head;
721 : : struct nix_cqe_hdr_s *cq;
722 : : struct rte_mbuf *mbuf;
723 : : uint64_t aura_handle;
724 : : uint64_t sa_base = 0;
725 : : uintptr_t cpth = 0;
726 : : uint16_t lmt_id;
727 : : uint64_t laddr;
728 : : uint64_t w4;
729 : : bool is_oop;
730 : :
731 : : nb_pkts = nix_rx_nb_pkts(rxq, wdata, pkts, qmask);
732 : :
733 : : if (flags & NIX_RX_OFFLOAD_SECURITY_F) {
734 : 0 : aura_handle = rxq->meta_aura;
735 : 0 : sa_base = rxq->sa_base;
736 : 0 : sa_base &= ~(ROC_NIX_INL_SA_BASE_ALIGN - 1);
737 : : ROC_LMT_BASE_ID_GET(lbase, lmt_id);
738 : : laddr = lbase;
739 : 0 : laddr += 8;
740 : : }
741 : :
742 [ # # # # ]: 0 : while (packets < nb_pkts) {
743 : : /* Prefetch N desc ahead */
744 : 0 : rte_prefetch_non_temporal((void *)(desc + (CQE_SZ((head + 2) & qmask))));
745 : 0 : cq = (struct nix_cqe_hdr_s *)(desc + CQE_SZ(head));
746 : :
747 : : mbuf = nix_get_mbuf_from_cqe(cq, data_off);
748 : :
749 : : /* Mark mempool obj as "get" as it is alloc'ed by NIX */
750 : : RTE_MEMPOOL_CHECK_COOKIES(mbuf->pool, (void **)&mbuf, 1, 1);
751 : :
752 : : /* Translate meta to mbuf */
753 : : if (flags & NIX_RX_OFFLOAD_SECURITY_F) {
754 : 0 : const uint64_t cq_w1 = *((const uint64_t *)cq + 1);
755 : :
756 : : cpth = ((uintptr_t)mbuf + (uint16_t)data_off);
757 : :
758 [ # # # # ]: 0 : if (cq_w1 & BIT(11)) {
759 : : /* Mark meta mbuf as put */
760 : : RTE_MEMPOOL_CHECK_COOKIES(mbuf->pool, (void **)&mbuf, 1, 0);
761 : :
762 : : /* Store meta in lmtline to free
763 : : * Assume all meta's from same aura.
764 : : */
765 : 0 : *(uint64_t *)(laddr + (loff << 3)) = (uint64_t)mbuf;
766 : 0 : loff = loff + 1;
767 : 0 : w4 = *(uint64_t *)(cpth + 32);
768 [ # # # # : 0 : is_oop = !((w4 >> 32) & 0x3) && ((w4 & 0xffffffff) == 1);
# # # # ]
769 [ # # # # ]: 0 : if ((flags & NIX_RX_REAS_F) && is_oop)
770 : 0 : mbuf = nix_sec_oop_process(cpth, buf_sz);
771 : : else
772 : 0 : mbuf = (struct rte_mbuf *)(*(uint64_t *)(cpth + 8) - m_sz);
773 : :
774 : : /* Mark inner mbuf as get */
775 : : RTE_MEMPOOL_CHECK_COOKIES(mbuf->pool, (void **)&mbuf, 1, 1);
776 : : }
777 : : }
778 : :
779 [ # # # # ]: 0 : cn20k_nix_cqe_to_mbuf(cq, cq->tag, mbuf, lookup_mem, mbuf_init, cpth, sa_base,
780 : : buf_sz, flags);
781 [ # # ]: 0 : cn20k_nix_mbuf_to_tstamp(mbuf, rxq->tstamp, (flags & NIX_RX_OFFLOAD_TSTAMP_F),
782 : : (uint64_t *)((uint8_t *)mbuf + data_off));
783 : 0 : rx_pkts[packets++] = mbuf;
784 : : roc_prefetch_store_keep(mbuf);
785 : 0 : head++;
786 : 0 : head &= qmask;
787 : :
788 : : if (flags & NIX_RX_OFFLOAD_SECURITY_F) {
789 : : /* Flush when we don't have space for 4 meta */
790 [ # # # # ]: 0 : if ((15 - loff) < 1) {
791 : : nix_sec_flush_meta(laddr, lmt_id + lnum, loff, aura_handle);
792 : 0 : lnum++;
793 : 0 : lnum &= BIT_ULL(ROC_LMT_LINES_PER_CORE_LOG2) - 1;
794 : : /* First pointer starts at 8B offset */
795 : 0 : laddr = (uintptr_t)LMT_OFF(lbase, lnum, 8);
796 : : loff = 0;
797 : : }
798 : : }
799 : : }
800 : :
801 : 0 : rxq->head = head;
802 : 0 : rxq->available -= nb_pkts;
803 : :
804 : : /* Free all the CQs that we've processed */
805 [ # # # # ]: 0 : plt_write64((wdata | nb_pkts), rxq->cq_door);
806 : :
807 : : /* Free remaining meta buffers if any */
808 [ # # # # ]: 0 : if (flags & NIX_RX_OFFLOAD_SECURITY_F && loff)
809 : : nix_sec_flush_meta(laddr, lmt_id + lnum, loff, aura_handle);
810 : :
811 : : if (flags & NIX_RX_OFFLOAD_SECURITY_F)
812 : 0 : rte_io_wmb();
813 : :
814 : : return nb_pkts;
815 : : }
816 : :
817 : : static __rte_always_inline uint16_t
818 : : cn20k_nix_flush_recv_pkts(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t pkts,
819 : : const uint16_t flags)
820 : : {
821 : : struct cn20k_eth_rxq *rxq = rx_queue;
822 : : uint64_t mbuf_init = rxq->mbuf_initializer;
823 : : const void *lookup_mem = rxq->lookup_mem;
824 : : const uint64_t data_off = rxq->data_off;
825 : : const uint32_t m_sz = sizeof(struct rte_mbuf);
826 : : const uint64_t wdata = rxq->wdata;
827 : : const uint32_t qmask = rxq->qmask;
828 : : const uintptr_t desc = rxq->desc;
829 : : uint64_t buf_sz = rxq->mp_buf_sz;
830 : : uint16_t packets = 0, nb_pkts;
831 : : uint16_t lmt_id __rte_unused;
832 : : uint32_t head = rxq->head;
833 : : struct nix_cqe_hdr_s *cq;
834 : : struct rte_mbuf *mbuf;
835 : : uint64_t sa_base = 0;
836 : : uintptr_t cpth = 0;
837 : :
838 : : nb_pkts = nix_rx_nb_pkts(rxq, wdata, pkts, qmask);
839 : :
840 : : if (flags & NIX_RX_OFFLOAD_SECURITY_F) {
841 : : sa_base = rxq->sa_base;
842 : : sa_base &= ~(ROC_NIX_INL_SA_BASE_ALIGN - 1);
843 : : }
844 : :
845 : : while (packets < nb_pkts) {
846 : : /* Prefetch N desc ahead */
847 : : rte_prefetch_non_temporal((void *)(desc + (CQE_SZ((head + 2) & qmask))));
848 : : cq = (struct nix_cqe_hdr_s *)(desc + CQE_SZ(head));
849 : :
850 : : mbuf = nix_get_mbuf_from_cqe(cq, data_off);
851 : :
852 : : /* Mark mempool obj as "get" as it is alloc'ed by NIX */
853 : : RTE_MEMPOOL_CHECK_COOKIES(mbuf->pool, (void **)&mbuf, 1, 1);
854 : :
855 : : /* Translate meta to mbuf */
856 : : if (flags & NIX_RX_OFFLOAD_SECURITY_F) {
857 : : const uint64_t cq_w1 = *((const uint64_t *)cq + 1);
858 : :
859 : : cpth = ((uintptr_t)mbuf + (uint16_t)data_off);
860 : :
861 : : if (cq_w1 & BIT(11)) {
862 : : /* Mark meta mbuf as put */
863 : : RTE_MEMPOOL_CHECK_COOKIES(mbuf->pool, (void **)&mbuf, 1, 0);
864 : :
865 : : /* Store meta in lmtline to free
866 : : * Assume all meta's from same aura.
867 : : */
868 : : roc_npa_aura_op_free(mbuf->pool->pool_id, 0, (uint64_t)mbuf);
869 : : mbuf = (struct rte_mbuf *)(*(uint64_t *)(cpth + 8) - m_sz);
870 : :
871 : : /* Mark inner mbuf as get */
872 : : RTE_MEMPOOL_CHECK_COOKIES(mbuf->pool, (void **)&mbuf, 1, 1);
873 : : }
874 : : }
875 : :
876 : : cn20k_nix_cqe_to_mbuf(cq, cq->tag, mbuf, lookup_mem, mbuf_init, cpth, sa_base,
877 : : buf_sz, flags);
878 : : cn20k_nix_mbuf_to_tstamp(mbuf, rxq->tstamp, (flags & NIX_RX_OFFLOAD_TSTAMP_F),
879 : : (uint64_t *)((uint8_t *)mbuf + data_off));
880 : : rx_pkts[packets++] = mbuf;
881 : : roc_prefetch_store_keep(mbuf);
882 : : head++;
883 : : head &= qmask;
884 : : }
885 : :
886 : : rxq->head = head;
887 : : rxq->available -= nb_pkts;
888 : :
889 : : /* Free all the CQs that we've processed */
890 : : plt_write64((wdata | nb_pkts), rxq->cq_door);
891 : :
892 : : if (flags & NIX_RX_OFFLOAD_SECURITY_F)
893 : : rte_io_wmb();
894 : :
895 : : return nb_pkts;
896 : : }
897 : :
898 : : #if defined(RTE_ARCH_ARM64)
899 : :
900 : : static __rte_always_inline uint16_t
901 : : cn20k_nix_rx_inj_prepare_mseg(struct rte_mbuf *m, uint64_t *cmd)
902 : : {
903 : : union nix_send_sg_s *sg, l_sg;
904 : : struct rte_mbuf *m_next;
905 : : uint16_t segdw, nb_segs;
906 : : uint64_t len, dlen;
907 : : uint64_t *slist;
908 : :
909 : : sg = (union nix_send_sg_s *)cmd;
910 : : l_sg.u = sg->u;
911 : : l_sg.u &= 0xC00000000000000; /* LD_TYPE */
912 : : l_sg.subdc = NIX_SUBDC_SG;
913 : : nb_segs = m->nb_segs;
914 : : len = m->pkt_len;
915 : : slist = &cmd[1];
916 : :
917 : : /* Fill mbuf segments */
918 : : do {
919 : : *slist = rte_pktmbuf_iova(m);
920 : : dlen = m->data_len;
921 : : len -= dlen;
922 : :
923 : : /* Set the segment length */
924 : : l_sg.u |= ((uint64_t)dlen << (l_sg.segs << 4));
925 : : l_sg.segs += 1;
926 : : slist++;
927 : : nb_segs--;
928 : : if (l_sg.segs > 2 && nb_segs) {
929 : : sg->u = l_sg.u;
930 : : /* Next SG subdesc */
931 : : sg = (union nix_send_sg_s *)slist;
932 : : l_sg.u = sg->u;
933 : : l_sg.u &= 0xC00000000000000; /* LD_TYPE */
934 : : l_sg.subdc = NIX_SUBDC_SG;
935 : : slist++;
936 : : }
937 : : m_next = m->next;
938 : : m = m_next;
939 : : } while (nb_segs);
940 : :
941 : : /* Add remaining bytes of data to last seg */
942 : : if (len) {
943 : : uint8_t shft = (l_sg.subdc == NIX_SUBDC_SG) ? ((l_sg.segs - 1) << 4) : 0;
944 : : dlen = ((l_sg.u >> shft) & 0xFFFFULL) + len;
945 : : l_sg.u = l_sg.u & ~(0xFFFFULL << shft);
946 : : l_sg.u |= dlen << shft;
947 : : }
948 : : /* Write the last subdc out */
949 : : sg->u = l_sg.u;
950 : :
951 : : segdw = (uint64_t *)slist - cmd;
952 : : /* Roundup extra dwords to multiple of 2 */
953 : : segdw = (segdw >> 1) + (segdw & 0x1);
954 : : return segdw;
955 : : }
956 : :
957 : : static __rte_always_inline uint16_t
958 : : cn20k_nix_inj_pkts(struct rte_security_session **sess, struct cnxk_ethdev_inj_cfg *inj_cfg,
959 : : struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
960 : : {
961 : : uintptr_t c_lbase = inj_cfg->lmt_base;
962 : : struct cn20k_sec_sess_priv sess_priv;
963 : : uint64_t sa_base = inj_cfg->sa_base;
964 : : uint16_t c_lmt_id, burst, left, i;
965 : : uintptr_t cptres, rxphdr, dptr;
966 : : struct rte_mbuf *m, *last;
967 : : uint64_t sa, w0, gthr_sz;
968 : : uint8_t lnum, shft, loff;
969 : : uint64x2_t cmd01, cmd23;
970 : : uint64_t ucode_cmd[4];
971 : : rte_iova_t c_io_addr;
972 : : uint16_t segdw, segs;
973 : : uint64_t *laddr;
974 : :
975 : : /* Get LMT base address and LMT ID as lcore id */
976 : : ROC_LMT_CPT_BASE_ID_GET(c_lbase, c_lmt_id);
977 : : c_io_addr = inj_cfg->io_addr;
978 : :
979 : : sa_base &= ~0xFFFFUL;
980 : : left = nb_pkts;
981 : : again:
982 : : burst = left > 32 ? 32 : left;
983 : :
984 : : lnum = 0;
985 : : loff = 0;
986 : : shft = 16;
987 : :
988 : : for (i = 0; i < burst; i++) {
989 : : m = tx_pkts[i];
990 : : sess_priv.u64 = sess[i]->fast_mdata;
991 : : last = rte_pktmbuf_lastseg(m);
992 : :
993 : : cptres = rte_pktmbuf_mtod_offset(last, uintptr_t, last->data_len);
994 : : cptres += BIT_ULL(7);
995 : : cptres = (cptres - 1) & ~(BIT_ULL(7) - 1);
996 : : segs = m->nb_segs;
997 : :
998 : : if (segs > 1) {
999 : : /* Pointer to WQE header */
1000 : : /* Reserve 8 Dwords of WQE Hdr + Rx Parse Hdr */
1001 : : rxphdr = cptres + 8;
1002 : : dptr = rxphdr + 7 * 8;
1003 : : /* Prepare Multiseg SG list */
1004 : : segdw = cn20k_nix_rx_inj_prepare_mseg(m, (uint64_t *)(dptr));
1005 : : *(uint64_t *)rxphdr = (uint64_t)(segdw - 1) << 12;
1006 : : cptres += 64 + segdw * 16;
1007 : : gthr_sz = (segs % 3) == 0 ? (segs / 3) : (segs / 3 + 1);
1008 : : ucode_cmd[1] = dptr | (gthr_sz << 60);
1009 : : } else {
1010 : : dptr = (uint64_t)rte_pktmbuf_iova(m);
1011 : : ucode_cmd[1] = dptr;
1012 : : }
1013 : :
1014 : : /* Prepare CPT instruction */
1015 : : /* CPT word 0 and 1 */
1016 : : cmd01 = vdupq_n_u64(0);
1017 : : w0 = inj_cfg->cmd_w0 | ((uint64_t)m->l2_len - 2) << 24 | (uint64_t)m->l2_len << 16;
1018 : : cmd01 = vsetq_lane_u64(w0, cmd01, 0);
1019 : : cmd01 = vsetq_lane_u64(cptres, cmd01, 1);
1020 : :
1021 : : /* CPT word 2 and 3 */
1022 : : cmd23 = vdupq_n_u64(0);
1023 : : /* Set PF func */
1024 : : w0 &= 0xFFFF000000000000UL;
1025 : : cmd23 = vsetq_lane_u64(w0, cmd23, 0);
1026 : : cmd23 = vsetq_lane_u64(((uint64_t)m + sizeof(struct rte_mbuf)) | 1, cmd23, 1);
1027 : :
1028 : : sa = (uintptr_t)roc_nix_inl_ow_ipsec_inb_sa(sa_base, sess_priv.sa_idx);
1029 : : ucode_cmd[0] = (ROC_IE_OW_MAJOR_OP_PROCESS_INBOUND_IPSEC << 48 | 1UL << 54 |
1030 : : ((uint64_t)sess_priv.chksum) << 32 | (1ULL << 34) | m->pkt_len);
1031 : :
1032 : : ucode_cmd[2] = 0;
1033 : : ucode_cmd[3] = (ROC_CPT_DFLT_ENG_GRP_SE << 61 | 1UL << 60 | sa);
1034 : :
1035 : : /* Move to our line */
1036 : : laddr = LMT_OFF(c_lbase, lnum, loff ? 64 : 0);
1037 : :
1038 : : /* Write CPT instruction to lmt line */
1039 : : vst1q_u64(laddr, cmd01);
1040 : : vst1q_u64((laddr + 2), cmd23);
1041 : :
1042 : : *(__uint128_t *)(laddr + 4) = *(__uint128_t *)ucode_cmd;
1043 : : *(__uint128_t *)(laddr + 6) = *(__uint128_t *)(ucode_cmd + 2);
1044 : :
1045 : : loff = !loff;
1046 : : lnum = lnum + (loff ? 0 : 1);
1047 : : shft = shft + (loff ? 0 : 3);
1048 : : }
1049 : :
1050 : : left -= burst;
1051 : : tx_pkts += burst;
1052 : : sess += burst;
1053 : :
1054 : : cn20k_nix_sec_steorl(c_io_addr, c_lmt_id, lnum, loff, shft);
1055 : :
1056 : : rte_io_wmb();
1057 : : if (left)
1058 : : goto again;
1059 : :
1060 : : return nb_pkts;
1061 : : }
1062 : :
1063 : : static __rte_always_inline void
1064 : : nix_sec_meta_to_mbuf(uintptr_t inb_sa, uintptr_t cpth, struct rte_mbuf **inner, uint64_t *ol_flags,
1065 : : const uint16_t flags, uint64x2_t *rearm, uint64_t buf_sz)
1066 : : {
1067 : : const struct cpt_parse_hdr_s *hdr = (const struct cpt_parse_hdr_s *)cpth;
1068 : : struct cn20k_inb_priv_data *inb_priv;
1069 : : struct rte_mbuf *inner_m;
1070 : : uint64_t w4;
1071 : : bool is_oop;
1072 : :
1073 : : w4 = *(uint64_t *)(cpth + 32);
1074 : : is_oop = !((w4 >> 32) & 0x3) && ((w4 & 0xffffffff) == 1);
1075 : :
1076 : : if ((flags & NIX_RX_REAS_F) && is_oop)
1077 : : inner[0] = nix_sec_oop_process(cpth, buf_sz);
1078 : :
1079 : : inner_m = inner[0];
1080 : :
1081 : : /* Clear checksum flags */
1082 : : *ol_flags &= ~(RTE_MBUF_F_RX_L4_CKSUM_MASK | RTE_MBUF_F_RX_IP_CKSUM_MASK);
1083 : :
1084 : : if (flags & NIX_RX_REAS_F && !inb_sa) {
1085 : : /* Clear and update original lower 16 bit of data offset */
1086 : : *rearm = (*rearm & ~(BIT_ULL(16) - 1)) | inner_m->data_off;
1087 : : } else {
1088 : : /* Get SPI from CPT_PARSE_S's cookie(already swapped) */
1089 : : inb_priv = roc_nix_inl_ow_ipsec_inb_sa_sw_rsvd((void *)inb_sa);
1090 : : /* Update dynamic field with userdata */
1091 : : *rte_security_dynfield(inner_m) = (uint64_t)inb_priv->userdata;
1092 : : }
1093 : :
1094 : : /* Clear and update original lower 16 bit of data offset */
1095 : : if (flags & NIX_RX_REAS_F && hdr->w0.match_id == 0xFFFFU)
1096 : : *rearm = (*rearm & ~(BIT_ULL(16) - 1)) | inner_m->data_off;
1097 : :
1098 : : /* Mark inner mbuf as get */
1099 : : RTE_MEMPOOL_CHECK_COOKIES(inner_m->pool, (void **)&inner_m, 1, 1);
1100 : : }
1101 : :
1102 : : static __rte_always_inline uint64_t
1103 : : nix_vlan_update(const uint64_t w2, uint64_t ol_flags, uint8x16_t *f)
1104 : : {
1105 : : if (w2 & BIT_ULL(21) /* vtag0_gone */) {
1106 : : ol_flags |= RTE_MBUF_F_RX_VLAN | RTE_MBUF_F_RX_VLAN_STRIPPED;
1107 : : *f = vsetq_lane_u16((uint16_t)(w2 >> 32), *f, 5);
1108 : : }
1109 : :
1110 : : return ol_flags;
1111 : : }
1112 : :
1113 : : static __rte_always_inline uint64_t
1114 : : nix_qinq_update(const uint64_t w2, uint64_t ol_flags, struct rte_mbuf *mbuf)
1115 : : {
1116 : : if (w2 & BIT_ULL(23) /* vtag1_gone */) {
1117 : : ol_flags |= RTE_MBUF_F_RX_QINQ | RTE_MBUF_F_RX_QINQ_STRIPPED;
1118 : : mbuf->vlan_tci_outer = (uint16_t)(w2 >> 48);
1119 : : }
1120 : :
1121 : : return ol_flags;
1122 : : }
1123 : :
1124 : : #define NIX_PUSH_META_TO_FREE(_mbuf, _laddr, _loff_p) \
1125 : : do { \
1126 : : *(uint64_t *)((_laddr) + (*(_loff_p) << 3)) = (uint64_t)_mbuf; \
1127 : : *(_loff_p) = *(_loff_p) + 1; \
1128 : : /* Mark meta mbuf as put */ \
1129 : : RTE_MEMPOOL_CHECK_COOKIES(_mbuf->pool, (void **)&_mbuf, 1, 0); \
1130 : : } while (0)
1131 : :
1132 : : static __rte_always_inline uint16_t
1133 : : cn20k_nix_recv_pkts_vector(void *args, struct rte_mbuf **mbufs, uint16_t pkts, const uint16_t flags,
1134 : : void *lookup_mem, struct cnxk_timesync_info *tstamp, uintptr_t lmt_base,
1135 : : uint64_t meta_aura)
1136 : : {
1137 : : struct cn20k_eth_rxq *rxq = args;
1138 : : const uint64_t mbuf_initializer =
1139 : : (flags & NIX_RX_VWQE_F) ? *(uint64_t *)args : rxq->mbuf_initializer;
1140 : : const uint64x2_t data_off = flags & NIX_RX_VWQE_F ? vdupq_n_u64(RTE_PKTMBUF_HEADROOM) :
1141 : : vdupq_n_u64(rxq->data_off);
1142 : : const uint32_t qmask = flags & NIX_RX_VWQE_F ? 0 : rxq->qmask;
1143 : : const uint64_t wdata = flags & NIX_RX_VWQE_F ? 0 : rxq->wdata;
1144 : : const uintptr_t desc = flags & NIX_RX_VWQE_F ? 0 : rxq->desc;
1145 : : uint64x2_t cq0_w8, cq1_w8, cq2_w8, cq3_w8, mbuf01, mbuf23;
1146 : : uintptr_t cpth0 = 0, cpth1 = 0, cpth2 = 0, cpth3 = 0;
1147 : : uint64_t ol_flags0, ol_flags1, ol_flags2, ol_flags3;
1148 : : uint64x2_t rearm0 = vdupq_n_u64(mbuf_initializer);
1149 : : uint64x2_t rearm1 = vdupq_n_u64(mbuf_initializer);
1150 : : uint64x2_t rearm2 = vdupq_n_u64(mbuf_initializer);
1151 : : uint64x2_t rearm3 = vdupq_n_u64(mbuf_initializer);
1152 : : struct rte_mbuf *mbuf0, *mbuf1, *mbuf2, *mbuf3;
1153 : : uint64_t lbase = 0, laddr = 0, buf_sz = 0;
1154 : : uint8_t loff = 0, lnum = 0, shft = 0;
1155 : : uint16_t lmt_id = 0, d_off;
1156 : : uint8x16_t f0, f1, f2, f3;
1157 : : uintptr_t sa_base = 0;
1158 : : uint16_t packets = 0;
1159 : : uint16_t pkts_left;
1160 : : uint32_t head;
1161 : : uintptr_t cq0;
1162 : :
1163 : : if (!(flags & NIX_RX_VWQE_F)) {
1164 : : lookup_mem = rxq->lookup_mem;
1165 : : head = rxq->head;
1166 : :
1167 : : pkts = nix_rx_nb_pkts(rxq, wdata, pkts, qmask);
1168 : : pkts_left = pkts & (NIX_DESCS_PER_LOOP - 1);
1169 : : /* Packets has to be floor-aligned to NIX_DESCS_PER_LOOP */
1170 : : pkts = RTE_ALIGN_FLOOR(pkts, NIX_DESCS_PER_LOOP);
1171 : : if (flags & NIX_RX_OFFLOAD_TSTAMP_F)
1172 : : tstamp = rxq->tstamp;
1173 : :
1174 : : cq0 = desc + CQE_SZ(head);
1175 : : rte_prefetch0(CQE_PTR_OFF(cq0, 0, 64, flags));
1176 : : rte_prefetch0(CQE_PTR_OFF(cq0, 1, 64, flags));
1177 : : rte_prefetch0(CQE_PTR_OFF(cq0, 2, 64, flags));
1178 : : rte_prefetch0(CQE_PTR_OFF(cq0, 3, 64, flags));
1179 : : } else {
1180 : : RTE_SET_USED(head);
1181 : : }
1182 : :
1183 : : if (flags & NIX_RX_OFFLOAD_SECURITY_F) {
1184 : : if (flags & NIX_RX_VWQE_F) {
1185 : : uint64_t sg_w1;
1186 : : uint16_t port;
1187 : :
1188 : : mbuf0 = (struct rte_mbuf *)((uintptr_t)mbufs[0] - sizeof(struct rte_mbuf));
1189 : : /* Pick first mbuf's aura handle assuming all
1190 : : * mbufs are from a vec and are from same RQ.
1191 : : */
1192 : : if (!meta_aura)
1193 : : meta_aura = mbuf0->pool->pool_id;
1194 : : /* Calculate offset from mbuf to actual data area */
1195 : : /* Zero aura's first skip i.e mbuf setup might not match the actual
1196 : : * offset as first skip is taken from second pass RQ. So compute
1197 : : * using diff b/w first SG pointer and mbuf addr.
1198 : : */
1199 : : sg_w1 = *(uint64_t *)((uintptr_t)mbufs[0] + 72);
1200 : : d_off = (sg_w1 - (uint64_t)mbuf0);
1201 : :
1202 : : /* Get SA Base from lookup tbl using port_id */
1203 : : port = mbuf_initializer >> 48;
1204 : : sa_base = cnxk_nix_sa_base_get(port, lookup_mem);
1205 : : buf_sz = cnxk_nix_inl_bufsize_get(port, lookup_mem);
1206 : : lbase = lmt_base;
1207 : : } else {
1208 : : meta_aura = rxq->meta_aura;
1209 : : d_off = rxq->data_off;
1210 : : sa_base = rxq->sa_base;
1211 : : lbase = rxq->lmt_base;
1212 : : buf_sz = rxq->mp_buf_sz;
1213 : : }
1214 : :
1215 : : sa_base &= ~(ROC_NIX_INL_SA_BASE_ALIGN - 1);
1216 : : ROC_LMT_BASE_ID_GET(lbase, lmt_id);
1217 : : lnum = 0;
1218 : : laddr = lbase;
1219 : : laddr += 8;
1220 : : }
1221 : :
1222 : : while (packets < pkts) {
1223 : : if (!(flags & NIX_RX_VWQE_F)) {
1224 : : /* Exit loop if head is about to wrap and become
1225 : : * unaligned.
1226 : : */
1227 : : if (((head + NIX_DESCS_PER_LOOP - 1) & qmask) < NIX_DESCS_PER_LOOP) {
1228 : : pkts_left += (pkts - packets);
1229 : : break;
1230 : : }
1231 : :
1232 : : cq0 = desc + CQE_SZ(head);
1233 : : } else {
1234 : : cq0 = (uintptr_t)&mbufs[packets];
1235 : : }
1236 : :
1237 : : if (flags & NIX_RX_VWQE_F) {
1238 : : if (pkts - packets > 4) {
1239 : : rte_prefetch_non_temporal(CQE_PTR_OFF(cq0, 4, 0, flags));
1240 : : rte_prefetch_non_temporal(CQE_PTR_OFF(cq0, 5, 0, flags));
1241 : : rte_prefetch_non_temporal(CQE_PTR_OFF(cq0, 6, 0, flags));
1242 : : rte_prefetch_non_temporal(CQE_PTR_OFF(cq0, 7, 0, flags));
1243 : :
1244 : : if (likely(pkts - packets > 8)) {
1245 : : rte_prefetch1(CQE_PTR_OFF(cq0, 8, 0, flags));
1246 : : rte_prefetch1(CQE_PTR_OFF(cq0, 9, 0, flags));
1247 : : rte_prefetch1(CQE_PTR_OFF(cq0, 10, 0, flags));
1248 : : rte_prefetch1(CQE_PTR_OFF(cq0, 11, 0, flags));
1249 : : if (pkts - packets > 12) {
1250 : : rte_prefetch1(CQE_PTR_OFF(cq0, 12, 0, flags));
1251 : : rte_prefetch1(CQE_PTR_OFF(cq0, 13, 0, flags));
1252 : : rte_prefetch1(CQE_PTR_OFF(cq0, 14, 0, flags));
1253 : : rte_prefetch1(CQE_PTR_OFF(cq0, 15, 0, flags));
1254 : : }
1255 : : }
1256 : :
1257 : : rte_prefetch0(CQE_PTR_DIFF(cq0, 4, RTE_PKTMBUF_HEADROOM, flags));
1258 : : rte_prefetch0(CQE_PTR_DIFF(cq0, 5, RTE_PKTMBUF_HEADROOM, flags));
1259 : : rte_prefetch0(CQE_PTR_DIFF(cq0, 6, RTE_PKTMBUF_HEADROOM, flags));
1260 : : rte_prefetch0(CQE_PTR_DIFF(cq0, 7, RTE_PKTMBUF_HEADROOM, flags));
1261 : :
1262 : : if (likely(pkts - packets > 8)) {
1263 : : rte_prefetch0(
1264 : : CQE_PTR_DIFF(cq0, 8, RTE_PKTMBUF_HEADROOM, flags));
1265 : : rte_prefetch0(
1266 : : CQE_PTR_DIFF(cq0, 9, RTE_PKTMBUF_HEADROOM, flags));
1267 : : rte_prefetch0(
1268 : : CQE_PTR_DIFF(cq0, 10, RTE_PKTMBUF_HEADROOM, flags));
1269 : : rte_prefetch0(
1270 : : CQE_PTR_DIFF(cq0, 11, RTE_PKTMBUF_HEADROOM, flags));
1271 : : }
1272 : : }
1273 : : } else {
1274 : : if (pkts - packets > 8) {
1275 : : if (flags) {
1276 : : rte_prefetch0(CQE_PTR_OFF(cq0, 8, 0, flags));
1277 : : rte_prefetch0(CQE_PTR_OFF(cq0, 9, 0, flags));
1278 : : rte_prefetch0(CQE_PTR_OFF(cq0, 10, 0, flags));
1279 : : rte_prefetch0(CQE_PTR_OFF(cq0, 11, 0, flags));
1280 : : }
1281 : : rte_prefetch0(CQE_PTR_OFF(cq0, 8, 64, flags));
1282 : : rte_prefetch0(CQE_PTR_OFF(cq0, 9, 64, flags));
1283 : : rte_prefetch0(CQE_PTR_OFF(cq0, 10, 64, flags));
1284 : : rte_prefetch0(CQE_PTR_OFF(cq0, 11, 64, flags));
1285 : : }
1286 : : }
1287 : :
1288 : : if (!(flags & NIX_RX_VWQE_F)) {
1289 : : /* Get NIX_RX_SG_S for size and buffer pointer */
1290 : : cq0_w8 = vld1q_u64(CQE_PTR_OFF(cq0, 0, 64, flags));
1291 : : cq1_w8 = vld1q_u64(CQE_PTR_OFF(cq0, 1, 64, flags));
1292 : : cq2_w8 = vld1q_u64(CQE_PTR_OFF(cq0, 2, 64, flags));
1293 : : cq3_w8 = vld1q_u64(CQE_PTR_OFF(cq0, 3, 64, flags));
1294 : :
1295 : : /* Extract mbuf from NIX_RX_SG_S */
1296 : : mbuf01 = vzip2q_u64(cq0_w8, cq1_w8);
1297 : : mbuf23 = vzip2q_u64(cq2_w8, cq3_w8);
1298 : : mbuf01 = vqsubq_u64(mbuf01, data_off);
1299 : : mbuf23 = vqsubq_u64(mbuf23, data_off);
1300 : : } else {
1301 : : mbuf01 = vsubq_u64(vld1q_u64((uint64_t *)cq0),
1302 : : vdupq_n_u64(sizeof(struct rte_mbuf)));
1303 : : mbuf23 = vsubq_u64(vld1q_u64((uint64_t *)(cq0 + 16)),
1304 : : vdupq_n_u64(sizeof(struct rte_mbuf)));
1305 : : }
1306 : :
1307 : : /* Move mbufs to scalar registers for future use */
1308 : : mbuf0 = (struct rte_mbuf *)vgetq_lane_u64(mbuf01, 0);
1309 : : mbuf1 = (struct rte_mbuf *)vgetq_lane_u64(mbuf01, 1);
1310 : : mbuf2 = (struct rte_mbuf *)vgetq_lane_u64(mbuf23, 0);
1311 : : mbuf3 = (struct rte_mbuf *)vgetq_lane_u64(mbuf23, 1);
1312 : :
1313 : : /* Mark mempool obj as "get" as it is alloc'ed by NIX */
1314 : : RTE_MEMPOOL_CHECK_COOKIES(mbuf0->pool, (void **)&mbuf0, 1, 1);
1315 : : RTE_MEMPOOL_CHECK_COOKIES(mbuf1->pool, (void **)&mbuf1, 1, 1);
1316 : : RTE_MEMPOOL_CHECK_COOKIES(mbuf2->pool, (void **)&mbuf2, 1, 1);
1317 : : RTE_MEMPOOL_CHECK_COOKIES(mbuf3->pool, (void **)&mbuf3, 1, 1);
1318 : :
1319 : : if (!(flags & NIX_RX_VWQE_F)) {
1320 : : /* Mask to get packet len from NIX_RX_SG_S */
1321 : : const uint8x16_t shuf_msk = {
1322 : : 0xFF, 0xFF, /* pkt_type set as unknown */
1323 : : 0xFF, 0xFF, /* pkt_type set as unknown */
1324 : : 0, 1, /* octet 1~0, low 16 bits pkt_len */
1325 : : 0xFF, 0xFF, /* skip high 16it pkt_len, zero out */
1326 : : 0, 1, /* octet 1~0, 16 bits data_len */
1327 : : 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
1328 : :
1329 : : /* Form the rx_descriptor_fields1 with pkt_len and data_len */
1330 : : f0 = vqtbl1q_u8(cq0_w8, shuf_msk);
1331 : : f1 = vqtbl1q_u8(cq1_w8, shuf_msk);
1332 : : f2 = vqtbl1q_u8(cq2_w8, shuf_msk);
1333 : : f3 = vqtbl1q_u8(cq3_w8, shuf_msk);
1334 : : }
1335 : :
1336 : : /* Load CQE word0 and word 1 */
1337 : : const uint64_t cq0_w0 = *CQE_PTR_OFF(cq0, 0, 0, flags);
1338 : : const uint64_t cq0_w1 = *CQE_PTR_OFF(cq0, 0, 8, flags);
1339 : : const uint64_t cq0_w2 = *CQE_PTR_OFF(cq0, 0, 16, flags);
1340 : : const uint64_t cq1_w0 = *CQE_PTR_OFF(cq0, 1, 0, flags);
1341 : : const uint64_t cq1_w1 = *CQE_PTR_OFF(cq0, 1, 8, flags);
1342 : : const uint64_t cq1_w2 = *CQE_PTR_OFF(cq0, 1, 16, flags);
1343 : : const uint64_t cq2_w0 = *CQE_PTR_OFF(cq0, 2, 0, flags);
1344 : : const uint64_t cq2_w1 = *CQE_PTR_OFF(cq0, 2, 8, flags);
1345 : : const uint64_t cq2_w2 = *CQE_PTR_OFF(cq0, 2, 16, flags);
1346 : : const uint64_t cq3_w0 = *CQE_PTR_OFF(cq0, 3, 0, flags);
1347 : : const uint64_t cq3_w1 = *CQE_PTR_OFF(cq0, 3, 8, flags);
1348 : : const uint64_t cq3_w2 = *CQE_PTR_OFF(cq0, 3, 16, flags);
1349 : :
1350 : : if (flags & NIX_RX_VWQE_F) {
1351 : : uint16_t psize0, psize1, psize2, psize3;
1352 : :
1353 : : psize0 = (cq0_w2 & 0xFFFF) + 1;
1354 : : psize1 = (cq1_w2 & 0xFFFF) + 1;
1355 : : psize2 = (cq2_w2 & 0xFFFF) + 1;
1356 : : psize3 = (cq3_w2 & 0xFFFF) + 1;
1357 : :
1358 : : f0 = vdupq_n_u64(0);
1359 : : f1 = vdupq_n_u64(0);
1360 : : f2 = vdupq_n_u64(0);
1361 : : f3 = vdupq_n_u64(0);
1362 : :
1363 : : f0 = vsetq_lane_u16(psize0, f0, 2);
1364 : : f0 = vsetq_lane_u16(psize0, f0, 4);
1365 : :
1366 : : f1 = vsetq_lane_u16(psize1, f1, 2);
1367 : : f1 = vsetq_lane_u16(psize1, f1, 4);
1368 : :
1369 : : f2 = vsetq_lane_u16(psize2, f2, 2);
1370 : : f2 = vsetq_lane_u16(psize2, f2, 4);
1371 : :
1372 : : f3 = vsetq_lane_u16(psize3, f3, 2);
1373 : : f3 = vsetq_lane_u16(psize3, f3, 4);
1374 : : }
1375 : :
1376 : : if (flags & NIX_RX_OFFLOAD_RSS_F) {
1377 : : /* Fill rss in the rx_descriptor_fields1 */
1378 : : f0 = vsetq_lane_u32(cq0_w0, f0, 3);
1379 : : f1 = vsetq_lane_u32(cq1_w0, f1, 3);
1380 : : f2 = vsetq_lane_u32(cq2_w0, f2, 3);
1381 : : f3 = vsetq_lane_u32(cq3_w0, f3, 3);
1382 : : ol_flags0 = RTE_MBUF_F_RX_RSS_HASH;
1383 : : ol_flags1 = RTE_MBUF_F_RX_RSS_HASH;
1384 : : ol_flags2 = RTE_MBUF_F_RX_RSS_HASH;
1385 : : ol_flags3 = RTE_MBUF_F_RX_RSS_HASH;
1386 : : } else {
1387 : : ol_flags0 = 0;
1388 : : ol_flags1 = 0;
1389 : : ol_flags2 = 0;
1390 : : ol_flags3 = 0;
1391 : : }
1392 : :
1393 : : if (flags & NIX_RX_OFFLOAD_PTYPE_F) {
1394 : : /* Fill packet_type in the rx_descriptor_fields1 */
1395 : : f0 = vsetq_lane_u32(nix_ptype_get(lookup_mem, cq0_w1), f0, 0);
1396 : : f1 = vsetq_lane_u32(nix_ptype_get(lookup_mem, cq1_w1), f1, 0);
1397 : : f2 = vsetq_lane_u32(nix_ptype_get(lookup_mem, cq2_w1), f2, 0);
1398 : : f3 = vsetq_lane_u32(nix_ptype_get(lookup_mem, cq3_w1), f3, 0);
1399 : : }
1400 : :
1401 : : if (flags & NIX_RX_OFFLOAD_CHECKSUM_F) {
1402 : : ol_flags0 |= (uint64_t)nix_rx_olflags_get(lookup_mem, cq0_w1);
1403 : : ol_flags1 |= (uint64_t)nix_rx_olflags_get(lookup_mem, cq1_w1);
1404 : : ol_flags2 |= (uint64_t)nix_rx_olflags_get(lookup_mem, cq2_w1);
1405 : : ol_flags3 |= (uint64_t)nix_rx_olflags_get(lookup_mem, cq3_w1);
1406 : : }
1407 : :
1408 : : /* Translate meta to mbuf */
1409 : : if (flags & NIX_RX_OFFLOAD_SECURITY_F) {
1410 : : uint64_t cq0_w5 = *CQE_PTR_OFF(cq0, 0, 40, flags);
1411 : : uint64_t cq1_w5 = *CQE_PTR_OFF(cq0, 1, 40, flags);
1412 : : uint64_t cq2_w5 = *CQE_PTR_OFF(cq0, 2, 40, flags);
1413 : : uint64_t cq3_w5 = *CQE_PTR_OFF(cq0, 3, 40, flags);
1414 : : uint8_t code;
1415 : :
1416 : : uint64x2_t inner0, inner1, inner2, inner3;
1417 : : uint64x2_t wqe01, wqe23, sa01, sa23;
1418 : : uint64x2_t mask01, mask23;
1419 : : uint16x4_t lens, l2lens;
1420 : : uint8x8_t ucc;
1421 : :
1422 : : cpth0 = (uintptr_t)mbuf0 + d_off;
1423 : : cpth1 = (uintptr_t)mbuf1 + d_off;
1424 : : cpth2 = (uintptr_t)mbuf2 + d_off;
1425 : : cpth3 = (uintptr_t)mbuf3 + d_off;
1426 : :
1427 : : inner0 = vld1q_u64((const uint64_t *)cpth0);
1428 : : inner1 = vld1q_u64((const uint64_t *)cpth1);
1429 : : inner2 = vld1q_u64((const uint64_t *)cpth2);
1430 : : inner3 = vld1q_u64((const uint64_t *)cpth3);
1431 : :
1432 : : /* Extract and reverse wqe pointers */
1433 : : wqe01 = vzip2q_u64(inner0, inner1);
1434 : : wqe23 = vzip2q_u64(inner2, inner3);
1435 : :
1436 : : /* Adjust wqe pointers to point to mbuf */
1437 : : wqe01 = vsubq_u64(wqe01, vdupq_n_u64(sizeof(struct rte_mbuf)));
1438 : : wqe23 = vsubq_u64(wqe23, vdupq_n_u64(sizeof(struct rte_mbuf)));
1439 : :
1440 : : /* Extract sa idx from cookie area and add to sa_base */
1441 : : sa01 = vzip1q_u64(inner0, inner1);
1442 : : sa23 = vzip1q_u64(inner2, inner3);
1443 : :
1444 : : sa01 = vandq_u64(sa01, vdupq_n_u64(0xFFFFFFFF));
1445 : : sa23 = vandq_u64(sa23, vdupq_n_u64(0xFFFFFFFF));
1446 : :
1447 : : if (flags & NIX_RX_REAS_F) {
1448 : : /* Crypto Look-aside Rx Inject case */
1449 : : mask01 = vceqq_u64(sa01, vdupq_n_u64(0xFFFFFFFF));
1450 : : mask23 = vceqq_u64(sa23, vdupq_n_u64(0xFFFFFFFF));
1451 : : }
1452 : :
1453 : : sa01 = vshlq_n_u64(sa01, ROC_NIX_INL_OW_IPSEC_INB_SA_SZ_LOG2);
1454 : : sa23 = vshlq_n_u64(sa23, ROC_NIX_INL_OW_IPSEC_INB_SA_SZ_LOG2);
1455 : : sa01 = vaddq_u64(sa01, vdupq_n_u64(sa_base));
1456 : : sa23 = vaddq_u64(sa23, vdupq_n_u64(sa_base));
1457 : :
1458 : : if (flags & NIX_RX_REAS_F) {
1459 : : sa01 = vbicq_u64(sa01, mask01);
1460 : : sa23 = vbicq_u64(sa23, mask23);
1461 : : }
1462 : :
1463 : : const uint8x16x2_t tbl = {{
1464 : : {
1465 : : /* ROC_IE_OW_UCC_SUCCESS_PKT_IP_BADCSUM */
1466 : : RTE_MBUF_F_RX_IP_CKSUM_BAD >> 1,
1467 : : /* ROC_IE_OW_UCC_SUCCESS_PKT_L4_GOODCSUM */
1468 : : (RTE_MBUF_F_RX_IP_CKSUM_GOOD |
1469 : : RTE_MBUF_F_RX_L4_CKSUM_GOOD) >>
1470 : : 1,
1471 : : /* ROC_IE_OW_UCC_SUCCESS_PKT_L4_BADCSUM */
1472 : : (RTE_MBUF_F_RX_IP_CKSUM_GOOD |
1473 : : RTE_MBUF_F_RX_L4_CKSUM_BAD) >>
1474 : : 1,
1475 : : 1,
1476 : : /* ROC_IE_OW_UCC_SUCCESS_PKT_UDPESP_NZCSUM */
1477 : : (RTE_MBUF_F_RX_IP_CKSUM_GOOD |
1478 : : RTE_MBUF_F_RX_L4_CKSUM_GOOD) >>
1479 : : 1,
1480 : : 1,
1481 : : /* ROC_IE_OW_UCC_SUCCESS_PKT_UDP_ZEROCSUM */
1482 : : (RTE_MBUF_F_RX_IP_CKSUM_GOOD |
1483 : : RTE_MBUF_F_RX_L4_CKSUM_GOOD) >>
1484 : : 1,
1485 : : 3,
1486 : : 1,
1487 : : 3,
1488 : : 3,
1489 : : 3,
1490 : : 3,
1491 : : 1,
1492 : : 3,
1493 : : 1,
1494 : : },
1495 : : {
1496 : : 1,
1497 : : 1,
1498 : : 1,
1499 : : /* ROC_IE_OW_UCC_SUCCESS_PKT_IP_GOODCSUM */
1500 : : RTE_MBUF_F_RX_IP_CKSUM_GOOD >> 1,
1501 : : /* Rest 0 to indicate RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED */
1502 : : 0,
1503 : : 0,
1504 : : 0,
1505 : : 0,
1506 : : 0,
1507 : : 0,
1508 : : 0,
1509 : : 0,
1510 : : 0,
1511 : : 0,
1512 : : 0,
1513 : : 0,
1514 : : },
1515 : : }};
1516 : :
1517 : : const uint8x8_t err_off = {
1518 : : /* HW_CCODE 0:6 -> 7:D */
1519 : : -7,
1520 : : /* UCC */
1521 : : 0xED,
1522 : : -7,
1523 : : 0xED,
1524 : : -7,
1525 : : 0xED,
1526 : : -7,
1527 : : 0xED,
1528 : : };
1529 : :
1530 : : ucc = vdup_n_u8(0);
1531 : : ucc = vset_lane_u16(*(uint16_t *)(cpth0 + 24), ucc, 0);
1532 : : ucc = vset_lane_u16(*(uint16_t *)(cpth1 + 24), ucc, 1);
1533 : : ucc = vset_lane_u16(*(uint16_t *)(cpth2 + 24), ucc, 2);
1534 : : ucc = vset_lane_u16(*(uint16_t *)(cpth3 + 24), ucc, 3);
1535 : : ucc = vsub_u8(ucc, err_off);
1536 : :
1537 : : /* Table lookup to get the corresponding flags, Out of the range
1538 : : * from this lookup will have value 0 and consider as
1539 : : * RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED.
1540 : : */
1541 : : ucc = vqtbl2_u8(tbl, ucc);
1542 : :
1543 : : /* Extract l3 lengths from hdr */
1544 : : lens = vdup_n_u16(0);
1545 : : lens = vset_lane_u16(*(uint16_t *)(cpth0 + 30), lens, 0);
1546 : : lens = vset_lane_u16(*(uint16_t *)(cpth1 + 30), lens, 1);
1547 : : lens = vset_lane_u16(*(uint16_t *)(cpth2 + 30), lens, 2);
1548 : : lens = vset_lane_u16(*(uint16_t *)(cpth3 + 30), lens, 3);
1549 : :
1550 : : /* Add l2 length to l3 lengths */
1551 : : l2lens = vdup_n_u16(0);
1552 : : l2lens =
1553 : : vset_lane_u16(((cq0_w5 >> 16) & 0xFF) - (cq0_w5 & 0xFF), l2lens, 0);
1554 : : l2lens =
1555 : : vset_lane_u16(((cq1_w5 >> 16) & 0xFF) - (cq1_w5 & 0xFF), l2lens, 1);
1556 : : l2lens =
1557 : : vset_lane_u16(((cq2_w5 >> 16) & 0xFF) - (cq2_w5 & 0xFF), l2lens, 2);
1558 : : l2lens =
1559 : : vset_lane_u16(((cq3_w5 >> 16) & 0xFF) - (cq3_w5 & 0xFF), l2lens, 3);
1560 : : lens = vadd_u16(lens, l2lens);
1561 : :
1562 : : /* Initialize rearm data when reassembly is enabled as
1563 : : * data offset might change.
1564 : : */
1565 : : if (flags & NIX_RX_REAS_F) {
1566 : : rearm0 = vdupq_n_u64(mbuf_initializer);
1567 : : rearm1 = vdupq_n_u64(mbuf_initializer);
1568 : : rearm2 = vdupq_n_u64(mbuf_initializer);
1569 : : rearm3 = vdupq_n_u64(mbuf_initializer);
1570 : : }
1571 : :
1572 : : /* Checksum ol_flags will be cleared if mbuf is meta */
1573 : : if (cq0_w1 & BIT(11)) {
1574 : : uintptr_t wqe = vgetq_lane_u64(wqe01, 0);
1575 : : uintptr_t sa = vgetq_lane_u64(sa01, 0);
1576 : : uint16_t len = vget_lane_u16(lens, 0);
1577 : :
1578 : : cpth0 = (uintptr_t)mbuf0 + d_off;
1579 : :
1580 : : /* Free meta to aura */
1581 : : NIX_PUSH_META_TO_FREE(mbuf0, laddr, &loff);
1582 : : mbuf0 = (struct rte_mbuf *)wqe;
1583 : :
1584 : : /* Update pkt_len and data_len */
1585 : : f0 = vsetq_lane_u16(len, f0, 2);
1586 : : f0 = vsetq_lane_u16(len, f0, 4);
1587 : :
1588 : : nix_sec_meta_to_mbuf(sa, cpth0, &mbuf0, &ol_flags0, flags, &rearm0,
1589 : : buf_sz);
1590 : : mbuf01 = vsetq_lane_u64((uintptr_t)mbuf0, mbuf01, 0);
1591 : : code = vget_lane_u8(ucc, 1);
1592 : : ol_flags0 |= code ? (code > 1 ? ((uint64_t)code) << 1 : 0) :
1593 : : RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED;
1594 : :
1595 : : ol_flags0 |= ((uint64_t)(vget_lane_u8(ucc, 0)) << 18);
1596 : : }
1597 : :
1598 : : if (cq1_w1 & BIT(11)) {
1599 : : uintptr_t wqe = vgetq_lane_u64(wqe01, 1);
1600 : : uintptr_t sa = vgetq_lane_u64(sa01, 1);
1601 : : uint16_t len = vget_lane_u16(lens, 1);
1602 : :
1603 : : cpth1 = (uintptr_t)mbuf1 + d_off;
1604 : :
1605 : : NIX_PUSH_META_TO_FREE(mbuf1, laddr, &loff);
1606 : : mbuf1 = (struct rte_mbuf *)wqe;
1607 : :
1608 : : /* Update pkt_len and data_len */
1609 : : f1 = vsetq_lane_u16(len, f1, 2);
1610 : : f1 = vsetq_lane_u16(len, f1, 4);
1611 : :
1612 : : nix_sec_meta_to_mbuf(sa, cpth1, &mbuf1, &ol_flags1, flags, &rearm1,
1613 : : buf_sz);
1614 : : mbuf01 = vsetq_lane_u64((uintptr_t)mbuf1, mbuf01, 1);
1615 : : code = vget_lane_u8(ucc, 3);
1616 : : ol_flags1 |= code ? (code > 1 ? ((uint64_t)code) << 1 : 0) :
1617 : : RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED;
1618 : : ol_flags1 |= ((uint64_t)(vget_lane_u8(ucc, 2)) << 18);
1619 : : }
1620 : :
1621 : : if (cq2_w1 & BIT(11)) {
1622 : : uintptr_t wqe = vgetq_lane_u64(wqe23, 0);
1623 : : uintptr_t sa = vgetq_lane_u64(sa23, 0);
1624 : : uint16_t len = vget_lane_u16(lens, 2);
1625 : :
1626 : : cpth2 = (uintptr_t)mbuf2 + d_off;
1627 : :
1628 : : /* Free meta to aura */
1629 : : NIX_PUSH_META_TO_FREE(mbuf2, laddr, &loff);
1630 : : mbuf2 = (struct rte_mbuf *)wqe;
1631 : :
1632 : : /* Update pkt_len and data_len */
1633 : : f2 = vsetq_lane_u16(len, f2, 2);
1634 : : f2 = vsetq_lane_u16(len, f2, 4);
1635 : :
1636 : : nix_sec_meta_to_mbuf(sa, cpth2, &mbuf2, &ol_flags2, flags, &rearm2,
1637 : : buf_sz);
1638 : : mbuf23 = vsetq_lane_u64((uintptr_t)mbuf2, mbuf23, 0);
1639 : : code = vget_lane_u8(ucc, 5);
1640 : : ol_flags2 |= code ? (code > 1 ? ((uint64_t)code) << 1 : 0) :
1641 : : RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED;
1642 : : ol_flags2 |= ((uint64_t)(vget_lane_u8(ucc, 4)) << 18);
1643 : : }
1644 : :
1645 : : if (cq3_w1 & BIT(11)) {
1646 : : uintptr_t wqe = vgetq_lane_u64(wqe23, 1);
1647 : : uintptr_t sa = vgetq_lane_u64(sa23, 1);
1648 : : uint16_t len = vget_lane_u16(lens, 3);
1649 : :
1650 : : cpth3 = (uintptr_t)mbuf3 + d_off;
1651 : :
1652 : : /* Free meta to aura */
1653 : : NIX_PUSH_META_TO_FREE(mbuf3, laddr, &loff);
1654 : : mbuf3 = (struct rte_mbuf *)wqe;
1655 : :
1656 : : /* Update pkt_len and data_len */
1657 : : f3 = vsetq_lane_u16(len, f3, 2);
1658 : : f3 = vsetq_lane_u16(len, f3, 4);
1659 : :
1660 : : nix_sec_meta_to_mbuf(sa, cpth3, &mbuf3, &ol_flags3, flags, &rearm3,
1661 : : buf_sz);
1662 : : mbuf23 = vsetq_lane_u64((uintptr_t)mbuf3, mbuf23, 1);
1663 : : code = vget_lane_u8(ucc, 7);
1664 : : ol_flags3 |= code ? (code > 1 ? ((uint64_t)code) << 1 : 0) :
1665 : : RTE_MBUF_F_RX_SEC_OFFLOAD_FAILED;
1666 : : ol_flags3 |= ((uint64_t)(vget_lane_u8(ucc, 6)) << 18);
1667 : : }
1668 : : }
1669 : :
1670 : : if (flags & NIX_RX_OFFLOAD_VLAN_STRIP_F) {
1671 : : ol_flags0 = nix_vlan_update(cq0_w2, ol_flags0, &f0);
1672 : : ol_flags1 = nix_vlan_update(cq1_w2, ol_flags1, &f1);
1673 : : ol_flags2 = nix_vlan_update(cq2_w2, ol_flags2, &f2);
1674 : : ol_flags3 = nix_vlan_update(cq3_w2, ol_flags3, &f3);
1675 : :
1676 : : ol_flags0 = nix_qinq_update(cq0_w2, ol_flags0, mbuf0);
1677 : : ol_flags1 = nix_qinq_update(cq1_w2, ol_flags1, mbuf1);
1678 : : ol_flags2 = nix_qinq_update(cq2_w2, ol_flags2, mbuf2);
1679 : : ol_flags3 = nix_qinq_update(cq3_w2, ol_flags3, mbuf3);
1680 : : }
1681 : :
1682 : : if (flags & NIX_RX_OFFLOAD_MARK_UPDATE_F) {
1683 : : ol_flags0 = nix_update_match_id(*(uint16_t *)CQE_PTR_OFF(cq0, 0, 38, flags),
1684 : : ol_flags0, mbuf0);
1685 : : ol_flags1 = nix_update_match_id(*(uint16_t *)CQE_PTR_OFF(cq0, 1, 38, flags),
1686 : : ol_flags1, mbuf1);
1687 : : ol_flags2 = nix_update_match_id(*(uint16_t *)CQE_PTR_OFF(cq0, 2, 38, flags),
1688 : : ol_flags2, mbuf2);
1689 : : ol_flags3 = nix_update_match_id(*(uint16_t *)CQE_PTR_OFF(cq0, 3, 38, flags),
1690 : : ol_flags3, mbuf3);
1691 : : }
1692 : :
1693 : : if ((flags & NIX_RX_OFFLOAD_TSTAMP_F) && ((flags & NIX_RX_VWQE_F) && tstamp)) {
1694 : : const uint16x8_t len_off = {0, /* ptype 0:15 */
1695 : : 0, /* ptype 16:32 */
1696 : : CNXK_NIX_TIMESYNC_RX_OFFSET, /* pktlen 0:15*/
1697 : : 0, /* pktlen 16:32 */
1698 : : CNXK_NIX_TIMESYNC_RX_OFFSET, /* datalen 0:15 */
1699 : : 0,
1700 : : 0,
1701 : : 0};
1702 : : const uint32x4_t ptype = {
1703 : : RTE_PTYPE_L2_ETHER_TIMESYNC, RTE_PTYPE_L2_ETHER_TIMESYNC,
1704 : : RTE_PTYPE_L2_ETHER_TIMESYNC, RTE_PTYPE_L2_ETHER_TIMESYNC};
1705 : : const uint64_t ts_olf = RTE_MBUF_F_RX_IEEE1588_PTP |
1706 : : RTE_MBUF_F_RX_IEEE1588_TMST |
1707 : : tstamp->rx_tstamp_dynflag;
1708 : : const uint32x4_t and_mask = {0x1, 0x2, 0x4, 0x8};
1709 : : uint64x2_t ts01, ts23, mask;
1710 : : uint64_t ts[4];
1711 : : uint8_t res;
1712 : :
1713 : : /* Subtract timesync length from total pkt length. */
1714 : : f0 = vsubq_u16(f0, len_off);
1715 : : f1 = vsubq_u16(f1, len_off);
1716 : : f2 = vsubq_u16(f2, len_off);
1717 : : f3 = vsubq_u16(f3, len_off);
1718 : :
1719 : : /* Get the address of actual timestamp. */
1720 : : ts01 = vaddq_u64(mbuf01, data_off);
1721 : : ts23 = vaddq_u64(mbuf23, data_off);
1722 : : /* Load timestamp from address. */
1723 : : ts01 = vsetq_lane_u64(*(uint64_t *)vgetq_lane_u64(ts01, 0), ts01, 0);
1724 : : ts01 = vsetq_lane_u64(*(uint64_t *)vgetq_lane_u64(ts01, 1), ts01, 1);
1725 : : ts23 = vsetq_lane_u64(*(uint64_t *)vgetq_lane_u64(ts23, 0), ts23, 0);
1726 : : ts23 = vsetq_lane_u64(*(uint64_t *)vgetq_lane_u64(ts23, 1), ts23, 1);
1727 : : /* Convert from be to cpu byteorder. */
1728 : : ts01 = vrev64q_u8(ts01);
1729 : : ts23 = vrev64q_u8(ts23);
1730 : : /* Store timestamp into scalar for later use. */
1731 : : ts[0] = vgetq_lane_u64(ts01, 0);
1732 : : ts[1] = vgetq_lane_u64(ts01, 1);
1733 : : ts[2] = vgetq_lane_u64(ts23, 0);
1734 : : ts[3] = vgetq_lane_u64(ts23, 1);
1735 : :
1736 : : /* Store timestamp into dynfield. */
1737 : : *cnxk_nix_timestamp_dynfield(mbuf0, tstamp) = ts[0];
1738 : : *cnxk_nix_timestamp_dynfield(mbuf1, tstamp) = ts[1];
1739 : : *cnxk_nix_timestamp_dynfield(mbuf2, tstamp) = ts[2];
1740 : : *cnxk_nix_timestamp_dynfield(mbuf3, tstamp) = ts[3];
1741 : :
1742 : : /* Generate ptype mask to filter L2 ether timesync */
1743 : : mask = vdupq_n_u32(vgetq_lane_u32(f0, 0));
1744 : : mask = vsetq_lane_u32(vgetq_lane_u32(f1, 0), mask, 1);
1745 : : mask = vsetq_lane_u32(vgetq_lane_u32(f2, 0), mask, 2);
1746 : : mask = vsetq_lane_u32(vgetq_lane_u32(f3, 0), mask, 3);
1747 : :
1748 : : /* Match against L2 ether timesync. */
1749 : : mask = vceqq_u32(mask, ptype);
1750 : : /* Convert from vector from scalar mask */
1751 : : res = vaddvq_u32(vandq_u32(mask, and_mask));
1752 : : res &= 0xF;
1753 : :
1754 : : if (res) {
1755 : : /* Fill in the ol_flags for any packets that
1756 : : * matched.
1757 : : */
1758 : : ol_flags0 |= ((res & 0x1) ? ts_olf : 0);
1759 : : ol_flags1 |= ((res & 0x2) ? ts_olf : 0);
1760 : : ol_flags2 |= ((res & 0x4) ? ts_olf : 0);
1761 : : ol_flags3 |= ((res & 0x8) ? ts_olf : 0);
1762 : :
1763 : : /* Update Rxq timestamp with the latest
1764 : : * timestamp.
1765 : : */
1766 : : tstamp->rx_ready = 1;
1767 : : tstamp->rx_tstamp = ts[31 - rte_clz32(res)];
1768 : : }
1769 : : }
1770 : :
1771 : : /* Form rearm_data with ol_flags */
1772 : : rearm0 = vsetq_lane_u64(ol_flags0, rearm0, 1);
1773 : : rearm1 = vsetq_lane_u64(ol_flags1, rearm1, 1);
1774 : : rearm2 = vsetq_lane_u64(ol_flags2, rearm2, 1);
1775 : : rearm3 = vsetq_lane_u64(ol_flags3, rearm3, 1);
1776 : :
1777 : : /* Update rx_descriptor_fields1 */
1778 : : vst1q_u64((uint64_t *)mbuf0->rx_descriptor_fields1, f0);
1779 : : vst1q_u64((uint64_t *)mbuf1->rx_descriptor_fields1, f1);
1780 : : vst1q_u64((uint64_t *)mbuf2->rx_descriptor_fields1, f2);
1781 : : vst1q_u64((uint64_t *)mbuf3->rx_descriptor_fields1, f3);
1782 : :
1783 : : /* Update rearm_data */
1784 : : vst1q_u64((uint64_t *)mbuf0->rearm_data, rearm0);
1785 : : vst1q_u64((uint64_t *)mbuf1->rearm_data, rearm1);
1786 : : vst1q_u64((uint64_t *)mbuf2->rearm_data, rearm2);
1787 : : vst1q_u64((uint64_t *)mbuf3->rearm_data, rearm3);
1788 : :
1789 : : if (flags & NIX_RX_MULTI_SEG_F || (flags & NIX_RX_REAS_F)) {
1790 : : /* Multi segment is enable build mseg list for
1791 : : * individual mbufs in scalar mode.
1792 : : */
1793 : : nix_cqe_xtract_mseg((union nix_rx_parse_u *)(CQE_PTR_OFF(cq0, 0, 8, flags)),
1794 : : mbuf0, mbuf_initializer, cpth0, sa_base, buf_sz, flags);
1795 : : nix_cqe_xtract_mseg((union nix_rx_parse_u *)(CQE_PTR_OFF(cq0, 1, 8, flags)),
1796 : : mbuf1, mbuf_initializer, cpth1, sa_base, buf_sz, flags);
1797 : : nix_cqe_xtract_mseg((union nix_rx_parse_u *)(CQE_PTR_OFF(cq0, 2, 8, flags)),
1798 : : mbuf2, mbuf_initializer, cpth2, sa_base, buf_sz, flags);
1799 : : nix_cqe_xtract_mseg((union nix_rx_parse_u *)(CQE_PTR_OFF(cq0, 3, 8, flags)),
1800 : : mbuf3, mbuf_initializer, cpth3, sa_base, buf_sz, flags);
1801 : : }
1802 : :
1803 : : /* Store the mbufs to rx_pkts */
1804 : : vst1q_u64((uint64_t *)&mbufs[packets], mbuf01);
1805 : : vst1q_u64((uint64_t *)&mbufs[packets + 2], mbuf23);
1806 : :
1807 : : nix_mbuf_validate_next(mbuf0);
1808 : : nix_mbuf_validate_next(mbuf1);
1809 : : nix_mbuf_validate_next(mbuf2);
1810 : : nix_mbuf_validate_next(mbuf3);
1811 : :
1812 : : packets += NIX_DESCS_PER_LOOP;
1813 : :
1814 : : if (!(flags & NIX_RX_VWQE_F)) {
1815 : : /* Advance head pointer and packets */
1816 : : head += NIX_DESCS_PER_LOOP;
1817 : : head &= qmask;
1818 : : }
1819 : :
1820 : : if (flags & NIX_RX_OFFLOAD_SECURITY_F) {
1821 : : /* Check if lmtline border is crossed and adjust lnum */
1822 : : if (loff > 15) {
1823 : : /* Update aura handle */
1824 : : *(uint64_t *)(laddr - 8) = (((uint64_t)(15 & 0x3) << 32) |
1825 : : roc_npa_aura_handle_to_aura(meta_aura));
1826 : : loff = loff - 15;
1827 : : shft += 3;
1828 : :
1829 : : lnum++;
1830 : : laddr = (uintptr_t)LMT_OFF(lbase, lnum, 8);
1831 : : /* Pick the pointer from 16th index and put it
1832 : : * at end of this new line.
1833 : : */
1834 : : *(uint64_t *)(laddr + (loff << 3) - 8) = *(uint64_t *)(laddr - 8);
1835 : : }
1836 : :
1837 : : /* Flush it when we are in 16th line and might
1838 : : * overflow it
1839 : : */
1840 : : if (lnum >= 15 && loff >= 12) {
1841 : : /* 16 LMT Line size m1 */
1842 : : uint64_t data = BIT_ULL(48) - 1;
1843 : :
1844 : : /* Update aura handle */
1845 : : *(uint64_t *)(laddr - 8) = (((uint64_t)(loff & 0x3) << 32) |
1846 : : roc_npa_aura_handle_to_aura(meta_aura));
1847 : :
1848 : : data = (data & ~(0x7UL << shft)) | (((uint64_t)loff >> 1) << shft);
1849 : :
1850 : : /* Send up to 16 lmt lines of pointers */
1851 : : nix_sec_flush_meta_burst(lmt_id, data, lnum + 1, meta_aura);
1852 : : rte_io_wmb();
1853 : : lnum = 0;
1854 : : loff = 0;
1855 : : shft = 0;
1856 : : /* First pointer starts at 8B offset */
1857 : : laddr = (uintptr_t)LMT_OFF(lbase, lnum, 8);
1858 : : }
1859 : : }
1860 : : }
1861 : :
1862 : : if (flags & NIX_RX_OFFLOAD_SECURITY_F && loff) {
1863 : : /* 16 LMT Line size m1 */
1864 : : uint64_t data = BIT_ULL(48) - 1;
1865 : :
1866 : : /* Update aura handle */
1867 : : *(uint64_t *)(laddr - 8) =
1868 : : (((uint64_t)(loff & 0x3) << 32) | roc_npa_aura_handle_to_aura(meta_aura));
1869 : :
1870 : : data = (data & ~(0x7UL << shft)) | (((uint64_t)loff >> 1) << shft);
1871 : :
1872 : : /* Send up to 16 lmt lines of pointers */
1873 : : nix_sec_flush_meta_burst(lmt_id, data, lnum + 1, meta_aura);
1874 : : if (flags & NIX_RX_VWQE_F)
1875 : : plt_io_wmb();
1876 : : }
1877 : :
1878 : : if (flags & NIX_RX_VWQE_F)
1879 : : return packets;
1880 : :
1881 : : rxq->head = head;
1882 : : rxq->available -= packets;
1883 : :
1884 : : rte_io_wmb();
1885 : : /* Free all the CQs that we've processed */
1886 : : plt_write64((rxq->wdata | packets), rxq->cq_door);
1887 : :
1888 : : if (unlikely(pkts_left))
1889 : : packets += cn20k_nix_recv_pkts(args, &mbufs[packets], pkts_left, flags);
1890 : :
1891 : : return packets;
1892 : : }
1893 : :
1894 : : #else
1895 : :
1896 : : static inline uint16_t
1897 : : cn20k_nix_recv_pkts_vector(void *args, struct rte_mbuf **mbufs, uint16_t pkts, const uint16_t flags,
1898 : : void *lookup_mem, struct cnxk_timesync_info *tstamp, uintptr_t lmt_base,
1899 : : uint64_t meta_aura)
1900 : : {
1901 : : RTE_SET_USED(args);
1902 : : RTE_SET_USED(mbufs);
1903 : : RTE_SET_USED(pkts);
1904 : : RTE_SET_USED(flags);
1905 : : RTE_SET_USED(lookup_mem);
1906 : : RTE_SET_USED(tstamp);
1907 : : RTE_SET_USED(lmt_base);
1908 : : RTE_SET_USED(meta_aura);
1909 : :
1910 : : return 0;
1911 : : }
1912 : :
1913 : : static __rte_always_inline uint16_t
1914 : : cn20k_nix_inj_pkts(struct rte_security_session **sess, struct cnxk_ethdev_inj_cfg *inj_cfg,
1915 : : struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
1916 : : {
1917 : : RTE_SET_USED(sess);
1918 : : RTE_SET_USED(inj_cfg);
1919 : : RTE_SET_USED(tx_pkts);
1920 : : RTE_SET_USED(nb_pkts);
1921 : : return 0;
1922 : : }
1923 : :
1924 : : #endif
1925 : :
1926 : : #define RSS_F NIX_RX_OFFLOAD_RSS_F
1927 : : #define PTYPE_F NIX_RX_OFFLOAD_PTYPE_F
1928 : : #define CKSUM_F NIX_RX_OFFLOAD_CHECKSUM_F
1929 : : #define MARK_F NIX_RX_OFFLOAD_MARK_UPDATE_F
1930 : : #define TS_F NIX_RX_OFFLOAD_TSTAMP_F
1931 : : #define RX_VLAN_F NIX_RX_OFFLOAD_VLAN_STRIP_F
1932 : : #define R_SEC_F NIX_RX_OFFLOAD_SECURITY_F
1933 : :
1934 : : /* [R_SEC_F] [RX_VLAN_F] [TS] [MARK] [CKSUM] [PTYPE] [RSS] */
1935 : : #define NIX_RX_FASTPATH_MODES_0_15 \
1936 : : R(no_offload, NIX_RX_OFFLOAD_NONE) \
1937 : : R(rss, RSS_F) \
1938 : : R(ptype, PTYPE_F) \
1939 : : R(ptype_rss, PTYPE_F | RSS_F) \
1940 : : R(cksum, CKSUM_F) \
1941 : : R(cksum_rss, CKSUM_F | RSS_F) \
1942 : : R(cksum_ptype, CKSUM_F | PTYPE_F) \
1943 : : R(cksum_ptype_rss, CKSUM_F | PTYPE_F | RSS_F) \
1944 : : R(mark, MARK_F) \
1945 : : R(mark_rss, MARK_F | RSS_F) \
1946 : : R(mark_ptype, MARK_F | PTYPE_F) \
1947 : : R(mark_ptype_rss, MARK_F | PTYPE_F | RSS_F) \
1948 : : R(mark_cksum, MARK_F | CKSUM_F) \
1949 : : R(mark_cksum_rss, MARK_F | CKSUM_F | RSS_F) \
1950 : : R(mark_cksum_ptype, MARK_F | CKSUM_F | PTYPE_F) \
1951 : : R(mark_cksum_ptype_rss, MARK_F | CKSUM_F | PTYPE_F | RSS_F)
1952 : :
1953 : : #define NIX_RX_FASTPATH_MODES_16_31 \
1954 : : R(ts, TS_F) \
1955 : : R(ts_rss, TS_F | RSS_F) \
1956 : : R(ts_ptype, TS_F | PTYPE_F) \
1957 : : R(ts_ptype_rss, TS_F | PTYPE_F | RSS_F) \
1958 : : R(ts_cksum, TS_F | CKSUM_F) \
1959 : : R(ts_cksum_rss, TS_F | CKSUM_F | RSS_F) \
1960 : : R(ts_cksum_ptype, TS_F | CKSUM_F | PTYPE_F) \
1961 : : R(ts_cksum_ptype_rss, TS_F | CKSUM_F | PTYPE_F | RSS_F) \
1962 : : R(ts_mark, TS_F | MARK_F) \
1963 : : R(ts_mark_rss, TS_F | MARK_F | RSS_F) \
1964 : : R(ts_mark_ptype, TS_F | MARK_F | PTYPE_F) \
1965 : : R(ts_mark_ptype_rss, TS_F | MARK_F | PTYPE_F | RSS_F) \
1966 : : R(ts_mark_cksum, TS_F | MARK_F | CKSUM_F) \
1967 : : R(ts_mark_cksum_rss, TS_F | MARK_F | CKSUM_F | RSS_F) \
1968 : : R(ts_mark_cksum_ptype, TS_F | MARK_F | CKSUM_F | PTYPE_F) \
1969 : : R(ts_mark_cksum_ptype_rss, TS_F | MARK_F | CKSUM_F | PTYPE_F | RSS_F)
1970 : :
1971 : : #define NIX_RX_FASTPATH_MODES_32_47 \
1972 : : R(vlan, RX_VLAN_F) \
1973 : : R(vlan_rss, RX_VLAN_F | RSS_F) \
1974 : : R(vlan_ptype, RX_VLAN_F | PTYPE_F) \
1975 : : R(vlan_ptype_rss, RX_VLAN_F | PTYPE_F | RSS_F) \
1976 : : R(vlan_cksum, RX_VLAN_F | CKSUM_F) \
1977 : : R(vlan_cksum_rss, RX_VLAN_F | CKSUM_F | RSS_F) \
1978 : : R(vlan_cksum_ptype, RX_VLAN_F | CKSUM_F | PTYPE_F) \
1979 : : R(vlan_cksum_ptype_rss, RX_VLAN_F | CKSUM_F | PTYPE_F | RSS_F) \
1980 : : R(vlan_mark, RX_VLAN_F | MARK_F) \
1981 : : R(vlan_mark_rss, RX_VLAN_F | MARK_F | RSS_F) \
1982 : : R(vlan_mark_ptype, RX_VLAN_F | MARK_F | PTYPE_F) \
1983 : : R(vlan_mark_ptype_rss, RX_VLAN_F | MARK_F | PTYPE_F | RSS_F) \
1984 : : R(vlan_mark_cksum, RX_VLAN_F | MARK_F | CKSUM_F) \
1985 : : R(vlan_mark_cksum_rss, RX_VLAN_F | MARK_F | CKSUM_F | RSS_F) \
1986 : : R(vlan_mark_cksum_ptype, RX_VLAN_F | MARK_F | CKSUM_F | PTYPE_F) \
1987 : : R(vlan_mark_cksum_ptype_rss, RX_VLAN_F | MARK_F | CKSUM_F | PTYPE_F | RSS_F)
1988 : :
1989 : : #define NIX_RX_FASTPATH_MODES_48_63 \
1990 : : R(vlan_ts, RX_VLAN_F | TS_F) \
1991 : : R(vlan_ts_rss, RX_VLAN_F | TS_F | RSS_F) \
1992 : : R(vlan_ts_ptype, RX_VLAN_F | TS_F | PTYPE_F) \
1993 : : R(vlan_ts_ptype_rss, RX_VLAN_F | TS_F | PTYPE_F | RSS_F) \
1994 : : R(vlan_ts_cksum, RX_VLAN_F | TS_F | CKSUM_F) \
1995 : : R(vlan_ts_cksum_rss, RX_VLAN_F | TS_F | CKSUM_F | RSS_F) \
1996 : : R(vlan_ts_cksum_ptype, RX_VLAN_F | TS_F | CKSUM_F | PTYPE_F) \
1997 : : R(vlan_ts_cksum_ptype_rss, RX_VLAN_F | TS_F | CKSUM_F | PTYPE_F | RSS_F) \
1998 : : R(vlan_ts_mark, RX_VLAN_F | TS_F | MARK_F) \
1999 : : R(vlan_ts_mark_rss, RX_VLAN_F | TS_F | MARK_F | RSS_F) \
2000 : : R(vlan_ts_mark_ptype, RX_VLAN_F | TS_F | MARK_F | PTYPE_F) \
2001 : : R(vlan_ts_mark_ptype_rss, RX_VLAN_F | TS_F | MARK_F | PTYPE_F | RSS_F) \
2002 : : R(vlan_ts_mark_cksum, RX_VLAN_F | TS_F | MARK_F | CKSUM_F) \
2003 : : R(vlan_ts_mark_cksum_rss, RX_VLAN_F | TS_F | MARK_F | CKSUM_F | RSS_F) \
2004 : : R(vlan_ts_mark_cksum_ptype, RX_VLAN_F | TS_F | MARK_F | CKSUM_F | PTYPE_F) \
2005 : : R(vlan_ts_mark_cksum_ptype_rss, RX_VLAN_F | TS_F | MARK_F | CKSUM_F | PTYPE_F | RSS_F)
2006 : :
2007 : : #define NIX_RX_FASTPATH_MODES_64_79 \
2008 : : R(sec, R_SEC_F) \
2009 : : R(sec_rss, R_SEC_F | RSS_F) \
2010 : : R(sec_ptype, R_SEC_F | PTYPE_F) \
2011 : : R(sec_ptype_rss, R_SEC_F | PTYPE_F | RSS_F) \
2012 : : R(sec_cksum, R_SEC_F | CKSUM_F) \
2013 : : R(sec_cksum_rss, R_SEC_F | CKSUM_F | RSS_F) \
2014 : : R(sec_cksum_ptype, R_SEC_F | CKSUM_F | PTYPE_F) \
2015 : : R(sec_cksum_ptype_rss, R_SEC_F | CKSUM_F | PTYPE_F | RSS_F) \
2016 : : R(sec_mark, R_SEC_F | MARK_F) \
2017 : : R(sec_mark_rss, R_SEC_F | MARK_F | RSS_F) \
2018 : : R(sec_mark_ptype, R_SEC_F | MARK_F | PTYPE_F) \
2019 : : R(sec_mark_ptype_rss, R_SEC_F | MARK_F | PTYPE_F | RSS_F) \
2020 : : R(sec_mark_cksum, R_SEC_F | MARK_F | CKSUM_F) \
2021 : : R(sec_mark_cksum_rss, R_SEC_F | MARK_F | CKSUM_F | RSS_F) \
2022 : : R(sec_mark_cksum_ptype, R_SEC_F | MARK_F | CKSUM_F | PTYPE_F) \
2023 : : R(sec_mark_cksum_ptype_rss, R_SEC_F | MARK_F | CKSUM_F | PTYPE_F | RSS_F)
2024 : :
2025 : : #define NIX_RX_FASTPATH_MODES_80_95 \
2026 : : R(sec_ts, R_SEC_F | TS_F) \
2027 : : R(sec_ts_rss, R_SEC_F | TS_F | RSS_F) \
2028 : : R(sec_ts_ptype, R_SEC_F | TS_F | PTYPE_F) \
2029 : : R(sec_ts_ptype_rss, R_SEC_F | TS_F | PTYPE_F | RSS_F) \
2030 : : R(sec_ts_cksum, R_SEC_F | TS_F | CKSUM_F) \
2031 : : R(sec_ts_cksum_rss, R_SEC_F | TS_F | CKSUM_F | RSS_F) \
2032 : : R(sec_ts_cksum_ptype, R_SEC_F | TS_F | CKSUM_F | PTYPE_F) \
2033 : : R(sec_ts_cksum_ptype_rss, R_SEC_F | TS_F | CKSUM_F | PTYPE_F | RSS_F) \
2034 : : R(sec_ts_mark, R_SEC_F | TS_F | MARK_F) \
2035 : : R(sec_ts_mark_rss, R_SEC_F | TS_F | MARK_F | RSS_F) \
2036 : : R(sec_ts_mark_ptype, R_SEC_F | TS_F | MARK_F | PTYPE_F) \
2037 : : R(sec_ts_mark_ptype_rss, R_SEC_F | TS_F | MARK_F | PTYPE_F | RSS_F) \
2038 : : R(sec_ts_mark_cksum, R_SEC_F | TS_F | MARK_F | CKSUM_F) \
2039 : : R(sec_ts_mark_cksum_rss, R_SEC_F | TS_F | MARK_F | CKSUM_F | RSS_F) \
2040 : : R(sec_ts_mark_cksum_ptype, R_SEC_F | TS_F | MARK_F | CKSUM_F | PTYPE_F) \
2041 : : R(sec_ts_mark_cksum_ptype_rss, R_SEC_F | TS_F | MARK_F | CKSUM_F | PTYPE_F | RSS_F)
2042 : :
2043 : : #define NIX_RX_FASTPATH_MODES_96_111 \
2044 : : R(sec_vlan, R_SEC_F | RX_VLAN_F) \
2045 : : R(sec_vlan_rss, R_SEC_F | RX_VLAN_F | RSS_F) \
2046 : : R(sec_vlan_ptype, R_SEC_F | RX_VLAN_F | PTYPE_F) \
2047 : : R(sec_vlan_ptype_rss, R_SEC_F | RX_VLAN_F | PTYPE_F | RSS_F) \
2048 : : R(sec_vlan_cksum, R_SEC_F | RX_VLAN_F | CKSUM_F) \
2049 : : R(sec_vlan_cksum_rss, R_SEC_F | RX_VLAN_F | CKSUM_F | RSS_F) \
2050 : : R(sec_vlan_cksum_ptype, R_SEC_F | RX_VLAN_F | CKSUM_F | PTYPE_F) \
2051 : : R(sec_vlan_cksum_ptype_rss, R_SEC_F | RX_VLAN_F | CKSUM_F | PTYPE_F | RSS_F) \
2052 : : R(sec_vlan_mark, R_SEC_F | RX_VLAN_F | MARK_F) \
2053 : : R(sec_vlan_mark_rss, R_SEC_F | RX_VLAN_F | MARK_F | RSS_F) \
2054 : : R(sec_vlan_mark_ptype, R_SEC_F | RX_VLAN_F | MARK_F | PTYPE_F) \
2055 : : R(sec_vlan_mark_ptype_rss, R_SEC_F | RX_VLAN_F | MARK_F | PTYPE_F | RSS_F) \
2056 : : R(sec_vlan_mark_cksum, R_SEC_F | RX_VLAN_F | MARK_F | CKSUM_F) \
2057 : : R(sec_vlan_mark_cksum_rss, R_SEC_F | RX_VLAN_F | MARK_F | CKSUM_F | RSS_F) \
2058 : : R(sec_vlan_mark_cksum_ptype, R_SEC_F | RX_VLAN_F | MARK_F | CKSUM_F | PTYPE_F) \
2059 : : R(sec_vlan_mark_cksum_ptype_rss, R_SEC_F | RX_VLAN_F | MARK_F | CKSUM_F | PTYPE_F | RSS_F)
2060 : :
2061 : : #define NIX_RX_FASTPATH_MODES_112_127 \
2062 : : R(sec_vlan_ts, R_SEC_F | RX_VLAN_F | TS_F) \
2063 : : R(sec_vlan_ts_rss, R_SEC_F | RX_VLAN_F | TS_F | RSS_F) \
2064 : : R(sec_vlan_ts_ptype, R_SEC_F | RX_VLAN_F | TS_F | PTYPE_F) \
2065 : : R(sec_vlan_ts_ptype_rss, R_SEC_F | RX_VLAN_F | TS_F | PTYPE_F | RSS_F) \
2066 : : R(sec_vlan_ts_cksum, R_SEC_F | RX_VLAN_F | TS_F | CKSUM_F) \
2067 : : R(sec_vlan_ts_cksum_rss, R_SEC_F | RX_VLAN_F | TS_F | CKSUM_F | RSS_F) \
2068 : : R(sec_vlan_ts_cksum_ptype, R_SEC_F | RX_VLAN_F | TS_F | CKSUM_F | PTYPE_F) \
2069 : : R(sec_vlan_ts_cksum_ptype_rss, R_SEC_F | RX_VLAN_F | TS_F | CKSUM_F | PTYPE_F | RSS_F) \
2070 : : R(sec_vlan_ts_mark, R_SEC_F | RX_VLAN_F | TS_F | MARK_F) \
2071 : : R(sec_vlan_ts_mark_rss, R_SEC_F | RX_VLAN_F | TS_F | MARK_F | RSS_F) \
2072 : : R(sec_vlan_ts_mark_ptype, R_SEC_F | RX_VLAN_F | TS_F | MARK_F | PTYPE_F) \
2073 : : R(sec_vlan_ts_mark_ptype_rss, R_SEC_F | RX_VLAN_F | TS_F | MARK_F | PTYPE_F | RSS_F) \
2074 : : R(sec_vlan_ts_mark_cksum, R_SEC_F | RX_VLAN_F | TS_F | MARK_F | CKSUM_F) \
2075 : : R(sec_vlan_ts_mark_cksum_rss, R_SEC_F | RX_VLAN_F | TS_F | MARK_F | CKSUM_F | RSS_F) \
2076 : : R(sec_vlan_ts_mark_cksum_ptype, R_SEC_F | RX_VLAN_F | TS_F | MARK_F | CKSUM_F | PTYPE_F) \
2077 : : R(sec_vlan_ts_mark_cksum_ptype_rss, \
2078 : : R_SEC_F | RX_VLAN_F | TS_F | MARK_F | CKSUM_F | PTYPE_F | RSS_F)
2079 : :
2080 : : #define NIX_RX_FASTPATH_MODES \
2081 : : NIX_RX_FASTPATH_MODES_0_15 \
2082 : : NIX_RX_FASTPATH_MODES_16_31 \
2083 : : NIX_RX_FASTPATH_MODES_32_47 \
2084 : : NIX_RX_FASTPATH_MODES_48_63 \
2085 : : NIX_RX_FASTPATH_MODES_64_79 \
2086 : : NIX_RX_FASTPATH_MODES_80_95 \
2087 : : NIX_RX_FASTPATH_MODES_96_111 \
2088 : : NIX_RX_FASTPATH_MODES_112_127
2089 : :
2090 : : #define R(name, flags) \
2091 : : uint16_t __rte_noinline __rte_hot cn20k_nix_recv_pkts_##name( \
2092 : : void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t pkts); \
2093 : : uint16_t __rte_noinline __rte_hot cn20k_nix_recv_pkts_mseg_##name( \
2094 : : void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t pkts); \
2095 : : uint16_t __rte_noinline __rte_hot cn20k_nix_recv_pkts_vec_##name( \
2096 : : void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t pkts); \
2097 : : uint16_t __rte_noinline __rte_hot cn20k_nix_recv_pkts_vec_mseg_##name( \
2098 : : void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t pkts); \
2099 : : uint16_t __rte_noinline __rte_hot cn20k_nix_recv_pkts_reas_##name( \
2100 : : void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t pkts); \
2101 : : uint16_t __rte_noinline __rte_hot cn20k_nix_recv_pkts_reas_mseg_##name( \
2102 : : void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t pkts); \
2103 : : uint16_t __rte_noinline __rte_hot cn20k_nix_recv_pkts_reas_vec_##name( \
2104 : : void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t pkts); \
2105 : : uint16_t __rte_noinline __rte_hot cn20k_nix_recv_pkts_reas_vec_mseg_##name( \
2106 : : void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t pkts);
2107 : :
2108 : : NIX_RX_FASTPATH_MODES
2109 : : #undef R
2110 : :
2111 : : #define NIX_RX_RECV(fn, flags) \
2112 : : uint16_t __rte_noinline __rte_hot fn(void *rx_queue, struct rte_mbuf **rx_pkts, \
2113 : : uint16_t pkts) \
2114 : : { \
2115 : : return cn20k_nix_recv_pkts(rx_queue, rx_pkts, pkts, (flags)); \
2116 : : }
2117 : :
2118 : : #define NIX_RX_RECV_MSEG(fn, flags) NIX_RX_RECV(fn, flags | NIX_RX_MULTI_SEG_F)
2119 : :
2120 : : #define NIX_RX_RECV_VEC(fn, flags) \
2121 : : uint16_t __rte_noinline __rte_hot fn(void *rx_queue, struct rte_mbuf **rx_pkts, \
2122 : : uint16_t pkts) \
2123 : : { \
2124 : : return cn20k_nix_recv_pkts_vector(rx_queue, rx_pkts, pkts, (flags), NULL, NULL, 0, \
2125 : : 0); \
2126 : : }
2127 : :
2128 : : #define NIX_RX_RECV_VEC_MSEG(fn, flags) NIX_RX_RECV_VEC(fn, flags | NIX_RX_MULTI_SEG_F)
2129 : :
2130 : : uint16_t __rte_noinline __rte_hot cn20k_nix_recv_pkts_all_offload(void *rx_queue,
2131 : : struct rte_mbuf **rx_pkts,
2132 : : uint16_t pkts);
2133 : :
2134 : : uint16_t __rte_noinline __rte_hot cn20k_nix_recv_pkts_vec_all_offload(void *rx_queue,
2135 : : struct rte_mbuf **rx_pkts,
2136 : : uint16_t pkts);
2137 : :
2138 : : uint16_t __rte_noinline __rte_hot cn20k_nix_recv_pkts_all_offload_tst(void *rx_queue,
2139 : : struct rte_mbuf **rx_pkts,
2140 : : uint16_t pkts);
2141 : :
2142 : : uint16_t __rte_noinline __rte_hot cn20k_nix_recv_pkts_vec_all_offload_tst(void *rx_queue,
2143 : : struct rte_mbuf **rx_pkts,
2144 : : uint16_t pkts);
2145 : :
2146 : : #endif /* __CN20K_RX_H__ */
|