DPDK  19.08.0-rc0
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 int __rte_experimental
229 rte_eth_switch_domain_alloc(uint16_t *domain_id);
230 
246 int __rte_experimental
247 rte_eth_switch_domain_free(uint16_t domain_id);
248 
251  uint16_t ports[RTE_MAX_ETHPORTS];
253  uint16_t nb_ports;
255  uint16_t representor_ports[RTE_MAX_ETHPORTS];
259 };
260 
275 int __rte_experimental
276 rte_eth_devargs_parse(const char *devargs, struct rte_eth_devargs *eth_devargs);
277 
278 
279 typedef int (*ethdev_init_t)(struct rte_eth_dev *ethdev, void *init_params);
280 typedef int (*ethdev_bus_specific_init)(struct rte_eth_dev *ethdev,
281  void *bus_specific_init_params);
282 
307 int __rte_experimental
308 rte_eth_dev_create(struct rte_device *device, const char *name,
309  size_t priv_data_size,
310  ethdev_bus_specific_init bus_specific_init, void *bus_init_params,
311  ethdev_init_t ethdev_init, void *init_params);
312 
313 
314 typedef int (*ethdev_uninit_t)(struct rte_eth_dev *ethdev);
315 
331 int __rte_experimental
332 rte_eth_dev_destroy(struct rte_eth_dev *ethdev, ethdev_uninit_t ethdev_uninit);
333 
334 #ifdef __cplusplus
335 }
336 #endif
337 
338 #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
#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)
int __rte_experimental rte_eth_devargs_parse(const char *devargs, struct rte_eth_devargs *eth_devargs)
int __rte_experimental rte_eth_switch_domain_alloc(uint16_t *domain_id)
int __rte_experimental rte_eth_switch_domain_free(uint16_t domain_id)
int32_t socket_id
Definition: rte_memzone.h:68
char name[RTE_MEMZONE_NAMESIZE]
Definition: rte_memzone.h:52
int __rte_experimental rte_eth_dev_destroy(struct rte_eth_dev *ethdev, ethdev_uninit_t ethdev_uninit)
static uint64_t rte_atomic64_exchange(volatile uint64_t *dst, uint64_t val)
int __rte_experimental 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)
uint16_t representor_ports[RTE_MAX_ETHPORTS]
rte_eth_event_type
Definition: rte_ethdev.h:2763