DPDK patches and discussions
 help / color / mirror / Atom feed
From: Shaiq Wani <shaiq.wani@intel.com>
To: dev@dpdk.org
Subject: [PATCH v2] net/cpfl: get running host ID for CPFL PMD
Date: Thu, 23 May 2024 06:10:45 +0000	[thread overview]
Message-ID: <20240523061045.483159-1-shaiq.wani@intel.com> (raw)

Check whether CPFL PMD runs on Host or ACC

Signed-off-by: Shaiq Wani <shaiq.wani@intel.com>
---
 drivers/net/cpfl/cpfl_ethdev.c | 21 +++++++++++++++++++++
 drivers/net/cpfl/cpfl_ethdev.h |  5 ++++-
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/drivers/net/cpfl/cpfl_ethdev.c b/drivers/net/cpfl/cpfl_ethdev.c
index ef19aa1b6a..cce7d8251c 100644
--- a/drivers/net/cpfl/cpfl_ethdev.c
+++ b/drivers/net/cpfl/cpfl_ethdev.c
@@ -14,6 +14,7 @@
 
 #include "cpfl_ethdev.h"
 #include <ethdev_private.h>
+#include <sys/utsname.h>
 #include "cpfl_rxtx.h"
 #include "cpfl_flow.h"
 #include "cpfl_rules.h"
@@ -2269,8 +2270,27 @@ cpfl_repr_allowlist_uninit(struct cpfl_adapter_ext *adapter)
 {
 	rte_hash_free(adapter->repr_allowlist_hash);
 }
+static uint8_t
+get_running_host_id(void)
+{
+	struct utsname unameData;
+	uint8_t host_id = CPFL_INVALID_HOST_ID;
+	uname(&unameData);
 
+	if (uname(&unameData) != 0) {
+		PMD_INIT_LOG(ERR, "Cannot fetch node_name for host\n");
+		return host_id;
+	}
+	/* get the first line */
+		if (strstr(unameData.nodename, "ipu_imc"))
+			PMD_INIT_LOG(ERR, "CPFL PMD cannot be running on IMC.");
+		else if (strstr(unameData.nodename, "ipu_acc"))
+			host_id = CPFL_HOST_ID_ACC;
+		else
+			host_id = CPFL_HOST_ID_HOST;
 
+	return host_id;
+}
 static int
 cpfl_adapter_ext_init(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *adapter,
 		      struct cpfl_devargs *devargs)
@@ -2289,6 +2309,7 @@ cpfl_adapter_ext_init(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *a
 	hw->vendor_id = pci_dev->id.vendor_id;
 	hw->device_id = pci_dev->id.device_id;
 	hw->subsystem_vendor_id = pci_dev->id.subsystem_vendor_id;
+	adapter->host_id = get_running_host_id();
 
 	strncpy(adapter->name, pci_dev->device.name, PCI_PRI_STR_SIZE);
 
diff --git a/drivers/net/cpfl/cpfl_ethdev.h b/drivers/net/cpfl/cpfl_ethdev.h
index 457db6d6be..3f6f9ca5ea 100644
--- a/drivers/net/cpfl/cpfl_ethdev.h
+++ b/drivers/net/cpfl/cpfl_ethdev.h
@@ -66,6 +66,7 @@
 #define CPFL_PF_TYPE_NUM	2
 #define CPFL_HOST_ID_HOST	0
 #define CPFL_HOST_ID_ACC	1
+#define CPFL_INVALID_HOST_ID    UINT8_MAX
 #define CPFL_PF_TYPE_APF	0
 #define CPFL_PF_TYPE_CPF	1
 
@@ -230,6 +231,7 @@ struct cpfl_adapter_ext {
 	uint8_t ctrl_vport_recv_info[IDPF_DFLT_MBX_BUF_SIZE];
 	struct idpf_ctlq_info *ctlqp[CPFL_CFGQ_NUM];
 	struct cpfl_ctlq_create_info cfgq_info[CPFL_CFGQ_NUM];
+	uint8_t host_id;
 };
 
 TAILQ_HEAD(cpfl_adapter_list, cpfl_adapter_ext);
@@ -296,7 +298,8 @@ cpfl_get_vsi_id(struct cpfl_itf *itf)
 
 		vport_identity.func_type = CPCHNL2_FTYPE_LAN_PF;
 		/* host: CPFL_HOST0_CPF_ID, acc: CPFL_ACC_CPF_ID */
-		vport_identity.pf_id = CPFL_ACC_CPF_ID;
+		vport_identity.pf_id = (itf->adapter->host_id == CPFL_HOST_ID_ACC) ?
+								CPFL_ACC_CPF_ID : CPFL_HOST0_CPF_ID;
 		vport_identity.vf_id = 0;
 		vport_identity.vport_id = vport_id;
 		ret = rte_hash_lookup_data(itf->adapter->vport_map_hash,
-- 
2.34.1


             reply	other threads:[~2024-05-23  6:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-23  6:10 Shaiq Wani [this message]
2024-05-23 14:52 ` Stephen Hemminger

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=20240523061045.483159-1-shaiq.wani@intel.com \
    --to=shaiq.wani@intel.com \
    --cc=dev@dpdk.org \
    /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).