1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright (c) 2015-2018 Atomic Rules LLC 3 */ 4 5 #ifndef _ARK_EXT_H_ 6 #define _ARK_EXT_H_ 7 8 #include <rte_mbuf.h> 9 #include <ethdev_driver.h> 10 11 /* The following section lists function prototypes for Arkville's 12 * dynamic PMD extension. User's who create an extension 13 * must include this file and define the necessary and desired 14 * functions. Only 1 function is required for an extension, 15 * rte_pmd_ark_dev_init(); all other functions prototypes in this 16 * section are optional. 17 * See documentation for compiling and use of extensions. 18 */ 19 20 /* private data optionally attached to mempool for rx */ 21 struct rte_pmd_ark_lmbuf_mempool_priv { 22 struct rte_pktmbuf_pool_private pool_private; 23 char cookie[4]; 24 uint32_t dataroom; 25 }; 26 #define ARK_MEMPOOL_COOKIE "ARK1" 27 28 /** 29 * Extension prototype, required implementation if extensions are used. 30 * Called during device probe to initialize the user structure 31 * passed to other extension functions. This is called once for each 32 * port of the device. 33 * 34 * @param dev 35 * current device. 36 * @param a_bar 37 * access to PCIe device bar (application bar) and hence access to 38 * user's portion of FPGA. 39 * @param port_id 40 * port identifier. 41 * @return user_data 42 * which will be passed to other extension functions. 43 */ 44 void *rte_pmd_ark_dev_init(struct rte_eth_dev *dev, void *a_bar, int port_id); 45 46 /** 47 * Extension prototype, optional implementation. 48 * Called during device uninit. 49 * 50 * @param dev 51 * current device. 52 * @param user_data 53 * user argument from dev_init() call. 54 */ 55 void rte_pmd_ark_dev_uninit(struct rte_eth_dev *dev, void *user_data); 56 57 /** 58 * Extension prototype, optional implementation. 59 * Called during device probe to change the port count from 1. 60 * 61 * @param dev 62 * current device. 63 * @param user_data 64 * user argument from dev_init() call. 65 * @return (0) if successful. 66 */ 67 uint8_t dev_get_port_count(struct rte_eth_dev *dev, void *user_data); 68 69 /** 70 * Extension prototype, optional implementation. 71 * Called during rte_eth_dev_configure(). 72 * 73 * @param dev 74 * current device. 75 * @param user_data 76 * user argument from dev_init() call. 77 * @return (0) if successful. 78 */ 79 int rte_pmd_ark_dev_configure(struct rte_eth_dev *dev, void *user_data); 80 81 /** 82 * Extension prototype, optional implementation. 83 * Called during rte_eth_dev_start(). 84 * 85 * @param dev 86 * current device. 87 * @param user_data 88 * user argument from dev_init() call. 89 * @return (0) if successful. 90 */ 91 int rte_pmd_ark_dev_start(struct rte_eth_dev *dev, void *user_data); 92 93 /** 94 * Extension prototype, optional implementation. 95 * Called during rte_eth_dev_stop(). 96 * 97 * @param dev 98 * current device. 99 * @param user_data 100 * user argument from dev_init() call. 101 * @return (0) if successful. 102 */ 103 void rte_pmd_ark_dev_stop(struct rte_eth_dev *dev, void *user_data); 104 105 /** 106 * Extension prototype, optional implementation. 107 * Called during rte_eth_dev_close(). 108 * 109 * @param dev 110 * current device. 111 * @param user_data 112 * user argument from dev_init() call. 113 * @return (0) if successful. 114 */ 115 void rte_pmd_ark_dev_close(struct rte_eth_dev *dev, void *user_data); 116 117 /** 118 * Extension prototype, optional implementation. 119 * Called during link_update status event. 120 * 121 * @param dev 122 * current device. 123 * @param wait_to_complete 124 * argument from update event. 125 * @param user_data 126 * user argument from dev_init() call. 127 * @return (0) if successful. 128 */ 129 int rte_pmd_ark_link_update(struct rte_eth_dev *dev, 130 int wait_to_complete, 131 void *user_data); 132 133 /** 134 * Extension prototype, optional implementation. 135 * Called during rte_eth_dev_set_link_up(). 136 * 137 * @param dev 138 * current device. 139 * @param user_data 140 * user argument from dev_init() call. 141 * @return (0) if successful. 142 */ 143 int rte_pmd_ark_dev_set_link_up(struct rte_eth_dev *dev, void *user_data); 144 145 /** 146 * Extension prototype, optional implementation. 147 * Called during rte_eth_dev_set_link_down(). 148 * 149 * @param dev 150 * current device. 151 * @param user_data 152 * user argument from dev_init() call. 153 * @return (0) if successful. 154 */ 155 int rte_pmd_ark_dev_set_link_down(struct rte_eth_dev *dev, void *user_data); 156 157 /** 158 * Extension prototype, optional implementation. 159 * Called during rte_eth_stats_get(); allows updates to the stats 160 * struct in addition Ark's PMD operations. 161 * 162 * @param dev 163 * current device. 164 * @param stats 165 * statistics struct already populated by Ark PMD. 166 * @param user_data 167 * user argument from dev_init() call. 168 * @return (0) if successful. 169 */ 170 int rte_pmd_ark_stats_get(struct rte_eth_dev *dev, 171 struct rte_eth_stats *stats, 172 void *user_data); 173 174 /** 175 * Extension prototype, optional implementation. 176 * Called during rte_eth_dev_stats_reset(). 177 * 178 * @param dev 179 * current device. 180 * @param user_data 181 * user argument from dev_init() call. 182 * @return (0) if successful. 183 */ 184 void rte_pmd_ark_stats_reset(struct rte_eth_dev *dev, void *user_data); 185 186 /** 187 * Extension prototype, optional implementation. 188 * Called during rte_eth_dev_mac_addr_add(). 189 * 190 * @param dev 191 * current device. 192 * @param macaddr 193 * The MAC address to add 194 * @param index 195 * The index into the MAC address array. 196 * @param pool 197 * VMDq pool index from caller 198 * @param user_data 199 * user argument from dev_init() call. 200 * @return (0) if successful. 201 */ 202 void rte_pmd_ark_mac_addr_add(struct rte_eth_dev *dev, 203 struct rte_ether_addr *macaddr, 204 uint32_t index, 205 uint32_t pool, 206 void *user_data); 207 208 /** 209 * Extension prototype, optional implementation. 210 * Called during rte_eth_dev_mac_addr_remove(). 211 * 212 * @param dev 213 * current device. 214 * @param index 215 * The index into the MAC address array. 216 * @param user_data 217 * user argument from dev_init() call. 218 * @return (0) if successful. 219 */ 220 void rte_pmd_ark_mac_addr_remove(struct rte_eth_dev *dev, 221 uint32_t index, 222 void *user_data); 223 224 /** 225 * Extension prototype, optional implementation. 226 * Called during rte_eth_dev_default_mac_addr_set(). 227 * 228 * @param dev 229 * current device. 230 * @param mac_addr 231 * The new default MAC address. 232 * @param user_data 233 * user argument from dev_init() call. 234 * @return (0) if successful. 235 */ 236 void rte_pmd_ark_mac_addr_set(struct rte_eth_dev *dev, 237 struct rte_ether_addr *mac_addr, 238 void *user_data); 239 240 /** 241 * Extension prototype, optional implementation. 242 * Called during rte_eth_dev_set_mtu(). 243 * 244 * @param dev 245 * current device. 246 * @param size 247 * The MTU to be applied 248 * @param user_data 249 * user argument from dev_init() call. 250 * @return (0) if successful. 251 */ 252 int rte_pmd_ark_set_mtu(struct rte_eth_dev *dev, 253 uint16_t size, 254 void *user_data); 255 256 /** 257 * Extension prototype, optional implementation. 258 * Called during rte_eth_rx_burst() for each packet. This extension 259 * function allows the transfer of meta data from the user's FPGA to 260 * mbuf fields. 261 * 262 * @param mbuf 263 * The newly received mbuf 264 * @param meta 265 * The meta data from the user, up to 20 bytes. The 266 * underlying data in the PMD is of type uint32_t meta[5]; 267 * @param user_data 268 * user argument from dev_init() call. 269 */ 270 void rte_pmd_ark_rx_user_meta_hook(struct rte_mbuf *mbuf, 271 const uint32_t *meta, 272 void *user_data); 273 274 /** 275 * Extension prototype, optional implementation. 276 * Called during rte_eth_tx_burst() for each packet. This extension 277 * function allows the transfer of data from the mbuf to the user's 278 * FPGA. Up to 20 bytes (5 32-bit words) are transferable 279 * 280 * @param mbuf 281 * The mbuf about to be transmitted. 282 * @param meta 283 * The meta data to be populate by this call. The 284 * underlying in the PMD is of type uint32_t meta[5]; 285 * @param meta_cnt 286 * The count in 32-bit words of the meta data populated, 0 to 5. 287 * @param user_data 288 * user argument from dev_init() call. 289 */ 290 void rte_pmd_ark_tx_user_meta_hook(const struct rte_mbuf *mbuf, 291 uint32_t *meta, 292 uint8_t *meta_cnt, 293 void *user_data); 294 295 #endif 296