ethdev: add dev configured flag
Currently, if dev_configure is not called or fails to be called, users can still call dev_start successfully. So it is necessary to have a flag which indicates whether the device is configured, to control whether dev_start can be called and eliminate dependency on user invocation order. The flag stored in "struct rte_eth_dev_data" is more reasonable than "enum rte_eth_dev_state". "enum rte_eth_dev_state" is private to the primary and secondary processes, and can be independently controlled. However, the secondary process does not make resource allocations and does not call dev_configure(). These are done by the primary process and can be obtained or used by the secondary process. So this patch adds a "dev_configured" flag in "rte_eth_dev_data", like "dev_started". Signed-off-by: Huisong Li <lihuisong@huawei.com> Reviewed-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru> Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com> libabigail raised a warning on this change. This change is fine wrt ABI as far as we understand, but we can't express an exception rule (see libabigail bug #28060) to waive the changes only in this part of the rte_eth_dev_data struct. The solution for now is to globally waive any change on the rte_eth_dev_data structure. Signed-off-by: David Marchand <david.marchand@redhat.com>
This commit is contained in:
parent
e7885281de
commit
02edbfab1e
@ -45,3 +45,10 @@
|
|||||||
[suppress_type]
|
[suppress_type]
|
||||||
name = rte_eth_txq_info
|
name = rte_eth_txq_info
|
||||||
has_data_member_inserted_between = {offset_after(nb_desc), end}
|
has_data_member_inserted_between = {offset_after(nb_desc), end}
|
||||||
|
|
||||||
|
; Ignore all changes to rte_eth_dev_data
|
||||||
|
; Note: we only cared about dev_configured bit addition, but libabigail
|
||||||
|
; seems to wrongly compute bitfields offset.
|
||||||
|
; https://sourceware.org/bugzilla/show_bug.cgi?id=28060
|
||||||
|
[suppress_type]
|
||||||
|
name = rte_eth_dev_data
|
||||||
|
@ -1356,6 +1356,13 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
|
|||||||
return -EBUSY;
|
return -EBUSY;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Ensure that "dev_configured" is always 0 each time prepare to do
|
||||||
|
* dev_configure() to avoid any non-anticipated behaviour.
|
||||||
|
* And set to 1 when dev_configure() is executed successfully.
|
||||||
|
*/
|
||||||
|
dev->data->dev_configured = 0;
|
||||||
|
|
||||||
/* Store original config, as rollback required on failure */
|
/* Store original config, as rollback required on failure */
|
||||||
memcpy(&orig_conf, &dev->data->dev_conf, sizeof(dev->data->dev_conf));
|
memcpy(&orig_conf, &dev->data->dev_conf, sizeof(dev->data->dev_conf));
|
||||||
|
|
||||||
@ -1605,6 +1612,7 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
|
|||||||
goto reset_queues;
|
goto reset_queues;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dev->data->dev_configured = 1;
|
||||||
rte_ethdev_trace_configure(port_id, nb_rx_q, nb_tx_q, dev_conf, 0);
|
rte_ethdev_trace_configure(port_id, nb_rx_q, nb_tx_q, dev_conf, 0);
|
||||||
return 0;
|
return 0;
|
||||||
reset_queues:
|
reset_queues:
|
||||||
@ -1751,6 +1759,13 @@ rte_eth_dev_start(uint16_t port_id)
|
|||||||
|
|
||||||
RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_start, -ENOTSUP);
|
RTE_FUNC_PTR_OR_ERR_RET(*dev->dev_ops->dev_start, -ENOTSUP);
|
||||||
|
|
||||||
|
if (dev->data->dev_configured == 0) {
|
||||||
|
RTE_ETHDEV_LOG(INFO,
|
||||||
|
"Device with port_id=%"PRIu16" is not configured.\n",
|
||||||
|
port_id);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
if (dev->data->dev_started != 0) {
|
if (dev->data->dev_started != 0) {
|
||||||
RTE_ETHDEV_LOG(INFO,
|
RTE_ETHDEV_LOG(INFO,
|
||||||
"Device with port_id=%"PRIu16" already started\n",
|
"Device with port_id=%"PRIu16" already started\n",
|
||||||
|
@ -167,7 +167,11 @@ struct rte_eth_dev_data {
|
|||||||
scattered_rx : 1, /**< RX of scattered packets is ON(1) / OFF(0) */
|
scattered_rx : 1, /**< RX of scattered packets is ON(1) / OFF(0) */
|
||||||
all_multicast : 1, /**< RX all multicast mode ON(1) / OFF(0). */
|
all_multicast : 1, /**< RX all multicast mode ON(1) / OFF(0). */
|
||||||
dev_started : 1, /**< Device state: STARTED(1) / STOPPED(0). */
|
dev_started : 1, /**< Device state: STARTED(1) / STOPPED(0). */
|
||||||
lro : 1; /**< RX LRO is ON(1) / OFF(0) */
|
lro : 1, /**< RX LRO is ON(1) / OFF(0) */
|
||||||
|
dev_configured : 1;
|
||||||
|
/**< Indicates whether the device is configured.
|
||||||
|
* CONFIGURED(1) / NOT CONFIGURED(0).
|
||||||
|
*/
|
||||||
uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT];
|
uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT];
|
||||||
/**< Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0). */
|
/**< Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0). */
|
||||||
uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT];
|
uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user