DPDK  18.05.1
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 
68 int rte_eth_dev_release_port(struct rte_eth_dev *eth_dev);
69 
81 void _rte_eth_dev_reset(struct rte_eth_dev *dev);
82 
100 int _rte_eth_dev_callback_process(struct rte_eth_dev *dev,
101  enum rte_eth_event_type event, void *ret_param);
102 
115 void rte_eth_dev_probing_finish(struct rte_eth_dev *dev);
116 
136 const struct rte_memzone *
137 rte_eth_dma_zone_reserve(const struct rte_eth_dev *eth_dev, const char *name,
138  uint16_t queue_id, size_t size,
139  unsigned align, int socket_id);
140 
156 static inline int
157 rte_eth_linkstatus_set(struct rte_eth_dev *dev,
158  const struct rte_eth_link *new_link)
159 {
160  volatile uint64_t *dev_link
161  = (volatile uint64_t *)&(dev->data->dev_link);
162  union {
163  uint64_t val64;
164  struct rte_eth_link link;
165  } orig;
166 
167  RTE_BUILD_BUG_ON(sizeof(*new_link) != sizeof(uint64_t));
168 
169  orig.val64 = rte_atomic64_exchange(dev_link,
170  *(const uint64_t *)new_link);
171 
172  return (orig.link.link_status == new_link->link_status) ? -1 : 0;
173 }
174 
184 static inline void
185 rte_eth_linkstatus_get(const struct rte_eth_dev *dev,
186  struct rte_eth_link *link)
187 {
188  volatile uint64_t *src = (uint64_t *)&(dev->data->dev_link);
189  uint64_t *dst = (uint64_t *)link;
190 
191  RTE_BUILD_BUG_ON(sizeof(*link) != sizeof(uint64_t));
192 
193 #ifdef __LP64__
194  /* if cpu arch has 64 bit unsigned lon then implicitly atomic */
195  *dst = *src;
196 #else
197  /* can't use rte_atomic64_read because it returns signed int */
198  do {
199  *dst = *src;
200  } while (!rte_atomic64_cmpset(src, *dst, *dst));
201 #endif
202 }
203 
221 int __rte_experimental
222 rte_eth_switch_domain_alloc(uint16_t *domain_id);
223 
239 int __rte_experimental
240 rte_eth_switch_domain_free(uint16_t domain_id);
241 
244  uint16_t ports[RTE_MAX_ETHPORTS];
246  uint16_t nb_ports;
248  uint16_t representor_ports[RTE_MAX_ETHPORTS];
252 };
253 
268 int __rte_experimental
269 rte_eth_devargs_parse(const char *devargs, struct rte_eth_devargs *eth_devargs);
270 
271 
272 typedef int (*ethdev_init_t)(struct rte_eth_dev *ethdev, void *init_params);
273 typedef int (*ethdev_bus_specific_init)(struct rte_eth_dev *ethdev,
274  void *bus_specific_init_params);
275 
300 int __rte_experimental
301 rte_eth_dev_create(struct rte_device *device, const char *name,
302  size_t priv_data_size,
303  ethdev_bus_specific_init bus_specific_init, void *bus_init_params,
304  ethdev_init_t ethdev_init, void *init_params);
305 
306 
307 typedef int (*ethdev_uninit_t)(struct rte_eth_dev *ethdev);
308 
324 int __rte_experimental
325 rte_eth_dev_destroy(struct rte_eth_dev *ethdev, ethdev_uninit_t ethdev_uninit);
326 
327 #ifdef __cplusplus
328 }
329 #endif
330 
331 #endif /* _RTE_ETHDEV_DRIVER_H_ */