LCOV - code coverage report
Current view: top level - drivers/event/cnxk - cnxk_eventdev.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 336 0.0 %
Date: 2024-01-22 16:13:49 Functions: 0 29 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 136 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(C) 2021 Marvell.
       3                 :            :  */
       4                 :            : 
       5                 :            : #include "roc_npa.h"
       6                 :            : 
       7                 :            : #include "cnxk_eventdev.h"
       8                 :            : #include "cnxk_eventdev_dp.h"
       9                 :            : 
      10                 :            : void
      11                 :          0 : cnxk_sso_info_get(struct cnxk_sso_evdev *dev,
      12                 :            :                   struct rte_event_dev_info *dev_info)
      13                 :            : {
      14                 :            : 
      15                 :          0 :         dev_info->min_dequeue_timeout_ns = dev->min_dequeue_timeout_ns;
      16                 :          0 :         dev_info->max_dequeue_timeout_ns = dev->max_dequeue_timeout_ns;
      17                 :          0 :         dev_info->max_event_queues = dev->max_event_queues;
      18                 :          0 :         dev_info->max_event_queue_flows = (1ULL << 20);
      19                 :          0 :         dev_info->max_event_queue_priority_levels = 8;
      20                 :          0 :         dev_info->max_event_priority_levels = 1;
      21                 :          0 :         dev_info->max_event_ports = dev->max_event_ports;
      22                 :          0 :         dev_info->max_event_port_dequeue_depth = 1;
      23                 :          0 :         dev_info->max_event_port_enqueue_depth = 1;
      24                 :          0 :         dev_info->max_num_events = dev->max_num_events;
      25                 :          0 :         dev_info->event_dev_cap = RTE_EVENT_DEV_CAP_QUEUE_QOS |
      26                 :            :                                   RTE_EVENT_DEV_CAP_DISTRIBUTED_SCHED |
      27                 :            :                                   RTE_EVENT_DEV_CAP_QUEUE_ALL_TYPES |
      28                 :            :                                   RTE_EVENT_DEV_CAP_RUNTIME_PORT_LINK |
      29                 :            :                                   RTE_EVENT_DEV_CAP_MULTIPLE_QUEUE_PORT |
      30                 :            :                                   RTE_EVENT_DEV_CAP_NONSEQ_MODE |
      31                 :            :                                   RTE_EVENT_DEV_CAP_CARRY_FLOW_ID |
      32                 :            :                                   RTE_EVENT_DEV_CAP_MAINTENANCE_FREE |
      33                 :            :                                   RTE_EVENT_DEV_CAP_RUNTIME_QUEUE_ATTR |
      34                 :            :                                   RTE_EVENT_DEV_CAP_PROFILE_LINK;
      35                 :          0 :         dev_info->max_profiles_per_port = CNXK_SSO_MAX_PROFILES;
      36                 :          0 : }
      37                 :            : 
      38                 :            : int
      39                 :          0 : cnxk_sso_xaq_allocate(struct cnxk_sso_evdev *dev)
      40                 :            : {
      41                 :            :         uint32_t xae_cnt;
      42                 :            :         int rc;
      43                 :            : 
      44         [ #  # ]:          0 :         if (dev->num_events > 0)
      45                 :          0 :                 xae_cnt = dev->num_events;
      46                 :            :         else
      47                 :          0 :                 xae_cnt = dev->sso.iue;
      48                 :            : 
      49         [ #  # ]:          0 :         if (dev->xae_cnt)
      50                 :          0 :                 xae_cnt += dev->xae_cnt;
      51         [ #  # ]:          0 :         if (dev->adptr_xae_cnt)
      52                 :          0 :                 xae_cnt += (dev->adptr_xae_cnt);
      53                 :            : 
      54                 :          0 :         plt_sso_dbg("Configuring %d xae buffers", xae_cnt);
      55                 :          0 :         rc = roc_sso_hwgrp_init_xaq_aura(&dev->sso, xae_cnt);
      56         [ #  # ]:          0 :         if (rc < 0) {
      57                 :          0 :                 plt_err("Failed to configure XAQ aura");
      58                 :          0 :                 return rc;
      59                 :            :         }
      60                 :          0 :         dev->xaq_lmt = dev->sso.xaq.xaq_lmt;
      61                 :          0 :         dev->fc_iova = (uint64_t)dev->sso.xaq.fc;
      62                 :            : 
      63                 :          0 :         return roc_sso_hwgrp_alloc_xaq(
      64                 :            :                 &dev->sso,
      65                 :          0 :                 roc_npa_aura_handle_to_aura(dev->sso.xaq.aura_handle),
      66                 :          0 :                 dev->nb_event_queues);
      67                 :            : }
      68                 :            : 
      69                 :            : int
      70         [ #  # ]:          0 : cnxk_sso_xae_reconfigure(struct rte_eventdev *event_dev)
      71                 :            : {
      72                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
      73                 :            :         int rc = 0;
      74                 :            : 
      75         [ #  # ]:          0 :         if (event_dev->data->dev_started)
      76                 :          0 :                 event_dev->dev_ops->dev_stop(event_dev);
      77                 :            : 
      78                 :          0 :         rc = cnxk_sso_xaq_allocate(dev);
      79         [ #  # ]:          0 :         if (rc < 0) {
      80                 :          0 :                 plt_err("Failed to alloc XAQ %d", rc);
      81                 :          0 :                 return rc;
      82                 :            :         }
      83                 :            : 
      84                 :            :         rte_mb();
      85         [ #  # ]:          0 :         if (event_dev->data->dev_started)
      86                 :          0 :                 event_dev->dev_ops->dev_start(event_dev);
      87                 :            : 
      88                 :            :         return 0;
      89                 :            : }
      90                 :            : 
      91                 :            : int
      92                 :          0 : cnxk_setup_event_ports(const struct rte_eventdev *event_dev,
      93                 :            :                        cnxk_sso_init_hws_mem_t init_hws_fn,
      94                 :            :                        cnxk_sso_hws_setup_t setup_hws_fn)
      95                 :            : {
      96                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
      97                 :            :         int i;
      98                 :            : 
      99         [ #  # ]:          0 :         for (i = 0; i < dev->nb_event_ports; i++) {
     100                 :            :                 struct cnxk_sso_hws_cookie *ws_cookie;
     101                 :            :                 void *ws;
     102                 :            : 
     103                 :            :                 /* Free memory prior to re-allocation if needed */
     104         [ #  # ]:          0 :                 if (event_dev->data->ports[i] != NULL)
     105                 :            :                         ws = event_dev->data->ports[i];
     106                 :            :                 else
     107                 :          0 :                         ws = init_hws_fn(dev, i);
     108         [ #  # ]:          0 :                 if (ws == NULL)
     109                 :          0 :                         goto hws_fini;
     110                 :            :                 ws_cookie = cnxk_sso_hws_get_cookie(ws);
     111                 :          0 :                 ws_cookie->event_dev = event_dev;
     112                 :          0 :                 ws_cookie->configured = 1;
     113                 :          0 :                 event_dev->data->ports[i] = ws;
     114                 :          0 :                 cnxk_sso_port_setup((struct rte_eventdev *)(uintptr_t)event_dev,
     115                 :            :                                     i, setup_hws_fn);
     116                 :            :         }
     117                 :            : 
     118                 :            :         return 0;
     119                 :            : hws_fini:
     120         [ #  # ]:          0 :         for (i = i - 1; i >= 0; i--) {
     121                 :          0 :                 event_dev->data->ports[i] = NULL;
     122                 :          0 :                 rte_free(cnxk_sso_hws_get_cookie(event_dev->data->ports[i]));
     123                 :            :         }
     124                 :            :         return -ENOMEM;
     125                 :            : }
     126                 :            : 
     127                 :            : void
     128                 :          0 : cnxk_sso_restore_links(const struct rte_eventdev *event_dev,
     129                 :            :                        cnxk_sso_link_t link_fn)
     130                 :            : {
     131                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
     132                 :            :         uint16_t *links_map, hwgrp[CNXK_SSO_MAX_HWGRP];
     133                 :            :         int i, j, k;
     134                 :            : 
     135         [ #  # ]:          0 :         for (i = 0; i < dev->nb_event_ports; i++) {
     136         [ #  # ]:          0 :                 for (k = 0; k < CNXK_SSO_MAX_PROFILES; k++) {
     137                 :            :                         uint16_t nb_hwgrp = 0;
     138                 :            : 
     139                 :          0 :                         links_map = event_dev->data->links_map[k];
     140                 :            :                         /* Point links_map to this port specific area */
     141                 :          0 :                         links_map += (i * RTE_EVENT_MAX_QUEUES_PER_DEV);
     142                 :            : 
     143         [ #  # ]:          0 :                         for (j = 0; j < dev->nb_event_queues; j++) {
     144         [ #  # ]:          0 :                                 if (links_map[j] == 0xdead)
     145                 :          0 :                                         continue;
     146                 :          0 :                                 hwgrp[nb_hwgrp] = j;
     147                 :          0 :                                 nb_hwgrp++;
     148                 :            :                         }
     149                 :            : 
     150                 :          0 :                         link_fn(dev, event_dev->data->ports[i], hwgrp, nb_hwgrp, k);
     151                 :            :                 }
     152                 :            :         }
     153                 :          0 : }
     154                 :            : 
     155                 :            : int
     156                 :          0 : cnxk_sso_dev_validate(const struct rte_eventdev *event_dev, uint32_t deq_depth,
     157                 :            :                       uint32_t enq_depth)
     158                 :            : {
     159         [ #  # ]:          0 :         struct rte_event_dev_config *conf = &event_dev->data->dev_conf;
     160                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
     161                 :            :         uint32_t deq_tmo_ns;
     162                 :            : 
     163                 :          0 :         deq_tmo_ns = conf->dequeue_timeout_ns;
     164                 :            : 
     165         [ #  # ]:          0 :         if (deq_tmo_ns == 0)
     166                 :          0 :                 deq_tmo_ns = dev->min_dequeue_timeout_ns;
     167         [ #  # ]:          0 :         if (deq_tmo_ns < dev->min_dequeue_timeout_ns ||
     168         [ #  # ]:          0 :             deq_tmo_ns > dev->max_dequeue_timeout_ns) {
     169                 :          0 :                 plt_err("Unsupported dequeue timeout requested");
     170                 :          0 :                 return -EINVAL;
     171                 :            :         }
     172                 :            : 
     173         [ #  # ]:          0 :         if (conf->event_dev_cfg & RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT)
     174                 :          0 :                 dev->is_timeout_deq = 1;
     175                 :            : 
     176                 :          0 :         dev->deq_tmo_ns = deq_tmo_ns;
     177                 :            : 
     178   [ #  #  #  # ]:          0 :         if (!conf->nb_event_queues || !conf->nb_event_ports ||
     179         [ #  # ]:          0 :             conf->nb_event_ports > dev->max_event_ports ||
     180         [ #  # ]:          0 :             conf->nb_event_queues > dev->max_event_queues) {
     181                 :          0 :                 plt_err("Unsupported event queues/ports requested");
     182                 :          0 :                 return -EINVAL;
     183                 :            :         }
     184                 :            : 
     185         [ #  # ]:          0 :         if (conf->nb_event_port_dequeue_depth > deq_depth) {
     186                 :          0 :                 plt_err("Unsupported event port deq depth requested");
     187                 :          0 :                 return -EINVAL;
     188                 :            :         }
     189                 :            : 
     190         [ #  # ]:          0 :         if (conf->nb_event_port_enqueue_depth > enq_depth) {
     191                 :          0 :                 plt_err("Unsupported event port enq depth requested");
     192                 :          0 :                 return -EINVAL;
     193                 :            :         }
     194                 :            : 
     195                 :          0 :         roc_sso_rsrc_fini(&dev->sso);
     196                 :          0 :         roc_sso_hwgrp_free_xaq_aura(&dev->sso, dev->sso.nb_hwgrp);
     197                 :            : 
     198                 :          0 :         dev->nb_event_queues = conf->nb_event_queues;
     199                 :          0 :         dev->nb_event_ports = conf->nb_event_ports;
     200                 :          0 :         dev->num_events = conf->nb_events_limit;
     201                 :            : 
     202                 :          0 :         return 0;
     203                 :            : }
     204                 :            : 
     205                 :            : void
     206                 :          0 : cnxk_sso_queue_def_conf(struct rte_eventdev *event_dev, uint8_t queue_id,
     207                 :            :                         struct rte_event_queue_conf *queue_conf)
     208                 :            : {
     209                 :            :         RTE_SET_USED(event_dev);
     210                 :            :         RTE_SET_USED(queue_id);
     211                 :            : 
     212                 :          0 :         queue_conf->nb_atomic_flows = (1ULL << 20);
     213                 :          0 :         queue_conf->nb_atomic_order_sequences = (1ULL << 20);
     214                 :          0 :         queue_conf->event_queue_cfg = RTE_EVENT_QUEUE_CFG_ALL_TYPES;
     215                 :          0 :         queue_conf->priority = RTE_EVENT_DEV_PRIORITY_NORMAL;
     216                 :          0 :         queue_conf->weight = RTE_EVENT_QUEUE_WEIGHT_LOWEST;
     217                 :          0 :         queue_conf->affinity = RTE_EVENT_QUEUE_AFFINITY_HIGHEST;
     218                 :          0 : }
     219                 :            : 
     220                 :            : int
     221                 :          0 : cnxk_sso_queue_setup(struct rte_eventdev *event_dev, uint8_t queue_id,
     222                 :            :                      const struct rte_event_queue_conf *queue_conf)
     223                 :            : {
     224                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
     225                 :            :         uint8_t priority, weight, affinity;
     226                 :            : 
     227                 :          0 :         priority = CNXK_QOS_NORMALIZE(queue_conf->priority, 0,
     228                 :            :                                       RTE_EVENT_DEV_PRIORITY_LOWEST,
     229                 :            :                                       CNXK_SSO_PRIORITY_CNT);
     230                 :          0 :         weight = CNXK_QOS_NORMALIZE(queue_conf->weight, CNXK_SSO_WEIGHT_MIN,
     231                 :            :                                     RTE_EVENT_QUEUE_WEIGHT_HIGHEST, CNXK_SSO_WEIGHT_CNT);
     232                 :          0 :         affinity = CNXK_QOS_NORMALIZE(queue_conf->affinity, 0, RTE_EVENT_QUEUE_AFFINITY_HIGHEST,
     233                 :            :                                       CNXK_SSO_AFFINITY_CNT);
     234                 :            : 
     235                 :          0 :         plt_sso_dbg("Queue=%u prio=%u weight=%u affinity=%u", queue_id,
     236                 :            :                     priority, weight, affinity);
     237                 :            : 
     238                 :          0 :         return roc_sso_hwgrp_set_priority(&dev->sso, queue_id, weight, affinity,
     239                 :            :                                           priority);
     240                 :            : }
     241                 :            : 
     242                 :            : void
     243                 :          0 : cnxk_sso_queue_release(struct rte_eventdev *event_dev, uint8_t queue_id)
     244                 :            : {
     245                 :            :         RTE_SET_USED(event_dev);
     246                 :            :         RTE_SET_USED(queue_id);
     247                 :          0 : }
     248                 :            : 
     249                 :            : int
     250   [ #  #  #  #  :          0 : cnxk_sso_queue_attribute_set(struct rte_eventdev *event_dev, uint8_t queue_id,
                      # ]
     251                 :            :                              uint32_t attr_id, uint64_t attr_value)
     252                 :            : {
     253                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
     254                 :            :         uint8_t priority, weight, affinity;
     255                 :            :         struct rte_event_queue_conf *conf;
     256                 :            : 
     257                 :          0 :         conf = &event_dev->data->queues_cfg[queue_id];
     258                 :            : 
     259   [ #  #  #  #  :          0 :         switch (attr_id) {
                      # ]
     260                 :          0 :         case RTE_EVENT_QUEUE_ATTR_PRIORITY:
     261                 :          0 :                 conf->priority = attr_value;
     262                 :          0 :                 break;
     263                 :          0 :         case RTE_EVENT_QUEUE_ATTR_WEIGHT:
     264                 :          0 :                 conf->weight = attr_value;
     265                 :          0 :                 break;
     266                 :          0 :         case RTE_EVENT_QUEUE_ATTR_AFFINITY:
     267                 :          0 :                 conf->affinity = attr_value;
     268                 :          0 :                 break;
     269                 :          0 :         case RTE_EVENT_QUEUE_ATTR_NB_ATOMIC_FLOWS:
     270                 :            :         case RTE_EVENT_QUEUE_ATTR_NB_ATOMIC_ORDER_SEQUENCES:
     271                 :            :         case RTE_EVENT_QUEUE_ATTR_EVENT_QUEUE_CFG:
     272                 :            :         case RTE_EVENT_QUEUE_ATTR_SCHEDULE_TYPE:
     273                 :            :                 /* FALLTHROUGH */
     274                 :          0 :                 plt_sso_dbg("Unsupported attribute id %u", attr_id);
     275                 :          0 :                 return -ENOTSUP;
     276                 :          0 :         default:
     277                 :          0 :                 plt_err("Invalid attribute id %u", attr_id);
     278                 :          0 :                 return -EINVAL;
     279                 :            :         }
     280                 :            : 
     281                 :          0 :         priority = CNXK_QOS_NORMALIZE(conf->priority, 0,
     282                 :            :                                       RTE_EVENT_DEV_PRIORITY_LOWEST,
     283                 :            :                                       CNXK_SSO_PRIORITY_CNT);
     284                 :          0 :         weight = CNXK_QOS_NORMALIZE(conf->weight, CNXK_SSO_WEIGHT_MIN,
     285                 :            :                                     RTE_EVENT_QUEUE_WEIGHT_HIGHEST, CNXK_SSO_WEIGHT_CNT);
     286                 :          0 :         affinity = CNXK_QOS_NORMALIZE(conf->affinity, 0, RTE_EVENT_QUEUE_AFFINITY_HIGHEST,
     287                 :            :                                       CNXK_SSO_AFFINITY_CNT);
     288                 :            : 
     289                 :          0 :         return roc_sso_hwgrp_set_priority(&dev->sso, queue_id, weight, affinity,
     290                 :            :                                           priority);
     291                 :            : }
     292                 :            : 
     293                 :            : void
     294                 :          0 : cnxk_sso_port_def_conf(struct rte_eventdev *event_dev, uint8_t port_id,
     295                 :            :                        struct rte_event_port_conf *port_conf)
     296                 :            : {
     297                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
     298                 :            : 
     299                 :            :         RTE_SET_USED(port_id);
     300                 :          0 :         port_conf->new_event_threshold = dev->max_num_events;
     301                 :          0 :         port_conf->dequeue_depth = 1;
     302                 :          0 :         port_conf->enqueue_depth = 1;
     303                 :          0 : }
     304                 :            : 
     305                 :            : int
     306                 :          0 : cnxk_sso_port_setup(struct rte_eventdev *event_dev, uint8_t port_id,
     307                 :            :                     cnxk_sso_hws_setup_t hws_setup_fn)
     308                 :            : {
     309                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
     310                 :            :         uintptr_t grp_base = 0;
     311                 :            : 
     312                 :          0 :         plt_sso_dbg("Port=%d", port_id);
     313         [ #  # ]:          0 :         if (event_dev->data->ports[port_id] == NULL) {
     314                 :          0 :                 plt_err("Invalid port Id %d", port_id);
     315                 :          0 :                 return -EINVAL;
     316                 :            :         }
     317                 :            : 
     318                 :          0 :         grp_base = roc_sso_hwgrp_base_get(&dev->sso, 0);
     319         [ #  # ]:          0 :         if (grp_base == 0) {
     320                 :          0 :                 plt_err("Failed to get grp base addr");
     321                 :          0 :                 return -EINVAL;
     322                 :            :         }
     323                 :            : 
     324                 :          0 :         hws_setup_fn(dev, event_dev->data->ports[port_id], grp_base);
     325                 :          0 :         plt_sso_dbg("Port=%d ws=%p", port_id, event_dev->data->ports[port_id]);
     326                 :            :         rte_mb();
     327                 :            : 
     328                 :          0 :         return 0;
     329                 :            : }
     330                 :            : 
     331                 :            : int
     332         [ #  # ]:          0 : cnxk_sso_timeout_ticks(struct rte_eventdev *event_dev, uint64_t ns,
     333                 :            :                        uint64_t *tmo_ticks)
     334                 :            : {
     335                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
     336                 :            : 
     337         [ #  # ]:          0 :         *tmo_ticks = dev->deq_tmo_ns ? ns / dev->deq_tmo_ns : 0;
     338                 :          0 :         return 0;
     339                 :            : }
     340                 :            : 
     341                 :            : void
     342                 :          0 : cnxk_sso_dump(struct rte_eventdev *event_dev, FILE *f)
     343                 :            : {
     344                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
     345                 :            : 
     346                 :          0 :         roc_sso_dump(&dev->sso, dev->sso.nb_hws, dev->sso.nb_hwgrp, f);
     347                 :          0 : }
     348                 :            : 
     349                 :            : static void
     350                 :          0 : cnxk_handle_event(void *arg, struct rte_event event)
     351                 :            : {
     352                 :            :         struct rte_eventdev *event_dev = arg;
     353                 :            : 
     354         [ #  # ]:          0 :         if (event_dev->dev_ops->dev_stop_flush != NULL)
     355                 :          0 :                 event_dev->dev_ops->dev_stop_flush(
     356                 :          0 :                         event_dev->data->dev_id, event,
     357                 :          0 :                         event_dev->data->dev_stop_flush_arg);
     358                 :          0 : }
     359                 :            : 
     360                 :            : static void
     361                 :          0 : cnxk_sso_cleanup(struct rte_eventdev *event_dev, cnxk_sso_hws_reset_t reset_fn,
     362                 :            :                  cnxk_sso_hws_flush_t flush_fn, uint8_t enable)
     363                 :            : {
     364                 :            :         uint8_t pend_list[RTE_EVENT_MAX_QUEUES_PER_DEV], pend_cnt, new_pcnt;
     365                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
     366                 :            :         uintptr_t hwgrp_base;
     367                 :            :         uint8_t queue_id, i;
     368                 :            :         void *ws;
     369                 :            : 
     370         [ #  # ]:          0 :         for (i = 0; i < dev->nb_event_ports; i++) {
     371                 :          0 :                 ws = event_dev->data->ports[i];
     372                 :          0 :                 reset_fn(dev, ws);
     373                 :            :         }
     374                 :            : 
     375                 :            :         rte_mb();
     376                 :            : 
     377                 :            :         /* Consume all the events through HWS0 */
     378                 :          0 :         ws = event_dev->data->ports[0];
     379                 :            : 
     380                 :            :         /* Starting list of queues to flush */
     381                 :          0 :         pend_cnt = dev->nb_event_queues;
     382         [ #  # ]:          0 :         for (i = 0; i < dev->nb_event_queues; i++)
     383                 :          0 :                 pend_list[i] = i;
     384                 :            : 
     385         [ #  # ]:          0 :         while (pend_cnt) {
     386                 :            :                 new_pcnt = 0;
     387         [ #  # ]:          0 :                 for (i = 0; i < pend_cnt; i++) {
     388                 :          0 :                         queue_id = pend_list[i];
     389                 :            :                         hwgrp_base =
     390                 :          0 :                                 roc_sso_hwgrp_base_get(&dev->sso, queue_id);
     391         [ #  # ]:          0 :                         if (flush_fn(ws, queue_id, hwgrp_base,
     392                 :            :                                      cnxk_handle_event, event_dev)) {
     393                 :          0 :                                 pend_list[new_pcnt++] = queue_id;
     394                 :          0 :                                 continue;
     395                 :            :                         }
     396                 :            :                         /* Enable/Disable SSO GGRP */
     397                 :          0 :                         plt_write64(enable, hwgrp_base + SSO_LF_GGRP_QCTL);
     398                 :            :                 }
     399                 :            :                 pend_cnt = new_pcnt;
     400                 :            :         }
     401                 :          0 : }
     402                 :            : 
     403                 :            : int
     404                 :          0 : cnxk_sso_start(struct rte_eventdev *event_dev, cnxk_sso_hws_reset_t reset_fn,
     405                 :            :                cnxk_sso_hws_flush_t flush_fn)
     406                 :          0 : {
     407                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
     408                 :          0 :         struct roc_sso_hwgrp_qos qos[dev->qos_queue_cnt];
     409                 :            :         int i, rc;
     410                 :            : 
     411                 :          0 :         plt_sso_dbg();
     412         [ #  # ]:          0 :         for (i = 0; i < dev->qos_queue_cnt; i++) {
     413                 :          0 :                 qos[i].hwgrp = dev->qos_parse_data[i].queue;
     414                 :          0 :                 qos[i].iaq_prcnt = dev->qos_parse_data[i].iaq_prcnt;
     415                 :          0 :                 qos[i].taq_prcnt = dev->qos_parse_data[i].taq_prcnt;
     416                 :            :         }
     417                 :          0 :         rc = roc_sso_hwgrp_qos_config(&dev->sso, qos, dev->qos_queue_cnt);
     418         [ #  # ]:          0 :         if (rc < 0) {
     419                 :          0 :                 plt_sso_dbg("failed to configure HWGRP QoS rc = %d", rc);
     420                 :          0 :                 return -EINVAL;
     421                 :            :         }
     422                 :          0 :         cnxk_sso_cleanup(event_dev, reset_fn, flush_fn, true);
     423                 :            :         rte_mb();
     424                 :            : 
     425                 :          0 :         return 0;
     426                 :            : }
     427                 :            : 
     428                 :            : void
     429                 :          0 : cnxk_sso_stop(struct rte_eventdev *event_dev, cnxk_sso_hws_reset_t reset_fn,
     430                 :            :               cnxk_sso_hws_flush_t flush_fn)
     431                 :            : {
     432                 :          0 :         plt_sso_dbg();
     433                 :          0 :         cnxk_sso_cleanup(event_dev, reset_fn, flush_fn, false);
     434                 :            :         rte_mb();
     435                 :          0 : }
     436                 :            : 
     437                 :            : int
     438         [ #  # ]:          0 : cnxk_sso_close(struct rte_eventdev *event_dev, cnxk_sso_unlink_t unlink_fn)
     439                 :            : {
     440                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
     441                 :            :         uint16_t all_queues[CNXK_SSO_MAX_HWGRP];
     442                 :            :         uint16_t i, j;
     443                 :            :         void *ws;
     444                 :            : 
     445         [ #  # ]:          0 :         if (!dev->configured)
     446                 :            :                 return 0;
     447                 :            : 
     448         [ #  # ]:          0 :         for (i = 0; i < dev->nb_event_queues; i++)
     449                 :          0 :                 all_queues[i] = i;
     450                 :            : 
     451         [ #  # ]:          0 :         for (i = 0; i < dev->nb_event_ports; i++) {
     452                 :          0 :                 ws = event_dev->data->ports[i];
     453         [ #  # ]:          0 :                 for (j = 0; j < CNXK_SSO_MAX_PROFILES; j++)
     454                 :          0 :                         unlink_fn(dev, ws, all_queues, dev->nb_event_queues, j);
     455                 :          0 :                 rte_free(cnxk_sso_hws_get_cookie(ws));
     456                 :          0 :                 event_dev->data->ports[i] = NULL;
     457                 :            :         }
     458                 :            : 
     459                 :          0 :         roc_sso_rsrc_fini(&dev->sso);
     460                 :            : 
     461                 :          0 :         dev->fc_iova = 0;
     462                 :          0 :         dev->configured = false;
     463                 :          0 :         dev->is_timeout_deq = 0;
     464                 :          0 :         dev->nb_event_ports = 0;
     465                 :          0 :         dev->max_num_events = -1;
     466                 :          0 :         dev->nb_event_queues = 0;
     467                 :          0 :         dev->min_dequeue_timeout_ns = USEC2NSEC(1);
     468                 :          0 :         dev->max_dequeue_timeout_ns = USEC2NSEC(0x3FF);
     469                 :            : 
     470                 :          0 :         return 0;
     471                 :            : }
     472                 :            : 
     473                 :            : typedef void (*param_parse_t)(char *value, void *opaque);
     474                 :            : 
     475                 :            : static void
     476                 :          0 : parse_queue_param(char *value, void *opaque)
     477                 :            : {
     478                 :          0 :         struct cnxk_sso_qos queue_qos = {0};
     479                 :            :         uint16_t *val = (uint16_t *)&queue_qos;
     480                 :            :         struct cnxk_sso_evdev *dev = opaque;
     481                 :          0 :         char *tok = strtok(value, "-");
     482                 :            :         struct cnxk_sso_qos *old_ptr;
     483                 :            : 
     484         [ #  # ]:          0 :         if (!strlen(value))
     485                 :          0 :                 return;
     486                 :            : 
     487         [ #  # ]:          0 :         while (tok != NULL) {
     488                 :          0 :                 *val = atoi(tok);
     489                 :          0 :                 tok = strtok(NULL, "-");
     490                 :          0 :                 val++;
     491                 :            :         }
     492                 :            : 
     493         [ #  # ]:          0 :         if (val != (&queue_qos.iaq_prcnt + 1)) {
     494                 :          0 :                 plt_err("Invalid QoS parameter expected [Qx-TAQ-IAQ]");
     495                 :          0 :                 return;
     496                 :            :         }
     497                 :            : 
     498                 :          0 :         dev->qos_queue_cnt++;
     499                 :          0 :         old_ptr = dev->qos_parse_data;
     500                 :          0 :         dev->qos_parse_data = rte_realloc(
     501                 :            :                 dev->qos_parse_data,
     502                 :          0 :                 sizeof(struct cnxk_sso_qos) * dev->qos_queue_cnt, 0);
     503         [ #  # ]:          0 :         if (dev->qos_parse_data == NULL) {
     504                 :          0 :                 dev->qos_parse_data = old_ptr;
     505                 :          0 :                 dev->qos_queue_cnt--;
     506                 :          0 :                 return;
     507                 :            :         }
     508                 :          0 :         dev->qos_parse_data[dev->qos_queue_cnt - 1] = queue_qos;
     509                 :            : }
     510                 :            : 
     511                 :            : static void
     512                 :          0 : parse_stash_param(char *value, void *opaque)
     513                 :            : {
     514                 :          0 :         struct cnxk_sso_stash queue_stash = {0};
     515                 :            :         struct cnxk_sso_evdev *dev = opaque;
     516                 :            :         struct cnxk_sso_stash *old_ptr;
     517                 :          0 :         char *tok = strtok(value, "|");
     518                 :            :         uint16_t *val;
     519                 :            : 
     520         [ #  # ]:          0 :         if (!strlen(value))
     521                 :          0 :                 return;
     522                 :            : 
     523                 :            :         val = (uint16_t *)&queue_stash;
     524         [ #  # ]:          0 :         while (tok != NULL) {
     525                 :          0 :                 *val = atoi(tok);
     526                 :          0 :                 tok = strtok(NULL, "|");
     527                 :          0 :                 val++;
     528                 :            :         }
     529                 :            : 
     530         [ #  # ]:          0 :         if (val != (&queue_stash.stash_length + 1)) {
     531                 :          0 :                 plt_err("Invalid QoS parameter expected [Qx|stash_offset|stash_length]");
     532                 :          0 :                 return;
     533                 :            :         }
     534                 :            : 
     535                 :          0 :         dev->stash_cnt++;
     536                 :          0 :         old_ptr = dev->stash_parse_data;
     537                 :          0 :         dev->stash_parse_data =
     538                 :          0 :                 rte_realloc(dev->stash_parse_data,
     539                 :          0 :                             sizeof(struct cnxk_sso_stash) * dev->stash_cnt, 0);
     540         [ #  # ]:          0 :         if (dev->stash_parse_data == NULL) {
     541                 :          0 :                 dev->stash_parse_data = old_ptr;
     542                 :          0 :                 dev->stash_cnt--;
     543                 :          0 :                 return;
     544                 :            :         }
     545                 :          0 :         dev->stash_parse_data[dev->stash_cnt - 1] = queue_stash;
     546                 :            : }
     547                 :            : 
     548                 :            : static void
     549                 :          0 : parse_list(const char *value, void *opaque, param_parse_t fn)
     550                 :            : {
     551                 :          0 :         char *s = strdup(value);
     552                 :            :         char *start = NULL;
     553                 :            :         char *end = NULL;
     554                 :            :         char *f = s;
     555                 :            : 
     556         [ #  # ]:          0 :         while (*s) {
     557         [ #  # ]:          0 :                 if (*s == '[')
     558                 :            :                         start = s;
     559         [ #  # ]:          0 :                 else if (*s == ']')
     560                 :            :                         end = s;
     561                 :            : 
     562         [ #  # ]:          0 :                 if (start && start < end) {
     563                 :          0 :                         *end = 0;
     564                 :          0 :                         fn(start + 1, opaque);
     565                 :            :                         s = end;
     566                 :            :                         start = end;
     567                 :            :                 }
     568                 :          0 :                 s++;
     569                 :            :         }
     570                 :            : 
     571                 :          0 :         free(f);
     572                 :          0 : }
     573                 :            : 
     574                 :            : static int
     575                 :          0 : parse_sso_kvargs_qos_dict(const char *key, const char *value, void *opaque)
     576                 :            : {
     577                 :            :         RTE_SET_USED(key);
     578                 :            : 
     579                 :            :         /* Dict format [Qx-TAQ-IAQ][Qz-TAQ-IAQ] use '-' cause ',' isn't allowed.
     580                 :            :          * Everything is expressed in percentages, 0 represents default.
     581                 :            :          */
     582                 :          0 :         parse_list(value, opaque, parse_queue_param);
     583                 :            : 
     584                 :          0 :         return 0;
     585                 :            : }
     586                 :            : 
     587                 :            : static int
     588                 :          0 : parse_sso_kvargs_stash_dict(const char *key, const char *value, void *opaque)
     589                 :            : {
     590                 :            :         RTE_SET_USED(key);
     591                 :            : 
     592                 :            :         /* Dict format [Qx|<stash_offset>|<stash_length>] use '|' cause ','
     593                 :            :          * isn't allowed.
     594                 :            :          */
     595                 :          0 :         parse_list(value, opaque, parse_stash_param);
     596                 :            : 
     597                 :          0 :         return 0;
     598                 :            : }
     599                 :            : 
     600                 :            : static void
     601                 :          0 : cnxk_sso_parse_devargs(struct cnxk_sso_evdev *dev, struct rte_devargs *devargs)
     602                 :            : {
     603                 :            :         struct rte_kvargs *kvlist;
     604                 :          0 :         uint8_t single_ws = 0;
     605                 :            : 
     606         [ #  # ]:          0 :         if (devargs == NULL)
     607                 :          0 :                 return;
     608                 :          0 :         kvlist = rte_kvargs_parse(devargs->args, NULL);
     609         [ #  # ]:          0 :         if (kvlist == NULL)
     610                 :            :                 return;
     611                 :            : 
     612                 :          0 :         rte_kvargs_process(kvlist, CNXK_SSO_XAE_CNT, &parse_kvargs_value,
     613                 :          0 :                            &dev->xae_cnt);
     614                 :          0 :         rte_kvargs_process(kvlist, CNXK_SSO_GGRP_QOS,
     615                 :            :                            &parse_sso_kvargs_qos_dict, dev);
     616                 :          0 :         rte_kvargs_process(kvlist, CNXK_SSO_FORCE_BP, &parse_kvargs_flag,
     617                 :          0 :                            &dev->force_ena_bp);
     618                 :          0 :         rte_kvargs_process(kvlist, CN9K_SSO_SINGLE_WS, &parse_kvargs_flag,
     619                 :            :                            &single_ws);
     620                 :          0 :         rte_kvargs_process(kvlist, CN10K_SSO_GW_MODE, &parse_kvargs_value,
     621                 :          0 :                            &dev->gw_mode);
     622                 :          0 :         rte_kvargs_process(kvlist, CN10K_SSO_STASH,
     623                 :            :                            &parse_sso_kvargs_stash_dict, dev);
     624                 :          0 :         dev->dual_ws = !single_ws;
     625                 :          0 :         rte_kvargs_free(kvlist);
     626                 :            : }
     627                 :            : 
     628                 :            : int
     629                 :          0 : cnxk_sso_init(struct rte_eventdev *event_dev)
     630                 :            : {
     631                 :            :         const struct rte_memzone *mz = NULL;
     632                 :            :         struct rte_pci_device *pci_dev;
     633                 :            :         struct cnxk_sso_evdev *dev;
     634                 :            :         int rc;
     635                 :            : 
     636                 :          0 :         mz = rte_memzone_reserve(CNXK_SSO_MZ_NAME, sizeof(uint64_t),
     637                 :            :                                  SOCKET_ID_ANY, 0);
     638         [ #  # ]:          0 :         if (mz == NULL) {
     639                 :          0 :                 plt_err("Failed to create eventdev memzone");
     640                 :          0 :                 return -ENOMEM;
     641                 :            :         }
     642                 :            : 
     643                 :            :         dev = cnxk_sso_pmd_priv(event_dev);
     644                 :          0 :         dev->fc_cache_space = rte_zmalloc("fc_cache", PLT_CACHE_LINE_SIZE,
     645                 :            :                                           PLT_CACHE_LINE_SIZE);
     646         [ #  # ]:          0 :         if (dev->fc_cache_space == NULL) {
     647                 :          0 :                 plt_memzone_free(mz);
     648                 :          0 :                 plt_err("Failed to reserve memory for XAQ fc cache");
     649                 :          0 :                 return -ENOMEM;
     650                 :            :         }
     651                 :            : 
     652                 :          0 :         pci_dev = container_of(event_dev->dev, struct rte_pci_device, device);
     653                 :          0 :         dev->sso.pci_dev = pci_dev;
     654                 :            : 
     655                 :          0 :         *(uint64_t *)mz->addr = (uint64_t)dev;
     656                 :          0 :         cnxk_sso_parse_devargs(dev, pci_dev->device.devargs);
     657                 :            : 
     658                 :            :         /* Initialize the base cnxk_dev object */
     659                 :          0 :         rc = roc_sso_dev_init(&dev->sso);
     660         [ #  # ]:          0 :         if (rc < 0) {
     661                 :          0 :                 plt_err("Failed to initialize RoC SSO rc=%d", rc);
     662                 :          0 :                 goto error;
     663                 :            :         }
     664                 :            : 
     665                 :          0 :         dev->is_timeout_deq = 0;
     666                 :          0 :         dev->min_dequeue_timeout_ns = 0;
     667                 :          0 :         dev->max_dequeue_timeout_ns = USEC2NSEC(0x3FF);
     668                 :          0 :         dev->max_num_events = -1;
     669                 :          0 :         dev->nb_event_queues = 0;
     670                 :          0 :         dev->nb_event_ports = 0;
     671                 :            : 
     672                 :          0 :         cnxk_tim_init(&dev->sso);
     673                 :            : 
     674                 :          0 :         return 0;
     675                 :            : 
     676                 :            : error:
     677                 :          0 :         rte_memzone_free(mz);
     678                 :          0 :         return rc;
     679                 :            : }
     680                 :            : 
     681                 :            : int
     682                 :          0 : cnxk_sso_fini(struct rte_eventdev *event_dev)
     683                 :            : {
     684                 :            :         struct cnxk_sso_evdev *dev = cnxk_sso_pmd_priv(event_dev);
     685                 :            : 
     686                 :            :         /* For secondary processes, nothing to be done */
     687         [ #  # ]:          0 :         if (rte_eal_process_type() != RTE_PROC_PRIMARY)
     688                 :            :                 return 0;
     689                 :            : 
     690                 :          0 :         cnxk_tim_fini();
     691                 :          0 :         roc_sso_rsrc_fini(&dev->sso);
     692                 :            : 
     693                 :          0 :         return roc_sso_dev_fini(&dev->sso);
     694                 :            : }
     695                 :            : 
     696                 :            : int
     697                 :          0 : cnxk_sso_remove(struct rte_pci_device *pci_dev)
     698                 :            : {
     699                 :          0 :         return rte_event_pmd_pci_remove(pci_dev, cnxk_sso_fini);
     700                 :            : }
     701                 :            : 
     702                 :            : void
     703                 :          0 : cn9k_sso_set_rsrc(void *arg)
     704                 :            : {
     705                 :            :         struct cnxk_sso_evdev *dev = arg;
     706                 :            : 
     707         [ #  # ]:          0 :         if (dev->dual_ws)
     708                 :          0 :                 dev->max_event_ports = dev->sso.max_hws / CN9K_DUAL_WS_NB_WS;
     709                 :            :         else
     710                 :          0 :                 dev->max_event_ports = dev->sso.max_hws;
     711                 :          0 :         dev->max_event_queues = dev->sso.max_hwgrp > RTE_EVENT_MAX_QUEUES_PER_DEV ?
     712                 :          0 :                                         RTE_EVENT_MAX_QUEUES_PER_DEV :
     713                 :            :                                         dev->sso.max_hwgrp;
     714                 :          0 : }

Generated by: LCOV version 1.14