LCOV - code coverage report
Current view: top level - drivers/event/cnxk - cn20k_eventdev.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 1 447 0.2 %
Date: 2025-11-01 17:50:34 Functions: 1 47 2.1 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 275 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(C) 2024 Marvell.
       3                 :            :  */
       4                 :            : 
       5                 :            : #include "roc_api.h"
       6                 :            : 
       7                 :            : #include "cn20k_cryptodev_ops.h"
       8                 :            : #include "cn20k_ethdev.h"
       9                 :            : #include "cn20k_eventdev.h"
      10                 :            : #include "cn20k_tx_worker.h"
      11                 :            : #include "cn20k_worker.h"
      12                 :            : #include "cnxk_common.h"
      13                 :            : #include "cnxk_eventdev.h"
      14                 :            : #include "cnxk_vector_adptr.h"
      15                 :            : #include "cnxk_worker.h"
      16                 :            : 
      17                 :            : #define CN20K_SET_EVDEV_DEQ_OP(dev, deq_op, deq_ops)                                               \
      18                 :            :         deq_op = deq_ops[dev->rx_offloads & (NIX_RX_OFFLOAD_MAX - 1)]
      19                 :            : 
      20                 :            : #define CN20K_SET_EVDEV_ENQ_OP(dev, enq_op, enq_ops)                                               \
      21                 :            :         enq_op = enq_ops[dev->tx_offloads & (NIX_TX_OFFLOAD_MAX - 1)]
      22                 :            : 
      23                 :            : static uint8_t
      24                 :            : cn20k_sso_hw_weight(uint8_t weight)
      25                 :            : {
      26                 :            :         /* Map DPDK weight 0-255 to HW weight 1-255 */
      27                 :          0 :         return (weight + 1) > CN20K_SSO_WEIGHT_MAX ? CN20K_SSO_WEIGHT_MAX : (weight + 1);
      28                 :            : }
      29                 :            : 
      30                 :            : static int
      31         [ #  # ]:          0 : cn20k_sso_queue_setup(struct rte_eventdev *event_dev, uint8_t queue_id,
      32                 :            :                       const struct rte_event_queue_conf *queue_conf)
      33                 :            : {
      34                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
      35                 :            :         uint8_t priority, weight, affinity;
      36                 :            : 
      37                 :          0 :         priority = CNXK_QOS_NORMALIZE(queue_conf->priority, 0, RTE_EVENT_DEV_PRIORITY_LOWEST,
      38                 :            :                                       CNXK_SSO_PRIORITY_CNT);
      39         [ #  # ]:          0 :         weight = cn20k_sso_hw_weight(queue_conf->weight);
      40                 :          0 :         affinity = CNXK_QOS_NORMALIZE(queue_conf->affinity, 0, RTE_EVENT_QUEUE_AFFINITY_HIGHEST,
      41                 :            :                                       CNXK_SSO_AFFINITY_CNT);
      42                 :            : 
      43                 :          0 :         plt_sso_dbg("Queue=%u prio=%u weight=%u affinity=%u", queue_id, priority, weight, affinity);
      44                 :            : 
      45                 :          0 :         return roc_sso_hwgrp_set_priority(&dev->sso, queue_id, weight, affinity, priority);
      46                 :            : }
      47                 :            : 
      48                 :            : static int
      49   [ #  #  #  #  :          0 : cn20k_sso_queue_attribute_set(struct rte_eventdev *event_dev, uint8_t queue_id, uint32_t attr_id,
                      # ]
      50                 :            :                               uint64_t attr_value)
      51                 :            : {
      52                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
      53                 :            :         uint8_t priority, weight, affinity;
      54                 :            :         struct rte_event_queue_conf *conf;
      55                 :            : 
      56                 :          0 :         conf = &event_dev->data->queues_cfg[queue_id];
      57                 :            : 
      58   [ #  #  #  #  :          0 :         switch (attr_id) {
                      # ]
      59                 :          0 :         case RTE_EVENT_QUEUE_ATTR_PRIORITY:
      60                 :          0 :                 conf->priority = attr_value;
      61                 :          0 :                 break;
      62                 :          0 :         case RTE_EVENT_QUEUE_ATTR_WEIGHT:
      63                 :          0 :                 conf->weight = attr_value;
      64                 :          0 :                 break;
      65                 :          0 :         case RTE_EVENT_QUEUE_ATTR_AFFINITY:
      66                 :          0 :                 conf->affinity = attr_value;
      67                 :          0 :                 break;
      68                 :          0 :         case RTE_EVENT_QUEUE_ATTR_NB_ATOMIC_FLOWS:
      69                 :            :         case RTE_EVENT_QUEUE_ATTR_NB_ATOMIC_ORDER_SEQUENCES:
      70                 :            :         case RTE_EVENT_QUEUE_ATTR_EVENT_QUEUE_CFG:
      71                 :            :         case RTE_EVENT_QUEUE_ATTR_SCHEDULE_TYPE:
      72                 :            :                 /* FALLTHROUGH */
      73                 :          0 :                 plt_sso_dbg("Unsupported attribute id %u", attr_id);
      74                 :          0 :                 return -ENOTSUP;
      75                 :          0 :         default:
      76                 :          0 :                 plt_err("Invalid attribute id %u", attr_id);
      77                 :          0 :                 return -EINVAL;
      78                 :            :         }
      79                 :            : 
      80                 :          0 :         priority = CNXK_QOS_NORMALIZE(conf->priority, 0, RTE_EVENT_DEV_PRIORITY_LOWEST,
      81                 :            :                                       CNXK_SSO_PRIORITY_CNT);
      82         [ #  # ]:          0 :         weight = cn20k_sso_hw_weight(conf->weight);
      83                 :          0 :         affinity = CNXK_QOS_NORMALIZE(conf->affinity, 0, RTE_EVENT_QUEUE_AFFINITY_HIGHEST,
      84                 :            :                                       CNXK_SSO_AFFINITY_CNT);
      85                 :            : 
      86                 :          0 :         return roc_sso_hwgrp_set_priority(&dev->sso, queue_id, weight, affinity, priority);
      87                 :            : }
      88                 :            : 
      89                 :            : static void *
      90                 :          0 : cn20k_sso_init_hws_mem(void *arg, uint8_t port_id)
      91                 :            : {
      92                 :            :         struct cnxk_sso_evdev *dev = arg;
      93                 :            :         struct cn20k_sso_hws *ws;
      94                 :            : 
      95                 :            :         /* Allocate event port memory */
      96                 :          0 :         ws = rte_zmalloc("cn20k_ws", sizeof(struct cn20k_sso_hws) + RTE_CACHE_LINE_SIZE,
      97                 :            :                          RTE_CACHE_LINE_SIZE);
      98         [ #  # ]:          0 :         if (ws == NULL) {
      99                 :          0 :                 plt_err("Failed to alloc memory for port=%d", port_id);
     100                 :          0 :                 return NULL;
     101                 :            :         }
     102                 :            : 
     103                 :            :         /* First cache line is reserved for cookie */
     104                 :          0 :         ws = (struct cn20k_sso_hws *)((uint8_t *)ws + RTE_CACHE_LINE_SIZE);
     105                 :          0 :         ws->base = roc_sso_hws_base_get(&dev->sso, port_id);
     106                 :          0 :         ws->hws_id = port_id;
     107         [ #  # ]:          0 :         ws->swtag_req = 0;
     108                 :          0 :         ws->gw_wdata = cnxk_sso_hws_prf_wdata(dev);
     109                 :          0 :         ws->gw_rdata = SSO_TT_EMPTY << 32;
     110                 :          0 :         ws->xae_waes = dev->sso.feat.xaq_wq_entries;
     111                 :            : 
     112                 :          0 :         return ws;
     113                 :            : }
     114                 :            : 
     115                 :            : static int
     116                 :          0 : cn20k_sso_hws_link(void *arg, void *port, uint16_t *map, uint16_t nb_link, uint8_t profile)
     117                 :            : {
     118                 :            :         struct cnxk_sso_evdev *dev = arg;
     119                 :            :         struct cn20k_sso_hws *ws = port;
     120                 :            : 
     121                 :          0 :         return roc_sso_hws_link(&dev->sso, ws->hws_id, map, nb_link, profile, 0);
     122                 :            : }
     123                 :            : 
     124                 :            : static int
     125                 :          0 : cn20k_sso_hws_unlink(void *arg, void *port, uint16_t *map, uint16_t nb_link, uint8_t profile)
     126                 :            : {
     127                 :            :         struct cnxk_sso_evdev *dev = arg;
     128                 :            :         struct cn20k_sso_hws *ws = port;
     129                 :            : 
     130                 :          0 :         return roc_sso_hws_unlink(&dev->sso, ws->hws_id, map, nb_link, profile, 0);
     131                 :            : }
     132                 :            : 
     133                 :            : static void
     134                 :          0 : cn20k_sso_hws_setup(void *arg, void *hws, uintptr_t grp_base)
     135                 :            : {
     136                 :            :         struct cnxk_sso_evdev *dev = arg;
     137                 :            :         struct cn20k_sso_hws *ws = hws;
     138                 :            :         uint64_t val;
     139                 :            : 
     140                 :          0 :         ws->grp_base = grp_base;
     141                 :          0 :         ws->fc_mem = (int64_t __rte_atomic *)dev->fc_iova;
     142                 :          0 :         ws->xaq_lmt = dev->xaq_lmt;
     143                 :          0 :         ws->fc_cache_space = (int64_t __rte_atomic *)dev->fc_cache_space;
     144         [ #  # ]:          0 :         ws->aw_lmt = dev->sso.lmt_base;
     145                 :          0 :         ws->gw_wdata = cnxk_sso_hws_prf_wdata(dev);
     146                 :          0 :         ws->lmt_base = dev->sso.lmt_base;
     147                 :            : 
     148                 :            :         /* Set get_work timeout for HWS */
     149                 :          0 :         val = NSEC2USEC(dev->deq_tmo_ns);
     150         [ #  # ]:          0 :         val = val ? val - 1 : 0;
     151                 :          0 :         plt_write64(val, ws->base + SSOW_LF_GWS_NW_TIM);
     152                 :          0 : }
     153                 :            : 
     154                 :            : static void
     155                 :          0 : cn20k_sso_hws_release(void *arg, void *hws)
     156                 :            : {
     157                 :            :         struct cnxk_sso_evdev *dev = arg;
     158                 :            :         struct cn20k_sso_hws *ws = hws;
     159                 :            :         uint16_t i, j;
     160                 :            : 
     161         [ #  # ]:          0 :         for (i = 0; i < CNXK_SSO_MAX_PROFILES; i++)
     162         [ #  # ]:          0 :                 for (j = 0; j < dev->nb_event_queues; j++)
     163                 :          0 :                         roc_sso_hws_unlink(&dev->sso, ws->hws_id, &j, 1, i, 0);
     164                 :            :         memset(ws, 0, sizeof(*ws));
     165                 :          0 : }
     166                 :            : 
     167                 :            : static int
     168                 :          0 : cn20k_sso_hws_flush_events(void *hws, uint8_t queue_id, uintptr_t base, cnxk_handle_event_t fn,
     169                 :            :                            void *arg)
     170                 :            : {
     171                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(arg);
     172                 :            :         uint64_t retry = CNXK_SSO_FLUSH_RETRY_MAX;
     173                 :            :         struct cn20k_sso_hws *ws = hws;
     174                 :            :         uint64_t cq_ds_cnt = 1;
     175                 :            :         uint64_t aq_cnt = 1;
     176                 :            :         uint64_t ds_cnt = 1;
     177                 :            :         struct rte_event ev;
     178                 :            :         uint64_t val, req;
     179                 :            : 
     180                 :          0 :         plt_write64(0, base + SSO_LF_GGRP_QCTL);
     181                 :            : 
     182                 :          0 :         roc_sso_hws_gwc_invalidate(&dev->sso, &ws->hws_id, 1);
     183                 :          0 :         plt_write64(0, ws->base + SSOW_LF_GWS_OP_GWC_INVAL);
     184                 :          0 :         req = queue_id;     /* GGRP ID */
     185                 :            :         req |= BIT_ULL(18); /* Grouped */
     186                 :          0 :         req |= BIT_ULL(16); /* WAIT */
     187                 :            : 
     188                 :          0 :         aq_cnt = plt_read64(base + SSO_LF_GGRP_AQ_CNT);
     189                 :          0 :         ds_cnt = plt_read64(base + SSO_LF_GGRP_MISC_CNT);
     190                 :          0 :         cq_ds_cnt = plt_read64(base + SSO_LF_GGRP_INT_CNT);
     191                 :          0 :         cq_ds_cnt &= 0x3FFF3FFF0000;
     192                 :            : 
     193         [ #  # ]:          0 :         while (aq_cnt || cq_ds_cnt || ds_cnt) {
     194                 :          0 :                 plt_write64(req, ws->base + SSOW_LF_GWS_OP_GET_WORK0);
     195                 :            :                 cn20k_sso_hws_get_work_empty(ws, &ev, 0);
     196   [ #  #  #  # ]:          0 :                 if (fn != NULL && ev.u64 != 0)
     197                 :          0 :                         fn(arg, ev);
     198         [ #  # ]:          0 :                 if (ev.sched_type != SSO_TT_EMPTY)
     199                 :          0 :                         cnxk_sso_hws_swtag_flush(ws->base);
     200         [ #  # ]:          0 :                 else if (retry-- == 0)
     201                 :            :                         break;
     202                 :            :                 do {
     203         [ #  # ]:          0 :                         val = plt_read64(ws->base + SSOW_LF_GWS_PENDSTATE);
     204         [ #  # ]:          0 :                 } while (val & BIT_ULL(56));
     205                 :            :                 aq_cnt = plt_read64(base + SSO_LF_GGRP_AQ_CNT);
     206                 :            :                 ds_cnt = plt_read64(base + SSO_LF_GGRP_MISC_CNT);
     207                 :            :                 cq_ds_cnt = plt_read64(base + SSO_LF_GGRP_INT_CNT);
     208                 :            :                 /* Extract cq and ds count */
     209                 :          0 :                 cq_ds_cnt &= 0x3FFF3FFF0000;
     210                 :            :         }
     211                 :            : 
     212         [ #  # ]:          0 :         if (aq_cnt || cq_ds_cnt || ds_cnt)
     213                 :            :                 return -EAGAIN;
     214                 :            : 
     215                 :          0 :         plt_write64(0, ws->base + SSOW_LF_GWS_OP_GWC_INVAL);
     216                 :          0 :         roc_sso_hws_gwc_invalidate(&dev->sso, &ws->hws_id, 1);
     217                 :            :         rte_mb();
     218                 :            : 
     219                 :          0 :         return 0;
     220                 :            : }
     221                 :            : 
     222                 :            : static void
     223                 :            : cn20k_sso_set_rsrc(void *arg)
     224                 :            : {
     225                 :            :         struct cnxk_sso_evdev *dev = arg;
     226                 :            : 
     227                 :          0 :         dev->max_event_ports = dev->sso.max_hws;
     228                 :          0 :         dev->max_event_queues = dev->sso.max_hwgrp > RTE_EVENT_MAX_QUEUES_PER_DEV ?
     229                 :          0 :                                         RTE_EVENT_MAX_QUEUES_PER_DEV :
     230                 :            :                                         dev->sso.max_hwgrp;
     231                 :            : }
     232                 :            : 
     233                 :            : static int
     234                 :          0 : cn20k_sso_rsrc_init(void *arg, uint8_t hws, uint8_t hwgrp)
     235                 :            : {
     236                 :            :         struct cnxk_tim_evdev *tim_dev = cnxk_tim_priv_get();
     237                 :            :         struct cnxk_sso_evdev *dev = arg;
     238                 :            :         uint16_t nb_tim_lfs;
     239                 :            : 
     240         [ #  # ]:          0 :         nb_tim_lfs = tim_dev ? tim_dev->nb_rings : 0;
     241                 :          0 :         return roc_sso_rsrc_init(&dev->sso, hws, hwgrp, nb_tim_lfs);
     242                 :            : }
     243                 :            : 
     244                 :            : static int
     245         [ #  # ]:          0 : cn20k_sso_updt_tx_adptr_data(const struct rte_eventdev *event_dev)
     246                 :            : {
     247                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
     248                 :            :         int i;
     249                 :            : 
     250         [ #  # ]:          0 :         if (dev->tx_adptr_data == NULL)
     251                 :            :                 return 0;
     252                 :            : 
     253         [ #  # ]:          0 :         for (i = 0; i < dev->nb_event_ports; i++) {
     254                 :          0 :                 struct cn20k_sso_hws *ws = event_dev->data->ports[i];
     255                 :            :                 void *ws_cookie;
     256                 :            : 
     257                 :            :                 ws_cookie = cnxk_sso_hws_get_cookie(ws);
     258                 :          0 :                 ws_cookie = rte_realloc_socket(ws_cookie,
     259                 :            :                                                sizeof(struct cnxk_sso_hws_cookie) +
     260                 :            :                                                        sizeof(struct cn20k_sso_hws) +
     261                 :          0 :                                                        dev->tx_adptr_data_sz,
     262                 :            :                                                RTE_CACHE_LINE_SIZE, SOCKET_ID_ANY);
     263         [ #  # ]:          0 :                 if (ws_cookie == NULL)
     264                 :            :                         return -ENOMEM;
     265                 :          0 :                 ws = RTE_PTR_ADD(ws_cookie, sizeof(struct cnxk_sso_hws_cookie));
     266                 :          0 :                 memcpy(&ws->tx_adptr_data, dev->tx_adptr_data, dev->tx_adptr_data_sz);
     267                 :          0 :                 event_dev->data->ports[i] = ws;
     268                 :            :         }
     269                 :            : 
     270                 :            :         return 0;
     271                 :            : }
     272                 :            : 
     273                 :            : #if defined(RTE_ARCH_ARM64)
     274                 :            : static inline void
     275                 :            : cn20k_sso_fp_tmplt_fns_set(struct rte_eventdev *event_dev)
     276                 :            : {
     277                 :            : #if !defined(CNXK_DIS_TMPLT_FUNC)
     278                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
     279                 :            : 
     280                 :            :         const event_dequeue_burst_t sso_hws_deq_burst[NIX_RX_OFFLOAD_MAX] = {
     281                 :            : #define R(name, flags) [flags] = cn20k_sso_hws_deq_burst_##name,
     282                 :            :                 NIX_RX_FASTPATH_MODES
     283                 :            : #undef R
     284                 :            :         };
     285                 :            : 
     286                 :            :         const event_dequeue_burst_t sso_hws_deq_tmo_burst[NIX_RX_OFFLOAD_MAX] = {
     287                 :            : #define R(name, flags) [flags] = cn20k_sso_hws_deq_tmo_burst_##name,
     288                 :            :                 NIX_RX_FASTPATH_MODES
     289                 :            : #undef R
     290                 :            :         };
     291                 :            : 
     292                 :            :         const event_dequeue_burst_t sso_hws_deq_seg_burst[NIX_RX_OFFLOAD_MAX] = {
     293                 :            : #define R(name, flags) [flags] = cn20k_sso_hws_deq_seg_burst_##name,
     294                 :            :                 NIX_RX_FASTPATH_MODES
     295                 :            : #undef R
     296                 :            :         };
     297                 :            : 
     298                 :            :         const event_dequeue_burst_t sso_hws_deq_tmo_seg_burst[NIX_RX_OFFLOAD_MAX] = {
     299                 :            : #define R(name, flags) [flags] = cn20k_sso_hws_deq_tmo_seg_burst_##name,
     300                 :            :                 NIX_RX_FASTPATH_MODES
     301                 :            : #undef R
     302                 :            :         };
     303                 :            : 
     304                 :            :         const event_dequeue_burst_t sso_hws_reas_deq_burst[NIX_RX_OFFLOAD_MAX] = {
     305                 :            : #define R(name, flags) [flags] = cn20k_sso_hws_reas_deq_burst_##name,
     306                 :            :                 NIX_RX_FASTPATH_MODES
     307                 :            : #undef R
     308                 :            :         };
     309                 :            : 
     310                 :            :         const event_dequeue_burst_t sso_hws_reas_deq_tmo_burst[NIX_RX_OFFLOAD_MAX] = {
     311                 :            : #define R(name, flags) [flags] = cn20k_sso_hws_reas_deq_tmo_burst_##name,
     312                 :            :                 NIX_RX_FASTPATH_MODES
     313                 :            : #undef R
     314                 :            :         };
     315                 :            : 
     316                 :            :         const event_dequeue_burst_t sso_hws_reas_deq_seg_burst[NIX_RX_OFFLOAD_MAX] = {
     317                 :            : #define R(name, flags) [flags] = cn20k_sso_hws_reas_deq_seg_burst_##name,
     318                 :            :                 NIX_RX_FASTPATH_MODES
     319                 :            : #undef R
     320                 :            :         };
     321                 :            : 
     322                 :            :         const event_dequeue_burst_t sso_hws_reas_deq_tmo_seg_burst[NIX_RX_OFFLOAD_MAX] = {
     323                 :            : #define R(name, flags) [flags] = cn20k_sso_hws_reas_deq_tmo_seg_burst_##name,
     324                 :            :                 NIX_RX_FASTPATH_MODES
     325                 :            : #undef R
     326                 :            :         };
     327                 :            : 
     328                 :            :         /* Tx modes */
     329                 :            :         const event_tx_adapter_enqueue_t sso_hws_tx_adptr_enq[NIX_TX_OFFLOAD_MAX] = {
     330                 :            : #define T(name, sz, flags) [flags] = cn20k_sso_hws_tx_adptr_enq_##name,
     331                 :            :                 NIX_TX_FASTPATH_MODES
     332                 :            : #undef T
     333                 :            :         };
     334                 :            : 
     335                 :            :         const event_tx_adapter_enqueue_t sso_hws_tx_adptr_enq_seg[NIX_TX_OFFLOAD_MAX] = {
     336                 :            : #define T(name, sz, flags) [flags] = cn20k_sso_hws_tx_adptr_enq_seg_##name,
     337                 :            :                 NIX_TX_FASTPATH_MODES
     338                 :            : #undef T
     339                 :            :         };
     340                 :            : 
     341                 :            :         if (dev->rx_offloads & NIX_RX_MULTI_SEG_F) {
     342                 :            :                 if (dev->rx_offloads & NIX_RX_REAS_F) {
     343                 :            :                         CN20K_SET_EVDEV_DEQ_OP(dev, event_dev->dequeue_burst,
     344                 :            :                                                sso_hws_reas_deq_seg_burst);
     345                 :            :                         if (dev->is_timeout_deq)
     346                 :            :                                 CN20K_SET_EVDEV_DEQ_OP(dev, event_dev->dequeue_burst,
     347                 :            :                                                        sso_hws_reas_deq_tmo_seg_burst);
     348                 :            :                 } else {
     349                 :            :                         CN20K_SET_EVDEV_DEQ_OP(dev, event_dev->dequeue_burst,
     350                 :            :                                                sso_hws_deq_seg_burst);
     351                 :            : 
     352                 :            :                         if (dev->is_timeout_deq)
     353                 :            :                                 CN20K_SET_EVDEV_DEQ_OP(dev, event_dev->dequeue_burst,
     354                 :            :                                                        sso_hws_deq_tmo_seg_burst);
     355                 :            :                 }
     356                 :            :         } else {
     357                 :            :                 if (dev->rx_offloads & NIX_RX_REAS_F) {
     358                 :            :                         CN20K_SET_EVDEV_DEQ_OP(dev, event_dev->dequeue_burst,
     359                 :            :                                                sso_hws_reas_deq_burst);
     360                 :            : 
     361                 :            :                         if (dev->is_timeout_deq)
     362                 :            :                                 CN20K_SET_EVDEV_DEQ_OP(dev, event_dev->dequeue_burst,
     363                 :            :                                                        sso_hws_reas_deq_tmo_burst);
     364                 :            :                 } else {
     365                 :            :                         CN20K_SET_EVDEV_DEQ_OP(dev, event_dev->dequeue_burst, sso_hws_deq_burst);
     366                 :            : 
     367                 :            :                         if (dev->is_timeout_deq)
     368                 :            :                                 CN20K_SET_EVDEV_DEQ_OP(dev, event_dev->dequeue_burst,
     369                 :            :                                                        sso_hws_deq_tmo_burst);
     370                 :            :                 }
     371                 :            :         }
     372                 :            : 
     373                 :            :         if (dev->tx_offloads & NIX_TX_MULTI_SEG_F)
     374                 :            :                 CN20K_SET_EVDEV_ENQ_OP(dev, event_dev->txa_enqueue, sso_hws_tx_adptr_enq_seg);
     375                 :            :         else
     376                 :            :                 CN20K_SET_EVDEV_ENQ_OP(dev, event_dev->txa_enqueue, sso_hws_tx_adptr_enq);
     377                 :            : 
     378                 :            :         event_dev->txa_enqueue_same_dest = event_dev->txa_enqueue;
     379                 :            : #else
     380                 :            :         RTE_SET_USED(event_dev);
     381                 :            : #endif
     382                 :            : }
     383                 :            : 
     384                 :            : static inline void
     385                 :            : cn20k_sso_fp_blk_fns_set(struct rte_eventdev *event_dev)
     386                 :            : {
     387                 :            : #if defined(CNXK_DIS_TMPLT_FUNC)
     388                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
     389                 :            : 
     390                 :            :         event_dev->dequeue_burst = cn20k_sso_hws_deq_burst_all_offload;
     391                 :            :         if (dev->rx_offloads & NIX_RX_OFFLOAD_TSTAMP_F)
     392                 :            :                 event_dev->dequeue_burst = cn20k_sso_hws_deq_burst_all_offload_tst;
     393                 :            :         event_dev->txa_enqueue = cn20k_sso_hws_tx_adptr_enq_seg_all_offload;
     394                 :            :         event_dev->txa_enqueue_same_dest = cn20k_sso_hws_tx_adptr_enq_seg_all_offload;
     395                 :            :         if (dev->tx_offloads & (NIX_TX_OFFLOAD_OL3_OL4_CSUM_F | NIX_TX_OFFLOAD_VLAN_QINQ_F |
     396                 :            :                                 NIX_TX_OFFLOAD_TSO_F | NIX_TX_OFFLOAD_TSTAMP_F)) {
     397                 :            :                 event_dev->txa_enqueue = cn20k_sso_hws_tx_adptr_enq_seg_all_offload_tst;
     398                 :            :                 event_dev->txa_enqueue_same_dest = cn20k_sso_hws_tx_adptr_enq_seg_all_offload_tst;
     399                 :            :         }
     400                 :            : #else
     401                 :            :         RTE_SET_USED(event_dev);
     402                 :            : #endif
     403                 :            : }
     404                 :            : #endif
     405                 :            : 
     406                 :            : static void
     407                 :            : cn20k_sso_fp_fns_set(struct rte_eventdev *event_dev)
     408                 :            : {
     409                 :            : #if defined(RTE_ARCH_ARM64)
     410                 :            :         cn20k_sso_fp_blk_fns_set(event_dev);
     411                 :            :         cn20k_sso_fp_tmplt_fns_set(event_dev);
     412                 :            : 
     413                 :            :         event_dev->enqueue_burst = cn20k_sso_hws_enq_burst;
     414                 :            :         event_dev->enqueue_new_burst = cn20k_sso_hws_enq_new_burst;
     415                 :            :         event_dev->enqueue_forward_burst = cn20k_sso_hws_enq_fwd_burst;
     416                 :            : 
     417                 :            :         event_dev->ca_enqueue = cn20k_cpt_crypto_adapter_enqueue;
     418                 :            :         event_dev->profile_switch = cn20k_sso_hws_profile_switch;
     419                 :            :         event_dev->preschedule_modify = cn20k_sso_hws_preschedule_modify;
     420                 :            :         event_dev->preschedule = cn20k_sso_hws_preschedule;
     421                 :            : #else
     422                 :            :         RTE_SET_USED(event_dev);
     423                 :            : #endif
     424                 :            : }
     425                 :            : 
     426                 :            : static void
     427                 :          0 : cn20k_sso_info_get(struct rte_eventdev *event_dev, struct rte_event_dev_info *dev_info)
     428                 :            : {
     429                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
     430                 :            : 
     431                 :          0 :         dev_info->driver_name = RTE_STR(EVENTDEV_NAME_CN20K_PMD);
     432                 :          0 :         cnxk_sso_info_get(dev, dev_info);
     433                 :          0 :         dev_info->max_event_port_enqueue_depth = UINT32_MAX;
     434                 :          0 : }
     435                 :            : 
     436                 :            : static int
     437                 :          0 : cn20k_sso_dev_configure(const struct rte_eventdev *event_dev)
     438                 :            : {
     439                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
     440                 :            :         int rc;
     441                 :            : 
     442                 :          0 :         rc = cnxk_sso_dev_validate(event_dev, 1, UINT32_MAX);
     443         [ #  # ]:          0 :         if (rc < 0) {
     444                 :          0 :                 plt_err("Invalid event device configuration");
     445                 :          0 :                 return -EINVAL;
     446                 :            :         }
     447                 :            : 
     448                 :          0 :         rc = cn20k_sso_rsrc_init(dev, dev->nb_event_ports, dev->nb_event_queues);
     449         [ #  # ]:          0 :         if (rc < 0) {
     450                 :          0 :                 plt_err("Failed to initialize SSO resources");
     451                 :          0 :                 return -ENODEV;
     452                 :            :         }
     453                 :            : 
     454                 :          0 :         rc = cnxk_sso_xaq_allocate(dev);
     455         [ #  # ]:          0 :         if (rc < 0)
     456                 :          0 :                 goto cnxk_rsrc_fini;
     457                 :            : 
     458      [ #  #  # ]:          0 :         dev->gw_mode = cnxk_sso_hws_preschedule_get(event_dev->data->dev_conf.preschedule_type);
     459                 :            : 
     460                 :          0 :         rc = cnxk_setup_event_ports(event_dev, cn20k_sso_init_hws_mem, cn20k_sso_hws_setup);
     461         [ #  # ]:          0 :         if (rc < 0)
     462                 :          0 :                 goto cnxk_rsrc_fini;
     463                 :            : 
     464                 :            :         /* Restore any prior port-queue mapping. */
     465                 :          0 :         cnxk_sso_restore_links(event_dev, cn20k_sso_hws_link);
     466                 :            : 
     467                 :          0 :         dev->configured = 1;
     468                 :            :         rte_mb();
     469                 :            : 
     470                 :          0 :         return 0;
     471                 :          0 : cnxk_rsrc_fini:
     472                 :          0 :         roc_sso_rsrc_fini(&dev->sso);
     473                 :          0 :         dev->nb_event_ports = 0;
     474                 :          0 :         return rc;
     475                 :            : }
     476                 :            : 
     477                 :            : static int
     478                 :          0 : cn20k_sso_port_setup(struct rte_eventdev *event_dev, uint8_t port_id,
     479                 :            :                      const struct rte_event_port_conf *port_conf)
     480                 :            : {
     481                 :            : 
     482                 :            :         RTE_SET_USED(port_conf);
     483                 :          0 :         return cnxk_sso_port_setup(event_dev, port_id, cn20k_sso_hws_setup);
     484                 :            : }
     485                 :            : 
     486                 :            : static void
     487         [ #  # ]:          0 : cn20k_sso_port_release(void *port)
     488                 :            : {
     489                 :            :         struct cnxk_sso_hws_cookie *gws_cookie = cnxk_sso_hws_get_cookie(port);
     490                 :            :         struct cnxk_sso_evdev *dev;
     491                 :            : 
     492         [ #  # ]:          0 :         if (port == NULL)
     493                 :            :                 return;
     494                 :            : 
     495         [ #  # ]:          0 :         dev = cnxk_sso_pmd_priv(gws_cookie->event_dev);
     496         [ #  # ]:          0 :         if (!gws_cookie->configured)
     497                 :          0 :                 goto free;
     498                 :            : 
     499                 :          0 :         cn20k_sso_hws_release(dev, port);
     500                 :            :         memset(gws_cookie, 0, sizeof(*gws_cookie));
     501                 :          0 : free:
     502                 :          0 :         rte_free(gws_cookie);
     503                 :            : }
     504                 :            : 
     505                 :            : static void
     506                 :          0 : cn20k_sso_port_quiesce(struct rte_eventdev *event_dev, void *port,
     507                 :            :                        rte_eventdev_port_flush_t flush_cb, void *args)
     508                 :            : {
     509                 :          0 :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
     510                 :            :         struct cn20k_sso_hws *ws = port;
     511                 :            :         struct rte_event ev;
     512                 :            :         uint64_t ptag;
     513                 :            :         bool is_pend;
     514                 :            : 
     515                 :            :         is_pend = false;
     516                 :            :         /* Work in WQE0 is always consumed, unless its a SWTAG. */
     517         [ #  # ]:          0 :         ptag = plt_read64(ws->base + SSOW_LF_GWS_PENDSTATE);
     518   [ #  #  #  # ]:          0 :         if (ptag & (BIT_ULL(62) | BIT_ULL(54)) || ws->swtag_req)
     519                 :            :                 is_pend = true;
     520                 :            :         do {
     521                 :            :                 ptag = plt_read64(ws->base + SSOW_LF_GWS_PENDSTATE);
     522         [ #  # ]:          0 :         } while (ptag & (BIT_ULL(62) | BIT_ULL(58) | BIT_ULL(56) | BIT_ULL(54)));
     523                 :            : 
     524                 :            :         cn20k_sso_hws_get_work_empty(ws, &ev,
     525                 :            :                                      (NIX_RX_OFFLOAD_MAX - 1) | NIX_RX_REAS_F | NIX_RX_MULTI_SEG_F);
     526   [ #  #  #  # ]:          0 :         if (is_pend && ev.u64)
     527         [ #  # ]:          0 :                 if (flush_cb)
     528                 :          0 :                         flush_cb(event_dev->data->dev_id, ev, args);
     529         [ #  # ]:          0 :         ptag = (plt_read64(ws->base + SSOW_LF_GWS_TAG) >> 32) & SSO_TT_EMPTY;
     530         [ #  # ]:          0 :         if (ptag != SSO_TT_EMPTY)
     531                 :            :                 cnxk_sso_hws_swtag_flush(ws->base);
     532                 :            : 
     533                 :            :         do {
     534         [ #  # ]:          0 :                 ptag = plt_read64(ws->base + SSOW_LF_GWS_PENDSTATE);
     535         [ #  # ]:          0 :         } while (ptag & BIT_ULL(56));
     536                 :            : 
     537                 :            :         /* Check if we have work in PRF_WQE0, if so extract it. */
     538         [ #  # ]:          0 :         switch (dev->gw_mode) {
     539                 :            :         case CNXK_GW_MODE_PREF:
     540                 :            :         case CNXK_GW_MODE_PREF_WFE:
     541         [ #  # ]:          0 :                 while (plt_read64(ws->base + SSOW_LF_GWS_PRF_WQE0) & BIT_ULL(63))
     542                 :            :                         ;
     543                 :            :                 break;
     544                 :            :         case CNXK_GW_MODE_NONE:
     545                 :            :         default:
     546                 :            :                 break;
     547                 :            :         }
     548                 :            : 
     549         [ #  # ]:          0 :         if (CNXK_TT_FROM_TAG(plt_read64(ws->base + SSOW_LF_GWS_PRF_WQE0)) != SSO_TT_EMPTY) {
     550                 :          0 :                 plt_write64(BIT_ULL(16) | 1, ws->base + SSOW_LF_GWS_OP_GET_WORK0);
     551                 :            :                 cn20k_sso_hws_get_work_empty(
     552                 :            :                         ws, &ev, (NIX_RX_OFFLOAD_MAX - 1) | NIX_RX_REAS_F | NIX_RX_MULTI_SEG_F);
     553         [ #  # ]:          0 :                 if (ev.u64) {
     554         [ #  # ]:          0 :                         if (flush_cb)
     555                 :          0 :                                 flush_cb(event_dev->data->dev_id, ev, args);
     556                 :            :                 }
     557                 :          0 :                 cnxk_sso_hws_swtag_flush(ws->base);
     558                 :            :                 do {
     559         [ #  # ]:          0 :                         ptag = plt_read64(ws->base + SSOW_LF_GWS_PENDSTATE);
     560         [ #  # ]:          0 :                 } while (ptag & BIT_ULL(56));
     561                 :            :         }
     562                 :          0 :         ws->swtag_req = 0;
     563                 :          0 :         plt_write64(0, ws->base + SSOW_LF_GWS_OP_GWC_INVAL);
     564                 :          0 : }
     565                 :            : 
     566                 :            : static int
     567                 :          0 : cn20k_sso_port_link_profile(struct rte_eventdev *event_dev, void *port, const uint8_t queues[],
     568                 :            :                             const uint8_t priorities[], uint16_t nb_links, uint8_t profile)
     569                 :          0 : {
     570                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
     571                 :          0 :         uint16_t hwgrp_ids[nb_links];
     572                 :            :         uint16_t link;
     573                 :            : 
     574                 :            :         RTE_SET_USED(priorities);
     575         [ #  # ]:          0 :         for (link = 0; link < nb_links; link++)
     576                 :          0 :                 hwgrp_ids[link] = queues[link];
     577                 :          0 :         nb_links = cn20k_sso_hws_link(dev, port, hwgrp_ids, nb_links, profile);
     578                 :            : 
     579                 :          0 :         return (int)nb_links;
     580                 :            : }
     581                 :            : 
     582                 :            : static int
     583                 :          0 : cn20k_sso_port_unlink_profile(struct rte_eventdev *event_dev, void *port, uint8_t queues[],
     584                 :            :                               uint16_t nb_unlinks, uint8_t profile)
     585                 :          0 : {
     586                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
     587                 :          0 :         uint16_t hwgrp_ids[nb_unlinks];
     588                 :            :         uint16_t unlink;
     589                 :            : 
     590         [ #  # ]:          0 :         for (unlink = 0; unlink < nb_unlinks; unlink++)
     591                 :          0 :                 hwgrp_ids[unlink] = queues[unlink];
     592                 :          0 :         nb_unlinks = cn20k_sso_hws_unlink(dev, port, hwgrp_ids, nb_unlinks, profile);
     593                 :            : 
     594                 :          0 :         return (int)nb_unlinks;
     595                 :            : }
     596                 :            : 
     597                 :            : static int
     598                 :          0 : cn20k_sso_port_link(struct rte_eventdev *event_dev, void *port, const uint8_t queues[],
     599                 :            :                     const uint8_t priorities[], uint16_t nb_links)
     600                 :            : {
     601                 :          0 :         return cn20k_sso_port_link_profile(event_dev, port, queues, priorities, nb_links, 0);
     602                 :            : }
     603                 :            : 
     604                 :            : static int
     605                 :          0 : cn20k_sso_port_unlink(struct rte_eventdev *event_dev, void *port, uint8_t queues[],
     606                 :            :                       uint16_t nb_unlinks)
     607                 :            : {
     608                 :          0 :         return cn20k_sso_port_unlink_profile(event_dev, port, queues, nb_unlinks, 0);
     609                 :            : }
     610                 :            : 
     611                 :            : static int
     612                 :          0 : cn20k_sso_start(struct rte_eventdev *event_dev)
     613                 :            : {
     614                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
     615                 :            :         uint8_t hws[RTE_EVENT_MAX_PORTS_PER_DEV];
     616                 :            :         int rc, i;
     617                 :            : 
     618                 :          0 :         cnxk_sso_configure_queue_stash(event_dev);
     619                 :          0 :         rc = cnxk_sso_start(event_dev, cnxk_sso_hws_reset, cn20k_sso_hws_flush_events);
     620         [ #  # ]:          0 :         if (rc < 0)
     621                 :            :                 return rc;
     622                 :            :         cn20k_sso_fp_fns_set(event_dev);
     623         [ #  # ]:          0 :         for (i = 0; i < event_dev->data->nb_ports; i++)
     624                 :          0 :                 hws[i] = i;
     625                 :          0 :         roc_sso_hws_gwc_invalidate(&dev->sso, hws, event_dev->data->nb_ports);
     626                 :            : 
     627                 :          0 :         return rc;
     628                 :            : }
     629                 :            : 
     630                 :            : static void
     631                 :          0 : cn20k_sso_stop(struct rte_eventdev *event_dev)
     632                 :            : {
     633                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
     634                 :            :         uint8_t hws[RTE_EVENT_MAX_PORTS_PER_DEV];
     635                 :            :         int i;
     636                 :            : 
     637         [ #  # ]:          0 :         for (i = 0; i < event_dev->data->nb_ports; i++)
     638                 :          0 :                 hws[i] = i;
     639                 :          0 :         roc_sso_hws_gwc_invalidate(&dev->sso, hws, event_dev->data->nb_ports);
     640                 :          0 :         cnxk_sso_stop(event_dev, cnxk_sso_hws_reset, cn20k_sso_hws_flush_events);
     641                 :          0 : }
     642                 :            : 
     643                 :            : static int
     644                 :          0 : cn20k_sso_close(struct rte_eventdev *event_dev)
     645                 :            : {
     646                 :          0 :         return cnxk_sso_close(event_dev, cn20k_sso_hws_unlink);
     647                 :            : }
     648                 :            : 
     649                 :            : static int
     650                 :          0 : cn20k_sso_selftest(void)
     651                 :            : {
     652                 :          0 :         return cnxk_sso_selftest(RTE_STR(event_cn20k));
     653                 :            : }
     654                 :            : 
     655                 :            : static int
     656                 :          0 : cn20k_sso_rx_adapter_caps_get(const struct rte_eventdev *event_dev,
     657                 :            :                               const struct rte_eth_dev *eth_dev, uint32_t *caps)
     658                 :            : {
     659                 :            :         int rc;
     660                 :            : 
     661                 :            :         RTE_SET_USED(event_dev);
     662                 :          0 :         rc = strncmp(eth_dev->device->driver->name, "net_cn20k", 9);
     663         [ #  # ]:          0 :         if (rc)
     664                 :          0 :                 *caps = RTE_EVENT_ETH_RX_ADAPTER_SW_CAP;
     665                 :            :         else
     666                 :          0 :                 *caps = RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT |
     667                 :            :                         RTE_EVENT_ETH_RX_ADAPTER_CAP_MULTI_EVENTQ |
     668                 :            :                         RTE_EVENT_ETH_RX_ADAPTER_CAP_OVERRIDE_FLOW_ID |
     669                 :            :                         RTE_EVENT_ETH_RX_ADAPTER_CAP_EVENT_VECTOR;
     670                 :            : 
     671                 :          0 :         return 0;
     672                 :            : }
     673                 :            : 
     674                 :            : static void
     675                 :          0 : cn20k_sso_set_priv_mem(const struct rte_eventdev *event_dev, void *lookup_mem)
     676                 :            : {
     677                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
     678                 :            :         int i;
     679                 :            : 
     680   [ #  #  #  #  :          0 :         for (i = 0; i < dev->nb_event_ports; i++) {
             #  #  #  # ]
     681                 :          0 :                 struct cn20k_sso_hws *ws = event_dev->data->ports[i];
     682                 :          0 :                 ws->xaq_lmt = dev->xaq_lmt;
     683                 :          0 :                 ws->fc_mem = (int64_t __rte_atomic *)dev->fc_iova;
     684                 :          0 :                 ws->tstamp = dev->tstamp;
     685   [ #  #  #  #  :          0 :                 if (lookup_mem)
                   #  # ]
     686                 :          0 :                         ws->lookup_mem = lookup_mem;
     687                 :            :         }
     688                 :          0 : }
     689                 :            : 
     690                 :            : static void
     691                 :            : eventdev_fops_tstamp_update(struct rte_eventdev *event_dev)
     692                 :            : {
     693                 :          0 :         struct rte_event_fp_ops *fp_op = rte_event_fp_ops + event_dev->data->dev_id;
     694                 :            : 
     695                 :          0 :         fp_op->dequeue_burst = event_dev->dequeue_burst;
     696                 :            : }
     697                 :            : 
     698                 :            : static void
     699                 :          0 : cn20k_sso_tstamp_hdl_update(uint16_t port_id, uint16_t flags, bool ptp_en)
     700                 :            : {
     701                 :          0 :         struct rte_eth_dev *dev = &rte_eth_devices[port_id];
     702                 :          0 :         struct cnxk_eth_dev *cnxk_eth_dev = dev->data->dev_private;
     703         [ #  # ]:          0 :         struct rte_eventdev *event_dev = cnxk_eth_dev->evdev_priv;
     704                 :            :         struct cnxk_sso_evdev *evdev = cnxk_sso_pmd_priv(event_dev);
     705                 :            : 
     706                 :          0 :         evdev->rx_offloads |= flags;
     707         [ #  # ]:          0 :         if (ptp_en)
     708                 :          0 :                 evdev->tstamp[port_id] = &cnxk_eth_dev->tstamp;
     709                 :            :         else
     710                 :          0 :                 evdev->tstamp[port_id] = NULL;
     711                 :            :         cn20k_sso_fp_fns_set((struct rte_eventdev *)(uintptr_t)event_dev);
     712                 :            :         eventdev_fops_tstamp_update(event_dev);
     713                 :          0 : }
     714                 :            : 
     715                 :            : static int
     716                 :          0 : cn20k_sso_rxq_enable(struct cnxk_eth_dev *cnxk_eth_dev, uint16_t rq_id, uint16_t port_id,
     717                 :            :                      const struct rte_event_eth_rx_adapter_queue_conf *queue_conf, int agq)
     718                 :            : {
     719                 :            :         struct roc_nix_rq *rq;
     720                 :            :         uint32_t tag_mask;
     721                 :            :         uint16_t wqe_skip;
     722                 :            :         uint8_t tt;
     723                 :            :         int rc;
     724                 :            : 
     725                 :          0 :         rq = &cnxk_eth_dev->rqs[rq_id];
     726         [ #  # ]:          0 :         if (queue_conf->rx_queue_flags & RTE_EVENT_ETH_RX_ADAPTER_QUEUE_EVENT_VECTOR) {
     727                 :          0 :                 tag_mask = agq;
     728                 :            :                 tt = SSO_TT_AGG;
     729                 :          0 :                 rq->flow_tag_width = 0;
     730                 :            :         } else {
     731                 :          0 :                 tag_mask = (port_id & 0xFF) << 20;
     732                 :            :                 tag_mask |= (RTE_EVENT_TYPE_ETHDEV << 28);
     733                 :          0 :                 tt = queue_conf->ev.sched_type;
     734                 :          0 :                 rq->flow_tag_width = 20;
     735         [ #  # ]:          0 :                 if (queue_conf->rx_queue_flags & RTE_EVENT_ETH_RX_ADAPTER_QUEUE_FLOW_ID_VALID) {
     736                 :          0 :                         rq->flow_tag_width = 0;
     737                 :          0 :                         tag_mask |= queue_conf->ev.flow_id;
     738                 :            :                 }
     739                 :            :         }
     740                 :            : 
     741                 :          0 :         rq->tag_mask = tag_mask;
     742                 :          0 :         rq->sso_ena = 1;
     743                 :          0 :         rq->tt = tt;
     744                 :          0 :         rq->hwgrp = queue_conf->ev.queue_id;
     745                 :            :         wqe_skip = RTE_ALIGN_CEIL(sizeof(struct rte_mbuf), ROC_CACHE_LINE_SZ);
     746                 :            :         wqe_skip = wqe_skip / ROC_CACHE_LINE_SZ;
     747                 :          0 :         rq->wqe_skip = wqe_skip;
     748                 :            : 
     749                 :          0 :         rc = roc_nix_rq_modify(&cnxk_eth_dev->nix, rq, 0);
     750                 :          0 :         return rc;
     751                 :            : }
     752                 :            : 
     753                 :            : static int
     754                 :          0 : cn20k_sso_rx_adapter_vwqe_enable(struct cnxk_sso_evdev *dev, uint16_t port_id, uint16_t rq_id,
     755                 :            :                                  const struct rte_event_eth_rx_adapter_queue_conf *queue_conf)
     756                 :            : {
     757                 :            :         uint32_t agq, tag_mask, stag_mask;
     758                 :            :         struct roc_sso_agq_data data;
     759                 :            :         int rc;
     760                 :            : 
     761                 :          0 :         tag_mask = (port_id & 0xff) << 20;
     762         [ #  # ]:          0 :         if (queue_conf->rx_queue_flags & RTE_EVENT_ETH_RX_ADAPTER_QUEUE_FLOW_ID_VALID)
     763                 :          0 :                 tag_mask |= queue_conf->ev.flow_id;
     764                 :            :         else
     765                 :          0 :                 tag_mask |= rq_id;
     766                 :            : 
     767                 :            :         stag_mask = tag_mask;
     768         [ #  # ]:          0 :         tag_mask |= RTE_EVENT_TYPE_ETHDEV_VECTOR << 28;
     769                 :            :         stag_mask |= RTE_EVENT_TYPE_ETHDEV << 28;
     770                 :            : 
     771                 :            :         memset(&data, 0, sizeof(struct roc_sso_agq_data));
     772                 :          0 :         data.tag = tag_mask;
     773                 :          0 :         data.tt = queue_conf->ev.sched_type;
     774                 :          0 :         data.stag = stag_mask;
     775         [ #  # ]:          0 :         data.vwqe_aura = roc_npa_aura_handle_to_aura(queue_conf->vector_mp->pool_id);
     776         [ #  # ]:          0 :         data.vwqe_max_sz_exp = rte_log2_u32(queue_conf->vector_sz);
     777                 :          0 :         data.vwqe_wait_tmo = queue_conf->vector_timeout_ns / ((SSO_AGGR_DEF_TMO + 1) * 100);
     778                 :            :         data.xqe_type = 0;
     779                 :            : 
     780                 :          0 :         agq = UINT32_MAX;
     781                 :          0 :         rc = roc_sso_hwgrp_agq_alloc(&dev->sso, queue_conf->ev.queue_id, &data, &agq);
     782         [ #  # ]:          0 :         if (rc < 0)
     783                 :            :                 return rc;
     784                 :            : 
     785                 :          0 :         return agq;
     786                 :            : }
     787                 :            : 
     788                 :            : static int
     789                 :          0 : cn20k_rx_adapter_queue_del(const struct rte_eventdev *event_dev, const struct rte_eth_dev *eth_dev,
     790                 :            :                            int32_t rx_queue_id)
     791                 :            : {
     792         [ #  # ]:          0 :         struct cnxk_eth_dev *cnxk_eth_dev = eth_dev->data->dev_private;
     793                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
     794                 :            :         struct roc_nix_rq *rxq;
     795                 :            :         int i, rc = 0;
     796                 :            : 
     797                 :            :         RTE_SET_USED(event_dev);
     798         [ #  # ]:          0 :         if (rx_queue_id < 0) {
     799         [ #  # ]:          0 :                 for (i = 0; i < eth_dev->data->nb_rx_queues; i++)
     800                 :          0 :                         cn20k_rx_adapter_queue_del(event_dev, eth_dev, i);
     801                 :            :         } else {
     802                 :          0 :                 rxq = &cnxk_eth_dev->rqs[rx_queue_id];
     803         [ #  # ]:          0 :                 if (rxq->tt == SSO_TT_AGG)
     804                 :          0 :                         roc_sso_hwgrp_agq_free(&dev->sso, rxq->hwgrp, rxq->tag_mask);
     805                 :          0 :                 rc = cnxk_sso_rxq_disable(eth_dev, (uint16_t)rx_queue_id);
     806                 :          0 :                 cnxk_eth_dev->nb_rxq_sso--;
     807                 :            :         }
     808                 :            : 
     809         [ #  # ]:          0 :         if (rc < 0)
     810                 :          0 :                 plt_err("Failed to clear Rx adapter config port=%d, q=%d", eth_dev->data->port_id,
     811                 :            :                         rx_queue_id);
     812                 :          0 :         return rc;
     813                 :            : }
     814                 :            : 
     815                 :            : static int
     816                 :          0 : cn20k_rx_adapter_queues_add(const struct rte_eventdev *event_dev, const struct rte_eth_dev *eth_dev,
     817                 :            :                             int32_t rx_queue_id[],
     818                 :            :                             const struct rte_event_eth_rx_adapter_queue_conf queue_conf[],
     819                 :            :                             uint16_t nb_rx_queues)
     820                 :            : {
     821         [ #  # ]:          0 :         struct cnxk_eth_dev *cnxk_eth_dev = eth_dev->data->dev_private;
     822                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
     823                 :            :         const struct rte_event_eth_rx_adapter_queue_conf *conf;
     824                 :          0 :         uint64_t old_xae_cnt = dev->adptr_xae_cnt;
     825                 :          0 :         uint16_t port = eth_dev->data->port_id;
     826                 :            :         struct cnxk_eth_rxq_sp *rxq_sp;
     827                 :            :         uint16_t max_rx_queues;
     828                 :            :         int i, rc = 0, agq = 0;
     829                 :            :         int32_t queue_id;
     830                 :            : 
     831         [ #  # ]:          0 :         max_rx_queues = nb_rx_queues ? nb_rx_queues : eth_dev->data->nb_rx_queues;
     832         [ #  # ]:          0 :         for (i = 0; i < max_rx_queues; i++) {
     833         [ #  # ]:          0 :                 conf = nb_rx_queues ? &queue_conf[i] : &queue_conf[0];
     834         [ #  # ]:          0 :                 queue_id = nb_rx_queues ? rx_queue_id[i] : i;
     835                 :          0 :                 rxq_sp = cnxk_eth_rxq_to_sp(eth_dev->data->rx_queues[queue_id]);
     836                 :          0 :                 cnxk_sso_updt_xae_cnt(dev, rxq_sp, RTE_EVENT_TYPE_ETHDEV);
     837                 :            : 
     838         [ #  # ]:          0 :                 if (conf->rx_queue_flags & RTE_EVENT_ETH_RX_ADAPTER_QUEUE_EVENT_VECTOR)
     839                 :          0 :                         cnxk_sso_updt_xae_cnt(dev, conf->vector_mp, RTE_EVENT_TYPE_ETHDEV_VECTOR);
     840                 :            :         }
     841                 :            : 
     842         [ #  # ]:          0 :         if (dev->adptr_xae_cnt != old_xae_cnt) {
     843                 :          0 :                 rc = cnxk_sso_xae_reconfigure((struct rte_eventdev *)(uintptr_t)event_dev);
     844         [ #  # ]:          0 :                 if (rc < 0)
     845                 :            :                         return rc;
     846                 :            :         }
     847                 :            : 
     848         [ #  # ]:          0 :         for (i = 0; i < max_rx_queues; i++) {
     849         [ #  # ]:          0 :                 conf = nb_rx_queues ? &queue_conf[i] : &queue_conf[0];
     850         [ #  # ]:          0 :                 queue_id = nb_rx_queues ? rx_queue_id[i] : i;
     851         [ #  # ]:          0 :                 if (conf->rx_queue_flags & RTE_EVENT_ETH_RX_ADAPTER_QUEUE_EVENT_VECTOR) {
     852                 :          0 :                         rc = cn20k_sso_rx_adapter_vwqe_enable(dev, port, queue_id, conf);
     853         [ #  # ]:          0 :                         if (rc < 0) {
     854                 :          0 :                                 plt_err("Failed to enable VWQE, port=%d, rxq=%d", port, queue_id);
     855                 :          0 :                                 goto fail;
     856                 :            :                         }
     857                 :            : 
     858                 :            :                         agq = rc;
     859                 :            :                 }
     860                 :            : 
     861                 :          0 :                 rc = cn20k_sso_rxq_enable(cnxk_eth_dev, (uint16_t)queue_id, port, conf, agq);
     862         [ #  # ]:          0 :                 if (rc < 0) {
     863                 :          0 :                         plt_err("Failed to enable Rx queue, port=%d, rxq=%d", port, queue_id);
     864                 :          0 :                         goto fail;
     865                 :            :                 }
     866                 :            : 
     867                 :          0 :                 cnxk_eth_dev->nb_rxq_sso++;
     868                 :            :         }
     869                 :            : 
     870                 :            :         /* Propagate force bp devarg */
     871                 :          0 :         cnxk_eth_dev->nix.force_rx_aura_bp = dev->force_ena_bp;
     872                 :          0 :         cnxk_sso_tstamp_cfg(port, eth_dev, dev);
     873                 :          0 :         dev->rx_offloads |= cnxk_eth_dev->rx_offload_flags;
     874                 :          0 :         return 0;
     875                 :            : 
     876                 :          0 : fail:
     877         [ #  # ]:          0 :         for (i = cnxk_eth_dev->nb_rxq_sso - 1; i >= 0; i--) {
     878         [ #  # ]:          0 :                 queue_id = nb_rx_queues ? rx_queue_id[i] : i;
     879                 :          0 :                 cn20k_rx_adapter_queue_del(event_dev, eth_dev, queue_id);
     880                 :            :         }
     881                 :            : 
     882                 :            :         return rc;
     883                 :            : }
     884                 :            : 
     885                 :            : static int
     886                 :          0 : cn20k_sso_configure_queue_stash_default(struct cnxk_sso_evdev *dev, uint16_t hwgrp)
     887                 :            : {
     888                 :            :         struct roc_sso_hwgrp_stash stash;
     889                 :            :         int rc;
     890                 :            : 
     891                 :          0 :         stash.hwgrp = hwgrp;
     892                 :          0 :         stash.stash_offset = CN20K_SSO_DEFAULT_STASH_OFFSET;
     893                 :          0 :         stash.stash_count = CN20K_SSO_DEFAULT_STASH_LENGTH;
     894                 :          0 :         rc = roc_sso_hwgrp_stash_config(&dev->sso, &stash, 1);
     895         [ #  # ]:          0 :         if (rc < 0)
     896                 :          0 :                 plt_warn("failed to configure HWGRP WQE stashing rc = %d", rc);
     897                 :            : 
     898                 :          0 :         return rc;
     899                 :            : }
     900                 :            : 
     901                 :            : static int
     902                 :          0 : cn20k_sso_rx_adapter_queue_add(const struct rte_eventdev *event_dev,
     903                 :            :                                const struct rte_eth_dev *eth_dev, int32_t rx_queue_id,
     904                 :            :                                const struct rte_event_eth_rx_adapter_queue_conf *queue_conf)
     905                 :            : {
     906         [ #  # ]:          0 :         struct cnxk_eth_dev *cnxk_eth_dev = eth_dev->data->dev_private;
     907                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
     908                 :            :         struct cn20k_eth_rxq *rxq;
     909                 :            :         uint16_t nb_rx_queues;
     910                 :            :         void *lookup_mem;
     911                 :            :         int rc;
     912                 :            : 
     913                 :          0 :         rc = strncmp(eth_dev->device->driver->name, "net_cn20k", 8);
     914         [ #  # ]:          0 :         if (rc)
     915                 :            :                 return -EINVAL;
     916                 :            : 
     917                 :          0 :         nb_rx_queues = rx_queue_id == -1 ? 0 : 1;
     918                 :          0 :         rc = cn20k_rx_adapter_queues_add(event_dev, eth_dev, &rx_queue_id, queue_conf,
     919                 :            :                                          nb_rx_queues);
     920         [ #  # ]:          0 :         if (rc)
     921                 :            :                 return -EINVAL;
     922                 :            : 
     923                 :          0 :         cnxk_eth_dev->cnxk_sso_ptp_tstamp_cb = cn20k_sso_tstamp_hdl_update;
     924                 :          0 :         cnxk_eth_dev->evdev_priv = (struct rte_eventdev *)(uintptr_t)event_dev;
     925                 :            : 
     926                 :          0 :         rxq = eth_dev->data->rx_queues[0];
     927                 :          0 :         lookup_mem = rxq->lookup_mem;
     928                 :            :         cn20k_sso_set_priv_mem(event_dev, lookup_mem);
     929                 :            :         cn20k_sso_fp_fns_set((struct rte_eventdev *)(uintptr_t)event_dev);
     930   [ #  #  #  # ]:          0 :         if (roc_feature_sso_has_stash() && dev->nb_event_ports > 1)
     931                 :          0 :                 rc = cn20k_sso_configure_queue_stash_default(dev, queue_conf->ev.queue_id);
     932                 :            : 
     933                 :            :         return rc;
     934                 :            : }
     935                 :            : 
     936                 :            : static int
     937                 :          0 : cn20k_sso_rx_adapter_queues_add(const struct rte_eventdev *event_dev,
     938                 :            :                                 const struct rte_eth_dev *eth_dev, int32_t rx_queue_id[],
     939                 :            :                                 const struct rte_event_eth_rx_adapter_queue_conf queue_conf[],
     940                 :            :                                 uint16_t nb_rx_queues)
     941                 :            : {
     942         [ #  # ]:          0 :         struct cnxk_eth_dev *cnxk_eth_dev = eth_dev->data->dev_private;
     943                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
     944                 :            :         struct cn20k_eth_rxq *rxq;
     945                 :            :         void *lookup_mem;
     946                 :            :         int rc, i;
     947                 :            : 
     948                 :          0 :         rc = strncmp(eth_dev->device->driver->name, "net_cn20k", 8);
     949         [ #  # ]:          0 :         if (rc)
     950                 :            :                 return -EINVAL;
     951                 :            : 
     952                 :          0 :         rc = cn20k_rx_adapter_queues_add(event_dev, eth_dev, rx_queue_id, queue_conf, nb_rx_queues);
     953         [ #  # ]:          0 :         if (rc)
     954                 :            :                 return -EINVAL;
     955                 :            : 
     956                 :          0 :         cnxk_eth_dev->cnxk_sso_ptp_tstamp_cb = cn20k_sso_tstamp_hdl_update;
     957                 :          0 :         cnxk_eth_dev->evdev_priv = (struct rte_eventdev *)(uintptr_t)event_dev;
     958                 :            : 
     959                 :          0 :         rxq = eth_dev->data->rx_queues[0];
     960                 :          0 :         lookup_mem = rxq->lookup_mem;
     961                 :            :         cn20k_sso_set_priv_mem(event_dev, lookup_mem);
     962                 :            :         cn20k_sso_fp_fns_set((struct rte_eventdev *)(uintptr_t)event_dev);
     963   [ #  #  #  # ]:          0 :         if (roc_feature_sso_has_stash() && dev->nb_event_ports > 1) {
     964                 :          0 :                 uint16_t hwgrp = dev->sso.max_hwgrp;
     965                 :            : 
     966         [ #  # ]:          0 :                 if (nb_rx_queues == 0)
     967                 :          0 :                         rc = cn20k_sso_configure_queue_stash_default(dev,
     968                 :          0 :                                                                      queue_conf[0].ev.queue_id);
     969                 :            : 
     970         [ #  # ]:          0 :                 for (i = 0; i < nb_rx_queues; i++) {
     971         [ #  # ]:          0 :                         if (hwgrp == queue_conf[i].ev.queue_id)
     972                 :          0 :                                 continue;
     973                 :            : 
     974                 :            :                         hwgrp = queue_conf[i].ev.queue_id;
     975                 :          0 :                         rc = cn20k_sso_configure_queue_stash_default(dev, hwgrp);
     976         [ #  # ]:          0 :                         if (rc < 0)
     977                 :            :                                 break;
     978                 :            :                 }
     979                 :            :         }
     980                 :            : 
     981                 :            :         return rc;
     982                 :            : }
     983                 :            : 
     984                 :            : static int
     985                 :          0 : cn20k_sso_rx_adapter_queue_del(const struct rte_eventdev *event_dev,
     986                 :            :                                const struct rte_eth_dev *eth_dev, int32_t rx_queue_id)
     987                 :            : {
     988                 :            :         int rc;
     989                 :            : 
     990                 :          0 :         rc = strncmp(eth_dev->device->driver->name, "net_cn20k", 8);
     991         [ #  # ]:          0 :         if (rc)
     992                 :            :                 return -EINVAL;
     993                 :            : 
     994                 :          0 :         return cn20k_rx_adapter_queue_del(event_dev, eth_dev, rx_queue_id);
     995                 :            : }
     996                 :            : 
     997                 :            : static int
     998                 :          0 : cn20k_sso_rx_adapter_vector_limits(const struct rte_eventdev *dev,
     999                 :            :                                    const struct rte_eth_dev *eth_dev,
    1000                 :            :                                    struct rte_event_eth_rx_adapter_vector_limits *limits)
    1001                 :            : {
    1002                 :            :         int ret;
    1003                 :            : 
    1004                 :            :         RTE_SET_USED(dev);
    1005                 :            :         RTE_SET_USED(eth_dev);
    1006                 :          0 :         ret = strncmp(eth_dev->device->driver->name, "net_cn20k", 8);
    1007         [ #  # ]:          0 :         if (ret)
    1008                 :            :                 return -ENOTSUP;
    1009                 :            : 
    1010                 :          0 :         limits->log2_sz = true;
    1011                 :          0 :         limits->min_sz = 1 << ROC_NIX_VWQE_MIN_SIZE_LOG2;
    1012                 :          0 :         limits->max_sz = 1 << ROC_NIX_VWQE_MAX_SIZE_LOG2;
    1013                 :          0 :         limits->min_timeout_ns = (SSO_AGGR_DEF_TMO + 1) * 100;
    1014                 :          0 :         limits->max_timeout_ns = (BITMASK_ULL(11, 0) + 1) * limits->min_timeout_ns;
    1015                 :            : 
    1016                 :          0 :         return 0;
    1017                 :            : }
    1018                 :            : 
    1019                 :            : static int
    1020                 :          0 : cn20k_sso_tx_adapter_caps_get(const struct rte_eventdev *dev, const struct rte_eth_dev *eth_dev,
    1021                 :            :                               uint32_t *caps)
    1022                 :            : {
    1023                 :            :         int ret;
    1024                 :            : 
    1025                 :            :         RTE_SET_USED(dev);
    1026                 :          0 :         ret = strncmp(eth_dev->device->driver->name, "net_cn20k", 8);
    1027         [ #  # ]:          0 :         if (ret)
    1028                 :          0 :                 *caps = 0;
    1029                 :            :         else
    1030                 :          0 :                 *caps = RTE_EVENT_ETH_TX_ADAPTER_CAP_INTERNAL_PORT |
    1031                 :            :                         RTE_EVENT_ETH_TX_ADAPTER_CAP_EVENT_VECTOR;
    1032                 :            : 
    1033                 :          0 :         return 0;
    1034                 :            : }
    1035                 :            : 
    1036                 :            : static void
    1037                 :          0 : cn20k_sso_txq_fc_update(const struct rte_eth_dev *eth_dev, int32_t tx_queue_id)
    1038                 :            : {
    1039                 :          0 :         struct cnxk_eth_dev *cnxk_eth_dev = eth_dev->data->dev_private;
    1040                 :            :         struct cn20k_eth_txq *txq;
    1041                 :            :         struct roc_nix_sq *sq;
    1042                 :            :         int i;
    1043                 :            : 
    1044         [ #  # ]:          0 :         if (tx_queue_id < 0) {
    1045         [ #  # ]:          0 :                 for (i = 0; i < eth_dev->data->nb_tx_queues; i++)
    1046                 :          0 :                         cn20k_sso_txq_fc_update(eth_dev, i);
    1047                 :            :         } else {
    1048                 :            :                 uint16_t sqes_per_sqb;
    1049                 :            : 
    1050                 :          0 :                 sq = &cnxk_eth_dev->sqs[tx_queue_id];
    1051                 :          0 :                 txq = eth_dev->data->tx_queues[tx_queue_id];
    1052                 :          0 :                 sqes_per_sqb = 1U << txq->sqes_per_sqb_log2;
    1053         [ #  # ]:          0 :                 if (cnxk_eth_dev->tx_offloads & RTE_ETH_TX_OFFLOAD_SECURITY)
    1054                 :          0 :                         sq->nb_sqb_bufs_adj -= (cnxk_eth_dev->outb.nb_desc / sqes_per_sqb);
    1055                 :          0 :                 txq->nb_sqb_bufs_adj = sq->nb_sqb_bufs_adj;
    1056                 :            :         }
    1057                 :          0 : }
    1058                 :            : 
    1059                 :            : static int
    1060                 :          0 : cn20k_sso_tx_adapter_queue_add(uint8_t id, const struct rte_eventdev *event_dev,
    1061                 :            :                                const struct rte_eth_dev *eth_dev, int32_t tx_queue_id)
    1062                 :            : {
    1063                 :          0 :         struct cnxk_eth_dev *cnxk_eth_dev = eth_dev->data->dev_private;
    1064                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
    1065                 :            :         uint64_t tx_offloads;
    1066                 :            :         int rc;
    1067                 :            : 
    1068                 :            :         RTE_SET_USED(id);
    1069                 :          0 :         rc = cnxk_sso_tx_adapter_queue_add(event_dev, eth_dev, tx_queue_id);
    1070         [ #  # ]:          0 :         if (rc < 0)
    1071                 :            :                 return rc;
    1072                 :            : 
    1073                 :            :         /* Can't enable tstamp if all the ports don't have it enabled. */
    1074                 :          0 :         tx_offloads = cnxk_eth_dev->tx_offload_flags;
    1075         [ #  # ]:          0 :         if (dev->tx_adptr_configured) {
    1076                 :          0 :                 uint8_t tstmp_req = !!(tx_offloads & NIX_TX_OFFLOAD_TSTAMP_F);
    1077                 :          0 :                 uint8_t tstmp_ena = !!(dev->tx_offloads & NIX_TX_OFFLOAD_TSTAMP_F);
    1078                 :            : 
    1079         [ #  # ]:          0 :                 if (tstmp_ena && !tstmp_req)
    1080                 :          0 :                         dev->tx_offloads &= ~(NIX_TX_OFFLOAD_TSTAMP_F);
    1081         [ #  # ]:          0 :                 else if (!tstmp_ena && tstmp_req)
    1082                 :          0 :                         tx_offloads &= ~(NIX_TX_OFFLOAD_TSTAMP_F);
    1083                 :            :         }
    1084                 :            : 
    1085                 :          0 :         dev->tx_offloads |= tx_offloads;
    1086                 :          0 :         cn20k_sso_txq_fc_update(eth_dev, tx_queue_id);
    1087                 :          0 :         rc = cn20k_sso_updt_tx_adptr_data(event_dev);
    1088         [ #  # ]:          0 :         if (rc < 0)
    1089                 :            :                 return rc;
    1090                 :            :         cn20k_sso_fp_fns_set((struct rte_eventdev *)(uintptr_t)event_dev);
    1091                 :          0 :         dev->tx_adptr_configured = 1;
    1092                 :            : 
    1093                 :          0 :         return 0;
    1094                 :            : }
    1095                 :            : 
    1096                 :            : static int
    1097                 :          0 : cn20k_sso_tx_adapter_queue_del(uint8_t id, const struct rte_eventdev *event_dev,
    1098                 :            :                                const struct rte_eth_dev *eth_dev, int32_t tx_queue_id)
    1099                 :            : {
    1100                 :            :         int rc;
    1101                 :            : 
    1102                 :            :         RTE_SET_USED(id);
    1103                 :          0 :         rc = cnxk_sso_tx_adapter_queue_del(event_dev, eth_dev, tx_queue_id);
    1104         [ #  # ]:          0 :         if (rc < 0)
    1105                 :            :                 return rc;
    1106                 :          0 :         return cn20k_sso_updt_tx_adptr_data(event_dev);
    1107                 :            : }
    1108                 :            : 
    1109                 :            : static int
    1110                 :          0 : cn20k_crypto_adapter_caps_get(const struct rte_eventdev *event_dev,
    1111                 :            :                               const struct rte_cryptodev *cdev, uint32_t *caps)
    1112                 :            : {
    1113         [ #  # ]:          0 :         CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn20k", ENOTSUP);
    1114         [ #  # ]:          0 :         CNXK_VALID_DEV_OR_ERR_RET(cdev->device, "crypto_cn20k", ENOTSUP);
    1115                 :            : 
    1116                 :          0 :         *caps = RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD |
    1117                 :            :                 RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA |
    1118                 :            :                 RTE_EVENT_CRYPTO_ADAPTER_CAP_EVENT_VECTOR;
    1119                 :            : 
    1120                 :          0 :         return 0;
    1121                 :            : }
    1122                 :            : 
    1123                 :            : static int
    1124                 :          0 : cn20k_crypto_adapter_qp_add(const struct rte_eventdev *event_dev, const struct rte_cryptodev *cdev,
    1125                 :            :                             int32_t queue_pair_id,
    1126                 :            :                             const struct rte_event_crypto_adapter_queue_conf *conf)
    1127                 :            : {
    1128                 :            :         int ret;
    1129                 :            : 
    1130         [ #  # ]:          0 :         CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn20k", EINVAL);
    1131         [ #  # ]:          0 :         CNXK_VALID_DEV_OR_ERR_RET(cdev->device, "crypto_cn20k", EINVAL);
    1132                 :            : 
    1133                 :            :         cn20k_sso_fp_fns_set((struct rte_eventdev *)(uintptr_t)event_dev);
    1134                 :            : 
    1135                 :          0 :         ret = cnxk_crypto_adapter_qp_add(event_dev, cdev, queue_pair_id, conf);
    1136                 :            :         cn20k_sso_set_priv_mem(event_dev, NULL);
    1137                 :            : 
    1138                 :            :         return ret;
    1139                 :            : }
    1140                 :            : 
    1141                 :            : static int
    1142                 :          0 : cn20k_crypto_adapter_qp_del(const struct rte_eventdev *event_dev, const struct rte_cryptodev *cdev,
    1143                 :            :                             int32_t queue_pair_id)
    1144                 :            : {
    1145         [ #  # ]:          0 :         CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn20k", EINVAL);
    1146         [ #  # ]:          0 :         CNXK_VALID_DEV_OR_ERR_RET(cdev->device, "crypto_cn20k", EINVAL);
    1147                 :            : 
    1148                 :          0 :         return cnxk_crypto_adapter_qp_del(cdev, queue_pair_id);
    1149                 :            : }
    1150                 :            : 
    1151                 :            : static int
    1152                 :          0 : cn20k_tim_caps_get(const struct rte_eventdev *evdev, uint64_t flags, uint32_t *caps,
    1153                 :            :                    const struct event_timer_adapter_ops **ops)
    1154                 :            : {
    1155                 :          0 :         return cnxk_tim_caps_get(evdev, flags, caps, ops, cn20k_sso_set_priv_mem);
    1156                 :            : }
    1157                 :            : 
    1158                 :            : static int
    1159                 :          0 : cn20k_crypto_adapter_vec_limits(const struct rte_eventdev *event_dev,
    1160                 :            :                                 const struct rte_cryptodev *cdev,
    1161                 :            :                                 struct rte_event_crypto_adapter_vector_limits *limits)
    1162                 :            : {
    1163         [ #  # ]:          0 :         CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn20k", EINVAL);
    1164         [ #  # ]:          0 :         CNXK_VALID_DEV_OR_ERR_RET(cdev->device, "crypto_cn20k", EINVAL);
    1165                 :            : 
    1166                 :          0 :         limits->log2_sz = false;
    1167                 :          0 :         limits->min_sz = 0;
    1168                 :          0 :         limits->max_sz = UINT16_MAX;
    1169                 :            :         /* Unused timeout, in software implementation we aggregate all crypto
    1170                 :            :          * operations passed to the enqueue function
    1171                 :            :          */
    1172                 :          0 :         limits->min_timeout_ns = 0;
    1173                 :          0 :         limits->max_timeout_ns = 0;
    1174                 :            : 
    1175                 :          0 :         return 0;
    1176                 :            : }
    1177                 :            : 
    1178                 :            : static struct eventdev_ops cn20k_sso_dev_ops = {
    1179                 :            :         .dev_infos_get = cn20k_sso_info_get,
    1180                 :            :         .dev_configure = cn20k_sso_dev_configure,
    1181                 :            : 
    1182                 :            :         .queue_def_conf = cnxk_sso_queue_def_conf,
    1183                 :            :         .queue_setup = cn20k_sso_queue_setup,
    1184                 :            :         .queue_release = cnxk_sso_queue_release,
    1185                 :            :         .queue_attr_set = cn20k_sso_queue_attribute_set,
    1186                 :            : 
    1187                 :            :         .port_def_conf = cnxk_sso_port_def_conf,
    1188                 :            :         .port_setup = cn20k_sso_port_setup,
    1189                 :            :         .port_release = cn20k_sso_port_release,
    1190                 :            :         .port_quiesce = cn20k_sso_port_quiesce,
    1191                 :            :         .port_link = cn20k_sso_port_link,
    1192                 :            :         .port_unlink = cn20k_sso_port_unlink,
    1193                 :            :         .port_link_profile = cn20k_sso_port_link_profile,
    1194                 :            :         .port_unlink_profile = cn20k_sso_port_unlink_profile,
    1195                 :            :         .timeout_ticks = cnxk_sso_timeout_ticks,
    1196                 :            : 
    1197                 :            :         .eth_rx_adapter_caps_get = cn20k_sso_rx_adapter_caps_get,
    1198                 :            :         .eth_rx_adapter_queue_add = cn20k_sso_rx_adapter_queue_add,
    1199                 :            :         .eth_rx_adapter_queues_add = cn20k_sso_rx_adapter_queues_add,
    1200                 :            :         .eth_rx_adapter_queue_del = cn20k_sso_rx_adapter_queue_del,
    1201                 :            :         .eth_rx_adapter_start = cnxk_sso_rx_adapter_start,
    1202                 :            :         .eth_rx_adapter_stop = cnxk_sso_rx_adapter_stop,
    1203                 :            : 
    1204                 :            :         .eth_rx_adapter_vector_limits_get = cn20k_sso_rx_adapter_vector_limits,
    1205                 :            : 
    1206                 :            :         .eth_tx_adapter_caps_get = cn20k_sso_tx_adapter_caps_get,
    1207                 :            :         .eth_tx_adapter_queue_add = cn20k_sso_tx_adapter_queue_add,
    1208                 :            :         .eth_tx_adapter_queue_del = cn20k_sso_tx_adapter_queue_del,
    1209                 :            :         .eth_tx_adapter_start = cnxk_sso_tx_adapter_start,
    1210                 :            :         .eth_tx_adapter_stop = cnxk_sso_tx_adapter_stop,
    1211                 :            :         .eth_tx_adapter_free = cnxk_sso_tx_adapter_free,
    1212                 :            : 
    1213                 :            :         .timer_adapter_caps_get = cn20k_tim_caps_get,
    1214                 :            : 
    1215                 :            :         .crypto_adapter_caps_get = cn20k_crypto_adapter_caps_get,
    1216                 :            :         .crypto_adapter_queue_pair_add = cn20k_crypto_adapter_qp_add,
    1217                 :            :         .crypto_adapter_queue_pair_del = cn20k_crypto_adapter_qp_del,
    1218                 :            :         .crypto_adapter_vector_limits_get = cn20k_crypto_adapter_vec_limits,
    1219                 :            : 
    1220                 :            :         .vector_adapter_caps_get = cnxk_vector_caps_get,
    1221                 :            :         .vector_adapter_info_get = cnxk_vector_info_get,
    1222                 :            : 
    1223                 :            :         .xstats_get = cnxk_sso_xstats_get,
    1224                 :            :         .xstats_reset = cnxk_sso_xstats_reset,
    1225                 :            :         .xstats_get_names = cnxk_sso_xstats_get_names,
    1226                 :            : 
    1227                 :            :         .dump = cnxk_sso_dump,
    1228                 :            :         .dev_start = cn20k_sso_start,
    1229                 :            :         .dev_stop = cn20k_sso_stop,
    1230                 :            :         .dev_close = cn20k_sso_close,
    1231                 :            :         .dev_selftest = cn20k_sso_selftest,
    1232                 :            : };
    1233                 :            : 
    1234                 :            : static int
    1235                 :          0 : cn20k_sso_init(struct rte_eventdev *event_dev)
    1236                 :            : {
    1237                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
    1238                 :            :         int rc;
    1239                 :            : 
    1240                 :          0 :         rc = roc_plt_init();
    1241         [ #  # ]:          0 :         if (rc < 0) {
    1242                 :          0 :                 plt_err("Failed to initialize platform model");
    1243                 :          0 :                 return rc;
    1244                 :            :         }
    1245                 :            : 
    1246                 :          0 :         event_dev->dev_ops = &cn20k_sso_dev_ops;
    1247                 :            :         /* For secondary processes, the primary has done all the work */
    1248         [ #  # ]:          0 :         if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
    1249                 :            :                 cn20k_sso_fp_fns_set(event_dev);
    1250                 :            :                 return 0;
    1251                 :            :         }
    1252                 :            : 
    1253                 :          0 :         rc = cnxk_sso_init(event_dev);
    1254         [ #  # ]:          0 :         if (rc < 0)
    1255                 :            :                 return rc;
    1256                 :            : 
    1257                 :            :         cn20k_sso_set_rsrc(cnxk_sso_pmd_priv(event_dev));
    1258   [ #  #  #  # ]:          0 :         if (!dev->max_event_ports || !dev->max_event_queues) {
    1259                 :          0 :                 plt_err("Not enough eventdev resource queues=%d ports=%d", dev->max_event_queues,
    1260                 :            :                         dev->max_event_ports);
    1261                 :          0 :                 cnxk_sso_fini(event_dev);
    1262                 :          0 :                 return -ENODEV;
    1263                 :            :         }
    1264                 :            : 
    1265                 :          0 :         plt_sso_dbg("Initializing %s max_queues=%d max_ports=%d", event_dev->data->name,
    1266                 :            :                     dev->max_event_queues, dev->max_event_ports);
    1267                 :            : 
    1268                 :          0 :         return 0;
    1269                 :            : }
    1270                 :            : 
    1271                 :            : static int
    1272                 :          0 : cn20k_sso_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
    1273                 :            : {
    1274                 :          0 :         return rte_event_pmd_pci_probe(pci_drv, pci_dev, sizeof(struct cnxk_sso_evdev),
    1275                 :            :                                        cn20k_sso_init);
    1276                 :            : }
    1277                 :            : 
    1278                 :            : static const struct rte_pci_id cn20k_pci_sso_map[] = {
    1279                 :            :         CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CN20KA, PCI_DEVID_CNXK_RVU_SSO_TIM_PF),
    1280                 :            :         CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CN20KA, PCI_DEVID_CNXK_RVU_SSO_TIM_VF),
    1281                 :            :         {
    1282                 :            :                 .vendor_id = 0,
    1283                 :            :         },
    1284                 :            : };
    1285                 :            : 
    1286                 :            : static struct rte_pci_driver cn20k_pci_sso = {
    1287                 :            :         .id_table = cn20k_pci_sso_map,
    1288                 :            :         .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_NEED_IOVA_AS_VA,
    1289                 :            :         .probe = cn20k_sso_probe,
    1290                 :            :         .remove = cnxk_sso_remove,
    1291                 :            : };
    1292                 :            : 
    1293                 :        253 : RTE_PMD_REGISTER_PCI(event_cn20k, cn20k_pci_sso);
    1294                 :            : RTE_PMD_REGISTER_PCI_TABLE(event_cn20k, cn20k_pci_sso_map);
    1295                 :            : RTE_PMD_REGISTER_KMOD_DEP(event_cn20k, "vfio-pci");
    1296                 :            : RTE_PMD_REGISTER_PARAM_STRING(event_cn20k,
    1297                 :            :                               CNXK_SSO_XAE_CNT "=<int>"
    1298                 :            :                               CNXK_SSO_GGRP_QOS "=<string>"
    1299                 :            :                               CNXK_SSO_STASH "=<string>"
    1300                 :            :                               CNXK_SSO_FORCE_BP "=1"
    1301                 :            :                               CNXK_TIM_DISABLE_NPA "=1"
    1302                 :            :                               CNXK_TIM_CHNK_SLOTS "=<int>"
    1303                 :            :                               CNXK_TIM_RINGS_LMT "=<int>"
    1304                 :            :                               CNXK_TIM_STATS_ENA "=1"
    1305                 :            :                               CNXK_TIM_EXT_CLK "=<string>");

Generated by: LCOV version 1.14