LCOV - code coverage report
Current view: top level - drivers/bus/auxiliary - auxiliary_params.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 16 0.0 %
Date: 2025-01-02 22:41:34 Functions: 0 2 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 10 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright (c) 2021 NVIDIA Corporation & Affiliates
       3                 :            :  */
       4                 :            : 
       5                 :            : #include <string.h>
       6                 :            : 
       7                 :            : #include <bus_driver.h>
       8                 :            : #include <dev_driver.h>
       9                 :            : #include <rte_errno.h>
      10                 :            : #include <rte_kvargs.h>
      11                 :            : 
      12                 :            : #include "private.h"
      13                 :            : 
      14                 :            : enum auxiliary_params {
      15                 :            :         RTE_AUXILIARY_PARAM_NAME,
      16                 :            : };
      17                 :            : 
      18                 :            : static const char * const auxiliary_params_keys[] = {
      19                 :            :         [RTE_AUXILIARY_PARAM_NAME] = "name",
      20                 :            :         NULL,
      21                 :            : };
      22                 :            : 
      23                 :            : static int
      24                 :          0 : auxiliary_dev_match(const struct rte_device *dev,
      25                 :            :               const void *_kvlist)
      26                 :            : {
      27                 :            :         const struct rte_kvargs *kvlist = _kvlist;
      28                 :            :         const char *key = auxiliary_params_keys[RTE_AUXILIARY_PARAM_NAME];
      29                 :            :         const char *name;
      30                 :            : 
      31                 :            :         /* no kvlist arg, all devices match */
      32         [ #  # ]:          0 :         if (kvlist == NULL)
      33                 :            :                 return 0;
      34                 :            : 
      35                 :            :         /* if key is present in kvlist and does not match, filter device */
      36                 :          0 :         name = rte_kvargs_get(kvlist, key);
      37   [ #  #  #  # ]:          0 :         if (name != NULL && strcmp(name, dev->name))
      38                 :          0 :                 return -1;
      39                 :            : 
      40                 :            :         return 0;
      41                 :            : }
      42                 :            : 
      43                 :            : void *
      44                 :          0 : auxiliary_dev_iterate(const void *start,
      45                 :            :                     const char *str,
      46                 :            :                     const struct rte_dev_iterator *it __rte_unused)
      47                 :            : {
      48                 :            :         rte_bus_find_device_t find_device;
      49                 :            :         struct rte_kvargs *kvargs = NULL;
      50                 :            :         struct rte_device *dev;
      51                 :            : 
      52         [ #  # ]:          0 :         if (str != NULL) {
      53                 :          0 :                 kvargs = rte_kvargs_parse(str, auxiliary_params_keys);
      54         [ #  # ]:          0 :                 if (kvargs == NULL) {
      55                 :          0 :                         AUXILIARY_LOG(ERR, "cannot parse argument list %s",
      56                 :            :                                       str);
      57                 :          0 :                         rte_errno = EINVAL;
      58                 :          0 :                         return NULL;
      59                 :            :                 }
      60                 :            :         }
      61                 :          0 :         find_device = auxiliary_bus.bus.find_device;
      62                 :          0 :         dev = find_device(start, auxiliary_dev_match, kvargs);
      63                 :          0 :         rte_kvargs_free(kvargs);
      64                 :          0 :         return dev;
      65                 :            : }

Generated by: LCOV version 1.14