LCOV - code coverage report
Current view: top level - drivers/common/sfc_efx - sfc_efx.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 1 35 2.9 %
Date: 2025-05-01 17:49:45 Functions: 1 6 16.7 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 1 18 5.6 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  *
       3                 :            :  * Copyright(c) 2019-2021 Xilinx, Inc.
       4                 :            :  * Copyright(c) 2019 Solarflare Communications Inc.
       5                 :            :  *
       6                 :            :  * This software was jointly developed between OKTET Labs (under contract
       7                 :            :  * for Solarflare) and Solarflare Communications, Inc.
       8                 :            :  */
       9                 :            : 
      10                 :            : #include <string.h>
      11                 :            : #include <eal_export.h>
      12                 :            : #include <rte_log.h>
      13                 :            : #include <rte_kvargs.h>
      14                 :            : #include <rte_devargs.h>
      15                 :            : 
      16                 :            : #include "sfc_efx_log.h"
      17                 :            : #include "sfc_efx.h"
      18                 :            : 
      19                 :            : int sfc_efx_logtype;
      20                 :            : 
      21                 :            : static int
      22                 :          0 : sfc_efx_kvarg_dev_class_handler(__rte_unused const char *key,
      23                 :            :                                 const char *class_str, void *opaque)
      24                 :            : {
      25                 :            :         enum sfc_efx_dev_class *dev_class = opaque;
      26                 :            : 
      27         [ #  # ]:          0 :         if (strcmp(class_str, "vdpa") == 0) {
      28                 :          0 :                 *dev_class = SFC_EFX_DEV_CLASS_VDPA;
      29         [ #  # ]:          0 :         } else if (strcmp(class_str, "net") == 0) {
      30                 :          0 :                 *dev_class = SFC_EFX_DEV_CLASS_NET;
      31                 :            :         } else {
      32                 :          0 :                 SFC_EFX_LOG(ERR, "Unsupported class %s.", class_str);
      33                 :          0 :                 *dev_class = SFC_EFX_DEV_CLASS_INVALID;
      34                 :            :         }
      35                 :            : 
      36                 :          0 :         return 0;
      37                 :            : }
      38                 :            : 
      39                 :            : RTE_EXPORT_INTERNAL_SYMBOL(sfc_efx_dev_class_get)
      40                 :            : enum sfc_efx_dev_class
      41                 :          0 : sfc_efx_dev_class_get(struct rte_devargs *devargs)
      42                 :            : {
      43                 :            :         struct rte_kvargs *kvargs;
      44                 :          0 :         enum sfc_efx_dev_class dev_class = SFC_EFX_DEV_CLASS_NET;
      45                 :            : 
      46         [ #  # ]:          0 :         if (devargs == NULL)
      47                 :            :                 return dev_class;
      48                 :            : 
      49                 :          0 :         kvargs = rte_kvargs_parse(devargs->args, NULL);
      50         [ #  # ]:          0 :         if (kvargs == NULL)
      51                 :          0 :                 return dev_class;
      52                 :            : 
      53         [ #  # ]:          0 :         if (rte_kvargs_count(kvargs, RTE_DEVARGS_KEY_CLASS) != 0) {
      54                 :          0 :                 rte_kvargs_process(kvargs, RTE_DEVARGS_KEY_CLASS,
      55                 :            :                                    sfc_efx_kvarg_dev_class_handler, &dev_class);
      56                 :            :         }
      57                 :            : 
      58                 :          0 :         rte_kvargs_free(kvargs);
      59                 :            : 
      60                 :          0 :         return dev_class;
      61                 :            : }
      62                 :            : 
      63                 :            : static efx_rc_t
      64         [ #  # ]:          0 : sfc_efx_find_mem_bar(efsys_pci_config_t *configp, int bar_index,
      65                 :            :                      efsys_bar_t *barp)
      66                 :            : {
      67                 :            :         efsys_bar_t result;
      68                 :            :         struct rte_pci_device *dev;
      69                 :            : 
      70                 :            :         memset(&result, 0, sizeof(result));
      71                 :            : 
      72         [ #  # ]:          0 :         if (bar_index < 0 || bar_index >= PCI_MAX_RESOURCE)
      73                 :            :                 return -EINVAL;
      74                 :            : 
      75                 :          0 :         dev = configp->espc_dev;
      76                 :            : 
      77                 :          0 :         result.esb_rid = bar_index;
      78                 :          0 :         result.esb_dev = dev;
      79                 :          0 :         result.esb_base = dev->mem_resource[bar_index].addr;
      80                 :            : 
      81                 :          0 :         *barp = result;
      82                 :            : 
      83                 :          0 :         return 0;
      84                 :            : }
      85                 :            : 
      86                 :            : static efx_rc_t
      87                 :          0 : sfc_efx_pci_config_readd(efsys_pci_config_t *configp, uint32_t offset,
      88                 :            :                          efx_dword_t *edp)
      89                 :            : {
      90                 :            :         int rc;
      91                 :            : 
      92                 :          0 :         rc = rte_pci_read_config(configp->espc_dev, edp->ed_u32, sizeof(*edp),
      93                 :            :                                  offset);
      94                 :            : 
      95         [ #  # ]:          0 :         return (rc < 0 || rc != sizeof(*edp)) ? EIO : 0;
      96                 :            : }
      97                 :            : 
      98                 :            : RTE_EXPORT_INTERNAL_SYMBOL(sfc_efx_family)
      99                 :            : int
     100                 :          0 : sfc_efx_family(struct rte_pci_device *pci_dev,
     101                 :            :                efx_bar_region_t *mem_ebrp, efx_family_t *family)
     102                 :            : {
     103                 :            :         static const efx_pci_ops_t ops = {
     104                 :            :                 .epo_config_readd = sfc_efx_pci_config_readd,
     105                 :            :                 .epo_find_mem_bar = sfc_efx_find_mem_bar,
     106                 :            :         };
     107                 :            : 
     108                 :            :         efsys_pci_config_t espcp;
     109                 :            :         int rc;
     110                 :            : 
     111                 :          0 :         espcp.espc_dev = pci_dev;
     112                 :            : 
     113                 :          0 :         rc = efx_family_probe_bar(pci_dev->id.vendor_id,
     114                 :          0 :                                   pci_dev->id.device_id,
     115                 :            :                                   &espcp, &ops, family, mem_ebrp);
     116                 :            : 
     117                 :          0 :         return rc;
     118                 :            : }
     119                 :            : 
     120         [ -  + ]:        252 : RTE_LOG_REGISTER_DEFAULT(sfc_efx_logtype, NOTICE);

Generated by: LCOV version 1.14