igc: Add NVM support
Subsystems (2)
PATCH v4 8/11 igc: Add NVM support
Add code for NVM support and get MAC address, complete probe method.
Sasha Neftin (v2):
minor cosmetic changes
Alexander Duyck (v3):
NVM access code optimization
Sasha Neftin (v4):
fix xmas tree layout
remove no need spaces
rework igc_read_nvm_srrd/srwr and igc_validate_nvm_checksum_i225 methods as suggested by Shannon Nelson's approach remove obsolete comments
replace e1000_ prefix with igc_ prefix
remove unused NVM control definitions
remove unused NVM Word offsets
remove unused SW FW SYNC definition
fix duplication of mask definition
--- drivers/net/ethernet/intel/igc/Makefile | 2 +- drivers/net/ethernet/intel/igc/igc.h | 6 + drivers/net/ethernet/intel/igc/igc_base.c | 118 ++++++++- drivers/net/ethernet/intel/igc/igc_defines.h | 54 ++++- drivers/net/ethernet/intel/igc/igc_hw.h | 3 + drivers/net/ethernet/intel/igc/igc_i225.c | 350 +++++++++++++++++++++++++++ drivers/net/ethernet/intel/igc/igc_i225.h | 3 + drivers/net/ethernet/intel/igc/igc_mac.c | 173 +++++++++++++ drivers/net/ethernet/intel/igc/igc_mac.h | 5 + drivers/net/ethernet/intel/igc/igc_main.c | 20 +- drivers/net/ethernet/intel/igc/igc_nvm.c | 215 ++++++++++++++++ drivers/net/ethernet/intel/igc/igc_nvm.h | 14 ++ drivers/net/ethernet/intel/igc/igc_regs.h | 3 + 13 files changed, 958 insertions(+), 8 deletions(-) create mode 100644 drivers/net/ethernet/intel/igc/igc_nvm.c create mode 100644 drivers/net/ethernet/intel/igc/igc_nvm.h
drivers/net/ethernet/intel/igc/Makefile +1 -1
@@ -7,4 +7,4 @@ obj-$(CONFIG_IGC) += igc.o -igc-objs := igc_main.o igc_mac.o igc_i225.o igc_base.o +igc-objs := igc_main.o igc_mac.o igc_i225.o igc_base.o igc_nvm.o
drivers/net/ethernet/intel/igc/igc.h +6 -0
@@ -131,6 +131,10 @@ enum igc_tx_flags { IGC_TX_FLAGS_CSUM = 0x20, }; +enum igc_boards { + board_base, +}; +/** * The largest size we can write to the descriptor is 65535. In order to * maintain a power of two alignment we have to limit ourselves to 32K.
@@ -348,6 +352,8 @@ struct igc_adapter {spinlock_t nfc_lock;struct igc_mac_addr *mac_table; + +struct igc_info ei; };/* igc_desc_unused - calculate if we have unused descriptors */
drivers/net/ethernet/intel/igc/igc_base.c +115 -3
165 lines not on this page · raw message
drivers/net/ethernet/intel/igc/igc_defines.h +52 -2
76 lines not on this page · raw message
drivers/net/ethernet/intel/igc/igc_hw.h +3 -0
@@ -11,6 +11,7 @@#include "igc_regs.h" #include "igc_defines.h" #include "igc_mac.h" +#include "igc_nvm.h" #include "igc_i225.h" #include "igc_base.h"
@@ -81,6 +82,8 @@ struct igc_info {struct igc_nvm_operations *nvm_ops; }; +extern const struct igc_info igc_base_info; +struct igc_mac_info {struct igc_mac_operations ops;
drivers/net/ethernet/intel/igc/igc_i225.c +350 -0
359 lines not on this page · raw message
drivers/net/ethernet/intel/igc/igc_i225.h +3 -0
@@ -7,4 +7,7 @@s32 igc_acquire_swfw_sync_i225 (struct igc_hw *hw,u16 mask);void igc_release_swfw_sync_i225 (struct igc_hw *hw,u16 mask); +s32 igc_init_nvm_params_i225 (struct igc_hw *hw); +bool igc_get_flash_presence_i225 (struct igc_hw *hw); +#endif
drivers/net/ethernet/intel/igc/igc_mac.c +173 -0
185 lines not on this page · raw message
drivers/net/ethernet/intel/igc/igc_mac.h +5 -0
@@ -12,13 +12,18 @@#endif /* IGC_REMOVED */ /* forward declaration */ +s32 igc_check_for_copper_link (struct igc_hw *hw);s32 igc_disable_pcie_master (struct igc_hw *hw);void igc_init_rx_addrs (struct igc_hw *hw,u16 rar_count);s32 igc_setup_link (struct igc_hw *hw);void igc_clear_hw_cntrs_base (struct igc_hw *hw);s32 igc_get_auto_rd_done (struct igc_hw *hw);void igc_put_hw_semaphore (struct igc_hw *hw); +void igc_rar_set (struct igc_hw *hw,u8 *addr,u32 index); +void igc_config_collision_dist (struct igc_hw *hw);s32 igc_get_bus_info_pcie (struct igc_hw *hw); +s32 igc_get_speed_and_duplex_copper (struct igc_hw *hw,u16 *speed, +u16 *duplex);#endif
drivers/net/ethernet/intel/igc/igc_main.c +18 -2
@@ -19,9 +19,13 @@ static const char igc_driver_string[] = DRV_SUMMARY;static const char igc_copyright[] ="Copyright(c) 2018 Intel Corporation." ; +static const struct igc_info *igc_info_tbl[] = { + [board_base] = &igc_base_info, +}; +static const struct pci_device_id igc_pci_tbl[] = { - {PCI_VDEVICE (INTEL ,IGC_DEV_ID_I225_LM ) }, - {PCI_VDEVICE (INTEL ,IGC_DEV_ID_I225_V ) }, + {PCI_VDEVICE (INTEL ,IGC_DEV_ID_I225_LM ), board_base }, + {PCI_VDEVICE (INTEL ,IGC_DEV_ID_I225_V ), board_base },/* required last entry */ {0 , } };
@@ -3311,6 +3315,7 @@ static int igc_probe(struct pci_dev *pdev,struct igc_adapter *adapter;struct net_device *netdev;struct igc_hw *hw; +const struct igc_info *ei = igc_info_tbl[ent->driver_data];int err, pci_using_dac; err =pci_enable_device_mem (pdev);
@@ -3394,6 +3399,14 @@ static int igc_probe(struct pci_dev *pdev, hw->subsystem_vendor_id = pdev->subsystem_vendor; hw->subsystem_device_id = pdev->subsystem_device; +/* Copy the default MAC and PHY function pointers */ +memcpy (&hw->mac.ops, ei->mac_ops,sizeof (hw->mac.ops)); + +/* Initialize skew-specific constants */ + err = ei->get_invariants (hw); +if (err) + goto err_sw_init; +/* setup the private structure */ err =igc_sw_init (adapter);if (err)
@@ -3429,6 +3442,9 @@ static int igc_probe(struct pci_dev *pdev,/* carrier off reporting is important to ethtool even BEFORE open */ netif_carrier_off (netdev); +/* Check if Media Autosense is enabled */ + adapter->ei = *ei; +/* print pcie link status and MAC address */ pcie_print_link_status (pdev);netdev_info (netdev,"MAC: %pM\n" , netdev->dev_addr);
drivers/net/ethernet/intel/igc/igc_nvm.c new file +215 -0
215 lines not on this page · raw message
drivers/net/ethernet/intel/igc/igc_nvm.h new file +14 -0
@@ -0,0 +1,14 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (c) 2018 Intel Corporation */ + +#ifndef _IGC_NVM_H_ +#define _IGC_NVM_H_ + +s32 igc_acquire_nvm (struct igc_hw *hw); +void igc_release_nvm (struct igc_hw *hw); +s32 igc_read_mac_addr (struct igc_hw *hw); +s32 igc_read_nvm_eerd (struct igc_hw *hw,u16 offset,u16 words,u16 *data); +s32 igc_validate_nvm_checksum (struct igc_hw *hw); +s32 igc_update_nvm_checksum (struct igc_hw *hw); + +#endif
drivers/net/ethernet/intel/igc/igc_regs.h +3 -0
@@ -191,6 +191,9 @@/* Management registers */ #define IGC_MANC 0x05820/* Management Control - RW */ +/* Shadow Ram Write Register - RW */ +#define IGC_SRWR 0x12018 +/* forward declaration */ struct igc_hw ;u32 igc_rd32 (struct igc_hw *hw,u32 reg);
Signature · 1 line
2.11.0
kbuild test robot
build botThank you for the patch! Perhaps something to improve:
Hi Sasha,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on jkirsher-next-queue/dev-queue]
[also build test WARNING on v4.18-rc5 next-20180718]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Sasha-Neftin/igc-Add-skeletal-frame-for-Intel-R-2-5G-Ethernet-Controller-support/20180719-055021 base: https://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next-queue.git dev-queue reproduce: # apt-get install sparse make ARCH=x86_64 allmodconfig make C=1 CF=-D__CHECK_ENDIAN__
sparse warnings: (new ones prefixed by >>)
>> drivers/net/ethernet/intel/igc/igc_nvm.c:52:9: sparse: incorrect type in initializer (different address spaces) @@ expected unsigned char [noderef] [usertype] <asn:2>*hw_addr @@ got deref] [usertype] <asn:2>*hw_addr @@
drivers/net/ethernet/intel/igc/igc_nvm.c:52:9: expected unsigned char [noderef] [usertype] <asn:2>*hw_addr
drivers/net/ethernet/intel/igc/igc_nvm.c:52:9: got unsigned char [usertype] *__val
drivers/net/ethernet/intel/igc/igc_nvm.c:65:17: sparse: incorrect type in initializer (different address spaces) @@ expected unsigned char [noderef] [usertype] <asn:2>*hw_addr @@ got deref] [usertype] <asn:2>*hw_addr @@
drivers/net/ethernet/intel/igc/igc_nvm.c:65:17: expected unsigned char [noderef] [usertype] <asn:2>*hw_addr
drivers/net/ethernet/intel/igc/igc_nvm.c:65:17: got unsigned char [usertype] *__val
drivers/net/ethernet/intel/igc/igc_nvm.c:85:9: sparse: incorrect type in initializer (different address spaces) @@ expected unsigned char [noderef] [usertype] <asn:2>*hw_addr @@ got deref] [usertype] <asn:2>*hw_addr @@
drivers/net/ethernet/intel/igc/igc_nvm.c:85:9: expected unsigned char [noderef] [usertype] <asn:2>*hw_addr
drivers/net/ethernet/intel/igc/igc_nvm.c:85:9: got unsigned char [usertype] *__val
drivers/net/ethernet/intel/igc/igc_nvm.c:117:17: sparse: incorrect type in initializer (different address spaces) @@ expected unsigned char [noderef] [usertype] <asn:2>*hw_addr @@ got deref] [usertype] <asn:2>*hw_addr @@
drivers/net/ethernet/intel/igc/igc_nvm.c:117:17: expected unsigned char [noderef] [usertype] <asn:2>*hw_addr
drivers/net/ethernet/intel/igc/igc_nvm.c:117:17: got unsigned char [usertype] *__val
vim +52 drivers/net/ethernet/intel/igc/igc_nvm.c
37
38 /**
39 * igc_acquire_nvm - Generic request for access to EEPROM
40 * @hw: pointer to the HW structure
41 *
42 * Set the EEPROM access request bit and wait for EEPROM access grant bit.
43 * Return successful if access grant bit set, else clear the request for
44 * EEPROM access and return -IGC_ERR_NVM (-1).
45 **/
46 s32 igc_acquire_nvm(struct igc_hw *hw)
47 {
48 s32 timeout = IGC_NVM_GRANT_ATTEMPTS;
49 u32 eecd = rd32(IGC_EECD);
50 s32 ret_val = 0;
51
> 52 wr32(IGC_EECD, eecd | IGC_EECD_REQ);
53 eecd = rd32(IGC_EECD);
54
55 while (timeout) {
56 if (eecd & IGC_EECD_GNT)
57 break;
58 udelay(5);
59 eecd = rd32(IGC_EECD);
60 timeout--;
61 }
62
63 if (!timeout) {
64 eecd &= ~IGC_EECD_REQ;
65 wr32(IGC_EECD, eecd);
66 hw_dbg("Could not acquire NVM grant\n");
67 ret_val = -IGC_ERR_NVM;
68 }
69
70 return ret_val;
71 }
72 ---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation