Skip to contentSkip to conversation

igc: Add setup link functionality

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 10/11 igc: Add setup link functionality

Add link establishment methods
Add auto negotiation methods
Add read MAC address method

Sasha Neftin (v2):
minor cosmetic changes

Sasha Neftin (v3):
remove not addressed methods

Sasha Neftin (v4):
address comments
remove improperly insertion of method from a patch replace e1000_ prefix with igc_ prefix remove duplicate PHY MII defines

Sasha Neftin (v5):
code clean
remove obsolete flash_address reference
fix initial autoneg advertisement and add 2.5G option
add option to clear the 2.5 Gbps advertising bit and disable 2.5 Gbps speed

Sasha Neftin (v6):
minor cosmetic changes

---
 drivers/net/ethernet/intel/igc/igc.h         |   1 +
 drivers/net/ethernet/intel/igc/igc_base.c    |  41 +++
 drivers/net/ethernet/intel/igc/igc_defines.h |  38 +++
 drivers/net/ethernet/intel/igc/igc_mac.c     | 271 +++++++++++++++
 drivers/net/ethernet/intel/igc/igc_mac.h     |   2 +
 drivers/net/ethernet/intel/igc/igc_main.c    |  30 ++
 drivers/net/ethernet/intel/igc/igc_phy.c     | 334 +++++++++++++++++++
 drivers/net/ethernet/intel/igc/igc_phy.h     |   2 +
 8 files changed, 719 insertions(+)
