* [PATCH v4 1/3] igb: Use FIELD_GET() to extract Link Width
2023-11-21 12:34 [PATCH v4 0/3] net/ethernet/intel: PCI cleanups Ilpo Järvinen
@ 2023-11-21 12:34 ` Ilpo Järvinen
2023-11-23 11:57 ` Simon Horman
2023-11-28 6:24 ` [Intel-wired-lan] " Pucha, HimasekharX Reddy
2023-11-21 12:34 ` [PATCH v4 2/3] e1000e: Use PCI_EXP_LNKSTA_NLW & FIELD_GET() instead of custom defines/code Ilpo Järvinen
2023-11-21 12:34 ` [PATCH v4 3/3] e1000e: Use pcie_capability_read_word() for reading LNKSTA Ilpo Järvinen
2 siblings, 2 replies; 10+ messages in thread
From: Ilpo Järvinen @ 2023-11-21 12:34 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, intel-wired-lan, Jakub Kicinski,
Jesse Brandeburg, Jonathan Cameron, netdev, Paolo Abeni,
Tony Nguyen, linux-kernel
Cc: Ilpo Järvinen
Use FIELD_GET() to extract PCIe Negotiated Link Width field instead of
custom masking and shifting.
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
drivers/net/ethernet/intel/igb/e1000_mac.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/intel/igb/e1000_mac.c b/drivers/net/ethernet/intel/igb/e1000_mac.c
index caf91c6f52b4..5a23b9cfec6c 100644
--- a/drivers/net/ethernet/intel/igb/e1000_mac.c
+++ b/drivers/net/ethernet/intel/igb/e1000_mac.c
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
/* Copyright(c) 2007 - 2018 Intel Corporation. */
+#include <linux/bitfield.h>
#include <linux/if_ether.h>
#include <linux/delay.h>
#include <linux/pci.h>
@@ -50,9 +51,8 @@ s32 igb_get_bus_info_pcie(struct e1000_hw *hw)
break;
}
- bus->width = (enum e1000_bus_width)((pcie_link_status &
- PCI_EXP_LNKSTA_NLW) >>
- PCI_EXP_LNKSTA_NLW_SHIFT);
+ bus->width = (enum e1000_bus_width)FIELD_GET(PCI_EXP_LNKSTA_NLW,
+ pcie_link_status);
}
reg = rd32(E1000_STATUS);
--
2.30.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v4 1/3] igb: Use FIELD_GET() to extract Link Width
2023-11-21 12:34 ` [PATCH v4 1/3] igb: Use FIELD_GET() to extract Link Width Ilpo Järvinen
@ 2023-11-23 11:57 ` Simon Horman
2023-11-28 6:24 ` [Intel-wired-lan] " Pucha, HimasekharX Reddy
1 sibling, 0 replies; 10+ messages in thread
From: Simon Horman @ 2023-11-23 11:57 UTC (permalink / raw)
To: Ilpo Järvinen
Cc: David S. Miller, Eric Dumazet, intel-wired-lan, Jakub Kicinski,
Jesse Brandeburg, Jonathan Cameron, netdev, Paolo Abeni,
Tony Nguyen, linux-kernel
On Tue, Nov 21, 2023 at 02:34:26PM +0200, Ilpo Järvinen wrote:
> Use FIELD_GET() to extract PCIe Negotiated Link Width field instead of
> custom masking and shifting.
>
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Thanks, nice to see FIELD_GET() used here.
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [Intel-wired-lan] [PATCH v4 1/3] igb: Use FIELD_GET() to extract Link Width
2023-11-21 12:34 ` [PATCH v4 1/3] igb: Use FIELD_GET() to extract Link Width Ilpo Järvinen
2023-11-23 11:57 ` Simon Horman
@ 2023-11-28 6:24 ` Pucha, HimasekharX Reddy
1 sibling, 0 replies; 10+ messages in thread
From: Pucha, HimasekharX Reddy @ 2023-11-28 6:24 UTC (permalink / raw)
To: Ilpo Järvinen, David S. Miller, Eric Dumazet,
intel-wired-lan@lists.osuosl.org, Jakub Kicinski,
Brandeburg, Jesse, Jonathan Cameron, netdev@vger.kernel.org,
Paolo Abeni, Nguyen, Anthony L, linux-kernel@vger.kernel.org
> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf Of Ilpo Järvinen
> Sent: Tuesday, November 21, 2023 6:04 PM
> To: David S. Miller <davem@davemloft.net>; Eric Dumazet <edumazet@google.com>; intel-wired-lan@lists.osuosl.org; Jakub Kicinski <kuba@kernel.org>; Brandeburg, Jesse <jesse.brandeburg@intel.com>; Jonathan Cameron <Jonathan.Cameron@huawei.com>; netdev@vger.kernel.org; Paolo Abeni <pabeni@redhat.com>; Nguyen, Anthony L <anthony.l.nguyen@intel.com>; linux-kernel@vger.kernel.org
> Cc: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> Subject: [Intel-wired-lan] [PATCH v4 1/3] igb: Use FIELD_GET() to extract Link Width
>
> Use FIELD_GET() to extract PCIe Negotiated Link Width field instead of
> custom masking and shifting.
>
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> ---
> drivers/net/ethernet/intel/igb/e1000_mac.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
Tested-by: Pucha Himasekhar Reddy <himasekharx.reddy.pucha@intel.com> (A Contingent worker at Intel)
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v4 2/3] e1000e: Use PCI_EXP_LNKSTA_NLW & FIELD_GET() instead of custom defines/code
2023-11-21 12:34 [PATCH v4 0/3] net/ethernet/intel: PCI cleanups Ilpo Järvinen
2023-11-21 12:34 ` [PATCH v4 1/3] igb: Use FIELD_GET() to extract Link Width Ilpo Järvinen
@ 2023-11-21 12:34 ` Ilpo Järvinen
2023-11-23 11:57 ` Simon Horman
2023-12-10 10:10 ` [Intel-wired-lan] " naamax.meir
2023-11-21 12:34 ` [PATCH v4 3/3] e1000e: Use pcie_capability_read_word() for reading LNKSTA Ilpo Järvinen
2 siblings, 2 replies; 10+ messages in thread
From: Ilpo Järvinen @ 2023-11-21 12:34 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, intel-wired-lan, Jakub Kicinski,
Jesse Brandeburg, Jonathan Cameron, netdev, Paolo Abeni,
Tony Nguyen, linux-kernel
Cc: Ilpo Järvinen
e1000e has own copy of PCI Negotiated Link Width field defines. Use the
ones from include/uapi/linux/pci_regs.h instead of the custom ones and
remove the custom ones and convert to FIELD_GET().
Suggested-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
drivers/net/ethernet/intel/e1000e/defines.h | 2 --
drivers/net/ethernet/intel/e1000e/mac.c | 7 ++++---
2 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/net/ethernet/intel/e1000e/defines.h b/drivers/net/ethernet/intel/e1000e/defines.h
index 63c3c79380a1..a4d29c9e03a6 100644
--- a/drivers/net/ethernet/intel/e1000e/defines.h
+++ b/drivers/net/ethernet/intel/e1000e/defines.h
@@ -681,8 +681,6 @@
#define PCIE_LINK_STATUS 0x12
#define PCI_HEADER_TYPE_MULTIFUNC 0x80
-#define PCIE_LINK_WIDTH_MASK 0x3F0
-#define PCIE_LINK_WIDTH_SHIFT 4
#define PHY_REVISION_MASK 0xFFFFFFF0
#define MAX_PHY_REG_ADDRESS 0x1F /* 5 bit address bus (0-0x1F) */
diff --git a/drivers/net/ethernet/intel/e1000e/mac.c b/drivers/net/ethernet/intel/e1000e/mac.c
index 5df7ad93f3d7..5340cf73778d 100644
--- a/drivers/net/ethernet/intel/e1000e/mac.c
+++ b/drivers/net/ethernet/intel/e1000e/mac.c
@@ -1,6 +1,8 @@
// SPDX-License-Identifier: GPL-2.0
/* Copyright(c) 1999 - 2018 Intel Corporation. */
+#include <linux/bitfield.h>
+
#include "e1000.h"
/**
@@ -25,9 +27,8 @@ s32 e1000e_get_bus_info_pcie(struct e1000_hw *hw)
pci_read_config_word(adapter->pdev,
cap_offset + PCIE_LINK_STATUS,
&pcie_link_status);
- bus->width = (enum e1000_bus_width)((pcie_link_status &
- PCIE_LINK_WIDTH_MASK) >>
- PCIE_LINK_WIDTH_SHIFT);
+ bus->width = (enum e1000_bus_width)FIELD_GET(PCI_EXP_LNKSTA_NLW,
+ pcie_link_status);
}
mac->ops.set_lan_id(hw);
--
2.30.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v4 2/3] e1000e: Use PCI_EXP_LNKSTA_NLW & FIELD_GET() instead of custom defines/code
2023-11-21 12:34 ` [PATCH v4 2/3] e1000e: Use PCI_EXP_LNKSTA_NLW & FIELD_GET() instead of custom defines/code Ilpo Järvinen
@ 2023-11-23 11:57 ` Simon Horman
2023-12-10 10:10 ` [Intel-wired-lan] " naamax.meir
1 sibling, 0 replies; 10+ messages in thread
From: Simon Horman @ 2023-11-23 11:57 UTC (permalink / raw)
To: Ilpo Järvinen
Cc: David S. Miller, Eric Dumazet, intel-wired-lan, Jakub Kicinski,
Jesse Brandeburg, Jonathan Cameron, netdev, Paolo Abeni,
Tony Nguyen, linux-kernel
On Tue, Nov 21, 2023 at 02:34:27PM +0200, Ilpo Järvinen wrote:
> e1000e has own copy of PCI Negotiated Link Width field defines. Use the
> ones from include/uapi/linux/pci_regs.h instead of the custom ones and
> remove the custom ones and convert to FIELD_GET().
>
> Suggested-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Intel-wired-lan] [PATCH v4 2/3] e1000e: Use PCI_EXP_LNKSTA_NLW & FIELD_GET() instead of custom defines/code
2023-11-21 12:34 ` [PATCH v4 2/3] e1000e: Use PCI_EXP_LNKSTA_NLW & FIELD_GET() instead of custom defines/code Ilpo Järvinen
2023-11-23 11:57 ` Simon Horman
@ 2023-12-10 10:10 ` naamax.meir
1 sibling, 0 replies; 10+ messages in thread
From: naamax.meir @ 2023-12-10 10:10 UTC (permalink / raw)
To: Ilpo Järvinen, David S. Miller, Eric Dumazet,
intel-wired-lan, Jakub Kicinski, Jesse Brandeburg,
Jonathan Cameron, netdev, Paolo Abeni, Tony Nguyen, linux-kernel
On 11/21/2023 14:34, Ilpo Järvinen wrote:
> e1000e has own copy of PCI Negotiated Link Width field defines. Use the
> ones from include/uapi/linux/pci_regs.h instead of the custom ones and
> remove the custom ones and convert to FIELD_GET().
>
> Suggested-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> ---
> drivers/net/ethernet/intel/e1000e/defines.h | 2 --
> drivers/net/ethernet/intel/e1000e/mac.c | 7 ++++---
> 2 files changed, 4 insertions(+), 5 deletions(-)
Tested-by: Naama Meir <naamax.meir@linux.intel.com>
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v4 3/3] e1000e: Use pcie_capability_read_word() for reading LNKSTA
2023-11-21 12:34 [PATCH v4 0/3] net/ethernet/intel: PCI cleanups Ilpo Järvinen
2023-11-21 12:34 ` [PATCH v4 1/3] igb: Use FIELD_GET() to extract Link Width Ilpo Järvinen
2023-11-21 12:34 ` [PATCH v4 2/3] e1000e: Use PCI_EXP_LNKSTA_NLW & FIELD_GET() instead of custom defines/code Ilpo Järvinen
@ 2023-11-21 12:34 ` Ilpo Järvinen
2023-11-23 11:58 ` Simon Horman
2023-12-07 12:53 ` [Intel-wired-lan] " naamax.meir
2 siblings, 2 replies; 10+ messages in thread
From: Ilpo Järvinen @ 2023-11-21 12:34 UTC (permalink / raw)
To: David S. Miller, Eric Dumazet, intel-wired-lan, Jakub Kicinski,
Jesse Brandeburg, Jonathan Cameron, netdev, Paolo Abeni,
Tony Nguyen, linux-kernel
Cc: Ilpo Järvinen
Use pcie_capability_read_word() for reading LNKSTA and remove the
custom define that matches to PCI_EXP_LNKSTA.
As only single user for cap_offset remains, replace it with a call to
pci_pcie_cap(). Instead of e1000_adapter, make local variable out of
pci_dev because both users are interested in it.
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
---
drivers/net/ethernet/intel/e1000e/defines.h | 1 -
drivers/net/ethernet/intel/e1000e/mac.c | 11 ++++-------
2 files changed, 4 insertions(+), 8 deletions(-)
diff --git a/drivers/net/ethernet/intel/e1000e/defines.h b/drivers/net/ethernet/intel/e1000e/defines.h
index a4d29c9e03a6..23a58cada43a 100644
--- a/drivers/net/ethernet/intel/e1000e/defines.h
+++ b/drivers/net/ethernet/intel/e1000e/defines.h
@@ -678,7 +678,6 @@
/* PCI/PCI-X/PCI-EX Config space */
#define PCI_HEADER_TYPE_REGISTER 0x0E
-#define PCIE_LINK_STATUS 0x12
#define PCI_HEADER_TYPE_MULTIFUNC 0x80
diff --git a/drivers/net/ethernet/intel/e1000e/mac.c b/drivers/net/ethernet/intel/e1000e/mac.c
index 5340cf73778d..694a779e718d 100644
--- a/drivers/net/ethernet/intel/e1000e/mac.c
+++ b/drivers/net/ethernet/intel/e1000e/mac.c
@@ -17,16 +17,13 @@ s32 e1000e_get_bus_info_pcie(struct e1000_hw *hw)
{
struct e1000_mac_info *mac = &hw->mac;
struct e1000_bus_info *bus = &hw->bus;
- struct e1000_adapter *adapter = hw->adapter;
- u16 pcie_link_status, cap_offset;
+ struct pci_dev *pdev = hw->adapter->pdev;
+ u16 pcie_link_status;
- cap_offset = adapter->pdev->pcie_cap;
- if (!cap_offset) {
+ if (!pci_pcie_cap(pdev)) {
bus->width = e1000_bus_width_unknown;
} else {
- pci_read_config_word(adapter->pdev,
- cap_offset + PCIE_LINK_STATUS,
- &pcie_link_status);
+ pcie_capability_read_word(pdev, PCI_EXP_LNKSTA, &pcie_link_status);
bus->width = (enum e1000_bus_width)FIELD_GET(PCI_EXP_LNKSTA_NLW,
pcie_link_status);
}
--
2.30.2
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH v4 3/3] e1000e: Use pcie_capability_read_word() for reading LNKSTA
2023-11-21 12:34 ` [PATCH v4 3/3] e1000e: Use pcie_capability_read_word() for reading LNKSTA Ilpo Järvinen
@ 2023-11-23 11:58 ` Simon Horman
2023-12-07 12:53 ` [Intel-wired-lan] " naamax.meir
1 sibling, 0 replies; 10+ messages in thread
From: Simon Horman @ 2023-11-23 11:58 UTC (permalink / raw)
To: Ilpo Järvinen
Cc: David S. Miller, Eric Dumazet, intel-wired-lan, Jakub Kicinski,
Jesse Brandeburg, Jonathan Cameron, netdev, Paolo Abeni,
Tony Nguyen, linux-kernel
On Tue, Nov 21, 2023 at 02:34:28PM +0200, Ilpo Järvinen wrote:
> Use pcie_capability_read_word() for reading LNKSTA and remove the
> custom define that matches to PCI_EXP_LNKSTA.
>
> As only single user for cap_offset remains, replace it with a call to
> pci_pcie_cap(). Instead of e1000_adapter, make local variable out of
> pci_dev because both users are interested in it.
>
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [Intel-wired-lan] [PATCH v4 3/3] e1000e: Use pcie_capability_read_word() for reading LNKSTA
2023-11-21 12:34 ` [PATCH v4 3/3] e1000e: Use pcie_capability_read_word() for reading LNKSTA Ilpo Järvinen
2023-11-23 11:58 ` Simon Horman
@ 2023-12-07 12:53 ` naamax.meir
1 sibling, 0 replies; 10+ messages in thread
From: naamax.meir @ 2023-12-07 12:53 UTC (permalink / raw)
To: Ilpo Järvinen, David S. Miller, Eric Dumazet,
intel-wired-lan, Jakub Kicinski, Jesse Brandeburg,
Jonathan Cameron, netdev, Paolo Abeni, Tony Nguyen, linux-kernel
On 11/21/2023 14:34, Ilpo Järvinen wrote:
> Use pcie_capability_read_word() for reading LNKSTA and remove the
> custom define that matches to PCI_EXP_LNKSTA.
>
> As only single user for cap_offset remains, replace it with a call to
> pci_pcie_cap(). Instead of e1000_adapter, make local variable out of
> pci_dev because both users are interested in it.
>
> Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
> ---
> drivers/net/ethernet/intel/e1000e/defines.h | 1 -
> drivers/net/ethernet/intel/e1000e/mac.c | 11 ++++-------
> 2 files changed, 4 insertions(+), 8 deletions(-)
Tested-by: Naama Meir <naamax.meir@linux.intel.com>
^ permalink raw reply [flat|nested] 10+ messages in thread