LCOV - code coverage report
Current view: top level - drivers/event/cnxk - cn9k_worker.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 78 0.0 %
Date: 2025-02-01 18:54:23 Functions: 0 1 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 94 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(C) 2021 Marvell.
       3                 :            :  */
       4                 :            : 
       5                 :            : #ifndef __CN9K_WORKER_H__
       6                 :            : #define __CN9K_WORKER_H__
       7                 :            : 
       8                 :            : #include <rte_eventdev.h>
       9                 :            : #include <rte_vect.h>
      10                 :            : 
      11                 :            : #include "cnxk_ethdev.h"
      12                 :            : #include "cnxk_eventdev.h"
      13                 :            : #include "cnxk_worker.h"
      14                 :            : #include "cnxk_dma_event_dp.h"
      15                 :            : #include "cn9k_cryptodev_ops.h"
      16                 :            : 
      17                 :            : #include "cn9k_ethdev.h"
      18                 :            : #include "cn9k_rx.h"
      19                 :            : #include "cn9k_tx.h"
      20                 :            : 
      21                 :            : /* SSO Operations */
      22                 :            : 
      23                 :            : static __rte_always_inline uint8_t
      24                 :            : cn9k_sso_hws_new_event(struct cn9k_sso_hws *ws, const struct rte_event *ev)
      25                 :            : {
      26                 :          0 :         const uint32_t tag = (uint32_t)ev->event;
      27                 :          0 :         const uint8_t new_tt = ev->sched_type;
      28                 :          0 :         const uint64_t event_ptr = ev->u64;
      29   [ #  #  #  # ]:          0 :         const uint16_t grp = ev->queue_id;
      30                 :            : 
      31                 :            :         rte_atomic_thread_fence(rte_memory_order_acq_rel);
      32   [ #  #  #  # ]:          0 :         if (ws->xaq_lmt <= *ws->fc_mem)
      33                 :            :                 return 0;
      34                 :            : 
      35                 :          0 :         cnxk_sso_hws_add_work(event_ptr, tag, new_tt,
      36                 :          0 :                               ws->grp_base + (grp << 12));
      37                 :          0 :         return 1;
      38                 :            : }
      39                 :            : 
      40                 :            : static __rte_always_inline void
      41                 :            : cn9k_sso_hws_fwd_swtag(uint64_t base, const struct rte_event *ev)
      42                 :            : {
      43                 :          0 :         const uint32_t tag = (uint32_t)ev->event;
      44   [ #  #  #  #  :          0 :         const uint8_t new_tt = ev->sched_type;
             #  #  #  # ]
      45                 :          0 :         const uint8_t cur_tt =
      46                 :          0 :                 CNXK_TT_FROM_TAG(plt_read64(base + SSOW_LF_GWS_TAG));
      47                 :            : 
      48                 :            :         /* CNXK model
      49                 :            :          * cur_tt/new_tt     SSO_TT_ORDERED SSO_TT_ATOMIC SSO_TT_UNTAGGED
      50                 :            :          *
      51                 :            :          * SSO_TT_ORDERED        norm           norm             untag
      52                 :            :          * SSO_TT_ATOMIC         norm           norm               untag
      53                 :            :          * SSO_TT_UNTAGGED       norm           norm             NOOP
      54                 :            :          */
      55                 :            : 
      56   [ #  #  #  #  :          0 :         if (new_tt == SSO_TT_UNTAGGED) {
             #  #  #  # ]
      57   [ #  #  #  #  :          0 :                 if (cur_tt != SSO_TT_UNTAGGED)
             #  #  #  # ]
      58                 :          0 :                         cnxk_sso_hws_swtag_untag(base +
      59                 :            :                                                  SSOW_LF_GWS_OP_SWTAG_UNTAG);
      60                 :            :         } else {
      61                 :            :                 cnxk_sso_hws_swtag_norm(tag, new_tt,
      62                 :          0 :                                         base + SSOW_LF_GWS_OP_SWTAG_NORM);
      63                 :            :         }
      64                 :            : }
      65                 :            : 
      66                 :            : static __rte_always_inline void
      67                 :            : cn9k_sso_hws_new_event_wait(struct cn9k_sso_hws *ws, const struct rte_event *ev)
      68                 :            : {
      69                 :          0 :         const uint32_t tag = (uint32_t)ev->event;
      70                 :          0 :         const uint8_t new_tt = ev->sched_type;
      71                 :          0 :         const uint64_t event_ptr = ev->u64;
      72                 :          0 :         const uint16_t grp = ev->queue_id;
      73                 :            : 
      74   [ #  #  #  # ]:          0 :         while (ws->xaq_lmt <= rte_atomic_load_explicit(ws->fc_mem, rte_memory_order_relaxed))
      75                 :            :                 ;
      76                 :            : 
      77                 :          0 :         cnxk_sso_hws_add_work(event_ptr, tag, new_tt,
      78                 :          0 :                               ws->grp_base + (grp << 12));
      79                 :          0 : }
      80                 :            : 
      81                 :            : static __rte_always_inline void
      82                 :            : cn9k_sso_hws_forward_event(struct cn9k_sso_hws *ws, const struct rte_event *ev)
      83                 :            : {
      84                 :          0 :         const uint8_t grp = ev->queue_id;
      85                 :            : 
      86                 :            :         /* Group hasn't changed, Use SWTAG to forward the event */
      87   [ #  #  #  # ]:          0 :         if (CNXK_GRP_FROM_TAG(plt_read64(ws->base + SSOW_LF_GWS_TAG)) == grp) {
      88                 :            :                 cn9k_sso_hws_fwd_swtag(ws->base, ev);
      89                 :          0 :                 ws->swtag_req = 1;
      90                 :            :         } else {
      91                 :            :                 /*
      92                 :            :                  * Group has been changed for group based work pipelining,
      93                 :            :                  * Use add_work operation to transfer the event to
      94                 :            :                  * new group/core
      95                 :            :                  */
      96                 :            :                 rte_atomic_thread_fence(rte_memory_order_release);
      97                 :          0 :                 roc_sso_hws_head_wait(ws->base);
      98                 :            :                 cn9k_sso_hws_new_event_wait(ws, ev);
      99                 :            :         }
     100                 :            : }
     101                 :            : 
     102                 :            : /* Dual ws ops. */
     103                 :            : 
     104                 :            : static __rte_always_inline uint8_t
     105                 :            : cn9k_sso_hws_dual_new_event(struct cn9k_sso_hws_dual *dws,
     106                 :            :                             const struct rte_event *ev)
     107                 :            : {
     108                 :          0 :         const uint32_t tag = (uint32_t)ev->event;
     109                 :          0 :         const uint8_t new_tt = ev->sched_type;
     110                 :          0 :         const uint64_t event_ptr = ev->u64;
     111   [ #  #  #  # ]:          0 :         const uint16_t grp = ev->queue_id;
     112                 :            : 
     113                 :            :         rte_atomic_thread_fence(rte_memory_order_acq_rel);
     114   [ #  #  #  # ]:          0 :         if (dws->xaq_lmt <= *dws->fc_mem)
     115                 :            :                 return 0;
     116                 :            : 
     117                 :          0 :         cnxk_sso_hws_add_work(event_ptr, tag, new_tt,
     118                 :          0 :                               dws->grp_base + (grp << 12));
     119                 :          0 :         return 1;
     120                 :            : }
     121                 :            : 
     122                 :            : static __rte_always_inline void
     123                 :            : cn9k_sso_hws_dual_new_event_wait(struct cn9k_sso_hws_dual *dws,
     124                 :            :                                  const struct rte_event *ev)
     125                 :            : {
     126                 :          0 :         const uint32_t tag = (uint32_t)ev->event;
     127                 :          0 :         const uint8_t new_tt = ev->sched_type;
     128                 :          0 :         const uint64_t event_ptr = ev->u64;
     129                 :          0 :         const uint16_t grp = ev->queue_id;
     130                 :            : 
     131   [ #  #  #  # ]:          0 :         while (dws->xaq_lmt <= rte_atomic_load_explicit(dws->fc_mem, rte_memory_order_relaxed))
     132                 :            :                 ;
     133                 :            : 
     134                 :          0 :         cnxk_sso_hws_add_work(event_ptr, tag, new_tt,
     135                 :          0 :                               dws->grp_base + (grp << 12));
     136                 :          0 : }
     137                 :            : 
     138                 :            : static __rte_always_inline void
     139                 :            : cn9k_sso_hws_dual_forward_event(struct cn9k_sso_hws_dual *dws, uint64_t base,
     140                 :            :                                 const struct rte_event *ev)
     141                 :            : {
     142                 :          0 :         const uint8_t grp = ev->queue_id;
     143                 :            : 
     144                 :            :         /* Group hasn't changed, Use SWTAG to forward the event */
     145   [ #  #  #  # ]:          0 :         if (CNXK_GRP_FROM_TAG(plt_read64(base + SSOW_LF_GWS_TAG)) == grp) {
     146                 :            :                 cn9k_sso_hws_fwd_swtag(base, ev);
     147                 :          0 :                 dws->swtag_req = 1;
     148                 :            :         } else {
     149                 :            :                 /*
     150                 :            :                  * Group has been changed for group based work pipelining,
     151                 :            :                  * Use add_work operation to transfer the event to
     152                 :            :                  * new group/core
     153                 :            :                  */
     154                 :            :                 rte_atomic_thread_fence(rte_memory_order_release);
     155                 :            :                 roc_sso_hws_head_wait(base);
     156                 :            :                 cn9k_sso_hws_dual_new_event_wait(dws, ev);
     157                 :            :         }
     158                 :            : }
     159                 :            : 
     160                 :            : static __rte_always_inline void
     161                 :            : cn9k_wqe_to_mbuf(uint64_t wqe, const uint64_t mbuf, uint8_t port_id,
     162                 :            :                  const uint32_t tag, const uint32_t flags,
     163                 :            :                  const void *const lookup_mem)
     164                 :            : {
     165                 :          0 :         const uint64_t mbuf_init = 0x100010000ULL | RTE_PKTMBUF_HEADROOM |
     166                 :          0 :                                    (flags & NIX_RX_OFFLOAD_TSTAMP_F ? 8 : 0);
     167                 :            : 
     168                 :          0 :         cn9k_nix_cqe_to_mbuf((struct nix_cqe_hdr_s *)wqe, tag,
     169                 :            :                              (struct rte_mbuf *)mbuf, lookup_mem,
     170                 :          0 :                              mbuf_init | ((uint64_t)port_id) << 48, flags);
     171                 :            : }
     172                 :            : 
     173                 :            : static void
     174                 :          0 : cn9k_sso_process_tstamp(uint64_t u64, uint64_t mbuf,
     175                 :            :                         struct cnxk_timesync_info *tstamp)
     176                 :            : {
     177                 :            :         uint64_t tstamp_ptr;
     178                 :            :         uint8_t laptr;
     179                 :            : 
     180                 :          0 :         laptr = (uint8_t) *
     181                 :          0 :                 (uint64_t *)(u64 + (CNXK_SSO_WQE_LAYR_PTR * sizeof(uint64_t)));
     182         [ #  # ]:          0 :         if (laptr == sizeof(uint64_t)) {
     183                 :            :                 /* Extracting tstamp, if PTP enabled*/
     184                 :          0 :                 tstamp_ptr = *(uint64_t *)(((struct nix_wqe_hdr_s *)u64) +
     185                 :            :                                            CNXK_SSO_WQE_SG_PTR);
     186         [ #  # ]:          0 :                 cn9k_nix_mbuf_to_tstamp((struct rte_mbuf *)mbuf, tstamp, true,
     187                 :            :                                         (uint64_t *)tstamp_ptr);
     188                 :            :         }
     189                 :          0 : }
     190                 :            : 
     191                 :            : static __rte_always_inline void
     192                 :            : cn9k_sso_hws_post_process(uint64_t *u64, uint64_t mbuf, const uint32_t flags,
     193                 :            :                           const void *const lookup_mem,
     194                 :            :                           struct cnxk_timesync_info **tstamp)
     195                 :            : {
     196                 :          0 :         u64[0] = (u64[0] & (0x3ull << 32)) << 6 |
     197                 :          0 :                  (u64[0] & (0x3FFull << 36)) << 4 | (u64[0] & 0xffffffff);
     198   [ #  #  #  # ]:          0 :         if (CNXK_EVENT_TYPE_FROM_TAG(u64[0]) == RTE_EVENT_TYPE_CRYPTODEV) {
     199                 :          0 :                 u64[1] = cn9k_cpt_crypto_adapter_dequeue(u64[1]);
     200   [ #  #  #  # ]:          0 :         } else if (CNXK_EVENT_TYPE_FROM_TAG(u64[0]) == RTE_EVENT_TYPE_ETHDEV) {
     201                 :          0 :                 uint8_t port = CNXK_SUB_EVENT_FROM_TAG(u64[0]);
     202                 :            : 
     203                 :          0 :                 u64[0] = CNXK_CLR_SUB_EVENT(u64[0]);
     204   [ #  #  #  # ]:          0 :                 cn9k_wqe_to_mbuf(u64[1], mbuf, port, u64[0] & 0xFFFFF, flags,
     205                 :            :                                  lookup_mem);
     206   [ #  #  #  # ]:          0 :                 if (flags & NIX_RX_OFFLOAD_TSTAMP_F)
     207                 :          0 :                         cn9k_sso_process_tstamp(u64[1], mbuf, tstamp[port]);
     208                 :            :                 u64[1] = mbuf;
     209   [ #  #  #  # ]:          0 :         } else if (CNXK_EVENT_TYPE_FROM_TAG(u64[0]) == RTE_EVENT_TYPE_DMADEV) {
     210                 :          0 :                 u64[1] = cnxk_dma_adapter_dequeue(u64[1]);
     211                 :            :         }
     212                 :            : }
     213                 :            : 
     214                 :            : static __rte_always_inline uint16_t
     215                 :            : cn9k_sso_hws_dual_get_work(uint64_t base, uint64_t pair_base,
     216                 :            :                            struct rte_event *ev, const uint32_t flags,
     217                 :            :                            struct cn9k_sso_hws_dual *dws)
     218                 :            : {
     219                 :            :         union {
     220                 :            :                 __uint128_t get_work;
     221                 :            :                 uint64_t u64[2];
     222                 :            :         } gw;
     223                 :            :         uint64_t mbuf;
     224                 :            : 
     225                 :            :         if (flags & NIX_RX_OFFLOAD_PTYPE_F)
     226                 :            :                 rte_prefetch_non_temporal(dws->lookup_mem);
     227                 :            : #ifdef RTE_ARCH_ARM64
     228                 :            :         asm volatile(PLT_CPU_FEATURE_PREAMBLE
     229                 :            :                      ".Lrty%=:                                     \n"
     230                 :            :                      "             ldr %[tag], [%[tag_loc]]        \n"
     231                 :            :                      "             ldr %[wqp], [%[wqp_loc]]        \n"
     232                 :            :                      "             tbnz %[tag], 63, .Lrty%=        \n"
     233                 :            :                      ".Ldone%=:    str %[gw], [%[pong]]            \n"
     234                 :            :                      "             dmb ld                          \n"
     235                 :            :                      "             sub %[mbuf], %[wqp], #0x80      \n"
     236                 :            :                      "             prfm pldl1keep, [%[mbuf]]       \n"
     237                 :            :                      : [tag] "=&r"(gw.u64[0]), [wqp] "=&r"(gw.u64[1]),
     238                 :            :                        [mbuf] "=&r"(mbuf)
     239                 :            :                      : [tag_loc] "r"(base + SSOW_LF_GWS_TAG),
     240                 :            :                        [wqp_loc] "r"(base + SSOW_LF_GWS_WQP),
     241                 :            :                        [gw] "r"(dws->gw_wdata),
     242                 :            :                        [pong] "r"(pair_base + SSOW_LF_GWS_OP_GET_WORK0));
     243                 :            : #else
     244                 :            :         gw.u64[0] = plt_read64(base + SSOW_LF_GWS_TAG);
     245                 :            :         while ((BIT_ULL(63)) & gw.u64[0])
     246                 :            :                 gw.u64[0] = plt_read64(base + SSOW_LF_GWS_TAG);
     247                 :            :         gw.u64[1] = plt_read64(base + SSOW_LF_GWS_WQP);
     248                 :            :         plt_write64(dws->gw_wdata, pair_base + SSOW_LF_GWS_OP_GET_WORK0);
     249                 :            :         mbuf = (uint64_t)((char *)gw.u64[1] - sizeof(struct rte_mbuf));
     250                 :            : #endif
     251                 :            : 
     252                 :            :         if (gw.u64[1])
     253                 :            :                 cn9k_sso_hws_post_process(gw.u64, mbuf, flags, dws->lookup_mem,
     254                 :            :                                           dws->tstamp);
     255                 :            : 
     256                 :            :         ev->event = gw.u64[0];
     257                 :            :         ev->u64 = gw.u64[1];
     258                 :            : 
     259                 :            :         return !!gw.u64[1];
     260                 :            : }
     261                 :            : 
     262                 :            : static __rte_always_inline uint16_t
     263                 :            : cn9k_sso_hws_get_work(struct cn9k_sso_hws *ws, struct rte_event *ev,
     264                 :            :                       const uint32_t flags, const void *const lookup_mem)
     265                 :            : {
     266                 :            :         union {
     267                 :            :                 __uint128_t get_work;
     268                 :            :                 uint64_t u64[2];
     269                 :            :         } gw;
     270                 :            :         uint64_t mbuf;
     271                 :            : 
     272                 :            :         plt_write64(ws->gw_wdata, ws->base + SSOW_LF_GWS_OP_GET_WORK0);
     273                 :            : 
     274                 :            :         if (flags & NIX_RX_OFFLOAD_PTYPE_F)
     275                 :            :                 rte_prefetch_non_temporal(lookup_mem);
     276                 :            : #ifdef RTE_ARCH_ARM64
     277                 :            :         asm volatile(PLT_CPU_FEATURE_PREAMBLE
     278                 :            :                      "             ldr %[tag], [%[tag_loc]]        \n"
     279                 :            :                      "             ldr %[wqp], [%[wqp_loc]]        \n"
     280                 :            :                      "             tbz %[tag], 63, .Ldone%=        \n"
     281                 :            :                      "             sevl                            \n"
     282                 :            :                      ".Lrty%=:     wfe                             \n"
     283                 :            :                      "             ldr %[tag], [%[tag_loc]]        \n"
     284                 :            :                      "             ldr %[wqp], [%[wqp_loc]]        \n"
     285                 :            :                      "             tbnz %[tag], 63, .Lrty%=        \n"
     286                 :            :                      ".Ldone%=:    dmb ld                          \n"
     287                 :            :                      "             sub %[mbuf], %[wqp], #0x80      \n"
     288                 :            :                      "             prfm pldl1keep, [%[mbuf]]       \n"
     289                 :            :                      : [tag] "=&r"(gw.u64[0]), [wqp] "=&r"(gw.u64[1]),
     290                 :            :                        [mbuf] "=&r"(mbuf)
     291                 :            :                      : [tag_loc] "r"(ws->base + SSOW_LF_GWS_TAG),
     292                 :            :                        [wqp_loc] "r"(ws->base + SSOW_LF_GWS_WQP));
     293                 :            : #else
     294                 :            :         gw.u64[0] = plt_read64(ws->base + SSOW_LF_GWS_TAG);
     295                 :            :         while ((BIT_ULL(63)) & gw.u64[0])
     296                 :            :                 gw.u64[0] = plt_read64(ws->base + SSOW_LF_GWS_TAG);
     297                 :            : 
     298                 :            :         gw.u64[1] = plt_read64(ws->base + SSOW_LF_GWS_WQP);
     299                 :            :         mbuf = (uint64_t)((char *)gw.u64[1] - sizeof(struct rte_mbuf));
     300                 :            : #endif
     301                 :            : 
     302                 :            :         if (gw.u64[1])
     303                 :            :                 cn9k_sso_hws_post_process(gw.u64, mbuf, flags, lookup_mem,
     304                 :            :                                           ws->tstamp);
     305                 :            : 
     306                 :            :         ev->event = gw.u64[0];
     307                 :            :         ev->u64 = gw.u64[1];
     308                 :            : 
     309                 :            :         return !!gw.u64[1];
     310                 :            : }
     311                 :            : 
     312                 :            : /* Used in cleaning up workslot. */
     313                 :            : static __rte_always_inline uint16_t
     314                 :            : cn9k_sso_hws_get_work_empty(uint64_t base, struct rte_event *ev,
     315                 :            :                             const uint32_t flags, void *lookup_mem,
     316                 :            :                             struct cnxk_timesync_info **tstamp)
     317                 :            : {
     318                 :            :         union {
     319                 :            :                 __uint128_t get_work;
     320                 :            :                 uint64_t u64[2];
     321                 :            :         } gw;
     322                 :            :         uint64_t mbuf;
     323                 :            : 
     324                 :            : #ifdef RTE_ARCH_ARM64
     325                 :            :         asm volatile(PLT_CPU_FEATURE_PREAMBLE
     326                 :            :                      "             ldr %[tag], [%[tag_loc]]        \n"
     327                 :            :                      "             ldr %[wqp], [%[wqp_loc]]        \n"
     328                 :            :                      "             tbz %[tag], 63, .Ldone%=        \n"
     329                 :            :                      "             sevl                            \n"
     330                 :            :                      ".Lrty%=:     wfe                             \n"
     331                 :            :                      "             ldr %[tag], [%[tag_loc]]        \n"
     332                 :            :                      "             ldr %[wqp], [%[wqp_loc]]        \n"
     333                 :            :                      "             tbnz %[tag], 63, .Lrty%=        \n"
     334                 :            :                      ".Ldone%=:    dmb ld                          \n"
     335                 :            :                      "             sub %[mbuf], %[wqp], #0x80      \n"
     336                 :            :                      : [tag] "=&r"(gw.u64[0]), [wqp] "=&r"(gw.u64[1]),
     337                 :            :                        [mbuf] "=&r"(mbuf)
     338                 :            :                      : [tag_loc] "r"(base + SSOW_LF_GWS_TAG),
     339                 :            :                        [wqp_loc] "r"(base + SSOW_LF_GWS_WQP));
     340                 :            : #else
     341                 :          0 :         gw.u64[0] = plt_read64(base + SSOW_LF_GWS_TAG);
     342   [ #  #  #  # ]:          0 :         while ((BIT_ULL(63)) & gw.u64[0])
     343                 :            :                 gw.u64[0] = plt_read64(base + SSOW_LF_GWS_TAG);
     344                 :            : 
     345   [ #  #  #  # ]:          0 :         gw.u64[1] = plt_read64(base + SSOW_LF_GWS_WQP);
     346                 :          0 :         mbuf = (uint64_t)((char *)gw.u64[1] - sizeof(struct rte_mbuf));
     347                 :            : #endif
     348                 :            : 
     349   [ #  #  #  # ]:          0 :         if (gw.u64[1])
     350                 :            :                 cn9k_sso_hws_post_process(gw.u64, mbuf, flags, lookup_mem, tstamp);
     351                 :            :         else
     352                 :          0 :                 gw.u64[0] = (gw.u64[0] & (0x3ull << 32)) << 6 |
     353                 :          0 :                             (gw.u64[0] & (0x3FFull << 36)) << 4 | (gw.u64[0] & 0xffffffff);
     354                 :            : 
     355         [ #  # ]:          0 :         ev->event = gw.u64[0];
     356                 :            :         ev->u64 = gw.u64[1];
     357                 :            : 
     358                 :            :         return !!gw.u64[1];
     359                 :            : }
     360                 :            : 
     361                 :            : /* CN9K Fastpath functions. */
     362                 :            : uint16_t __rte_hot cn9k_sso_hws_enq_burst(void *port,
     363                 :            :                                           const struct rte_event ev[],
     364                 :            :                                           uint16_t nb_events);
     365                 :            : uint16_t __rte_hot cn9k_sso_hws_enq_new_burst(void *port,
     366                 :            :                                               const struct rte_event ev[],
     367                 :            :                                               uint16_t nb_events);
     368                 :            : uint16_t __rte_hot cn9k_sso_hws_enq_fwd_burst(void *port,
     369                 :            :                                               const struct rte_event ev[],
     370                 :            :                                               uint16_t nb_events);
     371                 :            : int __rte_hot cn9k_sso_hws_profile_switch(void *port, uint8_t profile);
     372                 :            : 
     373                 :            : uint16_t __rte_hot cn9k_sso_hws_dual_enq_burst(void *port,
     374                 :            :                                                const struct rte_event ev[],
     375                 :            :                                                uint16_t nb_events);
     376                 :            : uint16_t __rte_hot cn9k_sso_hws_dual_enq_new_burst(void *port,
     377                 :            :                                                    const struct rte_event ev[],
     378                 :            :                                                    uint16_t nb_events);
     379                 :            : uint16_t __rte_hot cn9k_sso_hws_dual_enq_fwd_burst(void *port,
     380                 :            :                                                    const struct rte_event ev[],
     381                 :            :                                                    uint16_t nb_events);
     382                 :            : uint16_t __rte_hot cn9k_sso_hws_ca_enq(void *port, struct rte_event ev[],
     383                 :            :                                        uint16_t nb_events);
     384                 :            : uint16_t __rte_hot cn9k_sso_hws_dual_ca_enq(void *port, struct rte_event ev[],
     385                 :            :                                             uint16_t nb_events);
     386                 :            : int __rte_hot cn9k_sso_hws_dual_profile_switch(void *port, uint8_t profile);
     387                 :            : 
     388                 :            : #define R(name, flags)                                                         \
     389                 :            :         uint16_t __rte_hot cn9k_sso_hws_deq_burst_##name(                      \
     390                 :            :                 void *port, struct rte_event ev[], uint16_t nb_events,         \
     391                 :            :                 uint64_t timeout_ticks);                                       \
     392                 :            :         uint16_t __rte_hot cn9k_sso_hws_deq_tmo_burst_##name(                  \
     393                 :            :                 void *port, struct rte_event ev[], uint16_t nb_events,         \
     394                 :            :                 uint64_t timeout_ticks);                                       \
     395                 :            :         uint16_t __rte_hot cn9k_sso_hws_deq_seg_burst_##name(                  \
     396                 :            :                 void *port, struct rte_event ev[], uint16_t nb_events,         \
     397                 :            :                 uint64_t timeout_ticks);                                       \
     398                 :            :         uint16_t __rte_hot cn9k_sso_hws_deq_tmo_seg_burst_##name(              \
     399                 :            :                 void *port, struct rte_event ev[], uint16_t nb_events,         \
     400                 :            :                 uint64_t timeout_ticks);
     401                 :            : 
     402                 :            : NIX_RX_FASTPATH_MODES
     403                 :            : #undef R
     404                 :            : 
     405                 :            : #define SSO_DEQ(fn, flags)                                                                         \
     406                 :            :         static __rte_always_inline uint16_t fn(void *port, struct rte_event *ev,                   \
     407                 :            :                                                uint64_t timeout_ticks)                             \
     408                 :            :         {                                                                                          \
     409                 :            :                 struct cn9k_sso_hws *ws = port;                                                    \
     410                 :            :                 RTE_SET_USED(timeout_ticks);                                                       \
     411                 :            :                 if (ws->swtag_req) {                                                               \
     412                 :            :                         ws->swtag_req = 0;                                                         \
     413                 :            :                         cnxk_sso_hws_swtag_wait(ws->base + SSOW_LF_GWS_TAG);                       \
     414                 :            :                         return 1;                                                                  \
     415                 :            :                 }                                                                                  \
     416                 :            :                 return cn9k_sso_hws_get_work(ws, ev, flags, ws->lookup_mem);                       \
     417                 :            :         }
     418                 :            : 
     419                 :            : #define SSO_DEQ_SEG(fn, flags)    SSO_DEQ(fn, flags | NIX_RX_MULTI_SEG_F)
     420                 :            : 
     421                 :            : #define SSO_DEQ_TMO(fn, flags)                                                                     \
     422                 :            :         static __rte_always_inline uint16_t fn(void *port, struct rte_event *ev,                   \
     423                 :            :                                                uint64_t timeout_ticks)                             \
     424                 :            :         {                                                                                          \
     425                 :            :                 struct cn9k_sso_hws *ws = port;                                                    \
     426                 :            :                 uint16_t ret = 1;                                                                  \
     427                 :            :                 uint64_t iter;                                                                     \
     428                 :            :                 if (ws->swtag_req) {                                                               \
     429                 :            :                         ws->swtag_req = 0;                                                         \
     430                 :            :                         cnxk_sso_hws_swtag_wait(ws->base + SSOW_LF_GWS_TAG);                       \
     431                 :            :                         return ret;                                                                \
     432                 :            :                 }                                                                                  \
     433                 :            :                 ret = cn9k_sso_hws_get_work(ws, ev, flags, ws->lookup_mem);                        \
     434                 :            :                 for (iter = 1; iter < timeout_ticks && (ret == 0); iter++)                         \
     435                 :            :                         ret = cn9k_sso_hws_get_work(ws, ev, flags, ws->lookup_mem);                \
     436                 :            :                 return ret;                                                                        \
     437                 :            :         }
     438                 :            : 
     439                 :            : #define SSO_DEQ_TMO_SEG(fn, flags)    SSO_DEQ_TMO(fn, flags | NIX_RX_MULTI_SEG_F)
     440                 :            : 
     441                 :            : #define R(name, flags)                                                                             \
     442                 :            :         uint16_t __rte_hot cn9k_sso_hws_dual_deq_burst_##name(                                     \
     443                 :            :                 void *port, struct rte_event ev[], uint16_t nb_events, uint64_t timeout_ticks);    \
     444                 :            :         uint16_t __rte_hot cn9k_sso_hws_dual_deq_tmo_burst_##name(                                 \
     445                 :            :                 void *port, struct rte_event ev[], uint16_t nb_events, uint64_t timeout_ticks);    \
     446                 :            :         uint16_t __rte_hot cn9k_sso_hws_dual_deq_seg_burst_##name(                                 \
     447                 :            :                 void *port, struct rte_event ev[], uint16_t nb_events, uint64_t timeout_ticks);    \
     448                 :            :         uint16_t __rte_hot cn9k_sso_hws_dual_deq_tmo_seg_burst_##name(                             \
     449                 :            :                 void *port, struct rte_event ev[], uint16_t nb_events, uint64_t timeout_ticks);
     450                 :            : 
     451                 :            : NIX_RX_FASTPATH_MODES
     452                 :            : #undef R
     453                 :            : 
     454                 :            : #define SSO_DUAL_DEQ(fn, flags)                                                                    \
     455                 :            :         static __rte_always_inline uint16_t fn(void *port, struct rte_event *ev,                   \
     456                 :            :                                                uint64_t timeout_ticks)                             \
     457                 :            :         {                                                                                          \
     458                 :            :                 struct cn9k_sso_hws_dual *dws = port;                                              \
     459                 :            :                 uint16_t gw;                                                                       \
     460                 :            :                 RTE_SET_USED(timeout_ticks);                                                       \
     461                 :            :                 if (dws->swtag_req) {                                                              \
     462                 :            :                         dws->swtag_req = 0;                                                        \
     463                 :            :                         cnxk_sso_hws_swtag_wait(dws->base[!dws->vws] + SSOW_LF_GWS_TAG);           \
     464                 :            :                         return 1;                                                                  \
     465                 :            :                 }                                                                                  \
     466                 :            :                 gw = cn9k_sso_hws_dual_get_work(dws->base[dws->vws], dws->base[!dws->vws], ev,     \
     467                 :            :                                                 flags, dws);                                       \
     468                 :            :                 dws->vws = !dws->vws;                                                              \
     469                 :            :                 return gw;                                                                         \
     470                 :            :         }
     471                 :            : 
     472                 :            : #define SSO_DUAL_DEQ_SEG(fn, flags) SSO_DUAL_DEQ(fn, flags | NIX_RX_MULTI_SEG_F)
     473                 :            : 
     474                 :            : #define SSO_DUAL_DEQ_TMO(fn, flags)                                                                \
     475                 :            :         static __rte_always_inline uint16_t fn(void *port, struct rte_event *ev,                   \
     476                 :            :                                                uint64_t timeout_ticks)                             \
     477                 :            :         {                                                                                          \
     478                 :            :                 struct cn9k_sso_hws_dual *dws = port;                                              \
     479                 :            :                 uint16_t ret = 1;                                                                  \
     480                 :            :                 uint64_t iter;                                                                     \
     481                 :            :                 if (dws->swtag_req) {                                                              \
     482                 :            :                         dws->swtag_req = 0;                                                        \
     483                 :            :                         cnxk_sso_hws_swtag_wait(dws->base[!dws->vws] + SSOW_LF_GWS_TAG);           \
     484                 :            :                         return ret;                                                                \
     485                 :            :                 }                                                                                  \
     486                 :            :                 ret = cn9k_sso_hws_dual_get_work(dws->base[dws->vws], dws->base[!dws->vws], ev,    \
     487                 :            :                                                  flags, dws);                                      \
     488                 :            :                 dws->vws = !dws->vws;                                                              \
     489                 :            :                 for (iter = 1; iter < timeout_ticks && (ret == 0); iter++) {                       \
     490                 :            :                         ret = cn9k_sso_hws_dual_get_work(dws->base[dws->vws],                      \
     491                 :            :                                                          dws->base[!dws->vws], ev, flags, dws);    \
     492                 :            :                         dws->vws = !dws->vws;                                                      \
     493                 :            :                 }                                                                                  \
     494                 :            :                 return ret;                                                                        \
     495                 :            :         }
     496                 :            : 
     497                 :            : #define SSO_DUAL_DEQ_TMO_SEG(fn, flags)                                        \
     498                 :            :         SSO_DUAL_DEQ_TMO(fn, flags | NIX_RX_MULTI_SEG_F)
     499                 :            : 
     500                 :            : #define R(name, flags)                                                                             \
     501                 :            :         SSO_DEQ(cn9k_sso_hws_deq_##name, flags)                                                    \
     502                 :            :         SSO_DUAL_DEQ(cn9k_sso_hws_dual_deq_##name, flags)                                          \
     503                 :            :         SSO_DEQ_SEG(cn9k_sso_hws_deq_seg_##name, flags)                                            \
     504                 :            :         SSO_DUAL_DEQ_SEG(cn9k_sso_hws_dual_deq_seg_##name, flags)                                  \
     505                 :            :         SSO_DEQ_TMO(cn9k_sso_hws_deq_tmo_##name, flags)                                            \
     506                 :            :         SSO_DUAL_DEQ_TMO(cn9k_sso_hws_dual_deq_tmo_##name, flags)                                  \
     507                 :            :         SSO_DEQ_TMO_SEG(cn9k_sso_hws_deq_tmo_seg_##name, flags)                                    \
     508                 :            :         SSO_DUAL_DEQ_TMO_SEG(cn9k_sso_hws_dual_deq_tmo_seg_##name, flags)
     509                 :            : 
     510                 :            : NIX_RX_FASTPATH_MODES
     511                 :            : #undef R
     512                 :            : 
     513                 :            : #define SSO_CMN_DEQ_BURST(fnb, fn, flags)                                      \
     514                 :            :         uint16_t __rte_hot fnb(void *port, struct rte_event ev[],              \
     515                 :            :                                uint16_t nb_events, uint64_t timeout_ticks)     \
     516                 :            :         {                                                                      \
     517                 :            :                 RTE_SET_USED(nb_events);                                       \
     518                 :            :                 return fn(port, ev, timeout_ticks);                            \
     519                 :            :         }
     520                 :            : 
     521                 :            : #define SSO_CMN_DEQ_SEG_BURST(fnb, fn, flags)                                  \
     522                 :            :         uint16_t __rte_hot fnb(void *port, struct rte_event ev[],              \
     523                 :            :                                uint16_t nb_events, uint64_t timeout_ticks)     \
     524                 :            :         {                                                                      \
     525                 :            :                 RTE_SET_USED(nb_events);                                       \
     526                 :            :                 return fn(port, ev, timeout_ticks);                            \
     527                 :            :         }
     528                 :            : 
     529                 :            : uint16_t __rte_hot cn9k_sso_hws_deq_burst_all_offload(void *port, struct rte_event ev[],
     530                 :            :                                                       uint16_t nb_events, uint64_t timeout_ticks);
     531                 :            : 
     532                 :            : uint16_t __rte_hot cn9k_sso_hws_deq_dual_burst_all_offload(void *port, struct rte_event ev[],
     533                 :            :                                                            uint16_t nb_events,
     534                 :            :                                                            uint64_t timeout_ticks);
     535                 :            : 
     536                 :            : uint16_t __rte_hot cn9k_sso_hws_deq_burst_all_offload_tst(void *port, struct rte_event ev[],
     537                 :            :                                                           uint16_t nb_events,
     538                 :            :                                                           uint64_t timeout_ticks);
     539                 :            : 
     540                 :            : uint16_t __rte_hot cn9k_sso_hws_deq_dual_burst_all_offload_tst(void *port, struct rte_event ev[],
     541                 :            :                                                                uint16_t nb_events,
     542                 :            :                                                                uint64_t timeout_ticks);
     543                 :            : 
     544                 :            : static __rte_always_inline void
     545                 :            : cn9k_sso_txq_fc_wait(const struct cn9k_eth_txq *txq)
     546                 :            : {
     547                 :            :         int64_t avail;
     548                 :            : 
     549                 :            : #ifdef RTE_ARCH_ARM64
     550                 :            :         int64_t val;
     551                 :            : 
     552                 :            :         asm volatile(PLT_CPU_FEATURE_PREAMBLE
     553                 :            :                      "             ldxr %[val], [%[addr]]                  \n"
     554                 :            :                      "             sub %[val], %[adj], %[val]              \n"
     555                 :            :                      "             lsl %[refill], %[val], %[shft]          \n"
     556                 :            :                      "             sub %[refill], %[refill], %[val]        \n"
     557                 :            :                      "             cmp %[refill], #0x0                     \n"
     558                 :            :                      "             b.gt .Ldne%=                            \n"
     559                 :            :                      "             sevl                                    \n"
     560                 :            :                      ".Lrty%=:     wfe                                     \n"
     561                 :            :                      "             ldxr %[val], [%[addr]]                  \n"
     562                 :            :                      "             sub %[val], %[adj], %[val]              \n"
     563                 :            :                      "             lsl %[refill], %[val], %[shft]          \n"
     564                 :            :                      "             sub %[refill], %[refill], %[val]        \n"
     565                 :            :                      "             cmp %[refill], #0x0                     \n"
     566                 :            :                      "             b.le .Lrty%=                            \n"
     567                 :            :                      ".Ldne%=:                                             \n"
     568                 :            :                      : [refill] "=&r"(avail), [val] "=&r" (val)
     569                 :            :                      : [addr] "r"(txq->fc_mem), [adj] "r"(txq->nb_sqb_bufs_adj),
     570                 :            :                        [shft] "r"(txq->sqes_per_sqb_log2)
     571                 :            :                      : "memory");
     572                 :            : #else
     573                 :            :         do {
     574                 :            :                 avail = txq->nb_sqb_bufs_adj -
     575                 :            :                         rte_atomic_load_explicit((uint64_t __rte_atomic *)txq->fc_mem,
     576                 :            :                                                  rte_memory_order_relaxed);
     577                 :            :         } while (((avail << txq->sqes_per_sqb_log2) - avail) <= 0);
     578                 :            : #endif
     579                 :            : }
     580                 :            : 
     581                 :            : static __rte_always_inline struct cn9k_eth_txq *
     582                 :            : cn9k_sso_hws_xtract_meta(struct rte_mbuf *m, uint64_t *txq_data)
     583                 :            : {
     584                 :            :         return (struct cn9k_eth_txq
     585                 :            :                         *)(txq_data[(txq_data[m->port] >> 48) +
     586                 :            :                                     rte_event_eth_tx_adapter_txq_get(m)] &
     587                 :            :                            (BIT_ULL(48) - 1));
     588                 :            : }
     589                 :            : 
     590                 :            : #if defined(RTE_ARCH_ARM64)
     591                 :            : 
     592                 :            : static __rte_always_inline void
     593                 :            : cn9k_sso_hws_xmit_sec_one(const struct cn9k_eth_txq *txq, uint64_t base,
     594                 :            :                           struct rte_mbuf *m, uint64_t *cmd,
     595                 :            :                           uint32_t flags)
     596                 :            : {
     597                 :            :         struct cn9k_outb_priv_data *outb_priv;
     598                 :            :         rte_iova_t io_addr = txq->cpt_io_addr;
     599                 :            :         uint64_t *lmt_addr = txq->lmt_addr;
     600                 :            :         struct cn9k_sec_sess_priv mdata;
     601                 :            :         struct nix_send_hdr_s *send_hdr;
     602                 :            :         uint64_t sa_base = txq->sa_base;
     603                 :            :         uint32_t pkt_len, dlen_adj, rlen;
     604                 :            :         struct roc_ie_on_outb_hdr *hdr;
     605                 :            :         uint64x2_t cmd01, cmd23;
     606                 :            :         uint64_t lmt_status, sa;
     607                 :            :         union nix_send_sg_s *sg;
     608                 :            :         uint32_t esn_lo, esn_hi;
     609                 :            :         uintptr_t dptr, nixtx;
     610                 :            :         uint64_t ucode_cmd[4];
     611                 :            :         uint64_t esn;
     612                 :            :         uint8_t l2_len;
     613                 :            : 
     614                 :            :         mdata.u64 = *rte_security_dynfield(m);
     615                 :            :         send_hdr = (struct nix_send_hdr_s *)cmd;
     616                 :            :         if (flags & NIX_TX_NEED_EXT_HDR)
     617                 :            :                 sg = (union nix_send_sg_s *)&cmd[4];
     618                 :            :         else
     619                 :            :                 sg = (union nix_send_sg_s *)&cmd[2];
     620                 :            : 
     621                 :            :         if (flags & NIX_TX_NEED_SEND_HDR_W1)
     622                 :            :                 l2_len = cmd[1] & 0xFF;
     623                 :            :         else
     624                 :            :                 l2_len = m->l2_len;
     625                 :            : 
     626                 :            :         /* Retrieve DPTR */
     627                 :            :         dptr = *(uint64_t *)(sg + 1);
     628                 :            :         pkt_len = send_hdr->w0.total;
     629                 :            : 
     630                 :            :         /* Calculate rlen */
     631                 :            :         rlen = pkt_len - l2_len;
     632                 :            :         rlen = (rlen + mdata.roundup_len) + (mdata.roundup_byte - 1);
     633                 :            :         rlen &= ~(uint64_t)(mdata.roundup_byte - 1);
     634                 :            :         rlen += mdata.partial_len;
     635                 :            :         dlen_adj = rlen - pkt_len + l2_len;
     636                 :            : 
     637                 :            :         /* Update send descriptors. Security is single segment only */
     638                 :            :         send_hdr->w0.total = pkt_len + dlen_adj;
     639                 :            :         sg->seg1_size = pkt_len + dlen_adj;
     640                 :            : 
     641                 :            :         /* Get area where NIX descriptor needs to be stored */
     642                 :            :         nixtx = dptr + pkt_len + dlen_adj;
     643                 :            :         nixtx += BIT_ULL(7);
     644                 :            :         nixtx = (nixtx - 1) & ~(BIT_ULL(7) - 1);
     645                 :            : 
     646                 :            :         roc_lmt_mov_nv((void *)(nixtx + 16), cmd, cn9k_nix_tx_ext_subs(flags));
     647                 :            : 
     648                 :            :         /* Load opcode and cptr already prepared at pkt metadata set */
     649                 :            :         pkt_len -= l2_len;
     650                 :            :         pkt_len += (sizeof(struct roc_ie_on_outb_hdr) - ROC_IE_ON_MAX_IV_LEN) +
     651                 :            :                    ROC_ONF_IPSEC_OUTB_MAX_L2_INFO_SZ;
     652                 :            :         sa_base &= ~(ROC_NIX_INL_SA_BASE_ALIGN - 1);
     653                 :            : 
     654                 :            :         sa = (uintptr_t)roc_nix_inl_on_ipsec_outb_sa(sa_base, mdata.sa_idx);
     655                 :            :         ucode_cmd[3] = (ROC_CPT_DFLT_ENG_GRP_SE_IE << 61 | sa);
     656                 :            :         ucode_cmd[0] = (((ROC_IE_ON_OUTB_MAX_CTX_LEN << 8) |
     657                 :            :                          ROC_IE_ON_MAJOR_OP_PROCESS_OUTBOUND_IPSEC)
     658                 :            :                                 << 48 |
     659                 :            :                         (ROC_IE_ON_OUTB_IKEV2_SINGLE_SA_SUPPORT |
     660                 :            :                          (ROC_ONF_IPSEC_OUTB_MAX_L2_INFO_SZ >>
     661                 :            :                           3)) << 32 |
     662                 :            :                         pkt_len);
     663                 :            : 
     664                 :            :         /* CPT Word 0 and Word 1 */
     665                 :            :         cmd01 = vdupq_n_u64((nixtx + 16) | (cn9k_nix_tx_ext_subs(flags) + 1));
     666                 :            :         /* CPT_RES_S is 16B above NIXTX */
     667                 :            :         cmd01 = vsetq_lane_u8(nixtx & BIT_ULL(7), cmd01, 8);
     668                 :            : 
     669                 :            :         /* CPT word 2 and 3 */
     670                 :            :         cmd23 = vdupq_n_u64(0);
     671                 :            :         cmd23 = vsetq_lane_u64((((uint64_t)RTE_EVENT_TYPE_CPU << 28) |
     672                 :            :                                 CNXK_ETHDEV_SEC_OUTB_EV_SUB << 20),
     673                 :            :                                cmd23, 0);
     674                 :            :         cmd23 = vsetq_lane_u64(((uintptr_t)m + sizeof(struct rte_mbuf)) | 1,
     675                 :            :                                cmd23, 1);
     676                 :            : 
     677                 :            :         dptr += l2_len - ROC_ONF_IPSEC_OUTB_MAX_L2_INFO_SZ -
     678                 :            :                 (sizeof(struct roc_ie_on_outb_hdr) - ROC_IE_ON_MAX_IV_LEN);
     679                 :            :         ucode_cmd[1] = dptr;
     680                 :            :         ucode_cmd[2] = dptr;
     681                 :            : 
     682                 :            :         /* Update l2 sz */
     683                 :            :         *(uint16_t *)(dptr + (sizeof(struct roc_ie_on_outb_hdr) -
     684                 :            :                               ROC_IE_ON_MAX_IV_LEN)) =
     685                 :            :                 rte_cpu_to_be_16(ROC_ONF_IPSEC_OUTB_MAX_L2_INFO_SZ);
     686                 :            : 
     687                 :            :         /* Head wait if needed */
     688                 :            :         if (base)
     689                 :            :                 roc_sso_hws_head_wait(base);
     690                 :            : 
     691                 :            :         /* ESN */
     692                 :            :         outb_priv = roc_nix_inl_on_ipsec_outb_sa_sw_rsvd((void *)sa);
     693                 :            :         esn = outb_priv->esn;
     694                 :            :         outb_priv->esn = esn + 1;
     695                 :            : 
     696                 :            :         esn_lo = rte_cpu_to_be_32(esn & (BIT_ULL(32) - 1));
     697                 :            :         esn_hi = rte_cpu_to_be_32(esn >> 32);
     698                 :            : 
     699                 :            :         /* Update ESN, IPID and IV */
     700                 :            :         hdr = (struct roc_ie_on_outb_hdr *)dptr;
     701                 :            :         hdr->ip_id = esn_lo;
     702                 :            :         hdr->seq = esn_lo;
     703                 :            :         hdr->esn = esn_hi;
     704                 :            :         hdr->df_tos = 0;
     705                 :            : 
     706                 :            :         rte_io_wmb();
     707                 :            :         cn9k_sso_txq_fc_wait(txq);
     708                 :            :         cn9k_nix_sec_fc_wait_one(txq);
     709                 :            : 
     710                 :            :         /* Write CPT instruction to lmt line */
     711                 :            :         vst1q_u64(lmt_addr, cmd01);
     712                 :            :         vst1q_u64(lmt_addr + 2, cmd23);
     713                 :            : 
     714                 :            :         roc_lmt_mov_seg(lmt_addr + 4, ucode_cmd, 2);
     715                 :            : 
     716                 :            :         if (roc_lmt_submit_ldeor(io_addr) == 0) {
     717                 :            :                 do {
     718                 :            :                         vst1q_u64(lmt_addr, cmd01);
     719                 :            :                         vst1q_u64(lmt_addr + 2, cmd23);
     720                 :            :                         roc_lmt_mov_seg(lmt_addr + 4, ucode_cmd, 2);
     721                 :            : 
     722                 :            :                         lmt_status = roc_lmt_submit_ldeor(io_addr);
     723                 :            :                 } while (lmt_status == 0);
     724                 :            :         }
     725                 :            : }
     726                 :            : #else
     727                 :            : 
     728                 :            : static inline void
     729                 :            : cn9k_sso_hws_xmit_sec_one(const struct cn9k_eth_txq *txq, uint64_t base,
     730                 :            :                           struct rte_mbuf *m, uint64_t *cmd,
     731                 :            :                           uint32_t flags)
     732                 :            : {
     733                 :            :         RTE_SET_USED(txq);
     734                 :            :         RTE_SET_USED(base);
     735                 :            :         RTE_SET_USED(m);
     736                 :            :         RTE_SET_USED(cmd);
     737                 :            :         RTE_SET_USED(flags);
     738                 :            : }
     739                 :            : #endif
     740                 :            : 
     741                 :            : static __rte_always_inline int32_t
     742                 :            : cn9k_sso_sq_depth(const struct cn9k_eth_txq *txq)
     743                 :            : {
     744                 :            :         int32_t avail = (int32_t)txq->nb_sqb_bufs_adj -
     745                 :            :                         (int32_t)rte_atomic_load_explicit((uint64_t __rte_atomic *)txq->fc_mem,
     746                 :            :                                                           rte_memory_order_relaxed);
     747                 :            :         return (avail << txq->sqes_per_sqb_log2) - avail;
     748                 :            : }
     749                 :            : 
     750                 :            : static __rte_always_inline uint16_t
     751                 :            : cn9k_sso_hws_event_tx(uint64_t base, struct rte_event *ev, uint64_t *cmd,
     752                 :            :                       uint64_t *txq_data, const uint32_t flags)
     753                 :            : {
     754                 :            :         struct rte_mbuf *m = ev->mbuf, *extm = NULL;
     755                 :            :         struct cn9k_eth_txq *txq;
     756                 :            : 
     757                 :            :         /* Perform header writes before barrier for TSO */
     758                 :            :         cn9k_nix_xmit_prepare_tso(m, flags);
     759                 :            :         /* Lets commit any changes in the packet here in case when
     760                 :            :          * fast free is set as no further changes will be made to mbuf.
     761                 :            :          * In case of fast free is not set, both cn9k_nix_prepare_mseg()
     762                 :            :          * and cn9k_nix_xmit_prepare() has a barrier after refcnt update.
     763                 :            :          */
     764                 :            :         if (!(flags & NIX_TX_OFFLOAD_MBUF_NOFF_F) &&
     765                 :            :             !(flags & NIX_TX_OFFLOAD_SECURITY_F))
     766                 :            :                 rte_io_wmb();
     767                 :            :         txq = cn9k_sso_hws_xtract_meta(m, txq_data);
     768                 :            : 
     769                 :            :         if (flags & NIX_TX_OFFLOAD_MBUF_NOFF_F && txq->tx_compl.ena)
     770                 :            :                 handle_tx_completion_pkts(txq, 1);
     771                 :            : 
     772                 :            :         if (cn9k_sso_sq_depth(txq) <= 0)
     773                 :            :                 return 0;
     774                 :            :         cn9k_nix_tx_skeleton(txq, cmd, flags, 0);
     775                 :            :         cn9k_nix_xmit_prepare(txq, m, &extm, cmd, flags, txq->lso_tun_fmt, txq->mark_flag,
     776                 :            :                               txq->mark_fmt);
     777                 :            : 
     778                 :            :         if (flags & NIX_TX_OFFLOAD_SECURITY_F) {
     779                 :            :                 uint64_t ol_flags = m->ol_flags;
     780                 :            : 
     781                 :            :                 if (ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD) {
     782                 :            :                         uintptr_t ssow_base = base;
     783                 :            : 
     784                 :            :                         if (ev->sched_type)
     785                 :            :                                 ssow_base = 0;
     786                 :            : 
     787                 :            :                         cn9k_sso_hws_xmit_sec_one(txq, ssow_base, m, cmd,
     788                 :            :                                                   flags);
     789                 :            :                         goto done;
     790                 :            :                 }
     791                 :            : 
     792                 :            :                 if (!(flags & NIX_TX_OFFLOAD_MBUF_NOFF_F))
     793                 :            :                         rte_io_wmb();
     794                 :            :         }
     795                 :            : 
     796                 :            :         if (flags & NIX_TX_MULTI_SEG_F) {
     797                 :            :                 const uint16_t segdw = cn9k_nix_prepare_mseg(txq, m, &extm, cmd, flags);
     798                 :            :                 cn9k_nix_xmit_prepare_tstamp(txq, cmd, m->ol_flags, segdw,
     799                 :            :                                              flags);
     800                 :            :                 if (!CNXK_TT_FROM_EVENT(ev->event)) {
     801                 :            :                         cn9k_nix_xmit_mseg_prep_lmt(cmd, txq->lmt_addr, segdw);
     802                 :            :                         roc_sso_hws_head_wait(base);
     803                 :            :                         cn9k_sso_txq_fc_wait(txq);
     804                 :            :                         if (cn9k_nix_xmit_submit_lmt(txq->io_addr) == 0)
     805                 :            :                                 cn9k_nix_xmit_mseg_one(cmd, txq->lmt_addr,
     806                 :            :                                                        txq->io_addr, segdw);
     807                 :            :                 } else {
     808                 :            :                         cn9k_nix_xmit_mseg_one(cmd, txq->lmt_addr, txq->io_addr,
     809                 :            :                                                segdw);
     810                 :            :                 }
     811                 :            :         } else {
     812                 :            :                 cn9k_nix_xmit_prepare_tstamp(txq, cmd, m->ol_flags, 4, flags);
     813                 :            :                 if (!CNXK_TT_FROM_EVENT(ev->event)) {
     814                 :            :                         cn9k_nix_xmit_prep_lmt(cmd, txq->lmt_addr, flags);
     815                 :            :                         roc_sso_hws_head_wait(base);
     816                 :            :                         cn9k_sso_txq_fc_wait(txq);
     817                 :            :                         if (cn9k_nix_xmit_submit_lmt(txq->io_addr) == 0)
     818                 :            :                                 cn9k_nix_xmit_one(cmd, txq->lmt_addr,
     819                 :            :                                                   txq->io_addr, flags);
     820                 :            :                 } else {
     821                 :            :                         cn9k_nix_xmit_one(cmd, txq->lmt_addr, txq->io_addr,
     822                 :            :                                           flags);
     823                 :            :                 }
     824                 :            :         }
     825                 :            : 
     826                 :            : done:
     827                 :            :         if (flags & NIX_TX_OFFLOAD_MBUF_NOFF_F && !txq->tx_compl.ena)
     828                 :            :                 cn9k_nix_free_extmbuf(extm);
     829                 :            : 
     830                 :            :         return 1;
     831                 :            : }
     832                 :            : 
     833                 :            : #define T(name, sz, flags)                                                     \
     834                 :            :         uint16_t __rte_hot cn9k_sso_hws_tx_adptr_enq_##name(                   \
     835                 :            :                 void *port, struct rte_event ev[], uint16_t nb_events);        \
     836                 :            :         uint16_t __rte_hot cn9k_sso_hws_tx_adptr_enq_seg_##name(               \
     837                 :            :                 void *port, struct rte_event ev[], uint16_t nb_events);        \
     838                 :            :         uint16_t __rte_hot cn9k_sso_hws_dual_tx_adptr_enq_##name(              \
     839                 :            :                 void *port, struct rte_event ev[], uint16_t nb_events);        \
     840                 :            :         uint16_t __rte_hot cn9k_sso_hws_dual_tx_adptr_enq_seg_##name(          \
     841                 :            :                 void *port, struct rte_event ev[], uint16_t nb_events);
     842                 :            : 
     843                 :            : NIX_TX_FASTPATH_MODES
     844                 :            : #undef T
     845                 :            : 
     846                 :            : #define SSO_TX(fn, sz, flags)                                                  \
     847                 :            :         uint16_t __rte_hot fn(void *port, struct rte_event ev[],               \
     848                 :            :                               uint16_t nb_events)                              \
     849                 :            :         {                                                                      \
     850                 :            :                 struct cn9k_sso_hws *ws = port;                                \
     851                 :            :                 uint64_t cmd[sz];                                              \
     852                 :            :                 RTE_SET_USED(nb_events);                                       \
     853                 :            :                 return cn9k_sso_hws_event_tx(ws->base, &ev[0], cmd,            \
     854                 :            :                                              (uint64_t *)ws->tx_adptr_data,    \
     855                 :            :                                              flags);                           \
     856                 :            :         }
     857                 :            : 
     858                 :            : #define SSO_TX_SEG(fn, sz, flags)                                              \
     859                 :            :         uint16_t __rte_hot fn(void *port, struct rte_event ev[],               \
     860                 :            :                               uint16_t nb_events)                              \
     861                 :            :         {                                                                      \
     862                 :            :                 uint64_t cmd[(sz) + CNXK_NIX_TX_MSEG_SG_DWORDS - 2];           \
     863                 :            :                 struct cn9k_sso_hws *ws = port;                                \
     864                 :            :                 RTE_SET_USED(nb_events);                                       \
     865                 :            :                 return cn9k_sso_hws_event_tx(ws->base, &ev[0], cmd,            \
     866                 :            :                                              (uint64_t *)ws->tx_adptr_data,    \
     867                 :            :                                              (flags) | NIX_TX_MULTI_SEG_F);    \
     868                 :            :         }
     869                 :            : 
     870                 :            : #define SSO_DUAL_TX(fn, sz, flags)                                             \
     871                 :            :         uint16_t __rte_hot fn(void *port, struct rte_event ev[],               \
     872                 :            :                               uint16_t nb_events)                              \
     873                 :            :         {                                                                      \
     874                 :            :                 struct cn9k_sso_hws_dual *ws = port;                           \
     875                 :            :                 uint64_t cmd[sz];                                              \
     876                 :            :                 RTE_SET_USED(nb_events);                                       \
     877                 :            :                 return cn9k_sso_hws_event_tx(ws->base[!ws->vws], &ev[0], cmd,  \
     878                 :            :                                              (uint64_t *)ws->tx_adptr_data,    \
     879                 :            :                                              flags);                           \
     880                 :            :         }
     881                 :            : 
     882                 :            : #define SSO_DUAL_TX_SEG(fn, sz, flags)                                         \
     883                 :            :         uint16_t __rte_hot fn(void *port, struct rte_event ev[],               \
     884                 :            :                               uint16_t nb_events)                              \
     885                 :            :         {                                                                      \
     886                 :            :                 uint64_t cmd[(sz) + CNXK_NIX_TX_MSEG_SG_DWORDS - 2];           \
     887                 :            :                 struct cn9k_sso_hws_dual *ws = port;                           \
     888                 :            :                 RTE_SET_USED(nb_events);                                       \
     889                 :            :                 return cn9k_sso_hws_event_tx(ws->base[!ws->vws], &ev[0], cmd,  \
     890                 :            :                                              (uint64_t *)ws->tx_adptr_data,    \
     891                 :            :                                              (flags) | NIX_TX_MULTI_SEG_F);    \
     892                 :            :         }
     893                 :            : 
     894                 :            : uint16_t __rte_hot cn9k_sso_hws_tx_adptr_enq_seg_all_offload(void *port, struct rte_event ev[],
     895                 :            :                                                              uint16_t nb_events);
     896                 :            : 
     897                 :            : uint16_t __rte_hot cn9k_sso_hws_tx_adptr_enq_dual_seg_all_offload(void *port, struct rte_event ev[],
     898                 :            :                                                                   uint16_t nb_events);
     899                 :            : 
     900                 :            : uint16_t __rte_hot cn9k_sso_hws_tx_adptr_enq_seg_all_offload_tst(void *port, struct rte_event ev[],
     901                 :            :                                                                  uint16_t nb_events);
     902                 :            : 
     903                 :            : uint16_t __rte_hot cn9k_sso_hws_tx_adptr_enq_dual_seg_all_offload_tst(void *port,
     904                 :            :                                                                       struct rte_event ev[],
     905                 :            :                                                                       uint16_t nb_events);
     906                 :            : 
     907                 :            : #endif

Generated by: LCOV version 1.14