LCOV - code coverage report
Current view: top level - drivers/event/opdl - opdl_evdev.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 2 231 0.9 %
Date: 2026-11-01 19:11:22 Functions: 2 25 8.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 1 123 0.8 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2017 Intel Corporation
       3                 :            :  */
       4                 :            : 
       5                 :            : #include <inttypes.h>
       6                 :            : #include <stdlib.h>
       7                 :            : #include <string.h>
       8                 :            : 
       9                 :            : #include <bus_vdev_driver.h>
      10                 :            : #include <rte_lcore.h>
      11                 :            : #include <rte_memzone.h>
      12                 :            : #include <rte_kvargs.h>
      13                 :            : #include <rte_errno.h>
      14                 :            : #include <rte_cycles.h>
      15                 :            : 
      16                 :            : #include "opdl_evdev.h"
      17                 :            : #include "opdl_ring.h"
      18                 :            : #include "opdl_log.h"
      19                 :            : 
      20                 :            : #define EVENTDEV_NAME_OPDL_PMD event_opdl
      21                 :            : #define NUMA_NODE_ARG "numa_node"
      22                 :            : #define DO_VALIDATION_ARG "do_validation"
      23                 :            : #define DO_TEST_ARG "self_test"
      24                 :            : 
      25                 :            : 
      26                 :            : static void
      27                 :            : opdl_info_get(struct rte_eventdev *dev, struct rte_event_dev_info *info);
      28                 :            : 
      29                 :            : uint16_t
      30                 :          0 : opdl_event_enqueue_burst(void *port,
      31                 :            :                          const struct rte_event ev[],
      32                 :            :                          uint16_t num)
      33                 :            : {
      34                 :            :         struct opdl_port *p = port;
      35                 :            : 
      36         [ #  # ]:          0 :         if (unlikely(!p->opdl->data->dev_started))
      37                 :            :                 return 0;
      38                 :            : 
      39                 :            : 
      40                 :            :         /* either rx_enqueue or disclaim*/
      41                 :          0 :         return p->enq(p, ev, num);
      42                 :            : }
      43                 :            : 
      44                 :            : uint16_t
      45                 :          0 : opdl_event_enqueue(void *port, const struct rte_event *ev)
      46                 :            : {
      47                 :            :         struct opdl_port *p = port;
      48                 :            : 
      49         [ #  # ]:          0 :         if (unlikely(!p->opdl->data->dev_started))
      50                 :            :                 return 0;
      51                 :            : 
      52                 :            : 
      53                 :          0 :         return p->enq(p, ev, 1);
      54                 :            : }
      55                 :            : 
      56                 :            : uint16_t
      57                 :          0 : opdl_event_dequeue_burst(void *port,
      58                 :            :                          struct rte_event *ev,
      59                 :            :                          uint16_t num,
      60                 :            :                          uint64_t wait)
      61                 :            : {
      62                 :            :         struct opdl_port *p = (void *)port;
      63                 :            : 
      64                 :            :         RTE_SET_USED(wait);
      65                 :            : 
      66         [ #  # ]:          0 :         if (unlikely(!p->opdl->data->dev_started))
      67                 :            :                 return 0;
      68                 :            : 
      69                 :            :         /* This function pointer can point to tx_dequeue or claim*/
      70                 :          0 :         return p->deq(p, ev, num);
      71                 :            : }
      72                 :            : 
      73                 :            : uint16_t
      74                 :          0 : opdl_event_dequeue(void *port,
      75                 :            :                    struct rte_event *ev,
      76                 :            :                    uint64_t wait)
      77                 :            : {
      78                 :            :         struct opdl_port *p = (void *)port;
      79                 :            : 
      80         [ #  # ]:          0 :         if (unlikely(!p->opdl->data->dev_started))
      81                 :            :                 return 0;
      82                 :            : 
      83                 :            :         RTE_SET_USED(wait);
      84                 :            : 
      85                 :          0 :         return p->deq(p, ev, 1);
      86                 :            : }
      87                 :            : 
      88                 :            : static int
      89                 :          0 : opdl_port_link(struct rte_eventdev *dev,
      90                 :            :                void *port,
      91                 :            :                const uint8_t queues[],
      92                 :            :                const uint8_t priorities[],
      93                 :            :                uint16_t num)
      94                 :            : {
      95                 :            :         struct opdl_port *p = port;
      96                 :            : 
      97                 :            :         RTE_SET_USED(priorities);
      98                 :            :         RTE_SET_USED(dev);
      99                 :            : 
     100         [ #  # ]:          0 :         if (unlikely(dev->data->dev_started)) {
     101                 :          0 :                 PMD_DRV_LOG(ERR, "DEV_ID:[%02d] : "
     102                 :            :                              "Attempt to link queue (%u) to port %d while device started",
     103                 :            :                              dev->data->dev_id,
     104                 :            :                                 queues[0],
     105                 :            :                                 p->id);
     106                 :          0 :                 rte_errno = EINVAL;
     107                 :          0 :                 return 0;
     108                 :            :         }
     109                 :            : 
     110                 :            :         /* Max of 1 queue per port */
     111         [ #  # ]:          0 :         if (num > 1) {
     112                 :          0 :                 PMD_DRV_LOG(ERR, "DEV_ID:[%02d] : "
     113                 :            :                              "Attempt to link more than one queue (%u) to port %d requested",
     114                 :            :                              dev->data->dev_id,
     115                 :            :                                 num,
     116                 :            :                                 p->id);
     117                 :          0 :                 rte_errno = EDQUOT;
     118                 :          0 :                 return 0;
     119                 :            :         }
     120                 :            : 
     121         [ #  # ]:          0 :         if (!p->configured) {
     122                 :          0 :                 PMD_DRV_LOG(ERR, "DEV_ID:[%02d] : "
     123                 :            :                              "port %d not configured, cannot link to %u",
     124                 :            :                              dev->data->dev_id,
     125                 :            :                                 p->id,
     126                 :            :                                 queues[0]);
     127                 :          0 :                 rte_errno = EINVAL;
     128                 :          0 :                 return 0;
     129                 :            :         }
     130                 :            : 
     131         [ #  # ]:          0 :         if (p->external_qid != OPDL_INVALID_QID) {
     132                 :          0 :                 PMD_DRV_LOG(ERR, "DEV_ID:[%02d] : "
     133                 :            :                              "port %d already linked to queue %u, cannot link to %u",
     134                 :            :                              dev->data->dev_id,
     135                 :            :                                 p->id,
     136                 :            :                                 p->external_qid,
     137                 :            :                                 queues[0]);
     138                 :          0 :                 rte_errno = EINVAL;
     139                 :          0 :                 return 0;
     140                 :            :         }
     141                 :            : 
     142                 :          0 :         p->external_qid = queues[0];
     143                 :            : 
     144                 :          0 :         return 1;
     145                 :            : }
     146                 :            : 
     147                 :            : static int
     148                 :          0 : opdl_port_unlink(struct rte_eventdev *dev,
     149                 :            :                  void *port,
     150                 :            :                  uint8_t queues[],
     151                 :            :                  uint16_t nb_unlinks)
     152                 :            : {
     153                 :            :         struct opdl_port *p = port;
     154                 :            : 
     155                 :            :         RTE_SET_USED(queues);
     156                 :            :         RTE_SET_USED(nb_unlinks);
     157                 :            : 
     158         [ #  # ]:          0 :         if (unlikely(dev->data->dev_started)) {
     159                 :          0 :                 PMD_DRV_LOG(ERR, "DEV_ID:[%02d] : "
     160                 :            :                              "Attempt to unlink queue (%u) to port %d while device started",
     161                 :            :                              dev->data->dev_id,
     162                 :            :                              queues[0],
     163                 :            :                              p->id);
     164                 :          0 :                 rte_errno = EINVAL;
     165                 :          0 :                 return 0;
     166                 :            :         }
     167                 :            :         RTE_SET_USED(nb_unlinks);
     168                 :            : 
     169                 :            :         /* Port Stuff */
     170                 :          0 :         p->queue_id = OPDL_INVALID_QID;
     171                 :          0 :         p->p_type = OPDL_INVALID_PORT;
     172                 :          0 :         p->external_qid = OPDL_INVALID_QID;
     173                 :            : 
     174                 :            :         /* always unlink 0 queue due to statice pipeline */
     175                 :          0 :         return 0;
     176                 :            : }
     177                 :            : 
     178                 :            : static int
     179         [ #  # ]:          0 : opdl_port_setup(struct rte_eventdev *dev,
     180                 :            :                 uint8_t port_id,
     181                 :            :                 const struct rte_event_port_conf *conf)
     182                 :            : {
     183                 :            :         struct opdl_evdev *device = opdl_pmd_priv(dev);
     184                 :          0 :         struct opdl_port *p = &device->ports[port_id];
     185                 :            : 
     186                 :            :         RTE_SET_USED(conf);
     187                 :            : 
     188                 :            :         /* Check if port already configured */
     189         [ #  # ]:          0 :         if (p->configured) {
     190                 :          0 :                 PMD_DRV_LOG(ERR, "DEV_ID:[%02d] : "
     191                 :            :                              "Attempt to setup port %d which is already setup",
     192                 :            :                              dev->data->dev_id,
     193                 :            :                              p->id);
     194                 :          0 :                 return -EDQUOT;
     195                 :            :         }
     196                 :            : 
     197                 :          0 :         *p = (struct opdl_port){0}; /* zero entire structure */
     198                 :          0 :         p->id = port_id;
     199                 :          0 :         p->opdl = device;
     200                 :          0 :         p->queue_id = OPDL_INVALID_QID;
     201                 :          0 :         p->external_qid = OPDL_INVALID_QID;
     202                 :          0 :         dev->data->ports[port_id] = p;
     203                 :            :         /* Release publishes port setup before the configured flag */
     204                 :          0 :         rte_atomic_store_explicit((uint8_t __rte_atomic *)&p->configured, 1,
     205                 :            :                                   rte_memory_order_release);
     206                 :          0 :         device->nb_ports++;
     207                 :          0 :         return 0;
     208                 :            : }
     209                 :            : 
     210                 :            : static void
     211                 :          0 : opdl_port_release(void *port)
     212                 :            : {
     213                 :            :         struct opdl_port *p = (void *)port;
     214                 :            : 
     215         [ #  # ]:          0 :         if (p == NULL ||
     216         [ #  # ]:          0 :             p->opdl->data->dev_started) {
     217                 :            :                 return;
     218                 :            :         }
     219                 :            : 
     220                 :          0 :         p->configured = 0;
     221                 :          0 :         p->initialized = 0;
     222                 :            : }
     223                 :            : 
     224                 :            : static void
     225                 :          0 : opdl_port_def_conf(struct rte_eventdev *dev, uint8_t port_id,
     226                 :            :                 struct rte_event_port_conf *port_conf)
     227                 :            : {
     228                 :            :         RTE_SET_USED(dev);
     229                 :            :         RTE_SET_USED(port_id);
     230                 :            : 
     231                 :          0 :         port_conf->new_event_threshold = MAX_OPDL_CONS_Q_DEPTH;
     232                 :          0 :         port_conf->dequeue_depth = MAX_OPDL_CONS_Q_DEPTH;
     233                 :          0 :         port_conf->enqueue_depth = MAX_OPDL_CONS_Q_DEPTH;
     234                 :          0 : }
     235                 :            : 
     236                 :            : static int
     237         [ #  # ]:          0 : opdl_queue_setup(struct rte_eventdev *dev,
     238                 :            :                  uint8_t queue_id,
     239                 :            :                  const struct rte_event_queue_conf *conf)
     240                 :            : {
     241                 :            :         enum queue_type type;
     242                 :            : 
     243                 :            :         struct opdl_evdev *device = opdl_pmd_priv(dev);
     244                 :            : 
     245                 :            :         /* Extra sanity check, probably not needed */
     246         [ #  # ]:          0 :         if (queue_id == OPDL_INVALID_QID) {
     247                 :          0 :                 PMD_DRV_LOG(ERR, "DEV_ID:[%02d] : "
     248                 :            :                              "Invalid queue id %u requested",
     249                 :            :                              dev->data->dev_id,
     250                 :            :                              queue_id);
     251                 :          0 :                 return -EINVAL;
     252                 :            :         }
     253                 :            : 
     254         [ #  # ]:          0 :         if (device->nb_q_md > device->max_queue_nb) {
     255                 :          0 :                 PMD_DRV_LOG(ERR, "DEV_ID:[%02d] : "
     256                 :            :                              "Max number of queues %u exceeded by request %u",
     257                 :            :                              dev->data->dev_id,
     258                 :            :                              device->max_queue_nb,
     259                 :            :                              device->nb_q_md);
     260                 :          0 :                 return -EINVAL;
     261                 :            :         }
     262                 :            : 
     263                 :          0 :         if (RTE_EVENT_QUEUE_CFG_ALL_TYPES
     264         [ #  # ]:          0 :             & conf->event_queue_cfg) {
     265                 :          0 :                 PMD_DRV_LOG(ERR, "DEV_ID:[%02d] : "
     266                 :            :                              "QUEUE_CFG_ALL_TYPES not supported",
     267                 :            :                              dev->data->dev_id);
     268                 :          0 :                 return -ENOTSUP;
     269                 :          0 :         } else if (RTE_EVENT_QUEUE_CFG_SINGLE_LINK
     270         [ #  # ]:          0 :                    & conf->event_queue_cfg) {
     271                 :            :                 type = OPDL_Q_TYPE_SINGLE_LINK;
     272                 :            :         } else {
     273      [ #  #  # ]:          0 :                 switch (conf->schedule_type) {
     274                 :            :                 case RTE_SCHED_TYPE_ORDERED:
     275                 :            :                         type = OPDL_Q_TYPE_ORDERED;
     276                 :            :                         break;
     277                 :          0 :                 case RTE_SCHED_TYPE_ATOMIC:
     278                 :            :                         type = OPDL_Q_TYPE_ATOMIC;
     279                 :          0 :                         break;
     280                 :            :                 case RTE_SCHED_TYPE_PARALLEL:
     281                 :            :                         type = OPDL_Q_TYPE_ORDERED;
     282                 :            :                         break;
     283                 :          0 :                 default:
     284                 :          0 :                         PMD_DRV_LOG(ERR, "DEV_ID:[%02d] : "
     285                 :            :                                      "Unknown queue type %d requested",
     286                 :            :                                      dev->data->dev_id,
     287                 :            :                                      conf->event_queue_cfg);
     288                 :          0 :                         return -EINVAL;
     289                 :            :                 }
     290                 :            :         }
     291                 :            :         /* Check if queue id has been setup already */
     292                 :            :         uint32_t i;
     293         [ #  # ]:          0 :         for (i = 0; i < device->nb_q_md; i++) {
     294         [ #  # ]:          0 :                 if (device->q_md[i].ext_id == queue_id) {
     295                 :          0 :                         PMD_DRV_LOG(ERR, "DEV_ID:[%02d] : "
     296                 :            :                                      "queue id %u already setup",
     297                 :            :                                      dev->data->dev_id,
     298                 :            :                                      queue_id);
     299                 :          0 :                         return -EINVAL;
     300                 :            :                 }
     301                 :            :         }
     302                 :            : 
     303                 :          0 :         device->q_md[device->nb_q_md].ext_id = queue_id;
     304                 :          0 :         device->q_md[device->nb_q_md].type = type;
     305                 :          0 :         device->q_md[device->nb_q_md].setup = 1;
     306                 :          0 :         device->nb_q_md++;
     307                 :            : 
     308                 :          0 :         return 1;
     309                 :            : }
     310                 :            : 
     311                 :            : static void
     312                 :          0 : opdl_queue_release(struct rte_eventdev *dev, uint8_t queue_id)
     313                 :            : {
     314                 :            :         struct opdl_evdev *device = opdl_pmd_priv(dev);
     315                 :            : 
     316                 :            :         RTE_SET_USED(queue_id);
     317                 :            : 
     318                 :            :         if (device->data->dev_started)
     319                 :            :                 return;
     320                 :            : 
     321                 :            : }
     322                 :            : 
     323                 :            : static void
     324                 :          0 : opdl_queue_def_conf(struct rte_eventdev *dev,
     325                 :            :                     uint8_t queue_id,
     326                 :            :                     struct rte_event_queue_conf *conf)
     327                 :            : {
     328                 :            :         RTE_SET_USED(dev);
     329                 :            :         RTE_SET_USED(queue_id);
     330                 :            : 
     331                 :            :         static const struct rte_event_queue_conf default_conf = {
     332                 :            :                 .nb_atomic_flows = 1024,
     333                 :            :                 .nb_atomic_order_sequences = 1,
     334                 :            :                 .event_queue_cfg = 0,
     335                 :            :                 .schedule_type = RTE_SCHED_TYPE_ORDERED,
     336                 :            :                 .priority = RTE_EVENT_DEV_PRIORITY_NORMAL,
     337                 :            :         };
     338                 :            : 
     339                 :          0 :         *conf = default_conf;
     340                 :          0 : }
     341                 :            : 
     342                 :            : 
     343                 :            : static int
     344         [ #  # ]:          0 : opdl_dev_configure(const struct rte_eventdev *dev)
     345                 :            : {
     346                 :            :         struct opdl_evdev *opdl = opdl_pmd_priv(dev);
     347                 :            :         const struct rte_eventdev_data *data = dev->data;
     348                 :            :         const struct rte_event_dev_config *conf = &data->dev_conf;
     349                 :            : 
     350                 :          0 :         opdl->max_queue_nb = conf->nb_event_queues;
     351                 :          0 :         opdl->max_port_nb = conf->nb_event_ports;
     352                 :          0 :         opdl->nb_events_limit = conf->nb_events_limit;
     353                 :            : 
     354         [ #  # ]:          0 :         if (conf->event_dev_cfg & RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT) {
     355                 :          0 :                 PMD_DRV_LOG(ERR, "DEV_ID:[%02d] : "
     356                 :            :                              "DEQUEUE_TIMEOUT not supported",
     357                 :            :                              dev->data->dev_id);
     358                 :          0 :                 return -ENOTSUP;
     359                 :            :         }
     360                 :            : 
     361                 :            :         return 0;
     362                 :            : }
     363                 :            : 
     364                 :            : static void
     365                 :          0 : opdl_info_get(struct rte_eventdev *dev, struct rte_event_dev_info *info)
     366                 :            : {
     367                 :            :         RTE_SET_USED(dev);
     368                 :            : 
     369                 :            :         static const struct rte_event_dev_info evdev_opdl_info = {
     370                 :            :                 .driver_name = OPDL_PMD_NAME,
     371                 :            :                 .max_event_queues = RTE_EVENT_MAX_QUEUES_PER_DEV,
     372                 :            :                 .max_event_queue_flows = OPDL_QID_NUM_FIDS,
     373                 :            :                 .max_event_queue_priority_levels = OPDL_Q_PRIORITY_MAX,
     374                 :            :                 .max_event_priority_levels = OPDL_IQS_MAX,
     375                 :            :                 .max_event_ports = OPDL_PORTS_MAX,
     376                 :            :                 .max_event_port_dequeue_depth = MAX_OPDL_CONS_Q_DEPTH,
     377                 :            :                 .max_event_port_enqueue_depth = MAX_OPDL_CONS_Q_DEPTH,
     378                 :            :                 .max_num_events = OPDL_INFLIGHT_EVENTS_TOTAL,
     379                 :            :                 .event_dev_cap = RTE_EVENT_DEV_CAP_BURST_MODE |
     380                 :            :                                  RTE_EVENT_DEV_CAP_ORDERED |
     381                 :            :                                  RTE_EVENT_DEV_CAP_ATOMIC |
     382                 :            :                                  RTE_EVENT_DEV_CAP_PARALLEL |
     383                 :            :                                  RTE_EVENT_DEV_CAP_CARRY_FLOW_ID |
     384                 :            :                                  RTE_EVENT_DEV_CAP_MAINTENANCE_FREE,
     385                 :            :                 .max_profiles_per_port = 1,
     386                 :            :         };
     387                 :            : 
     388                 :          0 :         *info = evdev_opdl_info;
     389                 :          0 : }
     390                 :            : 
     391                 :            : static void
     392         [ #  # ]:          0 : opdl_dump(struct rte_eventdev *dev, FILE *f)
     393                 :            : {
     394                 :            :         struct opdl_evdev *device = opdl_pmd_priv(dev);
     395                 :            : 
     396         [ #  # ]:          0 :         if (!device->do_validation)
     397                 :            :                 return;
     398                 :            : 
     399                 :            :         fprintf(f,
     400                 :            :                 "\n\n -- RING STATISTICS --\n");
     401                 :            :         uint32_t i;
     402         [ #  # ]:          0 :         for (i = 0; i < device->nb_opdls; i++)
     403                 :          0 :                 opdl_ring_dump(device->opdl[i], f);
     404                 :            : 
     405                 :            :         fprintf(f,
     406                 :            :                 "\n\n -- PORT STATISTICS --\n"
     407                 :            :                 "Type Port Index  Port Id  Queue Id     Av. Req Size  "
     408                 :            :                 "Av. Grant Size     Av. Cycles PP"
     409                 :            :                 "      Empty DEQs   Non Empty DEQs   Pkts Processed\n");
     410                 :            : 
     411         [ #  # ]:          0 :         for (i = 0; i < device->max_port_nb; i++) {
     412                 :            :                 char queue_id[64];
     413                 :            :                 char total_cyc[64];
     414                 :            :                 const char *p_type;
     415                 :            : 
     416                 :            :                 uint64_t cne, cpg;
     417                 :            :                 struct opdl_port *port = &device->ports[i];
     418                 :            : 
     419         [ #  # ]:          0 :                 if (port->initialized) {
     420                 :          0 :                         cne = port->port_stat[claim_non_empty];
     421                 :          0 :                         cpg = port->port_stat[claim_pkts_granted];
     422         [ #  # ]:          0 :                         if (port->p_type == OPDL_REGULAR_PORT)
     423                 :            :                                 p_type = "REG";
     424                 :            :                         else if (port->p_type == OPDL_PURE_RX_PORT)
     425                 :            :                                 p_type = "  RX";
     426                 :            :                         else if (port->p_type == OPDL_PURE_TX_PORT)
     427                 :            :                                 p_type = "  TX";
     428                 :            :                         else if (port->p_type == OPDL_ASYNC_PORT)
     429                 :            :                                 p_type = "SYNC";
     430                 :            :                         else
     431                 :            :                                 p_type = "????";
     432                 :            : 
     433                 :          0 :                         snprintf(queue_id, sizeof(queue_id), "%02u",
     434         [ #  # ]:          0 :                                         port->external_qid);
     435         [ #  # ]:          0 :                         if (port->p_type == OPDL_REGULAR_PORT ||
     436                 :            :                                         port->p_type == OPDL_ASYNC_PORT)
     437         [ #  # ]:          0 :                                 snprintf(total_cyc, sizeof(total_cyc),
     438                 :            :                                         " %'16"PRIu64"",
     439                 :            :                                         (cpg != 0 ?
     440                 :          0 :                                          port->port_stat[total_cycles] / cpg
     441                 :            :                                          : 0));
     442                 :            :                         else
     443                 :            :                                 snprintf(total_cyc, sizeof(total_cyc),
     444                 :            :                                         "             ----");
     445   [ #  #  #  # ]:          0 :                         fprintf(f,
     446                 :            :                                 "%4s %10u %8u %9s %'16"PRIu64" %'16"PRIu64" %s "
     447                 :            :                                 "%'16"PRIu64" %'16"PRIu64" %'16"PRIu64"\n",
     448                 :            :                                 p_type,
     449                 :            :                                 i,
     450                 :          0 :                                 port->id,
     451         [ #  # ]:          0 :                                 (port->external_qid == OPDL_INVALID_QID ? "---"
     452                 :            :                                  : queue_id),
     453                 :            :                                 (cne != 0 ?
     454                 :          0 :                                  port->port_stat[claim_pkts_requested] / cne
     455                 :            :                                  : 0),
     456                 :            :                                 (cne != 0 ?
     457                 :            :                                  port->port_stat[claim_pkts_granted] / cne
     458                 :            :                                  : 0),
     459                 :            :                                 total_cyc,
     460                 :            :                                 port->port_stat[claim_empty],
     461                 :            :                                 port->port_stat[claim_non_empty],
     462                 :            :                                 port->port_stat[claim_pkts_granted]);
     463                 :            :                 }
     464                 :            :         }
     465                 :            :         fprintf(f, "\n");
     466                 :            : }
     467                 :            : 
     468                 :            : 
     469                 :            : static void
     470                 :          0 : opdl_stop(struct rte_eventdev *dev)
     471                 :            : {
     472                 :            :         struct opdl_evdev *device = opdl_pmd_priv(dev);
     473                 :            : 
     474                 :          0 :         opdl_xstats_uninit(dev);
     475                 :            : 
     476                 :          0 :         destroy_queues_and_rings(dev);
     477                 :            : 
     478                 :          0 :         device->started = 0;
     479                 :          0 : }
     480                 :            : 
     481                 :            : static int
     482                 :          0 : opdl_start(struct rte_eventdev *dev)
     483                 :            : {
     484                 :            :         int err = 0;
     485                 :            : 
     486                 :            :         if (!err)
     487                 :          0 :                 err = create_queues_and_rings(dev);
     488                 :            : 
     489                 :            : 
     490         [ #  # ]:          0 :         if (!err)
     491                 :          0 :                 err = assign_internal_queue_ids(dev);
     492                 :            : 
     493                 :            : 
     494         [ #  # ]:          0 :         if (!err)
     495                 :          0 :                 err = initialise_queue_zero_ports(dev);
     496                 :            : 
     497                 :            : 
     498         [ #  # ]:          0 :         if (!err)
     499                 :          0 :                 err = initialise_all_other_ports(dev);
     500                 :            : 
     501                 :            : 
     502         [ #  # ]:          0 :         if (!err)
     503                 :          0 :                 err = check_queues_linked(dev);
     504                 :            : 
     505                 :            : 
     506         [ #  # ]:          0 :         if (!err)
     507                 :          0 :                 err = opdl_add_event_handlers(dev);
     508                 :            : 
     509                 :            : 
     510         [ #  # ]:          0 :         if (!err)
     511                 :          0 :                 err = build_all_dependencies(dev);
     512                 :            : 
     513         [ #  # ]:          0 :         if (!err) {
     514                 :          0 :                 opdl_xstats_init(dev);
     515                 :            : 
     516                 :            :                 struct opdl_evdev *device = opdl_pmd_priv(dev);
     517                 :            : 
     518                 :          0 :                 PMD_DRV_LOG(INFO, "DEV_ID:[%02d] : "
     519                 :            :                               "SUCCESS : Created %u total queues (%u ex, %u in),"
     520                 :            :                               " %u opdls, %u event_dev ports, %u input ports",
     521                 :            :                               opdl_pmd_dev_id(device),
     522                 :            :                               device->nb_queues,
     523                 :            :                               (device->nb_queues - device->nb_opdls),
     524                 :            :                               device->nb_opdls,
     525                 :            :                               device->nb_opdls,
     526                 :            :                               device->nb_ports,
     527                 :            :                               device->queue[0].nb_ports);
     528                 :            :         } else
     529                 :          0 :                 opdl_stop(dev);
     530                 :            : 
     531                 :          0 :         return err;
     532                 :            : }
     533                 :            : 
     534                 :            : static int
     535                 :          0 : opdl_close(struct rte_eventdev *dev)
     536                 :            : {
     537                 :            :         struct opdl_evdev *device = opdl_pmd_priv(dev);
     538                 :            :         uint32_t i;
     539                 :            : 
     540         [ #  # ]:          0 :         for (i = 0; i < device->max_port_nb; i++) {
     541                 :          0 :                 memset(&device->ports[i],
     542                 :            :                        0,
     543                 :            :                        sizeof(struct opdl_port));
     544                 :            :         }
     545                 :            : 
     546                 :          0 :         memset(&device->s_md,
     547                 :            :                         0x0,
     548                 :            :                         sizeof(struct opdl_stage_meta_data)*OPDL_PORTS_MAX);
     549                 :            : 
     550                 :          0 :         memset(&device->q_md,
     551                 :            :                         0xFF,
     552                 :            :                         sizeof(struct opdl_queue_meta_data)*OPDL_MAX_QUEUES);
     553                 :            : 
     554                 :            : 
     555                 :          0 :         memset(device->q_map_ex_to_in,
     556                 :            :                         0,
     557                 :            :                         sizeof(uint8_t)*OPDL_INVALID_QID);
     558                 :            : 
     559                 :          0 :         opdl_xstats_uninit(dev);
     560                 :            : 
     561                 :          0 :         device->max_port_nb = 0;
     562                 :            : 
     563                 :          0 :         device->max_queue_nb = 0;
     564                 :            : 
     565                 :          0 :         device->nb_opdls = 0;
     566                 :            : 
     567                 :          0 :         device->nb_queues   = 0;
     568                 :            : 
     569                 :          0 :         device->nb_ports    = 0;
     570                 :            : 
     571                 :          0 :         device->nb_q_md     = 0;
     572                 :            : 
     573                 :          0 :         dev->data->nb_queues = 0;
     574                 :            : 
     575                 :          0 :         dev->data->nb_ports = 0;
     576                 :            : 
     577                 :            : 
     578                 :          0 :         return 0;
     579                 :            : }
     580                 :            : 
     581                 :            : static int
     582                 :          0 : assign_numa_node(const char *key __rte_unused, const char *value, void *opaque)
     583                 :            : {
     584                 :            :         int *socket_id = opaque;
     585                 :          0 :         *socket_id = atoi(value);
     586         [ #  # ]:          0 :         if (*socket_id >= RTE_MAX_NUMA_NODES)
     587                 :          0 :                 return -1;
     588                 :            :         return 0;
     589                 :            : }
     590                 :            : 
     591                 :            : static int
     592                 :          0 : set_do_validation(const char *key __rte_unused, const char *value, void *opaque)
     593                 :            : {
     594                 :            :         int *do_val = opaque;
     595                 :          0 :         *do_val = atoi(value);
     596         [ #  # ]:          0 :         if (*do_val != 0)
     597                 :          0 :                 *do_val = 1;
     598                 :            : 
     599                 :          0 :         return 0;
     600                 :            : }
     601                 :            : static int
     602                 :          0 : set_do_test(const char *key __rte_unused, const char *value, void *opaque)
     603                 :            : {
     604                 :            :         int *do_test = opaque;
     605                 :            : 
     606                 :          0 :         *do_test = atoi(value);
     607                 :            : 
     608         [ #  # ]:          0 :         if (*do_test != 0)
     609                 :          0 :                 *do_test = 1;
     610                 :          0 :         return 0;
     611                 :            : }
     612                 :            : 
     613                 :            : static int
     614                 :          0 : opdl_probe(struct rte_vdev_device *vdev)
     615                 :            : {
     616                 :            :         static struct eventdev_ops evdev_opdl_ops = {
     617                 :            :                 .dev_configure = opdl_dev_configure,
     618                 :            :                 .dev_infos_get = opdl_info_get,
     619                 :            :                 .dev_close = opdl_close,
     620                 :            :                 .dev_start = opdl_start,
     621                 :            :                 .dev_stop = opdl_stop,
     622                 :            :                 .dump = opdl_dump,
     623                 :            : 
     624                 :            :                 .queue_def_conf = opdl_queue_def_conf,
     625                 :            :                 .queue_setup = opdl_queue_setup,
     626                 :            :                 .queue_release = opdl_queue_release,
     627                 :            :                 .port_def_conf = opdl_port_def_conf,
     628                 :            :                 .port_setup = opdl_port_setup,
     629                 :            :                 .port_release = opdl_port_release,
     630                 :            :                 .port_link = opdl_port_link,
     631                 :            :                 .port_unlink = opdl_port_unlink,
     632                 :            : 
     633                 :            : 
     634                 :            :                 .xstats_get = opdl_xstats_get,
     635                 :            :                 .xstats_get_names = opdl_xstats_get_names,
     636                 :            :                 .xstats_get_by_name = opdl_xstats_get_by_name,
     637                 :            :                 .xstats_reset = opdl_xstats_reset,
     638                 :            :         };
     639                 :            : 
     640                 :            :         static const char *const args[] = {
     641                 :            :                 NUMA_NODE_ARG,
     642                 :            :                 DO_VALIDATION_ARG,
     643                 :            :                 DO_TEST_ARG,
     644                 :            :                 NULL
     645                 :            :         };
     646                 :            :         const char *name;
     647                 :            :         const char *params;
     648                 :            :         struct rte_eventdev *dev;
     649                 :            :         struct opdl_evdev *opdl;
     650                 :          0 :         int socket_id = rte_socket_id();
     651                 :          0 :         int do_validation = 0;
     652         [ #  # ]:          0 :         int do_test = 0;
     653                 :            :         int str_len;
     654                 :            :         int test_result = 0;
     655                 :            : 
     656                 :            :         name = rte_vdev_device_name(vdev);
     657                 :            :         params = rte_vdev_device_args(vdev);
     658   [ #  #  #  # ]:          0 :         if (params != NULL && params[0] != '\0') {
     659                 :          0 :                 struct rte_kvargs *kvlist = rte_kvargs_parse(params, args);
     660                 :            : 
     661         [ #  # ]:          0 :                 if (!kvlist) {
     662                 :          0 :                         PMD_DRV_LOG(INFO,
     663                 :            :                                         "Ignoring unsupported parameters when creating device '%s'",
     664                 :            :                                         name);
     665                 :            :                 } else {
     666                 :          0 :                         int ret = rte_kvargs_process(kvlist, NUMA_NODE_ARG,
     667                 :            :                                         assign_numa_node, &socket_id);
     668         [ #  # ]:          0 :                         if (ret != 0) {
     669                 :          0 :                                 PMD_DRV_LOG(ERR,
     670                 :            :                                                 "%s: Error parsing numa node parameter",
     671                 :            :                                                 name);
     672                 :            : 
     673                 :          0 :                                 rte_kvargs_free(kvlist);
     674                 :          0 :                                 return ret;
     675                 :            :                         }
     676                 :            : 
     677                 :          0 :                         ret = rte_kvargs_process(kvlist, DO_VALIDATION_ARG,
     678                 :            :                                         set_do_validation, &do_validation);
     679         [ #  # ]:          0 :                         if (ret != 0) {
     680                 :          0 :                                 PMD_DRV_LOG(ERR,
     681                 :            :                                         "%s: Error parsing do validation parameter",
     682                 :            :                                         name);
     683                 :          0 :                                 rte_kvargs_free(kvlist);
     684                 :          0 :                                 return ret;
     685                 :            :                         }
     686                 :            : 
     687                 :          0 :                         ret = rte_kvargs_process(kvlist, DO_TEST_ARG,
     688                 :            :                                         set_do_test, &do_test);
     689         [ #  # ]:          0 :                         if (ret != 0) {
     690                 :          0 :                                 PMD_DRV_LOG(ERR,
     691                 :            :                                         "%s: Error parsing do test parameter",
     692                 :            :                                         name);
     693                 :          0 :                                 rte_kvargs_free(kvlist);
     694                 :          0 :                                 return ret;
     695                 :            :                         }
     696                 :            : 
     697                 :          0 :                         rte_kvargs_free(kvlist);
     698                 :            :                 }
     699                 :            :         }
     700                 :          0 :         dev = rte_event_pmd_vdev_init(name,
     701                 :            :                         sizeof(struct opdl_evdev), socket_id, vdev);
     702                 :            : 
     703         [ #  # ]:          0 :         if (dev == NULL) {
     704                 :          0 :                 PMD_DRV_LOG(ERR, "eventdev vdev init() failed");
     705                 :          0 :                 return -EFAULT;
     706                 :            :         }
     707                 :            : 
     708   [ #  #  #  # ]:          0 :         PMD_DRV_LOG(INFO, "DEV_ID:[%02d] : "
     709                 :            :                       "Success - creating eventdev device %s, numa_node:[%d], do_validation:[%s]"
     710                 :            :                           " , self_test:[%s]",
     711                 :            :                       dev->data->dev_id,
     712                 :            :                       name,
     713                 :            :                       socket_id,
     714                 :            :                       (do_validation ? "true" : "false"),
     715                 :            :                           (do_test ? "true" : "false"));
     716                 :            : 
     717                 :          0 :         dev->dev_ops = &evdev_opdl_ops;
     718                 :            : 
     719                 :          0 :         dev->enqueue_burst = opdl_event_enqueue_burst;
     720                 :          0 :         dev->enqueue_new_burst = opdl_event_enqueue_burst;
     721                 :          0 :         dev->enqueue_forward_burst = opdl_event_enqueue_burst;
     722                 :          0 :         dev->dequeue_burst = opdl_event_dequeue_burst;
     723                 :            : 
     724         [ #  # ]:          0 :         if (rte_eal_process_type() != RTE_PROC_PRIMARY)
     725                 :          0 :                 goto done;
     726                 :            : 
     727                 :          0 :         opdl = dev->data->dev_private;
     728                 :          0 :         opdl->data = dev->data;
     729                 :          0 :         opdl->socket = socket_id;
     730                 :          0 :         opdl->do_validation = do_validation;
     731                 :          0 :         opdl->do_test = do_test;
     732                 :          0 :         str_len = strlen(name);
     733         [ #  # ]:          0 :         memcpy(opdl->service_name, name, str_len);
     734                 :            : 
     735         [ #  # ]:          0 :         if (do_test == 1)
     736                 :          0 :                 test_result =  opdl_selftest();
     737                 :            : 
     738                 :          0 : done:
     739                 :          0 :         event_dev_probing_finish(dev);
     740                 :          0 :         return test_result;
     741                 :            : }
     742                 :            : 
     743                 :            : static int
     744         [ #  # ]:          0 : opdl_remove(struct rte_vdev_device *vdev)
     745                 :            : {
     746                 :            :         const char *name;
     747                 :            : 
     748                 :            :         name = rte_vdev_device_name(vdev);
     749                 :            :         if (name == NULL)
     750                 :            :                 return -EINVAL;
     751                 :            : 
     752                 :          0 :         PMD_DRV_LOG(INFO, "Closing eventdev opdl device %s", name);
     753                 :            : 
     754                 :          0 :         return rte_event_pmd_vdev_uninit(name);
     755                 :            : }
     756                 :            : 
     757                 :            : static struct rte_vdev_driver evdev_opdl_pmd_drv = {
     758                 :            :         .probe = opdl_probe,
     759                 :            :         .remove = opdl_remove
     760                 :            : };
     761                 :            : 
     762         [ -  + ]:        305 : RTE_LOG_REGISTER_SUFFIX(opdl_logtype_driver, driver, INFO);
     763                 :            : 
     764                 :        305 : RTE_PMD_REGISTER_VDEV(EVENTDEV_NAME_OPDL_PMD, evdev_opdl_pmd_drv);
     765                 :            : RTE_PMD_REGISTER_PARAM_STRING(event_opdl, NUMA_NODE_ARG "=<int>"
     766                 :            :                               DO_VALIDATION_ARG "=<int>" DO_TEST_ARG "=<int>");

Generated by: LCOV version 1.14