LCOV - code coverage report
Current view: top level - drivers/raw/skeleton - skeleton_rawdev.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 1 1 100.0 %
Date: 2025-01-02 22:41:34 Functions: 0 0 -
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 6 14 42.9 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright 2017 NXP
       3                 :            :  */
       4                 :            : 
       5                 :            : #ifndef __SKELETON_RAWDEV_H__
       6                 :            : #define __SKELETON_RAWDEV_H__
       7                 :            : 
       8                 :            : #include <rte_rawdev.h>
       9                 :            : 
      10                 :            : extern int skeleton_pmd_logtype;
      11                 :            : #define RTE_LOGTYPE_SKELETON_PMD skeleton_pmd_logtype
      12                 :            : 
      13                 :            : #define SKELETON_PMD_LOG(level, ...) \
      14                 :            :         RTE_LOG_LINE_PREFIX(level, SKELETON_PMD, "%s(): ", __func__, __VA_ARGS__)
      15                 :            : 
      16                 :            : #define SKELETON_PMD_FUNC_TRACE() SKELETON_PMD_LOG(DEBUG, ">>")
      17                 :            : 
      18                 :            : #define SKELETON_PMD_DEBUG(fmt, ...) \
      19                 :            :         SKELETON_PMD_LOG(DEBUG, fmt, ##__VA_ARGS__)
      20                 :            : #define SKELETON_PMD_INFO(fmt, ...) \
      21                 :            :         SKELETON_PMD_LOG(INFO, fmt, ##__VA_ARGS__)
      22                 :            : #define SKELETON_PMD_ERR(fmt, ...) \
      23                 :            :         SKELETON_PMD_LOG(ERR, fmt, ##__VA_ARGS__)
      24                 :            : #define SKELETON_PMD_WARN(fmt, ...) \
      25                 :            :         SKELETON_PMD_LOG(WARNING, fmt, ##__VA_ARGS__)
      26                 :            : /* Macros for self test application */
      27                 :            : #define SKELETON_TEST_INFO      SKELETON_PMD_INFO
      28                 :            : #define SKELETON_TEST_DEBUG     SKELETON_PMD_DEBUG
      29                 :            : #define SKELETON_TEST_ERR       SKELETON_PMD_ERR
      30                 :            : #define SKELETON_TEST_WARN      SKELETON_PMD_WARN
      31                 :            : 
      32                 :            : #define SKELETON_SELFTEST_ARG   ("selftest")
      33                 :            : 
      34                 :            : #define SKELETON_VENDOR_ID 0x10
      35                 :            : #define SKELETON_DEVICE_ID 0x01
      36                 :            : 
      37                 :            : #define SKELETON_MAJOR_VER 1
      38                 :            : #define SKELETON_MINOR_VER 0
      39                 :            : #define SKELETON_SUB_VER   0
      40                 :            : 
      41                 :            : #define SKELETON_MAX_QUEUES 1
      42                 :            : 
      43                 :            : enum skeleton_firmware_state {
      44                 :            :         SKELETON_FW_READY,
      45                 :            :         SKELETON_FW_LOADED,
      46                 :            :         SKELETON_FW_ERROR
      47                 :            : };
      48                 :            : 
      49                 :            : enum skeleton_device_state {
      50                 :            :         SKELETON_DEV_RUNNING,
      51                 :            :         SKELETON_DEV_STOPPED
      52                 :            : };
      53                 :            : 
      54                 :            : enum skeleton_queue_state {
      55                 :            :         SKELETON_QUEUE_DETACH,
      56                 :            :         SKELETON_QUEUE_ATTACH
      57                 :            : };
      58                 :            : 
      59                 :            : #define SKELETON_QUEUE_DEF_DEPTH 10
      60                 :            : #define SKELETON_QUEUE_MAX_DEPTH 25
      61                 :            : 
      62                 :            : struct skeleton_firmware_version_info {
      63                 :            :         uint8_t major;
      64                 :            :         uint8_t minor;
      65                 :            :         uint8_t subrel;
      66                 :            : };
      67                 :            : 
      68                 :            : struct skeleton_firmware {
      69                 :            :         /**< Device firmware information */
      70                 :            :         struct skeleton_firmware_version_info firmware_version;
      71                 :            :         /**< Device state */
      72                 :            :         enum skeleton_firmware_state firmware_state;
      73                 :            : 
      74                 :            : };
      75                 :            : 
      76                 :            : #define SKELETON_MAX_ATTRIBUTES 10
      77                 :            : #define SKELETON_ATTRIBUTE_NAME_MAX 20
      78                 :            : 
      79                 :            : struct skeleton_rawdev_attributes {
      80                 :            :         /**< Name of the attribute */
      81                 :            :         char *name;
      82                 :            :         /**< Value or reference of value of attribute */
      83                 :            :         uint64_t value;
      84                 :            : };
      85                 :            : 
      86                 :            : /**< Device supports firmware loading/unloading */
      87                 :            : #define SKELETON_CAPA_FW_LOAD   0x0001
      88                 :            : /**< Device supports firmware reset */
      89                 :            : #define SKELETON_CAPA_FW_RESET  0x0002
      90                 :            : /**< Device support queue based communication */
      91                 :            : #define SKELETON_CAPA_QUEUES    0x0004
      92                 :            : /**< Default Capabilities: FW_LOAD, FW_RESET, QUEUES */
      93                 :            : #define SKELETON_DEFAULT_CAPA   0x7
      94                 :            : 
      95                 :            : struct skeleton_rawdev_queue {
      96                 :            :         uint8_t state;
      97                 :            :         uint32_t depth;
      98                 :            : };
      99                 :            : 
     100                 :            : struct skeleton_rawdev {
     101                 :            :         uint16_t device_id;
     102                 :            :         uint16_t vendor_id;
     103                 :            :         uint16_t num_queues;
     104                 :            :         /**< One of SKELETON_CAPA_* */
     105                 :            :         uint16_t capabilities;
     106                 :            :         /**< State of device; linked to firmware state */
     107                 :            :         enum skeleton_device_state device_state;
     108                 :            :         /**< Firmware configuration */
     109                 :            :         struct skeleton_firmware fw;
     110                 :            :         /**< Collection of all communication channels - which can be referred
     111                 :            :          *  to as queues.
     112                 :            :          */
     113                 :            :         struct skeleton_rawdev_queue queues[SKELETON_MAX_QUEUES];
     114                 :            :         /**< Global table containing various pre-defined and user-defined
     115                 :            :          * attributes.
     116                 :            :          */
     117                 :            :         struct skeleton_rawdev_attributes attr[SKELETON_MAX_ATTRIBUTES];
     118                 :            :         struct rte_device *device;
     119                 :            : };
     120                 :            : 
     121                 :            : struct skeleton_rawdev_conf {
     122                 :            :         uint16_t num_queues;
     123                 :            :         unsigned int capabilities;
     124                 :            :         enum skeleton_device_state device_state;
     125                 :            :         enum skeleton_firmware_state firmware_state;
     126                 :            : };
     127                 :            : 
     128                 :            : static inline struct skeleton_rawdev *
     129                 :            : skeleton_rawdev_get_priv(const struct rte_rawdev *rawdev)
     130                 :            : {
     131   [ +  -  -  -  :         34 :         return rawdev->dev_private;
          +  -  +  -  +  
             -  +  -  +  
                      - ]
     132                 :            : }
     133                 :            : 
     134                 :            : int test_rawdev_skeldev(uint16_t dev_id);
     135                 :            : 
     136                 :            : #endif /* __SKELETON_RAWDEV_H__ */

Generated by: LCOV version 1.14