DPDK  20.08.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 
195 __rte_internal
196 int
197 rte_eth_dma_zone_free(const struct rte_eth_dev *eth_dev, const char *name,
198  uint16_t queue_id);
199 
215 static inline int
216 rte_eth_linkstatus_set(struct rte_eth_dev *dev,
217  const struct rte_eth_link *new_link)
218 {
219  volatile uint64_t *dev_link
220  = (volatile uint64_t *)&(dev->data->dev_link);
221  union {
222  uint64_t val64;
223  struct rte_eth_link link;
224  } orig;
225 
226  RTE_BUILD_BUG_ON(sizeof(*new_link) != sizeof(uint64_t));
227 
228  orig.val64 = rte_atomic64_exchange(dev_link,
229  *(const uint64_t *)new_link);
230 
231  return (orig.link.link_status == new_link->link_status) ? -1 : 0;
232 }
233 
243 static inline void
244 rte_eth_linkstatus_get(const struct rte_eth_dev *dev,
245  struct rte_eth_link *link)
246 {
247  volatile uint64_t *src = (uint64_t *)&(dev->data->dev_link);
248  uint64_t *dst = (uint64_t *)link;
249 
250  RTE_BUILD_BUG_ON(sizeof(*link) != sizeof(uint64_t));
251 
252 #ifdef __LP64__
253  /* if cpu arch has 64 bit unsigned lon then implicitly atomic */
254  *dst = *src;
255 #else
256  /* can't use rte_atomic64_read because it returns signed int */
257  do {
258  *dst = *src;
259  } while (!rte_atomic64_cmpset(src, *dst, *dst));
260 #endif
261 }
262 
280 __rte_experimental
281 int
282 rte_eth_switch_domain_alloc(uint16_t *domain_id);
283 
299 __rte_experimental
300 int
301 rte_eth_switch_domain_free(uint16_t domain_id);
302 
305  uint16_t ports[RTE_MAX_ETHPORTS];
307  uint16_t nb_ports;
309  uint16_t representor_ports[RTE_MAX_ETHPORTS];
313 };
314 
329 __rte_experimental
330 int
331 rte_eth_devargs_parse(const char *devargs, struct rte_eth_devargs *eth_devargs);
332 
333 
334 typedef int (*ethdev_init_t)(struct rte_eth_dev *ethdev, void *init_params);
335 typedef int (*ethdev_bus_specific_init)(struct rte_eth_dev *ethdev,
336  void *bus_specific_init_params);
337 
362 __rte_experimental
363 int
364 rte_eth_dev_create(struct rte_device *device, const char *name,
365  size_t priv_data_size,
366  ethdev_bus_specific_init bus_specific_init, void *bus_init_params,
367  ethdev_init_t ethdev_init, void *init_params);
368 
369 
370 typedef int (*ethdev_uninit_t)(struct rte_eth_dev *ethdev);
371 
387 __rte_experimental
388 int
389 rte_eth_dev_destroy(struct rte_eth_dev *ethdev, ethdev_uninit_t ethdev_uninit);
390 
391 #ifdef __cplusplus
392 }
393 #endif
394 
395 #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:351
static int rte_atomic64_cmpset(volatile uint64_t *dst, uint64_t exp, uint64_t src)
__rte_internal int rte_eth_dma_zone_free(const struct rte_eth_dev *eth_dev, const char *name, uint16_t queue_id)
__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:3127