1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(C) 2021 Marvell.
5 #ifndef __CN10K_WORKER_H__
6 #define __CN10K_WORKER_H__
10 #include "cn10k_cryptodev_ops.h"
11 #include "cnxk_ethdev.h"
12 #include "cnxk_eventdev.h"
13 #include "cnxk_worker.h"
15 #include "cn10k_ethdev.h"
21 static __rte_always_inline uint8_t
22 cn10k_sso_hws_new_event(struct cn10k_sso_hws *ws, const struct rte_event *ev)
24 const uint32_t tag = (uint32_t)ev->event;
25 const uint8_t new_tt = ev->sched_type;
26 const uint64_t event_ptr = ev->u64;
27 const uint16_t grp = ev->queue_id;
29 rte_atomic_thread_fence(__ATOMIC_ACQ_REL);
30 if (ws->xaq_lmt <= *ws->fc_mem)
33 cnxk_sso_hws_add_work(event_ptr, tag, new_tt,
34 ws->grp_base + (grp << 12));
38 static __rte_always_inline void
39 cn10k_sso_hws_fwd_swtag(struct cn10k_sso_hws *ws, const struct rte_event *ev)
41 const uint32_t tag = (uint32_t)ev->event;
42 const uint8_t new_tt = ev->sched_type;
43 const uint8_t cur_tt = CNXK_TT_FROM_TAG(ws->gw_rdata);
46 * cur_tt/new_tt SSO_TT_ORDERED SSO_TT_ATOMIC SSO_TT_UNTAGGED
48 * SSO_TT_ORDERED norm norm untag
49 * SSO_TT_ATOMIC norm norm untag
50 * SSO_TT_UNTAGGED norm norm NOOP
53 if (new_tt == SSO_TT_UNTAGGED) {
54 if (cur_tt != SSO_TT_UNTAGGED)
55 cnxk_sso_hws_swtag_untag(ws->base +
56 SSOW_LF_GWS_OP_SWTAG_UNTAG);
58 cnxk_sso_hws_swtag_norm(tag, new_tt,
59 ws->base + SSOW_LF_GWS_OP_SWTAG_NORM);
64 static __rte_always_inline void
65 cn10k_sso_hws_fwd_group(struct cn10k_sso_hws *ws, const struct rte_event *ev,
68 const uint32_t tag = (uint32_t)ev->event;
69 const uint8_t new_tt = ev->sched_type;
71 plt_write64(ev->u64, ws->base + SSOW_LF_GWS_OP_UPD_WQP_GRP1);
72 cnxk_sso_hws_swtag_desched(tag, new_tt, grp,
73 ws->base + SSOW_LF_GWS_OP_SWTAG_DESCHED);
76 static __rte_always_inline void
77 cn10k_sso_hws_forward_event(struct cn10k_sso_hws *ws,
78 const struct rte_event *ev)
80 const uint8_t grp = ev->queue_id;
82 /* Group hasn't changed, Use SWTAG to forward the event */
83 if (CNXK_GRP_FROM_TAG(ws->gw_rdata) == grp)
84 cn10k_sso_hws_fwd_swtag(ws, ev);
87 * Group has been changed for group based work pipelining,
88 * Use deschedule/add_work operation to transfer the event to
91 cn10k_sso_hws_fwd_group(ws, ev, grp);
94 static __rte_always_inline void
95 cn10k_wqe_to_mbuf(uint64_t wqe, const uint64_t __mbuf, uint8_t port_id,
96 const uint32_t tag, const uint32_t flags,
97 const void *const lookup_mem)
99 const uint64_t mbuf_init = 0x100010000ULL | RTE_PKTMBUF_HEADROOM |
100 (flags & NIX_RX_OFFLOAD_TSTAMP_F ? 8 : 0);
101 struct rte_mbuf *mbuf = (struct rte_mbuf *)__mbuf;
103 /* Mark mempool obj as "get" as it is alloc'ed by NIX */
104 RTE_MEMPOOL_CHECK_COOKIES(mbuf->pool, (void **)&mbuf, 1, 1);
106 cn10k_nix_cqe_to_mbuf((struct nix_cqe_hdr_s *)wqe, tag,
107 (struct rte_mbuf *)mbuf, lookup_mem,
108 mbuf_init | ((uint64_t)port_id) << 48, flags);
111 static __rte_always_inline void
112 cn10k_process_vwqe(uintptr_t vwqe, uint16_t port_id, const uint32_t flags,
113 void *lookup_mem, void *tstamp, uintptr_t lbase)
115 uint64_t mbuf_init = 0x100010000ULL | RTE_PKTMBUF_HEADROOM |
116 (flags & NIX_RX_OFFLOAD_TSTAMP_F ? 8 : 0);
117 struct rte_event_vector *vec;
118 uint64_t aura_handle, laddr;
119 uint16_t nb_mbufs, non_vec;
120 uint16_t lmt_id, d_off;
121 struct rte_mbuf **wqe;
122 struct rte_mbuf *mbuf;
127 mbuf_init |= ((uint64_t)port_id) << 48;
128 vec = (struct rte_event_vector *)vwqe;
131 rte_prefetch0(&vec->ptrs[0]);
132 #define OBJS_PER_CLINE (RTE_CACHE_LINE_SIZE / sizeof(void *))
133 for (i = OBJS_PER_CLINE; i < vec->nb_elem; i += OBJS_PER_CLINE)
134 rte_prefetch0(&vec->ptrs[i]);
136 nb_mbufs = RTE_ALIGN_FLOOR(vec->nb_elem, NIX_DESCS_PER_LOOP);
137 nb_mbufs = cn10k_nix_recv_pkts_vector(&mbuf_init, wqe, nb_mbufs,
138 flags | NIX_RX_VWQE_F, lookup_mem,
141 non_vec = vec->nb_elem - nb_mbufs;
143 if (flags & NIX_RX_OFFLOAD_SECURITY_F && non_vec) {
144 mbuf = (struct rte_mbuf *)((uintptr_t)wqe[0] -
145 sizeof(struct rte_mbuf));
146 /* Pick first mbuf's aura handle assuming all
147 * mbufs are from a vec and are from same RQ.
149 aura_handle = mbuf->pool->pool_id;
150 ROC_LMT_BASE_ID_GET(lbase, lmt_id);
153 d_off = ((uintptr_t)mbuf->buf_addr - (uintptr_t)mbuf);
154 d_off += (mbuf_init & 0xFFFF);
155 sa_base = cnxk_nix_sa_base_get(mbuf_init >> 48, lookup_mem);
156 sa_base &= ~(ROC_NIX_INL_SA_BASE_ALIGN - 1);
160 struct nix_cqe_hdr_s *cqe = (struct nix_cqe_hdr_s *)wqe[0];
163 mbuf = (struct rte_mbuf *)((char *)cqe -
164 sizeof(struct rte_mbuf));
166 /* Mark mempool obj as "get" as it is alloc'ed by NIX */
167 RTE_MEMPOOL_CHECK_COOKIES(mbuf->pool, (void **)&mbuf, 1, 1);
169 /* Translate meta to mbuf */
170 if (flags & NIX_RX_OFFLOAD_SECURITY_F) {
171 const uint64_t cq_w1 = *((const uint64_t *)cqe + 1);
172 const uint64_t cq_w5 = *((const uint64_t *)cqe + 5);
174 mbuf = nix_sec_meta_to_mbuf_sc(cq_w1, cq_w5, sa_base, laddr,
179 cn10k_nix_cqe_to_mbuf(cqe, cqe->tag, mbuf, lookup_mem,
181 /* Extracting tstamp, if PTP enabled*/
182 tstamp_ptr = *(uint64_t *)(((struct nix_wqe_hdr_s *)cqe) +
183 CNXK_SSO_WQE_SG_PTR);
184 cn10k_nix_mbuf_to_tstamp((struct rte_mbuf *)mbuf, tstamp,
185 flags & NIX_RX_OFFLOAD_TSTAMP_F,
186 (uint64_t *)tstamp_ptr);
187 wqe[0] = (struct rte_mbuf *)mbuf;
192 /* Free remaining meta buffers if any */
193 if (flags & NIX_RX_OFFLOAD_SECURITY_F && loff) {
194 nix_sec_flush_meta(laddr, lmt_id, loff, aura_handle);
199 static __rte_always_inline void
200 cn10k_sso_hws_post_process(struct cn10k_sso_hws *ws, uint64_t *u64,
201 const uint32_t flags)
205 u64[0] = (u64[0] & (0x3ull << 32)) << 6 |
206 (u64[0] & (0x3FFull << 36)) << 4 | (u64[0] & 0xffffffff);
207 if ((flags & CPT_RX_WQE_F) &&
208 (CNXK_EVENT_TYPE_FROM_TAG(u64[0]) == RTE_EVENT_TYPE_CRYPTODEV)) {
209 u64[1] = cn10k_cpt_crypto_adapter_dequeue(u64[1]);
210 } else if (CNXK_EVENT_TYPE_FROM_TAG(u64[0]) == RTE_EVENT_TYPE_ETHDEV) {
211 uint8_t port = CNXK_SUB_EVENT_FROM_TAG(u64[0]);
214 mbuf = u64[1] - sizeof(struct rte_mbuf);
215 rte_prefetch0((void *)mbuf);
216 if (flags & NIX_RX_OFFLOAD_SECURITY_F) {
217 const uint64_t mbuf_init =
218 0x100010000ULL | RTE_PKTMBUF_HEADROOM |
219 (flags & NIX_RX_OFFLOAD_TSTAMP_F ? 8 : 0);
228 m = (struct rte_mbuf *)mbuf;
229 d_off = (uintptr_t)(m->buf_addr) - (uintptr_t)m;
230 d_off += RTE_PKTMBUF_HEADROOM;
232 cq_w1 = *(uint64_t *)(u64[1] + 8);
233 cq_w5 = *(uint64_t *)(u64[1] + 40);
235 sa_base = cnxk_nix_sa_base_get(port, ws->lookup_mem);
236 sa_base &= ~(ROC_NIX_INL_SA_BASE_ALIGN - 1);
238 mbuf = (uint64_t)nix_sec_meta_to_mbuf_sc(
239 cq_w1, cq_w5, sa_base, (uintptr_t)&iova, &loff,
240 (struct rte_mbuf *)mbuf, d_off, flags,
241 mbuf_init | ((uint64_t)port) << 48);
243 roc_npa_aura_op_free(m->pool->pool_id, 0, iova);
246 u64[0] = CNXK_CLR_SUB_EVENT(u64[0]);
247 cn10k_wqe_to_mbuf(u64[1], mbuf, port, u64[0] & 0xFFFFF, flags,
249 /* Extracting tstamp, if PTP enabled*/
250 tstamp_ptr = *(uint64_t *)(((struct nix_wqe_hdr_s *)u64[1]) +
251 CNXK_SSO_WQE_SG_PTR);
252 cn10k_nix_mbuf_to_tstamp((struct rte_mbuf *)mbuf, ws->tstamp,
253 flags & NIX_RX_OFFLOAD_TSTAMP_F,
254 (uint64_t *)tstamp_ptr);
256 } else if (CNXK_EVENT_TYPE_FROM_TAG(u64[0]) ==
257 RTE_EVENT_TYPE_ETHDEV_VECTOR) {
258 uint8_t port = CNXK_SUB_EVENT_FROM_TAG(u64[0]);
259 __uint128_t vwqe_hdr = *(__uint128_t *)u64[1];
261 vwqe_hdr = ((vwqe_hdr >> 64) & 0xFFF) | BIT_ULL(31) |
262 ((vwqe_hdr & 0xFFFF) << 48) | ((uint64_t)port << 32);
263 *(uint64_t *)u64[1] = (uint64_t)vwqe_hdr;
264 cn10k_process_vwqe(u64[1], port, flags, ws->lookup_mem,
265 ws->tstamp, ws->lmt_base);
266 /* Mark vector mempool object as get */
267 RTE_MEMPOOL_CHECK_COOKIES(rte_mempool_from_obj((void *)u64[1]),
268 (void **)&u64[1], 1, 1);
272 static __rte_always_inline uint16_t
273 cn10k_sso_hws_get_work(struct cn10k_sso_hws *ws, struct rte_event *ev,
274 const uint32_t flags)
277 __uint128_t get_work;
281 gw.get_work = ws->gw_wdata;
282 #if defined(RTE_ARCH_ARM64) && !defined(__clang__)
284 PLT_CPU_FEATURE_PREAMBLE
285 "caspal %[wdata], %H[wdata], %[wdata], %H[wdata], [%[gw_loc]]\n"
286 : [wdata] "+r"(gw.get_work)
287 : [gw_loc] "r"(ws->base + SSOW_LF_GWS_OP_GET_WORK0)
290 plt_write64(gw.u64[0], ws->base + SSOW_LF_GWS_OP_GET_WORK0);
292 roc_load_pair(gw.u64[0], gw.u64[1],
293 ws->base + SSOW_LF_GWS_WQE0);
294 } while (gw.u64[0] & BIT_ULL(63));
296 ws->gw_rdata = gw.u64[0];
298 cn10k_sso_hws_post_process(ws, gw.u64, flags);
300 ev->event = gw.u64[0];
306 /* Used in cleaning up workslot. */
307 static __rte_always_inline uint16_t
308 cn10k_sso_hws_get_work_empty(struct cn10k_sso_hws *ws, struct rte_event *ev,
309 const uint32_t flags)
312 __uint128_t get_work;
316 #ifdef RTE_ARCH_ARM64
317 asm volatile(PLT_CPU_FEATURE_PREAMBLE
318 " ldp %[tag], %[wqp], [%[tag_loc]] \n"
319 " tbz %[tag], 63, done%= \n"
322 " ldp %[tag], %[wqp], [%[tag_loc]] \n"
323 " tbnz %[tag], 63, rty%= \n"
325 : [tag] "=&r"(gw.u64[0]), [wqp] "=&r"(gw.u64[1])
326 : [tag_loc] "r"(ws->base + SSOW_LF_GWS_WQE0)
330 roc_load_pair(gw.u64[0], gw.u64[1],
331 ws->base + SSOW_LF_GWS_WQE0);
332 } while (gw.u64[0] & BIT_ULL(63));
335 ws->gw_rdata = gw.u64[0];
337 cn10k_sso_hws_post_process(ws, gw.u64, flags);
339 ev->event = gw.u64[0];
345 /* CN10K Fastpath functions. */
346 uint16_t __rte_hot cn10k_sso_hws_enq(void *port, const struct rte_event *ev);
347 uint16_t __rte_hot cn10k_sso_hws_enq_burst(void *port,
348 const struct rte_event ev[],
350 uint16_t __rte_hot cn10k_sso_hws_enq_new_burst(void *port,
351 const struct rte_event ev[],
353 uint16_t __rte_hot cn10k_sso_hws_enq_fwd_burst(void *port,
354 const struct rte_event ev[],
356 uint16_t __rte_hot cn10k_sso_hws_ca_enq(void *port, struct rte_event ev[],
359 #define R(name, flags) \
360 uint16_t __rte_hot cn10k_sso_hws_deq_##name( \
361 void *port, struct rte_event *ev, uint64_t timeout_ticks); \
362 uint16_t __rte_hot cn10k_sso_hws_deq_burst_##name( \
363 void *port, struct rte_event ev[], uint16_t nb_events, \
364 uint64_t timeout_ticks); \
365 uint16_t __rte_hot cn10k_sso_hws_deq_tmo_##name( \
366 void *port, struct rte_event *ev, uint64_t timeout_ticks); \
367 uint16_t __rte_hot cn10k_sso_hws_deq_tmo_burst_##name( \
368 void *port, struct rte_event ev[], uint16_t nb_events, \
369 uint64_t timeout_ticks); \
370 uint16_t __rte_hot cn10k_sso_hws_deq_ca_##name( \
371 void *port, struct rte_event *ev, uint64_t timeout_ticks); \
372 uint16_t __rte_hot cn10k_sso_hws_deq_ca_burst_##name( \
373 void *port, struct rte_event ev[], uint16_t nb_events, \
374 uint64_t timeout_ticks); \
375 uint16_t __rte_hot cn10k_sso_hws_deq_tmo_ca_##name( \
376 void *port, struct rte_event *ev, uint64_t timeout_ticks); \
377 uint16_t __rte_hot cn10k_sso_hws_deq_tmo_ca_burst_##name( \
378 void *port, struct rte_event ev[], uint16_t nb_events, \
379 uint64_t timeout_ticks); \
380 uint16_t __rte_hot cn10k_sso_hws_deq_seg_##name( \
381 void *port, struct rte_event *ev, uint64_t timeout_ticks); \
382 uint16_t __rte_hot cn10k_sso_hws_deq_seg_burst_##name( \
383 void *port, struct rte_event ev[], uint16_t nb_events, \
384 uint64_t timeout_ticks); \
385 uint16_t __rte_hot cn10k_sso_hws_deq_tmo_seg_##name( \
386 void *port, struct rte_event *ev, uint64_t timeout_ticks); \
387 uint16_t __rte_hot cn10k_sso_hws_deq_tmo_seg_burst_##name( \
388 void *port, struct rte_event ev[], uint16_t nb_events, \
389 uint64_t timeout_ticks); \
390 uint16_t __rte_hot cn10k_sso_hws_deq_ca_seg_##name( \
391 void *port, struct rte_event *ev, uint64_t timeout_ticks); \
392 uint16_t __rte_hot cn10k_sso_hws_deq_ca_seg_burst_##name( \
393 void *port, struct rte_event ev[], uint16_t nb_events, \
394 uint64_t timeout_ticks); \
395 uint16_t __rte_hot cn10k_sso_hws_deq_tmo_ca_seg_##name( \
396 void *port, struct rte_event *ev, uint64_t timeout_ticks); \
397 uint16_t __rte_hot cn10k_sso_hws_deq_tmo_ca_seg_burst_##name( \
398 void *port, struct rte_event ev[], uint16_t nb_events, \
399 uint64_t timeout_ticks); \
400 uint16_t __rte_hot cn10k_sso_hws_reas_deq_##name( \
401 void *port, struct rte_event *ev, uint64_t timeout_ticks); \
402 uint16_t __rte_hot cn10k_sso_hws_reas_deq_burst_##name( \
403 void *port, struct rte_event ev[], uint16_t nb_events, \
404 uint64_t timeout_ticks); \
405 uint16_t __rte_hot cn10k_sso_hws_reas_deq_tmo_##name( \
406 void *port, struct rte_event *ev, uint64_t timeout_ticks); \
407 uint16_t __rte_hot cn10k_sso_hws_reas_deq_tmo_burst_##name( \
408 void *port, struct rte_event ev[], uint16_t nb_events, \
409 uint64_t timeout_ticks); \
410 uint16_t __rte_hot cn10k_sso_hws_reas_deq_ca_##name( \
411 void *port, struct rte_event *ev, uint64_t timeout_ticks); \
412 uint16_t __rte_hot cn10k_sso_hws_reas_deq_ca_burst_##name( \
413 void *port, struct rte_event ev[], uint16_t nb_events, \
414 uint64_t timeout_ticks); \
415 uint16_t __rte_hot cn10k_sso_hws_reas_deq_tmo_ca_##name( \
416 void *port, struct rte_event *ev, uint64_t timeout_ticks); \
417 uint16_t __rte_hot cn10k_sso_hws_reas_deq_tmo_ca_burst_##name( \
418 void *port, struct rte_event ev[], uint16_t nb_events, \
419 uint64_t timeout_ticks); \
420 uint16_t __rte_hot cn10k_sso_hws_reas_deq_seg_##name( \
421 void *port, struct rte_event *ev, uint64_t timeout_ticks); \
422 uint16_t __rte_hot cn10k_sso_hws_reas_deq_seg_burst_##name( \
423 void *port, struct rte_event ev[], uint16_t nb_events, \
424 uint64_t timeout_ticks); \
425 uint16_t __rte_hot cn10k_sso_hws_reas_deq_tmo_seg_##name( \
426 void *port, struct rte_event *ev, uint64_t timeout_ticks); \
427 uint16_t __rte_hot cn10k_sso_hws_reas_deq_tmo_seg_burst_##name( \
428 void *port, struct rte_event ev[], uint16_t nb_events, \
429 uint64_t timeout_ticks); \
430 uint16_t __rte_hot cn10k_sso_hws_reas_deq_ca_seg_##name( \
431 void *port, struct rte_event *ev, uint64_t timeout_ticks); \
432 uint16_t __rte_hot cn10k_sso_hws_reas_deq_ca_seg_burst_##name( \
433 void *port, struct rte_event ev[], uint16_t nb_events, \
434 uint64_t timeout_ticks); \
435 uint16_t __rte_hot cn10k_sso_hws_reas_deq_tmo_ca_seg_##name( \
436 void *port, struct rte_event *ev, uint64_t timeout_ticks); \
437 uint16_t __rte_hot cn10k_sso_hws_reas_deq_tmo_ca_seg_burst_##name( \
438 void *port, struct rte_event ev[], uint16_t nb_events, \
439 uint64_t timeout_ticks);
441 NIX_RX_FASTPATH_MODES
444 #define SSO_DEQ(fn, flags) \
445 uint16_t __rte_hot fn(void *port, struct rte_event *ev, \
446 uint64_t timeout_ticks) \
448 struct cn10k_sso_hws *ws = port; \
449 RTE_SET_USED(timeout_ticks); \
450 if (ws->swtag_req) { \
452 ws->gw_rdata = cnxk_sso_hws_swtag_wait( \
453 ws->base + SSOW_LF_GWS_WQE0); \
456 return cn10k_sso_hws_get_work(ws, ev, flags); \
459 #define SSO_DEQ_SEG(fn, flags) SSO_DEQ(fn, flags | NIX_RX_MULTI_SEG_F)
460 #define SSO_DEQ_CA(fn, flags) SSO_DEQ(fn, flags | CPT_RX_WQE_F)
461 #define SSO_DEQ_CA_SEG(fn, flags) SSO_DEQ_SEG(fn, flags | CPT_RX_WQE_F)
463 #define SSO_DEQ_TMO(fn, flags) \
464 uint16_t __rte_hot fn(void *port, struct rte_event *ev, \
465 uint64_t timeout_ticks) \
467 struct cn10k_sso_hws *ws = port; \
470 if (ws->swtag_req) { \
472 ws->gw_rdata = cnxk_sso_hws_swtag_wait( \
473 ws->base + SSOW_LF_GWS_WQE0); \
476 ret = cn10k_sso_hws_get_work(ws, ev, flags); \
477 for (iter = 1; iter < timeout_ticks && (ret == 0); iter++) \
478 ret = cn10k_sso_hws_get_work(ws, ev, flags); \
482 #define SSO_DEQ_TMO_SEG(fn, flags) SSO_DEQ_TMO(fn, flags | NIX_RX_MULTI_SEG_F)
483 #define SSO_DEQ_TMO_CA(fn, flags) SSO_DEQ_TMO(fn, flags | CPT_RX_WQE_F)
484 #define SSO_DEQ_TMO_CA_SEG(fn, flags) SSO_DEQ_TMO_SEG(fn, flags | CPT_RX_WQE_F)
486 #define SSO_CMN_DEQ_BURST(fnb, fn, flags) \
487 uint16_t __rte_hot fnb(void *port, struct rte_event ev[], \
488 uint16_t nb_events, uint64_t timeout_ticks) \
490 RTE_SET_USED(nb_events); \
491 return fn(port, ev, timeout_ticks); \
494 #define SSO_CMN_DEQ_SEG_BURST(fnb, fn, flags) \
495 uint16_t __rte_hot fnb(void *port, struct rte_event ev[], \
496 uint16_t nb_events, uint64_t timeout_ticks) \
498 RTE_SET_USED(nb_events); \
499 return fn(port, ev, timeout_ticks); \
502 static __rte_always_inline struct cn10k_eth_txq *
503 cn10k_sso_hws_xtract_meta(struct rte_mbuf *m, const uint64_t *txq_data)
505 return (struct cn10k_eth_txq
506 *)(txq_data[(txq_data[m->port] >> 48) +
507 rte_event_eth_tx_adapter_txq_get(m)] &
511 static __rte_always_inline void
512 cn10k_sso_txq_fc_wait(const struct cn10k_eth_txq *txq)
514 while ((uint64_t)txq->nb_sqb_bufs_adj <=
515 __atomic_load_n(txq->fc_mem, __ATOMIC_RELAXED))
519 static __rte_always_inline void
520 cn10k_sso_tx_one(struct cn10k_sso_hws *ws, struct rte_mbuf *m, uint64_t *cmd,
521 uint16_t lmt_id, uintptr_t lmt_addr, uint8_t sched_type,
522 const uint64_t *txq_data, const uint32_t flags)
524 uint8_t lnum = 0, loff = 0, shft = 0;
525 struct cn10k_eth_txq *txq;
531 txq = cn10k_sso_hws_xtract_meta(m, txq_data);
532 cn10k_nix_tx_skeleton(txq, cmd, flags, 0);
533 /* Perform header writes before barrier
536 if (flags & NIX_TX_OFFLOAD_TSO_F)
537 cn10k_nix_xmit_prepare_tso(m, flags);
539 cn10k_nix_xmit_prepare(m, cmd, flags, txq->lso_tun_fmt, &sec,
540 txq->mark_flag, txq->mark_fmt);
543 /* Prepare CPT instruction and get nixtx addr if
544 * it is for CPT on same lmtline.
546 if (flags & NIX_TX_OFFLOAD_SECURITY_F && sec)
547 cn10k_nix_prep_sec(m, cmd, &laddr, lmt_addr, &lnum, &loff,
548 &shft, txq->sa_base, flags);
550 /* Move NIX desc to LMT/NIXTX area */
551 cn10k_nix_xmit_mv_lmt_base(laddr, cmd, flags);
553 if (flags & NIX_TX_MULTI_SEG_F)
554 segdw = cn10k_nix_prepare_mseg(m, (uint64_t *)laddr, flags);
556 segdw = cn10k_nix_tx_ext_subs(flags) + 2;
558 cn10k_nix_xmit_prepare_tstamp(txq, laddr, m->ol_flags, segdw, flags);
559 if (flags & NIX_TX_OFFLOAD_SECURITY_F && sec)
560 pa = txq->cpt_io_addr | 3 << 4;
562 pa = txq->io_addr | ((segdw - 1) << 4);
564 if (!CNXK_TAG_IS_HEAD(ws->gw_rdata) && !sched_type)
565 ws->gw_rdata = roc_sso_hws_head_wait(ws->base);
567 cn10k_sso_txq_fc_wait(txq);
568 roc_lmt_submit_steorl(lmt_id, pa);
571 static __rte_always_inline void
572 cn10k_sso_vwqe_split_tx(struct cn10k_sso_hws *ws, struct rte_mbuf **mbufs,
573 uint16_t nb_mbufs, uint64_t *cmd, uint16_t lmt_id,
574 uintptr_t lmt_addr, uint8_t sched_type,
575 const uint64_t *txq_data, const uint32_t flags)
577 uint16_t port[4], queue[4];
578 uint16_t i, j, pkts, scalar;
579 struct cn10k_eth_txq *txq;
581 scalar = nb_mbufs & (NIX_DESCS_PER_LOOP - 1);
582 pkts = RTE_ALIGN_FLOOR(nb_mbufs, NIX_DESCS_PER_LOOP);
584 for (i = 0; i < pkts; i += NIX_DESCS_PER_LOOP) {
585 port[0] = mbufs[i]->port;
586 port[1] = mbufs[i + 1]->port;
587 port[2] = mbufs[i + 2]->port;
588 port[3] = mbufs[i + 3]->port;
590 queue[0] = rte_event_eth_tx_adapter_txq_get(mbufs[i]);
591 queue[1] = rte_event_eth_tx_adapter_txq_get(mbufs[i + 1]);
592 queue[2] = rte_event_eth_tx_adapter_txq_get(mbufs[i + 2]);
593 queue[3] = rte_event_eth_tx_adapter_txq_get(mbufs[i + 3]);
595 if (((port[0] ^ port[1]) & (port[2] ^ port[3])) ||
596 ((queue[0] ^ queue[1]) & (queue[2] ^ queue[3]))) {
597 for (j = 0; j < 4; j++)
598 cn10k_sso_tx_one(ws, mbufs[i + j], cmd, lmt_id,
599 lmt_addr, sched_type, txq_data,
602 txq = (struct cn10k_eth_txq
603 *)(txq_data[(txq_data[port[0]] >> 48) +
606 cn10k_nix_xmit_pkts_vector(txq, (uint64_t *)ws,
608 flags | NIX_TX_VWQE_F);
614 for (i = 0; i < scalar; i++) {
615 cn10k_sso_tx_one(ws, mbufs[i], cmd, lmt_id, lmt_addr,
616 sched_type, txq_data, flags);
620 static __rte_always_inline uint16_t
621 cn10k_sso_hws_event_tx(struct cn10k_sso_hws *ws, struct rte_event *ev,
622 uint64_t *cmd, const uint64_t *txq_data,
623 const uint32_t flags)
625 struct cn10k_eth_txq *txq;
630 lmt_addr = ws->lmt_base;
631 ROC_LMT_BASE_ID_GET(lmt_addr, lmt_id);
633 if (ev->event_type & RTE_EVENT_TYPE_VECTOR) {
634 struct rte_mbuf **mbufs = ev->vec->mbufs;
635 uint64_t meta = *(uint64_t *)ev->vec;
637 if (meta & BIT(31)) {
638 txq = (struct cn10k_eth_txq
639 *)(txq_data[(txq_data[meta >> 32] >>
644 cn10k_nix_xmit_pkts_vector(txq, (uint64_t *)ws, mbufs,
646 flags | NIX_TX_VWQE_F);
648 cn10k_sso_vwqe_split_tx(
649 ws, mbufs, meta & 0xFFFF, cmd, lmt_id, lmt_addr,
650 ev->sched_type, txq_data, flags);
652 rte_mempool_put(rte_mempool_from_obj(ev->vec), ev->vec);
658 cn10k_sso_tx_one(ws, m, cmd, lmt_id, lmt_addr, ev->sched_type, txq_data,
664 #define T(name, sz, flags) \
665 uint16_t __rte_hot cn10k_sso_hws_tx_adptr_enq_##name( \
666 void *port, struct rte_event ev[], uint16_t nb_events); \
667 uint16_t __rte_hot cn10k_sso_hws_tx_adptr_enq_seg_##name( \
668 void *port, struct rte_event ev[], uint16_t nb_events);
670 NIX_TX_FASTPATH_MODES
673 #define SSO_TX(fn, sz, flags) \
674 uint16_t __rte_hot fn(void *port, struct rte_event ev[], \
675 uint16_t nb_events) \
677 struct cn10k_sso_hws *ws = port; \
679 RTE_SET_USED(nb_events); \
680 return cn10k_sso_hws_event_tx( \
681 ws, &ev[0], cmd, (const uint64_t *)ws->tx_adptr_data, \
685 #define SSO_TX_SEG(fn, sz, flags) \
686 uint16_t __rte_hot fn(void *port, struct rte_event ev[], \
687 uint16_t nb_events) \
689 uint64_t cmd[(sz) + CNXK_NIX_TX_MSEG_SG_DWORDS - 2]; \
690 struct cn10k_sso_hws *ws = port; \
691 RTE_SET_USED(nb_events); \
692 return cn10k_sso_hws_event_tx( \
693 ws, &ev[0], cmd, (const uint64_t *)ws->tx_adptr_data, \
694 (flags) | NIX_TX_MULTI_SEG_F); \