All of lore.kernel.org
 help / color / mirror / Atom feed
* [dpdk-dev] [RFC] lib/ethdev: add dev configured flag
@ 2021-05-08  8:00 Huisong Li
  2021-05-31  8:51 ` Huisong Li
                   ` (5 more replies)
  0 siblings, 6 replies; 33+ messages in thread
From: Huisong Li @ 2021-05-08  8:00 UTC (permalink / raw)
  To: dev; +Cc: ferruh.yigit

Currently, if dev_configure is not invoked or fails to be invoked, users
can still invoke dev_start successfully. This patch adds a "dev_configured"
flag in "rte_eth_dev_data" to control whether dev_start can be invoked.

Signed-off-by: Huisong Li <lihuisong@huawei.com>
---
 lib/ethdev/rte_ethdev.c      | 11 +++++++++++
 lib/ethdev/rte_ethdev_core.h |  6 +++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
index a187976..7d74b17 100644
--- a/lib/ethdev/rte_ethdev.c
+++ b/lib/ethdev/rte_ethdev.c
@@ -1604,6 +1604,8 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 	}
 
 	rte_ethdev_trace_configure(port_id, nb_rx_q, nb_tx_q, dev_conf, 0);
+	dev->data->dev_configured = 1;
+
 	return 0;
 reset_queues:
 	eth_dev_rx_queue_config(dev, 0);
@@ -1614,6 +1616,8 @@ rte_eth_dev_configure(uint16_t port_id, uint16_t nb_rx_q, uint16_t nb_tx_q,
 		dev->data->mtu = old_mtu;
 
 	rte_ethdev_trace_configure(port_id, nb_rx_q, nb_tx_q, dev_conf, ret);
+	dev->data->dev_configured = 0;
+
 	return ret;
 }
 
@@ -1749,6 +1753,13 @@ rte_eth_dev_start(uint16_t port_id)
 
 	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) {
 		RTE_ETHDEV_LOG(INFO,
 			"Device with port_id=%"PRIu16" already started\n",
diff --git a/lib/ethdev/rte_ethdev_core.h b/lib/ethdev/rte_ethdev_core.h
index 4679d94..b508769 100644
--- a/lib/ethdev/rte_ethdev_core.h
+++ b/lib/ethdev/rte_ethdev_core.h
@@ -167,7 +167,11 @@ struct rte_eth_dev_data {
 		scattered_rx : 1,  /**< RX of scattered packets is ON(1) / OFF(0) */
 		all_multicast : 1, /**< RX all multicast mode ON(1) / OFF(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;
+		/**< Device configuration state:
+		 * CONFIGURED(1) / NOT CONFIGURED(0).
+		 */
 	uint8_t rx_queue_state[RTE_MAX_QUEUES_PER_PORT];
 		/**< Queues state: HAIRPIN(2) / STARTED(1) / STOPPED(0). */
 	uint8_t tx_queue_state[RTE_MAX_QUEUES_PER_PORT];
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2021-07-08  9:57 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-08  8:00 [dpdk-dev] [RFC] lib/ethdev: add dev configured flag Huisong Li
2021-05-31  8:51 ` Huisong Li
2021-06-14 15:37 ` Andrew Rybchenko
2021-06-29  2:27   ` Huisong Li
2021-07-02 10:08     ` Andrew Rybchenko
2021-07-02 11:57       ` Ferruh Yigit
2021-07-02 13:23         ` Ananyev, Konstantin
2021-07-03  8:35           ` Huisong Li
2021-07-03 11:04             ` Ananyev, Konstantin
2021-07-05  3:03               ` Huisong Li
2021-07-05  9:50                 ` Andrew Rybchenko
2021-07-05 11:22                   ` Ananyev, Konstantin
2021-07-06  1:47                     ` Huisong Li
2021-07-04 20:05 ` Thomas Monjalon
2021-07-05  3:18   ` Huisong Li
2021-07-05  6:07     ` Thomas Monjalon
2021-07-05  9:50       ` Andrew Rybchenko
2021-07-06  1:48         ` Huisong Li
2021-07-06  3:24 ` [dpdk-dev] [PATCH V1] ethdev: " Huisong Li
2021-07-06  4:10 ` [dpdk-dev] [PATCH V2] " Huisong Li
2021-07-06  8:36   ` Andrew Rybchenko
2021-07-07  2:55     ` Huisong Li
2021-07-07  8:25       ` Andrew Rybchenko
2021-07-07  9:26         ` Huisong Li
2021-07-07  7:39     ` David Marchand
2021-07-07  8:23       ` Andrew Rybchenko
2021-07-07  9:36         ` David Marchand
2021-07-07  9:59           ` Thomas Monjalon
2021-07-07 10:40             ` David Marchand
2021-07-07 10:57               ` Thomas Monjalon
2021-07-06 17:49   ` Ananyev, Konstantin
2021-07-07  9:53 ` [dpdk-dev] [PATCH V3] " Huisong Li
2021-07-08  9:56   ` David Marchand

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.