DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH v3] net/cpfl: get running host ID for CPFL PMD
@ 2024-05-24  4:05 Shaiq Wani
  2024-05-30  9:39 ` [PATCH v4] " Shaiq Wani
  0 siblings, 1 reply; 7+ messages in thread
From: Shaiq Wani @ 2024-05-24  4:05 UTC (permalink / raw)
  To: dev

Check whether CPFL PMD runs on Host or ACC

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

diff --git a/drivers/net/cpfl/cpfl_ethdev.c b/drivers/net/cpfl/cpfl_ethdev.c
index ef19aa1b6a..05b52ed635 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,23 @@ 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;
 
+	if (uname(&unamedata) != 0)
+		PMD_INIT_LOG(ERR, "Cannot fetch node_name for host\n");
+	else 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 +2305,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


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

* [PATCH v4] net/cpfl: get running host ID for CPFL PMD
  2024-05-24  4:05 [PATCH v3] net/cpfl: get running host ID for CPFL PMD Shaiq Wani
@ 2024-05-30  9:39 ` Shaiq Wani
  2024-06-04 16:17   ` Stephen Hemminger
  2024-06-06 10:44   ` [PATCH v5] " Shaiq Wani
  0 siblings, 2 replies; 7+ messages in thread
From: Shaiq Wani @ 2024-05-30  9:39 UTC (permalink / raw)
  To: dev, bruce.richardson

Check whether CPFL PMD runs on Host or ACC

Signed-off-by: Shaiq Wani <shaiq.wani@intel.com>

---
v2 Changes:
-Changed implementation based on review comment.
v3 Changes:
-Fixed indentation and coding style.
v4 Changes:
-Fix ipu_imc and ipu_acc to ipu-imc and ipu-acc.
---
 drivers/net/cpfl/cpfl_ethdev.c | 17 +++++++++++++++++
 drivers/net/cpfl/cpfl_ethdev.h |  5 ++++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/drivers/net/cpfl/cpfl_ethdev.c b/drivers/net/cpfl/cpfl_ethdev.c
index ef19aa1b6a..87b1b124a1 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,23 @@ 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;
 
+	if (uname(&unamedata) != 0)
+		PMD_INIT_LOG(ERR, "Cannot fetch node_name for host\n");
+	else 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 +2305,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


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

* Re: [PATCH v4] net/cpfl: get running host ID for CPFL PMD
  2024-05-30  9:39 ` [PATCH v4] " Shaiq Wani
@ 2024-06-04 16:17   ` Stephen Hemminger
  2024-06-05  5:48     ` Wani, Shaiq
  2024-06-06 10:44   ` [PATCH v5] " Shaiq Wani
  1 sibling, 1 reply; 7+ messages in thread
From: Stephen Hemminger @ 2024-06-04 16:17 UTC (permalink / raw)
  To: Shaiq Wani; +Cc: dev, bruce.richardson

On Thu, 30 May 2024 09:39:58 +0000
Shaiq Wani <shaiq.wani@intel.com> wrote:

> +	if (uname(&unamedata) != 0)
> +		PMD_INIT_LOG(ERR, "Cannot fetch node_name for host\n");
> +	else 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;

The nodename in uname is the same as the hostname.
This can be changed by user, is that ok?

Also, please put one blank line between functions, it makes code easier to read.

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

* RE: [PATCH v4] net/cpfl: get running host ID for CPFL PMD
  2024-06-04 16:17   ` Stephen Hemminger
@ 2024-06-05  5:48     ` Wani, Shaiq
  2024-06-05 18:05       ` Stephen Hemminger
  0 siblings, 1 reply; 7+ messages in thread
From: Wani, Shaiq @ 2024-06-05  5:48 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: dev, Richardson, Bruce



> +	if (uname(&unamedata) != 0)
> +		PMD_INIT_LOG(ERR, "Cannot fetch node_name for host\n");
> +	else 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;

The nodename in uname is the same as the hostname.
This can be changed by user, is that ok?

We are making an assumption that user will not have hostname as ipu-acc or ipu-imc.
If this is okay, I will upload a new patch taking care of the blank line between the functions.

Also, please put one blank line between functions, it makes code easier to read.


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

* Re: [PATCH v4] net/cpfl: get running host ID for CPFL PMD
  2024-06-05  5:48     ` Wani, Shaiq
