The hotplug API introduced multiple states for a device with possible
values defined internally, while the related field in struct rte_eth_dev
was made public.
Exposing those states improves consistency because applications have to
deal with the device list directly.
"DEV_DETACHED" is renamed "RTE_ETH_DEV_UNUSED" to better reflect that
the emptiness of a slot is not necessarily the result of detaching a
device.
Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
-enum {
- DEV_DETACHED = 0,
- DEV_ATTACHED
-};
-
static void
rte_eth_dev_data_alloc(void)
{
static void
rte_eth_dev_data_alloc(void)
{
unsigned i;
for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
unsigned i;
for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
- if ((rte_eth_devices[i].attached == DEV_ATTACHED) &&
+ if ((rte_eth_devices[i].state == RTE_ETH_DEV_ATTACHED) &&
strcmp(rte_eth_devices[i].data->name, name) == 0)
return &rte_eth_devices[i];
}
strcmp(rte_eth_devices[i].data->name, name) == 0)
return &rte_eth_devices[i];
}
unsigned i;
for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
unsigned i;
for (i = 0; i < RTE_MAX_ETHPORTS; i++) {
- if (rte_eth_devices[i].attached == DEV_DETACHED)
+ if (rte_eth_devices[i].state == RTE_ETH_DEV_UNUSED)
return i;
}
return RTE_MAX_ETHPORTS;
return i;
}
return RTE_MAX_ETHPORTS;
struct rte_eth_dev *eth_dev = &rte_eth_devices[port_id];
eth_dev->data = &rte_eth_dev_data[port_id];
struct rte_eth_dev *eth_dev = &rte_eth_devices[port_id];
eth_dev->data = &rte_eth_dev_data[port_id];
- eth_dev->attached = DEV_ATTACHED;
+ eth_dev->state = RTE_ETH_DEV_ATTACHED;
TAILQ_INIT(&(eth_dev->link_intr_cbs));
eth_dev_last_created_port = port_id;
TAILQ_INIT(&(eth_dev->link_intr_cbs));
eth_dev_last_created_port = port_id;
if (eth_dev == NULL)
return -EINVAL;
if (eth_dev == NULL)
return -EINVAL;
- eth_dev->attached = DEV_DETACHED;
+ eth_dev->state = RTE_ETH_DEV_UNUSED;
rte_eth_dev_is_valid_port(uint8_t port_id)
{
if (port_id >= RTE_MAX_ETHPORTS ||
rte_eth_dev_is_valid_port(uint8_t port_id)
{
if (port_id >= RTE_MAX_ETHPORTS ||
- rte_eth_devices[port_id].attached != DEV_ATTACHED)
+ rte_eth_devices[port_id].state != RTE_ETH_DEV_ATTACHED)
+/**
+ * A set of values to describe the possible states of an eth device.
+ */
+enum rte_eth_dev_state {
+ RTE_ETH_DEV_UNUSED = 0,
+ RTE_ETH_DEV_ATTACHED,
+};
+
/**
* @internal
* The generic data structure associated with each ethernet device.
/**
* @internal
* The generic data structure associated with each ethernet device.
* received packets before passing them to the driver for transmission.
*/
struct rte_eth_rxtx_callback *pre_tx_burst_cbs[RTE_MAX_QUEUES_PER_PORT];
* received packets before passing them to the driver for transmission.
*/
struct rte_eth_rxtx_callback *pre_tx_burst_cbs[RTE_MAX_QUEUES_PER_PORT];
- uint8_t attached; /**< Flag indicating the port is attached */
+ enum rte_eth_dev_state state:8; /**< Flag indicating the port state */
} __rte_cache_aligned;
struct rte_eth_dev_sriov {
} __rte_cache_aligned;
struct rte_eth_dev_sriov {