DPDK patches and discussions
 help / color / mirror / Atom feed
From: Dariusz Sosnowski <dsosnowski@nvidia.com>
To: Thomas Monjalon <thomas@monjalon.net>,
	Ferruh Yigit <ferruh.yigit@amd.com>,
	Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Cc: <dev@dpdk.org>, Konstantin Ananyev <konstantin.ananyev@huawei.com>
Subject: [PATCH v3 2/4] ethdev: add get restore flags driver callback
Date: Fri, 11 Oct 2024 20:51:35 +0200	[thread overview]
Message-ID: <20241011185137.277874-3-dsosnowski@nvidia.com> (raw)
In-Reply-To: <20241011185137.277874-1-dsosnowski@nvidia.com>

Before this patch, ethdev layer assumed that all drivers require that
it has to forcefully restore:

- MAC addresses
- promiscuous mode setting
- all multicast mode setting

upon rte_eth_dev_start().

This patch introduces a new callback to eth_dev_ops -
get_restore_flags().
Drivers implementing this callback can explicitly enable/disable
certain parts of config restore procedure.

In order to minimize the changes to all the drivers and
preserve the current behavior, it is assumed that
if this callback is not defined, all configuration should be restored.

Signed-off-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
---
 lib/ethdev/ethdev_driver.c |  9 ++++++
 lib/ethdev/ethdev_driver.h | 66 ++++++++++++++++++++++++++++++++++++++
 lib/ethdev/version.map     |  1 +
 3 files changed, 76 insertions(+)

diff --git a/lib/ethdev/ethdev_driver.c b/lib/ethdev/ethdev_driver.c
index c335a25a82..9afef06431 100644
--- a/lib/ethdev/ethdev_driver.c
+++ b/lib/ethdev/ethdev_driver.c
@@ -958,3 +958,12 @@ rte_eth_switch_domain_free(uint16_t domain_id)
 
 	return 0;
 }
+
+uint64_t
+rte_eth_get_restore_flags(struct rte_eth_dev *dev, enum rte_eth_dev_operation op)
+{
+	if (dev->dev_ops->get_restore_flags != NULL)
+		return dev->dev_ops->get_restore_flags(dev, op);
+	else
+		return RTE_ETH_RESTORE_ALL;
+}
diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h
index ae00ead865..3974512a5c 100644
--- a/lib/ethdev/ethdev_driver.h
+++ b/lib/ethdev/ethdev_driver.h
@@ -1235,6 +1235,48 @@ typedef int (*eth_count_aggr_ports_t)(struct rte_eth_dev *dev);
 typedef int (*eth_map_aggr_tx_affinity_t)(struct rte_eth_dev *dev, uint16_t tx_queue_id,
 					  uint8_t affinity);
 
+/**
+ * @internal
+ * Defines types of operations which can be executed by the application.
+ */
+enum rte_eth_dev_operation {
+	RTE_ETH_START,
+};
+
+/**@{@name Restore flags
+ * Flags returned by get_restore_flags() callback.
+ * They indicate to ethdev layer which configuration is required to be restored.
+ */
+/** If set, ethdev layer will forcefully restore default and any other added MAC addresses. */
+#define RTE_ETH_RESTORE_MAC_ADDR RTE_BIT64(0)
+/** If set, ethdev layer will forcefully restore current promiscuous mode setting. */
+#define RTE_ETH_RESTORE_PROMISC  RTE_BIT64(1)
+/** If set, ethdev layer will forcefully restore current all multicast mode setting. */
+#define RTE_ETH_RESTORE_ALLMULTI RTE_BIT64(2)
+/**@}*/
+
+/** All configuration which can be restored by ethdev layer. */
+#define RTE_ETH_RESTORE_ALL (RTE_ETH_RESTORE_MAC_ADDR | \
+			     RTE_ETH_RESTORE_PROMISC | \
+			     RTE_ETH_RESTORE_ALLMULTI)
+
+/**
+ * @internal
+ * Fetch from the driver what kind of configuration must be restored by ethdev layer,
+ * after certain operations are performed by the application (such as rte_eth_dev_start()).
+ *
+ * @param dev
+ *   Port (ethdev) handle.
+ * @param op
+ *   Type of operation executed by the application.
+ *
+ * @return
+ *   ORed restore flags indicating which configuration should be restored by ethdev.
+ *   0 if no restore is required by the driver.
+ */
+typedef uint64_t (*eth_get_restore_flags_t)(struct rte_eth_dev *dev,
+					    enum rte_eth_dev_operation op);
+
 /**
  * @internal A structure containing the functions exported by an Ethernet driver.
  */