@ 2024-06-05 18:05       ` Stephen Hemminger
  0 siblings, 0 replies; 7+ messages in thread
From: Stephen Hemminger @ 2024-06-05 18:05 UTC (permalink / raw)
  To: Wani, Shaiq; +Cc: dev, Richardson, Bruce

On Wed, 5 Jun 2024 05:48:39 +0000
"Wani, Shaiq" <shaiq.wani@intel.com> wrote:

> > +	if (uname(&unamedata) != 0)
> > +		PMD_INIT_LOG(ERR, "Cannot fetch node_name for host\n");

No newline needed.

> > +	else 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;  
> 
> The nodename in uname is the same as the hostname.
> This can be changed by user, is that ok?
> 
> We are making an assumption that user will not have hostname as ipu-acc or ipu-imc.
> If this is okay, I will upload a new patch taking care of the blank line between the functions.
> 
> Also, please put one blank line between functions, it makes code easier to read.
> 

The blank line is not important, but there is something that is worth adding.
Could you add something to the NIC documentation and/or release notes if necessary.

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

* [PATCH v5] net/cpfl: get running host ID for CPFL PMD
  2024-05-30  9:39 ` [PATCH v4] " Shaiq Wani
  2024-06-04 16:17   ` Stephen Hemminger
@ 2024-06-06 10:44   ` Shaiq Wani
  2024-06-13 15:36     ` Stephen Hemminger
  1 sibling, 1 reply; 7+ messages in thread
From: Shaiq Wani @ 2024-06-06 10:44 UTC (permalink / raw)
  To: dev

Check whether CPFL PMD runs on Host or ACC

---
v2 Changes:
-Changed implementation based on review comment.
v3 Changes:
-Fixed indentation.
v4 Changes:
-Fix ipu_imc and ipu_acc to ipu-imc and ipu-acc.
v5 Changes:
-Updated the documentation with the changes implemented
 in this patch.
---

Signed-off-by: Shaiq Wani <shaiq.wani@intel.com>
---
 doc/guides/nics/cpfl.rst       |  3 +++
 drivers/net/cpfl/cpfl_ethdev.c | 19 +++++++++++++++++++
 drivers/net/cpfl/cpfl_ethdev.h |  5 ++++-
 3 files changed, 26 insertions(+), 1 deletion(-)

diff --git a/doc/guides/nics/cpfl.rst b/doc/guides/nics/cpfl.rst
index 9b7a99c894..3430ac7398 100644
--- a/doc/guides/nics/cpfl.rst
+++ b/doc/guides/nics/cpfl.rst
@@ -150,6 +150,9 @@ Runtime Configuration
   Then the PMD will load json file for device ``ca:00.0``.
   The parameter is optional.
 
+  As CPFL PMD can run on both XEON host and IPU's ACC, the driver dynamically detects
+  which system it is running on using get_running_host_id functionality.
+
 Driver compilation and testing
 ------------------------------
 
diff --git a/drivers/net/cpfl/cpfl_ethdev.c b/drivers/net/cpfl/cpfl_ethdev.c
index ef19aa1b6a..4e9fea9643 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"
@@ -2270,6 +2271,23 @@ 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;
+
+	if (uname(&unamedata) != 0)
+		PMD_INIT_LOG(ERR, "Cannot fetch node_name for host\n");
+	else 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,
@@ -2289,6 +2307,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


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

* Re: [PATCH v5] net/cpfl: get running host ID for CPFL PMD
  2024-06-06 10:44   ` [PATCH v5] " Shaiq Wani
@ 2024-06-13 15:36     ` Stephen Hemminger
  0 siblings, 0 replies; 7+ messages in thread
From: Stephen Hemminger @ 2024-06-13 15:36 UTC (permalink / raw)
  To: Shaiq Wani; +Cc: dev

On Thu,  6 Jun 2024 10:44:22 +0000
Shaiq Wani <shaiq.wani@intel.com> wrote:

> Check whether CPFL PMD runs on Host or ACC
> 
> ---
> v2 Changes:
> -Changed implementation based on review comment.
> v3 Changes:
> -Fixed indentation.
> v4 Changes:
> -Fix ipu_imc and ipu_acc to ipu-imc and ipu-acc.
> v5 Changes:
> -Updated the documentation with the changes implemented
>  in this patch.
> ---
> 
> Signed-off-by: Shaiq Wani <shaiq.wani@intel.com>
> ---
Acked-by: Stephen Hemminger <stephen@networkplumber.org>

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

end of thread, other threads:[~2024-06-13 15:36 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-24  4:05 [PATCH v3] net/cpfl: get running host ID for CPFL PMD Shaiq Wani
2024-05-30  9:39 ` [PATCH v4] " Shaiq Wani
2024-06-04 16:17   ` Stephen Hemminger
2024-06-05  5:48     ` Wani, Shaiq
2024-06-05 18:05       ` Stephen Hemminger
2024-06-06 10:44   ` [PATCH v5] " Shaiq Wani
2024-06-13 15:36     ` Stephen Hemminger

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).