net/ethernet/intel: PCI cleanups
Subsystems (3)
v4 cover net/ethernet/intel: PCI cleanups
Resending these PCI related cleanups for Intel Ethernet drivers. No other changes except removing the accepted patches in v4.
These can go through the usual driver tree as there are no PCI tree related dependencies.
v4:
- Removed accepted patches
Ilpo Järvinen (3):
igb: Use FIELD_GET() to extract Link Width
e1000e: Use PCI_EXP_LNKSTA_NLW & FIELD_GET() instead of custom
defines/code
e1000e: Use pcie_capability_read_word() for reading LNKSTA
drivers/net/ethernet/intel/e1000e/defines.h | 3 --- drivers/net/ethernet/intel/e1000e/mac.c | 18 ++++++++---------- drivers/net/ethernet/intel/igb/e1000_mac.c | 6 +++--- 3 files changed, 11 insertions(+), 16 deletions(-)
Signature · 1 line
2.30.2
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.
--- drivers/net/ethernet/intel/igb/e1000_mac.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/igb/e1000_mac.c +3 -3
@@ -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 );
Signature · 1 line
2.30.2
Re: [PATCH v4 1/3] igb: Use FIELD_GET() to extract Link Width
Quoted 5 lines · 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 <[email protected]>Reviewed-by Jonathan Cameron <[email protected]>
Thanks, nice to see FIELD_GET() used here.
RE: [Intel-wired-lan] [PATCH v4 1/3] igb: Use FIELD_GET() to extract Link Width
In reply to Ilpo JärvinenQuoted 7 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Ilpo Järvinen
Sent: Tuesday, November 21, 2023 6:04 PM
To: David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; [email protected]; Jakub Kicinski <[email protected]>; Brandeburg, Jesse <[email protected]>; Jonathan Cameron <[email protected]>; [email protected]; Paolo Abeni <[email protected]>; Nguyen, Anthony L <[email protected]>; [email protected]
Cc: Ilpo Järvinen <[email protected]>
Subject: [Intel-wired-lan] [PATCH v4 1/3] igb: UseFIELD_GET()to extract Link Width
Quoted 9 lines
Use
FIELD_GET()to extract PCIe Negotiated Link Width field instead of custom masking and shifting.Signed-off-by Ilpo Järvinen <[email protected]>Reviewed-by Jonathan Cameron <[email protected]>--- drivers/net/ethernet/intel/igb/e1000_mac.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
PATCH v4 2/3 e1000e: Use PCI_EXP_LNKSTA_NLW & FIELD_GET() instead of custom defines/code
In reply to Ilpo Järvinene1000e 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().
--- drivers/net/ethernet/intel/e1000e/defines.h | 2 -- drivers/net/ethernet/intel/e1000e/mac.c | 7 ++++--- 2 files changed, 4 insertions(+), 5 deletions(-)
drivers/net/ethernet/intel/e1000e/defines.h +0 -2
@@ -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) */
drivers/net/ethernet/intel/e1000e/mac.c +4 -3
@@ -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);
Signature · 1 line
2.30.2
Re: [PATCH v4 2/3] e1000e: Use PCI_EXP_LNKSTA_NLW & FIELD_GET() instead of custom defines/code
Quoted 7 lines · Ilpo Järvinen
e1000e has own copy of PCI Negotiated Link Width field defines. Use the ones from
include/uapi/linux/pci_regs.hinstead of the custom ones and remove the custom ones and convert toFIELD_GET().Suggested-by Jonathan Cameron <[email protected]>Signed-off-by Ilpo Järvinen <[email protected]>Reviewed-by Jonathan Cameron <[email protected]>
Re: [Intel-wired-lan] [PATCH v4 2/3] e1000e: Use PCI_EXP_LNKSTA_NLW & FIELD_GET() instead of custom defines/code
In reply to Ilpo JärvinenQuoted 11 lines · Ilpo Järvinen
e1000e has own copy of PCI Negotiated Link Width field defines. Use the ones from
include/uapi/linux/pci_regs.hinstead of the custom ones and remove the custom ones and convert toFIELD_GET().Suggested-by Jonathan Cameron <[email protected]>Signed-off-by Ilpo Järvinen <[email protected]>Reviewed-by Jonathan Cameron <[email protected]>--- drivers/net/ethernet/intel/e1000e/defines.h | 2 -- drivers/net/ethernet/intel/e1000e/mac.c | 7 ++++--- 2 files changed, 4 insertions(+), 5 deletions(-)
PATCH v4 3/3 e1000e: Use pcie_capability_read_word() for reading LNKSTA
In reply to Ilpo JärvinenUse 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.
--- drivers/net/ethernet/intel/e1000e/defines.h | 1 - drivers/net/ethernet/intel/e1000e/mac.c | 11 ++++------- 2 files changed, 4 insertions(+), 8 deletions(-)
drivers/net/ethernet/intel/e1000e/defines.h +0 -1
@@ -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
drivers/net/ethernet/intel/e1000e/mac.c +4 -7
@@ -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); }
Signature · 1 line
2.30.2
Re: [PATCH v4 3/3] e1000e: Use pcie_capability_read_word() for reading LNKSTA
Quoted 9 lines · Ilpo Järvinen
Use
pcie_capability_read_word()for reading LNKSTA and remove the custom define that matches toPCI_EXP_LNKSTA.As only single user for
cap_offsetremains, replace it with a call topci_pcie_cap(). Instead ofe1000_adapter, make local variable out ofpci_devbecause both users are interested in it.Signed-off-by Ilpo Järvinen <[email protected]>Reviewed-by Jonathan Cameron <[email protected]>
Re: [Intel-wired-lan] [PATCH v4 3/3] e1000e: Use pcie_capability_read_word() for reading LNKSTA
In reply to Ilpo JärvinenQuoted 7 lines · Ilpo Järvinen
Use
pcie_capability_read_word()for reading LNKSTA and remove the custom define that matches toPCI_EXP_LNKSTA.As only single user for
cap_offsetremains, replace it with a call topci_pcie_cap(). Instead ofe1000_adapter, make local variable out ofpci_devbecause both users are interested in it.
Quoted 6 lines
Signed-off-by Ilpo Järvinen <[email protected]>Reviewed-by Jonathan Cameron <[email protected]>--- drivers/net/ethernet/intel/e1000e/defines.h | 1 - drivers/net/ethernet/intel/e1000e/mac.c | 11 ++++------- 2 files changed, 4 insertions(+), 8 deletions(-)