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