diff mbox series

[v2] net/axgbe: use PCI root complex device to distinguish AMD hardware

Message ID 20211202161034.519226-1-chandu@amd.com (mailing list archive)
State Accepted
Delegated to: Ferruh Yigit
Headers show
Series [v2] net/axgbe: use PCI root complex device to distinguish AMD hardware | expand

Checks

Context Check Description
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Namburu, Chandu-babu Dec. 2, 2021, 4:10 p.m. UTC
"bus/pci: optimize bus scan" broke axgbe on V1000/R1000.
RV root complex pci device does not have any kernel driver assigned
so it is removed from pci scan list which is used in
"net/axgbe: add a HW quirk for register definitions".

Get root complex device id directly from pci sysfs instead of
pci scan list.

Fixes: 991e0b1dbc4a (net/axgbe: add a HW quirk for register definitions)
Cc: stable@dpdk.org

Signed-off-by: Chandubabu Namburu <chandu@amd.com>
---
 drivers/net/axgbe/axgbe_ethdev.c | 39 ++++++++++++++++----------------
 1 file changed, 20 insertions(+), 19 deletions(-)

Comments

Namburu, Chandu-babu Dec. 22, 2021, 9:27 a.m. UTC | #1
[Public]

Hi David Marchand,

I have submitted v2 patch with your suggestion in git log. Please review changes.

Regards,
Chandu

-----Original Message-----
From: Namburu, Chandu-babu <chandu@amd.com> 
Sent: Thursday, December 2, 2021 9:41 PM
To: dev@dpdk.org; david.marchand@redhat.com
Cc: Sebastian, Selwin <Selwin.Sebastian@amd.com>; Arsalan_Awan@mentor.com; ferruh.yigit@intel.com; Namburu, Chandu-babu <chandu@amd.com>; stable@dpdk.org
Subject: [PATCH v2] net/axgbe: use PCI root complex device to distinguish AMD hardware

"bus/pci: optimize bus scan" broke axgbe on V1000/R1000.
RV root complex pci device does not have any kernel driver assigned so it is removed from pci scan list which is used in
"net/axgbe: add a HW quirk for register definitions".

Get root complex device id directly from pci sysfs instead of pci scan list.

Fixes: 991e0b1dbc4a (net/axgbe: add a HW quirk for register definitions)
Cc: stable@dpdk.org

Signed-off-by: Chandubabu Namburu <chandu@amd.com>
---
 drivers/net/axgbe/axgbe_ethdev.c | 39 ++++++++++++++++----------------
 1 file changed, 20 insertions(+), 19 deletions(-)

diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c
index 7d40c18a86..7b8d94ca3c 100644
--- a/drivers/net/axgbe/axgbe_ethdev.c
+++ b/drivers/net/axgbe/axgbe_ethdev.c
@@ -10,6 +10,8 @@
 #include "axgbe_regs.h"
 #include "rte_time.h"
 
+#include "eal_filesystem.h"
+
 static int eth_axgbe_dev_init(struct rte_eth_dev *eth_dev);  static int  axgbe_dev_configure(struct rte_eth_dev *dev);  static int  axgbe_dev_start(struct rte_eth_dev *dev); @@ -2117,28 +2119,27 @@ static void axgbe_default_config(struct axgbe_port *pdata)
 	pdata->power_down = 0;
 }
 
-static int
-pci_device_cmp(const struct rte_device *dev, const void *_pci_id)
+/*
+ * Return PCI root complex device id on success else 0  */ static 
+uint16_t
+get_pci_rc_devid(void)
 {
-	const struct rte_pci_device *pdev = RTE_DEV_TO_PCI_CONST(dev);
-	const struct rte_pci_id *pcid = _pci_id;
+	char pci_sysfs[PATH_MAX];
+	const struct rte_pci_addr pci_rc_addr = {0, 0, 0, 0};
+	unsigned long device_id;
 
-	if (pdev->id.vendor_id == AMD_PCI_VENDOR_ID &&
-			pdev->id.device_id == pcid->device_id)
-		return 0;
-	return 1;
-}
+	snprintf(pci_sysfs, sizeof(pci_sysfs), "%s/" PCI_PRI_FMT "/device",
+		 rte_pci_get_sysfs_path(), pci_rc_addr.domain,
+		 pci_rc_addr.bus, pci_rc_addr.devid, pci_rc_addr.function);
 
-static bool
-pci_search_device(int device_id)
-{
-	struct rte_bus *pci_bus;
-	struct rte_pci_id dev_id;
+	/* get device id */
+	if (eal_parse_sysfs_value(pci_sysfs, &device_id) < 0) {
+		PMD_INIT_LOG(ERR, "Error in reading PCI sysfs\n");
+		return 0;
+	}
 
-	dev_id.device_id = device_id;
-	pci_bus = rte_bus_find_by_name("pci");
-	return (pci_bus != NULL) &&
-		(pci_bus->find_device(NULL, pci_device_cmp, &dev_id) != NULL);
+	return (uint16_t)device_id;
 }
 
 /*
@@ -2180,7 +2181,7 @@ eth_axgbe_dev_init(struct rte_eth_dev *eth_dev)
 	/*
 	 * Use root complex device ID to differentiate RV AXGBE vs SNOWY AXGBE
 	 */