drivers/net/ethernet/intel/igc/igc.h +1 -0
index 85a8edf5722c..599212c89dfd 100644
@@ -320,6 +320,7 @@ struct igc_adapter {
 	struct work_struct reset_task;
 	struct work_struct watchdog_task;
 	struct work_struct dma_err_task;
+	bool fc_autoneg;
 
 	u8  tx_timeout_factor;
 
drivers/net/ethernet/intel/igc/igc_base.c +41 -0

75 lines not on this page · raw message

drivers/net/ethernet/intel/igc/igc_defines.h +38 -0
index 5e9e646ad4c0..95d7891a252c 100644
@@ -16,6 +16,11 @@
 /* Physical Func Reset Done Indication */
 #define IGC_CTRL_EXT_LINK_MODE_MASK	0x00C00000
 
+/* Loop limit on how long we wait for auto-negotiation to complete */
+#define COPPER_LINK_UP_LIMIT		10
+#define PHY_AUTO_NEG_LIMIT		45
+#define PHY_FORCE_LIMIT			20
+
 /* Number of 100 microseconds we wait for PCI Express master disable */
 #define MASTER_DISABLE_TIMEOUT		800
 /*Blocks new Master requests */
@@ -57,6 +62,12 @@
 #define IGC_CTRL_RST		0x04000000  /* Global reset */
 
 #define IGC_CTRL_PHY_RST	0x80000000  /* PHY Reset */
+#define IGC_CTRL_SLU		0x00000040  /* Set link up (Force Link) */
+#define IGC_CTRL_FRCSPD		0x00000800  /* Force Speed */
+#define IGC_CTRL_FRCDPX		0x00001000  /* Force Duplex */
+
+#define IGC_CTRL_RFCE		0x08000000  /* Receive Flow Control enable */
+#define IGC_CTRL_TFCE		0x10000000  /* Transmit flow control enable */
 
 /* PBA constants */
 #define IGC_PBA_34K		0x0022
@@ -69,6 +80,29 @@
 #define IGC_SWFW_EEP_SM		0x1
 #define IGC_SWFW_PHY0_SM	0x2
 
+/* Autoneg Advertisement Register */
+#define NWAY_AR_10T_HD_CAPS	0x0020   /* 10T   Half Duplex Capable */
+#define NWAY_AR_10T_FD_CAPS	0x0040   /* 10T   Full Duplex Capable */
+#define NWAY_AR_100TX_HD_CAPS	0x0080   /* 100TX Half Duplex Capable */
+#define NWAY_AR_100TX_FD_CAPS	0x0100   /* 100TX Full Duplex Capable */
+#define NWAY_AR_PAUSE		0x0400   /* Pause operation desired */
+#define NWAY_AR_ASM_DIR		0x0800   /* Asymmetric Pause Direction bit */
+
+/* Link Partner Ability Register (Base Page) */
+#define NWAY_LPAR_PAUSE		0x0400 /* LP Pause operation desired */
+#define NWAY_LPAR_ASM_DIR	0x0800 /* LP Asymmetric Pause Direction bit */
+
+/* 1000BASE-T Control Register */
+#define CR_1000T_ASYM_PAUSE	0x0080 /* Advertise asymmetric pause bit */
+#define CR_1000T_HD_CAPS	0x0100 /* Advertise 1000T HD capability */
+#define CR_1000T_FD_CAPS	0x0200 /* Advertise 1000T FD capability  */
+
+/* PHY GPY 211 registers */
+#define STANDARD_AN_REG_MASK	0x0007 /* MMD */
+#define ANEG_MULTIGBT_AN_CTRL	0x0020 /* MULTI GBT AN Control Register */
+#define MMD_DEVADDR_SHIFT	16     /* Shift MMD to higher bits */
+#define CR_2500T_FD_CAPS	0x0080 /* Advertise 2500T FD capability */
+
 /* NVM Control */
 /* Number of milliseconds for NVM auto read done after MAC reset. */
 #define AUTO_READ_DONE_TIMEOUT		10
@@ -321,6 +355,10 @@
 #define PHY_STATUS		0x01 /* Status Register */
 #define PHY_ID1			0x02 /* Phy Id Reg (word 1) */
 #define PHY_ID2			0x03 /* Phy Id Reg (word 2) */
+#define PHY_AUTONEG_ADV		0x04 /* Autoneg Advertisement */
+#define PHY_LP_ABILITY		0x05 /* Link Partner Ability (Base Page) */
+#define PHY_1000T_CTRL		0x09 /* 1000Base-T Control Reg */
+#define PHY_1000T_STATUS	0x0A /* 1000Base-T Status Reg */
 
 /* Bit definitions for valid PHY IDs. I = Integrated E = External */
 #define I225_I_PHY_ID		0x67C9DC00
drivers/net/ethernet/intel/igc/igc_mac.c +271 -0

298 lines not on this page · raw message

drivers/net/ethernet/intel/igc/igc_mac.h +2 -0
index e61b9c5faa32..d60959f98ebc 100644
@@ -14,6 +14,8 @@
 
 /* forward declaration */
 s32 igc_check_for_copper_link(struct igc_hw *hw);
+s32 igc_config_fc_after_link_up(struct igc_hw *hw);
+s32 igc_force_mac_fc(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);
drivers/net/ethernet/intel/igc/igc_main.c +30 -0
index bd41ad5eaf65..528d2bdb113b 100644
@@ -3427,6 +3427,25 @@ static int igc_probe(struct pci_dev *pdev,
 	netdev->min_mtu = ETH_MIN_MTU;
 	netdev->max_mtu = MAX_STD_JUMBO_FRAME_SIZE;
 
+	/* before reading the NVM, reset the controller to put the device in a
+	 * known good starting state
+	 */
+	hw->mac.ops.reset_hw(hw);
+
+	if (eth_platform_get_mac_address(&pdev->dev, hw->mac.addr)) {
+		/* copy the MAC address out of the NVM */
+		if (hw->mac.ops.read_mac_addr(hw))
+			dev_err(&pdev->dev, "NVM Read Error\n");
+	}
+
+	memcpy(netdev->dev_addr, hw->mac.addr, netdev->addr_len);
+
+	if (!is_valid_ether_addr(netdev->dev_addr)) {
+		dev_err(&pdev->dev, "Invalid MAC Address\n");
+		err = -EIO;
+		goto err_eeprom;
+	}
+
 	/* configure RXPBSIZE and TXPBSIZE */
 	wr32(IGC_RXPBS, I225_RXPBSIZE_DEFAULT);
 	wr32(IGC_TXPBS, I225_TXPBSIZE_DEFAULT);
@@ -3435,6 +3454,14 @@ static int igc_probe(struct pci_dev *pdev,
 
 	INIT_WORK(&adapter->reset_task, igc_reset_task);
 
+	/* Initialize link properties that are user-changeable */
+	adapter->fc_autoneg = true;
+	hw->mac.autoneg = true;
+	hw->phy.autoneg_advertised = 0xaf;
+
+	hw->fc.requested_mode = igc_fc_default;
+	hw->fc.current_mode = igc_fc_default;
+
 	/* reset the hardware with the new settings */
 	igc_reset(adapter);
 
@@ -3462,6 +3489,9 @@ static int igc_probe(struct pci_dev *pdev,
 
 err_register:
 	igc_release_hw_control(adapter);
+err_eeprom:
+	if (!igc_check_reset_block(hw))
+		igc_reset_phy(hw);
 err_sw_init:
 	igc_clear_interrupt_scheme(adapter);
 	iounmap(adapter->io_addr);
drivers/net/ethernet/intel/igc/igc_phy.c +334 -0

346 lines not on this page · raw message

drivers/net/ethernet/intel/igc/igc_phy.h +2 -0
index deac52297052..8fc8873f0b2e 100644
@@ -12,8 +12,10 @@ s32  igc_get_phy_id(struct igc_hw *hw);
 s32  igc_phy_has_link(struct igc_hw *hw, u32 iterations,
 		      u32 usec_interval, bool *success);
 s32 igc_check_downshift(struct igc_hw *hw);
+s32 igc_setup_copper_link(struct igc_hw *hw);
 void igc_power_up_phy_copper(struct igc_hw *hw);
 void igc_power_down_phy_copper(struct igc_hw *hw);
+
 s32  igc_write_phy_reg_gpy(struct igc_hw *hw, u32 offset, u16 data);
 s32  igc_read_phy_reg_gpy(struct igc_hw *hw, u32 offset, u16 *data);
 
Signature · 1 line
2.18.0