DPDK  19.08.2
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 
33 struct rte_eth_dev *rte_eth_dev_allocated(const char *name);
34 
44 struct rte_eth_dev *rte_eth_dev_allocate(const char *name);
45 
57 struct rte_eth_dev *rte_eth_dev_attach_secondary(const char *name);
58 
75 int rte_eth_dev_release_port(struct rte_eth_dev *eth_dev);
76 
88 void _rte_eth_dev_reset(struct rte_eth_dev *dev);
89 
107 int _rte_eth_dev_callback_process(struct rte_eth_dev *dev,
108  enum rte_eth_event_type event, void *ret_param);
109 
122 void rte_eth_dev_probing_finish(struct rte_eth_dev *dev);
123 
143 const struct rte_memzone *
144 rte_eth_dma_zone_reserve(const struct rte_eth_dev *eth_dev, const char *name,
145  uint16_t queue_id, size_t size,
146  unsigned align, int socket_id);
147 
163 static inline int
164 rte_eth_linkstatus_set(struct rte_eth_dev *dev,
165  const struct rte_eth_link *new_link)
166 {
167  volatile uint64_t *dev_link
168  = (volatile uint64_t *)&(dev->data->dev_link);
169  union {
170  uint64_t val64;
171  struct rte_eth_link link;
172  } orig;
173 
174  RTE_BUILD_BUG_ON(sizeof(*new_link) != sizeof(uint64_t));
175 
176  orig.val64 = rte_atomic64_exchange(dev_link,
177  *(const uint64_t *)new_link);
178 
179  return (orig.link.link_status == new_link->link_status) ? -1 : 0;
180 }
181 
191 static inline void
192 rte_eth_linkstatus_get(const struct rte_eth_dev *dev,
193  struct rte_eth_link *link)
194 {
195  volatile uint64_t *src = (uint64_t *)&(dev->data->dev_link);
196  uint64_t *dst = (uint64_t *)link;
197 
198  RTE_BUILD_BUG_ON(sizeof(*link) != sizeof(uint64_t));
199 
200 #ifdef __LP64__
201  /* if cpu arch has 64 bit unsigned lon then implicitly atomic */
202  *dst = *src;
203 #else
204  /* can't use rte_atomic64_read because it returns signed int */
205  do {
206  *dst = *src;
207  } while (!rte_atomic64_cmpset(src, *dst, *dst));
208 #endif
209 }
210 
228 __rte_experimental
229 int
230 rte_eth_switch_domain_alloc(uint16_t *domain_id);
231 
247 __rte_experimental
248 int
249 rte_eth_switch_domain_free(uint16_t domain_id);
250 
253  uint16_t ports[RTE_MAX_ETHPORTS];
255  uint16_t nb_ports;
257  uint16_t representor_ports[RTE_MAX_ETHPORTS];
261 };
262 
277 __rte_experimental
278 int
279 rte_eth_devargs_parse(const char *devargs, struct rte_eth_devargs *eth_devargs);
280 
281 
282 typedef int (*ethdev_init_t)(struct rte_eth_dev *ethdev, void *init_params);
283 typedef int (*ethdev_bus_specific_init)(struct rte_eth_dev *ethdev,
284  void *bus_specific_init_params);
285 
310 __rte_experimental
311 int
312 rte_eth_dev_create(struct rte_device *device, const char *name,
313  size_t priv_data_size,
314  ethdev_bus_specific_init bus_specific_init, void *bus_init_params,
315  ethdev_init_t ethdev_init, void *init_params);
316 
317 
318 typedef int (*ethdev_uninit_t)(struct rte_eth_dev *ethdev);
319 
335 __rte_experimental
336 int
337 rte_eth_dev_destroy(struct rte_eth_dev *ethdev, ethdev_uninit_t ethdev_uninit);
338 
339 #ifdef __cplusplus
340 }
341 #endif
342 
343 #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:292
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:2776