DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH v1] net/cpfl: check if DPDK is running on host IMC ACC
@ 2024-05-16  8:12 Shaiq Wani
  2024-05-16  8:24 ` David Marchand
  0 siblings, 1 reply; 2+ messages in thread
From: Shaiq Wani @ 2024-05-16  8:12 UTC (permalink / raw)
  To: dev

Checks if DPDK is running on host, IMC or ACC

Signed-off-by: Shaiq Wani <shaiqwani@intel.com>
---
 get_running_host_id.patch | 70 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 70 insertions(+)
 create mode 100644 get_running_host_id.patch

diff --git a/get_running_host_id.patch b/get_running_host_id.patch
new file mode 100644
index 0000000000..32aa3445ab
--- /dev/null
+++ b/get_running_host_id.patch
@@ -0,0 +1,70 @@
+diff --git a/drivers/net/cpfl/cpfl_ethdev.c b/drivers/net/cpfl/cpfl_ethdev.c
+index ef19aa1b6a..cc708039da 100644
+--- a/drivers/net/cpfl/cpfl_ethdev.c
++++ b/drivers/net/cpfl/cpfl_ethdev.c
+@@ -2270,6 +2270,33 @@ cpfl_repr_allowlist_uninit(struct cpfl_adapter_ext *adapter)
+	rte_hash_free(adapter->repr_allowlist_hash);
+}
++static uint8_t
++get_running_host_id(void)
++{
++	char buf[BUFSIZ];
++	FILE *fd;
++	uint8_t host_id = CPFL_INVALID_HOST_ID;
++
++	fd = fopen("/etc/issue.net", "r");
++	if (fd == NULL) {
++		PMD_INIT_LOG(ERR, "Cannot open /etc/issue.net\n");
++		return host_id;
++	}
++
++	if (fgets(buf, sizeof(buf), fd)) {
++		/* get the first line */
++		if (strstr(buf, "IMC")) {
++			PMD_INIT_LOG(ERR, "CPFL PMD cannot running on IMC.");
++		} else if (strstr(buf, "ACC")) {
++			host_id = CPFL_HOST_ID_ACC;
++		} else {
++			host_id = CPFL_HOST_ID_HOST;
++		}
++	}
++
++	fclose(fd);
++	return host_id;
++}
+static int
+cpfl_adapter_ext_init(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *adapter,
+@@ -2290,6 +2317,7 @@ cpfl_adapter_ext_init(struct rte_pci_device *pci_dev, struct cpfl_adapter_ext *a
+	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);
+	rte_memcpy(&base->caps, &req_caps, sizeof(struct virtchnl2_get_capabilities));
+diff --git a/drivers/net/cpfl/cpfl_ethdev.h b/drivers/net/cpfl/cpfl_ethdev.h
+index 457db6d6be..3987afbd82 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,8 @@ 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 +299,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,
\ No newline at end of file
-- 
2.34.1


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

* Re: [PATCH v1] net/cpfl: check if DPDK is running on host IMC ACC
  2024-05-16  8:12 [PATCH v1] net/cpfl: check if DPDK is running on host IMC ACC Shaiq Wani
@ 2024-05-16  8:24 ` David Marchand
  0 siblings, 0 replies; 2+ messages in thread
From: David Marchand @ 2024-05-16  8:24 UTC (permalink / raw)
  To: Shaiq Wani; +Cc: dev

Hello Shaiq,

On Thu, May 16, 2024 at 10:17 AM Shaiq Wani <shaiqwani@intel.com> wrote:
>
> Checks if DPDK is running on host, IMC or ACC
>
> Signed-off-by: Shaiq Wani <shaiqwani@intel.com>

Thanks for the patch, though there are issues with this submission, as
this patch can't be applied.

Please make sure you are registered to this mailing list and have a
look at the contributing guide.
https://doc.dpdk.org/guides/contributing/patches.html


-- 
David Marchand


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

end of thread, other threads:[~2024-05-16  8:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-16  8:12 [PATCH v1] net/cpfl: check if DPDK is running on host IMC ACC Shaiq Wani
2024-05-16  8:24 ` David Marchand

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