1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2017 Intel Corporation
5 #ifndef _RTE_ETHDEV_DRIVER_H_
6 #define _RTE_ETHDEV_DRIVER_H_
11 * RTE Ethernet Device PMD API
13 * These APIs for the use from Ethernet drivers, user applications shouldn't
18 #include <rte_ethdev.h>
26 * Returns a ethdev slot specified by the unique identifier name.
29 * The pointer to the Unique identifier name for each Ethernet device
31 * - The pointer to the ethdev slot, on success. NULL on error
33 struct rte_eth_dev *rte_eth_dev_allocated(const char *name);
37 * Allocates a new ethdev slot for an ethernet device and returns the pointer
38 * to that slot for the driver to use.
40 * @param name Unique identifier name for each Ethernet device
41 * @param type Device type of this Ethernet device
43 * - Slot in the rte_dev_devices array for a new device;
45 struct rte_eth_dev *rte_eth_dev_allocate(const char *name);
49 * Attach to the ethdev already initialized by the primary
52 * @param name Ethernet device's name.
54 * - Success: Slot in the rte_dev_devices array for attached
56 * - Error: Null pointer.
58 struct rte_eth_dev *rte_eth_dev_attach_secondary(const char *name);
62 * Release the specified ethdev port.
65 * The *eth_dev* pointer is the address of the *rte_eth_dev* structure.
67 * - 0 on success, negative on error
69 int rte_eth_dev_release_port(struct rte_eth_dev *eth_dev);
73 * Release device queues and clear its configuration to force the user
74 * application to reconfigure it. It is for internal use only.
77 * Pointer to struct rte_eth_dev.
82 void _rte_eth_dev_reset(struct rte_eth_dev *dev);
85 * @internal Executes all the user application registered callbacks for
86 * the specific device. It is for DPDK internal user only. User
87 * application should not call it directly.
90 * Pointer to struct rte_eth_dev.
92 * Eth device interrupt event type.
94 * To pass data back to user application.
95 * This allows the user application to decide if a particular function
96 * is permitted or not.
101 int _rte_eth_dev_callback_process(struct rte_eth_dev *dev,
102 enum rte_eth_event_type event, void *ret_param);
105 * Create memzone for HW rings.
106 * malloc can't be used as the physical address is needed.
107 * If the memzone is already created, then this function returns a ptr
111 * The *eth_dev* pointer is the address of the *rte_eth_dev* structure
113 * The name of the memory zone
115 * The index of the queue to add to name
117 * The sizeof of the memory area
119 * Alignment for resulting memzone. Must be a power of 2.
121 * The *socket_id* argument is the socket identifier in case of NUMA.
123 const struct rte_memzone *
124 rte_eth_dma_zone_reserve(const struct rte_eth_dev *eth_dev, const char *name,
125 uint16_t queue_id, size_t size,
126 unsigned align, int socket_id);
130 * Atomically set the link status for the specific device.
131 * It is for use by DPDK device driver use only.
132 * User applications should not call it
135 * Pointer to struct rte_eth_dev.
137 * New link status value.
139 * Same convention as eth_link_update operation.
140 * 0 if link up status has changed
141 * -1 if link up status was unchanged
144 rte_eth_linkstatus_set(struct rte_eth_dev *dev,
145 const struct rte_eth_link *new_link)
147 volatile uint64_t *dev_link
148 = (volatile uint64_t *)&(dev->data->dev_link);
151 struct rte_eth_link link;
154 RTE_BUILD_BUG_ON(sizeof(*new_link) != sizeof(uint64_t));
156 orig.val64 = rte_atomic64_exchange(dev_link,
157 *(const uint64_t *)new_link);
159 return (orig.link.link_status == new_link->link_status) ? -1 : 0;
164 * Atomically get the link speed and status.
167 * Pointer to struct rte_eth_dev.
172 rte_eth_linkstatus_get(const struct rte_eth_dev *dev,
173 struct rte_eth_link *link)
175 volatile uint64_t *src = (uint64_t *)&(dev->data->dev_link);
176 uint64_t *dst = (uint64_t *)link;
178 RTE_BUILD_BUG_ON(sizeof(*link) != sizeof(uint64_t));
181 /* if cpu arch has 64 bit unsigned lon then implicitly atomic */
184 /* can't use rte_atomic64_read because it returns signed int */
187 } while (!rte_atomic64_cmpset(src, *dst, *dst));
195 #endif /* _RTE_ETHDEV_DRIVER_H_ */