LCOV - code coverage report
Current view: top level - drivers/bus/fslmc - bus_fslmc_driver.h (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 1 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 12 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  *
       3                 :            :  *   Copyright 2016,2021-2023 NXP
       4                 :            :  *
       5                 :            :  */
       6                 :            : 
       7                 :            : #ifndef BUS_FSLMC_DRIVER_H
       8                 :            : #define BUS_FSLMC_DRIVER_H
       9                 :            : 
      10                 :            : /**
      11                 :            :  * @file
      12                 :            :  *
      13                 :            :  * RTE FSLMC Bus Interface
      14                 :            :  */
      15                 :            : 
      16                 :            : #include <stdio.h>
      17                 :            : #include <stdlib.h>
      18                 :            : #include <limits.h>
      19                 :            : #include <errno.h>
      20                 :            : #include <sys/queue.h>
      21                 :            : #include <stdint.h>
      22                 :            : #include <inttypes.h>
      23                 :            : #include <linux/vfio.h>
      24                 :            : 
      25                 :            : #include <rte_compat.h>
      26                 :            : #include <rte_debug.h>
      27                 :            : #include <rte_interrupts.h>
      28                 :            : #include <dev_driver.h>
      29                 :            : #include <rte_tailq.h>
      30                 :            : #include <rte_devargs.h>
      31                 :            : #include <rte_mbuf.h>
      32                 :            : #include <rte_mbuf_dyn.h>
      33                 :            : 
      34                 :            : #include <fslmc_vfio.h>
      35                 :            : 
      36                 :            : #ifdef __cplusplus
      37                 :            : extern "C" {
      38                 :            : #endif
      39                 :            : 
      40                 :            : #define FSLMC_OBJECT_MAX_LEN 32   /**< Length of each device on bus */
      41                 :            : 
      42                 :            : #define DPAA2_INVALID_MBUF_SEQN        0
      43                 :            : 
      44                 :            : typedef uint32_t dpaa2_seqn_t;
      45                 :            : extern int dpaa2_seqn_dynfield_offset;
      46                 :            : 
      47                 :            : /**
      48                 :            :  * Read dpaa2 sequence number from mbuf.
      49                 :            :  *
      50                 :            :  * @param mbuf Structure to read from.
      51                 :            :  * @return pointer to dpaa2 sequence number.
      52                 :            :  */
      53                 :            : __rte_internal
      54                 :            : static inline dpaa2_seqn_t *
      55                 :            : dpaa2_seqn(struct rte_mbuf *mbuf)
      56                 :            : {
      57   [ #  #  #  #  :          0 :         return RTE_MBUF_DYNFIELD(mbuf, dpaa2_seqn_dynfield_offset,
          #  #  #  #  #  
                #  #  # ]
      58                 :            :                 dpaa2_seqn_t *);
      59                 :            : }
      60                 :            : 
      61                 :            : /** Device driver supports link state interrupt */
      62                 :            : #define RTE_DPAA2_DRV_INTR_LSC  0x0008
      63                 :            : 
      64                 :            : /** Device driver supports IOVA as VA */
      65                 :            : #define RTE_DPAA2_DRV_IOVA_AS_VA 0X0040
      66                 :            : 
      67                 :            : struct rte_dpaa2_driver;
      68                 :            : 
      69                 :            : #define RTE_DEV_TO_FSLMC_CONST(ptr) \
      70                 :            :         container_of(ptr, const struct rte_dpaa2_device, device)
      71                 :            : 
      72                 :            : enum rte_dpaa2_dev_type {
      73                 :            :         /* Devices backed by DPDK driver */
      74                 :            :         DPAA2_ETH,      /**< DPNI type device*/
      75                 :            :         DPAA2_CRYPTO,   /**< DPSECI type device */
      76                 :            :         DPAA2_CON,      /**< DPCONC type device */
      77                 :            :         /* Devices not backed by a DPDK driver: DPIO, DPBP, DPCI, DPMCP */
      78                 :            :         DPAA2_BPOOL,    /**< DPBP type device */
      79                 :            :         DPAA2_IO,       /**< DPIO type device */
      80                 :            :         DPAA2_CI,       /**< DPCI type device */
      81                 :            :         DPAA2_MPORTAL,  /**< DPMCP type device */
      82                 :            :         DPAA2_QDMA,     /**< DPDMAI type device */
      83                 :            :         DPAA2_MUX,      /**< DPDMUX type device */
      84                 :            :         DPAA2_DPRTC,    /**< DPRTC type device */
      85                 :            :         DPAA2_DPRC,     /**< DPRC type device */
      86                 :            :         DPAA2_MAC,      /**< DPMAC type device */
      87                 :            :         /* Unknown device placeholder */
      88                 :            :         DPAA2_UNKNOWN,
      89                 :            :         DPAA2_DEVTYPE_MAX,
      90                 :            : };
      91                 :            : 
      92                 :            : /**
      93                 :            :  * A structure describing a DPAA2 device.
      94                 :            :  */
      95                 :            : struct rte_dpaa2_device {
      96                 :            :         TAILQ_ENTRY(rte_dpaa2_device) next; /**< Next probed DPAA2 device. */
      97                 :            :         struct rte_device device;           /**< Inherit core device */
      98                 :            :         union {
      99                 :            :                 struct rte_eth_dev *eth_dev;        /**< ethernet device */
     100                 :            :                 struct rte_cryptodev *cryptodev;    /**< Crypto Device */
     101                 :            :                 struct rte_dma_dev *dmadev;          /**< DMA Device */
     102                 :            :                 struct rte_rawdev *rawdev;          /**< Raw Device */
     103                 :            :         };
     104                 :            :         enum rte_dpaa2_dev_type dev_type;   /**< Device Type */
     105                 :            :         uint16_t object_id;                 /**< DPAA2 Object ID */
     106                 :            :         enum rte_dpaa2_dev_type ep_dev_type;   /**< Endpoint Device Type */
     107                 :            :         struct dpaa2_dprc_dev *container;
     108                 :            :         uint16_t ep_object_id;                 /**< Endpoint DPAA2 Object ID */
     109                 :            :         char ep_name[RTE_DEV_NAME_MAX_LEN];
     110                 :            :         struct rte_intr_handle *intr_handle; /**< Interrupt handle */
     111                 :            :         struct rte_dpaa2_driver *driver;    /**< Associated driver */
     112                 :            :         char name[FSLMC_OBJECT_MAX_LEN];    /**< DPAA2 Object name*/
     113                 :            : };
     114                 :            : 
     115                 :            : typedef int (*rte_dpaa2_obj_create_t)(int vdev_fd,
     116                 :            :                                       struct vfio_device_info *obj_info,
     117                 :            :                                       struct rte_dpaa2_device *dev);
     118                 :            : 
     119                 :            : typedef void (*rte_dpaa2_obj_close_t)(int object_id);
     120                 :            : 
     121                 :            : typedef int (*rte_dpaa2_probe_t)(struct rte_dpaa2_driver *dpaa2_drv,
     122                 :            :                                  struct rte_dpaa2_device *dpaa2_dev);
     123                 :            : typedef int (*rte_dpaa2_remove_t)(struct rte_dpaa2_device *dpaa2_dev);
     124                 :            : 
     125                 :            : TAILQ_HEAD(rte_dpaa2_object_list, rte_dpaa2_object);
     126                 :            : 
     127                 :            : /**
     128                 :            :  * A structure describing a DPAA2 object.
     129                 :            :  */
     130                 :            : struct rte_dpaa2_object {
     131                 :            :         TAILQ_ENTRY(rte_dpaa2_object) next; /**< Next in list. */
     132                 :            :         const char *name;                   /**< Name of Object. */
     133                 :            :         enum rte_dpaa2_dev_type dev_type;   /**< Type of device */
     134                 :            :         rte_dpaa2_obj_create_t create;
     135                 :            :         rte_dpaa2_obj_close_t close;
     136                 :            : };
     137                 :            : 
     138                 :            : int
     139                 :            : rte_fslmc_vfio_mem_dmamap(uint64_t vaddr, uint64_t iova, uint64_t size);
     140                 :            : int
     141                 :            : rte_fslmc_vfio_mem_dmaunmap(uint64_t iova, uint64_t size);
     142                 :            : 
     143                 :            : /**
     144                 :            :  * A structure describing a DPAA2 driver.
     145                 :            :  */
     146                 :            : struct rte_dpaa2_driver {
     147                 :            :         TAILQ_ENTRY(rte_dpaa2_driver) next; /**< Next in list. */
     148                 :            :         struct rte_driver driver;           /**< Inherit core driver. */
     149                 :            :         uint32_t drv_flags;                 /**< Flags for controlling device.*/
     150                 :            :         enum rte_dpaa2_dev_type drv_type;   /**< Driver Type */
     151                 :            :         rte_dpaa2_probe_t probe;
     152                 :            :         rte_dpaa2_remove_t remove;
     153                 :            : };
     154                 :            : 
     155                 :            : int
     156                 :            : rte_fslmc_vfio_mem_dmamap(uint64_t vaddr, uint64_t iova, uint64_t size);
     157                 :            : __rte_internal
     158                 :            : int
     159                 :            : rte_fslmc_vfio_mem_dmaunmap(uint64_t iova, uint64_t size);
     160                 :            : __rte_internal
     161                 :            : uint64_t
     162                 :            : rte_fslmc_cold_mem_vaddr_to_iova(void *vaddr,
     163                 :            :         uint64_t size);
     164                 :            : __rte_internal
     165                 :            : void *
     166                 :            : rte_fslmc_cold_mem_iova_to_vaddr(uint64_t iova,
     167                 :            :         uint64_t size);
     168                 :            : __rte_internal
     169                 :            : __rte_hot uint64_t
     170                 :            : rte_fslmc_mem_vaddr_to_iova(void *vaddr);
     171                 :            : __rte_internal
     172                 :            : __rte_hot void *
     173                 :            : rte_fslmc_mem_iova_to_vaddr(uint64_t iova);
     174                 :            : __rte_internal
     175                 :            : uint64_t
     176                 :            : rte_fslmc_io_vaddr_to_iova(void *vaddr);
     177                 :            : __rte_internal
     178                 :            : void *
     179                 :            : rte_fslmc_io_iova_to_vaddr(uint64_t iova);
     180                 :            : 
     181                 :            : /**
     182                 :            :  * Register a DPAA2 driver.
     183                 :            :  *
     184                 :            :  * @param driver
     185                 :            :  *   A pointer to a rte_dpaa2_driver structure describing the driver
     186                 :            :  *   to be registered.
     187                 :            :  */
     188                 :            : __rte_internal
     189                 :            : void rte_fslmc_driver_register(struct rte_dpaa2_driver *driver);
     190                 :            : 
     191                 :            : /**
     192                 :            :  * Unregister a DPAA2 driver.
     193                 :            :  *
     194                 :            :  * @param driver
     195                 :            :  *   A pointer to a rte_dpaa2_driver structure describing the driver
     196                 :            :  *   to be unregistered.
     197                 :            :  */
     198                 :            : __rte_internal
     199                 :            : void rte_fslmc_driver_unregister(struct rte_dpaa2_driver *driver);
     200                 :            : 
     201                 :            : /** Helper for DPAA2 device registration from driver (eth, crypto) instance */
     202                 :            : #define RTE_PMD_REGISTER_DPAA2(nm, dpaa2_drv) \
     203                 :            : RTE_INIT(dpaa2initfn_ ##nm) \
     204                 :            : {\
     205                 :            :         (dpaa2_drv).driver.name = RTE_STR(nm);\
     206                 :            :         rte_fslmc_driver_register(&dpaa2_drv); \
     207                 :            : } \
     208                 :            : RTE_PMD_EXPORT_NAME(nm, __COUNTER__)
     209                 :            : 
     210                 :            : /**
     211                 :            :  * Register a DPAA2 MC Object driver.
     212                 :            :  *
     213                 :            :  * @param mc_object
     214                 :            :  *   A pointer to a rte_dpaa_object structure describing the mc object
     215                 :            :  *   to be registered.
     216                 :            :  */
     217                 :            : __rte_internal
     218                 :            : void rte_fslmc_object_register(struct rte_dpaa2_object *object);
     219                 :            : 
     220                 :            : /**
     221                 :            :  * Count of a particular type of DPAA2 device scanned on the bus.
     222                 :            :  *
     223                 :            :  * @param dev_type
     224                 :            :  *   Type of device as rte_dpaa2_dev_type enumerator
     225                 :            :  * @return
     226                 :            :  *   >=0 for count; 0 indicates either no device of the said type scanned or
     227                 :            :  *   invalid device type.
     228                 :            :  */
     229                 :            : __rte_internal
     230                 :            : uint32_t rte_fslmc_get_device_count(enum rte_dpaa2_dev_type device_type);
     231                 :            : 
     232                 :            : /** Helper for DPAA2 object registration */
     233                 :            : #define RTE_PMD_REGISTER_DPAA2_OBJECT(nm, dpaa2_obj) \
     234                 :            : RTE_INIT(dpaa2objinitfn_ ##nm) \
     235                 :            : {\
     236                 :            :         (dpaa2_obj).name = RTE_STR(nm);\
     237                 :            :         rte_fslmc_object_register(&dpaa2_obj); \
     238                 :            : } \
     239                 :            : RTE_PMD_EXPORT_NAME(nm, __COUNTER__)
     240                 :            : 
     241                 :            : #ifdef __cplusplus
     242                 :            : }
     243                 :            : #endif
     244                 :            : 
     245                 :            : #endif /* BUS_FSLMC_DRIVER_H */

Generated by: LCOV version 1.14