LCOV - code coverage report
Current view: top level - lib/eventdev - eventdev_pmd_vdev.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 17 18 94.4 %
Date: 2025-02-01 18:54:23 Functions: 2 2 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 6 12 50.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_VDEV_H_
       6                 :            : #define _RTE_EVENTDEV_PMD_VDEV_H_
       7                 :            : 
       8                 :            : /** @file
       9                 :            :  * RTE Eventdev VDEV PMD APIs
      10                 :            :  *
      11                 :            :  * @note
      12                 :            :  * These API are from event VDEV 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_debug.h>
      21                 :            : #include <rte_eal.h>
      22                 :            : #include <bus_vdev_driver.h>
      23                 :            : 
      24                 :            : #include "eventdev_pmd.h"
      25                 :            : 
      26                 :            : #ifdef __cplusplus
      27                 :            : extern "C" {
      28                 :            : #endif
      29                 :            : 
      30                 :            : /**
      31                 :            :  * @internal
      32                 :            :  * Creates a new virtual event device and returns the pointer to that device.
      33                 :            :  *
      34                 :            :  * @param name
      35                 :            :  *   PMD type name
      36                 :            :  * @param dev_private_size
      37                 :            :  *   Size of event PMDs private data
      38                 :            :  * @param socket_id
      39                 :            :  *   Socket to allocate resources on.
      40                 :            :  *
      41                 :            :  * @return
      42                 :            :  *   - Eventdev pointer if device is successfully created.
      43                 :            :  *   - NULL if device cannot be created.
      44                 :            :  */
      45                 :            : __rte_internal
      46                 :            : static inline struct rte_eventdev *
      47                 :          4 : rte_event_pmd_vdev_init(const char *name, size_t dev_private_size,
      48                 :            :                 int socket_id, struct rte_vdev_device *vdev)
      49                 :            : {
      50                 :            : 
      51                 :            :         struct rte_eventdev *eventdev;
      52                 :            : 
      53                 :            :         /* Allocate device structure */
      54                 :          4 :         eventdev = rte_event_pmd_allocate(name, socket_id);
      55         [ +  - ]:          4 :         if (eventdev == NULL)
      56                 :            :                 return NULL;
      57                 :            : 
      58                 :            :         /* Allocate private device structure */
      59         [ +  - ]:          4 :         if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
      60                 :          8 :                 eventdev->data->dev_private =
      61                 :          4 :                                 rte_zmalloc_socket("eventdev device private",
      62                 :            :                                                 dev_private_size,
      63                 :            :                                                 RTE_CACHE_LINE_SIZE,
      64                 :            :                                                 socket_id);
      65                 :            : 
      66         [ -  + ]:          4 :                 if (eventdev->data->dev_private == NULL)
      67                 :          0 :                         rte_panic("Cannot allocate memzone for private device"
      68                 :            :                                         " data");
      69                 :            :         }
      70                 :          4 :         eventdev->dev = &vdev->device;
      71                 :            : 
      72                 :          4 :         return eventdev;
      73                 :            : }
      74                 :            : 
      75                 :            : /**
      76                 :            :  * @internal
      77                 :            :  * Destroy the given virtual event device
      78                 :            :  *
      79                 :            :  * @param name
      80                 :            :  *   PMD type name
      81                 :            :  * @return
      82                 :            :  *   - 0 on success, negative on error
      83                 :            :  */
      84                 :            : __rte_internal
      85                 :            : static inline int
      86                 :          4 : rte_event_pmd_vdev_uninit(const char *name)
      87                 :            : {
      88                 :            :         int ret;
      89                 :            :         struct rte_eventdev *eventdev;
      90                 :            : 
      91         [ +  - ]:          4 :         if (name == NULL)
      92                 :            :                 return -EINVAL;
      93                 :            : 
      94                 :          4 :         eventdev = rte_event_pmd_get_named_dev(name);
      95         [ +  - ]:          4 :         if (eventdev == NULL)
      96                 :            :                 return -ENODEV;
      97                 :            : 
      98                 :          4 :         ret = rte_event_dev_close(eventdev->data->dev_id);
      99         [ +  - ]:          4 :         if (ret < 0)
     100                 :            :                 return ret;
     101                 :            : 
     102                 :            :         /* Free the event device */
     103                 :          4 :         rte_event_pmd_release(eventdev);
     104                 :            : 
     105                 :          4 :         return 0;
     106                 :            : }
     107                 :            : 
     108                 :            : #ifdef __cplusplus
     109                 :            : }
     110                 :            : #endif
     111                 :            : 
     112                 :            : #endif /* _RTE_EVENTDEV_PMD_VDEV_H_ */

Generated by: LCOV version 1.14