-	if (pci_search_device(AMD_PCI_RV_ROOT_COMPLEX_ID)) {
+	if ((get_pci_rc_devid()) == AMD_PCI_RV_ROOT_COMPLEX_ID) {
 		pdata->xpcs_window_def_reg = PCS_V2_RV_WINDOW_DEF;
 		pdata->xpcs_window_sel_reg = PCS_V2_RV_WINDOW_SELECT;
 	} else {
--
2.25.1
Namburu, Chandu-babu Jan. 10, 2022, 6:38 a.m. UTC | #2
[Public]

Hi,

Gentle reminder.

This is patch is required to submit changes for new AMD products. Please review and let us know if any modification are required.

Regards,
Chandu

-----Original Message-----
From: Namburu, Chandu-babu 
Sent: Wednesday, December 22, 2021 2:58 PM
To: dev@dpdk.org; david.marchand@redhat.com; ferruh.yigit@intel.com
Cc: Sebastian, Selwin <Selwin.Sebastian@amd.com>; Arsalan_Awan@mentor.com; stable@dpdk.org
Subject: RE: [PATCH v2] net/axgbe: use PCI root complex device to distinguish AMD hardware

[Public]

Hi David Marchand,

I have submitted v2 patch with your suggestion in git log. Please review changes.

Regards,
Chandu

-----Original Message-----
From: Namburu, Chandu-babu <chandu@amd.com>
Sent: Thursday, December 2, 2021 9:41 PM
To: dev@dpdk.org; david.marchand@redhat.com
Cc: Sebastian, Selwin <Selwin.Sebastian@amd.com>; Arsalan_Awan@mentor.com; ferruh.yigit@intel.com; Namburu, Chandu-babu <chandu@amd.com>; stable@dpdk.org
Subject: [PATCH v2] net/axgbe: use PCI root complex device to distinguish AMD hardware

"bus/pci: optimize bus scan" broke axgbe on V1000/R1000.
RV root complex pci device does not have any kernel driver assigned so it is removed from pci scan list which is used in
"net/axgbe: add a HW quirk for register definitions".

Get root complex device id directly from pci sysfs instead of pci scan list.

Fixes: 991e0b1dbc4a (net/axgbe: add a HW quirk for register definitions)
Cc: stable@dpdk.org

Signed-off-by: Chandubabu Namburu <chandu@amd.com>
---
 drivers/net/axgbe/axgbe_ethdev.c | 39 ++++++++++++++++----------------
 1 file changed, 20 insertions(+), 19 deletions(-)

diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c
index 7d40c18a86..7b8d94ca3c 100644
--- a/drivers/net/axgbe/axgbe_ethdev.c
+++ b/drivers/net/axgbe/axgbe_ethdev.c
@@ -10,6 +10,8 @@
 #include "axgbe_regs.h"
 #include "rte_time.h"
 
+#include "eal_filesystem.h"
+
 static int eth_axgbe_dev_init(struct rte_eth_dev *eth_dev);  static int  axgbe_dev_configure(struct rte_eth_dev *dev);  static int  axgbe_dev_start(struct rte_eth_dev *dev); @@ -2117,28 +2119,27 @@ static void axgbe_default_config(struct axgbe_port *pdata)
 	pdata->power_down = 0;
 }
 
-static int
-pci_device_cmp(const struct rte_device *dev, const void *_pci_id)
+/*
+ * Return PCI root complex device id on success else 0  */ static 
+uint16_t
+get_pci_rc_devid(void)
 {
-	const struct rte_pci_device *pdev = RTE_DEV_TO_PCI_CONST(dev);
-	const struct rte_pci_id *pcid = _pci_id;
+	char pci_sysfs[PATH_MAX];
+	const struct rte_pci_addr pci_rc_addr = {0, 0, 0, 0};
+	unsigned long device_id;
 
-	if (pdev->id.vendor_id == AMD_PCI_VENDOR_ID &&
-			pdev->id.device_id == pcid->device_id)
-		return 0;
-	return 1;
-}
+	snprintf(pci_sysfs, sizeof(pci_sysfs), "%s/" PCI_PRI_FMT "/device",
+		 rte_pci_get_sysfs_path(), pci_rc_addr.domain,
+		 pci_rc_addr.bus, pci_rc_addr.devid, pci_rc_addr.function);
 
-static bool
-pci_search_device(int device_id)
-{
-	struct rte_bus *pci_bus;
-	struct rte_pci_id dev_id;
+	/* get device id */
+	if (eal_parse_sysfs_value(pci_sysfs, &device_id) < 0) {
+		PMD_INIT_LOG(ERR, "Error in reading PCI sysfs\n");
+		return 0;
+	}
 
-	dev_id.device_id = device_id;
-	pci_bus = rte_bus_find_by_name("pci");
-	return (pci_bus != NULL) &&
-		(pci_bus->find_device(NULL, pci_device_cmp, &dev_id) != NULL);
+	return (uint16_t)device_id;
 }
 
 /*
@@ -2180,7 +2181,7 @@ eth_axgbe_dev_init(struct rte_eth_dev *eth_dev)
 	/*
 	 * Use root complex device ID to differentiate RV AXGBE vs SNOWY AXGBE
 	 */
-	if (pci_search_device(AMD_PCI_RV_ROOT_COMPLEX_ID)) {
+	if ((get_pci_rc_devid()) == AMD_PCI_RV_ROOT_COMPLEX_ID) {
 		pdata->xpcs_window_def_reg = PCS_V2_RV_WINDOW_DEF;
 		pdata->xpcs_window_sel_reg = PCS_V2_RV_WINDOW_SELECT;
 	} else {
--
2.25.1
Sebastian, Selwin Jan. 17, 2022, 5:40 a.m. UTC | #3
Acked by: Selwin Sebastian <selwin.sebastian@amd.com>

-----Original Message-----
From: Namburu, Chandu-babu <chandu@amd.com> 
Sent: Monday, January 10, 2022 12:08 PM
To: dev@dpdk.org; david.marchand@redhat.com; ferruh.yigit@intel.com
Cc: Sebastian, Selwin <Selwin.Sebastian@amd.com>; Arsalan_Awan@mentor.com; stable@dpdk.org
Subject: RE: [PATCH v2] net/axgbe: use PCI root complex device to distinguish AMD hardware

[Public]

Hi,

Gentle reminder.

This is patch is required to submit changes for new AMD products. Please review and let us know if any modification are required.

Regards,
Chandu

-----Original Message-----
From: Namburu, Chandu-babu
Sent: Wednesday, December 22, 2021 2:58 PM
To: dev@dpdk.org; david.marchand@redhat.com; ferruh.yigit@intel.com
Cc: Sebastian, Selwin <Selwin.Sebastian@amd.com>; Arsalan_Awan@mentor.com; stable@dpdk.org
Subject: RE: [PATCH v2] net/axgbe: use PCI root complex device to distinguish AMD hardware

[Public]

Hi David Marchand,

I have submitted v2 patch with your suggestion in git log. Please review changes.

Regards,
Chandu

-----Original Message-----
From: Namburu, Chandu-babu <chandu@amd.com>
Sent: Thursday, December 2, 2021 9:41 PM
To: dev@dpdk.org; david.marchand@redhat.com
Cc: Sebastian, Selwin <Selwin.Sebastian@amd.com>; Arsalan_Awan@mentor.com; ferruh.yigit@intel.com; Namburu, Chandu-babu <chandu@amd.com>; stable@dpdk.org
Subject: [PATCH v2] net/axgbe: use PCI root complex device to distinguish AMD hardware

"bus/pci: optimize bus scan" broke axgbe on V1000/R1000.
RV root complex pci device does not have any kernel driver assigned so it is removed from pci scan list which is used in
"net/axgbe: add a HW quirk for register definitions".

Get root complex device id directly from pci sysfs instead of pci scan list.

Fixes: 991e0b1dbc4a (net/axgbe: add a HW quirk for register definitions)
Cc: stable@dpdk.org

Signed-off-by: Chandubabu Namburu <chandu@amd.com>
---
 drivers/net/axgbe/axgbe_ethdev.c | 39 ++++++++++++++++----------------
 1 file changed, 20 insertions(+), 19 deletions(-)

diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c
index 7d40c18a86..7b8d94ca3c 100644
--- a/drivers/net/axgbe/axgbe_ethdev.c
+++ b/drivers/net/axgbe/axgbe_ethdev.c
@@ -10,6 +10,8 @@
 #include "axgbe_regs.h"
 #include "rte_time.h"
 
+#include "eal_filesystem.h"
+
 static int eth_axgbe_dev_init(struct rte_eth_dev *eth_dev);  static int  axgbe_dev_configure(struct rte_eth_dev *dev);  static int  axgbe_dev_start(struct rte_eth_dev *dev); @@ -2117,28 +2119,27 @@ static void axgbe_default_config(struct axgbe_port *pdata)
 	pdata->power_down = 0;
 }
 
-static int
-pci_device_cmp(const struct rte_device *dev, const void *_pci_id)
+/*
+ * Return PCI root complex device id on success else 0  */ static 
+uint16_t
+get_pci_rc_devid(void)
 {
-	const struct rte_pci_device *pdev = RTE_DEV_TO_PCI_CONST(dev);
-	const struct rte_pci_id *pcid = _pci_id;
+	char pci_sysfs[PATH_MAX];
+	const struct rte_pci_addr pci_rc_addr = {0, 0, 0, 0};
+	unsigned long device_id;
 
-	if (pdev->id.vendor_id == AMD_PCI_VENDOR_ID &&
-			pdev->id.device_id == pcid->device_id)
-		return 0;
-	return 1;
-}
+	snprintf(pci_sysfs, sizeof(pci_sysfs), "%s/" PCI_PRI_FMT "/device",
+		 rte_pci_get_sysfs_path(), pci_rc_addr.domain,
+		 pci_rc_addr.bus, pci_rc_addr.devid, pci_rc_addr.function);
 
-static bool
-pci_search_device(int device_id)
-{
-	struct rte_bus *pci_bus;
-	struct rte_pci_id dev_id;
+	/* get device id */
+	if (eal_parse_sysfs_value(pci_sysfs, &device_id) < 0) {
+		PMD_INIT_LOG(ERR, "Error in reading PCI sysfs\n");
+		return 0;
+	}
 
-	dev_id.device_id = device_id;
-	pci_bus = rte_bus_find_by_name("pci");
-	return (pci_bus != NULL) &&
-		(pci_bus->find_device(NULL, pci_device_cmp, &dev_id) != NULL);
+	return (uint16_t)device_id;
 }
 
 /*
@@ -2180,7 +2181,7 @@ eth_axgbe_dev_init(struct rte_eth_dev *eth_dev)
 	/*
 	 * Use root complex device ID to differentiate RV AXGBE vs SNOWY AXGBE
 	 */
-	if (pci_search_device(AMD_PCI_RV_ROOT_COMPLEX_ID)) {
+	if ((get_pci_rc_devid()) == AMD_PCI_RV_ROOT_COMPLEX_ID) {
 		pdata->xpcs_window_def_reg = PCS_V2_RV_WINDOW_DEF;
 		pdata->xpcs_window_sel_reg = PCS_V2_RV_WINDOW_SELECT;
 	} else {
--
2.25.1
Ferruh Yigit Jan. 17, 2022, 10:22 a.m. UTC | #4
On 1/17/2022 5:40 AM, Sebastian, Selwin wrote:
> Acked by: Selwin Sebastian <selwin.sebastian@amd.com>
> 

Hi Selwin,

Patchwork doesn't recognize the tag, I guess because it is looking for
exact "Acked-by: " tag, with '-'.

Can you please pay attention next time, able to see the status in the patchwork
help maintainers to trace patch's status.

Cheers,
ferruh

> -----Original Message-----
> From: Namburu, Chandu-babu <chandu@amd.com>
> Sent: Monday, January 10, 2022 12:08 PM
> To: dev@dpdk.org; david.marchand@redhat.com; ferruh.yigit@intel.com
> Cc: Sebastian, Selwin <Selwin.Sebastian@amd.com>; Arsalan_Awan@mentor.com; stable@dpdk.org
> Subject: RE: [PATCH v2] net/axgbe: use PCI root complex device to distinguish AMD hardware
> 
> [Public]
> 
> Hi,
> 
> Gentle reminder.
> 
> This is patch is required to submit changes for new AMD products. Please review and let us know if any modification are required.
> 
> Regards,
> Chandu
> 
> -----Original Message-----
> From: Namburu, Chandu-babu
> Sent: Wednesday, December 22, 2021 2:58 PM
> To: dev@dpdk.org; david.marchand@redhat.com; ferruh.yigit@intel.com
> Cc: Sebastian, Selwin <Selwin.Sebastian@amd.com>; Arsalan_Awan@mentor.com; stable@dpdk.org
> Subject: RE: [PATCH v2] net/axgbe: use PCI root complex device to distinguish AMD hardware
> 
> [Public]
> 
> Hi David Marchand,
> 
> I have submitted v2 patch with your suggestion in git log. Please review changes.
> 
> Regards,
> Chandu
> 
> -----Original Message-----
> From: Namburu, Chandu-babu <chandu@amd.com>
> Sent: Thursday, December 2, 2021 9:41 PM
> To: dev@dpdk.org; david.marchand@redhat.com
> Cc: Sebastian, Selwin <Selwin.Sebastian@amd.com>; Arsalan_Awan@mentor.com; ferruh.yigit@intel.com; Namburu, Chandu-babu <chandu@amd.com>; stable@dpdk.org
> Subject: [PATCH v2] net/axgbe: use PCI root complex device to distinguish AMD hardware
> 
> "bus/pci: optimize bus scan" broke axgbe on V1000/R1000.
> RV root complex pci device does not have any kernel driver assigned so it is removed from pci scan list which is used in
> "net/axgbe: add a HW quirk for register definitions".
> 
> Get root complex device id directly from pci sysfs instead of pci scan list.
> 
> Fixes: 991e0b1dbc4a (net/axgbe: add a HW quirk for register definitions)
> Cc: stable@dpdk.org
> 
> Signed-off-by: Chandubabu Namburu <chandu@amd.com>
> ---
>   drivers/net/axgbe/axgbe_ethdev.c | 39 ++++++++++++++++----------------
>   1 file changed, 20 insertions(+), 19 deletions(-)
> 
> diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c
> index 7d40c18a86..7b8d94ca3c 100644
> --- a/drivers/net/axgbe/axgbe_ethdev.c
> +++ b/drivers/net/axgbe/axgbe_ethdev.c
> @@ -10,6 +10,8 @@
>   #include "axgbe_regs.h"
>   #include "rte_time.h"
>   
> +#include "eal_filesystem.h"
> +
>   static int eth_axgbe_dev_init(struct rte_eth_dev *eth_dev);  static int  axgbe_dev_configure(struct rte_eth_dev *dev);  static int  axgbe_dev_start(struct rte_eth_dev *dev); @@ -2117,28 +2119,27 @@ static void axgbe_default_config(struct axgbe_port *pdata)
>   	pdata->power_down = 0;
>   }
>   
> -static int
> -pci_device_cmp(const struct rte_device *dev, const void *_pci_id)
> +/*
> + * Return PCI root complex device id on success else 0  */ static
> +uint16_t
> +get_pci_rc_devid(void)
>   {
> -	const struct rte_pci_device *pdev = RTE_DEV_TO_PCI_CONST(dev);
> -	const struct rte_pci_id *pcid = _pci_id;
> +	char pci_sysfs[PATH_MAX];
> +	const struct rte_pci_addr pci_rc_addr = {0, 0, 0, 0};
> +	unsigned long device_id;
>   
> -	if (pdev->id.vendor_id == AMD_PCI_VENDOR_ID &&
> -			pdev->id.device_id == pcid->device_id)
> -		return 0;
> -	return 1;
> -}
> +	snprintf(pci_sysfs, sizeof(pci_sysfs), "%s/" PCI_PRI_FMT "/device",
> +		 rte_pci_get_sysfs_path(), pci_rc_addr.domain,
> +		 pci_rc_addr.bus, pci_rc_addr.devid, pci_rc_addr.function);
>   
> -static bool
> -pci_search_device(int device_id)
> -{
> -	struct rte_bus *pci_bus;
> -	struct rte_pci_id dev_id;
> +	/* get device id */
> +	if (eal_parse_sysfs_value(pci_sysfs, &device_id) < 0) {
> +		PMD_INIT_LOG(ERR, "Error in reading PCI sysfs\n");
> +		return 0;
> +	}
>   
> -	dev_id.device_id = device_id;
> -	pci_bus = rte_bus_find_by_name("pci");
> -	return (pci_bus != NULL) &&
> -		(pci_bus->find_device(NULL, pci_device_cmp, &dev_id) != NULL);
> +	return (uint16_t)device_id;
>   }
>   
>   /*
> @@ -2180,7 +2181,7 @@ eth_axgbe_dev_init(struct rte_eth_dev *eth_dev)
>   	/*
>   	 * Use root complex device ID to differentiate RV AXGBE vs SNOWY AXGBE
>   	 */
> -	if (pci_search_device(AMD_PCI_RV_ROOT_COMPLEX_ID)) {
> +	if ((get_pci_rc_devid()) == AMD_PCI_RV_ROOT_COMPLEX_ID) {
>   		pdata->xpcs_window_def_reg = PCS_V2_RV_WINDOW_DEF;
>   		pdata->xpcs_window_sel_reg = PCS_V2_RV_WINDOW_SELECT;
>   	} else {
> --
> 2.25.1
Sebastian, Selwin Jan. 17, 2022, 10:29 a.m. UTC | #5
Acked-by: Selwin Sebastian <selwin.sebastian@amd.com>

-----Original Message-----
From: Namburu, Chandu-babu <chandu@amd.com>
Sent: Monday, January 10, 2022 12:08 PM
To: dev@dpdk.org; david.marchand@redhat.com; ferruh.yigit@intel.com
Cc: Sebastian, Selwin <Selwin.Sebastian@amd.com>; Arsalan_Awan@mentor.com; stable@dpdk.org
Subject: RE: [PATCH v2] net/axgbe: use PCI root complex device to distinguish AMD hardware

[Public]

Hi,

Gentle reminder.

This is patch is required to submit changes for new AMD products. Please review and let us know if any modification are required.

Regards,
Chandu

-----Original Message-----
From: Namburu, Chandu-babu
Sent: Wednesday, December 22, 2021 2:58 PM
To: dev@dpdk.org; david.marchand@redhat.com; ferruh.yigit@intel.com
Cc: Sebastian, Selwin <Selwin.Sebastian@amd.com>; Arsalan_Awan@mentor.com; stable@dpdk.org
Subject: RE: [PATCH v2] net/axgbe: use PCI root complex device to distinguish AMD hardware

[Public]

Hi David Marchand,

I have submitted v2 patch with your suggestion in git log. Please review changes.

Regards,
Chandu

-----Original Message-----
From: Namburu, Chandu-babu <chandu@amd.com>
Sent: Thursday, December 2, 2021 9:41 PM
To: dev@dpdk.org; david.marchand@redhat.com
Cc: Sebastian, Selwin <Selwin.Sebastian@amd.com>; Arsalan_Awan@mentor.com; ferruh.yigit@intel.com; Namburu, Chandu-babu <chandu@amd.com>; stable@dpdk.org
Subject: [PATCH v2] net/axgbe: use PCI root complex device to distinguish AMD hardware

"bus/pci: optimize bus scan" broke axgbe on V1000/R1000.
RV root complex pci device does not have any kernel driver assigned so it is removed from pci scan list which is used in
"net/axgbe: add a HW quirk for register definitions".

Get root complex device id directly from pci sysfs instead of pci scan list.

Fixes: 991e0b1dbc4a (net/axgbe: add a HW quirk for register definitions)
Cc: stable@dpdk.org

Signed-off-by: Chandubabu Namburu <chandu@amd.com>
---
 drivers/net/axgbe/axgbe_ethdev.c | 39 ++++++++++++++++----------------
 1 file changed, 20 insertions(+), 19 deletions(-)

diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c
index 7d40c18a86..7b8d94ca3c 100644
--- a/drivers/net/axgbe/axgbe_ethdev.c
+++ b/drivers/net/axgbe/axgbe_ethdev.c
@@ -10,6 +10,8 @@
 #include "axgbe_regs.h"
 #include "rte_time.h"
 
+#include "eal_filesystem.h"
+
 static int eth_axgbe_dev_init(struct rte_eth_dev *eth_dev);  static int  axgbe_dev_configure(struct rte_eth_dev *dev);  static int  axgbe_dev_start(struct rte_eth_dev *dev); @@ -2117,28 +2119,27 @@ static void axgbe_default_config(struct axgbe_port *pdata)
 	pdata->power_down = 0;
 }
 
-static int
-pci_device_cmp(const struct rte_device *dev, const void *_pci_id)
+/*
+ * Return PCI root complex device id on success else 0  */ static 
+uint16_t
+get_pci_rc_devid(void)
 {
-	const struct rte_pci_device *pdev = RTE_DEV_TO_PCI_CONST(dev);
-	const struct rte_pci_id *pcid = _pci_id;
+	char pci_sysfs[PATH_MAX];
+	const struct rte_pci_addr pci_rc_addr = {0, 0, 0, 0};
+	unsigned long device_id;
 
-	if (pdev->id.vendor_id == AMD_PCI_VENDOR_ID &&
-			pdev->id.device_id == pcid->device_id)
-		return 0;
-	return 1;
-}
+	snprintf(pci_sysfs, sizeof(pci_sysfs), "%s/" PCI_PRI_FMT "/device",
+		 rte_pci_get_sysfs_path(), pci_rc_addr.domain,
+		 pci_rc_addr.bus, pci_rc_addr.devid, pci_rc_addr.function);
 
-static bool
-pci_search_device(int device_id)
-{
-	struct rte_bus *pci_bus;
-	struct rte_pci_id dev_id;
+	/* get device id */
+	if (eal_parse_sysfs_value(pci_sysfs, &device_id) < 0) {
+		PMD_INIT_LOG(ERR, "Error in reading PCI sysfs\n");
+		return 0;
+	}
 
-	dev_id.device_id = device_id;
-	pci_bus = rte_bus_find_by_name("pci");
-	return (pci_bus != NULL) &&
-		(pci_bus->find_device(NULL, pci_device_cmp, &dev_id) != NULL);
+	return (uint16_t)device_id;
 }
 
 /*
@@ -2180,7 +2181,7 @@ eth_axgbe_dev_init(struct rte_eth_dev *eth_dev)
 	/*
 	 * Use root complex device ID to differentiate RV AXGBE vs SNOWY AXGBE
 	 */
-	if (pci_search_device(AMD_PCI_RV_ROOT_COMPLEX_ID)) {
+	if ((get_pci_rc_devid()) == AMD_PCI_RV_ROOT_COMPLEX_ID) {
 		pdata->xpcs_window_def_reg = PCS_V2_RV_WINDOW_DEF;
 		pdata->xpcs_window_sel_reg = PCS_V2_RV_WINDOW_SELECT;
 	} else {
--
2.25.1
Sebastian, Selwin Jan. 17, 2022, 10:30 a.m. UTC | #6
[AMD Official Use Only]

Hi Ferruh,
I'm Sorry...  corrected  and sent it again.

Thanks
Selwin

-----Original Message-----
From: Ferruh Yigit <ferruh.yigit@intel.com>
Sent: Monday, January 17, 2022 3:52 PM
To: Sebastian, Selwin <Selwin.Sebastian@amd.com>; Namburu, Chandu-babu <chandu@amd.com>; dev@dpdk.org; david.marchand@redhat.com
Cc: Arsalan_Awan@mentor.com; stable@dpdk.org
Subject: Re: [PATCH v2] net/axgbe: use PCI root complex device to distinguish AMD hardware

[CAUTION: External Email]

On 1/17/2022 5:40 AM, Sebastian, Selwin wrote:
> Acked by: Selwin Sebastian <selwin.sebastian@amd.com>
>

Hi Selwin,

Patchwork doesn't recognize the tag, I guess because it is looking for exact "Acked-by: " tag, with '-'.

Can you please pay attention next time, able to see the status in the patchwork help maintainers to trace patch's status.

Cheers,
ferruh

> -----Original Message-----
> From: Namburu, Chandu-babu <chandu@amd.com>
> Sent: Monday, January 10, 2022 12:08 PM
> To: dev@dpdk.org; david.marchand@redhat.com; ferruh.yigit@intel.com
> Cc: Sebastian, Selwin <Selwin.Sebastian@amd.com>;
> Arsalan_Awan@mentor.com; stable@dpdk.org
> Subject: RE: [PATCH v2] net/axgbe: use PCI root complex device to
> distinguish AMD hardware
>
> [Public]
>
> Hi,
>
> Gentle reminder.
>
> This is patch is required to submit changes for new AMD products. Please review and let us know if any modification are required.
>
> Regards,
> Chandu
>
> -----Original Message-----
> From: Namburu, Chandu-babu
> Sent: Wednesday, December 22, 2021 2:58 PM
> To: dev@dpdk.org; david.marchand@redhat.com; ferruh.yigit@intel.com
> Cc: Sebastian, Selwin <Selwin.Sebastian@amd.com>;
> Arsalan_Awan@mentor.com; stable@dpdk.org
> Subject: RE: [PATCH v2] net/axgbe: use PCI root complex device to
> distinguish AMD hardware
>
> [Public]
>
> Hi David Marchand,
>
> I have submitted v2 patch with your suggestion in git log. Please review changes.
>
> Regards,
> Chandu
>
> -----Original Message-----
> From: Namburu, Chandu-babu <chandu@amd.com>
> Sent: Thursday, December 2, 2021 9:41 PM
> To: dev@dpdk.org; david.marchand@redhat.com
> Cc: Sebastian, Selwin <Selwin.Sebastian@amd.com>;
> Arsalan_Awan@mentor.com; ferruh.yigit@intel.com; Namburu, Chandu-babu
> <chandu@amd.com>; stable@dpdk.org
> Subject: [PATCH v2] net/axgbe: use PCI root complex device to
> distinguish AMD hardware
>
> "bus/pci: optimize bus scan" broke axgbe on V1000/R1000.
> RV root complex pci device does not have any kernel driver assigned so
> it is removed from pci scan list which is used in
> "net/axgbe: add a HW quirk for register definitions".
>
> Get root complex device id directly from pci sysfs instead of pci scan list.
>
> Fixes: 991e0b1dbc4a (net/axgbe: add a HW quirk for register
> definitions)
> Cc: stable@dpdk.org
>
> Signed-off-by: Chandubabu Namburu <chandu@amd.com>
> ---
>   drivers/net/axgbe/axgbe_ethdev.c | 39 ++++++++++++++++----------------
>   1 file changed, 20 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/net/axgbe/axgbe_ethdev.c
> b/drivers/net/axgbe/axgbe_ethdev.c
> index 7d40c18a86..7b8d94ca3c 100644
> --- a/drivers/net/axgbe/axgbe_ethdev.c
> +++ b/drivers/net/axgbe/axgbe_ethdev.c
> @@ -10,6 +10,8 @@
>   #include "axgbe_regs.h"
>   #include "rte_time.h"
>
> +#include "eal_filesystem.h"
> +
>   static int eth_axgbe_dev_init(struct rte_eth_dev *eth_dev);  static int  axgbe_dev_configure(struct rte_eth_dev *dev);  static int  axgbe_dev_start(struct rte_eth_dev *dev); @@ -2117,28 +2119,27 @@ static void axgbe_default_config(struct axgbe_port *pdata)
>       pdata->power_down = 0;
>   }
>
> -static int
> -pci_device_cmp(const struct rte_device *dev, const void *_pci_id)
> +/*
> + * Return PCI root complex device id on success else 0  */ static
> +uint16_t
> +get_pci_rc_devid(void)
>   {
> -     const struct rte_pci_device *pdev = RTE_DEV_TO_PCI_CONST(dev);
> -     const struct rte_pci_id *pcid = _pci_id;
> +     char pci_sysfs[PATH_MAX];
> +     const struct rte_pci_addr pci_rc_addr = {0, 0, 0, 0};
> +     unsigned long device_id;
>
> -     if (pdev->id.vendor_id == AMD_PCI_VENDOR_ID &&
> -                     pdev->id.device_id == pcid->device_id)
> -             return 0;
> -     return 1;
> -}
> +     snprintf(pci_sysfs, sizeof(pci_sysfs), "%s/" PCI_PRI_FMT "/device",
> +              rte_pci_get_sysfs_path(), pci_rc_addr.domain,
> +              pci_rc_addr.bus, pci_rc_addr.devid,
> + pci_rc_addr.function);
>
> -static bool
> -pci_search_device(int device_id)
> -{
> -     struct rte_bus *pci_bus;
> -     struct rte_pci_id dev_id;
> +     /* get device id */
> +     if (eal_parse_sysfs_value(pci_sysfs, &device_id) < 0) {
> +             PMD_INIT_LOG(ERR, "Error in reading PCI sysfs\n");
> +             return 0;
> +     }
>
> -     dev_id.device_id = device_id;
> -     pci_bus = rte_bus_find_by_name("pci");
> -     return (pci_bus != NULL) &&
> -             (pci_bus->find_device(NULL, pci_device_cmp, &dev_id) != NULL);
> +     return (uint16_t)device_id;
>   }
>
>   /*
> @@ -2180,7 +2181,7 @@ eth_axgbe_dev_init(struct rte_eth_dev *eth_dev)
>       /*
>        * Use root complex device ID to differentiate RV AXGBE vs SNOWY AXGBE
>        */
> -     if (pci_search_device(AMD_PCI_RV_ROOT_COMPLEX_ID)) {
> +     if ((get_pci_rc_devid()) == AMD_PCI_RV_ROOT_COMPLEX_ID) {
>               pdata->xpcs_window_def_reg = PCS_V2_RV_WINDOW_DEF;
>               pdata->xpcs_window_sel_reg = PCS_V2_RV_WINDOW_SELECT;
>       } else {
> --
> 2.25.1
Ferruh Yigit Jan. 17, 2022, 2:07 p.m. UTC | #7
On 1/17/2022 10:29 AM, Sebastian, Selwin wrote:

<...>

> -----Original Message-----
> From: Namburu, Chandu-babu <chandu@amd.com>
> Sent: Thursday, December 2, 2021 9:41 PM
> To: dev@dpdk.org; david.marchand@redhat.com
> Cc: Sebastian, Selwin <Selwin.Sebastian@amd.com>; Arsalan_Awan@mentor.com; ferruh.yigit@intel.com; Namburu, Chandu-babu <chandu@amd.com>; stable@dpdk.org
> Subject: [PATCH v2] net/axgbe: use PCI root complex device to distinguish AMD hardware
> 
> "bus/pci: optimize bus scan" broke axgbe on V1000/R1000.
> RV root complex pci device does not have any kernel driver assigned so it is removed from pci scan list which is used in
> "net/axgbe: add a HW quirk for register definitions".
> 
> Get root complex device id directly from pci sysfs instead of pci scan list.
> 
> Fixes: 991e0b1dbc4a (net/axgbe: add a HW quirk for register definitions)
> Cc: stable@dpdk.org
> 
> Signed-off-by: Chandubabu Namburu <chandu@amd.com>
> 
> Acked-by: Selwin Sebastian <selwin.sebastian@amd.com>
> 

Applied to dpdk-next-net/main, thanks.
diff mbox series

Patch

diff --git a/drivers/net/axgbe/axgbe_ethdev.c b/drivers/net/axgbe/axgbe_ethdev.c
index 7d40c18a86..7b8d94ca3c 100644
--- a/drivers/net/axgbe/axgbe_ethdev.c
+++ b/drivers/net/axgbe/axgbe_ethdev.c
@@ -10,6 +10,8 @@ 
 #include "axgbe_regs.h"
 #include "rte_time.h"
 
+#include "eal_filesystem.h"
+
 static int eth_axgbe_dev_init(struct rte_eth_dev *eth_dev);
 static int  axgbe_dev_configure(struct rte_eth_dev *dev);
 static int  axgbe_dev_start(struct rte_eth_dev *dev);
@@ -2117,28 +2119,27 @@  static void axgbe_default_config(struct axgbe_port *pdata)
 	pdata->power_down = 0;
 }
 
-static int
-pci_device_cmp(const struct rte_device *dev, const void *_pci_id)
+/*
+ * Return PCI root complex device id on success else 0
+ */
+static uint16_t
+get_pci_rc_devid(void)
 {
-	const struct rte_pci_device *pdev = RTE_DEV_TO_PCI_CONST(dev);
-	const struct rte_pci_id *pcid = _pci_id;
+	char pci_sysfs[PATH_MAX];
+	const struct rte_pci_addr pci_rc_addr = {0, 0, 0, 0};
+	unsigned long device_id;
 
-	if (pdev->id.vendor_id == AMD_PCI_VENDOR_ID &&
-			pdev->id.device_id == pcid->device_id)
-		return 0;
-	return 1;
-}
+	snprintf(pci_sysfs, sizeof(pci_sysfs), "%s/" PCI_PRI_FMT "/device",
+		 rte_pci_get_sysfs_path(), pci_rc_addr.domain,
+		 pci_rc_addr.bus, pci_rc_addr.devid, pci_rc_addr.function);
 
-static bool
-pci_search_device(int device_id)
-{
-	struct rte_bus *pci_bus;
-	struct rte_pci_id dev_id;
+	/* get device id */
+	if (eal_parse_sysfs_value(pci_sysfs, &device_id) < 0) {
+		PMD_INIT_LOG(ERR, "Error in reading PCI sysfs\n");
+		return 0;
+	}
 
-	dev_id.device_id = device_id;
-	pci_bus = rte_bus_find_by_name("pci");
-	return (pci_bus != NULL) &&
-		(pci_bus->find_device(NULL, pci_device_cmp, &dev_id) != NULL);
+	return (uint16_t)device_id;
 }
 
 /*
@@ -2180,7 +2181,7 @@  eth_axgbe_dev_init(struct rte_eth_dev *eth_dev)
 	/*
 	 * Use root complex device ID to differentiate RV AXGBE vs SNOWY AXGBE
 	 */
-	if (pci_search_device(AMD_PCI_RV_ROOT_COMPLEX_ID)) {
+	if ((get_pci_rc_devid()) == AMD_PCI_RV_ROOT_COMPLEX_ID) {
 		pdata->xpcs_window_def_reg = PCS_V2_RV_WINDOW_DEF;
 		pdata->xpcs_window_sel_reg = PCS_V2_RV_WINDOW_SELECT;
 	} else {