LCOV - code coverage report
Current view: top level - drivers/event/cnxk - cn10k_eventdev.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 1 366 0.3 %
Date: 2024-04-01 19:00:53 Functions: 1 43 2.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 233 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(C) 2021 Marvell.
       3                 :            :  */
       4                 :            : 
       5                 :            : #include "cn10k_tx_worker.h"
       6                 :            : #include "cn10k_worker.h"
       7                 :            : #include "cn10k_ethdev.h"
       8                 :            : #include "cn10k_cryptodev_ops.h"
       9                 :            : #include "cnxk_eventdev.h"
      10                 :            : #include "cnxk_worker.h"
      11                 :            : #include "cnxk_dma_event_dp.h"
      12                 :            : 
      13                 :            : #include <rte_dmadev_pmd.h>
      14                 :            : 
      15                 :            : #define CN10K_SET_EVDEV_DEQ_OP(dev, deq_op, deq_ops)                           \
      16                 :            :         deq_op = deq_ops[dev->rx_offloads & (NIX_RX_OFFLOAD_MAX - 1)]
      17                 :            : 
      18                 :            : #define CN10K_SET_EVDEV_ENQ_OP(dev, enq_op, enq_ops)                           \
      19                 :            :         enq_op = enq_ops[dev->tx_offloads & (NIX_TX_OFFLOAD_MAX - 1)]
      20                 :            : 
      21                 :            : static uint32_t
      22                 :            : cn10k_sso_gw_mode_wdata(struct cnxk_sso_evdev *dev)
      23                 :            : {
      24                 :            :         uint32_t wdata = 1;
      25                 :            : 
      26                 :          0 :         if (dev->deq_tmo_ns)
      27                 :            :                 wdata |= BIT(16);
      28                 :            : 
      29      [ #  #  # ]:          0 :         switch (dev->gw_mode) {
      30                 :            :         case CN10K_GW_MODE_NONE:
      31                 :            :         default:
      32                 :            :                 break;
      33                 :          0 :         case CN10K_GW_MODE_PREF:
      34                 :          0 :                 wdata |= BIT(19);
      35                 :          0 :                 break;
      36                 :          0 :         case CN10K_GW_MODE_PREF_WFE:
      37                 :          0 :                 wdata |= BIT(20) | BIT(19);
      38                 :          0 :                 break;
      39                 :            :         }
      40                 :            : 
      41                 :            :         return wdata;
      42                 :            : }
      43                 :            : 
      44                 :            : static void *
      45                 :          0 : cn10k_sso_init_hws_mem(void *arg, uint8_t port_id)
      46                 :            : {
      47                 :            :         struct cnxk_sso_evdev *dev = arg;
      48                 :            :         struct cn10k_sso_hws *ws;
      49                 :            : 
      50                 :            :         /* Allocate event port memory */
      51                 :          0 :         ws = rte_zmalloc("cn10k_ws",
      52                 :            :                          sizeof(struct cn10k_sso_hws) + RTE_CACHE_LINE_SIZE,
      53                 :            :                          RTE_CACHE_LINE_SIZE);
      54         [ #  # ]:          0 :         if (ws == NULL) {
      55                 :          0 :                 plt_err("Failed to alloc memory for port=%d", port_id);
      56                 :          0 :                 return NULL;
      57                 :            :         }
      58                 :            : 
      59                 :            :         /* First cache line is reserved for cookie */
      60                 :          0 :         ws = (struct cn10k_sso_hws *)((uint8_t *)ws + RTE_CACHE_LINE_SIZE);
      61                 :          0 :         ws->base = roc_sso_hws_base_get(&dev->sso, port_id);
      62                 :          0 :         ws->hws_id = port_id;
      63         [ #  # ]:          0 :         ws->swtag_req = 0;
      64                 :          0 :         ws->gw_wdata = cn10k_sso_gw_mode_wdata(dev);
      65                 :          0 :         ws->gw_rdata = SSO_TT_EMPTY << 32;
      66                 :          0 :         ws->lmt_base = dev->sso.lmt_base;
      67                 :            : 
      68                 :          0 :         return ws;
      69                 :            : }
      70                 :            : 
      71                 :            : static int
      72                 :          0 : cn10k_sso_hws_link(void *arg, void *port, uint16_t *map, uint16_t nb_link, uint8_t profile)
      73                 :            : {
      74                 :            :         struct cnxk_sso_evdev *dev = arg;
      75                 :            :         struct cn10k_sso_hws *ws = port;
      76                 :            : 
      77                 :          0 :         return roc_sso_hws_link(&dev->sso, ws->hws_id, map, nb_link, profile, 0);
      78                 :            : }
      79                 :            : 
      80                 :            : static int
      81                 :          0 : cn10k_sso_hws_unlink(void *arg, void *port, uint16_t *map, uint16_t nb_link, uint8_t profile)
      82                 :            : {
      83                 :            :         struct cnxk_sso_evdev *dev = arg;
      84                 :            :         struct cn10k_sso_hws *ws = port;
      85                 :            : 
      86                 :          0 :         return roc_sso_hws_unlink(&dev->sso, ws->hws_id, map, nb_link, profile, 0);
      87                 :            : }
      88                 :            : 
      89                 :            : static void
      90                 :          0 : cn10k_sso_hws_setup(void *arg, void *hws, uintptr_t grp_base)
      91                 :            : {
      92                 :            :         struct cnxk_sso_evdev *dev = arg;
      93                 :            :         struct cn10k_sso_hws *ws = hws;
      94                 :            :         uint64_t val;
      95                 :            : 
      96                 :          0 :         ws->grp_base = grp_base;
      97                 :          0 :         ws->fc_mem = (int64_t *)dev->fc_iova;
      98                 :          0 :         ws->xaq_lmt = dev->xaq_lmt;
      99                 :          0 :         ws->fc_cache_space = dev->fc_cache_space;
     100                 :          0 :         ws->aw_lmt = ws->lmt_base;
     101                 :            : 
     102                 :            :         /* Set get_work timeout for HWS */
     103                 :          0 :         val = NSEC2USEC(dev->deq_tmo_ns);
     104         [ #  # ]:          0 :         val = val ? val - 1 : 0;
     105                 :          0 :         plt_write64(val, ws->base + SSOW_LF_GWS_NW_TIM);
     106                 :          0 : }
     107                 :            : 
     108                 :            : static void
     109                 :          0 : cn10k_sso_hws_release(void *arg, void *hws)
     110                 :            : {
     111                 :            :         struct cnxk_sso_evdev *dev = arg;
     112                 :            :         struct cn10k_sso_hws *ws = hws;
     113                 :            :         uint16_t i, j;
     114                 :            : 
     115         [ #  # ]:          0 :         for (i = 0; i < CNXK_SSO_MAX_PROFILES; i++)
     116         [ #  # ]:          0 :                 for (j = 0; j < dev->nb_event_queues; j++)
     117                 :          0 :                         roc_sso_hws_unlink(&dev->sso, ws->hws_id, &j, 1, i, 0);
     118                 :            :         memset(ws, 0, sizeof(*ws));
     119                 :          0 : }
     120                 :            : 
     121                 :            : static int
     122                 :          0 : cn10k_sso_hws_flush_events(void *hws, uint8_t queue_id, uintptr_t base,
     123                 :            :                            cnxk_handle_event_t fn, void *arg)
     124                 :            : {
     125                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(arg);
     126                 :            :         uint64_t retry = CNXK_SSO_FLUSH_RETRY_MAX;
     127                 :            :         struct cn10k_sso_hws *ws = hws;
     128                 :            :         uint64_t cq_ds_cnt = 1;
     129                 :            :         uint64_t aq_cnt = 1;
     130                 :            :         uint64_t ds_cnt = 1;
     131                 :            :         struct rte_event ev;
     132                 :            :         uint64_t val, req;
     133                 :            : 
     134                 :          0 :         plt_write64(0, base + SSO_LF_GGRP_QCTL);
     135                 :            : 
     136                 :          0 :         roc_sso_hws_gwc_invalidate(&dev->sso, &ws->hws_id, 1);
     137                 :          0 :         plt_write64(0, ws->base + SSOW_LF_GWS_OP_GWC_INVAL);
     138                 :          0 :         req = queue_id;     /* GGRP ID */
     139                 :            :         req |= BIT_ULL(18); /* Grouped */
     140                 :          0 :         req |= BIT_ULL(16); /* WAIT */
     141                 :            : 
     142                 :          0 :         aq_cnt = plt_read64(base + SSO_LF_GGRP_AQ_CNT);
     143                 :          0 :         ds_cnt = plt_read64(base + SSO_LF_GGRP_MISC_CNT);
     144                 :          0 :         cq_ds_cnt = plt_read64(base + SSO_LF_GGRP_INT_CNT);
     145                 :          0 :         cq_ds_cnt &= 0x3FFF3FFF0000;
     146                 :            : 
     147         [ #  # ]:          0 :         while (aq_cnt || cq_ds_cnt || ds_cnt) {
     148                 :          0 :                 plt_write64(req, ws->base + SSOW_LF_GWS_OP_GET_WORK0);
     149                 :            :                 cn10k_sso_hws_get_work_empty(
     150                 :            :                         ws, &ev, (NIX_RX_OFFLOAD_MAX - 1) | NIX_RX_REAS_F | NIX_RX_MULTI_SEG_F);
     151   [ #  #  #  # ]:          0 :                 if (fn != NULL && ev.u64 != 0)
     152                 :          0 :                         fn(arg, ev);
     153         [ #  # ]:          0 :                 if (ev.sched_type != SSO_TT_EMPTY)
     154                 :          0 :                         cnxk_sso_hws_swtag_flush(ws->base);
     155         [ #  # ]:          0 :                 else if (retry-- == 0)
     156                 :            :                         break;
     157                 :            :                 do {
     158         [ #  # ]:          0 :                         val = plt_read64(ws->base + SSOW_LF_GWS_PENDSTATE);
     159         [ #  # ]:          0 :                 } while (val & BIT_ULL(56));
     160                 :            :                 aq_cnt = plt_read64(base + SSO_LF_GGRP_AQ_CNT);
     161                 :            :                 ds_cnt = plt_read64(base + SSO_LF_GGRP_MISC_CNT);
     162                 :            :                 cq_ds_cnt = plt_read64(base + SSO_LF_GGRP_INT_CNT);
     163                 :            :                 /* Extract cq and ds count */
     164                 :          0 :                 cq_ds_cnt &= 0x3FFF3FFF0000;
     165                 :            :         }
     166                 :            : 
     167         [ #  # ]:          0 :         if (aq_cnt || cq_ds_cnt || ds_cnt)
     168                 :            :                 return -EAGAIN;
     169                 :            : 
     170                 :          0 :         plt_write64(0, ws->base + SSOW_LF_GWS_OP_GWC_INVAL);
     171                 :          0 :         roc_sso_hws_gwc_invalidate(&dev->sso, &ws->hws_id, 1);
     172                 :            :         rte_mb();
     173                 :            : 
     174                 :          0 :         return 0;
     175                 :            : }
     176                 :            : 
     177                 :            : static void
     178                 :          0 : cn10k_sso_hws_reset(void *arg, void *hws)
     179                 :            : {
     180                 :            :         struct cnxk_sso_evdev *dev = arg;
     181                 :            :         struct cn10k_sso_hws *ws = hws;
     182                 :          0 :         uintptr_t base = ws->base;
     183                 :            :         uint64_t pend_state;
     184                 :            :         union {
     185                 :            :                 __uint128_t wdata;
     186                 :            :                 uint64_t u64[2];
     187                 :            :         } gw;
     188                 :            :         uint8_t pend_tt;
     189                 :            :         bool is_pend;
     190                 :            : 
     191                 :          0 :         roc_sso_hws_gwc_invalidate(&dev->sso, &ws->hws_id, 1);
     192         [ #  # ]:          0 :         plt_write64(0, ws->base + SSOW_LF_GWS_OP_GWC_INVAL);
     193                 :            :         /* Wait till getwork/swtp/waitw/desched completes. */
     194                 :            :         is_pend = false;
     195                 :            :         /* Work in WQE0 is always consumed, unless its a SWTAG. */
     196         [ #  # ]:          0 :         pend_state = plt_read64(ws->base + SSOW_LF_GWS_PENDSTATE);
     197         [ #  # ]:          0 :         if (pend_state & (BIT_ULL(63) | BIT_ULL(62) | BIT_ULL(54)) ||
     198         [ #  # ]:          0 :             ws->swtag_req)
     199                 :            :                 is_pend = true;
     200                 :            : 
     201                 :            :         do {
     202         [ #  # ]:          0 :                 pend_state = plt_read64(base + SSOW_LF_GWS_PENDSTATE);
     203         [ #  # ]:          0 :         } while (pend_state & (BIT_ULL(63) | BIT_ULL(62) | BIT_ULL(58) |
     204                 :            :                                BIT_ULL(56) | BIT_ULL(54)));
     205         [ #  # ]:          0 :         pend_tt = CNXK_TT_FROM_TAG(plt_read64(base + SSOW_LF_GWS_WQE0));
     206         [ #  # ]:          0 :         if (is_pend && pend_tt != SSO_TT_EMPTY) { /* Work was pending */
     207         [ #  # ]:          0 :                 if (pend_tt == SSO_TT_ATOMIC || pend_tt == SSO_TT_ORDERED)
     208                 :          0 :                         cnxk_sso_hws_swtag_untag(base +
     209                 :            :                                                  SSOW_LF_GWS_OP_SWTAG_UNTAG);
     210                 :          0 :                 plt_write64(0, base + SSOW_LF_GWS_OP_DESCHED);
     211         [ #  # ]:          0 :         } else if (pend_tt != SSO_TT_EMPTY) {
     212                 :          0 :                 plt_write64(0, base + SSOW_LF_GWS_OP_SWTAG_FLUSH);
     213                 :            :         }
     214                 :            : 
     215                 :            :         /* Wait for desched to complete. */
     216                 :            :         do {
     217                 :            :                 pend_state = plt_read64(base + SSOW_LF_GWS_PENDSTATE);
     218         [ #  # ]:          0 :         } while (pend_state & (BIT_ULL(58) | BIT_ULL(56)));
     219                 :            : 
     220         [ #  # ]:          0 :         switch (dev->gw_mode) {
     221                 :            :         case CN10K_GW_MODE_PREF:
     222                 :            :         case CN10K_GW_MODE_PREF_WFE:
     223         [ #  # ]:          0 :                 while (plt_read64(base + SSOW_LF_GWS_PRF_WQE0) & BIT_ULL(63))
     224                 :            :                         ;
     225                 :            :                 break;
     226                 :            :         case CN10K_GW_MODE_NONE:
     227                 :            :         default:
     228                 :            :                 break;
     229                 :            :         }
     230                 :            : 
     231         [ #  # ]:          0 :         if (CNXK_TT_FROM_TAG(plt_read64(base + SSOW_LF_GWS_PRF_WQE0)) !=
     232                 :            :             SSO_TT_EMPTY) {
     233                 :          0 :                 plt_write64(BIT_ULL(16) | 1,
     234                 :            :                             ws->base + SSOW_LF_GWS_OP_GET_WORK0);
     235                 :            :                 do {
     236         [ #  # ]:          0 :                         roc_load_pair(gw.u64[0], gw.u64[1],
     237                 :            :                                       ws->base + SSOW_LF_GWS_WQE0);
     238         [ #  # ]:          0 :                 } while (gw.u64[0] & BIT_ULL(63));
     239                 :          0 :                 pend_tt = CNXK_TT_FROM_TAG(plt_read64(base + SSOW_LF_GWS_WQE0));
     240         [ #  # ]:          0 :                 if (pend_tt != SSO_TT_EMPTY) { /* Work was pending */
     241         [ #  # ]:          0 :                         if (pend_tt == SSO_TT_ATOMIC ||
     242                 :            :                             pend_tt == SSO_TT_ORDERED)
     243                 :            :                                 cnxk_sso_hws_swtag_untag(
     244                 :          0 :                                         base + SSOW_LF_GWS_OP_SWTAG_UNTAG);
     245                 :          0 :                         plt_write64(0, base + SSOW_LF_GWS_OP_DESCHED);
     246                 :            :                 }
     247                 :            :         }
     248                 :            : 
     249                 :          0 :         plt_write64(0, base + SSOW_LF_GWS_OP_GWC_INVAL);
     250                 :          0 :         roc_sso_hws_gwc_invalidate(&dev->sso, &ws->hws_id, 1);
     251                 :            :         rte_mb();
     252                 :          0 : }
     253                 :            : 
     254                 :            : static void
     255                 :            : cn10k_sso_set_rsrc(void *arg)
     256                 :            : {
     257                 :            :         struct cnxk_sso_evdev *dev = arg;
     258                 :            : 
     259                 :          0 :         dev->max_event_ports = dev->sso.max_hws;
     260                 :          0 :         dev->max_event_queues =
     261                 :          0 :                 dev->sso.max_hwgrp > RTE_EVENT_MAX_QUEUES_PER_DEV ?
     262                 :          0 :                               RTE_EVENT_MAX_QUEUES_PER_DEV :
     263                 :            :                               dev->sso.max_hwgrp;
     264                 :            : }
     265                 :            : 
     266                 :            : static int
     267                 :          0 : cn10k_sso_rsrc_init(void *arg, uint8_t hws, uint8_t hwgrp)
     268                 :            : {
     269                 :            :         struct cnxk_tim_evdev *tim_dev = cnxk_tim_priv_get();
     270                 :            :         struct cnxk_sso_evdev *dev = arg;
     271                 :            :         uint16_t nb_tim_lfs;
     272                 :            : 
     273         [ #  # ]:          0 :         nb_tim_lfs = tim_dev ? tim_dev->nb_rings : 0;
     274                 :          0 :         return roc_sso_rsrc_init(&dev->sso, hws, hwgrp, nb_tim_lfs);
     275                 :            : }
     276                 :            : 
     277                 :            : static int
     278         [ #  # ]:          0 : cn10k_sso_updt_tx_adptr_data(const struct rte_eventdev *event_dev)
     279                 :            : {
     280                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
     281                 :            :         int i;
     282                 :            : 
     283         [ #  # ]:          0 :         if (dev->tx_adptr_data == NULL)
     284                 :            :                 return 0;
     285                 :            : 
     286         [ #  # ]:          0 :         for (i = 0; i < dev->nb_event_ports; i++) {
     287                 :          0 :                 struct cn10k_sso_hws *ws = event_dev->data->ports[i];
     288                 :            :                 void *ws_cookie;
     289                 :            : 
     290                 :            :                 ws_cookie = cnxk_sso_hws_get_cookie(ws);
     291                 :          0 :                 ws_cookie = rte_realloc_socket(
     292                 :            :                         ws_cookie,
     293                 :            :                         sizeof(struct cnxk_sso_hws_cookie) +
     294                 :            :                                 sizeof(struct cn10k_sso_hws) +
     295                 :          0 :                                 dev->tx_adptr_data_sz,
     296                 :            :                         RTE_CACHE_LINE_SIZE, SOCKET_ID_ANY);
     297         [ #  # ]:          0 :                 if (ws_cookie == NULL)
     298                 :            :                         return -ENOMEM;
     299                 :          0 :                 ws = RTE_PTR_ADD(ws_cookie, sizeof(struct cnxk_sso_hws_cookie));
     300                 :          0 :                 memcpy(&ws->tx_adptr_data, dev->tx_adptr_data,
     301                 :            :                        dev->tx_adptr_data_sz);
     302                 :          0 :                 event_dev->data->ports[i] = ws;
     303                 :            :         }
     304                 :            : 
     305                 :            :         return 0;
     306                 :            : }
     307                 :            : 
     308                 :            : static void
     309                 :            : cn10k_sso_fp_fns_set(struct rte_eventdev *event_dev)
     310                 :            : {
     311                 :            : #if defined(RTE_ARCH_ARM64)
     312                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
     313                 :            : 
     314                 :            :         struct roc_cpt *cpt = roc_idev_cpt_get();
     315                 :            :         const event_dequeue_t sso_hws_deq[NIX_RX_OFFLOAD_MAX] = {
     316                 :            : #define R(name, flags)[flags] = cn10k_sso_hws_deq_##name,
     317                 :            :                 NIX_RX_FASTPATH_MODES
     318                 :            : #undef R
     319                 :            :         };
     320                 :            : 
     321                 :            :         const event_dequeue_burst_t sso_hws_deq_burst[NIX_RX_OFFLOAD_MAX] = {
     322                 :            : #define R(name, flags)[flags] = cn10k_sso_hws_deq_burst_##name,
     323                 :            :                 NIX_RX_FASTPATH_MODES
     324                 :            : #undef R
     325                 :            :         };
     326                 :            : 
     327                 :            :         const event_dequeue_t sso_hws_deq_tmo[NIX_RX_OFFLOAD_MAX] = {
     328                 :            : #define R(name, flags)[flags] = cn10k_sso_hws_deq_tmo_##name,
     329                 :            :                 NIX_RX_FASTPATH_MODES
     330                 :            : #undef R
     331                 :            :         };
     332                 :            : 
     333                 :            :         const event_dequeue_burst_t sso_hws_deq_tmo_burst[NIX_RX_OFFLOAD_MAX] = {
     334                 :            : #define R(name, flags)[flags] = cn10k_sso_hws_deq_tmo_burst_##name,
     335                 :            :                 NIX_RX_FASTPATH_MODES
     336                 :            : #undef R
     337                 :            :         };
     338                 :            : 
     339                 :            :         const event_dequeue_t sso_hws_deq_seg[NIX_RX_OFFLOAD_MAX] = {
     340                 :            : #define R(name, flags)[flags] = cn10k_sso_hws_deq_seg_##name,
     341                 :            : 
     342                 :            :                 NIX_RX_FASTPATH_MODES
     343                 :            : #undef R
     344                 :            :         };
     345                 :            : 
     346                 :            :         const event_dequeue_burst_t sso_hws_deq_seg_burst[NIX_RX_OFFLOAD_MAX] = {
     347                 :            : #define R(name, flags)[flags] = cn10k_sso_hws_deq_seg_burst_##name,
     348                 :            :                         NIX_RX_FASTPATH_MODES
     349                 :            : #undef R
     350                 :            :         };
     351                 :            : 
     352                 :            :         const event_dequeue_t sso_hws_deq_tmo_seg[NIX_RX_OFFLOAD_MAX] = {
     353                 :            : #define R(name, flags)[flags] = cn10k_sso_hws_deq_tmo_seg_##name,
     354                 :            :                 NIX_RX_FASTPATH_MODES
     355                 :            : #undef R
     356                 :            :         };
     357                 :            : 
     358                 :            :         const event_dequeue_burst_t sso_hws_deq_tmo_seg_burst[NIX_RX_OFFLOAD_MAX] = {
     359                 :            : #define R(name, flags)[flags] = cn10k_sso_hws_deq_tmo_seg_burst_##name,
     360                 :            :                 NIX_RX_FASTPATH_MODES
     361                 :            : #undef R
     362                 :            :         };
     363                 :            : 
     364                 :            :         const event_dequeue_t sso_hws_reas_deq[NIX_RX_OFFLOAD_MAX] = {
     365                 :            : #define R(name, flags)[flags] = cn10k_sso_hws_reas_deq_##name,
     366                 :            :                 NIX_RX_FASTPATH_MODES
     367                 :            : #undef R
     368                 :            :         };
     369                 :            : 
     370                 :            :         const event_dequeue_burst_t sso_hws_reas_deq_burst[NIX_RX_OFFLOAD_MAX] = {
     371                 :            : #define R(name, flags)[flags] = cn10k_sso_hws_reas_deq_burst_##name,
     372                 :            :                 NIX_RX_FASTPATH_MODES
     373                 :            : #undef R
     374                 :            :         };
     375                 :            : 
     376                 :            :         const event_dequeue_t sso_hws_reas_deq_tmo[NIX_RX_OFFLOAD_MAX] = {
     377                 :            : #define R(name, flags)[flags] = cn10k_sso_hws_reas_deq_tmo_##name,
     378                 :            :                 NIX_RX_FASTPATH_MODES
     379                 :            : #undef R
     380                 :            :         };
     381                 :            : 
     382                 :            :         const event_dequeue_burst_t sso_hws_reas_deq_tmo_burst[NIX_RX_OFFLOAD_MAX] = {
     383                 :            : #define R(name, flags)[flags] = cn10k_sso_hws_reas_deq_tmo_burst_##name,
     384                 :            :                 NIX_RX_FASTPATH_MODES
     385                 :            : #undef R
     386                 :            :         };
     387                 :            : 
     388                 :            :         const event_dequeue_t sso_hws_reas_deq_seg[NIX_RX_OFFLOAD_MAX] = {
     389                 :            : #define R(name, flags)[flags] = cn10k_sso_hws_reas_deq_seg_##name,
     390                 :            : 
     391                 :            :                 NIX_RX_FASTPATH_MODES
     392                 :            : #undef R
     393                 :            :         };
     394                 :            : 
     395                 :            :         const event_dequeue_burst_t sso_hws_reas_deq_seg_burst[NIX_RX_OFFLOAD_MAX] = {
     396                 :            : #define R(name, flags)[flags] = cn10k_sso_hws_reas_deq_seg_burst_##name,
     397                 :            :                 NIX_RX_FASTPATH_MODES
     398                 :            : #undef R
     399                 :            :         };
     400                 :            : 
     401                 :            :         const event_dequeue_t sso_hws_reas_deq_tmo_seg[NIX_RX_OFFLOAD_MAX] = {
     402                 :            : #define R(name, flags)[flags] = cn10k_sso_hws_reas_deq_tmo_seg_##name,
     403                 :            :                 NIX_RX_FASTPATH_MODES
     404                 :            : #undef R
     405                 :            :         };
     406                 :            : 
     407                 :            :         const event_dequeue_burst_t sso_hws_reas_deq_tmo_seg_burst[NIX_RX_OFFLOAD_MAX] = {
     408                 :            : #define R(name, flags)[flags] = cn10k_sso_hws_reas_deq_tmo_seg_burst_##name,
     409                 :            :                 NIX_RX_FASTPATH_MODES
     410                 :            : #undef R
     411                 :            :         };
     412                 :            : 
     413                 :            :         /* Tx modes */
     414                 :            :         const event_tx_adapter_enqueue_t sso_hws_tx_adptr_enq[NIX_TX_OFFLOAD_MAX] = {
     415                 :            : #define T(name, sz, flags)[flags] = cn10k_sso_hws_tx_adptr_enq_##name,
     416                 :            :                 NIX_TX_FASTPATH_MODES
     417                 :            : #undef T
     418                 :            :         };
     419                 :            : 
     420                 :            :         const event_tx_adapter_enqueue_t sso_hws_tx_adptr_enq_seg[NIX_TX_OFFLOAD_MAX] = {
     421                 :            : #define T(name, sz, flags)[flags] = cn10k_sso_hws_tx_adptr_enq_seg_##name,
     422                 :            :                 NIX_TX_FASTPATH_MODES
     423                 :            : #undef T
     424                 :            :         };
     425                 :            : 
     426                 :            :         event_dev->enqueue = cn10k_sso_hws_enq;
     427                 :            :         event_dev->enqueue_burst = cn10k_sso_hws_enq_burst;
     428                 :            :         event_dev->enqueue_new_burst = cn10k_sso_hws_enq_new_burst;
     429                 :            :         event_dev->enqueue_forward_burst = cn10k_sso_hws_enq_fwd_burst;
     430                 :            :         if (dev->rx_offloads & NIX_RX_MULTI_SEG_F) {
     431                 :            :                 if (dev->rx_offloads & NIX_RX_REAS_F) {
     432                 :            :                         CN10K_SET_EVDEV_DEQ_OP(dev, event_dev->dequeue, sso_hws_reas_deq_seg);
     433                 :            :                         CN10K_SET_EVDEV_DEQ_OP(dev, event_dev->dequeue_burst,
     434                 :            :                                                sso_hws_reas_deq_seg_burst);
     435                 :            :                         if (dev->is_timeout_deq) {
     436                 :            :                                 CN10K_SET_EVDEV_DEQ_OP(dev, event_dev->dequeue,
     437                 :            :                                                        sso_hws_reas_deq_tmo_seg);
     438                 :            :                                 CN10K_SET_EVDEV_DEQ_OP(dev, event_dev->dequeue_burst,
     439                 :            :                                                        sso_hws_reas_deq_tmo_seg_burst);
     440                 :            :                         }
     441                 :            :                 } else {
     442                 :            :                         CN10K_SET_EVDEV_DEQ_OP(dev, event_dev->dequeue, sso_hws_deq_seg);
     443                 :            :                         CN10K_SET_EVDEV_DEQ_OP(dev, event_dev->dequeue_burst,
     444                 :            :                                                sso_hws_deq_seg_burst);
     445                 :            : 
     446                 :            :                         if (dev->is_timeout_deq) {
     447                 :            :                                 CN10K_SET_EVDEV_DEQ_OP(dev, event_dev->dequeue,
     448                 :            :                                                        sso_hws_deq_tmo_seg);
     449                 :            :                                 CN10K_SET_EVDEV_DEQ_OP(dev, event_dev->dequeue_burst,
     450                 :            :                                                        sso_hws_deq_tmo_seg_burst);
     451                 :            :                         }
     452                 :            :                 }
     453                 :            :         } else {
     454                 :            :                 if (dev->rx_offloads & NIX_RX_REAS_F) {
     455                 :            :                         CN10K_SET_EVDEV_DEQ_OP(dev, event_dev->dequeue, sso_hws_reas_deq);
     456                 :            :                         CN10K_SET_EVDEV_DEQ_OP(dev, event_dev->dequeue_burst,
     457                 :            :                                                sso_hws_reas_deq_burst);
     458                 :            : 
     459                 :            :                         if (dev->is_timeout_deq) {
     460                 :            :                                 CN10K_SET_EVDEV_DEQ_OP(dev, event_dev->dequeue,
     461                 :            :                                                        sso_hws_reas_deq_tmo);
     462                 :            :                                 CN10K_SET_EVDEV_DEQ_OP(dev, event_dev->dequeue_burst,
     463                 :            :                                                        sso_hws_reas_deq_tmo_burst);
     464                 :            :                         }
     465                 :            :                 } else {
     466                 :            :                         CN10K_SET_EVDEV_DEQ_OP(dev, event_dev->dequeue, sso_hws_deq);
     467                 :            :                         CN10K_SET_EVDEV_DEQ_OP(dev, event_dev->dequeue_burst, sso_hws_deq_burst);
     468                 :            : 
     469                 :            :                         if (dev->is_timeout_deq) {
     470                 :            :                                 CN10K_SET_EVDEV_DEQ_OP(dev, event_dev->dequeue, sso_hws_deq_tmo);
     471                 :            :                                 CN10K_SET_EVDEV_DEQ_OP(dev, event_dev->dequeue_burst,
     472                 :            :                                                        sso_hws_deq_tmo_burst);
     473                 :            :                         }
     474                 :            :                 }
     475                 :            :         }
     476                 :            : 
     477                 :            :         if ((cpt != NULL) && cpt->hw_caps[CPT_ENG_TYPE_SE].sg_ver2 &&
     478                 :            :             cpt->hw_caps[CPT_ENG_TYPE_IE].sg_ver2)
     479                 :            :                 event_dev->ca_enqueue = cn10k_cpt_sg_ver2_crypto_adapter_enqueue;
     480                 :            :         else
     481                 :            :                 event_dev->ca_enqueue = cn10k_cpt_sg_ver1_crypto_adapter_enqueue;
     482                 :            : 
     483                 :            :         event_dev->dma_enqueue = cn10k_dma_adapter_enqueue;
     484                 :            : 
     485                 :            :         if (dev->tx_offloads & NIX_TX_MULTI_SEG_F)
     486                 :            :                 CN10K_SET_EVDEV_ENQ_OP(dev, event_dev->txa_enqueue, sso_hws_tx_adptr_enq_seg);
     487                 :            :         else
     488                 :            :                 CN10K_SET_EVDEV_ENQ_OP(dev, event_dev->txa_enqueue, sso_hws_tx_adptr_enq);
     489                 :            : 
     490                 :            :         event_dev->txa_enqueue_same_dest = event_dev->txa_enqueue;
     491                 :            :         event_dev->profile_switch = cn10k_sso_hws_profile_switch;
     492                 :            : #else
     493                 :            :         RTE_SET_USED(event_dev);
     494                 :            : #endif
     495                 :            : }
     496                 :            : 
     497                 :            : static void
     498                 :          0 : cn10k_sso_info_get(struct rte_eventdev *event_dev,
     499                 :            :                    struct rte_event_dev_info *dev_info)
     500                 :            : {
     501                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
     502                 :            : 
     503                 :          0 :         dev_info->driver_name = RTE_STR(EVENTDEV_NAME_CN10K_PMD);
     504                 :          0 :         cnxk_sso_info_get(dev, dev_info);
     505                 :          0 :         dev_info->max_event_port_enqueue_depth = UINT32_MAX;
     506                 :          0 : }
     507                 :            : 
     508                 :            : static int
     509                 :          0 : cn10k_sso_dev_configure(const struct rte_eventdev *event_dev)
     510                 :            : {
     511                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
     512                 :            :         int rc;
     513                 :            : 
     514                 :          0 :         rc = cnxk_sso_dev_validate(event_dev, 1, UINT32_MAX);
     515         [ #  # ]:          0 :         if (rc < 0) {
     516                 :          0 :                 plt_err("Invalid event device configuration");
     517                 :          0 :                 return -EINVAL;
     518                 :            :         }
     519                 :            : 
     520                 :          0 :         rc = cn10k_sso_rsrc_init(dev, dev->nb_event_ports,
     521                 :          0 :                                  dev->nb_event_queues);
     522         [ #  # ]:          0 :         if (rc < 0) {
     523                 :          0 :                 plt_err("Failed to initialize SSO resources");
     524                 :          0 :                 return -ENODEV;
     525                 :            :         }
     526                 :            : 
     527                 :          0 :         rc = cnxk_sso_xaq_allocate(dev);
     528         [ #  # ]:          0 :         if (rc < 0)
     529                 :          0 :                 goto cnxk_rsrc_fini;
     530                 :            : 
     531                 :          0 :         rc = cnxk_setup_event_ports(event_dev, cn10k_sso_init_hws_mem,
     532                 :            :                                     cn10k_sso_hws_setup);
     533         [ #  # ]:          0 :         if (rc < 0)
     534                 :          0 :                 goto cnxk_rsrc_fini;
     535                 :            : 
     536                 :            :         /* Restore any prior port-queue mapping. */
     537                 :          0 :         cnxk_sso_restore_links(event_dev, cn10k_sso_hws_link);
     538                 :            : 
     539                 :          0 :         dev->configured = 1;
     540                 :            :         rte_mb();
     541                 :            : 
     542                 :          0 :         return 0;
     543                 :          0 : cnxk_rsrc_fini:
     544                 :          0 :         roc_sso_rsrc_fini(&dev->sso);
     545                 :          0 :         dev->nb_event_ports = 0;
     546                 :          0 :         return rc;
     547                 :            : }
     548                 :            : 
     549                 :            : static int
     550                 :          0 : cn10k_sso_port_setup(struct rte_eventdev *event_dev, uint8_t port_id,
     551                 :            :                      const struct rte_event_port_conf *port_conf)
     552                 :            : {
     553                 :            : 
     554                 :            :         RTE_SET_USED(port_conf);
     555                 :          0 :         return cnxk_sso_port_setup(event_dev, port_id, cn10k_sso_hws_setup);
     556                 :            : }
     557                 :            : 
     558                 :            : static void
     559         [ #  # ]:          0 : cn10k_sso_port_release(void *port)
     560                 :            : {
     561                 :            :         struct cnxk_sso_hws_cookie *gws_cookie = cnxk_sso_hws_get_cookie(port);
     562                 :            :         struct cnxk_sso_evdev *dev;
     563                 :            : 
     564         [ #  # ]:          0 :         if (port == NULL)
     565                 :            :                 return;
     566                 :            : 
     567         [ #  # ]:          0 :         dev = cnxk_sso_pmd_priv(gws_cookie->event_dev);
     568         [ #  # ]:          0 :         if (!gws_cookie->configured)
     569                 :          0 :                 goto free;
     570                 :            : 
     571                 :          0 :         cn10k_sso_hws_release(dev, port);
     572                 :            :         memset(gws_cookie, 0, sizeof(*gws_cookie));
     573                 :          0 : free:
     574                 :          0 :         rte_free(gws_cookie);
     575                 :            : }
     576                 :            : 
     577                 :            : static void
     578         [ #  # ]:          0 : cn10k_sso_port_quiesce(struct rte_eventdev *event_dev, void *port,
     579                 :            :                        rte_eventdev_port_flush_t flush_cb, void *args)
     580                 :            : {
     581                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
     582                 :            :         struct cn10k_sso_hws *ws = port;
     583                 :            :         struct rte_event ev;
     584                 :            :         uint64_t ptag;
     585                 :            :         bool is_pend;
     586                 :            : 
     587                 :            :         is_pend = false;
     588                 :            :         /* Work in WQE0 is always consumed, unless its a SWTAG. */
     589         [ #  # ]:          0 :         ptag = plt_read64(ws->base + SSOW_LF_GWS_PENDSTATE);
     590   [ #  #  #  # ]:          0 :         if (ptag & (BIT_ULL(62) | BIT_ULL(54)) || ws->swtag_req)
     591                 :            :                 is_pend = true;
     592                 :            :         do {
     593                 :            :                 ptag = plt_read64(ws->base + SSOW_LF_GWS_PENDSTATE);
     594         [ #  # ]:          0 :         } while (ptag &
     595                 :            :                  (BIT_ULL(62) | BIT_ULL(58) | BIT_ULL(56) | BIT_ULL(54)));
     596                 :            : 
     597                 :            :         cn10k_sso_hws_get_work_empty(ws, &ev,
     598                 :            :                                      (NIX_RX_OFFLOAD_MAX - 1) | NIX_RX_REAS_F | NIX_RX_MULTI_SEG_F);
     599   [ #  #  #  # ]:          0 :         if (is_pend && ev.u64)
     600         [ #  # ]:          0 :                 if (flush_cb)
     601                 :          0 :                         flush_cb(event_dev->data->dev_id, ev, args);
     602         [ #  # ]:          0 :         ptag = (plt_read64(ws->base + SSOW_LF_GWS_TAG) >> 32) & SSO_TT_EMPTY;
     603         [ #  # ]:          0 :         if (ptag != SSO_TT_EMPTY)
     604                 :            :                 cnxk_sso_hws_swtag_flush(ws->base);
     605                 :            : 
     606                 :            :         do {
     607         [ #  # ]:          0 :                 ptag = plt_read64(ws->base + SSOW_LF_GWS_PENDSTATE);
     608         [ #  # ]:          0 :         } while (ptag & BIT_ULL(56));
     609                 :            : 
     610                 :            :         /* Check if we have work in PRF_WQE0, if so extract it. */
     611         [ #  # ]:          0 :         switch (dev->gw_mode) {
     612                 :            :         case CN10K_GW_MODE_PREF:
     613                 :            :         case CN10K_GW_MODE_PREF_WFE:
     614         [ #  # ]:          0 :                 while (plt_read64(ws->base + SSOW_LF_GWS_PRF_WQE0) &
     615                 :            :                        BIT_ULL(63))
     616                 :            :                         ;
     617                 :            :                 break;
     618                 :            :         case CN10K_GW_MODE_NONE:
     619                 :            :         default:
     620                 :            :                 break;
     621                 :            :         }
     622                 :            : 
     623         [ #  # ]:          0 :         if (CNXK_TT_FROM_TAG(plt_read64(ws->base + SSOW_LF_GWS_PRF_WQE0)) !=
     624                 :            :             SSO_TT_EMPTY) {
     625                 :          0 :                 plt_write64(BIT_ULL(16) | 1,
     626                 :            :                             ws->base + SSOW_LF_GWS_OP_GET_WORK0);
     627                 :            :                 cn10k_sso_hws_get_work_empty(
     628                 :            :                         ws, &ev, (NIX_RX_OFFLOAD_MAX - 1) | NIX_RX_REAS_F | NIX_RX_MULTI_SEG_F);
     629         [ #  # ]:          0 :                 if (ev.u64) {
     630         [ #  # ]:          0 :                         if (flush_cb)
     631                 :          0 :                                 flush_cb(event_dev->data->dev_id, ev, args);
     632                 :            :                 }
     633                 :          0 :                 cnxk_sso_hws_swtag_flush(ws->base);
     634                 :            :                 do {
     635         [ #  # ]:          0 :                         ptag = plt_read64(ws->base + SSOW_LF_GWS_PENDSTATE);
     636         [ #  # ]:          0 :                 } while (ptag & BIT_ULL(56));
     637                 :            :         }
     638                 :          0 :         ws->swtag_req = 0;
     639                 :          0 :         plt_write64(0, ws->base + SSOW_LF_GWS_OP_GWC_INVAL);
     640                 :          0 : }
     641                 :            : 
     642                 :            : static int
     643                 :          0 : cn10k_sso_port_link_profile(struct rte_eventdev *event_dev, void *port, const uint8_t queues[],
     644                 :            :                             const uint8_t priorities[], uint16_t nb_links, uint8_t profile)
     645                 :          0 : {
     646                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
     647                 :          0 :         uint16_t hwgrp_ids[nb_links];
     648                 :            :         uint16_t link;
     649                 :            : 
     650                 :            :         RTE_SET_USED(priorities);
     651         [ #  # ]:          0 :         for (link = 0; link < nb_links; link++)
     652                 :          0 :                 hwgrp_ids[link] = queues[link];
     653                 :          0 :         nb_links = cn10k_sso_hws_link(dev, port, hwgrp_ids, nb_links, profile);
     654                 :            : 
     655                 :          0 :         return (int)nb_links;
     656                 :            : }
     657                 :            : 
     658                 :            : static int
     659                 :          0 : cn10k_sso_port_unlink_profile(struct rte_eventdev *event_dev, void *port, uint8_t queues[],
     660                 :            :                               uint16_t nb_unlinks, uint8_t profile)
     661                 :          0 : {
     662                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
     663                 :          0 :         uint16_t hwgrp_ids[nb_unlinks];
     664                 :            :         uint16_t unlink;
     665                 :            : 
     666         [ #  # ]:          0 :         for (unlink = 0; unlink < nb_unlinks; unlink++)
     667                 :          0 :                 hwgrp_ids[unlink] = queues[unlink];
     668                 :          0 :         nb_unlinks = cn10k_sso_hws_unlink(dev, port, hwgrp_ids, nb_unlinks, profile);
     669                 :            : 
     670                 :          0 :         return (int)nb_unlinks;
     671                 :            : }
     672                 :            : 
     673                 :            : static int
     674                 :          0 : cn10k_sso_port_link(struct rte_eventdev *event_dev, void *port, const uint8_t queues[],
     675                 :            :                     const uint8_t priorities[], uint16_t nb_links)
     676                 :            : {
     677                 :          0 :         return cn10k_sso_port_link_profile(event_dev, port, queues, priorities, nb_links, 0);
     678                 :            : }
     679                 :            : 
     680                 :            : static int
     681                 :          0 : cn10k_sso_port_unlink(struct rte_eventdev *event_dev, void *port, uint8_t queues[],
     682                 :            :                       uint16_t nb_unlinks)
     683                 :            : {
     684                 :          0 :         return cn10k_sso_port_unlink_profile(event_dev, port, queues, nb_unlinks, 0);
     685                 :            : }
     686                 :            : 
     687                 :            : static void
     688                 :          0 : cn10k_sso_configure_queue_stash(struct rte_eventdev *event_dev)
     689                 :          0 : {
     690                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
     691                 :          0 :         struct roc_sso_hwgrp_stash stash[dev->stash_cnt];
     692                 :            :         int i, rc;
     693                 :            : 
     694                 :          0 :         plt_sso_dbg();
     695         [ #  # ]:          0 :         for (i = 0; i < dev->stash_cnt; i++) {
     696                 :          0 :                 stash[i].hwgrp = dev->stash_parse_data[i].queue;
     697                 :          0 :                 stash[i].stash_offset = dev->stash_parse_data[i].stash_offset;
     698                 :          0 :                 stash[i].stash_count = dev->stash_parse_data[i].stash_length;
     699                 :            :         }
     700                 :          0 :         rc = roc_sso_hwgrp_stash_config(&dev->sso, stash, dev->stash_cnt);
     701         [ #  # ]:          0 :         if (rc < 0)
     702                 :          0 :                 plt_warn("failed to configure HWGRP WQE stashing rc = %d", rc);
     703                 :          0 : }
     704                 :            : 
     705                 :            : static int
     706                 :          0 : cn10k_sso_start(struct rte_eventdev *event_dev)
     707                 :            : {
     708                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
     709                 :            :         uint8_t hws[RTE_EVENT_MAX_PORTS_PER_DEV];
     710                 :            :         int rc, i;
     711                 :            : 
     712                 :          0 :         rc = cn10k_sso_updt_tx_adptr_data(event_dev);
     713         [ #  # ]:          0 :         if (rc < 0)
     714                 :            :                 return rc;
     715                 :            : 
     716                 :          0 :         cn10k_sso_configure_queue_stash(event_dev);
     717                 :          0 :         rc = cnxk_sso_start(event_dev, cn10k_sso_hws_reset,
     718                 :            :                             cn10k_sso_hws_flush_events);
     719         [ #  # ]:          0 :         if (rc < 0)
     720                 :            :                 return rc;
     721                 :            :         cn10k_sso_fp_fns_set(event_dev);
     722         [ #  # ]:          0 :         for (i = 0; i < event_dev->data->nb_ports; i++)
     723                 :          0 :                 hws[i] = i;
     724                 :          0 :         roc_sso_hws_gwc_invalidate(&dev->sso, hws, event_dev->data->nb_ports);
     725                 :            : 
     726                 :          0 :         return rc;
     727                 :            : }
     728                 :            : 
     729                 :            : static void
     730                 :          0 : cn10k_sso_stop(struct rte_eventdev *event_dev)
     731                 :            : {
     732                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
     733                 :            :         uint8_t hws[RTE_EVENT_MAX_PORTS_PER_DEV];
     734                 :            :         int i;
     735                 :            : 
     736         [ #  # ]:          0 :         for (i = 0; i < event_dev->data->nb_ports; i++)
     737                 :          0 :                 hws[i] = i;
     738                 :          0 :         roc_sso_hws_gwc_invalidate(&dev->sso, hws, event_dev->data->nb_ports);
     739                 :          0 :         cnxk_sso_stop(event_dev, cn10k_sso_hws_reset,
     740                 :            :                       cn10k_sso_hws_flush_events);
     741                 :          0 : }
     742                 :            : 
     743                 :            : static int
     744                 :          0 : cn10k_sso_close(struct rte_eventdev *event_dev)
     745                 :            : {
     746                 :          0 :         return cnxk_sso_close(event_dev, cn10k_sso_hws_unlink);
     747                 :            : }
     748                 :            : 
     749                 :            : static int
     750                 :          0 : cn10k_sso_selftest(void)
     751                 :            : {
     752                 :          0 :         return cnxk_sso_selftest(RTE_STR(event_cn10k));
     753                 :            : }
     754                 :            : 
     755                 :            : static int
     756                 :          0 : cn10k_sso_rx_adapter_caps_get(const struct rte_eventdev *event_dev,
     757                 :            :                               const struct rte_eth_dev *eth_dev, uint32_t *caps)
     758                 :            : {
     759                 :            :         int rc;
     760                 :            : 
     761                 :            :         RTE_SET_USED(event_dev);
     762                 :          0 :         rc = strncmp(eth_dev->device->driver->name, "net_cn10k", 9);
     763         [ #  # ]:          0 :         if (rc)
     764                 :          0 :                 *caps = RTE_EVENT_ETH_RX_ADAPTER_SW_CAP;
     765                 :            :         else
     766                 :          0 :                 *caps = RTE_EVENT_ETH_RX_ADAPTER_CAP_INTERNAL_PORT |
     767                 :            :                         RTE_EVENT_ETH_RX_ADAPTER_CAP_MULTI_EVENTQ |
     768                 :            :                         RTE_EVENT_ETH_RX_ADAPTER_CAP_OVERRIDE_FLOW_ID |
     769                 :            :                         RTE_EVENT_ETH_RX_ADAPTER_CAP_EVENT_VECTOR;
     770                 :            : 
     771                 :          0 :         return 0;
     772                 :            : }
     773                 :            : 
     774                 :            : static void
     775                 :          0 : cn10k_sso_set_priv_mem(const struct rte_eventdev *event_dev, void *lookup_mem)
     776                 :            : {
     777                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
     778                 :            :         int i;
     779                 :            : 
     780   [ #  #  #  #  :          0 :         for (i = 0; i < dev->nb_event_ports; i++) {
             #  #  #  # ]
     781                 :          0 :                 struct cn10k_sso_hws *ws = event_dev->data->ports[i];
     782                 :          0 :                 ws->xaq_lmt = dev->xaq_lmt;
     783                 :          0 :                 ws->fc_mem = (int64_t *)dev->fc_iova;
     784                 :          0 :                 ws->tstamp = dev->tstamp;
     785   [ #  #  #  # ]:          0 :                 if (lookup_mem)
     786                 :          0 :                         ws->lookup_mem = lookup_mem;
     787                 :            :         }
     788                 :          0 : }
     789                 :            : 
     790                 :            : static int
     791         [ #  # ]:          0 : cn10k_sso_rx_adapter_queue_add(
     792                 :            :         const struct rte_eventdev *event_dev, const struct rte_eth_dev *eth_dev,
     793                 :            :         int32_t rx_queue_id,
     794                 :            :         const struct rte_event_eth_rx_adapter_queue_conf *queue_conf)
     795                 :            : {
     796                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
     797                 :            :         struct roc_sso_hwgrp_stash stash;
     798                 :            :         struct cn10k_eth_rxq *rxq;
     799                 :            :         void *lookup_mem;
     800                 :            :         int rc;
     801                 :            : 
     802                 :          0 :         rc = strncmp(eth_dev->device->driver->name, "net_cn10k", 8);
     803         [ #  # ]:          0 :         if (rc)
     804                 :            :                 return -EINVAL;
     805                 :            : 
     806                 :          0 :         rc = cnxk_sso_rx_adapter_queue_add(event_dev, eth_dev, rx_queue_id,
     807                 :            :                                            queue_conf);
     808         [ #  # ]:          0 :         if (rc)
     809                 :            :                 return -EINVAL;
     810                 :          0 :         rxq = eth_dev->data->rx_queues[0];
     811                 :          0 :         lookup_mem = rxq->lookup_mem;
     812                 :            :         cn10k_sso_set_priv_mem(event_dev, lookup_mem);
     813                 :            :         cn10k_sso_fp_fns_set((struct rte_eventdev *)(uintptr_t)event_dev);
     814   [ #  #  #  # ]:          0 :         if (roc_feature_sso_has_stash() && dev->nb_event_ports > 1) {
     815                 :          0 :                 stash.hwgrp = queue_conf->ev.queue_id;
     816                 :          0 :                 stash.stash_offset = CN10K_SSO_DEFAULT_STASH_OFFSET;
     817                 :          0 :                 stash.stash_count = CN10K_SSO_DEFAULT_STASH_LENGTH;
     818                 :          0 :                 rc = roc_sso_hwgrp_stash_config(&dev->sso, &stash, 1);
     819         [ #  # ]:          0 :                 if (rc < 0)
     820                 :          0 :                         plt_warn("failed to configure HWGRP WQE stashing rc = %d", rc);
     821                 :            :         }
     822                 :            : 
     823                 :            :         return 0;
     824                 :            : }
     825                 :            : 
     826                 :            : static int
     827                 :          0 : cn10k_sso_rx_adapter_queue_del(const struct rte_eventdev *event_dev,
     828                 :            :                                const struct rte_eth_dev *eth_dev,
     829                 :            :                                int32_t rx_queue_id)
     830                 :            : {
     831                 :            :         int rc;
     832                 :            : 
     833                 :          0 :         rc = strncmp(eth_dev->device->driver->name, "net_cn10k", 8);
     834         [ #  # ]:          0 :         if (rc)
     835                 :            :                 return -EINVAL;
     836                 :            : 
     837                 :          0 :         return cnxk_sso_rx_adapter_queue_del(event_dev, eth_dev, rx_queue_id);
     838                 :            : }
     839                 :            : 
     840                 :            : static int
     841                 :          0 : cn10k_sso_rx_adapter_vector_limits(
     842                 :            :         const struct rte_eventdev *dev, const struct rte_eth_dev *eth_dev,
     843                 :            :         struct rte_event_eth_rx_adapter_vector_limits *limits)
     844                 :            : {
     845                 :            :         struct cnxk_eth_dev *cnxk_eth_dev;
     846                 :            :         int ret;
     847                 :            : 
     848                 :            :         RTE_SET_USED(dev);
     849                 :          0 :         ret = strncmp(eth_dev->device->driver->name, "net_cn10k", 8);
     850         [ #  # ]:          0 :         if (ret)
     851                 :            :                 return -ENOTSUP;
     852                 :            : 
     853                 :            :         cnxk_eth_dev = cnxk_eth_pmd_priv(eth_dev);
     854                 :          0 :         limits->log2_sz = true;
     855                 :          0 :         limits->min_sz = 1 << ROC_NIX_VWQE_MIN_SIZE_LOG2;
     856                 :          0 :         limits->max_sz = 1 << ROC_NIX_VWQE_MAX_SIZE_LOG2;
     857                 :          0 :         limits->min_timeout_ns =
     858                 :          0 :                 (roc_nix_get_vwqe_interval(&cnxk_eth_dev->nix) + 1) * 100;
     859                 :          0 :         limits->max_timeout_ns = BITMASK_ULL(8, 0) * limits->min_timeout_ns;
     860                 :            : 
     861                 :          0 :         return 0;
     862                 :            : }
     863                 :            : 
     864                 :            : static int
     865                 :          0 : cn10k_sso_tx_adapter_caps_get(const struct rte_eventdev *dev,
     866                 :            :                               const struct rte_eth_dev *eth_dev, uint32_t *caps)
     867                 :            : {
     868                 :            :         int ret;
     869                 :            : 
     870                 :            :         RTE_SET_USED(dev);
     871                 :          0 :         ret = strncmp(eth_dev->device->driver->name, "net_cn10k", 8);
     872         [ #  # ]:          0 :         if (ret)
     873                 :          0 :                 *caps = 0;
     874                 :            :         else
     875                 :          0 :                 *caps = RTE_EVENT_ETH_TX_ADAPTER_CAP_INTERNAL_PORT |
     876                 :            :                         RTE_EVENT_ETH_TX_ADAPTER_CAP_EVENT_VECTOR;
     877                 :            : 
     878                 :          0 :         return 0;
     879                 :            : }
     880                 :            : 
     881                 :            : static void
     882                 :          0 : cn10k_sso_txq_fc_update(const struct rte_eth_dev *eth_dev, int32_t tx_queue_id)
     883                 :            : {
     884                 :          0 :         struct cnxk_eth_dev *cnxk_eth_dev = eth_dev->data->dev_private;
     885                 :            :         struct cn10k_eth_txq *txq;
     886                 :            :         struct roc_nix_sq *sq;
     887                 :            :         int i;
     888                 :            : 
     889         [ #  # ]:          0 :         if (tx_queue_id < 0) {
     890         [ #  # ]:          0 :                 for (i = 0; i < eth_dev->data->nb_tx_queues; i++)
     891                 :          0 :                         cn10k_sso_txq_fc_update(eth_dev, i);
     892                 :            :         } else {
     893                 :            :                 uint16_t sqes_per_sqb;
     894                 :            : 
     895                 :          0 :                 sq = &cnxk_eth_dev->sqs[tx_queue_id];
     896                 :          0 :                 txq = eth_dev->data->tx_queues[tx_queue_id];
     897                 :          0 :                 sqes_per_sqb = 1U << txq->sqes_per_sqb_log2;
     898         [ #  # ]:          0 :                 if (cnxk_eth_dev->tx_offloads & RTE_ETH_TX_OFFLOAD_SECURITY)
     899                 :          0 :                         sq->nb_sqb_bufs_adj -= (cnxk_eth_dev->outb.nb_desc / sqes_per_sqb);
     900                 :          0 :                 txq->nb_sqb_bufs_adj = sq->nb_sqb_bufs_adj;
     901                 :            :         }
     902                 :          0 : }
     903                 :            : 
     904                 :            : static int
     905                 :          0 : cn10k_sso_tx_adapter_queue_add(uint8_t id, const struct rte_eventdev *event_dev,
     906                 :            :                                const struct rte_eth_dev *eth_dev,
     907                 :            :                                int32_t tx_queue_id)
     908                 :            : {
     909                 :          0 :         struct cnxk_eth_dev *cnxk_eth_dev = eth_dev->data->dev_private;
     910                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
     911                 :            :         uint64_t tx_offloads;
     912                 :            :         int rc;
     913                 :            : 
     914                 :            :         RTE_SET_USED(id);
     915                 :          0 :         rc = cnxk_sso_tx_adapter_queue_add(event_dev, eth_dev, tx_queue_id);
     916         [ #  # ]:          0 :         if (rc < 0)
     917                 :            :                 return rc;
     918                 :            : 
     919                 :            :         /* Can't enable tstamp if all the ports don't have it enabled. */
     920                 :          0 :         tx_offloads = cnxk_eth_dev->tx_offload_flags;
     921         [ #  # ]:          0 :         if (dev->tx_adptr_configured) {
     922                 :          0 :                 uint8_t tstmp_req = !!(tx_offloads & NIX_TX_OFFLOAD_TSTAMP_F);
     923                 :            :                 uint8_t tstmp_ena =
     924                 :          0 :                         !!(dev->tx_offloads & NIX_TX_OFFLOAD_TSTAMP_F);
     925                 :            : 
     926         [ #  # ]:          0 :                 if (tstmp_ena && !tstmp_req)
     927                 :          0 :                         dev->tx_offloads &= ~(NIX_TX_OFFLOAD_TSTAMP_F);
     928         [ #  # ]:          0 :                 else if (!tstmp_ena && tstmp_req)
     929                 :          0 :                         tx_offloads &= ~(NIX_TX_OFFLOAD_TSTAMP_F);
     930                 :            :         }
     931                 :            : 
     932                 :          0 :         dev->tx_offloads |= tx_offloads;
     933                 :          0 :         cn10k_sso_txq_fc_update(eth_dev, tx_queue_id);
     934                 :          0 :         rc = cn10k_sso_updt_tx_adptr_data(event_dev);
     935         [ #  # ]:          0 :         if (rc < 0)
     936                 :            :                 return rc;
     937                 :            :         cn10k_sso_fp_fns_set((struct rte_eventdev *)(uintptr_t)event_dev);
     938                 :          0 :         dev->tx_adptr_configured = 1;
     939                 :            : 
     940                 :          0 :         return 0;
     941                 :            : }
     942                 :            : 
     943                 :            : static int
     944                 :          0 : cn10k_sso_tx_adapter_queue_del(uint8_t id, const struct rte_eventdev *event_dev,
     945                 :            :                                const struct rte_eth_dev *eth_dev,
     946                 :            :                                int32_t tx_queue_id)
     947                 :            : {
     948                 :            :         int rc;
     949                 :            : 
     950                 :            :         RTE_SET_USED(id);
     951                 :          0 :         rc = cnxk_sso_tx_adapter_queue_del(event_dev, eth_dev, tx_queue_id);
     952         [ #  # ]:          0 :         if (rc < 0)
     953                 :            :                 return rc;
     954                 :          0 :         return cn10k_sso_updt_tx_adptr_data(event_dev);
     955                 :            : }
     956                 :            : 
     957                 :            : static int
     958                 :          0 : cn10k_crypto_adapter_caps_get(const struct rte_eventdev *event_dev,
     959                 :            :                               const struct rte_cryptodev *cdev, uint32_t *caps)
     960                 :            : {
     961         [ #  # ]:          0 :         CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn10k", ENOTSUP);
     962         [ #  # ]:          0 :         CNXK_VALID_DEV_OR_ERR_RET(cdev->device, "crypto_cn10k", ENOTSUP);
     963                 :            : 
     964                 :          0 :         *caps = RTE_EVENT_CRYPTO_ADAPTER_CAP_INTERNAL_PORT_OP_FWD |
     965                 :            :                 RTE_EVENT_CRYPTO_ADAPTER_CAP_SESSION_PRIVATE_DATA |
     966                 :            :                 RTE_EVENT_CRYPTO_ADAPTER_CAP_EVENT_VECTOR;
     967                 :            : 
     968                 :          0 :         return 0;
     969                 :            : }
     970                 :            : 
     971                 :            : static int
     972                 :          0 : cn10k_crypto_adapter_qp_add(const struct rte_eventdev *event_dev,
     973                 :            :                             const struct rte_cryptodev *cdev,
     974                 :            :                             int32_t queue_pair_id,
     975                 :            :                             const struct rte_event_crypto_adapter_queue_conf *conf)
     976                 :            : {
     977                 :            :         int ret;
     978                 :            : 
     979         [ #  # ]:          0 :         CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn10k", EINVAL);
     980         [ #  # ]:          0 :         CNXK_VALID_DEV_OR_ERR_RET(cdev->device, "crypto_cn10k", EINVAL);
     981                 :            : 
     982                 :            :         cn10k_sso_fp_fns_set((struct rte_eventdev *)(uintptr_t)event_dev);
     983                 :            : 
     984                 :          0 :         ret = cnxk_crypto_adapter_qp_add(event_dev, cdev, queue_pair_id, conf);
     985                 :            :         cn10k_sso_set_priv_mem(event_dev, NULL);
     986                 :            : 
     987                 :            :         return ret;
     988                 :            : }
     989                 :            : 
     990                 :            : static int
     991                 :          0 : cn10k_crypto_adapter_qp_del(const struct rte_eventdev *event_dev, const struct rte_cryptodev *cdev,
     992                 :            :                             int32_t queue_pair_id)
     993                 :            : {
     994         [ #  # ]:          0 :         CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn10k", EINVAL);
     995         [ #  # ]:          0 :         CNXK_VALID_DEV_OR_ERR_RET(cdev->device, "crypto_cn10k", EINVAL);
     996                 :            : 
     997                 :          0 :         return cnxk_crypto_adapter_qp_del(cdev, queue_pair_id);
     998                 :            : }
     999                 :            : 
    1000                 :            : static int
    1001                 :          0 : cn10k_tim_caps_get(const struct rte_eventdev *evdev, uint64_t flags,
    1002                 :            :                    uint32_t *caps, const struct event_timer_adapter_ops **ops)
    1003                 :            : {
    1004                 :          0 :         return cnxk_tim_caps_get(evdev, flags, caps, ops,
    1005                 :            :                                  cn10k_sso_set_priv_mem);
    1006                 :            : }
    1007                 :            : 
    1008                 :            : static int
    1009                 :          0 : cn10k_crypto_adapter_vec_limits(const struct rte_eventdev *event_dev,
    1010                 :            :                                 const struct rte_cryptodev *cdev,
    1011                 :            :                                 struct rte_event_crypto_adapter_vector_limits *limits)
    1012                 :            : {
    1013         [ #  # ]:          0 :         CNXK_VALID_DEV_OR_ERR_RET(event_dev->dev, "event_cn10k", EINVAL);
    1014         [ #  # ]:          0 :         CNXK_VALID_DEV_OR_ERR_RET(cdev->device, "crypto_cn10k", EINVAL);
    1015                 :            : 
    1016                 :          0 :         limits->log2_sz = false;
    1017                 :          0 :         limits->min_sz = 0;
    1018                 :          0 :         limits->max_sz = UINT16_MAX;
    1019                 :            :         /* Unused timeout, in software implementation we aggregate all crypto
    1020                 :            :          * operations passed to the enqueue function
    1021                 :            :          */
    1022                 :          0 :         limits->min_timeout_ns = 0;
    1023                 :          0 :         limits->max_timeout_ns = 0;
    1024                 :            : 
    1025                 :          0 :         return 0;
    1026                 :            : }
    1027                 :            : 
    1028                 :            : static int
    1029                 :          0 : cn10k_dma_adapter_caps_get(const struct rte_eventdev *event_dev,
    1030                 :            :                            const int16_t dma_dev_id, uint32_t *caps)
    1031                 :            : {
    1032                 :            :         struct rte_dma_dev *dma_dev;
    1033                 :            : 
    1034                 :            :         RTE_SET_USED(event_dev);
    1035                 :            : 
    1036                 :          0 :         dma_dev = rte_dma_pmd_get_dev_by_id(dma_dev_id);
    1037         [ #  # ]:          0 :         if (dma_dev == NULL)
    1038                 :            :                 return -EINVAL;
    1039                 :            : 
    1040         [ #  # ]:          0 :         CNXK_VALID_DEV_OR_ERR_RET(dma_dev->device, "cnxk_dmadev_pci_driver", EINVAL);
    1041                 :            : 
    1042                 :          0 :         *caps = RTE_EVENT_DMA_ADAPTER_CAP_INTERNAL_PORT_OP_FWD;
    1043                 :            : 
    1044                 :          0 :         return 0;
    1045                 :            : }
    1046                 :            : 
    1047                 :            : static int
    1048                 :          0 : cn10k_dma_adapter_vchan_add(const struct rte_eventdev *event_dev,
    1049                 :            :                             const int16_t dma_dev_id, uint16_t vchan_id,
    1050                 :            :                             const struct rte_event *event)
    1051                 :            : {
    1052                 :            :         struct rte_dma_dev *dma_dev;
    1053                 :            :         int ret;
    1054                 :            : 
    1055                 :            :         RTE_SET_USED(event);
    1056                 :          0 :         dma_dev = rte_dma_pmd_get_dev_by_id(dma_dev_id);
    1057         [ #  # ]:          0 :         if (dma_dev == NULL)
    1058                 :            :                 return -EINVAL;
    1059                 :            : 
    1060         [ #  # ]:          0 :         CNXK_VALID_DEV_OR_ERR_RET(dma_dev->device, "cnxk_dmadev_pci_driver", EINVAL);
    1061                 :            : 
    1062                 :            :         cn10k_sso_fp_fns_set((struct rte_eventdev *)(uintptr_t)event_dev);
    1063                 :            : 
    1064                 :          0 :         ret = cnxk_dma_adapter_vchan_add(event_dev, dma_dev_id, vchan_id);
    1065                 :            :         cn10k_sso_set_priv_mem(event_dev, NULL);
    1066                 :            : 
    1067                 :            :         return ret;
    1068                 :            : }
    1069                 :            : 
    1070                 :            : static int
    1071                 :          0 : cn10k_dma_adapter_vchan_del(const struct rte_eventdev *event_dev,
    1072                 :            :                             const int16_t dma_dev_id, uint16_t vchan_id)
    1073                 :            : {
    1074                 :            :         struct rte_dma_dev *dma_dev;
    1075                 :            : 
    1076                 :            :         RTE_SET_USED(event_dev);
    1077                 :            : 
    1078                 :          0 :         dma_dev = rte_dma_pmd_get_dev_by_id(dma_dev_id);
    1079         [ #  # ]:          0 :         if (dma_dev == NULL)
    1080                 :            :                 return -EINVAL;
    1081                 :            : 
    1082         [ #  # ]:          0 :         CNXK_VALID_DEV_OR_ERR_RET(dma_dev->device, "cnxk_dmadev_pci_driver", EINVAL);
    1083                 :            : 
    1084                 :          0 :         return cnxk_dma_adapter_vchan_del(dma_dev_id, vchan_id);
    1085                 :            : }
    1086                 :            : 
    1087                 :            : 
    1088                 :            : 
    1089                 :            : static struct eventdev_ops cn10k_sso_dev_ops = {
    1090                 :            :         .dev_infos_get = cn10k_sso_info_get,
    1091                 :            :         .dev_configure = cn10k_sso_dev_configure,
    1092                 :            : 
    1093                 :            :         .queue_def_conf = cnxk_sso_queue_def_conf,
    1094                 :            :         .queue_setup = cnxk_sso_queue_setup,
    1095                 :            :         .queue_release = cnxk_sso_queue_release,
    1096                 :            :         .queue_attr_set = cnxk_sso_queue_attribute_set,
    1097                 :            : 
    1098                 :            :         .port_def_conf = cnxk_sso_port_def_conf,
    1099                 :            :         .port_setup = cn10k_sso_port_setup,
    1100                 :            :         .port_release = cn10k_sso_port_release,
    1101                 :            :         .port_quiesce = cn10k_sso_port_quiesce,
    1102                 :            :         .port_link = cn10k_sso_port_link,
    1103                 :            :         .port_unlink = cn10k_sso_port_unlink,
    1104                 :            :         .port_link_profile = cn10k_sso_port_link_profile,
    1105                 :            :         .port_unlink_profile = cn10k_sso_port_unlink_profile,
    1106                 :            :         .timeout_ticks = cnxk_sso_timeout_ticks,
    1107                 :            : 
    1108                 :            :         .eth_rx_adapter_caps_get = cn10k_sso_rx_adapter_caps_get,
    1109                 :            :         .eth_rx_adapter_queue_add = cn10k_sso_rx_adapter_queue_add,
    1110                 :            :         .eth_rx_adapter_queue_del = cn10k_sso_rx_adapter_queue_del,
    1111                 :            :         .eth_rx_adapter_start = cnxk_sso_rx_adapter_start,
    1112                 :            :         .eth_rx_adapter_stop = cnxk_sso_rx_adapter_stop,
    1113                 :            : 
    1114                 :            :         .eth_rx_adapter_vector_limits_get = cn10k_sso_rx_adapter_vector_limits,
    1115                 :            : 
    1116                 :            :         .eth_tx_adapter_caps_get = cn10k_sso_tx_adapter_caps_get,
    1117                 :            :         .eth_tx_adapter_queue_add = cn10k_sso_tx_adapter_queue_add,
    1118                 :            :         .eth_tx_adapter_queue_del = cn10k_sso_tx_adapter_queue_del,
    1119                 :            :         .eth_tx_adapter_start = cnxk_sso_tx_adapter_start,
    1120                 :            :         .eth_tx_adapter_stop = cnxk_sso_tx_adapter_stop,
    1121                 :            :         .eth_tx_adapter_free = cnxk_sso_tx_adapter_free,
    1122                 :            : 
    1123                 :            :         .timer_adapter_caps_get = cn10k_tim_caps_get,
    1124                 :            : 
    1125                 :            :         .crypto_adapter_caps_get = cn10k_crypto_adapter_caps_get,
    1126                 :            :         .crypto_adapter_queue_pair_add = cn10k_crypto_adapter_qp_add,
    1127                 :            :         .crypto_adapter_queue_pair_del = cn10k_crypto_adapter_qp_del,
    1128                 :            :         .crypto_adapter_vector_limits_get = cn10k_crypto_adapter_vec_limits,
    1129                 :            : 
    1130                 :            :         .dma_adapter_caps_get = cn10k_dma_adapter_caps_get,
    1131                 :            :         .dma_adapter_vchan_add = cn10k_dma_adapter_vchan_add,
    1132                 :            :         .dma_adapter_vchan_del = cn10k_dma_adapter_vchan_del,
    1133                 :            : 
    1134                 :            :         .xstats_get = cnxk_sso_xstats_get,
    1135                 :            :         .xstats_reset = cnxk_sso_xstats_reset,
    1136                 :            :         .xstats_get_names = cnxk_sso_xstats_get_names,
    1137                 :            : 
    1138                 :            :         .dump = cnxk_sso_dump,
    1139                 :            :         .dev_start = cn10k_sso_start,
    1140                 :            :         .dev_stop = cn10k_sso_stop,
    1141                 :            :         .dev_close = cn10k_sso_close,
    1142                 :            :         .dev_selftest = cn10k_sso_selftest,
    1143                 :            : };
    1144                 :            : 
    1145                 :            : static int
    1146                 :          0 : cn10k_sso_init(struct rte_eventdev *event_dev)
    1147                 :            : {
    1148                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
    1149                 :            :         int rc;
    1150                 :            : 
    1151                 :          0 :         rc = roc_plt_init();
    1152         [ #  # ]:          0 :         if (rc < 0) {
    1153                 :          0 :                 plt_err("Failed to initialize platform model");
    1154                 :          0 :                 return rc;
    1155                 :            :         }
    1156                 :            : 
    1157                 :          0 :         event_dev->dev_ops = &cn10k_sso_dev_ops;
    1158                 :            :         /* For secondary processes, the primary has done all the work */
    1159         [ #  # ]:          0 :         if (rte_eal_process_type() != RTE_PROC_PRIMARY) {
    1160                 :            :                 cn10k_sso_fp_fns_set(event_dev);
    1161                 :            :                 return 0;
    1162                 :            :         }
    1163                 :            : 
    1164                 :          0 :         dev->gw_mode = CN10K_GW_MODE_PREF_WFE;
    1165                 :          0 :         rc = cnxk_sso_init(event_dev);
    1166         [ #  # ]:          0 :         if (rc < 0)
    1167                 :            :                 return rc;
    1168                 :            : 
    1169                 :            :         cn10k_sso_set_rsrc(cnxk_sso_pmd_priv(event_dev));
    1170   [ #  #  #  # ]:          0 :         if (!dev->max_event_ports || !dev->max_event_queues) {
    1171                 :          0 :                 plt_err("Not enough eventdev resource queues=%d ports=%d",
    1172                 :            :                         dev->max_event_queues, dev->max_event_ports);
    1173                 :          0 :                 cnxk_sso_fini(event_dev);
    1174                 :          0 :                 return -ENODEV;
    1175                 :            :         }
    1176                 :            : 
    1177                 :          0 :         plt_sso_dbg("Initializing %s max_queues=%d max_ports=%d",
    1178                 :            :                     event_dev->data->name, dev->max_event_queues,
    1179                 :            :                     dev->max_event_ports);
    1180                 :            : 
    1181                 :          0 :         return 0;
    1182                 :            : }
    1183                 :            : 
    1184                 :            : static int
    1185                 :          0 : cn10k_sso_probe(struct rte_pci_driver *pci_drv, struct rte_pci_device *pci_dev)
    1186                 :            : {
    1187                 :          0 :         return rte_event_pmd_pci_probe(pci_drv, pci_dev,
    1188                 :            :                                        sizeof(struct cnxk_sso_evdev),
    1189                 :            :                                        cn10k_sso_init);
    1190                 :            : }
    1191                 :            : 
    1192                 :            : static const struct rte_pci_id cn10k_pci_sso_map[] = {
    1193                 :            :         CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CN10KA, PCI_DEVID_CNXK_RVU_SSO_TIM_PF),
    1194                 :            :         CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CN10KAS, PCI_DEVID_CNXK_RVU_SSO_TIM_PF),
    1195                 :            :         CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CNF10KA, PCI_DEVID_CNXK_RVU_SSO_TIM_PF),
    1196                 :            :         CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CN10KB, PCI_DEVID_CNXK_RVU_SSO_TIM_PF),
    1197                 :            :         CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CNF10KB, PCI_DEVID_CNXK_RVU_SSO_TIM_PF),
    1198                 :            :         CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CN10KA, PCI_DEVID_CNXK_RVU_SSO_TIM_VF),
    1199                 :            :         CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CN10KAS, PCI_DEVID_CNXK_RVU_SSO_TIM_VF),
    1200                 :            :         CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CNF10KA, PCI_DEVID_CNXK_RVU_SSO_TIM_VF),
    1201                 :            :         CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CN10KB, PCI_DEVID_CNXK_RVU_SSO_TIM_VF),
    1202                 :            :         CNXK_PCI_ID(PCI_SUBSYSTEM_DEVID_CNF10KB, PCI_DEVID_CNXK_RVU_SSO_TIM_VF),
    1203                 :            :         {
    1204                 :            :                 .vendor_id = 0,
    1205                 :            :         },
    1206                 :            : };
    1207                 :            : 
    1208                 :            : static struct rte_pci_driver cn10k_pci_sso = {
    1209                 :            :         .id_table = cn10k_pci_sso_map,
    1210                 :            :         .drv_flags = RTE_PCI_DRV_NEED_MAPPING | RTE_PCI_DRV_NEED_IOVA_AS_VA,
    1211                 :            :         .probe = cn10k_sso_probe,
    1212                 :            :         .remove = cnxk_sso_remove,
    1213                 :            : };
    1214                 :            : 
    1215                 :        238 : RTE_PMD_REGISTER_PCI(event_cn10k, cn10k_pci_sso);
    1216                 :            : RTE_PMD_REGISTER_PCI_TABLE(event_cn10k, cn10k_pci_sso_map);
    1217                 :            : RTE_PMD_REGISTER_KMOD_DEP(event_cn10k, "vfio-pci");
    1218                 :            : RTE_PMD_REGISTER_PARAM_STRING(event_cn10k, CNXK_SSO_XAE_CNT "=<int>"
    1219                 :            :                               CNXK_SSO_GGRP_QOS "=<string>"
    1220                 :            :                               CNXK_SSO_FORCE_BP "=1"
    1221                 :            :                               CN10K_SSO_GW_MODE "=<int>"
    1222                 :            :                               CN10K_SSO_STASH "=<string>"
    1223                 :            :                               CNXK_TIM_DISABLE_NPA "=1"
    1224                 :            :                               CNXK_TIM_CHNK_SLOTS "=<int>"
    1225                 :            :                               CNXK_TIM_RINGS_LMT "=<int>"
    1226                 :            :                               CNXK_TIM_STATS_ENA "=1"
    1227                 :            :                               CNXK_TIM_EXT_CLK "=<string>");

Generated by: LCOV version 1.14