Skip to contentSkip to conversation

igc: Add HW initialization code

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 7/11 igc: Add HW initialization code

Add code for hw initialization and reset.
Add code for semaphore handling.

Sasha Neftin (v2):
fix code indentation
refactor of igc_desc_unused method

Sasha Neftin (v3):
clean code and remove unused methods

Sasha Neftin (v4):
address comments
fix comments in e1000_i225.c and e1000_regs.h files fix xmas tree layout
fix typos in e1000_mac.c file
replace e1000_ prefix with igc_ prefix

Sasha Neftin (v5):
fix code indentation

Sasha Neftin (v6):
fix code indentation
remove unused defines
minor cosmetic changes

---
 drivers/net/ethernet/intel/igc/Makefile      |   2 +-
 drivers/net/ethernet/intel/igc/igc_base.c    | 192 +++++++++++
 drivers/net/ethernet/intel/igc/igc_base.h    |   2 +
 drivers/net/ethernet/intel/igc/igc_defines.h |  36 +++
 drivers/net/ethernet/intel/igc/igc_hw.h      |  85 +++++
 drivers/net/ethernet/intel/igc/igc_i225.c    | 141 ++++++++
 drivers/net/ethernet/intel/igc/igc_mac.c     | 320 +++++++++++++++++++
 drivers/net/ethernet/intel/igc/igc_mac.h     |  11 +
 drivers/net/ethernet/intel/igc/igc_main.c    |  21 ++
 drivers/net/ethernet/intel/igc/igc_regs.h    |  20 ++
 10 files changed, 829 insertions(+), 1 deletion(-)
 create mode 100644 drivers/net/ethernet/intel/igc/igc_i225.c
drivers/net/ethernet/intel/igc/Makefile +1 -1
index c32c45300692..8b8022ea590a 100644
@@ -7,4 +7,4 @@
 
 obj-$(CONFIG_IGC) += igc.o
 
-igc-objs := igc_main.o igc_mac.o igc_base.o
+igc-objs := igc_main.o igc_mac.o igc_i225.o igc_base.o
drivers/net/ethernet/intel/igc/igc_base.c +192 -0

201 lines not on this page · raw message

