LCOV - code coverage report
Current view: top level - lib/eventdev - rte_eventdev.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 473 821 57.6 %
Date: 2025-05-01 17:49:45 Functions: 38 57 66.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 289 678 42.6 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2016 Cavium, Inc
       3                 :            :  */
       4                 :            : 
       5                 :            : #include <stdalign.h>
       6                 :            : #include <ctype.h>
       7                 :            : #include <stdio.h>
       8                 :            : #include <stdlib.h>
       9                 :            : #include <string.h>
      10                 :            : #include <errno.h>
      11                 :            : #include <stdint.h>
      12                 :            : #include <inttypes.h>
      13                 :            : 
      14                 :            : #include <eal_export.h>
      15                 :            : #include <rte_string_fns.h>
      16                 :            : #include <rte_log.h>
      17                 :            : #include <dev_driver.h>
      18                 :            : #include <rte_memzone.h>
      19                 :            : #include <rte_eal.h>
      20                 :            : #include <rte_common.h>
      21                 :            : #include <rte_malloc.h>
      22                 :            : #include <rte_errno.h>
      23                 :            : #include <ethdev_driver.h>
      24                 :            : #include <rte_cryptodev.h>
      25                 :            : #include <rte_dmadev.h>
      26                 :            : #include <cryptodev_pmd.h>
      27                 :            : #include <rte_telemetry.h>
      28                 :            : 
      29                 :            : #include "rte_eventdev.h"
      30                 :            : #include "eventdev_pmd.h"
      31                 :            : #include "eventdev_trace.h"
      32                 :            : 
      33                 :            : RTE_EXPORT_INTERNAL_SYMBOL(rte_event_logtype)
      34         [ -  + ]:        252 : RTE_LOG_REGISTER_DEFAULT(rte_event_logtype, INFO);
      35                 :            : 
      36                 :            : static struct rte_eventdev rte_event_devices[RTE_EVENT_MAX_DEVS];
      37                 :            : 
      38                 :            : RTE_EXPORT_INTERNAL_SYMBOL(rte_eventdevs)
      39                 :            : struct rte_eventdev *rte_eventdevs = rte_event_devices;
      40                 :            : 
      41                 :            : static struct rte_eventdev_global eventdev_globals = {
      42                 :            :         .nb_devs                = 0
      43                 :            : };
      44                 :            : 
      45                 :            : /* Public fastpath APIs. */
      46                 :            : RTE_EXPORT_SYMBOL(rte_event_fp_ops)
      47                 :            : struct rte_event_fp_ops rte_event_fp_ops[RTE_EVENT_MAX_DEVS];
      48                 :            : 
      49                 :            : /* Event dev north bound API implementation */
      50                 :            : 
      51                 :            : RTE_EXPORT_SYMBOL(rte_event_dev_count)
      52                 :            : uint8_t
      53                 :          3 : rte_event_dev_count(void)
      54                 :            : {
      55                 :          3 :         return eventdev_globals.nb_devs;
      56                 :            : }
      57                 :            : 
      58                 :            : RTE_EXPORT_SYMBOL(rte_event_dev_get_dev_id)
      59                 :            : int
      60                 :          4 : rte_event_dev_get_dev_id(const char *name)
      61                 :            : {
      62                 :            :         int i;
      63                 :            :         uint8_t cmp;
      64                 :            : 
      65         [ +  - ]:          4 :         if (!name)
      66                 :            :                 return -EINVAL;
      67                 :            : 
      68         [ +  + ]:          5 :         for (i = 0; i < eventdev_globals.nb_devs; i++) {
      69                 :          6 :                 cmp = (strncmp(rte_event_devices[i].data->name, name,
      70         [ +  + ]:          3 :                                 RTE_EVENTDEV_NAME_MAX_LEN) == 0) ||
      71         [ +  - ]:          1 :                         (rte_event_devices[i].dev ? (strncmp(
      72         [ +  - ]:          1 :                                 rte_event_devices[i].dev->driver->name, name,
      73                 :            :                                          RTE_EVENTDEV_NAME_MAX_LEN) == 0) : 0);
      74   [ +  +  +  - ]:          3 :                 if (cmp && (rte_event_devices[i].attached ==
      75                 :            :                                         RTE_EVENTDEV_ATTACHED)) {
      76                 :          2 :                         rte_eventdev_trace_get_dev_id(name, i);
      77                 :          2 :                         return i;
      78                 :            :                 }
      79                 :            :         }
      80                 :            :         return -ENODEV;
      81                 :            : }
      82                 :            : 
      83                 :            : RTE_EXPORT_SYMBOL(rte_event_dev_socket_id)
      84                 :            : int
      85                 :          2 : rte_event_dev_socket_id(uint8_t dev_id)
      86                 :            : {
      87                 :            :         struct rte_eventdev *dev;
      88                 :            : 
      89         [ +  + ]:          2 :         RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
      90                 :            :         dev = &rte_eventdevs[dev_id];
      91                 :            : 
      92         [ -  + ]:          1 :         rte_eventdev_trace_socket_id(dev_id, dev, dev->data->socket_id);
      93                 :            : 
      94                 :          1 :         return dev->data->socket_id;
      95                 :            : }
      96                 :            : 
      97                 :            : RTE_EXPORT_SYMBOL(rte_event_dev_info_get)
      98                 :            : int
      99                 :         61 : rte_event_dev_info_get(uint8_t dev_id, struct rte_event_dev_info *dev_info)
     100                 :            : {
     101                 :            :         struct rte_eventdev *dev;
     102                 :            : 
     103         [ +  - ]:         61 :         RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
     104                 :            :         dev = &rte_eventdevs[dev_id];
     105                 :            : 
     106         [ +  + ]:         61 :         if (dev_info == NULL)
     107                 :            :                 return -EINVAL;
     108                 :            : 
     109                 :            :         memset(dev_info, 0, sizeof(struct rte_event_dev_info));
     110                 :            : 
     111         [ +  - ]:         60 :         if (dev->dev_ops->dev_infos_get == NULL)
     112                 :            :                 return -ENOTSUP;
     113                 :         60 :         dev->dev_ops->dev_infos_get(dev, dev_info);
     114                 :            : 
     115                 :         60 :         dev_info->dequeue_timeout_ns = dev->data->dev_conf.dequeue_timeout_ns;
     116                 :            : 
     117                 :         60 :         dev_info->dev = dev->dev;
     118   [ +  -  +  - ]:         60 :         if (dev->dev != NULL && dev->dev->driver != NULL)
     119                 :         60 :                 dev_info->driver_name = dev->dev->driver->name;
     120                 :            : 
     121                 :         60 :         rte_eventdev_trace_info_get(dev_id, dev_info, dev_info->dev);
     122                 :            : 
     123                 :         60 :         return 0;
     124                 :            : }
     125                 :            : 
     126                 :            : RTE_EXPORT_SYMBOL(rte_event_eth_rx_adapter_caps_get)
     127                 :            : int
     128                 :          0 : rte_event_eth_rx_adapter_caps_get(uint8_t dev_id, uint16_t eth_port_id,
     129                 :            :                                 uint32_t *caps)
     130                 :            : {
     131                 :            :         struct rte_eventdev *dev;
     132                 :            : 
     133   [ #  #  #  # ]:          0 :         rte_eventdev_trace_eth_rx_adapter_caps_get(dev_id, eth_port_id);
     134                 :            : 
     135                 :          0 :         RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
     136         [ #  # ]:          0 :         RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_port_id, -EINVAL);
     137                 :            : 
     138                 :          0 :         dev = &rte_eventdevs[dev_id];
     139                 :            : 
     140         [ #  # ]:          0 :         if (caps == NULL)
     141                 :            :                 return -EINVAL;
     142                 :            : 
     143         [ #  # ]:          0 :         if (dev->dev_ops->eth_rx_adapter_caps_get == NULL)
     144                 :          0 :                 *caps = RTE_EVENT_ETH_RX_ADAPTER_SW_CAP;
     145                 :            :         else
     146                 :          0 :                 *caps = 0;
     147                 :            : 
     148                 :            :         return dev->dev_ops->eth_rx_adapter_caps_get ?
     149                 :          0 :                 dev->dev_ops->eth_rx_adapter_caps_get(dev, &rte_eth_devices[eth_port_id], caps)
     150         [ #  # ]:          0 :                 : 0;
     151                 :            : }
     152                 :            : 
     153                 :            : RTE_EXPORT_SYMBOL(rte_event_timer_adapter_caps_get)
     154                 :            : int
     155                 :          0 : rte_event_timer_adapter_caps_get(uint8_t dev_id, uint32_t *caps)
     156                 :            : {
     157                 :            :         struct rte_eventdev *dev;
     158                 :            :         const struct event_timer_adapter_ops *ops;
     159                 :            : 
     160   [ #  #  #  # ]:          0 :         rte_eventdev_trace_timer_adapter_caps_get(dev_id);
     161                 :            : 
     162                 :          0 :         RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
     163                 :            : 
     164                 :            :         dev = &rte_eventdevs[dev_id];
     165                 :            : 
     166         [ #  # ]:          0 :         if (caps == NULL)
     167                 :            :                 return -EINVAL;
     168                 :            : 
     169         [ #  # ]:          0 :         if (dev->dev_ops->timer_adapter_caps_get == NULL)
     170                 :          0 :                 *caps = RTE_EVENT_TIMER_ADAPTER_SW_CAP;
     171                 :            :         else
     172                 :          0 :                 *caps = 0;
     173                 :            : 
     174                 :            :         return dev->dev_ops->timer_adapter_caps_get ?
     175                 :          0 :                 dev->dev_ops->timer_adapter_caps_get(dev, 0, caps, &ops)
     176         [ #  # ]:          0 :                 : 0;
     177                 :            : }
     178                 :            : 
     179                 :            : RTE_EXPORT_SYMBOL(rte_event_crypto_adapter_caps_get)
     180                 :            : int
     181                 :          0 : rte_event_crypto_adapter_caps_get(uint8_t dev_id, uint8_t cdev_id,
     182                 :            :                                   uint32_t *caps)
     183                 :            : {
     184                 :            :         struct rte_eventdev *dev;
     185                 :            :         struct rte_cryptodev *cdev;
     186                 :            : 
     187         [ #  # ]:          0 :         RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
     188         [ #  # ]:          0 :         if (!rte_cryptodev_is_valid_dev(cdev_id))
     189                 :            :                 return -EINVAL;
     190                 :            : 
     191                 :          0 :         dev = &rte_eventdevs[dev_id];
     192                 :          0 :         cdev = rte_cryptodev_pmd_get_dev(cdev_id);
     193                 :            : 
     194                 :          0 :         rte_eventdev_trace_crypto_adapter_caps_get(dev_id, dev, cdev_id, cdev);
     195                 :            : 
     196         [ #  # ]:          0 :         if (caps == NULL)
     197                 :            :                 return -EINVAL;
     198                 :            : 
     199         [ #  # ]:          0 :         if (dev->dev_ops->crypto_adapter_caps_get == NULL)
     200                 :          0 :                 *caps = RTE_EVENT_CRYPTO_ADAPTER_SW_CAP;
     201                 :            :         else
     202                 :          0 :                 *caps = 0;
     203                 :            : 
     204                 :            :         return dev->dev_ops->crypto_adapter_caps_get ?
     205         [ #  # ]:          0 :                 dev->dev_ops->crypto_adapter_caps_get(dev, cdev, caps) : 0;
     206                 :            : }
     207                 :            : 
     208                 :            : RTE_EXPORT_SYMBOL(rte_event_eth_tx_adapter_caps_get)
     209                 :            : int
     210                 :         18 : rte_event_eth_tx_adapter_caps_get(uint8_t dev_id, uint16_t eth_port_id,
     211                 :            :                                 uint32_t *caps)
     212                 :            : {
     213                 :            :         struct rte_eventdev *dev;
     214                 :            :         struct rte_eth_dev *eth_dev;
     215                 :            : 
     216         [ +  - ]:         18 :         RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
     217         [ -  + ]:         18 :         RTE_ETH_VALID_PORTID_OR_ERR_RET(eth_port_id, -EINVAL);
     218                 :            : 
     219                 :         18 :         dev = &rte_eventdevs[dev_id];
     220         [ -  + ]:         18 :         eth_dev = &rte_eth_devices[eth_port_id];
     221                 :            : 
     222                 :         18 :         rte_eventdev_trace_eth_tx_adapter_caps_get(dev_id, dev, eth_port_id, eth_dev);
     223                 :            : 
     224         [ +  - ]:         18 :         if (caps == NULL)
     225                 :            :                 return -EINVAL;
     226                 :            : 
     227         [ +  - ]:         18 :         if (dev->dev_ops->eth_tx_adapter_caps_get == NULL)
     228                 :         18 :                 *caps = RTE_EVENT_ETH_TX_ADAPTER_CAP_EVENT_VECTOR;
     229                 :            :         else
     230                 :          0 :                 *caps = 0;
     231                 :            : 
     232                 :            :         return dev->dev_ops->eth_tx_adapter_caps_get ?
     233                 :          0 :                 dev->dev_ops->eth_tx_adapter_caps_get(dev, eth_dev, caps)
     234         [ -  + ]:         18 :                 : 0;
     235                 :            : }
     236                 :            : 
     237                 :            : RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_event_dma_adapter_caps_get, 23.11)
     238                 :            : int
     239                 :          0 : rte_event_dma_adapter_caps_get(uint8_t dev_id, uint8_t dma_dev_id, uint32_t *caps)
     240                 :            : {
     241                 :            :         struct rte_eventdev *dev;
     242                 :            : 
     243         [ #  # ]:          0 :         RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
     244         [ #  # ]:          0 :         if (!rte_dma_is_valid(dma_dev_id))
     245                 :            :                 return -EINVAL;
     246                 :            : 
     247                 :          0 :         dev = &rte_eventdevs[dev_id];
     248                 :            : 
     249         [ #  # ]:          0 :         if (caps == NULL)
     250                 :            :                 return -EINVAL;
     251                 :            : 
     252                 :          0 :         *caps = 0;
     253                 :            : 
     254         [ #  # ]:          0 :         if (dev->dev_ops->dma_adapter_caps_get)
     255                 :          0 :                 return dev->dev_ops->dma_adapter_caps_get(dev, dma_dev_id, caps);
     256                 :            : 
     257                 :            :         return 0;
     258                 :            : }
     259                 :            : 
     260                 :            : static inline int
     261                 :         70 : event_dev_queue_config(struct rte_eventdev *dev, uint8_t nb_queues)
     262                 :            : {
     263                 :         70 :         uint8_t old_nb_queues = dev->data->nb_queues;
     264                 :            :         struct rte_event_queue_conf *queues_cfg;
     265                 :            :         unsigned int i;
     266                 :            : 
     267                 :            :         RTE_EDEV_LOG_DEBUG("Setup %d queues on device %u", nb_queues,
     268                 :            :                          dev->data->dev_id);
     269                 :            : 
     270         [ +  - ]:         70 :         if (nb_queues != 0) {
     271                 :         70 :                 queues_cfg = dev->data->queues_cfg;
     272         [ +  - ]:         70 :                 if (dev->dev_ops->queue_release == NULL)
     273                 :            :                         return -ENOTSUP;
     274                 :            : 
     275         [ +  + ]:        110 :                 for (i = nb_queues; i < old_nb_queues; i++)
     276                 :         40 :                         dev->dev_ops->queue_release(dev, i);
     277                 :            : 
     278                 :            : 
     279         [ +  + ]:         70 :                 if (nb_queues > old_nb_queues) {
     280                 :         10 :                         uint8_t new_qs = nb_queues - old_nb_queues;
     281                 :            : 
     282                 :         10 :                         memset(queues_cfg + old_nb_queues, 0,
     283                 :            :                                 sizeof(queues_cfg[0]) * new_qs);
     284                 :            :                 }
     285                 :            :         } else {
     286         [ #  # ]:          0 :                 if (dev->dev_ops->queue_release == NULL)
     287                 :            :                         return -ENOTSUP;
     288                 :            : 
     289         [ #  # ]:          0 :                 for (i = nb_queues; i < old_nb_queues; i++)
     290                 :          0 :                         dev->dev_ops->queue_release(dev, i);
     291                 :            :         }
     292                 :            : 
     293                 :         70 :         dev->data->nb_queues = nb_queues;
     294                 :         70 :         return 0;
     295                 :            : }
     296                 :            : 
     297                 :            : #define EVENT_QUEUE_SERVICE_PRIORITY_INVALID (0xdead)
     298                 :            : 
     299                 :            : static inline int
     300                 :         70 : event_dev_port_config(struct rte_eventdev *dev, uint8_t nb_ports)
     301                 :            : {
     302                 :         70 :         uint8_t old_nb_ports = dev->data->nb_ports;
     303                 :            :         void **ports;
     304                 :            :         uint16_t *links_map;
     305                 :            :         struct rte_event_port_conf *ports_cfg;
     306                 :            :         unsigned int i, j;
     307                 :            : 
     308                 :            :         RTE_EDEV_LOG_DEBUG("Setup %d ports on device %u", nb_ports,
     309                 :            :                          dev->data->dev_id);
     310                 :            : 
     311         [ +  - ]:         70 :         if (nb_ports != 0) { /* re-config */
     312         [ +  - ]:         70 :                 if (dev->dev_ops->port_release == NULL)
     313                 :            :                         return -ENOTSUP;
     314                 :            : 
     315                 :         70 :                 ports = dev->data->ports;
     316                 :         70 :                 ports_cfg = dev->data->ports_cfg;
     317                 :            : 
     318         [ +  + ]:        106 :                 for (i = nb_ports; i < old_nb_ports; i++)
     319                 :         36 :                         (dev->dev_ops->port_release)(ports[i]);
     320                 :            : 
     321         [ +  + ]:         70 :                 if (nb_ports > old_nb_ports) {
     322                 :         19 :                         uint8_t new_ps = nb_ports - old_nb_ports;
     323                 :         19 :                         unsigned int old_links_map_end =
     324                 :         19 :                                 old_nb_ports * RTE_EVENT_MAX_QUEUES_PER_DEV;
     325                 :         19 :                         unsigned int links_map_end =
     326                 :         19 :                                 nb_ports * RTE_EVENT_MAX_QUEUES_PER_DEV;
     327                 :            : 
     328                 :         19 :                         memset(ports + old_nb_ports, 0,
     329                 :            :                                 sizeof(ports[0]) * new_ps);
     330                 :         19 :                         memset(ports_cfg + old_nb_ports, 0,
     331                 :            :                                 sizeof(ports_cfg[0]) * new_ps);
     332         [ +  + ]:        171 :                         for (i = 0; i < RTE_EVENT_MAX_PROFILES_PER_PORT; i++) {
     333                 :        152 :                                 links_map = dev->data->links_map[i];
     334         [ +  + ]:     147032 :                                 for (j = old_links_map_end; j < links_map_end; j++)
     335                 :     146880 :                                         links_map[j] = EVENT_QUEUE_SERVICE_PRIORITY_INVALID;
     336                 :            :                         }
     337                 :            :                 }
     338                 :            :         } else {
     339         [ #  # ]:          0 :                 if (dev->dev_ops->port_release == NULL)
     340                 :            :                         return -ENOTSUP;
     341                 :            : 
     342                 :          0 :                 ports = dev->data->ports;
     343         [ #  # ]:          0 :                 for (i = nb_ports; i < old_nb_ports; i++) {
     344                 :          0 :                         (dev->dev_ops->port_release)(ports[i]);
     345                 :          0 :                         ports[i] = NULL;
     346                 :            :                 }
     347                 :            :         }
     348                 :            : 
     349                 :         70 :         dev->data->nb_ports = nb_ports;
     350                 :         70 :         return 0;
     351                 :            : }
     352                 :            : 
     353                 :            : RTE_EXPORT_SYMBOL(rte_event_dev_configure)
     354                 :            : int
     355                 :         78 : rte_event_dev_configure(uint8_t dev_id,
     356                 :            :                         const struct rte_event_dev_config *dev_conf)
     357                 :            : {
     358                 :            :         struct rte_event_dev_info info;
     359                 :            :         struct rte_eventdev *dev;
     360                 :            :         int diag;
     361                 :            : 
     362         [ +  - ]:         78 :         RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
     363                 :            :         dev = &rte_eventdevs[dev_id];
     364                 :            : 
     365         [ +  - ]:         78 :         if (dev->dev_ops->dev_infos_get == NULL)
     366                 :            :                 return -ENOTSUP;
     367         [ +  - ]:         78 :         if (dev->dev_ops->dev_configure == NULL)
     368                 :            :                 return -ENOTSUP;
     369                 :            : 
     370         [ -  + ]:         78 :         if (dev->data->dev_started) {
     371                 :          0 :                 RTE_EDEV_LOG_ERR(
     372                 :            :                     "device %d must be stopped to allow configuration", dev_id);
     373                 :          0 :                 return -EBUSY;
     374                 :            :         }
     375                 :            : 
     376         [ +  + ]:         78 :         if (dev_conf == NULL)
     377                 :            :                 return -EINVAL;
     378                 :            : 
     379                 :         77 :         dev->dev_ops->dev_infos_get(dev, &info);
     380                 :            : 
     381                 :            :         /* Check dequeue_timeout_ns value is in limit */
     382         [ +  - ]:         77 :         if (!(dev_conf->event_dev_cfg & RTE_EVENT_DEV_CFG_PER_DEQUEUE_TIMEOUT)) {
     383         [ +  + ]:         77 :                 if (dev_conf->dequeue_timeout_ns &&
     384         [ +  - ]:         35 :                     (dev_conf->dequeue_timeout_ns < info.min_dequeue_timeout_ns
     385                 :         35 :                         || dev_conf->dequeue_timeout_ns >
     386         [ +  + ]:         35 :                                  info.max_dequeue_timeout_ns)) {
     387                 :          1 :                         RTE_EDEV_LOG_ERR("dev%d invalid dequeue_timeout_ns=%d"
     388                 :            :                         " min_dequeue_timeout_ns=%d max_dequeue_timeout_ns=%d",
     389                 :            :                         dev_id, dev_conf->dequeue_timeout_ns,
     390                 :            :                         info.min_dequeue_timeout_ns,
     391                 :            :                         info.max_dequeue_timeout_ns);
     392                 :          1 :                         return -EINVAL;
     393                 :            :                 }
     394                 :            :         }
     395                 :            : 
     396                 :            :         /* Check nb_events_limit is in limit */
     397         [ +  + ]:         76 :         if (dev_conf->nb_events_limit > info.max_num_events) {
     398                 :          1 :                 RTE_EDEV_LOG_ERR("dev%d nb_events_limit=%d > max_num_events=%d",
     399                 :            :                 dev_id, dev_conf->nb_events_limit, info.max_num_events);
     400                 :          1 :                 return -EINVAL;
     401                 :            :         }
     402                 :            : 
     403                 :            :         /* Check nb_event_queues is in limit */
     404         [ -  + ]:         75 :         if (!dev_conf->nb_event_queues) {
     405                 :          0 :                 RTE_EDEV_LOG_ERR("dev%d nb_event_queues cannot be zero",
     406                 :            :                                         dev_id);
     407                 :          0 :                 return -EINVAL;
     408                 :            :         }
     409                 :         75 :         if (dev_conf->nb_event_queues > info.max_event_queues +
     410         [ +  + ]:         75 :                         info.max_single_link_event_port_queue_pairs) {
     411                 :          1 :                 RTE_EDEV_LOG_ERR("%d nb_event_queues=%d > max_event_queues=%d + max_single_link_event_port_queue_pairs=%d",
     412                 :            :                                  dev_id, dev_conf->nb_event_queues,
     413                 :            :                                  info.max_event_queues,
     414                 :            :                                  info.max_single_link_event_port_queue_pairs);
     415                 :          1 :                 return -EINVAL;
     416                 :            :         }
     417                 :         74 :         if (dev_conf->nb_event_queues -
     418         [ -  + ]:         74 :                         dev_conf->nb_single_link_event_port_queues >
     419                 :            :                         info.max_event_queues) {
     420                 :          0 :                 RTE_EDEV_LOG_ERR("id%d nb_event_queues=%d - nb_single_link_event_port_queues=%d > max_event_queues=%d",
     421                 :            :                                  dev_id, dev_conf->nb_event_queues,
     422                 :            :                                  dev_conf->nb_single_link_event_port_queues,
     423                 :            :                                  info.max_event_queues);
     424                 :          0 :                 return -EINVAL;
     425                 :            :         }
     426         [ -  + ]:         74 :         if (dev_conf->nb_single_link_event_port_queues >
     427                 :            :                         dev_conf->nb_event_queues) {
     428                 :          0 :                 RTE_EDEV_LOG_ERR("dev%d nb_single_link_event_port_queues=%d > nb_event_queues=%d",
     429                 :            :                                  dev_id,
     430                 :            :                                  dev_conf->nb_single_link_event_port_queues,
     431                 :            :                                  dev_conf->nb_event_queues);
     432                 :          0 :                 return -EINVAL;
     433                 :            :         }
     434                 :            : 
     435                 :            :         /* Check nb_event_ports is in limit */
     436         [ -  + ]:         74 :         if (!dev_conf->nb_event_ports) {
     437                 :          0 :                 RTE_EDEV_LOG_ERR("dev%d nb_event_ports cannot be zero", dev_id);
     438                 :          0 :                 return -EINVAL;
     439                 :            :         }
     440         [ +  + ]:         74 :         if (dev_conf->nb_event_ports > info.max_event_ports +
     441                 :            :                         info.max_single_link_event_port_queue_pairs) {
     442                 :          1 :                 RTE_EDEV_LOG_ERR("id%d nb_event_ports=%d > max_event_ports=%d + max_single_link_event_port_queue_pairs=%d",
     443                 :            :                                  dev_id, dev_conf->nb_event_ports,
     444                 :            :                                  info.max_event_ports,
     445                 :            :                                  info.max_single_link_event_port_queue_pairs);
     446                 :          1 :                 return -EINVAL;
     447                 :            :         }
     448         [ -  + ]:         73 :         if (dev_conf->nb_event_ports -
     449                 :            :                         dev_conf->nb_single_link_event_port_queues
     450                 :            :                         > info.max_event_ports) {
     451                 :          0 :                 RTE_EDEV_LOG_ERR("id%d nb_event_ports=%d - nb_single_link_event_port_queues=%d > max_event_ports=%d",
     452                 :            :                                  dev_id, dev_conf->nb_event_ports,
     453                 :            :                                  dev_conf->nb_single_link_event_port_queues,
     454                 :            :                                  info.max_event_ports);
     455                 :          0 :                 return -EINVAL;
     456                 :            :         }
     457                 :            : 
     458         [ -  + ]:         73 :         if (dev_conf->nb_single_link_event_port_queues >
     459                 :            :             dev_conf->nb_event_ports) {
     460                 :          0 :                 RTE_EDEV_LOG_ERR(
     461                 :            :                                  "dev%d nb_single_link_event_port_queues=%d > nb_event_ports=%d",
     462                 :            :                                  dev_id,
     463                 :            :                                  dev_conf->nb_single_link_event_port_queues,
     464                 :            :                                  dev_conf->nb_event_ports);
     465                 :          0 :                 return -EINVAL;
     466                 :            :         }
     467                 :            : 
     468                 :            :         /* Check nb_event_queue_flows is in limit */
     469         [ -  + ]:         73 :         if (!dev_conf->nb_event_queue_flows) {
     470                 :          0 :                 RTE_EDEV_LOG_ERR("dev%d nb_flows cannot be zero", dev_id);
     471                 :          0 :                 return -EINVAL;
     472                 :            :         }
     473         [ +  + ]:         73 :         if (dev_conf->nb_event_queue_flows > info.max_event_queue_flows) {
     474                 :          1 :                 RTE_EDEV_LOG_ERR("dev%d nb_flows=%x > max_flows=%x",
     475                 :            :                 dev_id, dev_conf->nb_event_queue_flows,
     476                 :            :                 info.max_event_queue_flows);
     477                 :          1 :                 return -EINVAL;
     478                 :            :         }
     479                 :            : 
     480                 :            :         /* Check nb_event_port_dequeue_depth is in limit */
     481         [ -  + ]:         72 :         if (!dev_conf->nb_event_port_dequeue_depth) {
     482                 :          0 :                 RTE_EDEV_LOG_ERR("dev%d nb_dequeue_depth cannot be zero",
     483                 :            :                                         dev_id);
     484                 :          0 :                 return -EINVAL;
     485                 :            :         }
     486         [ +  - ]:         72 :         if ((info.event_dev_cap & RTE_EVENT_DEV_CAP_BURST_MODE) &&
     487                 :         72 :                  (dev_conf->nb_event_port_dequeue_depth >
     488         [ +  + ]:         72 :                          info.max_event_port_dequeue_depth)) {
     489                 :          1 :                 RTE_EDEV_LOG_ERR("dev%d nb_dq_depth=%d > max_dq_depth=%d",
     490                 :            :                 dev_id, dev_conf->nb_event_port_dequeue_depth,
     491                 :            :                 info.max_event_port_dequeue_depth);
     492                 :          1 :                 return -EINVAL;
     493                 :            :         }
     494                 :            : 
     495                 :            :         /* Check nb_event_port_enqueue_depth is in limit */
     496         [ -  + ]:         71 :         if (!dev_conf->nb_event_port_enqueue_depth) {
     497                 :          0 :                 RTE_EDEV_LOG_ERR("dev%d nb_enqueue_depth cannot be zero",
     498                 :            :                                         dev_id);
     499                 :          0 :                 return -EINVAL;
     500                 :            :         }
     501         [ +  - ]:         71 :         if ((info.event_dev_cap & RTE_EVENT_DEV_CAP_BURST_MODE) &&
     502                 :            :                 (dev_conf->nb_event_port_enqueue_depth >
     503         [ +  + ]:         71 :                          info.max_event_port_enqueue_depth)) {
     504                 :          1 :                 RTE_EDEV_LOG_ERR("dev%d nb_enq_depth=%d > max_enq_depth=%d",
     505                 :            :                 dev_id, dev_conf->nb_event_port_enqueue_depth,
     506                 :            :                 info.max_event_port_enqueue_depth);
     507                 :          1 :                 return -EINVAL;
     508                 :            :         }
     509                 :            : 
     510                 :            :         /* Copy the dev_conf parameter into the dev structure */
     511                 :         70 :         memcpy(&dev->data->dev_conf, dev_conf, sizeof(dev->data->dev_conf));
     512                 :            : 
     513                 :            :         /* Setup new number of queues and reconfigure device. */
     514                 :         70 :         diag = event_dev_queue_config(dev, dev_conf->nb_event_queues);
     515         [ -  + ]:         70 :         if (diag != 0) {
     516                 :          0 :                 RTE_EDEV_LOG_ERR("dev%d event_dev_queue_config = %d", dev_id,
     517                 :            :                                  diag);
     518                 :          0 :                 return diag;
     519                 :            :         }
     520                 :            : 
     521                 :            :         /* Setup new number of ports and reconfigure device. */
     522                 :         70 :         diag = event_dev_port_config(dev, dev_conf->nb_event_ports);
     523         [ -  + ]:         70 :         if (diag != 0) {
     524                 :          0 :                 event_dev_queue_config(dev, 0);
     525                 :          0 :                 RTE_EDEV_LOG_ERR("dev%d event_dev_port_config = %d", dev_id,
     526                 :            :                                  diag);
     527                 :          0 :                 return diag;
     528                 :            :         }
     529                 :            : 
     530                 :         70 :         event_dev_fp_ops_reset(rte_event_fp_ops + dev_id);
     531                 :            : 
     532                 :            :         /* Configure the device */
     533                 :         70 :         diag = (dev->dev_ops->dev_configure)(dev);
     534         [ -  + ]:         70 :         if (diag != 0) {
     535                 :          0 :                 RTE_EDEV_LOG_ERR("dev%d dev_configure = %d", dev_id, diag);
     536                 :          0 :                 event_dev_fp_ops_reset(rte_event_fp_ops + dev_id);
     537                 :          0 :                 event_dev_queue_config(dev, 0);
     538                 :          0 :                 event_dev_port_config(dev, 0);
     539                 :            :         }
     540                 :            : 
     541         [ -  + ]:         70 :         dev->data->event_dev_cap = info.event_dev_cap;
     542                 :         70 :         rte_eventdev_trace_configure(dev_id, dev_conf, diag);
     543                 :         70 :         return diag;
     544                 :            : }
     545                 :            : 
     546                 :            : static inline int
     547                 :            : is_valid_queue(struct rte_eventdev *dev, uint8_t queue_id)
     548                 :            : {
     549         [ #  # ]:          0 :         if (queue_id < dev->data->nb_queues && queue_id <
     550                 :            :                                 RTE_EVENT_MAX_QUEUES_PER_DEV)
     551                 :            :                 return 1;
     552                 :            :         else
     553                 :            :                 return 0;
     554                 :            : }
     555                 :            : 
     556                 :            : RTE_EXPORT_SYMBOL(rte_event_queue_default_conf_get)
     557                 :            : int
     558                 :        134 : rte_event_queue_default_conf_get(uint8_t dev_id, uint8_t queue_id,
     559                 :            :                                  struct rte_event_queue_conf *queue_conf)
     560                 :            : {
     561                 :            :         struct rte_eventdev *dev;
     562                 :            : 
     563         [ +  - ]:        134 :         RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
     564                 :            :         dev = &rte_eventdevs[dev_id];
     565                 :            : 
     566         [ +  + ]:        134 :         if (queue_conf == NULL)
     567                 :            :                 return -EINVAL;
     568                 :            : 
     569         [ -  + ]:        133 :         if (!is_valid_queue(dev, queue_id)) {
     570                 :          0 :                 RTE_EDEV_LOG_ERR("Invalid queue_id=%" PRIu8, queue_id);
     571                 :          0 :                 return -EINVAL;
     572                 :            :         }
     573                 :            : 
     574         [ +  - ]:        133 :         if (dev->dev_ops->queue_def_conf == NULL)
     575                 :            :                 return -ENOTSUP;
     576                 :            :         memset(queue_conf, 0, sizeof(struct rte_event_queue_conf));
     577                 :        133 :         dev->dev_ops->queue_def_conf(dev, queue_id, queue_conf);
     578                 :            : 
     579                 :        133 :         rte_eventdev_trace_queue_default_conf_get(dev_id, dev, queue_id, queue_conf);
     580                 :            : 
     581                 :        133 :         return 0;
     582                 :            : }
     583                 :            : 
     584                 :            : static inline int
     585                 :            : is_valid_atomic_queue_conf(const struct rte_event_queue_conf *queue_conf)
     586                 :            : {
     587         [ +  + ]:        721 :         if (queue_conf &&
     588         [ +  + ]:        338 :                 !(queue_conf->event_queue_cfg &
     589         [ +  + ]:        265 :                   RTE_EVENT_QUEUE_CFG_SINGLE_LINK) &&
     590                 :            :                 ((queue_conf->event_queue_cfg &
     591                 :         70 :                          RTE_EVENT_QUEUE_CFG_ALL_TYPES) ||
     592         [ +  + ]:         70 :                 (queue_conf->schedule_type
     593                 :            :                         == RTE_SCHED_TYPE_ATOMIC)
     594                 :            :                 ))
     595                 :            :                 return 1;
     596                 :            :         else
     597                 :            :                 return 0;
     598                 :            : }
     599                 :            : 
     600                 :            : static inline int
     601                 :            : is_valid_ordered_queue_conf(const struct rte_event_queue_conf *queue_conf)
     602                 :            : {
     603         [ +  + ]:        720 :         if (queue_conf &&
     604         [ +  + ]:        337 :                 !(queue_conf->event_queue_cfg &
     605         [ +  + ]:        264 :                   RTE_EVENT_QUEUE_CFG_SINGLE_LINK) &&
     606                 :            :                 ((queue_conf->event_queue_cfg &
     607                 :         70 :                          RTE_EVENT_QUEUE_CFG_ALL_TYPES) ||
     608         [ +  + ]:         70 :                 (queue_conf->schedule_type
     609                 :            :                         == RTE_SCHED_TYPE_ORDERED)
     610                 :            :                 ))
     611                 :            :                 return 1;
     612                 :            :         else
     613                 :            :                 return 0;
     614                 :            : }
     615                 :            : 
     616                 :            : 
     617                 :            : RTE_EXPORT_SYMBOL(rte_event_queue_setup)
     618                 :            : int
     619                 :        722 : rte_event_queue_setup(uint8_t dev_id, uint8_t queue_id,
     620                 :            :                       const struct rte_event_queue_conf *queue_conf)
     621                 :            : {
     622                 :            :         struct rte_eventdev *dev;
     623                 :            :         struct rte_event_queue_conf def_conf;
     624                 :            : 
     625         [ +  - ]:        722 :         RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
     626                 :            :         dev = &rte_eventdevs[dev_id];
     627                 :            : 
     628         [ +  + ]:        722 :         if (!is_valid_queue(dev, queue_id)) {
     629                 :          1 :                 RTE_EDEV_LOG_ERR("Invalid queue_id=%" PRIu8, queue_id);
     630                 :          1 :                 return -EINVAL;
     631                 :            :         }
     632                 :            : 
     633                 :            :         /* Check nb_atomic_flows limit */
     634                 :            :         if (is_valid_atomic_queue_conf(queue_conf)) {
     635         [ +  - ]:        251 :                 if (queue_conf->nb_atomic_flows == 0 ||
     636                 :            :                     queue_conf->nb_atomic_flows >
     637         [ +  + ]:        251 :                         dev->data->dev_conf.nb_event_queue_flows) {
     638                 :          1 :                         RTE_EDEV_LOG_ERR(
     639                 :            :                 "dev%d queue%d Invalid nb_atomic_flows=%d max_flows=%d",
     640                 :            :                         dev_id, queue_id, queue_conf->nb_atomic_flows,
     641                 :            :                         dev->data->dev_conf.nb_event_queue_flows);
     642                 :          1 :                         return -EINVAL;
     643                 :            :                 }
     644                 :            :         }
     645                 :            : 
     646                 :            :         /* Check nb_atomic_order_sequences limit */
     647                 :            :         if (is_valid_ordered_queue_conf(queue_conf)) {
     648         [ +  - ]:        206 :                 if (queue_conf->nb_atomic_order_sequences == 0 ||
     649                 :            :                     queue_conf->nb_atomic_order_sequences >
     650         [ +  + ]:        206 :                         dev->data->dev_conf.nb_event_queue_flows) {
     651                 :          1 :                         RTE_EDEV_LOG_ERR(
     652                 :            :                 "dev%d queue%d Invalid nb_atomic_order_seq=%d max_flows=%d",
     653                 :            :                         dev_id, queue_id, queue_conf->nb_atomic_order_sequences,
     654                 :            :                         dev->data->dev_conf.nb_event_queue_flows);
     655                 :          1 :                         return -EINVAL;
     656                 :            :                 }
     657                 :            :         }
     658                 :            : 
     659         [ -  + ]:        719 :         if (dev->data->dev_started) {
     660                 :          0 :                 RTE_EDEV_LOG_ERR(
     661                 :            :                     "device %d must be stopped to allow queue setup", dev_id);
     662                 :          0 :                 return -EBUSY;
     663                 :            :         }
     664                 :            : 
     665         [ +  - ]:        719 :         if (dev->dev_ops->queue_setup == NULL)
     666                 :            :                 return -ENOTSUP;
     667                 :            : 
     668         [ +  + ]:        719 :         if (queue_conf == NULL) {
     669         [ +  - ]:        383 :                 if (dev->dev_ops->queue_def_conf == NULL)
     670                 :            :                         return -ENOTSUP;
     671                 :        383 :                 dev->dev_ops->queue_def_conf(dev, queue_id, &def_conf);
     672                 :            :                 queue_conf = &def_conf;
     673                 :            :         }
     674                 :            : 
     675         [ -  + ]:        719 :         dev->data->queues_cfg[queue_id] = *queue_conf;
     676                 :        719 :         rte_eventdev_trace_queue_setup(dev_id, queue_id, queue_conf);
     677                 :        719 :         return dev->dev_ops->queue_setup(dev, queue_id, queue_conf);
     678                 :            : }
     679                 :            : 
     680                 :            : static inline int
     681                 :            : is_valid_port(struct rte_eventdev *dev, uint8_t port_id)
     682                 :            : {
     683         [ -  + ]:          2 :         if (port_id < dev->data->nb_ports)
     684                 :            :                 return 1;
     685                 :            :         else
     686                 :            :                 return 0;
     687                 :            : }
     688                 :            : 
     689                 :            : RTE_EXPORT_SYMBOL(rte_event_port_default_conf_get)
     690                 :            : int
     691                 :         39 : rte_event_port_default_conf_get(uint8_t dev_id, uint8_t port_id,
     692                 :            :                                  struct rte_event_port_conf *port_conf)
     693                 :            : {
     694                 :            :         struct rte_eventdev *dev;
     695                 :            : 
     696         [ +  - ]:         39 :         RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
     697                 :            :         dev = &rte_eventdevs[dev_id];
     698                 :            : 
     699         [ +  + ]:         39 :         if (port_conf == NULL)
     700                 :            :                 return -EINVAL;
     701                 :            : 
     702         [ -  + ]:         37 :         if (!is_valid_port(dev, port_id)) {
     703                 :          0 :                 RTE_EDEV_LOG_ERR("Invalid port_id=%" PRIu8, port_id);
     704                 :          0 :                 return -EINVAL;
     705                 :            :         }
     706                 :            : 
     707         [ +  - ]:         37 :         if (dev->dev_ops->port_def_conf == NULL)
     708                 :            :                 return -ENOTSUP;
     709                 :            :         memset(port_conf, 0, sizeof(struct rte_event_port_conf));
     710                 :         37 :         dev->dev_ops->port_def_conf(dev, port_id, port_conf);
     711                 :            : 
     712                 :         37 :         rte_eventdev_trace_port_default_conf_get(dev_id, dev, port_id, port_conf);
     713                 :            : 
     714                 :         37 :         return 0;
     715                 :            : }
     716                 :            : 
     717                 :            : RTE_EXPORT_SYMBOL(rte_event_port_setup)
     718                 :            : int
     719                 :        316 : rte_event_port_setup(uint8_t dev_id, uint8_t port_id,
     720                 :            :                      const struct rte_event_port_conf *port_conf)
     721                 :            : {
     722                 :            :         struct rte_eventdev *dev;
     723                 :            :         struct rte_event_port_conf def_conf;
     724                 :            :         int diag;
     725                 :            : 
     726         [ +  - ]:        316 :         RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
     727                 :            :         dev = &rte_eventdevs[dev_id];
     728                 :            : 
     729         [ +  + ]:        316 :         if (!is_valid_port(dev, port_id)) {
     730                 :          1 :                 RTE_EDEV_LOG_ERR("Invalid port_id=%" PRIu8, port_id);
     731                 :          1 :                 return -EINVAL;
     732                 :            :         }
     733                 :            : 
     734                 :            :         /* Check new_event_threshold limit */
     735   [ +  +  +  - ]:        315 :         if ((port_conf && !port_conf->new_event_threshold) ||
     736                 :            :                         (port_conf && port_conf->new_event_threshold >
     737         [ +  + ]:        116 :                                  dev->data->dev_conf.nb_events_limit)) {
     738                 :          1 :                 RTE_EDEV_LOG_ERR(
     739                 :            :                    "dev%d port%d Invalid event_threshold=%d nb_events_limit=%d",
     740                 :            :                         dev_id, port_id, port_conf->new_event_threshold,
     741                 :            :                         dev->data->dev_conf.nb_events_limit);
     742                 :          1 :                 return -EINVAL;
     743                 :            :         }
     744                 :            : 
     745                 :            :         /* Check dequeue_depth limit */
     746   [ +  +  +  - ]:        314 :         if ((port_conf && !port_conf->dequeue_depth) ||
     747                 :        115 :                         (port_conf && port_conf->dequeue_depth >
     748         [ +  + ]:        115 :                 dev->data->dev_conf.nb_event_port_dequeue_depth)) {
     749                 :          1 :                 RTE_EDEV_LOG_ERR(
     750                 :            :                    "dev%d port%d Invalid dequeue depth=%d max_dequeue_depth=%d",
     751                 :            :                         dev_id, port_id, port_conf->dequeue_depth,
     752                 :            :                         dev->data->dev_conf.nb_event_port_dequeue_depth);
     753                 :          1 :                 return -EINVAL;
     754                 :            :         }
     755                 :            : 
     756                 :            :         /* Check enqueue_depth limit */
     757   [ +  +  +  - ]:        313 :         if ((port_conf && !port_conf->enqueue_depth) ||
     758                 :        114 :                         (port_conf && port_conf->enqueue_depth >
     759         [ +  + ]:        114 :                 dev->data->dev_conf.nb_event_port_enqueue_depth)) {
     760                 :          1 :                 RTE_EDEV_LOG_ERR(
     761                 :            :                    "dev%d port%d Invalid enqueue depth=%d max_enqueue_depth=%d",
     762                 :            :                         dev_id, port_id, port_conf->enqueue_depth,
     763                 :            :                         dev->data->dev_conf.nb_event_port_enqueue_depth);
     764                 :          1 :                 return -EINVAL;
     765                 :            :         }
     766                 :            : 
     767         [ +  + ]:        312 :         if (port_conf &&
     768         [ +  + ]:        113 :             (port_conf->event_port_cfg & RTE_EVENT_PORT_CFG_DISABLE_IMPL_REL) &&
     769         [ +  - ]:          1 :             !(dev->data->event_dev_cap &
     770                 :            :               RTE_EVENT_DEV_CAP_IMPLICIT_RELEASE_DISABLE)) {
     771                 :          1 :                 RTE_EDEV_LOG_ERR(
     772                 :            :                    "dev%d port%d Implicit release disable not supported",
     773                 :            :                         dev_id, port_id);
     774                 :          1 :                 return -EINVAL;
     775                 :            :         }
     776                 :            : 
     777         [ -  + ]:        311 :         if (dev->data->dev_started) {
     778                 :          0 :                 RTE_EDEV_LOG_ERR(
     779                 :            :                     "device %d must be stopped to allow port setup", dev_id);
     780                 :          0 :                 return -EBUSY;
     781                 :            :         }
     782                 :            : 
     783         [ +  - ]:        311 :         if (dev->dev_ops->port_setup == NULL)
     784                 :            :                 return -ENOTSUP;
     785                 :            : 
     786         [ +  + ]:        311 :         if (port_conf == NULL) {
     787         [ +  - ]:        199 :                 if (dev->dev_ops->port_def_conf == NULL)
     788                 :            :                         return -ENOTSUP;
     789                 :        199 :                 dev->dev_ops->port_def_conf(dev, port_id, &def_conf);
     790                 :            :                 port_conf = &def_conf;
     791                 :            :         }
     792                 :            : 
     793                 :        311 :         dev->data->ports_cfg[port_id] = *port_conf;
     794                 :            : 
     795                 :        311 :         diag = dev->dev_ops->port_setup(dev, port_id, port_conf);
     796                 :            : 
     797                 :            :         /* Unlink all the queues from this port(default state after setup) */
     798         [ +  - ]:        311 :         if (!diag)
     799                 :        311 :                 diag = rte_event_port_unlink(dev_id, port_id, NULL, 0);
     800                 :            : 
     801                 :        311 :         rte_eventdev_trace_port_setup(dev_id, port_id, port_conf, diag);
     802                 :            :         if (diag < 0)
     803                 :            :                 return diag;
     804                 :            : 
     805                 :            :         return 0;
     806                 :            : }
     807                 :            : 
     808                 :            : RTE_EXPORT_SYMBOL(rte_event_port_quiesce)
     809                 :            : void
     810                 :          0 : rte_event_port_quiesce(uint8_t dev_id, uint8_t port_id,
     811                 :            :                        rte_eventdev_port_flush_t release_cb, void *args)
     812                 :            : {
     813                 :            :         struct rte_eventdev *dev;
     814                 :            : 
     815         [ #  # ]:          0 :         RTE_EVENTDEV_VALID_DEVID_OR_RET(dev_id);
     816                 :            :         dev = &rte_eventdevs[dev_id];
     817                 :            : 
     818   [ #  #  #  # ]:          0 :         rte_eventdev_trace_port_quiesce(dev_id, dev, port_id, args);
     819                 :            : 
     820                 :            :         if (!is_valid_port(dev, port_id)) {
     821                 :          0 :                 RTE_EDEV_LOG_ERR("Invalid port_id=%" PRIu8, port_id);
     822                 :          0 :                 return;
     823                 :            :         }
     824                 :            : 
     825         [ #  # ]:          0 :         if (dev->dev_ops->port_quiesce)
     826                 :          0 :                 dev->dev_ops->port_quiesce(dev, dev->data->ports[port_id], release_cb, args);
     827                 :            : }
     828                 :            : 
     829                 :            : RTE_EXPORT_SYMBOL(rte_event_dev_attr_get)
     830                 :            : int
     831                 :         25 : rte_event_dev_attr_get(uint8_t dev_id, uint32_t attr_id,
     832                 :            :                        uint32_t *attr_value)
     833                 :            : {
     834                 :            :         struct rte_eventdev *dev;
     835                 :            : 
     836         [ +  - ]:         25 :         if (!attr_value)
     837                 :            :                 return -EINVAL;
     838         [ +  - ]:         25 :         RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
     839                 :            :         dev = &rte_eventdevs[dev_id];
     840                 :            : 
     841   [ +  +  -  - ]:         25 :         switch (attr_id) {
     842                 :          9 :         case RTE_EVENT_DEV_ATTR_PORT_COUNT:
     843                 :          9 :                 *attr_value = dev->data->nb_ports;
     844                 :          9 :                 break;
     845                 :         16 :         case RTE_EVENT_DEV_ATTR_QUEUE_COUNT:
     846                 :         16 :                 *attr_value = dev->data->nb_queues;
     847                 :         16 :                 break;
     848                 :          0 :         case RTE_EVENT_DEV_ATTR_STARTED:
     849                 :          0 :                 *attr_value = dev->data->dev_started;
     850                 :          0 :                 break;
     851                 :            :         default:
     852                 :            :                 return -EINVAL;
     853                 :            :         }
     854                 :            : 
     855         [ -  + ]:         25 :         rte_eventdev_trace_attr_get(dev_id, dev, attr_id, *attr_value);
     856                 :            : 
     857                 :         25 :         return 0;
     858                 :            : }
     859                 :            : 
     860                 :            : RTE_EXPORT_SYMBOL(rte_event_port_attr_get)
     861                 :            : int
     862                 :          3 : rte_event_port_attr_get(uint8_t dev_id, uint8_t port_id, uint32_t attr_id,
     863                 :            :                         uint32_t *attr_value)
     864                 :            : {
     865                 :            :         struct rte_eventdev *dev;
     866                 :            : 
     867         [ +  - ]:          3 :         if (!attr_value)
     868                 :            :                 return -EINVAL;
     869                 :            : 
     870         [ +  - ]:          3 :         RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
     871                 :            :         dev = &rte_eventdevs[dev_id];
     872         [ -  + ]:          3 :         if (!is_valid_port(dev, port_id)) {
     873                 :          0 :                 RTE_EDEV_LOG_ERR("Invalid port_id=%" PRIu8, port_id);
     874                 :          0 :                 return -EINVAL;
     875                 :            :         }
     876                 :            : 
     877   [ +  +  +  -  :          3 :         switch (attr_id) {
                   -  - ]
     878                 :          1 :         case RTE_EVENT_PORT_ATTR_ENQ_DEPTH:
     879                 :          1 :                 *attr_value = dev->data->ports_cfg[port_id].enqueue_depth;
     880                 :          1 :                 break;
     881                 :          1 :         case RTE_EVENT_PORT_ATTR_DEQ_DEPTH:
     882                 :          1 :                 *attr_value = dev->data->ports_cfg[port_id].dequeue_depth;
     883                 :          1 :                 break;
     884                 :          1 :         case RTE_EVENT_PORT_ATTR_NEW_EVENT_THRESHOLD:
     885                 :          1 :                 *attr_value = dev->data->ports_cfg[port_id].new_event_threshold;
     886                 :          1 :                 break;
     887                 :          0 :         case RTE_EVENT_PORT_ATTR_IMPLICIT_RELEASE_DISABLE:
     888                 :            :         {
     889                 :            :                 uint32_t config;
     890                 :            : 
     891                 :          0 :                 config = dev->data->ports_cfg[port_id].event_port_cfg;
     892                 :          0 :                 *attr_value = !!(config & RTE_EVENT_PORT_CFG_DISABLE_IMPL_REL);
     893                 :          0 :                 break;
     894                 :            :         }
     895                 :          0 :         case RTE_EVENT_PORT_ATTR_INDEPENDENT_ENQ:
     896                 :            :         {
     897                 :            :                 uint32_t config;
     898                 :            : 
     899                 :          0 :                 config = dev->data->ports_cfg[port_id].event_port_cfg;
     900                 :          0 :                 *attr_value = !!(config & RTE_EVENT_PORT_CFG_INDEPENDENT_ENQ);
     901                 :          0 :                 break;
     902                 :            :         }
     903                 :            :         default:
     904                 :            :                 return -EINVAL;
     905                 :            :         };
     906                 :            : 
     907         [ -  + ]:          3 :         rte_eventdev_trace_port_attr_get(dev_id, dev, port_id, attr_id, *attr_value);
     908                 :            : 
     909                 :          3 :         return 0;
     910                 :            : }
     911                 :            : 
     912                 :            : RTE_EXPORT_SYMBOL(rte_event_queue_attr_get)
     913                 :            : int
     914                 :        256 : rte_event_queue_attr_get(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id,
     915                 :            :                         uint32_t *attr_value)
     916                 :            : {
     917                 :            :         struct rte_event_queue_conf *conf;
     918                 :            :         struct rte_eventdev *dev;
     919                 :            : 
     920         [ +  - ]:        256 :         if (!attr_value)
     921                 :            :                 return -EINVAL;
     922                 :            : 
     923         [ +  - ]:        256 :         RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
     924                 :            :         dev = &rte_eventdevs[dev_id];
     925         [ -  + ]:        256 :         if (!is_valid_queue(dev, queue_id)) {
     926                 :          0 :                 RTE_EDEV_LOG_ERR("Invalid queue_id=%" PRIu8, queue_id);
     927                 :          0 :                 return -EINVAL;
     928                 :            :         }
     929                 :            : 
     930                 :            :         conf = &dev->data->queues_cfg[queue_id];
     931                 :            : 
     932   [ +  +  +  +  :        256 :         switch (attr_id) {
             -  -  -  - ]
     933                 :         64 :         case RTE_EVENT_QUEUE_ATTR_PRIORITY:
     934                 :         64 :                 *attr_value = RTE_EVENT_DEV_PRIORITY_NORMAL;
     935         [ +  - ]:         64 :                 if (dev->data->event_dev_cap & RTE_EVENT_DEV_CAP_QUEUE_QOS)
     936                 :         64 :                         *attr_value = conf->priority;
     937                 :            :                 break;
     938                 :         64 :         case RTE_EVENT_QUEUE_ATTR_NB_ATOMIC_FLOWS:
     939                 :         64 :                 *attr_value = conf->nb_atomic_flows;
     940                 :         64 :                 break;
     941                 :         64 :         case RTE_EVENT_QUEUE_ATTR_NB_ATOMIC_ORDER_SEQUENCES:
     942                 :         64 :                 *attr_value = conf->nb_atomic_order_sequences;
     943                 :         64 :                 break;
     944                 :         64 :         case RTE_EVENT_QUEUE_ATTR_EVENT_QUEUE_CFG:
     945                 :         64 :                 *attr_value = conf->event_queue_cfg;
     946                 :         64 :                 break;
     947                 :          0 :         case RTE_EVENT_QUEUE_ATTR_SCHEDULE_TYPE:
     948         [ #  # ]:          0 :                 if (conf->event_queue_cfg & RTE_EVENT_QUEUE_CFG_ALL_TYPES)
     949                 :            :                         return -EOVERFLOW;
     950                 :            : 
     951                 :          0 :                 *attr_value = conf->schedule_type;
     952                 :          0 :                 break;
     953                 :          0 :         case RTE_EVENT_QUEUE_ATTR_WEIGHT:
     954                 :          0 :                 *attr_value = RTE_EVENT_QUEUE_WEIGHT_LOWEST;
     955         [ #  # ]:          0 :                 if (dev->data->event_dev_cap & RTE_EVENT_DEV_CAP_QUEUE_QOS)
     956                 :          0 :                         *attr_value = conf->weight;
     957                 :            :                 break;
     958                 :          0 :         case RTE_EVENT_QUEUE_ATTR_AFFINITY:
     959                 :          0 :                 *attr_value = RTE_EVENT_QUEUE_AFFINITY_LOWEST;
     960         [ #  # ]:          0 :                 if (dev->data->event_dev_cap & RTE_EVENT_DEV_CAP_QUEUE_QOS)
     961                 :          0 :                         *attr_value = conf->affinity;
     962                 :            :                 break;
     963                 :            :         default:
     964                 :            :                 return -EINVAL;
     965                 :            :         };
     966                 :            : 
     967         [ -  + ]:        256 :         rte_eventdev_trace_queue_attr_get(dev_id, dev, queue_id, attr_id, *attr_value);
     968                 :            : 
     969                 :        256 :         return 0;
     970                 :            : }
     971                 :            : 
     972                 :            : RTE_EXPORT_SYMBOL(rte_event_queue_attr_set)
     973                 :            : int
     974                 :          0 : rte_event_queue_attr_set(uint8_t dev_id, uint8_t queue_id, uint32_t attr_id,
     975                 :            :                          uint64_t attr_value)
     976                 :            : {
     977                 :            :         struct rte_eventdev *dev;
     978                 :            : 
     979   [ #  #  #  # ]:          0 :         rte_eventdev_trace_queue_attr_set(dev_id, queue_id, attr_id, attr_value);
     980                 :            : 
     981                 :          0 :         RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
     982                 :            :         dev = &rte_eventdevs[dev_id];
     983                 :            :         if (!is_valid_queue(dev, queue_id)) {
     984                 :          0 :                 RTE_EDEV_LOG_ERR("Invalid queue_id=%" PRIu8, queue_id);
     985                 :          0 :                 return -EINVAL;
     986                 :            :         }
     987                 :            : 
     988         [ #  # ]:          0 :         if (!(dev->data->event_dev_cap &
     989                 :            :               RTE_EVENT_DEV_CAP_RUNTIME_QUEUE_ATTR)) {
     990                 :          0 :                 RTE_EDEV_LOG_ERR(
     991                 :            :                         "Device %" PRIu8 "does not support changing queue attributes at runtime",
     992                 :            :                         dev_id);
     993                 :          0 :                 return -ENOTSUP;
     994                 :            :         }
     995                 :            : 
     996         [ #  # ]:          0 :         if (dev->dev_ops->queue_attr_set == NULL)
     997                 :            :                 return -ENOTSUP;
     998                 :          0 :         return dev->dev_ops->queue_attr_set(dev, queue_id, attr_id, attr_value);
     999                 :            : }
    1000                 :            : 
    1001                 :            : RTE_EXPORT_SYMBOL(rte_event_port_link)
    1002                 :            : int
    1003                 :        100 : rte_event_port_link(uint8_t dev_id, uint8_t port_id,
    1004                 :            :                     const uint8_t queues[], const uint8_t priorities[],
    1005                 :            :                     uint16_t nb_links)
    1006                 :            : {
    1007                 :        100 :         return rte_event_port_profile_links_set(dev_id, port_id, queues, priorities, nb_links, 0);
    1008                 :            : }
    1009                 :            : 
    1010                 :            : RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_event_port_profile_links_set, 23.11)
    1011                 :            : int
    1012                 :        100 : rte_event_port_profile_links_set(uint8_t dev_id, uint8_t port_id, const uint8_t queues[],
    1013                 :            :                                  const uint8_t priorities[], uint16_t nb_links, uint8_t profile_id)
    1014                 :            : {
    1015                 :            :         uint8_t priorities_list[RTE_EVENT_MAX_QUEUES_PER_DEV];
    1016                 :            :         uint8_t queues_list[RTE_EVENT_MAX_QUEUES_PER_DEV];
    1017                 :            :         struct rte_event_dev_info info;
    1018                 :            :         struct rte_eventdev *dev;
    1019                 :            :         uint16_t *links_map;
    1020                 :            :         int i, diag;
    1021                 :            : 
    1022         [ +  - ]:        100 :         RTE_EVENTDEV_VALID_DEVID_OR_ERRNO_RET(dev_id, EINVAL, 0);
    1023                 :            :         dev = &rte_eventdevs[dev_id];
    1024                 :            : 
    1025         [ +  - ]:        100 :         if (dev->dev_ops->dev_infos_get == NULL)
    1026                 :            :                 return -ENOTSUP;
    1027                 :            : 
    1028                 :        100 :         dev->dev_ops->dev_infos_get(dev, &info);
    1029         [ +  - ]:        100 :         if (profile_id >= RTE_EVENT_MAX_PROFILES_PER_PORT ||
    1030         [ -  + ]:        100 :             profile_id >= info.max_profiles_per_port) {
    1031                 :          0 :                 RTE_EDEV_LOG_ERR("Invalid profile_id=%" PRIu8, profile_id);
    1032                 :          0 :                 return -EINVAL;
    1033                 :            :         }
    1034                 :            : 
    1035         [ -  + ]:        100 :         if (dev->dev_ops->port_link == NULL) {
    1036                 :          0 :                 RTE_EDEV_LOG_ERR("Function not supported");
    1037                 :          0 :                 rte_errno = ENOTSUP;
    1038                 :          0 :                 return 0;
    1039                 :            :         }
    1040                 :            : 
    1041   [ -  +  -  - ]:        100 :         if (profile_id && dev->dev_ops->port_link_profile == NULL) {
    1042                 :          0 :                 RTE_EDEV_LOG_ERR("Function not supported");
    1043                 :          0 :                 rte_errno = ENOTSUP;
    1044                 :          0 :                 return 0;
    1045                 :            :         }
    1046                 :            : 
    1047         [ -  + ]:        100 :         if (!is_valid_port(dev, port_id)) {
    1048                 :          0 :                 RTE_EDEV_LOG_ERR("Invalid port_id=%" PRIu8, port_id);
    1049                 :          0 :                 rte_errno = EINVAL;
    1050                 :          0 :                 return 0;
    1051                 :            :         }
    1052                 :            : 
    1053         [ +  + ]:        100 :         if (queues == NULL) {
    1054         [ +  + ]:        612 :                 for (i = 0; i < dev->data->nb_queues; i++)
    1055                 :        560 :                         queues_list[i] = i;
    1056                 :            : 
    1057                 :            :                 queues = queues_list;
    1058                 :         52 :                 nb_links = dev->data->nb_queues;
    1059                 :            :         }
    1060                 :            : 
    1061         [ +  + ]:        100 :         if (priorities == NULL) {
    1062         [ +  + ]:        684 :                 for (i = 0; i < nb_links; i++)
    1063                 :        596 :                         priorities_list[i] = RTE_EVENT_DEV_PRIORITY_NORMAL;
    1064                 :            : 
    1065                 :            :                 priorities = priorities_list;
    1066                 :            :         }
    1067                 :            : 
    1068         [ +  + ]:        837 :         for (i = 0; i < nb_links; i++)
    1069         [ -  + ]:        737 :                 if (queues[i] >= dev->data->nb_queues) {
    1070                 :          0 :                         rte_errno = EINVAL;
    1071                 :          0 :                         return 0;
    1072                 :            :                 }
    1073                 :            : 
    1074         [ -  + ]:        100 :         if (profile_id)
    1075                 :          0 :                 diag = dev->dev_ops->port_link_profile(dev, dev->data->ports[port_id], queues,
    1076                 :            :                                                        priorities, nb_links, profile_id);
    1077                 :            :         else
    1078                 :        100 :                 diag = dev->dev_ops->port_link(dev, dev->data->ports[port_id], queues,
    1079                 :            :                                                priorities, nb_links);
    1080         [ +  - ]:        100 :         if (diag < 0)
    1081                 :            :                 return diag;
    1082                 :            : 
    1083                 :        100 :         links_map = dev->data->links_map[profile_id];
    1084                 :            :         /* Point links_map to this port specific area */
    1085                 :        100 :         links_map += (port_id * RTE_EVENT_MAX_QUEUES_PER_DEV);
    1086         [ +  + ]:        837 :         for (i = 0; i < diag; i++)
    1087                 :        737 :                 links_map[queues[i]] = (uint8_t)priorities[i];
    1088                 :            : 
    1089                 :        100 :         rte_eventdev_trace_port_profile_links_set(dev_id, port_id, nb_links, profile_id, diag);
    1090                 :        100 :         return diag;
    1091                 :            : }
    1092                 :            : 
    1093                 :            : RTE_EXPORT_SYMBOL(rte_event_port_unlink)
    1094                 :            : int
    1095                 :        319 : rte_event_port_unlink(uint8_t dev_id, uint8_t port_id,
    1096                 :            :                       uint8_t queues[], uint16_t nb_unlinks)
    1097                 :            : {
    1098                 :        319 :         return rte_event_port_profile_unlink(dev_id, port_id, queues, nb_unlinks, 0);
    1099                 :            : }
    1100                 :            : 
    1101                 :            : RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_event_port_profile_unlink, 23.11)
    1102                 :            : int
    1103                 :        319 : rte_event_port_profile_unlink(uint8_t dev_id, uint8_t port_id, uint8_t queues[],
    1104                 :            :                               uint16_t nb_unlinks, uint8_t profile_id)
    1105                 :            : {
    1106                 :            :         uint8_t all_queues[RTE_EVENT_MAX_QUEUES_PER_DEV];
    1107                 :            :         struct rte_event_dev_info info;
    1108                 :            :         struct rte_eventdev *dev;
    1109                 :            :         uint16_t *links_map;
    1110                 :            :         int i, diag, j;
    1111                 :            : 
    1112         [ +  - ]:        319 :         RTE_EVENTDEV_VALID_DEVID_OR_ERRNO_RET(dev_id, EINVAL, 0);
    1113                 :            :         dev = &rte_eventdevs[dev_id];
    1114                 :            : 
    1115         [ +  - ]:        319 :         if (dev->dev_ops->dev_infos_get == NULL)
    1116                 :            :                 return -ENOTSUP;
    1117                 :            : 
    1118                 :        319 :         dev->dev_ops->dev_infos_get(dev, &info);
    1119         [ +  - ]:        319 :         if (profile_id >= RTE_EVENT_MAX_PROFILES_PER_PORT ||
    1120         [ -  + ]:        319 :             profile_id >= info.max_profiles_per_port) {
    1121                 :          0 :                 RTE_EDEV_LOG_ERR("Invalid profile_id=%" PRIu8, profile_id);
    1122                 :          0 :                 return -EINVAL;
    1123                 :            :         }
    1124                 :            : 
    1125         [ -  + ]:        319 :         if (dev->dev_ops->port_unlink == NULL) {
    1126                 :          0 :                 RTE_EDEV_LOG_ERR("Function not supported");
    1127                 :          0 :                 rte_errno = ENOTSUP;
    1128                 :          0 :                 return 0;
    1129                 :            :         }
    1130                 :            : 
    1131   [ -  +  -  - ]:        319 :         if (profile_id && dev->dev_ops->port_unlink_profile == NULL) {
    1132                 :          0 :                 RTE_EDEV_LOG_ERR("Function not supported");
    1133                 :          0 :                 rte_errno = ENOTSUP;
    1134                 :          0 :                 return 0;
    1135                 :            :         }
    1136                 :            : 
    1137         [ -  + ]:        319 :         if (!is_valid_port(dev, port_id)) {
    1138                 :          0 :                 RTE_EDEV_LOG_ERR("Invalid port_id=%" PRIu8, port_id);
    1139                 :          0 :                 rte_errno = EINVAL;
    1140                 :          0 :                 return 0;
    1141                 :            :         }
    1142                 :            : 
    1143                 :        319 :         links_map = dev->data->links_map[profile_id];
    1144                 :            :         /* Point links_map to this port specific area */
    1145                 :        319 :         links_map += (port_id * RTE_EVENT_MAX_QUEUES_PER_DEV);
    1146                 :            : 
    1147         [ +  + ]:        319 :         if (queues == NULL) {
    1148                 :            :                 j = 0;
    1149         [ +  + ]:      13136 :                 for (i = 0; i < dev->data->nb_queues; i++) {
    1150         [ +  + ]:      12821 :                         if (links_map[i] !=
    1151                 :            :                                         EVENT_QUEUE_SERVICE_PRIORITY_INVALID) {
    1152                 :        349 :                                 all_queues[j] = i;
    1153                 :        349 :                                 j++;
    1154                 :            :                         }
    1155                 :            :                 }
    1156                 :            :                 queues = all_queues;
    1157                 :            :         } else {
    1158         [ +  + ]:        135 :                 for (j = 0; j < nb_unlinks; j++) {
    1159         [ +  - ]:        131 :                         if (links_map[queues[j]] ==
    1160                 :            :                                         EVENT_QUEUE_SERVICE_PRIORITY_INVALID)
    1161                 :            :                                 break;
    1162                 :            :                 }
    1163                 :            :         }
    1164                 :            : 
    1165                 :        319 :         nb_unlinks = j;
    1166         [ +  + ]:        799 :         for (i = 0; i < nb_unlinks; i++)
    1167         [ -  + ]:        480 :                 if (queues[i] >= dev->data->nb_queues) {
    1168                 :          0 :                         rte_errno = EINVAL;
    1169                 :          0 :                         return 0;
    1170                 :            :                 }
    1171                 :            : 
    1172         [ -  + ]:        319 :         if (profile_id)
    1173                 :          0 :                 diag = dev->dev_ops->port_unlink_profile(dev, dev->data->ports[port_id], queues,
    1174                 :            :                                                          nb_unlinks, profile_id);
    1175                 :            :         else
    1176                 :        319 :                 diag = dev->dev_ops->port_unlink(dev, dev->data->ports[port_id], queues,
    1177                 :            :                                                  nb_unlinks);
    1178         [ +  - ]:        319 :         if (diag < 0)
    1179                 :            :                 return diag;
    1180                 :            : 
    1181         [ +  + ]:        713 :         for (i = 0; i < diag; i++)
    1182                 :        394 :                 links_map[queues[i]] = EVENT_QUEUE_SERVICE_PRIORITY_INVALID;
    1183                 :            : 
    1184                 :        319 :         rte_eventdev_trace_port_profile_unlink(dev_id, port_id, nb_unlinks, profile_id, diag);
    1185                 :        319 :         return diag;
    1186                 :            : }
    1187                 :            : 
    1188                 :            : RTE_EXPORT_SYMBOL(rte_event_port_unlinks_in_progress)
    1189                 :            : int
    1190                 :          2 : rte_event_port_unlinks_in_progress(uint8_t dev_id, uint8_t port_id)
    1191                 :            : {
    1192                 :            :         struct rte_eventdev *dev;
    1193                 :            : 
    1194   [ -  +  +  - ]:          2 :         rte_eventdev_trace_port_unlinks_in_progress(dev_id, port_id);
    1195                 :            : 
    1196                 :          0 :         RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
    1197                 :            :         dev = &rte_eventdevs[dev_id];
    1198                 :            :         if (!is_valid_port(dev, port_id)) {
    1199                 :          0 :                 RTE_EDEV_LOG_ERR("Invalid port_id=%" PRIu8, port_id);
    1200                 :          0 :                 return -EINVAL;
    1201                 :            :         }
    1202                 :            : 
    1203                 :            :         /* Return 0 if the PMD does not implement unlinks in progress.
    1204                 :            :          * This allows PMDs which handle unlink synchronously to not implement
    1205                 :            :          * this function at all.
    1206                 :            :          */
    1207         [ +  - ]:          2 :         if (dev->dev_ops->port_unlinks_in_progress == NULL)
    1208                 :            :                 return 0;
    1209                 :            : 
    1210                 :          2 :         return dev->dev_ops->port_unlinks_in_progress(dev, dev->data->ports[port_id]);
    1211                 :            : }
    1212                 :            : 
    1213                 :            : RTE_EXPORT_SYMBOL(rte_event_port_links_get)
    1214                 :            : int
    1215                 :          5 : rte_event_port_links_get(uint8_t dev_id, uint8_t port_id,
    1216                 :            :                          uint8_t queues[], uint8_t priorities[])
    1217                 :            : {
    1218                 :            :         struct rte_eventdev *dev;
    1219                 :            :         uint16_t *links_map;
    1220                 :            :         int i, count = 0;
    1221                 :            : 
    1222         [ +  - ]:          5 :         RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
    1223                 :            :         dev = &rte_eventdevs[dev_id];
    1224         [ -  + ]:          5 :         if (!is_valid_port(dev, port_id)) {
    1225                 :          0 :                 RTE_EDEV_LOG_ERR("Invalid port_id=%" PRIu8, port_id);
    1226                 :          0 :                 return -EINVAL;
    1227                 :            :         }
    1228                 :            : 
    1229                 :            :         /* Use the default profile_id. */
    1230                 :          5 :         links_map = dev->data->links_map[0];
    1231                 :            :         /* Point links_map to this port specific area */
    1232                 :          5 :         links_map += (port_id * RTE_EVENT_MAX_QUEUES_PER_DEV);
    1233         [ +  + ]:        263 :         for (i = 0; i < dev->data->nb_queues; i++) {
    1234         [ +  + ]:        258 :                 if (links_map[i] != EVENT_QUEUE_SERVICE_PRIORITY_INVALID) {
    1235                 :         68 :                         queues[count] = i;
    1236                 :         68 :                         priorities[count] = (uint8_t)links_map[i];
    1237                 :         68 :                         ++count;
    1238                 :            :                 }
    1239                 :            :         }
    1240                 :            : 
    1241                 :          5 :         rte_eventdev_trace_port_links_get(dev_id, port_id, count);
    1242                 :            : 
    1243                 :          5 :         return count;
    1244                 :            : }
    1245                 :            : 
    1246                 :            : RTE_EXPORT_EXPERIMENTAL_SYMBOL(rte_event_port_profile_links_get, 23.11)
    1247                 :            : int
    1248                 :          0 : rte_event_port_profile_links_get(uint8_t dev_id, uint8_t port_id, uint8_t queues[],
    1249                 :            :                                  uint8_t priorities[], uint8_t profile_id)
    1250                 :            : {
    1251                 :            :         struct rte_event_dev_info info;
    1252                 :            :         struct rte_eventdev *dev;
    1253                 :            :         uint16_t *links_map;
    1254                 :            :         int i, count = 0;
    1255                 :            : 
    1256         [ #  # ]:          0 :         RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
    1257                 :            : 
    1258                 :            :         dev = &rte_eventdevs[dev_id];
    1259         [ #  # ]:          0 :         if (dev->dev_ops->dev_infos_get == NULL)
    1260                 :            :                 return -ENOTSUP;
    1261                 :            : 
    1262                 :          0 :         dev->dev_ops->dev_infos_get(dev, &info);
    1263         [ #  # ]:          0 :         if (profile_id >= RTE_EVENT_MAX_PROFILES_PER_PORT ||
    1264         [ #  # ]:          0 :             profile_id >= info.max_profiles_per_port) {
    1265                 :          0 :                 RTE_EDEV_LOG_ERR("Invalid profile_id=%" PRIu8, profile_id);
    1266                 :          0 :                 return -EINVAL;
    1267                 :            :         }
    1268                 :            : 
    1269         [ #  # ]:          0 :         if (!is_valid_port(dev, port_id)) {
    1270                 :          0 :                 RTE_EDEV_LOG_ERR("Invalid port_id=%" PRIu8, port_id);
    1271                 :          0 :                 return -EINVAL;
    1272                 :            :         }
    1273                 :            : 
    1274                 :          0 :         links_map = dev->data->links_map[profile_id];
    1275                 :            :         /* Point links_map to this port specific area */
    1276                 :          0 :         links_map += (port_id * RTE_EVENT_MAX_QUEUES_PER_DEV);
    1277         [ #  # ]:          0 :         for (i = 0; i < dev->data->nb_queues; i++) {
    1278         [ #  # ]:          0 :                 if (links_map[i] != EVENT_QUEUE_SERVICE_PRIORITY_INVALID) {
    1279                 :          0 :                         queues[count] = i;
    1280                 :          0 :                         priorities[count] = (uint8_t)links_map[i];
    1281                 :          0 :                         ++count;
    1282                 :            :                 }
    1283                 :            :         }
    1284                 :            : 
    1285                 :          0 :         rte_eventdev_trace_port_profile_links_get(dev_id, port_id, profile_id, count);
    1286                 :            : 
    1287                 :          0 :         return count;
    1288                 :            : }
    1289                 :            : 
    1290                 :            : RTE_EXPORT_SYMBOL(rte_event_dequeue_timeout_ticks)
    1291                 :            : int
    1292                 :          1 : rte_event_dequeue_timeout_ticks(uint8_t dev_id, uint64_t ns,
    1293                 :            :                                  uint64_t *timeout_ticks)
    1294                 :            : {
    1295                 :            :         struct rte_eventdev *dev;
    1296                 :            : 
    1297   [ -  +  +  - ]:          1 :         rte_eventdev_trace_dequeue_timeout_ticks(dev_id, ns, timeout_ticks);
    1298                 :            : 
    1299                 :          0 :         RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
    1300                 :            :         dev = &rte_eventdevs[dev_id];
    1301         [ +  - ]:          1 :         if (dev->dev_ops->timeout_ticks == NULL)
    1302                 :            :                 return -ENOTSUP;
    1303                 :            : 
    1304         [ +  - ]:          1 :         if (timeout_ticks == NULL)
    1305                 :            :                 return -EINVAL;
    1306                 :            : 
    1307                 :          1 :         return dev->dev_ops->timeout_ticks(dev, ns, timeout_ticks);
    1308                 :            : }
    1309                 :            : 
    1310                 :            : RTE_EXPORT_SYMBOL(rte_event_dev_service_id_get)
    1311                 :            : int
    1312                 :          2 : rte_event_dev_service_id_get(uint8_t dev_id, uint32_t *service_id)
    1313                 :            : {
    1314                 :            :         struct rte_eventdev *dev;
    1315                 :            : 
    1316         [ +  - ]:          2 :         RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
    1317                 :            :         dev = &rte_eventdevs[dev_id];
    1318                 :            : 
    1319         [ +  - ]:          2 :         if (service_id == NULL)
    1320                 :            :                 return -EINVAL;
    1321                 :            : 
    1322         [ +  - ]:          2 :         if (dev->data->service_inited)
    1323                 :          2 :                 *service_id = dev->data->service_id;
    1324                 :            : 
    1325         [ -  + ]:          2 :         rte_eventdev_trace_service_id_get(dev_id, *service_id);
    1326                 :            : 
    1327         [ -  + ]:          2 :         return dev->data->service_inited ? 0 : -ESRCH;
    1328                 :            : }
    1329                 :            : 
    1330                 :            : RTE_EXPORT_SYMBOL(rte_event_dev_dump)
    1331                 :            : int
    1332                 :          0 : rte_event_dev_dump(uint8_t dev_id, FILE *f)
    1333                 :            : {
    1334                 :            :         struct rte_eventdev *dev;
    1335                 :            : 
    1336         [ #  # ]:          0 :         RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
    1337                 :            :         dev = &rte_eventdevs[dev_id];
    1338         [ #  # ]:          0 :         if (dev->dev_ops->dump == NULL)
    1339                 :            :                 return -ENOTSUP;
    1340         [ #  # ]:          0 :         if (f == NULL)
    1341                 :            :                 return -EINVAL;
    1342                 :            : 
    1343                 :          0 :         dev->dev_ops->dump(dev, f);
    1344                 :          0 :         return 0;
    1345                 :            : 
    1346                 :            : }
    1347                 :            : 
    1348                 :            : static int
    1349                 :            : xstats_get_count(uint8_t dev_id, enum rte_event_dev_xstats_mode mode,
    1350                 :            :                 uint8_t queue_port_id)
    1351                 :            : {
    1352                 :            :         struct rte_eventdev *dev = &rte_eventdevs[dev_id];
    1353                 :        776 :         if (dev->dev_ops->xstats_get_names != NULL)
    1354                 :        776 :                 return dev->dev_ops->xstats_get_names(dev, mode, queue_port_id, NULL, NULL, 0);
    1355                 :            :         return 0;
    1356                 :            : }
    1357                 :            : 
    1358                 :            : RTE_EXPORT_SYMBOL(rte_event_dev_xstats_names_get)
    1359                 :            : int
    1360                 :        776 : rte_event_dev_xstats_names_get(uint8_t dev_id,
    1361                 :            :                 enum rte_event_dev_xstats_mode mode, uint8_t queue_port_id,
    1362                 :            :                 struct rte_event_dev_xstats_name *xstats_names,
    1363                 :            :                 uint64_t *ids, unsigned int size)
    1364                 :            : {
    1365         [ +  - ]:        776 :         RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -ENODEV);
    1366         [ +  - ]:        776 :         const int cnt_expected_entries = xstats_get_count(dev_id, mode,
    1367                 :            :                                                           queue_port_id);
    1368         [ +  - ]:        776 :         if (xstats_names == NULL || cnt_expected_entries < 0 ||
    1369         [ +  - ]:        776 :                         (int)size < cnt_expected_entries)
    1370                 :            :                 return cnt_expected_entries;
    1371                 :            : 
    1372                 :            :         /* dev_id checked above */
    1373                 :        776 :         const struct rte_eventdev *dev = &rte_eventdevs[dev_id];
    1374                 :            : 
    1375         [ +  - ]:        776 :         if (dev->dev_ops->xstats_get_names != NULL)
    1376                 :        776 :                 return dev->dev_ops->xstats_get_names(dev, mode, queue_port_id,
    1377                 :            :                                                       xstats_names, ids, size);
    1378                 :            : 
    1379                 :            :         return -ENOTSUP;
    1380                 :            : }
    1381                 :            : 
    1382                 :            : /* retrieve eventdev extended statistics */
    1383                 :            : RTE_EXPORT_SYMBOL(rte_event_dev_xstats_get)
    1384                 :            : int
    1385                 :        778 : rte_event_dev_xstats_get(uint8_t dev_id, enum rte_event_dev_xstats_mode mode,
    1386                 :            :                 uint8_t queue_port_id, const uint64_t ids[],
    1387                 :            :                 uint64_t values[], unsigned int n)
    1388                 :            : {
    1389         [ +  - ]:        778 :         RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -ENODEV);
    1390                 :            :         const struct rte_eventdev *dev = &rte_eventdevs[dev_id];
    1391                 :            : 
    1392                 :            :         /* implemented by the driver */
    1393         [ +  - ]:        778 :         if (dev->dev_ops->xstats_get != NULL)
    1394                 :        778 :                 return dev->dev_ops->xstats_get(dev, mode, queue_port_id,
    1395                 :            :                                                 ids, values, n);
    1396                 :            :         return -ENOTSUP;
    1397                 :            : }
    1398                 :            : 
    1399                 :            : RTE_EXPORT_SYMBOL(rte_event_dev_xstats_by_name_get)
    1400                 :            : uint64_t
    1401                 :       2427 : rte_event_dev_xstats_by_name_get(uint8_t dev_id, const char *name,
    1402                 :            :                 uint64_t *id)
    1403                 :            : {
    1404         [ +  - ]:       2427 :         RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, 0);
    1405                 :            :         const struct rte_eventdev *dev = &rte_eventdevs[dev_id];
    1406                 :       2427 :         uint64_t temp = -1;
    1407                 :            : 
    1408         [ +  + ]:       2427 :         if (id != NULL)
    1409                 :       2345 :                 *id = (unsigned int)-1;
    1410                 :            :         else
    1411                 :            :                 id = &temp; /* ensure driver never gets a NULL value */
    1412                 :            : 
    1413                 :            :         /* implemented by driver */
    1414         [ +  - ]:       2427 :         if (dev->dev_ops->xstats_get_by_name != NULL)
    1415                 :       2427 :                 return dev->dev_ops->xstats_get_by_name(dev, name, id);
    1416                 :            :         return -ENOTSUP;
    1417                 :            : }
    1418                 :            : 
    1419                 :            : RTE_EXPORT_SYMBOL(rte_event_dev_xstats_reset)
    1420                 :         48 : int rte_event_dev_xstats_reset(uint8_t dev_id,
    1421                 :            :                 enum rte_event_dev_xstats_mode mode, int16_t queue_port_id,
    1422                 :            :                 const uint64_t ids[], uint32_t nb_ids)
    1423                 :            : {
    1424         [ +  - ]:         48 :         RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
    1425                 :            :         struct rte_eventdev *dev = &rte_eventdevs[dev_id];
    1426                 :            : 
    1427         [ +  - ]:         48 :         if (dev->dev_ops->xstats_reset != NULL)
    1428                 :         48 :                 return dev->dev_ops->xstats_reset(dev, mode, queue_port_id, ids, nb_ids);
    1429                 :            :         return -ENOTSUP;
    1430                 :            : }
    1431                 :            : 
    1432                 :            : RTE_EXPORT_INTERNAL_SYMBOL(rte_event_pmd_selftest_seqn_dynfield_offset)
    1433                 :            : int rte_event_pmd_selftest_seqn_dynfield_offset = -1;
    1434                 :            : 
    1435                 :            : RTE_EXPORT_SYMBOL(rte_event_dev_selftest)
    1436                 :          1 : int rte_event_dev_selftest(uint8_t dev_id)
    1437                 :            : {
    1438         [ +  - ]:          1 :         RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
    1439                 :            :         static const struct rte_mbuf_dynfield test_seqn_dynfield_desc = {
    1440                 :            :                 .name = "rte_event_pmd_selftest_seqn_dynfield",
    1441                 :            :                 .size = sizeof(rte_event_pmd_selftest_seqn_t),
    1442                 :            :                 .align = alignof(rte_event_pmd_selftest_seqn_t),
    1443                 :            :         };
    1444                 :            :         struct rte_eventdev *dev = &rte_eventdevs[dev_id];
    1445                 :            : 
    1446         [ +  - ]:          1 :         if (dev->dev_ops->dev_selftest != NULL) {
    1447                 :          1 :                 rte_event_pmd_selftest_seqn_dynfield_offset =
    1448                 :          1 :                         rte_mbuf_dynfield_register(&test_seqn_dynfield_desc);
    1449         [ +  - ]:          1 :                 if (rte_event_pmd_selftest_seqn_dynfield_offset < 0)
    1450                 :            :                         return -ENOMEM;
    1451                 :          1 :                 return dev->dev_ops->dev_selftest();
    1452                 :            :         }
    1453                 :            :         return -ENOTSUP;
    1454                 :            : }
    1455                 :            : 
    1456                 :            : RTE_EXPORT_SYMBOL(rte_event_vector_pool_create)
    1457                 :            : struct rte_mempool *
    1458                 :          0 : rte_event_vector_pool_create(const char *name, unsigned int n,
    1459                 :            :                              unsigned int cache_size, uint16_t nb_elem,
    1460                 :            :                              int socket_id)
    1461                 :            : {
    1462                 :            :         const char *mp_ops_name;
    1463                 :            :         struct rte_mempool *mp;
    1464                 :            :         unsigned int elt_sz;
    1465                 :            :         int ret;
    1466                 :            : 
    1467         [ #  # ]:          0 :         if (!nb_elem) {
    1468                 :          0 :                 RTE_EDEV_LOG_ERR("Invalid number of elements=%d requested",
    1469                 :            :                         nb_elem);
    1470                 :          0 :                 rte_errno = EINVAL;
    1471                 :          0 :                 return NULL;
    1472                 :            :         }
    1473                 :            : 
    1474                 :          0 :         elt_sz =
    1475                 :          0 :                 sizeof(struct rte_event_vector) + (nb_elem * sizeof(uintptr_t));
    1476                 :          0 :         mp = rte_mempool_create_empty(name, n, elt_sz, cache_size, 0, socket_id,
    1477                 :            :                                       0);
    1478         [ #  # ]:          0 :         if (mp == NULL)
    1479                 :            :                 return NULL;
    1480                 :            : 
    1481                 :          0 :         mp_ops_name = rte_mbuf_best_mempool_ops();
    1482                 :          0 :         ret = rte_mempool_set_ops_byname(mp, mp_ops_name, NULL);
    1483         [ #  # ]:          0 :         if (ret != 0) {
    1484                 :          0 :                 RTE_EDEV_LOG_ERR("error setting mempool handler");
    1485                 :          0 :                 goto err;
    1486                 :            :         }
    1487                 :            : 
    1488                 :          0 :         ret = rte_mempool_populate_default(mp);
    1489         [ #  # ]:          0 :         if (ret < 0)
    1490                 :          0 :                 goto err;
    1491                 :            : 
    1492         [ #  # ]:          0 :         rte_eventdev_trace_vector_pool_create(mp, mp->name, mp->socket_id,
    1493                 :            :                 mp->size, mp->cache_size, mp->elt_size);
    1494                 :            : 
    1495                 :          0 :         return mp;
    1496                 :          0 : err:
    1497                 :          0 :         rte_mempool_free(mp);
    1498                 :          0 :         rte_errno = -ret;
    1499                 :          0 :         return NULL;
    1500                 :            : }
    1501                 :            : 
    1502                 :            : RTE_EXPORT_SYMBOL(rte_event_dev_start)
    1503                 :            : int
    1504                 :         64 : rte_event_dev_start(uint8_t dev_id)
    1505                 :            : {
    1506                 :            :         struct rte_eventdev *dev;
    1507                 :            :         int diag;
    1508                 :            : 
    1509                 :            :         RTE_EDEV_LOG_DEBUG("Start dev_id=%" PRIu8, dev_id);
    1510                 :            : 
    1511         [ +  - ]:         64 :         RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
    1512                 :            :         dev = &rte_eventdevs[dev_id];
    1513         [ +  - ]:         64 :         if (dev->dev_ops->dev_start == NULL)
    1514                 :            :                 return -ENOTSUP;
    1515                 :            : 
    1516         [ -  + ]:         64 :         if (dev->data->dev_started != 0) {
    1517                 :          0 :                 RTE_EDEV_LOG_ERR("Device with dev_id=%" PRIu8 "already started",
    1518                 :            :                         dev_id);
    1519                 :          0 :                 return 0;
    1520                 :            :         }
    1521                 :            : 
    1522                 :         64 :         diag = (dev->dev_ops->dev_start)(dev);
    1523                 :         64 :         rte_eventdev_trace_start(dev_id, diag);
    1524         [ +  - ]:         64 :         if (diag == 0)
    1525                 :         64 :                 dev->data->dev_started = 1;
    1526                 :            :         else
    1527                 :            :                 return diag;
    1528                 :            : 
    1529                 :         64 :         event_dev_fp_ops_set(rte_event_fp_ops + dev_id, dev);
    1530                 :            : 
    1531                 :         64 :         return 0;
    1532                 :            : }
    1533                 :            : 
    1534                 :            : RTE_EXPORT_SYMBOL(rte_event_dev_stop_flush_callback_register)
    1535                 :            : int
    1536                 :          2 : rte_event_dev_stop_flush_callback_register(uint8_t dev_id,
    1537                 :            :                                            rte_eventdev_stop_flush_t callback,
    1538                 :            :                                            void *userdata)
    1539                 :            : {
    1540                 :            :         struct rte_eventdev *dev;
    1541                 :            : 
    1542                 :            :         RTE_EDEV_LOG_DEBUG("Stop flush register dev_id=%" PRIu8, dev_id);
    1543                 :            : 
    1544   [ -  +  +  - ]:          2 :         rte_eventdev_trace_stop_flush_callback_register(dev_id, callback, userdata);
    1545                 :            : 
    1546                 :          0 :         RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
    1547                 :            :         dev = &rte_eventdevs[dev_id];
    1548                 :            : 
    1549                 :          2 :         dev->dev_ops->dev_stop_flush = callback;
    1550                 :          2 :         dev->data->dev_stop_flush_arg = userdata;
    1551                 :            : 
    1552                 :          2 :         return 0;
    1553                 :            : }
    1554                 :            : 
    1555                 :            : RTE_EXPORT_SYMBOL(rte_event_dev_stop)
    1556                 :            : void
    1557                 :         68 : rte_event_dev_stop(uint8_t dev_id)
    1558                 :            : {
    1559                 :            :         struct rte_eventdev *dev;
    1560                 :            : 
    1561                 :            :         RTE_EDEV_LOG_DEBUG("Stop dev_id=%" PRIu8, dev_id);
    1562                 :            : 
    1563         [ +  - ]:         68 :         RTE_EVENTDEV_VALID_DEVID_OR_RET(dev_id);
    1564                 :            :         dev = &rte_eventdevs[dev_id];
    1565         [ +  - ]:         68 :         if (dev->dev_ops->dev_stop == NULL)
    1566                 :            :                 return;
    1567                 :            : 
    1568         [ +  + ]:         68 :         if (dev->data->dev_started == 0) {
    1569                 :          4 :                 RTE_EDEV_LOG_ERR("Device with dev_id=%" PRIu8 "already stopped",
    1570                 :            :                         dev_id);
    1571                 :          4 :                 return;
    1572                 :            :         }
    1573                 :            : 
    1574                 :         64 :         dev->data->dev_started = 0;
    1575                 :         64 :         dev->dev_ops->dev_stop(dev);
    1576                 :         64 :         rte_eventdev_trace_stop(dev_id);
    1577                 :         64 :         event_dev_fp_ops_reset(rte_event_fp_ops + dev_id);
    1578                 :            : }
    1579                 :            : 
    1580                 :            : RTE_EXPORT_SYMBOL(rte_event_dev_close)
    1581                 :            : int
    1582                 :         32 : rte_event_dev_close(uint8_t dev_id)
    1583                 :            : {
    1584                 :            :         struct rte_eventdev *dev;
    1585                 :            : 
    1586         [ +  - ]:         32 :         RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
    1587                 :            :         dev = &rte_eventdevs[dev_id];
    1588         [ +  - ]:         32 :         if (dev->dev_ops->dev_close == NULL)
    1589                 :            :                 return -ENOTSUP;
    1590                 :            : 
    1591                 :            :         /* Device must be stopped before it can be closed */
    1592         [ -  + ]:         32 :         if (dev->data->dev_started == 1) {
    1593                 :          0 :                 RTE_EDEV_LOG_ERR("Device %u must be stopped before closing",
    1594                 :            :                                 dev_id);
    1595                 :          0 :                 return -EBUSY;
    1596                 :            :         }
    1597                 :            : 
    1598                 :         32 :         event_dev_fp_ops_reset(rte_event_fp_ops + dev_id);
    1599                 :         32 :         rte_eventdev_trace_close(dev_id);
    1600                 :         32 :         return dev->dev_ops->dev_close(dev);
    1601                 :            : }
    1602                 :            : 
    1603                 :            : static inline int
    1604                 :          4 : eventdev_data_alloc(uint8_t dev_id, struct rte_eventdev_data **data,
    1605                 :            :                     int socket_id)
    1606                 :            : {
    1607                 :            :         char mz_name[RTE_EVENTDEV_NAME_MAX_LEN];
    1608                 :            :         const struct rte_memzone *mz;
    1609                 :            :         int i, n;
    1610                 :            : 
    1611                 :            :         /* Generate memzone name */
    1612         [ +  - ]:          4 :         n = snprintf(mz_name, sizeof(mz_name), "rte_eventdev_data_%u", dev_id);
    1613         [ +  - ]:          4 :         if (n >= (int)sizeof(mz_name))
    1614                 :            :                 return -EINVAL;
    1615                 :            : 
    1616         [ +  - ]:          4 :         if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
    1617                 :          4 :                 mz = rte_memzone_reserve(mz_name,
    1618                 :            :                                 sizeof(struct rte_eventdev_data),
    1619                 :            :                                 socket_id, 0);
    1620                 :            :         } else
    1621                 :          0 :                 mz = rte_memzone_lookup(mz_name);
    1622                 :            : 
    1623         [ +  - ]:          4 :         if (mz == NULL)
    1624                 :            :                 return -ENOMEM;
    1625                 :            : 
    1626                 :          4 :         *data = mz->addr;
    1627         [ +  - ]:          4 :         if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
    1628                 :          4 :                 memset(*data, 0, sizeof(struct rte_eventdev_data));
    1629         [ +  + ]:         36 :                 for (i = 0; i < RTE_EVENT_MAX_PROFILES_PER_PORT; i++)
    1630         [ +  + ]:    2080832 :                         for (n = 0; n < RTE_EVENT_MAX_PORTS_PER_DEV * RTE_EVENT_MAX_QUEUES_PER_DEV;
    1631                 :    2080800 :                              n++)
    1632                 :    2080800 :                                 (*data)->links_map[i][n] = EVENT_QUEUE_SERVICE_PRIORITY_INVALID;
    1633                 :            :         }
    1634                 :            : 
    1635                 :            :         return 0;
    1636                 :            : }
    1637                 :            : 
    1638                 :            : static inline uint8_t
    1639                 :            : eventdev_find_free_device_index(void)
    1640                 :            : {
    1641                 :            :         uint8_t dev_id;
    1642                 :            : 
    1643         [ +  - ]:          4 :         for (dev_id = 0; dev_id < RTE_EVENT_MAX_DEVS; dev_id++) {
    1644         [ -  + ]:          4 :                 if (rte_eventdevs[dev_id].attached ==
    1645                 :            :                                 RTE_EVENTDEV_DETACHED)
    1646                 :            :                         return dev_id;
    1647                 :            :         }
    1648                 :            :         return RTE_EVENT_MAX_DEVS;
    1649                 :            : }
    1650                 :            : 
    1651                 :            : RTE_EXPORT_INTERNAL_SYMBOL(rte_event_pmd_allocate)
    1652                 :            : struct rte_eventdev *
    1653                 :          4 : rte_event_pmd_allocate(const char *name, int socket_id)
    1654                 :            : {
    1655                 :            :         struct rte_eventdev *eventdev;
    1656                 :            :         uint8_t dev_id;
    1657                 :            : 
    1658         [ -  + ]:          4 :         if (rte_event_pmd_get_named_dev(name) != NULL) {
    1659                 :          0 :                 RTE_EDEV_LOG_ERR("Event device with name %s already "
    1660                 :            :                                 "allocated!", name);
    1661                 :          0 :                 return NULL;
    1662                 :            :         }
    1663                 :            : 
    1664                 :            :         dev_id = eventdev_find_free_device_index();
    1665         [ -  + ]:          4 :         if (dev_id == RTE_EVENT_MAX_DEVS) {
    1666                 :          0 :                 RTE_EDEV_LOG_ERR("Reached maximum number of event devices");
    1667                 :          0 :                 return NULL;
    1668                 :            :         }
    1669                 :            : 
    1670                 :          4 :         eventdev = &rte_eventdevs[dev_id];
    1671                 :            : 
    1672         [ +  - ]:          4 :         if (eventdev->data == NULL) {
    1673                 :          4 :                 struct rte_eventdev_data *eventdev_data = NULL;
    1674                 :            : 
    1675                 :            :                 int retval =
    1676                 :          4 :                         eventdev_data_alloc(dev_id, &eventdev_data, socket_id);
    1677                 :            : 
    1678   [ +  -  -  + ]:          4 :                 if (retval < 0 || eventdev_data == NULL)
    1679                 :          0 :                         return NULL;
    1680                 :            : 
    1681                 :          4 :                 eventdev->data = eventdev_data;
    1682                 :            : 
    1683         [ +  - ]:          4 :                 if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
    1684                 :            : 
    1685                 :          4 :                         strlcpy(eventdev->data->name, name,
    1686                 :            :                                 RTE_EVENTDEV_NAME_MAX_LEN);
    1687                 :            : 
    1688                 :          4 :                         eventdev->data->dev_id = dev_id;
    1689                 :          4 :                         eventdev->data->socket_id = socket_id;
    1690                 :          4 :                         eventdev->data->dev_started = 0;
    1691                 :            :                 }
    1692                 :            : 
    1693                 :          4 :                 eventdev->attached = RTE_EVENTDEV_ATTACHED;
    1694                 :          4 :                 eventdev_globals.nb_devs++;
    1695                 :            :         }
    1696                 :            : 
    1697                 :            :         return eventdev;
    1698                 :            : }
    1699                 :            : 
    1700                 :            : RTE_EXPORT_INTERNAL_SYMBOL(rte_event_pmd_release)
    1701                 :            : int
    1702                 :          4 : rte_event_pmd_release(struct rte_eventdev *eventdev)
    1703                 :            : {
    1704                 :            :         int ret;
    1705                 :            :         char mz_name[RTE_EVENTDEV_NAME_MAX_LEN];
    1706                 :            :         const struct rte_memzone *mz;
    1707                 :            : 
    1708         [ +  - ]:          4 :         if (eventdev == NULL)
    1709                 :            :                 return -EINVAL;
    1710                 :            : 
    1711                 :          4 :         event_dev_fp_ops_reset(rte_event_fp_ops + eventdev->data->dev_id);
    1712                 :          4 :         eventdev->attached = RTE_EVENTDEV_DETACHED;
    1713                 :          4 :         eventdev_globals.nb_devs--;
    1714                 :            : 
    1715         [ +  - ]:          4 :         if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
    1716                 :          4 :                 rte_free(eventdev->data->dev_private);
    1717                 :            : 
    1718                 :            :                 /* Generate memzone name */
    1719                 :          4 :                 ret = snprintf(mz_name, sizeof(mz_name), "rte_eventdev_data_%u",
    1720         [ +  - ]:          4 :                                 eventdev->data->dev_id);
    1721         [ +  - ]:          4 :                 if (ret >= (int)sizeof(mz_name))
    1722                 :            :                         return -EINVAL;
    1723                 :            : 
    1724                 :          4 :                 mz = rte_memzone_lookup(mz_name);
    1725         [ +  - ]:          4 :                 if (mz == NULL)
    1726                 :            :                         return -ENOMEM;
    1727                 :            : 
    1728                 :          4 :                 ret = rte_memzone_free(mz);
    1729         [ +  - ]:          4 :                 if (ret)
    1730                 :            :                         return ret;
    1731                 :            :         }
    1732                 :            : 
    1733                 :          4 :         eventdev->data = NULL;
    1734                 :          4 :         return 0;
    1735                 :            : }
    1736                 :            : 
    1737                 :            : RTE_EXPORT_INTERNAL_SYMBOL(event_dev_probing_finish)
    1738                 :            : void
    1739                 :          4 : event_dev_probing_finish(struct rte_eventdev *eventdev)
    1740                 :            : {
    1741         [ +  - ]:          4 :         if (eventdev == NULL)
    1742                 :            :                 return;
    1743                 :            : 
    1744                 :          4 :         event_dev_fp_ops_set(rte_event_fp_ops + eventdev->data->dev_id,
    1745                 :            :                              eventdev);
    1746                 :            : }
    1747                 :            : 
    1748                 :            : static int
    1749                 :          0 : handle_dev_list(const char *cmd __rte_unused,
    1750                 :            :                 const char *params __rte_unused,
    1751                 :            :                 struct rte_tel_data *d)
    1752                 :            : {
    1753                 :            :         uint8_t dev_id;
    1754                 :          0 :         int ndev = rte_event_dev_count();
    1755                 :            : 
    1756         [ #  # ]:          0 :         if (ndev < 1)
    1757                 :            :                 return -1;
    1758                 :            : 
    1759                 :          0 :         rte_tel_data_start_array(d, RTE_TEL_INT_VAL);
    1760         [ #  # ]:          0 :         for (dev_id = 0; dev_id < RTE_EVENT_MAX_DEVS; dev_id++) {
    1761         [ #  # ]:          0 :                 if (rte_eventdevs[dev_id].attached ==
    1762                 :            :                                 RTE_EVENTDEV_ATTACHED)
    1763                 :          0 :                         rte_tel_data_add_array_int(d, dev_id);
    1764                 :            :         }
    1765                 :            : 
    1766                 :            :         return 0;
    1767                 :            : }
    1768                 :            : 
    1769                 :            : static int
    1770                 :          0 : handle_dev_info(const char *cmd __rte_unused,
    1771                 :            :                 const char *params,
    1772                 :            :                 struct rte_tel_data *d)
    1773                 :            : {
    1774                 :            :         uint8_t dev_id;
    1775                 :            :         struct rte_eventdev *dev;
    1776                 :            :         char *end_param;
    1777                 :            : 
    1778   [ #  #  #  #  :          0 :         if (params == NULL || strlen(params) == 0 || !isdigit(*params))
                   #  # ]
    1779                 :            :                 return -1;
    1780                 :            : 
    1781                 :          0 :         dev_id = strtoul(params, &end_param, 10);
    1782                 :            :         if (*end_param != '\0')
    1783                 :            :                 RTE_EDEV_LOG_DEBUG(
    1784                 :            :                         "Extra parameters passed to eventdev telemetry command, ignoring");
    1785                 :            : 
    1786         [ #  # ]:          0 :         RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
    1787                 :            :         dev = &rte_eventdevs[dev_id];
    1788                 :            : 
    1789                 :          0 :         rte_tel_data_start_dict(d);
    1790                 :          0 :         rte_tel_data_add_dict_int(d, "dev_id", dev_id);
    1791                 :          0 :         rte_tel_data_add_dict_string(d, "dev_name", dev->dev->name);
    1792                 :          0 :         rte_tel_data_add_dict_string(d, "dev_driver", dev->dev->driver->name);
    1793                 :          0 :         rte_tel_data_add_dict_string(d, "state",
    1794         [ #  # ]:          0 :                 dev->data->dev_started ? "started" : "stopped");
    1795                 :          0 :         rte_tel_data_add_dict_int(d, "socket_id", dev->data->socket_id);
    1796                 :          0 :         rte_tel_data_add_dict_int(d, "nb_queues", dev->data->nb_queues);
    1797                 :          0 :         rte_tel_data_add_dict_int(d, "nb_ports", dev->data->nb_ports);
    1798                 :          0 :         rte_tel_data_add_dict_uint_hex(d, "capabilities", dev->data->event_dev_cap,
    1799                 :            :                 sizeof(dev->data->event_dev_cap) * CHAR_BIT);
    1800                 :            : 
    1801                 :          0 :         return 0;
    1802                 :            : }
    1803                 :            : 
    1804                 :            : static int
    1805                 :          0 : handle_port_list(const char *cmd __rte_unused,
    1806                 :            :                  const char *params,
    1807                 :            :                  struct rte_tel_data *d)
    1808                 :            : {
    1809                 :            :         int i;
    1810                 :            :         uint8_t dev_id;
    1811                 :            :         struct rte_eventdev *dev;
    1812                 :            :         char *end_param;
    1813                 :            : 
    1814   [ #  #  #  #  :          0 :         if (params == NULL || strlen(params) == 0 || !isdigit(*params))
                   #  # ]
    1815                 :            :                 return -1;
    1816                 :            : 
    1817                 :          0 :         dev_id = strtoul(params, &end_param, 10);
    1818                 :            :         if (*end_param != '\0')
    1819                 :            :                 RTE_EDEV_LOG_DEBUG(
    1820                 :            :                         "Extra parameters passed to eventdev telemetry command, ignoring");
    1821                 :            : 
    1822         [ #  # ]:          0 :         RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
    1823                 :            :         dev = &rte_eventdevs[dev_id];
    1824                 :            : 
    1825                 :          0 :         rte_tel_data_start_array(d, RTE_TEL_INT_VAL);
    1826         [ #  # ]:          0 :         for (i = 0; i < dev->data->nb_ports; i++)
    1827                 :          0 :                 rte_tel_data_add_array_int(d, i);
    1828                 :            : 
    1829                 :            :         return 0;
    1830                 :            : }
    1831                 :            : 
    1832                 :            : static int
    1833                 :          0 : handle_queue_list(const char *cmd __rte_unused,
    1834                 :            :                   const char *params,
    1835                 :            :                   struct rte_tel_data *d)
    1836                 :            : {
    1837                 :            :         int i;
    1838                 :            :         uint8_t dev_id;
    1839                 :            :         struct rte_eventdev *dev;
    1840                 :            :         char *end_param;
    1841                 :            : 
    1842   [ #  #  #  #  :          0 :         if (params == NULL || strlen(params) == 0 || !isdigit(*params))
                   #  # ]
    1843                 :            :                 return -1;
    1844                 :            : 
    1845                 :          0 :         dev_id = strtoul(params, &end_param, 10);
    1846                 :            :         if (*end_param != '\0')
    1847                 :            :                 RTE_EDEV_LOG_DEBUG(
    1848                 :            :                         "Extra parameters passed to eventdev telemetry command, ignoring");
    1849                 :            : 
    1850         [ #  # ]:          0 :         RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
    1851                 :            :         dev = &rte_eventdevs[dev_id];
    1852                 :            : 
    1853                 :          0 :         rte_tel_data_start_array(d, RTE_TEL_INT_VAL);
    1854         [ #  # ]:          0 :         for (i = 0; i < dev->data->nb_queues; i++)
    1855                 :          0 :                 rte_tel_data_add_array_int(d, i);
    1856                 :            : 
    1857                 :            :         return 0;
    1858                 :            : }
    1859                 :            : 
    1860                 :            : static int
    1861                 :          0 : handle_queue_links(const char *cmd __rte_unused,
    1862                 :            :                    const char *params,
    1863                 :            :                    struct rte_tel_data *d)
    1864                 :            : {
    1865                 :            :         int i, ret, port_id = 0;
    1866                 :            :         char *end_param;
    1867                 :            :         uint8_t dev_id;
    1868                 :            :         uint8_t queues[RTE_EVENT_MAX_QUEUES_PER_DEV];
    1869                 :            :         uint8_t priorities[RTE_EVENT_MAX_QUEUES_PER_DEV];
    1870                 :            :         const char *p_param;
    1871                 :            : 
    1872   [ #  #  #  #  :          0 :         if (params == NULL || strlen(params) == 0 || !isdigit(*params))
                   #  # ]
    1873                 :            :                 return -1;
    1874                 :            : 
    1875                 :            :         /* Get dev ID from parameter string */
    1876                 :          0 :         dev_id = strtoul(params, &end_param, 10);
    1877         [ #  # ]:          0 :         RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
    1878                 :            : 
    1879                 :          0 :         p_param = strtok(end_param, ",");
    1880   [ #  #  #  #  :          0 :         if (p_param == NULL || strlen(p_param) == 0 || !isdigit(*p_param))
                   #  # ]
    1881                 :            :                 return -1;
    1882                 :            : 
    1883                 :          0 :         port_id = strtoul(p_param, &end_param, 10);
    1884                 :          0 :         p_param = strtok(NULL, "\0");
    1885                 :            :         if (p_param != NULL)
    1886                 :            :                 RTE_EDEV_LOG_DEBUG(
    1887                 :            :                         "Extra parameters passed to eventdev telemetry command, ignoring");
    1888                 :            : 
    1889                 :          0 :         ret = rte_event_port_links_get(dev_id, port_id, queues, priorities);
    1890         [ #  # ]:          0 :         if (ret < 0)
    1891                 :            :                 return -1;
    1892                 :            : 
    1893                 :          0 :         rte_tel_data_start_dict(d);
    1894         [ #  # ]:          0 :         for (i = 0; i < ret; i++) {
    1895                 :            :                 char qid_name[32];
    1896                 :            : 
    1897                 :          0 :                 snprintf(qid_name, 31, "qid_%u", queues[i]);
    1898                 :          0 :                 rte_tel_data_add_dict_uint(d, qid_name, priorities[i]);
    1899                 :            :         }
    1900                 :            : 
    1901                 :            :         return 0;
    1902                 :            : }
    1903                 :            : 
    1904                 :            : static int
    1905                 :          0 : eventdev_build_telemetry_data(int dev_id,
    1906                 :            :                               enum rte_event_dev_xstats_mode mode,
    1907                 :            :                               int port_queue_id,
    1908                 :            :                               struct rte_tel_data *d)
    1909                 :            : {
    1910                 :            :         struct rte_event_dev_xstats_name *xstat_names;
    1911                 :            :         uint64_t *ids;
    1912                 :            :         uint64_t *values;
    1913                 :            :         int i, ret, num_xstats;
    1914                 :            : 
    1915                 :          0 :         num_xstats = rte_event_dev_xstats_names_get(dev_id,
    1916                 :            :                                                     mode,
    1917                 :            :                                                     port_queue_id,
    1918                 :            :                                                     NULL,
    1919                 :            :                                                     NULL,
    1920                 :            :                                                     0);
    1921                 :            : 
    1922         [ #  # ]:          0 :         if (num_xstats < 0)
    1923                 :            :                 return -1;
    1924                 :            : 
    1925                 :            :         /* use one malloc for names */
    1926                 :          0 :         xstat_names = malloc((sizeof(struct rte_event_dev_xstats_name))
    1927                 :            :                              * num_xstats);
    1928         [ #  # ]:          0 :         if (xstat_names == NULL)
    1929                 :            :                 return -1;
    1930                 :            : 
    1931                 :          0 :         ids = malloc((sizeof(uint64_t)) * num_xstats);
    1932         [ #  # ]:          0 :         if (ids == NULL) {
    1933                 :          0 :                 free(xstat_names);
    1934                 :          0 :                 return -1;
    1935                 :            :         }
    1936                 :            : 
    1937                 :          0 :         values = malloc((sizeof(uint64_t)) * num_xstats);
    1938         [ #  # ]:          0 :         if (values == NULL) {
    1939                 :          0 :                 free(xstat_names);
    1940                 :          0 :                 free(ids);
    1941                 :          0 :                 return -1;
    1942                 :            :         }
    1943                 :            : 
    1944                 :          0 :         ret = rte_event_dev_xstats_names_get(dev_id, mode, port_queue_id,
    1945                 :            :                                              xstat_names, ids, num_xstats);
    1946         [ #  # ]:          0 :         if (ret < 0 || ret > num_xstats) {
    1947                 :          0 :                 free(xstat_names);
    1948                 :          0 :                 free(ids);
    1949                 :          0 :                 free(values);
    1950                 :          0 :                 return -1;
    1951                 :            :         }
    1952                 :            : 
    1953                 :          0 :         ret = rte_event_dev_xstats_get(dev_id, mode, port_queue_id,
    1954                 :            :                                        ids, values, num_xstats);
    1955         [ #  # ]:          0 :         if (ret < 0 || ret > num_xstats) {
    1956                 :          0 :                 free(xstat_names);
    1957                 :          0 :                 free(ids);
    1958                 :          0 :                 free(values);
    1959                 :          0 :                 return -1;
    1960                 :            :         }
    1961                 :            : 
    1962                 :          0 :         rte_tel_data_start_dict(d);
    1963         [ #  # ]:          0 :         for (i = 0; i < num_xstats; i++)
    1964                 :          0 :                 rte_tel_data_add_dict_uint(d, xstat_names[i].name, values[i]);
    1965                 :            : 
    1966                 :          0 :         free(xstat_names);
    1967                 :          0 :         free(ids);
    1968                 :          0 :         free(values);
    1969                 :          0 :         return 0;
    1970                 :            : }
    1971                 :            : 
    1972                 :            : static int
    1973                 :          0 : handle_dev_xstats(const char *cmd __rte_unused,
    1974                 :            :                   const char *params,
    1975                 :            :                   struct rte_tel_data *d)
    1976                 :            : {
    1977                 :            :         int dev_id;
    1978                 :            :         enum rte_event_dev_xstats_mode mode;
    1979                 :            :         char *end_param;
    1980                 :            : 
    1981   [ #  #  #  #  :          0 :         if (params == NULL || strlen(params) == 0 || !isdigit(*params))
                   #  # ]
    1982                 :            :                 return -1;
    1983                 :            : 
    1984                 :            :         /* Get dev ID from parameter string */
    1985                 :          0 :         dev_id = strtoul(params, &end_param, 10);
    1986                 :            :         if (*end_param != '\0')
    1987                 :            :                 RTE_EDEV_LOG_DEBUG(
    1988                 :            :                         "Extra parameters passed to eventdev telemetry command, ignoring");
    1989                 :            : 
    1990         [ #  # ]:          0 :         RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
    1991                 :            : 
    1992                 :            :         mode = RTE_EVENT_DEV_XSTATS_DEVICE;
    1993                 :          0 :         return eventdev_build_telemetry_data(dev_id, mode, 0, d);
    1994                 :            : }
    1995                 :            : 
    1996                 :            : static int
    1997                 :          0 : handle_port_xstats(const char *cmd __rte_unused,
    1998                 :            :                    const char *params,
    1999                 :            :                    struct rte_tel_data *d)
    2000                 :            : {
    2001                 :            :         int dev_id;
    2002                 :            :         int port_queue_id = 0;
    2003                 :            :         enum rte_event_dev_xstats_mode mode;
    2004                 :            :         char *end_param;
    2005                 :            :         const char *p_param;
    2006                 :            : 
    2007   [ #  #  #  #  :          0 :         if (params == NULL || strlen(params) == 0 || !isdigit(*params))
                   #  # ]
    2008                 :            :                 return -1;
    2009                 :            : 
    2010                 :            :         /* Get dev ID from parameter string */
    2011                 :          0 :         dev_id = strtoul(params, &end_param, 10);
    2012         [ #  # ]:          0 :         RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
    2013                 :            : 
    2014                 :          0 :         p_param = strtok(end_param, ",");
    2015                 :            :         mode = RTE_EVENT_DEV_XSTATS_PORT;
    2016                 :            : 
    2017   [ #  #  #  #  :          0 :         if (p_param == NULL || strlen(p_param) == 0 || !isdigit(*p_param))
                   #  # ]
    2018                 :            :                 return -1;
    2019                 :            : 
    2020                 :          0 :         port_queue_id = strtoul(p_param, &end_param, 10);
    2021                 :            : 
    2022                 :          0 :         p_param = strtok(NULL, "\0");
    2023                 :            :         if (p_param != NULL)
    2024                 :            :                 RTE_EDEV_LOG_DEBUG(
    2025                 :            :                         "Extra parameters passed to eventdev telemetry command, ignoring");
    2026                 :            : 
    2027                 :          0 :         return eventdev_build_telemetry_data(dev_id, mode, port_queue_id, d);
    2028                 :            : }
    2029                 :            : 
    2030                 :            : static int
    2031                 :          0 : handle_queue_xstats(const char *cmd __rte_unused,
    2032                 :            :                     const char *params,
    2033                 :            :                     struct rte_tel_data *d)
    2034                 :            : {
    2035                 :            :         int dev_id;
    2036                 :            :         int port_queue_id = 0;
    2037                 :            :         enum rte_event_dev_xstats_mode mode;
    2038                 :            :         char *end_param;
    2039                 :            :         const char *p_param;
    2040                 :            : 
    2041   [ #  #  #  #  :          0 :         if (params == NULL || strlen(params) == 0 || !isdigit(*params))
                   #  # ]
    2042                 :            :                 return -1;
    2043                 :            : 
    2044                 :            :         /* Get dev ID from parameter string */
    2045                 :          0 :         dev_id = strtoul(params, &end_param, 10);
    2046         [ #  # ]:          0 :         RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
    2047                 :            : 
    2048                 :          0 :         p_param = strtok(end_param, ",");
    2049                 :            :         mode = RTE_EVENT_DEV_XSTATS_QUEUE;
    2050                 :            : 
    2051   [ #  #  #  #  :          0 :         if (p_param == NULL || strlen(p_param) == 0 || !isdigit(*p_param))
                   #  # ]
    2052                 :            :                 return -1;
    2053                 :            : 
    2054                 :          0 :         port_queue_id = strtoul(p_param, &end_param, 10);
    2055                 :            : 
    2056                 :          0 :         p_param = strtok(NULL, "\0");
    2057                 :            :         if (p_param != NULL)
    2058                 :            :                 RTE_EDEV_LOG_DEBUG(
    2059                 :            :                         "Extra parameters passed to eventdev telemetry command, ignoring");
    2060                 :            : 
    2061                 :          0 :         return eventdev_build_telemetry_data(dev_id, mode, port_queue_id, d);
    2062                 :            : }
    2063                 :            : 
    2064                 :            : static int
    2065                 :          0 : handle_dev_dump(const char *cmd __rte_unused,
    2066                 :            :                 const char *params,
    2067                 :            :                 struct rte_tel_data *d)
    2068                 :            : {
    2069                 :            :         char *buf, *end_param;
    2070                 :            :         int dev_id, ret;
    2071                 :            :         FILE *f;
    2072                 :            : 
    2073   [ #  #  #  #  :          0 :         if (params == NULL || strlen(params) == 0 || !isdigit(*params))
                   #  # ]
    2074                 :            :                 return -1;
    2075                 :            : 
    2076                 :            :         /* Get dev ID from parameter string */
    2077                 :          0 :         dev_id = strtoul(params, &end_param, 10);
    2078                 :            :         if (*end_param != '\0')
    2079                 :            :                 RTE_EDEV_LOG_DEBUG(
    2080                 :            :                         "Extra parameters passed to eventdev telemetry command, ignoring");
    2081                 :            : 
    2082         [ #  # ]:          0 :         RTE_EVENTDEV_VALID_DEVID_OR_ERR_RET(dev_id, -EINVAL);
    2083                 :            : 
    2084                 :          0 :         buf = calloc(RTE_TEL_MAX_SINGLE_STRING_LEN, sizeof(char));
    2085         [ #  # ]:          0 :         if (buf == NULL)
    2086                 :            :                 return -ENOMEM;
    2087                 :            : 
    2088                 :          0 :         f = fmemopen(buf, RTE_TEL_MAX_SINGLE_STRING_LEN - 1, "w+");
    2089         [ #  # ]:          0 :         if (f == NULL) {
    2090                 :          0 :                 free(buf);
    2091                 :          0 :                 return -EINVAL;
    2092                 :            :         }
    2093                 :            : 
    2094                 :          0 :         ret = rte_event_dev_dump(dev_id, f);
    2095                 :          0 :         fclose(f);
    2096         [ #  # ]:          0 :         if (ret == 0) {
    2097                 :          0 :                 rte_tel_data_start_dict(d);
    2098                 :          0 :                 rte_tel_data_string(d, buf);
    2099                 :            :         }
    2100                 :            : 
    2101                 :          0 :         free(buf);
    2102                 :          0 :         return ret;
    2103                 :            : }
    2104                 :            : 
    2105                 :        252 : RTE_INIT(eventdev_init_telemetry)
    2106                 :            : {
    2107                 :        252 :         rte_telemetry_register_cmd("/eventdev/dev_list", handle_dev_list,
    2108                 :            :                         "Returns list of available eventdevs. Takes no parameters");
    2109                 :        252 :         rte_telemetry_register_cmd("/eventdev/dev_info", handle_dev_info,
    2110                 :            :                         "Returns basic info about an eventdev. Parameter: DevID");
    2111                 :            : 
    2112                 :            :         /* alias "dev_list" and "dev_info" as just "list" and "info" to match
    2113                 :            :          * other categories, such as ethdev, ring, mempool etc.
    2114                 :            :          */
    2115                 :        252 :         rte_telemetry_register_cmd("/eventdev/list", handle_dev_list,
    2116                 :            :                         "Returns list of available eventdevs. Takes no parameters");
    2117                 :        252 :         rte_telemetry_register_cmd("/eventdev/info", handle_dev_info,
    2118                 :            :                         "Returns basic info about an eventdev. Parameter: DevID");
    2119                 :            : 
    2120                 :        252 :         rte_telemetry_register_cmd("/eventdev/port_list", handle_port_list,
    2121                 :            :                         "Returns list of available ports. Parameter: DevID");
    2122                 :        252 :         rte_telemetry_register_cmd("/eventdev/queue_list", handle_queue_list,
    2123                 :            :                         "Returns list of available queues. Parameter: DevID");
    2124                 :            : 
    2125                 :        252 :         rte_telemetry_register_cmd("/eventdev/dev_xstats", handle_dev_xstats,
    2126                 :            :                         "Returns stats for an eventdev. Parameter: DevID");
    2127                 :        252 :         rte_telemetry_register_cmd("/eventdev/port_xstats", handle_port_xstats,
    2128                 :            :                         "Returns stats for an eventdev port. Params: DevID,PortID");
    2129                 :        252 :         rte_telemetry_register_cmd("/eventdev/queue_xstats",
    2130                 :            :                         handle_queue_xstats,
    2131                 :            :                         "Returns stats for an eventdev queue. Params: DevID,QueueID");
    2132                 :        252 :         rte_telemetry_register_cmd("/eventdev/dev_dump", handle_dev_dump,
    2133                 :            :                         "Returns dump information for an eventdev. Parameter: DevID");
    2134                 :        252 :         rte_telemetry_register_cmd("/eventdev/queue_links", handle_queue_links,
    2135                 :            :                         "Returns links for an eventdev port. Params: DevID,QueueID");
    2136                 :        252 : }

Generated by: LCOV version 1.14