@@ -1474,6 +1516,9 @@ struct eth_dev_ops {
 	eth_count_aggr_ports_t count_aggr_ports;
 	/** Map a Tx queue with an aggregated port of the DPDK port */
 	eth_map_aggr_tx_affinity_t map_aggr_tx_affinity;
+
+	/** Get configuration which ethdev should restore */
+	eth_get_restore_flags_t get_restore_flags;
 };
 
 /**
@@ -2131,6 +2176,27 @@ struct rte_eth_fdir_conf {
 	struct rte_eth_fdir_flex_conf flex_conf;
 };
 
+/**
+ * @internal
+ * Fetch from the driver what kind of configuration must be restored by ethdev layer,
+ * using get_restore_flags() callback.
+ *
+ * If callback is not defined, it is assumed that all supported configuration must be restored.
+ *
+ * @param dev
+ *   Port (ethdev) handle.
+ * @param op
+ *   Type of operation executed by the application.
+ *
+ * @return
+ *   ORed restore flags indicating which configuration should be restored by ethdev.
+ *   0 if no restore is required by the driver.
+ */
+__rte_internal
+uint64_t
+rte_eth_get_restore_flags(struct rte_eth_dev *dev,
+			  enum rte_eth_dev_operation op);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map
index 1669055ca5..fa0469e602 100644
--- a/lib/ethdev/version.map
+++ b/lib/ethdev/version.map
@@ -358,4 +358,5 @@ INTERNAL {
 	rte_eth_switch_domain_alloc;
 	rte_eth_switch_domain_free;
 	rte_flow_fp_default_ops;
+	rte_eth_get_restore_flags;
 };
-- 
2.39.5


  parent reply	other threads:[~2024-10-11 18:52 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-11  9:20 [PATCH 0/4] ethdev: rework config restore Dariusz Sosnowski
2024-10-11  9:21 ` [PATCH 1/4] " Dariusz Sosnowski
2024-10-11  9:21 ` [PATCH 2/4] ethdev: add get restore flags driver callback Dariusz Sosnowski
2024-10-11  9:21 ` [PATCH 3/4] ethdev: restore config only when requested Dariusz Sosnowski
2024-10-11  9:21 ` [PATCH 4/4] net/mlx5: disable config restore Dariusz Sosnowski
2024-10-11  9:33 ` [PATCH v2 0/4] ethdev: rework " Dariusz Sosnowski
2024-10-11  9:33   ` [PATCH v2 1/4] " Dariusz Sosnowski
2024-10-11  9:33   ` [PATCH v2 2/4] ethdev: add get restore flags driver callback Dariusz Sosnowski
2024-10-11 12:54     ` Konstantin Ananyev
2024-10-11 15:30       ` Dariusz Sosnowski
2024-10-11  9:33   ` [PATCH v2 3/4] ethdev: restore config only when requested Dariusz Sosnowski
2024-10-11  9:33   ` [PATCH v2 4/4] net/mlx5: disable config restore Dariusz Sosnowski
2024-10-11 18:51   ` [PATCH v3 0/4] ethdev: rework " Dariusz Sosnowski
2024-10-11 18:51     ` [PATCH v3 1/4] " Dariusz Sosnowski
2024-10-11 18:51     ` Dariusz Sosnowski [this message]
2024-10-11 18:51     ` [PATCH v3 3/4] ethdev: restore config only when requested Dariusz Sosnowski
2024-10-11 18:51     ` [PATCH v3 4/4] net/mlx5: disable config restore Dariusz Sosnowski
2024-10-11 21:25     ` [PATCH v3 0/4] ethdev: rework " Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241011185137.277874-3-dsosnowski@nvidia.com \
    --to=dsosnowski@nvidia.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@amd.com \
    --cc=konstantin.ananyev@huawei.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).