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