LCOV - code coverage report
Current view: top level - lib/eventdev - eventdev_pmd_pci.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 35 0.0 %
Date: 2024-12-01 18:57:19 Functions: 0 3 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 22 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2016-2017 Cavium, Inc
       3                 :            :  */
       4                 :            : 
       5                 :            : #ifndef _RTE_EVENTDEV_PMD_PCI_H_
       6                 :            : #define _RTE_EVENTDEV_PMD_PCI_H_
       7                 :            : 
       8                 :            : /** @file
       9                 :            :  * RTE Eventdev PCI PMD APIs
      10                 :            :  *
      11                 :            :  * @note
      12                 :            :  * These API are from event PCI PMD only and user applications should not call
      13                 :            :  * them directly.
      14                 :            :  */
      15                 :            : 
      16                 :            : #include <string.h>
      17                 :            : 
      18                 :            : #include <rte_compat.h>
      19                 :            : #include <rte_config.h>
      20                 :            : #include <rte_eal.h>
      21                 :            : #include <rte_lcore.h>
      22                 :            : #include <rte_pci.h>
      23                 :            : #include <bus_pci_driver.h>
      24                 :            : 
      25                 :            : #include "eventdev_pmd.h"
      26                 :            : 
      27                 :            : #ifdef __cplusplus
      28                 :            : extern "C" {
      29                 :            : #endif
      30                 :            : 
      31                 :            : typedef int (*eventdev_pmd_pci_callback_t)(struct rte_eventdev *dev);
      32                 :            : 
      33                 :            : /**
      34                 :            :  * @internal
      35                 :            :  * Wrapper for use by pci drivers as a .probe function to attach to an event
      36                 :            :  * interface.  Same as rte_event_pmd_pci_probe, except caller can specify
      37                 :            :  * the name.
      38                 :            :  */
      39                 :            : __rte_internal
      40                 :            : static inline int
      41                 :          0 : rte_event_pmd_pci_probe_named(struct rte_pci_driver *pci_drv,
      42                 :            :                               struct rte_pci_device *pci_dev,
      43                 :            :                               size_t private_data_size,
      44                 :            :                               eventdev_pmd_pci_callback_t devinit,
      45                 :            :                               const char *name)
      46                 :            : {
      47                 :            :         struct rte_eventdev *eventdev;
      48                 :            :         int retval;
      49                 :            : 
      50         [ #  # ]:          0 :         if (devinit == NULL)
      51                 :            :                 return -EINVAL;
      52                 :            : 
      53                 :          0 :         eventdev = rte_event_pmd_allocate(name,
      54                 :            :                          pci_dev->device.numa_node);
      55         [ #  # ]:          0 :         if (eventdev == NULL)
      56                 :            :                 return -ENOMEM;
      57                 :            : 
      58         [ #  # ]:          0 :         if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
      59                 :          0 :                 eventdev->data->dev_private =
      60                 :          0 :                                 rte_zmalloc_socket(
      61                 :            :                                                 "eventdev private structure",
      62                 :            :                                                 private_data_size,
      63                 :            :                                                 RTE_CACHE_LINE_SIZE,
      64                 :          0 :                                                 rte_socket_id());
      65                 :            : 
      66         [ #  # ]:          0 :                 if (eventdev->data->dev_private == NULL)
      67                 :          0 :                         rte_panic("Cannot allocate memzone for private "
      68                 :            :                                         "device data");
      69                 :            :         }
      70                 :            : 
      71                 :          0 :         eventdev->dev = &pci_dev->device;
      72                 :            : 
      73                 :            :         /* Invoke PMD device initialization function */
      74                 :          0 :         retval = devinit(eventdev);
      75         [ #  # ]:          0 :         if (retval == 0) {
      76                 :          0 :                 event_dev_probing_finish(eventdev);
      77                 :          0 :                 return 0;
      78                 :            :         }
      79                 :            : 
      80                 :          0 :         RTE_EDEV_LOG_ERR("driver %s: (vendor_id=0x%x device_id=0x%x)"
      81                 :            :                         " failed", pci_drv->driver.name,
      82                 :            :                         (unsigned int) pci_dev->id.vendor_id,
      83                 :            :                         (unsigned int) pci_dev->id.device_id);
      84                 :            : 
      85                 :          0 :         rte_event_pmd_release(eventdev);
      86                 :            : 
      87                 :          0 :         return -ENXIO;
      88                 :            : }
      89                 :            : 
      90                 :            : /**
      91                 :            :  * @internal
      92                 :            :  * Wrapper for use by pci drivers as a .probe function to attach to a event
      93                 :            :  * interface.
      94                 :            :  */
      95                 :            : __rte_internal
      96                 :            : static inline int
      97                 :          0 : rte_event_pmd_pci_probe(struct rte_pci_driver *pci_drv,
      98                 :            :                             struct rte_pci_device *pci_dev,
      99                 :            :                             size_t private_data_size,
     100                 :            :                             eventdev_pmd_pci_callback_t devinit)
     101                 :            : {
     102                 :            :         char eventdev_name[RTE_EVENTDEV_NAME_MAX_LEN];
     103                 :            : 
     104                 :          0 :         rte_pci_device_name(&pci_dev->addr, eventdev_name,
     105                 :            :                         sizeof(eventdev_name));
     106                 :            : 
     107                 :          0 :         return rte_event_pmd_pci_probe_named(pci_drv,
     108                 :            :                                              pci_dev,
     109                 :            :                                              private_data_size,
     110                 :            :                                              devinit,
     111                 :            :                                              eventdev_name);
     112                 :            : }
     113                 :            : 
     114                 :            : /**
     115                 :            :  * @internal
     116                 :            :  * Wrapper for use by pci drivers as a .remove function to detach a event
     117                 :            :  * interface.
     118                 :            :  */
     119                 :            : __rte_internal
     120                 :            : static inline int
     121                 :          0 : rte_event_pmd_pci_remove(struct rte_pci_device *pci_dev,
     122                 :            :                              eventdev_pmd_pci_callback_t devuninit)
     123                 :            : {
     124                 :            :         struct rte_eventdev *eventdev;
     125                 :            :         char eventdev_name[RTE_EVENTDEV_NAME_MAX_LEN];
     126                 :            :         int ret = 0;
     127                 :            : 
     128         [ #  # ]:          0 :         if (pci_dev == NULL)
     129                 :            :                 return -EINVAL;
     130                 :            : 
     131                 :          0 :         rte_pci_device_name(&pci_dev->addr, eventdev_name,
     132                 :            :                         sizeof(eventdev_name));
     133                 :            : 
     134                 :          0 :         eventdev = rte_event_pmd_get_named_dev(eventdev_name);
     135         [ #  # ]:          0 :         if (eventdev == NULL)
     136                 :            :                 return -ENODEV;
     137                 :            : 
     138         [ #  # ]:          0 :         if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
     139                 :          0 :                 ret = rte_event_dev_close(eventdev->data->dev_id);
     140         [ #  # ]:          0 :                 if (ret < 0)
     141                 :            :                         return ret;
     142                 :            :         }
     143                 :            : 
     144                 :            :         /* Invoke PMD device un-init function */
     145         [ #  # ]:          0 :         if (devuninit)
     146                 :          0 :                 ret = devuninit(eventdev);
     147         [ #  # ]:          0 :         if (ret)
     148                 :            :                 return ret;
     149                 :            : 
     150                 :            :         /* Free event device */
     151                 :          0 :         rte_event_pmd_release(eventdev);
     152                 :            : 
     153                 :          0 :         eventdev->dev = NULL;
     154                 :            : 
     155                 :          0 :         return 0;
     156                 :            : }
     157                 :            : 
     158                 :            : #ifdef __cplusplus
     159                 :            : }
     160                 :            : #endif
     161                 :            : 
     162                 :            : #endif /* _RTE_EVENTDEV_PMD_PCI_H_ */

Generated by: LCOV version 1.14