LCOV - code coverage report
Current view: top level - drivers/bus/vdev - bus_vdev_driver.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 4 4 100.0 %
Date: 2026-07-01 18:02:41 Functions: 0 0 -
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 14 32 43.8 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2016 RehiveTech. All rights reserved.
       3                 :            :  */
       4                 :            : 
       5                 :            : #ifndef BUS_VDEV_DRIVER_H
       6                 :            : #define BUS_VDEV_DRIVER_H
       7                 :            : 
       8                 :            : #include <rte_bus_vdev.h>
       9                 :            : #include <rte_compat.h>
      10                 :            : #include <dev_driver.h>
      11                 :            : #include <bus_driver.h>
      12                 :            : #include <rte_devargs.h>
      13                 :            : 
      14                 :            : #ifdef __cplusplus
      15                 :            : extern "C" {
      16                 :            : #endif
      17                 :            : 
      18                 :            : struct rte_vdev_device {
      19                 :            :         struct rte_device device;               /**< Inherit core device */
      20                 :            : };
      21                 :            : 
      22                 :            : static inline const char *
      23                 :            : rte_vdev_device_name(const struct rte_vdev_device *dev)
      24                 :            : {
      25   [ +  -  +  -  :        389 :         if (dev && dev->device.name)
          +  -  +  -  +  
          -  +  -  +  -  
          +  -  +  -  -  
             -  +  -  +  
                      - ]
      26                 :        375 :                 return dev->device.name;
      27                 :            :         return NULL;
      28                 :            : }
      29                 :            : 
      30                 :            : static inline const char *
      31                 :            : rte_vdev_device_args(const struct rte_vdev_device *dev)
      32                 :            : {
      33   [ +  -  +  -  :         97 :         if (dev && dev->device.devargs)
             +  -  -  - ]
      34                 :         97 :                 return dev->device.devargs->args;
      35                 :            :         return "";
      36                 :            : }
      37                 :            : 
      38                 :            : /**
      39                 :            :  * Probe function called for each virtual device driver once.
      40                 :            :  */
      41                 :            : typedef int (rte_vdev_probe_t)(struct rte_vdev_device *dev);
      42                 :            : 
      43                 :            : /**
      44                 :            :  * Remove function called for each virtual device driver once.
      45                 :            :  */
      46                 :            : typedef int (rte_vdev_remove_t)(struct rte_vdev_device *dev);
      47                 :            : 
      48                 :            : /**
      49                 :            :  * Driver-specific DMA mapping. After a successful call the device
      50                 :            :  * will be able to read/write from/to this segment.
      51                 :            :  *
      52                 :            :  * @param dev
      53                 :            :  *   Pointer to the Virtual device.
      54                 :            :  * @param addr
      55                 :            :  *   Starting virtual address of memory to be mapped.
      56                 :            :  * @param iova
      57                 :            :  *   Starting IOVA address of memory to be mapped.
      58                 :            :  * @param len
      59                 :            :  *   Length of memory segment being mapped.
      60                 :            :  * @return
      61                 :            :  *   - 0 On success.
      62                 :            :  *   - Negative value and rte_errno is set otherwise.
      63                 :            :  */
      64                 :            : typedef int (rte_vdev_dma_map_t)(struct rte_vdev_device *dev, void *addr,
      65                 :            :                             uint64_t iova, size_t len);
      66                 :            : 
      67                 :            : /**
      68                 :            :  * Driver-specific DMA un-mapping. After a successful call the device
      69                 :            :  * will not be able to read/write from/to this segment.
      70                 :            :  *
      71                 :            :  * @param dev
      72                 :            :  *   Pointer to the Virtual device.
      73                 :            :  * @param addr
      74                 :            :  *   Starting virtual address of memory to be unmapped.
      75                 :            :  * @param iova
      76                 :            :  *   Starting IOVA address of memory to be unmapped.
      77                 :            :  * @param len
      78                 :            :  *   Length of memory segment being unmapped.
      79                 :            :  * @return
      80                 :            :  *   - 0 On success.
      81                 :            :  *   - Negative value and rte_errno is set otherwise.
      82                 :            :  */
      83                 :            : typedef int (rte_vdev_dma_unmap_t)(struct rte_vdev_device *dev, void *addr,
      84                 :            :                               uint64_t iova, size_t len);
      85                 :            : 
      86                 :            : /**
      87                 :            :  * A virtual device driver abstraction.
      88                 :            :  */
      89                 :            : struct rte_vdev_driver {
      90                 :            :         struct rte_driver driver;        /**< Inherited general driver. */
      91                 :            :         rte_vdev_probe_t *probe;         /**< Virtual device probe function. */
      92                 :            :         rte_vdev_remove_t *remove;       /**< Virtual device remove function. */
      93                 :            :         rte_vdev_dma_map_t *dma_map;     /**< Virtual device DMA map function. */
      94                 :            :         rte_vdev_dma_unmap_t *dma_unmap; /**< Virtual device DMA unmap function. */
      95                 :            :         uint32_t drv_flags;              /**< Flags RTE_VDEV_DRV_*. */
      96                 :            : };
      97                 :            : 
      98                 :            : /** Device driver needs IOVA as VA and cannot work with IOVA as PA */
      99                 :            : #define RTE_VDEV_DRV_NEED_IOVA_AS_VA 0x0001
     100                 :            : 
     101                 :            : /**
     102                 :            :  * Register a virtual device driver.
     103                 :            :  *
     104                 :            :  * @param driver
     105                 :            :  *   A pointer to a rte_vdev_driver structure describing the driver
     106                 :            :  *   to be registered.
     107                 :            :  */
     108                 :            : __rte_internal
     109                 :            : void rte_vdev_register(struct rte_vdev_driver *driver);
     110                 :            : 
     111                 :            : /**
     112                 :            :  * Unregister a virtual device driver.
     113                 :            :  *
     114                 :            :  * @param driver
     115                 :            :  *   A pointer to a rte_vdev_driver structure describing the driver
     116                 :            :  *   to be unregistered.
     117                 :            :  */
     118                 :            : __rte_internal
     119                 :            : void rte_vdev_unregister(struct rte_vdev_driver *driver);
     120                 :            : 
     121                 :            : #define RTE_PMD_REGISTER_VDEV(nm, vdrv)\
     122                 :            : static const char *vdrvinit_ ## nm ## _alias;\
     123                 :            : RTE_INIT(vdrvinitfn_ ##vdrv)\
     124                 :            : {\
     125                 :            :         (vdrv).driver.name = RTE_STR(nm);\
     126                 :            :         (vdrv).driver.alias = vdrvinit_ ## nm ## _alias;\
     127                 :            :         rte_vdev_register(&vdrv);\
     128                 :            : } \
     129                 :            : RTE_PMD_EXPORT_NAME(nm)
     130                 :            : 
     131                 :            : #define RTE_PMD_REGISTER_ALIAS(nm, alias)\
     132                 :            : static const char *vdrvinit_ ## nm ## _alias = RTE_STR(alias)
     133                 :            : 
     134                 :            : #ifdef __cplusplus
     135                 :            : }
     136                 :            : #endif
     137                 :            : 
     138                 :            : #endif /* BUS_VDEV_DRIVER_H */

Generated by: LCOV version 1.14