On Thu, Jun 06, 2024 at 10:44:22AM +0000, Shaiq Wani 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.w...@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. > +
Lines in rst text follow slightly different wrapping rules to the code - we generally try and wrap them at punctuation breaks. Also, the function name "get_running_host_id" is not meaningful in end-user docs like this, so it should be reworded to "by querying the hostname", which is a description of what the function in question does. Will fix on apply. > 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 Very minor nit: the indentation here is different to that on the surrounding lines - they use tabs, while the new line uses spaces. Again, I can fix this on apply. Thanks, /Bruce