LCOV - code coverage report
Current view: top level - lib/ethdev - ethdev_vdev.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 10 12 83.3 %
Date: 2025-03-01 20:23:48 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 4 8 50.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2017 Brocade Communications Systems, Inc.
       3                 :            :  *   Author: Jan Blunck <jblunck@infradead.org>
       4                 :            :  */
       5                 :            : 
       6                 :            : #ifndef _RTE_ETHDEV_VDEV_H_
       7                 :            : #define _RTE_ETHDEV_VDEV_H_
       8                 :            : 
       9                 :            : #include <rte_config.h>
      10                 :            : #include <rte_malloc.h>
      11                 :            : #include <bus_vdev_driver.h>
      12                 :            : #include <ethdev_driver.h>
      13                 :            : 
      14                 :            : #ifdef __cplusplus
      15                 :            : extern "C" {
      16                 :            : #endif
      17                 :            : 
      18                 :            : /**
      19                 :            :  * @internal
      20                 :            :  * Allocates a new ethdev slot for an Ethernet device and returns the pointer
      21                 :            :  * to that slot for the driver to use.
      22                 :            :  *
      23                 :            :  * @param dev
      24                 :            :  *      Pointer to virtual device
      25                 :            :  *
      26                 :            :  * @param private_data_size
      27                 :            :  *      Size of private data structure
      28                 :            :  *
      29                 :            :  * @return
      30                 :            :  *      A pointer to a rte_eth_dev or NULL if allocation failed.
      31                 :            :  */
      32                 :            : static inline struct rte_eth_dev *
      33         [ +  - ]:          6 : rte_eth_vdev_allocate(struct rte_vdev_device *dev, size_t private_data_size)
      34                 :            : {
      35                 :            :         struct rte_eth_dev *eth_dev;
      36                 :            :         const char *name = rte_vdev_device_name(dev);
      37                 :            : 
      38                 :          6 :         eth_dev = rte_eth_dev_allocate(name);
      39         [ +  - ]:          6 :         if (!eth_dev)
      40                 :            :                 return NULL;
      41                 :            : 
      42         [ +  - ]:          6 :         if (private_data_size) {
      43                 :          6 :                 eth_dev->data->dev_private = rte_zmalloc_socket(name,
      44                 :            :                         private_data_size, RTE_CACHE_LINE_SIZE,
      45                 :            :                         dev->device.numa_node);
      46         [ -  + ]:          6 :                 if (!eth_dev->data->dev_private) {
      47                 :          0 :                         rte_eth_dev_release_port(eth_dev);
      48                 :          0 :                         return NULL;
      49                 :            :                 }
      50                 :            :         }
      51                 :            : 
      52                 :          6 :         eth_dev->device = &dev->device;
      53                 :          6 :         eth_dev->intr_handle = NULL;
      54                 :            : 
      55                 :          6 :         eth_dev->data->numa_node = dev->device.numa_node;
      56                 :          6 :         return eth_dev;
      57                 :            : }
      58                 :            : 
      59                 :            : #ifdef __cplusplus
      60                 :            : }
      61                 :            : #endif
      62                 :            : 
      63                 :            : #endif /* _RTE_ETHDEV_VDEV_H_ */

Generated by: LCOV version 1.14