LCOV - code coverage report
Current view: top level - drivers/bus/ifpga - bus_ifpga_driver.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 2 0.0 %
Date: 2024-12-01 18:57:19 Functions: 0 0 -
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 8 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2010-2018 Intel Corporation
       3                 :            :  */
       4                 :            : 
       5                 :            : #ifndef BUS_IFPGA_DRIVER_H
       6                 :            : #define BUS_IFPGA_DRIVER_H
       7                 :            : 
       8                 :            : /**
       9                 :            :  * @file
      10                 :            :  *
      11                 :            :  * RTE Intel FPGA Bus Interface
      12                 :            :  */
      13                 :            : 
      14                 :            : #include <rte_compat.h>
      15                 :            : #include <dev_driver.h>
      16                 :            : #include <rte_pci.h>
      17                 :            : #include <rte_interrupts.h>
      18                 :            : #include <rte_spinlock.h>
      19                 :            : 
      20                 :            : #ifdef __cplusplus
      21                 :            : extern "C" {
      22                 :            : #endif /* __cplusplus */
      23                 :            : 
      24                 :            : #define IFPGA_BUS_NAME ifpga
      25                 :            : 
      26                 :            : /* Forward declarations */
      27                 :            : struct rte_afu_device;
      28                 :            : struct rte_afu_driver;
      29                 :            : 
      30                 :            : #define IFPGA_BUS_BITSTREAM_PATH_MAX_LEN 256
      31                 :            : 
      32                 :            : struct rte_afu_uuid {
      33                 :            :         uint64_t uuid_low;
      34                 :            :         uint64_t uuid_high;
      35                 :            : } __rte_packed;
      36                 :            : 
      37                 :            : #define IFPGA_BUS_DEV_PORT_MAX 4
      38                 :            : 
      39                 :            : /**
      40                 :            :  * A structure describing an ID for a AFU driver. Each driver provides a
      41                 :            :  * table of these IDs for each device that it supports.
      42                 :            :  */
      43                 :            : struct rte_afu_id {
      44                 :            :         struct rte_afu_uuid uuid;
      45                 :            :         int      port; /**< port number */
      46                 :            : } __rte_packed;
      47                 :            : 
      48                 :            : /**
      49                 :            :  * A structure PR (Partial Reconfiguration) configuration AFU driver.
      50                 :            :  */
      51                 :            : 
      52                 :            : struct rte_afu_pr_conf {
      53                 :            :         struct rte_afu_id afu_id;
      54                 :            :         int pr_enable;
      55                 :            :         char bs_path[IFPGA_BUS_BITSTREAM_PATH_MAX_LEN];
      56                 :            : };
      57                 :            : 
      58                 :            : #define AFU_PRI_STR_SIZE (PCI_PRI_STR_SIZE + 8)
      59                 :            : 
      60                 :            : struct rte_afu_shared {
      61                 :            :         rte_spinlock_t lock;
      62                 :            :         void *data;
      63                 :            : };
      64                 :            : 
      65                 :            : /**
      66                 :            :  * A structure describing a AFU device.
      67                 :            :  */
      68                 :            : struct rte_afu_device {
      69                 :            :         RTE_TAILQ_ENTRY(rte_afu_device) next;       /**< Next in device list. */
      70                 :            :         struct rte_device device;               /**< Inherit core device */
      71                 :            :         struct rte_rawdev *rawdev;    /**< Point Rawdev */
      72                 :            :         struct rte_afu_id id;                   /**< AFU id within FPGA. */
      73                 :            :         uint32_t num_region;   /**< number of regions found */
      74                 :            :         struct rte_mem_resource mem_resource[PCI_MAX_RESOURCE];
      75                 :            :                                                 /**< AFU Memory Resource */
      76                 :            :         struct rte_afu_shared shared;
      77                 :            :         struct rte_intr_handle *intr_handle;     /**< Interrupt handle */
      78                 :            :         struct rte_afu_driver *driver;          /**< Associated driver */
      79                 :            :         char path[IFPGA_BUS_BITSTREAM_PATH_MAX_LEN];
      80                 :            : };
      81                 :            : 
      82                 :            : /**
      83                 :            :  * @internal
      84                 :            :  * Helper macro for drivers that need to convert to struct rte_afu_device.
      85                 :            :  */
      86                 :            : #define RTE_DEV_TO_AFU(ptr) \
      87                 :            :         container_of(ptr, struct rte_afu_device, device)
      88                 :            : 
      89                 :            : /**
      90                 :            :  * Initialization function for the driver called during FPGA BUS probing.
      91                 :            :  */
      92                 :            : typedef int (afu_probe_t)(struct rte_afu_device *);
      93                 :            : 
      94                 :            : /**
      95                 :            :  * Uninitialization function for the driver called during hotplugging.
      96                 :            :  */
      97                 :            : typedef int (afu_remove_t)(struct rte_afu_device *);
      98                 :            : 
      99                 :            : /**
     100                 :            :  * A structure describing a AFU device.
     101                 :            :  */
     102                 :            : struct rte_afu_driver {
     103                 :            :         RTE_TAILQ_ENTRY(rte_afu_driver) next;   /**< Next afu driver. */
     104                 :            :         struct rte_driver driver;               /**< Inherit core driver. */
     105                 :            :         afu_probe_t *probe;                     /**< Device Probe function. */
     106                 :            :         afu_remove_t *remove;                   /**< Device Remove function. */
     107                 :            :         const struct rte_afu_uuid *id_table;    /**< AFU uuid within FPGA. */
     108                 :            : };
     109                 :            : 
     110                 :            : __rte_internal
     111                 :            : static inline const char *
     112                 :            : rte_ifpga_device_name(const struct rte_afu_device *afu)
     113                 :            : {
     114   [ #  #  #  #  :          0 :         if (afu && afu->device.name)
             #  #  #  # ]
     115                 :          0 :                 return afu->device.name;
     116                 :            :         return NULL;
     117                 :            : }
     118                 :            : 
     119                 :            : /**
     120                 :            :  * Find AFU by AFU name.
     121                 :            :  *
     122                 :            :  * @param name
     123                 :            :  *   A pointer to AFU name string.
     124                 :            :  */
     125                 :            : __rte_internal
     126                 :            : struct rte_afu_device *
     127                 :            : rte_ifpga_find_afu_by_name(const char *name);
     128                 :            : 
     129                 :            : /**
     130                 :            :  * Register a ifpga afu device driver.
     131                 :            :  *
     132                 :            :  * @param driver
     133                 :            :  *   A pointer to a rte_afu_driver structure describing the driver
     134                 :            :  *   to be registered.
     135                 :            :  */
     136                 :            : __rte_internal
     137                 :            : void rte_ifpga_driver_register(struct rte_afu_driver *driver);
     138                 :            : 
     139                 :            : /**
     140                 :            :  * Unregister a ifpga afu device driver.
     141                 :            :  *
     142                 :            :  * @param driver
     143                 :            :  *   A pointer to a rte_afu_driver structure describing the driver
     144                 :            :  *   to be unregistered.
     145                 :            :  */
     146                 :            : __rte_internal
     147                 :            : void rte_ifpga_driver_unregister(struct rte_afu_driver *driver);
     148                 :            : 
     149                 :            : #define RTE_PMD_REGISTER_AFU(nm, afudrv)\
     150                 :            : static const char *afudrvinit_ ## nm ## _alias;\
     151                 :            : RTE_INIT(afudrvinitfn_ ##afudrv)\
     152                 :            : {\
     153                 :            :         (afudrv).driver.name = RTE_STR(nm);\
     154                 :            :         (afudrv).driver.alias = afudrvinit_ ## nm ## _alias;\
     155                 :            :         rte_ifpga_driver_register(&afudrv);\
     156                 :            : } \
     157                 :            : RTE_PMD_EXPORT_NAME(nm, __COUNTER__)
     158                 :            : 
     159                 :            : #define RTE_PMD_REGISTER_AFU_ALIAS(nm, alias)\
     160                 :            : static const char *afudrvinit_ ## nm ## _alias = RTE_STR(alias)
     161                 :            : 
     162                 :            : #ifdef __cplusplus
     163                 :            : }
     164                 :            : #endif /* __cplusplus */
     165                 :            : 
     166                 :            : #endif /* BUS_IFPGA_DRIVER_H */

Generated by: LCOV version 1.14