From: Ivan Malov <ivan.malov@arknetworks.am>
To: dev@dpdk.org
Cc: Viacheslav Galaktionov <viacheslav.galaktionov@arknetworks.am>,
Roman Zhukov <Roman.Zhukov@arknetworks.am>,
Pieter Jansen van Vuuren <pieter.jansen-van-vuuren@amd.com>,
Stephen Hemminger <stephen@networkplumber.org>,
Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Subject: [PATCH v3 2/2] net/sfc: provide cached dev info to use in secondary process
Date: Sat, 22 Aug 2026 04:06:46 +0400 [thread overview]
Message-ID: <20260822000646.12718-3-ivan.malov@arknetworks.am> (raw)
In-Reply-To: <20260822000646.12718-1-ivan.malov@arknetworks.am>
Secondary process support in the 'test-pmd' application now requires that
the driver expose the 'dev_infos_get' method within that context. Use the
cached dev info from the primary process in order to meet the requirement.
Signed-off-by: Ivan Malov <ivan.malov@arknetworks.am>
Reviewed-by: Viacheslav Galaktionov <viacheslav.galaktionov@arknetworks.am>
---
drivers/net/sfc/sfc.h | 19 ++++++++++++++
drivers/net/sfc/sfc_ethdev.c | 48 ++++++++++++++++++++++++++++++++++++
2 files changed, 67 insertions(+)
diff --git a/drivers/net/sfc/sfc.h b/drivers/net/sfc/sfc.h
index 629578549f..809ad59148 100644
--- a/drivers/net/sfc/sfc.h
+++ b/drivers/net/sfc/sfc.h
@@ -156,6 +156,25 @@ struct sfc_adapter_shared {
unsigned int nb_repr_txq;
struct sfc_nic_dma_info nic_dma_info;
+
+ /*
+ * Snapshot of the 'rte_eth_dev_info_get' output created by the primary
+ * process attach path for the secondary process to use in its own
+ * implementation of the 'dev_infos_get' method.
+ *
+ * Some driver-computed fields derived from mutable post-attach state
+ * are knowingly stale, which is acceptable for the secondary process.
+ *
+ * This also contains a handful of stale fields which are normally
+ * set by the ethdev layer upon invocation of the 'dev_infos_get',
+ * so they will be overridden anyway in the secondary process.
+ */
+ struct rte_eth_dev_info dev_info_cache;
+ /*
+ * Set to 'true' by the probe function from the primary process. The
+ * secondary 'dev_infos_get' returns '-EAGAIN' when this is 'false'.
+ */
+ RTE_ATOMIC(bool) dev_info_cache_is_valid;
};
/* Adapter process private data */
diff --git a/drivers/net/sfc/sfc_ethdev.c b/drivers/net/sfc/sfc_ethdev.c
index 13619b4b9a..a02697a7cd 100644
--- a/drivers/net/sfc/sfc_ethdev.c
+++ b/drivers/net/sfc/sfc_ethdev.c
@@ -16,7 +16,9 @@
#include <bus_pci_driver.h>
#include <rte_errno.h>
#include <rte_string_fns.h>
+#include <rte_stdatomic.h>
#include <rte_bitops.h>
+#include <rte_ethdev.h>
#include <rte_ether.h>
#include "efx.h"
@@ -3163,7 +3165,32 @@ sfc_eth_dev_clear_ops(struct rte_eth_dev *dev)
sa->priv.dp_rx = NULL;
}
+static int
+sfc_dev_infos_get_secondary(struct rte_eth_dev *dev,
+ struct rte_eth_dev_info *dev_info)
+{
+ const struct sfc_adapter_shared *sas =
+ sfc_adapter_shared_by_eth_dev(dev);
+ bool valid = rte_atomic_load_explicit(&sas->dev_info_cache_is_valid,
+ rte_memory_order_acquire);
+
+ if (!valid)
+ return -EAGAIN;
+
+ *dev_info = sas->dev_info_cache;
+
+ /*
+ * The cache holds stale primary-process pointers; restore
+ * the process-local values from the caller-supplied 'dev'.
+ */
+ if (dev_info->switch_info.name != NULL)
+ dev_info->switch_info.name = dev->device->driver->name;
+ dev_info->device = dev->device;
+ return 0;
+}
+
static const struct eth_dev_ops sfc_eth_dev_secondary_ops = {
+ .dev_infos_get = sfc_dev_infos_get_secondary,
.dev_supported_ptypes_get = sfc_dev_supported_ptypes_get,
.reta_query = sfc_dev_rss_reta_query,
.rss_hash_conf_get = sfc_dev_rss_hash_conf_get,
@@ -3787,6 +3814,27 @@ static int sfc_eth_dev_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
if (rc != 0)
return rc;
+ if (rte_eal_process_type() == RTE_PROC_PRIMARY) {
+ struct sfc_adapter *sa = sfc_adapter_by_eth_dev(dev);
+ struct sfc_adapter_shared *sas =
+ sfc_adapter_shared_by_eth_dev(dev);
+
+ /*
+ * Pre-fill the dev info cache for the secondary
+ * process. The port has been registered at this
+ * point, allowing use of the public API.
+ */
+ rc = rte_eth_dev_info_get(dev->data->port_id,
+ &sas->dev_info_cache);
+ if (rc == 0) {
+ sas->dev_info_cache.device = NULL;
+ rte_atomic_store_explicit(&sas->dev_info_cache_is_valid,
+ true, rte_memory_order_release);
+ } else {
+ sfc_warn(sa, "failed to cache dev info for the secondary process");
+ }
+ }
+
rc = sfc_eth_dev_create_representors(dev, ð_da);
if (rc != 0) {
if (dev_created)
--
2.47.3
prev parent reply other threads:[~2026-08-22 0:07 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-20 13:03 [PATCH 0/2] net/sfc: fix and extend secondary process support Ivan Malov
2026-08-20 13:03 ` [PATCH 1/2] net/sfc: fix shared adapter pointer set in secondary process Ivan Malov
2026-08-21 19:09 ` Stephen Hemminger
2026-08-20 13:03 ` [PATCH 2/2] net/sfc: provide cached dev info to use " Ivan Malov
2026-08-21 19:10 ` Stephen Hemminger
2026-08-21 23:45 ` [PATCH v2 0/2] net/sfc: fix and extend secondary process support Ivan Malov
2026-08-21 23:45 ` [PATCH v2 1/2] net/sfc: fix shared adapter pointer set in secondary process Ivan Malov
2026-08-21 23:45 ` [PATCH v2 2/2] net/sfc: provide cached dev info to use " Ivan Malov
2026-08-22 0:06 ` [PATCH v3 0/2] net/sfc: fix and extend secondary process support Ivan Malov
2026-08-22 0:06 ` [PATCH v3 1/2] net/sfc: fix shared adapter pointer set in secondary process Ivan Malov
2026-08-22 0:06 ` Ivan Malov [this message]
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=20260822000646.12718-3-ivan.malov@arknetworks.am \
--to=ivan.malov@arknetworks.am \
--cc=Roman.Zhukov@arknetworks.am \
--cc=andrew.rybchenko@oktetlabs.ru \
--cc=dev@dpdk.org \
--cc=pieter.jansen-van-vuuren@amd.com \
--cc=stephen@networkplumber.org \
--cc=viacheslav.galaktionov@arknetworks.am \
/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