DPDK  20.05.0
rte_ethdev_driver.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2017 Intel Corporation
3  */
4 
5 #ifndef _RTE_ETHDEV_DRIVER_H_
6 #define _RTE_ETHDEV_DRIVER_H_
7 
18 #include <rte_ethdev.h>
19 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
27 #define RTE_ETH_QUEUE_STATE_STOPPED 0
28 #define RTE_ETH_QUEUE_STATE_STARTED 1
29 #define RTE_ETH_QUEUE_STATE_HAIRPIN 2
30 
43 int rte_eth_dev_is_rx_hairpin_queue(struct rte_eth_dev *dev, uint16_t queue_id);
44 
57 int rte_eth_dev_is_tx_hairpin_queue(struct rte_eth_dev *dev, uint16_t queue_id);
58 
68 struct rte_eth_dev *rte_eth_dev_allocated(const char *name);
69 
79 struct rte_eth_dev *rte_eth_dev_allocate(const char *name);
80 
92 struct rte_eth_dev *rte_eth_dev_attach_secondary(const char *name);
93 
110 int rte_eth_dev_release_port(struct rte_eth_dev *eth_dev);
111 
123 void _rte_eth_dev_reset(struct rte_eth_dev *dev);
124 
142 int _rte_eth_dev_callback_process(struct rte_eth_dev *dev,
143  enum rte_eth_event_type event, void *ret_param);
144 
157 void rte_eth_dev_probing_finish(struct rte_eth_dev *dev);
158 
178 const struct rte_memzone *
179 rte_eth_dma_zone_reserve(const struct rte_eth_dev *eth_dev, const char *name,
180  uint16_t queue_id, size_t size,
181  unsigned align, int socket_id);
182 
198 static inline int
199 rte_eth_linkstatus_set(struct rte_eth_dev *dev,
200  const struct rte_eth_link *new_link)
201 {
202  volatile uint64_t *dev_link
203  = (volatile uint64_t *)&(dev->data->dev_link);
204  union {
205  uint64_t val64;
206  struct rte_eth_link link;
207  } orig;
208 
209  RTE_BUILD_BUG_ON(sizeof(*new_link) != sizeof(uint64_t));
210 
211  orig.val64 = rte_atomic64_exchange(dev_link,
212  *(const uint64_t *)new_link);
213 
214  return (orig.link.link_status == new_link->link_status) ? -1 : 0;
215 }
216 
226 static inline void
227 rte_eth_linkstatus_get(const struct rte_eth_dev *dev,
228  struct rte_eth_link *link)
229 {
230  volatile uint64_t *src = (uint64_t *)&(dev->data->dev_link);
231  uint64_t *dst = (uint64_t *)link;
232 
233  RTE_BUILD_BUG_ON(sizeof(*link) != sizeof(uint64_t));
234 
235 #ifdef __LP64__
236  /* if cpu arch has 64 bit unsigned lon then implicitly atomic */
237  *dst = *src;
238 #else
239  /* can't use rte_atomic64_read because it returns signed int */
240  do {
241  *dst = *src;
242  } while (!rte_atomic64_cmpset(src, *dst, *dst));
243 #endif
244 }
245 
263 __rte_experimental
264 int
265 rte_eth_switch_domain_alloc(uint16_t *domain_id);
266 
282 __rte_experimental
283 int
284 rte_eth_switch_domain_free(uint16_t domain_id);
285 
288  uint16_t ports[RTE_MAX_ETHPORTS];
290  uint16_t nb_ports;
292  uint16_t representor_ports[RTE_MAX_ETHPORTS];
296 };
297 
312 __rte_experimental
313 int
314 rte_eth_devargs_parse(const char *devargs, struct rte_eth_devargs *eth_devargs);
315 
316 
317 typedef int (*ethdev_init_t)(struct rte_eth_dev *ethdev, void *init_params);
318 typedef int (*ethdev_bus_specific_init)(struct rte_eth_dev *ethdev,
319  void *bus_specific_init_params);
320 
345 __rte_experimental
346 int
347 rte_eth_dev_create(struct rte_device *device, const char *name,
348  size_t priv_data_size,
349  ethdev_bus_specific_init bus_specific_init, void *bus_init_params,
350  ethdev_init_t ethdev_init, void *init_params);
351 
352 
353 typedef int (*ethdev_uninit_t)(struct rte_eth_dev *ethdev);
354 
370 __rte_experimental
371 int
372 rte_eth_dev_destroy(struct rte_eth_dev *ethdev, ethdev_uninit_t ethdev_uninit);
373 
374 #ifdef __cplusplus
375 }
376 #endif
377 
378 #endif /* _RTE_ETHDEV_DRIVER_H_ */
const struct rte_memzone * rte_eth_dma_zone_reserve(const struct rte_eth_dev *eth_dev, const char *name, uint16_t queue_id, size_t size, unsigned align, int socket_id)
uint16_t nb_representor_ports
__rte_experimental int rte_eth_switch_domain_free(uint16_t domain_id)
__rte_experimental int rte_eth_switch_domain_alloc(uint16_t *domain_id)
#define RTE_BUILD_BUG_ON(condition)
Definition: rte_common.h:342
static int rte_atomic64_cmpset(volatile uint64_t *dst, uint64_t exp, uint64_t src)
__rte_experimental int rte_eth_dev_create(struct rte_device *device, const char *name, size_t priv_data_size, ethdev_bus_specific_init bus_specific_init, void *bus_init_params, ethdev_init_t ethdev_init, void *init_params)
int32_t socket_id
Definition: rte_memzone.h:68
__rte_experimental int rte_eth_dev_destroy(struct rte_eth_dev *ethdev, ethdev_uninit_t ethdev_uninit)
char name[RTE_MEMZONE_NAMESIZE]
Definition: rte_memzone.h:52
__rte_experimental int rte_eth_devargs_parse(const char *devargs, struct rte_eth_devargs *eth_devargs)
static uint64_t rte_atomic64_exchange(volatile uint64_t *dst, uint64_t val)
uint16_t representor_ports[RTE_MAX_ETHPORTS]
rte_eth_event_type
Definition: rte_ethdev.h:3022