Skip to contentSkip to conversation

igc: Add NVM support

PATCH Superseded Sasha Neftin 1 participant 1 message Aug 23, 2018

Subsystems (2)

v6 of 8 Superseded Latest is v8 →

lore
Share & tools
lore
#0 lore raw

PATCH v6 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 fix few 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

Sasha Neftin (v5):
no changes

Sasha Neftin (v6):
minor cosmetic changes
remove duplication of defines

---
 drivers/net/ethernet/intel/igc/Makefile      |   2 +-
 drivers/net/ethernet/intel/igc/igc.h         |   6 +
 drivers/net/ethernet/intel/igc/igc_base.c    | 111 ++++++
 drivers/net/ethernet/intel/igc/igc_defines.h |  52 +++
 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     | 170 +++++++++
 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, 951 insertions(+), 3 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
index 8b8022ea590a..2b5378d96c7b 100644
@@ -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
index f44648aa39a7..488f8220359b 100644
@@ -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 +111 -0

154 lines not on this page · raw message

drivers/net/ethernet/intel/igc/igc_defines.h +52 -0

73 lines not on this page · raw message

drivers/net/ethernet/intel/igc/igc_hw.h +3 -0
index 0fd8c9c486f0..e4d7c2fad1ad 100644
@@ -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
index 461cd8c7e352..7b66e1f9c0e6 100644
@@ -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 +170 -0

182 lines not on this page · raw message

drivers/net/ethernet/intel/igc/igc_mac.h +5 -0
index 1337168dc93a..7d935d581fc7 100644
@@ -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
index e5b8b020a30e..361effecb7dd 100644
@@ -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, }
 };
@@ -3309,6 +3313,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);
@@ -3392,6 +3397,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)
@@ -3427,6 +3440,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
new file mode 100644
index 000000000000..dcca6c699531
@@ -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
index fc7cce5d9b7a..aaeaf61b730a 100644
@@ -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.18.0