drivers/net/ethernet/intel/igc/igc_base.h +2 -0
index 3078a18f70a9..802a0cbd3123 100644
@@ -33,6 +33,8 @@ union igc_adv_tx_desc {
 #define IGC_ADVTXD_DCMD_TSE	0x80000000 /* TCP Seg enable */
 #define IGC_ADVTXD_PAYLEN_SHIFT	14 /* Adv desc PAYLEN shift */
 
+#define IGC_RAR_ENTRIES		16
+
 struct igc_adv_data_desc {
 	__le64 buffer_addr;    /* Address of the descriptor's data buffer */
 	union {
drivers/net/ethernet/intel/igc/igc_defines.h +36 -0
index f3dfd5a08670..73475ac958d5 100644
@@ -13,6 +13,22 @@
 #define PCIE_DEVICE_CONTROL2		0x28
 #define PCIE_DEVICE_CONTROL2_16ms	0x0005
 
+/* Physical Func Reset Done Indication */
+#define IGC_CTRL_EXT_LINK_MODE_MASK	0x00C00000
+
+/* Number of 100 microseconds we wait for PCI Express master disable */
+#define MASTER_DISABLE_TIMEOUT		800
+/*Blocks new Master requests */
+#define IGC_CTRL_GIO_MASTER_DISABLE	0x00000004
+/* Status of Master requests. */
+#define IGC_STATUS_GIO_MASTER_ENABLE	0x00080000
+
+/* PCI Express Control */
+#define IGC_GCR_CMPL_TMOUT_MASK		0x0000F000
+#define IGC_GCR_CMPL_TMOUT_10ms		0x00001000
+#define IGC_GCR_CMPL_TMOUT_RESEND	0x00010000
+#define IGC_GCR_CAP_VER2		0x00040000
+
 /* Receive Address
  * Number of high/low register pairs in the RAR. The RAR (Receive Address
  * Registers) holds the directed and multicast addresses that we monitor.
@@ -31,10 +47,23 @@
 #define IGC_ERR_PARAM			4
 #define IGC_ERR_MAC_INIT		5
 #define IGC_ERR_RESET			9
+#define IGC_ERR_MASTER_REQUESTS_PENDING	10
+#define IGC_ERR_SWFW_SYNC		13
+
+/* Device Control */
+#define IGC_CTRL_RST		0x04000000  /* Global reset */
 
 /* PBA constants */
 #define IGC_PBA_34K		0x0022
 
+/* SW Semaphore Register */
+#define IGC_SWSM_SMBI		0x00000001 /* Driver Semaphore bit */
+#define IGC_SWSM_SWESMBI	0x00000002 /* FW Semaphore bit */
+
+/* Number of milliseconds for NVM auto read done after MAC reset. */
+#define AUTO_READ_DONE_TIMEOUT		10
+#define IGC_EECD_AUTO_RD		0x00000200  /* NVM Auto Read done */
+
 /* Device Status */
 #define IGC_STATUS_FD		0x00000001      /* Full duplex.0=half,1=full */
 #define IGC_STATUS_LU		0x00000002      /* Link up.0=no,1=link */
@@ -121,6 +150,13 @@
 #define IGC_CT_SHIFT			4
 #define IGC_COLLISION_THRESHOLD		15
 
+/* Flow Control Constants */
+#define FLOW_CONTROL_ADDRESS_LOW	0x00C28001
+#define FLOW_CONTROL_ADDRESS_HIGH	0x00000100
+#define FLOW_CONTROL_TYPE		0x8808
+/* Enable XON frame transmission */
+#define IGC_FCRTL_XONE			0x80000000
+
 /* Management Control */
 #define IGC_MANC_RCV_TCO_EN	0x00020000 /* Receive TCO Packets Enabled */
 
drivers/net/ethernet/intel/igc/igc_hw.h +85 -0

136 lines not on this page · raw message

drivers/net/ethernet/intel/igc/igc_i225.c new file +141 -0

141 lines not on this page · raw message

drivers/net/ethernet/intel/igc/igc_mac.c +320 -0

331 lines not on this page · raw message

drivers/net/ethernet/intel/igc/igc_mac.h +11 -0
index f5de0213c2a5..1337168dc93a 100644
@@ -4,10 +4,21 @@
 #ifndef _IGC_MAC_H_
 #define _IGC_MAC_H_
 
+#include "igc_hw.h"
+#include "igc_defines.h"
+
 #ifndef IGC_REMOVED
 #define IGC_REMOVED@ (0)
 #endif /* IGC_REMOVED */
 
+/* forward declaration */
+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);
+
 s32 igc_get_bus_info_pcie(struct igc_hw *hw);
 
 #endif
drivers/net/ethernet/intel/igc/igc_main.c +21 -0
index 45a64db6e250..e5b8b020a30e 100644
@@ -86,6 +86,14 @@ enum latency_range {
 
 static void igc_reset(struct igc_adapter *adapter)
 {
+	struct pci_dev *pdev = adapter->pdev;
+	struct igc_hw *hw = &adapter->hw;
+
+	hw->mac.ops.reset_hw(hw);
+
+	if (hw->mac.ops.init_hw(hw))
+		dev_err(&pdev->dev, "Hardware Error\n");
+
 	if (!netif_running(adapter->netdev))
 		igc_power_down_link(adapter);
 }
@@ -3582,6 +3590,19 @@ static void igc_nfc_filter_exit(struct igc_adapter *adapter)
 {
 }
 
+/**
+ *  igc_get_hw_dev - return device
+ *  @hw: pointer to hardware structure
+ *
+ *  used by hardware layer to print debugging information
+ **/
+struct net_device *igc_get_hw_dev(struct igc_hw *hw)
+{
+	struct igc_adapter *adapter = hw->back;
+
+	return adapter->netdev;
+}
+
 /**
  *  igc_init_module - Driver Registration Routine
  *
drivers/net/ethernet/intel/igc/igc_regs.h +20 -0
index 753ac667c5a9..fc7cce5d9b7a 100644
@@ -7,6 +7,7 @@
 /* General Register Descriptions */
 #define IGC_CTRL		0x00000  /* Device Control - RW */
 #define IGC_STATUS		0x00008  /* Device Status - RO */
+#define IGC_EECD		0x00010  /* EEPROM/Flash Control - RW */
 #define IGC_CTRL_EXT		0x00018  /* Extended Device Control - RW */
 #define IGC_MDIC		0x00020  /* MDI Control - RW */
 #define IGC_MDICNFG		0x00E04  /* MDC/MDIO Configuration - RW */
@@ -56,6 +57,23 @@
 #define IGC_IVAR_MISC		0x01740   /* IVAR for "other" causes - RW */
 #define IGC_GPIE		0x01514  /* General Purpose Intr Enable - RW */
 
+/* Interrupt Cause */
+#define IGC_ICRXPTC		0x04104  /* Rx Packet Timer Expire Count */
+#define IGC_ICRXATC		0x04108  /* Rx Absolute Timer Expire Count */
+#define IGC_ICTXPTC		0x0410C  /* Tx Packet Timer Expire Count */
+#define IGC_ICTXATC		0x04110  /* Tx Absolute Timer Expire Count */
+#define IGC_ICTXQEC		0x04118  /* Tx Queue Empty Count */
+#define IGC_ICTXQMTC		0x0411C  /* Tx Queue Min Threshold Count */
+#define IGC_ICRXDMTC		0x04120  /* Rx Descriptor Min Threshold Count */
+#define IGC_ICRXOC		0x04124  /* Receiver Overrun Count */
+
+#define IGC_CBTMPC		0x0402C  /* Circuit Breaker TX Packet Count */
+#define IGC_HTDPMC		0x0403C  /* Host Transmit Discarded Packets */
+#define IGC_CBRMPC		0x040FC  /* Circuit Breaker RX Packet Count */
+#define IGC_RPTHC		0x04104  /* Rx Packets To Host */
+#define IGC_HGPTC		0x04118  /* Host Good Packets TX Count */
+#define IGC_HTCBDPC		0x04124  /* Host TX Circ.Breaker Drop Count */
+
 /* MSI-X Table Register Descriptions */
 #define IGC_PBACL		0x05B68  /* MSIx PBA Clear - R/W 1 to clear */
 
@@ -73,6 +91,8 @@
 #define IGC_RXCSUM		0x05000  /* Rx Checksum Control - RW */
 #define IGC_RLPML		0x05004  /* Rx Long Packet Max Length */
 #define IGC_RFCTL		0x05008  /* Receive Filter Control*/
+#define IGC_MTA			0x05200  /* Multicast Table Array - RW Array */
+#define IGC_UTA			0x0A000  /* Unicast Table Array - RW */
 #define IGC_RAL(_n)		(0x05400 + ((_n) * 0x08))
 #define IGC_RAH(_n)		(0x05404 + ((_n) * 0x08))
 
Signature · 1 line
2.18.0