LCOV - code coverage report
Current view: top level - drivers/net/cnxk - cn10k_tx.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 9 0.0 %
Date: 2025-01-02 22:41:34 Functions: 0 0 -
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 4 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(C) 2021 Marvell.
       3                 :            :  */
       4                 :            : #ifndef __CN10K_TX_H__
       5                 :            : #define __CN10K_TX_H__
       6                 :            : 
       7                 :            : #include <rte_vect.h>
       8                 :            : #include <rte_eventdev.h>
       9                 :            : #include "cn10k_rxtx.h"
      10                 :            : 
      11                 :            : #define NIX_TX_OFFLOAD_NONE           (0)
      12                 :            : #define NIX_TX_OFFLOAD_L3_L4_CSUM_F   BIT(0)
      13                 :            : #define NIX_TX_OFFLOAD_OL3_OL4_CSUM_F BIT(1)
      14                 :            : #define NIX_TX_OFFLOAD_VLAN_QINQ_F    BIT(2)
      15                 :            : #define NIX_TX_OFFLOAD_MBUF_NOFF_F    BIT(3)
      16                 :            : #define NIX_TX_OFFLOAD_TSO_F          BIT(4)
      17                 :            : #define NIX_TX_OFFLOAD_TSTAMP_F       BIT(5)
      18                 :            : #define NIX_TX_OFFLOAD_SECURITY_F     BIT(6)
      19                 :            : #define NIX_TX_OFFLOAD_MAX            (NIX_TX_OFFLOAD_SECURITY_F << 1)
      20                 :            : 
      21                 :            : /* Flags to control xmit_prepare function.
      22                 :            :  * Defining it from backwards to denote its been
      23                 :            :  * not used as offload flags to pick function
      24                 :            :  */
      25                 :            : #define NIX_TX_VWQE_F      BIT(14)
      26                 :            : #define NIX_TX_MULTI_SEG_F BIT(15)
      27                 :            : 
      28                 :            : #define NIX_TX_NEED_SEND_HDR_W1                                                \
      29                 :            :         (NIX_TX_OFFLOAD_L3_L4_CSUM_F | NIX_TX_OFFLOAD_OL3_OL4_CSUM_F |         \
      30                 :            :          NIX_TX_OFFLOAD_VLAN_QINQ_F | NIX_TX_OFFLOAD_TSO_F)
      31                 :            : 
      32                 :            : #define NIX_TX_NEED_EXT_HDR                                                    \
      33                 :            :         (NIX_TX_OFFLOAD_VLAN_QINQ_F | NIX_TX_OFFLOAD_TSTAMP_F |                \
      34                 :            :          NIX_TX_OFFLOAD_TSO_F)
      35                 :            : 
      36                 :            : #define NIX_XMIT_FC_OR_RETURN(txq, pkts)                                       \
      37                 :            :         do {                                                                   \
      38                 :            :                 int64_t avail;                                                 \
      39                 :            :                 /* Cached value is low, Update the fc_cache_pkts */            \
      40                 :            :                 if (unlikely((txq)->fc_cache_pkts < (pkts))) {                 \
      41                 :            :                         avail = txq->nb_sqb_bufs_adj - *txq->fc_mem;           \
      42                 :            :                         /* Multiply with sqe_per_sqb to express in pkts */     \
      43                 :            :                         (txq)->fc_cache_pkts =                                 \
      44                 :            :                                 (avail << (txq)->sqes_per_sqb_log2) - avail;   \
      45                 :            :                         /* Check it again for the room */                      \
      46                 :            :                         if (unlikely((txq)->fc_cache_pkts < (pkts)))           \
      47                 :            :                                 return 0;                                      \
      48                 :            :                 }                                                              \
      49                 :            :         } while (0)
      50                 :            : 
      51                 :            : #define NIX_XMIT_FC_OR_RETURN_MTS(txq, pkts)                                                       \
      52                 :            :         do {                                                                                       \
      53                 :            :                 int64_t *fc_cache = &(txq)->fc_cache_pkts;                                         \
      54                 :            :                 uint8_t retry_count = 8;                                                           \
      55                 :            :                 int64_t val, newval;                                                               \
      56                 :            :         retry:                                                                                     \
      57                 :            :                 /* Reduce the cached count */                                                      \
      58                 :            :                 val = (int64_t)__atomic_fetch_sub(fc_cache, pkts, __ATOMIC_RELAXED);               \
      59                 :            :                 val -= pkts;                                                                       \
      60                 :            :                 /* Cached value is low, Update the fc_cache_pkts */                                \
      61                 :            :                 if (unlikely(val < 0)) {                                                           \
      62                 :            :                         /* Multiply with sqe_per_sqb to express in pkts */                         \
      63                 :            :                         newval = txq->nb_sqb_bufs_adj - __atomic_load_n(txq->fc_mem,               \
      64                 :            :                                                                         __ATOMIC_RELAXED);         \
      65                 :            :                         newval = (newval << (txq)->sqes_per_sqb_log2) - newval;                    \
      66                 :            :                         newval -= pkts;                                                            \
      67                 :            :                         if (!__atomic_compare_exchange_n(fc_cache, &val, newval, false,            \
      68                 :            :                                                          __ATOMIC_RELAXED, __ATOMIC_RELAXED)) {    \
      69                 :            :                                 if (retry_count) {                                                 \
      70                 :            :                                         retry_count--;                                             \
      71                 :            :                                         goto retry;                                                \
      72                 :            :                                 } else                                                             \
      73                 :            :                                         return 0;                                                  \
      74                 :            :                         }                                                                          \
      75                 :            :                         /* Update and check it again for the room */                               \
      76                 :            :                         if (unlikely(newval < 0))                                                  \
      77                 :            :                                 return 0;                                                          \
      78                 :            :                 }                                                                                  \
      79                 :            :         } while (0)
      80                 :            : 
      81                 :            : #define NIX_XMIT_FC_CHECK_RETURN(txq, pkts)                                                        \
      82                 :            :         do {                                                                                       \
      83                 :            :                 if (unlikely((txq)->flag))                                                         \
      84                 :            :                         NIX_XMIT_FC_OR_RETURN_MTS(txq, pkts);                                      \
      85                 :            :                 else {                                                                             \
      86                 :            :                         NIX_XMIT_FC_OR_RETURN(txq, pkts);                                          \
      87                 :            :                         /* Reduce the cached count */                                              \
      88                 :            :                         txq->fc_cache_pkts -= pkts;                                                \
      89                 :            :                 }                                                                                  \
      90                 :            :         } while (0)
      91                 :            : 
      92                 :            : /* Encoded number of segments to number of dwords macro, each value of nb_segs
      93                 :            :  * is encoded as 4bits.
      94                 :            :  */
      95                 :            : #define NIX_SEGDW_MAGIC 0x76654432210ULL
      96                 :            : 
      97                 :            : #define NIX_NB_SEGS_TO_SEGDW(x) ((NIX_SEGDW_MAGIC >> ((x) << 2)) & 0xF)
      98                 :            : 
      99                 :            : static __plt_always_inline uint8_t
     100                 :            : cn10k_nix_mbuf_sg_dwords(struct rte_mbuf *m)
     101                 :            : {
     102                 :            :         uint32_t nb_segs = m->nb_segs;
     103                 :            :         uint16_t aura0, aura;
     104                 :            :         int segw, sg_segs;
     105                 :            : 
     106                 :            :         aura0 = roc_npa_aura_handle_to_aura(m->pool->pool_id);
     107                 :            : 
     108                 :            :         nb_segs--;
     109                 :            :         segw = 2;
     110                 :            :         sg_segs = 1;
     111                 :            :         while (nb_segs) {
     112                 :            :                 m = m->next;
     113                 :            :                 aura = roc_npa_aura_handle_to_aura(m->pool->pool_id);
     114                 :            :                 if (aura != aura0) {
     115                 :            :                         segw += 2 + (sg_segs == 2);
     116                 :            :                         sg_segs = 0;
     117                 :            :                 } else {
     118                 :            :                         segw += (sg_segs == 0); /* SUBDC */
     119                 :            :                         segw += 1;              /* IOVA */
     120                 :            :                         sg_segs += 1;
     121                 :            :                         sg_segs %= 3;
     122                 :            :                 }
     123                 :            :                 nb_segs--;
     124                 :            :         }
     125                 :            : 
     126                 :            :         return (segw + 1) / 2;
     127                 :            : }
     128                 :            : 
     129                 :            : static __plt_always_inline void
     130                 :            : cn10k_nix_tx_mbuf_validate(struct rte_mbuf *m, const uint32_t flags)
     131                 :            : {
     132                 :            : #ifdef RTE_LIBRTE_MBUF_DEBUG
     133                 :            :         uint16_t segdw;
     134                 :            : 
     135                 :            :         segdw = cn10k_nix_mbuf_sg_dwords(m);
     136                 :            :         segdw += 1 + !!(flags & NIX_TX_NEED_EXT_HDR) + !!(flags & NIX_TX_OFFLOAD_TSTAMP_F);
     137                 :            : 
     138                 :            :         PLT_ASSERT(segdw <= 8);
     139                 :            : #else
     140                 :            :         RTE_SET_USED(m);
     141                 :            :         RTE_SET_USED(flags);
     142                 :            : #endif
     143                 :            : }
     144                 :            : 
     145                 :            : static __plt_always_inline void
     146                 :            : cn10k_nix_vwqe_wait_fc(struct cn10k_eth_txq *txq, uint16_t req)
     147                 :            : {
     148                 :            :         int64_t cached, refill;
     149                 :            :         int64_t pkts;
     150                 :            : 
     151                 :            : retry:
     152                 :            : #ifdef RTE_ARCH_ARM64
     153                 :            : 
     154                 :            :         asm volatile(PLT_CPU_FEATURE_PREAMBLE
     155                 :            :                      "             ldxr %[pkts], [%[addr]]                 \n"
     156                 :            :                      "             tbz %[pkts], 63, .Ldne%=                \n"
     157                 :            :                      "             sevl                                    \n"
     158                 :            :                      ".Lrty%=:     wfe                                     \n"
     159                 :            :                      "             ldxr %[pkts], [%[addr]]                 \n"
     160                 :            :                      "             tbnz %[pkts], 63, .Lrty%=               \n"
     161                 :            :                      ".Ldne%=:                                             \n"
     162                 :            :                      : [pkts] "=&r"(pkts)
     163                 :            :                      : [addr] "r"(&txq->fc_cache_pkts)
     164                 :            :                      : "memory");
     165                 :            : #else
     166                 :            :         RTE_SET_USED(pkts);
     167                 :            :         while (__atomic_load_n(&txq->fc_cache_pkts, __ATOMIC_RELAXED) < 0)
     168                 :            :                 ;
     169                 :            : #endif
     170                 :            :         cached = __atomic_fetch_sub(&txq->fc_cache_pkts, req, __ATOMIC_ACQUIRE) - req;
     171                 :            :         /* Check if there is enough space, else update and retry. */
     172                 :            :         if (cached >= 0)
     173                 :            :                 return;
     174                 :            : 
     175                 :            :         /* Check if we have space else retry. */
     176                 :            : #ifdef RTE_ARCH_ARM64
     177                 :            :         int64_t val;
     178                 :            : 
     179                 :            :         asm volatile(PLT_CPU_FEATURE_PREAMBLE
     180                 :            :                      "             ldxr %[val], [%[addr]]                  \n"
     181                 :            :                      "             sub %[val], %[adj], %[val]              \n"
     182                 :            :                      "             lsl %[refill], %[val], %[shft]          \n"
     183                 :            :                      "             sub %[refill], %[refill], %[val]        \n"
     184                 :            :                      "             sub %[refill], %[refill], %[sub]        \n"
     185                 :            :                      "             cmp %[refill], #0x0                     \n"
     186                 :            :                      "             b.ge .Ldne%=                            \n"
     187                 :            :                      "             sevl                                    \n"
     188                 :            :                      ".Lrty%=:     wfe                                     \n"
     189                 :            :                      "             ldxr %[val], [%[addr]]                  \n"
     190                 :            :                      "             sub %[val], %[adj], %[val]              \n"
     191                 :            :                      "             lsl %[refill], %[val], %[shft]          \n"
     192                 :            :                      "             sub %[refill], %[refill], %[val]        \n"
     193                 :            :                      "             sub %[refill], %[refill], %[sub]        \n"
     194                 :            :                      "             cmp %[refill], #0x0                     \n"
     195                 :            :                      "             b.lt .Lrty%=                            \n"
     196                 :            :                      ".Ldne%=:                                             \n"
     197                 :            :                      : [refill] "=&r"(refill), [val] "=&r" (val)
     198                 :            :                      : [addr] "r"(txq->fc_mem), [adj] "r"(txq->nb_sqb_bufs_adj),
     199                 :            :                        [shft] "r"(txq->sqes_per_sqb_log2), [sub] "r"(req)
     200                 :            :                      : "memory");
     201                 :            : #else
     202                 :            :         do {
     203                 :            :                 refill = (txq->nb_sqb_bufs_adj - __atomic_load_n(txq->fc_mem, __ATOMIC_RELAXED));
     204                 :            :                 refill = (refill << txq->sqes_per_sqb_log2) - refill;
     205                 :            :                 refill -= req;
     206                 :            :         } while (refill < 0);
     207                 :            : #endif
     208                 :            :         if (!__atomic_compare_exchange(&txq->fc_cache_pkts, &cached, &refill,
     209                 :            :                                   0, __ATOMIC_RELEASE,
     210                 :            :                                   __ATOMIC_RELAXED))
     211                 :            :                 goto retry;
     212                 :            : }
     213                 :            : 
     214                 :            : /* Function to determine no of tx subdesc required in case ext
     215                 :            :  * sub desc is enabled.
     216                 :            :  */
     217                 :            : static __rte_always_inline int
     218                 :            : cn10k_nix_tx_ext_subs(const uint16_t flags)
     219                 :            : {
     220                 :            :         return (flags & NIX_TX_OFFLOAD_TSTAMP_F) ?
     221         [ #  # ]:          0 :                              2 :
     222                 :            :                              ((flags &
     223                 :            :                          (NIX_TX_OFFLOAD_VLAN_QINQ_F | NIX_TX_OFFLOAD_TSO_F)) ?
     224                 :          0 :                                       1 :
     225                 :            :                                       0);
     226                 :            : }
     227                 :            : 
     228                 :            : static __rte_always_inline uint8_t
     229                 :            : cn10k_nix_tx_dwords(const uint16_t flags, const uint8_t segdw)
     230                 :            : {
     231                 :            :         if (!(flags & NIX_TX_MULTI_SEG_F))
     232                 :            :                 return cn10k_nix_tx_ext_subs(flags) + 2;
     233                 :            : 
     234                 :            :         /* Already everything is accounted for in segdw */
     235                 :            :         return segdw;
     236                 :            : }
     237                 :            : 
     238                 :            : static __rte_always_inline uint8_t
     239                 :            : cn10k_nix_pkts_per_vec_brst(const uint16_t flags)
     240                 :            : {
     241                 :            :         return ((flags & NIX_TX_NEED_EXT_HDR) ? 2 : 4)
     242                 :            :                << ROC_LMT_LINES_PER_CORE_LOG2;
     243                 :            : }
     244                 :            : 
     245                 :            : static __rte_always_inline uint8_t
     246                 :            : cn10k_nix_tx_dwords_per_line(const uint16_t flags)
     247                 :            : {
     248                 :            :         return (flags & NIX_TX_NEED_EXT_HDR) ?
     249                 :            :                              ((flags & NIX_TX_OFFLOAD_TSTAMP_F) ? 8 : 6) :
     250                 :            :                              8;
     251                 :            : }
     252                 :            : 
     253                 :            : static __rte_always_inline uint64_t
     254                 :            : cn10k_nix_tx_steor_data(const uint16_t flags)
     255                 :            : {
     256                 :            :         const uint64_t dw_m1 = cn10k_nix_tx_ext_subs(flags) + 1;
     257                 :            :         uint64_t data;
     258                 :            : 
     259                 :            :         /* This will be moved to addr area */
     260                 :            :         data = dw_m1;
     261                 :            :         /* 15 vector sizes for single seg */
     262                 :            :         data |= dw_m1 << 19;
     263                 :            :         data |= dw_m1 << 22;
     264                 :            :         data |= dw_m1 << 25;
     265                 :            :         data |= dw_m1 << 28;
     266                 :            :         data |= dw_m1 << 31;
     267                 :            :         data |= dw_m1 << 34;
     268                 :            :         data |= dw_m1 << 37;
     269                 :            :         data |= dw_m1 << 40;
     270                 :            :         data |= dw_m1 << 43;
     271                 :            :         data |= dw_m1 << 46;
     272                 :            :         data |= dw_m1 << 49;
     273                 :            :         data |= dw_m1 << 52;
     274                 :            :         data |= dw_m1 << 55;
     275                 :            :         data |= dw_m1 << 58;
     276                 :            :         data |= dw_m1 << 61;
     277                 :            : 
     278                 :            :         return data;
     279                 :            : }
     280                 :            : 
     281                 :            : static __rte_always_inline uint8_t
     282                 :            : cn10k_nix_tx_dwords_per_line_seg(const uint16_t flags)
     283                 :            : {
     284                 :            :         return ((flags & NIX_TX_NEED_EXT_HDR) ?
     285                 :            :                               (flags & NIX_TX_OFFLOAD_TSTAMP_F) ? 8 : 6 :
     286                 :            :                               4);
     287                 :            : }
     288                 :            : 
     289                 :            : static __rte_always_inline uint64_t
     290                 :            : cn10k_nix_tx_steor_vec_data(const uint16_t flags)
     291                 :            : {
     292                 :            :         const uint64_t dw_m1 = cn10k_nix_tx_dwords_per_line(flags) - 1;
     293                 :            :         uint64_t data;
     294                 :            : 
     295                 :            :         /* This will be moved to addr area */
     296                 :            :         data = dw_m1;
     297                 :            :         /* 15 vector sizes for single seg */
     298                 :            :         data |= dw_m1 << 19;
     299                 :            :         data |= dw_m1 << 22;
     300                 :            :         data |= dw_m1 << 25;
     301                 :            :         data |= dw_m1 << 28;
     302                 :            :         data |= dw_m1 << 31;
     303                 :            :         data |= dw_m1 << 34;
     304                 :            :         data |= dw_m1 << 37;
     305                 :            :         data |= dw_m1 << 40;
     306                 :            :         data |= dw_m1 << 43;
     307                 :            :         data |= dw_m1 << 46;
     308                 :            :         data |= dw_m1 << 49;
     309                 :            :         data |= dw_m1 << 52;
     310                 :            :         data |= dw_m1 << 55;
     311                 :            :         data |= dw_m1 << 58;
     312                 :            :         data |= dw_m1 << 61;
     313                 :            : 
     314                 :            :         return data;
     315                 :            : }
     316                 :            : 
     317                 :            : static __rte_always_inline void
     318                 :            : cn10k_nix_tx_skeleton(struct cn10k_eth_txq *txq, uint64_t *cmd,
     319                 :            :                       const uint16_t flags, const uint16_t static_sz)
     320                 :            : {
     321                 :            :         if (static_sz)
     322                 :            :                 cmd[0] = txq->send_hdr_w0;
     323                 :            :         else
     324                 :            :                 cmd[0] = (txq->send_hdr_w0 & 0xFFFFF00000000000) |
     325                 :            :                          ((uint64_t)(cn10k_nix_tx_ext_subs(flags) + 1) << 40);
     326                 :            :         cmd[1] = 0;
     327                 :            : 
     328                 :            :         if (flags & NIX_TX_NEED_EXT_HDR) {
     329                 :            :                 if (flags & NIX_TX_OFFLOAD_TSTAMP_F)
     330                 :            :                         cmd[2] = (NIX_SUBDC_EXT << 60) | BIT_ULL(15);
     331                 :            :                 else
     332                 :            :                         cmd[2] = NIX_SUBDC_EXT << 60;
     333                 :            :                 cmd[3] = 0;
     334                 :            :                 if (!(flags & NIX_TX_OFFLOAD_MBUF_NOFF_F))
     335                 :            :                         cmd[4] = (NIX_SUBDC_SG << 60) | (NIX_SENDLDTYPE_LDWB << 58) | BIT_ULL(48);
     336                 :            :                 else
     337                 :            :                         cmd[4] = (NIX_SUBDC_SG << 60) | BIT_ULL(48);
     338                 :            :         } else {
     339                 :            :                 if (!(flags & NIX_TX_OFFLOAD_MBUF_NOFF_F))
     340                 :            :                         cmd[2] = (NIX_SUBDC_SG << 60) | (NIX_SENDLDTYPE_LDWB << 58) | BIT_ULL(48);
     341                 :            :                 else
     342                 :            :                         cmd[2] = (NIX_SUBDC_SG << 60) | BIT_ULL(48);
     343                 :            :         }
     344                 :            : }
     345                 :            : 
     346                 :            : static __rte_always_inline void
     347                 :            : cn10k_nix_sec_fc_wait_one(struct cn10k_eth_txq *txq)
     348                 :            : {
     349                 :            :         uint64_t nb_desc = txq->cpt_desc;
     350                 :            :         uint64_t fc;
     351                 :            : 
     352                 :            : #ifdef RTE_ARCH_ARM64
     353                 :            :         asm volatile(PLT_CPU_FEATURE_PREAMBLE
     354                 :            :                      "             ldxr %[space], [%[addr]]                \n"
     355                 :            :                      "             cmp %[nb_desc], %[space]                \n"
     356                 :            :                      "             b.hi .Ldne%=                            \n"
     357                 :            :                      "             sevl                                    \n"
     358                 :            :                      ".Lrty%=:     wfe                                     \n"
     359                 :            :                      "             ldxr %[space], [%[addr]]                \n"
     360                 :            :                      "             cmp %[nb_desc], %[space]                \n"
     361                 :            :                      "             b.ls .Lrty%=                            \n"
     362                 :            :                      ".Ldne%=:                                             \n"
     363                 :            :                      : [space] "=&r"(fc)
     364                 :            :                      : [nb_desc] "r"(nb_desc), [addr] "r"(txq->cpt_fc)
     365                 :            :                      : "memory");
     366                 :            : #else
     367                 :            :         RTE_SET_USED(fc);
     368                 :            :         while (nb_desc <= __atomic_load_n(txq->cpt_fc, __ATOMIC_RELAXED))
     369                 :            :                 ;
     370                 :            : #endif
     371                 :            : }
     372                 :            : 
     373                 :            : static __rte_always_inline void
     374                 :            : cn10k_nix_sec_fc_wait(struct cn10k_eth_txq *txq, uint16_t nb_pkts)
     375                 :            : {
     376                 :            :         int32_t nb_desc, val, newval;
     377                 :            :         int32_t *fc_sw;
     378                 :            :         uint64_t *fc;
     379                 :            : 
     380                 :            :         /* Check if there is any CPT instruction to submit */
     381                 :            :         if (!nb_pkts)
     382                 :            :                 return;
     383                 :            : 
     384                 :            : again:
     385                 :            :         fc_sw = txq->cpt_fc_sw;
     386                 :            : #ifdef RTE_ARCH_ARM64
     387                 :            :         asm volatile(PLT_CPU_FEATURE_PREAMBLE
     388                 :            :                      "             ldxr %w[pkts], [%[addr]]                \n"
     389                 :            :                      "             tbz %w[pkts], 31, .Ldne%=               \n"
     390                 :            :                      "             sevl                                    \n"
     391                 :            :                      ".Lrty%=:     wfe                                     \n"
     392                 :            :                      "             ldxr %w[pkts], [%[addr]]                \n"
     393                 :            :                      "             tbnz %w[pkts], 31, .Lrty%=              \n"
     394                 :            :                      ".Ldne%=:                                             \n"
     395                 :            :                      : [pkts] "=&r"(val)
     396                 :            :                      : [addr] "r"(fc_sw)
     397                 :            :                      : "memory");
     398                 :            : #else
     399                 :            :         /* Wait for primary core to refill FC. */
     400                 :            :         while (__atomic_load_n(fc_sw, __ATOMIC_RELAXED) < 0)
     401                 :            :                 ;
     402                 :            : #endif
     403                 :            : 
     404                 :            :         val = __atomic_fetch_sub(fc_sw, nb_pkts, __ATOMIC_ACQUIRE) - nb_pkts;
     405                 :            :         if (likely(val >= 0))
     406                 :            :                 return;
     407                 :            : 
     408                 :            :         nb_desc = txq->cpt_desc;
     409                 :            :         fc = txq->cpt_fc;
     410                 :            : #ifdef RTE_ARCH_ARM64
     411                 :            :         asm volatile(PLT_CPU_FEATURE_PREAMBLE
     412                 :            :                      "             ldxr %[refill], [%[addr]]               \n"
     413                 :            :                      "             sub %[refill], %[desc], %[refill]       \n"
     414                 :            :                      "             sub %[refill], %[refill], %[pkts]       \n"
     415                 :            :                      "             cmp %[refill], #0x0                     \n"
     416                 :            :                      "             b.ge .Ldne%=                            \n"
     417                 :            :                      "             sevl                                    \n"
     418                 :            :                      ".Lrty%=:     wfe                                     \n"
     419                 :            :                      "             ldxr %[refill], [%[addr]]               \n"
     420                 :            :                      "             sub %[refill], %[desc], %[refill]       \n"
     421                 :            :                      "             sub %[refill], %[refill], %[pkts]       \n"
     422                 :            :                      "             cmp %[refill], #0x0                     \n"
     423                 :            :                      "             b.lt .Lrty%=                            \n"
     424                 :            :                      ".Ldne%=:                                             \n"
     425                 :            :                      : [refill] "=&r"(newval)
     426                 :            :                      : [addr] "r"(fc), [desc] "r"(nb_desc), [pkts] "r"(nb_pkts)
     427                 :            :                      : "memory");
     428                 :            : #else
     429                 :            :         while (true) {
     430                 :            :                 newval = nb_desc - __atomic_load_n(fc, __ATOMIC_RELAXED);
     431                 :            :                 newval -= nb_pkts;
     432                 :            :                 if (newval >= 0)
     433                 :            :                         break;
     434                 :            :         }
     435                 :            : #endif
     436                 :            : 
     437                 :            :         if (!__atomic_compare_exchange_n(fc_sw, &val, newval, false, __ATOMIC_RELEASE,
     438                 :            :                                          __ATOMIC_RELAXED))
     439                 :            :                 goto again;
     440                 :            : }
     441                 :            : 
     442                 :            : #if defined(RTE_ARCH_ARM64)
     443                 :            : static __rte_always_inline void
     444                 :            : cn10k_nix_prep_sec_vec(struct rte_mbuf *m, uint64x2_t *cmd0, uint64x2_t *cmd1,
     445                 :            :                        uintptr_t *nixtx_addr, uintptr_t lbase, uint8_t *lnum,
     446                 :            :                        uint8_t *loff, uint8_t *shft, uint64_t sa_base,
     447                 :            :                        const uint16_t flags)
     448                 :            : {
     449                 :            :         struct cn10k_sec_sess_priv sess_priv;
     450                 :            :         uint32_t pkt_len, dlen_adj, rlen;
     451                 :            :         uint8_t l3l4type, chksum;
     452                 :            :         uint64x2_t cmd01, cmd23;
     453                 :            :         uint8_t l2_len, l3_len;
     454                 :            :         uintptr_t dptr, nixtx;
     455                 :            :         uint64_t ucode_cmd[4];
     456                 :            :         uint64_t *laddr, w0;
     457                 :            :         uint16_t tag;
     458                 :            :         uint64_t sa;
     459                 :            : 
     460                 :            :         sess_priv.u64 = *rte_security_dynfield(m);
     461                 :            : 
     462                 :            :         if (flags & NIX_TX_NEED_SEND_HDR_W1) {
     463                 :            :                 /* Extract l3l4type either from il3il4type or ol3ol4type */
     464                 :            :                 if (flags & NIX_TX_OFFLOAD_L3_L4_CSUM_F &&
     465                 :            :                     flags & NIX_TX_OFFLOAD_OL3_OL4_CSUM_F) {
     466                 :            :                         l2_len = vgetq_lane_u8(*cmd0, 10);
     467                 :            :                         /* L4 ptr from send hdr includes l2 and l3 len */
     468                 :            :                         l3_len = vgetq_lane_u8(*cmd0, 11) - l2_len;
     469                 :            :                         l3l4type = vgetq_lane_u8(*cmd0, 13);
     470                 :            :                 } else {
     471                 :            :                         l2_len = vgetq_lane_u8(*cmd0, 8);
     472                 :            :                         /* L4 ptr from send hdr includes l2 and l3 len */
     473                 :            :                         l3_len = vgetq_lane_u8(*cmd0, 9) - l2_len;
     474                 :            :                         l3l4type = vgetq_lane_u8(*cmd0, 12);
     475                 :            :                 }
     476                 :            : 
     477                 :            :                 chksum = (l3l4type & 0x1) << 1 | !!(l3l4type & 0x30);
     478                 :            :                 chksum = ~chksum;
     479                 :            :                 sess_priv.chksum = sess_priv.chksum & chksum;
     480                 :            :                 /* Clear SEND header flags */
     481                 :            :                 *cmd0 = vsetq_lane_u16(0, *cmd0, 6);
     482                 :            :         } else {
     483                 :            :                 l2_len = m->l2_len;
     484                 :            :                 l3_len = m->l3_len;
     485                 :            :         }
     486                 :            : 
     487                 :            :         /* Retrieve DPTR */
     488                 :            :         dptr = vgetq_lane_u64(*cmd1, 1);
     489                 :            :         pkt_len = vgetq_lane_u16(*cmd0, 0);
     490                 :            : 
     491                 :            :         /* Calculate dlen adj */
     492                 :            :         dlen_adj = pkt_len - l2_len;
     493                 :            :         /* Exclude l3 len from roundup for transport mode */
     494                 :            :         dlen_adj -= sess_priv.mode ? 0 : l3_len;
     495                 :            :         rlen = (dlen_adj + sess_priv.roundup_len) +
     496                 :            :                (sess_priv.roundup_byte - 1);
     497                 :            :         rlen &= ~(uint64_t)(sess_priv.roundup_byte - 1);
     498                 :            :         rlen += sess_priv.partial_len;
     499                 :            :         dlen_adj = rlen - dlen_adj;
     500                 :            : 
     501                 :            :         /* Update send descriptors. Security is single segment only */
     502                 :            :         *cmd0 = vsetq_lane_u16(pkt_len + dlen_adj, *cmd0, 0);
     503                 :            : 
     504                 :            :         /* CPT word 5 and word 6 */
     505                 :            :         w0 = 0;
     506                 :            :         ucode_cmd[2] = 0;
     507                 :            :         if (flags & NIX_TX_MULTI_SEG_F && m->nb_segs > 1) {
     508                 :            :                 struct rte_mbuf *last = rte_pktmbuf_lastseg(m);
     509                 :            : 
     510                 :            :                 /* Get area where NIX descriptor needs to be stored */
     511                 :            :                 nixtx = rte_pktmbuf_mtod_offset(last, uintptr_t, last->data_len + dlen_adj);
     512                 :            :                 nixtx += BIT_ULL(7);
     513                 :            :                 nixtx = (nixtx - 1) & ~(BIT_ULL(7) - 1);
     514                 :            :                 nixtx += 16;
     515                 :            : 
     516                 :            :                 dptr = nixtx + ((flags & NIX_TX_NEED_EXT_HDR) ? 32 : 16);
     517                 :            : 
     518                 :            :                 /* Set l2 length as data offset */
     519                 :            :                 w0 = (uint64_t)l2_len << 16;
     520                 :            :                 w0 |= cn10k_nix_tx_ext_subs(flags) + NIX_NB_SEGS_TO_SEGDW(m->nb_segs);
     521                 :            :                 ucode_cmd[1] = dptr | ((uint64_t)m->nb_segs << 60);
     522                 :            :         } else {
     523                 :            :                 /* Get area where NIX descriptor needs to be stored */
     524                 :            :                 nixtx = dptr + pkt_len + dlen_adj;
     525                 :            :                 nixtx += BIT_ULL(7);
     526                 :            :                 nixtx = (nixtx - 1) & ~(BIT_ULL(7) - 1);
     527                 :            :                 nixtx += 16;
     528                 :            : 
     529                 :            :                 w0 |= cn10k_nix_tx_ext_subs(flags) + 1ULL;
     530                 :            :                 dptr += l2_len;
     531                 :            :                 ucode_cmd[1] = dptr;
     532                 :            :                 *cmd1 = vsetq_lane_u16(pkt_len + dlen_adj, *cmd1, 0);
     533                 :            :                 /* DLEN passed is excluding L2 HDR */
     534                 :            :                 pkt_len -= l2_len;
     535                 :            :         }
     536                 :            :         w0 |= sess_priv.nixtx_off ? ((((int64_t)nixtx - (int64_t)dptr) & 0xFFFFF) << 32) : nixtx;
     537                 :            :         /* CPT word 0 and 1 */
     538                 :            :         cmd01 = vdupq_n_u64(0);
     539                 :            :         cmd01 = vsetq_lane_u64(w0, cmd01, 0);
     540                 :            :         /* CPT_RES_S is 16B above NIXTX */
     541                 :            :         cmd01 = vsetq_lane_u64(nixtx - 16, cmd01, 1);
     542                 :            : 
     543                 :            :         /* Return nixtx addr */
     544                 :            :         *nixtx_addr = nixtx;
     545                 :            : 
     546                 :            :         /* CPT Word 4 and Word 7 */
     547                 :            :         tag = sa_base & 0xFFFFUL;
     548                 :            :         sa_base &= ~0xFFFFUL;
     549                 :            :         sa = (uintptr_t)roc_nix_inl_ot_ipsec_outb_sa(sa_base, sess_priv.sa_idx);
     550                 :            :         ucode_cmd[3] = (ROC_CPT_DFLT_ENG_GRP_SE_IE << 61 | 1UL << 60 | sa);
     551                 :            :         ucode_cmd[0] = (ROC_IE_OT_MAJOR_OP_PROCESS_OUTBOUND_IPSEC << 48 | 1UL << 54 |
     552                 :            :                         ((uint64_t)sess_priv.chksum) << 32 | ((uint64_t)sess_priv.dec_ttl) << 34 |
     553                 :            :                         pkt_len);
     554                 :            : 
     555                 :            :         /* CPT word 2 and 3 */
     556                 :            :         cmd23 = vdupq_n_u64(0);
     557                 :            :         cmd23 = vsetq_lane_u64((((uint64_t)RTE_EVENT_TYPE_CPU << 28) | tag |
     558                 :            :                                 CNXK_ETHDEV_SEC_OUTB_EV_SUB << 20), cmd23, 0);
     559                 :            :         cmd23 = vsetq_lane_u64((uintptr_t)m | 1, cmd23, 1);
     560                 :            : 
     561                 :            :         /* Move to our line */
     562                 :            :         laddr = LMT_OFF(lbase, *lnum, *loff ? 64 : 0);
     563                 :            : 
     564                 :            :         /* Write CPT instruction to lmt line */
     565                 :            :         vst1q_u64(laddr, cmd01);
     566                 :            :         vst1q_u64((laddr + 2), cmd23);
     567                 :            : 
     568                 :            :         *(__uint128_t *)(laddr + 4) = *(__uint128_t *)ucode_cmd;
     569                 :            :         *(__uint128_t *)(laddr + 6) = *(__uint128_t *)(ucode_cmd + 2);
     570                 :            : 
     571                 :            :         /* Move to next line for every other CPT inst */
     572                 :            :         *loff = !(*loff);
     573                 :            :         *lnum = *lnum + (*loff ? 0 : 1);
     574                 :            :         *shft = *shft + (*loff ? 0 : 3);
     575                 :            : }
     576                 :            : 
     577                 :            : static __rte_always_inline void
     578                 :            : cn10k_nix_prep_sec(struct rte_mbuf *m, uint64_t *cmd, uintptr_t *nixtx_addr,
     579                 :            :                    uintptr_t lbase, uint8_t *lnum, uint8_t *loff, uint8_t *shft,
     580                 :            :                    uint64_t sa_base, const uint16_t flags)
     581                 :            : {
     582                 :            :         struct cn10k_sec_sess_priv sess_priv;
     583                 :            :         uint32_t pkt_len, dlen_adj, rlen;
     584                 :            :         struct nix_send_hdr_s *send_hdr;
     585                 :            :         uint8_t l3l4type, chksum;
     586                 :            :         uint64x2_t cmd01, cmd23;
     587                 :            :         union nix_send_sg_s *sg;
     588                 :            :         uint8_t l2_len, l3_len;
     589                 :            :         uintptr_t dptr, nixtx;
     590                 :            :         uint64_t ucode_cmd[4];
     591                 :            :         uint64_t *laddr, w0;
     592                 :            :         uint16_t tag;
     593                 :            :         uint64_t sa;
     594                 :            : 
     595                 :            :         /* Move to our line from base */
     596                 :            :         sess_priv.u64 = *rte_security_dynfield(m);
     597                 :            :         send_hdr = (struct nix_send_hdr_s *)cmd;
     598                 :            :         if (flags & NIX_TX_NEED_EXT_HDR)
     599                 :            :                 sg = (union nix_send_sg_s *)&cmd[4];
     600                 :            :         else
     601                 :            :                 sg = (union nix_send_sg_s *)&cmd[2];
     602                 :            : 
     603                 :            :         if (flags & NIX_TX_NEED_SEND_HDR_W1) {
     604                 :            :                 /* Extract l3l4type either from il3il4type or ol3ol4type */
     605                 :            :                 if (flags & NIX_TX_OFFLOAD_L3_L4_CSUM_F &&
     606                 :            :                     flags & NIX_TX_OFFLOAD_OL3_OL4_CSUM_F) {
     607                 :            :                         l2_len = (cmd[1] >> 16) & 0xFF;
     608                 :            :                         /* L4 ptr from send hdr includes l2 and l3 len */
     609                 :            :                         l3_len = ((cmd[1] >> 24) & 0xFF) - l2_len;
     610                 :            :                         l3l4type = (cmd[1] >> 40) & 0xFF;
     611                 :            :                 } else {
     612                 :            :                         l2_len = cmd[1] & 0xFF;
     613                 :            :                         /* L4 ptr from send hdr includes l2 and l3 len */
     614                 :            :                         l3_len = ((cmd[1] >> 8) & 0xFF) - l2_len;
     615                 :            :                         l3l4type = (cmd[1] >> 32) & 0xFF;
     616                 :            :                 }
     617                 :            : 
     618                 :            :                 chksum = (l3l4type & 0x1) << 1 | !!(l3l4type & 0x30);
     619                 :            :                 chksum = ~chksum;
     620                 :            :                 sess_priv.chksum = sess_priv.chksum & chksum;
     621                 :            :                 /* Clear SEND header flags */
     622                 :            :                 cmd[1] &= ~(0xFFFFUL << 32);
     623                 :            :         } else {
     624                 :            :                 l2_len = m->l2_len;
     625                 :            :                 l3_len = m->l3_len;
     626                 :            :         }
     627                 :            : 
     628                 :            :         /* Retrieve DPTR */
     629                 :            :         dptr = *(uint64_t *)(sg + 1);
     630                 :            :         pkt_len = send_hdr->w0.total;
     631                 :            : 
     632                 :            :         /* Calculate dlen adj */
     633                 :            :         dlen_adj = pkt_len - l2_len;
     634                 :            :         /* Exclude l3 len from roundup for transport mode */
     635                 :            :         dlen_adj -= sess_priv.mode ? 0 : l3_len;
     636                 :            :         rlen = (dlen_adj + sess_priv.roundup_len) +
     637                 :            :                (sess_priv.roundup_byte - 1);
     638                 :            :         rlen &= ~(uint64_t)(sess_priv.roundup_byte - 1);
     639                 :            :         rlen += sess_priv.partial_len;
     640                 :            :         dlen_adj = rlen - dlen_adj;
     641                 :            : 
     642                 :            :         /* Update send descriptors. Security is single segment only */
     643                 :            :         send_hdr->w0.total = pkt_len + dlen_adj;
     644                 :            : 
     645                 :            :         /* CPT word 5 and word 6 */
     646                 :            :         w0 = 0;
     647                 :            :         ucode_cmd[2] = 0;
     648                 :            :         if (flags & NIX_TX_MULTI_SEG_F && m->nb_segs > 1) {
     649                 :            :                 struct rte_mbuf *last = rte_pktmbuf_lastseg(m);
     650                 :            : 
     651                 :            :                 /* Get area where NIX descriptor needs to be stored */
     652                 :            :                 nixtx = rte_pktmbuf_mtod_offset(last, uintptr_t, last->data_len + dlen_adj);
     653                 :            :                 nixtx += BIT_ULL(7);
     654                 :            :                 nixtx = (nixtx - 1) & ~(BIT_ULL(7) - 1);
     655                 :            :                 nixtx += 16;
     656                 :            : 
     657                 :            :                 dptr = nixtx + ((flags & NIX_TX_NEED_EXT_HDR) ? 32 : 16);
     658                 :            : 
     659                 :            :                 /* Set l2 length as data offset */
     660                 :            :                 w0 = (uint64_t)l2_len << 16;
     661                 :            :                 w0 |= cn10k_nix_tx_ext_subs(flags) + NIX_NB_SEGS_TO_SEGDW(m->nb_segs);
     662                 :            :                 ucode_cmd[1] = dptr | ((uint64_t)m->nb_segs << 60);
     663                 :            :         } else {
     664                 :            :                 /* Get area where NIX descriptor needs to be stored */
     665                 :            :                 nixtx = dptr + pkt_len + dlen_adj;
     666                 :            :                 nixtx += BIT_ULL(7);
     667                 :            :                 nixtx = (nixtx - 1) & ~(BIT_ULL(7) - 1);
     668                 :            :                 nixtx += 16;
     669                 :            : 
     670                 :            :                 w0 |= cn10k_nix_tx_ext_subs(flags) + 1ULL;
     671                 :            :                 dptr += l2_len;
     672                 :            :                 ucode_cmd[1] = dptr;
     673                 :            :                 sg->seg1_size = pkt_len + dlen_adj;
     674                 :            :                 pkt_len -= l2_len;
     675                 :            :         }
     676                 :            :         w0 |= sess_priv.nixtx_off ? ((((int64_t)nixtx - (int64_t)dptr) & 0xFFFFF) << 32) : nixtx;
     677                 :            :         /* CPT word 0 and 1 */
     678                 :            :         cmd01 = vdupq_n_u64(0);
     679                 :            :         cmd01 = vsetq_lane_u64(w0, cmd01, 0);
     680                 :            :         /* CPT_RES_S is 16B above NIXTX */
     681                 :            :         cmd01 = vsetq_lane_u64(nixtx - 16, cmd01, 1);
     682                 :            : 
     683                 :            :         /* Return nixtx addr */
     684                 :            :         *nixtx_addr = nixtx;
     685                 :            : 
     686                 :            :         /* CPT Word 4 and Word 7 */
     687                 :            :         tag = sa_base & 0xFFFFUL;
     688                 :            :         sa_base &= ~0xFFFFUL;
     689                 :            :         sa = (uintptr_t)roc_nix_inl_ot_ipsec_outb_sa(sa_base, sess_priv.sa_idx);
     690                 :            :         ucode_cmd[3] = (ROC_CPT_DFLT_ENG_GRP_SE_IE << 61 | 1UL << 60 | sa);
     691                 :            :         ucode_cmd[0] = (ROC_IE_OT_MAJOR_OP_PROCESS_OUTBOUND_IPSEC << 48 | 1UL << 54 |
     692                 :            :                         ((uint64_t)sess_priv.chksum) << 32 | ((uint64_t)sess_priv.dec_ttl) << 34 |
     693                 :            :                         pkt_len);
     694                 :            : 
     695                 :            :         /* CPT word 2 and 3 */
     696                 :            :         cmd23 = vdupq_n_u64(0);
     697                 :            :         cmd23 = vsetq_lane_u64((((uint64_t)RTE_EVENT_TYPE_CPU << 28) | tag |
     698                 :            :                                 CNXK_ETHDEV_SEC_OUTB_EV_SUB << 20), cmd23, 0);
     699                 :            :         cmd23 = vsetq_lane_u64((uintptr_t)m | 1, cmd23, 1);
     700                 :            : 
     701                 :            :         /* Move to our line */
     702                 :            :         laddr = LMT_OFF(lbase, *lnum, *loff ? 64 : 0);
     703                 :            : 
     704                 :            :         /* Write CPT instruction to lmt line */
     705                 :            :         vst1q_u64(laddr, cmd01);
     706                 :            :         vst1q_u64((laddr + 2), cmd23);
     707                 :            : 
     708                 :            :         *(__uint128_t *)(laddr + 4) = *(__uint128_t *)ucode_cmd;
     709                 :            :         *(__uint128_t *)(laddr + 6) = *(__uint128_t *)(ucode_cmd + 2);
     710                 :            : 
     711                 :            :         /* Move to next line for every other CPT inst */
     712                 :            :         *loff = !(*loff);
     713                 :            :         *lnum = *lnum + (*loff ? 0 : 1);
     714                 :            :         *shft = *shft + (*loff ? 0 : 3);
     715                 :            : }
     716                 :            : 
     717                 :            : #else
     718                 :            : 
     719                 :            : static __rte_always_inline void
     720                 :            : cn10k_nix_prep_sec(struct rte_mbuf *m, uint64_t *cmd, uintptr_t *nixtx_addr,
     721                 :            :                    uintptr_t lbase, uint8_t *lnum, uint8_t *loff, uint8_t *shft,
     722                 :            :                    uint64_t sa_base, const uint16_t flags)
     723                 :            : {
     724                 :            :         RTE_SET_USED(m);
     725                 :            :         RTE_SET_USED(cmd);
     726                 :            :         RTE_SET_USED(nixtx_addr);
     727                 :            :         RTE_SET_USED(lbase);
     728                 :            :         RTE_SET_USED(lnum);
     729                 :            :         RTE_SET_USED(loff);
     730                 :            :         RTE_SET_USED(shft);
     731                 :            :         RTE_SET_USED(sa_base);
     732                 :            :         RTE_SET_USED(flags);
     733                 :            : }
     734                 :            : #endif
     735                 :            : 
     736                 :            : static inline void
     737                 :            : cn10k_nix_free_extmbuf(struct rte_mbuf *m)
     738                 :            : {
     739                 :            :         struct rte_mbuf *m_next;
     740                 :            :         while (m != NULL) {
     741                 :            :                 m_next = m->next;
     742                 :            :                 rte_pktmbuf_free_seg(m);
     743                 :            :                 m = m_next;
     744                 :            :         }
     745                 :            : }
     746                 :            : 
     747                 :            : static __rte_always_inline uint64_t
     748                 :            : cn10k_nix_prefree_seg(struct rte_mbuf *m, struct rte_mbuf **extm, struct cn10k_eth_txq *txq,
     749                 :            :                       struct nix_send_hdr_s *send_hdr, uint64_t *aura)
     750                 :            : {
     751                 :            :         struct rte_mbuf *prev = NULL;
     752                 :            :         uint32_t sqe_id;
     753                 :            : 
     754                 :            :         if (RTE_MBUF_HAS_EXTBUF(m)) {
     755                 :            :                 if (unlikely(txq->tx_compl.ena == 0)) {
     756                 :            :                         m->next = *extm;
     757                 :            :                         *extm = m;
     758                 :            :                         return 1;
     759                 :            :                 }
     760                 :            :                 if (send_hdr->w0.pnc) {
     761                 :            :                         sqe_id = send_hdr->w1.sqe_id;
     762                 :            :                         prev = txq->tx_compl.ptr[sqe_id];
     763                 :            :                         m->next = prev;
     764                 :            :                         txq->tx_compl.ptr[sqe_id] = m;
     765                 :            :                 } else {
     766                 :            :                         sqe_id = __atomic_fetch_add(&txq->tx_compl.sqe_id, 1, __ATOMIC_RELAXED);
     767                 :            :                         send_hdr->w0.pnc = 1;
     768                 :            :                         send_hdr->w1.sqe_id = sqe_id &
     769                 :            :                                 txq->tx_compl.nb_desc_mask;
     770                 :            :                         txq->tx_compl.ptr[send_hdr->w1.sqe_id] = m;
     771                 :            :                 }
     772                 :            :                 return 1;
     773                 :            :         } else {
     774                 :            :                 return cnxk_nix_prefree_seg(m, aura);
     775                 :            :         }
     776                 :            : }
     777                 :            : 
     778                 :            : #if defined(RTE_ARCH_ARM64)
     779                 :            : /* Only called for first segments of single segmented mbufs */
     780                 :            : static __rte_always_inline void
     781                 :            : cn10k_nix_prefree_seg_vec(struct rte_mbuf **mbufs, struct rte_mbuf **extm,
     782                 :            :                           struct cn10k_eth_txq *txq,
     783                 :            :                           uint64x2_t *senddesc01_w0, uint64x2_t *senddesc23_w0,
     784                 :            :                           uint64x2_t *senddesc01_w1, uint64x2_t *senddesc23_w1)
     785                 :            : {
     786                 :            :         struct rte_mbuf **tx_compl_ptr = txq->tx_compl.ptr;
     787                 :            :         uint32_t nb_desc_mask = txq->tx_compl.nb_desc_mask;
     788                 :            :         bool tx_compl_ena = txq->tx_compl.ena;
     789                 :            :         struct rte_mbuf *m0, *m1, *m2, *m3;
     790                 :            :         struct rte_mbuf *cookie;
     791                 :            :         uint64_t w0, w1, aura;
     792                 :            :         uint64_t sqe_id;
     793                 :            : 
     794                 :            :         m0 = mbufs[0];
     795                 :            :         m1 = mbufs[1];
     796                 :            :         m2 = mbufs[2];
     797                 :            :         m3 = mbufs[3];
     798                 :            : 
     799                 :            :         /* mbuf 0 */
     800                 :            :         w0 = vgetq_lane_u64(*senddesc01_w0, 0);
     801                 :            :         if (RTE_MBUF_HAS_EXTBUF(m0)) {
     802                 :            :                 w0 |= BIT_ULL(19);
     803                 :            :                 w1 = vgetq_lane_u64(*senddesc01_w1, 0);
     804                 :            :                 w1 &= ~0xFFFF000000000000UL;
     805                 :            :                 if (unlikely(!tx_compl_ena)) {
     806                 :            :                         m0->next = *extm;
     807                 :            :                         *extm = m0;
     808                 :            :                 } else {
     809                 :            :                         sqe_id = rte_atomic_fetch_add_explicit(&txq->tx_compl.sqe_id, 1,
     810                 :            :                                                                rte_memory_order_relaxed);
     811                 :            :                         sqe_id = sqe_id & nb_desc_mask;
     812                 :            :                         /* Set PNC */
     813                 :            :                         w0 |= BIT_ULL(43);
     814                 :            :                         w1 |= sqe_id << 48;
     815                 :            :                         tx_compl_ptr[sqe_id] = m0;
     816                 :            :                         *senddesc01_w1 = vsetq_lane_u64(w1, *senddesc01_w1, 0);
     817                 :            :                 }
     818                 :            :         } else {
     819                 :            :                 cookie = RTE_MBUF_DIRECT(m0) ? m0 : rte_mbuf_from_indirect(m0);
     820                 :            :                 aura = (w0 >> 20) & 0xFFFFF;
     821                 :            :                 w0 &= ~0xFFFFF00000UL;
     822                 :            :                 w0 |= cnxk_nix_prefree_seg(m0, &aura) << 19;
     823                 :            :                 w0 |= aura << 20;
     824                 :            : 
     825                 :            :                 if ((w0 & BIT_ULL(19)) == 0)
     826                 :            :                         RTE_MEMPOOL_CHECK_COOKIES(cookie->pool, (void **)&cookie, 1, 0);
     827                 :            :         }
     828                 :            :         *senddesc01_w0 = vsetq_lane_u64(w0, *senddesc01_w0, 0);
     829                 :            : 
     830                 :            :         /* mbuf1 */
     831                 :            :         w0 = vgetq_lane_u64(*senddesc01_w0, 1);
     832                 :            :         if (RTE_MBUF_HAS_EXTBUF(m1)) {
     833                 :            :                 w0 |= BIT_ULL(19);
     834                 :            :                 w1 = vgetq_lane_u64(*senddesc01_w1, 1);
     835                 :            :                 w1 &= ~0xFFFF000000000000UL;
     836                 :            :                 if (unlikely(!tx_compl_ena)) {
     837                 :            :                         m1->next = *extm;
     838                 :            :                         *extm = m1;
     839                 :            :                 } else {
     840                 :            :                         sqe_id = rte_atomic_fetch_add_explicit(&txq->tx_compl.sqe_id, 1,
     841                 :            :                                                                rte_memory_order_relaxed);
     842                 :            :                         sqe_id = sqe_id & nb_desc_mask;
     843                 :            :                         /* Set PNC */
     844                 :            :                         w0 |= BIT_ULL(43);
     845                 :            :                         w1 |= sqe_id << 48;
     846                 :            :                         tx_compl_ptr[sqe_id] = m1;
     847                 :            :                         *senddesc01_w1 = vsetq_lane_u64(w1, *senddesc01_w1, 1);
     848                 :            :                 }
     849                 :            :         } else {
     850                 :            :                 cookie = RTE_MBUF_DIRECT(m1) ? m1 : rte_mbuf_from_indirect(m1);
     851                 :            :                 aura = (w0 >> 20) & 0xFFFFF;
     852                 :            :                 w0 &= ~0xFFFFF00000UL;
     853                 :            :                 w0 |= cnxk_nix_prefree_seg(m1, &aura) << 19;
     854                 :            :                 w0 |= aura << 20;
     855                 :            : 
     856                 :            :                 if ((w0 & BIT_ULL(19)) == 0)
     857                 :            :                         RTE_MEMPOOL_CHECK_COOKIES(cookie->pool, (void **)&cookie, 1, 0);
     858                 :            :         }
     859                 :            :         *senddesc01_w0 = vsetq_lane_u64(w0, *senddesc01_w0, 1);
     860                 :            : 
     861                 :            :         /* mbuf 2 */
     862                 :            :         w0 = vgetq_lane_u64(*senddesc23_w0, 0);
     863                 :            :         if (RTE_MBUF_HAS_EXTBUF(m2)) {
     864                 :            :                 w0 |= BIT_ULL(19);
     865                 :            :                 w1 = vgetq_lane_u64(*senddesc23_w1, 0);
     866                 :            :                 w1 &= ~0xFFFF000000000000UL;
     867                 :            :                 if (unlikely(!tx_compl_ena)) {
     868                 :            :                         m2->next = *extm;
     869                 :            :                         *extm = m2;
     870                 :            :                 } else {
     871                 :            :                         sqe_id = rte_atomic_fetch_add_explicit(&txq->tx_compl.sqe_id, 1,
     872                 :            :                                                                rte_memory_order_relaxed);
     873                 :            :                         sqe_id = sqe_id & nb_desc_mask;
     874                 :            :                         /* Set PNC */
     875                 :            :                         w0 |= BIT_ULL(43);
     876                 :            :                         w1 |= sqe_id << 48;
     877                 :            :                         tx_compl_ptr[sqe_id] = m2;
     878                 :            :                         *senddesc23_w1 = vsetq_lane_u64(w1, *senddesc23_w1, 0);
     879                 :            :                 }
     880                 :            :         } else {
     881                 :            :                 cookie = RTE_MBUF_DIRECT(m2) ? m2 : rte_mbuf_from_indirect(m2);
     882                 :            :                 aura = (w0 >> 20) & 0xFFFFF;
     883                 :            :                 w0 &= ~0xFFFFF00000UL;
     884                 :            :                 w0 |= cnxk_nix_prefree_seg(m2, &aura) << 19;
     885                 :            :                 w0 |= aura << 20;
     886                 :            : 
     887                 :            :                 if ((w0 & BIT_ULL(19)) == 0)
     888                 :            :                         RTE_MEMPOOL_CHECK_COOKIES(cookie->pool, (void **)&cookie, 1, 0);
     889                 :            :         }
     890                 :            :         *senddesc23_w0 = vsetq_lane_u64(w0, *senddesc23_w0, 0);
     891                 :            : 
     892                 :            :         /* mbuf3 */
     893                 :            :         w0 = vgetq_lane_u64(*senddesc23_w0, 1);
     894                 :            :         if (RTE_MBUF_HAS_EXTBUF(m3)) {
     895                 :            :                 w0 |= BIT_ULL(19);
     896                 :            :                 w1 = vgetq_lane_u64(*senddesc23_w1, 1);
     897                 :            :                 w1 &= ~0xFFFF000000000000UL;
     898                 :            :                 if (unlikely(!tx_compl_ena)) {
     899                 :            :                         m3->next = *extm;
     900                 :            :                         *extm = m3;
     901                 :            :                 } else {
     902                 :            :                         sqe_id = rte_atomic_fetch_add_explicit(&txq->tx_compl.sqe_id, 1,
     903                 :            :                                                                rte_memory_order_relaxed);
     904                 :            :                         sqe_id = sqe_id & nb_desc_mask;
     905                 :            :                         /* Set PNC */
     906                 :            :                         w0 |= BIT_ULL(43);
     907                 :            :                         w1 |= sqe_id << 48;
     908                 :            :                         tx_compl_ptr[sqe_id] = m3;
     909                 :            :                         *senddesc23_w1 = vsetq_lane_u64(w1, *senddesc23_w1, 1);
     910                 :            :                 }
     911                 :            :         } else {
     912                 :            :                 cookie = RTE_MBUF_DIRECT(m3) ? m3 : rte_mbuf_from_indirect(m3);
     913                 :            :                 aura = (w0 >> 20) & 0xFFFFF;
     914                 :            :                 w0 &= ~0xFFFFF00000UL;
     915                 :            :                 w0 |= cnxk_nix_prefree_seg(m3, &aura) << 19;
     916                 :            :                 w0 |= aura << 20;
     917                 :            : 
     918                 :            :                 if ((w0 & BIT_ULL(19)) == 0)
     919                 :            :                         RTE_MEMPOOL_CHECK_COOKIES(cookie->pool, (void **)&cookie, 1, 0);
     920                 :            :         }
     921                 :            :         *senddesc23_w0 = vsetq_lane_u64(w0, *senddesc23_w0, 1);
     922                 :            : #ifndef RTE_LIBRTE_MEMPOOL_DEBUG
     923                 :            :         RTE_SET_USED(cookie);
     924                 :            : #endif
     925                 :            : }
     926                 :            : #endif
     927                 :            : 
     928                 :            : static __rte_always_inline void
     929                 :            : cn10k_nix_xmit_prepare_tso(struct rte_mbuf *m, const uint64_t flags)
     930                 :            : {
     931                 :            :         uint64_t mask, ol_flags = m->ol_flags;
     932                 :            : 
     933                 :            :         if (flags & NIX_TX_OFFLOAD_TSO_F && (ol_flags & RTE_MBUF_F_TX_TCP_SEG)) {
     934                 :            :                 uintptr_t mdata = rte_pktmbuf_mtod(m, uintptr_t);
     935                 :            :                 uint16_t *iplen, *oiplen, *oudplen;
     936                 :            :                 uint16_t lso_sb, paylen;
     937                 :            : 
     938                 :            :                 mask = -!!(ol_flags & (RTE_MBUF_F_TX_OUTER_IPV4 | RTE_MBUF_F_TX_OUTER_IPV6));
     939                 :            :                 lso_sb = (mask & (m->outer_l2_len + m->outer_l3_len)) +
     940                 :            :                          m->l2_len + m->l3_len + m->l4_len;
     941                 :            : 
     942                 :            :                 /* Reduce payload len from base headers */
     943                 :            :                 paylen = m->pkt_len - lso_sb;
     944                 :            : 
     945                 :            :                 /* Get iplen position assuming no tunnel hdr */
     946                 :            :                 iplen = (uint16_t *)(mdata + m->l2_len +
     947                 :            :                                      (2 << !!(ol_flags & RTE_MBUF_F_TX_IPV6)));
     948                 :            :                 /* Handle tunnel tso */
     949                 :            :                 if ((flags & NIX_TX_OFFLOAD_OL3_OL4_CSUM_F) &&
     950                 :            :                     (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK)) {
     951                 :            :                         const uint8_t is_udp_tun =
     952                 :            :                                 (CNXK_NIX_UDP_TUN_BITMASK >>
     953                 :            :                                  ((ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK) >> 45)) &
     954                 :            :                                 0x1;
     955                 :            : 
     956                 :            :                         oiplen = (uint16_t *)(mdata + m->outer_l2_len +
     957                 :            :                                               (2 << !!(ol_flags &
     958                 :            :                                                        RTE_MBUF_F_TX_OUTER_IPV6)));
     959                 :            :                         *oiplen = rte_cpu_to_be_16(rte_be_to_cpu_16(*oiplen) -
     960                 :            :                                                    paylen);
     961                 :            : 
     962                 :            :                         /* Update format for UDP tunneled packet */
     963                 :            :                         if (is_udp_tun) {
     964                 :            :                                 oudplen = (uint16_t *)(mdata + m->outer_l2_len +
     965                 :            :                                                        m->outer_l3_len + 4);
     966                 :            :                                 *oudplen = rte_cpu_to_be_16(
     967                 :            :                                         rte_be_to_cpu_16(*oudplen) - paylen);
     968                 :            :                         }
     969                 :            : 
     970                 :            :                         /* Update iplen position to inner ip hdr */
     971                 :            :                         iplen = (uint16_t *)(mdata + lso_sb - m->l3_len -
     972                 :            :                                              m->l4_len +
     973                 :            :                                              (2 << !!(ol_flags & RTE_MBUF_F_TX_IPV6)));
     974                 :            :                 }
     975                 :            : 
     976                 :            :                 *iplen = rte_cpu_to_be_16(rte_be_to_cpu_16(*iplen) - paylen);
     977                 :            :         }
     978                 :            : }
     979                 :            : 
     980                 :            : static __rte_always_inline void
     981                 :            : cn10k_nix_xmit_prepare(struct cn10k_eth_txq *txq,
     982                 :            :                        struct rte_mbuf *m, struct rte_mbuf **extm, uint64_t *cmd,
     983                 :            :                        const uint16_t flags, const uint64_t lso_tun_fmt, bool *sec,
     984                 :            :                        uint8_t mark_flag, uint64_t mark_fmt)
     985                 :            : {
     986                 :            :         uint8_t mark_off = 0, mark_vlan = 0, markptr = 0;
     987                 :            :         struct nix_send_ext_s *send_hdr_ext;
     988                 :            :         struct nix_send_hdr_s *send_hdr;
     989                 :            :         uint64_t ol_flags = 0, mask;
     990                 :            :         union nix_send_hdr_w1_u w1;
     991                 :            :         union nix_send_sg_s *sg;
     992                 :            :         uint16_t mark_form = 0;
     993                 :            : 
     994                 :            :         send_hdr = (struct nix_send_hdr_s *)cmd;
     995                 :            :         if (flags & NIX_TX_NEED_EXT_HDR) {
     996                 :            :                 send_hdr_ext = (struct nix_send_ext_s *)(cmd + 2);
     997                 :            :                 sg = (union nix_send_sg_s *)(cmd + 4);
     998                 :            :                 /* Clear previous markings */
     999                 :            :                 send_hdr_ext->w0.lso = 0;
    1000                 :            :                 send_hdr_ext->w0.mark_en = 0;
    1001                 :            :                 send_hdr_ext->w1.u = 0;
    1002                 :            :                 ol_flags = m->ol_flags;
    1003                 :            :         } else {
    1004                 :            :                 sg = (union nix_send_sg_s *)(cmd + 2);
    1005                 :            :         }
    1006                 :            : 
    1007                 :            :         if (flags & NIX_TX_OFFLOAD_MBUF_NOFF_F)
    1008                 :            :                 send_hdr->w0.pnc = 0;
    1009                 :            : 
    1010                 :            :         if (flags & (NIX_TX_NEED_SEND_HDR_W1 | NIX_TX_OFFLOAD_SECURITY_F)) {
    1011                 :            :                 ol_flags = m->ol_flags;
    1012                 :            :                 w1.u = 0;
    1013                 :            :         }
    1014                 :            : 
    1015                 :            :         if (!(flags & NIX_TX_MULTI_SEG_F))
    1016                 :            :                 send_hdr->w0.total = m->data_len;
    1017                 :            :         else
    1018                 :            :                 send_hdr->w0.total = m->pkt_len;
    1019                 :            :         send_hdr->w0.aura = roc_npa_aura_handle_to_aura(m->pool->pool_id);
    1020                 :            : 
    1021                 :            :         /*
    1022                 :            :          * L3type:  2 => IPV4
    1023                 :            :          *          3 => IPV4 with csum
    1024                 :            :          *          4 => IPV6
    1025                 :            :          * L3type and L3ptr needs to be set for either
    1026                 :            :          * L3 csum or L4 csum or LSO
    1027                 :            :          *
    1028                 :            :          */
    1029                 :            : 
    1030                 :            :         if ((flags & NIX_TX_OFFLOAD_OL3_OL4_CSUM_F) &&
    1031                 :            :             (flags & NIX_TX_OFFLOAD_L3_L4_CSUM_F)) {
    1032                 :            :                 const uint8_t csum = !!(ol_flags & RTE_MBUF_F_TX_OUTER_UDP_CKSUM);
    1033                 :            :                 const uint8_t ol3type =
    1034                 :            :                         ((!!(ol_flags & RTE_MBUF_F_TX_OUTER_IPV4)) << 1) +
    1035                 :            :                         ((!!(ol_flags & RTE_MBUF_F_TX_OUTER_IPV6)) << 2) +
    1036                 :            :                         !!(ol_flags & RTE_MBUF_F_TX_OUTER_IP_CKSUM);
    1037                 :            : 
    1038                 :            :                 /* Outer L3 */
    1039                 :            :                 w1.ol3type = ol3type;
    1040                 :            :                 mask = 0xffffull << ((!!ol3type) << 4);
    1041                 :            :                 w1.ol3ptr = ~mask & m->outer_l2_len;
    1042                 :            :                 w1.ol4ptr = ~mask & (w1.ol3ptr + m->outer_l3_len);
    1043                 :            : 
    1044                 :            :                 /* Outer L4 */
    1045                 :            :                 w1.ol4type = csum + (csum << 1);
    1046                 :            : 
    1047                 :            :                 /* Inner L3 */
    1048                 :            :                 w1.il3type = ((!!(ol_flags & RTE_MBUF_F_TX_IPV4)) << 1) +
    1049                 :            :                              ((!!(ol_flags & RTE_MBUF_F_TX_IPV6)) << 2);
    1050                 :            :                 w1.il3ptr = w1.ol4ptr + m->l2_len;
    1051                 :            :                 w1.il4ptr = w1.il3ptr + m->l3_len;
    1052                 :            :                 /* Increment it by 1 if it is IPV4 as 3 is with csum */
    1053                 :            :                 w1.il3type = w1.il3type + !!(ol_flags & RTE_MBUF_F_TX_IP_CKSUM);
    1054                 :            : 
    1055                 :            :                 /* Inner L4 */
    1056                 :            :                 w1.il4type = (ol_flags & RTE_MBUF_F_TX_L4_MASK) >> 52;
    1057                 :            : 
    1058                 :            :                 /* In case of no tunnel header use only
    1059                 :            :                  * shift IL3/IL4 fields a bit to use
    1060                 :            :                  * OL3/OL4 for header checksum
    1061                 :            :                  */
    1062                 :            :                 mask = !ol3type;
    1063                 :            :                 w1.u = ((w1.u & 0xFFFFFFFF00000000) >> (mask << 3)) |
    1064                 :            :                        ((w1.u & 0X00000000FFFFFFFF) >> (mask << 4));
    1065                 :            : 
    1066                 :            :         } else if (flags & NIX_TX_OFFLOAD_OL3_OL4_CSUM_F) {
    1067                 :            :                 const uint8_t csum = !!(ol_flags & RTE_MBUF_F_TX_OUTER_UDP_CKSUM);
    1068                 :            :                 const uint8_t outer_l2_len = m->outer_l2_len;
    1069                 :            : 
    1070                 :            :                 /* Outer L3 */
    1071                 :            :                 w1.ol3ptr = outer_l2_len;
    1072                 :            :                 w1.ol4ptr = outer_l2_len + m->outer_l3_len;
    1073                 :            :                 /* Increment it by 1 if it is IPV4 as 3 is with csum */
    1074                 :            :                 w1.ol3type = ((!!(ol_flags & RTE_MBUF_F_TX_OUTER_IPV4)) << 1) +
    1075                 :            :                              ((!!(ol_flags & RTE_MBUF_F_TX_OUTER_IPV6)) << 2) +
    1076                 :            :                              !!(ol_flags & RTE_MBUF_F_TX_OUTER_IP_CKSUM);
    1077                 :            : 
    1078                 :            :                 /* Outer L4 */
    1079                 :            :                 w1.ol4type = csum + (csum << 1);
    1080                 :            : 
    1081                 :            :         } else if (flags & NIX_TX_OFFLOAD_L3_L4_CSUM_F) {
    1082                 :            :                 const uint8_t l2_len = m->l2_len;
    1083                 :            : 
    1084                 :            :                 /* Always use OLXPTR and OLXTYPE when only
    1085                 :            :                  * when one header is present
    1086                 :            :                  */
    1087                 :            : 
    1088                 :            :                 /* Inner L3 */
    1089                 :            :                 w1.ol3ptr = l2_len;
    1090                 :            :                 w1.ol4ptr = l2_len + m->l3_len;
    1091                 :            :                 /* Increment it by 1 if it is IPV4 as 3 is with csum */
    1092                 :            :                 w1.ol3type = ((!!(ol_flags & RTE_MBUF_F_TX_IPV4)) << 1) +
    1093                 :            :                              ((!!(ol_flags & RTE_MBUF_F_TX_IPV6)) << 2) +
    1094                 :            :                              !!(ol_flags & RTE_MBUF_F_TX_IP_CKSUM);
    1095                 :            : 
    1096                 :            :                 /* Inner L4 */
    1097                 :            :                 w1.ol4type = (ol_flags & RTE_MBUF_F_TX_L4_MASK) >> 52;
    1098                 :            :         }
    1099                 :            : 
    1100                 :            :         if (flags & NIX_TX_NEED_EXT_HDR && flags & NIX_TX_OFFLOAD_VLAN_QINQ_F) {
    1101                 :            :                 const uint8_t ipv6 = !!(ol_flags & RTE_MBUF_F_TX_IPV6);
    1102                 :            :                 const uint8_t ip = !!(ol_flags & (RTE_MBUF_F_TX_IPV4 |
    1103                 :            :                                                   RTE_MBUF_F_TX_IPV6));
    1104                 :            : 
    1105                 :            :                 send_hdr_ext->w1.vlan1_ins_ena = !!(ol_flags & RTE_MBUF_F_TX_VLAN);
    1106                 :            :                 /* HW will update ptr after vlan0 update */
    1107                 :            :                 send_hdr_ext->w1.vlan1_ins_ptr = 12;
    1108                 :            :                 send_hdr_ext->w1.vlan1_ins_tci = m->vlan_tci;
    1109                 :            : 
    1110                 :            :                 send_hdr_ext->w1.vlan0_ins_ena = !!(ol_flags & RTE_MBUF_F_TX_QINQ);
    1111                 :            :                 /* 2B before end of l2 header */
    1112                 :            :                 send_hdr_ext->w1.vlan0_ins_ptr = 12;
    1113                 :            :                 send_hdr_ext->w1.vlan0_ins_tci = m->vlan_tci_outer;
    1114                 :            :                 /* Fill for VLAN marking only when VLAN insertion enabled */
    1115                 :            :                 mark_vlan = ((mark_flag & CNXK_TM_MARK_VLAN_DEI) &
    1116                 :            :                              (send_hdr_ext->w1.vlan1_ins_ena ||
    1117                 :            :                               send_hdr_ext->w1.vlan0_ins_ena));
    1118                 :            : 
    1119                 :            :                 /* Mask requested flags with packet data information */
    1120                 :            :                 mark_off = mark_flag & ((ip << 2) | (ip << 1) | mark_vlan);
    1121                 :            :                 mark_off = ffs(mark_off & CNXK_TM_MARK_MASK);
    1122                 :            : 
    1123                 :            :                 mark_form = (mark_fmt >> ((mark_off - !!mark_off) << 4));
    1124                 :            :                 mark_form = (mark_form >> (ipv6 << 3)) & 0xFF;
    1125                 :            :                 markptr = m->l2_len + (mark_form >> 7) - (mark_vlan << 2);
    1126                 :            : 
    1127                 :            :                 send_hdr_ext->w0.mark_en = !!mark_off;
    1128                 :            :                 send_hdr_ext->w0.markform = mark_form & 0x7F;
    1129                 :            :                 send_hdr_ext->w0.markptr = markptr;
    1130                 :            :         }
    1131                 :            : 
    1132                 :            :         if (flags & NIX_TX_NEED_EXT_HDR && flags & NIX_TX_OFFLOAD_TSO_F &&
    1133                 :            :             (ol_flags & RTE_MBUF_F_TX_TCP_SEG)) {
    1134                 :            :                 uint16_t lso_sb;
    1135                 :            :                 uint64_t mask;
    1136                 :            : 
    1137                 :            :                 mask = -(!w1.il3type);
    1138                 :            :                 lso_sb = (mask & w1.ol4ptr) + (~mask & w1.il4ptr) + m->l4_len;
    1139                 :            : 
    1140                 :            :                 send_hdr_ext->w0.lso_sb = lso_sb;
    1141                 :            :                 send_hdr_ext->w0.lso = 1;
    1142                 :            :                 send_hdr_ext->w0.lso_mps = m->tso_segsz;
    1143                 :            :                 send_hdr_ext->w0.lso_format =
    1144                 :            :                         NIX_LSO_FORMAT_IDX_TSOV4 + !!(ol_flags & RTE_MBUF_F_TX_IPV6);
    1145                 :            :                 w1.ol4type = NIX_SENDL4TYPE_TCP_CKSUM;
    1146                 :            : 
    1147                 :            :                 /* Handle tunnel tso */
    1148                 :            :                 if ((flags & NIX_TX_OFFLOAD_OL3_OL4_CSUM_F) &&
    1149                 :            :                     (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK)) {
    1150                 :            :                         const uint8_t is_udp_tun =
    1151                 :            :                                 (CNXK_NIX_UDP_TUN_BITMASK >>
    1152                 :            :                                  ((ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK) >> 45)) &
    1153                 :            :                                 0x1;
    1154                 :            :                         uint8_t shift = is_udp_tun ? 32 : 0;
    1155                 :            : 
    1156                 :            :                         shift += (!!(ol_flags & RTE_MBUF_F_TX_OUTER_IPV6) << 4);
    1157                 :            :                         shift += (!!(ol_flags & RTE_MBUF_F_TX_IPV6) << 3);
    1158                 :            : 
    1159                 :            :                         w1.il4type = NIX_SENDL4TYPE_TCP_CKSUM;
    1160                 :            :                         w1.ol4type = is_udp_tun ? NIX_SENDL4TYPE_UDP_CKSUM : 0;
    1161                 :            :                         /* Update format for UDP tunneled packet */
    1162                 :            :                         send_hdr_ext->w0.lso_format = (lso_tun_fmt >> shift);
    1163                 :            :                 }
    1164                 :            :         }
    1165                 :            : 
    1166                 :            :         if (flags & NIX_TX_NEED_SEND_HDR_W1)
    1167                 :            :                 send_hdr->w1.u = w1.u;
    1168                 :            : 
    1169                 :            :         if (!(flags & NIX_TX_MULTI_SEG_F)) {
    1170                 :            :                 struct rte_mbuf *cookie;
    1171                 :            : 
    1172                 :            :                 sg->seg1_size = send_hdr->w0.total;
    1173                 :            :                 *(rte_iova_t *)(sg + 1) = rte_mbuf_data_iova(m);
    1174                 :            :                 cookie = RTE_MBUF_DIRECT(m) ? m : rte_mbuf_from_indirect(m);
    1175                 :            : 
    1176                 :            :                 if (flags & NIX_TX_OFFLOAD_MBUF_NOFF_F) {
    1177                 :            :                         uint64_t aura;
    1178                 :            : 
    1179                 :            :                         /* DF bit = 1 if refcount of current mbuf or parent mbuf
    1180                 :            :                          *              is greater than 1
    1181                 :            :                          * DF bit = 0 otherwise
    1182                 :            :                          */
    1183                 :            :                         aura = send_hdr->w0.aura;
    1184                 :            :                         send_hdr->w0.df = cn10k_nix_prefree_seg(m, extm, txq, send_hdr, &aura);
    1185                 :            :                         send_hdr->w0.aura = aura;
    1186                 :            :                 }
    1187                 :            : #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
    1188                 :            :                 /* Mark mempool object as "put" since it is freed by NIX */
    1189                 :            :                 if (!send_hdr->w0.df)
    1190                 :            :                         RTE_MEMPOOL_CHECK_COOKIES(cookie->pool, (void **)&cookie, 1, 0);
    1191                 :            : #else
    1192                 :            :                 RTE_SET_USED(cookie);
    1193                 :            : #endif
    1194                 :            :         } else {
    1195                 :            :                 sg->seg1_size = m->data_len;
    1196                 :            :                 *(rte_iova_t *)(sg + 1) = rte_mbuf_data_iova(m);
    1197                 :            : 
    1198                 :            :                 /* NOFF is handled later for multi-seg */
    1199                 :            :         }
    1200                 :            : 
    1201                 :            :         if (flags & NIX_TX_OFFLOAD_SECURITY_F)
    1202                 :            :                 *sec = !!(ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD);
    1203                 :            : }
    1204                 :            : 
    1205                 :            : static __rte_always_inline void
    1206                 :            : cn10k_nix_xmit_mv_lmt_base(uintptr_t lmt_addr, uint64_t *cmd,
    1207                 :            :                            const uint16_t flags)
    1208                 :            : {
    1209                 :            :         struct nix_send_ext_s *send_hdr_ext;
    1210                 :            :         union nix_send_sg_s *sg;
    1211                 :            : 
    1212                 :            :         /* With minimal offloads, 'cmd' being local could be optimized out to
    1213                 :            :          * registers. In other cases, 'cmd' will be in stack. Intent is
    1214                 :            :          * 'cmd' stores content from txq->cmd which is copied only once.
    1215                 :            :          */
    1216                 :          0 :         *((struct nix_send_hdr_s *)lmt_addr) = *(struct nix_send_hdr_s *)cmd;
    1217                 :          0 :         lmt_addr += 16;
    1218         [ #  # ]:          0 :         if (flags & NIX_TX_NEED_EXT_HDR) {
    1219                 :            :                 send_hdr_ext = (struct nix_send_ext_s *)(cmd + 2);
    1220                 :          0 :                 *((struct nix_send_ext_s *)lmt_addr) = *send_hdr_ext;
    1221                 :          0 :                 lmt_addr += 16;
    1222                 :            : 
    1223                 :            :                 sg = (union nix_send_sg_s *)(cmd + 4);
    1224                 :            :         } else {
    1225                 :            :                 sg = (union nix_send_sg_s *)(cmd + 2);
    1226                 :            :         }
    1227                 :            :         /* In case of multi-seg, sg template is stored here */
    1228                 :          0 :         *((union nix_send_sg_s *)lmt_addr) = *sg;
    1229                 :          0 :         *(rte_iova_t *)(lmt_addr + 8) = *(rte_iova_t *)(sg + 1);
    1230                 :            : }
    1231                 :            : 
    1232                 :            : static __rte_always_inline void
    1233                 :            : cn10k_nix_xmit_prepare_tstamp(struct cn10k_eth_txq *txq, uintptr_t lmt_addr,
    1234                 :            :                               const uint64_t ol_flags, const uint16_t no_segdw,
    1235                 :            :                               const uint16_t flags)
    1236                 :            : {
    1237                 :            :         if (flags & NIX_TX_OFFLOAD_TSTAMP_F) {
    1238                 :            :                 const uint8_t is_ol_tstamp =
    1239                 :            :                         !(ol_flags & RTE_MBUF_F_TX_IEEE1588_TMST);
    1240                 :            :                 uint64_t *lmt = (uint64_t *)lmt_addr;
    1241                 :            :                 uint16_t off = (no_segdw - 1) << 1;
    1242                 :            :                 struct nix_send_mem_s *send_mem;
    1243                 :            : 
    1244                 :            :                 send_mem = (struct nix_send_mem_s *)(lmt + off);
    1245                 :            :                 /* Packets for which RTE_MBUF_F_TX_IEEE1588_TMST is not set, Tx tstamp
    1246                 :            :                  * should not be recorded, hence changing the alg type to
    1247                 :            :                  * NIX_SENDMEMALG_SUB and also changing send mem addr field to
    1248                 :            :                  * next 8 bytes as it corrupts the actual Tx tstamp registered
    1249                 :            :                  * address.
    1250                 :            :                  */
    1251                 :            :                 send_mem->w0.subdc = NIX_SUBDC_MEM;
    1252                 :            :                 send_mem->w0.alg =
    1253                 :            :                         NIX_SENDMEMALG_SETTSTMP + (is_ol_tstamp << 3);
    1254                 :            :                 send_mem->addr =
    1255                 :            :                         (rte_iova_t)(((uint64_t *)txq->ts_mem) + is_ol_tstamp);
    1256                 :            :         }
    1257                 :            : }
    1258                 :            : 
    1259                 :            : static __rte_always_inline uint16_t
    1260                 :            : cn10k_nix_prepare_mseg(struct cn10k_eth_txq *txq, struct rte_mbuf *m, struct rte_mbuf **extm,
    1261                 :            :                        uint64_t *cmd, const uint16_t flags)
    1262                 :            : {
    1263                 :            :         uint64_t prefree = 0, aura0, aura, nb_segs, segdw;
    1264                 :            :         struct nix_send_hdr_s *send_hdr;
    1265                 :            :         union nix_send_sg_s *sg, l_sg;
    1266                 :            :         union nix_send_sg2_s l_sg2;
    1267                 :            :         struct rte_mbuf *cookie;
    1268                 :            :         struct rte_mbuf *m_next;
    1269                 :            :         uint8_t off, is_sg2;
    1270                 :            :         uint64_t len, dlen;
    1271                 :            :         uint64_t ol_flags;
    1272                 :            :         uint64_t *slist;
    1273                 :            : 
    1274                 :            :         send_hdr = (struct nix_send_hdr_s *)cmd;
    1275                 :            : 
    1276                 :            :         if (flags & NIX_TX_NEED_EXT_HDR)
    1277                 :            :                 off = 2;
    1278                 :            :         else
    1279                 :            :                 off = 0;
    1280                 :            : 
    1281                 :            :         sg = (union nix_send_sg_s *)&cmd[2 + off];
    1282                 :            :         len = send_hdr->w0.total;
    1283                 :            :         if (flags & NIX_TX_OFFLOAD_SECURITY_F)
    1284                 :            :                 ol_flags = m->ol_flags;
    1285                 :            : 
    1286                 :            :         /* Start from second segment, first segment is already there */
    1287                 :            :         dlen = m->data_len;
    1288                 :            :         is_sg2 = 0;
    1289                 :            :         l_sg.u = sg->u;
    1290                 :            :         /* Clear l_sg.u first seg length that might be stale from vector path */
    1291                 :            :         l_sg.u &= ~0xFFFFUL;
    1292                 :            :         l_sg.u |= dlen;
    1293                 :            :         len -= dlen;
    1294                 :            :         nb_segs = m->nb_segs - 1;
    1295                 :            :         m_next = m->next;
    1296                 :            :         m->next = NULL;
    1297                 :            :         m->nb_segs = 1;
    1298                 :            :         slist = &cmd[3 + off + 1];
    1299                 :            : 
    1300                 :            :         cookie = RTE_MBUF_DIRECT(m) ? m : rte_mbuf_from_indirect(m);
    1301                 :            :         /* Set invert df if buffer is not to be freed by H/W */
    1302                 :            :         if (flags & NIX_TX_OFFLOAD_MBUF_NOFF_F) {
    1303                 :            :                 aura = send_hdr->w0.aura;
    1304                 :            :                 prefree = cn10k_nix_prefree_seg(m, extm, txq, send_hdr, &aura);
    1305                 :            :                 send_hdr->w0.aura = aura;
    1306                 :            :                 l_sg.i1 = prefree;
    1307                 :            :         }
    1308                 :            : 
    1309                 :            : #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
    1310                 :            :         /* Mark mempool object as "put" since it is freed by NIX */
    1311                 :            :         if (!prefree)
    1312                 :            :                 RTE_MEMPOOL_CHECK_COOKIES(cookie->pool, (void **)&cookie, 1, 0);
    1313                 :            :         rte_io_wmb();
    1314                 :            : #else
    1315                 :            :         RTE_SET_USED(cookie);
    1316                 :            : #endif
    1317                 :            : 
    1318                 :            :         /* Quickly handle single segmented packets. With this if-condition
    1319                 :            :          * compiler will completely optimize out the below do-while loop
    1320                 :            :          * from the Tx handler when NIX_TX_MULTI_SEG_F offload is not set.
    1321                 :            :          */
    1322                 :            :         if (!(flags & NIX_TX_MULTI_SEG_F))
    1323                 :            :                 goto done;
    1324                 :            : 
    1325                 :            :         aura0 = send_hdr->w0.aura;
    1326                 :            :         m = m_next;
    1327                 :            :         if (!m)
    1328                 :            :                 goto done;
    1329                 :            : 
    1330                 :            :         /* Fill mbuf segments */
    1331                 :            :         do {
    1332                 :            :                 uint64_t iova;
    1333                 :            : 
    1334                 :            :                 /* Save the current mbuf properties. These can get cleared in
    1335                 :            :                  * cnxk_nix_prefree_seg()
    1336                 :            :                  */
    1337                 :            :                 m_next = m->next;
    1338                 :            :                 iova = rte_mbuf_data_iova(m);
    1339                 :            :                 dlen = m->data_len;
    1340                 :            :                 len -= dlen;
    1341                 :            : 
    1342                 :            :                 nb_segs--;
    1343                 :            :                 aura = aura0;
    1344                 :            :                 prefree = 0;
    1345                 :            : 
    1346                 :            :                 m->next = NULL;
    1347                 :            : 
    1348                 :            :                 cookie = RTE_MBUF_DIRECT(m) ? m : rte_mbuf_from_indirect(m);
    1349                 :            :                 if (flags & NIX_TX_OFFLOAD_MBUF_NOFF_F) {
    1350                 :            :                         aura = roc_npa_aura_handle_to_aura(m->pool->pool_id);
    1351                 :            :                         prefree = cn10k_nix_prefree_seg(m, extm, txq, send_hdr, &aura);
    1352                 :            :                         is_sg2 = aura != aura0 && !prefree;
    1353                 :            :                 }
    1354                 :            : 
    1355                 :            :                 if (unlikely(is_sg2)) {
    1356                 :            :                         /* This mbuf belongs to a different pool and
    1357                 :            :                          * DF bit is not to be set, so use SG2 subdesc
    1358                 :            :                          * so that it is freed to the appropriate pool.
    1359                 :            :                          */
    1360                 :            : 
    1361                 :            :                         /* Write the previous descriptor out */
    1362                 :            :                         sg->u = l_sg.u;
    1363                 :            : 
    1364                 :            :                         /* If the current SG subdc does not have any
    1365                 :            :                          * iovas in it, then the SG2 subdc can overwrite
    1366                 :            :                          * that SG subdc.
    1367                 :            :                          *
    1368                 :            :                          * If the current SG subdc has 2 iovas in it, then
    1369                 :            :                          * the current iova word should be left empty.
    1370                 :            :                          */
    1371                 :            :                         slist += (-1 + (int)l_sg.segs);
    1372                 :            :                         sg = (union nix_send_sg_s *)slist;
    1373                 :            : 
    1374                 :            :                         l_sg2.u = l_sg.u & 0xC00000000000000; /* LD_TYPE */
    1375                 :            :                         l_sg2.subdc = NIX_SUBDC_SG2;
    1376                 :            :                         l_sg2.aura = aura;
    1377                 :            :                         l_sg2.seg1_size = dlen;
    1378                 :            :                         l_sg.u = l_sg2.u;
    1379                 :            : 
    1380                 :            :                         slist++;
    1381                 :            :                         *slist = iova;
    1382                 :            :                         slist++;
    1383                 :            :                 } else {
    1384                 :            :                         *slist = iova;
    1385                 :            :                         /* Set invert df if buffer is not to be freed by H/W */
    1386                 :            :                         l_sg.u |= (prefree << (l_sg.segs + 55));
    1387                 :            :                         /* Set the segment length */
    1388                 :            :                         l_sg.u |= ((uint64_t)dlen << (l_sg.segs << 4));
    1389                 :            :                         l_sg.segs += 1;
    1390                 :            :                         slist++;
    1391                 :            :                 }
    1392                 :            : 
    1393                 :            :                 if ((is_sg2 || l_sg.segs > 2) && nb_segs) {
    1394                 :            :                         sg->u = l_sg.u;
    1395                 :            :                         /* Next SG subdesc */
    1396                 :            :                         sg = (union nix_send_sg_s *)slist;
    1397                 :            :                         l_sg.u &= 0xC00000000000000; /* LD_TYPE */
    1398                 :            :                         l_sg.subdc = NIX_SUBDC_SG;
    1399                 :            :                         slist++;
    1400                 :            :                 }
    1401                 :            : 
    1402                 :            : #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
    1403                 :            :                 /* Mark mempool object as "put" since it is freed by NIX
    1404                 :            :                  */
    1405                 :            :                 if (!prefree)
    1406                 :            :                         RTE_MEMPOOL_CHECK_COOKIES(cookie->pool, (void **)&cookie, 1, 0);
    1407                 :            : #else
    1408                 :            :                 RTE_SET_USED(cookie);
    1409                 :            : #endif
    1410                 :            :                 m = m_next;
    1411                 :            :         } while (nb_segs);
    1412                 :            : 
    1413                 :            : done:
    1414                 :            :         /* Add remaining bytes of security data to last seg */
    1415                 :            :         if (flags & NIX_TX_OFFLOAD_SECURITY_F && ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD && len) {
    1416                 :            :                 uint8_t shft = (l_sg.subdc == NIX_SUBDC_SG) ? ((l_sg.segs - 1) << 4) : 0;
    1417                 :            : 
    1418                 :            :                 dlen = ((l_sg.u >> shft) & 0xFFFFULL) + len;
    1419                 :            :                 l_sg.u = l_sg.u & ~(0xFFFFULL << shft);
    1420                 :            :                 l_sg.u |= dlen << shft;
    1421                 :            :         }
    1422                 :            : 
    1423                 :            :         /* Write the last subdc out */
    1424                 :            :         sg->u = l_sg.u;
    1425                 :            : 
    1426                 :            :         segdw = (uint64_t *)slist - (uint64_t *)&cmd[2 + off];
    1427                 :            :         /* Roundup extra dwords to multiple of 2 */
    1428                 :            :         segdw = (segdw >> 1) + (segdw & 0x1);
    1429                 :            :         /* Default dwords */
    1430                 :            :         segdw += (off >> 1) + 1 + !!(flags & NIX_TX_OFFLOAD_TSTAMP_F);
    1431                 :            :         send_hdr->w0.sizem1 = segdw - 1;
    1432                 :            : 
    1433                 :            :         return segdw;
    1434                 :            : }
    1435                 :            : 
    1436                 :            : static __rte_always_inline uint16_t
    1437                 :            : cn10k_nix_xmit_pkts(void *tx_queue, uint64_t *ws, struct rte_mbuf **tx_pkts,
    1438                 :            :                     uint16_t pkts, uint64_t *cmd, const uint16_t flags)
    1439                 :            : {
    1440                 :            :         struct cn10k_eth_txq *txq = tx_queue;
    1441                 :            :         const rte_iova_t io_addr = txq->io_addr;
    1442                 :            :         uint8_t lnum, c_lnum, c_shft, c_loff;
    1443                 :            :         uintptr_t pa, lbase = txq->lmt_base;
    1444                 :            :         uint16_t lmt_id, burst, left, i;
    1445                 :            :         struct rte_mbuf *extm = NULL;
    1446                 :            :         uintptr_t c_lbase = lbase;
    1447                 :            :         uint64_t lso_tun_fmt = 0;
    1448                 :            :         uint64_t mark_fmt = 0;
    1449                 :            :         uint8_t mark_flag = 0;
    1450                 :            :         rte_iova_t c_io_addr;
    1451                 :            :         uint16_t c_lmt_id;
    1452                 :            :         uint64_t sa_base;
    1453                 :            :         uintptr_t laddr;
    1454                 :            :         uint64_t data;
    1455                 :            :         bool sec;
    1456                 :            : 
    1457                 :            :         if (flags & NIX_TX_OFFLOAD_MBUF_NOFF_F && txq->tx_compl.ena)
    1458                 :            :                 handle_tx_completion_pkts(txq, flags & NIX_TX_VWQE_F);
    1459                 :            : 
    1460                 :            :         if (!(flags & NIX_TX_VWQE_F))
    1461                 :            :                 NIX_XMIT_FC_CHECK_RETURN(txq, pkts);
    1462                 :            : 
    1463                 :            :         /* Get cmd skeleton */
    1464                 :            :         cn10k_nix_tx_skeleton(txq, cmd, flags, !(flags & NIX_TX_VWQE_F));
    1465                 :            : 
    1466                 :            :         if (flags & NIX_TX_OFFLOAD_TSO_F)
    1467                 :            :                 lso_tun_fmt = txq->lso_tun_fmt;
    1468                 :            : 
    1469                 :            :         if (flags & NIX_TX_OFFLOAD_VLAN_QINQ_F) {
    1470                 :            :                 mark_fmt = txq->mark_fmt;
    1471                 :            :                 mark_flag = txq->mark_flag;
    1472                 :            :         }
    1473                 :            : 
    1474                 :            :         /* Get LMT base address and LMT ID as lcore id */
    1475                 :            :         ROC_LMT_BASE_ID_GET(lbase, lmt_id);
    1476                 :            :         if (flags & NIX_TX_OFFLOAD_SECURITY_F) {
    1477                 :            :                 ROC_LMT_CPT_BASE_ID_GET(c_lbase, c_lmt_id);
    1478                 :            :                 c_io_addr = txq->cpt_io_addr;
    1479                 :            :                 sa_base = txq->sa_base;
    1480                 :            :         }
    1481                 :            : 
    1482                 :            :         left = pkts;
    1483                 :            : again:
    1484                 :            :         burst = left > 32 ? 32 : left;
    1485                 :            : 
    1486                 :            :         lnum = 0;
    1487                 :            :         if (flags & NIX_TX_OFFLOAD_SECURITY_F) {
    1488                 :            :                 c_lnum = 0;
    1489                 :            :                 c_loff = 0;
    1490                 :            :                 c_shft = 16;
    1491                 :            :         }
    1492                 :            : 
    1493                 :            :         for (i = 0; i < burst; i++) {
    1494                 :            :                 /* Perform header writes for TSO, barrier at
    1495                 :            :                  * lmt steorl will suffice.
    1496                 :            :                  */
    1497                 :            :                 if (flags & NIX_TX_OFFLOAD_TSO_F)
    1498                 :            :                         cn10k_nix_xmit_prepare_tso(tx_pkts[i], flags);
    1499                 :            : 
    1500                 :            :                 cn10k_nix_xmit_prepare(txq, tx_pkts[i], &extm, cmd, flags, lso_tun_fmt,
    1501                 :            :                                        &sec, mark_flag, mark_fmt);
    1502                 :            : 
    1503                 :            :                 laddr = (uintptr_t)LMT_OFF(lbase, lnum, 0);
    1504                 :            : 
    1505                 :            :                 /* Prepare CPT instruction and get nixtx addr */
    1506                 :            :                 if (flags & NIX_TX_OFFLOAD_SECURITY_F && sec)
    1507                 :            :                         cn10k_nix_prep_sec(tx_pkts[i], cmd, &laddr, c_lbase,
    1508                 :            :                                            &c_lnum, &c_loff, &c_shft, sa_base,
    1509                 :            :                                            flags);
    1510                 :            : 
    1511                 :            :                 /* Move NIX desc to LMT/NIXTX area */
    1512                 :            :                 cn10k_nix_xmit_mv_lmt_base(laddr, cmd, flags);
    1513                 :            :                 cn10k_nix_xmit_prepare_tstamp(txq, laddr, tx_pkts[i]->ol_flags,
    1514                 :            :                                               4, flags);
    1515                 :            :                 if (!(flags & NIX_TX_OFFLOAD_SECURITY_F) || !sec)
    1516                 :            :                         lnum++;
    1517                 :            :         }
    1518                 :            : 
    1519                 :            :         if ((flags & NIX_TX_VWQE_F) && !(ws[3] & BIT_ULL(35)))
    1520                 :            :                 ws[3] = roc_sso_hws_head_wait(ws[0]);
    1521                 :            : 
    1522                 :            :         left -= burst;
    1523                 :            :         tx_pkts += burst;
    1524                 :            : 
    1525                 :            :         /* Submit CPT instructions if any */
    1526                 :            :         if (flags & NIX_TX_OFFLOAD_SECURITY_F) {
    1527                 :            :                 uint16_t sec_pkts = ((c_lnum << 1) + c_loff);
    1528                 :            : 
    1529                 :            :                 /* Reduce pkts to be sent to CPT */
    1530                 :            :                 burst -= sec_pkts;
    1531                 :            :                 if (flags & NIX_TX_VWQE_F)
    1532                 :            :                         cn10k_nix_vwqe_wait_fc(txq, sec_pkts);
    1533                 :            :                 cn10k_nix_sec_fc_wait(txq, sec_pkts);
    1534                 :            :                 cn10k_nix_sec_steorl(c_io_addr, c_lmt_id, c_lnum, c_loff,
    1535                 :            :                                      c_shft);
    1536                 :            :         }
    1537                 :            : 
    1538                 :            :         /* Trigger LMTST */
    1539                 :            :         if (burst > 16) {
    1540                 :            :                 data = cn10k_nix_tx_steor_data(flags);
    1541                 :            :                 pa = io_addr | (data & 0x7) << 4;
    1542                 :            :                 data &= ~0x7ULL;
    1543                 :            :                 data |= (15ULL << 12);
    1544                 :            :                 data |= (uint64_t)lmt_id;
    1545                 :            : 
    1546                 :            :                 if (flags & NIX_TX_VWQE_F)
    1547                 :            :                         cn10k_nix_vwqe_wait_fc(txq, 16);
    1548                 :            :                 /* STEOR0 */
    1549                 :            :                 roc_lmt_submit_steorl(data, pa);
    1550                 :            : 
    1551                 :            :                 data = cn10k_nix_tx_steor_data(flags);
    1552                 :            :                 pa = io_addr | (data & 0x7) << 4;
    1553                 :            :                 data &= ~0x7ULL;
    1554                 :            :                 data |= ((uint64_t)(burst - 17)) << 12;
    1555                 :            :                 data |= (uint64_t)(lmt_id + 16);
    1556                 :            : 
    1557                 :            :                 if (flags & NIX_TX_VWQE_F)
    1558                 :            :                         cn10k_nix_vwqe_wait_fc(txq, burst - 16);
    1559                 :            :                 /* STEOR1 */
    1560                 :            :                 roc_lmt_submit_steorl(data, pa);
    1561                 :            :         } else if (burst) {
    1562                 :            :                 data = cn10k_nix_tx_steor_data(flags);
    1563                 :            :                 pa = io_addr | (data & 0x7) << 4;
    1564                 :            :                 data &= ~0x7ULL;
    1565                 :            :                 data |= ((uint64_t)(burst - 1)) << 12;
    1566                 :            :                 data |= (uint64_t)lmt_id;
    1567                 :            : 
    1568                 :            :                 if (flags & NIX_TX_VWQE_F)
    1569                 :            :                         cn10k_nix_vwqe_wait_fc(txq, burst);
    1570                 :            :                 /* STEOR0 */
    1571                 :            :                 roc_lmt_submit_steorl(data, pa);
    1572                 :            :         }
    1573                 :            : 
    1574                 :            :         rte_io_wmb();
    1575                 :            :         if (flags & NIX_TX_OFFLOAD_MBUF_NOFF_F && !txq->tx_compl.ena) {
    1576                 :            :                 cn10k_nix_free_extmbuf(extm);
    1577                 :            :                 extm = NULL;
    1578                 :            :         }
    1579                 :            : 
    1580                 :            :         if (left)
    1581                 :            :                 goto again;
    1582                 :            : 
    1583                 :            :         return pkts;
    1584                 :            : }
    1585                 :            : 
    1586                 :            : static __rte_always_inline uint16_t
    1587                 :            : cn10k_nix_xmit_pkts_mseg(void *tx_queue, uint64_t *ws,
    1588                 :            :                          struct rte_mbuf **tx_pkts, uint16_t pkts,
    1589                 :            :                          uint64_t *cmd, const uint16_t flags)
    1590                 :            : {
    1591                 :            :         struct cn10k_eth_txq *txq = tx_queue;
    1592                 :            :         uintptr_t pa0, pa1, lbase = txq->lmt_base;
    1593                 :            :         const rte_iova_t io_addr = txq->io_addr;
    1594                 :            :         uint16_t segdw, lmt_id, burst, left, i;
    1595                 :            :         struct rte_mbuf *extm = NULL;
    1596                 :            :         uint8_t lnum, c_lnum, c_loff;
    1597                 :            :         uintptr_t c_lbase = lbase;
    1598                 :            :         uint64_t lso_tun_fmt = 0;
    1599                 :            :         uint64_t mark_fmt = 0;
    1600                 :            :         uint8_t mark_flag = 0;
    1601                 :            :         uint64_t data0, data1;
    1602                 :            :         rte_iova_t c_io_addr;
    1603                 :            :         uint8_t shft, c_shft;
    1604                 :            :         __uint128_t data128;
    1605                 :            :         uint16_t c_lmt_id;
    1606                 :            :         uint64_t sa_base;
    1607                 :            :         uintptr_t laddr;
    1608                 :            :         bool sec;
    1609                 :            : 
    1610                 :            :         if (flags & NIX_TX_OFFLOAD_MBUF_NOFF_F && txq->tx_compl.ena)
    1611                 :            :                 handle_tx_completion_pkts(txq, flags & NIX_TX_VWQE_F);
    1612                 :            : 
    1613                 :            :         if (!(flags & NIX_TX_VWQE_F))
    1614                 :            :                 NIX_XMIT_FC_CHECK_RETURN(txq, pkts);
    1615                 :            : 
    1616                 :            :         /* Get cmd skeleton */
    1617                 :            :         cn10k_nix_tx_skeleton(txq, cmd, flags, !(flags & NIX_TX_VWQE_F));
    1618                 :            : 
    1619                 :            :         if (flags & NIX_TX_OFFLOAD_TSO_F)
    1620                 :            :                 lso_tun_fmt = txq->lso_tun_fmt;
    1621                 :            : 
    1622                 :            :         if (flags & NIX_TX_OFFLOAD_VLAN_QINQ_F) {
    1623                 :            :                 mark_fmt = txq->mark_fmt;
    1624                 :            :                 mark_flag = txq->mark_flag;
    1625                 :            :         }
    1626                 :            : 
    1627                 :            :         /* Get LMT base address and LMT ID as lcore id */
    1628                 :            :         ROC_LMT_BASE_ID_GET(lbase, lmt_id);
    1629                 :            :         if (flags & NIX_TX_OFFLOAD_SECURITY_F) {
    1630                 :            :                 ROC_LMT_CPT_BASE_ID_GET(c_lbase, c_lmt_id);
    1631                 :            :                 c_io_addr = txq->cpt_io_addr;
    1632                 :            :                 sa_base = txq->sa_base;
    1633                 :            :         }
    1634                 :            : 
    1635                 :            :         left = pkts;
    1636                 :            : again:
    1637                 :            :         burst = left > 32 ? 32 : left;
    1638                 :            :         shft = 16;
    1639                 :            :         data128 = 0;
    1640                 :            : 
    1641                 :            :         lnum = 0;
    1642                 :            :         if (flags & NIX_TX_OFFLOAD_SECURITY_F) {
    1643                 :            :                 c_lnum = 0;
    1644                 :            :                 c_loff = 0;
    1645                 :            :                 c_shft = 16;
    1646                 :            :         }
    1647                 :            : 
    1648                 :            :         for (i = 0; i < burst; i++) {
    1649                 :            :                 cn10k_nix_tx_mbuf_validate(tx_pkts[i], flags);
    1650                 :            : 
    1651                 :            :                 /* Perform header writes for TSO, barrier at
    1652                 :            :                  * lmt steorl will suffice.
    1653                 :            :                  */
    1654                 :            :                 if (flags & NIX_TX_OFFLOAD_TSO_F)
    1655                 :            :                         cn10k_nix_xmit_prepare_tso(tx_pkts[i], flags);
    1656                 :            : 
    1657                 :            :                 cn10k_nix_xmit_prepare(txq, tx_pkts[i], &extm, cmd, flags, lso_tun_fmt,
    1658                 :            :                                        &sec, mark_flag, mark_fmt);
    1659                 :            : 
    1660                 :            :                 laddr = (uintptr_t)LMT_OFF(lbase, lnum, 0);
    1661                 :            : 
    1662                 :            :                 /* Prepare CPT instruction and get nixtx addr */
    1663                 :            :                 if (flags & NIX_TX_OFFLOAD_SECURITY_F && sec)
    1664                 :            :                         cn10k_nix_prep_sec(tx_pkts[i], cmd, &laddr, c_lbase,
    1665                 :            :                                            &c_lnum, &c_loff, &c_shft, sa_base,
    1666                 :            :                                            flags);
    1667                 :            : 
    1668                 :            :                 /* Move NIX desc to LMT/NIXTX area */
    1669                 :            :                 cn10k_nix_xmit_mv_lmt_base(laddr, cmd, flags);
    1670                 :            :                 /* Store sg list directly on lmt line */
    1671                 :            :                 segdw = cn10k_nix_prepare_mseg(txq, tx_pkts[i], &extm, (uint64_t *)laddr,
    1672                 :            :                                                flags);
    1673                 :            :                 cn10k_nix_xmit_prepare_tstamp(txq, laddr, tx_pkts[i]->ol_flags,
    1674                 :            :                                               segdw, flags);
    1675                 :            :                 if (!(flags & NIX_TX_OFFLOAD_SECURITY_F) || !sec) {
    1676                 :            :                         lnum++;
    1677                 :            :                         data128 |= (((__uint128_t)(segdw - 1)) << shft);
    1678                 :            :                         shft += 3;
    1679                 :            :                 }
    1680                 :            :         }
    1681                 :            : 
    1682                 :            :         if ((flags & NIX_TX_VWQE_F) && !(ws[3] & BIT_ULL(35)))
    1683                 :            :                 ws[3] = roc_sso_hws_head_wait(ws[0]);
    1684                 :            : 
    1685                 :            :         left -= burst;
    1686                 :            :         tx_pkts += burst;
    1687                 :            : 
    1688                 :            :         /* Submit CPT instructions if any */
    1689                 :            :         if (flags & NIX_TX_OFFLOAD_SECURITY_F) {
    1690                 :            :                 uint16_t sec_pkts = ((c_lnum << 1) + c_loff);
    1691                 :            : 
    1692                 :            :                 /* Reduce pkts to be sent to CPT */
    1693                 :            :                 burst -= sec_pkts;
    1694                 :            :                 if (flags & NIX_TX_VWQE_F)
    1695                 :            :                         cn10k_nix_vwqe_wait_fc(txq, sec_pkts);
    1696                 :            :                 cn10k_nix_sec_fc_wait(txq, sec_pkts);
    1697                 :            :                 cn10k_nix_sec_steorl(c_io_addr, c_lmt_id, c_lnum, c_loff,
    1698                 :            :                                      c_shft);
    1699                 :            :         }
    1700                 :            : 
    1701                 :            :         data0 = (uint64_t)data128;
    1702                 :            :         data1 = (uint64_t)(data128 >> 64);
    1703                 :            :         /* Make data0 similar to data1 */
    1704                 :            :         data0 >>= 16;
    1705                 :            :         /* Trigger LMTST */
    1706                 :            :         if (burst > 16) {
    1707                 :            :                 pa0 = io_addr | (data0 & 0x7) << 4;
    1708                 :            :                 data0 &= ~0x7ULL;
    1709                 :            :                 /* Move lmtst1..15 sz to bits 63:19 */
    1710                 :            :                 data0 <<= 16;
    1711                 :            :                 data0 |= (15ULL << 12);
    1712                 :            :                 data0 |= (uint64_t)lmt_id;
    1713                 :            : 
    1714                 :            :                 if (flags & NIX_TX_VWQE_F)
    1715                 :            :                         cn10k_nix_vwqe_wait_fc(txq, 16);
    1716                 :            :                 /* STEOR0 */
    1717                 :            :                 roc_lmt_submit_steorl(data0, pa0);
    1718                 :            : 
    1719                 :            :                 pa1 = io_addr | (data1 & 0x7) << 4;
    1720                 :            :                 data1 &= ~0x7ULL;
    1721                 :            :                 data1 <<= 16;
    1722                 :            :                 data1 |= ((uint64_t)(burst - 17)) << 12;
    1723                 :            :                 data1 |= (uint64_t)(lmt_id + 16);
    1724                 :            : 
    1725                 :            :                 if (flags & NIX_TX_VWQE_F)
    1726                 :            :                         cn10k_nix_vwqe_wait_fc(txq, burst - 16);
    1727                 :            :                 /* STEOR1 */
    1728                 :            :                 roc_lmt_submit_steorl(data1, pa1);
    1729                 :            :         } else if (burst) {
    1730                 :            :                 pa0 = io_addr | (data0 & 0x7) << 4;
    1731                 :            :                 data0 &= ~0x7ULL;
    1732                 :            :                 /* Move lmtst1..15 sz to bits 63:19 */
    1733                 :            :                 data0 <<= 16;
    1734                 :            :                 data0 |= ((burst - 1ULL) << 12);
    1735                 :            :                 data0 |= (uint64_t)lmt_id;
    1736                 :            : 
    1737                 :            :                 if (flags & NIX_TX_VWQE_F)
    1738                 :            :                         cn10k_nix_vwqe_wait_fc(txq, burst);
    1739                 :            :                 /* STEOR0 */
    1740                 :            :                 roc_lmt_submit_steorl(data0, pa0);
    1741                 :            :         }
    1742                 :            : 
    1743                 :            :         rte_io_wmb();
    1744                 :            :         if (flags & NIX_TX_OFFLOAD_MBUF_NOFF_F && !txq->tx_compl.ena) {
    1745                 :            :                 cn10k_nix_free_extmbuf(extm);
    1746                 :            :                 extm = NULL;
    1747                 :            :         }
    1748                 :            : 
    1749                 :            :         if (left)
    1750                 :            :                 goto again;
    1751                 :            : 
    1752                 :            :         return pkts;
    1753                 :            : }
    1754                 :            : 
    1755                 :            : #if defined(RTE_ARCH_ARM64)
    1756                 :            : 
    1757                 :            : static __rte_always_inline void
    1758                 :            : cn10k_nix_prepare_tso(struct rte_mbuf *m, union nix_send_hdr_w1_u *w1,
    1759                 :            :                       union nix_send_ext_w0_u *w0, uint64_t ol_flags,
    1760                 :            :                       const uint64_t flags, const uint64_t lso_tun_fmt)
    1761                 :            : {
    1762                 :            :         uint16_t lso_sb;
    1763                 :            :         uint64_t mask;
    1764                 :            : 
    1765                 :            :         if (!(ol_flags & RTE_MBUF_F_TX_TCP_SEG))
    1766                 :            :                 return;
    1767                 :            : 
    1768                 :            :         mask = -(!w1->il3type);
    1769                 :            :         lso_sb = (mask & w1->ol4ptr) + (~mask & w1->il4ptr) + m->l4_len;
    1770                 :            : 
    1771                 :            :         w0->u |= BIT(14);
    1772                 :            :         w0->lso_sb = lso_sb;
    1773                 :            :         w0->lso_mps = m->tso_segsz;
    1774                 :            :         w0->lso_format = NIX_LSO_FORMAT_IDX_TSOV4 + !!(ol_flags & RTE_MBUF_F_TX_IPV6);
    1775                 :            :         w1->ol4type = NIX_SENDL4TYPE_TCP_CKSUM;
    1776                 :            : 
    1777                 :            :         /* Handle tunnel tso */
    1778                 :            :         if ((flags & NIX_TX_OFFLOAD_OL3_OL4_CSUM_F) &&
    1779                 :            :             (ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK)) {
    1780                 :            :                 const uint8_t is_udp_tun =
    1781                 :            :                         (CNXK_NIX_UDP_TUN_BITMASK >>
    1782                 :            :                          ((ol_flags & RTE_MBUF_F_TX_TUNNEL_MASK) >> 45)) &
    1783                 :            :                         0x1;
    1784                 :            :                 uint8_t shift = is_udp_tun ? 32 : 0;
    1785                 :            : 
    1786                 :            :                 shift += (!!(ol_flags & RTE_MBUF_F_TX_OUTER_IPV6) << 4);
    1787                 :            :                 shift += (!!(ol_flags & RTE_MBUF_F_TX_IPV6) << 3);
    1788                 :            : 
    1789                 :            :                 w1->il4type = NIX_SENDL4TYPE_TCP_CKSUM;
    1790                 :            :                 w1->ol4type = is_udp_tun ? NIX_SENDL4TYPE_UDP_CKSUM : 0;
    1791                 :            :                 /* Update format for UDP tunneled packet */
    1792                 :            : 
    1793                 :            :                 w0->lso_format = (lso_tun_fmt >> shift);
    1794                 :            :         }
    1795                 :            : }
    1796                 :            : 
    1797                 :            : static __rte_always_inline uint16_t
    1798                 :            : cn10k_nix_prepare_mseg_vec_noff(struct cn10k_eth_txq *txq,
    1799                 :            :                                 struct rte_mbuf *m, struct rte_mbuf **extm, uint64_t *cmd,
    1800                 :            :                                 uint64x2_t *cmd0, uint64x2_t *cmd1,
    1801                 :            :                                 uint64x2_t *cmd2, uint64x2_t *cmd3,
    1802                 :            :                                 const uint32_t flags)
    1803                 :            : {
    1804                 :            :         uint16_t segdw;
    1805                 :            : 
    1806                 :            :         vst1q_u64(cmd, *cmd0); /* Send hdr */
    1807                 :            :         if (flags & NIX_TX_NEED_EXT_HDR) {
    1808                 :            :                 vst1q_u64(cmd + 2, *cmd2); /* ext hdr */
    1809                 :            :                 vst1q_u64(cmd + 4, *cmd1); /* sg */
    1810                 :            :         } else {
    1811                 :            :                 vst1q_u64(cmd + 2, *cmd1); /* sg */
    1812                 :            :         }
    1813                 :            : 
    1814                 :            :         segdw = cn10k_nix_prepare_mseg(txq, m, extm, cmd, flags);
    1815                 :            : 
    1816                 :            :         if (flags & NIX_TX_OFFLOAD_TSTAMP_F)
    1817                 :            :                 vst1q_u64(cmd + segdw * 2 - 2, *cmd3);
    1818                 :            : 
    1819                 :            :         return segdw;
    1820                 :            : }
    1821                 :            : 
    1822                 :            : static __rte_always_inline void
    1823                 :            : cn10k_nix_prepare_mseg_vec_list(struct rte_mbuf *m, uint64_t *cmd,
    1824                 :            :                                 union nix_send_hdr_w0_u *sh,
    1825                 :            :                                 union nix_send_sg_s *sg, const uint32_t flags)
    1826                 :            : {
    1827                 :            :         struct rte_mbuf *m_next;
    1828                 :            :         uint64_t ol_flags, len;
    1829                 :            :         uint64_t *slist, sg_u;
    1830                 :            :         uint16_t nb_segs;
    1831                 :            :         uint64_t dlen;
    1832                 :            :         int i = 1;
    1833                 :            : 
    1834                 :            :         len = m->pkt_len;
    1835                 :            :         ol_flags = m->ol_flags;
    1836                 :            :         /* For security we would have already populated the right length */
    1837                 :            :         if (flags & NIX_TX_OFFLOAD_SECURITY_F && ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD)
    1838                 :            :                 len = sh->total;
    1839                 :            :         sh->total = len;
    1840                 :            :         /* Clear sg->u header before use */
    1841                 :            :         sg->u &= 0xFC00000000000000;
    1842                 :            :         sg_u = sg->u;
    1843                 :            :         slist = &cmd[0];
    1844                 :            : 
    1845                 :            :         dlen = m->data_len;
    1846                 :            :         len -= dlen;
    1847                 :            :         sg_u = sg_u | ((uint64_t)dlen);
    1848                 :            : 
    1849                 :            :         /* Mark mempool object as "put" since it is freed by NIX */
    1850                 :            :         RTE_MEMPOOL_CHECK_COOKIES(m->pool, (void **)&m, 1, 0);
    1851                 :            : 
    1852                 :            :         nb_segs = m->nb_segs - 1;
    1853                 :            :         m_next = m->next;
    1854                 :            :         m->next = NULL;
    1855                 :            :         m->nb_segs = 1;
    1856                 :            :         m = m_next;
    1857                 :            :         /* Fill mbuf segments */
    1858                 :            :         do {
    1859                 :            :                 m_next = m->next;
    1860                 :            :                 dlen = m->data_len;
    1861                 :            :                 len -= dlen;
    1862                 :            :                 sg_u = sg_u | ((uint64_t)dlen << (i << 4));
    1863                 :            :                 *slist = rte_mbuf_data_iova(m);
    1864                 :            :                 slist++;
    1865                 :            :                 i++;
    1866                 :            :                 nb_segs--;
    1867                 :            :                 if (i > 2 && nb_segs) {
    1868                 :            :                         i = 0;
    1869                 :            :                         /* Next SG subdesc */
    1870                 :            :                         *(uint64_t *)slist = sg_u & 0xFC00000000000000;
    1871                 :            :                         sg->u = sg_u;
    1872                 :            :                         sg->segs = 3;
    1873                 :            :                         sg = (union nix_send_sg_s *)slist;
    1874                 :            :                         sg_u = sg->u;
    1875                 :            :                         slist++;
    1876                 :            :                 }
    1877                 :            :                 m->next = NULL;
    1878                 :            :                 /* Mark mempool object as "put" since it is freed by NIX */
    1879                 :            :                 RTE_MEMPOOL_CHECK_COOKIES(m->pool, (void **)&m, 1, 0);
    1880                 :            : 
    1881                 :            :                 m = m_next;
    1882                 :            :         } while (nb_segs);
    1883                 :            : 
    1884                 :            :         /* Add remaining bytes of security data to last seg */
    1885                 :            :         if (flags & NIX_TX_OFFLOAD_SECURITY_F && ol_flags & RTE_MBUF_F_TX_SEC_OFFLOAD && len) {
    1886                 :            :                 uint8_t shft = ((i - 1) << 4);
    1887                 :            : 
    1888                 :            :                 dlen = ((sg_u >> shft) & 0xFFFF) + len;
    1889                 :            :                 sg_u = sg_u & ~(0xFFFFULL << shft);
    1890                 :            :                 sg_u |= dlen << shft;
    1891                 :            :         }
    1892                 :            :         sg->u = sg_u;
    1893                 :            :         sg->segs = i;
    1894                 :            : }
    1895                 :            : 
    1896                 :            : static __rte_always_inline void
    1897                 :            : cn10k_nix_prepare_mseg_vec(struct rte_mbuf *m, uint64_t *cmd, uint64x2_t *cmd0,
    1898                 :            :                            uint64x2_t *cmd1, const uint8_t segdw,
    1899                 :            :                            const uint32_t flags)
    1900                 :            : {
    1901                 :            :         union nix_send_hdr_w0_u sh;
    1902                 :            :         union nix_send_sg_s sg;
    1903                 :            : 
    1904                 :            :         if (m->nb_segs == 1) {
    1905                 :            :                 /* Mark mempool object as "put" since it is freed by NIX */
    1906                 :            :                 RTE_MEMPOOL_CHECK_COOKIES(m->pool, (void **)&m, 1, 0);
    1907                 :            :                 return;
    1908                 :            :         }
    1909                 :            : 
    1910                 :            :         sh.u = vgetq_lane_u64(cmd0[0], 0);
    1911                 :            :         sg.u = vgetq_lane_u64(cmd1[0], 0);
    1912                 :            : 
    1913                 :            :         cn10k_nix_prepare_mseg_vec_list(m, cmd, &sh, &sg, flags);
    1914                 :            : 
    1915                 :            :         sh.sizem1 = segdw - 1;
    1916                 :            :         cmd0[0] = vsetq_lane_u64(sh.u, cmd0[0], 0);
    1917                 :            :         cmd1[0] = vsetq_lane_u64(sg.u, cmd1[0], 0);
    1918                 :            : }
    1919                 :            : 
    1920                 :            : #define NIX_DESCS_PER_LOOP 4
    1921                 :            : 
    1922                 :            : static __rte_always_inline uint8_t
    1923                 :            : cn10k_nix_prep_lmt_mseg_vector(struct cn10k_eth_txq *txq,
    1924                 :            :                                struct rte_mbuf **mbufs, struct rte_mbuf **extm, uint64x2_t *cmd0,
    1925                 :            :                                uint64x2_t *cmd1, uint64x2_t *cmd2,
    1926                 :            :                                uint64x2_t *cmd3, uint8_t *segdw,
    1927                 :            :                                uint64_t *lmt_addr, __uint128_t *data128,
    1928                 :            :                                uint8_t *shift, const uint16_t flags)
    1929                 :            : {
    1930                 :            :         uint8_t j, off, lmt_used = 0;
    1931                 :            : 
    1932                 :            :         if (flags & NIX_TX_OFFLOAD_MBUF_NOFF_F) {
    1933                 :            :                 off = 0;
    1934                 :            :                 for (j = 0; j < NIX_DESCS_PER_LOOP; j++) {
    1935                 :            :                         if (off + segdw[j] > 8) {
    1936                 :            :                                 *data128 |= ((__uint128_t)off - 1) << *shift;
    1937                 :            :                                 *shift += 3;
    1938                 :            :                                 lmt_used++;
    1939                 :            :                                 lmt_addr += 16;
    1940                 :            :                                 off = 0;
    1941                 :            :                         }
    1942                 :            :                         off += cn10k_nix_prepare_mseg_vec_noff(txq, mbufs[j], extm,
    1943                 :            :                                         lmt_addr + off * 2, &cmd0[j], &cmd1[j],
    1944                 :            :                                         &cmd2[j], &cmd3[j], flags);
    1945                 :            :                 }
    1946                 :            :                 *data128 |= ((__uint128_t)off - 1) << *shift;
    1947                 :            :                 *shift += 3;
    1948                 :            :                 lmt_used++;
    1949                 :            :                 return lmt_used;
    1950                 :            :         }
    1951                 :            : 
    1952                 :            :         if (!(flags & NIX_TX_NEED_EXT_HDR) &&
    1953                 :            :             !(flags & NIX_TX_OFFLOAD_TSTAMP_F)) {
    1954                 :            :                 /* No segments in 4 consecutive packets. */
    1955                 :            :                 if ((segdw[0] + segdw[1] + segdw[2] + segdw[3]) <= 8) {
    1956                 :            :                         vst1q_u64(lmt_addr, cmd0[0]);
    1957                 :            :                         vst1q_u64(lmt_addr + 2, cmd1[0]);
    1958                 :            :                         vst1q_u64(lmt_addr + 4, cmd0[1]);
    1959                 :            :                         vst1q_u64(lmt_addr + 6, cmd1[1]);
    1960                 :            :                         vst1q_u64(lmt_addr + 8, cmd0[2]);
    1961                 :            :                         vst1q_u64(lmt_addr + 10, cmd1[2]);
    1962                 :            :                         vst1q_u64(lmt_addr + 12, cmd0[3]);
    1963                 :            :                         vst1q_u64(lmt_addr + 14, cmd1[3]);
    1964                 :            : 
    1965                 :            :                         *data128 |= ((__uint128_t)7) << *shift;
    1966                 :            :                         *shift += 3;
    1967                 :            : 
    1968                 :            :                         /* Mark mempool object as "put" since it is freed by NIX */
    1969                 :            :                         RTE_MEMPOOL_CHECK_COOKIES(mbufs[0]->pool, (void **)&mbufs[0], 1, 0);
    1970                 :            :                         RTE_MEMPOOL_CHECK_COOKIES(mbufs[1]->pool, (void **)&mbufs[1], 1, 0);
    1971                 :            :                         RTE_MEMPOOL_CHECK_COOKIES(mbufs[2]->pool, (void **)&mbufs[2], 1, 0);
    1972                 :            :                         RTE_MEMPOOL_CHECK_COOKIES(mbufs[3]->pool, (void **)&mbufs[3], 1, 0);
    1973                 :            :                         return 1;
    1974                 :            :                 }
    1975                 :            :         }
    1976                 :            : 
    1977                 :            :         for (j = 0; j < NIX_DESCS_PER_LOOP;) {
    1978                 :            :                 /* Fit consecutive packets in same LMTLINE. */
    1979                 :            :                 if ((segdw[j] + segdw[j + 1]) <= 8) {
    1980                 :            :                         if (flags & NIX_TX_OFFLOAD_TSTAMP_F) {
    1981                 :            :                                 /* TSTAMP takes 4 each, no segs. */
    1982                 :            :                                 vst1q_u64(lmt_addr, cmd0[j]);
    1983                 :            :                                 vst1q_u64(lmt_addr + 2, cmd2[j]);
    1984                 :            :                                 vst1q_u64(lmt_addr + 4, cmd1[j]);
    1985                 :            :                                 vst1q_u64(lmt_addr + 6, cmd3[j]);
    1986                 :            : 
    1987                 :            :                                 vst1q_u64(lmt_addr + 8, cmd0[j + 1]);
    1988                 :            :                                 vst1q_u64(lmt_addr + 10, cmd2[j + 1]);
    1989                 :            :                                 vst1q_u64(lmt_addr + 12, cmd1[j + 1]);
    1990                 :            :                                 vst1q_u64(lmt_addr + 14, cmd3[j + 1]);
    1991                 :            : 
    1992                 :            :                                 /* Mark mempool object as "put" since it is freed by NIX */
    1993                 :            :                                 RTE_MEMPOOL_CHECK_COOKIES(mbufs[j]->pool, (void **)&mbufs[j], 1, 0);
    1994                 :            :                                 RTE_MEMPOOL_CHECK_COOKIES(mbufs[j + 1]->pool,
    1995                 :            :                                                           (void **)&mbufs[j + 1], 1, 0);
    1996                 :            :                         } else if (flags & NIX_TX_NEED_EXT_HDR) {
    1997                 :            :                                 /* EXT header take 3 each, space for 2 segs.*/
    1998                 :            :                                 cn10k_nix_prepare_mseg_vec(mbufs[j],
    1999                 :            :                                                            lmt_addr + 6,
    2000                 :            :                                                            &cmd0[j], &cmd1[j],
    2001                 :            :                                                            segdw[j], flags);
    2002                 :            :                                 vst1q_u64(lmt_addr, cmd0[j]);
    2003                 :            :                                 vst1q_u64(lmt_addr + 2, cmd2[j]);
    2004                 :            :                                 vst1q_u64(lmt_addr + 4, cmd1[j]);
    2005                 :            :                                 off = segdw[j] - 3;
    2006                 :            :                                 off <<= 1;
    2007                 :            :                                 cn10k_nix_prepare_mseg_vec(mbufs[j + 1],
    2008                 :            :                                                            lmt_addr + 12 + off,
    2009                 :            :                                                            &cmd0[j + 1],
    2010                 :            :                                                            &cmd1[j + 1],
    2011                 :            :                                                            segdw[j + 1], flags);
    2012                 :            :                                 vst1q_u64(lmt_addr + 6 + off, cmd0[j + 1]);
    2013                 :            :                                 vst1q_u64(lmt_addr + 8 + off, cmd2[j + 1]);
    2014                 :            :                                 vst1q_u64(lmt_addr + 10 + off, cmd1[j + 1]);
    2015                 :            :                         } else {
    2016                 :            :                                 cn10k_nix_prepare_mseg_vec(mbufs[j],
    2017                 :            :                                                            lmt_addr + 4,
    2018                 :            :                                                            &cmd0[j], &cmd1[j],
    2019                 :            :                                                            segdw[j], flags);
    2020                 :            :                                 vst1q_u64(lmt_addr, cmd0[j]);
    2021                 :            :                                 vst1q_u64(lmt_addr + 2, cmd1[j]);
    2022                 :            :                                 off = segdw[j] - 2;
    2023                 :            :                                 off <<= 1;
    2024                 :            :                                 cn10k_nix_prepare_mseg_vec(mbufs[j + 1],
    2025                 :            :                                                            lmt_addr + 8 + off,
    2026                 :            :                                                            &cmd0[j + 1],
    2027                 :            :                                                            &cmd1[j + 1],
    2028                 :            :                                                            segdw[j + 1], flags);
    2029                 :            :                                 vst1q_u64(lmt_addr + 4 + off, cmd0[j + 1]);
    2030                 :            :                                 vst1q_u64(lmt_addr + 6 + off, cmd1[j + 1]);
    2031                 :            :                         }
    2032                 :            :                         *data128 |= ((__uint128_t)(segdw[j] + segdw[j + 1]) - 1)
    2033                 :            :                                     << *shift;
    2034                 :            :                         *shift += 3;
    2035                 :            :                         j += 2;
    2036                 :            :                 } else {
    2037                 :            :                         if ((flags & NIX_TX_NEED_EXT_HDR) &&
    2038                 :            :                             (flags & NIX_TX_OFFLOAD_TSTAMP_F)) {
    2039                 :            :                                 cn10k_nix_prepare_mseg_vec(mbufs[j],
    2040                 :            :                                                            lmt_addr + 6,
    2041                 :            :                                                            &cmd0[j], &cmd1[j],
    2042                 :            :                                                            segdw[j], flags);
    2043                 :            :                                 vst1q_u64(lmt_addr, cmd0[j]);
    2044                 :            :                                 vst1q_u64(lmt_addr + 2, cmd2[j]);
    2045                 :            :                                 vst1q_u64(lmt_addr + 4, cmd1[j]);
    2046                 :            :                                 off = segdw[j] - 4;
    2047                 :            :                                 off <<= 1;
    2048                 :            :                                 vst1q_u64(lmt_addr + 6 + off, cmd3[j]);
    2049                 :            :                         } else if (flags & NIX_TX_NEED_EXT_HDR) {
    2050                 :            :                                 cn10k_nix_prepare_mseg_vec(mbufs[j],
    2051                 :            :                                                            lmt_addr + 6,
    2052                 :            :                                                            &cmd0[j], &cmd1[j],
    2053                 :            :                                                            segdw[j], flags);
    2054                 :            :                                 vst1q_u64(lmt_addr, cmd0[j]);
    2055                 :            :                                 vst1q_u64(lmt_addr + 2, cmd2[j]);
    2056                 :            :                                 vst1q_u64(lmt_addr + 4, cmd1[j]);
    2057                 :            :                         } else {
    2058                 :            :                                 cn10k_nix_prepare_mseg_vec(mbufs[j],
    2059                 :            :                                                            lmt_addr + 4,
    2060                 :            :                                                            &cmd0[j], &cmd1[j],
    2061                 :            :                                                            segdw[j], flags);
    2062                 :            :                                 vst1q_u64(lmt_addr, cmd0[j]);
    2063                 :            :                                 vst1q_u64(lmt_addr + 2, cmd1[j]);
    2064                 :            :                         }
    2065                 :            :                         *data128 |= ((__uint128_t)(segdw[j]) - 1) << *shift;
    2066                 :            :                         *shift += 3;
    2067                 :            :                         j++;
    2068                 :            :                 }
    2069                 :            :                 lmt_used++;
    2070                 :            :                 lmt_addr += 16;
    2071                 :            :         }
    2072                 :            : 
    2073                 :            :         return lmt_used;
    2074                 :            : }
    2075                 :            : 
    2076                 :            : static __rte_always_inline void
    2077                 :            : cn10k_nix_lmt_next(uint8_t dw, uintptr_t laddr, uint8_t *lnum, uint8_t *loff,
    2078                 :            :                    uint8_t *shift, __uint128_t *data128, uintptr_t *next)
    2079                 :            : {
    2080                 :            :         /* Go to next line if we are out of space */
    2081                 :            :         if ((*loff + (dw << 4)) > 128) {
    2082                 :            :                 *data128 = *data128 |
    2083                 :            :                            (((__uint128_t)((*loff >> 4) - 1)) << *shift);
    2084                 :            :                 *shift = *shift + 3;
    2085                 :            :                 *loff = 0;
    2086                 :            :                 *lnum = *lnum + 1;
    2087                 :            :         }
    2088                 :            : 
    2089                 :            :         *next = (uintptr_t)LMT_OFF(laddr, *lnum, *loff);
    2090                 :            :         *loff = *loff + (dw << 4);
    2091                 :            : }
    2092                 :            : 
    2093                 :            : static __rte_always_inline void
    2094                 :            : cn10k_nix_xmit_store(struct cn10k_eth_txq *txq,
    2095                 :            :                      struct rte_mbuf *mbuf, struct rte_mbuf **extm, uint8_t segdw, uintptr_t laddr,
    2096                 :            :                      uint64x2_t cmd0, uint64x2_t cmd1, uint64x2_t cmd2,
    2097                 :            :                      uint64x2_t cmd3, const uint16_t flags)
    2098                 :            : {
    2099                 :            :         uint8_t off;
    2100                 :            : 
    2101                 :            :         if (flags & NIX_TX_OFFLOAD_MBUF_NOFF_F) {
    2102                 :            :                 cn10k_nix_prepare_mseg_vec_noff(txq, mbuf, extm, LMT_OFF(laddr, 0, 0),
    2103                 :            :                                                 &cmd0, &cmd1, &cmd2, &cmd3,
    2104                 :            :                                                 flags);
    2105                 :            :                 return;
    2106                 :            :         }
    2107                 :            :         if (flags & NIX_TX_MULTI_SEG_F) {
    2108                 :            :                 if ((flags & NIX_TX_NEED_EXT_HDR) &&
    2109                 :            :                     (flags & NIX_TX_OFFLOAD_TSTAMP_F)) {
    2110                 :            :                         cn10k_nix_prepare_mseg_vec(mbuf, LMT_OFF(laddr, 0, 48),
    2111                 :            :                                                    &cmd0, &cmd1, segdw, flags);
    2112                 :            :                         vst1q_u64(LMT_OFF(laddr, 0, 0), cmd0);
    2113                 :            :                         vst1q_u64(LMT_OFF(laddr, 0, 16), cmd2);
    2114                 :            :                         vst1q_u64(LMT_OFF(laddr, 0, 32), cmd1);
    2115                 :            :                         off = segdw - 4;
    2116                 :            :                         off <<= 4;
    2117                 :            :                         vst1q_u64(LMT_OFF(laddr, 0, 48 + off), cmd3);
    2118                 :            :                 } else if (flags & NIX_TX_NEED_EXT_HDR) {
    2119                 :            :                         cn10k_nix_prepare_mseg_vec(mbuf, LMT_OFF(laddr, 0, 48),
    2120                 :            :                                                    &cmd0, &cmd1, segdw, flags);
    2121                 :            :                         vst1q_u64(LMT_OFF(laddr, 0, 0), cmd0);
    2122                 :            :                         vst1q_u64(LMT_OFF(laddr, 0, 16), cmd2);
    2123                 :            :                         vst1q_u64(LMT_OFF(laddr, 0, 32), cmd1);
    2124                 :            :                 } else {
    2125                 :            :                         cn10k_nix_prepare_mseg_vec(mbuf, LMT_OFF(laddr, 0, 32),
    2126                 :            :                                                    &cmd0, &cmd1, segdw, flags);
    2127                 :            :                         vst1q_u64(LMT_OFF(laddr, 0, 0), cmd0);
    2128                 :            :                         vst1q_u64(LMT_OFF(laddr, 0, 16), cmd1);
    2129                 :            :                 }
    2130                 :            :         } else if (flags & NIX_TX_NEED_EXT_HDR) {
    2131                 :            :                 /* Store the prepared send desc to LMT lines */
    2132                 :            :                 if (flags & NIX_TX_OFFLOAD_TSTAMP_F) {
    2133                 :            :                         vst1q_u64(LMT_OFF(laddr, 0, 0), cmd0);
    2134                 :            :                         vst1q_u64(LMT_OFF(laddr, 0, 16), cmd2);
    2135                 :            :                         vst1q_u64(LMT_OFF(laddr, 0, 32), cmd1);
    2136                 :            :                         vst1q_u64(LMT_OFF(laddr, 0, 48), cmd3);
    2137                 :            :                 } else {
    2138                 :            :                         vst1q_u64(LMT_OFF(laddr, 0, 0), cmd0);
    2139                 :            :                         vst1q_u64(LMT_OFF(laddr, 0, 16), cmd2);
    2140                 :            :                         vst1q_u64(LMT_OFF(laddr, 0, 32), cmd1);
    2141                 :            :                 }
    2142                 :            :                 RTE_MEMPOOL_CHECK_COOKIES(mbuf->pool, (void **)&mbuf, 1, 0);
    2143                 :            :         } else {
    2144                 :            :                 /* Store the prepared send desc to LMT lines */
    2145                 :            :                 vst1q_u64(LMT_OFF(laddr, 0, 0), cmd0);
    2146                 :            :                 vst1q_u64(LMT_OFF(laddr, 0, 16), cmd1);
    2147                 :            :                 RTE_MEMPOOL_CHECK_COOKIES(mbuf->pool, (void **)&mbuf, 1, 0);
    2148                 :            :         }
    2149                 :            : }
    2150                 :            : 
    2151                 :            : static __rte_always_inline uint16_t
    2152                 :            : cn10k_nix_xmit_pkts_vector(void *tx_queue, uint64_t *ws,
    2153                 :            :                            struct rte_mbuf **tx_pkts, uint16_t pkts,
    2154                 :            :                            uint64_t *cmd, const uint16_t flags)
    2155                 :            : {
    2156                 :            :         uint64x2_t dataoff_iova0, dataoff_iova1, dataoff_iova2, dataoff_iova3;
    2157                 :            :         uint64x2_t len_olflags0, len_olflags1, len_olflags2, len_olflags3;
    2158                 :            :         uint64x2_t cmd0[NIX_DESCS_PER_LOOP], cmd1[NIX_DESCS_PER_LOOP],
    2159                 :            :                 cmd2[NIX_DESCS_PER_LOOP], cmd3[NIX_DESCS_PER_LOOP];
    2160                 :            :         uint16_t left, scalar, burst, i, lmt_id, c_lmt_id;
    2161                 :            :         uint64_t *mbuf0, *mbuf1, *mbuf2, *mbuf3, pa;
    2162                 :            :         uint64x2_t senddesc01_w0, senddesc23_w0;
    2163                 :            :         uint64x2_t senddesc01_w1, senddesc23_w1;
    2164                 :            :         uint64x2_t sendext01_w0, sendext23_w0;
    2165                 :            :         uint64x2_t sendext01_w1, sendext23_w1;
    2166                 :            :         uint64x2_t sendmem01_w0, sendmem23_w0;
    2167                 :            :         uint64x2_t sendmem01_w1, sendmem23_w1;
    2168                 :            :         uint8_t segdw[NIX_DESCS_PER_LOOP + 1];
    2169                 :            :         uint64x2_t sgdesc01_w0, sgdesc23_w0;
    2170                 :            :         uint64x2_t sgdesc01_w1, sgdesc23_w1;
    2171                 :            :         struct cn10k_eth_txq *txq = tx_queue;
    2172                 :            :         rte_iova_t io_addr = txq->io_addr;
    2173                 :            :         uint8_t lnum, shift = 0, loff = 0;
    2174                 :            :         uintptr_t laddr = txq->lmt_base;
    2175                 :            :         uint8_t c_lnum, c_shft, c_loff;
    2176                 :            :         uint64x2_t ltypes01, ltypes23;
    2177                 :            :         uint64x2_t xtmp128, ytmp128;
    2178                 :            :         uint64x2_t xmask01, xmask23;
    2179                 :            :         uintptr_t c_laddr = laddr;
    2180                 :            :         rte_iova_t c_io_addr;
    2181                 :            :         uint64_t sa_base;
    2182                 :            :         union wdata {
    2183                 :            :                 __uint128_t data128;
    2184                 :            :                 uint64_t data[2];
    2185                 :            :         } wd;
    2186                 :            :         struct rte_mbuf *extm = NULL;
    2187                 :            : 
    2188                 :            :         if (flags & NIX_TX_OFFLOAD_MBUF_NOFF_F && txq->tx_compl.ena)
    2189                 :            :                 handle_tx_completion_pkts(txq, flags & NIX_TX_VWQE_F);
    2190                 :            : 
    2191                 :            :         if (!(flags & NIX_TX_VWQE_F)) {
    2192                 :            :                 scalar = pkts & (NIX_DESCS_PER_LOOP - 1);
    2193                 :            :                 pkts = RTE_ALIGN_FLOOR(pkts, NIX_DESCS_PER_LOOP);
    2194                 :            :                 NIX_XMIT_FC_CHECK_RETURN(txq, pkts);
    2195                 :            :         } else {
    2196                 :            :                 scalar = pkts & (NIX_DESCS_PER_LOOP - 1);
    2197                 :            :                 pkts = RTE_ALIGN_FLOOR(pkts, NIX_DESCS_PER_LOOP);
    2198                 :            :         }
    2199                 :            : 
    2200                 :            :         /* Perform header writes before barrier for TSO */
    2201                 :            :         if (flags & NIX_TX_OFFLOAD_TSO_F) {
    2202                 :            :                 for (i = 0; i < pkts; i++)
    2203                 :            :                         cn10k_nix_xmit_prepare_tso(tx_pkts[i], flags);
    2204                 :            :         }
    2205                 :            : 
    2206                 :            :         if (!(flags & NIX_TX_VWQE_F)) {
    2207                 :            :                 senddesc01_w0 = vld1q_dup_u64(&txq->send_hdr_w0);
    2208                 :            :         } else {
    2209                 :            :                 uint64_t w0 =
    2210                 :            :                         (txq->send_hdr_w0 & 0xFFFFF00000000000) |
    2211                 :            :                         ((uint64_t)(cn10k_nix_tx_ext_subs(flags) + 1) << 40);
    2212                 :            : 
    2213                 :            :                 senddesc01_w0 = vdupq_n_u64(w0);
    2214                 :            :         }
    2215                 :            :         senddesc23_w0 = senddesc01_w0;
    2216                 :            : 
    2217                 :            :         senddesc01_w1 = vdupq_n_u64(0);
    2218                 :            :         senddesc23_w1 = senddesc01_w1;
    2219                 :            :         if (!(flags & NIX_TX_OFFLOAD_MBUF_NOFF_F))
    2220                 :            :                 sgdesc01_w0 = vdupq_n_u64((NIX_SUBDC_SG << 60) | (NIX_SENDLDTYPE_LDWB << 58) |
    2221                 :            :                                           BIT_ULL(48));
    2222                 :            :         else
    2223                 :            :                 sgdesc01_w0 = vdupq_n_u64((NIX_SUBDC_SG << 60) | BIT_ULL(48));
    2224                 :            :         sgdesc23_w0 = sgdesc01_w0;
    2225                 :            : 
    2226                 :            :         if (flags & NIX_TX_NEED_EXT_HDR) {
    2227                 :            :                 if (flags & NIX_TX_OFFLOAD_TSTAMP_F) {
    2228                 :            :                         sendext01_w0 = vdupq_n_u64((NIX_SUBDC_EXT << 60) |
    2229                 :            :                                                    BIT_ULL(15));
    2230                 :            :                         sendmem01_w0 =
    2231                 :            :                                 vdupq_n_u64((NIX_SUBDC_MEM << 60) |
    2232                 :            :                                             (NIX_SENDMEMALG_SETTSTMP << 56));
    2233                 :            :                         sendmem23_w0 = sendmem01_w0;
    2234                 :            :                         sendmem01_w1 = vdupq_n_u64(txq->ts_mem);
    2235                 :            :                         sendmem23_w1 = sendmem01_w1;
    2236                 :            :                 } else {
    2237                 :            :                         sendext01_w0 = vdupq_n_u64((NIX_SUBDC_EXT << 60));
    2238                 :            :                 }
    2239                 :            :                 sendext23_w0 = sendext01_w0;
    2240                 :            : 
    2241                 :            :                 if (flags & NIX_TX_OFFLOAD_VLAN_QINQ_F)
    2242                 :            :                         sendext01_w1 = vdupq_n_u64(12 | 12U << 24);
    2243                 :            :                 else
    2244                 :            :                         sendext01_w1 = vdupq_n_u64(0);
    2245                 :            :                 sendext23_w1 = sendext01_w1;
    2246                 :            :         }
    2247                 :            : 
    2248                 :            :         /* Get LMT base address and LMT ID as lcore id */
    2249                 :            :         ROC_LMT_BASE_ID_GET(laddr, lmt_id);
    2250                 :            :         if (flags & NIX_TX_OFFLOAD_SECURITY_F) {
    2251                 :            :                 ROC_LMT_CPT_BASE_ID_GET(c_laddr, c_lmt_id);
    2252                 :            :                 c_io_addr = txq->cpt_io_addr;
    2253                 :            :                 sa_base = txq->sa_base;
    2254                 :            :         }
    2255                 :            : 
    2256                 :            :         left = pkts;
    2257                 :            : again:
    2258                 :            :         /* Number of packets to prepare depends on offloads enabled. */
    2259                 :            :         burst = left > cn10k_nix_pkts_per_vec_brst(flags) ?
    2260                 :            :                               cn10k_nix_pkts_per_vec_brst(flags) :
    2261                 :            :                               left;
    2262                 :            :         if (flags & (NIX_TX_MULTI_SEG_F | NIX_TX_OFFLOAD_SECURITY_F)) {
    2263                 :            :                 wd.data128 = 0;
    2264                 :            :                 shift = 16;
    2265                 :            :         }
    2266                 :            :         lnum = 0;
    2267                 :            :         if (flags & NIX_TX_OFFLOAD_SECURITY_F) {
    2268                 :            :                 loff = 0;
    2269                 :            :                 c_loff = 0;
    2270                 :            :                 c_lnum = 0;
    2271                 :            :                 c_shft = 16;
    2272                 :            :         }
    2273                 :            : 
    2274                 :            :         for (i = 0; i < burst; i += NIX_DESCS_PER_LOOP) {
    2275                 :            :                 if (flags & NIX_TX_OFFLOAD_SECURITY_F &&
    2276                 :            :                     (((int)((16 - c_lnum) << 1) - c_loff) < 4)) {
    2277                 :            :                         burst = i;
    2278                 :            :                         break;
    2279                 :            :                 }
    2280                 :            : 
    2281                 :            :                 if (flags & NIX_TX_MULTI_SEG_F) {
    2282                 :            :                         uint8_t j;
    2283                 :            : 
    2284                 :            :                         for (j = 0; j < NIX_DESCS_PER_LOOP; j++) {
    2285                 :            :                                 struct rte_mbuf *m = tx_pkts[j];
    2286                 :            : 
    2287                 :            :                                 cn10k_nix_tx_mbuf_validate(m, flags);
    2288                 :            : 
    2289                 :            :                                 /* Get dwords based on nb_segs. */
    2290                 :            :                                 if (!(flags & NIX_TX_OFFLOAD_MBUF_NOFF_F &&
    2291                 :            :                                       flags & NIX_TX_MULTI_SEG_F))
    2292                 :            :                                         segdw[j] = NIX_NB_SEGS_TO_SEGDW(m->nb_segs);
    2293                 :            :                                 else
    2294                 :            :                                         segdw[j] = cn10k_nix_mbuf_sg_dwords(m);
    2295                 :            : 
    2296                 :            :                                 /* Add dwords based on offloads. */
    2297                 :            :                                 segdw[j] += 1 + /* SEND HDR */
    2298                 :            :                                             !!(flags & NIX_TX_NEED_EXT_HDR) +
    2299                 :            :                                             !!(flags & NIX_TX_OFFLOAD_TSTAMP_F);
    2300                 :            :                         }
    2301                 :            : 
    2302                 :            :                         /* Check if there are enough LMTLINES for this loop.
    2303                 :            :                          * Consider previous line to be partial.
    2304                 :            :                          */
    2305                 :            :                         if (lnum + 4 >= 32) {
    2306                 :            :                                 uint8_t ldwords_con = 0, lneeded = 0;
    2307                 :            : 
    2308                 :            :                                 if ((loff >> 4) + segdw[0] > 8) {
    2309                 :            :                                         lneeded += 1;
    2310                 :            :                                         ldwords_con = segdw[0];
    2311                 :            :                                 } else {
    2312                 :            :                                         ldwords_con = (loff >> 4) + segdw[0];
    2313                 :            :                                 }
    2314                 :            : 
    2315                 :            :                                 for (j = 1; j < NIX_DESCS_PER_LOOP; j++) {
    2316                 :            :                                         ldwords_con += segdw[j];
    2317                 :            :                                         if (ldwords_con > 8) {
    2318                 :            :                                                 lneeded += 1;
    2319                 :            :                                                 ldwords_con = segdw[j];
    2320                 :            :                                         }
    2321                 :            :                                 }
    2322                 :            :                                 lneeded += 1;
    2323                 :            :                                 if (lnum + lneeded > 32) {
    2324                 :            :                                         burst = i;
    2325                 :            :                                         break;
    2326                 :            :                                 }
    2327                 :            :                         }
    2328                 :            :                 }
    2329                 :            :                 /* Clear lower 32bit of SEND_HDR_W0 and SEND_SG_W0 */
    2330                 :            :                 senddesc01_w0 =
    2331                 :            :                         vbicq_u64(senddesc01_w0, vdupq_n_u64(0x800FFFFFFFF));
    2332                 :            :                 sgdesc01_w0 = vbicq_u64(sgdesc01_w0, vdupq_n_u64(0xFFFFFFFF));
    2333                 :            : 
    2334                 :            :                 senddesc23_w0 = senddesc01_w0;
    2335                 :            :                 sgdesc23_w0 = sgdesc01_w0;
    2336                 :            : 
    2337                 :            :                 /* Clear vlan enables. */
    2338                 :            :                 if (flags & NIX_TX_NEED_EXT_HDR) {
    2339                 :            :                         sendext01_w1 = vbicq_u64(sendext01_w1,
    2340                 :            :                                                  vdupq_n_u64(0x3FFFF00FFFF00));
    2341                 :            :                         sendext23_w1 = sendext01_w1;
    2342                 :            :                 }
    2343                 :            : 
    2344                 :            :                 if (flags & NIX_TX_OFFLOAD_TSTAMP_F) {
    2345                 :            :                         /* Reset send mem alg to SETTSTMP from SUB*/
    2346                 :            :                         sendmem01_w0 = vbicq_u64(sendmem01_w0,
    2347                 :            :                                                  vdupq_n_u64(BIT_ULL(59)));
    2348                 :            :                         /* Reset send mem address to default. */
    2349                 :            :                         sendmem01_w1 =
    2350                 :            :                                 vbicq_u64(sendmem01_w1, vdupq_n_u64(0xF));
    2351                 :            :                         sendmem23_w0 = sendmem01_w0;
    2352                 :            :                         sendmem23_w1 = sendmem01_w1;
    2353                 :            :                 }
    2354                 :            : 
    2355                 :            :                 if (flags & NIX_TX_OFFLOAD_TSO_F) {
    2356                 :            :                         /* Clear the LSO enable bit. */
    2357                 :            :                         sendext01_w0 = vbicq_u64(sendext01_w0,
    2358                 :            :                                                  vdupq_n_u64(BIT_ULL(14)));
    2359                 :            :                         sendext23_w0 = sendext01_w0;
    2360                 :            :                 }
    2361                 :            : 
    2362                 :            :                 /* Move mbufs to iova */
    2363                 :            :                 mbuf0 = (uint64_t *)tx_pkts[0];
    2364                 :            :                 mbuf1 = (uint64_t *)tx_pkts[1];
    2365                 :            :                 mbuf2 = (uint64_t *)tx_pkts[2];
    2366                 :            :                 mbuf3 = (uint64_t *)tx_pkts[3];
    2367                 :            : 
    2368                 :            :                 /*
    2369                 :            :                  * Get mbuf's, olflags, iova, pktlen, dataoff
    2370                 :            :                  * dataoff_iovaX.D[0] = iova,
    2371                 :            :                  * dataoff_iovaX.D[1](15:0) = mbuf->dataoff
    2372                 :            :                  * len_olflagsX.D[0] = ol_flags,
    2373                 :            :                  * len_olflagsX.D[1](63:32) = mbuf->pkt_len
    2374                 :            :                  */
    2375                 :            :                 dataoff_iova0 =
    2376                 :            :                         vsetq_lane_u64(((struct rte_mbuf *)mbuf0)->data_off, vld1q_u64(mbuf0), 1);
    2377                 :            :                 len_olflags0 = vld1q_u64(mbuf0 + 3);
    2378                 :            :                 dataoff_iova1 =
    2379                 :            :                         vsetq_lane_u64(((struct rte_mbuf *)mbuf1)->data_off, vld1q_u64(mbuf1), 1);
    2380                 :            :                 len_olflags1 = vld1q_u64(mbuf1 + 3);
    2381                 :            :                 dataoff_iova2 =
    2382                 :            :                         vsetq_lane_u64(((struct rte_mbuf *)mbuf2)->data_off, vld1q_u64(mbuf2), 1);
    2383                 :            :                 len_olflags2 = vld1q_u64(mbuf2 + 3);
    2384                 :            :                 dataoff_iova3 =
    2385                 :            :                         vsetq_lane_u64(((struct rte_mbuf *)mbuf3)->data_off, vld1q_u64(mbuf3), 1);
    2386                 :            :                 len_olflags3 = vld1q_u64(mbuf3 + 3);
    2387                 :            : 
    2388                 :            :                 /* Move mbufs to point pool */
    2389                 :            :                 mbuf0 = (uint64_t *)((uintptr_t)mbuf0 + offsetof(struct rte_mbuf, pool));
    2390                 :            :                 mbuf1 = (uint64_t *)((uintptr_t)mbuf1 + offsetof(struct rte_mbuf, pool));
    2391                 :            :                 mbuf2 = (uint64_t *)((uintptr_t)mbuf2 + offsetof(struct rte_mbuf, pool));
    2392                 :            :                 mbuf3 = (uint64_t *)((uintptr_t)mbuf3 + offsetof(struct rte_mbuf, pool));
    2393                 :            : 
    2394                 :            :                 if (flags & (NIX_TX_OFFLOAD_OL3_OL4_CSUM_F |
    2395                 :            :                              NIX_TX_OFFLOAD_L3_L4_CSUM_F)) {
    2396                 :            :                         /* Get tx_offload for ol2, ol3, l2, l3 lengths */
    2397                 :            :                         /*
    2398                 :            :                          * E(8):OL2_LEN(7):OL3_LEN(9):E(24):L3_LEN(9):L2_LEN(7)
    2399                 :            :                          * E(8):OL2_LEN(7):OL3_LEN(9):E(24):L3_LEN(9):L2_LEN(7)
    2400                 :            :                          */
    2401                 :            : 
    2402                 :            :                         asm volatile("LD1 {%[a].D}[0],[%[in]]\n\t"
    2403                 :            :                                      : [a] "+w"(senddesc01_w1)
    2404                 :            :                                      : [in] "r"(mbuf0 + 2)
    2405                 :            :                                      : "memory");
    2406                 :            : 
    2407                 :            :                         asm volatile("LD1 {%[a].D}[1],[%[in]]\n\t"
    2408                 :            :                                      : [a] "+w"(senddesc01_w1)
    2409                 :            :                                      : [in] "r"(mbuf1 + 2)
    2410                 :            :                                      : "memory");
    2411                 :            : 
    2412                 :            :                         asm volatile("LD1 {%[b].D}[0],[%[in]]\n\t"
    2413                 :            :                                      : [b] "+w"(senddesc23_w1)
    2414                 :            :                                      : [in] "r"(mbuf2 + 2)
    2415                 :            :                                      : "memory");
    2416                 :            : 
    2417                 :            :                         asm volatile("LD1 {%[b].D}[1],[%[in]]\n\t"
    2418                 :            :                                      : [b] "+w"(senddesc23_w1)
    2419                 :            :                                      : [in] "r"(mbuf3 + 2)
    2420                 :            :                                      : "memory");
    2421                 :            : 
    2422                 :            :                         /* Get pool pointer alone */
    2423                 :            :                         mbuf0 = (uint64_t *)*mbuf0;
    2424                 :            :                         mbuf1 = (uint64_t *)*mbuf1;
    2425                 :            :                         mbuf2 = (uint64_t *)*mbuf2;
    2426                 :            :                         mbuf3 = (uint64_t *)*mbuf3;
    2427                 :            :                 } else {
    2428                 :            :                         /* Get pool pointer alone */
    2429                 :            :                         mbuf0 = (uint64_t *)*mbuf0;
    2430                 :            :                         mbuf1 = (uint64_t *)*mbuf1;
    2431                 :            :                         mbuf2 = (uint64_t *)*mbuf2;
    2432                 :            :                         mbuf3 = (uint64_t *)*mbuf3;
    2433                 :            :                 }
    2434                 :            : 
    2435                 :            :                 const uint8x16_t shuf_mask2 = {
    2436                 :            :                         0x4, 0x5, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
    2437                 :            :                         0xc, 0xd, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
    2438                 :            :                 };
    2439                 :            :                 xtmp128 = vzip2q_u64(len_olflags0, len_olflags1);
    2440                 :            :                 ytmp128 = vzip2q_u64(len_olflags2, len_olflags3);
    2441                 :            : 
    2442                 :            :                 /*
    2443                 :            :                  * Pick only 16 bits of pktlen preset at bits 63:32
    2444                 :            :                  * and place them at bits 15:0.
    2445                 :            :                  */
    2446                 :            :                 xtmp128 = vqtbl1q_u8(xtmp128, shuf_mask2);
    2447                 :            :                 ytmp128 = vqtbl1q_u8(ytmp128, shuf_mask2);
    2448                 :            : 
    2449                 :            :                 /* Add pairwise to get dataoff + iova in sgdesc_w1 */
    2450                 :            :                 sgdesc01_w1 = vpaddq_u64(dataoff_iova0, dataoff_iova1);
    2451                 :            :                 sgdesc23_w1 = vpaddq_u64(dataoff_iova2, dataoff_iova3);
    2452                 :            : 
    2453                 :            :                 /* Orr both sgdesc_w0 and senddesc_w0 with 16 bits of
    2454                 :            :                  * pktlen at 15:0 position.
    2455                 :            :                  */
    2456                 :            :                 sgdesc01_w0 = vorrq_u64(sgdesc01_w0, xtmp128);
    2457                 :            :                 sgdesc23_w0 = vorrq_u64(sgdesc23_w0, ytmp128);
    2458                 :            :                 senddesc01_w0 = vorrq_u64(senddesc01_w0, xtmp128);
    2459                 :            :                 senddesc23_w0 = vorrq_u64(senddesc23_w0, ytmp128);
    2460                 :            : 
    2461                 :            :                 /* Move mbuf to point to pool_id. */
    2462                 :            :                 mbuf0 = (uint64_t *)((uintptr_t)mbuf0 +
    2463                 :            :                                      offsetof(struct rte_mempool, pool_id));
    2464                 :            :                 mbuf1 = (uint64_t *)((uintptr_t)mbuf1 +
    2465                 :            :                                      offsetof(struct rte_mempool, pool_id));
    2466                 :            :                 mbuf2 = (uint64_t *)((uintptr_t)mbuf2 +
    2467                 :            :                                      offsetof(struct rte_mempool, pool_id));
    2468                 :            :                 mbuf3 = (uint64_t *)((uintptr_t)mbuf3 +
    2469                 :            :                                      offsetof(struct rte_mempool, pool_id));
    2470                 :            : 
    2471                 :            :                 if ((flags & NIX_TX_OFFLOAD_L3_L4_CSUM_F) &&
    2472                 :            :                     !(flags & NIX_TX_OFFLOAD_OL3_OL4_CSUM_F)) {
    2473                 :            :                         /*
    2474                 :            :                          * Lookup table to translate ol_flags to
    2475                 :            :                          * il3/il4 types. But we still use ol3/ol4 types in
    2476                 :            :                          * senddesc_w1 as only one header processing is enabled.
    2477                 :            :                          */
    2478                 :            :                         const uint8x16_t tbl = {
    2479                 :            :                                 /* [0-15] = il4type:il3type */
    2480                 :            :                                 0x04, /* none (IPv6 assumed) */
    2481                 :            :                                 0x14, /* RTE_MBUF_F_TX_TCP_CKSUM (IPv6 assumed) */
    2482                 :            :                                 0x24, /* RTE_MBUF_F_TX_SCTP_CKSUM (IPv6 assumed) */
    2483                 :            :                                 0x34, /* RTE_MBUF_F_TX_UDP_CKSUM (IPv6 assumed) */
    2484                 :            :                                 0x03, /* RTE_MBUF_F_TX_IP_CKSUM */
    2485                 :            :                                 0x13, /* RTE_MBUF_F_TX_IP_CKSUM | RTE_MBUF_F_TX_TCP_CKSUM */
    2486                 :            :                                 0x23, /* RTE_MBUF_F_TX_IP_CKSUM | RTE_MBUF_F_TX_SCTP_CKSUM */
    2487                 :            :                                 0x33, /* RTE_MBUF_F_TX_IP_CKSUM | RTE_MBUF_F_TX_UDP_CKSUM */
    2488                 :            :                                 0x02, /* RTE_MBUF_F_TX_IPV4  */
    2489                 :            :                                 0x12, /* RTE_MBUF_F_TX_IPV4 | RTE_MBUF_F_TX_TCP_CKSUM */
    2490                 :            :                                 0x22, /* RTE_MBUF_F_TX_IPV4 | RTE_MBUF_F_TX_SCTP_CKSUM */
    2491                 :            :                                 0x32, /* RTE_MBUF_F_TX_IPV4 | RTE_MBUF_F_TX_UDP_CKSUM */
    2492                 :            :                                 0x03, /* RTE_MBUF_F_TX_IPV4 | RTE_MBUF_F_TX_IP_CKSUM */
    2493                 :            :                                 0x13, /* RTE_MBUF_F_TX_IPV4 | RTE_MBUF_F_TX_IP_CKSUM |
    2494                 :            :                                        * RTE_MBUF_F_TX_TCP_CKSUM
    2495                 :            :                                        */
    2496                 :            :                                 0x23, /* RTE_MBUF_F_TX_IPV4 | RTE_MBUF_F_TX_IP_CKSUM |
    2497                 :            :                                        * RTE_MBUF_F_TX_SCTP_CKSUM
    2498                 :            :                                        */
    2499                 :            :                                 0x33, /* RTE_MBUF_F_TX_IPV4 | RTE_MBUF_F_TX_IP_CKSUM |
    2500                 :            :                                        * RTE_MBUF_F_TX_UDP_CKSUM
    2501                 :            :                                        */
    2502                 :            :                         };
    2503                 :            : 
    2504                 :            :                         /* Extract olflags to translate to iltypes */
    2505                 :            :                         xtmp128 = vzip1q_u64(len_olflags0, len_olflags1);
    2506                 :            :                         ytmp128 = vzip1q_u64(len_olflags2, len_olflags3);
    2507                 :            : 
    2508                 :            :                         /*
    2509                 :            :                          * E(47):L3_LEN(9):L2_LEN(7+z)
    2510                 :            :                          * E(47):L3_LEN(9):L2_LEN(7+z)
    2511                 :            :                          */
    2512                 :            :                         senddesc01_w1 = vshlq_n_u64(senddesc01_w1, 1);
    2513                 :            :                         senddesc23_w1 = vshlq_n_u64(senddesc23_w1, 1);
    2514                 :            : 
    2515                 :            :                         /* Move OLFLAGS bits 55:52 to 51:48
    2516                 :            :                          * with zeros preprended on the byte and rest
    2517                 :            :                          * don't care
    2518                 :            :                          */
    2519                 :            :                         xtmp128 = vshrq_n_u8(xtmp128, 4);
    2520                 :            :                         ytmp128 = vshrq_n_u8(ytmp128, 4);
    2521                 :            :                         /*
    2522                 :            :                          * E(48):L3_LEN(8):L2_LEN(z+7)
    2523                 :            :                          * E(48):L3_LEN(8):L2_LEN(z+7)
    2524                 :            :                          */
    2525                 :            :                         const int8x16_t tshft3 = {
    2526                 :            :                                 -1, 0, 8, 8, 8, 8, 8, 8,
    2527                 :            :                                 -1, 0, 8, 8, 8, 8, 8, 8,
    2528                 :            :                         };
    2529                 :            : 
    2530                 :            :                         senddesc01_w1 = vshlq_u8(senddesc01_w1, tshft3);
    2531                 :            :                         senddesc23_w1 = vshlq_u8(senddesc23_w1, tshft3);
    2532                 :            : 
    2533                 :            :                         /* Do the lookup */
    2534                 :            :                         ltypes01 = vqtbl1q_u8(tbl, xtmp128);
    2535                 :            :                         ltypes23 = vqtbl1q_u8(tbl, ytmp128);
    2536                 :            : 
    2537                 :            :                         /* Pick only relevant fields i.e Bit 48:55 of iltype
    2538                 :            :                          * and place it in ol3/ol4type of senddesc_w1
    2539                 :            :                          */
    2540                 :            :                         const uint8x16_t shuf_mask0 = {
    2541                 :            :                                 0xFF, 0xFF, 0xFF, 0xFF, 0x6, 0xFF, 0xFF, 0xFF,
    2542                 :            :                                 0xFF, 0xFF, 0xFF, 0xFF, 0xE, 0xFF, 0xFF, 0xFF,
    2543                 :            :                         };
    2544                 :            : 
    2545                 :            :                         ltypes01 = vqtbl1q_u8(ltypes01, shuf_mask0);
    2546                 :            :                         ltypes23 = vqtbl1q_u8(ltypes23, shuf_mask0);
    2547                 :            : 
    2548                 :            :                         /* Prepare ol4ptr, ol3ptr from ol3len, ol2len.
    2549                 :            :                          * a [E(32):E(16):OL3(8):OL2(8)]
    2550                 :            :                          * a = a + (a << 8)
    2551                 :            :                          * a [E(32):E(16):(OL3+OL2):OL2]
    2552                 :            :                          * => E(32):E(16)::OL4PTR(8):OL3PTR(8)
    2553                 :            :                          */
    2554                 :            :                         senddesc01_w1 = vaddq_u8(senddesc01_w1,
    2555                 :            :                                                  vshlq_n_u16(senddesc01_w1, 8));
    2556                 :            :                         senddesc23_w1 = vaddq_u8(senddesc23_w1,
    2557                 :            :                                                  vshlq_n_u16(senddesc23_w1, 8));
    2558                 :            : 
    2559                 :            :                         /* Move ltypes to senddesc*_w1 */
    2560                 :            :                         senddesc01_w1 = vorrq_u64(senddesc01_w1, ltypes01);
    2561                 :            :                         senddesc23_w1 = vorrq_u64(senddesc23_w1, ltypes23);
    2562                 :            :                 } else if (!(flags & NIX_TX_OFFLOAD_L3_L4_CSUM_F) &&
    2563                 :            :                            (flags & NIX_TX_OFFLOAD_OL3_OL4_CSUM_F)) {
    2564                 :            :                         /*
    2565                 :            :                          * Lookup table to translate ol_flags to
    2566                 :            :                          * ol3/ol4 types.
    2567                 :            :                          */
    2568                 :            : 
    2569                 :            :                         const uint8x16_t tbl = {
    2570                 :            :                                 /* [0-15] = ol4type:ol3type */
    2571                 :            :                                 0x00, /* none */
    2572                 :            :                                 0x03, /* OUTER_IP_CKSUM */
    2573                 :            :                                 0x02, /* OUTER_IPV4 */
    2574                 :            :                                 0x03, /* OUTER_IPV4 | OUTER_IP_CKSUM */
    2575                 :            :                                 0x04, /* OUTER_IPV6 */
    2576                 :            :                                 0x00, /* OUTER_IPV6 | OUTER_IP_CKSUM */
    2577                 :            :                                 0x00, /* OUTER_IPV6 | OUTER_IPV4 */
    2578                 :            :                                 0x00, /* OUTER_IPV6 | OUTER_IPV4 |
    2579                 :            :                                        * OUTER_IP_CKSUM
    2580                 :            :                                        */
    2581                 :            :                                 0x00, /* OUTER_UDP_CKSUM */
    2582                 :            :                                 0x33, /* OUTER_UDP_CKSUM | OUTER_IP_CKSUM */
    2583                 :            :                                 0x32, /* OUTER_UDP_CKSUM | OUTER_IPV4 */
    2584                 :            :                                 0x33, /* OUTER_UDP_CKSUM | OUTER_IPV4 |
    2585                 :            :                                        * OUTER_IP_CKSUM
    2586                 :            :                                        */
    2587                 :            :                                 0x34, /* OUTER_UDP_CKSUM | OUTER_IPV6 */
    2588                 :            :                                 0x00, /* OUTER_UDP_CKSUM | OUTER_IPV6 |
    2589                 :            :                                        * OUTER_IP_CKSUM
    2590                 :            :                                        */
    2591                 :            :                                 0x00, /* OUTER_UDP_CKSUM | OUTER_IPV6 |
    2592                 :            :                                        * OUTER_IPV4
    2593                 :            :                                        */
    2594                 :            :                                 0x00, /* OUTER_UDP_CKSUM | OUTER_IPV6 |
    2595                 :            :                                        * OUTER_IPV4 | OUTER_IP_CKSUM
    2596                 :            :                                        */
    2597                 :            :                         };
    2598                 :            : 
    2599                 :            :                         /* Extract olflags to translate to iltypes */
    2600                 :            :                         xtmp128 = vzip1q_u64(len_olflags0, len_olflags1);
    2601                 :            :                         ytmp128 = vzip1q_u64(len_olflags2, len_olflags3);
    2602                 :            : 
    2603                 :            :                         /*
    2604                 :            :                          * E(47):OL3_LEN(9):OL2_LEN(7+z)
    2605                 :            :                          * E(47):OL3_LEN(9):OL2_LEN(7+z)
    2606                 :            :                          */
    2607                 :            :                         const uint8x16_t shuf_mask5 = {
    2608                 :            :                                 0x6, 0x5, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
    2609                 :            :                                 0xE, 0xD, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
    2610                 :            :                         };
    2611                 :            :                         senddesc01_w1 = vqtbl1q_u8(senddesc01_w1, shuf_mask5);
    2612                 :            :                         senddesc23_w1 = vqtbl1q_u8(senddesc23_w1, shuf_mask5);
    2613                 :            : 
    2614                 :            :                         /* Extract outer ol flags only */
    2615                 :            :                         const uint64x2_t o_cksum_mask = {
    2616                 :            :                                 0x1C00020000000000,
    2617                 :            :                                 0x1C00020000000000,
    2618                 :            :                         };
    2619                 :            : 
    2620                 :            :                         xtmp128 = vandq_u64(xtmp128, o_cksum_mask);
    2621                 :            :                         ytmp128 = vandq_u64(ytmp128, o_cksum_mask);
    2622                 :            : 
    2623                 :            :                         /* Extract OUTER_UDP_CKSUM bit 41 and
    2624                 :            :                          * move it to bit 61
    2625                 :            :                          */
    2626                 :            : 
    2627                 :            :                         xtmp128 = xtmp128 | vshlq_n_u64(xtmp128, 20);
    2628                 :            :                         ytmp128 = ytmp128 | vshlq_n_u64(ytmp128, 20);
    2629                 :            : 
    2630                 :            :                         /* Shift oltype by 2 to start nibble from BIT(56)
    2631                 :            :                          * instead of BIT(58)
    2632                 :            :                          */
    2633                 :            :                         xtmp128 = vshrq_n_u8(xtmp128, 2);
    2634                 :            :                         ytmp128 = vshrq_n_u8(ytmp128, 2);
    2635                 :            :                         /*
    2636                 :            :                          * E(48):L3_LEN(8):L2_LEN(z+7)
    2637                 :            :                          * E(48):L3_LEN(8):L2_LEN(z+7)
    2638                 :            :                          */
    2639                 :            :                         const int8x16_t tshft3 = {
    2640                 :            :                                 -1, 0, 8, 8, 8, 8, 8, 8,
    2641                 :            :                                 -1, 0, 8, 8, 8, 8, 8, 8,
    2642                 :            :                         };
    2643                 :            : 
    2644                 :            :                         senddesc01_w1 = vshlq_u8(senddesc01_w1, tshft3);
    2645                 :            :                         senddesc23_w1 = vshlq_u8(senddesc23_w1, tshft3);
    2646                 :            : 
    2647                 :            :                         /* Do the lookup */
    2648                 :            :                         ltypes01 = vqtbl1q_u8(tbl, xtmp128);
    2649                 :            :                         ltypes23 = vqtbl1q_u8(tbl, ytmp128);
    2650                 :            : 
    2651                 :            :                         /* Pick only relevant fields i.e Bit 56:63 of oltype
    2652                 :            :                          * and place it in ol3/ol4type of senddesc_w1
    2653                 :            :                          */
    2654                 :            :                         const uint8x16_t shuf_mask0 = {
    2655                 :            :                                 0xFF, 0xFF, 0xFF, 0xFF, 0x7, 0xFF, 0xFF, 0xFF,
    2656                 :            :                                 0xFF, 0xFF, 0xFF, 0xFF, 0xF, 0xFF, 0xFF, 0xFF,
    2657                 :            :                         };
    2658                 :            : 
    2659                 :            :                         ltypes01 = vqtbl1q_u8(ltypes01, shuf_mask0);
    2660                 :            :                         ltypes23 = vqtbl1q_u8(ltypes23, shuf_mask0);
    2661                 :            : 
    2662                 :            :                         /* Prepare ol4ptr, ol3ptr from ol3len, ol2len.
    2663                 :            :                          * a [E(32):E(16):OL3(8):OL2(8)]
    2664                 :            :                          * a = a + (a << 8)
    2665                 :            :                          * a [E(32):E(16):(OL3+OL2):OL2]
    2666                 :            :                          * => E(32):E(16)::OL4PTR(8):OL3PTR(8)
    2667                 :            :                          */
    2668                 :            :                         senddesc01_w1 = vaddq_u8(senddesc01_w1,
    2669                 :            :                                                  vshlq_n_u16(senddesc01_w1, 8));
    2670                 :            :                         senddesc23_w1 = vaddq_u8(senddesc23_w1,
    2671                 :            :                                                  vshlq_n_u16(senddesc23_w1, 8));
    2672                 :            : 
    2673                 :            :                         /* Move ltypes to senddesc*_w1 */
    2674                 :            :                         senddesc01_w1 = vorrq_u64(senddesc01_w1, ltypes01);
    2675                 :            :                         senddesc23_w1 = vorrq_u64(senddesc23_w1, ltypes23);
    2676                 :            :                 } else if ((flags & NIX_TX_OFFLOAD_L3_L4_CSUM_F) &&
    2677                 :            :                            (flags & NIX_TX_OFFLOAD_OL3_OL4_CSUM_F)) {
    2678                 :            :                         /* Lookup table to translate ol_flags to
    2679                 :            :                          * ol4type, ol3type, il4type, il3type of senddesc_w1
    2680                 :            :                          */
    2681                 :            :                         const uint8x16x2_t tbl = {{
    2682                 :            :                                 {
    2683                 :            :                                         /* [0-15] = il4type:il3type */
    2684                 :            :                                         0x04, /* none (IPv6) */
    2685                 :            :                                         0x14, /* RTE_MBUF_F_TX_TCP_CKSUM (IPv6) */
    2686                 :            :                                         0x24, /* RTE_MBUF_F_TX_SCTP_CKSUM (IPv6) */
    2687                 :            :                                         0x34, /* RTE_MBUF_F_TX_UDP_CKSUM (IPv6) */
    2688                 :            :                                         0x03, /* RTE_MBUF_F_TX_IP_CKSUM */
    2689                 :            :                                         0x13, /* RTE_MBUF_F_TX_IP_CKSUM |
    2690                 :            :                                                * RTE_MBUF_F_TX_TCP_CKSUM
    2691                 :            :                                                */
    2692                 :            :                                         0x23, /* RTE_MBUF_F_TX_IP_CKSUM |
    2693                 :            :                                                * RTE_MBUF_F_TX_SCTP_CKSUM
    2694                 :            :                                                */
    2695                 :            :                                         0x33, /* RTE_MBUF_F_TX_IP_CKSUM |
    2696                 :            :                                                * RTE_MBUF_F_TX_UDP_CKSUM
    2697                 :            :                                                */
    2698                 :            :                                         0x02, /* RTE_MBUF_F_TX_IPV4 */
    2699                 :            :                                         0x12, /* RTE_MBUF_F_TX_IPV4 |
    2700                 :            :                                                * RTE_MBUF_F_TX_TCP_CKSUM
    2701                 :            :                                                */
    2702                 :            :                                         0x22, /* RTE_MBUF_F_TX_IPV4 |
    2703                 :            :                                                * RTE_MBUF_F_TX_SCTP_CKSUM
    2704                 :            :                                                */
    2705                 :            :                                         0x32, /* RTE_MBUF_F_TX_IPV4 |
    2706                 :            :                                                * RTE_MBUF_F_TX_UDP_CKSUM
    2707                 :            :                                                */
    2708                 :            :                                         0x03, /* RTE_MBUF_F_TX_IPV4 |
    2709                 :            :                                                * RTE_MBUF_F_TX_IP_CKSUM
    2710                 :            :                                                */
    2711                 :            :                                         0x13, /* RTE_MBUF_F_TX_IPV4 | RTE_MBUF_F_TX_IP_CKSUM |
    2712                 :            :                                                * RTE_MBUF_F_TX_TCP_CKSUM
    2713                 :            :                                                */
    2714                 :            :                                         0x23, /* RTE_MBUF_F_TX_IPV4 | RTE_MBUF_F_TX_IP_CKSUM |
    2715                 :            :                                                * RTE_MBUF_F_TX_SCTP_CKSUM
    2716                 :            :                                                */
    2717                 :            :                                         0x33, /* RTE_MBUF_F_TX_IPV4 | RTE_MBUF_F_TX_IP_CKSUM |
    2718                 :            :                                                * RTE_MBUF_F_TX_UDP_CKSUM
    2719                 :            :                                                */
    2720                 :            :                                 },
    2721                 :            : 
    2722                 :            :                                 {
    2723                 :            :                                         /* [16-31] = ol4type:ol3type */
    2724                 :            :                                         0x00, /* none */
    2725                 :            :                                         0x03, /* OUTER_IP_CKSUM */
    2726                 :            :                                         0x02, /* OUTER_IPV4 */
    2727                 :            :                                         0x03, /* OUTER_IPV4 | OUTER_IP_CKSUM */
    2728                 :            :                                         0x04, /* OUTER_IPV6 */
    2729                 :            :                                         0x00, /* OUTER_IPV6 | OUTER_IP_CKSUM */
    2730                 :            :                                         0x00, /* OUTER_IPV6 | OUTER_IPV4 */
    2731                 :            :                                         0x00, /* OUTER_IPV6 | OUTER_IPV4 |
    2732                 :            :                                                * OUTER_IP_CKSUM
    2733                 :            :                                                */
    2734                 :            :                                         0x00, /* OUTER_UDP_CKSUM */
    2735                 :            :                                         0x33, /* OUTER_UDP_CKSUM |
    2736                 :            :                                                * OUTER_IP_CKSUM
    2737                 :            :                                                */
    2738                 :            :                                         0x32, /* OUTER_UDP_CKSUM |
    2739                 :            :                                                * OUTER_IPV4
    2740                 :            :                                                */
    2741                 :            :                                         0x33, /* OUTER_UDP_CKSUM |
    2742                 :            :                                                * OUTER_IPV4 | OUTER_IP_CKSUM
    2743                 :            :                                                */
    2744                 :            :                                         0x34, /* OUTER_UDP_CKSUM |
    2745                 :            :                                                * OUTER_IPV6
    2746                 :            :                                                */
    2747                 :            :                                         0x00, /* OUTER_UDP_CKSUM | OUTER_IPV6 |
    2748                 :            :                                                * OUTER_IP_CKSUM
    2749                 :            :                                                */
    2750                 :            :                                         0x00, /* OUTER_UDP_CKSUM | OUTER_IPV6 |
    2751                 :            :                                                * OUTER_IPV4
    2752                 :            :                                                */
    2753                 :            :                                         0x00, /* OUTER_UDP_CKSUM | OUTER_IPV6 |
    2754                 :            :                                                * OUTER_IPV4 | OUTER_IP_CKSUM
    2755                 :            :                                                */
    2756                 :            :                                 },
    2757                 :            :                         }};
    2758                 :            : 
    2759                 :            :                         /* Extract olflags to translate to oltype & iltype */
    2760                 :            :                         xtmp128 = vzip1q_u64(len_olflags0, len_olflags1);
    2761                 :            :                         ytmp128 = vzip1q_u64(len_olflags2, len_olflags3);
    2762                 :            : 
    2763                 :            :                         /*
    2764                 :            :                          * E(8):OL2_LN(7):OL3_LN(9):E(23):L3_LN(9):L2_LN(7+z)
    2765                 :            :                          * E(8):OL2_LN(7):OL3_LN(9):E(23):L3_LN(9):L2_LN(7+z)
    2766                 :            :                          */
    2767                 :            :                         const uint32x4_t tshft_4 = {
    2768                 :            :                                 1,
    2769                 :            :                                 0,
    2770                 :            :                                 1,
    2771                 :            :                                 0,
    2772                 :            :                         };
    2773                 :            :                         senddesc01_w1 = vshlq_u32(senddesc01_w1, tshft_4);
    2774                 :            :                         senddesc23_w1 = vshlq_u32(senddesc23_w1, tshft_4);
    2775                 :            : 
    2776                 :            :                         /*
    2777                 :            :                          * E(32):L3_LEN(8):L2_LEN(7+Z):OL3_LEN(8):OL2_LEN(7+Z)
    2778                 :            :                          * E(32):L3_LEN(8):L2_LEN(7+Z):OL3_LEN(8):OL2_LEN(7+Z)
    2779                 :            :                          */
    2780                 :            :                         const uint8x16_t shuf_mask5 = {
    2781                 :            :                                 0x6, 0x5, 0x0, 0x1, 0xFF, 0xFF, 0xFF, 0xFF,
    2782                 :            :                                 0xE, 0xD, 0x8, 0x9, 0xFF, 0xFF, 0xFF, 0xFF,
    2783                 :            :                         };
    2784                 :            :                         senddesc01_w1 = vqtbl1q_u8(senddesc01_w1, shuf_mask5);
    2785                 :            :                         senddesc23_w1 = vqtbl1q_u8(senddesc23_w1, shuf_mask5);
    2786                 :            : 
    2787                 :            :                         /* Extract outer and inner header ol_flags */
    2788                 :            :                         const uint64x2_t oi_cksum_mask = {
    2789                 :            :                                 0x1CF0020000000000,
    2790                 :            :                                 0x1CF0020000000000,
    2791                 :            :                         };
    2792                 :            : 
    2793                 :            :                         xtmp128 = vandq_u64(xtmp128, oi_cksum_mask);
    2794                 :            :                         ytmp128 = vandq_u64(ytmp128, oi_cksum_mask);
    2795                 :            : 
    2796                 :            :                         /* Extract OUTER_UDP_CKSUM bit 41 and
    2797                 :            :                          * move it to bit 61
    2798                 :            :                          */
    2799                 :            : 
    2800                 :            :                         xtmp128 = xtmp128 | vshlq_n_u64(xtmp128, 20);
    2801                 :            :                         ytmp128 = ytmp128 | vshlq_n_u64(ytmp128, 20);
    2802                 :            : 
    2803                 :            :                         /* Shift right oltype by 2 and iltype by 4
    2804                 :            :                          * to start oltype nibble from BIT(58)
    2805                 :            :                          * instead of BIT(56) and iltype nibble from BIT(48)
    2806                 :            :                          * instead of BIT(52).
    2807                 :            :                          */
    2808                 :            :                         const int8x16_t tshft5 = {
    2809                 :            :                                 8, 8, 8, 8, 8, 8, -4, -2,
    2810                 :            :                                 8, 8, 8, 8, 8, 8, -4, -2,
    2811                 :            :                         };
    2812                 :            : 
    2813                 :            :                         xtmp128 = vshlq_u8(xtmp128, tshft5);
    2814                 :            :                         ytmp128 = vshlq_u8(ytmp128, tshft5);
    2815                 :            :                         /*
    2816                 :            :                          * E(32):L3_LEN(8):L2_LEN(8):OL3_LEN(8):OL2_LEN(8)
    2817                 :            :                          * E(32):L3_LEN(8):L2_LEN(8):OL3_LEN(8):OL2_LEN(8)
    2818                 :            :                          */
    2819                 :            :                         const int8x16_t tshft3 = {
    2820                 :            :                                 -1, 0, -1, 0, 0, 0, 0, 0,
    2821                 :            :                                 -1, 0, -1, 0, 0, 0, 0, 0,
    2822                 :            :                         };
    2823                 :            : 
    2824                 :            :                         senddesc01_w1 = vshlq_u8(senddesc01_w1, tshft3);
    2825                 :            :                         senddesc23_w1 = vshlq_u8(senddesc23_w1, tshft3);
    2826                 :            : 
    2827                 :            :                         /* Mark Bit(4) of oltype */
    2828                 :            :                         const uint64x2_t oi_cksum_mask2 = {
    2829                 :            :                                 0x1000000000000000,
    2830                 :            :                                 0x1000000000000000,
    2831                 :            :                         };
    2832                 :            : 
    2833                 :            :                         xtmp128 = vorrq_u64(xtmp128, oi_cksum_mask2);
    2834                 :            :                         ytmp128 = vorrq_u64(ytmp128, oi_cksum_mask2);
    2835                 :            : 
    2836                 :            :                         /* Do the lookup */
    2837                 :            :                         ltypes01 = vqtbl2q_u8(tbl, xtmp128);
    2838                 :            :                         ltypes23 = vqtbl2q_u8(tbl, ytmp128);
    2839                 :            : 
    2840                 :            :                         /* Pick only relevant fields i.e Bit 48:55 of iltype and
    2841                 :            :                          * Bit 56:63 of oltype and place it in corresponding
    2842                 :            :                          * place in senddesc_w1.
    2843                 :            :                          */
    2844                 :            :                         const uint8x16_t shuf_mask0 = {
    2845                 :            :                                 0xFF, 0xFF, 0xFF, 0xFF, 0x7, 0x6, 0xFF, 0xFF,
    2846                 :            :                                 0xFF, 0xFF, 0xFF, 0xFF, 0xF, 0xE, 0xFF, 0xFF,
    2847                 :            :                         };
    2848                 :            : 
    2849                 :            :                         ltypes01 = vqtbl1q_u8(ltypes01, shuf_mask0);
    2850                 :            :                         ltypes23 = vqtbl1q_u8(ltypes23, shuf_mask0);
    2851                 :            : 
    2852                 :            :                         /* Prepare l4ptr, l3ptr, ol4ptr, ol3ptr from
    2853                 :            :                          * l3len, l2len, ol3len, ol2len.
    2854                 :            :                          * a [E(32):L3(8):L2(8):OL3(8):OL2(8)]
    2855                 :            :                          * a = a + (a << 8)
    2856                 :            :                          * a [E:(L3+L2):(L2+OL3):(OL3+OL2):OL2]
    2857                 :            :                          * a = a + (a << 16)
    2858                 :            :                          * a [E:(L3+L2+OL3+OL2):(L2+OL3+OL2):(OL3+OL2):OL2]
    2859                 :            :                          * => E(32):IL4PTR(8):IL3PTR(8):OL4PTR(8):OL3PTR(8)
    2860                 :            :                          */
    2861                 :            :                         senddesc01_w1 = vaddq_u8(senddesc01_w1,
    2862                 :            :                                                  vshlq_n_u32(senddesc01_w1, 8));
    2863                 :            :                         senddesc23_w1 = vaddq_u8(senddesc23_w1,
    2864                 :            :                                                  vshlq_n_u32(senddesc23_w1, 8));
    2865                 :            : 
    2866                 :            :                         /* Continue preparing l4ptr, l3ptr, ol4ptr, ol3ptr */
    2867                 :            :                         senddesc01_w1 = vaddq_u8(
    2868                 :            :                                 senddesc01_w1, vshlq_n_u32(senddesc01_w1, 16));
    2869                 :            :                         senddesc23_w1 = vaddq_u8(
    2870                 :            :                                 senddesc23_w1, vshlq_n_u32(senddesc23_w1, 16));
    2871                 :            : 
    2872                 :            :                         /* Move ltypes to senddesc*_w1 */
    2873                 :            :                         senddesc01_w1 = vorrq_u64(senddesc01_w1, ltypes01);
    2874                 :            :                         senddesc23_w1 = vorrq_u64(senddesc23_w1, ltypes23);
    2875                 :            :                 }
    2876                 :            : 
    2877                 :            :                 xmask01 = vdupq_n_u64(0);
    2878                 :            :                 xmask23 = xmask01;
    2879                 :            :                 asm volatile("LD1 {%[a].H}[0],[%[in]]\n\t"
    2880                 :            :                              : [a] "+w"(xmask01)
    2881                 :            :                              : [in] "r"(mbuf0)
    2882                 :            :                              : "memory");
    2883                 :            : 
    2884                 :            :                 asm volatile("LD1 {%[a].H}[4],[%[in]]\n\t"
    2885                 :            :                              : [a] "+w"(xmask01)
    2886                 :            :                              : [in] "r"(mbuf1)
    2887                 :            :                              : "memory");
    2888                 :            : 
    2889                 :            :                 asm volatile("LD1 {%[b].H}[0],[%[in]]\n\t"
    2890                 :            :                              : [b] "+w"(xmask23)
    2891                 :            :                              : [in] "r"(mbuf2)
    2892                 :            :                              : "memory");
    2893                 :            : 
    2894                 :            :                 asm volatile("LD1 {%[b].H}[4],[%[in]]\n\t"
    2895                 :            :                              : [b] "+w"(xmask23)
    2896                 :            :                              : [in] "r"(mbuf3)
    2897                 :            :                              : "memory");
    2898                 :            :                 xmask01 = vshlq_n_u64(xmask01, 20);
    2899                 :            :                 xmask23 = vshlq_n_u64(xmask23, 20);
    2900                 :            : 
    2901                 :            :                 senddesc01_w0 = vorrq_u64(senddesc01_w0, xmask01);
    2902                 :            :                 senddesc23_w0 = vorrq_u64(senddesc23_w0, xmask23);
    2903                 :            : 
    2904                 :            :                 if (flags & NIX_TX_OFFLOAD_VLAN_QINQ_F) {
    2905                 :            :                         /* Tx ol_flag for vlan. */
    2906                 :            :                         const uint64x2_t olv = {RTE_MBUF_F_TX_VLAN, RTE_MBUF_F_TX_VLAN};
    2907                 :            :                         /* Bit enable for VLAN1 */
    2908                 :            :                         const uint64x2_t mlv = {BIT_ULL(49), BIT_ULL(49)};
    2909                 :            :                         /* Tx ol_flag for QnQ. */
    2910                 :            :                         const uint64x2_t olq = {RTE_MBUF_F_TX_QINQ, RTE_MBUF_F_TX_QINQ};
    2911                 :            :                         /* Bit enable for VLAN0 */
    2912                 :            :                         const uint64x2_t mlq = {BIT_ULL(48), BIT_ULL(48)};
    2913                 :            :                         /* Load vlan values from packet. outer is VLAN 0 */
    2914                 :            :                         uint64x2_t ext01 = {
    2915                 :            :                                 ((uint32_t)tx_pkts[0]->vlan_tci_outer) << 8 |
    2916                 :            :                                         ((uint64_t)tx_pkts[0]->vlan_tci) << 32,
    2917                 :            :                                 ((uint32_t)tx_pkts[1]->vlan_tci_outer) << 8 |
    2918                 :            :                                         ((uint64_t)tx_pkts[1]->vlan_tci) << 32,
    2919                 :            :                         };
    2920                 :            :                         uint64x2_t ext23 = {
    2921                 :            :                                 ((uint32_t)tx_pkts[2]->vlan_tci_outer) << 8 |
    2922                 :            :                                         ((uint64_t)tx_pkts[2]->vlan_tci) << 32,
    2923                 :            :                                 ((uint32_t)tx_pkts[3]->vlan_tci_outer) << 8 |
    2924                 :            :                                         ((uint64_t)tx_pkts[3]->vlan_tci) << 32,
    2925                 :            :                         };
    2926                 :            : 
    2927                 :            :                         /* Get ol_flags of the packets. */
    2928                 :            :                         xtmp128 = vzip1q_u64(len_olflags0, len_olflags1);
    2929                 :            :                         ytmp128 = vzip1q_u64(len_olflags2, len_olflags3);
    2930                 :            : 
    2931                 :            :                         /* ORR vlan outer/inner values into cmd. */
    2932                 :            :                         sendext01_w1 = vorrq_u64(sendext01_w1, ext01);
    2933                 :            :                         sendext23_w1 = vorrq_u64(sendext23_w1, ext23);
    2934                 :            : 
    2935                 :            :                         /* Test for offload enable bits and generate masks. */
    2936                 :            :                         xtmp128 = vorrq_u64(vandq_u64(vtstq_u64(xtmp128, olv),
    2937                 :            :                                                       mlv),
    2938                 :            :                                             vandq_u64(vtstq_u64(xtmp128, olq),
    2939                 :            :                                                       mlq));
    2940                 :            :                         ytmp128 = vorrq_u64(vandq_u64(vtstq_u64(ytmp128, olv),
    2941                 :            :                                                       mlv),
    2942                 :            :                                             vandq_u64(vtstq_u64(ytmp128, olq),
    2943                 :            :                                                       mlq));
    2944                 :            : 
    2945                 :            :                         /* Set vlan enable bits into cmd based on mask. */
    2946                 :            :                         sendext01_w1 = vorrq_u64(sendext01_w1, xtmp128);
    2947                 :            :                         sendext23_w1 = vorrq_u64(sendext23_w1, ytmp128);
    2948                 :            :                 }
    2949                 :            : 
    2950                 :            :                 if (flags & NIX_TX_OFFLOAD_TSTAMP_F) {
    2951                 :            :                         /* Tx ol_flag for timestamp. */
    2952                 :            :                         const uint64x2_t olf = {RTE_MBUF_F_TX_IEEE1588_TMST,
    2953                 :            :                                                 RTE_MBUF_F_TX_IEEE1588_TMST};
    2954                 :            :                         /* Set send mem alg to SUB. */
    2955                 :            :                         const uint64x2_t alg = {BIT_ULL(59), BIT_ULL(59)};
    2956                 :            :                         /* Increment send mem address by 8. */
    2957                 :            :                         const uint64x2_t addr = {0x8, 0x8};
    2958                 :            : 
    2959                 :            :                         xtmp128 = vzip1q_u64(len_olflags0, len_olflags1);
    2960                 :            :                         ytmp128 = vzip1q_u64(len_olflags2, len_olflags3);
    2961                 :            : 
    2962                 :            :                         /* Check if timestamp is requested and generate inverted
    2963                 :            :                          * mask as we need not make any changes to default cmd
    2964                 :            :                          * value.
    2965                 :            :                          */
    2966                 :            :                         xtmp128 = vmvnq_u32(vtstq_u64(olf, xtmp128));
    2967                 :            :                         ytmp128 = vmvnq_u32(vtstq_u64(olf, ytmp128));
    2968                 :            : 
    2969                 :            :                         /* Change send mem address to an 8 byte offset when
    2970                 :            :                          * TSTMP is disabled.
    2971                 :            :                          */
    2972                 :            :                         sendmem01_w1 = vaddq_u64(sendmem01_w1,
    2973                 :            :                                                  vandq_u64(xtmp128, addr));
    2974                 :            :                         sendmem23_w1 = vaddq_u64(sendmem23_w1,
    2975                 :            :                                                  vandq_u64(ytmp128, addr));
    2976                 :            :                         /* Change send mem alg to SUB when TSTMP is disabled. */
    2977                 :            :                         sendmem01_w0 = vorrq_u64(sendmem01_w0,
    2978                 :            :                                                  vandq_u64(xtmp128, alg));
    2979                 :            :                         sendmem23_w0 = vorrq_u64(sendmem23_w0,
    2980                 :            :                                                  vandq_u64(ytmp128, alg));
    2981                 :            : 
    2982                 :            :                         cmd3[0] = vzip1q_u64(sendmem01_w0, sendmem01_w1);
    2983                 :            :                         cmd3[1] = vzip2q_u64(sendmem01_w0, sendmem01_w1);
    2984                 :            :                         cmd3[2] = vzip1q_u64(sendmem23_w0, sendmem23_w1);
    2985                 :            :                         cmd3[3] = vzip2q_u64(sendmem23_w0, sendmem23_w1);
    2986                 :            :                 }
    2987                 :            : 
    2988                 :            :                 if (flags & NIX_TX_OFFLOAD_TSO_F) {
    2989                 :            :                         const uint64_t lso_fmt = txq->lso_tun_fmt;
    2990                 :            :                         uint64_t sx_w0[NIX_DESCS_PER_LOOP];
    2991                 :            :                         uint64_t sd_w1[NIX_DESCS_PER_LOOP];
    2992                 :            : 
    2993                 :            :                         /* Extract SD W1 as we need to set L4 types. */
    2994                 :            :                         vst1q_u64(sd_w1, senddesc01_w1);
    2995                 :            :                         vst1q_u64(sd_w1 + 2, senddesc23_w1);
    2996                 :            : 
    2997                 :            :                         /* Extract SX W0 as we need to set LSO fields. */
    2998                 :            :                         vst1q_u64(sx_w0, sendext01_w0);
    2999                 :            :                         vst1q_u64(sx_w0 + 2, sendext23_w0);
    3000                 :            : 
    3001                 :            :                         /* Extract ol_flags. */
    3002                 :            :                         xtmp128 = vzip1q_u64(len_olflags0, len_olflags1);
    3003                 :            :                         ytmp128 = vzip1q_u64(len_olflags2, len_olflags3);
    3004                 :            : 
    3005                 :            :                         /* Prepare individual mbufs. */
    3006                 :            :                         cn10k_nix_prepare_tso(tx_pkts[0],
    3007                 :            :                                 (union nix_send_hdr_w1_u *)&sd_w1[0],
    3008                 :            :                                 (union nix_send_ext_w0_u *)&sx_w0[0],
    3009                 :            :                                 vgetq_lane_u64(xtmp128, 0), flags, lso_fmt);
    3010                 :            : 
    3011                 :            :                         cn10k_nix_prepare_tso(tx_pkts[1],
    3012                 :            :                                 (union nix_send_hdr_w1_u *)&sd_w1[1],
    3013                 :            :                                 (union nix_send_ext_w0_u *)&sx_w0[1],
    3014                 :            :                                 vgetq_lane_u64(xtmp128, 1), flags, lso_fmt);
    3015                 :            : 
    3016                 :            :                         cn10k_nix_prepare_tso(tx_pkts[2],
    3017                 :            :                                 (union nix_send_hdr_w1_u *)&sd_w1[2],
    3018                 :            :                                 (union nix_send_ext_w0_u *)&sx_w0[2],
    3019                 :            :                                 vgetq_lane_u64(ytmp128, 0), flags, lso_fmt);
    3020                 :            : 
    3021                 :            :                         cn10k_nix_prepare_tso(tx_pkts[3],
    3022                 :            :                                 (union nix_send_hdr_w1_u *)&sd_w1[3],
    3023                 :            :                                 (union nix_send_ext_w0_u *)&sx_w0[3],
    3024                 :            :                                 vgetq_lane_u64(ytmp128, 1), flags, lso_fmt);
    3025                 :            : 
    3026                 :            :                         senddesc01_w1 = vld1q_u64(sd_w1);
    3027                 :            :                         senddesc23_w1 = vld1q_u64(sd_w1 + 2);
    3028                 :            : 
    3029                 :            :                         sendext01_w0 = vld1q_u64(sx_w0);
    3030                 :            :                         sendext23_w0 = vld1q_u64(sx_w0 + 2);
    3031                 :            :                 }
    3032                 :            : 
    3033                 :            :                 if ((flags & NIX_TX_OFFLOAD_MBUF_NOFF_F) &&
    3034                 :            :                     !(flags & NIX_TX_MULTI_SEG_F) &&
    3035                 :            :                     !(flags & NIX_TX_OFFLOAD_SECURITY_F)) {
    3036                 :            :                         /* Set don't free bit if reference count > 1 */
    3037                 :            :                         cn10k_nix_prefree_seg_vec(tx_pkts, &extm, txq, &senddesc01_w0,
    3038                 :            :                                                   &senddesc23_w0, &senddesc01_w1, &senddesc23_w1);
    3039                 :            :                 } else if (!(flags & NIX_TX_MULTI_SEG_F) &&
    3040                 :            :                            !(flags & NIX_TX_OFFLOAD_SECURITY_F)) {
    3041                 :            :                         /* Move mbufs to iova */
    3042                 :            :                         mbuf0 = (uint64_t *)tx_pkts[0];
    3043                 :            :                         mbuf1 = (uint64_t *)tx_pkts[1];
    3044                 :            :                         mbuf2 = (uint64_t *)tx_pkts[2];
    3045                 :            :                         mbuf3 = (uint64_t *)tx_pkts[3];
    3046                 :            : 
    3047                 :            :                         /* Mark mempool object as "put" since
    3048                 :            :                          * it is freed by NIX
    3049                 :            :                          */
    3050                 :            :                         RTE_MEMPOOL_CHECK_COOKIES(
    3051                 :            :                                 ((struct rte_mbuf *)mbuf0)->pool,
    3052                 :            :                                 (void **)&mbuf0, 1, 0);
    3053                 :            : 
    3054                 :            :                         RTE_MEMPOOL_CHECK_COOKIES(
    3055                 :            :                                 ((struct rte_mbuf *)mbuf1)->pool,
    3056                 :            :                                 (void **)&mbuf1, 1, 0);
    3057                 :            : 
    3058                 :            :                         RTE_MEMPOOL_CHECK_COOKIES(
    3059                 :            :                                 ((struct rte_mbuf *)mbuf2)->pool,
    3060                 :            :                                 (void **)&mbuf2, 1, 0);
    3061                 :            : 
    3062                 :            :                         RTE_MEMPOOL_CHECK_COOKIES(
    3063                 :            :                                 ((struct rte_mbuf *)mbuf3)->pool,
    3064                 :            :                                 (void **)&mbuf3, 1, 0);
    3065                 :            :                 }
    3066                 :            : 
    3067                 :            :                 /* Create 4W cmd for 4 mbufs (sendhdr, sgdesc) */
    3068                 :            :                 cmd0[0] = vzip1q_u64(senddesc01_w0, senddesc01_w1);
    3069                 :            :                 cmd0[1] = vzip2q_u64(senddesc01_w0, senddesc01_w1);
    3070                 :            :                 cmd0[2] = vzip1q_u64(senddesc23_w0, senddesc23_w1);
    3071                 :            :                 cmd0[3] = vzip2q_u64(senddesc23_w0, senddesc23_w1);
    3072                 :            : 
    3073                 :            :                 cmd1[0] = vzip1q_u64(sgdesc01_w0, sgdesc01_w1);
    3074                 :            :                 cmd1[1] = vzip2q_u64(sgdesc01_w0, sgdesc01_w1);
    3075                 :            :                 cmd1[2] = vzip1q_u64(sgdesc23_w0, sgdesc23_w1);
    3076                 :            :                 cmd1[3] = vzip2q_u64(sgdesc23_w0, sgdesc23_w1);
    3077                 :            : 
    3078                 :            :                 if (flags & NIX_TX_NEED_EXT_HDR) {
    3079                 :            :                         cmd2[0] = vzip1q_u64(sendext01_w0, sendext01_w1);
    3080                 :            :                         cmd2[1] = vzip2q_u64(sendext01_w0, sendext01_w1);
    3081                 :            :                         cmd2[2] = vzip1q_u64(sendext23_w0, sendext23_w1);
    3082                 :            :                         cmd2[3] = vzip2q_u64(sendext23_w0, sendext23_w1);
    3083                 :            :                 }
    3084                 :            : 
    3085                 :            :                 if (flags & NIX_TX_OFFLOAD_SECURITY_F) {
    3086                 :            :                         const uint64x2_t olf = {RTE_MBUF_F_TX_SEC_OFFLOAD,
    3087                 :            :                                                 RTE_MBUF_F_TX_SEC_OFFLOAD};
    3088                 :            :                         uintptr_t next;
    3089                 :            :                         uint8_t dw;
    3090                 :            : 
    3091                 :            :                         /* Extract ol_flags. */
    3092                 :            :                         xtmp128 = vzip1q_u64(len_olflags0, len_olflags1);
    3093                 :            :                         ytmp128 = vzip1q_u64(len_olflags2, len_olflags3);
    3094                 :            : 
    3095                 :            :                         xtmp128 = vtstq_u64(olf, xtmp128);
    3096                 :            :                         ytmp128 = vtstq_u64(olf, ytmp128);
    3097                 :            : 
    3098                 :            :                         /* Process mbuf0 */
    3099                 :            :                         dw = cn10k_nix_tx_dwords(flags, segdw[0]);
    3100                 :            :                         if (vgetq_lane_u64(xtmp128, 0))
    3101                 :            :                                 cn10k_nix_prep_sec_vec(tx_pkts[0], &cmd0[0],
    3102                 :            :                                                        &cmd1[0], &next, c_laddr,
    3103                 :            :                                                        &c_lnum, &c_loff,
    3104                 :            :                                                        &c_shft, sa_base, flags);
    3105                 :            :                         else
    3106                 :            :                                 cn10k_nix_lmt_next(dw, laddr, &lnum, &loff,
    3107                 :            :                                                    &shift, &wd.data128, &next);
    3108                 :            : 
    3109                 :            :                         /* Store mbuf0 to LMTLINE/CPT NIXTX area */
    3110                 :            :                         cn10k_nix_xmit_store(txq, tx_pkts[0], &extm, segdw[0], next,
    3111                 :            :                                              cmd0[0], cmd1[0], cmd2[0], cmd3[0],
    3112                 :            :                                              flags);
    3113                 :            : 
    3114                 :            :                         /* Process mbuf1 */
    3115                 :            :                         dw = cn10k_nix_tx_dwords(flags, segdw[1]);
    3116                 :            :                         if (vgetq_lane_u64(xtmp128, 1))
    3117                 :            :                                 cn10k_nix_prep_sec_vec(tx_pkts[1], &cmd0[1],
    3118                 :            :                                                        &cmd1[1], &next, c_laddr,
    3119                 :            :                                                        &c_lnum, &c_loff,
    3120                 :            :                                                        &c_shft, sa_base, flags);
    3121                 :            :                         else
    3122                 :            :                                 cn10k_nix_lmt_next(dw, laddr, &lnum, &loff,
    3123                 :            :                                                    &shift, &wd.data128, &next);
    3124                 :            : 
    3125                 :            :                         /* Store mbuf1 to LMTLINE/CPT NIXTX area */
    3126                 :            :                         cn10k_nix_xmit_store(txq, tx_pkts[1], &extm, segdw[1], next,
    3127                 :            :                                              cmd0[1], cmd1[1], cmd2[1], cmd3[1],
    3128                 :            :                                              flags);
    3129                 :            : 
    3130                 :            :                         /* Process mbuf2 */
    3131                 :            :                         dw = cn10k_nix_tx_dwords(flags, segdw[2]);
    3132                 :            :                         if (vgetq_lane_u64(ytmp128, 0))
    3133                 :            :                                 cn10k_nix_prep_sec_vec(tx_pkts[2], &cmd0[2],
    3134                 :            :                                                        &cmd1[2], &next, c_laddr,
    3135                 :            :                                                        &c_lnum, &c_loff,
    3136                 :            :                                                        &c_shft, sa_base, flags);
    3137                 :            :                         else
    3138                 :            :                                 cn10k_nix_lmt_next(dw, laddr, &lnum, &loff,
    3139                 :            :                                                    &shift, &wd.data128, &next);
    3140                 :            : 
    3141                 :            :                         /* Store mbuf2 to LMTLINE/CPT NIXTX area */
    3142                 :            :                         cn10k_nix_xmit_store(txq, tx_pkts[2], &extm, segdw[2], next,
    3143                 :            :                                              cmd0[2], cmd1[2], cmd2[2], cmd3[2],
    3144                 :            :                                              flags);
    3145                 :            : 
    3146                 :            :                         /* Process mbuf3 */
    3147                 :            :                         dw = cn10k_nix_tx_dwords(flags, segdw[3]);
    3148                 :            :                         if (vgetq_lane_u64(ytmp128, 1))
    3149                 :            :                                 cn10k_nix_prep_sec_vec(tx_pkts[3], &cmd0[3],
    3150                 :            :                                                        &cmd1[3], &next, c_laddr,
    3151                 :            :                                                        &c_lnum, &c_loff,
    3152                 :            :                                                        &c_shft, sa_base, flags);
    3153                 :            :                         else
    3154                 :            :                                 cn10k_nix_lmt_next(dw, laddr, &lnum, &loff,
    3155                 :            :                                                    &shift, &wd.data128, &next);
    3156                 :            : 
    3157                 :            :                         /* Store mbuf3 to LMTLINE/CPT NIXTX area */
    3158                 :            :                         cn10k_nix_xmit_store(txq, tx_pkts[3], &extm, segdw[3], next,
    3159                 :            :                                              cmd0[3], cmd1[3], cmd2[3], cmd3[3],
    3160                 :            :                                              flags);
    3161                 :            : 
    3162                 :            :                 } else if (flags & NIX_TX_MULTI_SEG_F) {
    3163                 :            :                         uint8_t j;
    3164                 :            : 
    3165                 :            :                         segdw[4] = 8;
    3166                 :            :                         j = cn10k_nix_prep_lmt_mseg_vector(txq, tx_pkts, &extm, cmd0, cmd1,
    3167                 :            :                                                           cmd2, cmd3, segdw,
    3168                 :            :                                                           (uint64_t *)
    3169                 :            :                                                           LMT_OFF(laddr, lnum,
    3170                 :            :                                                                   0),
    3171                 :            :                                                           &wd.data128, &shift,
    3172                 :            :                                                           flags);
    3173                 :            :                         lnum += j;
    3174                 :            :                 } else if (flags & NIX_TX_NEED_EXT_HDR) {
    3175                 :            :                         /* Store the prepared send desc to LMT lines */
    3176                 :            :                         if (flags & NIX_TX_OFFLOAD_TSTAMP_F) {
    3177                 :            :                                 vst1q_u64(LMT_OFF(laddr, lnum, 0), cmd0[0]);
    3178                 :            :                                 vst1q_u64(LMT_OFF(laddr, lnum, 16), cmd2[0]);
    3179                 :            :                                 vst1q_u64(LMT_OFF(laddr, lnum, 32), cmd1[0]);
    3180                 :            :                                 vst1q_u64(LMT_OFF(laddr, lnum, 48), cmd3[0]);
    3181                 :            :                                 vst1q_u64(LMT_OFF(laddr, lnum, 64), cmd0[1]);
    3182                 :            :                                 vst1q_u64(LMT_OFF(laddr, lnum, 80), cmd2[1]);
    3183                 :            :                                 vst1q_u64(LMT_OFF(laddr, lnum, 96), cmd1[1]);
    3184                 :            :                                 vst1q_u64(LMT_OFF(laddr, lnum, 112), cmd3[1]);
    3185                 :            :                                 lnum += 1;
    3186                 :            :                                 vst1q_u64(LMT_OFF(laddr, lnum, 0), cmd0[2]);
    3187                 :            :                                 vst1q_u64(LMT_OFF(laddr, lnum, 16), cmd2[2]);
    3188                 :            :                                 vst1q_u64(LMT_OFF(laddr, lnum, 32), cmd1[2]);
    3189                 :            :                                 vst1q_u64(LMT_OFF(laddr, lnum, 48), cmd3[2]);
    3190                 :            :                                 vst1q_u64(LMT_OFF(laddr, lnum, 64), cmd0[3]);
    3191                 :            :                                 vst1q_u64(LMT_OFF(laddr, lnum, 80), cmd2[3]);
    3192                 :            :                                 vst1q_u64(LMT_OFF(laddr, lnum, 96), cmd1[3]);
    3193                 :            :                                 vst1q_u64(LMT_OFF(laddr, lnum, 112), cmd3[3]);
    3194                 :            :                         } else {
    3195                 :            :                                 vst1q_u64(LMT_OFF(laddr, lnum, 0), cmd0[0]);
    3196                 :            :                                 vst1q_u64(LMT_OFF(laddr, lnum, 16), cmd2[0]);
    3197                 :            :                                 vst1q_u64(LMT_OFF(laddr, lnum, 32), cmd1[0]);
    3198                 :            :                                 vst1q_u64(LMT_OFF(laddr, lnum, 48), cmd0[1]);
    3199                 :            :                                 vst1q_u64(LMT_OFF(laddr, lnum, 64), cmd2[1]);
    3200                 :            :                                 vst1q_u64(LMT_OFF(laddr, lnum, 80), cmd1[1]);
    3201                 :            :                                 lnum += 1;
    3202                 :            :                                 vst1q_u64(LMT_OFF(laddr, lnum, 0), cmd0[2]);
    3203                 :            :                                 vst1q_u64(LMT_OFF(laddr, lnum, 16), cmd2[2]);
    3204                 :            :                                 vst1q_u64(LMT_OFF(laddr, lnum, 32), cmd1[2]);
    3205                 :            :                                 vst1q_u64(LMT_OFF(laddr, lnum, 48), cmd0[3]);
    3206                 :            :                                 vst1q_u64(LMT_OFF(laddr, lnum, 64), cmd2[3]);
    3207                 :            :                                 vst1q_u64(LMT_OFF(laddr, lnum, 80), cmd1[3]);
    3208                 :            :                         }
    3209                 :            :                         lnum += 1;
    3210                 :            :                 } else {
    3211                 :            :                         /* Store the prepared send desc to LMT lines */
    3212                 :            :                         vst1q_u64(LMT_OFF(laddr, lnum, 0), cmd0[0]);
    3213                 :            :                         vst1q_u64(LMT_OFF(laddr, lnum, 16), cmd1[0]);
    3214                 :            :                         vst1q_u64(LMT_OFF(laddr, lnum, 32), cmd0[1]);
    3215                 :            :                         vst1q_u64(LMT_OFF(laddr, lnum, 48), cmd1[1]);
    3216                 :            :                         vst1q_u64(LMT_OFF(laddr, lnum, 64), cmd0[2]);
    3217                 :            :                         vst1q_u64(LMT_OFF(laddr, lnum, 80), cmd1[2]);
    3218                 :            :                         vst1q_u64(LMT_OFF(laddr, lnum, 96), cmd0[3]);
    3219                 :            :                         vst1q_u64(LMT_OFF(laddr, lnum, 112), cmd1[3]);
    3220                 :            :                         lnum += 1;
    3221                 :            :                 }
    3222                 :            : 
    3223                 :            :                 tx_pkts = tx_pkts + NIX_DESCS_PER_LOOP;
    3224                 :            :         }
    3225                 :            : 
    3226                 :            :         /* Roundup lnum to last line if it is partial */
    3227                 :            :         if (flags & NIX_TX_OFFLOAD_SECURITY_F) {
    3228                 :            :                 lnum = lnum + !!loff;
    3229                 :            :                 wd.data128 = wd.data128 |
    3230                 :            :                         (((__uint128_t)(((loff >> 4) - 1) & 0x7) << shift));
    3231                 :            :         }
    3232                 :            : 
    3233                 :            :         if (flags & (NIX_TX_MULTI_SEG_F | NIX_TX_OFFLOAD_SECURITY_F))
    3234                 :            :                 wd.data[0] >>= 16;
    3235                 :            : 
    3236                 :            :         if ((flags & NIX_TX_VWQE_F) && !(ws[3] & BIT_ULL(35)))
    3237                 :            :                 ws[3] = roc_sso_hws_head_wait(ws[0]);
    3238                 :            : 
    3239                 :            :         left -= burst;
    3240                 :            : 
    3241                 :            :         /* Submit CPT instructions if any */
    3242                 :            :         if (flags & NIX_TX_OFFLOAD_SECURITY_F) {
    3243                 :            :                 uint16_t sec_pkts = (c_lnum << 1) + c_loff;
    3244                 :            : 
    3245                 :            :                 if (flags & NIX_TX_VWQE_F)
    3246                 :            :                         cn10k_nix_vwqe_wait_fc(txq, sec_pkts);
    3247                 :            :                 cn10k_nix_sec_fc_wait(txq, sec_pkts);
    3248                 :            :                 cn10k_nix_sec_steorl(c_io_addr, c_lmt_id, c_lnum, c_loff,
    3249                 :            :                                      c_shft);
    3250                 :            :         }
    3251                 :            : 
    3252                 :            :         /* Trigger LMTST */
    3253                 :            :         if (lnum > 16) {
    3254                 :            :                 if (!(flags & (NIX_TX_MULTI_SEG_F | NIX_TX_OFFLOAD_SECURITY_F)))
    3255                 :            :                         wd.data[0] = cn10k_nix_tx_steor_vec_data(flags);
    3256                 :            : 
    3257                 :            :                 pa = io_addr | (wd.data[0] & 0x7) << 4;
    3258                 :            :                 wd.data[0] &= ~0x7ULL;
    3259                 :            : 
    3260                 :            :                 if (flags & (NIX_TX_MULTI_SEG_F | NIX_TX_OFFLOAD_SECURITY_F))
    3261                 :            :                         wd.data[0] <<= 16;
    3262                 :            : 
    3263                 :            :                 wd.data[0] |= (15ULL << 12);
    3264                 :            :                 wd.data[0] |= (uint64_t)lmt_id;
    3265                 :            : 
    3266                 :            :                 if (flags & NIX_TX_VWQE_F)
    3267                 :            :                         cn10k_nix_vwqe_wait_fc(txq,
    3268                 :            :                                 cn10k_nix_pkts_per_vec_brst(flags) >> 1);
    3269                 :            :                 /* STEOR0 */
    3270                 :            :                 roc_lmt_submit_steorl(wd.data[0], pa);
    3271                 :            : 
    3272                 :            :                 if (!(flags & (NIX_TX_MULTI_SEG_F | NIX_TX_OFFLOAD_SECURITY_F)))
    3273                 :            :                         wd.data[1] = cn10k_nix_tx_steor_vec_data(flags);
    3274                 :            : 
    3275                 :            :                 pa = io_addr | (wd.data[1] & 0x7) << 4;
    3276                 :            :                 wd.data[1] &= ~0x7ULL;
    3277                 :            : 
    3278                 :            :                 if (flags & (NIX_TX_MULTI_SEG_F | NIX_TX_OFFLOAD_SECURITY_F))
    3279                 :            :                         wd.data[1] <<= 16;
    3280                 :            : 
    3281                 :            :                 wd.data[1] |= ((uint64_t)(lnum - 17)) << 12;
    3282                 :            :                 wd.data[1] |= (uint64_t)(lmt_id + 16);
    3283                 :            : 
    3284                 :            :                 if (flags & NIX_TX_VWQE_F) {
    3285                 :            :                         if (flags & NIX_TX_MULTI_SEG_F) {
    3286                 :            :                                 if (burst - (cn10k_nix_pkts_per_vec_brst(flags) >> 1) > 0)
    3287                 :            :                                         cn10k_nix_vwqe_wait_fc(txq,
    3288                 :            :                                                 burst - (cn10k_nix_pkts_per_vec_brst(flags) >> 1));
    3289                 :            :                         } else {
    3290                 :            :                                 cn10k_nix_vwqe_wait_fc(txq,
    3291                 :            :                                                 burst - (cn10k_nix_pkts_per_vec_brst(flags) >> 1));
    3292                 :            :                         }
    3293                 :            :                 }
    3294                 :            :                 /* STEOR1 */
    3295                 :            :                 roc_lmt_submit_steorl(wd.data[1], pa);
    3296                 :            :         } else if (lnum) {
    3297                 :            :                 if (!(flags & (NIX_TX_MULTI_SEG_F | NIX_TX_OFFLOAD_SECURITY_F)))
    3298                 :            :                         wd.data[0] = cn10k_nix_tx_steor_vec_data(flags);
    3299                 :            : 
    3300                 :            :                 pa = io_addr | (wd.data[0] & 0x7) << 4;
    3301                 :            :                 wd.data[0] &= ~0x7ULL;
    3302                 :            : 
    3303                 :            :                 if (flags & (NIX_TX_MULTI_SEG_F | NIX_TX_OFFLOAD_SECURITY_F))
    3304                 :            :                         wd.data[0] <<= 16;
    3305                 :            : 
    3306                 :            :                 wd.data[0] |= ((uint64_t)(lnum - 1)) << 12;
    3307                 :            :                 wd.data[0] |= (uint64_t)lmt_id;
    3308                 :            : 
    3309                 :            :                 if (flags & NIX_TX_VWQE_F)
    3310                 :            :                         cn10k_nix_vwqe_wait_fc(txq, burst);
    3311                 :            :                 /* STEOR0 */
    3312                 :            :                 roc_lmt_submit_steorl(wd.data[0], pa);
    3313                 :            :         }
    3314                 :            : 
    3315                 :            :         rte_io_wmb();
    3316                 :            :         if (flags & NIX_TX_OFFLOAD_MBUF_NOFF_F && !txq->tx_compl.ena) {
    3317                 :            :                 cn10k_nix_free_extmbuf(extm);
    3318                 :            :                 extm = NULL;
    3319                 :            :         }
    3320                 :            : 
    3321                 :            :         if (left)
    3322                 :            :                 goto again;
    3323                 :            : 
    3324                 :            :         if (unlikely(scalar)) {
    3325                 :            :                 if (flags & NIX_TX_MULTI_SEG_F)
    3326                 :            :                         pkts += cn10k_nix_xmit_pkts_mseg(tx_queue, ws, tx_pkts,
    3327                 :            :                                                          scalar, cmd, flags);
    3328                 :            :                 else
    3329                 :            :                         pkts += cn10k_nix_xmit_pkts(tx_queue, ws, tx_pkts,
    3330                 :            :                                                     scalar, cmd, flags);
    3331                 :            :         }
    3332                 :            : 
    3333                 :            :         return pkts;
    3334                 :            : }
    3335                 :            : 
    3336                 :            : #else
    3337                 :            : static __rte_always_inline uint16_t
    3338                 :            : cn10k_nix_xmit_pkts_vector(void *tx_queue, uint64_t *ws,
    3339                 :            :                            struct rte_mbuf **tx_pkts, uint16_t pkts,
    3340                 :            :                            uint64_t *cmd, const uint16_t flags)
    3341                 :            : {
    3342                 :            :         RTE_SET_USED(ws);
    3343                 :            :         RTE_SET_USED(tx_queue);
    3344                 :            :         RTE_SET_USED(tx_pkts);
    3345                 :            :         RTE_SET_USED(pkts);
    3346                 :            :         RTE_SET_USED(cmd);
    3347                 :            :         RTE_SET_USED(flags);
    3348                 :            :         return 0;
    3349                 :            : }
    3350                 :            : #endif
    3351                 :            : 
    3352                 :            : #define L3L4CSUM_F   NIX_TX_OFFLOAD_L3_L4_CSUM_F
    3353                 :            : #define OL3OL4CSUM_F NIX_TX_OFFLOAD_OL3_OL4_CSUM_F
    3354                 :            : #define VLAN_F       NIX_TX_OFFLOAD_VLAN_QINQ_F
    3355                 :            : #define NOFF_F       NIX_TX_OFFLOAD_MBUF_NOFF_F
    3356                 :            : #define TSO_F        NIX_TX_OFFLOAD_TSO_F
    3357                 :            : #define TSP_F        NIX_TX_OFFLOAD_TSTAMP_F
    3358                 :            : #define T_SEC_F      NIX_TX_OFFLOAD_SECURITY_F
    3359                 :            : 
    3360                 :            : /* [T_SEC_F] [TSP] [TSO] [NOFF] [VLAN] [OL3OL4CSUM] [L3L4CSUM] */
    3361                 :            : #define NIX_TX_FASTPATH_MODES_0_15                                             \
    3362                 :            :         T(no_offload, 6, NIX_TX_OFFLOAD_NONE)                                  \
    3363                 :            :         T(l3l4csum, 6, L3L4CSUM_F)                                             \
    3364                 :            :         T(ol3ol4csum, 6, OL3OL4CSUM_F)                                         \
    3365                 :            :         T(ol3ol4csum_l3l4csum, 6, OL3OL4CSUM_F | L3L4CSUM_F)                   \
    3366                 :            :         T(vlan, 6, VLAN_F)                                                     \
    3367                 :            :         T(vlan_l3l4csum, 6, VLAN_F | L3L4CSUM_F)                               \
    3368                 :            :         T(vlan_ol3ol4csum, 6, VLAN_F | OL3OL4CSUM_F)                           \
    3369                 :            :         T(vlan_ol3ol4csum_l3l4csum, 6, VLAN_F | OL3OL4CSUM_F | L3L4CSUM_F)     \
    3370                 :            :         T(noff, 6, NOFF_F)                                                     \
    3371                 :            :         T(noff_l3l4csum, 6, NOFF_F | L3L4CSUM_F)                               \
    3372                 :            :         T(noff_ol3ol4csum, 6, NOFF_F | OL3OL4CSUM_F)                           \
    3373                 :            :         T(noff_ol3ol4csum_l3l4csum, 6, NOFF_F | OL3OL4CSUM_F | L3L4CSUM_F)     \
    3374                 :            :         T(noff_vlan, 6, NOFF_F | VLAN_F)                                       \
    3375                 :            :         T(noff_vlan_l3l4csum, 6, NOFF_F | VLAN_F | L3L4CSUM_F)                 \
    3376                 :            :         T(noff_vlan_ol3ol4csum, 6, NOFF_F | VLAN_F | OL3OL4CSUM_F)             \
    3377                 :            :         T(noff_vlan_ol3ol4csum_l3l4csum, 6,                                    \
    3378                 :            :           NOFF_F | VLAN_F | OL3OL4CSUM_F | L3L4CSUM_F)
    3379                 :            : 
    3380                 :            : #define NIX_TX_FASTPATH_MODES_16_31                                            \
    3381                 :            :         T(tso, 6, TSO_F)                                                       \
    3382                 :            :         T(tso_l3l4csum, 6, TSO_F | L3L4CSUM_F)                                 \
    3383                 :            :         T(tso_ol3ol4csum, 6, TSO_F | OL3OL4CSUM_F)                             \
    3384                 :            :         T(tso_ol3ol4csum_l3l4csum, 6, TSO_F | OL3OL4CSUM_F | L3L4CSUM_F)       \
    3385                 :            :         T(tso_vlan, 6, TSO_F | VLAN_F)                                         \
    3386                 :            :         T(tso_vlan_l3l4csum, 6, TSO_F | VLAN_F | L3L4CSUM_F)                   \
    3387                 :            :         T(tso_vlan_ol3ol4csum, 6, TSO_F | VLAN_F | OL3OL4CSUM_F)               \
    3388                 :            :         T(tso_vlan_ol3ol4csum_l3l4csum, 6,                                     \
    3389                 :            :           TSO_F | VLAN_F | OL3OL4CSUM_F | L3L4CSUM_F)                          \
    3390                 :            :         T(tso_noff, 6, TSO_F | NOFF_F)                                         \
    3391                 :            :         T(tso_noff_l3l4csum, 6, TSO_F | NOFF_F | L3L4CSUM_F)                   \
    3392                 :            :         T(tso_noff_ol3ol4csum, 6, TSO_F | NOFF_F | OL3OL4CSUM_F)               \
    3393                 :            :         T(tso_noff_ol3ol4csum_l3l4csum, 6,                                     \
    3394                 :            :           TSO_F | NOFF_F | OL3OL4CSUM_F | L3L4CSUM_F)                          \
    3395                 :            :         T(tso_noff_vlan, 6, TSO_F | NOFF_F | VLAN_F)                           \
    3396                 :            :         T(tso_noff_vlan_l3l4csum, 6, TSO_F | NOFF_F | VLAN_F | L3L4CSUM_F)     \
    3397                 :            :         T(tso_noff_vlan_ol3ol4csum, 6, TSO_F | NOFF_F | VLAN_F | OL3OL4CSUM_F) \
    3398                 :            :         T(tso_noff_vlan_ol3ol4csum_l3l4csum, 6,                                \
    3399                 :            :           TSO_F | NOFF_F | VLAN_F | OL3OL4CSUM_F | L3L4CSUM_F)
    3400                 :            : 
    3401                 :            : #define NIX_TX_FASTPATH_MODES_32_47                                            \
    3402                 :            :         T(ts, 8, TSP_F)                                                        \
    3403                 :            :         T(ts_l3l4csum, 8, TSP_F | L3L4CSUM_F)                                  \
    3404                 :            :         T(ts_ol3ol4csum, 8, TSP_F | OL3OL4CSUM_F)                              \
    3405                 :            :         T(ts_ol3ol4csum_l3l4csum, 8, TSP_F | OL3OL4CSUM_F | L3L4CSUM_F)        \
    3406                 :            :         T(ts_vlan, 8, TSP_F | VLAN_F)                                          \
    3407                 :            :         T(ts_vlan_l3l4csum, 8, TSP_F | VLAN_F | L3L4CSUM_F)                    \
    3408                 :            :         T(ts_vlan_ol3ol4csum, 8, TSP_F | VLAN_F | OL3OL4CSUM_F)                \
    3409                 :            :         T(ts_vlan_ol3ol4csum_l3l4csum, 8,                                      \
    3410                 :            :           TSP_F | VLAN_F | OL3OL4CSUM_F | L3L4CSUM_F)                          \
    3411                 :            :         T(ts_noff, 8, TSP_F | NOFF_F)                                          \
    3412                 :            :         T(ts_noff_l3l4csum, 8, TSP_F | NOFF_F | L3L4CSUM_F)                    \
    3413                 :            :         T(ts_noff_ol3ol4csum, 8, TSP_F | NOFF_F | OL3OL4CSUM_F)                \
    3414                 :            :         T(ts_noff_ol3ol4csum_l3l4csum, 8,                                      \
    3415                 :            :           TSP_F | NOFF_F | OL3OL4CSUM_F | L3L4CSUM_F)                          \
    3416                 :            :         T(ts_noff_vlan, 8, TSP_F | NOFF_F | VLAN_F)                            \
    3417                 :            :         T(ts_noff_vlan_l3l4csum, 8, TSP_F | NOFF_F | VLAN_F | L3L4CSUM_F)      \
    3418                 :            :         T(ts_noff_vlan_ol3ol4csum, 8, TSP_F | NOFF_F | VLAN_F | OL3OL4CSUM_F)  \
    3419                 :            :         T(ts_noff_vlan_ol3ol4csum_l3l4csum, 8,                                 \
    3420                 :            :           TSP_F | NOFF_F | VLAN_F | OL3OL4CSUM_F | L3L4CSUM_F)
    3421                 :            : 
    3422                 :            : #define NIX_TX_FASTPATH_MODES_48_63                                            \
    3423                 :            :         T(ts_tso, 8, TSP_F | TSO_F)                                            \
    3424                 :            :         T(ts_tso_l3l4csum, 8, TSP_F | TSO_F | L3L4CSUM_F)                      \
    3425                 :            :         T(ts_tso_ol3ol4csum, 8, TSP_F | TSO_F | OL3OL4CSUM_F)                  \
    3426                 :            :         T(ts_tso_ol3ol4csum_l3l4csum, 8,                                       \
    3427                 :            :           TSP_F | TSO_F | OL3OL4CSUM_F | L3L4CSUM_F)                           \
    3428                 :            :         T(ts_tso_vlan, 8, TSP_F | TSO_F | VLAN_F)                              \
    3429                 :            :         T(ts_tso_vlan_l3l4csum, 8, TSP_F | TSO_F | VLAN_F | L3L4CSUM_F)        \
    3430                 :            :         T(ts_tso_vlan_ol3ol4csum, 8, TSP_F | TSO_F | VLAN_F | OL3OL4CSUM_F)    \
    3431                 :            :         T(ts_tso_vlan_ol3ol4csum_l3l4csum, 8,                                  \
    3432                 :            :           TSP_F | TSO_F | VLAN_F | OL3OL4CSUM_F | L3L4CSUM_F)                  \
    3433                 :            :         T(ts_tso_noff, 8, TSP_F | TSO_F | NOFF_F)                              \
    3434                 :            :         T(ts_tso_noff_l3l4csum, 8, TSP_F | TSO_F | NOFF_F | L3L4CSUM_F)        \
    3435                 :            :         T(ts_tso_noff_ol3ol4csum, 8, TSP_F | TSO_F | NOFF_F | OL3OL4CSUM_F)    \
    3436                 :            :         T(ts_tso_noff_ol3ol4csum_l3l4csum, 8,                                  \
    3437                 :            :           TSP_F | TSO_F | NOFF_F | OL3OL4CSUM_F | L3L4CSUM_F)                  \
    3438                 :            :         T(ts_tso_noff_vlan, 8, TSP_F | TSO_F | NOFF_F | VLAN_F)                \
    3439                 :            :         T(ts_tso_noff_vlan_l3l4csum, 8,                                        \
    3440                 :            :           TSP_F | TSO_F | NOFF_F | VLAN_F | L3L4CSUM_F)                        \
    3441                 :            :         T(ts_tso_noff_vlan_ol3ol4csum, 8,                                      \
    3442                 :            :           TSP_F | TSO_F | NOFF_F | VLAN_F | OL3OL4CSUM_F)                      \
    3443                 :            :         T(ts_tso_noff_vlan_ol3ol4csum_l3l4csum, 8,                             \
    3444                 :            :           TSP_F | TSO_F | NOFF_F | VLAN_F | OL3OL4CSUM_F | L3L4CSUM_F)
    3445                 :            : 
    3446                 :            : #define NIX_TX_FASTPATH_MODES_64_79                                            \
    3447                 :            :         T(sec, 6, T_SEC_F)                                                     \
    3448                 :            :         T(sec_l3l4csum, 6, T_SEC_F | L3L4CSUM_F)                               \
    3449                 :            :         T(sec_ol3ol4csum, 6, T_SEC_F | OL3OL4CSUM_F)                           \
    3450                 :            :         T(sec_ol3ol4csum_l3l4csum, 6, T_SEC_F | OL3OL4CSUM_F | L3L4CSUM_F)     \
    3451                 :            :         T(sec_vlan, 6, T_SEC_F | VLAN_F)                                       \
    3452                 :            :         T(sec_vlan_l3l4csum, 6, T_SEC_F | VLAN_F | L3L4CSUM_F)                 \
    3453                 :            :         T(sec_vlan_ol3ol4csum, 6, T_SEC_F | VLAN_F | OL3OL4CSUM_F)             \
    3454                 :            :         T(sec_vlan_ol3ol4csum_l3l4csum, 6,                                     \
    3455                 :            :           T_SEC_F | VLAN_F | OL3OL4CSUM_F | L3L4CSUM_F)                        \
    3456                 :            :         T(sec_noff, 6, T_SEC_F | NOFF_F)                                       \
    3457                 :            :         T(sec_noff_l3l4csum, 6, T_SEC_F | NOFF_F | L3L4CSUM_F)                 \
    3458                 :            :         T(sec_noff_ol3ol4csum, 6, T_SEC_F | NOFF_F | OL3OL4CSUM_F)             \
    3459                 :            :         T(sec_noff_ol3ol4csum_l3l4csum, 6,                                     \
    3460                 :            :           T_SEC_F | NOFF_F | OL3OL4CSUM_F | L3L4CSUM_F)                        \
    3461                 :            :         T(sec_noff_vlan, 6, T_SEC_F | NOFF_F | VLAN_F)                         \
    3462                 :            :         T(sec_noff_vlan_l3l4csum, 6, T_SEC_F | NOFF_F | VLAN_F | L3L4CSUM_F)   \
    3463                 :            :         T(sec_noff_vlan_ol3ol4csum, 6,                                         \
    3464                 :            :           T_SEC_F | NOFF_F | VLAN_F | OL3OL4CSUM_F)                            \
    3465                 :            :         T(sec_noff_vlan_ol3ol4csum_l3l4csum, 6,                                \
    3466                 :            :           T_SEC_F | NOFF_F | VLAN_F | OL3OL4CSUM_F | L3L4CSUM_F)
    3467                 :            : 
    3468                 :            : #define NIX_TX_FASTPATH_MODES_80_95                                            \
    3469                 :            :         T(sec_tso, 6, T_SEC_F | TSO_F)                                         \
    3470                 :            :         T(sec_tso_l3l4csum, 6, T_SEC_F | TSO_F | L3L4CSUM_F)                   \
    3471                 :            :         T(sec_tso_ol3ol4csum, 6, T_SEC_F | TSO_F | OL3OL4CSUM_F)               \
    3472                 :            :         T(sec_tso_ol3ol4csum_l3l4csum, 6,                                      \
    3473                 :            :           T_SEC_F | TSO_F | OL3OL4CSUM_F | L3L4CSUM_F)                         \
    3474                 :            :         T(sec_tso_vlan, 6, T_SEC_F | TSO_F | VLAN_F)                           \
    3475                 :            :         T(sec_tso_vlan_l3l4csum, 6, T_SEC_F | TSO_F | VLAN_F | L3L4CSUM_F)     \
    3476                 :            :         T(sec_tso_vlan_ol3ol4csum, 6, T_SEC_F | TSO_F | VLAN_F | OL3OL4CSUM_F) \
    3477                 :            :         T(sec_tso_vlan_ol3ol4csum_l3l4csum, 6,                                 \
    3478                 :            :           T_SEC_F | TSO_F | VLAN_F | OL3OL4CSUM_F | L3L4CSUM_F)                \
    3479                 :            :         T(sec_tso_noff, 6, T_SEC_F | TSO_F | NOFF_F)                           \
    3480                 :            :         T(sec_tso_noff_l3l4csum, 6, T_SEC_F | TSO_F | NOFF_F | L3L4CSUM_F)     \
    3481                 :            :         T(sec_tso_noff_ol3ol4csum, 6, T_SEC_F | TSO_F | NOFF_F | OL3OL4CSUM_F) \
    3482                 :            :         T(sec_tso_noff_ol3ol4csum_l3l4csum, 6,                                 \
    3483                 :            :           T_SEC_F | TSO_F | NOFF_F | OL3OL4CSUM_F | L3L4CSUM_F)                \
    3484                 :            :         T(sec_tso_noff_vlan, 6, T_SEC_F | TSO_F | NOFF_F | VLAN_F)             \
    3485                 :            :         T(sec_tso_noff_vlan_l3l4csum, 6,                                       \
    3486                 :            :           T_SEC_F | TSO_F | NOFF_F | VLAN_F | L3L4CSUM_F)                      \
    3487                 :            :         T(sec_tso_noff_vlan_ol3ol4csum, 6,                                     \
    3488                 :            :           T_SEC_F | TSO_F | NOFF_F | VLAN_F | OL3OL4CSUM_F)                    \
    3489                 :            :         T(sec_tso_noff_vlan_ol3ol4csum_l3l4csum, 6,                            \
    3490                 :            :           T_SEC_F | TSO_F | NOFF_F | VLAN_F | OL3OL4CSUM_F | L3L4CSUM_F)
    3491                 :            : 
    3492                 :            : #define NIX_TX_FASTPATH_MODES_96_111                                           \
    3493                 :            :         T(sec_ts, 8, T_SEC_F | TSP_F)                                          \
    3494                 :            :         T(sec_ts_l3l4csum, 8, T_SEC_F | TSP_F | L3L4CSUM_F)                    \
    3495                 :            :         T(sec_ts_ol3ol4csum, 8, T_SEC_F | TSP_F | OL3OL4CSUM_F)                \
    3496                 :            :         T(sec_ts_ol3ol4csum_l3l4csum, 8,                                       \
    3497                 :            :           T_SEC_F | TSP_F | OL3OL4CSUM_F | L3L4CSUM_F)                         \
    3498                 :            :         T(sec_ts_vlan, 8, T_SEC_F | TSP_F | VLAN_F)                            \
    3499                 :            :         T(sec_ts_vlan_l3l4csum, 8, T_SEC_F | TSP_F | VLAN_F | L3L4CSUM_F)      \
    3500                 :            :         T(sec_ts_vlan_ol3ol4csum, 8, T_SEC_F | TSP_F | VLAN_F | OL3OL4CSUM_F)  \
    3501                 :            :         T(sec_ts_vlan_ol3ol4csum_l3l4csum, 8,                                  \
    3502                 :            :           T_SEC_F | TSP_F | VLAN_F | OL3OL4CSUM_F | L3L4CSUM_F)                \
    3503                 :            :         T(sec_ts_noff, 8, T_SEC_F | TSP_F | NOFF_F)                            \
    3504                 :            :         T(sec_ts_noff_l3l4csum, 8, T_SEC_F | TSP_F | NOFF_F | L3L4CSUM_F)      \
    3505                 :            :         T(sec_ts_noff_ol3ol4csum, 8, T_SEC_F | TSP_F | NOFF_F | OL3OL4CSUM_F)  \
    3506                 :            :         T(sec_ts_noff_ol3ol4csum_l3l4csum, 8,                                  \
    3507                 :            :           T_SEC_F | TSP_F | NOFF_F | OL3OL4CSUM_F | L3L4CSUM_F)                \
    3508                 :            :         T(sec_ts_noff_vlan, 8, T_SEC_F | TSP_F | NOFF_F | VLAN_F)              \
    3509                 :            :         T(sec_ts_noff_vlan_l3l4csum, 8,                                        \
    3510                 :            :           T_SEC_F | TSP_F | NOFF_F | VLAN_F | L3L4CSUM_F)                      \
    3511                 :            :         T(sec_ts_noff_vlan_ol3ol4csum, 8,                                      \
    3512                 :            :           T_SEC_F | TSP_F | NOFF_F | VLAN_F | OL3OL4CSUM_F)                    \
    3513                 :            :         T(sec_ts_noff_vlan_ol3ol4csum_l3l4csum, 8,                             \
    3514                 :            :           T_SEC_F | TSP_F | NOFF_F | VLAN_F | OL3OL4CSUM_F | L3L4CSUM_F)
    3515                 :            : 
    3516                 :            : #define NIX_TX_FASTPATH_MODES_112_127                                          \
    3517                 :            :         T(sec_ts_tso, 8, T_SEC_F | TSP_F | TSO_F)                              \
    3518                 :            :         T(sec_ts_tso_l3l4csum, 8, T_SEC_F | TSP_F | TSO_F | L3L4CSUM_F)        \
    3519                 :            :         T(sec_ts_tso_ol3ol4csum, 8, T_SEC_F | TSP_F | TSO_F | OL3OL4CSUM_F)    \
    3520                 :            :         T(sec_ts_tso_ol3ol4csum_l3l4csum, 8,                                   \
    3521                 :            :           T_SEC_F | TSP_F | TSO_F | OL3OL4CSUM_F | L3L4CSUM_F)                 \
    3522                 :            :         T(sec_ts_tso_vlan, 8, T_SEC_F | TSP_F | TSO_F | VLAN_F)                \
    3523                 :            :         T(sec_ts_tso_vlan_l3l4csum, 8,                                         \
    3524                 :            :           T_SEC_F | TSP_F | TSO_F | VLAN_F | L3L4CSUM_F)                       \
    3525                 :            :         T(sec_ts_tso_vlan_ol3ol4csum, 8,                                       \
    3526                 :            :           T_SEC_F | TSP_F | TSO_F | VLAN_F | OL3OL4CSUM_F)                     \
    3527                 :            :         T(sec_ts_tso_vlan_ol3ol4csum_l3l4csum, 8,                              \
    3528                 :            :           T_SEC_F | TSP_F | TSO_F | VLAN_F | OL3OL4CSUM_F | L3L4CSUM_F)        \
    3529                 :            :         T(sec_ts_tso_noff, 8, T_SEC_F | TSP_F | TSO_F | NOFF_F)                \
    3530                 :            :         T(sec_ts_tso_noff_l3l4csum, 8,                                         \
    3531                 :            :           T_SEC_F | TSP_F | TSO_F | NOFF_F | L3L4CSUM_F)                       \
    3532                 :            :         T(sec_ts_tso_noff_ol3ol4csum, 8,                                       \
    3533                 :            :           T_SEC_F | TSP_F | TSO_F | NOFF_F | OL3OL4CSUM_F)                     \
    3534                 :            :         T(sec_ts_tso_noff_ol3ol4csum_l3l4csum, 8,                              \
    3535                 :            :           T_SEC_F | TSP_F | TSO_F | NOFF_F | OL3OL4CSUM_F | L3L4CSUM_F)        \
    3536                 :            :         T(sec_ts_tso_noff_vlan, 8, T_SEC_F | TSP_F | TSO_F | NOFF_F | VLAN_F)  \
    3537                 :            :         T(sec_ts_tso_noff_vlan_l3l4csum, 8,                                    \
    3538                 :            :           T_SEC_F | TSP_F | TSO_F | NOFF_F | VLAN_F | L3L4CSUM_F)              \
    3539                 :            :         T(sec_ts_tso_noff_vlan_ol3ol4csum, 8,                                  \
    3540                 :            :           T_SEC_F | TSP_F | TSO_F | NOFF_F | VLAN_F | OL3OL4CSUM_F)            \
    3541                 :            :         T(sec_ts_tso_noff_vlan_ol3ol4csum_l3l4csum, 8,                         \
    3542                 :            :           T_SEC_F | TSP_F | TSO_F | NOFF_F | VLAN_F | OL3OL4CSUM_F |           \
    3543                 :            :                   L3L4CSUM_F)
    3544                 :            : 
    3545                 :            : #define NIX_TX_FASTPATH_MODES                                                  \
    3546                 :            :         NIX_TX_FASTPATH_MODES_0_15                                             \
    3547                 :            :         NIX_TX_FASTPATH_MODES_16_31                                            \
    3548                 :            :         NIX_TX_FASTPATH_MODES_32_47                                            \
    3549                 :            :         NIX_TX_FASTPATH_MODES_48_63                                            \
    3550                 :            :         NIX_TX_FASTPATH_MODES_64_79                                            \
    3551                 :            :         NIX_TX_FASTPATH_MODES_80_95                                            \
    3552                 :            :         NIX_TX_FASTPATH_MODES_96_111                                           \
    3553                 :            :         NIX_TX_FASTPATH_MODES_112_127
    3554                 :            : 
    3555                 :            : #define T(name, sz, flags)                                                     \
    3556                 :            :         uint16_t __rte_noinline __rte_hot cn10k_nix_xmit_pkts_##name(          \
    3557                 :            :                 void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t pkts);     \
    3558                 :            :         uint16_t __rte_noinline __rte_hot cn10k_nix_xmit_pkts_mseg_##name(     \
    3559                 :            :                 void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t pkts);     \
    3560                 :            :         uint16_t __rte_noinline __rte_hot cn10k_nix_xmit_pkts_vec_##name(      \
    3561                 :            :                 void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t pkts);     \
    3562                 :            :         uint16_t __rte_noinline __rte_hot cn10k_nix_xmit_pkts_vec_mseg_##name( \
    3563                 :            :                 void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t pkts);
    3564                 :            : 
    3565                 :            : NIX_TX_FASTPATH_MODES
    3566                 :            : #undef T
    3567                 :            : 
    3568                 :            : #define NIX_TX_XMIT(fn, sz, flags)                                             \
    3569                 :            :         uint16_t __rte_noinline __rte_hot fn(                                  \
    3570                 :            :                 void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t pkts)      \
    3571                 :            :         {                                                                      \
    3572                 :            :                 uint64_t cmd[sz];                                              \
    3573                 :            :                 /* For TSO inner checksum is a must */                         \
    3574                 :            :                 if (((flags) & NIX_TX_OFFLOAD_TSO_F) &&                        \
    3575                 :            :                     !((flags) & NIX_TX_OFFLOAD_L3_L4_CSUM_F))                  \
    3576                 :            :                         return 0;                                              \
    3577                 :            :                 return cn10k_nix_xmit_pkts(tx_queue, NULL, tx_pkts, pkts, cmd, \
    3578                 :            :                                            flags);                             \
    3579                 :            :         }
    3580                 :            : 
    3581                 :            : #define NIX_TX_XMIT_MSEG(fn, sz, flags)                                        \
    3582                 :            :         uint16_t __rte_noinline __rte_hot fn(                                  \
    3583                 :            :                 void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t pkts)      \
    3584                 :            :         {                                                                      \
    3585                 :            :                 uint64_t cmd[(sz) + CNXK_NIX_TX_MSEG_SG_DWORDS - 2];           \
    3586                 :            :                 /* For TSO inner checksum is a must */                         \
    3587                 :            :                 if (((flags) & NIX_TX_OFFLOAD_TSO_F) &&                        \
    3588                 :            :                     !((flags) & NIX_TX_OFFLOAD_L3_L4_CSUM_F))                  \
    3589                 :            :                         return 0;                                              \
    3590                 :            :                 return cn10k_nix_xmit_pkts_mseg(tx_queue, NULL, tx_pkts, pkts, \
    3591                 :            :                                                 cmd,                           \
    3592                 :            :                                                 flags | NIX_TX_MULTI_SEG_F);   \
    3593                 :            :         }
    3594                 :            : 
    3595                 :            : #define NIX_TX_XMIT_VEC(fn, sz, flags)                                         \
    3596                 :            :         uint16_t __rte_noinline __rte_hot fn(                                  \
    3597                 :            :                 void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t pkts)      \
    3598                 :            :         {                                                                      \
    3599                 :            :                 uint64_t cmd[sz];                                              \
    3600                 :            :                 /* For TSO inner checksum is a must */                         \
    3601                 :            :                 if (((flags) & NIX_TX_OFFLOAD_TSO_F) &&                        \
    3602                 :            :                     !((flags) & NIX_TX_OFFLOAD_L3_L4_CSUM_F))                  \
    3603                 :            :                         return 0;                                              \
    3604                 :            :                 return cn10k_nix_xmit_pkts_vector(tx_queue, NULL, tx_pkts,     \
    3605                 :            :                                                   pkts, cmd, (flags));         \
    3606                 :            :         }
    3607                 :            : 
    3608                 :            : #define NIX_TX_XMIT_VEC_MSEG(fn, sz, flags)                                    \
    3609                 :            :         uint16_t __rte_noinline __rte_hot fn(                                  \
    3610                 :            :                 void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t pkts)      \
    3611                 :            :         {                                                                      \
    3612                 :            :                 uint64_t cmd[(sz) + CNXK_NIX_TX_MSEG_SG_DWORDS - 2];           \
    3613                 :            :                 /* For TSO inner checksum is a must */                         \
    3614                 :            :                 if (((flags) & NIX_TX_OFFLOAD_TSO_F) &&                        \
    3615                 :            :                     !((flags) & NIX_TX_OFFLOAD_L3_L4_CSUM_F))                  \
    3616                 :            :                         return 0;                                              \
    3617                 :            :                 return cn10k_nix_xmit_pkts_vector(                             \
    3618                 :            :                         tx_queue, NULL, tx_pkts, pkts, cmd,                    \
    3619                 :            :                         (flags) | NIX_TX_MULTI_SEG_F);                         \
    3620                 :            :         }
    3621                 :            : 
    3622                 :            : uint16_t __rte_noinline __rte_hot cn10k_nix_xmit_pkts_all_offload(void *tx_queue,
    3623                 :            :                                                                   struct rte_mbuf **tx_pkts,
    3624                 :            :                                                                   uint16_t pkts);
    3625                 :            : 
    3626                 :            : uint16_t __rte_noinline __rte_hot cn10k_nix_xmit_pkts_vec_all_offload(void *tx_queue,
    3627                 :            :                                                                       struct rte_mbuf **tx_pkts,
    3628                 :            :                                                                       uint16_t pkts);
    3629                 :            : 
    3630                 :            : #endif /* __CN10K_TX_H__ */

Generated by: LCOV version 1.14