diff options
Diffstat (limited to 'drivers/net/ethernet/intel')
85 files changed, 6233 insertions, 3081 deletions
diff --git a/drivers/net/ethernet/intel/Kconfig b/drivers/net/ethernet/intel/Kconfig index ddee4060948..05f7264c51f 100644 --- a/drivers/net/ethernet/intel/Kconfig +++ b/drivers/net/ethernet/intel/Kconfig @@ -5,11 +5,6 @@  config NET_VENDOR_INTEL  	bool "Intel devices"  	default y -	depends on PCI || PCI_MSI || ISA || ISA_DMA_API || ARM || \ -		   ARCH_ACORN || MCA || MCA_LEGACY || SNI_RM || SUN3 || \ -		   GSC || BVME6000 || MVME16x || \ -		   (ARM && ARCH_IXP4XX && IXP4XX_NPE && IXP4XX_QMGR) || \ -		   EXPERIMENTAL  	---help---  	  If you have a network (Ethernet) card belonging to this class, say Y  	  and read the Ethernet-HOWTO, available from @@ -74,6 +69,7 @@ config E1000E  	tristate "Intel(R) PRO/1000 PCI-Express Gigabit Ethernet support"  	depends on PCI && (!SPARC32 || BROKEN)  	select CRC32 +	select PTP_1588_CLOCK  	---help---  	  This driver supports the PCI-Express Intel(R) PRO/1000 gigabit  	  ethernet family of adapters. For PCI or PCI-X e1000 adapters, @@ -94,6 +90,8 @@ config IGB  	tristate "Intel(R) 82575/82576 PCI-Express Gigabit Ethernet support"  	depends on PCI  	select PTP_1588_CLOCK +	select I2C +	select I2C_ALGOBIT  	---help---  	  This driver supports Intel(R) 82575/82576 gigabit ethernet family of  	  adapters.  For more information on how to identify your adapter, go @@ -112,6 +110,17 @@ config IGB  	  To compile this driver as a module, choose M here. The module  	  will be called igb. +config IGB_HWMON +	bool "Intel(R) PCI-Express Gigabit adapters HWMON support" +	default y +	depends on IGB && HWMON && !(IGB=y && HWMON=m) +	---help--- +	  Say Y if you want to expose thermal sensor data on Intel devices. + +	  Some of our devices contain thermal sensors, both external and internal. +	  This data is available via the hwmon sysfs interface and exposes +	  the onboard sensors. +  config IGB_DCA  	bool "Direct Cache Access (DCA) Support"  	default y diff --git a/drivers/net/ethernet/intel/e100.c b/drivers/net/ethernet/intel/e100.c index a59f0779e1c..ec800b093e7 100644 --- a/drivers/net/ethernet/intel/e100.c +++ b/drivers/net/ethernet/intel/e100.c @@ -2928,8 +2928,7 @@ static int e100_probe(struct pci_dev *pdev, const struct pci_device_id *ent)  	e100_phy_init(nic);  	memcpy(netdev->dev_addr, nic->eeprom, ETH_ALEN); -	memcpy(netdev->perm_addr, nic->eeprom, ETH_ALEN); -	if (!is_valid_ether_addr(netdev->perm_addr)) { +	if (!is_valid_ether_addr(netdev->dev_addr)) {  		if (!eeprom_bad_csum_allow) {  			netif_err(nic, probe, nic->netdev, "Invalid MAC address from EEPROM, aborting\n");  			err = -EAGAIN; diff --git a/drivers/net/ethernet/intel/e1000/e1000.h b/drivers/net/ethernet/intel/e1000/e1000.h index 2b6cd02bfba..26d9cd59ec7 100644 --- a/drivers/net/ethernet/intel/e1000/e1000.h +++ b/drivers/net/ethernet/intel/e1000/e1000.h @@ -81,68 +81,69 @@ struct e1000_adapter;  #include "e1000_hw.h" -#define E1000_MAX_INTR 10 +#define E1000_MAX_INTR			10  /* TX/RX descriptor defines */ -#define E1000_DEFAULT_TXD                  256 -#define E1000_MAX_TXD                      256 -#define E1000_MIN_TXD                       48 -#define E1000_MAX_82544_TXD               4096 +#define E1000_DEFAULT_TXD		256 +#define E1000_MAX_TXD			256 +#define E1000_MIN_TXD			48 +#define E1000_MAX_82544_TXD		4096 -#define E1000_DEFAULT_RXD                  256 -#define E1000_MAX_RXD                      256 -#define E1000_MIN_RXD                       48 -#define E1000_MAX_82544_RXD               4096 +#define E1000_DEFAULT_RXD		256 +#define E1000_MAX_RXD			256 +#define E1000_MIN_RXD			48 +#define E1000_MAX_82544_RXD		4096  #define E1000_MIN_ITR_USECS		10 /* 100000 irq/sec */  #define E1000_MAX_ITR_USECS		10000 /* 100    irq/sec */  /* this is the size past which hardware will drop packets when setting LPE=0 */ -#define MAXIMUM_ETHERNET_VLAN_SIZE 1522 +#define MAXIMUM_ETHERNET_VLAN_SIZE	1522  /* Supported Rx Buffer Sizes */ -#define E1000_RXBUFFER_128   128    /* Used for packet split */ -#define E1000_RXBUFFER_256   256    /* Used for packet split */ -#define E1000_RXBUFFER_512   512 -#define E1000_RXBUFFER_1024  1024 -#define E1000_RXBUFFER_2048  2048 -#define E1000_RXBUFFER_4096  4096 -#define E1000_RXBUFFER_8192  8192 -#define E1000_RXBUFFER_16384 16384 +#define E1000_RXBUFFER_128		128    /* Used for packet split */ +#define E1000_RXBUFFER_256		256    /* Used for packet split */ +#define E1000_RXBUFFER_512		512 +#define E1000_RXBUFFER_1024		1024 +#define E1000_RXBUFFER_2048		2048 +#define E1000_RXBUFFER_4096		4096 +#define E1000_RXBUFFER_8192		8192 +#define E1000_RXBUFFER_16384		16384  /* SmartSpeed delimiters */ -#define E1000_SMARTSPEED_DOWNSHIFT 3 -#define E1000_SMARTSPEED_MAX       15 +#define E1000_SMARTSPEED_DOWNSHIFT	3 +#define E1000_SMARTSPEED_MAX		15  /* Packet Buffer allocations */ -#define E1000_PBA_BYTES_SHIFT 0xA -#define E1000_TX_HEAD_ADDR_SHIFT 7 -#define E1000_PBA_TX_MASK 0xFFFF0000 +#define E1000_PBA_BYTES_SHIFT		0xA +#define E1000_TX_HEAD_ADDR_SHIFT	7 +#define E1000_PBA_TX_MASK		0xFFFF0000  /* Flow Control Watermarks */ -#define E1000_FC_HIGH_DIFF 0x1638  /* High: 5688 bytes below Rx FIFO size */ -#define E1000_FC_LOW_DIFF 0x1640   /* Low:  5696 bytes below Rx FIFO size */ +#define E1000_FC_HIGH_DIFF	0x1638 /* High: 5688 bytes below Rx FIFO size */ +#define E1000_FC_LOW_DIFF	0x1640 /* Low:  5696 bytes below Rx FIFO size */ -#define E1000_FC_PAUSE_TIME 0xFFFF /* pause for the max or until send xon */ +#define E1000_FC_PAUSE_TIME	0xFFFF /* pause for the max or until send xon */  /* How many Tx Descriptors do we need to call netif_wake_queue ? */  #define E1000_TX_QUEUE_WAKE	16  /* How many Rx Buffers do we bundle into one write to the hardware ? */ -#define E1000_RX_BUFFER_WRITE	16	/* Must be power of 2 */ +#define E1000_RX_BUFFER_WRITE	16 /* Must be power of 2 */ -#define AUTO_ALL_MODES            0 -#define E1000_EEPROM_82544_APM    0x0004 -#define E1000_EEPROM_APME         0x0400 +#define AUTO_ALL_MODES		0 +#define E1000_EEPROM_82544_APM	0x0004 +#define E1000_EEPROM_APME	0x0400  #ifndef E1000_MASTER_SLAVE  /* Switch to override PHY master/slave setting */  #define E1000_MASTER_SLAVE	e1000_ms_hw_default  #endif -#define E1000_MNG_VLAN_NONE (-1) +#define E1000_MNG_VLAN_NONE	(-1)  /* wrapper around a pointer to a socket buffer, - * so a DMA handle can be stored along with the buffer */ + * so a DMA handle can be stored along with the buffer + */  struct e1000_buffer {  	struct sk_buff *skb;  	dma_addr_t dma; diff --git a/drivers/net/ethernet/intel/e1000/e1000_ethtool.c b/drivers/net/ethernet/intel/e1000/e1000_ethtool.c index 14e30515f6a..43462d596a4 100644 --- a/drivers/net/ethernet/intel/e1000/e1000_ethtool.c +++ b/drivers/net/ethernet/intel/e1000/e1000_ethtool.c @@ -115,12 +115,12 @@ static int e1000_get_settings(struct net_device *netdev,  	if (hw->media_type == e1000_media_type_copper) {  		ecmd->supported = (SUPPORTED_10baseT_Half | -		                   SUPPORTED_10baseT_Full | -		                   SUPPORTED_100baseT_Half | -		                   SUPPORTED_100baseT_Full | -		                   SUPPORTED_1000baseT_Full| -		                   SUPPORTED_Autoneg | -		                   SUPPORTED_TP); +				   SUPPORTED_10baseT_Full | +				   SUPPORTED_100baseT_Half | +				   SUPPORTED_100baseT_Full | +				   SUPPORTED_1000baseT_Full| +				   SUPPORTED_Autoneg | +				   SUPPORTED_TP);  		ecmd->advertising = ADVERTISED_TP;  		if (hw->autoneg == 1) { @@ -161,8 +161,8 @@ static int e1000_get_settings(struct net_device *netdev,  		ethtool_cmd_speed_set(ecmd, adapter->link_speed);  		/* unfortunately FULL_DUPLEX != DUPLEX_FULL -		 *          and HALF_DUPLEX != DUPLEX_HALF */ - +		 * and HALF_DUPLEX != DUPLEX_HALF +		 */  		if (adapter->link_duplex == FULL_DUPLEX)  			ecmd->duplex = DUPLEX_FULL;  		else @@ -179,8 +179,7 @@ static int e1000_get_settings(struct net_device *netdev,  	if ((hw->media_type == e1000_media_type_copper) &&  	    netif_carrier_ok(netdev))  		ecmd->eth_tp_mdix = (!!adapter->phy_info.mdix_mode ? -							ETH_TP_MDI_X : -							ETH_TP_MDI); +				     ETH_TP_MDI_X : ETH_TP_MDI);  	else  		ecmd->eth_tp_mdix = ETH_TP_MDI_INVALID; @@ -197,8 +196,7 @@ static int e1000_set_settings(struct net_device *netdev,  	struct e1000_adapter *adapter = netdev_priv(netdev);  	struct e1000_hw *hw = &adapter->hw; -	/* -	 * MDI setting is only allowed when autoneg enabled because +	/* MDI setting is only allowed when autoneg enabled because  	 * some hardware doesn't allow MDI setting when speed or  	 * duplex is forced.  	 */ @@ -224,8 +222,8 @@ static int e1000_set_settings(struct net_device *netdev,  				     ADVERTISED_Autoneg;  		else  			hw->autoneg_advertised = ecmd->advertising | -			                         ADVERTISED_TP | -			                         ADVERTISED_Autoneg; +						 ADVERTISED_TP | +						 ADVERTISED_Autoneg;  		ecmd->advertising = hw->autoneg_advertised;  	} else {  		u32 speed = ethtool_cmd_speed(ecmd); @@ -260,8 +258,7 @@ static u32 e1000_get_link(struct net_device *netdev)  {  	struct e1000_adapter *adapter = netdev_priv(netdev); -	/* -	 * If the link is not reported up to netdev, interrupts are disabled, +	/* If the link is not reported up to netdev, interrupts are disabled,  	 * and so the physical link state may have changed since we last  	 * looked. Set get_link_status to make sure that the true link  	 * state is interrogated, rather than pulling a cached and possibly @@ -484,7 +481,7 @@ static int e1000_get_eeprom(struct net_device *netdev,  		le16_to_cpus(&eeprom_buff[i]);  	memcpy(bytes, (u8 *)eeprom_buff + (eeprom->offset & 1), -			eeprom->len); +	       eeprom->len);  	kfree(eeprom_buff);  	return ret_val; @@ -517,15 +514,17 @@ static int e1000_set_eeprom(struct net_device *netdev,  	ptr = (void *)eeprom_buff;  	if (eeprom->offset & 1) { -		/* need read/modify/write of first changed EEPROM word */ -		/* only the second byte of the word is being modified */ +		/* need read/modify/write of first changed EEPROM word +		 * only the second byte of the word is being modified +		 */  		ret_val = e1000_read_eeprom(hw, first_word, 1,  					    &eeprom_buff[0]);  		ptr++;  	}  	if (((eeprom->offset + eeprom->len) & 1) && (ret_val == 0)) { -		/* need read/modify/write of last changed EEPROM word */ -		/* only the first byte of the word is being modified */ +		/* need read/modify/write of last changed EEPROM word +		 * only the first byte of the word is being modified +		 */  		ret_val = e1000_read_eeprom(hw, last_word, 1,  		                  &eeprom_buff[last_word - first_word]);  	} @@ -606,11 +605,13 @@ static int e1000_set_ringparam(struct net_device *netdev,  	rx_old = adapter->rx_ring;  	err = -ENOMEM; -	txdr = kcalloc(adapter->num_tx_queues, sizeof(struct e1000_tx_ring), GFP_KERNEL); +	txdr = kcalloc(adapter->num_tx_queues, sizeof(struct e1000_tx_ring), +		       GFP_KERNEL);  	if (!txdr)  		goto err_alloc_tx; -	rxdr = kcalloc(adapter->num_rx_queues, sizeof(struct e1000_rx_ring), GFP_KERNEL); +	rxdr = kcalloc(adapter->num_rx_queues, sizeof(struct e1000_rx_ring), +		       GFP_KERNEL);  	if (!rxdr)  		goto err_alloc_rx; @@ -619,12 +620,12 @@ static int e1000_set_ringparam(struct net_device *netdev,  	rxdr->count = max(ring->rx_pending,(u32)E1000_MIN_RXD);  	rxdr->count = min(rxdr->count,(u32)(mac_type < e1000_82544 ? -		E1000_MAX_RXD : E1000_MAX_82544_RXD)); +			  E1000_MAX_RXD : E1000_MAX_82544_RXD));  	rxdr->count = ALIGN(rxdr->count, REQ_RX_DESCRIPTOR_MULTIPLE);  	txdr->count = max(ring->tx_pending,(u32)E1000_MIN_TXD);  	txdr->count = min(txdr->count,(u32)(mac_type < e1000_82544 ? -		E1000_MAX_TXD : E1000_MAX_82544_TXD)); +			  E1000_MAX_TXD : E1000_MAX_82544_TXD));  	txdr->count = ALIGN(txdr->count, REQ_TX_DESCRIPTOR_MULTIPLE);  	for (i = 0; i < adapter->num_tx_queues; i++) @@ -642,7 +643,8 @@ static int e1000_set_ringparam(struct net_device *netdev,  			goto err_setup_tx;  		/* save the new, restore the old in order to free it, -		 * then restore the new back again */ +		 * then restore the new back again +		 */  		adapter->rx_ring = rx_old;  		adapter->tx_ring = tx_old; @@ -784,7 +786,6 @@ static int e1000_reg_test(struct e1000_adapter *adapter, u64 *data)  	REG_SET_AND_CHECK(TCTL, 0xFFFFFFFF, 0x00000000);  	if (hw->mac_type >= e1000_82543) { -  		REG_SET_AND_CHECK(RCTL, before, 0xFFFFFFFF);  		REG_PATTERN_TEST(RDBAL, 0xFFFFFFF0, 0xFFFFFFFF);  		REG_PATTERN_TEST(TXCW, 0xC000FFFF, 0x0000FFFF); @@ -795,14 +796,11 @@ static int e1000_reg_test(struct e1000_adapter *adapter, u64 *data)  			REG_PATTERN_TEST(RA + (((i << 1) + 1) << 2), 0x8003FFFF,  			                 0xFFFFFFFF);  		} -  	} else { -  		REG_SET_AND_CHECK(RCTL, 0xFFFFFFFF, 0x01FFFFFF);  		REG_PATTERN_TEST(RDBAL, 0xFFFFF000, 0xFFFFFFFF);  		REG_PATTERN_TEST(TXCW, 0x0000FFFF, 0x0000FFFF);  		REG_PATTERN_TEST(TDBAL, 0xFFFFF000, 0xFFFFFFFF); -  	}  	value = E1000_MC_TBL_SIZE; @@ -858,13 +856,14 @@ static int e1000_intr_test(struct e1000_adapter *adapter, u64 *data)  	*data = 0; -	/* NOTE: we don't test MSI interrupts here, yet */ -	/* Hook up test interrupt handler just for this test */ +	/* NOTE: we don't test MSI interrupts here, yet +	 * Hook up test interrupt handler just for this test +	 */  	if (!request_irq(irq, e1000_test_intr, IRQF_PROBE_SHARED, netdev->name, -	                 netdev)) +			 netdev))  		shared_int = false;  	else if (request_irq(irq, e1000_test_intr, IRQF_SHARED, -	         netdev->name, netdev)) { +			     netdev->name, netdev)) {  		*data = 1;  		return -1;  	} @@ -1253,14 +1252,15 @@ static int e1000_integrated_phy_loopback(struct e1000_adapter *adapter)  	ctrl_reg |= (E1000_CTRL_FRCSPD | /* Set the Force Speed Bit */  			E1000_CTRL_FRCDPX | /* Set the Force Duplex Bit */  			E1000_CTRL_SPD_1000 |/* Force Speed to 1000 */ -			E1000_CTRL_FD);	 /* Force Duplex to FULL */ +			E1000_CTRL_FD); /* Force Duplex to FULL */  	if (hw->media_type == e1000_media_type_copper &&  	   hw->phy_type == e1000_phy_m88)  		ctrl_reg |= E1000_CTRL_ILOS; /* Invert Loss of Signal */  	else {  		/* Set the ILOS bit on the fiber Nic is half -		 * duplex link is detected. */ +		 * duplex link is detected. +		 */  		stat_reg = er32(STATUS);  		if ((stat_reg & E1000_STATUS_FD) == 0)  			ctrl_reg |= (E1000_CTRL_ILOS | E1000_CTRL_SLU); @@ -1446,7 +1446,7 @@ static int e1000_run_loopback_test(struct e1000_adapter *adapter)  			ret_val = e1000_check_lbtest_frame(  					rxdr->buffer_info[l].skb, -				   	1024); +					1024);  			if (!ret_val)  				good_cnt++;  			if (unlikely(++l == rxdr->count)) l = 0; @@ -1493,7 +1493,8 @@ static int e1000_link_test(struct e1000_adapter *adapter, u64 *data)  		hw->serdes_has_link = false;  		/* On some blade server designs, link establishment -		 * could take as long as 2-3 minutes */ +		 * could take as long as 2-3 minutes +		 */  		do {  			e1000_check_for_link(hw);  			if (hw->serdes_has_link) @@ -1545,7 +1546,8 @@ static void e1000_diag_test(struct net_device *netdev,  		e_info(hw, "offline testing starting\n");  		/* Link test performed before hardware reset so autoneg doesn't -		 * interfere with test result */ +		 * interfere with test result +		 */  		if (e1000_link_test(adapter, &data[4]))  			eth_test->flags |= ETH_TEST_FL_FAILED; @@ -1639,7 +1641,8 @@ static int e1000_wol_exclusion(struct e1000_adapter *adapter,  	default:  		/* dual port cards only support WoL on port A from now on  		 * unless it was enabled in the eeprom for port B -		 * so exclude FUNC_1 ports from having WoL enabled */ +		 * so exclude FUNC_1 ports from having WoL enabled +		 */  		if (er32(STATUS) & E1000_STATUS_FUNC_1 &&  		    !adapter->eeprom_wol) {  			wol->supported = 0; @@ -1663,7 +1666,8 @@ static void e1000_get_wol(struct net_device *netdev,  	wol->wolopts = 0;  	/* this function will set ->supported = 0 and return 1 if wol is not -	 * supported by this hardware */ +	 * supported by this hardware +	 */  	if (e1000_wol_exclusion(adapter, wol) ||  	    !device_can_wakeup(&adapter->pdev->dev))  		return; @@ -1839,7 +1843,7 @@ static void e1000_get_ethtool_stats(struct net_device *netdev,  		data[i] = (e1000_gstrings_stats[i].sizeof_stat ==  			sizeof(u64)) ? *(u64 *)p : *(u32 *)p;  	} -/*	BUG_ON(i != E1000_STATS_LEN); */ +/* BUG_ON(i != E1000_STATS_LEN); */  }  static void e1000_get_strings(struct net_device *netdev, u32 stringset, @@ -1859,37 +1863,37 @@ static void e1000_get_strings(struct net_device *netdev, u32 stringset,  			       ETH_GSTRING_LEN);  			p += ETH_GSTRING_LEN;  		} -/*		BUG_ON(p - data != E1000_STATS_LEN * ETH_GSTRING_LEN); */ +		/* BUG_ON(p - data != E1000_STATS_LEN * ETH_GSTRING_LEN); */  		break;  	}  }  static const struct ethtool_ops e1000_ethtool_ops = { -	.get_settings           = e1000_get_settings, -	.set_settings           = e1000_set_settings, -	.get_drvinfo            = e1000_get_drvinfo, -	.get_regs_len           = e1000_get_regs_len, -	.get_regs               = e1000_get_regs, -	.get_wol                = e1000_get_wol, -	.set_wol                = e1000_set_wol, -	.get_msglevel           = e1000_get_msglevel, -	.set_msglevel           = e1000_set_msglevel, -	.nway_reset             = e1000_nway_reset, -	.get_link               = e1000_get_link, -	.get_eeprom_len         = e1000_get_eeprom_len, -	.get_eeprom             = e1000_get_eeprom, -	.set_eeprom             = e1000_set_eeprom, -	.get_ringparam          = e1000_get_ringparam, -	.set_ringparam          = e1000_set_ringparam, -	.get_pauseparam         = e1000_get_pauseparam, -	.set_pauseparam         = e1000_set_pauseparam, -	.self_test              = e1000_diag_test, -	.get_strings            = e1000_get_strings, -	.set_phys_id            = e1000_set_phys_id, -	.get_ethtool_stats      = e1000_get_ethtool_stats, -	.get_sset_count         = e1000_get_sset_count, -	.get_coalesce           = e1000_get_coalesce, -	.set_coalesce           = e1000_set_coalesce, +	.get_settings		= e1000_get_settings, +	.set_settings		= e1000_set_settings, +	.get_drvinfo		= e1000_get_drvinfo, +	.get_regs_len		= e1000_get_regs_len, +	.get_regs		= e1000_get_regs, +	.get_wol		= e1000_get_wol, +	.set_wol		= e1000_set_wol, +	.get_msglevel		= e1000_get_msglevel, +	.set_msglevel		= e1000_set_msglevel, +	.nway_reset		= e1000_nway_reset, +	.get_link		= e1000_get_link, +	.get_eeprom_len		= e1000_get_eeprom_len, +	.get_eeprom		= e1000_get_eeprom, +	.set_eeprom		= e1000_set_eeprom, +	.get_ringparam		= e1000_get_ringparam, +	.set_ringparam		= e1000_set_ringparam, +	.get_pauseparam		= e1000_get_pauseparam, +	.set_pauseparam		= e1000_set_pauseparam, +	.self_test		= e1000_diag_test, +	.get_strings		= e1000_get_strings, +	.set_phys_id		= e1000_set_phys_id, +	.get_ethtool_stats	= e1000_get_ethtool_stats, +	.get_sset_count		= e1000_get_sset_count, +	.get_coalesce		= e1000_get_coalesce, +	.set_coalesce		= e1000_set_coalesce,  	.get_ts_info		= ethtool_op_get_ts_info,  }; diff --git a/drivers/net/ethernet/intel/e1000/e1000_hw.c b/drivers/net/ethernet/intel/e1000/e1000_hw.c index 8fedd245153..2879b9631e1 100644 --- a/drivers/net/ethernet/intel/e1000/e1000_hw.c +++ b/drivers/net/ethernet/intel/e1000/e1000_hw.c @@ -164,8 +164,9 @@ static void e1000_phy_init_script(struct e1000_hw *hw)  	if (hw->phy_init_script) {  		msleep(20); -		/* Save off the current value of register 0x2F5B to be restored at -		 * the end of this routine. */ +		/* Save off the current value of register 0x2F5B to be restored +		 * at the end of this routine. +		 */  		ret_val = e1000_read_phy_reg(hw, 0x2F5B, &phy_saved_data);  		/* Disabled the PHY transmitter */ @@ -466,7 +467,8 @@ s32 e1000_reset_hw(struct e1000_hw *hw)  	case e1000_82541:  	case e1000_82541_rev_2:  		/* These controllers can't ack the 64-bit write when issuing the -		 * reset, so use IO-mapping as a workaround to issue the reset */ +		 * reset, so use IO-mapping as a workaround to issue the reset +		 */  		E1000_WRITE_REG_IO(hw, CTRL, (ctrl | E1000_CTRL_RST));  		break;  	case e1000_82545_rev_3: @@ -480,9 +482,9 @@ s32 e1000_reset_hw(struct e1000_hw *hw)  		break;  	} -	/* After MAC reset, force reload of EEPROM to restore power-on settings to -	 * device.  Later controllers reload the EEPROM automatically, so just wait -	 * for reload to complete. +	/* After MAC reset, force reload of EEPROM to restore power-on settings +	 * to device.  Later controllers reload the EEPROM automatically, so +	 * just wait for reload to complete.  	 */  	switch (hw->mac_type) {  	case e1000_82542_rev2_0: @@ -591,8 +593,8 @@ s32 e1000_init_hw(struct e1000_hw *hw)  		msleep(5);  	} -	/* Setup the receive address. This involves initializing all of the Receive -	 * Address Registers (RARs 0 - 15). +	/* Setup the receive address. This involves initializing all of the +	 * Receive Address Registers (RARs 0 - 15).  	 */  	e1000_init_rx_addrs(hw); @@ -611,7 +613,8 @@ s32 e1000_init_hw(struct e1000_hw *hw)  	for (i = 0; i < mta_size; i++) {  		E1000_WRITE_REG_ARRAY(hw, MTA, i, 0);  		/* use write flush to prevent Memory Write Block (MWB) from -		 * occurring when accessing our register space */ +		 * occurring when accessing our register space +		 */  		E1000_WRITE_FLUSH();  	} @@ -630,7 +633,9 @@ s32 e1000_init_hw(struct e1000_hw *hw)  	case e1000_82546_rev_3:  		break;  	default: -		/* Workaround for PCI-X problem when BIOS sets MMRBC incorrectly. */ +		/* Workaround for PCI-X problem when BIOS sets MMRBC +		 * incorrectly. +		 */  		if (hw->bus_type == e1000_bus_type_pcix  		    && e1000_pcix_get_mmrbc(hw) > 2048)  			e1000_pcix_set_mmrbc(hw, 2048); @@ -660,7 +665,8 @@ s32 e1000_init_hw(struct e1000_hw *hw)  	    hw->device_id == E1000_DEV_ID_82546GB_QUAD_COPPER_KSP3) {  		ctrl_ext = er32(CTRL_EXT);  		/* Relaxed ordering must be disabled to avoid a parity -		 * error crash in a PCI slot. */ +		 * error crash in a PCI slot. +		 */  		ctrl_ext |= E1000_CTRL_EXT_RO_DIS;  		ew32(CTRL_EXT, ctrl_ext);  	} @@ -810,8 +816,9 @@ s32 e1000_setup_link(struct e1000_hw *hw)  		ew32(FCRTL, 0);  		ew32(FCRTH, 0);  	} else { -		/* We need to set up the Receive Threshold high and low water marks -		 * as well as (optionally) enabling the transmission of XON frames. +		/* We need to set up the Receive Threshold high and low water +		 * marks as well as (optionally) enabling the transmission of +		 * XON frames.  		 */  		if (hw->fc_send_xon) {  			ew32(FCRTL, (hw->fc_low_water | E1000_FCRTL_XONE)); @@ -868,42 +875,46 @@ static s32 e1000_setup_fiber_serdes_link(struct e1000_hw *hw)  	e1000_config_collision_dist(hw);  	/* Check for a software override of the flow control settings, and setup -	 * the device accordingly.  If auto-negotiation is enabled, then software -	 * will have to set the "PAUSE" bits to the correct value in the Tranmsit -	 * Config Word Register (TXCW) and re-start auto-negotiation.  However, if -	 * auto-negotiation is disabled, then software will have to manually -	 * configure the two flow control enable bits in the CTRL register. +	 * the device accordingly.  If auto-negotiation is enabled, then +	 * software will have to set the "PAUSE" bits to the correct value in +	 * the Tranmsit Config Word Register (TXCW) and re-start +	 * auto-negotiation.  However, if auto-negotiation is disabled, then +	 * software will have to manually configure the two flow control enable +	 * bits in the CTRL register.  	 *  	 * The possible values of the "fc" parameter are: -	 *      0:  Flow control is completely disabled -	 *      1:  Rx flow control is enabled (we can receive pause frames, but -	 *          not send pause frames). -	 *      2:  Tx flow control is enabled (we can send pause frames but we do -	 *          not support receiving pause frames). -	 *      3:  Both Rx and TX flow control (symmetric) are enabled. +	 *  0:  Flow control is completely disabled +	 *  1:  Rx flow control is enabled (we can receive pause frames, but +	 *      not send pause frames). +	 *  2:  Tx flow control is enabled (we can send pause frames but we do +	 *      not support receiving pause frames). +	 *  3:  Both Rx and TX flow control (symmetric) are enabled.  	 */  	switch (hw->fc) {  	case E1000_FC_NONE: -		/* Flow control is completely disabled by a software over-ride. */ +		/* Flow ctrl is completely disabled by a software over-ride */  		txcw = (E1000_TXCW_ANE | E1000_TXCW_FD);  		break;  	case E1000_FC_RX_PAUSE: -		/* RX Flow control is enabled and TX Flow control is disabled by a -		 * software over-ride. Since there really isn't a way to advertise -		 * that we are capable of RX Pause ONLY, we will advertise that we -		 * support both symmetric and asymmetric RX PAUSE. Later, we will -		 *  disable the adapter's ability to send PAUSE frames. +		/* Rx Flow control is enabled and Tx Flow control is disabled by +		 * a software over-ride. Since there really isn't a way to +		 * advertise that we are capable of Rx Pause ONLY, we will +		 * advertise that we support both symmetric and asymmetric Rx +		 * PAUSE. Later, we will disable the adapter's ability to send +		 * PAUSE frames.  		 */  		txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_PAUSE_MASK);  		break;  	case E1000_FC_TX_PAUSE: -		/* TX Flow control is enabled, and RX Flow control is disabled, by a -		 * software over-ride. +		/* Tx Flow control is enabled, and Rx Flow control is disabled, +		 * by a software over-ride.  		 */  		txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_ASM_DIR);  		break;  	case E1000_FC_FULL: -		/* Flow control (both RX and TX) is enabled by a software over-ride. */ +		/* Flow control (both Rx and Tx) is enabled by a software +		 * over-ride. +		 */  		txcw = (E1000_TXCW_ANE | E1000_TXCW_FD | E1000_TXCW_PAUSE_MASK);  		break;  	default: @@ -912,11 +923,11 @@ static s32 e1000_setup_fiber_serdes_link(struct e1000_hw *hw)  		break;  	} -	/* Since auto-negotiation is enabled, take the link out of reset (the link -	 * will be in reset, because we previously reset the chip). This will -	 * restart auto-negotiation.  If auto-negotiation is successful then the -	 * link-up status bit will be set and the flow control enable bits (RFCE -	 * and TFCE) will be set according to their negotiated value. +	/* Since auto-negotiation is enabled, take the link out of reset (the +	 * link will be in reset, because we previously reset the chip). This +	 * will restart auto-negotiation.  If auto-negotiation is successful +	 * then the link-up status bit will be set and the flow control enable +	 * bits (RFCE and TFCE) will be set according to their negotiated value.  	 */  	e_dbg("Auto-negotiation enabled\n"); @@ -927,11 +938,12 @@ static s32 e1000_setup_fiber_serdes_link(struct e1000_hw *hw)  	hw->txcw = txcw;  	msleep(1); -	/* If we have a signal (the cable is plugged in) then poll for a "Link-Up" -	 * indication in the Device Status Register.  Time-out if a link isn't -	 * seen in 500 milliseconds seconds (Auto-negotiation should complete in -	 * less than 500 milliseconds even if the other end is doing it in SW). -	 * For internal serdes, we just assume a signal is present, then poll. +	/* If we have a signal (the cable is plugged in) then poll for a +	 * "Link-Up" indication in the Device Status Register.  Time-out if a +	 * link isn't seen in 500 milliseconds seconds (Auto-negotiation should +	 * complete in less than 500 milliseconds even if the other end is doing +	 * it in SW). For internal serdes, we just assume a signal is present, +	 * then poll.  	 */  	if (hw->media_type == e1000_media_type_internal_serdes ||  	    (er32(CTRL) & E1000_CTRL_SWDPIN1) == signal) { @@ -946,9 +958,9 @@ static s32 e1000_setup_fiber_serdes_link(struct e1000_hw *hw)  			e_dbg("Never got a valid link from auto-neg!!!\n");  			hw->autoneg_failed = 1;  			/* AutoNeg failed to achieve a link, so we'll call -			 * e1000_check_for_link. This routine will force the link up if -			 * we detect a signal. This will allow us to communicate with -			 * non-autonegotiating link partners. +			 * e1000_check_for_link. This routine will force the +			 * link up if we detect a signal. This will allow us to +			 * communicate with non-autonegotiating link partners.  			 */  			ret_val = e1000_check_for_link(hw);  			if (ret_val) { @@ -1042,9 +1054,9 @@ static s32 e1000_copper_link_preconfig(struct e1000_hw *hw)  	e_dbg("e1000_copper_link_preconfig");  	ctrl = er32(CTRL); -	/* With 82543, we need to force speed and duplex on the MAC equal to what -	 * the PHY speed and duplex configuration is. In addition, we need to -	 * perform a hardware reset on the PHY to take it out of reset. +	/* With 82543, we need to force speed and duplex on the MAC equal to +	 * what the PHY speed and duplex configuration is. In addition, we need +	 * to perform a hardware reset on the PHY to take it out of reset.  	 */  	if (hw->mac_type > e1000_82543) {  		ctrl |= E1000_CTRL_SLU; @@ -1175,7 +1187,8 @@ static s32 e1000_copper_link_igp_setup(struct e1000_hw *hw)  		/* when autonegotiation advertisement is only 1000Mbps then we  		 * should disable SmartSpeed and enable Auto MasterSlave -		 * resolution as hardware default. */ +		 * resolution as hardware default. +		 */  		if (hw->autoneg_advertised == ADVERTISE_1000_FULL) {  			/* Disable SmartSpeed */  			ret_val = @@ -1485,13 +1498,15 @@ static s32 e1000_setup_copper_link(struct e1000_hw *hw)  	if (hw->autoneg) {  		/* Setup autoneg and flow control advertisement -		 * and perform autonegotiation */ +		 * and perform autonegotiation +		 */  		ret_val = e1000_copper_link_autoneg(hw);  		if (ret_val)  			return ret_val;  	} else {  		/* PHY will be set to 10H, 10F, 100H,or 100F -		 * depending on value from forced_speed_duplex. */ +		 * depending on value from forced_speed_duplex. +		 */  		e_dbg("Forcing speed and duplex\n");  		ret_val = e1000_phy_force_speed_duplex(hw);  		if (ret_val) { @@ -1609,7 +1624,8 @@ s32 e1000_phy_setup_autoneg(struct e1000_hw *hw)  	 * setup the PHY advertisement registers accordingly.  If  	 * auto-negotiation is enabled, then software will have to set the  	 * "PAUSE" bits to the correct value in the Auto-Negotiation -	 * Advertisement Register (PHY_AUTONEG_ADV) and re-start auto-negotiation. +	 * Advertisement Register (PHY_AUTONEG_ADV) and re-start +	 * auto-negotiation.  	 *  	 * The possible values of the "fc" parameter are:  	 *      0:  Flow control is completely disabled @@ -1636,7 +1652,7 @@ s32 e1000_phy_setup_autoneg(struct e1000_hw *hw)  		 * capable of RX Pause ONLY, we will advertise that we  		 * support both symmetric and asymmetric RX PAUSE.  Later  		 * (in e1000_config_fc_after_link_up) we will disable the -		 *hw's ability to send PAUSE frames. +		 * hw's ability to send PAUSE frames.  		 */  		mii_autoneg_adv_reg |= (NWAY_AR_ASM_DIR | NWAY_AR_PAUSE);  		break; @@ -1720,15 +1736,15 @@ static s32 e1000_phy_force_speed_duplex(struct e1000_hw *hw)  	/* Are we forcing Full or Half Duplex? */  	if (hw->forced_speed_duplex == e1000_100_full ||  	    hw->forced_speed_duplex == e1000_10_full) { -		/* We want to force full duplex so we SET the full duplex bits in the -		 * Device and MII Control Registers. +		/* We want to force full duplex so we SET the full duplex bits +		 * in the Device and MII Control Registers.  		 */  		ctrl |= E1000_CTRL_FD;  		mii_ctrl_reg |= MII_CR_FULL_DUPLEX;  		e_dbg("Full Duplex\n");  	} else { -		/* We want to force half duplex so we CLEAR the full duplex bits in -		 * the Device and MII Control Registers. +		/* We want to force half duplex so we CLEAR the full duplex bits +		 * in the Device and MII Control Registers.  		 */  		ctrl &= ~E1000_CTRL_FD;  		mii_ctrl_reg &= ~MII_CR_FULL_DUPLEX; @@ -1762,8 +1778,8 @@ static s32 e1000_phy_force_speed_duplex(struct e1000_hw *hw)  		if (ret_val)  			return ret_val; -		/* Clear Auto-Crossover to force MDI manually. M88E1000 requires MDI -		 * forced whenever speed are duplex are forced. +		/* Clear Auto-Crossover to force MDI manually. M88E1000 requires +		 * MDI forced whenever speed are duplex are forced.  		 */  		phy_data &= ~M88E1000_PSCR_AUTO_X_MODE;  		ret_val = @@ -1814,10 +1830,10 @@ static s32 e1000_phy_force_speed_duplex(struct e1000_hw *hw)  		e_dbg("Waiting for forced speed/duplex link.\n");  		mii_status_reg = 0; -		/* We will wait for autoneg to complete or 4.5 seconds to expire. */ +		/* Wait for autoneg to complete or 4.5 seconds to expire */  		for (i = PHY_FORCE_TIME; i > 0; i--) { -			/* Read the MII Status Register and wait for Auto-Neg Complete bit -			 * to be set. +			/* Read the MII Status Register and wait for Auto-Neg +			 * Complete bit to be set.  			 */  			ret_val =  			    e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg); @@ -1834,20 +1850,24 @@ static s32 e1000_phy_force_speed_duplex(struct e1000_hw *hw)  			msleep(100);  		}  		if ((i == 0) && (hw->phy_type == e1000_phy_m88)) { -			/* We didn't get link.  Reset the DSP and wait again for link. */ +			/* We didn't get link.  Reset the DSP and wait again +			 * for link. +			 */  			ret_val = e1000_phy_reset_dsp(hw);  			if (ret_val) {  				e_dbg("Error Resetting PHY DSP\n");  				return ret_val;  			}  		} -		/* This loop will early-out if the link condition has been met.  */ +		/* This loop will early-out if the link condition has been +		 * met +		 */  		for (i = PHY_FORCE_TIME; i > 0; i--) {  			if (mii_status_reg & MII_SR_LINK_STATUS)  				break;  			msleep(100); -			/* Read the MII Status Register and wait for Auto-Neg Complete bit -			 * to be set. +			/* Read the MII Status Register and wait for Auto-Neg +			 * Complete bit to be set.  			 */  			ret_val =  			    e1000_read_phy_reg(hw, PHY_STATUS, &mii_status_reg); @@ -1862,9 +1882,10 @@ static s32 e1000_phy_force_speed_duplex(struct e1000_hw *hw)  	}  	if (hw->phy_type == e1000_phy_m88) { -		/* Because we reset the PHY above, we need to re-force TX_CLK in the -		 * Extended PHY Specific Control Register to 25MHz clock.  This value -		 * defaults back to a 2.5MHz clock when the PHY is reset. +		/* Because we reset the PHY above, we need to re-force TX_CLK in +		 * the Extended PHY Specific Control Register to 25MHz clock. +		 * This value defaults back to a 2.5MHz clock when the PHY is +		 * reset.  		 */  		ret_val =  		    e1000_read_phy_reg(hw, M88E1000_EXT_PHY_SPEC_CTRL, @@ -1879,8 +1900,9 @@ static s32 e1000_phy_force_speed_duplex(struct e1000_hw *hw)  		if (ret_val)  			return ret_val; -		/* In addition, because of the s/w reset above, we need to enable CRS on -		 * TX.  This must be set for both full and half duplex operation. +		/* In addition, because of the s/w reset above, we need to +		 * enable CRS on Tx.  This must be set for both full and half +		 * duplex operation.  		 */  		ret_val =  		    e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data); @@ -1951,7 +1973,8 @@ static s32 e1000_config_mac_to_phy(struct e1000_hw *hw)  	e_dbg("e1000_config_mac_to_phy");  	/* 82544 or newer MAC, Auto Speed Detection takes care of -	 * MAC speed/duplex configuration.*/ +	 * MAC speed/duplex configuration. +	 */  	if ((hw->mac_type >= e1000_82544) && (hw->mac_type != e1000_ce4100))  		return E1000_SUCCESS; @@ -1985,7 +2008,7 @@ static s32 e1000_config_mac_to_phy(struct e1000_hw *hw)  		 * registers depending on negotiated values.  		 */  		ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_STATUS, -		                             &phy_data); +					     &phy_data);  		if (ret_val)  			return ret_val; @@ -2002,7 +2025,7 @@ static s32 e1000_config_mac_to_phy(struct e1000_hw *hw)  		if ((phy_data & M88E1000_PSSR_SPEED) == M88E1000_PSSR_1000MBS)  			ctrl |= E1000_CTRL_SPD_1000;  		else if ((phy_data & M88E1000_PSSR_SPEED) == -		         M88E1000_PSSR_100MBS) +			 M88E1000_PSSR_100MBS)  			ctrl |= E1000_CTRL_SPD_100;  	} @@ -2135,9 +2158,9 @@ static s32 e1000_config_fc_after_link_up(struct e1000_hw *hw)  		if (mii_status_reg & MII_SR_AUTONEG_COMPLETE) {  			/* The AutoNeg process has completed, so we now need to  			 * read both the Auto Negotiation Advertisement Register -			 * (Address 4) and the Auto_Negotiation Base Page Ability -			 * Register (Address 5) to determine how flow control was -			 * negotiated. +			 * (Address 4) and the Auto_Negotiation Base Page +			 * Ability Register (Address 5) to determine how flow +			 * control was negotiated.  			 */  			ret_val = e1000_read_phy_reg(hw, PHY_AUTONEG_ADV,  						     &mii_nway_adv_reg); @@ -2148,18 +2171,19 @@ static s32 e1000_config_fc_after_link_up(struct e1000_hw *hw)  			if (ret_val)  				return ret_val; -			/* Two bits in the Auto Negotiation Advertisement Register -			 * (Address 4) and two bits in the Auto Negotiation Base -			 * Page Ability Register (Address 5) determine flow control -			 * for both the PHY and the link partner.  The following -			 * table, taken out of the IEEE 802.3ab/D6.0 dated March 25, -			 * 1999, describes these PAUSE resolution bits and how flow -			 * control is determined based upon these settings. +			/* Two bits in the Auto Negotiation Advertisement +			 * Register (Address 4) and two bits in the Auto +			 * Negotiation Base Page Ability Register (Address 5) +			 * determine flow control for both the PHY and the link +			 * partner.  The following table, taken out of the IEEE +			 * 802.3ab/D6.0 dated March 25, 1999, describes these +			 * PAUSE resolution bits and how flow control is +			 * determined based upon these settings.  			 * NOTE:  DC = Don't Care  			 *  			 *   LOCAL DEVICE  |   LINK PARTNER  			 * PAUSE | ASM_DIR | PAUSE | ASM_DIR | NIC Resolution -			 *-------|---------|-------|---------|-------------------- +			 *-------|---------|-------|---------|------------------  			 *   0   |    0    |  DC   |   DC    | E1000_FC_NONE  			 *   0   |    1    |   0   |   DC    | E1000_FC_NONE  			 *   0   |    1    |   1   |    0    | E1000_FC_NONE @@ -2178,17 +2202,18 @@ static s32 e1000_config_fc_after_link_up(struct e1000_hw *hw)  			 *  			 *   LOCAL DEVICE  |   LINK PARTNER  			 * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result -			 *-------|---------|-------|---------|-------------------- +			 *-------|---------|-------|---------|------------------  			 *   1   |   DC    |   1   |   DC    | E1000_FC_FULL  			 *  			 */  			if ((mii_nway_adv_reg & NWAY_AR_PAUSE) &&  			    (mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE)) { -				/* Now we need to check if the user selected RX ONLY -				 * of pause frames.  In this case, we had to advertise -				 * FULL flow control because we could not advertise RX -				 * ONLY. Hence, we must now check to see if we need to -				 * turn OFF  the TRANSMISSION of PAUSE frames. +				/* Now we need to check if the user selected Rx +				 * ONLY of pause frames.  In this case, we had +				 * to advertise FULL flow control because we +				 * could not advertise Rx ONLY. Hence, we must +				 * now check to see if we need to turn OFF the +				 * TRANSMISSION of PAUSE frames.  				 */  				if (hw->original_fc == E1000_FC_FULL) {  					hw->fc = E1000_FC_FULL; @@ -2203,7 +2228,7 @@ static s32 e1000_config_fc_after_link_up(struct e1000_hw *hw)  			 *  			 *   LOCAL DEVICE  |   LINK PARTNER  			 * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result -			 *-------|---------|-------|---------|-------------------- +			 *-------|---------|-------|---------|------------------  			 *   0   |    1    |   1   |    1    | E1000_FC_TX_PAUSE  			 *  			 */ @@ -2220,7 +2245,7 @@ static s32 e1000_config_fc_after_link_up(struct e1000_hw *hw)  			 *  			 *   LOCAL DEVICE  |   LINK PARTNER  			 * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result -			 *-------|---------|-------|---------|-------------------- +			 *-------|---------|-------|---------|------------------  			 *   1   |    1    |   0   |    1    | E1000_FC_RX_PAUSE  			 *  			 */ @@ -2233,25 +2258,27 @@ static s32 e1000_config_fc_after_link_up(struct e1000_hw *hw)  				e_dbg  				    ("Flow Control = RX PAUSE frames only.\n");  			} -			/* Per the IEEE spec, at this point flow control should be -			 * disabled.  However, we want to consider that we could -			 * be connected to a legacy switch that doesn't advertise -			 * desired flow control, but can be forced on the link -			 * partner.  So if we advertised no flow control, that is -			 * what we will resolve to.  If we advertised some kind of -			 * receive capability (Rx Pause Only or Full Flow Control) -			 * and the link partner advertised none, we will configure -			 * ourselves to enable Rx Flow Control only.  We can do -			 * this safely for two reasons:  If the link partner really -			 * didn't want flow control enabled, and we enable Rx, no -			 * harm done since we won't be receiving any PAUSE frames -			 * anyway.  If the intent on the link partner was to have -			 * flow control enabled, then by us enabling RX only, we -			 * can at least receive pause frames and process them. -			 * This is a good idea because in most cases, since we are -			 * predominantly a server NIC, more times than not we will -			 * be asked to delay transmission of packets than asking -			 * our link partner to pause transmission of frames. +			/* Per the IEEE spec, at this point flow control should +			 * be disabled.  However, we want to consider that we +			 * could be connected to a legacy switch that doesn't +			 * advertise desired flow control, but can be forced on +			 * the link partner.  So if we advertised no flow +			 * control, that is what we will resolve to.  If we +			 * advertised some kind of receive capability (Rx Pause +			 * Only or Full Flow Control) and the link partner +			 * advertised none, we will configure ourselves to +			 * enable Rx Flow Control only.  We can do this safely +			 * for two reasons:  If the link partner really +			 * didn't want flow control enabled, and we enable Rx, +			 * no harm done since we won't be receiving any PAUSE +			 * frames anyway.  If the intent on the link partner was +			 * to have flow control enabled, then by us enabling Rx +			 * only, we can at least receive pause frames and +			 * process them. This is a good idea because in most +			 * cases, since we are predominantly a server NIC, more +			 * times than not we will be asked to delay transmission +			 * of packets than asking our link partner to pause +			 * transmission of frames.  			 */  			else if ((hw->original_fc == E1000_FC_NONE ||  				  hw->original_fc == E1000_FC_TX_PAUSE) || @@ -2316,8 +2343,7 @@ static s32 e1000_check_for_serdes_link_generic(struct e1000_hw *hw)  	status = er32(STATUS);  	rxcw = er32(RXCW); -	/* -	 * If we don't have link (auto-negotiation failed or link partner +	/* If we don't have link (auto-negotiation failed or link partner  	 * cannot auto-negotiate), and our link partner is not trying to  	 * auto-negotiate with us (we are receiving idles or data),  	 * we need to force link up. We also need to give auto-negotiation @@ -2346,8 +2372,7 @@ static s32 e1000_check_for_serdes_link_generic(struct e1000_hw *hw)  			goto out;  		}  	} else if ((ctrl & E1000_CTRL_SLU) && (rxcw & E1000_RXCW_C)) { -		/* -		 * If we are forcing link and we are receiving /C/ ordered +		/* If we are forcing link and we are receiving /C/ ordered  		 * sets, re-enable auto-negotiation in the TXCW register  		 * and disable forced link in the Device Control register  		 * in an attempt to auto-negotiate with our link partner. @@ -2358,8 +2383,7 @@ static s32 e1000_check_for_serdes_link_generic(struct e1000_hw *hw)  		hw->serdes_has_link = true;  	} else if (!(E1000_TXCW_ANE & er32(TXCW))) { -		/* -		 * If we force link for non-auto-negotiation switch, check +		/* If we force link for non-auto-negotiation switch, check  		 * link status based on MAC synchronization for internal  		 * serdes media type.  		 */ @@ -2468,15 +2492,17 @@ s32 e1000_check_for_link(struct e1000_hw *hw)  		if (phy_data & MII_SR_LINK_STATUS) {  			hw->get_link_status = false; -			/* Check if there was DownShift, must be checked immediately after -			 * link-up */ +			/* Check if there was DownShift, must be checked +			 * immediately after link-up +			 */  			e1000_check_downshift(hw);  			/* If we are on 82544 or 82543 silicon and speed/duplex -			 * are forced to 10H or 10F, then we will implement the polarity -			 * reversal workaround.  We disable interrupts first, and upon -			 * returning, place the devices interrupt state to its previous -			 * value except for the link status change interrupt which will +			 * are forced to 10H or 10F, then we will implement the +			 * polarity reversal workaround.  We disable interrupts +			 * first, and upon returning, place the devices +			 * interrupt state to its previous value except for the +			 * link status change interrupt which will  			 * happen due to the execution of this workaround.  			 */ @@ -2527,9 +2553,10 @@ s32 e1000_check_for_link(struct e1000_hw *hw)  			}  		} -		/* Configure Flow Control now that Auto-Neg has completed. First, we -		 * need to restore the desired flow control settings because we may -		 * have had to re-autoneg with a different link partner. +		/* Configure Flow Control now that Auto-Neg has completed. +		 * First, we need to restore the desired flow control settings +		 * because we may have had to re-autoneg with a different link +		 * partner.  		 */  		ret_val = e1000_config_fc_after_link_up(hw);  		if (ret_val) { @@ -2538,11 +2565,12 @@ s32 e1000_check_for_link(struct e1000_hw *hw)  		}  		/* At this point we know that we are on copper and we have -		 * auto-negotiated link.  These are conditions for checking the link -		 * partner capability register.  We use the link speed to determine if -		 * TBI compatibility needs to be turned on or off.  If the link is not -		 * at gigabit speed, then TBI compatibility is not needed.  If we are -		 * at gigabit speed, we turn on TBI compatibility. +		 * auto-negotiated link.  These are conditions for checking the +		 * link partner capability register.  We use the link speed to +		 * determine if TBI compatibility needs to be turned on or off. +		 * If the link is not at gigabit speed, then TBI compatibility +		 * is not needed.  If we are at gigabit speed, we turn on TBI +		 * compatibility.  		 */  		if (hw->tbi_compatibility_en) {  			u16 speed, duplex; @@ -2554,20 +2582,23 @@ s32 e1000_check_for_link(struct e1000_hw *hw)  				return ret_val;  			}  			if (speed != SPEED_1000) { -				/* If link speed is not set to gigabit speed, we do not need -				 * to enable TBI compatibility. +				/* If link speed is not set to gigabit speed, we +				 * do not need to enable TBI compatibility.  				 */  				if (hw->tbi_compatibility_on) { -					/* If we previously were in the mode, turn it off. */ +					/* If we previously were in the mode, +					 * turn it off. +					 */  					rctl = er32(RCTL);  					rctl &= ~E1000_RCTL_SBP;  					ew32(RCTL, rctl);  					hw->tbi_compatibility_on = false;  				}  			} else { -				/* If TBI compatibility is was previously off, turn it on. For -				 * compatibility with a TBI link partner, we will store bad -				 * packets. Some frames have an additional byte on the end and +				/* If TBI compatibility is was previously off, +				 * turn it on. For compatibility with a TBI link +				 * partner, we will store bad packets. Some +				 * frames have an additional byte on the end and  				 * will look like CRC errors to to the hardware.  				 */  				if (!hw->tbi_compatibility_on) { @@ -2629,9 +2660,9 @@ s32 e1000_get_speed_and_duplex(struct e1000_hw *hw, u16 *speed, u16 *duplex)  		*duplex = FULL_DUPLEX;  	} -	/* IGP01 PHY may advertise full duplex operation after speed downgrade even -	 * if it is operating at half duplex.  Here we set the duplex settings to -	 * match the duplex in the link partner's capabilities. +	/* IGP01 PHY may advertise full duplex operation after speed downgrade +	 * even if it is operating at half duplex.  Here we set the duplex +	 * settings to match the duplex in the link partner's capabilities.  	 */  	if (hw->phy_type == e1000_phy_igp && hw->speed_downgraded) {  		ret_val = e1000_read_phy_reg(hw, PHY_AUTONEG_EXP, &phy_data); @@ -2697,8 +2728,8 @@ static s32 e1000_wait_autoneg(struct e1000_hw *hw)   */  static void e1000_raise_mdi_clk(struct e1000_hw *hw, u32 *ctrl)  { -	/* Raise the clock input to the Management Data Clock (by setting the MDC -	 * bit), and then delay 10 microseconds. +	/* Raise the clock input to the Management Data Clock (by setting the +	 * MDC bit), and then delay 10 microseconds.  	 */  	ew32(CTRL, (*ctrl | E1000_CTRL_MDC));  	E1000_WRITE_FLUSH(); @@ -2712,8 +2743,8 @@ static void e1000_raise_mdi_clk(struct e1000_hw *hw, u32 *ctrl)   */  static void e1000_lower_mdi_clk(struct e1000_hw *hw, u32 *ctrl)  { -	/* Lower the clock input to the Management Data Clock (by clearing the MDC -	 * bit), and then delay 10 microseconds. +	/* Lower the clock input to the Management Data Clock (by clearing the +	 * MDC bit), and then delay 10 microseconds.  	 */  	ew32(CTRL, (*ctrl & ~E1000_CTRL_MDC));  	E1000_WRITE_FLUSH(); @@ -2746,10 +2777,10 @@ static void e1000_shift_out_mdi_bits(struct e1000_hw *hw, u32 data, u16 count)  	ctrl |= (E1000_CTRL_MDIO_DIR | E1000_CTRL_MDC_DIR);  	while (mask) { -		/* A "1" is shifted out to the PHY by setting the MDIO bit to "1" and -		 * then raising and lowering the Management Data Clock. A "0" is -		 * shifted out to the PHY by setting the MDIO bit to "0" and then -		 * raising and lowering the clock. +		/* A "1" is shifted out to the PHY by setting the MDIO bit to +		 * "1" and then raising and lowering the Management Data Clock. +		 * A "0" is shifted out to the PHY by setting the MDIO bit to +		 * "0" and then raising and lowering the clock.  		 */  		if (data & mask)  			ctrl |= E1000_CTRL_MDIO; @@ -2781,24 +2812,26 @@ static u16 e1000_shift_in_mdi_bits(struct e1000_hw *hw)  	u8 i;  	/* In order to read a register from the PHY, we need to shift in a total -	 * of 18 bits from the PHY. The first two bit (turnaround) times are used -	 * to avoid contention on the MDIO pin when a read operation is performed. -	 * These two bits are ignored by us and thrown away. Bits are "shifted in" -	 * by raising the input to the Management Data Clock (setting the MDC bit), -	 * and then reading the value of the MDIO bit. +	 * of 18 bits from the PHY. The first two bit (turnaround) times are +	 * used to avoid contention on the MDIO pin when a read operation is +	 * performed. These two bits are ignored by us and thrown away. Bits are +	 * "shifted in" by raising the input to the Management Data Clock +	 * (setting the MDC bit), and then reading the value of the MDIO bit.  	 */  	ctrl = er32(CTRL); -	/* Clear MDIO_DIR (SWDPIO1) to indicate this bit is to be used as input. */ +	/* Clear MDIO_DIR (SWDPIO1) to indicate this bit is to be used as +	 * input. +	 */  	ctrl &= ~E1000_CTRL_MDIO_DIR;  	ctrl &= ~E1000_CTRL_MDIO;  	ew32(CTRL, ctrl);  	E1000_WRITE_FLUSH(); -	/* Raise and Lower the clock before reading in the data. This accounts for -	 * the turnaround bits. The first clock occurred when we clocked out the -	 * last bit of the Register Address. +	/* Raise and Lower the clock before reading in the data. This accounts +	 * for the turnaround bits. The first clock occurred when we clocked out +	 * the last bit of the Register Address.  	 */  	e1000_raise_mdi_clk(hw, &ctrl);  	e1000_lower_mdi_clk(hw, &ctrl); @@ -2870,8 +2903,8 @@ static s32 e1000_read_phy_reg_ex(struct e1000_hw *hw, u32 reg_addr,  	if (hw->mac_type > e1000_82543) {  		/* Set up Op-code, Phy Address, and register address in the MDI -		 * Control register.  The MAC will take care of interfacing with the -		 * PHY to retrieve the desired data. +		 * Control register.  The MAC will take care of interfacing with +		 * the PHY to retrieve the desired data.  		 */  		if (hw->mac_type == e1000_ce4100) {  			mdic = ((reg_addr << E1000_MDIC_REG_SHIFT) | @@ -2929,31 +2962,32 @@ static s32 e1000_read_phy_reg_ex(struct e1000_hw *hw, u32 reg_addr,  			*phy_data = (u16) mdic;  		}  	} else { -		/* We must first send a preamble through the MDIO pin to signal the -		 * beginning of an MII instruction.  This is done by sending 32 -		 * consecutive "1" bits. +		/* We must first send a preamble through the MDIO pin to signal +		 * the beginning of an MII instruction.  This is done by sending +		 * 32 consecutive "1" bits.  		 */  		e1000_shift_out_mdi_bits(hw, PHY_PREAMBLE, PHY_PREAMBLE_SIZE);  		/* Now combine the next few fields that are required for a read  		 * operation.  We use this method instead of calling the -		 * e1000_shift_out_mdi_bits routine five different times. The format of -		 * a MII read instruction consists of a shift out of 14 bits and is -		 * defined as follows: +		 * e1000_shift_out_mdi_bits routine five different times. The +		 * format of a MII read instruction consists of a shift out of +		 * 14 bits and is defined as follows:  		 *    <Preamble><SOF><Op Code><Phy Addr><Reg Addr> -		 * followed by a shift in of 18 bits.  This first two bits shifted in -		 * are TurnAround bits used to avoid contention on the MDIO pin when a -		 * READ operation is performed.  These two bits are thrown away -		 * followed by a shift in of 16 bits which contains the desired data. +		 * followed by a shift in of 18 bits.  This first two bits +		 * shifted in are TurnAround bits used to avoid contention on +		 * the MDIO pin when a READ operation is performed.  These two +		 * bits are thrown away followed by a shift in of 16 bits which +		 * contains the desired data.  		 */  		mdic = ((reg_addr) | (phy_addr << 5) |  			(PHY_OP_READ << 10) | (PHY_SOF << 12));  		e1000_shift_out_mdi_bits(hw, mdic, 14); -		/* Now that we've shifted out the read command to the MII, we need to -		 * "shift in" the 16-bit value (18 total bits) of the requested PHY -		 * register address. +		/* Now that we've shifted out the read command to the MII, we +		 * need to "shift in" the 16-bit value (18 total bits) of the +		 * requested PHY register address.  		 */  		*phy_data = e1000_shift_in_mdi_bits(hw);  	} @@ -3060,18 +3094,18 @@ static s32 e1000_write_phy_reg_ex(struct e1000_hw *hw, u32 reg_addr,  			}  		}  	} else { -		/* We'll need to use the SW defined pins to shift the write command -		 * out to the PHY. We first send a preamble to the PHY to signal the -		 * beginning of the MII instruction.  This is done by sending 32 -		 * consecutive "1" bits. +		/* We'll need to use the SW defined pins to shift the write +		 * command out to the PHY. We first send a preamble to the PHY +		 * to signal the beginning of the MII instruction.  This is done +		 * by sending 32 consecutive "1" bits.  		 */  		e1000_shift_out_mdi_bits(hw, PHY_PREAMBLE, PHY_PREAMBLE_SIZE); -		/* Now combine the remaining required fields that will indicate a -		 * write operation. We use this method instead of calling the -		 * e1000_shift_out_mdi_bits routine for each field in the command. The -		 * format of a MII write instruction is as follows: -		 * <Preamble><SOF><Op Code><Phy Addr><Reg Addr><Turnaround><Data>. +		/* Now combine the remaining required fields that will indicate +		 * a write operation. We use this method instead of calling the +		 * e1000_shift_out_mdi_bits routine for each field in the +		 * command. The format of a MII write instruction is as follows: +		 * <Preamble><SOF><OpCode><PhyAddr><RegAddr><Turnaround><Data>.  		 */  		mdic = ((PHY_TURNAROUND) | (reg_addr << 2) | (phy_addr << 7) |  			(PHY_OP_WRITE << 12) | (PHY_SOF << 14)); @@ -3100,10 +3134,10 @@ s32 e1000_phy_hw_reset(struct e1000_hw *hw)  	e_dbg("Resetting Phy...\n");  	if (hw->mac_type > e1000_82543) { -		/* Read the device control register and assert the E1000_CTRL_PHY_RST -		 * bit. Then, take it out of reset. +		/* Read the device control register and assert the +		 * E1000_CTRL_PHY_RST bit. Then, take it out of reset.  		 * For e1000 hardware, we delay for 10ms between the assert -		 * and deassert. +		 * and de-assert.  		 */  		ctrl = er32(CTRL);  		ew32(CTRL, ctrl | E1000_CTRL_PHY_RST); @@ -3115,8 +3149,9 @@ s32 e1000_phy_hw_reset(struct e1000_hw *hw)  		E1000_WRITE_FLUSH();  	} else { -		/* Read the Extended Device Control Register, assert the PHY_RESET_DIR -		 * bit to put the PHY into reset. Then, take it out of reset. +		/* Read the Extended Device Control Register, assert the +		 * PHY_RESET_DIR bit to put the PHY into reset. Then, take it +		 * out of reset.  		 */  		ctrl_ext = er32(CTRL_EXT);  		ctrl_ext |= E1000_CTRL_EXT_SDP4_DIR; @@ -3301,7 +3336,8 @@ static s32 e1000_phy_igp_get_info(struct e1000_hw *hw,  	e_dbg("e1000_phy_igp_get_info");  	/* The downshift status is checked only once, after link is established, -	 * and it stored in the hw->speed_downgraded parameter. */ +	 * and it stored in the hw->speed_downgraded parameter. +	 */  	phy_info->downshift = (e1000_downshift) hw->speed_downgraded;  	/* IGP01E1000 does not need to support it. */ @@ -3327,7 +3363,9 @@ static s32 e1000_phy_igp_get_info(struct e1000_hw *hw,  	if ((phy_data & IGP01E1000_PSSR_SPEED_MASK) ==  	    IGP01E1000_PSSR_SPEED_1000MBPS) { -		/* Local/Remote Receiver Information are only valid at 1000 Mbps */ +		/* Local/Remote Receiver Information are only valid @ 1000 +		 * Mbps +		 */  		ret_val = e1000_read_phy_reg(hw, PHY_1000T_STATUS, &phy_data);  		if (ret_val)  			return ret_val; @@ -3379,7 +3417,8 @@ static s32 e1000_phy_m88_get_info(struct e1000_hw *hw,  	e_dbg("e1000_phy_m88_get_info");  	/* The downshift status is checked only once, after link is established, -	 * and it stored in the hw->speed_downgraded parameter. */ +	 * and it stored in the hw->speed_downgraded parameter. +	 */  	phy_info->downshift = (e1000_downshift) hw->speed_downgraded;  	ret_val = e1000_read_phy_reg(hw, M88E1000_PHY_SPEC_CTRL, &phy_data); @@ -3574,8 +3613,8 @@ s32 e1000_init_eeprom_params(struct e1000_hw *hw)  	}  	if (eeprom->type == e1000_eeprom_spi) { -		/* eeprom_size will be an enum [0..8] that maps to eeprom sizes 128B to -		 * 32KB (incremented by powers of 2). +		/* eeprom_size will be an enum [0..8] that maps to eeprom sizes +		 * 128B to 32KB (incremented by powers of 2).  		 */  		/* Set to default value for initial eeprom read. */  		eeprom->word_size = 64; @@ -3585,8 +3624,9 @@ s32 e1000_init_eeprom_params(struct e1000_hw *hw)  		eeprom_size =  		    (eeprom_size & EEPROM_SIZE_MASK) >> EEPROM_SIZE_SHIFT;  		/* 256B eeprom size was not supported in earlier hardware, so we -		 * bump eeprom_size up one to ensure that "1" (which maps to 256B) -		 * is never the result used in the shifting logic below. */ +		 * bump eeprom_size up one to ensure that "1" (which maps to +		 * 256B) is never the result used in the shifting logic below. +		 */  		if (eeprom_size)  			eeprom_size++; @@ -3618,8 +3658,8 @@ static void e1000_raise_ee_clk(struct e1000_hw *hw, u32 *eecd)   */  static void e1000_lower_ee_clk(struct e1000_hw *hw, u32 *eecd)  { -	/* Lower the clock input to the EEPROM (by clearing the SK bit), and then -	 * wait 50 microseconds. +	/* Lower the clock input to the EEPROM (by clearing the SK bit), and +	 * then wait 50 microseconds.  	 */  	*eecd = *eecd & ~E1000_EECD_SK;  	ew32(EECD, *eecd); @@ -3651,10 +3691,11 @@ static void e1000_shift_out_ee_bits(struct e1000_hw *hw, u16 data, u16 count)  		eecd |= E1000_EECD_DO;  	}  	do { -		/* A "1" is shifted out to the EEPROM by setting bit "DI" to a "1", -		 * and then raising and then lowering the clock (the SK bit controls -		 * the clock input to the EEPROM).  A "0" is shifted out to the EEPROM -		 * by setting "DI" to "0" and then raising and then lowering the clock. +		/* A "1" is shifted out to the EEPROM by setting bit "DI" to a +		 * "1", and then raising and then lowering the clock (the SK bit +		 * controls the clock input to the EEPROM).  A "0" is shifted +		 * out to the EEPROM by setting "DI" to "0" and then raising and +		 * then lowering the clock.  		 */  		eecd &= ~E1000_EECD_DI; @@ -3691,9 +3732,9 @@ static u16 e1000_shift_in_ee_bits(struct e1000_hw *hw, u16 count)  	/* In order to read a register from the EEPROM, we need to shift 'count'  	 * bits in from the EEPROM. Bits are "shifted in" by raising the clock -	 * input to the EEPROM (setting the SK bit), and then reading the value of -	 * the "DO" bit.  During this "shifting in" process the "DI" bit should -	 * always be clear. +	 * input to the EEPROM (setting the SK bit), and then reading the value +	 * of the "DO" bit.  During this "shifting in" process the "DI" bit +	 * should always be clear.  	 */  	eecd = er32(EECD); @@ -3945,8 +3986,8 @@ static s32 e1000_do_read_eeprom(struct e1000_hw *hw, u16 offset, u16 words,  	if (eeprom->word_size == 0)  		e1000_init_eeprom_params(hw); -	/* A check for invalid values:  offset too large, too many words, and not -	 * enough words. +	/* A check for invalid values:  offset too large, too many words, and +	 * not enough words.  	 */  	if ((offset >= eeprom->word_size)  	    || (words > eeprom->word_size - offset) || (words == 0)) { @@ -3964,7 +4005,8 @@ static s32 e1000_do_read_eeprom(struct e1000_hw *hw, u16 offset, u16 words,  		return -E1000_ERR_EEPROM;  	/* Set up the SPI or Microwire EEPROM for bit-bang reading.  We have -	 * acquired the EEPROM at this point, so any returns should release it */ +	 * acquired the EEPROM at this point, so any returns should release it +	 */  	if (eeprom->type == e1000_eeprom_spi) {  		u16 word_in;  		u8 read_opcode = EEPROM_READ_OPCODE_SPI; @@ -3976,7 +4018,9 @@ static s32 e1000_do_read_eeprom(struct e1000_hw *hw, u16 offset, u16 words,  		e1000_standby_eeprom(hw); -		/* Some SPI eeproms use the 8th address bit embedded in the opcode */ +		/* Some SPI eeproms use the 8th address bit embedded in the +		 * opcode +		 */  		if ((eeprom->address_bits == 8) && (offset >= 128))  			read_opcode |= EEPROM_A8_OPCODE_SPI; @@ -3985,11 +4029,13 @@ static s32 e1000_do_read_eeprom(struct e1000_hw *hw, u16 offset, u16 words,  		e1000_shift_out_ee_bits(hw, (u16) (offset * 2),  					eeprom->address_bits); -		/* Read the data.  The address of the eeprom internally increments with -		 * each byte (spi) being read, saving on the overhead of eeprom setup -		 * and tear-down.  The address counter will roll over if reading beyond -		 * the size of the eeprom, thus allowing the entire memory to be read -		 * starting from any offset. */ +		/* Read the data.  The address of the eeprom internally +		 * increments with each byte (spi) being read, saving on the +		 * overhead of eeprom setup and tear-down.  The address counter +		 * will roll over if reading beyond the size of the eeprom, thus +		 * allowing the entire memory to be read starting from any +		 * offset. +		 */  		for (i = 0; i < words; i++) {  			word_in = e1000_shift_in_ee_bits(hw, 16);  			data[i] = (word_in >> 8) | (word_in << 8); @@ -4003,8 +4049,9 @@ static s32 e1000_do_read_eeprom(struct e1000_hw *hw, u16 offset, u16 words,  			e1000_shift_out_ee_bits(hw, (u16) (offset + i),  						eeprom->address_bits); -			/* Read the data.  For microwire, each word requires the overhead -			 * of eeprom setup and tear-down. */ +			/* Read the data.  For microwire, each word requires the +			 * overhead of eeprom setup and tear-down. +			 */  			data[i] = e1000_shift_in_ee_bits(hw, 16);  			e1000_standby_eeprom(hw);  		} @@ -4119,8 +4166,8 @@ static s32 e1000_do_write_eeprom(struct e1000_hw *hw, u16 offset, u16 words,  	if (eeprom->word_size == 0)  		e1000_init_eeprom_params(hw); -	/* A check for invalid values:  offset too large, too many words, and not -	 * enough words. +	/* A check for invalid values:  offset too large, too many words, and +	 * not enough words.  	 */  	if ((offset >= eeprom->word_size)  	    || (words > eeprom->word_size - offset) || (words == 0)) { @@ -4174,7 +4221,9 @@ static s32 e1000_write_eeprom_spi(struct e1000_hw *hw, u16 offset, u16 words,  		e1000_standby_eeprom(hw); -		/* Some SPI eeproms use the 8th address bit embedded in the opcode */ +		/* Some SPI eeproms use the 8th address bit embedded in the +		 * opcode +		 */  		if ((eeprom->address_bits == 8) && (offset >= 128))  			write_opcode |= EEPROM_A8_OPCODE_SPI; @@ -4186,16 +4235,19 @@ static s32 e1000_write_eeprom_spi(struct e1000_hw *hw, u16 offset, u16 words,  		/* Send the data */ -		/* Loop to allow for up to whole page write (32 bytes) of eeprom */ +		/* Loop to allow for up to whole page write (32 bytes) of +		 * eeprom +		 */  		while (widx < words) {  			u16 word_out = data[widx];  			word_out = (word_out >> 8) | (word_out << 8);  			e1000_shift_out_ee_bits(hw, word_out, 16);  			widx++; -			/* Some larger eeprom sizes are capable of a 32-byte PAGE WRITE -			 * operation, while the smaller eeproms are capable of an 8-byte -			 * PAGE WRITE operation.  Break the inner loop to pass new address +			/* Some larger eeprom sizes are capable of a 32-byte +			 * PAGE WRITE operation, while the smaller eeproms are +			 * capable of an 8-byte PAGE WRITE operation.  Break the +			 * inner loop to pass new address  			 */  			if ((((offset + widx) * 2) % eeprom->page_size) == 0) {  				e1000_standby_eeprom(hw); @@ -4249,14 +4301,15 @@ static s32 e1000_write_eeprom_microwire(struct e1000_hw *hw, u16 offset,  		/* Send the data */  		e1000_shift_out_ee_bits(hw, data[words_written], 16); -		/* Toggle the CS line.  This in effect tells the EEPROM to execute -		 * the previous command. +		/* Toggle the CS line.  This in effect tells the EEPROM to +		 * execute the previous command.  		 */  		e1000_standby_eeprom(hw); -		/* Read DO repeatedly until it is high (equal to '1').  The EEPROM will -		 * signal that the command has been completed by raising the DO signal. -		 * If DO does not go high in 10 milliseconds, then error out. +		/* Read DO repeatedly until it is high (equal to '1').  The +		 * EEPROM will signal that the command has been completed by +		 * raising the DO signal. If DO does not go high in 10 +		 * milliseconds, then error out.  		 */  		for (i = 0; i < 200; i++) {  			eecd = er32(EECD); @@ -4483,7 +4536,8 @@ static void e1000_clear_vfta(struct e1000_hw *hw)  	for (offset = 0; offset < E1000_VLAN_FILTER_TBL_SIZE; offset++) {  		/* If the offset we want to clear is the same offset of the  		 * manageability VLAN ID, then clear all bits except that of the -		 * manageability unit */ +		 * manageability unit +		 */  		vfta_value = (offset == vfta_offset) ? vfta_bit_in_reg : 0;  		E1000_WRITE_REG_ARRAY(hw, VFTA, offset, vfta_value);  		E1000_WRITE_FLUSH(); @@ -4911,12 +4965,12 @@ void e1000_tbi_adjust_stats(struct e1000_hw *hw, struct e1000_hw_stats *stats,  	 * counters overcount this packet as a CRC error and undercount  	 * the packet as a good packet  	 */ -	/* This packet should not be counted as a CRC error.    */ +	/* This packet should not be counted as a CRC error. */  	stats->crcerrs--; -	/* This packet does count as a Good Packet Received.    */ +	/* This packet does count as a Good Packet Received. */  	stats->gprc++; -	/* Adjust the Good Octets received counters             */ +	/* Adjust the Good Octets received counters */  	carry_bit = 0x80000000 & stats->gorcl;  	stats->gorcl += frame_len;  	/* If the high bit of Gorcl (the low 32 bits of the Good Octets @@ -5196,8 +5250,9 @@ static s32 e1000_check_polarity(struct e1000_hw *hw,  		if (ret_val)  			return ret_val; -		/* If speed is 1000 Mbps, must read the IGP01E1000_PHY_PCS_INIT_REG to -		 * find the polarity status */ +		/* If speed is 1000 Mbps, must read the +		 * IGP01E1000_PHY_PCS_INIT_REG to find the polarity status +		 */  		if ((phy_data & IGP01E1000_PSSR_SPEED_MASK) ==  		    IGP01E1000_PSSR_SPEED_1000MBPS) { @@ -5213,8 +5268,9 @@ static s32 e1000_check_polarity(struct e1000_hw *hw,  			    e1000_rev_polarity_reversed :  			    e1000_rev_polarity_normal;  		} else { -			/* For 10 Mbps, read the polarity bit in the status register. (for -			 * 100 Mbps this bit is always 0) */ +			/* For 10 Mbps, read the polarity bit in the status +			 * register. (for 100 Mbps this bit is always 0) +			 */  			*polarity =  			    (phy_data & IGP01E1000_PSSR_POLARITY_REVERSED) ?  			    e1000_rev_polarity_reversed : @@ -5374,8 +5430,9 @@ static s32 e1000_config_dsp_after_link_change(struct e1000_hw *hw, bool link_up)  		}  	} else {  		if (hw->dsp_config_state == e1000_dsp_config_activated) { -			/* Save off the current value of register 0x2F5B to be restored at -			 * the end of the routines. */ +			/* Save off the current value of register 0x2F5B to be +			 * restored at the end of the routines. +			 */  			ret_val =  			    e1000_read_phy_reg(hw, 0x2F5B, &phy_saved_data); @@ -5391,7 +5448,7 @@ static s32 e1000_config_dsp_after_link_change(struct e1000_hw *hw, bool link_up)  			msleep(20);  			ret_val = e1000_write_phy_reg(hw, 0x0000, -						      IGP01E1000_IEEE_FORCE_GIGA); +						    IGP01E1000_IEEE_FORCE_GIGA);  			if (ret_val)  				return ret_val;  			for (i = 0; i < IGP01E1000_PHY_CHANNEL_NUM; i++) { @@ -5412,7 +5469,7 @@ static s32 e1000_config_dsp_after_link_change(struct e1000_hw *hw, bool link_up)  			}  			ret_val = e1000_write_phy_reg(hw, 0x0000, -						      IGP01E1000_IEEE_RESTART_AUTONEG); +					IGP01E1000_IEEE_RESTART_AUTONEG);  			if (ret_val)  				return ret_val; @@ -5429,8 +5486,9 @@ static s32 e1000_config_dsp_after_link_change(struct e1000_hw *hw, bool link_up)  		}  		if (hw->ffe_config_state == e1000_ffe_config_active) { -			/* Save off the current value of register 0x2F5B to be restored at -			 * the end of the routines. */ +			/* Save off the current value of register 0x2F5B to be +			 * restored at the end of the routines. +			 */  			ret_val =  			    e1000_read_phy_reg(hw, 0x2F5B, &phy_saved_data); @@ -5446,7 +5504,7 @@ static s32 e1000_config_dsp_after_link_change(struct e1000_hw *hw, bool link_up)  			msleep(20);  			ret_val = e1000_write_phy_reg(hw, 0x0000, -						      IGP01E1000_IEEE_FORCE_GIGA); +						    IGP01E1000_IEEE_FORCE_GIGA);  			if (ret_val)  				return ret_val;  			ret_val = @@ -5456,7 +5514,7 @@ static s32 e1000_config_dsp_after_link_change(struct e1000_hw *hw, bool link_up)  				return ret_val;  			ret_val = e1000_write_phy_reg(hw, 0x0000, -						      IGP01E1000_IEEE_RESTART_AUTONEG); +					IGP01E1000_IEEE_RESTART_AUTONEG);  			if (ret_val)  				return ret_val; @@ -5542,8 +5600,9 @@ static s32 e1000_set_d3_lplu_state(struct e1000_hw *hw, bool active)  		return E1000_SUCCESS;  	/* During driver activity LPLU should not be used or it will attain link -	 * from the lowest speeds starting from 10Mbps. The capability is used for -	 * Dx transitions and states */ +	 * from the lowest speeds starting from 10Mbps. The capability is used +	 * for Dx transitions and states +	 */  	if (hw->mac_type == e1000_82541_rev_2  	    || hw->mac_type == e1000_82547_rev_2) {  		ret_val = @@ -5563,10 +5622,11 @@ static s32 e1000_set_d3_lplu_state(struct e1000_hw *hw, bool active)  				return ret_val;  		} -		/* LPLU and SmartSpeed are mutually exclusive.  LPLU is used during -		 * Dx states where the power conservation is most important.  During -		 * driver activity we should enable SmartSpeed, so performance is -		 * maintained. */ +		/* LPLU and SmartSpeed are mutually exclusive.  LPLU is used +		 * during Dx states where the power conservation is most +		 * important.  During driver activity we should enable +		 * SmartSpeed, so performance is maintained. +		 */  		if (hw->smart_speed == e1000_smart_speed_on) {  			ret_val =  			    e1000_read_phy_reg(hw, IGP01E1000_PHY_PORT_CONFIG, diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/ethernet/intel/e1000/e1000_main.c index 294da56b824..8502c625dbe 100644 --- a/drivers/net/ethernet/intel/e1000/e1000_main.c +++ b/drivers/net/ethernet/intel/e1000/e1000_main.c @@ -239,7 +239,6 @@ struct net_device *e1000_get_hw_dev(struct e1000_hw *hw)   * e1000_init_module is the first routine called when the driver is   * loaded. All it does is register with the PCI subsystem.   **/ -  static int __init e1000_init_module(void)  {  	int ret; @@ -266,7 +265,6 @@ module_init(e1000_init_module);   * e1000_exit_module is called just before the driver is removed   * from memory.   **/ -  static void __exit e1000_exit_module(void)  {  	pci_unregister_driver(&e1000_driver); @@ -301,7 +299,6 @@ static void e1000_free_irq(struct e1000_adapter *adapter)   * e1000_irq_disable - Mask off interrupt generation on the NIC   * @adapter: board private structure   **/ -  static void e1000_irq_disable(struct e1000_adapter *adapter)  {  	struct e1000_hw *hw = &adapter->hw; @@ -315,7 +312,6 @@ static void e1000_irq_disable(struct e1000_adapter *adapter)   * e1000_irq_enable - Enable default interrupt generation settings   * @adapter: board private structure   **/ -  static void e1000_irq_enable(struct e1000_adapter *adapter)  {  	struct e1000_hw *hw = &adapter->hw; @@ -398,11 +394,12 @@ static void e1000_configure(struct e1000_adapter *adapter)  	e1000_configure_rx(adapter);  	/* call E1000_DESC_UNUSED which always leaves  	 * at least 1 descriptor unused to make sure -	 * next_to_use != next_to_clean */ +	 * next_to_use != next_to_clean +	 */  	for (i = 0; i < adapter->num_rx_queues; i++) {  		struct e1000_rx_ring *ring = &adapter->rx_ring[i];  		adapter->alloc_rx_buf(adapter, ring, -		                      E1000_DESC_UNUSED(ring)); +				      E1000_DESC_UNUSED(ring));  	}  } @@ -433,9 +430,7 @@ int e1000_up(struct e1000_adapter *adapter)   * The phy may be powered down to save power and turn off link when the   * driver is unloaded and wake on lan is not enabled (among others)   * *** this routine MUST be followed by a call to e1000_reset *** - *   **/ -  void e1000_power_up_phy(struct e1000_adapter *adapter)  {  	struct e1000_hw *hw = &adapter->hw; @@ -444,7 +439,8 @@ void e1000_power_up_phy(struct e1000_adapter *adapter)  	/* Just clear the power down bit to wake the phy back up */  	if (hw->media_type == e1000_media_type_copper) {  		/* according to the manual, the phy will retain its -		 * settings across a power-down/up cycle */ +		 * settings across a power-down/up cycle +		 */  		e1000_read_phy_reg(hw, PHY_CTRL, &mii_reg);  		mii_reg &= ~MII_CR_POWER_DOWN;  		e1000_write_phy_reg(hw, PHY_CTRL, mii_reg); @@ -459,7 +455,8 @@ static void e1000_power_down_phy(struct e1000_adapter *adapter)  	 * The PHY cannot be powered down if any of the following is true *  	 * (a) WoL is enabled  	 * (b) AMT is active -	 * (c) SoL/IDER session is active */ +	 * (c) SoL/IDER session is active +	 */  	if (!adapter->wol && hw->mac_type >= e1000_82540 &&  	   hw->media_type == e1000_media_type_copper) {  		u16 mii_reg = 0; @@ -529,8 +526,7 @@ void e1000_down(struct e1000_adapter *adapter)  	e1000_irq_disable(adapter); -	/* -	 * Setting DOWN must be after irq_disable to prevent +	/* Setting DOWN must be after irq_disable to prevent  	 * a screaming interrupt.  Setting DOWN also prevents  	 * tasks from rescheduling.  	 */ @@ -627,14 +623,14 @@ void e1000_reset(struct e1000_adapter *adapter)  		 * rounded up to the next 1KB and expressed in KB.  Likewise,  		 * the Rx FIFO should be large enough to accommodate at least  		 * one full receive packet and is similarly rounded up and -		 * expressed in KB. */ +		 * expressed in KB. +		 */  		pba = er32(PBA);  		/* upper 16 bits has Tx packet buffer allocation size in KB */  		tx_space = pba >> 16;  		/* lower 16 bits has Rx packet buffer allocation size in KB */  		pba &= 0xffff; -		/* -		 * the tx fifo also stores 16 bytes of information about the tx +		/* the Tx fifo also stores 16 bytes of information about the Tx  		 * but don't include ethernet FCS because hardware appends it  		 */  		min_tx_space = (hw->max_frame_size + @@ -649,7 +645,8 @@ void e1000_reset(struct e1000_adapter *adapter)  		/* If current Tx allocation is less than the min Tx FIFO size,  		 * and the min Tx FIFO size is less than the current Rx FIFO -		 * allocation, take space away from current Rx allocation */ +		 * allocation, take space away from current Rx allocation +		 */  		if (tx_space < min_tx_space &&  		    ((min_tx_space - tx_space) < pba)) {  			pba = pba - (min_tx_space - tx_space); @@ -663,8 +660,9 @@ void e1000_reset(struct e1000_adapter *adapter)  				break;  			} -			/* if short on rx space, rx wins and must trump tx -			 * adjustment or use Early Receive if available */ +			/* if short on Rx space, Rx wins and must trump Tx +			 * adjustment or use Early Receive if available +			 */  			if (pba < min_rx_space)  				pba = min_rx_space;  		} @@ -672,8 +670,7 @@ void e1000_reset(struct e1000_adapter *adapter)  	ew32(PBA, pba); -	/* -	 * flow control settings: +	/* flow control settings:  	 * The high water mark must be low enough to fit one full frame  	 * (or the size used for early receive) above it in the Rx FIFO.  	 * Set it to the lower of: @@ -707,7 +704,8 @@ void e1000_reset(struct e1000_adapter *adapter)  		u32 ctrl = er32(CTRL);  		/* clear phy power management bit if we are in gig only mode,  		 * which if enabled will attempt negotiation to 100Mb, which -		 * can cause a loss of link at power off or driver unload */ +		 * can cause a loss of link at power off or driver unload +		 */  		ctrl &= ~E1000_CTRL_SWDPIN3;  		ew32(CTRL, ctrl);  	} @@ -808,9 +806,8 @@ static int e1000_is_need_ioport(struct pci_dev *pdev)  static netdev_features_t e1000_fix_features(struct net_device *netdev,  	netdev_features_t features)  { -	/* -	 * Since there is no support for separate rx/tx vlan accel -	 * enable/disable make sure tx flag is always in same state as rx. +	/* Since there is no support for separate Rx/Tx vlan accel +	 * enable/disable make sure Tx flag is always in same state as Rx.  	 */  	if (features & NETIF_F_HW_VLAN_RX)  		features |= NETIF_F_HW_VLAN_TX; @@ -1012,16 +1009,14 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)  	if (err)  		goto err_sw_init; -	/* -	 * there is a workaround being applied below that limits +	/* there is a workaround being applied below that limits  	 * 64-bit DMA addresses to 64-bit hardware.  There are some  	 * 32-bit adapters that Tx hang when given 64-bit DMA addresses  	 */  	pci_using_dac = 0;  	if ((hw->bus_type == e1000_bus_type_pcix) &&  	    !dma_set_mask(&pdev->dev, DMA_BIT_MASK(64))) { -		/* -		 * according to DMA-API-HOWTO, coherent calls will always +		/* according to DMA-API-HOWTO, coherent calls will always  		 * succeed if the set call did  		 */  		dma_set_coherent_mask(&pdev->dev, DMA_BIT_MASK(64)); @@ -1099,7 +1094,8 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)  	}  	/* before reading the EEPROM, reset the controller to -	 * put the device in a known good starting state */ +	 * put the device in a known good starting state +	 */  	e1000_reset_hw(hw); @@ -1107,8 +1103,7 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)  	if (e1000_validate_eeprom_checksum(hw) < 0) {  		e_err(probe, "The EEPROM Checksum Is Not Valid\n");  		e1000_dump_eeprom(adapter); -		/* -		 * set MAC address to all zeroes to invalidate and temporary +		/* set MAC address to all zeroes to invalidate and temporary  		 * disable this device for the user. This blocks regular  		 * traffic while still permitting ethtool ioctls from reaching  		 * the hardware as well as allowing the user to run the @@ -1123,9 +1118,8 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)  	}  	/* don't block initalization here due to bad MAC address */  	memcpy(netdev->dev_addr, hw->mac_addr, netdev->addr_len); -	memcpy(netdev->perm_addr, hw->mac_addr, netdev->addr_len); -	if (!is_valid_ether_addr(netdev->perm_addr)) +	if (!is_valid_ether_addr(netdev->dev_addr))  		e_err(probe, "Invalid MAC Address\n"); @@ -1170,7 +1164,8 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)  	/* now that we have the eeprom settings, apply the special cases  	 * where the eeprom may be wrong or the board simply won't support -	 * wake on lan on a particular port */ +	 * wake on lan on a particular port +	 */  	switch (pdev->device) {  	case E1000_DEV_ID_82546GB_PCIE:  		adapter->eeprom_wol = 0; @@ -1178,7 +1173,8 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)  	case E1000_DEV_ID_82546EB_FIBER:  	case E1000_DEV_ID_82546GB_FIBER:  		/* Wake events only supported on port A for dual fiber -		 * regardless of eeprom setting */ +		 * regardless of eeprom setting +		 */  		if (er32(STATUS) & E1000_STATUS_FUNC_1)  			adapter->eeprom_wol = 0;  		break; @@ -1271,7 +1267,6 @@ err_pci_reg:   * Hot-Plug event, or because the driver is going to be removed from   * memory.   **/ -  static void e1000_remove(struct pci_dev *pdev)  {  	struct net_device *netdev = pci_get_drvdata(pdev); @@ -1307,7 +1302,6 @@ static void e1000_remove(struct pci_dev *pdev)   * e1000_sw_init initializes the Adapter private data structure.   * e1000_init_hw_struct MUST be called before this function   **/ -  static int e1000_sw_init(struct e1000_adapter *adapter)  {  	adapter->rx_buffer_len = MAXIMUM_ETHERNET_VLAN_SIZE; @@ -1338,7 +1332,6 @@ static int e1000_sw_init(struct e1000_adapter *adapter)   * We allocate one ring per queue at run-time since we don't know the   * number of queues at compile-time.   **/ -  static int e1000_alloc_queues(struct e1000_adapter *adapter)  {  	adapter->tx_ring = kcalloc(adapter->num_tx_queues, @@ -1368,7 +1361,6 @@ static int e1000_alloc_queues(struct e1000_adapter *adapter)   * handler is registered with the OS, the watchdog task is started,   * and the stack is notified that the interface is ready.   **/ -  static int e1000_open(struct net_device *netdev)  {  	struct e1000_adapter *adapter = netdev_priv(netdev); @@ -1402,7 +1394,8 @@ static int e1000_open(struct net_device *netdev)  	/* before we allocate an interrupt, we must be ready to handle it.  	 * Setting DEBUG_SHIRQ in the kernel makes it fire an interrupt  	 * as soon as we call pci_request_irq, so we have to setup our -	 * clean_rx handler before we do so.  */ +	 * clean_rx handler before we do so. +	 */  	e1000_configure(adapter);  	err = e1000_request_irq(adapter); @@ -1445,7 +1438,6 @@ err_setup_tx:   * needs to be disabled.  A global MAC reset is issued to stop the   * hardware, and all transmit and receive resources are freed.   **/ -  static int e1000_close(struct net_device *netdev)  {  	struct e1000_adapter *adapter = netdev_priv(netdev); @@ -1460,10 +1452,11 @@ static int e1000_close(struct net_device *netdev)  	e1000_free_all_rx_resources(adapter);  	/* kill manageability vlan ID if supported, but not if a vlan with -	 * the same ID is registered on the host OS (let 8021q kill it) */ +	 * the same ID is registered on the host OS (let 8021q kill it) +	 */  	if ((hw->mng_cookie.status & -			  E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) && -	     !test_bit(adapter->mng_vlan_id, adapter->active_vlans)) { +	     E1000_MNG_DHCP_COOKIE_STATUS_VLAN_SUPPORT) && +	    !test_bit(adapter->mng_vlan_id, adapter->active_vlans)) {  		e1000_vlan_rx_kill_vid(netdev, adapter->mng_vlan_id);  	} @@ -1484,7 +1477,8 @@ static bool e1000_check_64k_bound(struct e1000_adapter *adapter, void *start,  	unsigned long end = begin + len;  	/* First rev 82545 and 82546 need to not allow any memory -	 * write location to cross 64k boundary due to errata 23 */ +	 * write location to cross 64k boundary due to errata 23 +	 */  	if (hw->mac_type == e1000_82545 ||  	    hw->mac_type == e1000_ce4100 ||  	    hw->mac_type == e1000_82546) { @@ -1501,7 +1495,6 @@ static bool e1000_check_64k_bound(struct e1000_adapter *adapter, void *start,   *   * Return 0 on success, negative on failure   **/ -  static int e1000_setup_tx_resources(struct e1000_adapter *adapter,  				    struct e1000_tx_ring *txdr)  { @@ -1510,11 +1503,8 @@ static int e1000_setup_tx_resources(struct e1000_adapter *adapter,  	size = sizeof(struct e1000_buffer) * txdr->count;  	txdr->buffer_info = vzalloc(size); -	if (!txdr->buffer_info) { -		e_err(probe, "Unable to allocate memory for the Tx descriptor " -		      "ring\n"); +	if (!txdr->buffer_info)  		return -ENOMEM; -	}  	/* round up to nearest 4K */ @@ -1578,7 +1568,6 @@ setup_tx_desc_die:   *   * Return 0 on success, negative on failure   **/ -  int e1000_setup_all_tx_resources(struct e1000_adapter *adapter)  {  	int i, err = 0; @@ -1603,7 +1592,6 @@ int e1000_setup_all_tx_resources(struct e1000_adapter *adapter)   *   * Configure the Tx unit of the MAC after a reset.   **/ -  static void e1000_configure_tx(struct e1000_adapter *adapter)  {  	u64 tdba; @@ -1624,8 +1612,10 @@ static void e1000_configure_tx(struct e1000_adapter *adapter)  		ew32(TDBAL, (tdba & 0x00000000ffffffffULL));  		ew32(TDT, 0);  		ew32(TDH, 0); -		adapter->tx_ring[0].tdh = ((hw->mac_type >= e1000_82543) ? E1000_TDH : E1000_82542_TDH); -		adapter->tx_ring[0].tdt = ((hw->mac_type >= e1000_82543) ? E1000_TDT : E1000_82542_TDT); +		adapter->tx_ring[0].tdh = ((hw->mac_type >= e1000_82543) ? +					   E1000_TDH : E1000_82542_TDH); +		adapter->tx_ring[0].tdt = ((hw->mac_type >= e1000_82543) ? +					   E1000_TDT : E1000_82542_TDT);  		break;  	} @@ -1680,7 +1670,8 @@ static void e1000_configure_tx(struct e1000_adapter *adapter)  		adapter->txd_cmd |= E1000_TXD_CMD_RS;  	/* Cache if we're 82544 running in PCI-X because we'll -	 * need this to apply a workaround later in the send path. */ +	 * need this to apply a workaround later in the send path. +	 */  	if (hw->mac_type == e1000_82544 &&  	    hw->bus_type == e1000_bus_type_pcix)  		adapter->pcix_82544 = true; @@ -1696,7 +1687,6 @@ static void e1000_configure_tx(struct e1000_adapter *adapter)   *   * Returns 0 on success, negative on failure   **/ -  static int e1000_setup_rx_resources(struct e1000_adapter *adapter,  				    struct e1000_rx_ring *rxdr)  { @@ -1705,11 +1695,8 @@ static int e1000_setup_rx_resources(struct e1000_adapter *adapter,  	size = sizeof(struct e1000_buffer) * rxdr->count;  	rxdr->buffer_info = vzalloc(size); -	if (!rxdr->buffer_info) { -		e_err(probe, "Unable to allocate memory for the Rx descriptor " -		      "ring\n"); +	if (!rxdr->buffer_info)  		return -ENOMEM; -	}  	desc_len = sizeof(struct e1000_rx_desc); @@ -1778,7 +1765,6 @@ setup_rx_desc_die:   *   * Return 0 on success, negative on failure   **/ -  int e1000_setup_all_rx_resources(struct e1000_adapter *adapter)  {  	int i, err = 0; @@ -1847,7 +1833,8 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter)  	/* This is useful for sniffing bad packets. */  	if (adapter->netdev->features & NETIF_F_RXALL) {  		/* UPE and MPE will be handled by normal PROMISC logic -		 * in e1000e_set_rx_mode */ +		 * in e1000e_set_rx_mode +		 */  		rctl |= (E1000_RCTL_SBP | /* Receive bad packets */  			 E1000_RCTL_BAM | /* RX All Bcast Pkts */  			 E1000_RCTL_PMCF); /* RX All MAC Ctrl Pkts */ @@ -1869,7 +1856,6 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter)   *   * Configure the Rx unit of the MAC after a reset.   **/ -  static void e1000_configure_rx(struct e1000_adapter *adapter)  {  	u64 rdba; @@ -1902,7 +1888,8 @@ static void e1000_configure_rx(struct e1000_adapter *adapter)  	}  	/* Setup the HW Rx Head and Tail Descriptor Pointers and -	 * the Base and Length of the Rx Descriptor Ring */ +	 * the Base and Length of the Rx Descriptor Ring +	 */  	switch (adapter->num_rx_queues) {  	case 1:  	default: @@ -1912,8 +1899,10 @@ static void e1000_configure_rx(struct e1000_adapter *adapter)  		ew32(RDBAL, (rdba & 0x00000000ffffffffULL));  		ew32(RDT, 0);  		ew32(RDH, 0); -		adapter->rx_ring[0].rdh = ((hw->mac_type >= e1000_82543) ? E1000_RDH : E1000_82542_RDH); -		adapter->rx_ring[0].rdt = ((hw->mac_type >= e1000_82543) ? E1000_RDT : E1000_82542_RDT); +		adapter->rx_ring[0].rdh = ((hw->mac_type >= e1000_82543) ? +					   E1000_RDH : E1000_82542_RDH); +		adapter->rx_ring[0].rdt = ((hw->mac_type >= e1000_82543) ? +					   E1000_RDT : E1000_82542_RDT);  		break;  	} @@ -1939,7 +1928,6 @@ static void e1000_configure_rx(struct e1000_adapter *adapter)   *   * Free all transmit software resources   **/ -  static void e1000_free_tx_resources(struct e1000_adapter *adapter,  				    struct e1000_tx_ring *tx_ring)  { @@ -1962,7 +1950,6 @@ static void e1000_free_tx_resources(struct e1000_adapter *adapter,   *   * Free all transmit software resources   **/ -  void e1000_free_all_tx_resources(struct e1000_adapter *adapter)  {  	int i; @@ -1997,7 +1984,6 @@ static void e1000_unmap_and_free_tx_resource(struct e1000_adapter *adapter,   * @adapter: board private structure   * @tx_ring: ring to be cleaned   **/ -  static void e1000_clean_tx_ring(struct e1000_adapter *adapter,  				struct e1000_tx_ring *tx_ring)  { @@ -2033,7 +2019,6 @@ static void e1000_clean_tx_ring(struct e1000_adapter *adapter,   * e1000_clean_all_tx_rings - Free Tx Buffers for all queues   * @adapter: board private structure   **/ -  static void e1000_clean_all_tx_rings(struct e1000_adapter *adapter)  {  	int i; @@ -2049,7 +2034,6 @@ static void e1000_clean_all_tx_rings(struct e1000_adapter *adapter)   *   * Free all receive software resources   **/ -  static void e1000_free_rx_resources(struct e1000_adapter *adapter,  				    struct e1000_rx_ring *rx_ring)  { @@ -2072,7 +2056,6 @@ static void e1000_free_rx_resources(struct e1000_adapter *adapter,   *   * Free all receive software resources   **/ -  void e1000_free_all_rx_resources(struct e1000_adapter *adapter)  {  	int i; @@ -2086,7 +2069,6 @@ void e1000_free_all_rx_resources(struct e1000_adapter *adapter)   * @adapter: board private structure   * @rx_ring: ring to free buffers from   **/ -  static void e1000_clean_rx_ring(struct e1000_adapter *adapter,  				struct e1000_rx_ring *rx_ring)  { @@ -2145,7 +2127,6 @@ static void e1000_clean_rx_ring(struct e1000_adapter *adapter,   * e1000_clean_all_rx_rings - Free Rx Buffers for all queues   * @adapter: board private structure   **/ -  static void e1000_clean_all_rx_rings(struct e1000_adapter *adapter)  {  	int i; @@ -2205,7 +2186,6 @@ static void e1000_leave_82542_rst(struct e1000_adapter *adapter)   *   * Returns 0 on success, negative on failure   **/ -  static int e1000_set_mac(struct net_device *netdev, void *p)  {  	struct e1000_adapter *adapter = netdev_priv(netdev); @@ -2240,7 +2220,6 @@ static int e1000_set_mac(struct net_device *netdev, void *p)   * responsible for configuring the hardware for proper unicast, multicast,   * promiscuous mode, and all-multi behavior.   **/ -  static void e1000_set_rx_mode(struct net_device *netdev)  {  	struct e1000_adapter *adapter = netdev_priv(netdev); @@ -2253,10 +2232,8 @@ static void e1000_set_rx_mode(struct net_device *netdev)  	int mta_reg_count = E1000_NUM_MTA_REGISTERS;  	u32 *mcarray = kcalloc(mta_reg_count, sizeof(u32), GFP_ATOMIC); -	if (!mcarray) { -		e_err(probe, "memory allocation failed\n"); +	if (!mcarray)  		return; -	}  	/* Check for Promiscuous and All Multicast modes */ @@ -2326,10 +2303,10 @@ static void e1000_set_rx_mode(struct net_device *netdev)  	}  	/* write the hash table completely, write from bottom to avoid -	 * both stupid write combining chipsets, and flushing each write */ +	 * both stupid write combining chipsets, and flushing each write +	 */  	for (i = mta_reg_count - 1; i >= 0 ; i--) { -		/* -		 * If we are on an 82544 has an errata where writing odd +		/* If we are on an 82544 has an errata where writing odd  		 * offsets overwrites the previous even offset, but writing  		 * backwards over the range solves the issue by always  		 * writing the odd offset first @@ -2467,8 +2444,8 @@ static void e1000_watchdog(struct work_struct *work)  			bool txb2b = true;  			/* update snapshot of PHY registers on LSC */  			e1000_get_speed_and_duplex(hw, -			                           &adapter->link_speed, -			                           &adapter->link_duplex); +						   &adapter->link_speed, +						   &adapter->link_duplex);  			ctrl = er32(CTRL);  			pr_info("%s NIC Link is Up %d Mbps %s, " @@ -2542,7 +2519,8 @@ link_up:  			/* We've lost link, so the controller stops DMA,  			 * but we've got queued Tx work that's never going  			 * to get done, so reset controller to flush Tx. -			 * (Do the reset outside of interrupt context). */ +			 * (Do the reset outside of interrupt context). +			 */  			adapter->tx_timeout_count++;  			schedule_work(&adapter->reset_task);  			/* exit immediately since reset is imminent */ @@ -2552,8 +2530,7 @@ link_up:  	/* Simple mode for Interrupt Throttle Rate (ITR) */  	if (hw->mac_type >= e1000_82540 && adapter->itr_setting == 4) { -		/* -		 * Symmetric Tx/Rx gets a reduced ITR=2000; +		/* Symmetric Tx/Rx gets a reduced ITR=2000;  		 * Total asymmetrical Tx or Rx gets ITR=8000;  		 * everyone else is between 2000-8000.  		 */ @@ -2668,18 +2645,16 @@ static void e1000_set_itr(struct e1000_adapter *adapter)  		goto set_itr_now;  	} -	adapter->tx_itr = e1000_update_itr(adapter, -	                            adapter->tx_itr, -	                            adapter->total_tx_packets, -	                            adapter->total_tx_bytes); +	adapter->tx_itr = e1000_update_itr(adapter, adapter->tx_itr, +					   adapter->total_tx_packets, +					   adapter->total_tx_bytes);  	/* conservative mode (itr 3) eliminates the lowest_latency setting */  	if (adapter->itr_setting == 3 && adapter->tx_itr == lowest_latency)  		adapter->tx_itr = low_latency; -	adapter->rx_itr = e1000_update_itr(adapter, -	                            adapter->rx_itr, -	                            adapter->total_rx_packets, -	                            adapter->total_rx_bytes); +	adapter->rx_itr = e1000_update_itr(adapter, adapter->rx_itr, +					   adapter->total_rx_packets, +					   adapter->total_rx_bytes);  	/* conservative mode (itr 3) eliminates the lowest_latency setting */  	if (adapter->itr_setting == 3 && adapter->rx_itr == lowest_latency)  		adapter->rx_itr = low_latency; @@ -2705,10 +2680,11 @@ set_itr_now:  	if (new_itr != adapter->itr) {  		/* this attempts to bias the interrupt rate towards Bulk  		 * by adding intermediate steps when interrupt rate is -		 * increasing */ +		 * increasing +		 */  		new_itr = new_itr > adapter->itr ? -		             min(adapter->itr + (new_itr >> 2), new_itr) : -		             new_itr; +			  min(adapter->itr + (new_itr >> 2), new_itr) : +			  new_itr;  		adapter->itr = new_itr;  		ew32(ITR, 1000000000 / (new_itr * 256));  	} @@ -2870,7 +2846,8 @@ static int e1000_tx_map(struct e1000_adapter *adapter,  		/* Workaround for Controller erratum --  		 * descriptor for non-tso packet in a linear SKB that follows a  		 * tso gets written back prematurely before the data is fully -		 * DMA'd to the controller */ +		 * DMA'd to the controller +		 */  		if (!skb->data_len && tx_ring->last_tx_tso &&  		    !skb_is_gso(skb)) {  			tx_ring->last_tx_tso = false; @@ -2878,7 +2855,8 @@ static int e1000_tx_map(struct e1000_adapter *adapter,  		}  		/* Workaround for premature desc write-backs -		 * in TSO mode.  Append 4-byte sentinel desc */ +		 * in TSO mode.  Append 4-byte sentinel desc +		 */  		if (unlikely(mss && !nr_frags && size == len && size > 8))  			size -= 4;  		/* work-around for errata 10 and it applies @@ -2891,7 +2869,8 @@ static int e1000_tx_map(struct e1000_adapter *adapter,  		        size = 2015;  		/* Workaround for potential 82544 hang in PCI-X.  Avoid -		 * terminating buffers within evenly-aligned dwords. */ +		 * terminating buffers within evenly-aligned dwords. +		 */  		if (unlikely(adapter->pcix_82544 &&  		   !((unsigned long)(skb->data + offset + size - 1) & 4) &&  		   size > 4)) @@ -2903,7 +2882,7 @@ static int e1000_tx_map(struct e1000_adapter *adapter,  		buffer_info->mapped_as_page = false;  		buffer_info->dma = dma_map_single(&pdev->dev,  						  skb->data + offset, -						  size,	DMA_TO_DEVICE); +						  size, DMA_TO_DEVICE);  		if (dma_mapping_error(&pdev->dev, buffer_info->dma))  			goto dma_error;  		buffer_info->next_to_watch = i; @@ -2934,12 +2913,15 @@ static int e1000_tx_map(struct e1000_adapter *adapter,  			buffer_info = &tx_ring->buffer_info[i];  			size = min(len, max_per_txd);  			/* Workaround for premature desc write-backs -			 * in TSO mode.  Append 4-byte sentinel desc */ -			if (unlikely(mss && f == (nr_frags-1) && size == len && size > 8)) +			 * in TSO mode.  Append 4-byte sentinel desc +			 */ +			if (unlikely(mss && f == (nr_frags-1) && +			    size == len && size > 8))  				size -= 4;  			/* Workaround for potential 82544 hang in PCI-X.  			 * Avoid terminating buffers within evenly-aligned -			 * dwords. */ +			 * dwords. +			 */  			bufend = (unsigned long)  				page_to_phys(skb_frag_page(frag));  			bufend += offset + size - 1; @@ -3003,7 +2985,7 @@ static void e1000_tx_queue(struct e1000_adapter *adapter,  	if (likely(tx_flags & E1000_TX_FLAGS_TSO)) {  		txd_lower |= E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D | -		             E1000_TXD_CMD_TSE; +			     E1000_TXD_CMD_TSE;  		txd_upper |= E1000_TXD_POPTS_TXSM << 8;  		if (likely(tx_flags & E1000_TX_FLAGS_IPV4)) @@ -3044,13 +3026,15 @@ static void e1000_tx_queue(struct e1000_adapter *adapter,  	/* Force memory writes to complete before letting h/w  	 * know there are new descriptors to fetch.  (Only  	 * applicable for weak-ordered memory model archs, -	 * such as IA-64). */ +	 * such as IA-64). +	 */  	wmb();  	tx_ring->next_to_use = i;  	writel(i, hw->hw_addr + tx_ring->tdt);  	/* we need this if more than one processor can write to our tail -	 * at a time, it syncronizes IO on IA64/Altix systems */ +	 * at a time, it synchronizes IO on IA64/Altix systems +	 */  	mmiowb();  } @@ -3099,11 +3083,13 @@ static int __e1000_maybe_stop_tx(struct net_device *netdev, int size)  	netif_stop_queue(netdev);  	/* Herbert's original patch had:  	 *  smp_mb__after_netif_stop_queue(); -	 * but since that doesn't exist yet, just open code it. */ +	 * but since that doesn't exist yet, just open code it. +	 */  	smp_mb();  	/* We need to check again in a case another CPU has just -	 * made room available. */ +	 * made room available. +	 */  	if (likely(E1000_DESC_UNUSED(tx_ring) < size))  		return -EBUSY; @@ -3114,7 +3100,7 @@ static int __e1000_maybe_stop_tx(struct net_device *netdev, int size)  }  static int e1000_maybe_stop_tx(struct net_device *netdev, -                               struct e1000_tx_ring *tx_ring, int size) +			       struct e1000_tx_ring *tx_ring, int size)  {  	if (likely(E1000_DESC_UNUSED(tx_ring) >= size))  		return 0; @@ -3138,10 +3124,11 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,  	int tso;  	unsigned int f; -	/* This goes back to the question of how to logically map a tx queue +	/* This goes back to the question of how to logically map a Tx queue  	 * to a flow.  Right now, performance is impacted slightly negatively -	 * if using multiple tx queues.  If the stack breaks away from a -	 * single qdisc implementation, we can look at this again. */ +	 * if using multiple Tx queues.  If the stack breaks away from a +	 * single qdisc implementation, we can look at this again. +	 */  	tx_ring = adapter->tx_ring;  	if (unlikely(skb->len <= 0)) { @@ -3166,7 +3153,8 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,  	 * initiating the DMA for each buffer.  The calc is:  	 * 4 = ceil(buffer len/mss).  To make sure we don't  	 * overrun the FIFO, adjust the max buffer len if mss -	 * drops. */ +	 * drops. +	 */  	if (mss) {  		u8 hdr_len;  		max_per_txd = min(mss << 2, max_per_txd); @@ -3182,8 +3170,10 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,  				 * this hardware's requirements  				 * NOTE: this is a TSO only workaround  				 * if end byte alignment not correct move us -				 * into the next dword */ -				if ((unsigned long)(skb_tail_pointer(skb) - 1) & 4) +				 * into the next dword +				 */ +				if ((unsigned long)(skb_tail_pointer(skb) - 1) +				    & 4)  					break;  				/* fall through */  				pull_size = min((unsigned int)4, skb->data_len); @@ -3231,7 +3221,8 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,  		count += nr_frags;  	/* need: count + 2 desc gap to keep tail from touching -	 * head, otherwise try next time */ +	 * head, otherwise try next time +	 */  	if (unlikely(e1000_maybe_stop_tx(netdev, tx_ring, count + 2)))  		return NETDEV_TX_BUSY; @@ -3270,7 +3261,7 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,  		tx_flags |= E1000_TX_FLAGS_NO_FCS;  	count = e1000_tx_map(adapter, tx_ring, skb, first, max_per_txd, -	                     nr_frags, mss); +			     nr_frags, mss);  	if (count) {  		netdev_sent_queue(netdev, skb->len); @@ -3372,9 +3363,7 @@ static void e1000_dump(struct e1000_adapter *adapter)  	/* Print Registers */  	e1000_regdump(adapter); -	/* -	 * transmit dump -	 */ +	/* transmit dump */  	pr_info("TX Desc ring0 dump\n");  	/* Transmit Descriptor Formats - DEXT[29] is 0 (Legacy) or 1 (Extended) @@ -3435,9 +3424,7 @@ static void e1000_dump(struct e1000_adapter *adapter)  	}  rx_ring_summary: -	/* -	 * receive dump -	 */ +	/* receive dump */  	pr_info("\nRX Desc ring dump\n");  	/* Legacy Receive Descriptor Format @@ -3502,7 +3489,6 @@ exit:   * e1000_tx_timeout - Respond to a Tx Hang   * @netdev: network interface device structure   **/ -  static void e1000_tx_timeout(struct net_device *netdev)  {  	struct e1000_adapter *adapter = netdev_priv(netdev); @@ -3530,7 +3516,6 @@ static void e1000_reset_task(struct work_struct *work)   * Returns the address of the device statistics structure.   * The statistics are actually updated from the watchdog.   **/ -  static struct net_device_stats *e1000_get_stats(struct net_device *netdev)  {  	/* only return the current stats */ @@ -3544,7 +3529,6 @@ static struct net_device_stats *e1000_get_stats(struct net_device *netdev)   *   * Returns 0 on success, negative on failure   **/ -  static int e1000_change_mtu(struct net_device *netdev, int new_mtu)  {  	struct e1000_adapter *adapter = netdev_priv(netdev); @@ -3581,8 +3565,9 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu)  	 * means we reserve 2 more, this pushes us to allocate from the next  	 * larger slab size.  	 * i.e. RXBUFFER_2048 --> size-4096 slab -	 *  however with the new *_jumbo_rx* routines, jumbo receives will use -	 *  fragmented skbs */ +	 * however with the new *_jumbo_rx* routines, jumbo receives will use +	 * fragmented skbs +	 */  	if (max_frame <= E1000_RXBUFFER_2048)  		adapter->rx_buffer_len = E1000_RXBUFFER_2048; @@ -3617,7 +3602,6 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu)   * e1000_update_stats - Update the board statistics counters   * @adapter: board private structure   **/ -  void e1000_update_stats(struct e1000_adapter *adapter)  {  	struct net_device *netdev = adapter->netdev; @@ -3628,8 +3612,7 @@ void e1000_update_stats(struct e1000_adapter *adapter)  #define PHY_IDLE_ERROR_COUNT_MASK 0x00FF -	/* -	 * Prevent stats update while adapter is being reset, or if the pci +	/* Prevent stats update while adapter is being reset, or if the pci  	 * connection is down.  	 */  	if (adapter->link_speed == 0) @@ -3719,7 +3702,8 @@ void e1000_update_stats(struct e1000_adapter *adapter)  	/* Rx Errors */  	/* RLEC on some newer hardware can be incorrect so build -	* our own version based on RUC and ROC */ +	 * our own version based on RUC and ROC +	 */  	netdev->stats.rx_errors = adapter->stats.rxerrc +  		adapter->stats.crcerrs + adapter->stats.algnerrc +  		adapter->stats.ruc + adapter->stats.roc + @@ -3773,7 +3757,6 @@ void e1000_update_stats(struct e1000_adapter *adapter)   * @irq: interrupt number   * @data: pointer to a network interface device structure   **/ -  static irqreturn_t e1000_intr(int irq, void *data)  {  	struct net_device *netdev = data; @@ -3784,8 +3767,7 @@ static irqreturn_t e1000_intr(int irq, void *data)  	if (unlikely((!icr)))  		return IRQ_NONE;  /* Not our interrupt */ -	/* -	 * we might have caused the interrupt, but the above +	/* we might have caused the interrupt, but the above  	 * read cleared it, and just in case the driver is  	 * down there is nothing to do so return handled  	 */ @@ -3811,7 +3793,8 @@ static irqreturn_t e1000_intr(int irq, void *data)  		__napi_schedule(&adapter->napi);  	} else {  		/* this really should not happen! if it does it is basically a -		 * bug, but not a hard error, so enable ints and continue */ +		 * bug, but not a hard error, so enable ints and continue +		 */  		if (!test_bit(__E1000_DOWN, &adapter->flags))  			e1000_irq_enable(adapter);  	} @@ -3825,7 +3808,8 @@ static irqreturn_t e1000_intr(int irq, void *data)   **/  static int e1000_clean(struct napi_struct *napi, int budget)  { -	struct e1000_adapter *adapter = container_of(napi, struct e1000_adapter, napi); +	struct e1000_adapter *adapter = container_of(napi, struct e1000_adapter, +						     napi);  	int tx_clean_complete = 0, work_done = 0;  	tx_clean_complete = e1000_clean_tx_irq(adapter, &adapter->tx_ring[0]); @@ -3916,11 +3900,12 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter,  	if (adapter->detect_tx_hung) {  		/* Detect a transmit hang in hardware, this serializes the -		 * check with the clearing of time_stamp and movement of i */ +		 * check with the clearing of time_stamp and movement of i +		 */  		adapter->detect_tx_hung = false;  		if (tx_ring->buffer_info[eop].time_stamp &&  		    time_after(jiffies, tx_ring->buffer_info[eop].time_stamp + -		               (adapter->tx_timeout_factor * HZ)) && +			       (adapter->tx_timeout_factor * HZ)) &&  		    !(er32(STATUS) & E1000_STATUS_TXOFF)) {  			/* detected Tx unit hang */ @@ -3963,7 +3948,6 @@ static bool e1000_clean_tx_irq(struct e1000_adapter *adapter,   * @csum:        receive descriptor csum field   * @sk_buff:     socket buffer with received data   **/ -  static void e1000_rx_checksum(struct e1000_adapter *adapter, u32 status_err,  			      u32 csum, struct sk_buff *skb)  { @@ -3999,7 +3983,7 @@ static void e1000_rx_checksum(struct e1000_adapter *adapter, u32 status_err,   * e1000_consume_page - helper function   **/  static void e1000_consume_page(struct e1000_buffer *bi, struct sk_buff *skb, -                               u16 length) +			       u16 length)  {  	bi->page = NULL;  	skb->len += length; @@ -4095,11 +4079,11 @@ static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter,  			if (TBI_ACCEPT(hw, status, rx_desc->errors, length,  				       last_byte)) {  				spin_lock_irqsave(&adapter->stats_lock, -				                  irq_flags); +						  irq_flags);  				e1000_tbi_adjust_stats(hw, &adapter->stats,  						       length, mapped);  				spin_unlock_irqrestore(&adapter->stats_lock, -				                       irq_flags); +						       irq_flags);  				length--;  			} else {  				if (netdev->features & NETIF_F_RXALL) @@ -4107,7 +4091,8 @@ static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter,  				/* recycle both page and skb */  				buffer_info->skb = skb;  				/* an error means any chain goes out the window -				 * too */ +				 * too +				 */  				if (rx_ring->rx_skb_top)  					dev_kfree_skb(rx_ring->rx_skb_top);  				rx_ring->rx_skb_top = NULL; @@ -4123,7 +4108,7 @@ process_skb:  				/* this is the beginning of a chain */  				rxtop = skb;  				skb_fill_page_desc(rxtop, 0, buffer_info->page, -				                   0, length); +						   0, length);  			} else {  				/* this is the middle of a chain */  				skb_fill_page_desc(rxtop, @@ -4141,38 +4126,42 @@ process_skb:  				    skb_shinfo(rxtop)->nr_frags,  				    buffer_info->page, 0, length);  				/* re-use the current skb, we only consumed the -				 * page */ +				 * page +				 */  				buffer_info->skb = skb;  				skb = rxtop;  				rxtop = NULL;  				e1000_consume_page(buffer_info, skb, length);  			} else {  				/* no chain, got EOP, this buf is the packet -				 * copybreak to save the put_page/alloc_page */ +				 * copybreak to save the put_page/alloc_page +				 */  				if (length <= copybreak &&  				    skb_tailroom(skb) >= length) {  					u8 *vaddr;  					vaddr = kmap_atomic(buffer_info->page); -					memcpy(skb_tail_pointer(skb), vaddr, length); +					memcpy(skb_tail_pointer(skb), vaddr, +					       length);  					kunmap_atomic(vaddr);  					/* re-use the page, so don't erase -					 * buffer_info->page */ +					 * buffer_info->page +					 */  					skb_put(skb, length);  				} else {  					skb_fill_page_desc(skb, 0, -					                   buffer_info->page, 0, -				                           length); +							   buffer_info->page, 0, +							   length);  					e1000_consume_page(buffer_info, skb, -					                   length); +							   length);  				}  			}  		}  		/* Receive Checksum Offload XXX recompute due to CRC strip? */  		e1000_rx_checksum(adapter, -		                  (u32)(status) | -		                  ((u32)(rx_desc->errors) << 24), -		                  le16_to_cpu(rx_desc->csum), skb); +				  (u32)(status) | +				  ((u32)(rx_desc->errors) << 24), +				  le16_to_cpu(rx_desc->csum), skb);  		total_rx_bytes += (skb->len - 4); /* don't count FCS */  		if (likely(!(netdev->features & NETIF_F_RXFCS))) @@ -4214,8 +4203,7 @@ next_desc:  	return cleaned;  } -/* - * this should improve performance for small packets with large amounts +/* this should improve performance for small packets with large amounts   * of reassembly being done in the stack   */  static void e1000_check_copybreak(struct net_device *netdev, @@ -4319,9 +4307,9 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter,  				       last_byte)) {  				spin_lock_irqsave(&adapter->stats_lock, flags);  				e1000_tbi_adjust_stats(hw, &adapter->stats, -				                       length, skb->data); +						       length, skb->data);  				spin_unlock_irqrestore(&adapter->stats_lock, -				                       flags); +						       flags);  				length--;  			} else {  				if (netdev->features & NETIF_F_RXALL) @@ -4386,10 +4374,9 @@ next_desc:   * @rx_ring: pointer to receive ring structure   * @cleaned_count: number of buffers to allocate this pass   **/ -  static void  e1000_alloc_jumbo_rx_buffers(struct e1000_adapter *adapter, -                             struct e1000_rx_ring *rx_ring, int cleaned_count) +			     struct e1000_rx_ring *rx_ring, int cleaned_count)  {  	struct net_device *netdev = adapter->netdev;  	struct pci_dev *pdev = adapter->pdev; @@ -4430,7 +4417,7 @@ check_page:  		if (!buffer_info->dma) {  			buffer_info->dma = dma_map_page(&pdev->dev, -			                                buffer_info->page, 0, +							buffer_info->page, 0,  							buffer_info->length,  							DMA_FROM_DEVICE);  			if (dma_mapping_error(&pdev->dev, buffer_info->dma)) { @@ -4460,7 +4447,8 @@ check_page:  		/* Force memory writes to complete before letting h/w  		 * know there are new descriptors to fetch.  (Only  		 * applicable for weak-ordered memory model archs, -		 * such as IA-64). */ +		 * such as IA-64). +		 */  		wmb();  		writel(i, adapter->hw.hw_addr + rx_ring->rdt);  	} @@ -4470,7 +4458,6 @@ check_page:   * e1000_alloc_rx_buffers - Replace used receive buffers; legacy & extended   * @adapter: address of board private structure   **/ -  static void e1000_alloc_rx_buffers(struct e1000_adapter *adapter,  				   struct e1000_rx_ring *rx_ring,  				   int cleaned_count) @@ -4541,8 +4528,7 @@ map_skb:  			break; /* while !buffer_info->skb */  		} -		/* -		 * XXX if it was allocated cleanly it will never map to a +		/* XXX if it was allocated cleanly it will never map to a  		 * boundary crossing  		 */ @@ -4580,7 +4566,8 @@ map_skb:  		/* Force memory writes to complete before letting h/w  		 * know there are new descriptors to fetch.  (Only  		 * applicable for weak-ordered memory model archs, -		 * such as IA-64). */ +		 * such as IA-64). +		 */  		wmb();  		writel(i, hw->hw_addr + rx_ring->rdt);  	} @@ -4590,7 +4577,6 @@ map_skb:   * e1000_smartspeed - Workaround for SmartSpeed on 82541 and 82547 controllers.   * @adapter:   **/ -  static void e1000_smartspeed(struct e1000_adapter *adapter)  {  	struct e1000_hw *hw = &adapter->hw; @@ -4603,7 +4589,8 @@ static void e1000_smartspeed(struct e1000_adapter *adapter)  	if (adapter->smartspeed == 0) {  		/* If Master/Slave config fault is asserted twice, -		 * we assume back-to-back */ +		 * we assume back-to-back +		 */  		e1000_read_phy_reg(hw, PHY_1000T_STATUS, &phy_status);  		if (!(phy_status & SR_1000T_MS_CONFIG_FAULT)) return;  		e1000_read_phy_reg(hw, PHY_1000T_STATUS, &phy_status); @@ -4616,7 +4603,7 @@ static void e1000_smartspeed(struct e1000_adapter *adapter)  			adapter->smartspeed++;  			if (!e1000_phy_setup_autoneg(hw) &&  			   !e1000_read_phy_reg(hw, PHY_CTRL, -				   	       &phy_ctrl)) { +					       &phy_ctrl)) {  				phy_ctrl |= (MII_CR_AUTO_NEG_EN |  					     MII_CR_RESTART_AUTO_NEG);  				e1000_write_phy_reg(hw, PHY_CTRL, @@ -4647,7 +4634,6 @@ static void e1000_smartspeed(struct e1000_adapter *adapter)   * @ifreq:   * @cmd:   **/ -  static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)  {  	switch (cmd) { @@ -4666,7 +4652,6 @@ static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)   * @ifreq:   * @cmd:   **/ -  static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,  			   int cmd)  { @@ -4928,7 +4913,8 @@ int e1000_set_spd_dplx(struct e1000_adapter *adapter, u32 spd, u8 dplx)  	hw->autoneg = 0;  	/* Make sure dplx is at most 1 bit and lsb of speed is not set -	 * for the switch() below to work */ +	 * for the switch() below to work +	 */  	if ((spd & 1) || (dplx & ~1))  		goto err_inval; @@ -5131,8 +5117,7 @@ static void e1000_shutdown(struct pci_dev *pdev)  }  #ifdef CONFIG_NET_POLL_CONTROLLER -/* - * Polling 'interrupt' - used by things like netconsole to send skbs +/* Polling 'interrupt' - used by things like netconsole to send skbs   * without having to re-enable interrupts. It's not called while   * the interrupt routine is executing.   */ diff --git a/drivers/net/ethernet/intel/e1000/e1000_param.c b/drivers/net/ethernet/intel/e1000/e1000_param.c index 750fc0194f3..c9cde352b1c 100644 --- a/drivers/net/ethernet/intel/e1000/e1000_param.c +++ b/drivers/net/ethernet/intel/e1000/e1000_param.c @@ -267,7 +267,6 @@ static void e1000_check_copper_options(struct e1000_adapter *adapter);   * value exists, a default value is used.  The final value is stored   * in a variable in the adapter structure.   **/ -  void e1000_check_options(struct e1000_adapter *adapter)  {  	struct e1000_option opt; @@ -319,7 +318,8 @@ void e1000_check_options(struct e1000_adapter *adapter)  			.def  = E1000_DEFAULT_RXD,  			.arg  = { .r = {  				.min = E1000_MIN_RXD, -				.max = mac_type < e1000_82544 ? E1000_MAX_RXD : E1000_MAX_82544_RXD +				.max = mac_type < e1000_82544 ? E1000_MAX_RXD : +				       E1000_MAX_82544_RXD  			}}  		}; @@ -408,7 +408,7 @@ void e1000_check_options(struct e1000_adapter *adapter)  		if (num_TxAbsIntDelay > bd) {  			adapter->tx_abs_int_delay = TxAbsIntDelay[bd];  			e1000_validate_option(&adapter->tx_abs_int_delay, &opt, -			                      adapter); +					      adapter);  		} else {  			adapter->tx_abs_int_delay = opt.def;  		} @@ -426,7 +426,7 @@ void e1000_check_options(struct e1000_adapter *adapter)  		if (num_RxIntDelay > bd) {  			adapter->rx_int_delay = RxIntDelay[bd];  			e1000_validate_option(&adapter->rx_int_delay, &opt, -			                      adapter); +					      adapter);  		} else {  			adapter->rx_int_delay = opt.def;  		} @@ -444,7 +444,7 @@ void e1000_check_options(struct e1000_adapter *adapter)  		if (num_RxAbsIntDelay > bd) {  			adapter->rx_abs_int_delay = RxAbsIntDelay[bd];  			e1000_validate_option(&adapter->rx_abs_int_delay, &opt, -			                      adapter); +					      adapter);  		} else {  			adapter->rx_abs_int_delay = opt.def;  		} @@ -479,16 +479,17 @@ void e1000_check_options(struct e1000_adapter *adapter)  				break;  			case 4:  				e_dev_info("%s set to simplified " -				           "(2000-8000) ints mode\n", opt.name); +					   "(2000-8000) ints mode\n", opt.name);  				adapter->itr_setting = adapter->itr;  				break;  			default:  				e1000_validate_option(&adapter->itr, &opt, -				        adapter); +						      adapter);  				/* save the setting, because the dynamic bits  				 * change itr.  				 * clear the lower two bits because they are -				 * used as control */ +				 * used as control +				 */  				adapter->itr_setting = adapter->itr & ~3;  				break;  			} @@ -533,7 +534,6 @@ void e1000_check_options(struct e1000_adapter *adapter)   *   * Handles speed and duplex options on fiber adapters   **/ -  static void e1000_check_fiber_options(struct e1000_adapter *adapter)  {  	int bd = adapter->bd_number; @@ -559,7 +559,6 @@ static void e1000_check_fiber_options(struct e1000_adapter *adapter)   *   * Handles speed and duplex options on copper adapters   **/ -  static void e1000_check_copper_options(struct e1000_adapter *adapter)  {  	struct e1000_option opt; @@ -681,22 +680,22 @@ static void e1000_check_copper_options(struct e1000_adapter *adapter)  		e_dev_info("Using Autonegotiation at Half Duplex only\n");  		adapter->hw.autoneg = adapter->fc_autoneg = 1;  		adapter->hw.autoneg_advertised = ADVERTISE_10_HALF | -		                                 ADVERTISE_100_HALF; +						 ADVERTISE_100_HALF;  		break;  	case FULL_DUPLEX:  		e_dev_info("Full Duplex specified without Speed\n");  		e_dev_info("Using Autonegotiation at Full Duplex only\n");  		adapter->hw.autoneg = adapter->fc_autoneg = 1;  		adapter->hw.autoneg_advertised = ADVERTISE_10_FULL | -		                                 ADVERTISE_100_FULL | -		                                 ADVERTISE_1000_FULL; +						 ADVERTISE_100_FULL | +						 ADVERTISE_1000_FULL;  		break;  	case SPEED_10:  		e_dev_info("10 Mbps Speed specified without Duplex\n");  		e_dev_info("Using Autonegotiation at 10 Mbps only\n");  		adapter->hw.autoneg = adapter->fc_autoneg = 1;  		adapter->hw.autoneg_advertised = ADVERTISE_10_HALF | -		                                 ADVERTISE_10_FULL; +						 ADVERTISE_10_FULL;  		break;  	case SPEED_10 + HALF_DUPLEX:  		e_dev_info("Forcing to 10 Mbps Half Duplex\n"); @@ -715,7 +714,7 @@ static void e1000_check_copper_options(struct e1000_adapter *adapter)  		e_dev_info("Using Autonegotiation at 100 Mbps only\n");  		adapter->hw.autoneg = adapter->fc_autoneg = 1;  		adapter->hw.autoneg_advertised = ADVERTISE_100_HALF | -		                                 ADVERTISE_100_FULL; +						 ADVERTISE_100_FULL;  		break;  	case SPEED_100 + HALF_DUPLEX:  		e_dev_info("Forcing to 100 Mbps Half Duplex\n"); diff --git a/drivers/net/ethernet/intel/e1000e/80003es2lan.c b/drivers/net/ethernet/intel/e1000e/80003es2lan.c index e73c2c35599..e0991388664 100644 --- a/drivers/net/ethernet/intel/e1000e/80003es2lan.c +++ b/drivers/net/ethernet/intel/e1000e/80003es2lan.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel PRO/1000 Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -32,69 +32,6 @@  #include "e1000.h" -#define E1000_KMRNCTRLSTA_OFFSET_FIFO_CTRL	 0x00 -#define E1000_KMRNCTRLSTA_OFFSET_INB_CTRL	 0x02 -#define E1000_KMRNCTRLSTA_OFFSET_HD_CTRL	 0x10 -#define E1000_KMRNCTRLSTA_OFFSET_MAC2PHY_OPMODE	 0x1F - -#define E1000_KMRNCTRLSTA_FIFO_CTRL_RX_BYPASS	 0x0008 -#define E1000_KMRNCTRLSTA_FIFO_CTRL_TX_BYPASS	 0x0800 -#define E1000_KMRNCTRLSTA_INB_CTRL_DIS_PADDING	 0x0010 - -#define E1000_KMRNCTRLSTA_HD_CTRL_10_100_DEFAULT 0x0004 -#define E1000_KMRNCTRLSTA_HD_CTRL_1000_DEFAULT	 0x0000 -#define E1000_KMRNCTRLSTA_OPMODE_E_IDLE		 0x2000 - -#define E1000_KMRNCTRLSTA_OPMODE_MASK		 0x000C -#define E1000_KMRNCTRLSTA_OPMODE_INBAND_MDIO	 0x0004 - -#define E1000_TCTL_EXT_GCEX_MASK 0x000FFC00 /* Gigabit Carry Extend Padding */ -#define DEFAULT_TCTL_EXT_GCEX_80003ES2LAN	 0x00010000 - -#define DEFAULT_TIPG_IPGT_1000_80003ES2LAN	 0x8 -#define DEFAULT_TIPG_IPGT_10_100_80003ES2LAN	 0x9 - -/* GG82563 PHY Specific Status Register (Page 0, Register 16 */ -#define GG82563_PSCR_POLARITY_REVERSAL_DISABLE	 0x0002 /* 1=Reversal Disab. */ -#define GG82563_PSCR_CROSSOVER_MODE_MASK	 0x0060 -#define GG82563_PSCR_CROSSOVER_MODE_MDI		 0x0000 /* 00=Manual MDI */ -#define GG82563_PSCR_CROSSOVER_MODE_MDIX	 0x0020 /* 01=Manual MDIX */ -#define GG82563_PSCR_CROSSOVER_MODE_AUTO	 0x0060 /* 11=Auto crossover */ - -/* PHY Specific Control Register 2 (Page 0, Register 26) */ -#define GG82563_PSCR2_REVERSE_AUTO_NEG		 0x2000 -						/* 1=Reverse Auto-Negotiation */ - -/* MAC Specific Control Register (Page 2, Register 21) */ -/* Tx clock speed for Link Down and 1000BASE-T for the following speeds */ -#define GG82563_MSCR_TX_CLK_MASK		 0x0007 -#define GG82563_MSCR_TX_CLK_10MBPS_2_5		 0x0004 -#define GG82563_MSCR_TX_CLK_100MBPS_25		 0x0005 -#define GG82563_MSCR_TX_CLK_1000MBPS_25		 0x0007 - -#define GG82563_MSCR_ASSERT_CRS_ON_TX		 0x0010 /* 1=Assert */ - -/* DSP Distance Register (Page 5, Register 26) */ -#define GG82563_DSPD_CABLE_LENGTH		 0x0007 /* 0 = <50M -							   1 = 50-80M -							   2 = 80-110M -							   3 = 110-140M -							   4 = >140M -							*/ - -/* Kumeran Mode Control Register (Page 193, Register 16) */ -#define GG82563_KMCR_PASS_FALSE_CARRIER		 0x0800 - -/* Max number of times Kumeran read/write should be validated */ -#define GG82563_MAX_KMRN_RETRY  0x5 - -/* Power Management Control Register (Page 193, Register 20) */ -#define GG82563_PMCR_ENABLE_ELECTRICAL_IDLE	 0x0001 -					   /* 1=Enable SERDES Electrical Idle */ - -/* In-Band Control Register (Page 194, Register 18) */ -#define GG82563_ICR_DIS_PADDING			 0x0010 /* Disable Padding */ -  /* A table for the GG82563 cable length where the range is defined   * with a lower bound at "index" and the upper bound at   * "index + 5". @@ -111,11 +48,10 @@ static void e1000_initialize_hw_bits_80003es2lan(struct e1000_hw *hw);  static void e1000_clear_hw_cntrs_80003es2lan(struct e1000_hw *hw);  static s32 e1000_cfg_kmrn_1000_80003es2lan(struct e1000_hw *hw);  static s32 e1000_cfg_kmrn_10_100_80003es2lan(struct e1000_hw *hw, u16 duplex); -static s32 e1000_cfg_on_link_up_80003es2lan(struct e1000_hw *hw); -static s32  e1000_read_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset, -                                            u16 *data); -static s32  e1000_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset, -                                             u16 data); +static s32 e1000_read_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset, +					   u16 *data); +static s32 e1000_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset, +					    u16 data);  static void e1000_power_down_phy_copper_80003es2lan(struct e1000_hw *hw);  /** @@ -625,16 +561,16 @@ static s32 e1000_phy_force_speed_duplex_80003es2lan(struct e1000_hw *hw)  	e_dbg("GG82563 PSCR: %X\n", phy_data); -	ret_val = e1e_rphy(hw, PHY_CONTROL, &phy_data); +	ret_val = e1e_rphy(hw, MII_BMCR, &phy_data);  	if (ret_val)  		return ret_val;  	e1000e_phy_force_speed_duplex_setup(hw, &phy_data);  	/* Reset the phy to commit changes. */ -	phy_data |= MII_CR_RESET; +	phy_data |= BMCR_RESET; -	ret_val = e1e_wphy(hw, PHY_CONTROL, phy_data); +	ret_val = e1e_wphy(hw, MII_BMCR, phy_data);  	if (ret_val)  		return ret_val; @@ -696,7 +632,7 @@ static s32 e1000_phy_force_speed_duplex_80003es2lan(struct e1000_hw *hw)  static s32 e1000_get_cable_length_80003es2lan(struct e1000_hw *hw)  {  	struct e1000_phy_info *phy = &hw->phy; -	s32 ret_val = 0; +	s32 ret_val;  	u16 phy_data, index;  	ret_val = e1e_rphy(hw, GG82563_PHY_DSP_DISTANCE, &phy_data); @@ -774,6 +710,9 @@ static s32 e1000_reset_hw_80003es2lan(struct e1000_hw *hw)  	ctrl = er32(CTRL);  	ret_val = e1000_acquire_phy_80003es2lan(hw); +	if (ret_val) +		return ret_val; +  	e_dbg("Issuing a global reset to MAC\n");  	ew32(CTRL, ctrl | E1000_CTRL_RST);  	e1000_release_phy_80003es2lan(hw); @@ -833,6 +772,8 @@ static s32 e1000_init_hw_80003es2lan(struct e1000_hw *hw)  	/* Setup link and flow control */  	ret_val = mac->ops.setup_link(hw); +	if (ret_val) +		return ret_val;  	/* Disable IBIST slave mode (far-end loopback) */  	e1000_read_kmrn_reg_80003es2lan(hw, E1000_KMRNCTRLSTA_INBAND_PARAM, @@ -1006,7 +947,7 @@ static s32 e1000_copper_link_setup_gg82563_80003es2lan(struct e1000_hw *hw)  		return ret_val;  	/* SW Reset the PHY so all changes take effect */ -	ret_val = e1000e_commit_phy(hw); +	ret_val = hw->phy.ops.commit(hw);  	if (ret_val) {  		e_dbg("Error Resetting the PHY\n");  		return ret_val; @@ -1272,7 +1213,7 @@ static s32 e1000_read_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,  					   u16 *data)  {  	u32 kmrnctrlsta; -	s32 ret_val = 0; +	s32 ret_val;  	ret_val = e1000_acquire_mac_csr_80003es2lan(hw);  	if (ret_val) @@ -1307,7 +1248,7 @@ static s32 e1000_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,  					    u16 data)  {  	u32 kmrnctrlsta; -	s32 ret_val = 0; +	s32 ret_val;  	ret_val = e1000_acquire_mac_csr_80003es2lan(hw);  	if (ret_val) @@ -1331,7 +1272,7 @@ static s32 e1000_write_kmrn_reg_80003es2lan(struct e1000_hw *hw, u32 offset,   **/  static s32 e1000_read_mac_addr_80003es2lan(struct e1000_hw *hw)  { -	s32 ret_val = 0; +	s32 ret_val;  	/* If there's an alternate MAC address place it in RAR0  	 * so that it will override the Si installed default perm @@ -1434,18 +1375,18 @@ static const struct e1000_phy_operations es2_phy_ops = {  	.acquire		= e1000_acquire_phy_80003es2lan,  	.check_polarity		= e1000_check_polarity_m88,  	.check_reset_block	= e1000e_check_reset_block_generic, -	.commit		 	= e1000e_phy_sw_reset, -	.force_speed_duplex 	= e1000_phy_force_speed_duplex_80003es2lan, -	.get_cfg_done       	= e1000_get_cfg_done_80003es2lan, -	.get_cable_length   	= e1000_get_cable_length_80003es2lan, -	.get_info       	= e1000e_get_phy_info_m88, -	.read_reg       	= e1000_read_phy_reg_gg82563_80003es2lan, +	.commit			= e1000e_phy_sw_reset, +	.force_speed_duplex	= e1000_phy_force_speed_duplex_80003es2lan, +	.get_cfg_done		= e1000_get_cfg_done_80003es2lan, +	.get_cable_length	= e1000_get_cable_length_80003es2lan, +	.get_info		= e1000e_get_phy_info_m88, +	.read_reg		= e1000_read_phy_reg_gg82563_80003es2lan,  	.release		= e1000_release_phy_80003es2lan, -	.reset		  	= e1000e_phy_hw_reset_generic, -	.set_d0_lplu_state  	= NULL, -	.set_d3_lplu_state  	= e1000e_set_d3_lplu_state, -	.write_reg      	= e1000_write_phy_reg_gg82563_80003es2lan, -	.cfg_on_link_up      	= e1000_cfg_on_link_up_80003es2lan, +	.reset			= e1000e_phy_hw_reset_generic, +	.set_d0_lplu_state	= NULL, +	.set_d3_lplu_state	= e1000e_set_d3_lplu_state, +	.write_reg		= e1000_write_phy_reg_gg82563_80003es2lan, +	.cfg_on_link_up		= e1000_cfg_on_link_up_80003es2lan,  };  static const struct e1000_nvm_operations es2_nvm_ops = { diff --git a/drivers/net/ethernet/intel/e1000e/80003es2lan.h b/drivers/net/ethernet/intel/e1000e/80003es2lan.h new file mode 100644 index 00000000000..90d363b2d28 --- /dev/null +++ b/drivers/net/ethernet/intel/e1000e/80003es2lan.h @@ -0,0 +1,95 @@ +/******************************************************************************* + +  Intel PRO/1000 Linux driver +  Copyright(c) 1999 - 2013 Intel Corporation. + +  This program is free software; you can redistribute it and/or modify it +  under the terms and conditions of the GNU General Public License, +  version 2, as published by the Free Software Foundation. + +  This program is distributed in the hope it will be useful, but WITHOUT +  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for +  more details. + +  You should have received a copy of the GNU General Public License along with +  this program; if not, write to the Free Software Foundation, Inc., +  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + +  The full GNU General Public License is included in this distribution in +  the file called "COPYING". + +  Contact Information: +  Linux NICS <linux.nics@intel.com> +  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> +  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + +*******************************************************************************/ + +#ifndef _E1000E_80003ES2LAN_H_ +#define _E1000E_80003ES2LAN_H_ + +#define E1000_KMRNCTRLSTA_OFFSET_FIFO_CTRL	0x00 +#define E1000_KMRNCTRLSTA_OFFSET_INB_CTRL	0x02 +#define E1000_KMRNCTRLSTA_OFFSET_HD_CTRL	0x10 +#define E1000_KMRNCTRLSTA_OFFSET_MAC2PHY_OPMODE	0x1F + +#define E1000_KMRNCTRLSTA_FIFO_CTRL_RX_BYPASS	0x0008 +#define E1000_KMRNCTRLSTA_FIFO_CTRL_TX_BYPASS	0x0800 +#define E1000_KMRNCTRLSTA_INB_CTRL_DIS_PADDING	0x0010 + +#define E1000_KMRNCTRLSTA_HD_CTRL_10_100_DEFAULT 0x0004 +#define E1000_KMRNCTRLSTA_HD_CTRL_1000_DEFAULT	0x0000 +#define E1000_KMRNCTRLSTA_OPMODE_E_IDLE		0x2000 + +#define E1000_KMRNCTRLSTA_OPMODE_MASK		0x000C +#define E1000_KMRNCTRLSTA_OPMODE_INBAND_MDIO	0x0004 + +#define E1000_TCTL_EXT_GCEX_MASK 0x000FFC00	/* Gig Carry Extend Padding */ +#define DEFAULT_TCTL_EXT_GCEX_80003ES2LAN	0x00010000 + +#define DEFAULT_TIPG_IPGT_1000_80003ES2LAN	0x8 +#define DEFAULT_TIPG_IPGT_10_100_80003ES2LAN	0x9 + +/* GG82563 PHY Specific Status Register (Page 0, Register 16 */ +#define GG82563_PSCR_POLARITY_REVERSAL_DISABLE	0x0002	/* 1=Reversal Dis */ +#define GG82563_PSCR_CROSSOVER_MODE_MASK	0x0060 +#define GG82563_PSCR_CROSSOVER_MODE_MDI		0x0000	/* 00=Manual MDI */ +#define GG82563_PSCR_CROSSOVER_MODE_MDIX	0x0020	/* 01=Manual MDIX */ +#define GG82563_PSCR_CROSSOVER_MODE_AUTO	0x0060	/* 11=Auto crossover */ + +/* PHY Specific Control Register 2 (Page 0, Register 26) */ +#define GG82563_PSCR2_REVERSE_AUTO_NEG		0x2000	/* 1=Reverse Auto-Neg */ + +/* MAC Specific Control Register (Page 2, Register 21) */ +/* Tx clock speed for Link Down and 1000BASE-T for the following speeds */ +#define GG82563_MSCR_TX_CLK_MASK		0x0007 +#define GG82563_MSCR_TX_CLK_10MBPS_2_5		0x0004 +#define GG82563_MSCR_TX_CLK_100MBPS_25		0x0005 +#define GG82563_MSCR_TX_CLK_1000MBPS_25		0x0007 + +#define GG82563_MSCR_ASSERT_CRS_ON_TX		0x0010	/* 1=Assert */ + +/* DSP Distance Register (Page 5, Register 26) + * 0 = <50M + * 1 = 50-80M + * 2 = 80-100M + * 3 = 110-140M + * 4 = >140M + */ +#define GG82563_DSPD_CABLE_LENGTH		0x0007 + +/* Kumeran Mode Control Register (Page 193, Register 16) */ +#define GG82563_KMCR_PASS_FALSE_CARRIER		0x0800 + +/* Max number of times Kumeran read/write should be validated */ +#define GG82563_MAX_KMRN_RETRY			0x5 + +/* Power Management Control Register (Page 193, Register 20) */ +/* 1=Enable SERDES Electrical Idle */ +#define GG82563_PMCR_ENABLE_ELECTRICAL_IDLE	0x0001 + +/* In-Band Control Register (Page 194, Register 18) */ +#define GG82563_ICR_DIS_PADDING			0x0010	/* Disable Padding */ + +#endif diff --git a/drivers/net/ethernet/intel/e1000e/82571.c b/drivers/net/ethernet/intel/e1000e/82571.c index c77d010d5c5..2faffbde179 100644 --- a/drivers/net/ethernet/intel/e1000e/82571.c +++ b/drivers/net/ethernet/intel/e1000e/82571.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel PRO/1000 Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -44,21 +44,6 @@  #include "e1000.h" -#define ID_LED_RESERVED_F746 0xF746 -#define ID_LED_DEFAULT_82573 ((ID_LED_DEF1_DEF2 << 12) | \ -			      (ID_LED_OFF1_ON2  <<  8) | \ -			      (ID_LED_DEF1_DEF2 <<  4) | \ -			      (ID_LED_DEF1_DEF2)) - -#define E1000_GCR_L1_ACT_WITHOUT_L0S_RX 0x08000000 -#define AN_RETRY_COUNT          5 /* Autoneg Retry Count value */ -#define E1000_BASE1000T_STATUS          10 -#define E1000_IDLE_ERROR_COUNT_MASK     0xFF -#define E1000_RECEIVE_ERROR_COUNTER     21 -#define E1000_RECEIVE_ERROR_MAX         0xFFFF - -#define E1000_NVM_INIT_CTRL2_MNGM 0x6000 /* Manageability Operation Mode mask */ -  static s32 e1000_get_phy_id_82571(struct e1000_hw *hw);  static s32 e1000_setup_copper_link_82571(struct e1000_hw *hw);  static s32 e1000_setup_fiber_serdes_link_82571(struct e1000_hw *hw); @@ -67,9 +52,7 @@ static s32 e1000_write_nvm_eewr_82571(struct e1000_hw *hw, u16 offset,  				      u16 words, u16 *data);  static s32 e1000_fix_nvm_checksum_82571(struct e1000_hw *hw);  static void e1000_initialize_hw_bits_82571(struct e1000_hw *hw); -static s32 e1000_setup_link_82571(struct e1000_hw *hw);  static void e1000_clear_hw_cntrs_82571(struct e1000_hw *hw); -static void e1000_clear_vfta_82571(struct e1000_hw *hw);  static bool e1000_check_mng_mode_82574(struct e1000_hw *hw);  static s32 e1000_led_on_82574(struct e1000_hw *hw);  static void e1000_put_hw_semaphore_82571(struct e1000_hw *hw); @@ -449,13 +432,13 @@ static s32 e1000_get_phy_id_82571(struct e1000_hw *hw)  		break;  	case e1000_82574:  	case e1000_82583: -		ret_val = e1e_rphy(hw, PHY_ID1, &phy_id); +		ret_val = e1e_rphy(hw, MII_PHYSID1, &phy_id);  		if (ret_val)  			return ret_val;  		phy->id = (u32)(phy_id << 16);  		udelay(20); -		ret_val = e1e_rphy(hw, PHY_ID2, &phy_id); +		ret_val = e1e_rphy(hw, MII_PHYSID2, &phy_id);  		if (ret_val)  			return ret_val; @@ -556,16 +539,14 @@ static s32 e1000_get_hw_semaphore_82573(struct e1000_hw *hw)  	s32 i = 0;  	extcnf_ctrl = er32(EXTCNF_CTRL); -	extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;  	do { +		extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP;  		ew32(EXTCNF_CTRL, extcnf_ctrl);  		extcnf_ctrl = er32(EXTCNF_CTRL);  		if (extcnf_ctrl & E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP)  			break; -		extcnf_ctrl |= E1000_EXTCNF_CTRL_MDIO_SW_OWNERSHIP; -  		usleep_range(2000, 4000);  		i++;  	} while (i < MDIO_OWNERSHIP_TIMEOUT); @@ -937,6 +918,8 @@ static s32 e1000_set_d0_lplu_state_82571(struct e1000_hw *hw, bool active)  		/* When LPLU is enabled, we should disable SmartSpeed */  		ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data); +		if (ret_val) +			return ret_val;  		data &= ~IGP01E1000_PSCFR_SMART_SPEED;  		ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data);  		if (ret_val) @@ -1329,9 +1312,10 @@ static void e1000_clear_vfta_82571(struct e1000_hw *hw)  			 */  			vfta_offset = (hw->mng_cookie.vlan_id >>  				       E1000_VFTA_ENTRY_SHIFT) & -				      E1000_VFTA_ENTRY_MASK; -			vfta_bit_in_reg = 1 << (hw->mng_cookie.vlan_id & -					       E1000_VFTA_ENTRY_BIT_SHIFT_MASK); +			    E1000_VFTA_ENTRY_MASK; +			vfta_bit_in_reg = +			    1 << (hw->mng_cookie.vlan_id & +				  E1000_VFTA_ENTRY_BIT_SHIFT_MASK);  		}  		break;  	default: @@ -1399,7 +1383,7 @@ bool e1000_check_phy_82574(struct e1000_hw *hw)  {  	u16 status_1kbt = 0;  	u16 receive_errors = 0; -	s32 ret_val = 0; +	s32 ret_val;  	/* Read PHY Receive Error counter first, if its is max - all F's then  	 * read the Base1000T status register If both are max then PHY is hung. @@ -1544,13 +1528,12 @@ static s32 e1000_check_for_serdes_link_82571(struct e1000_hw *hw)  	ctrl = er32(CTRL);  	status = er32(STATUS); -	rxcw = er32(RXCW); +	er32(RXCW);  	/* SYNCH bit and IV bit are sticky */  	udelay(10);  	rxcw = er32(RXCW);  	if ((rxcw & E1000_RXCW_SYNCH) && !(rxcw & E1000_RXCW_IV)) { -  		/* Receiver is synchronized with no invalid bits.  */  		switch (mac->serdes_link_state) {  		case e1000_serdes_link_autoneg_complete: @@ -1799,6 +1782,8 @@ static s32 e1000_fix_nvm_checksum_82571(struct e1000_hw *hw)  			if (ret_val)  				return ret_val;  			ret_val = e1000e_update_nvm_checksum(hw); +			if (ret_val) +				return ret_val;  		}  	} @@ -1812,7 +1797,7 @@ static s32 e1000_fix_nvm_checksum_82571(struct e1000_hw *hw)  static s32 e1000_read_mac_addr_82571(struct e1000_hw *hw)  {  	if (hw->mac.type == e1000_82571) { -		s32 ret_val = 0; +		s32 ret_val;  		/* If there's an alternate MAC address place it in RAR0  		 * so that it will override the Si installed default perm @@ -1931,7 +1916,7 @@ static const struct e1000_phy_operations e82_phy_ops_igp = {  	.set_d0_lplu_state	= e1000_set_d0_lplu_state_82571,  	.set_d3_lplu_state	= e1000e_set_d3_lplu_state,  	.write_reg		= e1000e_write_phy_reg_igp, -	.cfg_on_link_up      	= NULL, +	.cfg_on_link_up		= NULL,  };  static const struct e1000_phy_operations e82_phy_ops_m88 = { @@ -1940,7 +1925,7 @@ static const struct e1000_phy_operations e82_phy_ops_m88 = {  	.check_reset_block	= e1000e_check_reset_block_generic,  	.commit			= e1000e_phy_sw_reset,  	.force_speed_duplex	= e1000e_phy_force_speed_duplex_m88, -	.get_cfg_done		= e1000e_get_cfg_done, +	.get_cfg_done		= e1000e_get_cfg_done_generic,  	.get_cable_length	= e1000e_get_cable_length_m88,  	.get_info		= e1000e_get_phy_info_m88,  	.read_reg		= e1000e_read_phy_reg_m88, @@ -1949,7 +1934,7 @@ static const struct e1000_phy_operations e82_phy_ops_m88 = {  	.set_d0_lplu_state	= e1000_set_d0_lplu_state_82571,  	.set_d3_lplu_state	= e1000e_set_d3_lplu_state,  	.write_reg		= e1000e_write_phy_reg_m88, -	.cfg_on_link_up      	= NULL, +	.cfg_on_link_up		= NULL,  };  static const struct e1000_phy_operations e82_phy_ops_bm = { @@ -1958,7 +1943,7 @@ static const struct e1000_phy_operations e82_phy_ops_bm = {  	.check_reset_block	= e1000e_check_reset_block_generic,  	.commit			= e1000e_phy_sw_reset,  	.force_speed_duplex	= e1000e_phy_force_speed_duplex_m88, -	.get_cfg_done		= e1000e_get_cfg_done, +	.get_cfg_done		= e1000e_get_cfg_done_generic,  	.get_cable_length	= e1000e_get_cable_length_m88,  	.get_info		= e1000e_get_phy_info_m88,  	.read_reg		= e1000e_read_phy_reg_bm2, @@ -1967,7 +1952,7 @@ static const struct e1000_phy_operations e82_phy_ops_bm = {  	.set_d0_lplu_state	= e1000_set_d0_lplu_state_82571,  	.set_d3_lplu_state	= e1000e_set_d3_lplu_state,  	.write_reg		= e1000e_write_phy_reg_bm2, -	.cfg_on_link_up      	= NULL, +	.cfg_on_link_up		= NULL,  };  static const struct e1000_nvm_operations e82571_nvm_ops = { @@ -2044,6 +2029,7 @@ const struct e1000_info e1000_82574_info = {  				  | FLAG_HAS_MSIX  				  | FLAG_HAS_JUMBO_FRAMES  				  | FLAG_HAS_WOL +				  | FLAG_HAS_HW_TIMESTAMP  				  | FLAG_APME_IN_CTRL3  				  | FLAG_HAS_SMART_POWER_DOWN  				  | FLAG_HAS_AMT @@ -2065,6 +2051,7 @@ const struct e1000_info e1000_82583_info = {  	.mac			= e1000_82583,  	.flags			= FLAG_HAS_HW_VLAN_FILTER  				  | FLAG_HAS_WOL +				  | FLAG_HAS_HW_TIMESTAMP  				  | FLAG_APME_IN_CTRL3  				  | FLAG_HAS_SMART_POWER_DOWN  				  | FLAG_HAS_AMT diff --git a/drivers/net/ethernet/intel/e1000e/82571.h b/drivers/net/ethernet/intel/e1000e/82571.h new file mode 100644 index 00000000000..85cb1a3b7cd --- /dev/null +++ b/drivers/net/ethernet/intel/e1000e/82571.h @@ -0,0 +1,58 @@ +/******************************************************************************* + +  Intel PRO/1000 Linux driver +  Copyright(c) 1999 - 2013 Intel Corporation. + +  This program is free software; you can redistribute it and/or modify it +  under the terms and conditions of the GNU General Public License, +  version 2, as published by the Free Software Foundation. + +  This program is distributed in the hope it will be useful, but WITHOUT +  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for +  more details. + +  You should have received a copy of the GNU General Public License along with +  this program; if not, write to the Free Software Foundation, Inc., +  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + +  The full GNU General Public License is included in this distribution in +  the file called "COPYING". + +  Contact Information: +  Linux NICS <linux.nics@intel.com> +  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> +  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + +*******************************************************************************/ + +#ifndef _E1000E_82571_H_ +#define _E1000E_82571_H_ + +#define ID_LED_RESERVED_F746	0xF746 +#define ID_LED_DEFAULT_82573	((ID_LED_DEF1_DEF2 << 12) | \ +				 (ID_LED_OFF1_ON2  <<  8) | \ +				 (ID_LED_DEF1_DEF2 <<  4) | \ +				 (ID_LED_DEF1_DEF2)) + +#define E1000_GCR_L1_ACT_WITHOUT_L0S_RX	0x08000000 +#define AN_RETRY_COUNT		5	/* Autoneg Retry Count value */ + +/* Intr Throttling - RW */ +#define E1000_EITR_82574(_n)	(0x000E8 + (0x4 * (_n))) + +#define E1000_EIAC_82574	0x000DC	/* Ext. Interrupt Auto Clear - RW */ +#define E1000_EIAC_MASK_82574	0x01F00000 + +/* Manageability Operation Mode mask */ +#define E1000_NVM_INIT_CTRL2_MNGM	0x6000 + +#define E1000_BASE1000T_STATUS		10 +#define E1000_IDLE_ERROR_COUNT_MASK	0xFF +#define E1000_RECEIVE_ERROR_COUNTER	21 +#define E1000_RECEIVE_ERROR_MAX		0xFFFF +bool e1000_check_phy_82574(struct e1000_hw *hw); +bool e1000e_get_laa_state_82571(struct e1000_hw *hw); +void e1000e_set_laa_state_82571(struct e1000_hw *hw, bool state); + +#endif diff --git a/drivers/net/ethernet/intel/e1000e/Makefile b/drivers/net/ethernet/intel/e1000e/Makefile index 591b7132450..c2dcfcc1085 100644 --- a/drivers/net/ethernet/intel/e1000e/Makefile +++ b/drivers/net/ethernet/intel/e1000e/Makefile @@ -1,7 +1,7 @@  ################################################################################  #  # Intel PRO/1000 Linux driver -# Copyright(c) 1999 - 2012 Intel Corporation. +# Copyright(c) 1999 - 2013 Intel Corporation.  #  # This program is free software; you can redistribute it and/or modify it  # under the terms and conditions of the GNU General Public License, @@ -34,5 +34,5 @@ obj-$(CONFIG_E1000E) += e1000e.o  e1000e-objs := 82571.o ich8lan.o 80003es2lan.o \  	       mac.o manage.o nvm.o phy.o \ -	       param.o ethtool.o netdev.o +	       param.o ethtool.o netdev.o ptp.o diff --git a/drivers/net/ethernet/intel/e1000e/defines.h b/drivers/net/ethernet/intel/e1000e/defines.h index 02a12b69555..fc3a4fe1ac7 100644 --- a/drivers/net/ethernet/intel/e1000e/defines.h +++ b/drivers/net/ethernet/intel/e1000e/defines.h @@ -1,7 +1,7 @@  /*******************************************************************************    Intel PRO/1000 Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -29,25 +29,6 @@  #ifndef _E1000_DEFINES_H_  #define _E1000_DEFINES_H_ -#define E1000_TXD_POPTS_IXSM 0x01       /* Insert IP checksum */ -#define E1000_TXD_POPTS_TXSM 0x02       /* Insert TCP/UDP checksum */ -#define E1000_TXD_CMD_EOP    0x01000000 /* End of Packet */ -#define E1000_TXD_CMD_IFCS   0x02000000 /* Insert FCS (Ethernet CRC) */ -#define E1000_TXD_CMD_IC     0x04000000 /* Insert Checksum */ -#define E1000_TXD_CMD_RS     0x08000000 /* Report Status */ -#define E1000_TXD_CMD_RPS    0x10000000 /* Report Packet Sent */ -#define E1000_TXD_CMD_DEXT   0x20000000 /* Descriptor extension (0 = legacy) */ -#define E1000_TXD_CMD_VLE    0x40000000 /* Add VLAN tag */ -#define E1000_TXD_CMD_IDE    0x80000000 /* Enable Tidv register */ -#define E1000_TXD_STAT_DD    0x00000001 /* Descriptor Done */ -#define E1000_TXD_STAT_EC    0x00000002 /* Excess Collisions */ -#define E1000_TXD_STAT_LC    0x00000004 /* Late Collisions */ -#define E1000_TXD_STAT_TU    0x00000008 /* Transmit underrun */ -#define E1000_TXD_CMD_TCP    0x01000000 /* TCP packet */ -#define E1000_TXD_CMD_IP     0x02000000 /* IP packet */ -#define E1000_TXD_CMD_TSE    0x04000000 /* TCP Seg enable */ -#define E1000_TXD_STAT_TC    0x00000004 /* Tx Underrun */ -  /* Number of Transmit and Receive Descriptors must be a multiple of 8 */  #define REQ_TX_DESCRIPTOR_MULTIPLE  8  #define REQ_RX_DESCRIPTOR_MULTIPLE  8 @@ -86,7 +67,6 @@  #define E1000_CTRL_EXT_EIAME          0x01000000  #define E1000_CTRL_EXT_DRV_LOAD       0x10000000 /* Driver loaded bit for FW */  #define E1000_CTRL_EXT_IAME           0x08000000 /* Interrupt acknowledge Auto-mask */ -#define E1000_CTRL_EXT_INT_TIMER_CLR  0x20000000 /* Clear Interrupt timers after IMS clear */  #define E1000_CTRL_EXT_PBA_CLR        0x80000000 /* PBA Clear */  #define E1000_CTRL_EXT_LSECCK         0x00001000  #define E1000_CTRL_EXT_PHYPDEN        0x00100000 @@ -107,6 +87,7 @@  #define E1000_RXD_ERR_RXE       0x80    /* Rx Data Error */  #define E1000_RXD_SPC_VLAN_MASK 0x0FFF  /* VLAN ID is in lower 12 bits */ +#define E1000_RXDEXT_STATERR_TST   0x00000100	/* Time Stamp taken */  #define E1000_RXDEXT_STATERR_CE    0x01000000  #define E1000_RXDEXT_STATERR_SE    0x02000000  #define E1000_RXDEXT_STATERR_SEQ   0x04000000 @@ -115,19 +96,19 @@  /* mask to determine if packets should be dropped due to frame errors */  #define E1000_RXD_ERR_FRAME_ERR_MASK ( \ -    E1000_RXD_ERR_CE  |                \ -    E1000_RXD_ERR_SE  |                \ -    E1000_RXD_ERR_SEQ |                \ -    E1000_RXD_ERR_CXE |                \ -    E1000_RXD_ERR_RXE) +	E1000_RXD_ERR_CE  |		\ +	E1000_RXD_ERR_SE  |		\ +	E1000_RXD_ERR_SEQ |		\ +	E1000_RXD_ERR_CXE |		\ +	E1000_RXD_ERR_RXE)  /* Same mask, but for extended and packet split descriptors */  #define E1000_RXDEXT_ERR_FRAME_ERR_MASK ( \ -    E1000_RXDEXT_STATERR_CE  |            \ -    E1000_RXDEXT_STATERR_SE  |            \ -    E1000_RXDEXT_STATERR_SEQ |            \ -    E1000_RXDEXT_STATERR_CXE |            \ -    E1000_RXDEXT_STATERR_RXE) +	E1000_RXDEXT_STATERR_CE  |	\ +	E1000_RXDEXT_STATERR_SE  |	\ +	E1000_RXDEXT_STATERR_SEQ |	\ +	E1000_RXDEXT_STATERR_CXE |	\ +	E1000_RXDEXT_STATERR_RXE)  #define E1000_MRQC_RSS_FIELD_MASK              0xFFFF0000  #define E1000_MRQC_RSS_FIELD_IPV4_TCP          0x00010000 @@ -232,6 +213,7 @@  #define E1000_CTRL_FRCDPX   0x00001000  /* Force Duplex */  #define E1000_CTRL_LANPHYPC_OVERRIDE 0x00010000 /* SW control of LANPHYPC */  #define E1000_CTRL_LANPHYPC_VALUE    0x00020000 /* SW value of LANPHYPC */ +#define E1000_CTRL_MEHE     0x00080000  /* Memory Error Handling Enable */  #define E1000_CTRL_SWDPIN0  0x00040000  /* SWDPIN 0 value */  #define E1000_CTRL_SWDPIN1  0x00080000  /* SWDPIN 1 value */  #define E1000_CTRL_SWDPIO0  0x00400000  /* SWDPIN 0 Input or output */ @@ -241,9 +223,9 @@  #define E1000_CTRL_VME      0x40000000  /* IEEE VLAN mode enable */  #define E1000_CTRL_PHY_RST  0x80000000  /* PHY Reset */ -/* Bit definitions for the Management Data IO (MDIO) and Management Data - * Clock (MDC) pins in the Device Control Register. - */ +#define E1000_PCS_LCTL_FORCE_FCTRL	0x80 + +#define E1000_PCS_LSTS_AN_COMPLETE	0x10000  /* Device Status */  #define E1000_STATUS_FD         0x00000001      /* Full duplex.0=half,1=full */ @@ -259,8 +241,6 @@  #define E1000_STATUS_PHYRA      0x00000400      /* PHY Reset Asserted */  #define E1000_STATUS_GIO_MASTER_ENABLE 0x00080000 /* Status of Master requests. */ -/* Constants used to interpret the masked PCI-X bus speed. */ -  #define HALF_DUPLEX 1  #define FULL_DUPLEX 2 @@ -273,14 +253,15 @@  #define ADVERTISE_1000_FULL               0x0020  /* 1000/H is not supported, nor spec-compliant. */ -#define E1000_ALL_SPEED_DUPLEX ( ADVERTISE_10_HALF |   ADVERTISE_10_FULL | \ -				ADVERTISE_100_HALF |  ADVERTISE_100_FULL | \ -						     ADVERTISE_1000_FULL) -#define E1000_ALL_NOT_GIG      ( ADVERTISE_10_HALF |   ADVERTISE_10_FULL | \ -				ADVERTISE_100_HALF |  ADVERTISE_100_FULL) -#define E1000_ALL_100_SPEED    (ADVERTISE_100_HALF |  ADVERTISE_100_FULL) -#define E1000_ALL_10_SPEED      (ADVERTISE_10_HALF |   ADVERTISE_10_FULL) -#define E1000_ALL_HALF_DUPLEX   (ADVERTISE_10_HALF |  ADVERTISE_100_HALF) +#define E1000_ALL_SPEED_DUPLEX	( \ +	ADVERTISE_10_HALF | ADVERTISE_10_FULL | ADVERTISE_100_HALF | \ +	ADVERTISE_100_FULL | ADVERTISE_1000_FULL) +#define E1000_ALL_NOT_GIG	( \ +	ADVERTISE_10_HALF | ADVERTISE_10_FULL | ADVERTISE_100_HALF | \ +	ADVERTISE_100_FULL) +#define E1000_ALL_100_SPEED	(ADVERTISE_100_HALF | ADVERTISE_100_FULL) +#define E1000_ALL_10_SPEED	(ADVERTISE_10_HALF | ADVERTISE_10_FULL) +#define E1000_ALL_HALF_DUPLEX	(ADVERTISE_10_HALF | ADVERTISE_100_HALF)  #define AUTONEG_ADVERTISE_SPEED_DEFAULT   E1000_ALL_SPEED_DUPLEX @@ -318,6 +299,7 @@  #define E1000_TXD_CMD_IP     0x02000000 /* IP packet */  #define E1000_TXD_CMD_TSE    0x04000000 /* TCP Seg enable */  #define E1000_TXD_STAT_TC    0x00000004 /* Tx Underrun */ +#define E1000_TXD_EXTCMD_TSTAMP	0x00000010 /* IEEE1588 Timestamp packet */  /* Transmit Control */  #define E1000_TCTL_EN     0x00000002    /* enable Tx */ @@ -327,8 +309,6 @@  #define E1000_TCTL_RTLC   0x01000000    /* Re-transmit on late collision */  #define E1000_TCTL_MULR   0x10000000    /* Multiple request support */ -/* Transmit Arbitration Count */ -  /* SerDes Control */  #define E1000_SCTL_DISABLE_SERDES_LOOPBACK 0x0400 @@ -383,12 +363,23 @@  #define E1000_KABGTXD_BGSQLBIAS           0x00050000 +/* Low Power IDLE Control */ +#define E1000_LPIC_LPIET_SHIFT		24	/* Low Power Idle Entry Time */ +  /* PBA constants */  #define E1000_PBA_8K  0x0008    /* 8KB */  #define E1000_PBA_16K 0x0010    /* 16KB */ +#define E1000_PBA_RXA_MASK	0xFFFF +  #define E1000_PBS_16K E1000_PBA_16K +/* Uncorrectable/correctable ECC Error counts and enable bits */ +#define E1000_PBECCSTS_CORR_ERR_CNT_MASK	0x000000FF +#define E1000_PBECCSTS_UNCORR_ERR_CNT_MASK	0x0000FF00 +#define E1000_PBECCSTS_UNCORR_ERR_CNT_SHIFT	8 +#define E1000_PBECCSTS_ECC_ENABLE		0x00010000 +  #define IFS_MAX       80  #define IFS_MIN       40  #define IFS_RATIO     4 @@ -408,6 +399,7 @@  #define E1000_ICR_RXSEQ         0x00000008 /* Rx sequence error */  #define E1000_ICR_RXDMT0        0x00000010 /* Rx desc min. threshold (0) */  #define E1000_ICR_RXT0          0x00000080 /* Rx timer intr (ring 0) */ +#define E1000_ICR_ECCER         0x00400000 /* Uncorrectable ECC Error */  #define E1000_ICR_INT_ASSERTED  0x80000000 /* If this bit asserted, the driver should claim the interrupt */  #define E1000_ICR_RXQ0          0x00100000 /* Rx Queue 0 Interrupt */  #define E1000_ICR_RXQ1          0x00200000 /* Rx Queue 1 Interrupt */ @@ -431,11 +423,11 @@   *   o LSC    = Link Status Change   */  #define IMS_ENABLE_MASK ( \ -    E1000_IMS_RXT0   |    \ -    E1000_IMS_TXDW   |    \ -    E1000_IMS_RXDMT0 |    \ -    E1000_IMS_RXSEQ  |    \ -    E1000_IMS_LSC) +	E1000_IMS_RXT0   |    \ +	E1000_IMS_TXDW   |    \ +	E1000_IMS_RXDMT0 |    \ +	E1000_IMS_RXSEQ  |    \ +	E1000_IMS_LSC)  /* Interrupt Mask Set */  #define E1000_IMS_TXDW      E1000_ICR_TXDW      /* Transmit desc written back */ @@ -443,6 +435,7 @@  #define E1000_IMS_RXSEQ     E1000_ICR_RXSEQ     /* Rx sequence error */  #define E1000_IMS_RXDMT0    E1000_ICR_RXDMT0    /* Rx desc min. threshold */  #define E1000_IMS_RXT0      E1000_ICR_RXT0      /* Rx timer intr */ +#define E1000_IMS_ECCER     E1000_ICR_ECCER     /* Uncorrectable ECC Error */  #define E1000_IMS_RXQ0      E1000_ICR_RXQ0      /* Rx Queue 0 Interrupt */  #define E1000_IMS_RXQ1      E1000_ICR_RXQ1      /* Rx Queue 1 Interrupt */  #define E1000_IMS_TXQ0      E1000_ICR_TXQ0      /* Tx Queue 0 Interrupt */ @@ -533,6 +526,28 @@  #define E1000_RXCW_C          0x20000000        /* Receive config */  #define E1000_RXCW_SYNCH      0x40000000        /* Receive config synch */ +#define E1000_TSYNCTXCTL_VALID		0x00000001 /* Tx timestamp valid */ +#define E1000_TSYNCTXCTL_ENABLED	0x00000010 /* enable Tx timestamping */ + +#define E1000_TSYNCRXCTL_VALID		0x00000001 /* Rx timestamp valid */ +#define E1000_TSYNCRXCTL_TYPE_MASK	0x0000000E /* Rx type mask */ +#define E1000_TSYNCRXCTL_TYPE_L2_V2	0x00 +#define E1000_TSYNCRXCTL_TYPE_L4_V1	0x02 +#define E1000_TSYNCRXCTL_TYPE_L2_L4_V2	0x04 +#define E1000_TSYNCRXCTL_TYPE_ALL	0x08 +#define E1000_TSYNCRXCTL_TYPE_EVENT_V2	0x0A +#define E1000_TSYNCRXCTL_ENABLED	0x00000010 /* enable Rx timestamping */ +#define E1000_TSYNCRXCTL_SYSCFI		0x00000020 /* Sys clock frequency */ + +#define E1000_RXMTRL_PTP_V1_SYNC_MESSAGE	0x00000000 +#define E1000_RXMTRL_PTP_V1_DELAY_REQ_MESSAGE	0x00010000 + +#define E1000_RXMTRL_PTP_V2_SYNC_MESSAGE	0x00000000 +#define E1000_RXMTRL_PTP_V2_DELAY_REQ_MESSAGE	0x01000000 + +#define E1000_TIMINCA_INCPERIOD_SHIFT	24 +#define E1000_TIMINCA_INCVALUE_MASK	0x00FFFFFF +  /* PCI Express Control */  #define E1000_GCR_RXD_NO_SNOOP          0x00000001  #define E1000_GCR_RXDSCW_NO_SNOOP       0x00000002 @@ -548,66 +563,6 @@  			   E1000_GCR_TXDSCW_NO_SNOOP      | \  			   E1000_GCR_TXDSCR_NO_SNOOP) -/* PHY Control Register */ -#define MII_CR_FULL_DUPLEX      0x0100  /* FDX =1, half duplex =0 */ -#define MII_CR_RESTART_AUTO_NEG 0x0200  /* Restart auto negotiation */ -#define MII_CR_POWER_DOWN       0x0800  /* Power down */ -#define MII_CR_AUTO_NEG_EN      0x1000  /* Auto Neg Enable */ -#define MII_CR_LOOPBACK         0x4000  /* 0 = normal, 1 = loopback */ -#define MII_CR_RESET            0x8000  /* 0 = normal, 1 = PHY reset */ -#define MII_CR_SPEED_1000       0x0040 -#define MII_CR_SPEED_100        0x2000 -#define MII_CR_SPEED_10         0x0000 - -/* PHY Status Register */ -#define MII_SR_LINK_STATUS       0x0004 /* Link Status 1 = link */ -#define MII_SR_AUTONEG_COMPLETE  0x0020 /* Auto Neg Complete */ - -/* 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_100TX_FD_CAPS  0x0100 /* LP 100TX Full Dplx Capable */ -#define NWAY_LPAR_PAUSE          0x0400 /* LP Pause operation desired */ -#define NWAY_LPAR_ASM_DIR        0x0800 /* LP Asymmetric Pause Direction bit */ - -/* Autoneg Expansion Register */ -#define NWAY_ER_LP_NWAY_CAPS     0x0001 /* LP has Auto Neg Capability */ - -/* 1000BASE-T Control Register */ -#define CR_1000T_HD_CAPS         0x0100 /* Advertise 1000T HD capability */ -#define CR_1000T_FD_CAPS         0x0200 /* Advertise 1000T FD capability  */ -					/* 0=DTE device */ -#define CR_1000T_MS_VALUE        0x0800 /* 1=Configure PHY as Master */ -					/* 0=Configure PHY as Slave */ -#define CR_1000T_MS_ENABLE       0x1000 /* 1=Master/Slave manual config value */ -					/* 0=Automatic Master/Slave config */ - -/* 1000BASE-T Status Register */ -#define SR_1000T_REMOTE_RX_STATUS 0x1000 /* Remote receiver OK */ -#define SR_1000T_LOCAL_RX_STATUS  0x2000 /* Local receiver OK */ - - -/* PHY 1000 MII Register/Bit Definitions */ -/* PHY Registers defined by IEEE */ -#define PHY_CONTROL      0x00 /* Control Register */ -#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_AUTONEG_EXP  0x06 /* Autoneg Expansion Reg */ -#define PHY_1000T_CTRL   0x09 /* 1000Base-T Control Reg */ -#define PHY_1000T_STATUS 0x0A /* 1000Base-T Status Reg */ -#define PHY_EXT_STATUS   0x0F /* Extended Status Reg */ - -#define PHY_CONTROL_LB   0x4000 /* PHY Loopback bit */ -  /* NVM Control */  #define E1000_EECD_SK        0x00000001 /* NVM Clock */  #define E1000_EECD_CS        0x00000002 /* NVM Chip Select */ @@ -639,6 +594,10 @@  /* NVM Word Offsets */  #define NVM_COMPAT                 0x0003  #define NVM_ID_LED_SETTINGS        0x0004 +#define NVM_FUTURE_INIT_WORD1      0x0019 +#define NVM_COMPAT_VALID_CSUM      0x0001 +#define NVM_FUTURE_INIT_WORD1_VALID_CSUM	0x0040 +  #define NVM_INIT_CONTROL2_REG      0x000F  #define NVM_INIT_CONTROL3_PORT_B   0x0014  #define NVM_INIT_3GIO_3            0x001A @@ -647,8 +606,6 @@  #define NVM_ALT_MAC_ADDR_PTR       0x0037  #define NVM_CHECKSUM_REG           0x003F -#define E1000_NVM_INIT_CTRL2_MNGM 0x6000 /* Manageability Operation Mode mask */ -  #define E1000_NVM_CFG_DONE_PORT_0  0x40000 /* MNG config cycle done */  #define E1000_NVM_CFG_DONE_PORT_1  0x80000 /* ...for second port */ @@ -757,9 +714,6 @@  #define M88E1000_PSCR_AUTO_X_1000T     0x0040  /* Auto crossover enabled all speeds */  #define M88E1000_PSCR_AUTO_X_MODE      0x0060 -/* 1=Enable Extended 10BASE-T distance (Lower 10BASE-T Rx Threshold) - * 0=Normal 10BASE-T Rx Threshold - */  #define M88E1000_PSCR_ASSERT_CRS_ON_TX 0x0800 /* 1=Assert CRS on Transmit */  /* M88E1000 PHY Specific Status Register */ @@ -795,11 +749,6 @@  /* BME1000 PHY Specific Control Register */  #define BME1000_PSCR_ENABLE_DOWNSHIFT   0x0800 /* 1 = enable downshift */ - -#define PHY_PAGE_SHIFT 5 -#define PHY_REG(page, reg) (((page) << PHY_PAGE_SHIFT) | \ -                           ((reg) & MAX_PHY_REG_ADDRESS)) -  /* Bits...   * 15-5: page   * 4-0: register offset @@ -846,8 +795,4 @@  /* SerDes Control */  #define E1000_GEN_POLL_TIMEOUT          640 -/* FW Semaphore */ -#define E1000_FWSM_WLOCK_MAC_MASK	0x0380 -#define E1000_FWSM_WLOCK_MAC_SHIFT	7 -  #endif /* _E1000_DEFINES_H_ */ diff --git a/drivers/net/ethernet/intel/e1000e/e1000.h b/drivers/net/ethernet/intel/e1000e/e1000.h index 6782a2eea1b..fcc758138b8 100644 --- a/drivers/net/ethernet/intel/e1000e/e1000.h +++ b/drivers/net/ethernet/intel/e1000e/e1000.h @@ -1,7 +1,7 @@  /*******************************************************************************    Intel PRO/1000 Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -41,7 +41,11 @@  #include <linux/pci-aspm.h>  #include <linux/crc32.h>  #include <linux/if_vlan.h> - +#include <linux/clocksource.h> +#include <linux/net_tstamp.h> +#include <linux/ptp_clock_kernel.h> +#include <linux/ptp_classify.h> +#include <linux/mii.h>  #include "hw.h"  struct e1000_info; @@ -75,9 +79,6 @@ struct e1000_info;  #define E1000_MIN_ITR_USECS		10 /* 100000 irq/sec */  #define E1000_MAX_ITR_USECS		10000 /* 100    irq/sec */ -/* Early Receive defines */ -#define E1000_ERT_2048			0x100 -  #define E1000_FC_PAUSE_TIME		0x0680 /* 858 usec */  /* How many Tx Descriptors do we need to call netif_wake_queue ? */ @@ -94,70 +95,6 @@ struct e1000_info;  #define DEFAULT_JUMBO			9234 -/* BM/HV Specific Registers */ -#define BM_PORT_CTRL_PAGE                 769 - -#define PHY_UPPER_SHIFT                   21 -#define BM_PHY_REG(page, reg) \ -	(((reg) & MAX_PHY_REG_ADDRESS) |\ -	 (((page) & 0xFFFF) << PHY_PAGE_SHIFT) |\ -	 (((reg) & ~MAX_PHY_REG_ADDRESS) << (PHY_UPPER_SHIFT - PHY_PAGE_SHIFT))) - -/* PHY Wakeup Registers and defines */ -#define BM_PORT_GEN_CFG PHY_REG(BM_PORT_CTRL_PAGE, 17) -#define BM_RCTL         PHY_REG(BM_WUC_PAGE, 0) -#define BM_WUC          PHY_REG(BM_WUC_PAGE, 1) -#define BM_WUFC         PHY_REG(BM_WUC_PAGE, 2) -#define BM_WUS          PHY_REG(BM_WUC_PAGE, 3) -#define BM_RAR_L(_i)    (BM_PHY_REG(BM_WUC_PAGE, 16 + ((_i) << 2))) -#define BM_RAR_M(_i)    (BM_PHY_REG(BM_WUC_PAGE, 17 + ((_i) << 2))) -#define BM_RAR_H(_i)    (BM_PHY_REG(BM_WUC_PAGE, 18 + ((_i) << 2))) -#define BM_RAR_CTRL(_i) (BM_PHY_REG(BM_WUC_PAGE, 19 + ((_i) << 2))) -#define BM_MTA(_i)      (BM_PHY_REG(BM_WUC_PAGE, 128 + ((_i) << 1))) - -#define BM_RCTL_UPE           0x0001          /* Unicast Promiscuous Mode */ -#define BM_RCTL_MPE           0x0002          /* Multicast Promiscuous Mode */ -#define BM_RCTL_MO_SHIFT      3               /* Multicast Offset Shift */ -#define BM_RCTL_MO_MASK       (3 << 3)        /* Multicast Offset Mask */ -#define BM_RCTL_BAM           0x0020          /* Broadcast Accept Mode */ -#define BM_RCTL_PMCF          0x0040          /* Pass MAC Control Frames */ -#define BM_RCTL_RFCE          0x0080          /* Rx Flow Control Enable */ - -#define HV_STATS_PAGE	778 -#define HV_SCC_UPPER	PHY_REG(HV_STATS_PAGE, 16) /* Single Collision Count */ -#define HV_SCC_LOWER	PHY_REG(HV_STATS_PAGE, 17) -#define HV_ECOL_UPPER	PHY_REG(HV_STATS_PAGE, 18) /* Excessive Coll. Count */ -#define HV_ECOL_LOWER	PHY_REG(HV_STATS_PAGE, 19) -#define HV_MCC_UPPER	PHY_REG(HV_STATS_PAGE, 20) /* Multiple Coll. Count */ -#define HV_MCC_LOWER	PHY_REG(HV_STATS_PAGE, 21) -#define HV_LATECOL_UPPER PHY_REG(HV_STATS_PAGE, 23) /* Late Collision Count */ -#define HV_LATECOL_LOWER PHY_REG(HV_STATS_PAGE, 24) -#define HV_COLC_UPPER	PHY_REG(HV_STATS_PAGE, 25) /* Collision Count */ -#define HV_COLC_LOWER	PHY_REG(HV_STATS_PAGE, 26) -#define HV_DC_UPPER	PHY_REG(HV_STATS_PAGE, 27) /* Defer Count */ -#define HV_DC_LOWER	PHY_REG(HV_STATS_PAGE, 28) -#define HV_TNCRS_UPPER	PHY_REG(HV_STATS_PAGE, 29) /* Transmit with no CRS */ -#define HV_TNCRS_LOWER	PHY_REG(HV_STATS_PAGE, 30) - -#define E1000_FCRTV_PCH     0x05F40 /* PCH Flow Control Refresh Timer Value */ - -/* BM PHY Copper Specific Status */ -#define BM_CS_STATUS                      17 -#define BM_CS_STATUS_LINK_UP              0x0400 -#define BM_CS_STATUS_RESOLVED             0x0800 -#define BM_CS_STATUS_SPEED_MASK           0xC000 -#define BM_CS_STATUS_SPEED_1000           0x8000 - -/* 82577 Mobile Phy Status Register */ -#define HV_M_STATUS                       26 -#define HV_M_STATUS_AUTONEG_COMPLETE      0x1000 -#define HV_M_STATUS_SPEED_MASK            0x0300 -#define HV_M_STATUS_SPEED_1000            0x0200 -#define HV_M_STATUS_LINK_UP               0x0040 - -#define E1000_ICH_FWSM_PCIM2PCI		0x01000000 /* ME PCIm-to-PCI active */ -#define E1000_ICH_FWSM_PCIM2PCI_COUNT	2000 -  /* Time to wait before putting the device into D3 if there's no link (in ms). */  #define LINK_TIMEOUT		100 @@ -309,6 +246,8 @@ struct e1000_adapter {  	struct napi_struct napi; +	unsigned int uncorr_errors;	/* uncorrectable ECC errors */ +	unsigned int corr_errors;	/* correctable ECC errors */  	unsigned int restart_queue;  	u32 txd_cmd; @@ -353,6 +292,7 @@ struct e1000_adapter {  	u64 gorc_old;  	u32 alloc_rx_buff_failed;  	u32 rx_dma_failed; +	u32 rx_hwtstamp_cleared;  	unsigned int rx_ps_pages;  	u16 rx_ps_bsize0; @@ -366,7 +306,7 @@ struct e1000_adapter {  	/* structs defined in e1000_hw.h */  	struct e1000_hw hw; -	spinlock_t stats64_lock; +	spinlock_t stats64_lock;	/* protects statistics counters */  	struct e1000_hw_stats stats;  	struct e1000_phy_info phy_info;  	struct e1000_phy_stats phy_stats; @@ -402,6 +342,16 @@ struct e1000_adapter {  	u16 tx_ring_count;  	u16 rx_ring_count; + +	struct hwtstamp_config hwtstamp_config; +	struct delayed_work systim_overflow_work; +	struct sk_buff *tx_hwtstamp_skb; +	struct work_struct tx_hwtstamp_work; +	spinlock_t systim_lock;	/* protects SYSTIML/H regsters */ +	struct cyclecounter cc; +	struct timecounter tc; +	struct ptp_clock *ptp_clock; +	struct ptp_clock_info ptp_clock_info;  };  struct e1000_info { @@ -416,6 +366,40 @@ struct e1000_info {  	const struct e1000_nvm_operations *nvm_ops;  }; +s32 e1000e_get_base_timinca(struct e1000_adapter *adapter, u32 *timinca); + +/* The system time is maintained by a 64-bit counter comprised of the 32-bit + * SYSTIMH and SYSTIML registers.  How the counter increments (and therefore + * its resolution) is based on the contents of the TIMINCA register - it + * increments every incperiod (bits 31:24) clock ticks by incvalue (bits 23:0). + * For the best accuracy, the incperiod should be as small as possible.  The + * incvalue is scaled by a factor as large as possible (while still fitting + * in bits 23:0) so that relatively small clock corrections can be made. + * + * As a result, a shift of INCVALUE_SHIFT_n is used to fit a value of + * INCVALUE_n into the TIMINCA register allowing 32+8+(24-INCVALUE_SHIFT_n) + * bits to count nanoseconds leaving the rest for fractional nonseconds. + */ +#define INCVALUE_96MHz		125 +#define INCVALUE_SHIFT_96MHz	17 +#define INCPERIOD_SHIFT_96MHz	2 +#define INCPERIOD_96MHz		(12 >> INCPERIOD_SHIFT_96MHz) + +#define INCVALUE_25MHz		40 +#define INCVALUE_SHIFT_25MHz	18 +#define INCPERIOD_25MHz		1 + +/* Another drawback of scaling the incvalue by a large factor is the + * 64-bit SYSTIM register overflows more quickly.  This is dealt with + * by simply reading the clock before it overflows. + * + * Clock	ns bits	Overflows after + * ~~~~~~	~~~~~~~	~~~~~~~~~~~~~~~ + * 96MHz	47-bit	2^(47-INCPERIOD_SHIFT_96MHz) / 10^9 / 3600 = 9.77 hrs + * 25MHz	46-bit	2^46 / 10^9 / 3600 = 19.55 hours + */ +#define E1000_SYSTIM_OVERFLOW_PERIOD	(HZ * 60 * 60 * 4) +  /* hardware capability, feature, and workaround flags */  #define FLAG_HAS_AMT                      (1 << 0)  #define FLAG_HAS_FLASH                    (1 << 1) @@ -431,7 +415,7 @@ struct e1000_info {  #define FLAG_HAS_SMART_POWER_DOWN         (1 << 11)  #define FLAG_IS_QUAD_PORT_A               (1 << 12)  #define FLAG_IS_QUAD_PORT                 (1 << 13) -/* reserved bit14 */ +#define FLAG_HAS_HW_TIMESTAMP             (1 << 14)  #define FLAG_APME_IN_WUC                  (1 << 15)  #define FLAG_APME_IN_CTRL3                (1 << 16)  #define FLAG_APME_CHECK_PORT_B            (1 << 17) @@ -447,7 +431,7 @@ struct e1000_info {  #define FLAG_MSI_ENABLED                  (1 << 27)  /* reserved (1 << 28) */  #define FLAG_TSO_FORCE                    (1 << 29) -#define FLAG_RX_RESTART_NOW               (1 << 30) +#define FLAG_RESTART_NOW                  (1 << 30)  #define FLAG_MSI_TEST_FAILED              (1 << 31)  #define FLAG2_CRC_STRIPPING               (1 << 0) @@ -463,6 +447,7 @@ struct e1000_info {  #define FLAG2_NO_DISABLE_RX               (1 << 10)  #define FLAG2_PCIM2PCI_ARBITER_WA         (1 << 11)  #define FLAG2_DFLT_CRC_STRIPPING          (1 << 12) +#define FLAG2_CHECK_RX_HWTSTAMP           (1 << 13)  #define E1000_RX_DESC_PS(R, i)	    \  	(&(((union e1000_rx_desc_packet_split *)((R).desc))[i])) @@ -512,8 +497,6 @@ extern void e1000e_write_itr(struct e1000_adapter *adapter, u32 itr);  extern unsigned int copybreak; -extern char *e1000e_get_hw_dev_name(struct e1000_hw *hw); -  extern const struct e1000_info e1000_82571_info;  extern const struct e1000_info e1000_82572_info;  extern const struct e1000_info e1000_82573_info; @@ -527,138 +510,8 @@ extern const struct e1000_info e1000_pch2_info;  extern const struct e1000_info e1000_pch_lpt_info;  extern const struct e1000_info e1000_es2_info; -extern s32 e1000_read_pba_string_generic(struct e1000_hw *hw, u8 *pba_num, -					 u32 pba_num_size); - -extern s32  e1000e_commit_phy(struct e1000_hw *hw); - -extern bool e1000e_enable_mng_pass_thru(struct e1000_hw *hw); - -extern bool e1000e_get_laa_state_82571(struct e1000_hw *hw); -extern void e1000e_set_laa_state_82571(struct e1000_hw *hw, bool state); - -extern void e1000e_write_protect_nvm_ich8lan(struct e1000_hw *hw); -extern void e1000e_set_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw, -						 bool state); -extern void e1000e_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw); -extern void e1000e_gig_downshift_workaround_ich8lan(struct e1000_hw *hw); -extern void e1000_suspend_workarounds_ich8lan(struct e1000_hw *hw); -extern void e1000_resume_workarounds_pchlan(struct e1000_hw *hw); -extern s32 e1000_configure_k1_ich8lan(struct e1000_hw *hw, bool k1_enable); -extern s32 e1000_lv_jumbo_workaround_ich8lan(struct e1000_hw *hw, bool enable); -extern void e1000_copy_rx_addrs_to_phy_ich8lan(struct e1000_hw *hw); - -extern s32 e1000e_check_for_copper_link(struct e1000_hw *hw); -extern s32 e1000e_check_for_fiber_link(struct e1000_hw *hw); -extern s32 e1000e_check_for_serdes_link(struct e1000_hw *hw); -extern s32 e1000e_setup_led_generic(struct e1000_hw *hw); -extern s32 e1000e_cleanup_led_generic(struct e1000_hw *hw); -extern s32 e1000e_led_on_generic(struct e1000_hw *hw); -extern s32 e1000e_led_off_generic(struct e1000_hw *hw); -extern s32 e1000e_get_bus_info_pcie(struct e1000_hw *hw); -extern void e1000_set_lan_id_multi_port_pcie(struct e1000_hw *hw); -extern void e1000_set_lan_id_single_port(struct e1000_hw *hw); -extern s32 e1000e_get_speed_and_duplex_copper(struct e1000_hw *hw, u16 *speed, u16 *duplex); -extern s32 e1000e_get_speed_and_duplex_fiber_serdes(struct e1000_hw *hw, u16 *speed, u16 *duplex); -extern s32 e1000e_disable_pcie_master(struct e1000_hw *hw); -extern s32 e1000e_get_auto_rd_done(struct e1000_hw *hw); -extern s32 e1000e_id_led_init_generic(struct e1000_hw *hw); -extern void e1000e_clear_hw_cntrs_base(struct e1000_hw *hw); -extern s32 e1000e_setup_fiber_serdes_link(struct e1000_hw *hw); -extern s32 e1000e_copper_link_setup_m88(struct e1000_hw *hw); -extern s32 e1000e_copper_link_setup_igp(struct e1000_hw *hw); -extern s32 e1000e_setup_link_generic(struct e1000_hw *hw); -extern void e1000_clear_vfta_generic(struct e1000_hw *hw); -extern void e1000e_init_rx_addrs(struct e1000_hw *hw, u16 rar_count); -extern void e1000e_update_mc_addr_list_generic(struct e1000_hw *hw, -					       u8 *mc_addr_list, -					       u32 mc_addr_count); -extern void e1000e_rar_set_generic(struct e1000_hw *hw, u8 *addr, u32 index); -extern s32 e1000e_set_fc_watermarks(struct e1000_hw *hw); -extern void e1000e_set_pcie_no_snoop(struct e1000_hw *hw, u32 no_snoop); -extern s32 e1000e_get_hw_semaphore(struct e1000_hw *hw); -extern s32 e1000e_valid_led_default(struct e1000_hw *hw, u16 *data); -extern void e1000e_config_collision_dist_generic(struct e1000_hw *hw); -extern s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw); -extern s32 e1000e_force_mac_fc(struct e1000_hw *hw); -extern s32 e1000e_blink_led_generic(struct e1000_hw *hw); -extern void e1000_write_vfta_generic(struct e1000_hw *hw, u32 offset, u32 value); -extern s32 e1000_check_alt_mac_addr_generic(struct e1000_hw *hw); -extern void e1000e_reset_adaptive(struct e1000_hw *hw); -extern void e1000e_update_adaptive(struct e1000_hw *hw); - -extern s32 e1000e_setup_copper_link(struct e1000_hw *hw); -extern s32 e1000e_get_phy_id(struct e1000_hw *hw); -extern void e1000e_put_hw_semaphore(struct e1000_hw *hw); -extern s32 e1000e_check_reset_block_generic(struct e1000_hw *hw); -extern s32 e1000e_phy_force_speed_duplex_igp(struct e1000_hw *hw); -extern s32 e1000e_get_cable_length_igp_2(struct e1000_hw *hw); -extern s32 e1000e_get_phy_info_igp(struct e1000_hw *hw); -extern s32 e1000_set_page_igp(struct e1000_hw *hw, u16 page); -extern s32 e1000e_read_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 *data); -extern s32 e1000e_read_phy_reg_igp_locked(struct e1000_hw *hw, u32 offset, -                                          u16 *data); -extern s32 e1000e_phy_hw_reset_generic(struct e1000_hw *hw); -extern s32 e1000e_set_d3_lplu_state(struct e1000_hw *hw, bool active); -extern s32 e1000e_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data); -extern s32 e1000e_write_phy_reg_igp_locked(struct e1000_hw *hw, u32 offset, -                                           u16 data); -extern s32 e1000e_phy_sw_reset(struct e1000_hw *hw); -extern s32 e1000e_phy_force_speed_duplex_m88(struct e1000_hw *hw); -extern s32 e1000e_get_cfg_done(struct e1000_hw *hw); -extern s32 e1000e_get_cable_length_m88(struct e1000_hw *hw); -extern s32 e1000e_get_phy_info_m88(struct e1000_hw *hw); -extern s32 e1000e_read_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 *data); -extern s32 e1000e_write_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 data); -extern s32 e1000e_phy_init_script_igp3(struct e1000_hw *hw); -extern enum e1000_phy_type e1000e_get_phy_type_from_id(u32 phy_id); -extern s32 e1000e_determine_phy_address(struct e1000_hw *hw); -extern s32 e1000e_write_phy_reg_bm(struct e1000_hw *hw, u32 offset, u16 data); -extern s32 e1000e_read_phy_reg_bm(struct e1000_hw *hw, u32 offset, u16 *data); -extern s32 e1000_enable_phy_wakeup_reg_access_bm(struct e1000_hw *hw, -						 u16 *phy_reg); -extern s32 e1000_disable_phy_wakeup_reg_access_bm(struct e1000_hw *hw, -						  u16 *phy_reg); -extern s32 e1000e_read_phy_reg_bm2(struct e1000_hw *hw, u32 offset, u16 *data); -extern s32 e1000e_write_phy_reg_bm2(struct e1000_hw *hw, u32 offset, u16 data); -extern void e1000e_phy_force_speed_duplex_setup(struct e1000_hw *hw, u16 *phy_ctrl); -extern s32 e1000e_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data); -extern s32 e1000e_write_kmrn_reg_locked(struct e1000_hw *hw, u32 offset, -                                        u16 data); -extern s32 e1000e_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data); -extern s32 e1000e_read_kmrn_reg_locked(struct e1000_hw *hw, u32 offset, -                                       u16 *data); -extern s32 e1000e_phy_has_link_generic(struct e1000_hw *hw, u32 iterations, -			       u32 usec_interval, bool *success); -extern s32 e1000e_phy_reset_dsp(struct e1000_hw *hw); -extern void e1000_power_up_phy_copper(struct e1000_hw *hw); -extern void e1000_power_down_phy_copper(struct e1000_hw *hw); -extern s32 e1000e_read_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 *data); -extern s32 e1000e_write_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 data); -extern s32 e1000e_check_downshift(struct e1000_hw *hw); -extern s32 e1000_read_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 *data); -extern s32 e1000_read_phy_reg_hv_locked(struct e1000_hw *hw, u32 offset, -                                        u16 *data); -extern s32 e1000_read_phy_reg_page_hv(struct e1000_hw *hw, u32 offset, -				      u16 *data); -extern s32 e1000_write_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 data); -extern s32 e1000_write_phy_reg_hv_locked(struct e1000_hw *hw, u32 offset, -                                         u16 data); -extern s32 e1000_write_phy_reg_page_hv(struct e1000_hw *hw, u32 offset, -				       u16 data); -extern s32 e1000_link_stall_workaround_hv(struct e1000_hw *hw); -extern s32 e1000_copper_link_setup_82577(struct e1000_hw *hw); -extern s32 e1000_check_polarity_82577(struct e1000_hw *hw); -extern s32 e1000_get_phy_info_82577(struct e1000_hw *hw); -extern s32 e1000_phy_force_speed_duplex_82577(struct e1000_hw *hw); -extern s32 e1000_get_cable_length_82577(struct e1000_hw *hw); - -extern s32 e1000_check_polarity_m88(struct e1000_hw *hw); -extern s32 e1000_get_phy_info_ife(struct e1000_hw *hw); -extern s32 e1000_check_polarity_ife(struct e1000_hw *hw); -extern s32 e1000_phy_force_speed_duplex_ife(struct e1000_hw *hw); -extern s32 e1000_check_polarity_igp(struct e1000_hw *hw); -extern bool e1000_check_phy_82574(struct e1000_hw *hw); +extern void e1000e_ptp_init(struct e1000_adapter *adapter); +extern void e1000e_ptp_remove(struct e1000_adapter *adapter);  static inline s32 e1000_phy_hw_reset(struct e1000_hw *hw)  { @@ -685,20 +538,7 @@ static inline s32 e1e_wphy_locked(struct e1000_hw *hw, u32 offset, u16 data)  	return hw->phy.ops.write_reg_locked(hw, offset, data);  } -static inline s32 e1000_get_cable_length(struct e1000_hw *hw) -{ -	return hw->phy.ops.get_cable_length(hw); -} - -extern s32 e1000e_acquire_nvm(struct e1000_hw *hw); -extern s32 e1000e_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data); -extern s32 e1000e_update_nvm_checksum_generic(struct e1000_hw *hw); -extern s32 e1000e_poll_eerd_eewr_done(struct e1000_hw *hw, int ee_reg); -extern s32 e1000e_read_nvm_eerd(struct e1000_hw *hw, u16 offset, u16 words, u16 *data); -extern s32 e1000e_validate_nvm_checksum_generic(struct e1000_hw *hw); -extern void e1000e_release_nvm(struct e1000_hw *hw);  extern void e1000e_reload_nvm_generic(struct e1000_hw *hw); -extern s32 e1000_read_mac_addr_generic(struct e1000_hw *hw);  static inline s32 e1000e_read_mac_addr(struct e1000_hw *hw)  { @@ -733,10 +573,6 @@ static inline s32 e1000_get_phy_info(struct e1000_hw *hw)  	return hw->phy.ops.get_info(hw);  } -extern bool e1000e_check_mng_mode_generic(struct e1000_hw *hw); -extern bool e1000e_enable_tx_pkt_filtering(struct e1000_hw *hw); -extern s32 e1000e_mng_write_dhcp_info(struct e1000_hw *hw, u8 *buffer, u16 length); -  static inline u32 __er32(struct e1000_hw *hw, unsigned long reg)  {  	return readl(hw->hw_addr + reg); diff --git a/drivers/net/ethernet/intel/e1000e/ethtool.c b/drivers/net/ethernet/intel/e1000e/ethtool.c index f95bc6ee1c2..2c1813737f6 100644 --- a/drivers/net/ethernet/intel/e1000e/ethtool.c +++ b/drivers/net/ethernet/intel/e1000e/ethtool.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel PRO/1000 Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -35,6 +35,7 @@  #include <linux/slab.h>  #include <linux/delay.h>  #include <linux/vmalloc.h> +#include <linux/mdio.h>  #include "e1000.h" @@ -98,7 +99,6 @@ static const struct e1000_stats e1000_gstrings_stats[] = {  	E1000_STAT("rx_flow_control_xoff", stats.xoffrxc),  	E1000_STAT("tx_flow_control_xon", stats.xontxc),  	E1000_STAT("tx_flow_control_xoff", stats.xofftxc), -	E1000_STAT("rx_long_byte_count", stats.gorc),  	E1000_STAT("rx_csum_offload_good", hw_csum_good),  	E1000_STAT("rx_csum_offload_errors", hw_csum_err),  	E1000_STAT("rx_header_split", rx_hdr_split), @@ -108,6 +108,9 @@ static const struct e1000_stats e1000_gstrings_stats[] = {  	E1000_STAT("dropped_smbus", stats.mgpdc),  	E1000_STAT("rx_dma_failed", rx_dma_failed),  	E1000_STAT("tx_dma_failed", tx_dma_failed), +	E1000_STAT("rx_hwtstamp_cleared", rx_hwtstamp_cleared), +	E1000_STAT("uncorr_ecc_errors", uncorr_errors), +	E1000_STAT("corr_ecc_errors", corr_errors),  };  #define E1000_GLOBAL_STATS_LEN	ARRAY_SIZE(e1000_gstrings_stats) @@ -127,7 +130,6 @@ static int e1000_get_settings(struct net_device *netdev,  	u32 speed;  	if (hw->phy.media_type == e1000_media_type_copper) { -  		ecmd->supported = (SUPPORTED_10baseT_Half |  				   SUPPORTED_10baseT_Full |  				   SUPPORTED_100baseT_Half | @@ -325,12 +327,12 @@ static int e1000_set_settings(struct net_device *netdev,  	}  	/* reset the link */ -  	if (netif_running(adapter->netdev)) {  		e1000e_down(adapter);  		e1000e_up(adapter); -	} else +	} else {  		e1000e_reset(adapter); +	}  	clear_bit(__E1000_RESETTING, &adapter->state);  	return 0; @@ -415,7 +417,7 @@ static void e1000_set_msglevel(struct net_device *netdev, u32 data)  	adapter->msg_enable = data;  } -static int e1000_get_regs_len(struct net_device *netdev) +static int e1000_get_regs_len(struct net_device __always_unused *netdev)  {  #define E1000_REGS_LEN 32 /* overestimate */  	return E1000_REGS_LEN * sizeof(u32); @@ -469,10 +471,10 @@ static void e1000_get_regs(struct net_device *netdev,  		regs_buff[22] = adapter->phy_stats.receive_errors;  		regs_buff[23] = regs_buff[13]; /* mdix mode */  	} -	regs_buff[21] = 0; /* was idle_errors */ -	e1e_rphy(hw, PHY_1000T_STATUS, &phy_data); -	regs_buff[24] = (u32)phy_data;  /* phy local receiver status */ -	regs_buff[25] = regs_buff[24];  /* phy remote receiver status */ +	regs_buff[21] = 0;	/* was idle_errors */ +	e1e_rphy(hw, MII_STAT1000, &phy_data); +	regs_buff[24] = (u32)phy_data;	/* phy local receiver status */ +	regs_buff[25] = regs_buff[24];	/* phy remote receiver status */  }  static int e1000_get_eeprom_len(struct net_device *netdev) @@ -759,8 +761,9 @@ static bool reg_pattern_test(struct e1000_adapter *adapter, u64 *data,  				      (test[pat] & write));  		val = E1000_READ_REG_ARRAY(&adapter->hw, reg, offset);  		if (val != (test[pat] & write & mask)) { -			e_err("pattern test reg %04X failed: got 0x%08X expected 0x%08X\n", -			      reg + offset, val, (test[pat] & write & mask)); +			e_err("pattern test failed (reg 0x%05X): got 0x%08X expected 0x%08X\n", +			      reg + (offset << 2), val, +			      (test[pat] & write & mask));  			*data = reg;  			return 1;  		} @@ -775,7 +778,7 @@ static bool reg_set_and_check(struct e1000_adapter *adapter, u64 *data,  	__ew32(&adapter->hw, reg, write & mask);  	val = __er32(&adapter->hw, reg);  	if ((write & mask) != (val & mask)) { -		e_err("set/check reg %04X test failed: got 0x%08X expected 0x%08X\n", +		e_err("set/check test failed (reg 0x%05X): got 0x%08X expected 0x%08X\n",  		      reg, (val & mask), (write & mask));  		*data = reg;  		return 1; @@ -883,12 +886,20 @@ static int e1000_reg_test(struct e1000_adapter *adapter, u64 *data)  		    E1000_FWSM_WLOCK_MAC_SHIFT;  	for (i = 0; i < mac->rar_entry_count; i++) { -		/* Cannot test write-protected SHRAL[n] registers */ -		if ((wlock_mac == 1) || (wlock_mac && (i > wlock_mac))) -			continue; +		if (mac->type == e1000_pch_lpt) { +			/* Cannot test write-protected SHRAL[n] registers */ +			if ((wlock_mac == 1) || (wlock_mac && (i > wlock_mac))) +				continue; -		REG_PATTERN_TEST_ARRAY(E1000_RA, ((i << 1) + 1), -				       mask, 0xFFFFFFFF); +			/* SHRAH[9] different than the others */ +			if (i == 10) +				mask |= (1 << 30); +			else +				mask &= ~(1 << 30); +		} + +		REG_PATTERN_TEST_ARRAY(E1000_RA, ((i << 1) + 1), mask, +				       0xFFFFFFFF);  	}  	for (i = 0; i < mac->mta_reg_count; i++) @@ -922,7 +933,7 @@ static int e1000_eeprom_test(struct e1000_adapter *adapter, u64 *data)  	return *data;  } -static irqreturn_t e1000_test_intr(int irq, void *data) +static irqreturn_t e1000_test_intr(int __always_unused irq, void *data)  {  	struct net_device *netdev = (struct net_device *) data;  	struct e1000_adapter *adapter = netdev_priv(netdev); @@ -1272,7 +1283,7 @@ static int e1000_integrated_phy_loopback(struct e1000_adapter *adapter)  	if (hw->phy.type == e1000_phy_ife) {  		/* force 100, set loopback */ -		e1e_wphy(hw, PHY_CONTROL, 0x6100); +		e1e_wphy(hw, MII_BMCR, 0x6100);  		/* Now set up the MAC to the same speed/duplex as the PHY. */  		ctrl_reg = er32(CTRL); @@ -1295,9 +1306,9 @@ static int e1000_integrated_phy_loopback(struct e1000_adapter *adapter)  		/* Auto-MDI/MDIX Off */  		e1e_wphy(hw, M88E1000_PHY_SPEC_CTRL, 0x0808);  		/* reset to update Auto-MDI/MDIX */ -		e1e_wphy(hw, PHY_CONTROL, 0x9140); +		e1e_wphy(hw, MII_BMCR, 0x9140);  		/* autoneg off */ -		e1e_wphy(hw, PHY_CONTROL, 0x8140); +		e1e_wphy(hw, MII_BMCR, 0x8140);  		break;  	case e1000_phy_gg82563:  		e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, 0x1CC); @@ -1309,7 +1320,7 @@ static int e1000_integrated_phy_loopback(struct e1000_adapter *adapter)  		phy_reg |= 0x006;  		e1e_wphy(hw, PHY_REG(2, 21), phy_reg);  		/* Assert SW reset for above settings to take effect */ -		e1000e_commit_phy(hw); +		hw->phy.ops.commit(hw);  		mdelay(1);  		/* Force Full Duplex */  		e1e_rphy(hw, PHY_REG(769, 16), &phy_reg); @@ -1343,7 +1354,6 @@ static int e1000_integrated_phy_loopback(struct e1000_adapter *adapter)  		e1e_rphy(hw, PHY_REG(776, 18), &phy_reg);  		e1e_wphy(hw, PHY_REG(776, 18), phy_reg | 1);  		/* Enable loopback on the PHY */ -#define I82577_PHY_LBK_CTRL          19  		e1e_wphy(hw, I82577_PHY_LBK_CTRL, 0x8001);  		break;  	default: @@ -1351,7 +1361,7 @@ static int e1000_integrated_phy_loopback(struct e1000_adapter *adapter)  	}  	/* force 1000, set loopback */ -	e1e_wphy(hw, PHY_CONTROL, 0x4140); +	e1e_wphy(hw, MII_BMCR, 0x4140);  	mdelay(250);  	/* Now set up the MAC to the same speed/duplex as the PHY. */ @@ -1393,7 +1403,7 @@ static int e1000_set_82571_fiber_loopback(struct e1000_adapter *adapter)  {  	struct e1000_hw *hw = &adapter->hw;  	u32 ctrl = er32(CTRL); -	int link = 0; +	int link;  	/* special requirements for 82571/82572 fiber adapters */ @@ -1526,11 +1536,12 @@ static void e1000_loopback_cleanup(struct e1000_adapter *adapter)  		hw->mac.autoneg = 1;  		if (hw->phy.type == e1000_phy_gg82563)  			e1e_wphy(hw, GG82563_PHY_KMRN_MODE_CTRL, 0x180); -		e1e_rphy(hw, PHY_CONTROL, &phy_reg); -		if (phy_reg & MII_CR_LOOPBACK) { -			phy_reg &= ~MII_CR_LOOPBACK; -			e1e_wphy(hw, PHY_CONTROL, phy_reg); -			e1000e_commit_phy(hw); +		e1e_rphy(hw, MII_BMCR, &phy_reg); +		if (phy_reg & BMCR_LOOPBACK) { +			phy_reg &= ~BMCR_LOOPBACK; +			e1e_wphy(hw, MII_BMCR, phy_reg); +			if (hw->phy.ops.commit) +				hw->phy.ops.commit(hw);  		}  		break;  	} @@ -1692,7 +1703,8 @@ static int e1000_link_test(struct e1000_adapter *adapter, u64 *data)  	return *data;  } -static int e1000e_get_sset_count(struct net_device *netdev, int sset) +static int e1000e_get_sset_count(struct net_device __always_unused *netdev, +				 int sset)  {  	switch (sset) {  	case ETH_SS_TEST: @@ -1955,7 +1967,7 @@ static int e1000_nway_reset(struct net_device *netdev)  }  static void e1000_get_ethtool_stats(struct net_device *netdev, -				    struct ethtool_stats *stats, +				    struct ethtool_stats __always_unused *stats,  				    u64 *data)  {  	struct e1000_adapter *adapter = netdev_priv(netdev); @@ -1984,8 +1996,8 @@ static void e1000_get_ethtool_stats(struct net_device *netdev,  	}  } -static void e1000_get_strings(struct net_device *netdev, u32 stringset, -			      u8 *data) +static void e1000_get_strings(struct net_device __always_unused *netdev, +			      u32 stringset, u8 *data)  {  	u8 *p = data;  	int i; @@ -2005,7 +2017,8 @@ static void e1000_get_strings(struct net_device *netdev, u32 stringset,  }  static int e1000_get_rxnfc(struct net_device *netdev, -			   struct ethtool_rxnfc *info, u32 *rule_locs) +			   struct ethtool_rxnfc *info, +			   u32 __always_unused *rule_locs)  {  	info->data = 0; @@ -2051,6 +2064,171 @@ static int e1000_get_rxnfc(struct net_device *netdev,  	}  } +static int e1000e_get_eee(struct net_device *netdev, struct ethtool_eee *edata) +{ +	struct e1000_adapter *adapter = netdev_priv(netdev); +	struct e1000_hw *hw = &adapter->hw; +	u16 cap_addr, adv_addr, lpa_addr, pcs_stat_addr, phy_data, lpi_ctrl; +	u32 status, ret_val; + +	if (!(adapter->flags & FLAG_IS_ICH) || +	    !(adapter->flags2 & FLAG2_HAS_EEE)) +		return -EOPNOTSUPP; + +	switch (hw->phy.type) { +	case e1000_phy_82579: +		cap_addr = I82579_EEE_CAPABILITY; +		adv_addr = I82579_EEE_ADVERTISEMENT; +		lpa_addr = I82579_EEE_LP_ABILITY; +		pcs_stat_addr = I82579_EEE_PCS_STATUS; +		break; +	case e1000_phy_i217: +		cap_addr = I217_EEE_CAPABILITY; +		adv_addr = I217_EEE_ADVERTISEMENT; +		lpa_addr = I217_EEE_LP_ABILITY; +		pcs_stat_addr = I217_EEE_PCS_STATUS; +		break; +	default: +		return -EOPNOTSUPP; +	} + +	ret_val = hw->phy.ops.acquire(hw); +	if (ret_val) +		return -EBUSY; + +	/* EEE Capability */ +	ret_val = e1000_read_emi_reg_locked(hw, cap_addr, &phy_data); +	if (ret_val) +		goto release; +	edata->supported = mmd_eee_cap_to_ethtool_sup_t(phy_data); + +	/* EEE Advertised */ +	ret_val = e1000_read_emi_reg_locked(hw, adv_addr, &phy_data); +	if (ret_val) +		goto release; +	edata->advertised = mmd_eee_adv_to_ethtool_adv_t(phy_data); + +	/* EEE Link Partner Advertised */ +	ret_val = e1000_read_emi_reg_locked(hw, lpa_addr, &phy_data); +	if (ret_val) +		goto release; +	edata->lp_advertised = mmd_eee_adv_to_ethtool_adv_t(phy_data); + +	/* EEE PCS Status */ +	ret_val = e1000_read_emi_reg_locked(hw, pcs_stat_addr, &phy_data); +	if (hw->phy.type == e1000_phy_82579) +		phy_data <<= 8; + +release: +	hw->phy.ops.release(hw); +	if (ret_val) +		return -ENODATA; + +	e1e_rphy(hw, I82579_LPI_CTRL, &lpi_ctrl); +	status = er32(STATUS); + +	/* Result of the EEE auto negotiation - there is no register that +	 * has the status of the EEE negotiation so do a best-guess based +	 * on whether both Tx and Rx LPI indications have been received or +	 * base it on the link speed, the EEE advertised speeds on both ends +	 * and the speeds on which EEE is enabled locally. +	 */ +	if (((phy_data & E1000_EEE_TX_LPI_RCVD) && +	     (phy_data & E1000_EEE_RX_LPI_RCVD)) || +	    ((status & E1000_STATUS_SPEED_100) && +	     (edata->advertised & ADVERTISED_100baseT_Full) && +	     (edata->lp_advertised & ADVERTISED_100baseT_Full) && +	     (lpi_ctrl & I82579_LPI_CTRL_100_ENABLE)) || +	    ((status & E1000_STATUS_SPEED_1000) && +	     (edata->advertised & ADVERTISED_1000baseT_Full) && +	     (edata->lp_advertised & ADVERTISED_1000baseT_Full) && +	     (lpi_ctrl & I82579_LPI_CTRL_1000_ENABLE))) +		edata->eee_active = true; + +	edata->eee_enabled = !hw->dev_spec.ich8lan.eee_disable; +	edata->tx_lpi_enabled = true; +	edata->tx_lpi_timer = er32(LPIC) >> E1000_LPIC_LPIET_SHIFT; + +	return 0; +} + +static int e1000e_set_eee(struct net_device *netdev, struct ethtool_eee *edata) +{ +	struct e1000_adapter *adapter = netdev_priv(netdev); +	struct e1000_hw *hw = &adapter->hw; +	struct ethtool_eee eee_curr; +	s32 ret_val; + +	if (!(adapter->flags & FLAG_IS_ICH) || +	    !(adapter->flags2 & FLAG2_HAS_EEE)) +		return -EOPNOTSUPP; + +	ret_val = e1000e_get_eee(netdev, &eee_curr); +	if (ret_val) +		return ret_val; + +	if (eee_curr.advertised != edata->advertised) { +		e_err("Setting EEE advertisement is not supported\n"); +		return -EINVAL; +	} + +	if (eee_curr.tx_lpi_enabled != edata->tx_lpi_enabled) { +		e_err("Setting EEE tx-lpi is not supported\n"); +		return -EINVAL; +	} + +	if (eee_curr.tx_lpi_timer != edata->tx_lpi_timer) { +		e_err("Setting EEE Tx LPI timer is not supported\n"); +		return -EINVAL; +	} + +	if (hw->dev_spec.ich8lan.eee_disable != !edata->eee_enabled) { +		hw->dev_spec.ich8lan.eee_disable = !edata->eee_enabled; + +		/* reset the link */ +		if (netif_running(netdev)) +			e1000e_reinit_locked(adapter); +		else +			e1000e_reset(adapter); +	} + +	return 0; +} + +static int e1000e_get_ts_info(struct net_device *netdev, +			      struct ethtool_ts_info *info) +{ +	struct e1000_adapter *adapter = netdev_priv(netdev); + +	ethtool_op_get_ts_info(netdev, info); + +	if (!(adapter->flags & FLAG_HAS_HW_TIMESTAMP)) +		return 0; + +	info->so_timestamping |= (SOF_TIMESTAMPING_TX_HARDWARE | +				  SOF_TIMESTAMPING_RX_HARDWARE | +				  SOF_TIMESTAMPING_RAW_HARDWARE); + +	info->tx_types = (1 << HWTSTAMP_TX_OFF) | (1 << HWTSTAMP_TX_ON); + +	info->rx_filters = ((1 << HWTSTAMP_FILTER_NONE) | +			    (1 << HWTSTAMP_FILTER_PTP_V1_L4_SYNC) | +			    (1 << HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ) | +			    (1 << HWTSTAMP_FILTER_PTP_V2_L4_SYNC) | +			    (1 << HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ) | +			    (1 << HWTSTAMP_FILTER_PTP_V2_L2_SYNC) | +			    (1 << HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ) | +			    (1 << HWTSTAMP_FILTER_PTP_V2_EVENT) | +			    (1 << HWTSTAMP_FILTER_PTP_V2_SYNC) | +			    (1 << HWTSTAMP_FILTER_PTP_V2_DELAY_REQ) | +			    (1 << HWTSTAMP_FILTER_ALL)); + +	if (adapter->ptp_clock) +		info->phc_index = ptp_clock_index(adapter->ptp_clock); + +	return 0; +} +  static const struct ethtool_ops e1000_ethtool_ops = {  	.get_settings		= e1000_get_settings,  	.set_settings		= e1000_set_settings, @@ -2078,7 +2256,9 @@ static const struct ethtool_ops e1000_ethtool_ops = {  	.get_coalesce		= e1000_get_coalesce,  	.set_coalesce		= e1000_set_coalesce,  	.get_rxnfc		= e1000_get_rxnfc, -	.get_ts_info		= ethtool_op_get_ts_info, +	.get_ts_info		= e1000e_get_ts_info, +	.get_eee		= e1000e_get_eee, +	.set_eee		= e1000e_set_eee,  };  void e1000e_set_ethtool_ops(struct net_device *netdev) diff --git a/drivers/net/ethernet/intel/e1000e/hw.h b/drivers/net/ethernet/intel/e1000e/hw.h index cf217777586..1e6b889aee8 100644 --- a/drivers/net/ethernet/intel/e1000e/hw.h +++ b/drivers/net/ethernet/intel/e1000e/hw.h @@ -1,7 +1,7 @@  /*******************************************************************************    Intel PRO/1000 Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -29,331 +29,10 @@  #ifndef _E1000_HW_H_  #define _E1000_HW_H_ -#include <linux/types.h> - -struct e1000_hw; -struct e1000_adapter; - +#include "regs.h"  #include "defines.h" -enum e1e_registers { -	E1000_CTRL     = 0x00000, /* Device Control - RW */ -	E1000_STATUS   = 0x00008, /* Device Status - RO */ -	E1000_EECD     = 0x00010, /* EEPROM/Flash Control - RW */ -	E1000_EERD     = 0x00014, /* EEPROM Read - RW */ -	E1000_CTRL_EXT = 0x00018, /* Extended Device Control - RW */ -	E1000_FLA      = 0x0001C, /* Flash Access - RW */ -	E1000_MDIC     = 0x00020, /* MDI Control - RW */ -	E1000_SCTL     = 0x00024, /* SerDes Control - RW */ -	E1000_FCAL     = 0x00028, /* Flow Control Address Low - RW */ -	E1000_FCAH     = 0x0002C, /* Flow Control Address High -RW */ -	E1000_FEXTNVM4 = 0x00024, /* Future Extended NVM 4 - RW */ -	E1000_FEXTNVM  = 0x00028, /* Future Extended NVM - RW */ -	E1000_FCT      = 0x00030, /* Flow Control Type - RW */ -	E1000_VET      = 0x00038, /* VLAN Ether Type - RW */ -	E1000_FEXTNVM3 = 0x0003C, /* Future Extended NVM 3 - RW */ -	E1000_ICR      = 0x000C0, /* Interrupt Cause Read - R/clr */ -	E1000_ITR      = 0x000C4, /* Interrupt Throttling Rate - RW */ -	E1000_ICS      = 0x000C8, /* Interrupt Cause Set - WO */ -	E1000_IMS      = 0x000D0, /* Interrupt Mask Set - RW */ -	E1000_IMC      = 0x000D8, /* Interrupt Mask Clear - WO */ -	E1000_EIAC_82574 = 0x000DC, /* Ext. Interrupt Auto Clear - RW */ -	E1000_IAM      = 0x000E0, /* Interrupt Acknowledge Auto Mask */ -	E1000_IVAR     = 0x000E4, /* Interrupt Vector Allocation - RW */ -	E1000_EITR_82574_BASE = 0x000E8, /* Interrupt Throttling - RW */ -#define E1000_EITR_82574(_n) (E1000_EITR_82574_BASE + (_n << 2)) -	E1000_RCTL     = 0x00100, /* Rx Control - RW */ -	E1000_FCTTV    = 0x00170, /* Flow Control Transmit Timer Value - RW */ -	E1000_TXCW     = 0x00178, /* Tx Configuration Word - RW */ -	E1000_RXCW     = 0x00180, /* Rx Configuration Word - RO */ -	E1000_TCTL     = 0x00400, /* Tx Control - RW */ -	E1000_TCTL_EXT = 0x00404, /* Extended Tx Control - RW */ -	E1000_TIPG     = 0x00410, /* Tx Inter-packet gap -RW */ -	E1000_AIT      = 0x00458, /* Adaptive Interframe Spacing Throttle -RW */ -	E1000_LEDCTL   = 0x00E00, /* LED Control - RW */ -	E1000_EXTCNF_CTRL  = 0x00F00, /* Extended Configuration Control */ -	E1000_EXTCNF_SIZE  = 0x00F08, /* Extended Configuration Size */ -	E1000_PHY_CTRL     = 0x00F10, /* PHY Control Register in CSR */ -#define E1000_POEMB	E1000_PHY_CTRL	/* PHY OEM Bits */ -	E1000_PBA      = 0x01000, /* Packet Buffer Allocation - RW */ -	E1000_PBS      = 0x01008, /* Packet Buffer Size */ -	E1000_EEMNGCTL = 0x01010, /* MNG EEprom Control */ -	E1000_EEWR     = 0x0102C, /* EEPROM Write Register - RW */ -	E1000_FLOP     = 0x0103C, /* FLASH Opcode Register */ -	E1000_PBA_ECC  = 0x01100, /* PBA ECC Register */ -	E1000_ERT      = 0x02008, /* Early Rx Threshold - RW */ -	E1000_FCRTL    = 0x02160, /* Flow Control Receive Threshold Low - RW */ -	E1000_FCRTH    = 0x02168, /* Flow Control Receive Threshold High - RW */ -	E1000_PSRCTL   = 0x02170, /* Packet Split Receive Control - RW */ -/* Convenience macros - * - * Note: "_n" is the queue number of the register to be written to. - * - * Example usage: - * E1000_RDBAL(current_rx_queue) - */ -	E1000_RDBAL_BASE = 0x02800, /* Rx Descriptor Base Address Low - RW */ -#define E1000_RDBAL(_n)	(E1000_RDBAL_BASE + (_n << 8)) -	E1000_RDBAH_BASE = 0x02804, /* Rx Descriptor Base Address High - RW */ -#define E1000_RDBAH(_n)	(E1000_RDBAH_BASE + (_n << 8)) -	E1000_RDLEN_BASE = 0x02808, /* Rx Descriptor Length - RW */ -#define E1000_RDLEN(_n)	(E1000_RDLEN_BASE + (_n << 8)) -	E1000_RDH_BASE = 0x02810, /* Rx Descriptor Head - RW */ -#define E1000_RDH(_n)	(E1000_RDH_BASE + (_n << 8)) -	E1000_RDT_BASE = 0x02818, /* Rx Descriptor Tail - RW */ -#define E1000_RDT(_n)	(E1000_RDT_BASE + (_n << 8)) -	E1000_RDTR     = 0x02820, /* Rx Delay Timer - RW */ -	E1000_RXDCTL_BASE = 0x02828, /* Rx Descriptor Control - RW */ -#define E1000_RXDCTL(_n)   (E1000_RXDCTL_BASE + (_n << 8)) -	E1000_RADV     = 0x0282C, /* Rx Interrupt Absolute Delay Timer - RW */ - -	E1000_KABGTXD  = 0x03004, /* AFE Band Gap Transmit Ref Data */ -	E1000_TDBAL_BASE = 0x03800, /* Tx Descriptor Base Address Low - RW */ -#define E1000_TDBAL(_n)	(E1000_TDBAL_BASE + (_n << 8)) -	E1000_TDBAH_BASE = 0x03804, /* Tx Descriptor Base Address High - RW */ -#define E1000_TDBAH(_n)	(E1000_TDBAH_BASE + (_n << 8)) -	E1000_TDLEN_BASE = 0x03808, /* Tx Descriptor Length - RW */ -#define E1000_TDLEN(_n)	(E1000_TDLEN_BASE + (_n << 8)) -	E1000_TDH_BASE = 0x03810, /* Tx Descriptor Head - RW */ -#define E1000_TDH(_n)	(E1000_TDH_BASE + (_n << 8)) -	E1000_TDT_BASE = 0x03818, /* Tx Descriptor Tail - RW */ -#define E1000_TDT(_n)	(E1000_TDT_BASE + (_n << 8)) -	E1000_TIDV     = 0x03820, /* Tx Interrupt Delay Value - RW */ -	E1000_TXDCTL_BASE = 0x03828, /* Tx Descriptor Control - RW */ -#define E1000_TXDCTL(_n)   (E1000_TXDCTL_BASE + (_n << 8)) -	E1000_TADV     = 0x0382C, /* Tx Interrupt Absolute Delay Val - RW */ -	E1000_TARC_BASE = 0x03840, /* Tx Arbitration Count (0) */ -#define E1000_TARC(_n)   (E1000_TARC_BASE + (_n << 8)) -	E1000_CRCERRS  = 0x04000, /* CRC Error Count - R/clr */ -	E1000_ALGNERRC = 0x04004, /* Alignment Error Count - R/clr */ -	E1000_SYMERRS  = 0x04008, /* Symbol Error Count - R/clr */ -	E1000_RXERRC   = 0x0400C, /* Receive Error Count - R/clr */ -	E1000_MPC      = 0x04010, /* Missed Packet Count - R/clr */ -	E1000_SCC      = 0x04014, /* Single Collision Count - R/clr */ -	E1000_ECOL     = 0x04018, /* Excessive Collision Count - R/clr */ -	E1000_MCC      = 0x0401C, /* Multiple Collision Count - R/clr */ -	E1000_LATECOL  = 0x04020, /* Late Collision Count - R/clr */ -	E1000_COLC     = 0x04028, /* Collision Count - R/clr */ -	E1000_DC       = 0x04030, /* Defer Count - R/clr */ -	E1000_TNCRS    = 0x04034, /* Tx-No CRS - R/clr */ -	E1000_SEC      = 0x04038, /* Sequence Error Count - R/clr */ -	E1000_CEXTERR  = 0x0403C, /* Carrier Extension Error Count - R/clr */ -	E1000_RLEC     = 0x04040, /* Receive Length Error Count - R/clr */ -	E1000_XONRXC   = 0x04048, /* XON Rx Count - R/clr */ -	E1000_XONTXC   = 0x0404C, /* XON Tx Count - R/clr */ -	E1000_XOFFRXC  = 0x04050, /* XOFF Rx Count - R/clr */ -	E1000_XOFFTXC  = 0x04054, /* XOFF Tx Count - R/clr */ -	E1000_FCRUC    = 0x04058, /* Flow Control Rx Unsupported Count- R/clr */ -	E1000_PRC64    = 0x0405C, /* Packets Rx (64 bytes) - R/clr */ -	E1000_PRC127   = 0x04060, /* Packets Rx (65-127 bytes) - R/clr */ -	E1000_PRC255   = 0x04064, /* Packets Rx (128-255 bytes) - R/clr */ -	E1000_PRC511   = 0x04068, /* Packets Rx (255-511 bytes) - R/clr */ -	E1000_PRC1023  = 0x0406C, /* Packets Rx (512-1023 bytes) - R/clr */ -	E1000_PRC1522  = 0x04070, /* Packets Rx (1024-1522 bytes) - R/clr */ -	E1000_GPRC     = 0x04074, /* Good Packets Rx Count - R/clr */ -	E1000_BPRC     = 0x04078, /* Broadcast Packets Rx Count - R/clr */ -	E1000_MPRC     = 0x0407C, /* Multicast Packets Rx Count - R/clr */ -	E1000_GPTC     = 0x04080, /* Good Packets Tx Count - R/clr */ -	E1000_GORCL    = 0x04088, /* Good Octets Rx Count Low - R/clr */ -	E1000_GORCH    = 0x0408C, /* Good Octets Rx Count High - R/clr */ -	E1000_GOTCL    = 0x04090, /* Good Octets Tx Count Low - R/clr */ -	E1000_GOTCH    = 0x04094, /* Good Octets Tx Count High - R/clr */ -	E1000_RNBC     = 0x040A0, /* Rx No Buffers Count - R/clr */ -	E1000_RUC      = 0x040A4, /* Rx Undersize Count - R/clr */ -	E1000_RFC      = 0x040A8, /* Rx Fragment Count - R/clr */ -	E1000_ROC      = 0x040AC, /* Rx Oversize Count - R/clr */ -	E1000_RJC      = 0x040B0, /* Rx Jabber Count - R/clr */ -	E1000_MGTPRC   = 0x040B4, /* Management Packets Rx Count - R/clr */ -	E1000_MGTPDC   = 0x040B8, /* Management Packets Dropped Count - R/clr */ -	E1000_MGTPTC   = 0x040BC, /* Management Packets Tx Count - R/clr */ -	E1000_TORL     = 0x040C0, /* Total Octets Rx Low - R/clr */ -	E1000_TORH     = 0x040C4, /* Total Octets Rx High - R/clr */ -	E1000_TOTL     = 0x040C8, /* Total Octets Tx Low - R/clr */ -	E1000_TOTH     = 0x040CC, /* Total Octets Tx High - R/clr */ -	E1000_TPR      = 0x040D0, /* Total Packets Rx - R/clr */ -	E1000_TPT      = 0x040D4, /* Total Packets Tx - R/clr */ -	E1000_PTC64    = 0x040D8, /* Packets Tx (64 bytes) - R/clr */ -	E1000_PTC127   = 0x040DC, /* Packets Tx (65-127 bytes) - R/clr */ -	E1000_PTC255   = 0x040E0, /* Packets Tx (128-255 bytes) - R/clr */ -	E1000_PTC511   = 0x040E4, /* Packets Tx (256-511 bytes) - R/clr */ -	E1000_PTC1023  = 0x040E8, /* Packets Tx (512-1023 bytes) - R/clr */ -	E1000_PTC1522  = 0x040EC, /* Packets Tx (1024-1522 Bytes) - R/clr */ -	E1000_MPTC     = 0x040F0, /* Multicast Packets Tx Count - R/clr */ -	E1000_BPTC     = 0x040F4, /* Broadcast Packets Tx Count - R/clr */ -	E1000_TSCTC    = 0x040F8, /* TCP Segmentation Context Tx - R/clr */ -	E1000_TSCTFC   = 0x040FC, /* TCP Segmentation Context Tx Fail - R/clr */ -	E1000_IAC      = 0x04100, /* Interrupt Assertion Count */ -	E1000_ICRXPTC  = 0x04104, /* Irq Cause Rx Packet Timer Expire Count */ -	E1000_ICRXATC  = 0x04108, /* Irq Cause Rx Abs Timer Expire Count */ -	E1000_ICTXPTC  = 0x0410C, /* Irq Cause Tx Packet Timer Expire Count */ -	E1000_ICTXATC  = 0x04110, /* Irq Cause Tx Abs Timer Expire Count */ -	E1000_ICTXQEC  = 0x04118, /* Irq Cause Tx Queue Empty Count */ -	E1000_ICTXQMTC = 0x0411C, /* Irq Cause Tx Queue MinThreshold Count */ -	E1000_ICRXDMTC = 0x04120, /* Irq Cause Rx Desc MinThreshold Count */ -	E1000_ICRXOC   = 0x04124, /* Irq Cause Receiver Overrun Count */ -	E1000_RXCSUM   = 0x05000, /* Rx Checksum Control - RW */ -	E1000_RFCTL    = 0x05008, /* Receive Filter Control */ -	E1000_MTA      = 0x05200, /* Multicast Table Array - RW Array */ -	E1000_RAL_BASE = 0x05400, /* Receive Address Low - RW */ -#define E1000_RAL(_n)   (E1000_RAL_BASE + ((_n) * 8)) -#define E1000_RA        (E1000_RAL(0)) -	E1000_RAH_BASE = 0x05404, /* Receive Address High - RW */ -#define E1000_RAH(_n)   (E1000_RAH_BASE + ((_n) * 8)) -	E1000_SHRAL_PCH_LPT_BASE = 0x05408, -#define E1000_SHRAL_PCH_LPT(_n)   (E1000_SHRAL_PCH_LPT_BASE + ((_n) * 8)) -	E1000_SHRAH_PCH_LTP_BASE = 0x0540C, -#define E1000_SHRAH_PCH_LPT(_n)   (E1000_SHRAH_PCH_LTP_BASE + ((_n) * 8)) -	E1000_SHRAL_BASE = 0x05438, /* Shared Receive Address Low - RW */ -#define E1000_SHRAL(_n)   (E1000_SHRAL_BASE + ((_n) * 8)) -	E1000_SHRAH_BASE = 0x0543C, /* Shared Receive Address High - RW */ -#define E1000_SHRAH(_n)   (E1000_SHRAH_BASE + ((_n) * 8)) -	E1000_VFTA     = 0x05600, /* VLAN Filter Table Array - RW Array */ -	E1000_WUC      = 0x05800, /* Wakeup Control - RW */ -	E1000_WUFC     = 0x05808, /* Wakeup Filter Control - RW */ -	E1000_WUS      = 0x05810, /* Wakeup Status - RO */ -	E1000_MRQC     = 0x05818, /* Multiple Receive Control - RW */ -	E1000_MANC     = 0x05820, /* Management Control - RW */ -	E1000_FFLT     = 0x05F00, /* Flexible Filter Length Table - RW Array */ -	E1000_HOST_IF  = 0x08800, /* Host Interface */ - -	E1000_KMRNCTRLSTA = 0x00034, /* MAC-PHY interface - RW */ -	E1000_MANC2H    = 0x05860, /* Management Control To Host - RW */ -	E1000_MDEF_BASE = 0x05890, /* Management Decision Filters */ -#define E1000_MDEF(_n)   (E1000_MDEF_BASE + ((_n) * 4)) -	E1000_SW_FW_SYNC = 0x05B5C, /* Software-Firmware Synchronization - RW */ -	E1000_GCR	= 0x05B00, /* PCI-Ex Control */ -	E1000_GCR2      = 0x05B64, /* PCI-Ex Control #2 */ -	E1000_FACTPS    = 0x05B30, /* Function Active and Power State to MNG */ -	E1000_SWSM      = 0x05B50, /* SW Semaphore */ -	E1000_FWSM      = 0x05B54, /* FW Semaphore */ -	E1000_SWSM2     = 0x05B58, /* Driver-only SW semaphore */ -	E1000_RETA_BASE = 0x05C00, /* Redirection Table - RW */ -#define E1000_RETA(_n)	(E1000_RETA_BASE + ((_n) * 4)) -	E1000_RSSRK_BASE = 0x05C80, /* RSS Random Key - RW */ -#define E1000_RSSRK(_n)	(E1000_RSSRK_BASE + ((_n) * 4)) -	E1000_FFLT_DBG  = 0x05F04, /* Debug Register */ -	E1000_PCH_RAICC_BASE = 0x05F50, /* Receive Address Initial CRC */ -#define E1000_PCH_RAICC(_n)	(E1000_PCH_RAICC_BASE + ((_n) * 4)) -#define E1000_CRC_OFFSET	E1000_PCH_RAICC_BASE -	E1000_HICR      = 0x08F00, /* Host Interface Control */ -}; - -#define E1000_MAX_PHY_ADDR		4 - -/* IGP01E1000 Specific Registers */ -#define IGP01E1000_PHY_PORT_CONFIG	0x10 /* Port Config */ -#define IGP01E1000_PHY_PORT_STATUS	0x11 /* Status */ -#define IGP01E1000_PHY_PORT_CTRL	0x12 /* Control */ -#define IGP01E1000_PHY_LINK_HEALTH	0x13 /* PHY Link Health */ -#define IGP02E1000_PHY_POWER_MGMT	0x19 /* Power Management */ -#define IGP01E1000_PHY_PAGE_SELECT	0x1F /* Page Select */ -#define BM_PHY_PAGE_SELECT		22   /* Page Select for BM */ -#define IGP_PAGE_SHIFT			5 -#define PHY_REG_MASK			0x1F - -#define BM_WUC_PAGE			800 -#define BM_WUC_ADDRESS_OPCODE		0x11 -#define BM_WUC_DATA_OPCODE		0x12 -#define BM_WUC_ENABLE_PAGE		769 -#define BM_WUC_ENABLE_REG		17 -#define BM_WUC_ENABLE_BIT		(1 << 2) -#define BM_WUC_HOST_WU_BIT		(1 << 4) -#define BM_WUC_ME_WU_BIT		(1 << 5) - -#define BM_WUC	PHY_REG(BM_WUC_PAGE, 1) -#define BM_WUFC PHY_REG(BM_WUC_PAGE, 2) -#define BM_WUS	PHY_REG(BM_WUC_PAGE, 3) - -#define IGP01E1000_PHY_PCS_INIT_REG	0x00B4 -#define IGP01E1000_PHY_POLARITY_MASK	0x0078 - -#define IGP01E1000_PSCR_AUTO_MDIX	0x1000 -#define IGP01E1000_PSCR_FORCE_MDI_MDIX	0x2000 /* 0=MDI, 1=MDIX */ - -#define IGP01E1000_PSCFR_SMART_SPEED	0x0080 - -#define IGP02E1000_PM_SPD		0x0001 /* Smart Power Down */ -#define IGP02E1000_PM_D0_LPLU		0x0002 /* For D0a states */ -#define IGP02E1000_PM_D3_LPLU		0x0004 /* For all other states */ - -#define IGP01E1000_PLHR_SS_DOWNGRADE	0x8000 - -#define IGP01E1000_PSSR_POLARITY_REVERSED	0x0002 -#define IGP01E1000_PSSR_MDIX			0x0800 -#define IGP01E1000_PSSR_SPEED_MASK		0xC000 -#define IGP01E1000_PSSR_SPEED_1000MBPS		0xC000 - -#define IGP02E1000_PHY_CHANNEL_NUM		4 -#define IGP02E1000_PHY_AGC_A			0x11B1 -#define IGP02E1000_PHY_AGC_B			0x12B1 -#define IGP02E1000_PHY_AGC_C			0x14B1 -#define IGP02E1000_PHY_AGC_D			0x18B1 - -#define IGP02E1000_AGC_LENGTH_SHIFT	9 /* Course - 15:13, Fine - 12:9 */ -#define IGP02E1000_AGC_LENGTH_MASK	0x7F -#define IGP02E1000_AGC_RANGE		15 - -/* manage.c */ -#define E1000_VFTA_ENTRY_SHIFT		5 -#define E1000_VFTA_ENTRY_MASK		0x7F -#define E1000_VFTA_ENTRY_BIT_SHIFT_MASK	0x1F - -#define E1000_HICR_EN			0x01  /* Enable bit - RO */ -/* Driver sets this bit when done to put command in RAM */ -#define E1000_HICR_C			0x02 -#define E1000_HICR_FW_RESET_ENABLE	0x40 -#define E1000_HICR_FW_RESET		0x80 - -#define E1000_FWSM_MODE_MASK		0xE -#define E1000_FWSM_MODE_SHIFT		1 - -#define E1000_MNG_IAMT_MODE		0x3 -#define E1000_MNG_DHCP_COOKIE_LENGTH	0x10 -#define E1000_MNG_DHCP_COOKIE_OFFSET	0x6F0 -#define E1000_MNG_DHCP_COMMAND_TIMEOUT	10 -#define E1000_MNG_DHCP_TX_PAYLOAD_CMD	64 -#define E1000_MNG_DHCP_COOKIE_STATUS_PARSING	0x1 -#define E1000_MNG_DHCP_COOKIE_STATUS_VLAN	0x2 - -/* nvm.c */ -#define E1000_STM_OPCODE  0xDB00 - -#define E1000_KMRNCTRLSTA_OFFSET	0x001F0000 -#define E1000_KMRNCTRLSTA_OFFSET_SHIFT	16 -#define E1000_KMRNCTRLSTA_REN		0x00200000 -#define E1000_KMRNCTRLSTA_CTRL_OFFSET	0x1    /* Kumeran Control */ -#define E1000_KMRNCTRLSTA_DIAG_OFFSET	0x3    /* Kumeran Diagnostic */ -#define E1000_KMRNCTRLSTA_TIMEOUTS	0x4    /* Kumeran Timeouts */ -#define E1000_KMRNCTRLSTA_INBAND_PARAM	0x9    /* Kumeran InBand Parameters */ -#define E1000_KMRNCTRLSTA_IBIST_DISABLE	0x0200 /* Kumeran IBIST Disable */ -#define E1000_KMRNCTRLSTA_DIAG_NELPBK	0x1000 /* Nearend Loopback mode */ -#define E1000_KMRNCTRLSTA_K1_CONFIG	0x7 -#define E1000_KMRNCTRLSTA_K1_ENABLE	0x0002 -#define E1000_KMRNCTRLSTA_HD_CTRL	0x10   /* Kumeran HD Control */ - -#define IFE_PHY_EXTENDED_STATUS_CONTROL	0x10 -#define IFE_PHY_SPECIAL_CONTROL		0x11 /* 100BaseTx PHY Special Control */ -#define IFE_PHY_SPECIAL_CONTROL_LED	0x1B /* PHY Special and LED Control */ -#define IFE_PHY_MDIX_CONTROL		0x1C /* MDI/MDI-X Control */ - -/* IFE PHY Extended Status Control */ -#define IFE_PESC_POLARITY_REVERSED	0x0100 - -/* IFE PHY Special Control */ -#define IFE_PSC_AUTO_POLARITY_DISABLE		0x0010 -#define IFE_PSC_FORCE_POLARITY			0x0020 - -/* IFE PHY Special Control and LED Control */ -#define IFE_PSCL_PROBE_MODE		0x0020 -#define IFE_PSCL_PROBE_LEDS_OFF		0x0006 /* Force LEDs 0 and 2 off */ -#define IFE_PSCL_PROBE_LEDS_ON		0x0007 /* Force LEDs 0 and 2 on */ - -/* IFE PHY MDIX Control */ -#define IFE_PMC_MDIX_STATUS	0x0020 /* 1=MDI-X, 0=MDI */ -#define IFE_PMC_FORCE_MDIX	0x0040 /* 1=force MDI-X, 0=force MDI */ -#define IFE_PMC_AUTO_MDIX	0x0080 /* 1=enable auto MDI/MDI-X, 0=disable */ - -#define E1000_CABLE_LENGTH_UNDEFINED	0xFF +struct e1000_hw;  #define E1000_DEV_ID_82571EB_COPPER		0x105E  #define E1000_DEV_ID_82571EB_FIBER		0x105F @@ -373,13 +52,11 @@ enum e1e_registers {  #define E1000_DEV_ID_82573L			0x109A  #define E1000_DEV_ID_82574L			0x10D3  #define E1000_DEV_ID_82574LA			0x10F6 -#define E1000_DEV_ID_82583V                     0x150C - +#define E1000_DEV_ID_82583V			0x150C  #define E1000_DEV_ID_80003ES2LAN_COPPER_DPT	0x1096  #define E1000_DEV_ID_80003ES2LAN_SERDES_DPT	0x1098  #define E1000_DEV_ID_80003ES2LAN_COPPER_SPT	0x10BA  #define E1000_DEV_ID_80003ES2LAN_SERDES_SPT	0x10BB -  #define E1000_DEV_ID_ICH8_82567V_3		0x1501  #define E1000_DEV_ID_ICH8_IGP_M_AMT		0x1049  #define E1000_DEV_ID_ICH8_IGP_AMT		0x104A @@ -414,12 +91,12 @@ enum e1e_registers {  #define E1000_DEV_ID_PCH_LPTLP_I218_LM		0x155A  #define E1000_DEV_ID_PCH_LPTLP_I218_V		0x1559 -#define E1000_REVISION_4 4 +#define E1000_REVISION_4	4 -#define E1000_FUNC_1 1 +#define E1000_FUNC_1		1 -#define E1000_ALT_MAC_ADDRESS_OFFSET_LAN0   0 -#define E1000_ALT_MAC_ADDRESS_OFFSET_LAN1   3 +#define E1000_ALT_MAC_ADDRESS_OFFSET_LAN0	0 +#define E1000_ALT_MAC_ADDRESS_OFFSET_LAN1	3  enum e1000_mac_type {  	e1000_82571, @@ -524,16 +201,6 @@ enum e1000_serdes_link_state {  	e1000_serdes_link_forced_up  }; -/* Receive Descriptor */ -struct e1000_rx_desc { -	__le64 buffer_addr; /* Address of the descriptor's data buffer */ -	__le16 length;      /* Length of data DMAed into data buffer */ -	__le16 csum;	/* Packet checksum */ -	u8  status;      /* Descriptor status */ -	u8  errors;      /* Descriptor Errors */ -	__le16 special; -}; -  /* Receive Descriptor - Extended */  union e1000_rx_desc_extended {  	struct { @@ -656,7 +323,7 @@ struct e1000_data_desc {  		struct {  			u8 status;     /* Descriptor status */  			u8 popts;      /* Packet Options */ -			__le16 special;   /* */ +			__le16 special;  		} fields;  	} upper;  }; @@ -752,7 +419,7 @@ struct e1000_host_command_header {  	u8 checksum;  }; -#define E1000_HI_MAX_DATA_LENGTH     252 +#define E1000_HI_MAX_DATA_LENGTH	252  struct e1000_host_command_info {  	struct e1000_host_command_header command_header;  	u8 command_data[E1000_HI_MAX_DATA_LENGTH]; @@ -767,13 +434,18 @@ struct e1000_host_mng_command_header {  	u16 command_length;  }; -#define E1000_HI_MAX_MNG_DATA_LENGTH 0x6F8 +#define E1000_HI_MAX_MNG_DATA_LENGTH	0x6F8  struct e1000_host_mng_command_info {  	struct e1000_host_mng_command_header command_header;  	u8 command_data[E1000_HI_MAX_MNG_DATA_LENGTH];  }; -/* Function pointers and static data for the MAC. */ +#include "mac.h" +#include "phy.h" +#include "nvm.h" +#include "manage.h" + +/* Function pointers for the MAC. */  struct e1000_mac_operations {  	s32  (*id_led_init)(struct e1000_hw *);  	s32  (*blink_led)(struct e1000_hw *); @@ -1002,4 +674,8 @@ struct e1000_hw {  	} dev_spec;  }; +#include "82571.h" +#include "80003es2lan.h" +#include "ich8lan.h" +  #endif diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.c b/drivers/net/ethernet/intel/e1000e/ich8lan.c index 97633654760..dff7bff8b8e 100644 --- a/drivers/net/ethernet/intel/e1000e/ich8lan.c +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel PRO/1000 Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -57,147 +57,6 @@  #include "e1000.h" -#define ICH_FLASH_GFPREG		0x0000 -#define ICH_FLASH_HSFSTS		0x0004 -#define ICH_FLASH_HSFCTL		0x0006 -#define ICH_FLASH_FADDR			0x0008 -#define ICH_FLASH_FDATA0		0x0010 -#define ICH_FLASH_PR0			0x0074 - -#define ICH_FLASH_READ_COMMAND_TIMEOUT	500 -#define ICH_FLASH_WRITE_COMMAND_TIMEOUT	500 -#define ICH_FLASH_ERASE_COMMAND_TIMEOUT	3000000 -#define ICH_FLASH_LINEAR_ADDR_MASK	0x00FFFFFF -#define ICH_FLASH_CYCLE_REPEAT_COUNT	10 - -#define ICH_CYCLE_READ			0 -#define ICH_CYCLE_WRITE			2 -#define ICH_CYCLE_ERASE			3 - -#define FLASH_GFPREG_BASE_MASK		0x1FFF -#define FLASH_SECTOR_ADDR_SHIFT		12 - -#define ICH_FLASH_SEG_SIZE_256		256 -#define ICH_FLASH_SEG_SIZE_4K		4096 -#define ICH_FLASH_SEG_SIZE_8K		8192 -#define ICH_FLASH_SEG_SIZE_64K		65536 - - -#define E1000_ICH_FWSM_RSPCIPHY	0x00000040 /* Reset PHY on PCI Reset */ -/* FW established a valid mode */ -#define E1000_ICH_FWSM_FW_VALID		0x00008000 - -#define E1000_ICH_MNG_IAMT_MODE		0x2 - -#define ID_LED_DEFAULT_ICH8LAN  ((ID_LED_DEF1_DEF2 << 12) | \ -				 (ID_LED_DEF1_OFF2 <<  8) | \ -				 (ID_LED_DEF1_ON2  <<  4) | \ -				 (ID_LED_DEF1_DEF2)) - -#define E1000_ICH_NVM_SIG_WORD		0x13 -#define E1000_ICH_NVM_SIG_MASK		0xC000 -#define E1000_ICH_NVM_VALID_SIG_MASK    0xC0 -#define E1000_ICH_NVM_SIG_VALUE         0x80 - -#define E1000_ICH8_LAN_INIT_TIMEOUT	1500 - -#define E1000_FEXTNVM_SW_CONFIG		1 -#define E1000_FEXTNVM_SW_CONFIG_ICH8M (1 << 27) /* Bit redefined for ICH8M :/ */ - -#define E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK    0x0C000000 -#define E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC  0x08000000 - -#define E1000_FEXTNVM4_BEACON_DURATION_MASK    0x7 -#define E1000_FEXTNVM4_BEACON_DURATION_8USEC   0x7 -#define E1000_FEXTNVM4_BEACON_DURATION_16USEC  0x3 - -#define PCIE_ICH8_SNOOP_ALL		PCIE_NO_SNOOP_ALL - -#define E1000_ICH_RAR_ENTRIES		7 -#define E1000_PCH2_RAR_ENTRIES		5 /* RAR[0], SHRA[0-3] */ -#define E1000_PCH_LPT_RAR_ENTRIES	12 /* RAR[0], SHRA[0-10] */ - -#define PHY_PAGE_SHIFT 5 -#define PHY_REG(page, reg) (((page) << PHY_PAGE_SHIFT) | \ -			   ((reg) & MAX_PHY_REG_ADDRESS)) -#define IGP3_KMRN_DIAG  PHY_REG(770, 19) /* KMRN Diagnostic */ -#define IGP3_VR_CTRL    PHY_REG(776, 18) /* Voltage Regulator Control */ - -#define IGP3_KMRN_DIAG_PCS_LOCK_LOSS	0x0002 -#define IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK 0x0300 -#define IGP3_VR_CTRL_MODE_SHUTDOWN	0x0200 - -#define HV_LED_CONFIG		PHY_REG(768, 30) /* LED Configuration */ - -#define SW_FLAG_TIMEOUT    1000 /* SW Semaphore flag timeout in milliseconds */ - -/* SMBus Control Phy Register */ -#define CV_SMB_CTRL		PHY_REG(769, 23) -#define CV_SMB_CTRL_FORCE_SMBUS	0x0001 - -/* SMBus Address Phy Register */ -#define HV_SMB_ADDR            PHY_REG(768, 26) -#define HV_SMB_ADDR_MASK       0x007F -#define HV_SMB_ADDR_PEC_EN     0x0200 -#define HV_SMB_ADDR_VALID      0x0080 -#define HV_SMB_ADDR_FREQ_MASK           0x1100 -#define HV_SMB_ADDR_FREQ_LOW_SHIFT      8 -#define HV_SMB_ADDR_FREQ_HIGH_SHIFT     12 - -/* PHY Power Management Control */ -#define HV_PM_CTRL		PHY_REG(770, 17) -#define HV_PM_CTRL_PLL_STOP_IN_K1_GIGA	0x100 - -/* PHY Low Power Idle Control */ -#define I82579_LPI_CTRL				PHY_REG(772, 20) -#define I82579_LPI_CTRL_ENABLE_MASK		0x6000 -#define I82579_LPI_CTRL_FORCE_PLL_LOCK_COUNT	0x80 - -/* EMI Registers */ -#define I82579_EMI_ADDR         0x10 -#define I82579_EMI_DATA         0x11 -#define I82579_LPI_UPDATE_TIMER 0x4805	/* in 40ns units + 40 ns base value */ -#define I82579_MSE_THRESHOLD    0x084F	/* Mean Square Error Threshold */ -#define I82579_MSE_LINK_DOWN    0x2411	/* MSE count before dropping link */ -#define I217_EEE_ADVERTISEMENT  0x8001	/* IEEE MMD Register 7.60 */ -#define I217_EEE_LP_ABILITY     0x8002	/* IEEE MMD Register 7.61 */ -#define I217_EEE_100_SUPPORTED  (1 << 1)	/* 100BaseTx EEE supported */ - -/* Intel Rapid Start Technology Support */ -#define I217_PROXY_CTRL                 BM_PHY_REG(BM_WUC_PAGE, 70) -#define I217_PROXY_CTRL_AUTO_DISABLE    0x0080 -#define I217_SxCTRL                     PHY_REG(BM_PORT_CTRL_PAGE, 28) -#define I217_SxCTRL_ENABLE_LPI_RESET    0x1000 -#define I217_CGFREG                     PHY_REG(772, 29) -#define I217_CGFREG_ENABLE_MTA_RESET    0x0002 -#define I217_MEMPWR                     PHY_REG(772, 26) -#define I217_MEMPWR_DISABLE_SMB_RELEASE 0x0010 - -/* Strapping Option Register - RO */ -#define E1000_STRAP                     0x0000C -#define E1000_STRAP_SMBUS_ADDRESS_MASK  0x00FE0000 -#define E1000_STRAP_SMBUS_ADDRESS_SHIFT 17 -#define E1000_STRAP_SMT_FREQ_MASK       0x00003000 -#define E1000_STRAP_SMT_FREQ_SHIFT      12 - -/* OEM Bits Phy Register */ -#define HV_OEM_BITS            PHY_REG(768, 25) -#define HV_OEM_BITS_LPLU       0x0004 /* Low Power Link Up */ -#define HV_OEM_BITS_GBE_DIS    0x0040 /* Gigabit Disable */ -#define HV_OEM_BITS_RESTART_AN 0x0400 /* Restart Auto-negotiation */ - -#define E1000_NVM_K1_CONFIG 0x1B /* NVM K1 Config Word */ -#define E1000_NVM_K1_ENABLE 0x1  /* NVM Enable K1 bit */ - -/* KMRN Mode Control */ -#define HV_KMRN_MODE_CTRL      PHY_REG(769, 16) -#define HV_KMRN_MDIO_SLOW      0x0400 - -/* KMRN FIFO Control and Status */ -#define HV_KMRN_FIFO_CTRLSTA                  PHY_REG(770, 16) -#define HV_KMRN_FIFO_CTRLSTA_PREAMBLE_MASK    0x7000 -#define HV_KMRN_FIFO_CTRLSTA_PREAMBLE_SHIFT   12 -  /* ICH GbE Flash Hardware Sequencing Flash Status Register bit breakdown */  /* Offset 04h HSFSTS */  union ich8_hws_flash_status { @@ -252,7 +111,6 @@ union ich8_flash_protected_range {  	u32 regval;  }; -static s32 e1000_setup_link_ich8lan(struct e1000_hw *hw);  static void e1000_clear_hw_cntrs_ich8lan(struct e1000_hw *hw);  static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw);  static s32 e1000_erase_flash_bank_ich8lan(struct e1000_hw *hw, u32 bank); @@ -264,9 +122,7 @@ static s32 e1000_read_flash_word_ich8lan(struct e1000_hw *hw, u32 offset,  					 u16 *data);  static s32 e1000_read_flash_data_ich8lan(struct e1000_hw *hw, u32 offset,  					 u8 size, u16 *data); -static s32 e1000_setup_copper_link_ich8lan(struct e1000_hw *hw);  static s32 e1000_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw); -static s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw);  static s32 e1000_cleanup_led_ich8lan(struct e1000_hw *hw);  static s32 e1000_led_on_ich8lan(struct e1000_hw *hw);  static s32 e1000_led_off_ich8lan(struct e1000_hw *hw); @@ -278,7 +134,7 @@ static s32 e1000_led_off_pchlan(struct e1000_hw *hw);  static s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active);  static void e1000_power_down_phy_copper_ich8lan(struct e1000_hw *hw);  static void e1000_lan_init_done_ich8lan(struct e1000_hw *hw); -static s32  e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link); +static s32 e1000_k1_gig_workaround_hv(struct e1000_hw *hw, bool link);  static s32 e1000_set_mdio_slow_mode_hv(struct e1000_hw *hw);  static bool e1000_check_mng_mode_ich8lan(struct e1000_hw *hw);  static bool e1000_check_mng_mode_pchlan(struct e1000_hw *hw); @@ -330,12 +186,12 @@ static bool e1000_phy_is_accessible_pchlan(struct e1000_hw *hw)  	u16 retry_count;  	for (retry_count = 0; retry_count < 2; retry_count++) { -		ret_val = e1e_rphy_locked(hw, PHY_ID1, &phy_reg); +		ret_val = e1e_rphy_locked(hw, MII_PHYSID1, &phy_reg);  		if (ret_val || (phy_reg == 0xFFFF))  			continue;  		phy_id = (u32)(phy_reg << 16); -		ret_val = e1e_rphy_locked(hw, PHY_ID2, &phy_reg); +		ret_val = e1e_rphy_locked(hw, MII_PHYSID2, &phy_reg);  		if (ret_val || (phy_reg == 0xFFFF)) {  			phy_id = 0;  			continue; @@ -378,10 +234,15 @@ static s32 e1000_init_phy_workarounds_pchlan(struct e1000_hw *hw)  	s32 ret_val;  	u16 phy_reg; +	/* Gate automatic PHY configuration by hardware on managed and +	 * non-managed 82579 and newer adapters. +	 */ +	e1000_gate_hw_phy_config_ich8lan(hw, true); +  	ret_val = hw->phy.ops.acquire(hw);  	if (ret_val) {  		e_dbg("Failed to initialize PHY flow\n"); -		return ret_val; +		goto out;  	}  	/* The MAC-PHY interconnect may be in SMBus mode.  If the PHY is @@ -402,13 +263,6 @@ static s32 e1000_init_phy_workarounds_pchlan(struct e1000_hw *hw)  		/* fall-through */  	case e1000_pch2lan: -		/* Gate automatic PHY configuration by hardware on -		 * non-managed 82579 -		 */ -		if ((hw->mac.type == e1000_pch2lan) && -		    !(fwsm & E1000_ICH_FWSM_FW_VALID)) -			e1000_gate_hw_phy_config_ich8lan(hw, true); -  		if (e1000_phy_is_accessible_pchlan(hw)) {  			if (hw->mac.type == e1000_pch_lpt) {  				/* Unforce SMBus mode in PHY */ @@ -443,6 +297,15 @@ static s32 e1000_init_phy_workarounds_pchlan(struct e1000_hw *hw)  		mac_reg |= E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC;  		ew32(FEXTNVM3, mac_reg); +		if (hw->mac.type == e1000_pch_lpt) { +			/* Toggling LANPHYPC brings the PHY out of SMBus mode +			 * So ensure that the MAC is also out of SMBus mode +			 */ +			mac_reg = er32(CTRL_EXT); +			mac_reg &= ~E1000_CTRL_EXT_FORCE_SMBUS; +			ew32(CTRL_EXT, mac_reg); +		} +  		/* Toggle LANPHYPC Value bit */  		mac_reg = er32(CTRL);  		mac_reg |= E1000_CTRL_LANPHYPC_OVERRIDE; @@ -476,6 +339,7 @@ static s32 e1000_init_phy_workarounds_pchlan(struct e1000_hw *hw)  	 */  	ret_val = e1000e_phy_hw_reset_generic(hw); +out:  	/* Ungate automatic PHY configuration on non-managed 82579 */  	if ((hw->mac.type == e1000_pch2lan) &&  	    !(fwsm & E1000_ICH_FWSM_FW_VALID)) { @@ -495,7 +359,7 @@ static s32 e1000_init_phy_workarounds_pchlan(struct e1000_hw *hw)  static s32 e1000_init_phy_params_pchlan(struct e1000_hw *hw)  {  	struct e1000_phy_info *phy = &hw->phy; -	s32 ret_val = 0; +	s32 ret_val;  	phy->addr                     = 1;  	phy->reset_delay_us           = 100; @@ -778,68 +642,143 @@ static s32 e1000_init_mac_params_ich8lan(struct e1000_hw *hw)  	if (mac->type == e1000_ich8lan)  		e1000e_set_kmrn_lock_loss_workaround_ich8lan(hw, true); -	/* Gate automatic PHY configuration by hardware on managed -	 * 82579 and i217 -	 */ -	if ((mac->type == e1000_pch2lan || mac->type == e1000_pch_lpt) && -	    (er32(FWSM) & E1000_ICH_FWSM_FW_VALID)) -		e1000_gate_hw_phy_config_ich8lan(hw, true); -  	return 0;  }  /** + *  __e1000_access_emi_reg_locked - Read/write EMI register + *  @hw: pointer to the HW structure + *  @addr: EMI address to program + *  @data: pointer to value to read/write from/to the EMI address + *  @read: boolean flag to indicate read or write + * + *  This helper function assumes the SW/FW/HW Semaphore is already acquired. + **/ +static s32 __e1000_access_emi_reg_locked(struct e1000_hw *hw, u16 address, +					 u16 *data, bool read) +{ +	s32 ret_val; + +	ret_val = e1e_wphy_locked(hw, I82579_EMI_ADDR, address); +	if (ret_val) +		return ret_val; + +	if (read) +		ret_val = e1e_rphy_locked(hw, I82579_EMI_DATA, data); +	else +		ret_val = e1e_wphy_locked(hw, I82579_EMI_DATA, *data); + +	return ret_val; +} + +/** + *  e1000_read_emi_reg_locked - Read Extended Management Interface register + *  @hw: pointer to the HW structure + *  @addr: EMI address to program + *  @data: value to be read from the EMI address + * + *  Assumes the SW/FW/HW Semaphore is already acquired. + **/ +s32 e1000_read_emi_reg_locked(struct e1000_hw *hw, u16 addr, u16 *data) +{ +	return __e1000_access_emi_reg_locked(hw, addr, data, true); +} + +/** + *  e1000_write_emi_reg_locked - Write Extended Management Interface register + *  @hw: pointer to the HW structure + *  @addr: EMI address to program + *  @data: value to be written to the EMI address + * + *  Assumes the SW/FW/HW Semaphore is already acquired. + **/ +static s32 e1000_write_emi_reg_locked(struct e1000_hw *hw, u16 addr, u16 data) +{ +	return __e1000_access_emi_reg_locked(hw, addr, &data, false); +} + +/**   *  e1000_set_eee_pchlan - Enable/disable EEE support   *  @hw: pointer to the HW structure   * - *  Enable/disable EEE based on setting in dev_spec structure.  The bits in - *  the LPI Control register will remain set only if/when link is up. + *  Enable/disable EEE based on setting in dev_spec structure, the duplex of + *  the link and the EEE capabilities of the link partner.  The LPI Control + *  register bits will remain set only if/when link is up.   **/  static s32 e1000_set_eee_pchlan(struct e1000_hw *hw)  {  	struct e1000_dev_spec_ich8lan *dev_spec = &hw->dev_spec.ich8lan; -	s32 ret_val = 0; -	u16 phy_reg; +	s32 ret_val; +	u16 lpi_ctrl;  	if ((hw->phy.type != e1000_phy_82579) &&  	    (hw->phy.type != e1000_phy_i217))  		return 0; -	ret_val = e1e_rphy(hw, I82579_LPI_CTRL, &phy_reg); +	ret_val = hw->phy.ops.acquire(hw);  	if (ret_val)  		return ret_val; -	if (dev_spec->eee_disable) -		phy_reg &= ~I82579_LPI_CTRL_ENABLE_MASK; -	else -		phy_reg |= I82579_LPI_CTRL_ENABLE_MASK; - -	ret_val = e1e_wphy(hw, I82579_LPI_CTRL, phy_reg); +	ret_val = e1e_rphy_locked(hw, I82579_LPI_CTRL, &lpi_ctrl);  	if (ret_val) -		return ret_val; +		goto release; + +	/* Clear bits that enable EEE in various speeds */ +	lpi_ctrl &= ~I82579_LPI_CTRL_ENABLE_MASK; + +	/* Enable EEE if not disabled by user */ +	if (!dev_spec->eee_disable) { +		u16 lpa, pcs_status, data; -	if ((hw->phy.type == e1000_phy_i217) && !dev_spec->eee_disable) {  		/* Save off link partner's EEE ability */ -		ret_val = hw->phy.ops.acquire(hw); -		if (ret_val) -			return ret_val; -		ret_val = e1e_wphy_locked(hw, I82579_EMI_ADDR, -					  I217_EEE_LP_ABILITY); +		switch (hw->phy.type) { +		case e1000_phy_82579: +			lpa = I82579_EEE_LP_ABILITY; +			pcs_status = I82579_EEE_PCS_STATUS; +			break; +		case e1000_phy_i217: +			lpa = I217_EEE_LP_ABILITY; +			pcs_status = I217_EEE_PCS_STATUS; +			break; +		default: +			ret_val = -E1000_ERR_PHY; +			goto release; +		} +		ret_val = e1000_read_emi_reg_locked(hw, lpa, +						    &dev_spec->eee_lp_ability);  		if (ret_val)  			goto release; -		e1e_rphy_locked(hw, I82579_EMI_DATA, &dev_spec->eee_lp_ability); -		/* EEE is not supported in 100Half, so ignore partner's EEE -		 * in 100 ability if full-duplex is not advertised. +		/* Enable EEE only for speeds in which the link partner is +		 * EEE capable.  		 */ -		e1e_rphy_locked(hw, PHY_LP_ABILITY, &phy_reg); -		if (!(phy_reg & NWAY_LPAR_100TX_FD_CAPS)) -			dev_spec->eee_lp_ability &= ~I217_EEE_100_SUPPORTED; -release: -		hw->phy.ops.release(hw); +		if (dev_spec->eee_lp_ability & I82579_EEE_1000_SUPPORTED) +			lpi_ctrl |= I82579_LPI_CTRL_1000_ENABLE; + +		if (dev_spec->eee_lp_ability & I82579_EEE_100_SUPPORTED) { +			e1e_rphy_locked(hw, MII_LPA, &data); +			if (data & LPA_100FULL) +				lpi_ctrl |= I82579_LPI_CTRL_100_ENABLE; +			else +				/* EEE is not supported in 100Half, so ignore +				 * partner's EEE in 100 ability if full-duplex +				 * is not advertised. +				 */ +				dev_spec->eee_lp_ability &= +				    ~I82579_EEE_100_SUPPORTED; +		} + +		/* R/Clr IEEE MMD 3.1 bits 11:10 - Tx/Rx LPI Received */ +		ret_val = e1000_read_emi_reg_locked(hw, pcs_status, &data); +		if (ret_val) +			goto release;  	} -	return 0; +	ret_val = e1e_wphy_locked(hw, I82579_LPI_CTRL, lpi_ctrl); +release: +	hw->phy.ops.release(hw); + +	return ret_val;  }  /** @@ -1017,7 +956,7 @@ static DEFINE_MUTEX(nvm_mutex);   *   *  Acquires the mutex for performing NVM operations.   **/ -static s32 e1000_acquire_nvm_ich8lan(struct e1000_hw *hw) +static s32 e1000_acquire_nvm_ich8lan(struct e1000_hw __always_unused *hw)  {  	mutex_lock(&nvm_mutex); @@ -1030,7 +969,7 @@ static s32 e1000_acquire_nvm_ich8lan(struct e1000_hw *hw)   *   *  Releases the mutex used while performing NVM operations.   **/ -static void e1000_release_nvm_ich8lan(struct e1000_hw *hw) +static void e1000_release_nvm_ich8lan(struct e1000_hw __always_unused *hw)  {  	mutex_unlock(&nvm_mutex);  } @@ -1322,7 +1261,7 @@ static s32 e1000_write_smbus_addr(struct e1000_hw *hw)  	u32 strap = er32(STRAP);  	u32 freq = (strap & E1000_STRAP_SMT_FREQ_MASK) >>  	    E1000_STRAP_SMT_FREQ_SHIFT; -	s32 ret_val = 0; +	s32 ret_val;  	strap &= E1000_STRAP_SMBUS_ADDRESS_MASK; @@ -1558,7 +1497,7 @@ release:   **/  s32 e1000_configure_k1_ich8lan(struct e1000_hw *hw, bool k1_enable)  { -	s32 ret_val = 0; +	s32 ret_val;  	u32 ctrl_reg = 0;  	u32 ctrl_ext = 0;  	u32 reg = 0; @@ -1727,7 +1666,7 @@ static s32 e1000_hv_phy_workarounds_ich8lan(struct e1000_hw *hw)  		 */  		if (hw->phy.revision < 2) {  			e1000e_phy_sw_reset(hw); -			ret_val = e1e_wphy(hw, PHY_CONTROL, 0x3140); +			ret_val = e1e_wphy(hw, MII_BMCR, 0x3140);  		}  	} @@ -1757,6 +1696,11 @@ static s32 e1000_hv_phy_workarounds_ich8lan(struct e1000_hw *hw)  	if (ret_val)  		goto release;  	ret_val = e1e_wphy_locked(hw, BM_PORT_GEN_CFG, phy_data & 0x00FF); +	if (ret_val) +		goto release; + +	/* set MSE higher to enable link to stay up when noise is high */ +	ret_val = e1000_write_emi_reg_locked(hw, I82577_MSE_THRESHOLD, 0x0034);  release:  	hw->phy.ops.release(hw); @@ -1983,22 +1927,18 @@ static s32 e1000_lv_phy_workarounds_ich8lan(struct e1000_hw *hw)  	/* Set MDIO slow mode before any other MDIO access */  	ret_val = e1000_set_mdio_slow_mode_hv(hw); +	if (ret_val) +		return ret_val;  	ret_val = hw->phy.ops.acquire(hw);  	if (ret_val)  		return ret_val; -	ret_val = e1e_wphy_locked(hw, I82579_EMI_ADDR, I82579_MSE_THRESHOLD); -	if (ret_val) -		goto release;  	/* set MSE higher to enable link to stay up when noise is high */ -	ret_val = e1e_wphy_locked(hw, I82579_EMI_DATA, 0x0034); -	if (ret_val) -		goto release; -	ret_val = e1e_wphy_locked(hw, I82579_EMI_ADDR, I82579_MSE_LINK_DOWN); +	ret_val = e1000_write_emi_reg_locked(hw, I82579_MSE_THRESHOLD, 0x0034);  	if (ret_val)  		goto release;  	/* drop link after 5 times MSE threshold was reached */ -	ret_val = e1e_wphy_locked(hw, I82579_EMI_DATA, 0x0005); +	ret_val = e1000_write_emi_reg_locked(hw, I82579_MSE_LINK_DOWN, 0x0005);  release:  	hw->phy.ops.release(hw); @@ -2172,10 +2112,9 @@ static s32 e1000_post_phy_reset_ich8lan(struct e1000_hw *hw)  		ret_val = hw->phy.ops.acquire(hw);  		if (ret_val)  			return ret_val; -		ret_val = e1e_wphy_locked(hw, I82579_EMI_ADDR, -					  I82579_LPI_UPDATE_TIMER); -		if (!ret_val) -			ret_val = e1e_wphy_locked(hw, I82579_EMI_DATA, 0x1387); +		ret_val = e1000_write_emi_reg_locked(hw, +						     I82579_LPI_UPDATE_TIMER, +						     0x1387);  		hw->phy.ops.release(hw);  	} @@ -2219,7 +2158,7 @@ static s32 e1000_phy_hw_reset_ich8lan(struct e1000_hw *hw)   **/  static s32 e1000_set_lplu_state_pchlan(struct e1000_hw *hw, bool active)  { -	s32 ret_val = 0; +	s32 ret_val;  	u16 oem_reg;  	ret_val = e1e_rphy(hw, HV_OEM_BITS, &oem_reg); @@ -2277,6 +2216,8 @@ static s32 e1000_set_d0_lplu_state_ich8lan(struct e1000_hw *hw, bool active)  		/* When LPLU is enabled, we should disable SmartSpeed */  		ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CONFIG, &data); +		if (ret_val) +			return ret_val;  		data &= ~IGP01E1000_PSCFR_SMART_SPEED;  		ret_val = e1e_wphy(hw, IGP01E1000_PHY_PORT_CONFIG, data);  		if (ret_val) @@ -2949,19 +2890,32 @@ static s32 e1000_validate_nvm_checksum_ich8lan(struct e1000_hw *hw)  {  	s32 ret_val;  	u16 data; +	u16 word; +	u16 valid_csum_mask; -	/* Read 0x19 and check bit 6.  If this bit is 0, the checksum -	 * needs to be fixed.  This bit is an indication that the NVM -	 * was prepared by OEM software and did not calculate the -	 * checksum...a likely scenario. +	/* Read NVM and check Invalid Image CSUM bit.  If this bit is 0, +	 * the checksum needs to be fixed.  This bit is an indication that +	 * the NVM was prepared by OEM software and did not calculate +	 * the checksum...a likely scenario.  	 */ -	ret_val = e1000_read_nvm(hw, 0x19, 1, &data); +	switch (hw->mac.type) { +	case e1000_pch_lpt: +		word = NVM_COMPAT; +		valid_csum_mask = NVM_COMPAT_VALID_CSUM; +		break; +	default: +		word = NVM_FUTURE_INIT_WORD1; +		valid_csum_mask = NVM_FUTURE_INIT_WORD1_VALID_CSUM; +		break; +	} + +	ret_val = e1000_read_nvm(hw, word, 1, &data);  	if (ret_val)  		return ret_val; -	if (!(data & 0x40)) { -		data |= 0x40; -		ret_val = e1000_write_nvm(hw, 0x19, 1, &data); +	if (!(data & valid_csum_mask)) { +		data |= valid_csum_mask; +		ret_val = e1000_write_nvm(hw, word, 1, &data);  		if (ret_val)  			return ret_val;  		ret_val = e1000e_update_nvm_checksum(hw); @@ -3624,6 +3578,17 @@ static void e1000_initialize_hw_bits_ich8lan(struct e1000_hw *hw)  	if (hw->mac.type == e1000_ich8lan)  		reg |= (E1000_RFCTL_IPV6_EX_DIS | E1000_RFCTL_NEW_IPV6_EXT_DIS);  	ew32(RFCTL, reg); + +	/* Enable ECC on Lynxpoint */ +	if (hw->mac.type == e1000_pch_lpt) { +		reg = er32(PBECCSTS); +		reg |= E1000_PBECCSTS_ECC_ENABLE; +		ew32(PBECCSTS, reg); + +		reg = er32(CTRL); +		reg |= E1000_CTRL_MEHE; +		ew32(CTRL, reg); +	}  }  /** @@ -3964,8 +3929,7 @@ void e1000e_gig_downshift_workaround_ich8lan(struct e1000_hw *hw)  	if (ret_val)  		return;  	reg_data &= ~E1000_KMRNCTRLSTA_DIAG_NELPBK; -	ret_val = e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET, -				       reg_data); +	e1000e_write_kmrn_reg(hw, E1000_KMRNCTRLSTA_DIAG_OFFSET, reg_data);  }  /** @@ -4000,19 +3964,20 @@ void e1000_suspend_workarounds_ich8lan(struct e1000_hw *hw)  		if (!dev_spec->eee_disable) {  			u16 eee_advert; -			ret_val = e1e_wphy_locked(hw, I82579_EMI_ADDR, -						  I217_EEE_ADVERTISEMENT); +			ret_val = +			    e1000_read_emi_reg_locked(hw, +						      I217_EEE_ADVERTISEMENT, +						      &eee_advert);  			if (ret_val)  				goto release; -			e1e_rphy_locked(hw, I82579_EMI_DATA, &eee_advert);  			/* Disable LPLU if both link partners support 100BaseT  			 * EEE and 100Full is advertised on both ends of the  			 * link.  			 */ -			if ((eee_advert & I217_EEE_100_SUPPORTED) && +			if ((eee_advert & I82579_EEE_100_SUPPORTED) &&  			    (dev_spec->eee_lp_ability & -			     I217_EEE_100_SUPPORTED) && +			     I82579_EEE_100_SUPPORTED) &&  			    (hw->phy.autoneg_advertised & ADVERTISE_100_FULL))  				phy_ctrl &= ~(E1000_PHY_CTRL_D0A_LPLU |  					      E1000_PHY_CTRL_NOND0A_LPLU); @@ -4026,7 +3991,6 @@ void e1000_suspend_workarounds_ich8lan(struct e1000_hw *hw)  		 * The SMBus release must also be disabled on LCD reset.  		 */  		if (!(er32(FWSM) & E1000_ICH_FWSM_FW_VALID)) { -  			/* Enable proxy to reset only on power good. */  			e1e_rphy_locked(hw, I217_PROXY_CTRL, &phy_reg);  			phy_reg |= I217_PROXY_CTRL_AUTO_DISABLE; @@ -4287,7 +4251,7 @@ static s32 e1000_get_cfg_done_ich8lan(struct e1000_hw *hw)  	u32 bank = 0;  	u32 status; -	e1000e_get_cfg_done(hw); +	e1000e_get_cfg_done_generic(hw);  	/* Wait for indication from h/w that it has completed basic config */  	if (hw->mac.type >= e1000_ich10lan) { @@ -4416,7 +4380,7 @@ static const struct e1000_mac_operations ich8_mac_ops = {  	.reset_hw		= e1000_reset_hw_ich8lan,  	.init_hw		= e1000_init_hw_ich8lan,  	.setup_link		= e1000_setup_link_ich8lan, -	.setup_physical_interface= e1000_setup_copper_link_ich8lan, +	.setup_physical_interface = e1000_setup_copper_link_ich8lan,  	/* id_led_init dependent on mac type */  	.config_collision_dist	= e1000e_config_collision_dist_generic,  	.rar_set		= e1000e_rar_set_generic, @@ -4438,7 +4402,7 @@ static const struct e1000_phy_operations ich8_phy_ops = {  static const struct e1000_nvm_operations ich8_nvm_ops = {  	.acquire		= e1000_acquire_nvm_ich8lan, -	.read		 	= e1000_read_nvm_ich8lan, +	.read			= e1000_read_nvm_ich8lan,  	.release		= e1000_release_nvm_ich8lan,  	.reload			= e1000e_reload_nvm_generic,  	.update			= e1000_update_nvm_checksum_ich8lan, @@ -4520,6 +4484,7 @@ const struct e1000_info e1000_pch2_info = {  	.mac			= e1000_pch2lan,  	.flags			= FLAG_IS_ICH  				  | FLAG_HAS_WOL +				  | FLAG_HAS_HW_TIMESTAMP  				  | FLAG_HAS_CTRLEXT_ON_LOAD  				  | FLAG_HAS_AMT  				  | FLAG_HAS_FLASH @@ -4528,7 +4493,7 @@ const struct e1000_info e1000_pch2_info = {  	.flags2			= FLAG2_HAS_PHY_STATS  				  | FLAG2_HAS_EEE,  	.pba			= 26, -	.max_hw_frame_size	= DEFAULT_JUMBO, +	.max_hw_frame_size	= 9018,  	.get_variants		= e1000_get_variants_ich8lan,  	.mac_ops		= &ich8_mac_ops,  	.phy_ops		= &ich8_phy_ops, @@ -4539,6 +4504,7 @@ const struct e1000_info e1000_pch_lpt_info = {  	.mac			= e1000_pch_lpt,  	.flags			= FLAG_IS_ICH  				  | FLAG_HAS_WOL +				  | FLAG_HAS_HW_TIMESTAMP  				  | FLAG_HAS_CTRLEXT_ON_LOAD  				  | FLAG_HAS_AMT  				  | FLAG_HAS_FLASH @@ -4547,7 +4513,7 @@ const struct e1000_info e1000_pch_lpt_info = {  	.flags2			= FLAG2_HAS_PHY_STATS  				  | FLAG2_HAS_EEE,  	.pba			= 26, -	.max_hw_frame_size	= DEFAULT_JUMBO, +	.max_hw_frame_size	= 9018,  	.get_variants		= e1000_get_variants_ich8lan,  	.mac_ops		= &ich8_mac_ops,  	.phy_ops		= &ich8_phy_ops, diff --git a/drivers/net/ethernet/intel/e1000e/ich8lan.h b/drivers/net/ethernet/intel/e1000e/ich8lan.h new file mode 100644 index 00000000000..b6d3174d7d2 --- /dev/null +++ b/drivers/net/ethernet/intel/e1000e/ich8lan.h @@ -0,0 +1,268 @@ +/******************************************************************************* + +  Intel PRO/1000 Linux driver +  Copyright(c) 1999 - 2013 Intel Corporation. + +  This program is free software; you can redistribute it and/or modify it +  under the terms and conditions of the GNU General Public License, +  version 2, as published by the Free Software Foundation. + +  This program is distributed in the hope it will be useful, but WITHOUT +  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for +  more details. + +  You should have received a copy of the GNU General Public License along with +  this program; if not, write to the Free Software Foundation, Inc., +  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + +  The full GNU General Public License is included in this distribution in +  the file called "COPYING". + +  Contact Information: +  Linux NICS <linux.nics@intel.com> +  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> +  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + +*******************************************************************************/ + +#ifndef _E1000E_ICH8LAN_H_ +#define _E1000E_ICH8LAN_H_ + +#define ICH_FLASH_GFPREG		0x0000 +#define ICH_FLASH_HSFSTS		0x0004 +#define ICH_FLASH_HSFCTL		0x0006 +#define ICH_FLASH_FADDR			0x0008 +#define ICH_FLASH_FDATA0		0x0010 +#define ICH_FLASH_PR0			0x0074 + +/* Requires up to 10 seconds when MNG might be accessing part. */ +#define ICH_FLASH_READ_COMMAND_TIMEOUT	10000000 +#define ICH_FLASH_WRITE_COMMAND_TIMEOUT	10000000 +#define ICH_FLASH_ERASE_COMMAND_TIMEOUT	10000000 +#define ICH_FLASH_LINEAR_ADDR_MASK	0x00FFFFFF +#define ICH_FLASH_CYCLE_REPEAT_COUNT	10 + +#define ICH_CYCLE_READ			0 +#define ICH_CYCLE_WRITE			2 +#define ICH_CYCLE_ERASE			3 + +#define FLASH_GFPREG_BASE_MASK		0x1FFF +#define FLASH_SECTOR_ADDR_SHIFT		12 + +#define ICH_FLASH_SEG_SIZE_256		256 +#define ICH_FLASH_SEG_SIZE_4K		4096 +#define ICH_FLASH_SEG_SIZE_8K		8192 +#define ICH_FLASH_SEG_SIZE_64K		65536 + +#define E1000_ICH_FWSM_RSPCIPHY	0x00000040	/* Reset PHY on PCI Reset */ +/* FW established a valid mode */ +#define E1000_ICH_FWSM_FW_VALID	0x00008000 +#define E1000_ICH_FWSM_PCIM2PCI	0x01000000	/* ME PCIm-to-PCI active */ +#define E1000_ICH_FWSM_PCIM2PCI_COUNT	2000 + +#define E1000_ICH_MNG_IAMT_MODE		0x2 + +#define E1000_FWSM_WLOCK_MAC_MASK	0x0380 +#define E1000_FWSM_WLOCK_MAC_SHIFT	7 + +/* Shared Receive Address Registers */ +#define E1000_SHRAL_PCH_LPT(_i)		(0x05408 + ((_i) * 8)) +#define E1000_SHRAH_PCH_LPT(_i)		(0x0540C + ((_i) * 8)) + +#define ID_LED_DEFAULT_ICH8LAN	((ID_LED_DEF1_DEF2 << 12) | \ +				 (ID_LED_OFF1_OFF2 <<  8) | \ +				 (ID_LED_OFF1_ON2  <<  4) | \ +				 (ID_LED_DEF1_DEF2)) + +#define E1000_ICH_NVM_SIG_WORD		0x13 +#define E1000_ICH_NVM_SIG_MASK		0xC000 +#define E1000_ICH_NVM_VALID_SIG_MASK	0xC0 +#define E1000_ICH_NVM_SIG_VALUE		0x80 + +#define E1000_ICH8_LAN_INIT_TIMEOUT	1500 + +#define E1000_FEXTNVM_SW_CONFIG		1 +#define E1000_FEXTNVM_SW_CONFIG_ICH8M	(1 << 27)	/* different on ICH8M */ + +#define E1000_FEXTNVM3_PHY_CFG_COUNTER_MASK	0x0C000000 +#define E1000_FEXTNVM3_PHY_CFG_COUNTER_50MSEC	0x08000000 + +#define E1000_FEXTNVM4_BEACON_DURATION_MASK	0x7 +#define E1000_FEXTNVM4_BEACON_DURATION_8USEC	0x7 +#define E1000_FEXTNVM4_BEACON_DURATION_16USEC	0x3 + +#define PCIE_ICH8_SNOOP_ALL	PCIE_NO_SNOOP_ALL + +#define E1000_ICH_RAR_ENTRIES	7 +#define E1000_PCH2_RAR_ENTRIES	5	/* RAR[0], SHRA[0-3] */ +#define E1000_PCH_LPT_RAR_ENTRIES	12	/* RAR[0], SHRA[0-10] */ + +#define PHY_PAGE_SHIFT		5 +#define PHY_REG(page, reg)	(((page) << PHY_PAGE_SHIFT) | \ +				 ((reg) & MAX_PHY_REG_ADDRESS)) +#define IGP3_KMRN_DIAG	PHY_REG(770, 19)	/* KMRN Diagnostic */ +#define IGP3_VR_CTRL	PHY_REG(776, 18)	/* Voltage Regulator Control */ + +#define IGP3_KMRN_DIAG_PCS_LOCK_LOSS		0x0002 +#define IGP3_VR_CTRL_DEV_POWERDOWN_MODE_MASK	0x0300 +#define IGP3_VR_CTRL_MODE_SHUTDOWN		0x0200 + +/* PHY Wakeup Registers and defines */ +#define BM_PORT_GEN_CFG		PHY_REG(BM_PORT_CTRL_PAGE, 17) +#define BM_RCTL			PHY_REG(BM_WUC_PAGE, 0) +#define BM_WUC			PHY_REG(BM_WUC_PAGE, 1) +#define BM_WUFC			PHY_REG(BM_WUC_PAGE, 2) +#define BM_WUS			PHY_REG(BM_WUC_PAGE, 3) +#define BM_RAR_L(_i)		(BM_PHY_REG(BM_WUC_PAGE, 16 + ((_i) << 2))) +#define BM_RAR_M(_i)		(BM_PHY_REG(BM_WUC_PAGE, 17 + ((_i) << 2))) +#define BM_RAR_H(_i)		(BM_PHY_REG(BM_WUC_PAGE, 18 + ((_i) << 2))) +#define BM_RAR_CTRL(_i)		(BM_PHY_REG(BM_WUC_PAGE, 19 + ((_i) << 2))) +#define BM_MTA(_i)		(BM_PHY_REG(BM_WUC_PAGE, 128 + ((_i) << 1))) + +#define BM_RCTL_UPE		0x0001	/* Unicast Promiscuous Mode */ +#define BM_RCTL_MPE		0x0002	/* Multicast Promiscuous Mode */ +#define BM_RCTL_MO_SHIFT	3	/* Multicast Offset Shift */ +#define BM_RCTL_MO_MASK		(3 << 3)	/* Multicast Offset Mask */ +#define BM_RCTL_BAM		0x0020	/* Broadcast Accept Mode */ +#define BM_RCTL_PMCF		0x0040	/* Pass MAC Control Frames */ +#define BM_RCTL_RFCE		0x0080	/* Rx Flow Control Enable */ + +#define HV_LED_CONFIG		PHY_REG(768, 30)	/* LED Configuration */ +#define HV_MUX_DATA_CTRL	PHY_REG(776, 16) +#define HV_MUX_DATA_CTRL_GEN_TO_MAC	0x0400 +#define HV_MUX_DATA_CTRL_FORCE_SPEED	0x0004 +#define HV_STATS_PAGE	778 +/* Half-duplex collision counts */ +#define HV_SCC_UPPER	PHY_REG(HV_STATS_PAGE, 16)	/* Single Collision */ +#define HV_SCC_LOWER	PHY_REG(HV_STATS_PAGE, 17) +#define HV_ECOL_UPPER	PHY_REG(HV_STATS_PAGE, 18)	/* Excessive Coll. */ +#define HV_ECOL_LOWER	PHY_REG(HV_STATS_PAGE, 19) +#define HV_MCC_UPPER	PHY_REG(HV_STATS_PAGE, 20)	/* Multiple Collision */ +#define HV_MCC_LOWER	PHY_REG(HV_STATS_PAGE, 21) +#define HV_LATECOL_UPPER PHY_REG(HV_STATS_PAGE, 23)	/* Late Collision */ +#define HV_LATECOL_LOWER PHY_REG(HV_STATS_PAGE, 24) +#define HV_COLC_UPPER	PHY_REG(HV_STATS_PAGE, 25)	/* Collision */ +#define HV_COLC_LOWER	PHY_REG(HV_STATS_PAGE, 26) +#define HV_DC_UPPER	PHY_REG(HV_STATS_PAGE, 27)	/* Defer Count */ +#define HV_DC_LOWER	PHY_REG(HV_STATS_PAGE, 28) +#define HV_TNCRS_UPPER	PHY_REG(HV_STATS_PAGE, 29)	/* Tx with no CRS */ +#define HV_TNCRS_LOWER	PHY_REG(HV_STATS_PAGE, 30) + +#define E1000_FCRTV_PCH	0x05F40	/* PCH Flow Control Refresh Timer Value */ + +#define E1000_NVM_K1_CONFIG	0x1B	/* NVM K1 Config Word */ +#define E1000_NVM_K1_ENABLE	0x1	/* NVM Enable K1 bit */ + +/* SMBus Control Phy Register */ +#define CV_SMB_CTRL		PHY_REG(769, 23) +#define CV_SMB_CTRL_FORCE_SMBUS	0x0001 + +/* SMBus Address Phy Register */ +#define HV_SMB_ADDR		PHY_REG(768, 26) +#define HV_SMB_ADDR_MASK	0x007F +#define HV_SMB_ADDR_PEC_EN	0x0200 +#define HV_SMB_ADDR_VALID	0x0080 +#define HV_SMB_ADDR_FREQ_MASK		0x1100 +#define HV_SMB_ADDR_FREQ_LOW_SHIFT	8 +#define HV_SMB_ADDR_FREQ_HIGH_SHIFT	12 + +/* Strapping Option Register - RO */ +#define E1000_STRAP			0x0000C +#define E1000_STRAP_SMBUS_ADDRESS_MASK	0x00FE0000 +#define E1000_STRAP_SMBUS_ADDRESS_SHIFT	17 +#define E1000_STRAP_SMT_FREQ_MASK	0x00003000 +#define E1000_STRAP_SMT_FREQ_SHIFT	12 + +/* OEM Bits Phy Register */ +#define HV_OEM_BITS		PHY_REG(768, 25) +#define HV_OEM_BITS_LPLU	0x0004	/* Low Power Link Up */ +#define HV_OEM_BITS_GBE_DIS	0x0040	/* Gigabit Disable */ +#define HV_OEM_BITS_RESTART_AN	0x0400	/* Restart Auto-negotiation */ + +/* KMRN Mode Control */ +#define HV_KMRN_MODE_CTRL	PHY_REG(769, 16) +#define HV_KMRN_MDIO_SLOW	0x0400 + +/* KMRN FIFO Control and Status */ +#define HV_KMRN_FIFO_CTRLSTA			PHY_REG(770, 16) +#define HV_KMRN_FIFO_CTRLSTA_PREAMBLE_MASK	0x7000 +#define HV_KMRN_FIFO_CTRLSTA_PREAMBLE_SHIFT	12 + +/* PHY Power Management Control */ +#define HV_PM_CTRL		PHY_REG(770, 17) +#define HV_PM_CTRL_PLL_STOP_IN_K1_GIGA	0x100 + +#define SW_FLAG_TIMEOUT		1000	/* SW Semaphore flag timeout in ms */ + +/* PHY Low Power Idle Control */ +#define I82579_LPI_CTRL				PHY_REG(772, 20) +#define I82579_LPI_CTRL_100_ENABLE		0x2000 +#define I82579_LPI_CTRL_1000_ENABLE		0x4000 +#define I82579_LPI_CTRL_ENABLE_MASK		0x6000 +#define I82579_LPI_CTRL_FORCE_PLL_LOCK_COUNT	0x80 + +/* Extended Management Interface (EMI) Registers */ +#define I82579_EMI_ADDR		0x10 +#define I82579_EMI_DATA		0x11 +#define I82579_LPI_UPDATE_TIMER	0x4805	/* in 40ns units + 40 ns base value */ +#define I82579_MSE_THRESHOLD	0x084F	/* 82579 Mean Square Error Threshold */ +#define I82577_MSE_THRESHOLD	0x0887	/* 82577 Mean Square Error Threshold */ +#define I82579_MSE_LINK_DOWN	0x2411	/* MSE count before dropping link */ +#define I82579_EEE_PCS_STATUS		0x182D	/* IEEE MMD Register 3.1 >> 8 */ +#define I82579_EEE_CAPABILITY		0x0410	/* IEEE MMD Register 3.20 */ +#define I82579_EEE_ADVERTISEMENT	0x040E	/* IEEE MMD Register 7.60 */ +#define I82579_EEE_LP_ABILITY		0x040F	/* IEEE MMD Register 7.61 */ +#define I82579_EEE_100_SUPPORTED	(1 << 1)	/* 100BaseTx EEE */ +#define I82579_EEE_1000_SUPPORTED	(1 << 2)	/* 1000BaseTx EEE */ +#define I217_EEE_PCS_STATUS	0x9401	/* IEEE MMD Register 3.1 */ +#define I217_EEE_CAPABILITY	0x8000	/* IEEE MMD Register 3.20 */ +#define I217_EEE_ADVERTISEMENT	0x8001	/* IEEE MMD Register 7.60 */ +#define I217_EEE_LP_ABILITY	0x8002	/* IEEE MMD Register 7.61 */ + +#define E1000_EEE_RX_LPI_RCVD	0x0400	/* Tx LP idle received */ +#define E1000_EEE_TX_LPI_RCVD	0x0800	/* Rx LP idle received */ + +/* Intel Rapid Start Technology Support */ +#define I217_PROXY_CTRL		BM_PHY_REG(BM_WUC_PAGE, 70) +#define I217_PROXY_CTRL_AUTO_DISABLE	0x0080 +#define I217_SxCTRL			PHY_REG(BM_PORT_CTRL_PAGE, 28) +#define I217_SxCTRL_ENABLE_LPI_RESET	0x1000 +#define I217_CGFREG			PHY_REG(772, 29) +#define I217_CGFREG_ENABLE_MTA_RESET	0x0002 +#define I217_MEMPWR			PHY_REG(772, 26) +#define I217_MEMPWR_DISABLE_SMB_RELEASE	0x0010 + +/* Receive Address Initial CRC Calculation */ +#define E1000_PCH_RAICC(_n)	(0x05F50 + ((_n) * 4)) + +/* Latency Tolerance Reporting */ +#define E1000_LTRV			0x000F8 +#define E1000_LTRV_SCALE_MAX		5 +#define E1000_LTRV_SCALE_FACTOR		5 +#define E1000_LTRV_REQ_SHIFT		15 +#define E1000_LTRV_NOSNOOP_SHIFT	16 +#define E1000_LTRV_SEND			(1 << 30) + +/* Proprietary Latency Tolerance Reporting PCI Capability */ +#define E1000_PCI_LTR_CAP_LPT		0xA8 + +/* OBFF Control & Threshold Defines */ +#define E1000_SVCR_OFF_EN		0x00000001 +#define E1000_SVCR_OFF_MASKINT		0x00001000 +#define E1000_SVCR_OFF_TIMER_MASK	0xFFFF0000 +#define E1000_SVCR_OFF_TIMER_SHIFT	16 +#define E1000_SVT_OFF_HWM_MASK		0x0000001F + +void e1000e_write_protect_nvm_ich8lan(struct e1000_hw *hw); +void e1000e_set_kmrn_lock_loss_workaround_ich8lan(struct e1000_hw *hw, +						  bool state); +void e1000e_igp3_phy_powerdown_workaround_ich8lan(struct e1000_hw *hw); +void e1000e_gig_downshift_workaround_ich8lan(struct e1000_hw *hw); +void e1000_suspend_workarounds_ich8lan(struct e1000_hw *hw); +void e1000_resume_workarounds_pchlan(struct e1000_hw *hw); +s32 e1000_configure_k1_ich8lan(struct e1000_hw *hw, bool k1_enable); +void e1000_copy_rx_addrs_to_phy_ich8lan(struct e1000_hw *hw); +s32 e1000_lv_jumbo_workaround_ich8lan(struct e1000_hw *hw, bool enable); +s32 e1000_read_emi_reg_locked(struct e1000_hw *hw, u16 addr, u16 *data); +#endif /* _E1000E_ICH8LAN_H_ */ diff --git a/drivers/net/ethernet/intel/e1000e/mac.c b/drivers/net/ethernet/intel/e1000e/mac.c index 54d9dafaf12..b78e0217460 100644 --- a/drivers/net/ethernet/intel/e1000e/mac.c +++ b/drivers/net/ethernet/intel/e1000e/mac.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel PRO/1000 Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -165,7 +165,7 @@ void e1000e_init_rx_addrs(struct e1000_hw *hw, u16 rar_count)  s32 e1000_check_alt_mac_addr_generic(struct e1000_hw *hw)  {  	u32 i; -	s32 ret_val = 0; +	s32 ret_val;  	u16 offset, nvm_alt_mac_addr_offset, nvm_data;  	u8 alt_mac_addr[ETH_ALEN]; @@ -1021,6 +1021,7 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw)  {  	struct e1000_mac_info *mac = &hw->mac;  	s32 ret_val = 0; +	u32 pcs_status_reg, pcs_adv_reg, pcs_lp_ability_reg, pcs_ctrl_reg;  	u16 mii_status_reg, mii_nway_adv_reg, mii_nway_lp_ability_reg;  	u16 speed, duplex; @@ -1052,14 +1053,14 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw)  		 * has completed.  We read this twice because this reg has  		 * some "sticky" (latched) bits.  		 */ -		ret_val = e1e_rphy(hw, PHY_STATUS, &mii_status_reg); +		ret_val = e1e_rphy(hw, MII_BMSR, &mii_status_reg);  		if (ret_val)  			return ret_val; -		ret_val = e1e_rphy(hw, PHY_STATUS, &mii_status_reg); +		ret_val = e1e_rphy(hw, MII_BMSR, &mii_status_reg);  		if (ret_val)  			return ret_val; -		if (!(mii_status_reg & MII_SR_AUTONEG_COMPLETE)) { +		if (!(mii_status_reg & BMSR_ANEGCOMPLETE)) {  			e_dbg("Copper PHY and Auto Neg has not completed.\n");  			return ret_val;  		} @@ -1070,11 +1071,10 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw)  		 * Page Ability Register (Address 5) to determine how  		 * flow control was negotiated.  		 */ -		ret_val = e1e_rphy(hw, PHY_AUTONEG_ADV, &mii_nway_adv_reg); +		ret_val = e1e_rphy(hw, MII_ADVERTISE, &mii_nway_adv_reg);  		if (ret_val)  			return ret_val; -		ret_val = -		    e1e_rphy(hw, PHY_LP_ABILITY, &mii_nway_lp_ability_reg); +		ret_val = e1e_rphy(hw, MII_LPA, &mii_nway_lp_ability_reg);  		if (ret_val)  			return ret_val; @@ -1111,8 +1111,8 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw)  		 *   1   |   DC    |   1   |   DC    | E1000_fc_full  		 *  		 */ -		if ((mii_nway_adv_reg & NWAY_AR_PAUSE) && -		    (mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE)) { +		if ((mii_nway_adv_reg & ADVERTISE_PAUSE_CAP) && +		    (mii_nway_lp_ability_reg & LPA_PAUSE_CAP)) {  			/* Now we need to check if the user selected Rx ONLY  			 * of pause frames.  In this case, we had to advertise  			 * FULL flow control because we could not advertise Rx @@ -1134,10 +1134,10 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw)  		 *-------|---------|-------|---------|--------------------  		 *   0   |    1    |   1   |    1    | e1000_fc_tx_pause  		 */ -		else if (!(mii_nway_adv_reg & NWAY_AR_PAUSE) && -			 (mii_nway_adv_reg & NWAY_AR_ASM_DIR) && -			 (mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) && -			 (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) { +		else if (!(mii_nway_adv_reg & ADVERTISE_PAUSE_CAP) && +			 (mii_nway_adv_reg & ADVERTISE_PAUSE_ASYM) && +			 (mii_nway_lp_ability_reg & LPA_PAUSE_CAP) && +			 (mii_nway_lp_ability_reg & LPA_PAUSE_ASYM)) {  			hw->fc.current_mode = e1000_fc_tx_pause;  			e_dbg("Flow Control = Tx PAUSE frames only.\n");  		} @@ -1148,10 +1148,10 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw)  		 *-------|---------|-------|---------|--------------------  		 *   1   |    1    |   0   |    1    | e1000_fc_rx_pause  		 */ -		else if ((mii_nway_adv_reg & NWAY_AR_PAUSE) && -			 (mii_nway_adv_reg & NWAY_AR_ASM_DIR) && -			 !(mii_nway_lp_ability_reg & NWAY_LPAR_PAUSE) && -			 (mii_nway_lp_ability_reg & NWAY_LPAR_ASM_DIR)) { +		else if ((mii_nway_adv_reg & ADVERTISE_PAUSE_CAP) && +			 (mii_nway_adv_reg & ADVERTISE_PAUSE_ASYM) && +			 !(mii_nway_lp_ability_reg & LPA_PAUSE_CAP) && +			 (mii_nway_lp_ability_reg & LPA_PAUSE_ASYM)) {  			hw->fc.current_mode = e1000_fc_rx_pause;  			e_dbg("Flow Control = Rx PAUSE frames only.\n");  		} else { @@ -1185,6 +1185,130 @@ s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw)  		}  	} +	/* Check for the case where we have SerDes media and auto-neg is +	 * enabled.  In this case, we need to check and see if Auto-Neg +	 * has completed, and if so, how the PHY and link partner has +	 * flow control configured. +	 */ +	if ((hw->phy.media_type == e1000_media_type_internal_serdes) && +	    mac->autoneg) { +		/* Read the PCS_LSTS and check to see if AutoNeg +		 * has completed. +		 */ +		pcs_status_reg = er32(PCS_LSTAT); + +		if (!(pcs_status_reg & E1000_PCS_LSTS_AN_COMPLETE)) { +			e_dbg("PCS Auto Neg has not completed.\n"); +			return ret_val; +		} + +		/* The AutoNeg process has completed, so we now need to +		 * read both the Auto Negotiation Advertisement +		 * Register (PCS_ANADV) and the Auto_Negotiation Base +		 * Page Ability Register (PCS_LPAB) to determine how +		 * flow control was negotiated. +		 */ +		pcs_adv_reg = er32(PCS_ANADV); +		pcs_lp_ability_reg = er32(PCS_LPAB); + +		/* Two bits in the Auto Negotiation Advertisement Register +		 * (PCS_ANADV) and two bits in the Auto Negotiation Base +		 * Page Ability Register (PCS_LPAB) determine flow control +		 * for both the PHY and the link partner.  The following +		 * table, taken out of the IEEE 802.3ab/D6.0 dated March 25, +		 * 1999, describes these PAUSE resolution bits and how flow +		 * control is determined based upon these settings. +		 * NOTE:  DC = Don't Care +		 * +		 *   LOCAL DEVICE  |   LINK PARTNER +		 * PAUSE | ASM_DIR | PAUSE | ASM_DIR | NIC Resolution +		 *-------|---------|-------|---------|-------------------- +		 *   0   |    0    |  DC   |   DC    | e1000_fc_none +		 *   0   |    1    |   0   |   DC    | e1000_fc_none +		 *   0   |    1    |   1   |    0    | e1000_fc_none +		 *   0   |    1    |   1   |    1    | e1000_fc_tx_pause +		 *   1   |    0    |   0   |   DC    | e1000_fc_none +		 *   1   |   DC    |   1   |   DC    | e1000_fc_full +		 *   1   |    1    |   0   |    0    | e1000_fc_none +		 *   1   |    1    |   0   |    1    | e1000_fc_rx_pause +		 * +		 * Are both PAUSE bits set to 1?  If so, this implies +		 * Symmetric Flow Control is enabled at both ends.  The +		 * ASM_DIR bits are irrelevant per the spec. +		 * +		 * For Symmetric Flow Control: +		 * +		 *   LOCAL DEVICE  |   LINK PARTNER +		 * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result +		 *-------|---------|-------|---------|-------------------- +		 *   1   |   DC    |   1   |   DC    | e1000_fc_full +		 * +		 */ +		if ((pcs_adv_reg & E1000_TXCW_PAUSE) && +		    (pcs_lp_ability_reg & E1000_TXCW_PAUSE)) { +			/* Now we need to check if the user selected Rx ONLY +			 * of pause frames.  In this case, we had to advertise +			 * FULL flow control because we could not advertise Rx +			 * ONLY. Hence, we must now check to see if we need to +			 * turn OFF the TRANSMISSION of PAUSE frames. +			 */ +			if (hw->fc.requested_mode == e1000_fc_full) { +				hw->fc.current_mode = e1000_fc_full; +				e_dbg("Flow Control = FULL.\n"); +			} else { +				hw->fc.current_mode = e1000_fc_rx_pause; +				e_dbg("Flow Control = Rx PAUSE frames only.\n"); +			} +		} +		/* For receiving PAUSE frames ONLY. +		 * +		 *   LOCAL DEVICE  |   LINK PARTNER +		 * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result +		 *-------|---------|-------|---------|-------------------- +		 *   0   |    1    |   1   |    1    | e1000_fc_tx_pause +		 */ +		else if (!(pcs_adv_reg & E1000_TXCW_PAUSE) && +			 (pcs_adv_reg & E1000_TXCW_ASM_DIR) && +			 (pcs_lp_ability_reg & E1000_TXCW_PAUSE) && +			 (pcs_lp_ability_reg & E1000_TXCW_ASM_DIR)) { +			hw->fc.current_mode = e1000_fc_tx_pause; +			e_dbg("Flow Control = Tx PAUSE frames only.\n"); +		} +		/* For transmitting PAUSE frames ONLY. +		 * +		 *   LOCAL DEVICE  |   LINK PARTNER +		 * PAUSE | ASM_DIR | PAUSE | ASM_DIR | Result +		 *-------|---------|-------|---------|-------------------- +		 *   1   |    1    |   0   |    1    | e1000_fc_rx_pause +		 */ +		else if ((pcs_adv_reg & E1000_TXCW_PAUSE) && +			 (pcs_adv_reg & E1000_TXCW_ASM_DIR) && +			 !(pcs_lp_ability_reg & E1000_TXCW_PAUSE) && +			 (pcs_lp_ability_reg & E1000_TXCW_ASM_DIR)) { +			hw->fc.current_mode = e1000_fc_rx_pause; +			e_dbg("Flow Control = Rx PAUSE frames only.\n"); +		} else { +			/* Per the IEEE spec, at this point flow control +			 * should be disabled. +			 */ +			hw->fc.current_mode = e1000_fc_none; +			e_dbg("Flow Control = NONE.\n"); +		} + +		/* Now we call a subroutine to actually force the MAC +		 * controller to use the correct flow control settings. +		 */ +		pcs_ctrl_reg = er32(PCS_LCTL); +		pcs_ctrl_reg |= E1000_PCS_LCTL_FORCE_FCTRL; +		ew32(PCS_LCTL, pcs_ctrl_reg); + +		ret_val = e1000e_force_mac_fc(hw); +		if (ret_val) { +			e_dbg("Error forcing flow control settings\n"); +			return ret_val; +		} +	} +  	return 0;  } @@ -1231,8 +1355,8 @@ s32 e1000e_get_speed_and_duplex_copper(struct e1000_hw *hw, u16 *speed,   *  Sets the speed and duplex to gigabit full duplex (the only possible option)   *  for fiber/serdes links.   **/ -s32 e1000e_get_speed_and_duplex_fiber_serdes(struct e1000_hw *hw, u16 *speed, -					     u16 *duplex) +s32 e1000e_get_speed_and_duplex_fiber_serdes(struct e1000_hw __always_unused +					     *hw, u16 *speed, u16 *duplex)  {  	*speed = SPEED_1000;  	*duplex = FULL_DUPLEX; diff --git a/drivers/net/ethernet/intel/e1000e/mac.h b/drivers/net/ethernet/intel/e1000e/mac.h new file mode 100644 index 00000000000..a61fee404eb --- /dev/null +++ b/drivers/net/ethernet/intel/e1000e/mac.h @@ -0,0 +1,74 @@ +/******************************************************************************* + +  Intel PRO/1000 Linux driver +  Copyright(c) 1999 - 2013 Intel Corporation. + +  This program is free software; you can redistribute it and/or modify it +  under the terms and conditions of the GNU General Public License, +  version 2, as published by the Free Software Foundation. + +  This program is distributed in the hope it will be useful, but WITHOUT +  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for +  more details. + +  You should have received a copy of the GNU General Public License along with +  this program; if not, write to the Free Software Foundation, Inc., +  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + +  The full GNU General Public License is included in this distribution in +  the file called "COPYING". + +  Contact Information: +  Linux NICS <linux.nics@intel.com> +  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> +  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + +*******************************************************************************/ + +#ifndef _E1000E_MAC_H_ +#define _E1000E_MAC_H_ + +s32 e1000e_blink_led_generic(struct e1000_hw *hw); +s32 e1000e_check_for_copper_link(struct e1000_hw *hw); +s32 e1000e_check_for_fiber_link(struct e1000_hw *hw); +s32 e1000e_check_for_serdes_link(struct e1000_hw *hw); +s32 e1000e_cleanup_led_generic(struct e1000_hw *hw); +s32 e1000e_config_fc_after_link_up(struct e1000_hw *hw); +s32 e1000e_disable_pcie_master(struct e1000_hw *hw); +s32 e1000e_force_mac_fc(struct e1000_hw *hw); +s32 e1000e_get_auto_rd_done(struct e1000_hw *hw); +s32 e1000e_get_bus_info_pcie(struct e1000_hw *hw); +void e1000_set_lan_id_single_port(struct e1000_hw *hw); +s32 e1000e_get_hw_semaphore(struct e1000_hw *hw); +s32 e1000e_get_speed_and_duplex_copper(struct e1000_hw *hw, u16 *speed, +				       u16 *duplex); +s32 e1000e_get_speed_and_duplex_fiber_serdes(struct e1000_hw *hw, +					     u16 *speed, u16 *duplex); +s32 e1000e_id_led_init_generic(struct e1000_hw *hw); +s32 e1000e_led_on_generic(struct e1000_hw *hw); +s32 e1000e_led_off_generic(struct e1000_hw *hw); +void e1000e_update_mc_addr_list_generic(struct e1000_hw *hw, +					u8 *mc_addr_list, u32 mc_addr_count); +s32 e1000e_set_fc_watermarks(struct e1000_hw *hw); +s32 e1000e_setup_fiber_serdes_link(struct e1000_hw *hw); +s32 e1000e_setup_led_generic(struct e1000_hw *hw); +s32 e1000e_setup_link_generic(struct e1000_hw *hw); +s32 e1000e_validate_mdi_setting_generic(struct e1000_hw *hw); +s32 e1000e_validate_mdi_setting_crossover_generic(struct e1000_hw *hw); + +void e1000e_clear_hw_cntrs_base(struct e1000_hw *hw); +void e1000_clear_vfta_generic(struct e1000_hw *hw); +void e1000e_init_rx_addrs(struct e1000_hw *hw, u16 rar_count); +void e1000e_put_hw_semaphore(struct e1000_hw *hw); +s32 e1000_check_alt_mac_addr_generic(struct e1000_hw *hw); +void e1000e_reset_adaptive(struct e1000_hw *hw); +void e1000e_set_pcie_no_snoop(struct e1000_hw *hw, u32 no_snoop); +void e1000e_update_adaptive(struct e1000_hw *hw); +void e1000_write_vfta_generic(struct e1000_hw *hw, u32 offset, u32 value); + +void e1000_set_lan_id_multi_port_pcie(struct e1000_hw *hw); +void e1000e_rar_set_generic(struct e1000_hw *hw, u8 *addr, u32 index); +void e1000e_config_collision_dist_generic(struct e1000_hw *hw); + +#endif diff --git a/drivers/net/ethernet/intel/e1000e/manage.c b/drivers/net/ethernet/intel/e1000e/manage.c index 6dc47beb3ad..e4b0f1ef92f 100644 --- a/drivers/net/ethernet/intel/e1000e/manage.c +++ b/drivers/net/ethernet/intel/e1000e/manage.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel PRO/1000 Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -28,19 +28,6 @@  #include "e1000.h" -enum e1000_mng_mode { -	e1000_mng_mode_none = 0, -	e1000_mng_mode_asf, -	e1000_mng_mode_pt, -	e1000_mng_mode_ipmi, -	e1000_mng_mode_host_if_only -}; - -#define E1000_FACTPS_MNGCG		0x20000000 - -/* Intel(R) Active Management Technology signature */ -#define E1000_IAMT_SIGNATURE		0x544D4149 -  /**   *  e1000_calculate_checksum - Calculate checksum for buffer   *  @buffer: pointer to EEPROM diff --git a/drivers/net/ethernet/intel/e1000e/manage.h b/drivers/net/ethernet/intel/e1000e/manage.h new file mode 100644 index 00000000000..326897c29ea --- /dev/null +++ b/drivers/net/ethernet/intel/e1000e/manage.h @@ -0,0 +1,72 @@ +/******************************************************************************* + +  Intel PRO/1000 Linux driver +  Copyright(c) 1999 - 2013 Intel Corporation. + +  This program is free software; you can redistribute it and/or modify it +  under the terms and conditions of the GNU General Public License, +  version 2, as published by the Free Software Foundation. + +  This program is distributed in the hope it will be useful, but WITHOUT +  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for +  more details. + +  You should have received a copy of the GNU General Public License along with +  this program; if not, write to the Free Software Foundation, Inc., +  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + +  The full GNU General Public License is included in this distribution in +  the file called "COPYING". + +  Contact Information: +  Linux NICS <linux.nics@intel.com> +  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> +  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + +*******************************************************************************/ + +#ifndef _E1000E_MANAGE_H_ +#define _E1000E_MANAGE_H_ + +bool e1000e_check_mng_mode_generic(struct e1000_hw *hw); +bool e1000e_enable_tx_pkt_filtering(struct e1000_hw *hw); +s32 e1000e_mng_write_dhcp_info(struct e1000_hw *hw, u8 *buffer, u16 length); +bool e1000e_enable_mng_pass_thru(struct e1000_hw *hw); + +enum e1000_mng_mode { +	e1000_mng_mode_none = 0, +	e1000_mng_mode_asf, +	e1000_mng_mode_pt, +	e1000_mng_mode_ipmi, +	e1000_mng_mode_host_if_only +}; + +#define E1000_FACTPS_MNGCG			0x20000000 + +#define E1000_FWSM_MODE_MASK			0xE +#define E1000_FWSM_MODE_SHIFT			1 + +#define E1000_MNG_IAMT_MODE			0x3 +#define E1000_MNG_DHCP_COOKIE_LENGTH		0x10 +#define E1000_MNG_DHCP_COOKIE_OFFSET		0x6F0 +#define E1000_MNG_DHCP_COMMAND_TIMEOUT		10 +#define E1000_MNG_DHCP_TX_PAYLOAD_CMD		64 +#define E1000_MNG_DHCP_COOKIE_STATUS_PARSING	0x1 +#define E1000_MNG_DHCP_COOKIE_STATUS_VLAN	0x2 + +#define E1000_VFTA_ENTRY_SHIFT			5 +#define E1000_VFTA_ENTRY_MASK			0x7F +#define E1000_VFTA_ENTRY_BIT_SHIFT_MASK		0x1F + +#define E1000_HICR_EN			0x01	/* Enable bit - RO */ +/* Driver sets this bit when done to put command in RAM */ +#define E1000_HICR_C			0x02 +#define E1000_HICR_SV			0x04	/* Status Validity */ +#define E1000_HICR_FW_RESET_ENABLE	0x40 +#define E1000_HICR_FW_RESET		0x80 + +/* Intel(R) Active Management Technology signature */ +#define E1000_IAMT_SIGNATURE		0x544D4149 + +#endif diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index fbf75fdca99..a177b8b65c4 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel PRO/1000 Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -42,7 +42,6 @@  #include <linux/slab.h>  #include <net/checksum.h>  #include <net/ip6_checksum.h> -#include <linux/mii.h>  #include <linux/ethtool.h>  #include <linux/if_vlan.h>  #include <linux/cpu.h> @@ -56,7 +55,7 @@  #define DRV_EXTRAVERSION "-k" -#define DRV_VERSION "2.1.4" DRV_EXTRAVERSION +#define DRV_VERSION "2.2.14" DRV_EXTRAVERSION  char e1000e_driver_name[] = "e1000e";  const char e1000e_driver_version[] = DRV_VERSION; @@ -87,20 +86,7 @@ struct e1000_reg_info {  	char *name;  }; -#define E1000_RDFH	0x02410	/* Rx Data FIFO Head - RW */ -#define E1000_RDFT	0x02418	/* Rx Data FIFO Tail - RW */ -#define E1000_RDFHS	0x02420	/* Rx Data FIFO Head Saved - RW */ -#define E1000_RDFTS	0x02428	/* Rx Data FIFO Tail Saved - RW */ -#define E1000_RDFPC	0x02430	/* Rx Data FIFO Packet Count - RW */ - -#define E1000_TDFH	0x03410	/* Tx Data FIFO Head - RW */ -#define E1000_TDFT	0x03418	/* Tx Data FIFO Tail - RW */ -#define E1000_TDFHS	0x03420	/* Tx Data FIFO Head Saved - RW */ -#define E1000_TDFTS	0x03428	/* Tx Data FIFO Tail Saved - RW */ -#define E1000_TDFPC	0x03430	/* Tx Data FIFO Packet Count - RW */ -  static const struct e1000_reg_info e1000_reg_info_tbl[] = { -  	/* General Registers */  	{E1000_CTRL, "CTRL"},  	{E1000_STATUS, "STATUS"}, @@ -488,20 +474,87 @@ static int e1000_desc_unused(struct e1000_ring *ring)  }  /** + * e1000e_systim_to_hwtstamp - convert system time value to hw time stamp + * @adapter: board private structure + * @hwtstamps: time stamp structure to update + * @systim: unsigned 64bit system time value. + * + * Convert the system time value stored in the RX/TXSTMP registers into a + * hwtstamp which can be used by the upper level time stamping functions. + * + * The 'systim_lock' spinlock is used to protect the consistency of the + * system time value. This is needed because reading the 64 bit time + * value involves reading two 32 bit registers. The first read latches the + * value. + **/ +static void e1000e_systim_to_hwtstamp(struct e1000_adapter *adapter, +				      struct skb_shared_hwtstamps *hwtstamps, +				      u64 systim) +{ +	u64 ns; +	unsigned long flags; + +	spin_lock_irqsave(&adapter->systim_lock, flags); +	ns = timecounter_cyc2time(&adapter->tc, systim); +	spin_unlock_irqrestore(&adapter->systim_lock, flags); + +	memset(hwtstamps, 0, sizeof(*hwtstamps)); +	hwtstamps->hwtstamp = ns_to_ktime(ns); +} + +/** + * e1000e_rx_hwtstamp - utility function which checks for Rx time stamp + * @adapter: board private structure + * @status: descriptor extended error and status field + * @skb: particular skb to include time stamp + * + * If the time stamp is valid, convert it into the timecounter ns value + * and store that result into the shhwtstamps structure which is passed + * up the network stack. + **/ +static void e1000e_rx_hwtstamp(struct e1000_adapter *adapter, u32 status, +			       struct sk_buff *skb) +{ +	struct e1000_hw *hw = &adapter->hw; +	u64 rxstmp; + +	if (!(adapter->flags & FLAG_HAS_HW_TIMESTAMP) || +	    !(status & E1000_RXDEXT_STATERR_TST) || +	    !(er32(TSYNCRXCTL) & E1000_TSYNCRXCTL_VALID)) +		return; + +	/* The Rx time stamp registers contain the time stamp.  No other +	 * received packet will be time stamped until the Rx time stamp +	 * registers are read.  Because only one packet can be time stamped +	 * at a time, the register values must belong to this packet and +	 * therefore none of the other additional attributes need to be +	 * compared. +	 */ +	rxstmp = (u64)er32(RXSTMPL); +	rxstmp |= (u64)er32(RXSTMPH) << 32; +	e1000e_systim_to_hwtstamp(adapter, skb_hwtstamps(skb), rxstmp); + +	adapter->flags2 &= ~FLAG2_CHECK_RX_HWTSTAMP; +} + +/**   * e1000_receive_skb - helper function to handle Rx indications   * @adapter: board private structure - * @status: descriptor status field as written by hardware + * @staterr: descriptor extended error and status field as written by hardware   * @vlan: descriptor vlan field as written by hardware (no le/be conversion)   * @skb: pointer to sk_buff to be indicated to stack   **/  static void e1000_receive_skb(struct e1000_adapter *adapter,  			      struct net_device *netdev, struct sk_buff *skb, -			      u8 status, __le16 vlan) +			      u32 staterr, __le16 vlan)  {  	u16 tag = le16_to_cpu(vlan); + +	e1000e_rx_hwtstamp(adapter, staterr, skb); +  	skb->protocol = eth_type_trans(skb, netdev); -	if (status & E1000_RXD_STAT_VP) +	if (staterr & E1000_RXD_STAT_VP)  		__vlan_hwaccel_put_tag(skb, tag);  	napi_gro_receive(&adapter->napi, skb); @@ -765,7 +818,7 @@ static void e1000_alloc_jumbo_rx_buffers(struct e1000_ring *rx_ring,  	struct e1000_buffer *buffer_info;  	struct sk_buff *skb;  	unsigned int i; -	unsigned int bufsz = 256 - 16 /* for skb_reserve */; +	unsigned int bufsz = 256 - 16;	/* for skb_reserve */  	i = rx_ring->next_to_use;  	buffer_info = &rx_ring->buffer_info[i]; @@ -1050,9 +1103,9 @@ static void e1000_print_hw_hang(struct work_struct *work)  	adapter->tx_hang_recheck = false;  	netif_stop_queue(netdev); -	e1e_rphy(hw, PHY_STATUS, &phy_status); -	e1e_rphy(hw, PHY_1000T_STATUS, &phy_1000t_status); -	e1e_rphy(hw, PHY_EXT_STATUS, &phy_ext_status); +	e1e_rphy(hw, MII_BMSR, &phy_status); +	e1e_rphy(hw, MII_STAT1000, &phy_1000t_status); +	e1e_rphy(hw, MII_ESTATUS, &phy_ext_status);  	pci_read_config_word(adapter->pdev, PCI_STATUS, &pci_status); @@ -1092,6 +1145,41 @@ static void e1000_print_hw_hang(struct work_struct *work)  }  /** + * e1000e_tx_hwtstamp_work - check for Tx time stamp + * @work: pointer to work struct + * + * This work function polls the TSYNCTXCTL valid bit to determine when a + * timestamp has been taken for the current stored skb.  The timestamp must + * be for this skb because only one such packet is allowed in the queue. + */ +static void e1000e_tx_hwtstamp_work(struct work_struct *work) +{ +	struct e1000_adapter *adapter = container_of(work, struct e1000_adapter, +						     tx_hwtstamp_work); +	struct e1000_hw *hw = &adapter->hw; + +	if (!adapter->tx_hwtstamp_skb) +		return; + +	if (er32(TSYNCTXCTL) & E1000_TSYNCTXCTL_VALID) { +		struct skb_shared_hwtstamps shhwtstamps; +		u64 txstmp; + +		txstmp = er32(TXSTMPL); +		txstmp |= (u64)er32(TXSTMPH) << 32; + +		e1000e_systim_to_hwtstamp(adapter, &shhwtstamps, txstmp); + +		skb_tstamp_tx(adapter->tx_hwtstamp_skb, &shhwtstamps); +		dev_kfree_skb_any(adapter->tx_hwtstamp_skb); +		adapter->tx_hwtstamp_skb = NULL; +	} else { +		/* reschedule to check later */ +		schedule_work(&adapter->tx_hwtstamp_work); +	} +} + +/**   * e1000_clean_tx_irq - Reclaim resources after transmit completes   * @tx_ring: Tx descriptor ring   * @@ -1345,8 +1433,8 @@ copydone:  			   cpu_to_le16(E1000_RXDPS_HDRSTAT_HDRSP))  			adapter->rx_hdr_split++; -		e1000_receive_skb(adapter, netdev, skb, -				  staterr, rx_desc->wb.middle.vlan); +		e1000_receive_skb(adapter, netdev, skb, staterr, +				  rx_desc->wb.middle.vlan);  next_desc:  		rx_desc->wb.middle.status_error &= cpu_to_le32(~0xFF); @@ -1645,7 +1733,7 @@ static void e1000e_downshift_workaround(struct work_struct *work)   * @irq: interrupt number   * @data: pointer to a network interface device structure   **/ -static irqreturn_t e1000_intr_msi(int irq, void *data) +static irqreturn_t e1000_intr_msi(int __always_unused irq, void *data)  {  	struct net_device *netdev = data;  	struct e1000_adapter *adapter = netdev_priv(netdev); @@ -1671,13 +1759,30 @@ static irqreturn_t e1000_intr_msi(int irq, void *data)  			/* disable receives */  			u32 rctl = er32(RCTL);  			ew32(RCTL, rctl & ~E1000_RCTL_EN); -			adapter->flags |= FLAG_RX_RESTART_NOW; +			adapter->flags |= FLAG_RESTART_NOW;  		}  		/* guard against interrupt when we're going down */  		if (!test_bit(__E1000_DOWN, &adapter->state))  			mod_timer(&adapter->watchdog_timer, jiffies + 1);  	} +	/* Reset on uncorrectable ECC error */ +	if ((icr & E1000_ICR_ECCER) && (hw->mac.type == e1000_pch_lpt)) { +		u32 pbeccsts = er32(PBECCSTS); + +		adapter->corr_errors += +		    pbeccsts & E1000_PBECCSTS_CORR_ERR_CNT_MASK; +		adapter->uncorr_errors += +		    (pbeccsts & E1000_PBECCSTS_UNCORR_ERR_CNT_MASK) >> +		    E1000_PBECCSTS_UNCORR_ERR_CNT_SHIFT; + +		/* Do the reset outside of interrupt context */ +		schedule_work(&adapter->reset_task); + +		/* return immediately since reset is imminent */ +		return IRQ_HANDLED; +	} +  	if (napi_schedule_prep(&adapter->napi)) {  		adapter->total_tx_bytes = 0;  		adapter->total_tx_packets = 0; @@ -1694,7 +1799,7 @@ static irqreturn_t e1000_intr_msi(int irq, void *data)   * @irq: interrupt number   * @data: pointer to a network interface device structure   **/ -static irqreturn_t e1000_intr(int irq, void *data) +static irqreturn_t e1000_intr(int __always_unused irq, void *data)  {  	struct net_device *netdev = data;  	struct e1000_adapter *adapter = netdev_priv(netdev); @@ -1734,13 +1839,30 @@ static irqreturn_t e1000_intr(int irq, void *data)  			/* disable receives */  			rctl = er32(RCTL);  			ew32(RCTL, rctl & ~E1000_RCTL_EN); -			adapter->flags |= FLAG_RX_RESTART_NOW; +			adapter->flags |= FLAG_RESTART_NOW;  		}  		/* guard against interrupt when we're going down */  		if (!test_bit(__E1000_DOWN, &adapter->state))  			mod_timer(&adapter->watchdog_timer, jiffies + 1);  	} +	/* Reset on uncorrectable ECC error */ +	if ((icr & E1000_ICR_ECCER) && (hw->mac.type == e1000_pch_lpt)) { +		u32 pbeccsts = er32(PBECCSTS); + +		adapter->corr_errors += +		    pbeccsts & E1000_PBECCSTS_CORR_ERR_CNT_MASK; +		adapter->uncorr_errors += +		    (pbeccsts & E1000_PBECCSTS_UNCORR_ERR_CNT_MASK) >> +		    E1000_PBECCSTS_UNCORR_ERR_CNT_SHIFT; + +		/* Do the reset outside of interrupt context */ +		schedule_work(&adapter->reset_task); + +		/* return immediately since reset is imminent */ +		return IRQ_HANDLED; +	} +  	if (napi_schedule_prep(&adapter->napi)) {  		adapter->total_tx_bytes = 0;  		adapter->total_tx_packets = 0; @@ -1752,7 +1874,7 @@ static irqreturn_t e1000_intr(int irq, void *data)  	return IRQ_HANDLED;  } -static irqreturn_t e1000_msix_other(int irq, void *data) +static irqreturn_t e1000_msix_other(int __always_unused irq, void *data)  {  	struct net_device *netdev = data;  	struct e1000_adapter *adapter = netdev_priv(netdev); @@ -1784,8 +1906,7 @@ no_link_interrupt:  	return IRQ_HANDLED;  } - -static irqreturn_t e1000_intr_msix_tx(int irq, void *data) +static irqreturn_t e1000_intr_msix_tx(int __always_unused irq, void *data)  {  	struct net_device *netdev = data;  	struct e1000_adapter *adapter = netdev_priv(netdev); @@ -1803,7 +1924,7 @@ static irqreturn_t e1000_intr_msix_tx(int irq, void *data)  	return IRQ_HANDLED;  } -static irqreturn_t e1000_intr_msix_rx(int irq, void *data) +static irqreturn_t e1000_intr_msix_rx(int __always_unused irq, void *data)  {  	struct net_device *netdev = data;  	struct e1000_adapter *adapter = netdev_priv(netdev); @@ -1890,7 +2011,6 @@ static void e1000_configure_msix(struct e1000_adapter *adapter)  	ctrl_ext |= E1000_CTRL_EXT_PBA_CLR;  	/* Auto-Mask Other interrupts upon ICR read */ -#define E1000_EIAC_MASK_82574   0x01F00000  	ew32(IAM, ~E1000_EIAC_MASK_82574 | E1000_IMS_OTHER);  	ctrl_ext |= E1000_CTRL_EXT_EIAME;  	ew32(CTRL_EXT, ctrl_ext); @@ -2104,6 +2224,8 @@ static void e1000_irq_enable(struct e1000_adapter *adapter)  	if (adapter->msix_entries) {  		ew32(EIAC_82574, adapter->eiac_mask & E1000_EIAC_MASK_82574);  		ew32(IMS, adapter->eiac_mask | E1000_IMS_OTHER | E1000_IMS_LSC); +	} else if (hw->mac.type == e1000_pch_lpt) { +		ew32(IMS, IMS_ENABLE_MASK | E1000_IMS_ECCER);  	} else {  		ew32(IMS, IMS_ENABLE_MASK);  	} @@ -2358,9 +2480,7 @@ void e1000e_free_rx_resources(struct e1000_ring *rx_ring)   *      while increasing bulk throughput.  This functionality is controlled   *      by the InterruptThrottleRate module parameter.   **/ -static unsigned int e1000_update_itr(struct e1000_adapter *adapter, -				     u16 itr_setting, int packets, -				     int bytes) +static unsigned int e1000_update_itr(u16 itr_setting, int packets, int bytes)  {  	unsigned int retval = itr_setting; @@ -2405,7 +2525,6 @@ static unsigned int e1000_update_itr(struct e1000_adapter *adapter,  static void e1000_set_itr(struct e1000_adapter *adapter)  { -	struct e1000_hw *hw = &adapter->hw;  	u16 current_itr;  	u32 new_itr = adapter->itr; @@ -2421,18 +2540,16 @@ static void e1000_set_itr(struct e1000_adapter *adapter)  		goto set_itr_now;  	} -	adapter->tx_itr = e1000_update_itr(adapter, -				    adapter->tx_itr, -				    adapter->total_tx_packets, -				    adapter->total_tx_bytes); +	adapter->tx_itr = e1000_update_itr(adapter->tx_itr, +					   adapter->total_tx_packets, +					   adapter->total_tx_bytes);  	/* conservative mode (itr 3) eliminates the lowest_latency setting */  	if (adapter->itr_setting == 3 && adapter->tx_itr == lowest_latency)  		adapter->tx_itr = low_latency; -	adapter->rx_itr = e1000_update_itr(adapter, -				    adapter->rx_itr, -				    adapter->total_rx_packets, -				    adapter->total_rx_bytes); +	adapter->rx_itr = e1000_update_itr(adapter->rx_itr, +					   adapter->total_rx_packets, +					   adapter->total_rx_bytes);  	/* conservative mode (itr 3) eliminates the lowest_latency setting */  	if (adapter->itr_setting == 3 && adapter->rx_itr == lowest_latency)  		adapter->rx_itr = low_latency; @@ -2468,10 +2585,7 @@ set_itr_now:  		if (adapter->msix_entries)  			adapter->rx_ring->set_itr = 1;  		else -			if (new_itr) -				ew32(ITR, 1000000000 / (new_itr * 256)); -			else -				ew32(ITR, 0); +			e1000e_write_itr(adapter, new_itr);  	}  } @@ -3013,7 +3127,7 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter)  	ew32(RCTL, rctl);  	/* just started the receive unit, no need to restart */ -	adapter->flags &= ~FLAG_RX_RESTART_NOW; +	adapter->flags &= ~FLAG_RESTART_NOW;  }  /** @@ -3108,18 +3222,23 @@ static void e1000_configure_rx(struct e1000_adapter *adapter)  		rxcsum &= ~E1000_RXCSUM_TUOFL;  	ew32(RXCSUM, rxcsum); -	if (adapter->hw.mac.type == e1000_pch2lan) { -		/* With jumbo frames, excessive C-state transition -		 * latencies result in dropped transactions. -		 */ -		if (adapter->netdev->mtu > ETH_DATA_LEN) { +	/* With jumbo frames, excessive C-state transition latencies result +	 * in dropped transactions. +	 */ +	if (adapter->netdev->mtu > ETH_DATA_LEN) { +		u32 lat = +		    ((er32(PBA) & E1000_PBA_RXA_MASK) * 1024 - +		     adapter->max_frame_size) * 8 / 1000; + +		if (adapter->flags & FLAG_IS_ICH) {  			u32 rxdctl = er32(RXDCTL(0));  			ew32(RXDCTL(0), rxdctl | 0x3); -			pm_qos_update_request(&adapter->netdev->pm_qos_req, 55); -		} else { -			pm_qos_update_request(&adapter->netdev->pm_qos_req, -					      PM_QOS_DEFAULT_VALUE);  		} + +		pm_qos_update_request(&adapter->netdev->pm_qos_req, lat); +	} else { +		pm_qos_update_request(&adapter->netdev->pm_qos_req, +				      PM_QOS_DEFAULT_VALUE);  	}  	/* Enable Receives */ @@ -3308,6 +3427,241 @@ static void e1000e_setup_rss_hash(struct e1000_adapter *adapter)  }  /** + * e1000e_get_base_timinca - get default SYSTIM time increment attributes + * @adapter: board private structure + * @timinca: pointer to returned time increment attributes + * + * Get attributes for incrementing the System Time Register SYSTIML/H at + * the default base frequency, and set the cyclecounter shift value. + **/ +s32 e1000e_get_base_timinca(struct e1000_adapter *adapter, u32 *timinca) +{ +	struct e1000_hw *hw = &adapter->hw; +	u32 incvalue, incperiod, shift; + +	/* Make sure clock is enabled on I217 before checking the frequency */ +	if ((hw->mac.type == e1000_pch_lpt) && +	    !(er32(TSYNCTXCTL) & E1000_TSYNCTXCTL_ENABLED) && +	    !(er32(TSYNCRXCTL) & E1000_TSYNCRXCTL_ENABLED)) { +		u32 fextnvm7 = er32(FEXTNVM7); + +		if (!(fextnvm7 & (1 << 0))) { +			ew32(FEXTNVM7, fextnvm7 | (1 << 0)); +			e1e_flush(); +		} +	} + +	switch (hw->mac.type) { +	case e1000_pch2lan: +	case e1000_pch_lpt: +		/* On I217, the clock frequency is 25MHz or 96MHz as +		 * indicated by the System Clock Frequency Indication +		 */ +		if ((hw->mac.type != e1000_pch_lpt) || +		    (er32(TSYNCRXCTL) & E1000_TSYNCRXCTL_SYSCFI)) { +			/* Stable 96MHz frequency */ +			incperiod = INCPERIOD_96MHz; +			incvalue = INCVALUE_96MHz; +			shift = INCVALUE_SHIFT_96MHz; +			adapter->cc.shift = shift + INCPERIOD_SHIFT_96MHz; +			break; +		} +		/* fall-through */ +	case e1000_82574: +	case e1000_82583: +		/* Stable 25MHz frequency */ +		incperiod = INCPERIOD_25MHz; +		incvalue = INCVALUE_25MHz; +		shift = INCVALUE_SHIFT_25MHz; +		adapter->cc.shift = shift; +		break; +	default: +		return -EINVAL; +	} + +	*timinca = ((incperiod << E1000_TIMINCA_INCPERIOD_SHIFT) | +		    ((incvalue << shift) & E1000_TIMINCA_INCVALUE_MASK)); + +	return 0; +} + +/** + * e1000e_config_hwtstamp - configure the hwtstamp registers and enable/disable + * @adapter: board private structure + * + * Outgoing time stamping can be enabled and disabled. Play nice and + * disable it when requested, although it shouldn't cause any overhead + * when no packet needs it. At most one packet in the queue may be + * marked for time stamping, otherwise it would be impossible to tell + * for sure to which packet the hardware time stamp belongs. + * + * Incoming time stamping has to be configured via the hardware filters. + * Not all combinations are supported, in particular event type has to be + * specified. Matching the kind of event packet is not supported, with the + * exception of "all V2 events regardless of level 2 or 4". + **/ +static int e1000e_config_hwtstamp(struct e1000_adapter *adapter) +{ +	struct e1000_hw *hw = &adapter->hw; +	struct hwtstamp_config *config = &adapter->hwtstamp_config; +	u32 tsync_tx_ctl = E1000_TSYNCTXCTL_ENABLED; +	u32 tsync_rx_ctl = E1000_TSYNCRXCTL_ENABLED; +	u32 rxmtrl = 0; +	u16 rxudp = 0; +	bool is_l4 = false; +	bool is_l2 = false; +	u32 regval; +	s32 ret_val; + +	if (!(adapter->flags & FLAG_HAS_HW_TIMESTAMP)) +		return -EINVAL; + +	/* flags reserved for future extensions - must be zero */ +	if (config->flags) +		return -EINVAL; + +	switch (config->tx_type) { +	case HWTSTAMP_TX_OFF: +		tsync_tx_ctl = 0; +		break; +	case HWTSTAMP_TX_ON: +		break; +	default: +		return -ERANGE; +	} + +	switch (config->rx_filter) { +	case HWTSTAMP_FILTER_NONE: +		tsync_rx_ctl = 0; +		break; +	case HWTSTAMP_FILTER_PTP_V1_L4_SYNC: +		tsync_rx_ctl |= E1000_TSYNCRXCTL_TYPE_L4_V1; +		rxmtrl = E1000_RXMTRL_PTP_V1_SYNC_MESSAGE; +		is_l4 = true; +		break; +	case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ: +		tsync_rx_ctl |= E1000_TSYNCRXCTL_TYPE_L4_V1; +		rxmtrl = E1000_RXMTRL_PTP_V1_DELAY_REQ_MESSAGE; +		is_l4 = true; +		break; +	case HWTSTAMP_FILTER_PTP_V2_L2_SYNC: +		/* Also time stamps V2 L2 Path Delay Request/Response */ +		tsync_rx_ctl |= E1000_TSYNCRXCTL_TYPE_L2_V2; +		rxmtrl = E1000_RXMTRL_PTP_V2_SYNC_MESSAGE; +		is_l2 = true; +		break; +	case HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ: +		/* Also time stamps V2 L2 Path Delay Request/Response. */ +		tsync_rx_ctl |= E1000_TSYNCRXCTL_TYPE_L2_V2; +		rxmtrl = E1000_RXMTRL_PTP_V2_DELAY_REQ_MESSAGE; +		is_l2 = true; +		break; +	case HWTSTAMP_FILTER_PTP_V2_L4_SYNC: +		/* Hardware cannot filter just V2 L4 Sync messages; +		 * fall-through to V2 (both L2 and L4) Sync. +		 */ +	case HWTSTAMP_FILTER_PTP_V2_SYNC: +		/* Also time stamps V2 Path Delay Request/Response. */ +		tsync_rx_ctl |= E1000_TSYNCRXCTL_TYPE_L2_L4_V2; +		rxmtrl = E1000_RXMTRL_PTP_V2_SYNC_MESSAGE; +		is_l2 = true; +		is_l4 = true; +		break; +	case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ: +		/* Hardware cannot filter just V2 L4 Delay Request messages; +		 * fall-through to V2 (both L2 and L4) Delay Request. +		 */ +	case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ: +		/* Also time stamps V2 Path Delay Request/Response. */ +		tsync_rx_ctl |= E1000_TSYNCRXCTL_TYPE_L2_L4_V2; +		rxmtrl = E1000_RXMTRL_PTP_V2_DELAY_REQ_MESSAGE; +		is_l2 = true; +		is_l4 = true; +		break; +	case HWTSTAMP_FILTER_PTP_V2_L4_EVENT: +	case HWTSTAMP_FILTER_PTP_V2_L2_EVENT: +		/* Hardware cannot filter just V2 L4 or L2 Event messages; +		 * fall-through to all V2 (both L2 and L4) Events. +		 */ +	case HWTSTAMP_FILTER_PTP_V2_EVENT: +		tsync_rx_ctl |= E1000_TSYNCRXCTL_TYPE_EVENT_V2; +		config->rx_filter = HWTSTAMP_FILTER_PTP_V2_EVENT; +		is_l2 = true; +		is_l4 = true; +		break; +	case HWTSTAMP_FILTER_PTP_V1_L4_EVENT: +		/* For V1, the hardware can only filter Sync messages or +		 * Delay Request messages but not both so fall-through to +		 * time stamp all packets. +		 */ +	case HWTSTAMP_FILTER_ALL: +		is_l2 = true; +		is_l4 = true; +		tsync_rx_ctl |= E1000_TSYNCRXCTL_TYPE_ALL; +		config->rx_filter = HWTSTAMP_FILTER_ALL; +		break; +	default: +		return -ERANGE; +	} + +	/* enable/disable Tx h/w time stamping */ +	regval = er32(TSYNCTXCTL); +	regval &= ~E1000_TSYNCTXCTL_ENABLED; +	regval |= tsync_tx_ctl; +	ew32(TSYNCTXCTL, regval); +	if ((er32(TSYNCTXCTL) & E1000_TSYNCTXCTL_ENABLED) != +	    (regval & E1000_TSYNCTXCTL_ENABLED)) { +		e_err("Timesync Tx Control register not set as expected\n"); +		return -EAGAIN; +	} + +	/* enable/disable Rx h/w time stamping */ +	regval = er32(TSYNCRXCTL); +	regval &= ~(E1000_TSYNCRXCTL_ENABLED | E1000_TSYNCRXCTL_TYPE_MASK); +	regval |= tsync_rx_ctl; +	ew32(TSYNCRXCTL, regval); +	if ((er32(TSYNCRXCTL) & (E1000_TSYNCRXCTL_ENABLED | +				 E1000_TSYNCRXCTL_TYPE_MASK)) != +	    (regval & (E1000_TSYNCRXCTL_ENABLED | +		       E1000_TSYNCRXCTL_TYPE_MASK))) { +		e_err("Timesync Rx Control register not set as expected\n"); +		return -EAGAIN; +	} + +	/* L2: define ethertype filter for time stamped packets */ +	if (is_l2) +		rxmtrl |= ETH_P_1588; + +	/* define which PTP packets get time stamped */ +	ew32(RXMTRL, rxmtrl); + +	/* Filter by destination port */ +	if (is_l4) { +		rxudp = PTP_EV_PORT; +		cpu_to_be16s(&rxudp); +	} +	ew32(RXUDP, rxudp); + +	e1e_flush(); + +	/* Clear TSYNCRXCTL_VALID & TSYNCTXCTL_VALID bit */ +	er32(RXSTMPH); +	er32(TXSTMPH); + +	/* Get and set the System Time Register SYSTIM base frequency */ +	ret_val = e1000e_get_base_timinca(adapter, ®val); +	if (ret_val) +		return ret_val; +	ew32(TIMINCA, regval); + +	/* reset the ns time counter */ +	timecounter_init(&adapter->tc, &adapter->cc, +			 ktime_to_ns(ktime_get_real())); + +	return 0; +} + +/**   * e1000_configure - configure the hardware for Rx and Tx   * @adapter: private board structure   **/ @@ -3473,14 +3827,17 @@ void e1000e_reset(struct e1000_adapter *adapter)  		break;  	case e1000_pch2lan:  	case e1000_pch_lpt: -		fc->high_water = 0x05C20; -		fc->low_water = 0x05048; -		fc->pause_time = 0x0650;  		fc->refresh_time = 0x0400; -		if (adapter->netdev->mtu > ETH_DATA_LEN) { -			pba = 14; -			ew32(PBA, pba); + +		if (adapter->netdev->mtu <= ETH_DATA_LEN) { +			fc->high_water = 0x05C20; +			fc->low_water = 0x05048; +			fc->pause_time = 0x0650; +			break;  		} + +		fc->high_water = ((pba << 10) * 9 / 10) & E1000_FCRTH_RTH; +		fc->low_water = ((pba << 10) * 8 / 10) & E1000_FCRTL_RTL;  		break;  	} @@ -3533,6 +3890,9 @@ void e1000e_reset(struct e1000_adapter *adapter)  	e1000e_reset_adaptive(hw); +	/* initialize systim and reset the ns time counter */ +	e1000e_config_hwtstamp(adapter); +  	if (!netif_running(adapter->netdev) &&  	    !test_bit(__E1000_TESTING, &adapter->state)) {  		e1000_power_down_phy(adapter); @@ -3669,6 +4029,24 @@ void e1000e_reinit_locked(struct e1000_adapter *adapter)  }  /** + * e1000e_cyclecounter_read - read raw cycle counter (used by time counter) + * @cc: cyclecounter structure + **/ +static cycle_t e1000e_cyclecounter_read(const struct cyclecounter *cc) +{ +	struct e1000_adapter *adapter = container_of(cc, struct e1000_adapter, +						     cc); +	struct e1000_hw *hw = &adapter->hw; +	cycle_t systim; + +	/* latch SYSTIMH on read of SYSTIML */ +	systim = (cycle_t)er32(SYSTIML); +	systim |= (cycle_t)er32(SYSTIMH) << 32; + +	return systim; +} + +/**   * e1000_sw_init - Initialize general software structures (struct e1000_adapter)   * @adapter: board private structure to initialize   * @@ -3694,6 +4072,17 @@ static int e1000_sw_init(struct e1000_adapter *adapter)  	if (e1000_alloc_queues(adapter))  		return -ENOMEM; +	/* Setup hardware time stamping cyclecounter */ +	if (adapter->flags & FLAG_HAS_HW_TIMESTAMP) { +		adapter->cc.read = e1000e_cyclecounter_read; +		adapter->cc.mask = CLOCKSOURCE_MASK(64); +		adapter->cc.mult = 1; +		/* cc.shift set in e1000e_get_base_tininca() */ + +		spin_lock_init(&adapter->systim_lock); +		INIT_WORK(&adapter->tx_hwtstamp_work, e1000e_tx_hwtstamp_work); +	} +  	/* Explicitly disable IRQ since the NIC can be in any state. */  	e1000_irq_disable(adapter); @@ -3706,7 +4095,7 @@ static int e1000_sw_init(struct e1000_adapter *adapter)   * @irq: interrupt number   * @data: pointer to a network interface device structure   **/ -static irqreturn_t e1000_intr_msi_test(int irq, void *data) +static irqreturn_t e1000_intr_msi_test(int __always_unused irq, void *data)  {  	struct net_device *netdev = data;  	struct e1000_adapter *adapter = netdev_priv(netdev); @@ -3877,10 +4266,8 @@ static int e1000_open(struct net_device *netdev)  		e1000_update_mng_vlan(adapter);  	/* DMA latency requirement to workaround jumbo issue */ -	if (adapter->hw.mac.type == e1000_pch2lan) -		pm_qos_add_request(&adapter->netdev->pm_qos_req, -				   PM_QOS_CPU_DMA_LATENCY, -				   PM_QOS_DEFAULT_VALUE); +	pm_qos_add_request(&adapter->netdev->pm_qos_req, PM_QOS_CPU_DMA_LATENCY, +			   PM_QOS_DEFAULT_VALUE);  	/* before we allocate an interrupt, we must be ready to handle it.  	 * Setting DEBUG_SHIRQ in the kernel makes it fire an interrupt @@ -3988,8 +4375,7 @@ static int e1000_close(struct net_device *netdev)  	    !test_bit(__E1000_TESTING, &adapter->state))  		e1000e_release_hw_control(adapter); -	if (adapter->hw.mac.type == e1000_pch2lan) -		pm_qos_remove_request(&adapter->netdev->pm_qos_req); +	pm_qos_remove_request(&adapter->netdev->pm_qos_req);  	pm_runtime_put_sync(&pdev->dev); @@ -4251,6 +4637,16 @@ static void e1000e_update_stats(struct e1000_adapter *adapter)  	adapter->stats.mgptc += er32(MGTPTC);  	adapter->stats.mgprc += er32(MGTPRC);  	adapter->stats.mgpdc += er32(MGTPDC); + +	/* Correctable ECC Errors */ +	if (hw->mac.type == e1000_pch_lpt) { +		u32 pbeccsts = er32(PBECCSTS); +		adapter->corr_errors += +		    pbeccsts & E1000_PBECCSTS_CORR_ERR_CNT_MASK; +		adapter->uncorr_errors += +		    (pbeccsts & E1000_PBECCSTS_UNCORR_ERR_CNT_MASK) >> +		    E1000_PBECCSTS_UNCORR_ERR_CNT_SHIFT; +	}  }  /** @@ -4266,14 +4662,14 @@ static void e1000_phy_read_status(struct e1000_adapter *adapter)  	    (adapter->hw.phy.media_type == e1000_media_type_copper)) {  		int ret_val; -		ret_val  = e1e_rphy(hw, PHY_CONTROL, &phy->bmcr); -		ret_val |= e1e_rphy(hw, PHY_STATUS, &phy->bmsr); -		ret_val |= e1e_rphy(hw, PHY_AUTONEG_ADV, &phy->advertise); -		ret_val |= e1e_rphy(hw, PHY_LP_ABILITY, &phy->lpa); -		ret_val |= e1e_rphy(hw, PHY_AUTONEG_EXP, &phy->expansion); -		ret_val |= e1e_rphy(hw, PHY_1000T_CTRL, &phy->ctrl1000); -		ret_val |= e1e_rphy(hw, PHY_1000T_STATUS, &phy->stat1000); -		ret_val |= e1e_rphy(hw, PHY_EXT_STATUS, &phy->estatus); +		ret_val = e1e_rphy(hw, MII_BMCR, &phy->bmcr); +		ret_val |= e1e_rphy(hw, MII_BMSR, &phy->bmsr); +		ret_val |= e1e_rphy(hw, MII_ADVERTISE, &phy->advertise); +		ret_val |= e1e_rphy(hw, MII_LPA, &phy->lpa); +		ret_val |= e1e_rphy(hw, MII_EXPANSION, &phy->expansion); +		ret_val |= e1e_rphy(hw, MII_CTRL1000, &phy->ctrl1000); +		ret_val |= e1e_rphy(hw, MII_STAT1000, &phy->stat1000); +		ret_val |= e1e_rphy(hw, MII_ESTATUS, &phy->estatus);  		if (ret_val)  			e_warn("Error reading PHY register\n");  	} else { @@ -4300,9 +4696,8 @@ static void e1000_print_link_info(struct e1000_adapter *adapter)  	u32 ctrl = er32(CTRL);  	/* Link status message must follow this format for user tools */ -	printk(KERN_INFO "e1000e: %s NIC Link is Up %d Mbps %s Duplex, Flow Control: %s\n", -		adapter->netdev->name, -		adapter->link_speed, +	pr_info("%s NIC Link is Up %d Mbps %s Duplex, Flow Control: %s\n", +		adapter->netdev->name, adapter->link_speed,  		adapter->link_duplex == FULL_DUPLEX ? "Full" : "Half",  		(ctrl & E1000_CTRL_TFCE) && (ctrl & E1000_CTRL_RFCE) ? "Rx/Tx" :  		(ctrl & E1000_CTRL_RFCE) ? "Rx" : @@ -4355,11 +4750,11 @@ static void e1000e_enable_receives(struct e1000_adapter *adapter)  {  	/* make sure the receive unit is started */  	if ((adapter->flags & FLAG_RX_NEEDS_RESTART) && -	    (adapter->flags & FLAG_RX_RESTART_NOW)) { +	    (adapter->flags & FLAG_RESTART_NOW)) {  		struct e1000_hw *hw = &adapter->hw;  		u32 rctl = er32(RCTL);  		ew32(RCTL, rctl | E1000_RCTL_EN); -		adapter->flags &= ~FLAG_RX_RESTART_NOW; +		adapter->flags &= ~FLAG_RESTART_NOW;  	}  } @@ -4435,6 +4830,13 @@ static void e1000_watchdog_task(struct work_struct *work)  						   &adapter->link_speed,  						   &adapter->link_duplex);  			e1000_print_link_info(adapter); + +			/* check if SmartSpeed worked */ +			e1000e_check_downshift(hw); +			if (phy->speed_downgraded) +				netdev_warn(netdev, +					    "Link Speed was downgraded by SmartSpeed\n"); +  			/* On supported PHYs, check for duplex mismatch only  			 * if link has autonegotiated at 10/100 half  			 */ @@ -4446,9 +4848,9 @@ static void e1000_watchdog_task(struct work_struct *work)  			    (adapter->link_duplex == HALF_DUPLEX)) {  				u16 autoneg_exp; -				e1e_rphy(hw, PHY_AUTONEG_EXP, &autoneg_exp); +				e1e_rphy(hw, MII_EXPANSION, &autoneg_exp); -				if (!(autoneg_exp & NWAY_ER_LP_NWAY_CAPS)) +				if (!(autoneg_exp & EXPANSION_NWAY))  					e_info("Autonegotiated half duplex but link partner cannot autoneg.  Try forcing full duplex if link gets many collisions.\n");  			} @@ -4521,15 +4923,22 @@ static void e1000_watchdog_task(struct work_struct *work)  			adapter->link_speed = 0;  			adapter->link_duplex = 0;  			/* Link status message must follow this format */ -			printk(KERN_INFO "e1000e: %s NIC Link is Down\n", -			       adapter->netdev->name); +			pr_info("%s NIC Link is Down\n", adapter->netdev->name);  			netif_carrier_off(netdev);  			if (!test_bit(__E1000_DOWN, &adapter->state))  				mod_timer(&adapter->phy_info_timer,  					  round_jiffies(jiffies + 2 * HZ)); -			if (adapter->flags & FLAG_RX_NEEDS_RESTART) -				schedule_work(&adapter->reset_task); +			/* The link is lost so the controller stops DMA. +			 * If there is queued Tx work that cannot be done +			 * or if on an 8000ES2LAN which requires a Rx packet +			 * buffer work-around on link down event, reset the +			 * controller to flush the Tx/Rx packet buffers. +			 * (Do the reset outside of interrupt context). +			 */ +			if ((adapter->flags & FLAG_RX_NEEDS_RESTART) || +			    (e1000_desc_unused(tx_ring) + 1 < tx_ring->count)) +				adapter->flags |= FLAG_RESTART_NOW;  			else  				pm_schedule_suspend(netdev->dev.parent,  							LINK_TIMEOUT); @@ -4551,20 +4960,14 @@ link_up:  	adapter->gotc_old = adapter->stats.gotc;  	spin_unlock(&adapter->stats64_lock); -	e1000e_update_adaptive(&adapter->hw); - -	if (!netif_carrier_ok(netdev) && -	    (e1000_desc_unused(tx_ring) + 1 < tx_ring->count)) { -		/* We've lost link, so the controller stops DMA, -		 * but we've got queued Tx work that's never going -		 * to get done, so reset controller to flush Tx. -		 * (Do the reset outside of interrupt context). -		 */ +	if (adapter->flags & FLAG_RESTART_NOW) {  		schedule_work(&adapter->reset_task);  		/* return immediately since reset is imminent */  		return;  	} +	e1000e_update_adaptive(&adapter->hw); +  	/* Simple mode for Interrupt Throttle Rate (ITR) */  	if (adapter->itr_setting == 4) {  		/* Symmetric Tx/Rx gets a reduced ITR=2000; @@ -4601,6 +5004,17 @@ link_up:  	if (adapter->flags2 & FLAG2_CHECK_PHY_HANG)  		e1000e_check_82574_phy_workaround(adapter); +	/* Clear valid timestamp stuck in RXSTMPL/H due to a Rx error */ +	if (adapter->hwtstamp_config.rx_filter != HWTSTAMP_FILTER_NONE) { +		if ((adapter->flags2 & FLAG2_CHECK_RX_HWTSTAMP) && +		    (er32(TSYNCRXCTL) & E1000_TSYNCRXCTL_VALID)) { +			er32(RXSTMPH); +			adapter->rx_hwtstamp_cleared++; +		} else { +			adapter->flags2 |= FLAG2_CHECK_RX_HWTSTAMP; +		} +	} +  	/* Reset the timer */  	if (!test_bit(__E1000_DOWN, &adapter->state))  		mod_timer(&adapter->watchdog_timer, @@ -4612,6 +5026,7 @@ link_up:  #define E1000_TX_FLAGS_TSO		0x00000004  #define E1000_TX_FLAGS_IPV4		0x00000008  #define E1000_TX_FLAGS_NO_FCS		0x00000010 +#define E1000_TX_FLAGS_HWTSTAMP		0x00000020  #define E1000_TX_FLAGS_VLAN_MASK	0xffff0000  #define E1000_TX_FLAGS_VLAN_SHIFT	16 @@ -4870,6 +5285,11 @@ static void e1000_tx_queue(struct e1000_ring *tx_ring, int tx_flags, int count)  	if (unlikely(tx_flags & E1000_TX_FLAGS_NO_FCS))  		txd_lower &= ~(E1000_TXD_CMD_IFCS); +	if (unlikely(tx_flags & E1000_TX_FLAGS_HWTSTAMP)) { +		txd_lower |= E1000_TXD_CMD_DEXT | E1000_TXD_DTYP_D; +		txd_upper |= E1000_TXD_EXTCMD_TSTAMP; +	} +  	i = tx_ring->next_to_use;  	do { @@ -4918,12 +5338,11 @@ static int e1000_transfer_dhcp_info(struct e1000_adapter *adapter,  	struct e1000_hw *hw =  &adapter->hw;  	u16 length, offset; -	if (vlan_tx_tag_present(skb)) { -		if (!((vlan_tx_tag_get(skb) == adapter->hw.mng_cookie.vlan_id) && -		    (adapter->hw.mng_cookie.status & -			E1000_MNG_DHCP_COOKIE_STATUS_VLAN))) -			return 0; -	} +	if (vlan_tx_tag_present(skb) && +	    !((vlan_tx_tag_get(skb) == adapter->hw.mng_cookie.vlan_id) && +	      (adapter->hw.mng_cookie.status & +	       E1000_MNG_DHCP_COOKIE_STATUS_VLAN))) +		return 0;  	if (skb->len <= MINIMUM_DHCP_PACKET_SIZE)  		return 0; @@ -5094,7 +5513,15 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,  	count = e1000_tx_map(tx_ring, skb, first, adapter->tx_fifo_limit,  			     nr_frags);  	if (count) { -		skb_tx_timestamp(skb); +		if (unlikely((skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) && +			     !adapter->tx_hwtstamp_skb)) { +			skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; +			tx_flags |= E1000_TX_FLAGS_HWTSTAMP; +			adapter->tx_hwtstamp_skb = skb_get(skb); +			schedule_work(&adapter->tx_hwtstamp_work); +		} else { +			skb_tx_timestamp(skb); +		}  		netdev_sent_queue(netdev, skb->len);  		e1000_tx_queue(tx_ring, tx_flags, count); @@ -5134,10 +5561,9 @@ static void e1000_reset_task(struct work_struct *work)  	if (test_bit(__E1000_DOWN, &adapter->state))  		return; -	if (!((adapter->flags & FLAG_RX_NEEDS_RESTART) && -	      (adapter->flags & FLAG_RX_RESTART_NOW))) { +	if (!(adapter->flags & FLAG_RESTART_NOW)) {  		e1000e_dump(adapter); -		e_err("Reset adapter\n"); +		e_err("Reset adapter unexpectedly\n");  	}  	e1000e_reinit_locked(adapter);  } @@ -5323,6 +5749,61 @@ static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr,  	return 0;  } +/** + * e1000e_hwtstamp_ioctl - control hardware time stamping + * @netdev: network interface device structure + * @ifreq: interface request + * + * Outgoing time stamping can be enabled and disabled. Play nice and + * disable it when requested, although it shouldn't cause any overhead + * when no packet needs it. At most one packet in the queue may be + * marked for time stamping, otherwise it would be impossible to tell + * for sure to which packet the hardware time stamp belongs. + * + * Incoming time stamping has to be configured via the hardware filters. + * Not all combinations are supported, in particular event type has to be + * specified. Matching the kind of event packet is not supported, with the + * exception of "all V2 events regardless of level 2 or 4". + **/ +static int e1000e_hwtstamp_ioctl(struct net_device *netdev, struct ifreq *ifr) +{ +	struct e1000_adapter *adapter = netdev_priv(netdev); +	struct hwtstamp_config config; +	int ret_val; + +	if (copy_from_user(&config, ifr->ifr_data, sizeof(config))) +		return -EFAULT; + +	adapter->hwtstamp_config = config; + +	ret_val = e1000e_config_hwtstamp(adapter); +	if (ret_val) +		return ret_val; + +	config = adapter->hwtstamp_config; + +	switch (config.rx_filter) { +	case HWTSTAMP_FILTER_PTP_V2_L4_SYNC: +	case HWTSTAMP_FILTER_PTP_V2_L2_SYNC: +	case HWTSTAMP_FILTER_PTP_V2_SYNC: +	case HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ: +	case HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ: +	case HWTSTAMP_FILTER_PTP_V2_DELAY_REQ: +		/* With V2 type filters which specify a Sync or Delay Request, +		 * Path Delay Request/Response messages are also time stamped +		 * by hardware so notify the caller the requested packets plus +		 * some others are time stamped. +		 */ +		config.rx_filter = HWTSTAMP_FILTER_SOME; +		break; +	default: +		break; +	} + +	return copy_to_user(ifr->ifr_data, &config, +			    sizeof(config)) ? -EFAULT : 0; +} +  static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)  {  	switch (cmd) { @@ -5330,6 +5811,8 @@ static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)  	case SIOCGMIIREG:  	case SIOCSMIIREG:  		return e1000_mii_ioctl(netdev, ifr, cmd); +	case SIOCSHWTSTAMP: +		return e1000e_hwtstamp_ioctl(netdev, ifr);  	default:  		return -EOPNOTSUPP;  	} @@ -5340,7 +5823,7 @@ static int e1000_init_phy_wakeup(struct e1000_adapter *adapter, u32 wufc)  	struct e1000_hw *hw = &adapter->hw;  	u32 i, mac_reg;  	u16 phy_reg, wuc_enable; -	int retval = 0; +	int retval;  	/* copy MAC RARs to PHY RARs */  	e1000_copy_rx_addrs_to_phy_ich8lan(hw); @@ -5554,14 +6037,21 @@ static void __e1000e_disable_aspm(struct pci_dev *pdev, u16 state)  #else  static void __e1000e_disable_aspm(struct pci_dev *pdev, u16 state)  { +	u16 aspm_ctl = 0; + +	if (state & PCIE_LINK_STATE_L0S) +		aspm_ctl |= PCI_EXP_LNKCTL_ASPM_L0S; +	if (state & PCIE_LINK_STATE_L1) +		aspm_ctl |= PCI_EXP_LNKCTL_ASPM_L1; +  	/* Both device and parent should have the same ASPM setting.  	 * Disable ASPM in downstream component first and then upstream.  	 */ -	pcie_capability_clear_word(pdev, PCI_EXP_LNKCTL, state); +	pcie_capability_clear_word(pdev, PCI_EXP_LNKCTL, aspm_ctl);  	if (pdev->bus->self)  		pcie_capability_clear_word(pdev->bus->self, PCI_EXP_LNKCTL, -					   state); +					   aspm_ctl);  }  #endif  static void e1000e_disable_aspm(struct pci_dev *pdev, u16 state) @@ -5746,7 +6236,7 @@ static void e1000_shutdown(struct pci_dev *pdev)  #ifdef CONFIG_NET_POLL_CONTROLLER -static irqreturn_t e1000_intr_msix(int irq, void *data) +static irqreturn_t e1000_intr_msix(int __always_unused irq, void *data)  {  	struct net_device *netdev = data;  	struct e1000_adapter *adapter = netdev_priv(netdev); @@ -5910,7 +6400,6 @@ static void e1000_io_resume(struct pci_dev *pdev)  	 */  	if (!(adapter->flags & FLAG_HAS_AMT))  		e1000e_get_hw_control(adapter); -  }  static void e1000_print_device_info(struct e1000_adapter *adapter) @@ -6068,8 +6557,8 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)  	}  	err = pci_request_selected_regions_exclusive(pdev, -	                                  pci_select_bars(pdev, IORESOURCE_MEM), -	                                  e1000e_driver_name); +					  pci_select_bars(pdev, IORESOURCE_MEM), +					  e1000e_driver_name);  	if (err)  		goto err_pci_reg; @@ -6228,11 +6717,10 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)  			"NVM Read Error while reading MAC address\n");  	memcpy(netdev->dev_addr, adapter->hw.mac.addr, netdev->addr_len); -	memcpy(netdev->perm_addr, adapter->hw.mac.addr, netdev->addr_len); -	if (!is_valid_ether_addr(netdev->perm_addr)) { +	if (!is_valid_ether_addr(netdev->dev_addr)) {  		dev_err(&pdev->dev, "Invalid MAC Address: %pM\n", -			netdev->perm_addr); +			netdev->dev_addr);  		err = -EIO;  		goto err_eeprom;  	} @@ -6318,6 +6806,9 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *ent)  	/* carrier off reporting is important to ethtool even BEFORE open */  	netif_carrier_off(netdev); +	/* init PTP hardware clock */ +	e1000e_ptp_init(adapter); +  	e1000_print_device_info(adapter);  	if (pci_dev_run_wake(pdev)) @@ -6366,6 +6857,8 @@ static void e1000_remove(struct pci_dev *pdev)  	struct e1000_adapter *adapter = netdev_priv(netdev);  	bool down = test_bit(__E1000_DOWN, &adapter->state); +	e1000e_ptp_remove(adapter); +  	/* The timers may be rescheduled, so explicitly disable them  	 * from being rescheduled.  	 */ @@ -6380,6 +6873,14 @@ static void e1000_remove(struct pci_dev *pdev)  	cancel_work_sync(&adapter->update_phy_task);  	cancel_work_sync(&adapter->print_hang_task); +	if (adapter->flags & FLAG_HAS_HW_TIMESTAMP) { +		cancel_work_sync(&adapter->tx_hwtstamp_work); +		if (adapter->tx_hwtstamp_skb) { +			dev_kfree_skb_any(adapter->tx_hwtstamp_skb); +			adapter->tx_hwtstamp_skb = NULL; +		} +	} +  	if (!(netdev->flags & IFF_UP))  		e1000_power_down_phy(adapter); @@ -6532,7 +7033,7 @@ static int __init e1000_init_module(void)  	int ret;  	pr_info("Intel(R) PRO/1000 Network Driver - %s\n",  		e1000e_driver_version); -	pr_info("Copyright(c) 1999 - 2012 Intel Corporation.\n"); +	pr_info("Copyright(c) 1999 - 2013 Intel Corporation.\n");  	ret = pci_register_driver(&e1000_driver);  	return ret; diff --git a/drivers/net/ethernet/intel/e1000e/nvm.c b/drivers/net/ethernet/intel/e1000e/nvm.c index b6468804cb2..84fecc26816 100644 --- a/drivers/net/ethernet/intel/e1000e/nvm.c +++ b/drivers/net/ethernet/intel/e1000e/nvm.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel PRO/1000 Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -359,7 +359,7 @@ s32 e1000e_read_nvm_eerd(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)  s32 e1000e_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)  {  	struct e1000_nvm_info *nvm = &hw->nvm; -	s32 ret_val; +	s32 ret_val = -E1000_ERR_NVM;  	u16 widx = 0;  	/* A check for invalid values:  offset too large, too many words, @@ -371,16 +371,18 @@ s32 e1000e_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)  		return -E1000_ERR_NVM;  	} -	ret_val = nvm->ops.acquire(hw); -	if (ret_val) -		return ret_val; -  	while (widx < words) {  		u8 write_opcode = NVM_WRITE_OPCODE_SPI; -		ret_val = e1000_ready_nvm_eeprom(hw); +		ret_val = nvm->ops.acquire(hw);  		if (ret_val) -			goto release; +			return ret_val; + +		ret_val = e1000_ready_nvm_eeprom(hw); +		if (ret_val) { +			nvm->ops.release(hw); +			return ret_val; +		}  		e1000_standby_nvm(hw); @@ -413,12 +415,10 @@ s32 e1000e_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data)  				break;  			}  		} +		usleep_range(10000, 20000); +		nvm->ops.release(hw);  	} -	usleep_range(10000, 20000); -release: -	nvm->ops.release(hw); -  	return ret_val;  } @@ -464,8 +464,8 @@ s32 e1000_read_pba_string_generic(struct e1000_hw *hw, u8 *pba_num,  	if (nvm_data != NVM_PBA_PTR_GUARD) {  		e_dbg("NVM PBA number is not stored as string\n"); -		/* we will need 11 characters to store the PBA */ -		if (pba_num_size < 11) { +		/* make sure callers buffer is big enough to store the PBA */ +		if (pba_num_size < E1000_PBANUM_LENGTH) {  			e_dbg("PBA string buffer too small\n");  			return E1000_ERR_NO_SPACE;  		} diff --git a/drivers/net/ethernet/intel/e1000e/nvm.h b/drivers/net/ethernet/intel/e1000e/nvm.h new file mode 100644 index 00000000000..45fc6956162 --- /dev/null +++ b/drivers/net/ethernet/intel/e1000e/nvm.h @@ -0,0 +1,47 @@ +/******************************************************************************* + +  Intel PRO/1000 Linux driver +  Copyright(c) 1999 - 2013 Intel Corporation. + +  This program is free software; you can redistribute it and/or modify it +  under the terms and conditions of the GNU General Public License, +  version 2, as published by the Free Software Foundation. + +  This program is distributed in the hope it will be useful, but WITHOUT +  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for +  more details. + +  You should have received a copy of the GNU General Public License along with +  this program; if not, write to the Free Software Foundation, Inc., +  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + +  The full GNU General Public License is included in this distribution in +  the file called "COPYING". + +  Contact Information: +  Linux NICS <linux.nics@intel.com> +  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> +  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + +*******************************************************************************/ + +#ifndef _E1000E_NVM_H_ +#define _E1000E_NVM_H_ + +s32 e1000e_acquire_nvm(struct e1000_hw *hw); + +s32 e1000e_poll_eerd_eewr_done(struct e1000_hw *hw, int ee_reg); +s32 e1000_read_mac_addr_generic(struct e1000_hw *hw); +s32 e1000_read_pba_string_generic(struct e1000_hw *hw, u8 *pba_num, +				  u32 pba_num_size); +s32 e1000e_read_nvm_eerd(struct e1000_hw *hw, u16 offset, u16 words, u16 *data); +s32 e1000e_valid_led_default(struct e1000_hw *hw, u16 *data); +s32 e1000e_validate_nvm_checksum_generic(struct e1000_hw *hw); +s32 e1000e_write_nvm_spi(struct e1000_hw *hw, u16 offset, u16 words, u16 *data); +s32 e1000e_update_nvm_checksum_generic(struct e1000_hw *hw); +void e1000e_release_nvm(struct e1000_hw *hw); + +#define E1000_STM_OPCODE	0xDB00 + +#endif diff --git a/drivers/net/ethernet/intel/e1000e/param.c b/drivers/net/ethernet/intel/e1000e/param.c index 89d536dd7ff..98da75dff93 100644 --- a/drivers/net/ethernet/intel/e1000e/param.c +++ b/drivers/net/ethernet/intel/e1000e/param.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel PRO/1000 Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -53,8 +53,7 @@ MODULE_PARM_DESC(copybreak,   */  #define E1000_PARAM_INIT { [0 ... E1000_MAX_NIC] = OPTION_UNSET }  #define E1000_PARAM(X, desc)					\ -	static int X[E1000_MAX_NIC+1]		\ -		= E1000_PARAM_INIT;				\ +	static int X[E1000_MAX_NIC+1] = E1000_PARAM_INIT;	\  	static unsigned int num_##X;				\  	module_param_array_named(X, X, int, &num_##X, 0);	\  	MODULE_PARM_DESC(X, desc); @@ -447,8 +446,7 @@ void e1000e_check_options(struct e1000_adapter *adapter)  		if (num_SmartPowerDownEnable > bd) {  			unsigned int spd = SmartPowerDownEnable[bd];  			e1000_validate_option(&spd, &opt, adapter); -			if ((adapter->flags & FLAG_HAS_SMART_POWER_DOWN) -			    && spd) +			if ((adapter->flags & FLAG_HAS_SMART_POWER_DOWN) && spd)  				adapter->flags |= FLAG_SMART_POWER_DOWN;  		}  	} diff --git a/drivers/net/ethernet/intel/e1000e/phy.c b/drivers/net/ethernet/intel/e1000e/phy.c index 28b38ff37e8..0930c136aa3 100644 --- a/drivers/net/ethernet/intel/e1000e/phy.c +++ b/drivers/net/ethernet/intel/e1000e/phy.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel PRO/1000 Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -28,16 +28,12 @@  #include "e1000.h" -static s32 e1000_get_phy_cfg_done(struct e1000_hw *hw); -static s32 e1000_phy_force_speed_duplex(struct e1000_hw *hw); -static s32 e1000_set_d0_lplu_state(struct e1000_hw *hw, bool active);  static s32 e1000_wait_autoneg(struct e1000_hw *hw); -static u32 e1000_get_phy_addr_for_bm_page(u32 page, u32 reg);  static s32 e1000_access_phy_wakeup_reg_bm(struct e1000_hw *hw, u32 offset,  					  u16 *data, bool read, bool page_set);  static u32 e1000_get_phy_addr_for_hv_page(u32 page);  static s32 e1000_access_phy_debug_regs_hv(struct e1000_hw *hw, u32 offset, -                                          u16 *data, bool read); +					  u16 *data, bool read);  /* Cable length tables */  static const u16 e1000_m88_cable_length_table[] = { @@ -57,48 +53,6 @@ static const u16 e1000_igp_2_cable_length_table[] = {  #define IGP02E1000_CABLE_LENGTH_TABLE_SIZE \  		ARRAY_SIZE(e1000_igp_2_cable_length_table) -#define BM_PHY_REG_PAGE(offset) \ -	((u16)(((offset) >> PHY_PAGE_SHIFT) & 0xFFFF)) -#define BM_PHY_REG_NUM(offset) \ -	((u16)(((offset) & MAX_PHY_REG_ADDRESS) |\ -	 (((offset) >> (PHY_UPPER_SHIFT - PHY_PAGE_SHIFT)) &\ -		~MAX_PHY_REG_ADDRESS))) - -#define HV_INTC_FC_PAGE_START             768 -#define I82578_ADDR_REG                   29 -#define I82577_ADDR_REG                   16 -#define I82577_CFG_REG                    22 -#define I82577_CFG_ASSERT_CRS_ON_TX       (1 << 15) -#define I82577_CFG_ENABLE_DOWNSHIFT       (3 << 10) /* auto downshift 100/10 */ -#define I82577_CTRL_REG                   23 - -/* 82577 specific PHY registers */ -#define I82577_PHY_CTRL_2            18 -#define I82577_PHY_STATUS_2          26 -#define I82577_PHY_DIAG_STATUS       31 - -/* I82577 PHY Status 2 */ -#define I82577_PHY_STATUS2_REV_POLARITY   0x0400 -#define I82577_PHY_STATUS2_MDIX           0x0800 -#define I82577_PHY_STATUS2_SPEED_MASK     0x0300 -#define I82577_PHY_STATUS2_SPEED_1000MBPS 0x0200 - -/* I82577 PHY Control 2 */ -#define I82577_PHY_CTRL2_MANUAL_MDIX      0x0200 -#define I82577_PHY_CTRL2_AUTO_MDI_MDIX    0x0400 -#define I82577_PHY_CTRL2_MDIX_CFG_MASK    0x0600 - -/* I82577 PHY Diagnostics Status */ -#define I82577_DSTATUS_CABLE_LENGTH       0x03FC -#define I82577_DSTATUS_CABLE_LENGTH_SHIFT 2 - -/* BM PHY Copper Specific Control 1 */ -#define BM_CS_CTRL1                       16 - -#define HV_MUX_DATA_CTRL               PHY_REG(776, 16) -#define HV_MUX_DATA_CTRL_GEN_TO_MAC    0x0400 -#define HV_MUX_DATA_CTRL_FORCE_SPEED   0x0004 -  /**   *  e1000e_check_reset_block_generic - Check if PHY reset is blocked   *  @hw: pointer to the HW structure @@ -135,13 +89,13 @@ s32 e1000e_get_phy_id(struct e1000_hw *hw)  		return 0;  	while (retry_count < 2) { -		ret_val = e1e_rphy(hw, PHY_ID1, &phy_id); +		ret_val = e1e_rphy(hw, MII_PHYSID1, &phy_id);  		if (ret_val)  			return ret_val;  		phy->id = (u32)(phy_id << 16);  		udelay(20); -		ret_val = e1e_rphy(hw, PHY_ID2, &phy_id); +		ret_val = e1e_rphy(hw, MII_PHYSID2, &phy_id);  		if (ret_val)  			return ret_val; @@ -645,31 +599,31 @@ static s32 e1000_set_master_slave_mode(struct e1000_hw *hw)  	u16 phy_data;  	/* Resolve Master/Slave mode */ -	ret_val = e1e_rphy(hw, PHY_1000T_CTRL, &phy_data); +	ret_val = e1e_rphy(hw, MII_CTRL1000, &phy_data);  	if (ret_val)  		return ret_val;  	/* load defaults for future use */ -	hw->phy.original_ms_type = (phy_data & CR_1000T_MS_ENABLE) ? -	    ((phy_data & CR_1000T_MS_VALUE) ? +	hw->phy.original_ms_type = (phy_data & CTL1000_ENABLE_MASTER) ? +	    ((phy_data & CTL1000_AS_MASTER) ?  	     e1000_ms_force_master : e1000_ms_force_slave) : e1000_ms_auto;  	switch (hw->phy.ms_type) {  	case e1000_ms_force_master: -		phy_data |= (CR_1000T_MS_ENABLE | CR_1000T_MS_VALUE); +		phy_data |= (CTL1000_ENABLE_MASTER | CTL1000_AS_MASTER);  		break;  	case e1000_ms_force_slave: -		phy_data |= CR_1000T_MS_ENABLE; -		phy_data &= ~(CR_1000T_MS_VALUE); +		phy_data |= CTL1000_ENABLE_MASTER; +		phy_data &= ~(CTL1000_AS_MASTER);  		break;  	case e1000_ms_auto: -		phy_data &= ~CR_1000T_MS_ENABLE; +		phy_data &= ~CTL1000_ENABLE_MASTER;  		/* fall-through */  	default:  		break;  	} -	return e1e_wphy(hw, PHY_1000T_CTRL, phy_data); +	return e1e_wphy(hw, MII_CTRL1000, phy_data);  }  /** @@ -792,7 +746,7 @@ s32 e1000e_copper_link_setup_m88(struct e1000_hw *hw)  			if (ret_val)  				return ret_val;  			/* Commit the changes. */ -			ret_val = e1000e_commit_phy(hw); +			ret_val = phy->ops.commit(hw);  			if (ret_val) {  				e_dbg("Error committing the PHY changes\n");  				return ret_val; @@ -848,10 +802,12 @@ s32 e1000e_copper_link_setup_m88(struct e1000_hw *hw)  	}  	/* Commit the changes. */ -	ret_val = e1000e_commit_phy(hw); -	if (ret_val) { -		e_dbg("Error committing the PHY changes\n"); -		return ret_val; +	if (phy->ops.commit) { +		ret_val = phy->ops.commit(hw); +		if (ret_val) { +			e_dbg("Error committing the PHY changes\n"); +			return ret_val; +		}  	}  	if (phy->type == e1000_phy_82578) { @@ -895,10 +851,12 @@ s32 e1000e_copper_link_setup_igp(struct e1000_hw *hw)  	msleep(100);  	/* disable lplu d0 during driver init */ -	ret_val = e1000_set_d0_lplu_state(hw, false); -	if (ret_val) { -		e_dbg("Error Disabling LPLU D0\n"); -		return ret_val; +	if (hw->phy.ops.set_d0_lplu_state) { +		ret_val = hw->phy.ops.set_d0_lplu_state(hw, false); +		if (ret_val) { +			e_dbg("Error Disabling LPLU D0\n"); +			return ret_val; +		}  	}  	/* Configure mdi-mdix settings */  	ret_val = e1e_rphy(hw, IGP01E1000_PHY_PORT_CTRL, &data); @@ -943,12 +901,12 @@ s32 e1000e_copper_link_setup_igp(struct e1000_hw *hw)  				return ret_val;  			/* Set auto Master/Slave resolution process */ -			ret_val = e1e_rphy(hw, PHY_1000T_CTRL, &data); +			ret_val = e1e_rphy(hw, MII_CTRL1000, &data);  			if (ret_val)  				return ret_val; -			data &= ~CR_1000T_MS_ENABLE; -			ret_val = e1e_wphy(hw, PHY_1000T_CTRL, data); +			data &= ~CTL1000_ENABLE_MASTER; +			ret_val = e1e_wphy(hw, MII_CTRL1000, data);  			if (ret_val)  				return ret_val;  		} @@ -978,13 +936,13 @@ static s32 e1000_phy_setup_autoneg(struct e1000_hw *hw)  	phy->autoneg_advertised &= phy->autoneg_mask;  	/* Read the MII Auto-Neg Advertisement Register (Address 4). */ -	ret_val = e1e_rphy(hw, PHY_AUTONEG_ADV, &mii_autoneg_adv_reg); +	ret_val = e1e_rphy(hw, MII_ADVERTISE, &mii_autoneg_adv_reg);  	if (ret_val)  		return ret_val;  	if (phy->autoneg_mask & ADVERTISE_1000_FULL) {  		/* Read the MII 1000Base-T Control Register (Address 9). */ -		ret_val = e1e_rphy(hw, PHY_1000T_CTRL, &mii_1000t_ctrl_reg); +		ret_val = e1e_rphy(hw, MII_CTRL1000, &mii_1000t_ctrl_reg);  		if (ret_val)  			return ret_val;  	} @@ -1000,36 +958,35 @@ static s32 e1000_phy_setup_autoneg(struct e1000_hw *hw)  	 * Advertisement Register (Address 4) and the 1000 mb speed bits in  	 * the  1000Base-T Control Register (Address 9).  	 */ -	mii_autoneg_adv_reg &= ~(NWAY_AR_100TX_FD_CAPS | -				 NWAY_AR_100TX_HD_CAPS | -				 NWAY_AR_10T_FD_CAPS   | -				 NWAY_AR_10T_HD_CAPS); -	mii_1000t_ctrl_reg &= ~(CR_1000T_HD_CAPS | CR_1000T_FD_CAPS); +	mii_autoneg_adv_reg &= ~(ADVERTISE_100FULL | +				 ADVERTISE_100HALF | +				 ADVERTISE_10FULL | ADVERTISE_10HALF); +	mii_1000t_ctrl_reg &= ~(ADVERTISE_1000HALF | ADVERTISE_1000FULL);  	e_dbg("autoneg_advertised %x\n", phy->autoneg_advertised);  	/* Do we want to advertise 10 Mb Half Duplex? */  	if (phy->autoneg_advertised & ADVERTISE_10_HALF) {  		e_dbg("Advertise 10mb Half duplex\n"); -		mii_autoneg_adv_reg |= NWAY_AR_10T_HD_CAPS; +		mii_autoneg_adv_reg |= ADVERTISE_10HALF;  	}  	/* Do we want to advertise 10 Mb Full Duplex? */  	if (phy->autoneg_advertised & ADVERTISE_10_FULL) {  		e_dbg("Advertise 10mb Full duplex\n"); -		mii_autoneg_adv_reg |= NWAY_AR_10T_FD_CAPS; +		mii_autoneg_adv_reg |= ADVERTISE_10FULL;  	}  	/* Do we want to advertise 100 Mb Half Duplex? */  	if (phy->autoneg_advertised & ADVERTISE_100_HALF) {  		e_dbg("Advertise 100mb Half duplex\n"); -		mii_autoneg_adv_reg |= NWAY_AR_100TX_HD_CAPS; +		mii_autoneg_adv_reg |= ADVERTISE_100HALF;  	}  	/* Do we want to advertise 100 Mb Full Duplex? */  	if (phy->autoneg_advertised & ADVERTISE_100_FULL) {  		e_dbg("Advertise 100mb Full duplex\n"); -		mii_autoneg_adv_reg |= NWAY_AR_100TX_FD_CAPS; +		mii_autoneg_adv_reg |= ADVERTISE_100FULL;  	}  	/* We do not allow the Phy to advertise 1000 Mb Half Duplex */ @@ -1039,14 +996,14 @@ static s32 e1000_phy_setup_autoneg(struct e1000_hw *hw)  	/* Do we want to advertise 1000 Mb Full Duplex? */  	if (phy->autoneg_advertised & ADVERTISE_1000_FULL) {  		e_dbg("Advertise 1000mb Full duplex\n"); -		mii_1000t_ctrl_reg |= CR_1000T_FD_CAPS; +		mii_1000t_ctrl_reg |= ADVERTISE_1000FULL;  	}  	/* Check for a software override of the flow control settings, and  	 * setup the PHY advertisement registers accordingly.  If  	 * auto-negotiation is enabled, then software will have to set the  	 * "PAUSE" bits to the correct value in the Auto-Negotiation -	 * Advertisement Register (PHY_AUTONEG_ADV) and re-start auto- +	 * Advertisement Register (MII_ADVERTISE) and re-start auto-  	 * negotiation.  	 *  	 * The possible values of the "fc" parameter are: @@ -1064,7 +1021,8 @@ static s32 e1000_phy_setup_autoneg(struct e1000_hw *hw)  		/* Flow control (Rx & Tx) is completely disabled by a  		 * software over-ride.  		 */ -		mii_autoneg_adv_reg &= ~(NWAY_AR_ASM_DIR | NWAY_AR_PAUSE); +		mii_autoneg_adv_reg &= +		    ~(ADVERTISE_PAUSE_ASYM | ADVERTISE_PAUSE_CAP);  		break;  	case e1000_fc_rx_pause:  		/* Rx Flow control is enabled, and Tx Flow control is @@ -1076,34 +1034,36 @@ static s32 e1000_phy_setup_autoneg(struct e1000_hw *hw)  		 * (in e1000e_config_fc_after_link_up) we will disable the  		 * hw's ability to send PAUSE frames.  		 */ -		mii_autoneg_adv_reg |= (NWAY_AR_ASM_DIR | NWAY_AR_PAUSE); +		mii_autoneg_adv_reg |= +		    (ADVERTISE_PAUSE_ASYM | ADVERTISE_PAUSE_CAP);  		break;  	case e1000_fc_tx_pause:  		/* Tx Flow control is enabled, and Rx Flow control is  		 * disabled, by a software over-ride.  		 */ -		mii_autoneg_adv_reg |= NWAY_AR_ASM_DIR; -		mii_autoneg_adv_reg &= ~NWAY_AR_PAUSE; +		mii_autoneg_adv_reg |= ADVERTISE_PAUSE_ASYM; +		mii_autoneg_adv_reg &= ~ADVERTISE_PAUSE_CAP;  		break;  	case e1000_fc_full:  		/* Flow control (both Rx and Tx) is enabled by a software  		 * over-ride.  		 */ -		mii_autoneg_adv_reg |= (NWAY_AR_ASM_DIR | NWAY_AR_PAUSE); +		mii_autoneg_adv_reg |= +		    (ADVERTISE_PAUSE_ASYM | ADVERTISE_PAUSE_CAP);  		break;  	default:  		e_dbg("Flow control param set incorrectly\n");  		return -E1000_ERR_CONFIG;  	} -	ret_val = e1e_wphy(hw, PHY_AUTONEG_ADV, mii_autoneg_adv_reg); +	ret_val = e1e_wphy(hw, MII_ADVERTISE, mii_autoneg_adv_reg);  	if (ret_val)  		return ret_val;  	e_dbg("Auto-Neg Advertising %x\n", mii_autoneg_adv_reg);  	if (phy->autoneg_mask & ADVERTISE_1000_FULL) -		ret_val = e1e_wphy(hw, PHY_1000T_CTRL, mii_1000t_ctrl_reg); +		ret_val = e1e_wphy(hw, MII_CTRL1000, mii_1000t_ctrl_reg);  	return ret_val;  } @@ -1145,12 +1105,12 @@ static s32 e1000_copper_link_autoneg(struct e1000_hw *hw)  	/* Restart auto-negotiation by setting the Auto Neg Enable bit and  	 * the Auto Neg Restart bit in the PHY control register.  	 */ -	ret_val = e1e_rphy(hw, PHY_CONTROL, &phy_ctrl); +	ret_val = e1e_rphy(hw, MII_BMCR, &phy_ctrl);  	if (ret_val)  		return ret_val; -	phy_ctrl |= (MII_CR_AUTO_NEG_EN | MII_CR_RESTART_AUTO_NEG); -	ret_val = e1e_wphy(hw, PHY_CONTROL, phy_ctrl); +	phy_ctrl |= (BMCR_ANENABLE | BMCR_ANRESTART); +	ret_val = e1e_wphy(hw, MII_BMCR, phy_ctrl);  	if (ret_val)  		return ret_val; @@ -1196,7 +1156,7 @@ s32 e1000e_setup_copper_link(struct e1000_hw *hw)  		 * depending on user settings.  		 */  		e_dbg("Forcing Speed and Duplex\n"); -		ret_val = e1000_phy_force_speed_duplex(hw); +		ret_val = hw->phy.ops.force_speed_duplex(hw);  		if (ret_val) {  			e_dbg("Error Forcing Speed and Duplex\n");  			return ret_val; @@ -1237,13 +1197,13 @@ s32 e1000e_phy_force_speed_duplex_igp(struct e1000_hw *hw)  	u16 phy_data;  	bool link; -	ret_val = e1e_rphy(hw, PHY_CONTROL, &phy_data); +	ret_val = e1e_rphy(hw, MII_BMCR, &phy_data);  	if (ret_val)  		return ret_val;  	e1000e_phy_force_speed_duplex_setup(hw, &phy_data); -	ret_val = e1e_wphy(hw, PHY_CONTROL, phy_data); +	ret_val = e1e_wphy(hw, MII_BMCR, phy_data);  	if (ret_val)  		return ret_val; @@ -1315,20 +1275,22 @@ s32 e1000e_phy_force_speed_duplex_m88(struct e1000_hw *hw)  	e_dbg("M88E1000 PSCR: %X\n", phy_data); -	ret_val = e1e_rphy(hw, PHY_CONTROL, &phy_data); +	ret_val = e1e_rphy(hw, MII_BMCR, &phy_data);  	if (ret_val)  		return ret_val;  	e1000e_phy_force_speed_duplex_setup(hw, &phy_data); -	ret_val = e1e_wphy(hw, PHY_CONTROL, phy_data); +	ret_val = e1e_wphy(hw, MII_BMCR, phy_data);  	if (ret_val)  		return ret_val;  	/* Reset the phy to commit changes. */ -	ret_val = e1000e_commit_phy(hw); -	if (ret_val) -		return ret_val; +	if (hw->phy.ops.commit) { +		ret_val = hw->phy.ops.commit(hw); +		if (ret_val) +			return ret_val; +	}  	if (phy->autoneg_wait_to_complete) {  		e_dbg("Waiting for forced speed/duplex link on M88 phy.\n"); @@ -1406,13 +1368,13 @@ s32 e1000_phy_force_speed_duplex_ife(struct e1000_hw *hw)  	u16 data;  	bool link; -	ret_val = e1e_rphy(hw, PHY_CONTROL, &data); +	ret_val = e1e_rphy(hw, MII_BMCR, &data);  	if (ret_val)  		return ret_val;  	e1000e_phy_force_speed_duplex_setup(hw, &data); -	ret_val = e1e_wphy(hw, PHY_CONTROL, data); +	ret_val = e1e_wphy(hw, MII_BMCR, data);  	if (ret_val)  		return ret_val; @@ -1456,13 +1418,13 @@ s32 e1000_phy_force_speed_duplex_ife(struct e1000_hw *hw)  /**   *  e1000e_phy_force_speed_duplex_setup - Configure forced PHY speed/duplex   *  @hw: pointer to the HW structure - *  @phy_ctrl: pointer to current value of PHY_CONTROL + *  @phy_ctrl: pointer to current value of MII_BMCR   *   *  Forces speed and duplex on the PHY by doing the following: disable flow   *  control, force speed/duplex on the MAC, disable auto speed detection,   *  disable auto-negotiation, configure duplex, configure speed, configure   *  the collision distance, write configuration to CTRL register.  The - *  caller must write to the PHY_CONTROL register for these settings to + *  caller must write to the MII_BMCR register for these settings to   *  take affect.   **/  void e1000e_phy_force_speed_duplex_setup(struct e1000_hw *hw, u16 *phy_ctrl) @@ -1482,29 +1444,28 @@ void e1000e_phy_force_speed_duplex_setup(struct e1000_hw *hw, u16 *phy_ctrl)  	ctrl &= ~E1000_CTRL_ASDE;  	/* Disable autoneg on the phy */ -	*phy_ctrl &= ~MII_CR_AUTO_NEG_EN; +	*phy_ctrl &= ~BMCR_ANENABLE;  	/* Forcing Full or Half Duplex? */  	if (mac->forced_speed_duplex & E1000_ALL_HALF_DUPLEX) {  		ctrl &= ~E1000_CTRL_FD; -		*phy_ctrl &= ~MII_CR_FULL_DUPLEX; +		*phy_ctrl &= ~BMCR_FULLDPLX;  		e_dbg("Half Duplex\n");  	} else {  		ctrl |= E1000_CTRL_FD; -		*phy_ctrl |= MII_CR_FULL_DUPLEX; +		*phy_ctrl |= BMCR_FULLDPLX;  		e_dbg("Full Duplex\n");  	}  	/* Forcing 10mb or 100mb? */  	if (mac->forced_speed_duplex & E1000_ALL_100_SPEED) {  		ctrl |= E1000_CTRL_SPD_100; -		*phy_ctrl |= MII_CR_SPEED_100; -		*phy_ctrl &= ~(MII_CR_SPEED_1000 | MII_CR_SPEED_10); +		*phy_ctrl |= BMCR_SPEED100; +		*phy_ctrl &= ~BMCR_SPEED1000;  		e_dbg("Forcing 100mb\n");  	} else {  		ctrl &= ~(E1000_CTRL_SPD_1000 | E1000_CTRL_SPD_100); -		*phy_ctrl |= MII_CR_SPEED_10; -		*phy_ctrl &= ~(MII_CR_SPEED_1000 | MII_CR_SPEED_100); +		*phy_ctrl &= ~(BMCR_SPEED1000 | BMCR_SPEED100);  		e_dbg("Forcing 10mb\n");  	} @@ -1745,13 +1706,13 @@ static s32 e1000_wait_autoneg(struct e1000_hw *hw)  	/* Break after autoneg completes or PHY_AUTO_NEG_LIMIT expires. */  	for (i = PHY_AUTO_NEG_LIMIT; i > 0; i--) { -		ret_val = e1e_rphy(hw, PHY_STATUS, &phy_status); +		ret_val = e1e_rphy(hw, MII_BMSR, &phy_status);  		if (ret_val)  			break; -		ret_val = e1e_rphy(hw, PHY_STATUS, &phy_status); +		ret_val = e1e_rphy(hw, MII_BMSR, &phy_status);  		if (ret_val)  			break; -		if (phy_status & MII_SR_AUTONEG_COMPLETE) +		if (phy_status & BMSR_ANEGCOMPLETE)  			break;  		msleep(100);  	} @@ -1778,21 +1739,21 @@ s32 e1000e_phy_has_link_generic(struct e1000_hw *hw, u32 iterations,  	u16 i, phy_status;  	for (i = 0; i < iterations; i++) { -		/* Some PHYs require the PHY_STATUS register to be read +		/* Some PHYs require the MII_BMSR register to be read  		 * twice due to the link bit being sticky.  No harm doing  		 * it across the board.  		 */ -		ret_val = e1e_rphy(hw, PHY_STATUS, &phy_status); +		ret_val = e1e_rphy(hw, MII_BMSR, &phy_status);  		if (ret_val)  			/* If the first read fails, another entity may have  			 * ownership of the resources, wait and try again to  			 * see if they have relinquished the resources yet.  			 */  			udelay(usec_interval); -		ret_val = e1e_rphy(hw, PHY_STATUS, &phy_status); +		ret_val = e1e_rphy(hw, MII_BMSR, &phy_status);  		if (ret_val)  			break; -		if (phy_status & MII_SR_LINK_STATUS) +		if (phy_status & BMSR_LSTATUS)  			break;  		if (usec_interval >= 1000)  			mdelay(usec_interval/1000); @@ -1962,21 +1923,19 @@ s32 e1000e_get_phy_info_m88(struct e1000_hw *hw)  	phy->is_mdix = !!(phy_data & M88E1000_PSSR_MDIX);  	if ((phy_data & M88E1000_PSSR_SPEED) == M88E1000_PSSR_1000MBS) { -		ret_val = e1000_get_cable_length(hw); +		ret_val = hw->phy.ops.get_cable_length(hw);  		if (ret_val)  			return ret_val; -		ret_val = e1e_rphy(hw, PHY_1000T_STATUS, &phy_data); +		ret_val = e1e_rphy(hw, MII_STAT1000, &phy_data);  		if (ret_val)  			return ret_val; -		phy->local_rx = (phy_data & SR_1000T_LOCAL_RX_STATUS) -				? e1000_1000t_rx_status_ok -				: e1000_1000t_rx_status_not_ok; +		phy->local_rx = (phy_data & LPA_1000LOCALRXOK) +		    ? e1000_1000t_rx_status_ok : e1000_1000t_rx_status_not_ok; -		phy->remote_rx = (phy_data & SR_1000T_REMOTE_RX_STATUS) -				 ? e1000_1000t_rx_status_ok -				 : e1000_1000t_rx_status_not_ok; +		phy->remote_rx = (phy_data & LPA_1000REMRXOK) +		    ? e1000_1000t_rx_status_ok : e1000_1000t_rx_status_not_ok;  	} else {  		/* Set values to "undefined" */  		phy->cable_length = E1000_CABLE_LENGTH_UNDEFINED; @@ -2026,21 +1985,19 @@ s32 e1000e_get_phy_info_igp(struct e1000_hw *hw)  	if ((data & IGP01E1000_PSSR_SPEED_MASK) ==  	    IGP01E1000_PSSR_SPEED_1000MBPS) { -		ret_val = e1000_get_cable_length(hw); +		ret_val = phy->ops.get_cable_length(hw);  		if (ret_val)  			return ret_val; -		ret_val = e1e_rphy(hw, PHY_1000T_STATUS, &data); +		ret_val = e1e_rphy(hw, MII_STAT1000, &data);  		if (ret_val)  			return ret_val; -		phy->local_rx = (data & SR_1000T_LOCAL_RX_STATUS) -				? e1000_1000t_rx_status_ok -				: e1000_1000t_rx_status_not_ok; +		phy->local_rx = (data & LPA_1000LOCALRXOK) +		    ? e1000_1000t_rx_status_ok : e1000_1000t_rx_status_not_ok; -		phy->remote_rx = (data & SR_1000T_REMOTE_RX_STATUS) -				 ? e1000_1000t_rx_status_ok -				 : e1000_1000t_rx_status_not_ok; +		phy->remote_rx = (data & LPA_1000REMRXOK) +		    ? e1000_1000t_rx_status_ok : e1000_1000t_rx_status_not_ok;  	} else {  		phy->cable_length = E1000_CABLE_LENGTH_UNDEFINED;  		phy->local_rx = e1000_1000t_rx_status_undefined; @@ -2114,12 +2071,12 @@ s32 e1000e_phy_sw_reset(struct e1000_hw *hw)  	s32 ret_val;  	u16 phy_ctrl; -	ret_val = e1e_rphy(hw, PHY_CONTROL, &phy_ctrl); +	ret_val = e1e_rphy(hw, MII_BMCR, &phy_ctrl);  	if (ret_val)  		return ret_val; -	phy_ctrl |= MII_CR_RESET; -	ret_val = e1e_wphy(hw, PHY_CONTROL, phy_ctrl); +	phy_ctrl |= BMCR_RESET; +	ret_val = e1e_wphy(hw, MII_BMCR, phy_ctrl);  	if (ret_val)  		return ret_val; @@ -2166,17 +2123,17 @@ s32 e1000e_phy_hw_reset_generic(struct e1000_hw *hw)  	phy->ops.release(hw); -	return e1000_get_phy_cfg_done(hw); +	return phy->ops.get_cfg_done(hw);  }  /** - *  e1000e_get_cfg_done - Generic configuration done + *  e1000e_get_cfg_done_generic - Generic configuration done   *  @hw: pointer to the HW structure   *   *  Generic function to wait 10 milli-seconds for configuration to complete   *  and return success.   **/ -s32 e1000e_get_cfg_done(struct e1000_hw *hw) +s32 e1000e_get_cfg_done_generic(struct e1000_hw __always_unused *hw)  {  	mdelay(10); @@ -2266,38 +2223,6 @@ s32 e1000e_phy_init_script_igp3(struct e1000_hw *hw)  	return 0;  } -/* Internal function pointers */ - -/** - *  e1000_get_phy_cfg_done - Generic PHY configuration done - *  @hw: pointer to the HW structure - * - *  Return success if silicon family did not implement a family specific - *  get_cfg_done function. - **/ -static s32 e1000_get_phy_cfg_done(struct e1000_hw *hw) -{ -	if (hw->phy.ops.get_cfg_done) -		return hw->phy.ops.get_cfg_done(hw); - -	return 0; -} - -/** - *  e1000_phy_force_speed_duplex - Generic force PHY speed/duplex - *  @hw: pointer to the HW structure - * - *  When the silicon family has not implemented a forced speed/duplex - *  function for the PHY, simply return 0. - **/ -static s32 e1000_phy_force_speed_duplex(struct e1000_hw *hw) -{ -	if (hw->phy.ops.force_speed_duplex) -		return hw->phy.ops.force_speed_duplex(hw); - -	return 0; -} -  /**   *  e1000e_get_phy_type_from_id - Get PHY type from id   *  @phy_id: phy_id read from the phy @@ -2549,7 +2474,6 @@ s32 e1000e_read_phy_reg_bm2(struct e1000_hw *hw, u32 offset, u16 *data)  	hw->phy.addr = 1;  	if (offset > MAX_PHY_MULTI_PAGE_REG) { -  		/* Page is shifted left, PHY expects (page x 32) */  		ret_val = e1000e_write_phy_reg_mdic(hw, BM_PHY_PAGE_SELECT,  						    page); @@ -2672,7 +2596,7 @@ s32 e1000_enable_phy_wakeup_reg_access_bm(struct e1000_hw *hw, u16 *phy_reg)   **/  s32 e1000_disable_phy_wakeup_reg_access_bm(struct e1000_hw *hw, u16 *phy_reg)  { -	s32 ret_val = 0; +	s32 ret_val;  	/* Select Port Control Registers page */  	ret_val = e1000_set_page_igp(hw, (BM_PORT_CTRL_PAGE << IGP_PAGE_SHIFT)); @@ -2781,9 +2705,9 @@ void e1000_power_up_phy_copper(struct e1000_hw *hw)  	u16 mii_reg = 0;  	/* The PHY will retain its settings across a power down/up cycle */ -	e1e_rphy(hw, PHY_CONTROL, &mii_reg); -	mii_reg &= ~MII_CR_POWER_DOWN; -	e1e_wphy(hw, PHY_CONTROL, mii_reg); +	e1e_rphy(hw, MII_BMCR, &mii_reg); +	mii_reg &= ~BMCR_PDOWN; +	e1e_wphy(hw, MII_BMCR, mii_reg);  }  /** @@ -2799,50 +2723,13 @@ void e1000_power_down_phy_copper(struct e1000_hw *hw)  	u16 mii_reg = 0;  	/* The PHY will retain its settings across a power down/up cycle */ -	e1e_rphy(hw, PHY_CONTROL, &mii_reg); -	mii_reg |= MII_CR_POWER_DOWN; -	e1e_wphy(hw, PHY_CONTROL, mii_reg); +	e1e_rphy(hw, MII_BMCR, &mii_reg); +	mii_reg |= BMCR_PDOWN; +	e1e_wphy(hw, MII_BMCR, mii_reg);  	usleep_range(1000, 2000);  }  /** - *  e1000e_commit_phy - Soft PHY reset - *  @hw: pointer to the HW structure - * - *  Performs a soft PHY reset on those that apply. This is a function pointer - *  entry point called by drivers. - **/ -s32 e1000e_commit_phy(struct e1000_hw *hw) -{ -	if (hw->phy.ops.commit) -		return hw->phy.ops.commit(hw); - -	return 0; -} - -/** - *  e1000_set_d0_lplu_state - Sets low power link up state for D0 - *  @hw: pointer to the HW structure - *  @active: boolean used to enable/disable lplu - * - *  Success returns 0, Failure returns 1 - * - *  The low power link up (lplu) state is set to the power management level D0 - *  and SmartSpeed is disabled when active is true, else clear lplu for D0 - *  and enable Smartspeed.  LPLU and Smartspeed are mutually exclusive.  LPLU - *  is used during Dx states where the power conservation is most important. - *  During driver activity, SmartSpeed should be enabled so performance is - *  maintained.  This is a function pointer entry point called by drivers. - **/ -static s32 e1000_set_d0_lplu_state(struct e1000_hw *hw, bool active) -{ -	if (hw->phy.ops.set_d0_lplu_state) -		return hw->phy.ops.set_d0_lplu_state(hw, active); - -	return 0; -} - -/**   *  __e1000_read_phy_reg_hv -  Read HV PHY register   *  @hw: pointer to the HW structure   *  @offset: register offset to be read @@ -3104,8 +2991,8 @@ static s32 e1000_access_phy_debug_regs_hv(struct e1000_hw *hw, u32 offset,                                            u16 *data, bool read)  {  	s32 ret_val; -	u32 addr_reg = 0; -	u32 data_reg = 0; +	u32 addr_reg; +	u32 data_reg;  	/* This takes care of the difference with desktop vs mobile phy */  	addr_reg = (hw->phy.type == e1000_phy_82578) ? @@ -3154,8 +3041,8 @@ s32 e1000_link_stall_workaround_hv(struct e1000_hw *hw)  		return 0;  	/* Do not apply workaround if in PHY loopback bit 14 set */ -	e1e_rphy(hw, PHY_CONTROL, &data); -	if (data & PHY_CONTROL_LB) +	e1e_rphy(hw, MII_BMCR, &data); +	if (data & BMCR_LOOPBACK)  		return 0;  	/* check if link is up and at 1Gbps */ @@ -3173,8 +3060,9 @@ s32 e1000_link_stall_workaround_hv(struct e1000_hw *hw)  	msleep(200);  	/* flush the packets in the fifo buffer */ -	ret_val = e1e_wphy(hw, HV_MUX_DATA_CTRL, HV_MUX_DATA_CTRL_GEN_TO_MAC | -			   HV_MUX_DATA_CTRL_FORCE_SPEED); +	ret_val = e1e_wphy(hw, HV_MUX_DATA_CTRL, +			   (HV_MUX_DATA_CTRL_GEN_TO_MAC | +			    HV_MUX_DATA_CTRL_FORCE_SPEED));  	if (ret_val)  		return ret_val; @@ -3218,13 +3106,13 @@ s32 e1000_phy_force_speed_duplex_82577(struct e1000_hw *hw)  	u16 phy_data;  	bool link; -	ret_val = e1e_rphy(hw, PHY_CONTROL, &phy_data); +	ret_val = e1e_rphy(hw, MII_BMCR, &phy_data);  	if (ret_val)  		return ret_val;  	e1000e_phy_force_speed_duplex_setup(hw, &phy_data); -	ret_val = e1e_wphy(hw, PHY_CONTROL, phy_data); +	ret_val = e1e_wphy(hw, MII_BMCR, phy_data);  	if (ret_val)  		return ret_val; @@ -3292,17 +3180,15 @@ s32 e1000_get_phy_info_82577(struct e1000_hw *hw)  		if (ret_val)  			return ret_val; -		ret_val = e1e_rphy(hw, PHY_1000T_STATUS, &data); +		ret_val = e1e_rphy(hw, MII_STAT1000, &data);  		if (ret_val)  			return ret_val; -		phy->local_rx = (data & SR_1000T_LOCAL_RX_STATUS) -		                ? e1000_1000t_rx_status_ok -		                : e1000_1000t_rx_status_not_ok; +		phy->local_rx = (data & LPA_1000LOCALRXOK) +		    ? e1000_1000t_rx_status_ok : e1000_1000t_rx_status_not_ok; -		phy->remote_rx = (data & SR_1000T_REMOTE_RX_STATUS) -		                 ? e1000_1000t_rx_status_ok -		                 : e1000_1000t_rx_status_not_ok; +		phy->remote_rx = (data & LPA_1000REMRXOK) +		    ? e1000_1000t_rx_status_ok : e1000_1000t_rx_status_not_ok;  	} else {  		phy->cable_length = E1000_CABLE_LENGTH_UNDEFINED;  		phy->local_rx = e1000_1000t_rx_status_undefined; @@ -3333,7 +3219,7 @@ s32 e1000_get_cable_length_82577(struct e1000_hw *hw)  	         I82577_DSTATUS_CABLE_LENGTH_SHIFT;  	if (length == E1000_CABLE_LENGTH_UNDEFINED) -		ret_val = -E1000_ERR_PHY; +		return -E1000_ERR_PHY;  	phy->cable_length = length; diff --git a/drivers/net/ethernet/intel/e1000e/phy.h b/drivers/net/ethernet/intel/e1000e/phy.h new file mode 100644 index 00000000000..f4f71b9991e --- /dev/null +++ b/drivers/net/ethernet/intel/e1000e/phy.h @@ -0,0 +1,242 @@ +/******************************************************************************* + +  Intel PRO/1000 Linux driver +  Copyright(c) 1999 - 2013 Intel Corporation. + +  This program is free software; you can redistribute it and/or modify it +  under the terms and conditions of the GNU General Public License, +  version 2, as published by the Free Software Foundation. + +  This program is distributed in the hope it will be useful, but WITHOUT +  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for +  more details. + +  You should have received a copy of the GNU General Public License along with +  this program; if not, write to the Free Software Foundation, Inc., +  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + +  The full GNU General Public License is included in this distribution in +  the file called "COPYING". + +  Contact Information: +  Linux NICS <linux.nics@intel.com> +  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> +  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + +*******************************************************************************/ + +#ifndef _E1000E_PHY_H_ +#define _E1000E_PHY_H_ + +s32 e1000e_check_downshift(struct e1000_hw *hw); +s32 e1000_check_polarity_m88(struct e1000_hw *hw); +s32 e1000_check_polarity_igp(struct e1000_hw *hw); +s32 e1000_check_polarity_ife(struct e1000_hw *hw); +s32 e1000e_check_reset_block_generic(struct e1000_hw *hw); +s32 e1000e_copper_link_setup_igp(struct e1000_hw *hw); +s32 e1000e_copper_link_setup_m88(struct e1000_hw *hw); +s32 e1000e_phy_force_speed_duplex_igp(struct e1000_hw *hw); +s32 e1000e_phy_force_speed_duplex_m88(struct e1000_hw *hw); +s32 e1000_phy_force_speed_duplex_ife(struct e1000_hw *hw); +s32 e1000e_get_cable_length_m88(struct e1000_hw *hw); +s32 e1000e_get_cable_length_igp_2(struct e1000_hw *hw); +s32 e1000e_get_cfg_done_generic(struct e1000_hw *hw); +s32 e1000e_get_phy_id(struct e1000_hw *hw); +s32 e1000e_get_phy_info_igp(struct e1000_hw *hw); +s32 e1000e_get_phy_info_m88(struct e1000_hw *hw); +s32 e1000_get_phy_info_ife(struct e1000_hw *hw); +s32 e1000e_phy_sw_reset(struct e1000_hw *hw); +void e1000e_phy_force_speed_duplex_setup(struct e1000_hw *hw, u16 *phy_ctrl); +s32 e1000e_phy_hw_reset_generic(struct e1000_hw *hw); +s32 e1000e_phy_reset_dsp(struct e1000_hw *hw); +s32 e1000e_read_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 *data); +s32 e1000e_read_kmrn_reg_locked(struct e1000_hw *hw, u32 offset, u16 *data); +s32 e1000_set_page_igp(struct e1000_hw *hw, u16 page); +s32 e1000e_read_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 *data); +s32 e1000e_read_phy_reg_igp_locked(struct e1000_hw *hw, u32 offset, u16 *data); +s32 e1000e_read_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 *data); +s32 e1000e_set_d3_lplu_state(struct e1000_hw *hw, bool active); +s32 e1000e_setup_copper_link(struct e1000_hw *hw); +s32 e1000e_write_kmrn_reg(struct e1000_hw *hw, u32 offset, u16 data); +s32 e1000e_write_kmrn_reg_locked(struct e1000_hw *hw, u32 offset, u16 data); +s32 e1000e_write_phy_reg_igp(struct e1000_hw *hw, u32 offset, u16 data); +s32 e1000e_write_phy_reg_igp_locked(struct e1000_hw *hw, u32 offset, u16 data); +s32 e1000e_write_phy_reg_m88(struct e1000_hw *hw, u32 offset, u16 data); +s32 e1000e_phy_has_link_generic(struct e1000_hw *hw, u32 iterations, +				u32 usec_interval, bool *success); +s32 e1000e_phy_init_script_igp3(struct e1000_hw *hw); +enum e1000_phy_type e1000e_get_phy_type_from_id(u32 phy_id); +s32 e1000e_determine_phy_address(struct e1000_hw *hw); +s32 e1000e_write_phy_reg_bm(struct e1000_hw *hw, u32 offset, u16 data); +s32 e1000e_read_phy_reg_bm(struct e1000_hw *hw, u32 offset, u16 *data); +s32 e1000_enable_phy_wakeup_reg_access_bm(struct e1000_hw *hw, u16 *phy_reg); +s32 e1000_disable_phy_wakeup_reg_access_bm(struct e1000_hw *hw, u16 *phy_reg); +s32 e1000e_read_phy_reg_bm2(struct e1000_hw *hw, u32 offset, u16 *data); +s32 e1000e_write_phy_reg_bm2(struct e1000_hw *hw, u32 offset, u16 data); +void e1000_power_up_phy_copper(struct e1000_hw *hw); +void e1000_power_down_phy_copper(struct e1000_hw *hw); +s32 e1000e_read_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 *data); +s32 e1000e_write_phy_reg_mdic(struct e1000_hw *hw, u32 offset, u16 data); +s32 e1000_read_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 *data); +s32 e1000_read_phy_reg_hv_locked(struct e1000_hw *hw, u32 offset, u16 *data); +s32 e1000_read_phy_reg_page_hv(struct e1000_hw *hw, u32 offset, u16 *data); +s32 e1000_write_phy_reg_hv(struct e1000_hw *hw, u32 offset, u16 data); +s32 e1000_write_phy_reg_hv_locked(struct e1000_hw *hw, u32 offset, u16 data); +s32 e1000_write_phy_reg_page_hv(struct e1000_hw *hw, u32 offset, u16 data); +s32 e1000_link_stall_workaround_hv(struct e1000_hw *hw); +s32 e1000_copper_link_setup_82577(struct e1000_hw *hw); +s32 e1000_check_polarity_82577(struct e1000_hw *hw); +s32 e1000_get_phy_info_82577(struct e1000_hw *hw); +s32 e1000_phy_force_speed_duplex_82577(struct e1000_hw *hw); +s32 e1000_get_cable_length_82577(struct e1000_hw *hw); + +#define E1000_MAX_PHY_ADDR		8 + +/* IGP01E1000 Specific Registers */ +#define IGP01E1000_PHY_PORT_CONFIG	0x10	/* Port Config */ +#define IGP01E1000_PHY_PORT_STATUS	0x11	/* Status */ +#define IGP01E1000_PHY_PORT_CTRL	0x12	/* Control */ +#define IGP01E1000_PHY_LINK_HEALTH	0x13	/* PHY Link Health */ +#define IGP02E1000_PHY_POWER_MGMT	0x19	/* Power Management */ +#define IGP01E1000_PHY_PAGE_SELECT	0x1F	/* Page Select */ +#define BM_PHY_PAGE_SELECT		22	/* Page Select for BM */ +#define IGP_PAGE_SHIFT			5 +#define PHY_REG_MASK			0x1F + +/* BM/HV Specific Registers */ +#define BM_PORT_CTRL_PAGE		769 +#define BM_WUC_PAGE			800 +#define BM_WUC_ADDRESS_OPCODE		0x11 +#define BM_WUC_DATA_OPCODE		0x12 +#define BM_WUC_ENABLE_PAGE		BM_PORT_CTRL_PAGE +#define BM_WUC_ENABLE_REG		17 +#define BM_WUC_ENABLE_BIT		(1 << 2) +#define BM_WUC_HOST_WU_BIT		(1 << 4) +#define BM_WUC_ME_WU_BIT		(1 << 5) + +#define PHY_UPPER_SHIFT			21 +#define BM_PHY_REG(page, reg) \ +	(((reg) & MAX_PHY_REG_ADDRESS) |\ +	 (((page) & 0xFFFF) << PHY_PAGE_SHIFT) |\ +	 (((reg) & ~MAX_PHY_REG_ADDRESS) << (PHY_UPPER_SHIFT - PHY_PAGE_SHIFT))) +#define BM_PHY_REG_PAGE(offset) \ +	((u16)(((offset) >> PHY_PAGE_SHIFT) & 0xFFFF)) +#define BM_PHY_REG_NUM(offset) \ +	((u16)(((offset) & MAX_PHY_REG_ADDRESS) |\ +	 (((offset) >> (PHY_UPPER_SHIFT - PHY_PAGE_SHIFT)) &\ +		~MAX_PHY_REG_ADDRESS))) + +#define HV_INTC_FC_PAGE_START		768 +#define I82578_ADDR_REG			29 +#define I82577_ADDR_REG			16 +#define I82577_CFG_REG			22 +#define I82577_CFG_ASSERT_CRS_ON_TX	(1 << 15) +#define I82577_CFG_ENABLE_DOWNSHIFT	(3 << 10)	/* auto downshift */ +#define I82577_CTRL_REG			23 + +/* 82577 specific PHY registers */ +#define I82577_PHY_CTRL_2		18 +#define I82577_PHY_LBK_CTRL		19 +#define I82577_PHY_STATUS_2		26 +#define I82577_PHY_DIAG_STATUS		31 + +/* I82577 PHY Status 2 */ +#define I82577_PHY_STATUS2_REV_POLARITY		0x0400 +#define I82577_PHY_STATUS2_MDIX			0x0800 +#define I82577_PHY_STATUS2_SPEED_MASK		0x0300 +#define I82577_PHY_STATUS2_SPEED_1000MBPS	0x0200 + +/* I82577 PHY Control 2 */ +#define I82577_PHY_CTRL2_MANUAL_MDIX		0x0200 +#define I82577_PHY_CTRL2_AUTO_MDI_MDIX		0x0400 +#define I82577_PHY_CTRL2_MDIX_CFG_MASK		0x0600 + +/* I82577 PHY Diagnostics Status */ +#define I82577_DSTATUS_CABLE_LENGTH		0x03FC +#define I82577_DSTATUS_CABLE_LENGTH_SHIFT	2 + +/* BM PHY Copper Specific Control 1 */ +#define BM_CS_CTRL1			16 + +/* BM PHY Copper Specific Status */ +#define BM_CS_STATUS			17 +#define BM_CS_STATUS_LINK_UP		0x0400 +#define BM_CS_STATUS_RESOLVED		0x0800 +#define BM_CS_STATUS_SPEED_MASK		0xC000 +#define BM_CS_STATUS_SPEED_1000		0x8000 + +/* 82577 Mobile Phy Status Register */ +#define HV_M_STATUS			26 +#define HV_M_STATUS_AUTONEG_COMPLETE	0x1000 +#define HV_M_STATUS_SPEED_MASK		0x0300 +#define HV_M_STATUS_SPEED_1000		0x0200 +#define HV_M_STATUS_LINK_UP		0x0040 + +#define IGP01E1000_PHY_PCS_INIT_REG	0x00B4 +#define IGP01E1000_PHY_POLARITY_MASK	0x0078 + +#define IGP01E1000_PSCR_AUTO_MDIX	0x1000 +#define IGP01E1000_PSCR_FORCE_MDI_MDIX	0x2000	/* 0=MDI, 1=MDIX */ + +#define IGP01E1000_PSCFR_SMART_SPEED	0x0080 + +#define IGP02E1000_PM_SPD		0x0001	/* Smart Power Down */ +#define IGP02E1000_PM_D0_LPLU		0x0002	/* For D0a states */ +#define IGP02E1000_PM_D3_LPLU		0x0004	/* For all other states */ + +#define IGP01E1000_PLHR_SS_DOWNGRADE	0x8000 + +#define IGP01E1000_PSSR_POLARITY_REVERSED	0x0002 +#define IGP01E1000_PSSR_MDIX		0x0800 +#define IGP01E1000_PSSR_SPEED_MASK	0xC000 +#define IGP01E1000_PSSR_SPEED_1000MBPS	0xC000 + +#define IGP02E1000_PHY_CHANNEL_NUM	4 +#define IGP02E1000_PHY_AGC_A		0x11B1 +#define IGP02E1000_PHY_AGC_B		0x12B1 +#define IGP02E1000_PHY_AGC_C		0x14B1 +#define IGP02E1000_PHY_AGC_D		0x18B1 + +#define IGP02E1000_AGC_LENGTH_SHIFT	9	/* Course=15:13, Fine=12:9 */ +#define IGP02E1000_AGC_LENGTH_MASK	0x7F +#define IGP02E1000_AGC_RANGE		15 + +#define E1000_CABLE_LENGTH_UNDEFINED	0xFF + +#define E1000_KMRNCTRLSTA_OFFSET	0x001F0000 +#define E1000_KMRNCTRLSTA_OFFSET_SHIFT	16 +#define E1000_KMRNCTRLSTA_REN		0x00200000 +#define E1000_KMRNCTRLSTA_CTRL_OFFSET	0x1	/* Kumeran Control */ +#define E1000_KMRNCTRLSTA_DIAG_OFFSET	0x3	/* Kumeran Diagnostic */ +#define E1000_KMRNCTRLSTA_TIMEOUTS	0x4	/* Kumeran Timeouts */ +#define E1000_KMRNCTRLSTA_INBAND_PARAM	0x9	/* Kumeran InBand Parameters */ +#define E1000_KMRNCTRLSTA_IBIST_DISABLE	0x0200	/* Kumeran IBIST Disable */ +#define E1000_KMRNCTRLSTA_DIAG_NELPBK	0x1000	/* Nearend Loopback mode */ +#define E1000_KMRNCTRLSTA_K1_CONFIG	0x7 +#define E1000_KMRNCTRLSTA_K1_ENABLE	0x0002	/* enable K1 */ +#define E1000_KMRNCTRLSTA_HD_CTRL	0x10	/* Kumeran HD Control */ + +#define IFE_PHY_EXTENDED_STATUS_CONTROL	0x10 +#define IFE_PHY_SPECIAL_CONTROL		0x11	/* 100BaseTx PHY Special Ctrl */ +#define IFE_PHY_SPECIAL_CONTROL_LED	0x1B	/* PHY Special and LED Ctrl */ +#define IFE_PHY_MDIX_CONTROL		0x1C	/* MDI/MDI-X Control */ + +/* IFE PHY Extended Status Control */ +#define IFE_PESC_POLARITY_REVERSED	0x0100 + +/* IFE PHY Special Control */ +#define IFE_PSC_AUTO_POLARITY_DISABLE	0x0010 +#define IFE_PSC_FORCE_POLARITY		0x0020 + +/* IFE PHY Special Control and LED Control */ +#define IFE_PSCL_PROBE_MODE		0x0020 +#define IFE_PSCL_PROBE_LEDS_OFF		0x0006	/* Force LEDs 0 and 2 off */ +#define IFE_PSCL_PROBE_LEDS_ON		0x0007	/* Force LEDs 0 and 2 on */ + +/* IFE PHY MDIX Control */ +#define IFE_PMC_MDIX_STATUS		0x0020	/* 1=MDI-X, 0=MDI */ +#define IFE_PMC_FORCE_MDIX		0x0040	/* 1=force MDI-X, 0=force MDI */ +#define IFE_PMC_AUTO_MDIX		0x0080	/* 1=enable auto, 0=disable */ + +#endif diff --git a/drivers/net/ethernet/intel/e1000e/ptp.c b/drivers/net/ethernet/intel/e1000e/ptp.c new file mode 100644 index 00000000000..b477fa53ec9 --- /dev/null +++ b/drivers/net/ethernet/intel/e1000e/ptp.c @@ -0,0 +1,277 @@ +/******************************************************************************* + +  Intel PRO/1000 Linux driver +  Copyright(c) 1999 - 2013 Intel Corporation. + +  This program is free software; you can redistribute it and/or modify it +  under the terms and conditions of the GNU General Public License, +  version 2, as published by the Free Software Foundation. + +  This program is distributed in the hope it will be useful, but WITHOUT +  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for +  more details. + +  You should have received a copy of the GNU General Public License along with +  this program; if not, write to the Free Software Foundation, Inc., +  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + +  The full GNU General Public License is included in this distribution in +  the file called "COPYING". + +  Contact Information: +  Linux NICS <linux.nics@intel.com> +  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> +  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + +*******************************************************************************/ + +/* PTP 1588 Hardware Clock (PHC) + * Derived from PTP Hardware Clock driver for Intel 82576 and 82580 (igb) + * Copyright (C) 2011 Richard Cochran <richardcochran@gmail.com> + */ + +#include "e1000.h" + +/** + * e1000e_phc_adjfreq - adjust the frequency of the hardware clock + * @ptp: ptp clock structure + * @delta: Desired frequency change in parts per billion + * + * Adjust the frequency of the PHC cycle counter by the indicated delta from + * the base frequency. + **/ +static int e1000e_phc_adjfreq(struct ptp_clock_info *ptp, s32 delta) +{ +	struct e1000_adapter *adapter = container_of(ptp, struct e1000_adapter, +						     ptp_clock_info); +	struct e1000_hw *hw = &adapter->hw; +	bool neg_adj = false; +	u64 adjustment; +	u32 timinca, incvalue; +	s32 ret_val; + +	if ((delta > ptp->max_adj) || (delta <= -1000000000)) +		return -EINVAL; + +	if (delta < 0) { +		neg_adj = true; +		delta = -delta; +	} + +	/* Get the System Time Register SYSTIM base frequency */ +	ret_val = e1000e_get_base_timinca(adapter, &timinca); +	if (ret_val) +		return ret_val; + +	incvalue = timinca & E1000_TIMINCA_INCVALUE_MASK; + +	adjustment = incvalue; +	adjustment *= delta; +	adjustment = div_u64(adjustment, 1000000000); + +	incvalue = neg_adj ? (incvalue - adjustment) : (incvalue + adjustment); + +	timinca &= ~E1000_TIMINCA_INCVALUE_MASK; +	timinca |= incvalue; + +	ew32(TIMINCA, timinca); + +	return 0; +} + +/** + * e1000e_phc_adjtime - Shift the time of the hardware clock + * @ptp: ptp clock structure + * @delta: Desired change in nanoseconds + * + * Adjust the timer by resetting the timecounter structure. + **/ +static int e1000e_phc_adjtime(struct ptp_clock_info *ptp, s64 delta) +{ +	struct e1000_adapter *adapter = container_of(ptp, struct e1000_adapter, +						     ptp_clock_info); +	unsigned long flags; +	s64 now; + +	spin_lock_irqsave(&adapter->systim_lock, flags); +	now = timecounter_read(&adapter->tc); +	now += delta; +	timecounter_init(&adapter->tc, &adapter->cc, now); +	spin_unlock_irqrestore(&adapter->systim_lock, flags); + +	return 0; +} + +/** + * e1000e_phc_gettime - Reads the current time from the hardware clock + * @ptp: ptp clock structure + * @ts: timespec structure to hold the current time value + * + * Read the timecounter and return the correct value in ns after converting + * it into a struct timespec. + **/ +static int e1000e_phc_gettime(struct ptp_clock_info *ptp, struct timespec *ts) +{ +	struct e1000_adapter *adapter = container_of(ptp, struct e1000_adapter, +						     ptp_clock_info); +	unsigned long flags; +	u32 remainder; +	u64 ns; + +	spin_lock_irqsave(&adapter->systim_lock, flags); +	ns = timecounter_read(&adapter->tc); +	spin_unlock_irqrestore(&adapter->systim_lock, flags); + +	ts->tv_sec = div_u64_rem(ns, NSEC_PER_SEC, &remainder); +	ts->tv_nsec = remainder; + +	return 0; +} + +/** + * e1000e_phc_settime - Set the current time on the hardware clock + * @ptp: ptp clock structure + * @ts: timespec containing the new time for the cycle counter + * + * Reset the timecounter to use a new base value instead of the kernel + * wall timer value. + **/ +static int e1000e_phc_settime(struct ptp_clock_info *ptp, +			      const struct timespec *ts) +{ +	struct e1000_adapter *adapter = container_of(ptp, struct e1000_adapter, +						     ptp_clock_info); +	unsigned long flags; +	u64 ns; + +	ns = ts->tv_sec * NSEC_PER_SEC; +	ns += ts->tv_nsec; + +	/* reset the timecounter */ +	spin_lock_irqsave(&adapter->systim_lock, flags); +	timecounter_init(&adapter->tc, &adapter->cc, ns); +	spin_unlock_irqrestore(&adapter->systim_lock, flags); + +	return 0; +} + +/** + * e1000e_phc_enable - enable or disable an ancillary feature + * @ptp: ptp clock structure + * @request: Desired resource to enable or disable + * @on: Caller passes one to enable or zero to disable + * + * Enable (or disable) ancillary features of the PHC subsystem. + * Currently, no ancillary features are supported. + **/ +static int e1000e_phc_enable(struct ptp_clock_info __always_unused *ptp, +			     struct ptp_clock_request __always_unused *request, +			     int __always_unused on) +{ +	return -EOPNOTSUPP; +} + +static void e1000e_systim_overflow_work(struct work_struct *work) +{ +	struct e1000_adapter *adapter = container_of(work, struct e1000_adapter, +						     systim_overflow_work.work); +	struct e1000_hw *hw = &adapter->hw; +	struct timespec ts; + +	adapter->ptp_clock_info.gettime(&adapter->ptp_clock_info, &ts); + +	e_dbg("SYSTIM overflow check at %ld.%09lu\n", ts.tv_sec, ts.tv_nsec); + +	schedule_delayed_work(&adapter->systim_overflow_work, +			      E1000_SYSTIM_OVERFLOW_PERIOD); +} + +static const struct ptp_clock_info e1000e_ptp_clock_info = { +	.owner		= THIS_MODULE, +	.n_alarm	= 0, +	.n_ext_ts	= 0, +	.n_per_out	= 0, +	.pps		= 0, +	.adjfreq	= e1000e_phc_adjfreq, +	.adjtime	= e1000e_phc_adjtime, +	.gettime	= e1000e_phc_gettime, +	.settime	= e1000e_phc_settime, +	.enable		= e1000e_phc_enable, +}; + +/** + * e1000e_ptp_init - initialize PTP for devices which support it + * @adapter: board private structure + * + * This function performs the required steps for enabling PTP support. + * If PTP support has already been loaded it simply calls the cyclecounter + * init routine and exits. + **/ +void e1000e_ptp_init(struct e1000_adapter *adapter) +{ +	struct e1000_hw *hw = &adapter->hw; + +	adapter->ptp_clock = NULL; + +	if (!(adapter->flags & FLAG_HAS_HW_TIMESTAMP)) +		return; + +	adapter->ptp_clock_info = e1000e_ptp_clock_info; + +	snprintf(adapter->ptp_clock_info.name, +		 sizeof(adapter->ptp_clock_info.name), "%pm", +		 adapter->netdev->perm_addr); + +	switch (hw->mac.type) { +	case e1000_pch2lan: +	case e1000_pch_lpt: +		if ((hw->mac.type != e1000_pch_lpt) || +		    (er32(TSYNCRXCTL) & E1000_TSYNCRXCTL_SYSCFI)) { +			adapter->ptp_clock_info.max_adj = 24000000 - 1; +			break; +		} +		/* fall-through */ +	case e1000_82574: +	case e1000_82583: +		adapter->ptp_clock_info.max_adj = 600000000 - 1; +		break; +	default: +		break; +	} + +	INIT_DELAYED_WORK(&adapter->systim_overflow_work, +			  e1000e_systim_overflow_work); + +	schedule_delayed_work(&adapter->systim_overflow_work, +			      E1000_SYSTIM_OVERFLOW_PERIOD); + +	adapter->ptp_clock = ptp_clock_register(&adapter->ptp_clock_info, +						&adapter->pdev->dev); +	if (IS_ERR(adapter->ptp_clock)) { +		adapter->ptp_clock = NULL; +		e_err("ptp_clock_register failed\n"); +	} else { +		e_info("registered PHC clock\n"); +	} +} + +/** + * e1000e_ptp_remove - disable PTP device and stop the overflow check + * @adapter: board private structure + * + * Stop the PTP support, and cancel the delayed work. + **/ +void e1000e_ptp_remove(struct e1000_adapter *adapter) +{ +	if (!(adapter->flags & FLAG_HAS_HW_TIMESTAMP)) +		return; + +	cancel_delayed_work_sync(&adapter->systim_overflow_work); + +	if (adapter->ptp_clock) { +		ptp_clock_unregister(adapter->ptp_clock); +		adapter->ptp_clock = NULL; +		e_info("removed PHC\n"); +	} +} diff --git a/drivers/net/ethernet/intel/e1000e/regs.h b/drivers/net/ethernet/intel/e1000e/regs.h new file mode 100644 index 00000000000..794fe149766 --- /dev/null +++ b/drivers/net/ethernet/intel/e1000e/regs.h @@ -0,0 +1,252 @@ +/******************************************************************************* + +  Intel PRO/1000 Linux driver +  Copyright(c) 1999 - 2013 Intel Corporation. + +  This program is free software; you can redistribute it and/or modify it +  under the terms and conditions of the GNU General Public License, +  version 2, as published by the Free Software Foundation. + +  This program is distributed in the hope it will be useful, but WITHOUT +  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for +  more details. + +  You should have received a copy of the GNU General Public License along with +  this program; if not, write to the Free Software Foundation, Inc., +  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + +  The full GNU General Public License is included in this distribution in +  the file called "COPYING". + +  Contact Information: +  Linux NICS <linux.nics@intel.com> +  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> +  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + +*******************************************************************************/ + +#ifndef _E1000E_REGS_H_ +#define _E1000E_REGS_H_ + +#define E1000_CTRL	0x00000	/* Device Control - RW */ +#define E1000_STATUS	0x00008	/* Device Status - RO */ +#define E1000_EECD	0x00010	/* EEPROM/Flash Control - RW */ +#define E1000_EERD	0x00014	/* EEPROM Read - RW */ +#define E1000_CTRL_EXT	0x00018	/* Extended Device Control - RW */ +#define E1000_FLA	0x0001C	/* Flash Access - RW */ +#define E1000_MDIC	0x00020	/* MDI Control - RW */ +#define E1000_SCTL	0x00024	/* SerDes Control - RW */ +#define E1000_FCAL	0x00028	/* Flow Control Address Low - RW */ +#define E1000_FCAH	0x0002C	/* Flow Control Address High -RW */ +#define E1000_FEXTNVM	0x00028	/* Future Extended NVM - RW */ +#define E1000_FEXTNVM3	0x0003C	/* Future Extended NVM 3 - RW */ +#define E1000_FEXTNVM4	0x00024	/* Future Extended NVM 4 - RW */ +#define E1000_FEXTNVM7	0x000E4	/* Future Extended NVM 7 - RW */ +#define E1000_FCT	0x00030	/* Flow Control Type - RW */ +#define E1000_VET	0x00038	/* VLAN Ether Type - RW */ +#define E1000_ICR	0x000C0	/* Interrupt Cause Read - R/clr */ +#define E1000_ITR	0x000C4	/* Interrupt Throttling Rate - RW */ +#define E1000_ICS	0x000C8	/* Interrupt Cause Set - WO */ +#define E1000_IMS	0x000D0	/* Interrupt Mask Set - RW */ +#define E1000_IMC	0x000D8	/* Interrupt Mask Clear - WO */ +#define E1000_IAM	0x000E0	/* Interrupt Acknowledge Auto Mask */ +#define E1000_IVAR	0x000E4	/* Interrupt Vector Allocation Register - RW */ +#define E1000_SVCR	0x000F0 +#define E1000_SVT	0x000F4 +#define E1000_LPIC	0x000FC	/* Low Power IDLE control */ +#define E1000_RCTL	0x00100	/* Rx Control - RW */ +#define E1000_FCTTV	0x00170	/* Flow Control Transmit Timer Value - RW */ +#define E1000_TXCW	0x00178	/* Tx Configuration Word - RW */ +#define E1000_RXCW	0x00180	/* Rx Configuration Word - RO */ +#define E1000_PBA_ECC	0x01100	/* PBA ECC Register */ +#define E1000_TCTL	0x00400	/* Tx Control - RW */ +#define E1000_TCTL_EXT	0x00404	/* Extended Tx Control - RW */ +#define E1000_TIPG	0x00410	/* Tx Inter-packet gap -RW */ +#define E1000_AIT	0x00458	/* Adaptive Interframe Spacing Throttle - RW */ +#define E1000_LEDCTL	0x00E00	/* LED Control - RW */ +#define E1000_EXTCNF_CTRL	0x00F00	/* Extended Configuration Control */ +#define E1000_EXTCNF_SIZE	0x00F08	/* Extended Configuration Size */ +#define E1000_PHY_CTRL	0x00F10	/* PHY Control Register in CSR */ +#define E1000_POEMB	E1000_PHY_CTRL	/* PHY OEM Bits */ +#define E1000_PBA	0x01000	/* Packet Buffer Allocation - RW */ +#define E1000_PBS	0x01008	/* Packet Buffer Size */ +#define E1000_PBECCSTS	0x0100C	/* Packet Buffer ECC Status - RW */ +#define E1000_EEMNGCTL	0x01010	/* MNG EEprom Control */ +#define E1000_EEWR	0x0102C	/* EEPROM Write Register - RW */ +#define E1000_FLOP	0x0103C	/* FLASH Opcode Register */ +#define E1000_ERT	0x02008	/* Early Rx Threshold - RW */ +#define E1000_FCRTL	0x02160	/* Flow Control Receive Threshold Low - RW */ +#define E1000_FCRTH	0x02168	/* Flow Control Receive Threshold High - RW */ +#define E1000_PSRCTL	0x02170	/* Packet Split Receive Control - RW */ +#define E1000_RDFH	0x02410	/* Rx Data FIFO Head - RW */ +#define E1000_RDFT	0x02418	/* Rx Data FIFO Tail - RW */ +#define E1000_RDFHS	0x02420	/* Rx Data FIFO Head Saved - RW */ +#define E1000_RDFTS	0x02428	/* Rx Data FIFO Tail Saved - RW */ +#define E1000_RDFPC	0x02430	/* Rx Data FIFO Packet Count - RW */ +/* Split and Replication Rx Control - RW */ +#define E1000_RDTR	0x02820	/* Rx Delay Timer - RW */ +#define E1000_RADV	0x0282C	/* Rx Interrupt Absolute Delay Timer - RW */ +/* Convenience macros + * + * Note: "_n" is the queue number of the register to be written to. + * + * Example usage: + * E1000_RDBAL_REG(current_rx_queue) + */ +#define E1000_RDBAL(_n)	((_n) < 4 ? (0x02800 + ((_n) * 0x100)) : \ +			 (0x0C000 + ((_n) * 0x40))) +#define E1000_RDBAH(_n)	((_n) < 4 ? (0x02804 + ((_n) * 0x100)) : \ +			 (0x0C004 + ((_n) * 0x40))) +#define E1000_RDLEN(_n)	((_n) < 4 ? (0x02808 + ((_n) * 0x100)) : \ +			 (0x0C008 + ((_n) * 0x40))) +#define E1000_RDH(_n)	((_n) < 4 ? (0x02810 + ((_n) * 0x100)) : \ +			 (0x0C010 + ((_n) * 0x40))) +#define E1000_RDT(_n)	((_n) < 4 ? (0x02818 + ((_n) * 0x100)) : \ +			 (0x0C018 + ((_n) * 0x40))) +#define E1000_RXDCTL(_n)	((_n) < 4 ? (0x02828 + ((_n) * 0x100)) : \ +				 (0x0C028 + ((_n) * 0x40))) +#define E1000_TDBAL(_n)	((_n) < 4 ? (0x03800 + ((_n) * 0x100)) : \ +			 (0x0E000 + ((_n) * 0x40))) +#define E1000_TDBAH(_n)	((_n) < 4 ? (0x03804 + ((_n) * 0x100)) : \ +			 (0x0E004 + ((_n) * 0x40))) +#define E1000_TDLEN(_n)	((_n) < 4 ? (0x03808 + ((_n) * 0x100)) : \ +			 (0x0E008 + ((_n) * 0x40))) +#define E1000_TDH(_n)	((_n) < 4 ? (0x03810 + ((_n) * 0x100)) : \ +			 (0x0E010 + ((_n) * 0x40))) +#define E1000_TDT(_n)	((_n) < 4 ? (0x03818 + ((_n) * 0x100)) : \ +			 (0x0E018 + ((_n) * 0x40))) +#define E1000_TXDCTL(_n)	((_n) < 4 ? (0x03828 + ((_n) * 0x100)) : \ +				 (0x0E028 + ((_n) * 0x40))) +#define E1000_TARC(_n)		(0x03840 + ((_n) * 0x100)) +#define E1000_KABGTXD		0x03004	/* AFE Band Gap Transmit Ref Data */ +#define E1000_RAL(_i)		(((_i) <= 15) ? (0x05400 + ((_i) * 8)) : \ +				 (0x054E0 + ((_i - 16) * 8))) +#define E1000_RAH(_i)		(((_i) <= 15) ? (0x05404 + ((_i) * 8)) : \ +				 (0x054E4 + ((_i - 16) * 8))) +#define E1000_SHRAL(_i)		(0x05438 + ((_i) * 8)) +#define E1000_SHRAH(_i)		(0x0543C + ((_i) * 8)) +#define E1000_TDFH		0x03410	/* Tx Data FIFO Head - RW */ +#define E1000_TDFT		0x03418	/* Tx Data FIFO Tail - RW */ +#define E1000_TDFHS		0x03420	/* Tx Data FIFO Head Saved - RW */ +#define E1000_TDFTS		0x03428	/* Tx Data FIFO Tail Saved - RW */ +#define E1000_TDFPC		0x03430	/* Tx Data FIFO Packet Count - RW */ +#define E1000_TIDV	0x03820	/* Tx Interrupt Delay Value - RW */ +#define E1000_TADV	0x0382C	/* Tx Interrupt Absolute Delay Val - RW */ +#define E1000_CRCERRS	0x04000	/* CRC Error Count - R/clr */ +#define E1000_ALGNERRC	0x04004	/* Alignment Error Count - R/clr */ +#define E1000_SYMERRS	0x04008	/* Symbol Error Count - R/clr */ +#define E1000_RXERRC	0x0400C	/* Receive Error Count - R/clr */ +#define E1000_MPC	0x04010	/* Missed Packet Count - R/clr */ +#define E1000_SCC	0x04014	/* Single Collision Count - R/clr */ +#define E1000_ECOL	0x04018	/* Excessive Collision Count - R/clr */ +#define E1000_MCC	0x0401C	/* Multiple Collision Count - R/clr */ +#define E1000_LATECOL	0x04020	/* Late Collision Count - R/clr */ +#define E1000_COLC	0x04028	/* Collision Count - R/clr */ +#define E1000_DC	0x04030	/* Defer Count - R/clr */ +#define E1000_TNCRS	0x04034	/* Tx-No CRS - R/clr */ +#define E1000_SEC	0x04038	/* Sequence Error Count - R/clr */ +#define E1000_CEXTERR	0x0403C	/* Carrier Extension Error Count - R/clr */ +#define E1000_RLEC	0x04040	/* Receive Length Error Count - R/clr */ +#define E1000_XONRXC	0x04048	/* XON Rx Count - R/clr */ +#define E1000_XONTXC	0x0404C	/* XON Tx Count - R/clr */ +#define E1000_XOFFRXC	0x04050	/* XOFF Rx Count - R/clr */ +#define E1000_XOFFTXC	0x04054	/* XOFF Tx Count - R/clr */ +#define E1000_FCRUC	0x04058	/* Flow Control Rx Unsupported Count- R/clr */ +#define E1000_PRC64	0x0405C	/* Packets Rx (64 bytes) - R/clr */ +#define E1000_PRC127	0x04060	/* Packets Rx (65-127 bytes) - R/clr */ +#define E1000_PRC255	0x04064	/* Packets Rx (128-255 bytes) - R/clr */ +#define E1000_PRC511	0x04068	/* Packets Rx (255-511 bytes) - R/clr */ +#define E1000_PRC1023	0x0406C	/* Packets Rx (512-1023 bytes) - R/clr */ +#define E1000_PRC1522	0x04070	/* Packets Rx (1024-1522 bytes) - R/clr */ +#define E1000_GPRC	0x04074	/* Good Packets Rx Count - R/clr */ +#define E1000_BPRC	0x04078	/* Broadcast Packets Rx Count - R/clr */ +#define E1000_MPRC	0x0407C	/* Multicast Packets Rx Count - R/clr */ +#define E1000_GPTC	0x04080	/* Good Packets Tx Count - R/clr */ +#define E1000_GORCL	0x04088	/* Good Octets Rx Count Low - R/clr */ +#define E1000_GORCH	0x0408C	/* Good Octets Rx Count High - R/clr */ +#define E1000_GOTCL	0x04090	/* Good Octets Tx Count Low - R/clr */ +#define E1000_GOTCH	0x04094	/* Good Octets Tx Count High - R/clr */ +#define E1000_RNBC	0x040A0	/* Rx No Buffers Count - R/clr */ +#define E1000_RUC	0x040A4	/* Rx Undersize Count - R/clr */ +#define E1000_RFC	0x040A8	/* Rx Fragment Count - R/clr */ +#define E1000_ROC	0x040AC	/* Rx Oversize Count - R/clr */ +#define E1000_RJC	0x040B0	/* Rx Jabber Count - R/clr */ +#define E1000_MGTPRC	0x040B4	/* Management Packets Rx Count - R/clr */ +#define E1000_MGTPDC	0x040B8	/* Management Packets Dropped Count - R/clr */ +#define E1000_MGTPTC	0x040BC	/* Management Packets Tx Count - R/clr */ +#define E1000_TORL	0x040C0	/* Total Octets Rx Low - R/clr */ +#define E1000_TORH	0x040C4	/* Total Octets Rx High - R/clr */ +#define E1000_TOTL	0x040C8	/* Total Octets Tx Low - R/clr */ +#define E1000_TOTH	0x040CC	/* Total Octets Tx High - R/clr */ +#define E1000_TPR	0x040D0	/* Total Packets Rx - R/clr */ +#define E1000_TPT	0x040D4	/* Total Packets Tx - R/clr */ +#define E1000_PTC64	0x040D8	/* Packets Tx (64 bytes) - R/clr */ +#define E1000_PTC127	0x040DC	/* Packets Tx (65-127 bytes) - R/clr */ +#define E1000_PTC255	0x040E0	/* Packets Tx (128-255 bytes) - R/clr */ +#define E1000_PTC511	0x040E4	/* Packets Tx (256-511 bytes) - R/clr */ +#define E1000_PTC1023	0x040E8	/* Packets Tx (512-1023 bytes) - R/clr */ +#define E1000_PTC1522	0x040EC	/* Packets Tx (1024-1522 Bytes) - R/clr */ +#define E1000_MPTC	0x040F0	/* Multicast Packets Tx Count - R/clr */ +#define E1000_BPTC	0x040F4	/* Broadcast Packets Tx Count - R/clr */ +#define E1000_TSCTC	0x040F8	/* TCP Segmentation Context Tx - R/clr */ +#define E1000_TSCTFC	0x040FC	/* TCP Segmentation Context Tx Fail - R/clr */ +#define E1000_IAC	0x04100	/* Interrupt Assertion Count */ +#define E1000_ICRXPTC	0x04104	/* Interrupt Cause Rx Pkt Timer Expire Count */ +#define E1000_ICRXATC	0x04108	/* Interrupt Cause Rx Abs Timer Expire Count */ +#define E1000_ICTXPTC	0x0410C	/* Interrupt Cause Tx Pkt Timer Expire Count */ +#define E1000_ICTXATC	0x04110	/* Interrupt Cause Tx Abs Timer Expire Count */ +#define E1000_ICTXQEC	0x04118	/* Interrupt Cause Tx Queue Empty Count */ +#define E1000_ICTXQMTC	0x0411C	/* Interrupt Cause Tx Queue Min Thresh Count */ +#define E1000_ICRXDMTC	0x04120	/* Interrupt Cause Rx Desc Min Thresh Count */ +#define E1000_ICRXOC	0x04124	/* Interrupt Cause Receiver Overrun Count */ +#define E1000_CRC_OFFSET	0x05F50	/* CRC Offset register */ + +#define E1000_PCS_LCTL	0x04208	/* PCS Link Control - RW */ +#define E1000_PCS_LSTAT	0x0420C	/* PCS Link Status - RO */ +#define E1000_PCS_ANADV	0x04218	/* AN advertisement - RW */ +#define E1000_PCS_LPAB	0x0421C	/* Link Partner Ability - RW */ +#define E1000_RXCSUM	0x05000	/* Rx Checksum Control - RW */ +#define E1000_RFCTL	0x05008	/* Receive Filter Control */ +#define E1000_MTA	0x05200	/* Multicast Table Array - RW Array */ +#define E1000_RA	0x05400	/* Receive Address - RW Array */ +#define E1000_VFTA	0x05600	/* VLAN Filter Table Array - RW Array */ +#define E1000_WUC	0x05800	/* Wakeup Control - RW */ +#define E1000_WUFC	0x05808	/* Wakeup Filter Control - RW */ +#define E1000_WUS	0x05810	/* Wakeup Status - RO */ +#define E1000_MANC	0x05820	/* Management Control - RW */ +#define E1000_FFLT	0x05F00	/* Flexible Filter Length Table - RW Array */ +#define E1000_HOST_IF	0x08800	/* Host Interface */ + +#define E1000_KMRNCTRLSTA	0x00034	/* MAC-PHY interface - RW */ +#define E1000_MANC2H		0x05860	/* Management Control To Host - RW */ +/* Management Decision Filters */ +#define E1000_MDEF(_n)		(0x05890 + (4 * (_n))) +#define E1000_SW_FW_SYNC	0x05B5C	/* SW-FW Synchronization - RW */ +#define E1000_GCR	0x05B00	/* PCI-Ex Control */ +#define E1000_GCR2	0x05B64	/* PCI-Ex Control #2 */ +#define E1000_FACTPS	0x05B30	/* Function Active and Power State to MNG */ +#define E1000_SWSM	0x05B50	/* SW Semaphore */ +#define E1000_FWSM	0x05B54	/* FW Semaphore */ +/* Driver-only SW semaphore (not used by BOOT agents) */ +#define E1000_SWSM2	0x05B58 +#define E1000_FFLT_DBG	0x05F04	/* Debug Register */ +#define E1000_HICR	0x08F00	/* Host Interface Control */ + +/* RSS registers */ +#define E1000_MRQC	0x05818	/* Multiple Receive Control - RW */ +#define E1000_RETA(_i)	(0x05C00 + ((_i) * 4))	/* Redirection Table - RW */ +#define E1000_RSSRK(_i)	(0x05C80 + ((_i) * 4))	/* RSS Random Key - RW */ +#define E1000_TSYNCRXCTL	0x0B620	/* Rx Time Sync Control register - RW */ +#define E1000_TSYNCTXCTL	0x0B614	/* Tx Time Sync Control register - RW */ +#define E1000_RXSTMPL	0x0B624	/* Rx timestamp Low - RO */ +#define E1000_RXSTMPH	0x0B628	/* Rx timestamp High - RO */ +#define E1000_TXSTMPL	0x0B618	/* Tx timestamp value Low - RO */ +#define E1000_TXSTMPH	0x0B61C	/* Tx timestamp value High - RO */ +#define E1000_SYSTIML	0x0B600	/* System time register Low - RO */ +#define E1000_SYSTIMH	0x0B604	/* System time register High - RO */ +#define E1000_TIMINCA	0x0B608	/* Increment attributes register - RW */ +#define E1000_RXMTRL	0x0B634	/* Time sync Rx EtherType and Msg Type - RW */ +#define E1000_RXUDP	0x0B638	/* Time Sync Rx UDP Port - RW */ + +#endif diff --git a/drivers/net/ethernet/intel/igb/Makefile b/drivers/net/ethernet/intel/igb/Makefile index 624476cfa72..f19700e285b 100644 --- a/drivers/net/ethernet/intel/igb/Makefile +++ b/drivers/net/ethernet/intel/igb/Makefile @@ -1,7 +1,7 @@  ################################################################################  #  # Intel 82575 PCI-Express Ethernet Linux driver -# Copyright(c) 1999 - 2012 Intel Corporation. +# Copyright(c) 1999 - 2013 Intel Corporation.  #  # This program is free software; you can redistribute it and/or modify it  # under the terms and conditions of the GNU General Public License, @@ -34,4 +34,4 @@ obj-$(CONFIG_IGB) += igb.o  igb-objs := igb_main.o igb_ethtool.o e1000_82575.o \  	    e1000_mac.o e1000_nvm.o e1000_phy.o e1000_mbx.o \ -	    e1000_i210.o igb_ptp.o +	    e1000_i210.o igb_ptp.o igb_hwmon.o diff --git a/drivers/net/ethernet/intel/igb/e1000_82575.c b/drivers/net/ethernet/intel/igb/e1000_82575.c index fdaaf2709d0..84e7e0909de 100644 --- a/drivers/net/ethernet/intel/igb/e1000_82575.c +++ b/drivers/net/ethernet/intel/igb/e1000_82575.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel(R) Gigabit Ethernet Linux driver -  Copyright(c) 2007-2012 Intel Corporation. +  Copyright(c) 2007-2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -33,6 +33,7 @@  #include <linux/types.h>  #include <linux/if_ether.h> +#include <linux/i2c.h>  #include "e1000_mac.h"  #include "e1000_82575.h" @@ -110,184 +111,168 @@ static bool igb_sgmii_uses_mdio_82575(struct e1000_hw *hw)  	return ext_mdio;  } -static s32 igb_get_invariants_82575(struct e1000_hw *hw) +/** + *  igb_init_phy_params_82575 - Init PHY func ptrs. + *  @hw: pointer to the HW structure + **/ +static s32 igb_init_phy_params_82575(struct e1000_hw *hw)  {  	struct e1000_phy_info *phy = &hw->phy; -	struct e1000_nvm_info *nvm = &hw->nvm; -	struct e1000_mac_info *mac = &hw->mac; -	struct e1000_dev_spec_82575 * dev_spec = &hw->dev_spec._82575; -	u32 eecd; -	s32 ret_val; -	u16 size; -	u32 ctrl_ext = 0; +	s32 ret_val = 0; +	u32 ctrl_ext; -	switch (hw->device_id) { -	case E1000_DEV_ID_82575EB_COPPER: -	case E1000_DEV_ID_82575EB_FIBER_SERDES: -	case E1000_DEV_ID_82575GB_QUAD_COPPER: -		mac->type = e1000_82575; -		break; -	case E1000_DEV_ID_82576: -	case E1000_DEV_ID_82576_NS: -	case E1000_DEV_ID_82576_NS_SERDES: -	case E1000_DEV_ID_82576_FIBER: -	case E1000_DEV_ID_82576_SERDES: -	case E1000_DEV_ID_82576_QUAD_COPPER: -	case E1000_DEV_ID_82576_QUAD_COPPER_ET2: -	case E1000_DEV_ID_82576_SERDES_QUAD: -		mac->type = e1000_82576; -		break; -	case E1000_DEV_ID_82580_COPPER: -	case E1000_DEV_ID_82580_FIBER: -	case E1000_DEV_ID_82580_QUAD_FIBER: -	case E1000_DEV_ID_82580_SERDES: -	case E1000_DEV_ID_82580_SGMII: -	case E1000_DEV_ID_82580_COPPER_DUAL: -	case E1000_DEV_ID_DH89XXCC_SGMII: -	case E1000_DEV_ID_DH89XXCC_SERDES: -	case E1000_DEV_ID_DH89XXCC_BACKPLANE: -	case E1000_DEV_ID_DH89XXCC_SFP: -		mac->type = e1000_82580; -		break; -	case E1000_DEV_ID_I350_COPPER: -	case E1000_DEV_ID_I350_FIBER: -	case E1000_DEV_ID_I350_SERDES: -	case E1000_DEV_ID_I350_SGMII: -		mac->type = e1000_i350; -		break; -	case E1000_DEV_ID_I210_COPPER: -	case E1000_DEV_ID_I210_COPPER_OEM1: -	case E1000_DEV_ID_I210_COPPER_IT: -	case E1000_DEV_ID_I210_FIBER: -	case E1000_DEV_ID_I210_SERDES: -	case E1000_DEV_ID_I210_SGMII: -		mac->type = e1000_i210; -		break; -	case E1000_DEV_ID_I211_COPPER: -		mac->type = e1000_i211; -		break; -	default: -		return -E1000_ERR_MAC_INIT; -		break; +	if (hw->phy.media_type != e1000_media_type_copper) { +		phy->type = e1000_phy_none; +		goto out;  	} -	/* Set media type */ -	/* -	 * The 82575 uses bits 22:23 for link mode. The mode can be changed -	 * based on the EEPROM. We cannot rely upon device ID. There -	 * is no distinguishable difference between fiber and internal -	 * SerDes mode on the 82575. There can be an external PHY attached -	 * on the SGMII interface. For this, we'll set sgmii_active to true. -	 */ -	phy->media_type = e1000_media_type_copper; -	dev_spec->sgmii_active = false; +	phy->autoneg_mask	= AUTONEG_ADVERTISE_SPEED_DEFAULT; +	phy->reset_delay_us	= 100;  	ctrl_ext = rd32(E1000_CTRL_EXT); -	switch (ctrl_ext & E1000_CTRL_EXT_LINK_MODE_MASK) { -	case E1000_CTRL_EXT_LINK_MODE_SGMII: -		dev_spec->sgmii_active = true; -		break; -	case E1000_CTRL_EXT_LINK_MODE_1000BASE_KX: -	case E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES: -		hw->phy.media_type = e1000_media_type_internal_serdes; -		break; -	default: -		break; + +	if (igb_sgmii_active_82575(hw)) { +		phy->ops.reset = igb_phy_hw_reset_sgmii_82575; +		ctrl_ext |= E1000_CTRL_I2C_ENA; +	} else { +		phy->ops.reset = igb_phy_hw_reset; +		ctrl_ext &= ~E1000_CTRL_I2C_ENA;  	} -	/* Set mta register count */ -	mac->mta_reg_count = 128; -	/* Set rar entry count */ -	switch (mac->type) { -	case e1000_82576: -		mac->rar_entry_count = E1000_RAR_ENTRIES_82576; +	wr32(E1000_CTRL_EXT, ctrl_ext); +	igb_reset_mdicnfg_82580(hw); + +	if (igb_sgmii_active_82575(hw) && !igb_sgmii_uses_mdio_82575(hw)) { +		phy->ops.read_reg = igb_read_phy_reg_sgmii_82575; +		phy->ops.write_reg = igb_write_phy_reg_sgmii_82575; +	} else { +		switch (hw->mac.type) { +		case e1000_82580: +		case e1000_i350: +			phy->ops.read_reg = igb_read_phy_reg_82580; +			phy->ops.write_reg = igb_write_phy_reg_82580; +			break; +		case e1000_i210: +		case e1000_i211: +			phy->ops.read_reg = igb_read_phy_reg_gs40g; +			phy->ops.write_reg = igb_write_phy_reg_gs40g; +			break; +		default: +			phy->ops.read_reg = igb_read_phy_reg_igp; +			phy->ops.write_reg = igb_write_phy_reg_igp; +		} +	} + +	/* set lan id */ +	hw->bus.func = (rd32(E1000_STATUS) & E1000_STATUS_FUNC_MASK) >> +			E1000_STATUS_FUNC_SHIFT; + +	/* Set phy->phy_addr and phy->id. */ +	ret_val = igb_get_phy_id_82575(hw); +	if (ret_val) +		return ret_val; + +	/* Verify phy id and set remaining function pointers */ +	switch (phy->id) { +	case I347AT4_E_PHY_ID: +	case M88E1112_E_PHY_ID: +	case M88E1111_I_PHY_ID: +		phy->type		= e1000_phy_m88; +		phy->ops.get_phy_info	= igb_get_phy_info_m88; +		if (phy->id == I347AT4_E_PHY_ID || +		    phy->id == M88E1112_E_PHY_ID) +			phy->ops.get_cable_length = +					 igb_get_cable_length_m88_gen2; +		else +			phy->ops.get_cable_length = igb_get_cable_length_m88; +		phy->ops.force_speed_duplex = igb_phy_force_speed_duplex_m88;  		break; -	case e1000_82580: -		mac->rar_entry_count = E1000_RAR_ENTRIES_82580; +	case IGP03E1000_E_PHY_ID: +		phy->type = e1000_phy_igp_3; +		phy->ops.get_phy_info = igb_get_phy_info_igp; +		phy->ops.get_cable_length = igb_get_cable_length_igp_2; +		phy->ops.force_speed_duplex = igb_phy_force_speed_duplex_igp; +		phy->ops.set_d0_lplu_state = igb_set_d0_lplu_state_82575; +		phy->ops.set_d3_lplu_state = igb_set_d3_lplu_state;  		break; -	case e1000_i350: -		mac->rar_entry_count = E1000_RAR_ENTRIES_I350; +	case I82580_I_PHY_ID: +	case I350_I_PHY_ID: +		phy->type = e1000_phy_82580; +		phy->ops.force_speed_duplex = +					 igb_phy_force_speed_duplex_82580; +		phy->ops.get_cable_length = igb_get_cable_length_82580; +		phy->ops.get_phy_info = igb_get_phy_info_82580; +		phy->ops.set_d0_lplu_state = igb_set_d0_lplu_state_82580; +		phy->ops.set_d3_lplu_state = igb_set_d3_lplu_state_82580;  		break; -	default: -		mac->rar_entry_count = E1000_RAR_ENTRIES_82575; +	case I210_I_PHY_ID: +		phy->type		= e1000_phy_i210; +		phy->ops.check_polarity	= igb_check_polarity_m88; +		phy->ops.get_phy_info	= igb_get_phy_info_m88; +		phy->ops.get_cable_length = igb_get_cable_length_m88_gen2; +		phy->ops.set_d0_lplu_state = igb_set_d0_lplu_state_82580; +		phy->ops.set_d3_lplu_state = igb_set_d3_lplu_state_82580; +		phy->ops.force_speed_duplex = igb_phy_force_speed_duplex_m88;  		break; +	default: +		ret_val = -E1000_ERR_PHY; +		goto out;  	} -	/* reset */ -	if (mac->type >= e1000_82580) -		mac->ops.reset_hw = igb_reset_hw_82580; -	else -		mac->ops.reset_hw = igb_reset_hw_82575; -	if (mac->type >= e1000_i210) { -		mac->ops.acquire_swfw_sync = igb_acquire_swfw_sync_i210; -		mac->ops.release_swfw_sync = igb_release_swfw_sync_i210; -	} else { -		mac->ops.acquire_swfw_sync = igb_acquire_swfw_sync_82575; -		mac->ops.release_swfw_sync = igb_release_swfw_sync_82575; -	} +out: +	return ret_val; +} -	/* Set if part includes ASF firmware */ -	mac->asf_firmware_present = true; -	/* Set if manageability features are enabled. */ -	mac->arc_subsystem_valid = -		(rd32(E1000_FWSM) & E1000_FWSM_MODE_MASK) -			? true : false; -	/* enable EEE on i350 parts and later parts */ -	if (mac->type >= e1000_i350) -		dev_spec->eee_disable = false; -	else -		dev_spec->eee_disable = true; -	/* physical interface link setup */ -	mac->ops.setup_physical_interface = -		(hw->phy.media_type == e1000_media_type_copper) -			? igb_setup_copper_link_82575 -			: igb_setup_serdes_link_82575; +/** + *  igb_init_nvm_params_82575 - Init NVM func ptrs. + *  @hw: pointer to the HW structure + **/ +s32 igb_init_nvm_params_82575(struct e1000_hw *hw) +{ +	struct e1000_nvm_info *nvm = &hw->nvm; +	u32 eecd = rd32(E1000_EECD); +	u16 size; -	/* NVM initialization */ -	eecd = rd32(E1000_EECD);  	size = (u16)((eecd & E1000_EECD_SIZE_EX_MASK) >>  		     E1000_EECD_SIZE_EX_SHIFT); - -	/* -	 * Added to a constant, "size" becomes the left-shift value +	/* Added to a constant, "size" becomes the left-shift value  	 * for setting word_size.  	 */  	size += NVM_WORD_SIZE_BASE_SHIFT; -	/* -	 * Check for invalid size +	/* Just in case size is out of range, cap it to the largest +	 * EEPROM size supported  	 */ -	if ((hw->mac.type == e1000_82576) && (size > 15)) { -		pr_notice("The NVM size is not valid, defaulting to 32K\n"); +	if (size > 15)  		size = 15; -	}  	nvm->word_size = 1 << size;  	if (hw->mac.type < e1000_i210) { -		nvm->opcode_bits        = 8; -		nvm->delay_usec         = 1; +		nvm->opcode_bits = 8; +		nvm->delay_usec = 1; +  		switch (nvm->override) {  		case e1000_nvm_override_spi_large: -			nvm->page_size    = 32; +			nvm->page_size = 32;  			nvm->address_bits = 16;  			break;  		case e1000_nvm_override_spi_small: -			nvm->page_size    = 8; +			nvm->page_size = 8;  			nvm->address_bits = 8;  			break;  		default: -			nvm->page_size    = eecd -				& E1000_EECD_ADDR_BITS ? 32 : 8; -			nvm->address_bits = eecd -				& E1000_EECD_ADDR_BITS ? 16 : 8; +			nvm->page_size = eecd & E1000_EECD_ADDR_BITS ? 32 : 8; +			nvm->address_bits = eecd & E1000_EECD_ADDR_BITS ? +					    16 : 8;  			break;  		}  		if (nvm->word_size == (1 << 15))  			nvm->page_size = 128;  		nvm->type = e1000_nvm_eeprom_spi; -	} else +	} else {  		nvm->type = e1000_nvm_flash_hw; +	}  	/* NVM Function Pointers */  	switch (hw->mac.type) { @@ -344,118 +329,176 @@ static s32 igb_get_invariants_82575(struct e1000_hw *hw)  		break;  	} -	/* if part supports SR-IOV then initialize mailbox parameters */ +	return 0; +} + +/** + *  igb_init_mac_params_82575 - Init MAC func ptrs. + *  @hw: pointer to the HW structure + **/ +static s32 igb_init_mac_params_82575(struct e1000_hw *hw) +{ +	struct e1000_mac_info *mac = &hw->mac; +	struct e1000_dev_spec_82575 *dev_spec = &hw->dev_spec._82575; + +	/* Set mta register count */ +	mac->mta_reg_count = 128; +	/* Set rar entry count */  	switch (mac->type) {  	case e1000_82576: +		mac->rar_entry_count = E1000_RAR_ENTRIES_82576; +		break; +	case e1000_82580: +		mac->rar_entry_count = E1000_RAR_ENTRIES_82580; +		break;  	case e1000_i350: -		igb_init_mbx_params_pf(hw); +		mac->rar_entry_count = E1000_RAR_ENTRIES_I350;  		break;  	default: +		mac->rar_entry_count = E1000_RAR_ENTRIES_82575;  		break;  	} +	/* reset */ +	if (mac->type >= e1000_82580) +		mac->ops.reset_hw = igb_reset_hw_82580; +	else +		mac->ops.reset_hw = igb_reset_hw_82575; -	/* setup PHY parameters */ -	if (phy->media_type != e1000_media_type_copper) { -		phy->type = e1000_phy_none; -		return 0; -	} - -	phy->autoneg_mask        = AUTONEG_ADVERTISE_SPEED_DEFAULT; -	phy->reset_delay_us      = 100; - -	ctrl_ext = rd32(E1000_CTRL_EXT); +	if (mac->type >= e1000_i210) { +		mac->ops.acquire_swfw_sync = igb_acquire_swfw_sync_i210; +		mac->ops.release_swfw_sync = igb_release_swfw_sync_i210; -	/* PHY function pointers */ -	if (igb_sgmii_active_82575(hw)) { -		phy->ops.reset      = igb_phy_hw_reset_sgmii_82575; -		ctrl_ext |= E1000_CTRL_I2C_ENA;  	} else { -		phy->ops.reset      = igb_phy_hw_reset; -		ctrl_ext &= ~E1000_CTRL_I2C_ENA; +		mac->ops.acquire_swfw_sync = igb_acquire_swfw_sync_82575; +		mac->ops.release_swfw_sync = igb_release_swfw_sync_82575;  	} -	wr32(E1000_CTRL_EXT, ctrl_ext); -	igb_reset_mdicnfg_82580(hw); - -	if (igb_sgmii_active_82575(hw) && !igb_sgmii_uses_mdio_82575(hw)) { -		phy->ops.read_reg   = igb_read_phy_reg_sgmii_82575; -		phy->ops.write_reg  = igb_write_phy_reg_sgmii_82575; -	} else if ((hw->mac.type == e1000_82580) -		|| (hw->mac.type == e1000_i350)) { -		phy->ops.read_reg   = igb_read_phy_reg_82580; -		phy->ops.write_reg  = igb_write_phy_reg_82580; -	} else if (hw->phy.type >= e1000_phy_i210) { -		phy->ops.read_reg   = igb_read_phy_reg_gs40g; -		phy->ops.write_reg  = igb_write_phy_reg_gs40g; -	} else { -		phy->ops.read_reg   = igb_read_phy_reg_igp; -		phy->ops.write_reg  = igb_write_phy_reg_igp; -	} +	/* Set if part includes ASF firmware */ +	mac->asf_firmware_present = true; +	/* Set if manageability features are enabled. */ +	mac->arc_subsystem_valid = +		(rd32(E1000_FWSM) & E1000_FWSM_MODE_MASK) +			? true : false; +	/* enable EEE on i350 parts and later parts */ +	if (mac->type >= e1000_i350) +		dev_spec->eee_disable = false; +	else +		dev_spec->eee_disable = true; +	/* physical interface link setup */ +	mac->ops.setup_physical_interface = +		(hw->phy.media_type == e1000_media_type_copper) +			? igb_setup_copper_link_82575 +			: igb_setup_serdes_link_82575; -	/* set lan id */ -	hw->bus.func = (rd32(E1000_STATUS) & E1000_STATUS_FUNC_MASK) >> -	               E1000_STATUS_FUNC_SHIFT; +	return 0; +} -	/* Set phy->phy_addr and phy->id. */ -	ret_val = igb_get_phy_id_82575(hw); -	if (ret_val) -		return ret_val; +static s32 igb_get_invariants_82575(struct e1000_hw *hw) +{ +	struct e1000_mac_info *mac = &hw->mac; +	struct e1000_dev_spec_82575 * dev_spec = &hw->dev_spec._82575; +	s32 ret_val; +	u32 ctrl_ext = 0; -	/* Verify phy id and set remaining function pointers */ -	switch (phy->id) { -	case I347AT4_E_PHY_ID: -	case M88E1112_E_PHY_ID: -	case M88E1111_I_PHY_ID: -		phy->type                   = e1000_phy_m88; -		phy->ops.get_phy_info       = igb_get_phy_info_m88; +	switch (hw->device_id) { +	case E1000_DEV_ID_82575EB_COPPER: +	case E1000_DEV_ID_82575EB_FIBER_SERDES: +	case E1000_DEV_ID_82575GB_QUAD_COPPER: +		mac->type = e1000_82575; +		break; +	case E1000_DEV_ID_82576: +	case E1000_DEV_ID_82576_NS: +	case E1000_DEV_ID_82576_NS_SERDES: +	case E1000_DEV_ID_82576_FIBER: +	case E1000_DEV_ID_82576_SERDES: +	case E1000_DEV_ID_82576_QUAD_COPPER: +	case E1000_DEV_ID_82576_QUAD_COPPER_ET2: +	case E1000_DEV_ID_82576_SERDES_QUAD: +		mac->type = e1000_82576; +		break; +	case E1000_DEV_ID_82580_COPPER: +	case E1000_DEV_ID_82580_FIBER: +	case E1000_DEV_ID_82580_QUAD_FIBER: +	case E1000_DEV_ID_82580_SERDES: +	case E1000_DEV_ID_82580_SGMII: +	case E1000_DEV_ID_82580_COPPER_DUAL: +	case E1000_DEV_ID_DH89XXCC_SGMII: +	case E1000_DEV_ID_DH89XXCC_SERDES: +	case E1000_DEV_ID_DH89XXCC_BACKPLANE: +	case E1000_DEV_ID_DH89XXCC_SFP: +		mac->type = e1000_82580; +		break; +	case E1000_DEV_ID_I350_COPPER: +	case E1000_DEV_ID_I350_FIBER: +	case E1000_DEV_ID_I350_SERDES: +	case E1000_DEV_ID_I350_SGMII: +		mac->type = e1000_i350; +		break; +	case E1000_DEV_ID_I210_COPPER: +	case E1000_DEV_ID_I210_COPPER_OEM1: +	case E1000_DEV_ID_I210_COPPER_IT: +	case E1000_DEV_ID_I210_FIBER: +	case E1000_DEV_ID_I210_SERDES: +	case E1000_DEV_ID_I210_SGMII: +		mac->type = e1000_i210; +		break; +	case E1000_DEV_ID_I211_COPPER: +		mac->type = e1000_i211; +		break; +	default: +		return -E1000_ERR_MAC_INIT; +		break; +	} -		if (phy->id == I347AT4_E_PHY_ID || -		    phy->id == M88E1112_E_PHY_ID) -			phy->ops.get_cable_length = igb_get_cable_length_m88_gen2; -		else -			phy->ops.get_cable_length = igb_get_cable_length_m88; +	/* Set media type */ +	/* +	 * The 82575 uses bits 22:23 for link mode. The mode can be changed +	 * based on the EEPROM. We cannot rely upon device ID. There +	 * is no distinguishable difference between fiber and internal +	 * SerDes mode on the 82575. There can be an external PHY attached +	 * on the SGMII interface. For this, we'll set sgmii_active to true. +	 */ +	hw->phy.media_type = e1000_media_type_copper; +	dev_spec->sgmii_active = false; -		if (phy->id == I210_I_PHY_ID) { -			phy->ops.get_cable_length = -					 igb_get_cable_length_m88_gen2; -			phy->ops.set_d0_lplu_state = -					igb_set_d0_lplu_state_82580; -			phy->ops.set_d3_lplu_state = -					igb_set_d3_lplu_state_82580; -		} -		phy->ops.force_speed_duplex = igb_phy_force_speed_duplex_m88; +	ctrl_ext = rd32(E1000_CTRL_EXT); +	switch (ctrl_ext & E1000_CTRL_EXT_LINK_MODE_MASK) { +	case E1000_CTRL_EXT_LINK_MODE_SGMII: +		dev_spec->sgmii_active = true;  		break; -	case IGP03E1000_E_PHY_ID: -		phy->type                   = e1000_phy_igp_3; -		phy->ops.get_phy_info       = igb_get_phy_info_igp; -		phy->ops.get_cable_length   = igb_get_cable_length_igp_2; -		phy->ops.force_speed_duplex = igb_phy_force_speed_duplex_igp; -		phy->ops.set_d0_lplu_state  = igb_set_d0_lplu_state_82575; -		phy->ops.set_d3_lplu_state  = igb_set_d3_lplu_state; +	case E1000_CTRL_EXT_LINK_MODE_1000BASE_KX: +	case E1000_CTRL_EXT_LINK_MODE_PCIE_SERDES: +		hw->phy.media_type = e1000_media_type_internal_serdes;  		break; -	case I82580_I_PHY_ID: -	case I350_I_PHY_ID: -		phy->type                   = e1000_phy_82580; -		phy->ops.force_speed_duplex = igb_phy_force_speed_duplex_82580; -		phy->ops.get_cable_length   = igb_get_cable_length_82580; -		phy->ops.get_phy_info       = igb_get_phy_info_82580; -		phy->ops.set_d0_lplu_state  = igb_set_d0_lplu_state_82580; -		phy->ops.set_d3_lplu_state  = igb_set_d3_lplu_state_82580; +	default:  		break; -	case I210_I_PHY_ID: -		phy->type                   = e1000_phy_i210; -		phy->ops.get_phy_info       = igb_get_phy_info_m88; -		phy->ops.check_polarity     = igb_check_polarity_m88; -		phy->ops.get_cable_length   = igb_get_cable_length_m88_gen2; -		phy->ops.set_d0_lplu_state  = igb_set_d0_lplu_state_82580; -		phy->ops.set_d3_lplu_state  = igb_set_d3_lplu_state_82580; -		phy->ops.force_speed_duplex = igb_phy_force_speed_duplex_m88; +	} + +	/* mac initialization and operations */ +	ret_val = igb_init_mac_params_82575(hw); +	if (ret_val) +		goto out; + +	/* NVM initialization */ +	ret_val = igb_init_nvm_params_82575(hw); +	if (ret_val) +		goto out; + +	/* if part supports SR-IOV then initialize mailbox parameters */ +	switch (mac->type) { +	case e1000_82576: +	case e1000_i350: +		igb_init_mbx_params_pf(hw);  		break;  	default: -		return -E1000_ERR_PHY; +		break;  	} -	return 0; +	/* setup PHY parameters */ +	ret_val = igb_init_phy_params_82575(hw); + +out: +	return ret_val;  }  /** @@ -2302,18 +2345,157 @@ out:  	return ret_val;  } +static const u8 e1000_emc_temp_data[4] = { +	E1000_EMC_INTERNAL_DATA, +	E1000_EMC_DIODE1_DATA, +	E1000_EMC_DIODE2_DATA, +	E1000_EMC_DIODE3_DATA +}; +static const u8 e1000_emc_therm_limit[4] = { +	E1000_EMC_INTERNAL_THERM_LIMIT, +	E1000_EMC_DIODE1_THERM_LIMIT, +	E1000_EMC_DIODE2_THERM_LIMIT, +	E1000_EMC_DIODE3_THERM_LIMIT +}; + +/* igb_get_thermal_sensor_data_generic - Gathers thermal sensor data + *  @hw: pointer to hardware structure + * + *  Updates the temperatures in mac.thermal_sensor_data + */ +s32 igb_get_thermal_sensor_data_generic(struct e1000_hw *hw) +{ +	s32 status = E1000_SUCCESS; +	u16 ets_offset; +	u16 ets_cfg; +	u16 ets_sensor; +	u8  num_sensors; +	u8  sensor_index; +	u8  sensor_location; +	u8  i; +	struct e1000_thermal_sensor_data *data = &hw->mac.thermal_sensor_data; + +	if ((hw->mac.type != e1000_i350) || (hw->bus.func != 0)) +		return E1000_NOT_IMPLEMENTED; + +	data->sensor[0].temp = (rd32(E1000_THMJT) & 0xFF); + +	/* Return the internal sensor only if ETS is unsupported */ +	hw->nvm.ops.read(hw, NVM_ETS_CFG, 1, &ets_offset); +	if ((ets_offset == 0x0000) || (ets_offset == 0xFFFF)) +		return status; + +	hw->nvm.ops.read(hw, ets_offset, 1, &ets_cfg); +	if (((ets_cfg & NVM_ETS_TYPE_MASK) >> NVM_ETS_TYPE_SHIFT) +	    != NVM_ETS_TYPE_EMC) +		return E1000_NOT_IMPLEMENTED; + +	num_sensors = (ets_cfg & NVM_ETS_NUM_SENSORS_MASK); +	if (num_sensors > E1000_MAX_SENSORS) +		num_sensors = E1000_MAX_SENSORS; + +	for (i = 1; i < num_sensors; i++) { +		hw->nvm.ops.read(hw, (ets_offset + i), 1, &ets_sensor); +		sensor_index = ((ets_sensor & NVM_ETS_DATA_INDEX_MASK) >> +				NVM_ETS_DATA_INDEX_SHIFT); +		sensor_location = ((ets_sensor & NVM_ETS_DATA_LOC_MASK) >> +				   NVM_ETS_DATA_LOC_SHIFT); + +		if (sensor_location != 0) +			hw->phy.ops.read_i2c_byte(hw, +					e1000_emc_temp_data[sensor_index], +					E1000_I2C_THERMAL_SENSOR_ADDR, +					&data->sensor[i].temp); +	} +	return status; +} + +/* igb_init_thermal_sensor_thresh_generic - Sets thermal sensor thresholds + *  @hw: pointer to hardware structure + * + *  Sets the thermal sensor thresholds according to the NVM map + *  and save off the threshold and location values into mac.thermal_sensor_data + */ +s32 igb_init_thermal_sensor_thresh_generic(struct e1000_hw *hw) +{ +	s32 status = E1000_SUCCESS; +	u16 ets_offset; +	u16 ets_cfg; +	u16 ets_sensor; +	u8  low_thresh_delta; +	u8  num_sensors; +	u8  sensor_index; +	u8  sensor_location; +	u8  therm_limit; +	u8  i; +	struct e1000_thermal_sensor_data *data = &hw->mac.thermal_sensor_data; + +	if ((hw->mac.type != e1000_i350) || (hw->bus.func != 0)) +		return E1000_NOT_IMPLEMENTED; + +	memset(data, 0, sizeof(struct e1000_thermal_sensor_data)); + +	data->sensor[0].location = 0x1; +	data->sensor[0].caution_thresh = +		(rd32(E1000_THHIGHTC) & 0xFF); +	data->sensor[0].max_op_thresh = +		(rd32(E1000_THLOWTC) & 0xFF); + +	/* Return the internal sensor only if ETS is unsupported */ +	hw->nvm.ops.read(hw, NVM_ETS_CFG, 1, &ets_offset); +	if ((ets_offset == 0x0000) || (ets_offset == 0xFFFF)) +		return status; + +	hw->nvm.ops.read(hw, ets_offset, 1, &ets_cfg); +	if (((ets_cfg & NVM_ETS_TYPE_MASK) >> NVM_ETS_TYPE_SHIFT) +	    != NVM_ETS_TYPE_EMC) +		return E1000_NOT_IMPLEMENTED; + +	low_thresh_delta = ((ets_cfg & NVM_ETS_LTHRES_DELTA_MASK) >> +			    NVM_ETS_LTHRES_DELTA_SHIFT); +	num_sensors = (ets_cfg & NVM_ETS_NUM_SENSORS_MASK); + +	for (i = 1; i <= num_sensors; i++) { +		hw->nvm.ops.read(hw, (ets_offset + i), 1, &ets_sensor); +		sensor_index = ((ets_sensor & NVM_ETS_DATA_INDEX_MASK) >> +				NVM_ETS_DATA_INDEX_SHIFT); +		sensor_location = ((ets_sensor & NVM_ETS_DATA_LOC_MASK) >> +				   NVM_ETS_DATA_LOC_SHIFT); +		therm_limit = ets_sensor & NVM_ETS_DATA_HTHRESH_MASK; + +		hw->phy.ops.write_i2c_byte(hw, +			e1000_emc_therm_limit[sensor_index], +			E1000_I2C_THERMAL_SENSOR_ADDR, +			therm_limit); + +		if ((i < E1000_MAX_SENSORS) && (sensor_location != 0)) { +			data->sensor[i].location = sensor_location; +			data->sensor[i].caution_thresh = therm_limit; +			data->sensor[i].max_op_thresh = therm_limit - +							low_thresh_delta; +		} +	} +	return status; +} +  static struct e1000_mac_operations e1000_mac_ops_82575 = {  	.init_hw              = igb_init_hw_82575,  	.check_for_link       = igb_check_for_link_82575,  	.rar_set              = igb_rar_set,  	.read_mac_addr        = igb_read_mac_addr_82575,  	.get_speed_and_duplex = igb_get_speed_and_duplex_copper, +#ifdef CONFIG_IGB_HWMON +	.get_thermal_sensor_data = igb_get_thermal_sensor_data_generic, +	.init_thermal_sensor_thresh = igb_init_thermal_sensor_thresh_generic, +#endif  };  static struct e1000_phy_operations e1000_phy_ops_82575 = {  	.acquire              = igb_acquire_phy_82575,  	.get_cfg_done         = igb_get_cfg_done_82575,  	.release              = igb_release_phy_82575, +	.write_i2c_byte       = igb_write_i2c_byte, +	.read_i2c_byte        = igb_read_i2c_byte,  };  static struct e1000_nvm_operations e1000_nvm_ops_82575 = { diff --git a/drivers/net/ethernet/intel/igb/e1000_82575.h b/drivers/net/ethernet/intel/igb/e1000_82575.h index 44b76b3b681..73ab41f0e03 100644 --- a/drivers/net/ethernet/intel/igb/e1000_82575.h +++ b/drivers/net/ethernet/intel/igb/e1000_82575.h @@ -1,7 +1,7 @@  /*******************************************************************************    Intel(R) Gigabit Ethernet Linux driver -  Copyright(c) 2007-2012 Intel Corporation. +  Copyright(c) 2007-2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -32,6 +32,10 @@ extern void igb_shutdown_serdes_link_82575(struct e1000_hw *hw);  extern void igb_power_up_serdes_link_82575(struct e1000_hw *hw);  extern void igb_power_down_phy_copper_82575(struct e1000_hw *hw);  extern void igb_rx_fifo_flush_82575(struct e1000_hw *hw); +extern s32 igb_read_i2c_byte(struct e1000_hw *hw, u8 byte_offset, +				u8 dev_addr, u8 *data); +extern s32 igb_write_i2c_byte(struct e1000_hw *hw, u8 byte_offset, +				 u8 dev_addr, u8 data);  #define ID_LED_DEFAULT_82575_SERDES ((ID_LED_DEF1_DEF2 << 12) | \                                       (ID_LED_DEF1_DEF2 <<  8) | \ @@ -260,5 +264,16 @@ void igb_vmdq_set_loopback_pf(struct e1000_hw *, bool);  void igb_vmdq_set_replication_pf(struct e1000_hw *, bool);  u16 igb_rxpbs_adjust_82580(u32 data);  s32 igb_set_eee_i350(struct e1000_hw *); +s32 igb_init_thermal_sensor_thresh_generic(struct e1000_hw *); +s32 igb_get_thermal_sensor_data_generic(struct e1000_hw *hw); +#define E1000_I2C_THERMAL_SENSOR_ADDR	0xF8 +#define E1000_EMC_INTERNAL_DATA		0x00 +#define E1000_EMC_INTERNAL_THERM_LIMIT	0x20 +#define E1000_EMC_DIODE1_DATA		0x01 +#define E1000_EMC_DIODE1_THERM_LIMIT	0x19 +#define E1000_EMC_DIODE2_DATA		0x23 +#define E1000_EMC_DIODE2_THERM_LIMIT	0x1A +#define E1000_EMC_DIODE3_DATA		0x2A +#define E1000_EMC_DIODE3_THERM_LIMIT	0x30  #endif diff --git a/drivers/net/ethernet/intel/igb/e1000_defines.h b/drivers/net/ethernet/intel/igb/e1000_defines.h index 45dce06eff2..7e13337d3b9 100644 --- a/drivers/net/ethernet/intel/igb/e1000_defines.h +++ b/drivers/net/ethernet/intel/igb/e1000_defines.h @@ -1,7 +1,7 @@  /*******************************************************************************    Intel(R) Gigabit Ethernet Linux driver -  Copyright(c) 2007-2012 Intel Corporation. +  Copyright(c) 2007-2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -470,6 +470,7 @@  #define E1000_ERR_NO_SPACE          17  #define E1000_ERR_NVM_PBA_SECTION   18  #define E1000_ERR_INVM_VALUE_NOT_FOUND	19 +#define E1000_ERR_I2C               20  /* Loop limit on how long we wait for auto-negotiation to complete */  #define COPPER_LINK_UP_LIMIT              10 @@ -674,6 +675,18 @@  #define NVM_COMB_VER_SHFT               8  #define NVM_VER_INVALID            0xFFFF  #define NVM_ETRACK_SHIFT               16 +#define NVM_ETS_CFG			0x003E +#define NVM_ETS_LTHRES_DELTA_MASK	0x07C0 +#define NVM_ETS_LTHRES_DELTA_SHIFT	6 +#define NVM_ETS_TYPE_MASK		0x0038 +#define NVM_ETS_TYPE_SHIFT		3 +#define NVM_ETS_TYPE_EMC		0x000 +#define NVM_ETS_NUM_SENSORS_MASK	0x0007 +#define NVM_ETS_DATA_LOC_MASK		0x3C00 +#define NVM_ETS_DATA_LOC_SHIFT		10 +#define NVM_ETS_DATA_INDEX_MASK		0x0300 +#define NVM_ETS_DATA_INDEX_SHIFT	8 +#define NVM_ETS_DATA_HTHRESH_MASK	0x00FF  #define E1000_NVM_CFG_DONE_PORT_0  0x040000 /* MNG config cycle done */  #define E1000_NVM_CFG_DONE_PORT_1  0x080000 /* ...for second port */ diff --git a/drivers/net/ethernet/intel/igb/e1000_hw.h b/drivers/net/ethernet/intel/igb/e1000_hw.h index c2a51dcda55..0d5cf9c63d0 100644 --- a/drivers/net/ethernet/intel/igb/e1000_hw.h +++ b/drivers/net/ethernet/intel/igb/e1000_hw.h @@ -1,7 +1,7 @@  /*******************************************************************************    Intel(R) Gigabit Ethernet Linux driver -  Copyright(c) 2007-2012 Intel Corporation. +  Copyright(c) 2007-2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -325,6 +325,10 @@ struct e1000_mac_operations {  	s32  (*get_speed_and_duplex)(struct e1000_hw *, u16 *, u16 *);  	s32  (*acquire_swfw_sync)(struct e1000_hw *, u16);  	void (*release_swfw_sync)(struct e1000_hw *, u16); +#ifdef CONFIG_IGB_HWMON +	s32 (*get_thermal_sensor_data)(struct e1000_hw *); +	s32 (*init_thermal_sensor_thresh)(struct e1000_hw *); +#endif  }; @@ -342,6 +346,8 @@ struct e1000_phy_operations {  	s32  (*set_d0_lplu_state)(struct e1000_hw *, bool);  	s32  (*set_d3_lplu_state)(struct e1000_hw *, bool);  	s32  (*write_reg)(struct e1000_hw *, u32, u16); +	s32 (*read_i2c_byte)(struct e1000_hw *, u8, u8, u8 *); +	s32 (*write_i2c_byte)(struct e1000_hw *, u8, u8, u8);  };  struct e1000_nvm_operations { @@ -354,6 +360,19 @@ struct e1000_nvm_operations {  	s32  (*valid_led_default)(struct e1000_hw *, u16 *);  }; +#define E1000_MAX_SENSORS		3 + +struct e1000_thermal_diode_data { +	u8 location; +	u8 temp; +	u8 caution_thresh; +	u8 max_op_thresh; +}; + +struct e1000_thermal_sensor_data { +	struct e1000_thermal_diode_data sensor[E1000_MAX_SENSORS]; +}; +  struct e1000_info {  	s32 (*get_invariants)(struct e1000_hw *);  	struct e1000_mac_operations *mac_ops; @@ -399,6 +418,7 @@ struct e1000_mac_info {  	bool report_tx_early;  	bool serdes_has_link;  	bool tx_pkt_filtering; +	struct e1000_thermal_sensor_data thermal_sensor_data;  };  struct e1000_phy_info { diff --git a/drivers/net/ethernet/intel/igb/e1000_i210.c b/drivers/net/ethernet/intel/igb/e1000_i210.c index fbcdbebb0b5..6a42344f24f 100644 --- a/drivers/net/ethernet/intel/igb/e1000_i210.c +++ b/drivers/net/ethernet/intel/igb/e1000_i210.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel(R) Gigabit Ethernet Linux driver -  Copyright(c) 2007-2012 Intel Corporation. +  Copyright(c) 2007-2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, diff --git a/drivers/net/ethernet/intel/igb/e1000_i210.h b/drivers/net/ethernet/intel/igb/e1000_i210.h index 1c89358a99a..e4e1a73b7c7 100644 --- a/drivers/net/ethernet/intel/igb/e1000_i210.h +++ b/drivers/net/ethernet/intel/igb/e1000_i210.h @@ -1,7 +1,7 @@  /*******************************************************************************    Intel(R) Gigabit Ethernet Linux driver -  Copyright(c) 2007-2012 Intel Corporation. +  Copyright(c) 2007-2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, diff --git a/drivers/net/ethernet/intel/igb/e1000_mac.c b/drivers/net/ethernet/intel/igb/e1000_mac.c index 101e6e4da97..a5c7200b9a7 100644 --- a/drivers/net/ethernet/intel/igb/e1000_mac.c +++ b/drivers/net/ethernet/intel/igb/e1000_mac.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel(R) Gigabit Ethernet Linux driver -  Copyright(c) 2007-2012 Intel Corporation. +  Copyright(c) 2007-2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, diff --git a/drivers/net/ethernet/intel/igb/e1000_mac.h b/drivers/net/ethernet/intel/igb/e1000_mac.h index e2b2c4b9c95..e6d6ce43326 100644 --- a/drivers/net/ethernet/intel/igb/e1000_mac.h +++ b/drivers/net/ethernet/intel/igb/e1000_mac.h @@ -1,7 +1,7 @@  /*******************************************************************************    Intel(R) Gigabit Ethernet Linux driver -  Copyright(c) 2007-2012 Intel Corporation. +  Copyright(c) 2007-2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, diff --git a/drivers/net/ethernet/intel/igb/e1000_mbx.c b/drivers/net/ethernet/intel/igb/e1000_mbx.c index 5988b8958ba..38e0df35090 100644 --- a/drivers/net/ethernet/intel/igb/e1000_mbx.c +++ b/drivers/net/ethernet/intel/igb/e1000_mbx.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel(R) Gigabit Ethernet Linux driver -  Copyright(c) 2007-2012 Intel Corporation. +  Copyright(c) 2007-2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, diff --git a/drivers/net/ethernet/intel/igb/e1000_mbx.h b/drivers/net/ethernet/intel/igb/e1000_mbx.h index dbcfa3d5cae..c13b56d9edb 100644 --- a/drivers/net/ethernet/intel/igb/e1000_mbx.h +++ b/drivers/net/ethernet/intel/igb/e1000_mbx.h @@ -1,7 +1,7 @@  /*******************************************************************************    Intel(R) Gigabit Ethernet Linux driver -  Copyright(c) 2007-2012 Intel Corporation. +  Copyright(c) 2007-2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, diff --git a/drivers/net/ethernet/intel/igb/e1000_nvm.c b/drivers/net/ethernet/intel/igb/e1000_nvm.c index fbb7604db36..5b62adbe134 100644 --- a/drivers/net/ethernet/intel/igb/e1000_nvm.c +++ b/drivers/net/ethernet/intel/igb/e1000_nvm.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel(R) Gigabit Ethernet Linux driver -  Copyright(c) 2007-2012 Intel Corporation. +  Copyright(c) 2007-2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, diff --git a/drivers/net/ethernet/intel/igb/e1000_nvm.h b/drivers/net/ethernet/intel/igb/e1000_nvm.h index 7012d458c6f..6bfc0c43aac 100644 --- a/drivers/net/ethernet/intel/igb/e1000_nvm.h +++ b/drivers/net/ethernet/intel/igb/e1000_nvm.h @@ -1,7 +1,7 @@  /*******************************************************************************    Intel(R) Gigabit Ethernet Linux driver -  Copyright(c) 2012 Intel Corporation. +  Copyright(c) 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, diff --git a/drivers/net/ethernet/intel/igb/e1000_phy.c b/drivers/net/ethernet/intel/igb/e1000_phy.c index fe76004aca4..2918c979b5b 100644 --- a/drivers/net/ethernet/intel/igb/e1000_phy.c +++ b/drivers/net/ethernet/intel/igb/e1000_phy.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel(R) Gigabit Ethernet Linux driver -  Copyright(c) 2007-2012 Intel Corporation. +  Copyright(c) 2007-2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, diff --git a/drivers/net/ethernet/intel/igb/e1000_phy.h b/drivers/net/ethernet/intel/igb/e1000_phy.h index ed282f877d9..784fd1c4098 100644 --- a/drivers/net/ethernet/intel/igb/e1000_phy.h +++ b/drivers/net/ethernet/intel/igb/e1000_phy.h @@ -1,7 +1,7 @@  /*******************************************************************************    Intel(R) Gigabit Ethernet Linux driver -  Copyright(c) 2007-2012 Intel Corporation. +  Copyright(c) 2007-2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, diff --git a/drivers/net/ethernet/intel/igb/e1000_regs.h b/drivers/net/ethernet/intel/igb/e1000_regs.h index e5db48594e8..15343286082 100644 --- a/drivers/net/ethernet/intel/igb/e1000_regs.h +++ b/drivers/net/ethernet/intel/igb/e1000_regs.h @@ -1,7 +1,7 @@  /*******************************************************************************    Intel(R) Gigabit Ethernet Linux driver -  Copyright(c) 2007-2012 Intel Corporation. +  Copyright(c) 2007-2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -75,6 +75,14 @@  #define E1000_FCRTL    0x02160  /* Flow Control Receive Threshold Low - RW */  #define E1000_FCRTH    0x02168  /* Flow Control Receive Threshold High - RW */  #define E1000_FCRTV    0x02460  /* Flow Control Refresh Timer Value - RW */ +#define E1000_I2CPARAMS        0x0102C /* SFPI2C Parameters Register - RW */ +#define E1000_I2CBB_EN      0x00000100  /* I2C - Bit Bang Enable */ +#define E1000_I2C_CLK_OUT   0x00000200  /* I2C- Clock */ +#define E1000_I2C_DATA_OUT  0x00000400  /* I2C- Data Out */ +#define E1000_I2C_DATA_OE_N 0x00000800  /* I2C- Data Output Enable */ +#define E1000_I2C_DATA_IN   0x00001000  /* I2C- Data In */ +#define E1000_I2C_CLK_OE_N  0x00002000  /* I2C- Clock Output Enable */ +#define E1000_I2C_CLK_IN    0x00004000  /* I2C- Clock In */  /* IEEE 1588 TIMESYNCH */  #define E1000_TSYNCRXCTL 0x0B620 /* Rx Time Sync Control register - RW */ @@ -124,6 +132,14 @@  /* Split and Replication RX Control - RW */  #define E1000_RXPBS    0x02404  /* Rx Packet Buffer Size - RW */ + +/* Thermal sensor configuration and status registers */ +#define E1000_THMJT	0x08100 /* Junction Temperature */ +#define E1000_THLOWTC	0x08104 /* Low Threshold Control */ +#define E1000_THMIDTC	0x08108 /* Mid Threshold Control */ +#define E1000_THHIGHTC	0x0810C /* High Threshold Control */ +#define E1000_THSTAT	0x08110 /* Thermal Sensor Status */ +  /*   * Convenience macros   * diff --git a/drivers/net/ethernet/intel/igb/igb.h b/drivers/net/ethernet/intel/igb/igb.h index 17f1686ee41..d27edbc6392 100644 --- a/drivers/net/ethernet/intel/igb/igb.h +++ b/drivers/net/ethernet/intel/igb/igb.h @@ -1,7 +1,7 @@  /*******************************************************************************    Intel(R) Gigabit Ethernet Linux driver -  Copyright(c) 2007-2012 Intel Corporation. +  Copyright(c) 2007-2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -39,6 +39,8 @@  #include <linux/ptp_clock_kernel.h>  #include <linux/bitops.h>  #include <linux/if_vlan.h> +#include <linux/i2c.h> +#include <linux/i2c-algo-bit.h>  struct igb_adapter; @@ -137,8 +139,6 @@ struct vf_data_storage {  #define IGB_RX_HDR_LEN		IGB_RXBUFFER_256  #define IGB_RX_BUFSZ		IGB_RXBUFFER_2048 -/* How many Tx Descriptors do we need to call netif_wake_queue ? */ -#define IGB_TX_QUEUE_WAKE	16  /* How many Rx Buffers do we bundle into one write to the hardware ? */  #define IGB_RX_BUFFER_WRITE	16	/* Must be power of 2 */ @@ -167,6 +167,17 @@ enum igb_tx_flags {  #define IGB_TX_FLAGS_VLAN_MASK		0xffff0000  #define IGB_TX_FLAGS_VLAN_SHIFT	16 +/* + * 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. + */ +#define IGB_MAX_TXD_PWR	15 +#define IGB_MAX_DATA_PER_TXD	(1 << IGB_MAX_TXD_PWR) + +/* Tx Descriptors needed, worst case */ +#define TXD_USE_COUNT(S) DIV_ROUND_UP((S), IGB_MAX_DATA_PER_TXD) +#define DESC_NEEDED (MAX_SKB_FRAGS + 4) +  /* wrapper around a pointer to a socket buffer,   * so a DMA handle can be stored along with the buffer */  struct igb_tx_buffer { @@ -219,6 +230,7 @@ struct igb_ring {  		struct igb_tx_buffer *tx_buffer_info;  		struct igb_rx_buffer *rx_buffer_info;  	}; +	unsigned long last_rx_timestamp;  	void *desc;			/* descriptor ring memory */  	unsigned long flags;		/* ring specific flags */  	void __iomem *tail;		/* pointer to ring tail register */ @@ -272,10 +284,18 @@ struct igb_q_vector {  enum e1000_ring_flags_t {  	IGB_RING_FLAG_RX_SCTP_CSUM,  	IGB_RING_FLAG_RX_LB_VLAN_BSWAP, +	IGB_RING_FLAG_RX_BUILD_SKB_ENABLED,  	IGB_RING_FLAG_TX_CTX_IDX,  	IGB_RING_FLAG_TX_DETECT_HANG  }; +#define ring_uses_build_skb(ring) \ +	test_bit(IGB_RING_FLAG_RX_BUILD_SKB_ENABLED, &(ring)->flags) +#define set_ring_build_skb_enabled(ring) \ +	set_bit(IGB_RING_FLAG_RX_BUILD_SKB_ENABLED, &(ring)->flags) +#define clear_ring_build_skb_enabled(ring) \ +	clear_bit(IGB_RING_FLAG_RX_BUILD_SKB_ENABLED, &(ring)->flags) +  #define IGB_TXD_DCMD (E1000_ADVTXD_DCMD_EOP | E1000_ADVTXD_DCMD_RS)  #define IGB_RX_DESC(R, i)	    \ @@ -301,6 +321,32 @@ static inline int igb_desc_unused(struct igb_ring *ring)  	return ring->count + ring->next_to_clean - ring->next_to_use - 1;  } +struct igb_i2c_client_list { +	struct i2c_client *client; +	struct igb_i2c_client_list *next; +}; + +#ifdef CONFIG_IGB_HWMON + +#define IGB_HWMON_TYPE_LOC	0 +#define IGB_HWMON_TYPE_TEMP	1 +#define IGB_HWMON_TYPE_CAUTION	2 +#define IGB_HWMON_TYPE_MAX	3 + +struct hwmon_attr { +	struct device_attribute dev_attr; +	struct e1000_hw *hw; +	struct e1000_thermal_diode_data *sensor; +	char name[12]; +	}; + +struct hwmon_buff { +	struct device *device; +	struct hwmon_attr *hwmon_list; +	unsigned int n_hwmon; +	}; +#endif +  /* board specific private data structure */  struct igb_adapter {  	unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; @@ -386,11 +432,22 @@ struct igb_adapter {  	struct delayed_work ptp_overflow_work;  	struct work_struct ptp_tx_work;  	struct sk_buff *ptp_tx_skb; +	unsigned long ptp_tx_start; +	unsigned long last_rx_ptp_check;  	spinlock_t tmreg_lock;  	struct cyclecounter cc;  	struct timecounter tc; +	u32 tx_hwtstamp_timeouts; +	u32 rx_hwtstamp_cleared;  	char fw_version[32]; +#ifdef CONFIG_IGB_HWMON +	struct hwmon_buff igb_hwmon_buff; +	bool ets; +#endif +	struct i2c_algo_bit_data i2c_algo; +	struct i2c_adapter i2c_adap; +	struct igb_i2c_client_list *i2c_clients;  };  #define IGB_FLAG_HAS_MSI		(1 << 0) @@ -449,6 +506,7 @@ extern void igb_ptp_init(struct igb_adapter *adapter);  extern void igb_ptp_stop(struct igb_adapter *adapter);  extern void igb_ptp_reset(struct igb_adapter *adapter);  extern void igb_ptp_tx_work(struct work_struct *work); +extern void igb_ptp_rx_hang(struct igb_adapter *adapter);  extern void igb_ptp_tx_hwtstamp(struct igb_adapter *adapter);  extern void igb_ptp_rx_rgtstamp(struct igb_q_vector *q_vector,  				struct sk_buff *skb); @@ -466,7 +524,10 @@ static inline void igb_ptp_rx_hwtstamp(struct igb_q_vector *q_vector,  extern int igb_ptp_hwtstamp_ioctl(struct net_device *netdev,  				  struct ifreq *ifr, int cmd); - +#ifdef CONFIG_IGB_HWMON +extern void igb_sysfs_exit(struct igb_adapter *adapter); +extern int igb_sysfs_init(struct igb_adapter *adapter); +#endif  static inline s32 igb_reset_phy(struct e1000_hw *hw)  {  	if (hw->phy.ops.reset) diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c b/drivers/net/ethernet/intel/igb/igb_ethtool.c index bfe9208c4b1..a3830a8ba4c 100644 --- a/drivers/net/ethernet/intel/igb/igb_ethtool.c +++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel(R) Gigabit Ethernet Linux driver -  Copyright(c) 2007-2012 Intel Corporation. +  Copyright(c) 2007-2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -92,6 +92,8 @@ static const struct igb_stats igb_gstrings_stats[] = {  	IGB_STAT("os2bmc_tx_by_bmc", stats.b2ospc),  	IGB_STAT("os2bmc_tx_by_host", stats.o2bspc),  	IGB_STAT("os2bmc_rx_by_host", stats.b2ogprc), +	IGB_STAT("tx_hwtstamp_timeouts", tx_hwtstamp_timeouts), +	IGB_STAT("rx_hwtstamp_cleared", rx_hwtstamp_cleared),  };  #define IGB_NETDEV_STAT(_net_stat) { \ @@ -1889,7 +1891,7 @@ static int igb_link_test(struct igb_adapter *adapter, u64 *data)  	} else {  		hw->mac.ops.check_for_link(&adapter->hw);  		if (hw->mac.autoneg) -			msleep(4000); +			msleep(5000);  		if (!(rd32(E1000_STATUS) & E1000_STATUS_LU))  			*data = 1; @@ -2272,12 +2274,21 @@ static int igb_get_ts_info(struct net_device *dev,  	struct igb_adapter *adapter = netdev_priv(dev);  	switch (adapter->hw.mac.type) { +	case e1000_82575: +		info->so_timestamping = +			SOF_TIMESTAMPING_TX_SOFTWARE | +			SOF_TIMESTAMPING_RX_SOFTWARE | +			SOF_TIMESTAMPING_SOFTWARE; +		return 0;  	case e1000_82576:  	case e1000_82580:  	case e1000_i350:  	case e1000_i210:  	case e1000_i211:  		info->so_timestamping = +			SOF_TIMESTAMPING_TX_SOFTWARE | +			SOF_TIMESTAMPING_RX_SOFTWARE | +			SOF_TIMESTAMPING_SOFTWARE |  			SOF_TIMESTAMPING_TX_HARDWARE |  			SOF_TIMESTAMPING_RX_HARDWARE |  			SOF_TIMESTAMPING_RAW_HARDWARE; diff --git a/drivers/net/ethernet/intel/igb/igb_hwmon.c b/drivers/net/ethernet/intel/igb/igb_hwmon.c new file mode 100644 index 00000000000..0a9b073d0b0 --- /dev/null +++ b/drivers/net/ethernet/intel/igb/igb_hwmon.c @@ -0,0 +1,242 @@ +/******************************************************************************* + +  Intel(R) Gigabit Ethernet Linux driver +  Copyright(c) 2007-2013 Intel Corporation. + +  This program is free software; you can redistribute it and/or modify it +  under the terms and conditions of the GNU General Public License, +  version 2, as published by the Free Software Foundation. + +  This program is distributed in the hope it will be useful, but WITHOUT +  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for +  more details. + +  You should have received a copy of the GNU General Public License along with +  this program; if not, write to the Free Software Foundation, Inc., +  51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + +  The full GNU General Public License is included in this distribution in +  the file called "COPYING". + +  Contact Information: +  e1000-devel Mailing List <e1000-devel@lists.sourceforge.net> +  Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497 + +*******************************************************************************/ + +#include "igb.h" +#include "e1000_82575.h" +#include "e1000_hw.h" + +#include <linux/module.h> +#include <linux/types.h> +#include <linux/sysfs.h> +#include <linux/kobject.h> +#include <linux/device.h> +#include <linux/netdevice.h> +#include <linux/hwmon.h> +#include <linux/pci.h> + +#ifdef CONFIG_IGB_HWMON +/* hwmon callback functions */ +static ssize_t igb_hwmon_show_location(struct device *dev, +					 struct device_attribute *attr, +					 char *buf) +{ +	struct hwmon_attr *igb_attr = container_of(attr, struct hwmon_attr, +						     dev_attr); +	return sprintf(buf, "loc%u\n", +		       igb_attr->sensor->location); +} + +static ssize_t igb_hwmon_show_temp(struct device *dev, +				     struct device_attribute *attr, +				     char *buf) +{ +	struct hwmon_attr *igb_attr = container_of(attr, struct hwmon_attr, +						     dev_attr); +	unsigned int value; + +	/* reset the temp field */ +	igb_attr->hw->mac.ops.get_thermal_sensor_data(igb_attr->hw); + +	value = igb_attr->sensor->temp; + +	/* display millidegree */ +	value *= 1000; + +	return sprintf(buf, "%u\n", value); +} + +static ssize_t igb_hwmon_show_cautionthresh(struct device *dev, +				     struct device_attribute *attr, +				     char *buf) +{ +	struct hwmon_attr *igb_attr = container_of(attr, struct hwmon_attr, +						     dev_attr); +	unsigned int value = igb_attr->sensor->caution_thresh; + +	/* display millidegree */ +	value *= 1000; + +	return sprintf(buf, "%u\n", value); +} + +static ssize_t igb_hwmon_show_maxopthresh(struct device *dev, +				     struct device_attribute *attr, +				     char *buf) +{ +	struct hwmon_attr *igb_attr = container_of(attr, struct hwmon_attr, +						     dev_attr); +	unsigned int value = igb_attr->sensor->max_op_thresh; + +	/* display millidegree */ +	value *= 1000; + +	return sprintf(buf, "%u\n", value); +} + +/* igb_add_hwmon_attr - Create hwmon attr table for a hwmon sysfs file. + * @ adapter: pointer to the adapter structure + * @ offset: offset in the eeprom sensor data table + * @ type: type of sensor data to display + * + * For each file we want in hwmon's sysfs interface we need a device_attribute + * This is included in our hwmon_attr struct that contains the references to + * the data structures we need to get the data to display. + */ +static int igb_add_hwmon_attr(struct igb_adapter *adapter, +				unsigned int offset, int type) { +	int rc; +	unsigned int n_attr; +	struct hwmon_attr *igb_attr; + +	n_attr = adapter->igb_hwmon_buff.n_hwmon; +	igb_attr = &adapter->igb_hwmon_buff.hwmon_list[n_attr]; + +	switch (type) { +	case IGB_HWMON_TYPE_LOC: +		igb_attr->dev_attr.show = igb_hwmon_show_location; +		snprintf(igb_attr->name, sizeof(igb_attr->name), +			 "temp%u_label", offset); +		break; +	case IGB_HWMON_TYPE_TEMP: +		igb_attr->dev_attr.show = igb_hwmon_show_temp; +		snprintf(igb_attr->name, sizeof(igb_attr->name), +			 "temp%u_input", offset); +		break; +	case IGB_HWMON_TYPE_CAUTION: +		igb_attr->dev_attr.show = igb_hwmon_show_cautionthresh; +		snprintf(igb_attr->name, sizeof(igb_attr->name), +			 "temp%u_max", offset); +		break; +	case IGB_HWMON_TYPE_MAX: +		igb_attr->dev_attr.show = igb_hwmon_show_maxopthresh; +		snprintf(igb_attr->name, sizeof(igb_attr->name), +			 "temp%u_crit", offset); +		break; +	default: +		rc = -EPERM; +		return rc; +	} + +	/* These always the same regardless of type */ +	igb_attr->sensor = +		&adapter->hw.mac.thermal_sensor_data.sensor[offset]; +	igb_attr->hw = &adapter->hw; +	igb_attr->dev_attr.store = NULL; +	igb_attr->dev_attr.attr.mode = S_IRUGO; +	igb_attr->dev_attr.attr.name = igb_attr->name; +	sysfs_attr_init(&igb_attr->dev_attr.attr); +	rc = device_create_file(&adapter->pdev->dev, +				&igb_attr->dev_attr); +	if (rc == 0) +		++adapter->igb_hwmon_buff.n_hwmon; + +	return rc; +} + +static void igb_sysfs_del_adapter(struct igb_adapter *adapter) +{ +	int i; + +	if (adapter == NULL) +		return; + +	for (i = 0; i < adapter->igb_hwmon_buff.n_hwmon; i++) { +		device_remove_file(&adapter->pdev->dev, +			   &adapter->igb_hwmon_buff.hwmon_list[i].dev_attr); +	} + +	kfree(adapter->igb_hwmon_buff.hwmon_list); + +	if (adapter->igb_hwmon_buff.device) +		hwmon_device_unregister(adapter->igb_hwmon_buff.device); +} + +/* called from igb_main.c */ +void igb_sysfs_exit(struct igb_adapter *adapter) +{ +	igb_sysfs_del_adapter(adapter); +} + +/* called from igb_main.c */ +int igb_sysfs_init(struct igb_adapter *adapter) +{ +	struct hwmon_buff *igb_hwmon = &adapter->igb_hwmon_buff; +	unsigned int i; +	int n_attrs; +	int rc = 0; + +	/* If this method isn't defined we don't support thermals */ +	if (adapter->hw.mac.ops.init_thermal_sensor_thresh == NULL) +		goto exit; + +	/* Don't create thermal hwmon interface if no sensors present */ +	rc = (adapter->hw.mac.ops.init_thermal_sensor_thresh(&adapter->hw)); +		if (rc) +			goto exit; + +	/* Allocation space for max attributes +	 * max num sensors * values (loc, temp, max, caution) +	 */ +	n_attrs = E1000_MAX_SENSORS * 4; +	igb_hwmon->hwmon_list = kcalloc(n_attrs, sizeof(struct hwmon_attr), +					  GFP_KERNEL); +	if (!igb_hwmon->hwmon_list) { +		rc = -ENOMEM; +		goto err; +	} + +	igb_hwmon->device = hwmon_device_register(&adapter->pdev->dev); +	if (IS_ERR(igb_hwmon->device)) { +		rc = PTR_ERR(igb_hwmon->device); +		goto err; +	} + +	for (i = 0; i < E1000_MAX_SENSORS; i++) { + +		/* Only create hwmon sysfs entries for sensors that have +		 * meaningful data. +		 */ +		if (adapter->hw.mac.thermal_sensor_data.sensor[i].location == 0) +			continue; + +		/* Bail if any hwmon attr struct fails to initialize */ +		rc = igb_add_hwmon_attr(adapter, i, IGB_HWMON_TYPE_CAUTION); +		rc |= igb_add_hwmon_attr(adapter, i, IGB_HWMON_TYPE_LOC); +		rc |= igb_add_hwmon_attr(adapter, i, IGB_HWMON_TYPE_TEMP); +		rc |= igb_add_hwmon_attr(adapter, i, IGB_HWMON_TYPE_MAX); +		if (rc) +			goto err; +	} + +	goto exit; + +err: +	igb_sysfs_del_adapter(adapter); +exit: +	return rc; +} +#endif diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c index 31cfe2ec75d..ed79a1c53b5 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel(R) Gigabit Ethernet Linux driver -  Copyright(c) 2007-2012 Intel Corporation. +  Copyright(c) 2007-2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -57,6 +57,7 @@  #ifdef CONFIG_IGB_DCA  #include <linux/dca.h>  #endif +#include <linux/i2c.h>  #include "igb.h"  #define MAJ 4 @@ -68,7 +69,8 @@ char igb_driver_name[] = "igb";  char igb_driver_version[] = DRV_VERSION;  static const char igb_driver_string[] =  				"Intel(R) Gigabit Ethernet Network Driver"; -static const char igb_copyright[] = "Copyright (c) 2007-2012 Intel Corporation."; +static const char igb_copyright[] = +				"Copyright (c) 2007-2013 Intel Corporation.";  static const struct e1000_info *igb_info_tbl[] = {  	[board_82575] = &e1000_82575_info, @@ -193,6 +195,7 @@ static const struct dev_pm_ops igb_pm_ops = {  };  #endif  static void igb_shutdown(struct pci_dev *); +static int igb_pci_sriov_configure(struct pci_dev *dev, int num_vfs);  #ifdef CONFIG_IGB_DCA  static int igb_notify_dca(struct notifier_block *, unsigned long, void *);  static struct notifier_block dca_notifier = { @@ -234,6 +237,7 @@ static struct pci_driver igb_driver = {  	.driver.pm = &igb_pm_ops,  #endif  	.shutdown = igb_shutdown, +	.sriov_configure = igb_pci_sriov_configure,  	.err_handler = &igb_err_handler  }; @@ -565,6 +569,91 @@ exit:  	return;  } +/*  igb_get_i2c_data - Reads the I2C SDA data bit + *  @hw: pointer to hardware structure + *  @i2cctl: Current value of I2CCTL register + * + *  Returns the I2C data bit value + */ +static int igb_get_i2c_data(void *data) +{ +	struct igb_adapter *adapter = (struct igb_adapter *)data; +	struct e1000_hw *hw = &adapter->hw; +	s32 i2cctl = rd32(E1000_I2CPARAMS); + +	return ((i2cctl & E1000_I2C_DATA_IN) != 0); +} + +/* igb_set_i2c_data - Sets the I2C data bit + *  @data: pointer to hardware structure + *  @state: I2C data value (0 or 1) to set + * + *  Sets the I2C data bit + */ +static void igb_set_i2c_data(void *data, int state) +{ +	struct igb_adapter *adapter = (struct igb_adapter *)data; +	struct e1000_hw *hw = &adapter->hw; +	s32 i2cctl = rd32(E1000_I2CPARAMS); + +	if (state) +		i2cctl |= E1000_I2C_DATA_OUT; +	else +		i2cctl &= ~E1000_I2C_DATA_OUT; + +	i2cctl &= ~E1000_I2C_DATA_OE_N; +	i2cctl |= E1000_I2C_CLK_OE_N; +	wr32(E1000_I2CPARAMS, i2cctl); +	wrfl(); + +} + +/* igb_set_i2c_clk - Sets the I2C SCL clock + *  @data: pointer to hardware structure + *  @state: state to set clock + * + *  Sets the I2C clock line to state + */ +static void igb_set_i2c_clk(void *data, int state) +{ +	struct igb_adapter *adapter = (struct igb_adapter *)data; +	struct e1000_hw *hw = &adapter->hw; +	s32 i2cctl = rd32(E1000_I2CPARAMS); + +	if (state) { +		i2cctl |= E1000_I2C_CLK_OUT; +		i2cctl &= ~E1000_I2C_CLK_OE_N; +	} else { +		i2cctl &= ~E1000_I2C_CLK_OUT; +		i2cctl &= ~E1000_I2C_CLK_OE_N; +	} +	wr32(E1000_I2CPARAMS, i2cctl); +	wrfl(); +} + +/* igb_get_i2c_clk - Gets the I2C SCL clock state + *  @data: pointer to hardware structure + * + *  Gets the I2C clock state + */ +static int igb_get_i2c_clk(void *data) +{ +	struct igb_adapter *adapter = (struct igb_adapter *)data; +	struct e1000_hw *hw = &adapter->hw; +	s32 i2cctl = rd32(E1000_I2CPARAMS); + +	return ((i2cctl & E1000_I2C_CLK_IN) != 0); +} + +static const struct i2c_algo_bit_data igb_i2c_algo = { +	.setsda		= igb_set_i2c_data, +	.setscl		= igb_set_i2c_clk, +	.getsda		= igb_get_i2c_data, +	.getscl		= igb_get_i2c_clk, +	.udelay		= 5, +	.timeout	= 20, +}; +  /**   * igb_get_hw_dev - return device   * used by hardware layer to print debugging information @@ -1708,6 +1797,18 @@ void igb_reset(struct igb_adapter *adapter)  		igb_force_mac_fc(hw);  	igb_init_dmac(adapter, pba); +#ifdef CONFIG_IGB_HWMON +	/* Re-initialize the thermal sensor on i350 devices. */ +	if (!test_bit(__IGB_DOWN, &adapter->state)) { +		if (mac->type == e1000_i350 && hw->bus.func == 0) { +			/* If present, re-initialize the external thermal sensor +			 * interface. +			 */ +			if (adapter->ets) +				mac->ops.init_thermal_sensor_thresh(hw); +		} +	} +#endif  	if (!netif_running(adapter->netdev))  		igb_power_down_link(adapter); @@ -1822,6 +1923,37 @@ void igb_set_fw_version(struct igb_adapter *adapter)  	return;  } +static const struct i2c_board_info i350_sensor_info = { +	I2C_BOARD_INFO("i350bb", 0Xf8), +}; + +/*  igb_init_i2c - Init I2C interface + *  @adapter: pointer to adapter structure + * + */ +static s32 igb_init_i2c(struct igb_adapter *adapter) +{ +	s32 status = E1000_SUCCESS; + +	/* I2C interface supported on i350 devices */ +	if (adapter->hw.mac.type != e1000_i350) +		return E1000_SUCCESS; + +	/* Initialize the i2c bus which is controlled by the registers. +	 * This bus will use the i2c_algo_bit structue that implements +	 * the protocol through toggling of the 4 bits in the register. +	 */ +	adapter->i2c_adap.owner = THIS_MODULE; +	adapter->i2c_algo = igb_i2c_algo; +	adapter->i2c_algo.data = adapter; +	adapter->i2c_adap.algo_data = &adapter->i2c_algo; +	adapter->i2c_adap.dev.parent = &adapter->pdev->dev; +	strlcpy(adapter->i2c_adap.name, "igb BB", +		sizeof(adapter->i2c_adap.name)); +	status = i2c_bit_add_bus(&adapter->i2c_adap); +	return status; +} +  /**   * igb_probe - Device Initialization Routine   * @pdev: PCI device information struct @@ -2022,9 +2154,8 @@ static int igb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)  		dev_err(&pdev->dev, "NVM Read Error\n");  	memcpy(netdev->dev_addr, hw->mac.addr, netdev->addr_len); -	memcpy(netdev->perm_addr, hw->mac.addr, netdev->addr_len); -	if (!is_valid_ether_addr(netdev->perm_addr)) { +	if (!is_valid_ether_addr(netdev->dev_addr)) {  		dev_err(&pdev->dev, "Invalid MAC Address\n");  		err = -EIO;  		goto err_eeprom; @@ -2115,6 +2246,13 @@ static int igb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)  	/* reset the hardware with the new settings */  	igb_reset(adapter); +	/* Init the I2C interface */ +	err = igb_init_i2c(adapter); +	if (err) { +		dev_err(&pdev->dev, "failed to init i2c interface\n"); +		goto err_eeprom; +	} +  	/* let the f/w know that the h/w is now under the control of the  	 * driver. */  	igb_get_hw_control(adapter); @@ -2135,7 +2273,27 @@ static int igb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)  	}  #endif +#ifdef CONFIG_IGB_HWMON +	/* Initialize the thermal sensor on i350 devices. */ +	if (hw->mac.type == e1000_i350 && hw->bus.func == 0) { +		u16 ets_word; +		/* +		 * Read the NVM to determine if this i350 device supports an +		 * external thermal sensor. +		 */ +		hw->nvm.ops.read(hw, NVM_ETS_CFG, 1, &ets_word); +		if (ets_word != 0x0000 && ets_word != 0xFFFF) +			adapter->ets = true; +		else +			adapter->ets = false; +		if (igb_sysfs_init(adapter)) +			dev_err(&pdev->dev, +				"failed to allocate sysfs resources\n"); +	} else { +		adapter->ets = false; +	} +#endif  	/* do hw tstamp init after resetting */  	igb_ptp_init(adapter); @@ -2176,6 +2334,7 @@ static int igb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)  err_register:  	igb_release_hw_control(adapter); +	memset(&adapter->i2c_adap, 0, sizeof(adapter->i2c_adap));  err_eeprom:  	if (!igb_check_reset_block(hw))  		igb_reset_phy(hw); @@ -2196,6 +2355,111 @@ err_dma:  	return err;  } +#ifdef CONFIG_PCI_IOV +static int  igb_disable_sriov(struct pci_dev *pdev) +{ +	struct net_device *netdev = pci_get_drvdata(pdev); +	struct igb_adapter *adapter = netdev_priv(netdev); +	struct e1000_hw *hw = &adapter->hw; + +	/* reclaim resources allocated to VFs */ +	if (adapter->vf_data) { +		/* disable iov and allow time for transactions to clear */ +		if (igb_vfs_are_assigned(adapter)) { +			dev_warn(&pdev->dev, +				 "Cannot deallocate SR-IOV virtual functions while they are assigned - VFs will not be deallocated\n"); +			return -EPERM; +		} else { +			pci_disable_sriov(pdev); +			msleep(500); +		} + +		kfree(adapter->vf_data); +		adapter->vf_data = NULL; +		adapter->vfs_allocated_count = 0; +		wr32(E1000_IOVCTL, E1000_IOVCTL_REUSE_VFQ); +		wrfl(); +		msleep(100); +		dev_info(&pdev->dev, "IOV Disabled\n"); + +		/* Re-enable DMA Coalescing flag since IOV is turned off */ +		adapter->flags |= IGB_FLAG_DMAC; +	} + +	return 0; +} + +static int igb_enable_sriov(struct pci_dev *pdev, int num_vfs) +{ +	struct net_device *netdev = pci_get_drvdata(pdev); +	struct igb_adapter *adapter = netdev_priv(netdev); +	int old_vfs = pci_num_vf(pdev); +	int err = 0; +	int i; + +	if (!num_vfs) +		goto out; +	else if (old_vfs && old_vfs == num_vfs) +		goto out; +	else if (old_vfs && old_vfs != num_vfs) +		err = igb_disable_sriov(pdev); + +	if (err) +		goto out; + +	if (num_vfs > 7) { +		err = -EPERM; +		goto out; +	} + +	adapter->vfs_allocated_count = num_vfs; + +	adapter->vf_data = kcalloc(adapter->vfs_allocated_count, +				sizeof(struct vf_data_storage), GFP_KERNEL); + +	/* if allocation failed then we do not support SR-IOV */ +	if (!adapter->vf_data) { +		adapter->vfs_allocated_count = 0; +		dev_err(&pdev->dev, +			"Unable to allocate memory for VF Data Storage\n"); +		err = -ENOMEM; +		goto out; +	} + +	err = pci_enable_sriov(pdev, adapter->vfs_allocated_count); +	if (err) +		goto err_out; + +	dev_info(&pdev->dev, "%d VFs allocated\n", +		 adapter->vfs_allocated_count); +	for (i = 0; i < adapter->vfs_allocated_count; i++) +		igb_vf_configure(adapter, i); + +	/* DMA Coalescing is not supported in IOV mode. */ +	adapter->flags &= ~IGB_FLAG_DMAC; +	goto out; + +err_out: +	kfree(adapter->vf_data); +	adapter->vf_data = NULL; +	adapter->vfs_allocated_count = 0; +out: +	return err; +} + +#endif +/* + *  igb_remove_i2c - Cleanup  I2C interface + *  @adapter: pointer to adapter structure + * + */ +static void igb_remove_i2c(struct igb_adapter *adapter) +{ + +	/* free the adapter bus structure */ +	i2c_del_adapter(&adapter->i2c_adap); +} +  /**   * igb_remove - Device Removal Routine   * @pdev: PCI device information struct @@ -2212,8 +2476,11 @@ static void igb_remove(struct pci_dev *pdev)  	struct e1000_hw *hw = &adapter->hw;  	pm_runtime_get_noresume(&pdev->dev); +#ifdef CONFIG_IGB_HWMON +	igb_sysfs_exit(adapter); +#endif +	igb_remove_i2c(adapter);  	igb_ptp_stop(adapter); -  	/*  	 * The watchdog timer may be rescheduled, so explicitly  	 * disable watchdog from being rescheduled. @@ -2243,23 +2510,7 @@ static void igb_remove(struct pci_dev *pdev)  	igb_clear_interrupt_scheme(adapter);  #ifdef CONFIG_PCI_IOV -	/* reclaim resources allocated to VFs */ -	if (adapter->vf_data) { -		/* disable iov and allow time for transactions to clear */ -		if (igb_vfs_are_assigned(adapter)) { -			dev_info(&pdev->dev, "Unloading driver while VFs are assigned - VFs will not be deallocated\n"); -		} else { -			pci_disable_sriov(pdev); -			msleep(500); -		} - -		kfree(adapter->vf_data); -		adapter->vf_data = NULL; -		wr32(E1000_IOVCTL, E1000_IOVCTL_REUSE_VFQ); -		wrfl(); -		msleep(100); -		dev_info(&pdev->dev, "IOV Disabled\n"); -	} +	igb_disable_sriov(pdev);  #endif  	iounmap(hw->hw_addr); @@ -2290,103 +2541,22 @@ static void igb_probe_vfs(struct igb_adapter *adapter)  #ifdef CONFIG_PCI_IOV  	struct pci_dev *pdev = adapter->pdev;  	struct e1000_hw *hw = &adapter->hw; -	int old_vfs = pci_num_vf(adapter->pdev); -	int i;  	/* Virtualization features not supported on i210 family. */  	if ((hw->mac.type == e1000_i210) || (hw->mac.type == e1000_i211))  		return; -	if (old_vfs) { -		dev_info(&pdev->dev, "%d pre-allocated VFs found - override " -			 "max_vfs setting of %d\n", old_vfs, max_vfs); -		adapter->vfs_allocated_count = old_vfs; -	} - -	if (!adapter->vfs_allocated_count) -		return; +	igb_enable_sriov(pdev, max_vfs); +	pci_sriov_set_totalvfs(pdev, 7); -	adapter->vf_data = kcalloc(adapter->vfs_allocated_count, -				sizeof(struct vf_data_storage), GFP_KERNEL); - -	/* if allocation failed then we do not support SR-IOV */ -	if (!adapter->vf_data) { -		adapter->vfs_allocated_count = 0; -		dev_err(&pdev->dev, "Unable to allocate memory for VF " -			"Data Storage\n"); -		goto out; -	} - -	if (!old_vfs) { -		if (pci_enable_sriov(pdev, adapter->vfs_allocated_count)) -			goto err_out; -	} -	dev_info(&pdev->dev, "%d VFs allocated\n", -		 adapter->vfs_allocated_count); -	for (i = 0; i < adapter->vfs_allocated_count; i++) -		igb_vf_configure(adapter, i); - -	/* DMA Coalescing is not supported in IOV mode. */ -	adapter->flags &= ~IGB_FLAG_DMAC; -	goto out; -err_out: -	kfree(adapter->vf_data); -	adapter->vf_data = NULL; -	adapter->vfs_allocated_count = 0; -out: -	return;  #endif /* CONFIG_PCI_IOV */  } -/** - * igb_sw_init - Initialize general software structures (struct igb_adapter) - * @adapter: board private structure to initialize - * - * igb_sw_init initializes the Adapter private data structure. - * Fields are initialized based on PCI device information and - * OS network device settings (MTU size). - **/ -static int igb_sw_init(struct igb_adapter *adapter) +static void igb_init_queue_configuration(struct igb_adapter *adapter)  {  	struct e1000_hw *hw = &adapter->hw; -	struct net_device *netdev = adapter->netdev; -	struct pci_dev *pdev = adapter->pdev;  	u32 max_rss_queues; -	pci_read_config_word(pdev, PCI_COMMAND, &hw->bus.pci_cmd_word); - -	/* set default ring sizes */ -	adapter->tx_ring_count = IGB_DEFAULT_TXD; -	adapter->rx_ring_count = IGB_DEFAULT_RXD; - -	/* set default ITR values */ -	adapter->rx_itr_setting = IGB_DEFAULT_ITR; -	adapter->tx_itr_setting = IGB_DEFAULT_ITR; - -	/* set default work limits */ -	adapter->tx_work_limit = IGB_DEFAULT_TX_WORK; - -	adapter->max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN + -				  VLAN_HLEN; -	adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN; - -	spin_lock_init(&adapter->stats64_lock); -#ifdef CONFIG_PCI_IOV -	switch (hw->mac.type) { -	case e1000_82576: -	case e1000_i350: -		if (max_vfs > 7) { -			dev_warn(&pdev->dev, -				 "Maximum of 7 VFs per PF, using max\n"); -			adapter->vfs_allocated_count = 7; -		} else -			adapter->vfs_allocated_count = max_vfs; -		break; -	default: -		break; -	} -#endif /* CONFIG_PCI_IOV */ -  	/* Determine the maximum number of RSS queues supported. */  	switch (hw->mac.type) {  	case e1000_i211: @@ -2445,11 +2615,64 @@ static int igb_sw_init(struct igb_adapter *adapter)  			adapter->flags |= IGB_FLAG_QUEUE_PAIRS;  		break;  	} +} + +/** + * igb_sw_init - Initialize general software structures (struct igb_adapter) + * @adapter: board private structure to initialize + * + * igb_sw_init initializes the Adapter private data structure. + * Fields are initialized based on PCI device information and + * OS network device settings (MTU size). + **/ +static int igb_sw_init(struct igb_adapter *adapter) +{ +	struct e1000_hw *hw = &adapter->hw; +	struct net_device *netdev = adapter->netdev; +	struct pci_dev *pdev = adapter->pdev; + +	pci_read_config_word(pdev, PCI_COMMAND, &hw->bus.pci_cmd_word); + +	/* set default ring sizes */ +	adapter->tx_ring_count = IGB_DEFAULT_TXD; +	adapter->rx_ring_count = IGB_DEFAULT_RXD; + +	/* set default ITR values */ +	adapter->rx_itr_setting = IGB_DEFAULT_ITR; +	adapter->tx_itr_setting = IGB_DEFAULT_ITR; + +	/* set default work limits */ +	adapter->tx_work_limit = IGB_DEFAULT_TX_WORK; + +	adapter->max_frame_size = netdev->mtu + ETH_HLEN + ETH_FCS_LEN + +				  VLAN_HLEN; +	adapter->min_frame_size = ETH_ZLEN + ETH_FCS_LEN; + +	spin_lock_init(&adapter->stats64_lock); +#ifdef CONFIG_PCI_IOV +	switch (hw->mac.type) { +	case e1000_82576: +	case e1000_i350: +		if (max_vfs > 7) { +			dev_warn(&pdev->dev, +				 "Maximum of 7 VFs per PF, using max\n"); +			adapter->vfs_allocated_count = 7; +		} else +			adapter->vfs_allocated_count = max_vfs; +		if (adapter->vfs_allocated_count) +			dev_warn(&pdev->dev, +				 "Enabling SR-IOV VFs using the module parameter is deprecated - please use the pci sysfs interface.\n"); +		break; +	default: +		break; +	} +#endif /* CONFIG_PCI_IOV */ + +	igb_init_queue_configuration(adapter);  	/* Setup and initialize a copy of the hw vlan table array */ -	adapter->shadow_vfta = kzalloc(sizeof(u32) * -				E1000_VLAN_FILTER_TBL_SIZE, -				GFP_ATOMIC); +	adapter->shadow_vfta = kcalloc(E1000_VLAN_FILTER_TBL_SIZE, sizeof(u32), +				       GFP_ATOMIC);  	/* This call may decrease the number of queues */  	if (igb_init_interrupt_scheme(adapter, true)) { @@ -3131,6 +3354,20 @@ void igb_configure_rx_ring(struct igb_adapter *adapter,  	wr32(E1000_RXDCTL(reg_idx), rxdctl);  } +static void igb_set_rx_buffer_len(struct igb_adapter *adapter, +				  struct igb_ring *rx_ring) +{ +#define IGB_MAX_BUILD_SKB_SIZE \ +	(SKB_WITH_OVERHEAD(IGB_RX_BUFSZ) - \ +	 (NET_SKB_PAD + NET_IP_ALIGN + IGB_TS_HDR_LEN)) + +	/* set build_skb flag */ +	if (adapter->max_frame_size <= IGB_MAX_BUILD_SKB_SIZE) +		set_ring_build_skb_enabled(rx_ring); +	else +		clear_ring_build_skb_enabled(rx_ring); +} +  /**   * igb_configure_rx - Configure receive Unit after Reset   * @adapter: board private structure @@ -3150,8 +3387,11 @@ static void igb_configure_rx(struct igb_adapter *adapter)  	/* Setup the HW Rx Head and Tail Descriptor Pointers and  	 * the Base and Length of the Rx Descriptor Ring */ -	for (i = 0; i < adapter->num_rx_queues; i++) -		igb_configure_rx_ring(adapter, adapter->rx_ring[i]); +	for (i = 0; i < adapter->num_rx_queues; i++) { +		struct igb_ring *rx_ring = adapter->rx_ring[i]; +		igb_set_rx_buffer_len(adapter, rx_ring); +		igb_configure_rx_ring(adapter, rx_ring); +	}  }  /** @@ -3768,6 +4008,7 @@ static void igb_watchdog_task(struct work_struct *work)  	}  	igb_spoof_check(adapter); +	igb_ptp_rx_hang(adapter);  	/* Reset the timer */  	if (!test_bit(__IGB_DOWN, &adapter->state)) @@ -4193,13 +4434,6 @@ static void igb_tx_olinfo_status(struct igb_ring *tx_ring,  	tx_desc->read.olinfo_status = cpu_to_le32(olinfo_status);  } -/* - * 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. - */ -#define IGB_MAX_TXD_PWR	15 -#define IGB_MAX_DATA_PER_TXD	(1<<IGB_MAX_TXD_PWR) -  static void igb_tx_map(struct igb_ring *tx_ring,  		       struct igb_tx_buffer *first,  		       const u8 hdr_len) @@ -4368,15 +4602,25 @@ netdev_tx_t igb_xmit_frame_ring(struct sk_buff *skb,  	struct igb_tx_buffer *first;  	int tso;  	u32 tx_flags = 0; +	u16 count = TXD_USE_COUNT(skb_headlen(skb));  	__be16 protocol = vlan_get_protocol(skb);  	u8 hdr_len = 0; -	/* need: 1 descriptor per page, +	/* need: 1 descriptor per page * PAGE_SIZE/IGB_MAX_DATA_PER_TXD, +	 *       + 1 desc for skb_headlen/IGB_MAX_DATA_PER_TXD,  	 *       + 2 desc gap to keep tail from touching head, -	 *       + 1 desc for skb->data,  	 *       + 1 desc for context descriptor, -	 * otherwise try next time */ -	if (igb_maybe_stop_tx(tx_ring, skb_shinfo(skb)->nr_frags + 4)) { +	 * otherwise try next time +	 */ +	if (NETDEV_FRAG_PAGE_MAX_SIZE > IGB_MAX_DATA_PER_TXD) { +		unsigned short f; +		for (f = 0; f < skb_shinfo(skb)->nr_frags; f++) +			count += TXD_USE_COUNT(skb_shinfo(skb)->frags[f].size); +	} else { +		count += skb_shinfo(skb)->nr_frags; +	} + +	if (igb_maybe_stop_tx(tx_ring, count + 3)) {  		/* this is a hard error */  		return NETDEV_TX_BUSY;  	} @@ -4387,12 +4631,15 @@ netdev_tx_t igb_xmit_frame_ring(struct sk_buff *skb,  	first->bytecount = skb->len;  	first->gso_segs = 1; +	skb_tx_timestamp(skb); +  	if (unlikely((skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) &&  		     !(adapter->ptp_tx_skb))) {  		skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;  		tx_flags |= IGB_TX_FLAGS_TSTAMP;  		adapter->ptp_tx_skb = skb_get(skb); +		adapter->ptp_tx_start = jiffies;  		if (adapter->hw.mac.type == e1000_82576)  			schedule_work(&adapter->ptp_tx_work);  	} @@ -4415,7 +4662,7 @@ netdev_tx_t igb_xmit_frame_ring(struct sk_buff *skb,  	igb_tx_map(tx_ring, first, hdr_len);  	/* Make sure there is space in the ring for the next send. */ -	igb_maybe_stop_tx(tx_ring, MAX_SKB_FRAGS + 4); +	igb_maybe_stop_tx(tx_ring, DESC_NEEDED);  	return NETDEV_TX_OK; @@ -4969,7 +5216,7 @@ static int igb_vf_configure(struct igb_adapter *adapter, int vf)  {  	unsigned char mac_addr[ETH_ALEN]; -	eth_random_addr(mac_addr); +	eth_zero_addr(mac_addr);  	igb_set_vf_mac(adapter, vf, mac_addr);  	return 0; @@ -5322,9 +5569,9 @@ static void igb_vf_reset_event(struct igb_adapter *adapter, u32 vf)  {  	unsigned char *vf_mac = adapter->vf_data[vf].vf_mac_addresses; -	/* generate a new mac address as we were hotplug removed/added */ +	/* clear mac address as we were hotplug removed/added */  	if (!(adapter->vf_data[vf].flags & IGB_VF_FLAG_PF_SET_MAC)) -		eth_random_addr(vf_mac); +		eth_zero_addr(vf_mac);  	/* process remaining reset events */  	igb_vf_reset(adapter, vf); @@ -5703,7 +5950,7 @@ static bool igb_clean_tx_irq(struct igb_q_vector *q_vector)  			break;  		/* prevent any other reads prior to eop_desc */ -		rmb(); +		read_barrier_depends();  		/* if DD is not set pending work has not been completed */  		if (!(eop_desc->wb.status & cpu_to_le32(E1000_TXD_STAT_DD))) @@ -5819,9 +6066,10 @@ static bool igb_clean_tx_irq(struct igb_q_vector *q_vector)  		}  	} +#define TX_WAKE_THRESHOLD (DESC_NEEDED * 2)  	if (unlikely(total_packets &&  		     netif_carrier_ok(tx_ring->netdev) && -		     igb_desc_unused(tx_ring) >= IGB_TX_QUEUE_WAKE)) { +		     igb_desc_unused(tx_ring) >= TX_WAKE_THRESHOLD)) {  		/* Make sure that anybody stopping the queue after this  		 * sees the new next_to_clean.  		 */ @@ -5870,6 +6118,41 @@ static void igb_reuse_rx_page(struct igb_ring *rx_ring,  					 DMA_FROM_DEVICE);  } +static bool igb_can_reuse_rx_page(struct igb_rx_buffer *rx_buffer, +				  struct page *page, +				  unsigned int truesize) +{ +	/* avoid re-using remote pages */ +	if (unlikely(page_to_nid(page) != numa_node_id())) +		return false; + +#if (PAGE_SIZE < 8192) +	/* if we are only owner of page we can reuse it */ +	if (unlikely(page_count(page) != 1)) +		return false; + +	/* flip page offset to other buffer */ +	rx_buffer->page_offset ^= IGB_RX_BUFSZ; + +	/* since we are the only owner of the page and we need to +	 * increment it, just set the value to 2 in order to avoid +	 * an unnecessary locked operation +	 */ +	atomic_set(&page->_count, 2); +#else +	/* move offset up to the next cache line */ +	rx_buffer->page_offset += truesize; + +	if (rx_buffer->page_offset > (PAGE_SIZE - IGB_RX_BUFSZ)) +		return false; + +	/* bump ref count on page before it is given to the stack */ +	get_page(page); +#endif + +	return true; +} +  /**   * igb_add_rx_frag - Add contents of Rx buffer to sk_buff   * @rx_ring: rx descriptor ring to transact packets on @@ -5892,6 +6175,11 @@ static bool igb_add_rx_frag(struct igb_ring *rx_ring,  {  	struct page *page = rx_buffer->page;  	unsigned int size = le16_to_cpu(rx_desc->wb.upper.length); +#if (PAGE_SIZE < 8192) +	unsigned int truesize = IGB_RX_BUFSZ; +#else +	unsigned int truesize = ALIGN(size, L1_CACHE_BYTES); +#endif  	if ((size <= IGB_RX_HDR_LEN) && !skb_is_nonlinear(skb)) {  		unsigned char *va = page_address(page) + rx_buffer->page_offset; @@ -5914,38 +6202,88 @@ static bool igb_add_rx_frag(struct igb_ring *rx_ring,  	}  	skb_add_rx_frag(skb, skb_shinfo(skb)->nr_frags, page, -			rx_buffer->page_offset, size, IGB_RX_BUFSZ); +			rx_buffer->page_offset, size, truesize); -	/* avoid re-using remote pages */ -	if (unlikely(page_to_nid(page) != numa_node_id())) -		return false; +	return igb_can_reuse_rx_page(rx_buffer, page, truesize); +} +static struct sk_buff *igb_build_rx_buffer(struct igb_ring *rx_ring, +					   union e1000_adv_rx_desc *rx_desc) +{ +	struct igb_rx_buffer *rx_buffer; +	struct sk_buff *skb; +	struct page *page; +	void *page_addr; +	unsigned int size = le16_to_cpu(rx_desc->wb.upper.length);  #if (PAGE_SIZE < 8192) -	/* if we are only owner of page we can reuse it */ -	if (unlikely(page_count(page) != 1)) -		return false; +	unsigned int truesize = IGB_RX_BUFSZ; +#else +	unsigned int truesize = SKB_DATA_ALIGN(sizeof(struct skb_shared_info)) + +				SKB_DATA_ALIGN(NET_SKB_PAD + +					       NET_IP_ALIGN + +					       size); +#endif -	/* flip page offset to other buffer */ -	rx_buffer->page_offset ^= IGB_RX_BUFSZ; +	/* If we spanned a buffer we have a huge mess so test for it */ +	BUG_ON(unlikely(!igb_test_staterr(rx_desc, E1000_RXD_STAT_EOP))); -	/* -	 * since we are the only owner of the page and we need to -	 * increment it, just set the value to 2 in order to avoid -	 * an unnecessary locked operation -	 */ -	atomic_set(&page->_count, 2); -#else -	/* move offset up to the next cache line */ -	rx_buffer->page_offset += SKB_DATA_ALIGN(size); +	/* Guarantee this function can be used by verifying buffer sizes */ +	BUILD_BUG_ON(SKB_WITH_OVERHEAD(IGB_RX_BUFSZ) < (NET_SKB_PAD + +							NET_IP_ALIGN + +							IGB_TS_HDR_LEN + +							ETH_FRAME_LEN + +							ETH_FCS_LEN)); -	if (rx_buffer->page_offset > (PAGE_SIZE - IGB_RX_BUFSZ)) -		return false; +	rx_buffer = &rx_ring->rx_buffer_info[rx_ring->next_to_clean]; +	page = rx_buffer->page; +	prefetchw(page); -	/* bump ref count on page before it is given to the stack */ -	get_page(page); +	page_addr = page_address(page) + rx_buffer->page_offset; + +	/* prefetch first cache line of first page */ +	prefetch(page_addr + NET_SKB_PAD + NET_IP_ALIGN); +#if L1_CACHE_BYTES < 128 +	prefetch(page_addr + L1_CACHE_BYTES + NET_SKB_PAD + NET_IP_ALIGN);  #endif -	return true; +	/* build an skb to around the page buffer */ +	skb = build_skb(page_addr, truesize); +	if (unlikely(!skb)) { +		rx_ring->rx_stats.alloc_failed++; +		return NULL; +	} + +	/* we are reusing so sync this buffer for CPU use */ +	dma_sync_single_range_for_cpu(rx_ring->dev, +				      rx_buffer->dma, +				      rx_buffer->page_offset, +				      IGB_RX_BUFSZ, +				      DMA_FROM_DEVICE); + +	/* update pointers within the skb to store the data */ +	skb_reserve(skb, NET_IP_ALIGN + NET_SKB_PAD); +	__skb_put(skb, size); + +	/* pull timestamp out of packet data */ +	if (igb_test_staterr(rx_desc, E1000_RXDADV_STAT_TSIP)) { +		igb_ptp_rx_pktstamp(rx_ring->q_vector, skb->data, skb); +		__skb_pull(skb, IGB_TS_HDR_LEN); +	} + +	if (igb_can_reuse_rx_page(rx_buffer, page, truesize)) { +		/* hand second half of page back to the ring */ +		igb_reuse_rx_page(rx_ring, rx_buffer); +	} else { +		/* we are not reusing the buffer so unmap it */ +		dma_unmap_page(rx_ring->dev, rx_buffer->dma, +			       PAGE_SIZE, DMA_FROM_DEVICE); +	} + +	/* clear contents of buffer_info */ +	rx_buffer->dma = 0; +	rx_buffer->page = NULL; + +	return skb;  }  static struct sk_buff *igb_fetch_rx_buffer(struct igb_ring *rx_ring, @@ -5957,13 +6295,6 @@ static struct sk_buff *igb_fetch_rx_buffer(struct igb_ring *rx_ring,  	rx_buffer = &rx_ring->rx_buffer_info[rx_ring->next_to_clean]; -	/* -	 * This memory barrier is needed to keep us from reading -	 * any other fields out of the rx_desc until we know the -	 * RXD_STAT_DD bit is set -	 */ -	rmb(); -  	page = rx_buffer->page;  	prefetchw(page); @@ -6363,8 +6694,17 @@ static bool igb_clean_rx_irq(struct igb_q_vector *q_vector, const int budget)  		if (!igb_test_staterr(rx_desc, E1000_RXD_STAT_DD))  			break; +		/* This memory barrier is needed to keep us from reading +		 * any other fields out of the rx_desc until we know the +		 * RXD_STAT_DD bit is set +		 */ +		rmb(); +  		/* retrieve a buffer from the ring */ -		skb = igb_fetch_rx_buffer(rx_ring, rx_desc, skb); +		if (ring_uses_build_skb(rx_ring)) +			skb = igb_build_rx_buffer(rx_ring, rx_desc); +		else +			skb = igb_fetch_rx_buffer(rx_ring, rx_desc, skb);  		/* exit if we failed to retrieve a buffer */  		if (!skb) @@ -6451,6 +6791,14 @@ static bool igb_alloc_mapped_page(struct igb_ring *rx_ring,  	return true;  } +static inline unsigned int igb_rx_offset(struct igb_ring *rx_ring) +{ +	if (ring_uses_build_skb(rx_ring)) +		return NET_SKB_PAD + NET_IP_ALIGN; +	else +		return 0; +} +  /**   * igb_alloc_rx_buffers - Replace used receive buffers; packet split   * @adapter: address of board private structure @@ -6477,7 +6825,9 @@ void igb_alloc_rx_buffers(struct igb_ring *rx_ring, u16 cleaned_count)  		 * Refresh the desc even if buffer_addrs didn't change  		 * because each write-back erases this info.  		 */ -		rx_desc->read.pkt_addr = cpu_to_le64(bi->dma + bi->page_offset); +		rx_desc->read.pkt_addr = cpu_to_le64(bi->dma + +						     bi->page_offset + +						     igb_rx_offset(rx_ring));  		rx_desc++;  		bi++; @@ -6903,6 +7253,72 @@ static void igb_shutdown(struct pci_dev *pdev)  	}  } +#ifdef CONFIG_PCI_IOV +static int igb_sriov_reinit(struct pci_dev *dev) +{ +	struct net_device *netdev = pci_get_drvdata(dev); +	struct igb_adapter *adapter = netdev_priv(netdev); +	struct pci_dev *pdev = adapter->pdev; + +	rtnl_lock(); + +	if (netif_running(netdev)) +		igb_close(netdev); + +	igb_clear_interrupt_scheme(adapter); + +	igb_init_queue_configuration(adapter); + +	if (igb_init_interrupt_scheme(adapter, true)) { +		dev_err(&pdev->dev, "Unable to allocate memory for queues\n"); +		return -ENOMEM; +	} + +	if (netif_running(netdev)) +		igb_open(netdev); + +	rtnl_unlock(); + +	return 0; +} + +static int igb_pci_disable_sriov(struct pci_dev *dev) +{ +	int err = igb_disable_sriov(dev); + +	if (!err) +		err = igb_sriov_reinit(dev); + +	return err; +} + +static int igb_pci_enable_sriov(struct pci_dev *dev, int num_vfs) +{ +	int err = igb_enable_sriov(dev, num_vfs); + +	if (err) +		goto out; + +	err = igb_sriov_reinit(dev); +	if (!err) +		return num_vfs; + +out: +	return err; +} + +#endif +static int igb_pci_sriov_configure(struct pci_dev *dev, int num_vfs) +{ +#ifdef CONFIG_PCI_IOV +	if (num_vfs == 0) +		return igb_pci_disable_sriov(dev); +	else +		return igb_pci_enable_sriov(dev, num_vfs); +#endif +	return 0; +} +  #ifdef CONFIG_NET_POLL_CONTROLLER  /*   * Polling 'interrupt' - used by things like netconsole to send skbs @@ -7308,4 +7724,133 @@ static void igb_init_dmac(struct igb_adapter *adapter, u32 pba)  	}  } +static DEFINE_SPINLOCK(i2c_clients_lock); + +/*  igb_get_i2c_client - returns matching client + *  in adapters's client list. + *  @adapter: adapter struct + *  @dev_addr: device address of i2c needed. + */ +static struct i2c_client * +igb_get_i2c_client(struct igb_adapter *adapter, u8 dev_addr) +{ +	ulong flags; +	struct igb_i2c_client_list *client_list; +	struct i2c_client *client = NULL; +	struct i2c_board_info client_info = { +		I2C_BOARD_INFO("igb", 0x00), +	}; + +	spin_lock_irqsave(&i2c_clients_lock, flags); +	client_list = adapter->i2c_clients; + +	/* See if we already have an i2c_client */ +	while (client_list) { +		if (client_list->client->addr == (dev_addr >> 1)) { +			client = client_list->client; +			goto exit; +		} else { +			client_list = client_list->next; +		} +	} + +	/* no client_list found, create a new one */ +	client_list = kzalloc(sizeof(*client_list), GFP_ATOMIC); +	if (client_list == NULL) +		goto exit; + +	/* dev_addr passed to us is left-shifted by 1 bit +	 * i2c_new_device call expects it to be flush to the right. +	 */ +	client_info.addr = dev_addr >> 1; +	client_info.platform_data = adapter; +	client_list->client = i2c_new_device(&adapter->i2c_adap, &client_info); +	if (client_list->client == NULL) { +		dev_info(&adapter->pdev->dev, +			"Failed to create new i2c device..\n"); +		goto err_no_client; +	} + +	/* insert new client at head of list */ +	client_list->next = adapter->i2c_clients; +	adapter->i2c_clients = client_list; + +	client = client_list->client; +	goto exit; + +err_no_client: +	kfree(client_list); +exit: +	spin_unlock_irqrestore(&i2c_clients_lock, flags); +	return client; +} + +/*  igb_read_i2c_byte - Reads 8 bit word over I2C + *  @hw: pointer to hardware structure + *  @byte_offset: byte offset to read + *  @dev_addr: device address + *  @data: value read + * + *  Performs byte read operation over I2C interface at + *  a specified device address. + */ +s32 igb_read_i2c_byte(struct e1000_hw *hw, u8 byte_offset, +				u8 dev_addr, u8 *data) +{ +	struct igb_adapter *adapter = container_of(hw, struct igb_adapter, hw); +	struct i2c_client *this_client = igb_get_i2c_client(adapter, dev_addr); +	s32 status; +	u16 swfw_mask = 0; + +	if (!this_client) +		return E1000_ERR_I2C; + +	swfw_mask = E1000_SWFW_PHY0_SM; + +	if (hw->mac.ops.acquire_swfw_sync(hw, swfw_mask) +	    != E1000_SUCCESS) +		return E1000_ERR_SWFW_SYNC; + +	status = i2c_smbus_read_byte_data(this_client, byte_offset); +	hw->mac.ops.release_swfw_sync(hw, swfw_mask); + +	if (status < 0) +		return E1000_ERR_I2C; +	else { +		*data = status; +		return E1000_SUCCESS; +	} +} + +/*  igb_write_i2c_byte - Writes 8 bit word over I2C + *  @hw: pointer to hardware structure + *  @byte_offset: byte offset to write + *  @dev_addr: device address + *  @data: value to write + * + *  Performs byte write operation over I2C interface at + *  a specified device address. + */ +s32 igb_write_i2c_byte(struct e1000_hw *hw, u8 byte_offset, +				 u8 dev_addr, u8 data) +{ +	struct igb_adapter *adapter = container_of(hw, struct igb_adapter, hw); +	struct i2c_client *this_client = igb_get_i2c_client(adapter, dev_addr); +	s32 status; +	u16 swfw_mask = E1000_SWFW_PHY0_SM; + +	if (!this_client) +		return E1000_ERR_I2C; + +	if (hw->mac.ops.acquire_swfw_sync(hw, swfw_mask) != E1000_SUCCESS) +		return E1000_ERR_SWFW_SYNC; +	status = i2c_smbus_write_byte_data(this_client, byte_offset, data); +	hw->mac.ops.release_swfw_sync(hw, swfw_mask); + +	if (status) +		return E1000_ERR_I2C; +	else +		return E1000_SUCCESS; + +}  /* igb_main.c */ diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c index ab3429729bd..0987822359f 100644 --- a/drivers/net/ethernet/intel/igb/igb_ptp.c +++ b/drivers/net/ethernet/intel/igb/igb_ptp.c @@ -20,6 +20,7 @@  #include <linux/module.h>  #include <linux/device.h>  #include <linux/pci.h> +#include <linux/ptp_classify.h>  #include "igb.h" @@ -70,6 +71,7 @@   */  #define IGB_SYSTIM_OVERFLOW_PERIOD	(HZ * 60 * 9) +#define IGB_PTP_TX_TIMEOUT		(HZ * 15)  #define INCPERIOD_82576			(1 << E1000_TIMINCA_16NS_SHIFT)  #define INCVALUE_82576_MASK		((1 << E1000_TIMINCA_16NS_SHIFT) - 1)  #define INCVALUE_82576			(16 << IGB_82576_TSYNC_SHIFT) @@ -396,6 +398,15 @@ void igb_ptp_tx_work(struct work_struct *work)  	if (!adapter->ptp_tx_skb)  		return; +	if (time_is_before_jiffies(adapter->ptp_tx_start + +				   IGB_PTP_TX_TIMEOUT)) { +		dev_kfree_skb_any(adapter->ptp_tx_skb); +		adapter->ptp_tx_skb = NULL; +		adapter->tx_hwtstamp_timeouts++; +		dev_warn(&adapter->pdev->dev, "clearing Tx timestamp hang"); +		return; +	} +  	tsynctxctl = rd32(E1000_TSYNCTXCTL);  	if (tsynctxctl & E1000_TSYNCTXCTL_VALID)  		igb_ptp_tx_hwtstamp(adapter); @@ -419,6 +430,51 @@ static void igb_ptp_overflow_check(struct work_struct *work)  }  /** + * igb_ptp_rx_hang - detect error case when Rx timestamp registers latched + * @adapter: private network adapter structure + * + * This watchdog task is scheduled to detect error case where hardware has + * dropped an Rx packet that was timestamped when the ring is full. The + * particular error is rare but leaves the device in a state unable to timestamp + * any future packets. + */ +void igb_ptp_rx_hang(struct igb_adapter *adapter) +{ +	struct e1000_hw *hw = &adapter->hw; +	struct igb_ring *rx_ring; +	u32 tsyncrxctl = rd32(E1000_TSYNCRXCTL); +	unsigned long rx_event; +	int n; + +	if (hw->mac.type != e1000_82576) +		return; + +	/* If we don't have a valid timestamp in the registers, just update the +	 * timeout counter and exit +	 */ +	if (!(tsyncrxctl & E1000_TSYNCRXCTL_VALID)) { +		adapter->last_rx_ptp_check = jiffies; +		return; +	} + +	/* Determine the most recent watchdog or rx_timestamp event */ +	rx_event = adapter->last_rx_ptp_check; +	for (n = 0; n < adapter->num_rx_queues; n++) { +		rx_ring = adapter->rx_ring[n]; +		if (time_after(rx_ring->last_rx_timestamp, rx_event)) +			rx_event = rx_ring->last_rx_timestamp; +	} + +	/* Only need to read the high RXSTMP register to clear the lock */ +	if (time_is_before_jiffies(rx_event + 5 * HZ)) { +		rd32(E1000_RXSTMPH); +		adapter->last_rx_ptp_check = jiffies; +		adapter->rx_hwtstamp_cleared++; +		dev_warn(&adapter->pdev->dev, "clearing Rx timestamp hang"); +	} +} + +/**   * igb_ptp_tx_hwtstamp - utility function which checks for TX time stamp   * @adapter: Board private structure.   * @@ -643,7 +699,6 @@ int igb_ptp_hwtstamp_ioctl(struct net_device *netdev,  	else  		wr32(E1000_ETQF(3), 0); -#define PTP_PORT 319  	/* L4 Queue Filter[3]: filter by destination port and protocol */  	if (is_l4) {  		u32 ftqf = (IPPROTO_UDP /* UDP */ @@ -652,12 +707,12 @@ int igb_ptp_hwtstamp_ioctl(struct net_device *netdev,  			| E1000_FTQF_MASK); /* mask all inputs */  		ftqf &= ~E1000_FTQF_MASK_PROTO_BP; /* enable protocol check */ -		wr32(E1000_IMIR(3), htons(PTP_PORT)); +		wr32(E1000_IMIR(3), htons(PTP_EV_PORT));  		wr32(E1000_IMIREXT(3),  		     (E1000_IMIREXT_SIZE_BP | E1000_IMIREXT_CTRL_BP));  		if (hw->mac.type == e1000_82576) {  			/* enable source port check */ -			wr32(E1000_SPQF(3), htons(PTP_PORT)); +			wr32(E1000_SPQF(3), htons(PTP_EV_PORT));  			ftqf &= ~E1000_FTQF_MASK_SOURCE_PORT_BP;  		}  		wr32(E1000_FTQF(3), ftqf); @@ -801,6 +856,10 @@ void igb_ptp_stop(struct igb_adapter *adapter)  	}  	cancel_work_sync(&adapter->ptp_tx_work); +	if (adapter->ptp_tx_skb) { +		dev_kfree_skb_any(adapter->ptp_tx_skb); +		adapter->ptp_tx_skb = NULL; +	}  	if (adapter->ptp_clock) {  		ptp_clock_unregister(adapter->ptp_clock); diff --git a/drivers/net/ethernet/intel/igbvf/igbvf.h b/drivers/net/ethernet/intel/igbvf/igbvf.h index fdca7b67277..a1463e3d14c 100644 --- a/drivers/net/ethernet/intel/igbvf/igbvf.h +++ b/drivers/net/ethernet/intel/igbvf/igbvf.h @@ -127,8 +127,8 @@ struct igbvf_buffer {  		/* Tx */  		struct {  			unsigned long time_stamp; +			union e1000_adv_tx_desc *next_to_watch;  			u16 length; -			u16 next_to_watch;  			u16 mapped_as_page;  		};  		/* Rx */ diff --git a/drivers/net/ethernet/intel/igbvf/netdev.c b/drivers/net/ethernet/intel/igbvf/netdev.c index 277f5dfe3d9..d60cd439341 100644 --- a/drivers/net/ethernet/intel/igbvf/netdev.c +++ b/drivers/net/ethernet/intel/igbvf/netdev.c @@ -797,20 +797,31 @@ static bool igbvf_clean_tx_irq(struct igbvf_ring *tx_ring)  	struct sk_buff *skb;  	union e1000_adv_tx_desc *tx_desc, *eop_desc;  	unsigned int total_bytes = 0, total_packets = 0; -	unsigned int i, eop, count = 0; +	unsigned int i, count = 0;  	bool cleaned = false;  	i = tx_ring->next_to_clean; -	eop = tx_ring->buffer_info[i].next_to_watch; -	eop_desc = IGBVF_TX_DESC_ADV(*tx_ring, eop); +	buffer_info = &tx_ring->buffer_info[i]; +	eop_desc = buffer_info->next_to_watch; + +	do { +		/* if next_to_watch is not set then there is no work pending */ +		if (!eop_desc) +			break; + +		/* prevent any other reads prior to eop_desc */ +		read_barrier_depends(); + +		/* if DD is not set pending work has not been completed */ +		if (!(eop_desc->wb.status & cpu_to_le32(E1000_TXD_STAT_DD))) +			break; + +		/* clear next_to_watch to prevent false hangs */ +		buffer_info->next_to_watch = NULL; -	while ((eop_desc->wb.status & cpu_to_le32(E1000_TXD_STAT_DD)) && -	       (count < tx_ring->count)) { -		rmb();	/* read buffer_info after eop_desc status */  		for (cleaned = false; !cleaned; count++) {  			tx_desc = IGBVF_TX_DESC_ADV(*tx_ring, i); -			buffer_info = &tx_ring->buffer_info[i]; -			cleaned = (i == eop); +			cleaned = (tx_desc == eop_desc);  			skb = buffer_info->skb;  			if (skb) { @@ -831,10 +842,12 @@ static bool igbvf_clean_tx_irq(struct igbvf_ring *tx_ring)  			i++;  			if (i == tx_ring->count)  				i = 0; + +			buffer_info = &tx_ring->buffer_info[i];  		} -		eop = tx_ring->buffer_info[i].next_to_watch; -		eop_desc = IGBVF_TX_DESC_ADV(*tx_ring, eop); -	} + +		eop_desc = buffer_info->next_to_watch; +	} while (count < tx_ring->count);  	tx_ring->next_to_clean = i; @@ -1399,12 +1412,10 @@ static void igbvf_set_multi(struct net_device *netdev)  	int i;  	if (!netdev_mc_empty(netdev)) { -		mta_list = kmalloc(netdev_mc_count(netdev) * 6, GFP_ATOMIC); -		if (!mta_list) { -			dev_err(&adapter->pdev->dev, -			        "failed to allocate multicast filter list\n"); +		mta_list = kmalloc_array(netdev_mc_count(netdev), ETH_ALEN, +					 GFP_ATOMIC); +		if (!mta_list)  			return; -		}  	}  	/* prepare a packed array of only addresses. */ @@ -1738,7 +1749,6 @@ static int igbvf_set_mac(struct net_device *netdev, void *p)  		return -EADDRNOTAVAIL;  	memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); -	netdev->addr_assign_type &= ~NET_ADDR_RANDOM;  	return 0;  } @@ -1964,7 +1974,6 @@ static int igbvf_tso(struct igbvf_adapter *adapter,  	context_desc->seqnum_seed = 0;  	buffer_info->time_stamp = jiffies; -	buffer_info->next_to_watch = i;  	buffer_info->dma = 0;  	i++;  	if (i == tx_ring->count) @@ -2024,7 +2033,6 @@ static inline bool igbvf_tx_csum(struct igbvf_adapter *adapter,  		context_desc->mss_l4len_idx = 0;  		buffer_info->time_stamp = jiffies; -		buffer_info->next_to_watch = i;  		buffer_info->dma = 0;  		i++;  		if (i == tx_ring->count) @@ -2064,8 +2072,7 @@ static int igbvf_maybe_stop_tx(struct net_device *netdev, int size)  static inline int igbvf_tx_map_adv(struct igbvf_adapter *adapter,                                     struct igbvf_ring *tx_ring, -                                   struct sk_buff *skb, -                                   unsigned int first) +				   struct sk_buff *skb)  {  	struct igbvf_buffer *buffer_info;  	struct pci_dev *pdev = adapter->pdev; @@ -2080,7 +2087,6 @@ static inline int igbvf_tx_map_adv(struct igbvf_adapter *adapter,  	buffer_info->length = len;  	/* set time_stamp *before* dma to help avoid a possible race */  	buffer_info->time_stamp = jiffies; -	buffer_info->next_to_watch = i;  	buffer_info->mapped_as_page = false;  	buffer_info->dma = dma_map_single(&pdev->dev, skb->data, len,  					  DMA_TO_DEVICE); @@ -2103,7 +2109,6 @@ static inline int igbvf_tx_map_adv(struct igbvf_adapter *adapter,  		BUG_ON(len >= IGBVF_MAX_DATA_PER_TXD);  		buffer_info->length = len;  		buffer_info->time_stamp = jiffies; -		buffer_info->next_to_watch = i;  		buffer_info->mapped_as_page = true;  		buffer_info->dma = skb_frag_dma_map(&pdev->dev, frag, 0, len,  						DMA_TO_DEVICE); @@ -2112,7 +2117,6 @@ static inline int igbvf_tx_map_adv(struct igbvf_adapter *adapter,  	}  	tx_ring->buffer_info[i].skb = skb; -	tx_ring->buffer_info[first].next_to_watch = i;  	return ++count; @@ -2123,7 +2127,6 @@ dma_error:  	buffer_info->dma = 0;  	buffer_info->time_stamp = 0;  	buffer_info->length = 0; -	buffer_info->next_to_watch = 0;  	buffer_info->mapped_as_page = false;  	if (count)  		count--; @@ -2142,7 +2145,8 @@ dma_error:  static inline void igbvf_tx_queue_adv(struct igbvf_adapter *adapter,                                        struct igbvf_ring *tx_ring, -                                      int tx_flags, int count, u32 paylen, +				      int tx_flags, int count, +				      unsigned int first, u32 paylen,                                        u8 hdr_len)  {  	union e1000_adv_tx_desc *tx_desc = NULL; @@ -2192,6 +2196,7 @@ static inline void igbvf_tx_queue_adv(struct igbvf_adapter *adapter,  	 * such as IA-64). */  	wmb(); +	tx_ring->buffer_info[first].next_to_watch = tx_desc;  	tx_ring->next_to_use = i;  	writel(i, adapter->hw.hw_addr + tx_ring->tail);  	/* we need this if more than one processor can write to our tail @@ -2258,11 +2263,11 @@ static netdev_tx_t igbvf_xmit_frame_ring_adv(struct sk_buff *skb,  	 * count reflects descriptors mapped, if 0 then mapping error  	 * has occurred and we need to rewind the descriptor queue  	 */ -	count = igbvf_tx_map_adv(adapter, tx_ring, skb, first); +	count = igbvf_tx_map_adv(adapter, tx_ring, skb);  	if (count) {  		igbvf_tx_queue_adv(adapter, tx_ring, tx_flags, count, -		                   skb->len, hdr_len); +				   first, skb->len, hdr_len);  		/* Make sure there is space in the ring for the next send. */  		igbvf_maybe_stop_tx(netdev, MAX_SKB_FRAGS + 4);  	} else { @@ -2736,30 +2741,24 @@ static int igbvf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)  	err = hw->mac.ops.reset_hw(hw);  	if (err) {  		dev_info(&pdev->dev, -			 "PF still in reset state, assigning new address." -			 " Is the PF interface up?\n"); -		eth_hw_addr_random(netdev); -		memcpy(adapter->hw.mac.addr, netdev->dev_addr, -			netdev->addr_len); +			 "PF still in reset state. Is the PF interface up?\n");  	} else {  		err = hw->mac.ops.read_mac_addr(hw); -		if (err) { -			dev_err(&pdev->dev, "Error reading MAC address\n"); -			goto err_hw_init; -		} +		if (err) +			dev_info(&pdev->dev, "Error reading MAC address.\n"); +		else if (is_zero_ether_addr(adapter->hw.mac.addr)) +			dev_info(&pdev->dev, "MAC address not assigned by administrator.\n");  		memcpy(netdev->dev_addr, adapter->hw.mac.addr, -			netdev->addr_len); +		       netdev->addr_len);  	}  	if (!is_valid_ether_addr(netdev->dev_addr)) { -		dev_err(&pdev->dev, "Invalid MAC Address: %pM\n", -		        netdev->dev_addr); -		err = -EIO; -		goto err_hw_init; +		dev_info(&pdev->dev, "Assigning random MAC address.\n"); +		eth_hw_addr_random(netdev); +		memcpy(adapter->hw.mac.addr, netdev->dev_addr, +			netdev->addr_len);  	} -	memcpy(netdev->perm_addr, netdev->dev_addr, netdev->addr_len); -  	setup_timer(&adapter->watchdog_timer, &igbvf_watchdog,  	            (unsigned long) adapter); diff --git a/drivers/net/ethernet/intel/ixgb/ixgb_main.c b/drivers/net/ethernet/intel/ixgb/ixgb_main.c index ae96c10251b..ea480837343 100644 --- a/drivers/net/ethernet/intel/ixgb/ixgb_main.c +++ b/drivers/net/ethernet/intel/ixgb/ixgb_main.c @@ -500,9 +500,8 @@ ixgb_probe(struct pci_dev *pdev, const struct pci_device_id *ent)  	}  	ixgb_get_ee_mac_addr(&adapter->hw, netdev->dev_addr); -	memcpy(netdev->perm_addr, netdev->dev_addr, netdev->addr_len); -	if (!is_valid_ether_addr(netdev->perm_addr)) { +	if (!is_valid_ether_addr(netdev->dev_addr)) {  		netif_err(adapter, probe, adapter->netdev, "Invalid MAC Address\n");  		err = -EIO;  		goto err_eeprom; @@ -709,11 +708,8 @@ ixgb_setup_tx_resources(struct ixgb_adapter *adapter)  	size = sizeof(struct ixgb_buffer) * txdr->count;  	txdr->buffer_info = vzalloc(size); -	if (!txdr->buffer_info) { -		netif_err(adapter, probe, adapter->netdev, -			  "Unable to allocate transmit descriptor ring memory\n"); +	if (!txdr->buffer_info)  		return -ENOMEM; -	}  	/* round up to nearest 4K */ @@ -798,11 +794,8 @@ ixgb_setup_rx_resources(struct ixgb_adapter *adapter)  	size = sizeof(struct ixgb_buffer) * rxdr->count;  	rxdr->buffer_info = vzalloc(size); -	if (!rxdr->buffer_info) { -		netif_err(adapter, probe, adapter->netdev, -			  "Unable to allocate receive descriptor ring\n"); +	if (!rxdr->buffer_info)  		return -ENOMEM; -	}  	/* Round up to nearest 4K */ diff --git a/drivers/net/ethernet/intel/ixgbe/Makefile b/drivers/net/ethernet/intel/ixgbe/Makefile index f3a632bf8d9..be2989e6000 100644 --- a/drivers/net/ethernet/intel/ixgbe/Makefile +++ b/drivers/net/ethernet/intel/ixgbe/Makefile @@ -1,7 +1,7 @@  ################################################################################  #  # Intel 10 Gigabit PCI Express Linux driver -# Copyright(c) 1999 - 2012 Intel Corporation. +# Copyright(c) 1999 - 2013 Intel Corporation.  #  # This program is free software; you can redistribute it and/or modify it  # under the terms and conditions of the GNU General Public License, @@ -32,7 +32,7 @@  obj-$(CONFIG_IXGBE) += ixgbe.o -ixgbe-objs := ixgbe_main.o ixgbe_common.o ixgbe_ethtool.o ixgbe_debugfs.o\ +ixgbe-objs := ixgbe_main.o ixgbe_common.o ixgbe_ethtool.o \                ixgbe_82599.o ixgbe_82598.o ixgbe_phy.o ixgbe_sriov.o \                ixgbe_mbx.o ixgbe_x540.o ixgbe_lib.o ixgbe_ptp.o @@ -40,4 +40,5 @@ ixgbe-$(CONFIG_IXGBE_DCB) +=  ixgbe_dcb.o ixgbe_dcb_82598.o \                                ixgbe_dcb_82599.o ixgbe_dcb_nl.o  ixgbe-$(CONFIG_IXGBE_HWMON) += ixgbe_sysfs.o +ixgbe-$(CONFIG_DEBUG_FS) += ixgbe_debugfs.o  ixgbe-$(CONFIG_FCOE:m=y) += ixgbe_fcoe.o diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe.h index 8e786764c60..a8e10cff7a8 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe.h @@ -1,7 +1,7 @@  /*******************************************************************************    Intel 10 Gigabit PCI Express Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -35,6 +35,7 @@  #include <linux/cpumask.h>  #include <linux/aer.h>  #include <linux/if_vlan.h> +#include <linux/jiffies.h>  #include <linux/clocksource.h>  #include <linux/net_tstamp.h> @@ -91,21 +92,26 @@   */  #define IXGBE_RX_HDR_SIZE IXGBE_RXBUFFER_256 -#define MAXIMUM_ETHERNET_VLAN_SIZE (ETH_FRAME_LEN + ETH_FCS_LEN + VLAN_HLEN) -  /* How many Rx Buffers do we bundle into one write to the hardware ? */  #define IXGBE_RX_BUFFER_WRITE	16	/* Must be power of 2 */ -#define IXGBE_TX_FLAGS_CSUM		(u32)(1) -#define IXGBE_TX_FLAGS_HW_VLAN		(u32)(1 << 1) -#define IXGBE_TX_FLAGS_SW_VLAN		(u32)(1 << 2) -#define IXGBE_TX_FLAGS_TSO		(u32)(1 << 3) -#define IXGBE_TX_FLAGS_IPV4		(u32)(1 << 4) -#define IXGBE_TX_FLAGS_FCOE		(u32)(1 << 5) -#define IXGBE_TX_FLAGS_FSO		(u32)(1 << 6) -#define IXGBE_TX_FLAGS_TXSW		(u32)(1 << 7) -#define IXGBE_TX_FLAGS_TSTAMP		(u32)(1 << 8) -#define IXGBE_TX_FLAGS_NO_IFCS		(u32)(1 << 9) +enum ixgbe_tx_flags { +	/* cmd_type flags */ +	IXGBE_TX_FLAGS_HW_VLAN	= 0x01, +	IXGBE_TX_FLAGS_TSO	= 0x02, +	IXGBE_TX_FLAGS_TSTAMP	= 0x04, + +	/* olinfo flags */ +	IXGBE_TX_FLAGS_CC	= 0x08, +	IXGBE_TX_FLAGS_IPV4	= 0x10, +	IXGBE_TX_FLAGS_CSUM	= 0x20, + +	/* software defined flags */ +	IXGBE_TX_FLAGS_SW_VLAN	= 0x40, +	IXGBE_TX_FLAGS_FCOE	= 0x80, +}; + +/* VLAN info */  #define IXGBE_TX_FLAGS_VLAN_MASK	0xffff0000  #define IXGBE_TX_FLAGS_VLAN_PRIO_MASK	0xe0000000  #define IXGBE_TX_FLAGS_VLAN_PRIO_SHIFT  29 @@ -150,7 +156,7 @@ struct vf_macvlans {  /* Tx Descriptors needed, worst case */  #define TXD_USE_COUNT(S) DIV_ROUND_UP((S), IXGBE_MAX_DATA_PER_TXD) -#define DESC_NEEDED ((MAX_SKB_FRAGS * TXD_USE_COUNT(PAGE_SIZE)) + 4) +#define DESC_NEEDED (MAX_SKB_FRAGS + 4)  /* wrapper around a pointer to a socket buffer,   * so a DMA handle can be stored along with the buffer */ @@ -195,6 +201,7 @@ struct ixgbe_rx_queue_stats {  enum ixgbe_ring_state_t {  	__IXGBE_TX_FDIR_INIT_DONE, +	__IXGBE_TX_XPS_INIT_DONE,  	__IXGBE_TX_DETECT_HANG,  	__IXGBE_HANG_CHECK_ARMED,  	__IXGBE_RX_RSC_ENABLED, @@ -224,6 +231,7 @@ struct ixgbe_ring {  		struct ixgbe_tx_buffer *tx_buffer_info;  		struct ixgbe_rx_buffer *rx_buffer_info;  	}; +	unsigned long last_rx_timestamp;  	unsigned long state;  	u8 __iomem *tail;  	dma_addr_t dma;			/* phys. address of descriptor ring */ @@ -271,15 +279,10 @@ enum ixgbe_ring_f_enum {  #define IXGBE_MAX_RSS_INDICES  16  #define IXGBE_MAX_VMDQ_INDICES 64 -#define IXGBE_MAX_FDIR_INDICES 64 -#ifdef IXGBE_FCOE +#define IXGBE_MAX_FDIR_INDICES 63	/* based on q_vector limit */  #define IXGBE_MAX_FCOE_INDICES  8 -#define MAX_RX_QUEUES (IXGBE_MAX_FDIR_INDICES + IXGBE_MAX_FCOE_INDICES) -#define MAX_TX_QUEUES (IXGBE_MAX_FDIR_INDICES + IXGBE_MAX_FCOE_INDICES) -#else -#define MAX_RX_QUEUES IXGBE_MAX_FDIR_INDICES -#define MAX_TX_QUEUES IXGBE_MAX_FDIR_INDICES -#endif /* IXGBE_FCOE */ +#define MAX_RX_QUEUES (IXGBE_MAX_FDIR_INDICES + 1) +#define MAX_TX_QUEUES (IXGBE_MAX_FDIR_INDICES + 1)  struct ixgbe_ring_feature {  	u16 limit;	/* upper limit on feature indices */  	u16 indices;	/* current value of indices */ @@ -573,11 +576,14 @@ struct ixgbe_adapter {  	struct ptp_clock *ptp_clock;  	struct ptp_clock_info ptp_caps; +	struct work_struct ptp_tx_work; +	struct sk_buff *ptp_tx_skb; +	unsigned long ptp_tx_start;  	unsigned long last_overflow_check; +	unsigned long last_rx_ptp_check;  	spinlock_t tmreg_lock;  	struct cyclecounter cc;  	struct timecounter tc; -	int rx_hwtstamp_filter;  	u32 base_incval;  	/* SR-IOV */ @@ -614,6 +620,7 @@ enum ixgbe_state_t {  	__IXGBE_DOWN,  	__IXGBE_SERVICE_SCHED,  	__IXGBE_IN_SFP_INIT, +	__IXGBE_READ_I2C,  };  struct ixgbe_cb { @@ -694,8 +701,8 @@ extern bool ixgbe_verify_lesm_fw_enabled_82599(struct ixgbe_hw *hw);  extern void ixgbe_set_rx_mode(struct net_device *netdev);  #ifdef CONFIG_IXGBE_DCB  extern void ixgbe_set_rx_drop_en(struct ixgbe_adapter *adapter); -extern int ixgbe_setup_tc(struct net_device *dev, u8 tc);  #endif +extern int ixgbe_setup_tc(struct net_device *dev, u8 tc);  extern void ixgbe_tx_ctxtdesc(struct ixgbe_ring *, u32, u32, u32, u32);  extern void ixgbe_do_reset(struct net_device *netdev);  #ifdef CONFIG_IXGBE_HWMON @@ -742,15 +749,32 @@ static inline struct netdev_queue *txring_txq(const struct ixgbe_ring *ring)  extern void ixgbe_ptp_init(struct ixgbe_adapter *adapter);  extern void ixgbe_ptp_stop(struct ixgbe_adapter *adapter);  extern void ixgbe_ptp_overflow_check(struct ixgbe_adapter *adapter); -extern void ixgbe_ptp_tx_hwtstamp(struct ixgbe_q_vector *q_vector, -				  struct sk_buff *skb); -extern void ixgbe_ptp_rx_hwtstamp(struct ixgbe_q_vector *q_vector, -				  union ixgbe_adv_rx_desc *rx_desc, -				  struct sk_buff *skb); +extern void ixgbe_ptp_rx_hang(struct ixgbe_adapter *adapter); +extern void __ixgbe_ptp_rx_hwtstamp(struct ixgbe_q_vector *q_vector, +				    struct sk_buff *skb); +static inline void ixgbe_ptp_rx_hwtstamp(struct ixgbe_ring *rx_ring, +					 union ixgbe_adv_rx_desc *rx_desc, +					 struct sk_buff *skb) +{ +	if (unlikely(!ixgbe_test_staterr(rx_desc, IXGBE_RXDADV_STAT_TS))) +		return; + +	__ixgbe_ptp_rx_hwtstamp(rx_ring->q_vector, skb); + +	/* +	 * Update the last_rx_timestamp timer in order to enable watchdog check +	 * for error case of latched timestamp on a dropped packet. +	 */ +	rx_ring->last_rx_timestamp = jiffies; +} +  extern int ixgbe_ptp_hwtstamp_ioctl(struct ixgbe_adapter *adapter,  				    struct ifreq *ifr, int cmd);  extern void ixgbe_ptp_start_cyclecounter(struct ixgbe_adapter *adapter);  extern void ixgbe_ptp_reset(struct ixgbe_adapter *adapter);  extern void ixgbe_ptp_check_pps_event(struct ixgbe_adapter *adapter, u32 eicr); +#ifdef CONFIG_PCI_IOV +void ixgbe_sriov_reinit(struct ixgbe_adapter *adapter); +#endif  #endif /* _IXGBE_H_ */ diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c index 42537336110..d0113fc97b6 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_82598.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel 10 Gigabit PCI Express Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -41,7 +41,6 @@  static s32 ixgbe_setup_copper_link_82598(struct ixgbe_hw *hw,                                           ixgbe_link_speed speed, -                                         bool autoneg,                                           bool autoneg_wait_to_complete);  static s32 ixgbe_read_i2c_eeprom_82598(struct ixgbe_hw *hw, u8 byte_offset,                                         u8 *eeprom_data); @@ -633,15 +632,15 @@ out:   *  ixgbe_setup_mac_link_82598 - Set MAC link speed   *  @hw: pointer to hardware structure   *  @speed: new link speed - *  @autoneg: true if auto-negotiation enabled   *  @autoneg_wait_to_complete: true when waiting for completion is needed   *   *  Set the link speed in the AUTOC register and restarts link.   **/  static s32 ixgbe_setup_mac_link_82598(struct ixgbe_hw *hw, -                                           ixgbe_link_speed speed, bool autoneg, -                                           bool autoneg_wait_to_complete) +				      ixgbe_link_speed speed, +				      bool autoneg_wait_to_complete)  { +	bool		 autoneg	   = false;  	s32              status            = 0;  	ixgbe_link_speed link_capabilities = IXGBE_LINK_SPEED_UNKNOWN;  	u32              curr_autoc        = IXGBE_READ_REG(hw, IXGBE_AUTOC); @@ -685,20 +684,18 @@ static s32 ixgbe_setup_mac_link_82598(struct ixgbe_hw *hw,   *  ixgbe_setup_copper_link_82598 - Set the PHY autoneg advertised field   *  @hw: pointer to hardware structure   *  @speed: new link speed - *  @autoneg: true if autonegotiation enabled   *  @autoneg_wait_to_complete: true if waiting is needed to complete   *   *  Sets the link speed in the AUTOC register in the MAC and restarts link.   **/  static s32 ixgbe_setup_copper_link_82598(struct ixgbe_hw *hw,                                                 ixgbe_link_speed speed, -                                               bool autoneg,                                                 bool autoneg_wait_to_complete)  {  	s32 status;  	/* Setup the PHY according to input speed */ -	status = hw->phy.ops.setup_link_speed(hw, speed, autoneg, +	status = hw->phy.ops.setup_link_speed(hw, speed,  	                                      autoneg_wait_to_complete);  	/* Set up MAC */  	ixgbe_start_mac_link_82598(hw, autoneg_wait_to_complete); @@ -1006,15 +1003,16 @@ static s32 ixgbe_write_analog_reg8_82598(struct ixgbe_hw *hw, u32 reg, u8 val)  }  /** - *  ixgbe_read_i2c_eeprom_82598 - Reads 8 bit word over I2C interface. + *  ixgbe_read_i2c_phy_82598 - Reads 8 bit word over I2C interface.   *  @hw: pointer to hardware structure - *  @byte_offset: EEPROM byte offset to read + *  @dev_addr: address to read from + *  @byte_offset: byte offset to read from dev_addr   *  @eeprom_data: value read   * - *  Performs 8 byte read operation to SFP module's EEPROM over I2C interface. + *  Performs 8 byte read operation to SFP module's data over I2C interface.   **/ -static s32 ixgbe_read_i2c_eeprom_82598(struct ixgbe_hw *hw, u8 byte_offset, -				       u8 *eeprom_data) +static s32 ixgbe_read_i2c_phy_82598(struct ixgbe_hw *hw, u8 dev_addr, +				    u8 byte_offset, u8 *eeprom_data)  {  	s32 status = 0;  	u16 sfp_addr = 0; @@ -1028,7 +1026,7 @@ static s32 ixgbe_read_i2c_eeprom_82598(struct ixgbe_hw *hw, u8 byte_offset,  		 * 0xC30D.  These registers are used to talk to the SFP+  		 * module's EEPROM through the SDA/SCL (I2C) interface.  		 */ -		sfp_addr = (IXGBE_I2C_EEPROM_DEV_ADDR << 8) + byte_offset; +		sfp_addr = (dev_addr << 8) + byte_offset;  		sfp_addr = (sfp_addr | IXGBE_I2C_EEPROM_READ_MASK);  		hw->phy.ops.write_reg(hw,  		                      IXGBE_MDIO_PMA_PMD_SDA_SCL_ADDR, @@ -1060,7 +1058,6 @@ static s32 ixgbe_read_i2c_eeprom_82598(struct ixgbe_hw *hw, u8 byte_offset,  		*eeprom_data = (u8)(sfp_data >> 8);  	} else {  		status = IXGBE_ERR_PHY; -		goto out;  	}  out: @@ -1068,6 +1065,36 @@ out:  }  /** + *  ixgbe_read_i2c_eeprom_82598 - Reads 8 bit word over I2C interface. + *  @hw: pointer to hardware structure + *  @byte_offset: EEPROM byte offset to read + *  @eeprom_data: value read + * + *  Performs 8 byte read operation to SFP module's EEPROM over I2C interface. + **/ +static s32 ixgbe_read_i2c_eeprom_82598(struct ixgbe_hw *hw, u8 byte_offset, +				       u8 *eeprom_data) +{ +	return ixgbe_read_i2c_phy_82598(hw, IXGBE_I2C_EEPROM_DEV_ADDR, +					byte_offset, eeprom_data); +} + +/** + *  ixgbe_read_i2c_sff8472_82598 - Reads 8 bit word over I2C interface. + *  @hw: pointer to hardware structure + *  @byte_offset: byte offset at address 0xA2 + *  @eeprom_data: value read + * + *  Performs 8 byte read operation to SFP module's SFF-8472 data over I2C + **/ +static s32 ixgbe_read_i2c_sff8472_82598(struct ixgbe_hw *hw, u8 byte_offset, +				       u8 *sff8472_data) +{ +	return ixgbe_read_i2c_phy_82598(hw, IXGBE_I2C_EEPROM_DEV_ADDR2, +					byte_offset, sff8472_data); +} + +/**   *  ixgbe_get_supported_physical_layer_82598 - Returns physical layer type   *  @hw: pointer to hardware structure   * @@ -1300,6 +1327,7 @@ static struct ixgbe_phy_operations phy_ops_82598 = {  	.write_reg		= &ixgbe_write_phy_reg_generic,  	.setup_link		= &ixgbe_setup_phy_link_generic,  	.setup_link_speed	= &ixgbe_setup_phy_link_speed_generic, +	.read_i2c_sff8472	= &ixgbe_read_i2c_sff8472_82598,  	.read_i2c_eeprom	= &ixgbe_read_i2c_eeprom_82598,  	.check_overtemp   = &ixgbe_tn_check_overtemp,  }; @@ -1311,4 +1339,3 @@ struct ixgbe_info ixgbe_82598_info = {  	.eeprom_ops		= &eeprom_ops_82598,  	.phy_ops		= &phy_ops_82598,  }; - diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c index 1073aea5da4..203a00c2433 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_82599.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel 10 Gigabit PCI Express Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -45,21 +45,17 @@ static void ixgbe_enable_tx_laser_multispeed_fiber(struct ixgbe_hw *hw);  static void ixgbe_flap_tx_laser_multispeed_fiber(struct ixgbe_hw *hw);  static s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw,  						 ixgbe_link_speed speed, -						 bool autoneg,  						 bool autoneg_wait_to_complete);  static s32 ixgbe_setup_mac_link_smartspeed(struct ixgbe_hw *hw,                                             ixgbe_link_speed speed, -                                           bool autoneg,                                             bool autoneg_wait_to_complete);  static s32 ixgbe_start_mac_link_82599(struct ixgbe_hw *hw,  				      bool autoneg_wait_to_complete);  static s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw,                                 ixgbe_link_speed speed, -                               bool autoneg,                                 bool autoneg_wait_to_complete);  static s32 ixgbe_setup_copper_link_82599(struct ixgbe_hw *hw,                                           ixgbe_link_speed speed, -                                         bool autoneg,                                           bool autoneg_wait_to_complete);  static s32 ixgbe_verify_fw_version_82599(struct ixgbe_hw *hw); @@ -234,13 +230,13 @@ static s32 ixgbe_init_phy_ops_82599(struct ixgbe_hw *hw)   *  ixgbe_get_link_capabilities_82599 - Determines link capabilities   *  @hw: pointer to hardware structure   *  @speed: pointer to link speed - *  @negotiation: true when autoneg or autotry is enabled + *  @autoneg: true when autoneg or autotry is enabled   *   *  Determines the link capabilities by reading the AUTOC register.   **/  static s32 ixgbe_get_link_capabilities_82599(struct ixgbe_hw *hw,                                               ixgbe_link_speed *speed, -                                             bool *negotiation) +					     bool *autoneg)  {  	s32 status = 0;  	u32 autoc = 0; @@ -251,7 +247,7 @@ static s32 ixgbe_get_link_capabilities_82599(struct ixgbe_hw *hw,  	    hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core0 ||  	    hw->phy.sfp_type == ixgbe_sfp_type_1g_sx_core1) {  		*speed = IXGBE_LINK_SPEED_1GB_FULL; -		*negotiation = true; +		*autoneg = true;  		goto out;  	} @@ -268,22 +264,22 @@ static s32 ixgbe_get_link_capabilities_82599(struct ixgbe_hw *hw,  	switch (autoc & IXGBE_AUTOC_LMS_MASK) {  	case IXGBE_AUTOC_LMS_1G_LINK_NO_AN:  		*speed = IXGBE_LINK_SPEED_1GB_FULL; -		*negotiation = false; +		*autoneg = false;  		break;  	case IXGBE_AUTOC_LMS_10G_LINK_NO_AN:  		*speed = IXGBE_LINK_SPEED_10GB_FULL; -		*negotiation = false; +		*autoneg = false;  		break;  	case IXGBE_AUTOC_LMS_1G_AN:  		*speed = IXGBE_LINK_SPEED_1GB_FULL; -		*negotiation = true; +		*autoneg = true;  		break;  	case IXGBE_AUTOC_LMS_10G_SERIAL:  		*speed = IXGBE_LINK_SPEED_10GB_FULL; -		*negotiation = false; +		*autoneg = false;  		break;  	case IXGBE_AUTOC_LMS_KX4_KX_KR: @@ -295,7 +291,7 @@ static s32 ixgbe_get_link_capabilities_82599(struct ixgbe_hw *hw,  			*speed |= IXGBE_LINK_SPEED_10GB_FULL;  		if (autoc & IXGBE_AUTOC_KX_SUPP)  			*speed |= IXGBE_LINK_SPEED_1GB_FULL; -		*negotiation = true; +		*autoneg = true;  		break;  	case IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII: @@ -306,12 +302,12 @@ static s32 ixgbe_get_link_capabilities_82599(struct ixgbe_hw *hw,  			*speed |= IXGBE_LINK_SPEED_10GB_FULL;  		if (autoc & IXGBE_AUTOC_KX_SUPP)  			*speed |= IXGBE_LINK_SPEED_1GB_FULL; -		*negotiation = true; +		*autoneg = true;  		break;  	case IXGBE_AUTOC_LMS_SGMII_1G_100M:  		*speed = IXGBE_LINK_SPEED_1GB_FULL | IXGBE_LINK_SPEED_100_FULL; -		*negotiation = false; +		*autoneg = false;  		break;  	default: @@ -323,7 +319,7 @@ static s32 ixgbe_get_link_capabilities_82599(struct ixgbe_hw *hw,  	if (hw->phy.multispeed_fiber) {  		*speed |= IXGBE_LINK_SPEED_10GB_FULL |  		          IXGBE_LINK_SPEED_1GB_FULL; -		*negotiation = true; +		*autoneg = true;  	}  out: @@ -510,14 +506,12 @@ static void ixgbe_flap_tx_laser_multispeed_fiber(struct ixgbe_hw *hw)   *  ixgbe_setup_mac_link_multispeed_fiber - Set MAC link speed   *  @hw: pointer to hardware structure   *  @speed: new link speed - *  @autoneg: true if autonegotiation enabled   *  @autoneg_wait_to_complete: true when waiting for completion is needed   *   *  Set the link speed in the AUTOC register and restarts link.   **/  static s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw,                                            ixgbe_link_speed speed, -                                          bool autoneg,                                            bool autoneg_wait_to_complete)  {  	s32 status = 0; @@ -527,11 +521,11 @@ static s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw,  	u32 esdp_reg = IXGBE_READ_REG(hw, IXGBE_ESDP);  	u32 i = 0;  	bool link_up = false; -	bool negotiation; +	bool autoneg = false;  	/* Mask off requested but non-supported speeds */  	status = hw->mac.ops.get_link_capabilities(hw, &link_speed, -						   &negotiation); +						   &autoneg);  	if (status != 0)  		return status; @@ -564,7 +558,6 @@ static s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw,  		status = ixgbe_setup_mac_link_82599(hw,  						    IXGBE_LINK_SPEED_10GB_FULL, -						    autoneg,  						    autoneg_wait_to_complete);  		if (status != 0)  			return status; @@ -617,7 +610,6 @@ static s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw,  		status = ixgbe_setup_mac_link_82599(hw,  						    IXGBE_LINK_SPEED_1GB_FULL, -						    autoneg,  						    autoneg_wait_to_complete);  		if (status != 0)  			return status; @@ -646,7 +638,6 @@ static s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw,  	if (speedcnt > 1)  		status = ixgbe_setup_mac_link_multispeed_fiber(hw,  		                                               highest_link_speed, -		                                               autoneg,  		                                               autoneg_wait_to_complete);  out: @@ -666,13 +657,12 @@ out:   *  ixgbe_setup_mac_link_smartspeed - Set MAC link speed using SmartSpeed   *  @hw: pointer to hardware structure   *  @speed: new link speed - *  @autoneg: true if autonegotiation enabled   *  @autoneg_wait_to_complete: true when waiting for completion is needed   *   *  Implements the Intel SmartSpeed algorithm.   **/  static s32 ixgbe_setup_mac_link_smartspeed(struct ixgbe_hw *hw, -				     ixgbe_link_speed speed, bool autoneg, +				     ixgbe_link_speed speed,  				     bool autoneg_wait_to_complete)  {  	s32 status = 0; @@ -703,7 +693,7 @@ static s32 ixgbe_setup_mac_link_smartspeed(struct ixgbe_hw *hw,  	/* First, try to get link with full advertisement */  	hw->phy.smart_speed_active = false;  	for (j = 0; j < IXGBE_SMARTSPEED_MAX_RETRIES; j++) { -		status = ixgbe_setup_mac_link_82599(hw, speed, autoneg, +		status = ixgbe_setup_mac_link_82599(hw, speed,  						    autoneg_wait_to_complete);  		if (status != 0)  			goto out; @@ -738,7 +728,7 @@ static s32 ixgbe_setup_mac_link_smartspeed(struct ixgbe_hw *hw,  	/* Turn SmartSpeed on to disable KR support */  	hw->phy.smart_speed_active = true; -	status = ixgbe_setup_mac_link_82599(hw, speed, autoneg, +	status = ixgbe_setup_mac_link_82599(hw, speed,  					    autoneg_wait_to_complete);  	if (status != 0)  		goto out; @@ -764,7 +754,7 @@ static s32 ixgbe_setup_mac_link_smartspeed(struct ixgbe_hw *hw,  	/* We didn't get link.  Turn SmartSpeed back off. */  	hw->phy.smart_speed_active = false; -	status = ixgbe_setup_mac_link_82599(hw, speed, autoneg, +	status = ixgbe_setup_mac_link_82599(hw, speed,  					    autoneg_wait_to_complete);  out: @@ -778,14 +768,13 @@ out:   *  ixgbe_setup_mac_link_82599 - Set MAC link speed   *  @hw: pointer to hardware structure   *  @speed: new link speed - *  @autoneg: true if autonegotiation enabled   *  @autoneg_wait_to_complete: true when waiting for completion is needed   *   *  Set the link speed in the AUTOC register and restarts link.   **/  static s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw, -                               ixgbe_link_speed speed, bool autoneg, -                               bool autoneg_wait_to_complete) +				      ixgbe_link_speed speed, +				      bool autoneg_wait_to_complete)  {  	s32 status = 0;  	u32 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC); @@ -799,6 +788,7 @@ static s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw,  	u32 i;  	ixgbe_link_speed link_capabilities = IXGBE_LINK_SPEED_UNKNOWN;  	bool got_lock = false; +	bool autoneg = false;  	/* Check to see if speed passed in is supported. */  	status = hw->mac.ops.get_link_capabilities(hw, &link_capabilities, @@ -911,20 +901,18 @@ out:   *  ixgbe_setup_copper_link_82599 - Set the PHY autoneg advertised field   *  @hw: pointer to hardware structure   *  @speed: new link speed - *  @autoneg: true if autonegotiation enabled   *  @autoneg_wait_to_complete: true if waiting is needed to complete   *   *  Restarts link on PHY and MAC based on settings passed in.   **/  static s32 ixgbe_setup_copper_link_82599(struct ixgbe_hw *hw,                                           ixgbe_link_speed speed, -                                         bool autoneg,                                           bool autoneg_wait_to_complete)  {  	s32 status;  	/* Setup the PHY according to input speed */ -	status = hw->phy.ops.setup_link_speed(hw, speed, autoneg, +	status = hw->phy.ops.setup_link_speed(hw, speed,  	                                      autoneg_wait_to_complete);  	/* Set up MAC */  	ixgbe_start_mac_link_82599(hw, autoneg_wait_to_complete); @@ -2253,6 +2241,7 @@ static struct ixgbe_phy_operations phy_ops_82599 = {  	.setup_link_speed	= &ixgbe_setup_phy_link_speed_generic,  	.read_i2c_byte		= &ixgbe_read_i2c_byte_generic,  	.write_i2c_byte		= &ixgbe_write_i2c_byte_generic, +	.read_i2c_sff8472	= &ixgbe_read_i2c_sff8472_generic,  	.read_i2c_eeprom	= &ixgbe_read_i2c_eeprom_generic,  	.write_i2c_eeprom	= &ixgbe_write_i2c_eeprom_generic,  	.check_overtemp		= &ixgbe_tn_check_overtemp, diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c index 5e68afdd502..99e472ebaa7 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel 10 Gigabit PCI Express Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h index f7a0970a251..bc3948ead6e 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h @@ -1,7 +1,7 @@  /*******************************************************************************    Intel 10 Gigabit PCI Express Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb.c index 9bc17c0cb97..1f2c805684d 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel 10 Gigabit PCI Express Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb.h index 1f4108ee154..1634de8b627 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb.h @@ -1,7 +1,7 @@  /*******************************************************************************    Intel 10 Gigabit PCI Express Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82598.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82598.c index 87592b458c9..ac780770863 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82598.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82598.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel 10 Gigabit PCI Express Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82598.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82598.h index ba835708fca..3164f5453b8 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82598.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82598.h @@ -1,7 +1,7 @@  /*******************************************************************************    Intel 10 Gigabit PCI Express Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82599.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82599.c index 4eac80d0185..05e23b80b5e 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82599.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82599.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel 10 Gigabit PCI Express Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82599.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82599.h index 4dec47faeb0..a4ef07631d1 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82599.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_82599.h @@ -1,7 +1,7 @@  /*******************************************************************************    Intel 10 Gigabit PCI Express Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c index f1e002d5fa8..f3d68f9696b 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_dcb_nl.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel 10 Gigabit PCI Express Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -30,6 +30,7 @@  #include <linux/dcbnl.h>  #include "ixgbe_dcb_82598.h"  #include "ixgbe_dcb_82599.h" +#include "ixgbe_sriov.h"  /* Callbacks for DCB netlink in the kernel */  #define BIT_DCB_MODE	0x01 @@ -301,7 +302,6 @@ static void ixgbe_dcbnl_get_pfc_cfg(struct net_device *netdev, int priority,  	*setting = adapter->dcb_cfg.tc_config[priority].dcb_pfc;  } -#ifdef IXGBE_FCOE  static void ixgbe_dcbnl_devreset(struct net_device *dev)  {  	struct ixgbe_adapter *adapter = netdev_priv(dev); @@ -320,7 +320,6 @@ static void ixgbe_dcbnl_devreset(struct net_device *dev)  	clear_bit(__IXGBE_RESETTING, &adapter->state);  } -#endif  static u8 ixgbe_dcbnl_set_all(struct net_device *netdev)  { @@ -450,7 +449,6 @@ static u8 ixgbe_dcbnl_getcap(struct net_device *netdev, int capid, u8 *cap)  static int ixgbe_dcbnl_getnumtcs(struct net_device *netdev, int tcid, u8 *num)  {  	struct ixgbe_adapter *adapter = netdev_priv(netdev); -	u8 rval = 0;  	if (adapter->flags & IXGBE_FLAG_DCB_ENABLED) {  		switch (tcid) { @@ -461,14 +459,14 @@ static int ixgbe_dcbnl_getnumtcs(struct net_device *netdev, int tcid, u8 *num)  			*num = adapter->dcb_cfg.num_tcs.pfc_tcs;  			break;  		default: -			rval = -EINVAL; +			return -EINVAL;  			break;  		}  	} else { -		rval = -EINVAL; +		return -EINVAL;  	} -	return rval; +	return 0;  }  static int ixgbe_dcbnl_setnumtcs(struct net_device *netdev, int tcid, u8 num) @@ -541,6 +539,7 @@ static int ixgbe_dcbnl_ieee_setets(struct net_device *dev,  	int max_frame = dev->mtu + ETH_HLEN + ETH_FCS_LEN;  	int i, err = 0;  	__u8 max_tc = 0; +	__u8 map_chg = 0;  	if (!(adapter->dcbx_cap & DCB_CAP_DCBX_VER_IEEE))  		return -EINVAL; @@ -550,15 +549,22 @@ static int ixgbe_dcbnl_ieee_setets(struct net_device *dev,  						  GFP_KERNEL);  		if (!adapter->ixgbe_ieee_ets)  			return -ENOMEM; -	} -	memcpy(adapter->ixgbe_ieee_ets, ets, sizeof(*adapter->ixgbe_ieee_ets)); +		/* initialize UP2TC mappings to invalid value */ +		for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) +			adapter->ixgbe_ieee_ets->prio_tc[i] = +				IEEE_8021QAZ_MAX_TCS; +	}  	for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) {  		if (ets->prio_tc[i] > max_tc)  			max_tc = ets->prio_tc[i]; +		if (ets->prio_tc[i] != adapter->ixgbe_ieee_ets->prio_tc[i]) +			map_chg = 1;  	} +	memcpy(adapter->ixgbe_ieee_ets, ets, sizeof(*adapter->ixgbe_ieee_ets)); +  	if (max_tc)  		max_tc++; @@ -567,6 +573,8 @@ static int ixgbe_dcbnl_ieee_setets(struct net_device *dev,  	if (max_tc != netdev_get_num_tc(dev))  		err = ixgbe_setup_tc(dev, max_tc); +	else if (map_chg) +		ixgbe_dcbnl_devreset(dev);  	if (err)  		goto err_out; @@ -643,9 +651,11 @@ static int ixgbe_dcbnl_ieee_setapp(struct net_device *dev,  		return err;  	err = dcb_ieee_setapp(dev, app); +	if (err) +		return err;  #ifdef IXGBE_FCOE -	if (!err && app->selector == IEEE_8021QAZ_APP_SEL_ETHERTYPE && +	if (app->selector == IEEE_8021QAZ_APP_SEL_ETHERTYPE &&  	    app->protocol == ETH_P_FCOE) {  		u8 app_mask = dcb_ieee_getapp_mask(dev, app); @@ -656,6 +666,23 @@ static int ixgbe_dcbnl_ieee_setapp(struct net_device *dev,  		ixgbe_dcbnl_devreset(dev);  	}  #endif + +	/* VF devices should use default UP when available */ +	if (app->selector == IEEE_8021QAZ_APP_SEL_ETHERTYPE && +	    app->protocol == 0) { +		int vf; + +		adapter->default_up = app->priority; + +		for (vf = 0; vf < adapter->num_vfs; vf++) { +			struct vf_data_storage *vfinfo = &adapter->vfinfo[vf]; + +			if (!vfinfo->pf_qos) +				ixgbe_set_vmvir(adapter, vfinfo->pf_vlan, +						app->priority, vf); +		} +	} +  	return 0;  } @@ -683,6 +710,24 @@ static int ixgbe_dcbnl_ieee_delapp(struct net_device *dev,  		ixgbe_dcbnl_devreset(dev);  	}  #endif +	/* IF default priority is being removed clear VF default UP */ +	if (app->selector == IEEE_8021QAZ_APP_SEL_ETHERTYPE && +	    app->protocol == 0 && adapter->default_up == app->priority) { +		int vf; +		long unsigned int app_mask = dcb_ieee_getapp_mask(dev, app); +		int qos = app_mask ? find_first_bit(&app_mask, 8) : 0; + +		adapter->default_up = qos; + +		for (vf = 0; vf < adapter->num_vfs; vf++) { +			struct vf_data_storage *vfinfo = &adapter->vfinfo[vf]; + +			if (!vfinfo->pf_qos) +				ixgbe_set_vmvir(adapter, vfinfo->pf_vlan, +						qos, vf); +		} +	} +  	return err;  } diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c index 50aa546b8c7..c5933f6dcee 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel 10 Gigabit PCI Express Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -24,9 +24,6 @@    Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497  *******************************************************************************/ - -#ifdef CONFIG_DEBUG_FS -  #include <linux/debugfs.h>  #include <linux/module.h> @@ -277,5 +274,3 @@ void ixgbe_dbg_exit(void)  {  	debugfs_remove_recursive(ixgbe_dbg_root);  } - -#endif /* CONFIG_DEBUG_FS */ diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c index 32685842434..c3f1afd8690 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel 10 Gigabit PCI Express Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -39,6 +39,7 @@  #include <linux/uaccess.h>  #include "ixgbe.h" +#include "ixgbe_phy.h"  #define IXGBE_ALL_RAR_ENTRIES 16 @@ -156,7 +157,7 @@ static int ixgbe_get_settings(struct net_device *netdev,  	struct ixgbe_hw *hw = &adapter->hw;  	ixgbe_link_speed supported_link;  	u32 link_speed = 0; -	bool autoneg; +	bool autoneg = false;  	bool link_up;  	hw->mac.ops.get_link_capabilities(hw, &supported_link, &autoneg); @@ -333,10 +334,10 @@ static int ixgbe_set_settings(struct net_device *netdev,  			return err;  		/* this sets the link speed and restarts auto-neg */  		hw->mac.autotry_restart = true; -		err = hw->mac.ops.setup_link(hw, advertised, true, true); +		err = hw->mac.ops.setup_link(hw, advertised, true);  		if (err) {  			e_info(probe, "setup link failed with code %d\n", err); -			hw->mac.ops.setup_link(hw, old, true, true); +			hw->mac.ops.setup_link(hw, old, true);  		}  	} else {  		/* in this case we currently only support 10Gb/FULL */ @@ -1040,6 +1041,9 @@ static void ixgbe_get_ethtool_stats(struct net_device *netdev,  			p = (char *) adapter +  					ixgbe_gstrings_stats[i].stat_offset;  			break; +		default: +			data[i] = 0; +			continue;  		}  		data[i] = (ixgbe_gstrings_stats[i].sizeof_stat == @@ -1096,8 +1100,10 @@ static void ixgbe_get_strings(struct net_device *netdev, u32 stringset,  	switch (stringset) {  	case ETH_SS_TEST: -		memcpy(data, *ixgbe_gstrings_test, -		       IXGBE_TEST_LEN * ETH_GSTRING_LEN); +		for (i = 0; i < IXGBE_TEST_LEN; i++) { +			memcpy(data, ixgbe_gstrings_test[i], ETH_GSTRING_LEN); +			data += ETH_GSTRING_LEN; +		}  		break;  	case ETH_SS_STATS:  		for (i = 0; i < IXGBE_GLOBAL_STATS_LEN; i++) { @@ -1837,19 +1843,11 @@ static void ixgbe_diag_test(struct net_device *netdev,                              struct ethtool_test *eth_test, u64 *data)  {  	struct ixgbe_adapter *adapter = netdev_priv(netdev); +	struct ixgbe_hw *hw = &adapter->hw;  	bool if_running = netif_running(netdev);  	set_bit(__IXGBE_TESTING, &adapter->state);  	if (eth_test->flags == ETH_TEST_FL_OFFLINE) { -		/* Offline tests */ - -		e_info(hw, "offline testing starting\n"); - -		/* Link test performed before hardware reset so autoneg doesn't -		 * interfere with test result */ -		if (ixgbe_link_test(adapter, &data[4])) -			eth_test->flags |= ETH_TEST_FL_FAILED; -  		if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) {  			int i;  			for (i = 0; i < adapter->num_vfs; i++) { @@ -1870,12 +1868,24 @@ static void ixgbe_diag_test(struct net_device *netdev,  			}  		} +		/* Offline tests */ +		e_info(hw, "offline testing starting\n"); +  		if (if_running)  			/* indicate we're in test mode */  			dev_close(netdev); -		else -			ixgbe_reset(adapter); +		/* bringing adapter down disables SFP+ optics */ +		if (hw->mac.ops.enable_tx_laser) +			hw->mac.ops.enable_tx_laser(hw); + +		/* Link test performed before hardware reset so autoneg doesn't +		 * interfere with test result +		 */ +		if (ixgbe_link_test(adapter, &data[4])) +			eth_test->flags |= ETH_TEST_FL_FAILED; + +		ixgbe_reset(adapter);  		e_info(hw, "register testing starting\n");  		if (ixgbe_reg_test(adapter, &data[0]))  			eth_test->flags |= ETH_TEST_FL_FAILED; @@ -1908,16 +1918,22 @@ static void ixgbe_diag_test(struct net_device *netdev,  skip_loopback:  		ixgbe_reset(adapter); +		/* clear testing bit and return adapter to previous state */  		clear_bit(__IXGBE_TESTING, &adapter->state);  		if (if_running)  			dev_open(netdev);  	} else {  		e_info(hw, "online testing starting\n"); + +		/* if adapter is down, SFP+ optics will be disabled */ +		if (!if_running && hw->mac.ops.enable_tx_laser) +			hw->mac.ops.enable_tx_laser(hw); +  		/* Online tests */  		if (ixgbe_link_test(adapter, &data[4]))  			eth_test->flags |= ETH_TEST_FL_FAILED; -		/* Online tests aren't run; pass by default */ +		/* Offline tests aren't run; pass by default */  		data[0] = 0;  		data[1] = 0;  		data[2] = 0; @@ -1925,6 +1941,10 @@ skip_loopback:  		clear_bit(__IXGBE_TESTING, &adapter->state);  	} + +	/* if adapter was down, ensure SFP+ optics are disabled again */ +	if (!if_running && hw->mac.ops.disable_tx_laser) +		hw->mac.ops.disable_tx_laser(hw);  skip_ol_tests:  	msleep_interruptible(4 * 1000);  } @@ -2093,13 +2113,17 @@ static int ixgbe_set_coalesce(struct net_device *netdev,  	struct ixgbe_adapter *adapter = netdev_priv(netdev);  	struct ixgbe_q_vector *q_vector;  	int i; -	u16 tx_itr_param, rx_itr_param; +	u16 tx_itr_param, rx_itr_param, tx_itr_prev;  	bool need_reset = false; -	/* don't accept tx specific changes if we've got mixed RxTx vectors */ -	if (adapter->q_vector[0]->tx.count && adapter->q_vector[0]->rx.count -	    && ec->tx_coalesce_usecs) -		return -EINVAL; +	if (adapter->q_vector[0]->tx.count && adapter->q_vector[0]->rx.count) { +		/* reject Tx specific changes in case of mixed RxTx vectors */ +		if (ec->tx_coalesce_usecs) +			return -EINVAL; +		tx_itr_prev = adapter->rx_itr_setting; +	} else { +		tx_itr_prev = adapter->tx_itr_setting; +	}  	if ((ec->rx_coalesce_usecs > (IXGBE_MAX_EITR >> 2)) ||  	    (ec->tx_coalesce_usecs > (IXGBE_MAX_EITR >> 2))) @@ -2125,8 +2149,25 @@ static int ixgbe_set_coalesce(struct net_device *netdev,  	else  		tx_itr_param = adapter->tx_itr_setting; +	/* mixed Rx/Tx */ +	if (adapter->q_vector[0]->tx.count && adapter->q_vector[0]->rx.count) +		adapter->tx_itr_setting = adapter->rx_itr_setting; + +#if IS_ENABLED(CONFIG_BQL) +	/* detect ITR changes that require update of TXDCTL.WTHRESH */ +	if ((adapter->tx_itr_setting > 1) && +	    (adapter->tx_itr_setting < IXGBE_100K_ITR)) { +		if ((tx_itr_prev == 1) || +		    (tx_itr_prev > IXGBE_100K_ITR)) +			need_reset = true; +	} else { +		if ((tx_itr_prev > 1) && +		    (tx_itr_prev < IXGBE_100K_ITR)) +			need_reset = true; +	} +#endif  	/* check the old value and enable RSC if necessary */ -	need_reset = ixgbe_update_rsc(adapter); +	need_reset |= ixgbe_update_rsc(adapter);  	for (i = 0; i < adapter->num_q_vectors; i++) {  		q_vector = adapter->q_vector[i]; @@ -2156,13 +2197,13 @@ static int ixgbe_get_ethtool_fdir_entry(struct ixgbe_adapter *adapter,  	union ixgbe_atr_input *mask = &adapter->fdir_mask;  	struct ethtool_rx_flow_spec *fsp =  		(struct ethtool_rx_flow_spec *)&cmd->fs; -	struct hlist_node *node, *node2; +	struct hlist_node *node2;  	struct ixgbe_fdir_filter *rule = NULL;  	/* report total rule count */  	cmd->data = (1024 << adapter->fdir_pballoc) - 2; -	hlist_for_each_entry_safe(rule, node, node2, +	hlist_for_each_entry_safe(rule, node2,  				  &adapter->fdir_filter_list, fdir_node) {  		if (fsp->location <= rule->sw_idx)  			break; @@ -2223,14 +2264,14 @@ static int ixgbe_get_ethtool_fdir_all(struct ixgbe_adapter *adapter,  				      struct ethtool_rxnfc *cmd,  				      u32 *rule_locs)  { -	struct hlist_node *node, *node2; +	struct hlist_node *node2;  	struct ixgbe_fdir_filter *rule;  	int cnt = 0;  	/* report total rule count */  	cmd->data = (1024 << adapter->fdir_pballoc) - 2; -	hlist_for_each_entry_safe(rule, node, node2, +	hlist_for_each_entry_safe(rule, node2,  				  &adapter->fdir_filter_list, fdir_node) {  		if (cnt == cmd->rule_cnt)  			return -EMSGSIZE; @@ -2317,19 +2358,19 @@ static int ixgbe_update_ethtool_fdir_entry(struct ixgbe_adapter *adapter,  					   u16 sw_idx)  {  	struct ixgbe_hw *hw = &adapter->hw; -	struct hlist_node *node, *node2, *parent; -	struct ixgbe_fdir_filter *rule; +	struct hlist_node *node2; +	struct ixgbe_fdir_filter *rule, *parent;  	int err = -EINVAL;  	parent = NULL;  	rule = NULL; -	hlist_for_each_entry_safe(rule, node, node2, +	hlist_for_each_entry_safe(rule, node2,  				  &adapter->fdir_filter_list, fdir_node) {  		/* hash found, or no matching entry */  		if (rule->sw_idx >= sw_idx)  			break; -		parent = node; +		parent = rule;  	}  	/* if there is an old rule occupying our place remove it */ @@ -2358,7 +2399,7 @@ static int ixgbe_update_ethtool_fdir_entry(struct ixgbe_adapter *adapter,  	/* add filter to the list */  	if (parent) -		hlist_add_after(parent, &input->fdir_node); +		hlist_add_after(&parent->fdir_node, &input->fdir_node);  	else  		hlist_add_head(&input->fdir_node,  			       &adapter->fdir_filter_list); @@ -2695,6 +2736,14 @@ static int ixgbe_get_ts_info(struct net_device *dev,  			(1 << HWTSTAMP_FILTER_NONE) |  			(1 << HWTSTAMP_FILTER_PTP_V1_L4_SYNC) |  			(1 << HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ) | +			(1 << HWTSTAMP_FILTER_PTP_V2_L2_EVENT) | +			(1 << HWTSTAMP_FILTER_PTP_V2_L4_EVENT) | +			(1 << HWTSTAMP_FILTER_PTP_V2_SYNC) | +			(1 << HWTSTAMP_FILTER_PTP_V2_L2_SYNC) | +			(1 << HWTSTAMP_FILTER_PTP_V2_L4_SYNC) | +			(1 << HWTSTAMP_FILTER_PTP_V2_DELAY_REQ) | +			(1 << HWTSTAMP_FILTER_PTP_V2_L2_DELAY_REQ) | +			(1 << HWTSTAMP_FILTER_PTP_V2_L4_DELAY_REQ) |  			(1 << HWTSTAMP_FILTER_PTP_V2_EVENT);  		break;  	default: @@ -2704,6 +2753,225 @@ static int ixgbe_get_ts_info(struct net_device *dev,  	return 0;  } +static unsigned int ixgbe_max_channels(struct ixgbe_adapter *adapter) +{ +	unsigned int max_combined; +	u8 tcs = netdev_get_num_tc(adapter->netdev); + +	if (!(adapter->flags & IXGBE_FLAG_MSIX_ENABLED)) { +		/* We only support one q_vector without MSI-X */ +		max_combined = 1; +	} else if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) { +		/* SR-IOV currently only allows one queue on the PF */ +		max_combined = 1; +	} else if (tcs > 1) { +		/* For DCB report channels per traffic class */ +		if (adapter->hw.mac.type == ixgbe_mac_82598EB) { +			/* 8 TC w/ 4 queues per TC */ +			max_combined = 4; +		} else if (tcs > 4) { +			/* 8 TC w/ 8 queues per TC */ +			max_combined = 8; +		} else { +			/* 4 TC w/ 16 queues per TC */ +			max_combined = 16; +		} +	} else if (adapter->atr_sample_rate) { +		/* support up to 64 queues with ATR */ +		max_combined = IXGBE_MAX_FDIR_INDICES; +	} else { +		/* support up to 16 queues with RSS */ +		max_combined = IXGBE_MAX_RSS_INDICES; +	} + +	return max_combined; +} + +static void ixgbe_get_channels(struct net_device *dev, +			       struct ethtool_channels *ch) +{ +	struct ixgbe_adapter *adapter = netdev_priv(dev); + +	/* report maximum channels */ +	ch->max_combined = ixgbe_max_channels(adapter); + +	/* report info for other vector */ +	if (adapter->flags & IXGBE_FLAG_MSIX_ENABLED) { +		ch->max_other = NON_Q_VECTORS; +		ch->other_count = NON_Q_VECTORS; +	} + +	/* record RSS queues */ +	ch->combined_count = adapter->ring_feature[RING_F_RSS].indices; + +	/* nothing else to report if RSS is disabled */ +	if (ch->combined_count == 1) +		return; + +	/* we do not support ATR queueing if SR-IOV is enabled */ +	if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) +		return; + +	/* same thing goes for being DCB enabled */ +	if (netdev_get_num_tc(dev) > 1) +		return; + +	/* if ATR is disabled we can exit */ +	if (!adapter->atr_sample_rate) +		return; + +	/* report flow director queues as maximum channels */ +	ch->combined_count = adapter->ring_feature[RING_F_FDIR].indices; +} + +static int ixgbe_set_channels(struct net_device *dev, +			      struct ethtool_channels *ch) +{ +	struct ixgbe_adapter *adapter = netdev_priv(dev); +	unsigned int count = ch->combined_count; + +	/* verify they are not requesting separate vectors */ +	if (!count || ch->rx_count || ch->tx_count) +		return -EINVAL; + +	/* verify other_count has not changed */ +	if (ch->other_count != NON_Q_VECTORS) +		return -EINVAL; + +	/* verify the number of channels does not exceed hardware limits */ +	if (count > ixgbe_max_channels(adapter)) +		return -EINVAL; + +	/* update feature limits from largest to smallest supported values */ +	adapter->ring_feature[RING_F_FDIR].limit = count; + +	/* cap RSS limit at 16 */ +	if (count > IXGBE_MAX_RSS_INDICES) +		count = IXGBE_MAX_RSS_INDICES; +	adapter->ring_feature[RING_F_RSS].limit = count; + +#ifdef IXGBE_FCOE +	/* cap FCoE limit at 8 */ +	if (count > IXGBE_FCRETA_SIZE) +		count = IXGBE_FCRETA_SIZE; +	adapter->ring_feature[RING_F_FCOE].limit = count; + +#endif +	/* use setup TC to update any traffic class queue mapping */ +	return ixgbe_setup_tc(dev, netdev_get_num_tc(dev)); +} + +static int ixgbe_get_module_info(struct net_device *dev, +				       struct ethtool_modinfo *modinfo) +{ +	struct ixgbe_adapter *adapter = netdev_priv(dev); +	struct ixgbe_hw *hw = &adapter->hw; +	u32 status; +	u8 sff8472_rev, addr_mode; +	int ret_val = 0; +	bool page_swap = false; + +	/* avoid concurent i2c reads */ +	while (test_bit(__IXGBE_IN_SFP_INIT, &adapter->state)) +		msleep(100); + +	/* used by the service task */ +	set_bit(__IXGBE_READ_I2C, &adapter->state); + +	/* Check whether we support SFF-8472 or not */ +	status = hw->phy.ops.read_i2c_eeprom(hw, +					     IXGBE_SFF_SFF_8472_COMP, +					     &sff8472_rev); +	if (status != 0) { +		ret_val = -EIO; +		goto err_out; +	} + +	/* addressing mode is not supported */ +	status = hw->phy.ops.read_i2c_eeprom(hw, +					     IXGBE_SFF_SFF_8472_SWAP, +					     &addr_mode); +	if (status != 0) { +		ret_val = -EIO; +		goto err_out; +	} + +	if (addr_mode & IXGBE_SFF_ADDRESSING_MODE) { +		e_err(drv, "Address change required to access page 0xA2, but not supported. Please report the module type to the driver maintainers.\n"); +		page_swap = true; +	} + +	if (sff8472_rev == IXGBE_SFF_SFF_8472_UNSUP || page_swap) { +		/* We have a SFP, but it does not support SFF-8472 */ +		modinfo->type = ETH_MODULE_SFF_8079; +		modinfo->eeprom_len = ETH_MODULE_SFF_8079_LEN; +	} else { +		/* We have a SFP which supports a revision of SFF-8472. */ +		modinfo->type = ETH_MODULE_SFF_8472; +		modinfo->eeprom_len = ETH_MODULE_SFF_8472_LEN; +	} + +err_out: +	clear_bit(__IXGBE_READ_I2C, &adapter->state); +	return ret_val; +} + +static int ixgbe_get_module_eeprom(struct net_device *dev, +					 struct ethtool_eeprom *ee, +					 u8 *data) +{ +	struct ixgbe_adapter *adapter = netdev_priv(dev); +	struct ixgbe_hw *hw = &adapter->hw; +	u32 status = IXGBE_ERR_PHY_ADDR_INVALID; +	u8 databyte = 0xFF; +	int i = 0; +	int ret_val = 0; + +	/* ixgbe_get_module_info is called before this function in all +	 * cases, so we do not need any checks we already do above, +	 * and can trust ee->len to be a known value. +	 */ + +	while (test_bit(__IXGBE_IN_SFP_INIT, &adapter->state)) +		msleep(100); +	set_bit(__IXGBE_READ_I2C, &adapter->state); + +	/* Read the first block, SFF-8079 */ +	for (i = 0; i < ETH_MODULE_SFF_8079_LEN; i++) { +		status = hw->phy.ops.read_i2c_eeprom(hw, i, &databyte); +		if (status != 0) { +			/* Error occured while reading module */ +			ret_val = -EIO; +			goto err_out; +		} +		data[i] = databyte; +	} + +	/* If the second block is requested, check if SFF-8472 is supported. */ +	if (ee->len == ETH_MODULE_SFF_8472_LEN) { +		if (data[IXGBE_SFF_SFF_8472_COMP] == IXGBE_SFF_SFF_8472_UNSUP) +			return -EOPNOTSUPP; + +		/* Read the second block, SFF-8472 */ +		for (i = ETH_MODULE_SFF_8079_LEN; +		     i < ETH_MODULE_SFF_8472_LEN; i++) { +			status = hw->phy.ops.read_i2c_sff8472(hw, +				i - ETH_MODULE_SFF_8079_LEN, &databyte); +			if (status != 0) { +				/* Error occured while reading module */ +				ret_val = -EIO; +				goto err_out; +			} +			data[i] = databyte; +		} +	} + +err_out: +	clear_bit(__IXGBE_READ_I2C, &adapter->state); + +	return ret_val; +} +  static const struct ethtool_ops ixgbe_ethtool_ops = {  	.get_settings           = ixgbe_get_settings,  	.set_settings           = ixgbe_set_settings, @@ -2732,7 +3000,11 @@ static const struct ethtool_ops ixgbe_ethtool_ops = {  	.set_coalesce           = ixgbe_set_coalesce,  	.get_rxnfc		= ixgbe_get_rxnfc,  	.set_rxnfc		= ixgbe_set_rxnfc, +	.get_channels		= ixgbe_get_channels, +	.set_channels		= ixgbe_set_channels,  	.get_ts_info		= ixgbe_get_ts_info, +	.get_module_info	= ixgbe_get_module_info, +	.get_module_eeprom	= ixgbe_get_module_eeprom,  };  void ixgbe_set_ethtool_ops(struct net_device *netdev) diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c index 252850d9a3e..f58db453a97 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel 10 Gigabit PCI Express Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -544,15 +544,14 @@ int ixgbe_fso(struct ixgbe_ring *tx_ring,  		first->gso_segs = DIV_ROUND_UP(skb->len - *hdr_len,  					       skb_shinfo(skb)->gso_size);  		first->bytecount += (first->gso_segs - 1) * *hdr_len; -		first->tx_flags |= IXGBE_TX_FLAGS_FSO; +		first->tx_flags |= IXGBE_TX_FLAGS_TSO;  	}  	/* set flag indicating FCOE to ixgbe_tx_map call */ -	first->tx_flags |= IXGBE_TX_FLAGS_FCOE; +	first->tx_flags |= IXGBE_TX_FLAGS_FCOE | IXGBE_TX_FLAGS_CC; -	/* mss_l4len_id: use 1 for FSO as TSO, no need for L4LEN */ +	/* mss_l4len_id: use 0 for FSO as TSO, no need for L4LEN */  	mss_l4len_idx = skb_shinfo(skb)->gso_size << IXGBE_ADVTXD_MSS_SHIFT; -	mss_l4len_idx |= 1 << IXGBE_ADVTXD_IDX_SHIFT;  	/* vlan_macip_lens: HEADLEN, MACLEN, VLAN tag */  	vlan_macip_lens = skb_transport_offset(skb) + @@ -717,10 +716,8 @@ int ixgbe_setup_fcoe_ddp_resources(struct ixgbe_adapter *adapter)  	/* Extra buffer to be shared by all DDPs for HW work around */  	buffer = kmalloc(IXGBE_FCBUFF_MIN, GFP_ATOMIC); -	if (!buffer) { -		e_err(drv, "failed to allocate extra DDP buffer\n"); +	if (!buffer)  		return -ENOMEM; -	}  	dma = dma_map_single(dev, buffer, IXGBE_FCBUFF_MIN, DMA_FROM_DEVICE);  	if (dma_mapping_error(dev, dma)) { diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.h index bf724da9937..3a02759b5e9 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_fcoe.h @@ -1,7 +1,7 @@  /*******************************************************************************    Intel 10 Gigabit PCI Express Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c index 8c74f739011..ef5f7a678ce 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_lib.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel 10 Gigabit PCI Express Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -386,7 +386,6 @@ static bool ixgbe_set_dcb_sriov_queues(struct ixgbe_adapter *adapter)  		fcoe = &adapter->ring_feature[RING_F_FCOE];  		/* limit ourselves based on feature limits */ -		fcoe_i = min_t(u16, fcoe_i, num_online_cpus());  		fcoe_i = min_t(u16, fcoe_i, fcoe->limit);  		if (fcoe_i) { @@ -562,9 +561,6 @@ static bool ixgbe_set_sriov_queues(struct ixgbe_adapter *adapter)  		fcoe_i = min_t(u16, fcoe_i, fcoe->limit);  		if (vmdq_i > 1 && fcoe_i) { -			/* reserve no more than number of CPUs */ -			fcoe_i = min_t(u16, fcoe_i, num_online_cpus()); -  			/* alloc queues for FCoE separately */  			fcoe->indices = fcoe_i;  			fcoe->offset = vmdq_i * rss_i; @@ -623,8 +619,7 @@ static bool ixgbe_set_rss_queues(struct ixgbe_adapter *adapter)  	if (rss_i > 1 && adapter->atr_sample_rate) {  		f = &adapter->ring_feature[RING_F_FDIR]; -		f->indices = min_t(u16, num_online_cpus(), f->limit); -		rss_i = max_t(u16, rss_i, f->indices); +		rss_i = f->indices = f->limit;  		if (!(adapter->flags & IXGBE_FLAG_FDIR_PERFECT_CAPABLE))  			adapter->flags |= IXGBE_FLAG_FDIR_HASH_CAPABLE; @@ -776,19 +771,23 @@ static int ixgbe_alloc_q_vector(struct ixgbe_adapter *adapter,  {  	struct ixgbe_q_vector *q_vector;  	struct ixgbe_ring *ring; -	int node = -1; +	int node = NUMA_NO_NODE;  	int cpu = -1;  	int ring_count, size; +	u8 tcs = netdev_get_num_tc(adapter->netdev);  	ring_count = txr_count + rxr_count;  	size = sizeof(struct ixgbe_q_vector) +  	       (sizeof(struct ixgbe_ring) * ring_count);  	/* customize cpu for Flow Director mapping */ -	if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) { -		if (cpu_online(v_idx)) { -			cpu = v_idx; -			node = cpu_to_node(cpu); +	if ((tcs <= 1) && !(adapter->flags & IXGBE_FLAG_SRIOV_ENABLED)) { +		u16 rss_i = adapter->ring_feature[RING_F_RSS].indices; +		if (rss_i > 1 && adapter->atr_sample_rate) { +			if (cpu_online(v_idx)) { +				cpu = v_idx; +				node = cpu_to_node(cpu); +			}  		}  	} diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 20a5af6d87d..db5611ae407 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel 10 Gigabit PCI Express Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -66,7 +66,7 @@ static char ixgbe_default_device_descr[] =  #define DRV_VERSION "3.11.33-k"  const char ixgbe_driver_version[] = DRV_VERSION;  static const char ixgbe_copyright[] = -				"Copyright (c) 1999-2012 Intel Corporation."; +				"Copyright (c) 1999-2013 Intel Corporation.";  static const struct ixgbe_info *ixgbe_info_tbl[] = {  	[board_82598] = &ixgbe_82598_info, @@ -803,6 +803,7 @@ static void ixgbe_tx_timeout_reset(struct ixgbe_adapter *adapter)  	/* Do the reset outside of interrupt context */  	if (!test_bit(__IXGBE_DOWN, &adapter->state)) {  		adapter->flags2 |= IXGBE_FLAG2_RESET_REQUESTED; +		e_warn(drv, "initiating reset due to tx timeout\n");  		ixgbe_service_event_schedule(adapter);  	}  } @@ -837,7 +838,7 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_q_vector *q_vector,  			break;  		/* prevent any other reads prior to eop_desc */ -		rmb(); +		read_barrier_depends();  		/* if DD is not set pending work has not been completed */  		if (!(eop_desc->wb.status & cpu_to_le32(IXGBE_TXD_STAT_DD))) @@ -850,9 +851,6 @@ static bool ixgbe_clean_tx_irq(struct ixgbe_q_vector *q_vector,  		total_bytes += tx_buffer->bytecount;  		total_packets += tx_buffer->gso_segs; -		if (unlikely(tx_buffer->tx_flags & IXGBE_TX_FLAGS_TSTAMP)) -			ixgbe_ptp_tx_hwtstamp(q_vector, tx_buffer->skb); -  		/* free the skb */  		dev_kfree_skb_any(tx_buffer->skb); @@ -1401,6 +1399,7 @@ static void ixgbe_set_rsc_gso_size(struct ixgbe_ring *ring,  	/* set gso_size to avoid messing up TCP MSS */  	skb_shinfo(skb)->gso_size = DIV_ROUND_UP((skb->len - hdr_len),  						 IXGBE_CB(skb)->append_cnt); +	skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4;  }  static void ixgbe_update_rsc_stats(struct ixgbe_ring *rx_ring, @@ -1441,7 +1440,7 @@ static void ixgbe_process_skb_fields(struct ixgbe_ring *rx_ring,  	ixgbe_rx_checksum(rx_ring, rx_desc, skb); -	ixgbe_ptp_rx_hwtstamp(rx_ring->q_vector, rx_desc, skb); +	ixgbe_ptp_rx_hwtstamp(rx_ring, rx_desc, skb);  	if ((dev->features & NETIF_F_HW_VLAN_RX) &&  	    ixgbe_test_staterr(rx_desc, IXGBE_RXD_STAT_VP)) { @@ -2180,10 +2179,10 @@ static void ixgbe_check_overtemp_subtask(struct ixgbe_adapter *adapter)  			return;  		if (!(eicr & IXGBE_EICR_LSC) && hw->mac.ops.check_link) { -			u32 autoneg; +			u32 speed;  			bool link_up = false; -			hw->mac.ops.check_link(hw, &autoneg, &link_up, false); +			hw->mac.ops.check_link(hw, &speed, &link_up, false);  			if (link_up)  				return; @@ -2787,13 +2786,19 @@ void ixgbe_configure_tx_ring(struct ixgbe_adapter *adapter,  	/*  	 * set WTHRESH to encourage burst writeback, it should not be set -	 * higher than 1 when ITR is 0 as it could cause false TX hangs +	 * higher than 1 when: +	 * - ITR is 0 as it could cause false TX hangs +	 * - ITR is set to > 100k int/sec and BQL is enabled  	 *  	 * In order to avoid issues WTHRESH + PTHRESH should always be equal  	 * to or less than the number of on chip descriptors, which is  	 * currently 40.  	 */ +#if IS_ENABLED(CONFIG_BQL) +	if (!ring->q_vector || (ring->q_vector->itr < IXGBE_100K_ITR)) +#else  	if (!ring->q_vector || (ring->q_vector->itr < 8)) +#endif  		txdctl |= (1 << 16);	/* WTHRESH = 1 */  	else  		txdctl |= (8 << 16);	/* WTHRESH = 8 */ @@ -2814,6 +2819,16 @@ void ixgbe_configure_tx_ring(struct ixgbe_adapter *adapter,  		ring->atr_sample_rate = 0;  	} +	/* initialize XPS */ +	if (!test_and_set_bit(__IXGBE_TX_XPS_INIT_DONE, &ring->state)) { +		struct ixgbe_q_vector *q_vector = ring->q_vector; + +		if (q_vector) +			netif_set_xps_queue(adapter->netdev, +					    &q_vector->affinity_mask, +					    ring->queue_index); +	} +  	clear_bit(__IXGBE_HANG_CHECK_ARMED, &ring->state);  	/* enable queue */ @@ -3876,7 +3891,7 @@ static void ixgbe_configure_pb(struct ixgbe_adapter *adapter)  static void ixgbe_fdir_filter_restore(struct ixgbe_adapter *adapter)  {  	struct ixgbe_hw *hw = &adapter->hw; -	struct hlist_node *node, *node2; +	struct hlist_node *node2;  	struct ixgbe_fdir_filter *filter;  	spin_lock(&adapter->fdir_perfect_lock); @@ -3884,7 +3899,7 @@ static void ixgbe_fdir_filter_restore(struct ixgbe_adapter *adapter)  	if (!hlist_empty(&adapter->fdir_filter_list))  		ixgbe_fdir_set_input_mask_82599(hw, &adapter->fdir_mask); -	hlist_for_each_entry_safe(filter, node, node2, +	hlist_for_each_entry_safe(filter, node2,  				  &adapter->fdir_filter_list, fdir_node) {  		ixgbe_fdir_write_perfect_filter_82599(hw,  				&filter->filter, @@ -3996,25 +4011,25 @@ static void ixgbe_sfp_link_config(struct ixgbe_adapter *adapter)   **/  static int ixgbe_non_sfp_link_config(struct ixgbe_hw *hw)  { -	u32 autoneg; -	bool negotiation, link_up = false; +	u32 speed; +	bool autoneg, link_up = false;  	u32 ret = IXGBE_ERR_LINK_SETUP;  	if (hw->mac.ops.check_link) -		ret = hw->mac.ops.check_link(hw, &autoneg, &link_up, false); +		ret = hw->mac.ops.check_link(hw, &speed, &link_up, false);  	if (ret)  		goto link_cfg_out; -	autoneg = hw->phy.autoneg_advertised; -	if ((!autoneg) && (hw->mac.ops.get_link_capabilities)) -		ret = hw->mac.ops.get_link_capabilities(hw, &autoneg, -							&negotiation); +	speed = hw->phy.autoneg_advertised; +	if ((!speed) && (hw->mac.ops.get_link_capabilities)) +		ret = hw->mac.ops.get_link_capabilities(hw, &speed, +							&autoneg);  	if (ret)  		goto link_cfg_out;  	if (hw->mac.ops.setup_link) -		ret = hw->mac.ops.setup_link(hw, autoneg, negotiation, link_up); +		ret = hw->mac.ops.setup_link(hw, speed, link_up);  link_cfg_out:  	return ret;  } @@ -4341,12 +4356,12 @@ static void ixgbe_clean_all_tx_rings(struct ixgbe_adapter *adapter)  static void ixgbe_fdir_filter_exit(struct ixgbe_adapter *adapter)  { -	struct hlist_node *node, *node2; +	struct hlist_node *node2;  	struct ixgbe_fdir_filter *filter;  	spin_lock(&adapter->fdir_perfect_lock); -	hlist_for_each_entry_safe(filter, node, node2, +	hlist_for_each_entry_safe(filter, node2,  				  &adapter->fdir_filter_list, fdir_node) {  		hlist_del(&filter->fdir_node);  		kfree(filter); @@ -4466,7 +4481,7 @@ static int ixgbe_sw_init(struct ixgbe_adapter *adapter)  {  	struct ixgbe_hw *hw = &adapter->hw;  	struct pci_dev *pdev = adapter->pdev; -	unsigned int rss; +	unsigned int rss, fdir;  	u32 fwsm;  #ifdef CONFIG_IXGBE_DCB  	int j; @@ -4481,38 +4496,57 @@ static int ixgbe_sw_init(struct ixgbe_adapter *adapter)  	hw->subsystem_vendor_id = pdev->subsystem_vendor;  	hw->subsystem_device_id = pdev->subsystem_device; -	/* Set capability flags */ +	/* Set common capability flags and settings */  	rss = min_t(int, IXGBE_MAX_RSS_INDICES, num_online_cpus());  	adapter->ring_feature[RING_F_RSS].limit = rss; +	adapter->flags2 |= IXGBE_FLAG2_RSC_CAPABLE; +	adapter->flags2 |= IXGBE_FLAG2_RSC_ENABLED; +	adapter->max_q_vectors = MAX_Q_VECTORS_82599; +	adapter->atr_sample_rate = 20; +	fdir = min_t(int, IXGBE_MAX_FDIR_INDICES, num_online_cpus()); +	adapter->ring_feature[RING_F_FDIR].limit = fdir; +	adapter->fdir_pballoc = IXGBE_FDIR_PBALLOC_64K; +#ifdef CONFIG_IXGBE_DCA +	adapter->flags |= IXGBE_FLAG_DCA_CAPABLE; +#endif +#ifdef IXGBE_FCOE +	adapter->flags |= IXGBE_FLAG_FCOE_CAPABLE; +	adapter->flags &= ~IXGBE_FLAG_FCOE_ENABLED; +#ifdef CONFIG_IXGBE_DCB +	/* Default traffic class to use for FCoE */ +	adapter->fcoe.up = IXGBE_FCOE_DEFTC; +#endif /* CONFIG_IXGBE_DCB */ +#endif /* IXGBE_FCOE */ + +	/* Set MAC specific capability flags and exceptions */  	switch (hw->mac.type) {  	case ixgbe_mac_82598EB: +		adapter->flags2 &= ~IXGBE_FLAG2_RSC_CAPABLE; +		adapter->flags2 &= ~IXGBE_FLAG2_RSC_ENABLED; +  		if (hw->device_id == IXGBE_DEV_ID_82598AT)  			adapter->flags |= IXGBE_FLAG_FAN_FAIL_CAPABLE; +  		adapter->max_q_vectors = MAX_Q_VECTORS_82598; +		adapter->ring_feature[RING_F_FDIR].limit = 0; +		adapter->atr_sample_rate = 0; +		adapter->fdir_pballoc = 0; +#ifdef IXGBE_FCOE +		adapter->flags &= ~IXGBE_FLAG_FCOE_CAPABLE; +		adapter->flags &= ~IXGBE_FLAG_FCOE_ENABLED; +#ifdef CONFIG_IXGBE_DCB +		adapter->fcoe.up = 0; +#endif /* IXGBE_DCB */ +#endif /* IXGBE_FCOE */ +		break; +	case ixgbe_mac_82599EB: +		if (hw->device_id == IXGBE_DEV_ID_82599_T3_LOM) +			adapter->flags2 |= IXGBE_FLAG2_TEMP_SENSOR_CAPABLE;  		break;  	case ixgbe_mac_X540:  		fwsm = IXGBE_READ_REG(hw, IXGBE_FWSM);  		if (fwsm & IXGBE_FWSM_TS_ENABLED)  			adapter->flags2 |= IXGBE_FLAG2_TEMP_SENSOR_CAPABLE; -	case ixgbe_mac_82599EB: -		adapter->max_q_vectors = MAX_Q_VECTORS_82599; -		adapter->flags2 |= IXGBE_FLAG2_RSC_CAPABLE; -		adapter->flags2 |= IXGBE_FLAG2_RSC_ENABLED; -		if (hw->device_id == IXGBE_DEV_ID_82599_T3_LOM) -			adapter->flags2 |= IXGBE_FLAG2_TEMP_SENSOR_CAPABLE; -		/* Flow Director hash filters enabled */ -		adapter->atr_sample_rate = 20; -		adapter->ring_feature[RING_F_FDIR].limit = -							 IXGBE_MAX_FDIR_INDICES; -		adapter->fdir_pballoc = IXGBE_FDIR_PBALLOC_64K; -#ifdef IXGBE_FCOE -		adapter->flags |= IXGBE_FLAG_FCOE_CAPABLE; -		adapter->flags &= ~IXGBE_FLAG_FCOE_ENABLED; -#ifdef CONFIG_IXGBE_DCB -		/* Default traffic class to use for FCoE */ -		adapter->fcoe.up = IXGBE_FCOE_DEFTC; -#endif -#endif /* IXGBE_FCOE */  		break;  	default:  		break; @@ -4871,7 +4905,7 @@ static int ixgbe_change_mtu(struct net_device *netdev, int new_mtu)  	 */  	if ((adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) &&  	    (adapter->hw.mac.type == ixgbe_mac_82599EB) && -	    (max_frame > MAXIMUM_ETHERNET_VLAN_SIZE)) +	    (max_frame > (ETH_FRAME_LEN + ETH_FCS_LEN)))  		e_warn(probe, "Setting MTU > 1500 will disable legacy VFs\n");  	e_info(probe, "changing MTU from %d to %d\n", netdev->mtu, new_mtu); @@ -5534,6 +5568,8 @@ static void ixgbe_watchdog_link_is_up(struct ixgbe_adapter *adapter)  		break;  	} +	adapter->last_rx_ptp_check = jiffies; +  	if (adapter->flags2 & IXGBE_FLAG2_PTP_ENABLED)  		ixgbe_ptp_start_cyclecounter(adapter); @@ -5614,6 +5650,7 @@ static void ixgbe_watchdog_flush_tx(struct ixgbe_adapter *adapter)  			 * to get done, so reset controller to flush Tx.  			 * (Do the reset outside of interrupt context).  			 */ +			e_warn(drv, "initiating reset to clear Tx work after link loss\n");  			adapter->flags2 |= IXGBE_FLAG2_RESET_REQUESTED;  		}  	} @@ -5678,6 +5715,10 @@ static void ixgbe_sfp_detection_subtask(struct ixgbe_adapter *adapter)  	    !(adapter->flags2 & IXGBE_FLAG2_SFP_NEEDS_RESET))  		return; +	/* concurent i2c reads are not supported */ +	if (test_bit(__IXGBE_READ_I2C, &adapter->state)) +		return; +  	/* someone else is in init, wait until next service event */  	if (test_and_set_bit(__IXGBE_IN_SFP_INIT, &adapter->state))  		return; @@ -5738,8 +5779,8 @@ sfp_out:  static void ixgbe_sfp_link_config_subtask(struct ixgbe_adapter *adapter)  {  	struct ixgbe_hw *hw = &adapter->hw; -	u32 autoneg; -	bool negotiation; +	u32 speed; +	bool autoneg = false;  	if (!(adapter->flags & IXGBE_FLAG_NEED_LINK_CONFIG))  		return; @@ -5750,11 +5791,11 @@ static void ixgbe_sfp_link_config_subtask(struct ixgbe_adapter *adapter)  	adapter->flags &= ~IXGBE_FLAG_NEED_LINK_CONFIG; -	autoneg = hw->phy.autoneg_advertised; -	if ((!autoneg) && (hw->mac.ops.get_link_capabilities)) -		hw->mac.ops.get_link_capabilities(hw, &autoneg, &negotiation); +	speed = hw->phy.autoneg_advertised; +	if ((!speed) && (hw->mac.ops.get_link_capabilities)) +		hw->mac.ops.get_link_capabilities(hw, &speed, &autoneg);  	if (hw->mac.ops.setup_link) -		hw->mac.ops.setup_link(hw, autoneg, negotiation, true); +		hw->mac.ops.setup_link(hw, speed, true);  	adapter->flags |= IXGBE_FLAG_NEED_LINK_UPDATE;  	adapter->link_check_timeout = jiffies; @@ -5878,7 +5919,6 @@ static void ixgbe_service_task(struct work_struct *work)  	struct ixgbe_adapter *adapter = container_of(work,  						     struct ixgbe_adapter,  						     service_task); -  	ixgbe_reset_subtask(adapter);  	ixgbe_sfp_detection_subtask(adapter);  	ixgbe_sfp_link_config_subtask(adapter); @@ -5886,7 +5926,11 @@ static void ixgbe_service_task(struct work_struct *work)  	ixgbe_watchdog_subtask(adapter);  	ixgbe_fdir_reinit_subtask(adapter);  	ixgbe_check_hang_subtask(adapter); -	ixgbe_ptp_overflow_check(adapter); + +	if (adapter->flags2 & IXGBE_FLAG2_PTP_ENABLED) { +		ixgbe_ptp_overflow_check(adapter); +		ixgbe_ptp_rx_hang(adapter); +	}  	ixgbe_service_event_complete(adapter);  } @@ -5899,6 +5943,9 @@ static int ixgbe_tso(struct ixgbe_ring *tx_ring,  	u32 vlan_macip_lens, type_tucmd;  	u32 mss_l4len_idx, l4len; +	if (skb->ip_summed != CHECKSUM_PARTIAL) +		return 0; +  	if (!skb_is_gso(skb))  		return 0; @@ -5941,10 +5988,9 @@ static int ixgbe_tso(struct ixgbe_ring *tx_ring,  	first->gso_segs = skb_shinfo(skb)->gso_segs;  	first->bytecount += (first->gso_segs - 1) * *hdr_len; -	/* mss_l4len_id: use 1 as index for TSO */ +	/* mss_l4len_id: use 0 as index for TSO */  	mss_l4len_idx = l4len << IXGBE_ADVTXD_L4LEN_SHIFT;  	mss_l4len_idx |= skb_shinfo(skb)->gso_size << IXGBE_ADVTXD_MSS_SHIFT; -	mss_l4len_idx |= 1 << IXGBE_ADVTXD_IDX_SHIFT;  	/* vlan_macip_lens: HEADLEN, MACLEN, VLAN tag */  	vlan_macip_lens = skb_network_header_len(skb); @@ -5966,12 +6012,9 @@ static void ixgbe_tx_csum(struct ixgbe_ring *tx_ring,  	u32 type_tucmd = 0;  	if (skb->ip_summed != CHECKSUM_PARTIAL) { -		if (!(first->tx_flags & IXGBE_TX_FLAGS_HW_VLAN)) { -			if (unlikely(skb->no_fcs)) -				first->tx_flags |= IXGBE_TX_FLAGS_NO_IFCS; -			if (!(first->tx_flags & IXGBE_TX_FLAGS_TXSW)) -				return; -		} +		if (!(first->tx_flags & IXGBE_TX_FLAGS_HW_VLAN) && +		    !(first->tx_flags & IXGBE_TX_FLAGS_CC)) +			return;  	} else {  		u8 l4_hdr = 0;  		switch (first->protocol) { @@ -6029,30 +6072,32 @@ static void ixgbe_tx_csum(struct ixgbe_ring *tx_ring,  			  type_tucmd, mss_l4len_idx);  } -static __le32 ixgbe_tx_cmd_type(u32 tx_flags) +#define IXGBE_SET_FLAG(_input, _flag, _result) \ +	((_flag <= _result) ? \ +	 ((u32)(_input & _flag) * (_result / _flag)) : \ +	 ((u32)(_input & _flag) / (_flag / _result))) + +static u32 ixgbe_tx_cmd_type(struct sk_buff *skb, u32 tx_flags)  {  	/* set type for advanced descriptor with frame checksum insertion */ -	__le32 cmd_type = cpu_to_le32(IXGBE_ADVTXD_DTYP_DATA | -				      IXGBE_ADVTXD_DCMD_DEXT); +	u32 cmd_type = IXGBE_ADVTXD_DTYP_DATA | +		       IXGBE_ADVTXD_DCMD_DEXT | +		       IXGBE_ADVTXD_DCMD_IFCS;  	/* set HW vlan bit if vlan is present */ -	if (tx_flags & IXGBE_TX_FLAGS_HW_VLAN) -		cmd_type |= cpu_to_le32(IXGBE_ADVTXD_DCMD_VLE); - -	if (tx_flags & IXGBE_TX_FLAGS_TSTAMP) -		cmd_type |= cpu_to_le32(IXGBE_ADVTXD_MAC_TSTAMP); +	cmd_type |= IXGBE_SET_FLAG(tx_flags, IXGBE_TX_FLAGS_HW_VLAN, +				   IXGBE_ADVTXD_DCMD_VLE);  	/* set segmentation enable bits for TSO/FSO */ -#ifdef IXGBE_FCOE -	if (tx_flags & (IXGBE_TX_FLAGS_TSO | IXGBE_TX_FLAGS_FSO)) -#else -	if (tx_flags & IXGBE_TX_FLAGS_TSO) -#endif -		cmd_type |= cpu_to_le32(IXGBE_ADVTXD_DCMD_TSE); +	cmd_type |= IXGBE_SET_FLAG(tx_flags, IXGBE_TX_FLAGS_TSO, +				   IXGBE_ADVTXD_DCMD_TSE); + +	/* set timestamp bit if present */ +	cmd_type |= IXGBE_SET_FLAG(tx_flags, IXGBE_TX_FLAGS_TSTAMP, +				   IXGBE_ADVTXD_MAC_TSTAMP);  	/* insert frame checksum */ -	if (!(tx_flags & IXGBE_TX_FLAGS_NO_IFCS)) -		cmd_type |= cpu_to_le32(IXGBE_ADVTXD_DCMD_IFCS); +	cmd_type ^= IXGBE_SET_FLAG(skb->no_fcs, 1, IXGBE_ADVTXD_DCMD_IFCS);  	return cmd_type;  } @@ -6060,36 +6105,27 @@ static __le32 ixgbe_tx_cmd_type(u32 tx_flags)  static void ixgbe_tx_olinfo_status(union ixgbe_adv_tx_desc *tx_desc,  				   u32 tx_flags, unsigned int paylen)  { -	__le32 olinfo_status = cpu_to_le32(paylen << IXGBE_ADVTXD_PAYLEN_SHIFT); +	u32 olinfo_status = paylen << IXGBE_ADVTXD_PAYLEN_SHIFT;  	/* enable L4 checksum for TSO and TX checksum offload */ -	if (tx_flags & IXGBE_TX_FLAGS_CSUM) -		olinfo_status |= cpu_to_le32(IXGBE_ADVTXD_POPTS_TXSM); +	olinfo_status |= IXGBE_SET_FLAG(tx_flags, +					IXGBE_TX_FLAGS_CSUM, +					IXGBE_ADVTXD_POPTS_TXSM);  	/* enble IPv4 checksum for TSO */ -	if (tx_flags & IXGBE_TX_FLAGS_IPV4) -		olinfo_status |= cpu_to_le32(IXGBE_ADVTXD_POPTS_IXSM); - -	/* use index 1 context for TSO/FSO/FCOE */ -#ifdef IXGBE_FCOE -	if (tx_flags & (IXGBE_TX_FLAGS_TSO | IXGBE_TX_FLAGS_FCOE)) -#else -	if (tx_flags & IXGBE_TX_FLAGS_TSO) -#endif -		olinfo_status |= cpu_to_le32(1 << IXGBE_ADVTXD_IDX_SHIFT); +	olinfo_status |= IXGBE_SET_FLAG(tx_flags, +					IXGBE_TX_FLAGS_IPV4, +					IXGBE_ADVTXD_POPTS_IXSM);  	/*  	 * Check Context must be set if Tx switch is enabled, which it  	 * always is for case where virtual functions are running  	 */ -#ifdef IXGBE_FCOE -	if (tx_flags & (IXGBE_TX_FLAGS_TXSW | IXGBE_TX_FLAGS_FCOE)) -#else -	if (tx_flags & IXGBE_TX_FLAGS_TXSW) -#endif -		olinfo_status |= cpu_to_le32(IXGBE_ADVTXD_CC); +	olinfo_status |= IXGBE_SET_FLAG(tx_flags, +					IXGBE_TX_FLAGS_CC, +					IXGBE_ADVTXD_CC); -	tx_desc->read.olinfo_status = olinfo_status; +	tx_desc->read.olinfo_status = cpu_to_le32(olinfo_status);  }  #define IXGBE_TXD_CMD (IXGBE_TXD_CMD_EOP | \ @@ -6099,22 +6135,22 @@ static void ixgbe_tx_map(struct ixgbe_ring *tx_ring,  			 struct ixgbe_tx_buffer *first,  			 const u8 hdr_len)  { -	dma_addr_t dma;  	struct sk_buff *skb = first->skb;  	struct ixgbe_tx_buffer *tx_buffer;  	union ixgbe_adv_tx_desc *tx_desc; -	struct skb_frag_struct *frag = &skb_shinfo(skb)->frags[0]; -	unsigned int data_len = skb->data_len; -	unsigned int size = skb_headlen(skb); -	unsigned int paylen = skb->len - hdr_len; +	struct skb_frag_struct *frag; +	dma_addr_t dma; +	unsigned int data_len, size;  	u32 tx_flags = first->tx_flags; -	__le32 cmd_type; +	u32 cmd_type = ixgbe_tx_cmd_type(skb, tx_flags);  	u16 i = tx_ring->next_to_use;  	tx_desc = IXGBE_TX_DESC(tx_ring, i); -	ixgbe_tx_olinfo_status(tx_desc, tx_flags, paylen); -	cmd_type = ixgbe_tx_cmd_type(tx_flags); +	ixgbe_tx_olinfo_status(tx_desc, tx_flags, skb->len - hdr_len); + +	size = skb_headlen(skb); +	data_len = skb->data_len;  #ifdef IXGBE_FCOE  	if (tx_flags & IXGBE_TX_FLAGS_FCOE) { @@ -6128,19 +6164,22 @@ static void ixgbe_tx_map(struct ixgbe_ring *tx_ring,  #endif  	dma = dma_map_single(tx_ring->dev, skb->data, size, DMA_TO_DEVICE); -	if (dma_mapping_error(tx_ring->dev, dma)) -		goto dma_error; -	/* record length, and DMA address */ -	dma_unmap_len_set(first, len, size); -	dma_unmap_addr_set(first, dma, dma); +	tx_buffer = first; -	tx_desc->read.buffer_addr = cpu_to_le64(dma); +	for (frag = &skb_shinfo(skb)->frags[0];; frag++) { +		if (dma_mapping_error(tx_ring->dev, dma)) +			goto dma_error; + +		/* record length, and DMA address */ +		dma_unmap_len_set(tx_buffer, len, size); +		dma_unmap_addr_set(tx_buffer, dma, dma); + +		tx_desc->read.buffer_addr = cpu_to_le64(dma); -	for (;;) {  		while (unlikely(size > IXGBE_MAX_DATA_PER_TXD)) {  			tx_desc->read.cmd_type_len = -				cmd_type | cpu_to_le32(IXGBE_MAX_DATA_PER_TXD); +				cpu_to_le32(cmd_type ^ IXGBE_MAX_DATA_PER_TXD);  			i++;  			tx_desc++; @@ -6148,18 +6187,18 @@ static void ixgbe_tx_map(struct ixgbe_ring *tx_ring,  				tx_desc = IXGBE_TX_DESC(tx_ring, 0);  				i = 0;  			} +			tx_desc->read.olinfo_status = 0;  			dma += IXGBE_MAX_DATA_PER_TXD;  			size -= IXGBE_MAX_DATA_PER_TXD;  			tx_desc->read.buffer_addr = cpu_to_le64(dma); -			tx_desc->read.olinfo_status = 0;  		}  		if (likely(!data_len))  			break; -		tx_desc->read.cmd_type_len = cmd_type | cpu_to_le32(size); +		tx_desc->read.cmd_type_len = cpu_to_le32(cmd_type ^ size);  		i++;  		tx_desc++; @@ -6167,6 +6206,7 @@ static void ixgbe_tx_map(struct ixgbe_ring *tx_ring,  			tx_desc = IXGBE_TX_DESC(tx_ring, 0);  			i = 0;  		} +		tx_desc->read.olinfo_status = 0;  #ifdef IXGBE_FCOE  		size = min_t(unsigned int, data_len, skb_frag_size(frag)); @@ -6177,22 +6217,13 @@ static void ixgbe_tx_map(struct ixgbe_ring *tx_ring,  		dma = skb_frag_dma_map(tx_ring->dev, frag, 0, size,  				       DMA_TO_DEVICE); -		if (dma_mapping_error(tx_ring->dev, dma)) -			goto dma_error;  		tx_buffer = &tx_ring->tx_buffer_info[i]; -		dma_unmap_len_set(tx_buffer, len, size); -		dma_unmap_addr_set(tx_buffer, dma, dma); - -		tx_desc->read.buffer_addr = cpu_to_le64(dma); -		tx_desc->read.olinfo_status = 0; - -		frag++;  	}  	/* write last descriptor with RS and EOP bits */ -	cmd_type |= cpu_to_le32(size) | cpu_to_le32(IXGBE_TXD_CMD); -	tx_desc->read.cmd_type_len = cmd_type; +	cmd_type |= size | IXGBE_TXD_CMD; +	tx_desc->read.cmd_type_len = cpu_to_le32(cmd_type);  	netdev_tx_sent_queue(txring_txq(tx_ring), first->bytecount); @@ -6353,38 +6384,40 @@ static inline int ixgbe_maybe_stop_tx(struct ixgbe_ring *tx_ring, u16 size)  	return __ixgbe_maybe_stop_tx(tx_ring, size);  } +#ifdef IXGBE_FCOE  static u16 ixgbe_select_queue(struct net_device *dev, struct sk_buff *skb)  { -	struct ixgbe_adapter *adapter = netdev_priv(dev); -	int txq = skb_rx_queue_recorded(skb) ? skb_get_rx_queue(skb) : -					       smp_processor_id(); -#ifdef IXGBE_FCOE -	__be16 protocol = vlan_get_protocol(skb); +	struct ixgbe_adapter *adapter; +	struct ixgbe_ring_feature *f; +	int txq; -	if (((protocol == htons(ETH_P_FCOE)) || -	    (protocol == htons(ETH_P_FIP))) && -	    (adapter->flags & IXGBE_FLAG_FCOE_ENABLED)) { -		struct ixgbe_ring_feature *f; +	/* +	 * only execute the code below if protocol is FCoE +	 * or FIP and we have FCoE enabled on the adapter +	 */ +	switch (vlan_get_protocol(skb)) { +	case __constant_htons(ETH_P_FCOE): +	case __constant_htons(ETH_P_FIP): +		adapter = netdev_priv(dev); -		f = &adapter->ring_feature[RING_F_FCOE]; +		if (adapter->flags & IXGBE_FLAG_FCOE_ENABLED) +			break; +	default: +		return __netdev_pick_tx(dev, skb); +	} -		while (txq >= f->indices) -			txq -= f->indices; -		txq += adapter->ring_feature[RING_F_FCOE].offset; +	f = &adapter->ring_feature[RING_F_FCOE]; -		return txq; -	} -#endif +	txq = skb_rx_queue_recorded(skb) ? skb_get_rx_queue(skb) : +					   smp_processor_id(); -	if (adapter->flags & IXGBE_FLAG_FDIR_HASH_CAPABLE) { -		while (unlikely(txq >= dev->real_num_tx_queues)) -			txq -= dev->real_num_tx_queues; -		return txq; -	} +	while (txq >= f->indices) +		txq -= f->indices; -	return skb_tx_hash(dev, skb); +	return txq + f->offset;  } +#endif  netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb,  			  struct ixgbe_adapter *adapter,  			  struct ixgbe_ring *tx_ring) @@ -6445,6 +6478,11 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb,  	if (unlikely(skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP)) {  		skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;  		tx_flags |= IXGBE_TX_FLAGS_TSTAMP; + +		/* schedule check for Tx timestamp */ +		adapter->ptp_tx_skb = skb_get(skb); +		adapter->ptp_tx_start = jiffies; +		schedule_work(&adapter->ptp_tx_work);  	}  #ifdef CONFIG_PCI_IOV @@ -6453,7 +6491,7 @@ netdev_tx_t ixgbe_xmit_frame_ring(struct sk_buff *skb,  	 * Tx switch had been disabled.  	 */  	if (adapter->flags & IXGBE_FLAG_SRIOV_ENABLED) -		tx_flags |= IXGBE_TX_FLAGS_TXSW; +		tx_flags |= IXGBE_TX_FLAGS_CC;  #endif  	/* DCB maps skb priorities 0-7 onto 3 bit PCP of VLAN tag. */ @@ -6784,6 +6822,7 @@ static void ixgbe_set_prio_tc_map(struct ixgbe_adapter *adapter)  	}  } +#endif /* CONFIG_IXGBE_DCB */  /**   * ixgbe_setup_tc - configure net_device for multiple traffic classes   * @@ -6809,6 +6848,7 @@ int ixgbe_setup_tc(struct net_device *dev, u8 tc)  		ixgbe_close(dev);  	ixgbe_clear_interrupt_scheme(adapter); +#ifdef CONFIG_IXGBE_DCB  	if (tc) {  		netdev_set_num_tc(dev, tc);  		ixgbe_set_prio_tc_map(adapter); @@ -6831,15 +6871,28 @@ int ixgbe_setup_tc(struct net_device *dev, u8 tc)  		adapter->dcb_cfg.pfc_mode_enable = false;  	} -	ixgbe_init_interrupt_scheme(adapter);  	ixgbe_validate_rtr(adapter, tc); + +#endif /* CONFIG_IXGBE_DCB */ +	ixgbe_init_interrupt_scheme(adapter); +  	if (netif_running(dev)) -		ixgbe_open(dev); +		return ixgbe_open(dev);  	return 0;  } -#endif /* CONFIG_IXGBE_DCB */ +#ifdef CONFIG_PCI_IOV +void ixgbe_sriov_reinit(struct ixgbe_adapter *adapter) +{ +	struct net_device *netdev = adapter->netdev; + +	rtnl_lock(); +	ixgbe_setup_tc(netdev, netdev_get_num_tc(netdev)); +	rtnl_unlock(); +} + +#endif  void ixgbe_do_reset(struct net_device *netdev)  {  	struct ixgbe_adapter *adapter = netdev_priv(netdev); @@ -6985,7 +7038,7 @@ static int ixgbe_ndo_fdb_add(struct ndmsg *ndm, struct nlattr *tb[],  	return err;  } -static int ixgbe_ndo_fdb_del(struct ndmsg *ndm, +static int ixgbe_ndo_fdb_del(struct ndmsg *ndm, struct nlattr *tb[],  			     struct net_device *dev,  			     const unsigned char *addr)  { @@ -7062,7 +7115,8 @@ static int ixgbe_ndo_bridge_setlink(struct net_device *dev,  }  static int ixgbe_ndo_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq, -				    struct net_device *dev) +				    struct net_device *dev, +				    u32 filter_mask)  {  	struct ixgbe_adapter *adapter = netdev_priv(dev);  	u16 mode; @@ -7082,7 +7136,9 @@ static const struct net_device_ops ixgbe_netdev_ops = {  	.ndo_open		= ixgbe_open,  	.ndo_stop		= ixgbe_close,  	.ndo_start_xmit		= ixgbe_xmit_frame, +#ifdef IXGBE_FCOE  	.ndo_select_queue	= ixgbe_select_queue, +#endif  	.ndo_set_rx_mode	= ixgbe_set_rx_mode,  	.ndo_validate_addr	= eth_validate_addr,  	.ndo_set_mac_address	= ixgbe_set_mac, @@ -7194,9 +7250,8 @@ static int ixgbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)  	const struct ixgbe_info *ii = ixgbe_info_tbl[ent->driver_data];  	static int cards_found;  	int i, err, pci_using_dac; +	unsigned int indices = MAX_TX_QUEUES;  	u8 part_str[IXGBE_PBANUM_LENGTH]; -	unsigned int indices = num_possible_cpus(); -	unsigned int dcb_max = 0;  #ifdef IXGBE_FCOE  	u16 device_caps;  #endif @@ -7245,25 +7300,15 @@ static int ixgbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)  	pci_set_master(pdev);  	pci_save_state(pdev); +	if (ii->mac == ixgbe_mac_82598EB) {  #ifdef CONFIG_IXGBE_DCB -	if (ii->mac == ixgbe_mac_82598EB) -		dcb_max = min_t(unsigned int, indices * MAX_TRAFFIC_CLASS, -				IXGBE_MAX_RSS_INDICES); -	else -		dcb_max = min_t(unsigned int, indices * MAX_TRAFFIC_CLASS, -				IXGBE_MAX_FDIR_INDICES); +		/* 8 TC w/ 4 queues per TC */ +		indices = 4 * MAX_TRAFFIC_CLASS; +#else +		indices = IXGBE_MAX_RSS_INDICES;  #endif +	} -	if (ii->mac == ixgbe_mac_82598EB) -		indices = min_t(unsigned int, indices, IXGBE_MAX_RSS_INDICES); -	else -		indices = min_t(unsigned int, indices, IXGBE_MAX_FDIR_INDICES); - -#ifdef IXGBE_FCOE -	indices += min_t(unsigned int, num_possible_cpus(), -			 IXGBE_MAX_FCOE_INDICES); -#endif -	indices = max_t(unsigned int, dcb_max, indices);  	netdev = alloc_etherdev_mq(sizeof(struct ixgbe_adapter), indices);  	if (!netdev) {  		err = -ENOMEM; @@ -7366,7 +7411,15 @@ static int ixgbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)  	}  #ifdef CONFIG_PCI_IOV -	ixgbe_enable_sriov(adapter, ii); +	/* SR-IOV not supported on the 82598 */ +	if (adapter->hw.mac.type == ixgbe_mac_82598EB) +		goto skip_sriov; +	/* Mailbox */ +	ixgbe_init_mbx_params_pf(hw); +	memcpy(&hw->mbx.ops, ii->mbx_ops, sizeof(hw->mbx.ops)); +	ixgbe_enable_sriov(adapter); +	pci_sriov_set_totalvfs(pdev, 63); +skip_sriov:  #endif  	netdev->features = NETIF_F_SG | @@ -7410,13 +7463,17 @@ static int ixgbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)  #ifdef IXGBE_FCOE  	if (adapter->flags & IXGBE_FLAG_FCOE_CAPABLE) { +		unsigned int fcoe_l; +  		if (hw->mac.ops.get_device_caps) {  			hw->mac.ops.get_device_caps(hw, &device_caps);  			if (device_caps & IXGBE_DEVICE_CAPS_FCOE_OFFLOADS)  				adapter->flags &= ~IXGBE_FLAG_FCOE_CAPABLE;  		} -		adapter->ring_feature[RING_F_FCOE].limit = IXGBE_FCRETA_SIZE; + +		fcoe_l = min_t(int, IXGBE_FCRETA_SIZE, num_online_cpus()); +		adapter->ring_feature[RING_F_FCOE].limit = fcoe_l;  		netdev->features |= NETIF_F_FSO |  				    NETIF_F_FCOE_CRC; @@ -7444,9 +7501,8 @@ static int ixgbe_probe(struct pci_dev *pdev, const struct pci_device_id *ent)  	}  	memcpy(netdev->dev_addr, hw->mac.perm_addr, netdev->addr_len); -	memcpy(netdev->perm_addr, hw->mac.perm_addr, netdev->addr_len); -	if (!is_valid_ether_addr(netdev->perm_addr)) { +	if (!is_valid_ether_addr(netdev->dev_addr)) {  		e_dev_err("invalid MAC address\n");  		err = -EIO;  		goto err_sw_init; @@ -7623,8 +7679,14 @@ static void ixgbe_remove(struct pci_dev *pdev)  	if (netdev->reg_state == NETREG_REGISTERED)  		unregister_netdev(netdev); -	ixgbe_disable_sriov(adapter); - +#ifdef CONFIG_PCI_IOV +	/* +	 * Only disable SR-IOV on unload if the user specified the now +	 * deprecated max_vfs module parameter. +	 */ +	if (max_vfs) +		ixgbe_disable_sriov(adapter); +#endif  	ixgbe_clear_interrupt_scheme(adapter);  	ixgbe_release_hw_control(adapter); @@ -7729,6 +7791,8 @@ static pci_ers_result_t ixgbe_io_error_detected(struct pci_dev *pdev,  		if (vfdev) {  			e_dev_err("Issuing VFLR to VF %d\n", vf);  			pci_write_config_dword(vfdev, 0xA8, 0x00008000); +			/* Free device reference count */ +			pci_dev_put(vfdev);  		}  		pci_cleanup_aer_uncorrect_error_status(pdev); @@ -7838,6 +7902,7 @@ static struct pci_driver ixgbe_driver = {  	.resume   = ixgbe_resume,  #endif  	.shutdown = ixgbe_shutdown, +	.sriov_configure = ixgbe_pci_sriov_configure,  	.err_handler = &ixgbe_err_handler  }; diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_mbx.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_mbx.c index 1f3e32b576a..d4a64e66539 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_mbx.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_mbx.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel 10 Gigabit PCI Express Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_mbx.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_mbx.h index 42dd65e6ac9..e44ff47659b 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_mbx.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_mbx.h @@ -1,7 +1,7 @@  /*******************************************************************************    Intel 10 Gigabit PCI Express Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c index 71659edf81a..060d2ad2ac9 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel 10 Gigabit PCI Express Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -494,11 +494,9 @@ s32 ixgbe_setup_phy_link_generic(struct ixgbe_hw *hw)   *  ixgbe_setup_phy_link_speed_generic - Sets the auto advertised capabilities   *  @hw: pointer to hardware structure   *  @speed: new link speed - *  @autoneg: true if autonegotiation enabled   **/  s32 ixgbe_setup_phy_link_speed_generic(struct ixgbe_hw *hw,                                         ixgbe_link_speed speed, -                                       bool autoneg,                                         bool autoneg_wait_to_complete)  { @@ -854,11 +852,9 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)  	status = hw->phy.ops.read_i2c_eeprom(hw,  					     IXGBE_SFF_IDENTIFIER, -	                                     &identifier); +					     &identifier); -	if (status == IXGBE_ERR_SWFW_SYNC || -	    status == IXGBE_ERR_I2C || -	    status == IXGBE_ERR_SFP_NOT_PRESENT) +	if (status != 0)  		goto err_read_i2c_eeprom;  	/* LAN ID is needed for sfp_type determination */ @@ -872,26 +868,20 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)  						     IXGBE_SFF_1GBE_COMP_CODES,  						     &comp_codes_1g); -		if (status == IXGBE_ERR_SWFW_SYNC || -		    status == IXGBE_ERR_I2C || -		    status == IXGBE_ERR_SFP_NOT_PRESENT) +		if (status != 0)  			goto err_read_i2c_eeprom;  		status = hw->phy.ops.read_i2c_eeprom(hw,  						     IXGBE_SFF_10GBE_COMP_CODES,  						     &comp_codes_10g); -		if (status == IXGBE_ERR_SWFW_SYNC || -		    status == IXGBE_ERR_I2C || -		    status == IXGBE_ERR_SFP_NOT_PRESENT) +		if (status != 0)  			goto err_read_i2c_eeprom;  		status = hw->phy.ops.read_i2c_eeprom(hw,  						     IXGBE_SFF_CABLE_TECHNOLOGY,  						     &cable_tech); -		if (status == IXGBE_ERR_SWFW_SYNC || -		    status == IXGBE_ERR_I2C || -		    status == IXGBE_ERR_SFP_NOT_PRESENT) +		if (status != 0)  			goto err_read_i2c_eeprom;  		 /* ID Module @@ -986,30 +976,24 @@ s32 ixgbe_identify_sfp_module_generic(struct ixgbe_hw *hw)  		if (hw->phy.type != ixgbe_phy_nl) {  			hw->phy.id = identifier;  			status = hw->phy.ops.read_i2c_eeprom(hw, -			                            IXGBE_SFF_VENDOR_OUI_BYTE0, -			                            &oui_bytes[0]); +						    IXGBE_SFF_VENDOR_OUI_BYTE0, +						    &oui_bytes[0]); -			if (status == IXGBE_ERR_SWFW_SYNC || -			    status == IXGBE_ERR_I2C || -			    status == IXGBE_ERR_SFP_NOT_PRESENT) +			if (status != 0)  				goto err_read_i2c_eeprom;  			status = hw->phy.ops.read_i2c_eeprom(hw,  			                            IXGBE_SFF_VENDOR_OUI_BYTE1,  			                            &oui_bytes[1]); -			if (status == IXGBE_ERR_SWFW_SYNC || -			    status == IXGBE_ERR_I2C || -			    status == IXGBE_ERR_SFP_NOT_PRESENT) +			if (status != 0)  				goto err_read_i2c_eeprom;  			status = hw->phy.ops.read_i2c_eeprom(hw,  			                            IXGBE_SFF_VENDOR_OUI_BYTE2,  			                            &oui_bytes[2]); -			if (status == IXGBE_ERR_SWFW_SYNC || -			    status == IXGBE_ERR_I2C || -			    status == IXGBE_ERR_SFP_NOT_PRESENT) +			if (status != 0)  				goto err_read_i2c_eeprom;  			vendor_oui = @@ -1206,6 +1190,22 @@ s32 ixgbe_read_i2c_eeprom_generic(struct ixgbe_hw *hw, u8 byte_offset,  }  /** + *  ixgbe_read_i2c_sff8472_generic - Reads 8 bit word over I2C interface + *  @hw: pointer to hardware structure + *  @byte_offset: byte offset at address 0xA2 + *  @eeprom_data: value read + * + *  Performs byte read operation to SFP module's SFF-8472 data over I2C + **/ +s32 ixgbe_read_i2c_sff8472_generic(struct ixgbe_hw *hw, u8 byte_offset, +				   u8 *sff8472_data) +{ +	return hw->phy.ops.read_i2c_byte(hw, byte_offset, +					 IXGBE_I2C_EEPROM_DEV_ADDR2, +					 sff8472_data); +} + +/**   *  ixgbe_write_i2c_eeprom_generic - Writes 8 bit EEPROM word over I2C interface   *  @hw: pointer to hardware structure   *  @byte_offset: EEPROM byte offset to write @@ -1293,9 +1293,9 @@ s32 ixgbe_read_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset,  		break;  fail: +		ixgbe_i2c_bus_clear(hw);  		hw->mac.ops.release_swfw_sync(hw, swfw_mask);  		msleep(100); -		ixgbe_i2c_bus_clear(hw);  		retry++;  		if (retry < max_retry)  			hw_dbg(hw, "I2C byte read error - Retrying.\n"); diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.h index cc18165b4c0..886a3431cf5 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_phy.h @@ -1,7 +1,7 @@  /*******************************************************************************    Intel 10 Gigabit PCI Express Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -30,6 +30,7 @@  #include "ixgbe_type.h"  #define IXGBE_I2C_EEPROM_DEV_ADDR    0xA0 +#define IXGBE_I2C_EEPROM_DEV_ADDR2   0xA2  /* EEPROM byte offsets */  #define IXGBE_SFF_IDENTIFIER         0x0 @@ -41,6 +42,8 @@  #define IXGBE_SFF_10GBE_COMP_CODES   0x3  #define IXGBE_SFF_CABLE_TECHNOLOGY   0x8  #define IXGBE_SFF_CABLE_SPEC_COMP    0x3C +#define IXGBE_SFF_SFF_8472_SWAP      0x5C +#define IXGBE_SFF_SFF_8472_COMP      0x5E  /* Bitmasks */  #define IXGBE_SFF_DA_PASSIVE_CABLE           0x4 @@ -51,6 +54,7 @@  #define IXGBE_SFF_1GBASET_CAPABLE            0x8  #define IXGBE_SFF_10GBASESR_CAPABLE          0x10  #define IXGBE_SFF_10GBASELR_CAPABLE          0x20 +#define IXGBE_SFF_ADDRESSING_MODE	     0x4  #define IXGBE_I2C_EEPROM_READ_MASK           0x100  #define IXGBE_I2C_EEPROM_STATUS_MASK         0x3  #define IXGBE_I2C_EEPROM_STATUS_NO_OPERATION 0x0 @@ -88,6 +92,9 @@  #define IXGBE_TN_LASI_STATUS_REG        0x9005  #define IXGBE_TN_LASI_STATUS_TEMP_ALARM 0x0008 +/* SFP+ SFF-8472 Compliance code */ +#define IXGBE_SFF_SFF_8472_UNSUP      0x00 +  s32 ixgbe_init_phy_ops_generic(struct ixgbe_hw *hw);  s32 ixgbe_identify_phy_generic(struct ixgbe_hw *hw);  s32 ixgbe_reset_phy_generic(struct ixgbe_hw *hw); @@ -98,7 +105,6 @@ s32 ixgbe_write_phy_reg_generic(struct ixgbe_hw *hw, u32 reg_addr,  s32 ixgbe_setup_phy_link_generic(struct ixgbe_hw *hw);  s32 ixgbe_setup_phy_link_speed_generic(struct ixgbe_hw *hw,                                         ixgbe_link_speed speed, -                                       bool autoneg,                                         bool autoneg_wait_to_complete);  s32 ixgbe_get_copper_link_capabilities_generic(struct ixgbe_hw *hw,                                                 ixgbe_link_speed *speed, @@ -126,6 +132,8 @@ s32 ixgbe_write_i2c_byte_generic(struct ixgbe_hw *hw, u8 byte_offset,                                   u8 dev_addr, u8 data);  s32 ixgbe_read_i2c_eeprom_generic(struct ixgbe_hw *hw, u8 byte_offset,                                    u8 *eeprom_data); +s32 ixgbe_read_i2c_sff8472_generic(struct ixgbe_hw *hw, u8 byte_offset, +				   u8 *sff8472_data);  s32 ixgbe_write_i2c_eeprom_generic(struct ixgbe_hw *hw, u8 byte_offset,                                     u8 eeprom_data);  #endif /* _IXGBE_PHY_H_ */ diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c index 1a751c9d09c..331987d6815 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel 10 Gigabit PCI Express Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -96,15 +96,12 @@  #define IXGBE_MAX_TIMEADJ_VALUE  0x7FFFFFFFFFFFFFFFULL  #define IXGBE_OVERFLOW_PERIOD    (HZ * 30) +#define IXGBE_PTP_TX_TIMEOUT     (HZ * 15)  #ifndef NSECS_PER_SEC  #define NSECS_PER_SEC 1000000000ULL  #endif -static struct sock_filter ptp_filter[] = { -	PTP_FILTER -}; -  /**   * ixgbe_ptp_setup_sdp   * @hw: the hardware private structure @@ -405,149 +402,145 @@ void ixgbe_ptp_check_pps_event(struct ixgbe_adapter *adapter, u32 eicr)  	}  } -  /** - * ixgbe_ptp_overflow_check - delayed work to detect SYSTIME overflow - * @work: structure containing information about this work task + * ixgbe_ptp_overflow_check - watchdog task to detect SYSTIME overflow + * @adapter: private adapter struct   * - * this work function is scheduled to continue reading the timecounter + * this watchdog task periodically reads the timecounter   * in order to prevent missing when the system time registers wrap - * around. This needs to be run approximately twice a minute when no - * PTP activity is occurring. + * around. This needs to be run approximately twice a minute.   */  void ixgbe_ptp_overflow_check(struct ixgbe_adapter *adapter)  { -	unsigned long elapsed_jiffies = adapter->last_overflow_check - jiffies; +	bool timeout = time_is_before_jiffies(adapter->last_overflow_check + +					     IXGBE_OVERFLOW_PERIOD);  	struct timespec ts; -	if ((adapter->flags2 & IXGBE_FLAG2_PTP_ENABLED) && -	    (elapsed_jiffies >= IXGBE_OVERFLOW_PERIOD)) { +	if (timeout) {  		ixgbe_ptp_gettime(&adapter->ptp_caps, &ts);  		adapter->last_overflow_check = jiffies;  	}  }  /** - * ixgbe_ptp_match - determine if this skb matches a ptp packet - * @skb: pointer to the skb - * @hwtstamp: pointer to the hwtstamp_config to check - * - * Determine whether the skb should have been timestamped, assuming the - * hwtstamp was set via the hwtstamp ioctl. Returns non-zero when the packet - * should have a timestamp waiting in the registers, and 0 otherwise. + * ixgbe_ptp_rx_hang - detect error case when Rx timestamp registers latched + * @adapter: private network adapter structure   * - * V1 packets have to check the version type to determine whether they are - * correct. However, we can't directly access the data because it might be - * fragmented in the SKB, in paged memory. In order to work around this, we - * use skb_copy_bits which will properly copy the data whether it is in the - * paged memory fragments or not. We have to copy the IP header as well as the - * message type. + * this watchdog task is scheduled to detect error case where hardware has + * dropped an Rx packet that was timestamped when the ring is full. The + * particular error is rare but leaves the device in a state unable to timestamp + * any future packets.   */ -static int ixgbe_ptp_match(struct sk_buff *skb, int rx_filter) +void ixgbe_ptp_rx_hang(struct ixgbe_adapter *adapter)  { -	struct iphdr iph; -	u8 msgtype; -	unsigned int type, offset; - -	if (rx_filter == HWTSTAMP_FILTER_NONE) -		return 0; - -	type = sk_run_filter(skb, ptp_filter); - -	if (likely(rx_filter == HWTSTAMP_FILTER_PTP_V2_EVENT)) -		return type & PTP_CLASS_V2; +	struct ixgbe_hw *hw = &adapter->hw; +	struct ixgbe_ring *rx_ring; +	u32 tsyncrxctl = IXGBE_READ_REG(hw, IXGBE_TSYNCRXCTL); +	unsigned long rx_event; +	int n; -	/* For the remaining cases actually check message type */ -	switch (type) { -	case PTP_CLASS_V1_IPV4: -		skb_copy_bits(skb, OFF_IHL, &iph, sizeof(iph)); -		offset = ETH_HLEN + (iph.ihl << 2) + UDP_HLEN + OFF_PTP_CONTROL; -		break; -	case PTP_CLASS_V1_IPV6: -		offset = OFF_PTP6 + OFF_PTP_CONTROL; -		break; -	default: -		/* other cases invalid or handled above */ -		return 0; +	/* if we don't have a valid timestamp in the registers, just update the +	 * timeout counter and exit +	 */ +	if (!(tsyncrxctl & IXGBE_TSYNCRXCTL_VALID)) { +		adapter->last_rx_ptp_check = jiffies; +		return;  	} -	/* Make sure our buffer is long enough */ -	if (skb->len < offset) -		return 0; +	/* determine the most recent watchdog or rx_timestamp event */ +	rx_event = adapter->last_rx_ptp_check; +	for (n = 0; n < adapter->num_rx_queues; n++) { +		rx_ring = adapter->rx_ring[n]; +		if (time_after(rx_ring->last_rx_timestamp, rx_event)) +			rx_event = rx_ring->last_rx_timestamp; +	} -	skb_copy_bits(skb, offset, &msgtype, sizeof(msgtype)); +	/* only need to read the high RXSTMP register to clear the lock */ +	if (time_is_before_jiffies(rx_event + 5*HZ)) { +		IXGBE_READ_REG(hw, IXGBE_RXSTMPH); +		adapter->last_rx_ptp_check = jiffies; -	switch (rx_filter) { -	case HWTSTAMP_FILTER_PTP_V1_L4_SYNC: -		return (msgtype == IXGBE_RXMTRL_V1_SYNC_MSG); -		break; -	case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ: -		return (msgtype == IXGBE_RXMTRL_V1_DELAY_REQ_MSG); -		break; -	default: -		return 0; +		e_warn(drv, "clearing RX Timestamp hang");  	}  }  /**   * ixgbe_ptp_tx_hwtstamp - utility function which checks for TX time stamp - * @q_vector: structure containing interrupt and ring information - * @skb: particular skb to send timestamp with + * @adapter: the private adapter struct   *   * if the timestamp is valid, we convert it into the timecounter ns   * value, then store that result into the shhwtstamps structure which   * is passed up the network stack   */ -void ixgbe_ptp_tx_hwtstamp(struct ixgbe_q_vector *q_vector, -			   struct sk_buff *skb) +static void ixgbe_ptp_tx_hwtstamp(struct ixgbe_adapter *adapter)  { -	struct ixgbe_adapter *adapter; -	struct ixgbe_hw *hw; +	struct ixgbe_hw *hw = &adapter->hw;  	struct skb_shared_hwtstamps shhwtstamps;  	u64 regval = 0, ns; -	u32 tsynctxctl;  	unsigned long flags; -	/* we cannot process timestamps on a ring without a q_vector */ -	if (!q_vector || !q_vector->adapter) -		return; - -	adapter = q_vector->adapter; -	hw = &adapter->hw; - -	tsynctxctl = IXGBE_READ_REG(hw, IXGBE_TSYNCTXCTL);  	regval |= (u64)IXGBE_READ_REG(hw, IXGBE_TXSTMPL);  	regval |= (u64)IXGBE_READ_REG(hw, IXGBE_TXSTMPH) << 32; -	/* -	 * if TX timestamp is not valid, exit after clearing the -	 * timestamp registers -	 */ -	if (!(tsynctxctl & IXGBE_TSYNCTXCTL_VALID)) -		return; -  	spin_lock_irqsave(&adapter->tmreg_lock, flags);  	ns = timecounter_cyc2time(&adapter->tc, regval);  	spin_unlock_irqrestore(&adapter->tmreg_lock, flags);  	memset(&shhwtstamps, 0, sizeof(shhwtstamps));  	shhwtstamps.hwtstamp = ns_to_ktime(ns); -	skb_tstamp_tx(skb, &shhwtstamps); +	skb_tstamp_tx(adapter->ptp_tx_skb, &shhwtstamps); + +	dev_kfree_skb_any(adapter->ptp_tx_skb); +	adapter->ptp_tx_skb = NULL; +} + +/** + * ixgbe_ptp_tx_hwtstamp_work + * @work: pointer to the work struct + * + * This work item polls TSYNCTXCTL valid bit to determine when a Tx hardware + * timestamp has been taken for the current skb. It is necesary, because the + * descriptor's "done" bit does not correlate with the timestamp event. + */ +static void ixgbe_ptp_tx_hwtstamp_work(struct work_struct *work) +{ +	struct ixgbe_adapter *adapter = container_of(work, struct ixgbe_adapter, +						     ptp_tx_work); +	struct ixgbe_hw *hw = &adapter->hw; +	bool timeout = time_is_before_jiffies(adapter->ptp_tx_start + +					      IXGBE_PTP_TX_TIMEOUT); +	u32 tsynctxctl; + +	/* we have to have a valid skb */ +	if (!adapter->ptp_tx_skb) +		return; + +	if (timeout) { +		dev_kfree_skb_any(adapter->ptp_tx_skb); +		adapter->ptp_tx_skb = NULL; +		e_warn(drv, "clearing Tx Timestamp hang"); +		return; +	} + +	tsynctxctl = IXGBE_READ_REG(hw, IXGBE_TSYNCTXCTL); +	if (tsynctxctl & IXGBE_TSYNCTXCTL_VALID) +		ixgbe_ptp_tx_hwtstamp(adapter); +	else +		/* reschedule to keep checking if it's not available yet */ +		schedule_work(&adapter->ptp_tx_work);  }  /** - * ixgbe_ptp_rx_hwtstamp - utility function which checks for RX time stamp + * __ixgbe_ptp_rx_hwtstamp - utility function which checks for RX time stamp   * @q_vector: structure containing interrupt and ring information - * @rx_desc: the rx descriptor   * @skb: particular skb to send timestamp with   *   * if the timestamp is valid, we convert it into the timecounter ns   * value, then store that result into the shhwtstamps structure which   * is passed up the network stack   */ -void ixgbe_ptp_rx_hwtstamp(struct ixgbe_q_vector *q_vector, -			   union ixgbe_adv_rx_desc *rx_desc, -			   struct sk_buff *skb) +void __ixgbe_ptp_rx_hwtstamp(struct ixgbe_q_vector *q_vector, +			     struct sk_buff *skb)  {  	struct ixgbe_adapter *adapter;  	struct ixgbe_hw *hw; @@ -563,37 +556,17 @@ void ixgbe_ptp_rx_hwtstamp(struct ixgbe_q_vector *q_vector,  	adapter = q_vector->adapter;  	hw = &adapter->hw; -	if (likely(!ixgbe_ptp_match(skb, adapter->rx_hwtstamp_filter))) -		return; - +	/* +	 * Read the tsyncrxctl register afterwards in order to prevent taking an +	 * I/O hit on every packet. +	 */  	tsyncrxctl = IXGBE_READ_REG(hw, IXGBE_TSYNCRXCTL); - -	/* Check if we have a valid timestamp and make sure the skb should -	 * have been timestamped */  	if (!(tsyncrxctl & IXGBE_TSYNCRXCTL_VALID))  		return; -	/* -	 * Always read the registers, in order to clear a possible fault -	 * because of stagnant RX timestamp values for a packet that never -	 * reached the queue. -	 */  	regval |= (u64)IXGBE_READ_REG(hw, IXGBE_RXSTMPL);  	regval |= (u64)IXGBE_READ_REG(hw, IXGBE_RXSTMPH) << 32; -	/* -	 * If the timestamp bit is set in the packet's descriptor, we know the -	 * timestamp belongs to this packet. No other packet can be -	 * timestamped until the registers for timestamping have been read. -	 * Therefor only one packet with this bit can be in the queue at a -	 * time, and the rx timestamp values that were in the registers belong -	 * to this packet. -	 * -	 * If nothing went wrong, then it should have a skb_shared_tx that we -	 * can turn into a skb_shared_hwtstamps. -	 */ -	if (unlikely(!ixgbe_test_staterr(rx_desc, IXGBE_RXDADV_STAT_TS))) -		return;  	spin_lock_irqsave(&adapter->tmreg_lock, flags);  	ns = timecounter_cyc2time(&adapter->tc, regval); @@ -660,11 +633,11 @@ int ixgbe_ptp_hwtstamp_ioctl(struct ixgbe_adapter *adapter,  		break;  	case HWTSTAMP_FILTER_PTP_V1_L4_SYNC:  		tsync_rx_ctl |= IXGBE_TSYNCRXCTL_TYPE_L4_V1; -		tsync_rx_mtrl = IXGBE_RXMTRL_V1_SYNC_MSG; +		tsync_rx_mtrl |= IXGBE_RXMTRL_V1_SYNC_MSG;  		break;  	case HWTSTAMP_FILTER_PTP_V1_L4_DELAY_REQ:  		tsync_rx_ctl |= IXGBE_TSYNCRXCTL_TYPE_L4_V1; -		tsync_rx_mtrl = IXGBE_RXMTRL_V1_DELAY_REQ_MSG; +		tsync_rx_mtrl |= IXGBE_RXMTRL_V1_DELAY_REQ_MSG;  		break;  	case HWTSTAMP_FILTER_PTP_V2_EVENT:  	case HWTSTAMP_FILTER_PTP_V2_L2_EVENT: @@ -698,9 +671,6 @@ int ixgbe_ptp_hwtstamp_ioctl(struct ixgbe_adapter *adapter,  		return 0;  	} -	/* Store filter value for later use */ -	adapter->rx_hwtstamp_filter = config.rx_filter; -  	/* define ethertype filter for timestamping L2 packets */  	if (is_l2)  		IXGBE_WRITE_REG(hw, IXGBE_ETQF(IXGBE_ETQF_FILTER_1588), @@ -902,11 +872,8 @@ void ixgbe_ptp_init(struct ixgbe_adapter *adapter)  		return;  	} -	/* initialize the ptp filter */ -	if (ptp_filter_init(ptp_filter, ARRAY_SIZE(ptp_filter))) -		e_dev_warn("ptp_filter_init failed\n"); -  	spin_lock_init(&adapter->tmreg_lock); +	INIT_WORK(&adapter->ptp_tx_work, ixgbe_ptp_tx_hwtstamp_work);  	adapter->ptp_clock = ptp_clock_register(&adapter->ptp_caps,  						&adapter->pdev->dev); @@ -938,6 +905,12 @@ void ixgbe_ptp_stop(struct ixgbe_adapter *adapter)  	ixgbe_ptp_setup_sdp(adapter); +	cancel_work_sync(&adapter->ptp_tx_work); +	if (adapter->ptp_tx_skb) { +		dev_kfree_skb_any(adapter->ptp_tx_skb); +		adapter->ptp_tx_skb = NULL; +	} +  	if (adapter->ptp_clock) {  		ptp_clock_unregister(adapter->ptp_clock);  		adapter->ptp_clock = NULL; diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c index 85cddac673e..d44b4d21268 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel 10 Gigabit PCI Express Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -44,50 +44,11 @@  #include "ixgbe_sriov.h"  #ifdef CONFIG_PCI_IOV -void ixgbe_enable_sriov(struct ixgbe_adapter *adapter, -			 const struct ixgbe_info *ii) +static int __ixgbe_enable_sriov(struct ixgbe_adapter *adapter)  {  	struct ixgbe_hw *hw = &adapter->hw;  	int num_vf_macvlans, i;  	struct vf_macvlans *mv_list; -	int pre_existing_vfs = 0; - -	pre_existing_vfs = pci_num_vf(adapter->pdev); -	if (!pre_existing_vfs && !adapter->num_vfs) -		return; - -	/* If there are pre-existing VFs then we have to force -	 * use of that many because they were not deleted the last -	 * time someone removed the PF driver.  That would have -	 * been because they were allocated to guest VMs and can't -	 * be removed.  Go ahead and just re-enable the old amount. -	 * If the user wants to change the number of VFs they can -	 * use ethtool while making sure no VFs are allocated to -	 * guest VMs... i.e. the right way. -	 */ -	if (pre_existing_vfs) { -		adapter->num_vfs = pre_existing_vfs; -		dev_warn(&adapter->pdev->dev, "Virtual Functions already " -			 "enabled for this device - Please reload all " -			 "VF drivers to avoid spoofed packet errors\n"); -	} else { -		int err; -		/* -		 * The 82599 supports up to 64 VFs per physical function -		 * but this implementation limits allocation to 63 so that -		 * basic networking resources are still available to the -		 * physical function.  If the user requests greater thn -		 * 63 VFs then it is an error - reset to default of zero. -		 */ -		adapter->num_vfs = min_t(unsigned int, adapter->num_vfs, 63); - -		err = pci_enable_sriov(adapter->pdev, adapter->num_vfs); -		if (err) { -			e_err(probe, "Failed to enable PCI sriov: %d\n", err); -			adapter->num_vfs = 0; -			return; -		} -	}  	adapter->flags |= IXGBE_FLAG_SRIOV_ENABLED;  	e_info(probe, "SR-IOV enabled with %d VFs\n", adapter->num_vfs); @@ -128,12 +89,6 @@ void ixgbe_enable_sriov(struct ixgbe_adapter *adapter,  		kcalloc(adapter->num_vfs,  			sizeof(struct vf_data_storage), GFP_KERNEL);  	if (adapter->vfinfo) { -		/* Now that we're sure SR-IOV is enabled -		 * and memory allocated set up the mailbox parameters -		 */ -		ixgbe_init_mbx_params_pf(hw); -		memcpy(&hw->mbx.ops, ii->mbx_ops, sizeof(hw->mbx.ops)); -  		/* limit trafffic classes based on VFs enabled */  		if ((adapter->hw.mac.type == ixgbe_mac_82599EB) &&  		    (adapter->num_vfs < 16)) { @@ -157,10 +112,62 @@ void ixgbe_enable_sriov(struct ixgbe_adapter *adapter,  		/* enable spoof checking for all VFs */  		for (i = 0; i < adapter->num_vfs; i++)  			adapter->vfinfo[i].spoofchk_enabled = true; +		return 0; +	} + +	return -ENOMEM; +} + +/* Note this function is called when the user wants to enable SR-IOV + * VFs using the now deprecated module parameter + */ +void ixgbe_enable_sriov(struct ixgbe_adapter *adapter) +{ +	int pre_existing_vfs = 0; + +	pre_existing_vfs = pci_num_vf(adapter->pdev); +	if (!pre_existing_vfs && !adapter->num_vfs)  		return; + +	if (!pre_existing_vfs) +		dev_warn(&adapter->pdev->dev, +			 "Enabling SR-IOV VFs using the module parameter is deprecated - please use the pci sysfs interface.\n"); + +	/* If there are pre-existing VFs then we have to force +	 * use of that many - over ride any module parameter value. +	 * This may result from the user unloading the PF driver +	 * while VFs were assigned to guest VMs or because the VFs +	 * have been created via the new PCI SR-IOV sysfs interface. +	 */ +	if (pre_existing_vfs) { +		adapter->num_vfs = pre_existing_vfs; +		dev_warn(&adapter->pdev->dev, +			 "Virtual Functions already enabled for this device - Please reload all VF drivers to avoid spoofed packet errors\n"); +	} else { +		int err; +		/* +		 * The 82599 supports up to 64 VFs per physical function +		 * but this implementation limits allocation to 63 so that +		 * basic networking resources are still available to the +		 * physical function.  If the user requests greater thn +		 * 63 VFs then it is an error - reset to default of zero. +		 */ +		adapter->num_vfs = min_t(unsigned int, adapter->num_vfs, 63); + +		err = pci_enable_sriov(adapter->pdev, adapter->num_vfs); +		if (err) { +			e_err(probe, "Failed to enable PCI sriov: %d\n", err); +			adapter->num_vfs = 0; +			return; +		}  	} -	/* Oh oh */ +	if (!__ixgbe_enable_sriov(adapter)) +		return; + +	/* If we have gotten to this point then there is no memory available +	 * to manage the VF devices - print message and bail. +	 */  	e_err(probe, "Unable to allocate memory for VF Data Storage - "  	      "SRIOV disabled\n");  	ixgbe_disable_sriov(adapter); @@ -200,11 +207,12 @@ static bool ixgbe_vfs_are_assigned(struct ixgbe_adapter *adapter)  }  #endif /* #ifdef CONFIG_PCI_IOV */ -void ixgbe_disable_sriov(struct ixgbe_adapter *adapter) +int ixgbe_disable_sriov(struct ixgbe_adapter *adapter)  {  	struct ixgbe_hw *hw = &adapter->hw;  	u32 gpie;  	u32 vmdctl; +	int rss;  	/* set num VFs to 0 to prevent access to vfinfo */  	adapter->num_vfs = 0; @@ -219,7 +227,7 @@ void ixgbe_disable_sriov(struct ixgbe_adapter *adapter)  	/* if SR-IOV is already disabled then there is nothing to do */  	if (!(adapter->flags & IXGBE_FLAG_SRIOV_ENABLED)) -		return; +		return 0;  #ifdef CONFIG_PCI_IOV  	/* @@ -229,7 +237,7 @@ void ixgbe_disable_sriov(struct ixgbe_adapter *adapter)  	 */  	if (ixgbe_vfs_are_assigned(adapter)) {  		e_dev_warn("Unloading driver while VFs are assigned - VFs will not be deallocated\n"); -		return; +		return -EPERM;  	}  	/* disable iov and allow time for transactions to clear */  	pci_disable_sriov(adapter->pdev); @@ -252,10 +260,94 @@ void ixgbe_disable_sriov(struct ixgbe_adapter *adapter)  		adapter->flags &= ~IXGBE_FLAG_VMDQ_ENABLED;  	adapter->ring_feature[RING_F_VMDQ].offset = 0; +	rss = min_t(int, IXGBE_MAX_RSS_INDICES, num_online_cpus()); +	adapter->ring_feature[RING_F_RSS].limit = rss; +  	/* take a breather then clean up driver data */  	msleep(100);  	adapter->flags &= ~IXGBE_FLAG_SRIOV_ENABLED; +	return 0; +} + +static int ixgbe_pci_sriov_enable(struct pci_dev *dev, int num_vfs) +{ +#ifdef CONFIG_PCI_IOV +	struct ixgbe_adapter *adapter = pci_get_drvdata(dev); +	int err = 0; +	int i; +	int pre_existing_vfs = pci_num_vf(dev); + +	if (pre_existing_vfs && pre_existing_vfs != num_vfs) +		err = ixgbe_disable_sriov(adapter); +	else if (pre_existing_vfs && pre_existing_vfs == num_vfs) +		goto out; + +	if (err) +		goto err_out; + +	/* While the SR-IOV capability structure reports total VFs to be +	 * 64 we limit the actual number that can be allocated to 63 so +	 * that some transmit/receive resources can be reserved to the +	 * PF.  The PCI bus driver already checks for other values out of +	 * range. +	 */ +	if (num_vfs > 63) { +		err = -EPERM; +		goto err_out; +	} + +	adapter->num_vfs = num_vfs; + +	err = __ixgbe_enable_sriov(adapter); +	if (err) +		goto err_out; + +	for (i = 0; i < adapter->num_vfs; i++) +		ixgbe_vf_configuration(dev, (i | 0x10000000)); + +	err = pci_enable_sriov(dev, num_vfs); +	if (err) { +		e_dev_warn("Failed to enable PCI sriov: %d\n", err); +		goto err_out; +	} +	ixgbe_sriov_reinit(adapter); + +out: +	return num_vfs; + +err_out: +	return err; +#endif +	return 0; +} + +static int ixgbe_pci_sriov_disable(struct pci_dev *dev) +{ +	struct ixgbe_adapter *adapter = pci_get_drvdata(dev); +	int err; +	u32 current_flags = adapter->flags; + +	err = ixgbe_disable_sriov(adapter); + +	/* Only reinit if no error and state changed */ +	if (!err && current_flags != adapter->flags) { +		/* ixgbe_disable_sriov() doesn't clear VMDQ flag */ +		adapter->flags &= ~IXGBE_FLAG_VMDQ_ENABLED; +#ifdef CONFIG_PCI_IOV +		ixgbe_sriov_reinit(adapter); +#endif +	} + +	return err; +} + +int ixgbe_pci_sriov_configure(struct pci_dev *dev, int num_vfs) +{ +	if (num_vfs == 0) +		return ixgbe_pci_sriov_disable(dev); +	else +		return ixgbe_pci_sriov_enable(dev, num_vfs);  }  static int ixgbe_set_vf_multicasts(struct ixgbe_adapter *adapter, @@ -447,15 +539,6 @@ static void ixgbe_set_vmolr(struct ixgbe_hw *hw, u32 vf, bool aupe)  	IXGBE_WRITE_REG(hw, IXGBE_VMOLR(vf), vmolr);  } -static void ixgbe_set_vmvir(struct ixgbe_adapter *adapter, -			    u16 vid, u16 qos, u32 vf) -{ -	struct ixgbe_hw *hw = &adapter->hw; -	u32 vmvir = vid | (qos << VLAN_PRIO_SHIFT) | IXGBE_VMVIR_VLANA_DEFAULT; - -	IXGBE_WRITE_REG(hw, IXGBE_VMVIR(vf), vmvir); -} -  static void ixgbe_clear_vmvir(struct ixgbe_adapter *adapter, u32 vf)  {  	struct ixgbe_hw *hw = &adapter->hw; diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.h index 1be1d30e4e7..4713f9fc7f4 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_sriov.h @@ -1,7 +1,7 @@  /*******************************************************************************    Intel 10 Gigabit PCI Express Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -41,12 +41,20 @@ int ixgbe_ndo_set_vf_spoofchk(struct net_device *netdev, int vf, bool setting);  int ixgbe_ndo_get_vf_config(struct net_device *netdev,  			    int vf, struct ifla_vf_info *ivi);  void ixgbe_check_vf_rate_limit(struct ixgbe_adapter *adapter); -void ixgbe_disable_sriov(struct ixgbe_adapter *adapter); +int ixgbe_disable_sriov(struct ixgbe_adapter *adapter);  #ifdef CONFIG_PCI_IOV -void ixgbe_enable_sriov(struct ixgbe_adapter *adapter, -			const struct ixgbe_info *ii); +void ixgbe_enable_sriov(struct ixgbe_adapter *adapter);  #endif +int ixgbe_pci_sriov_configure(struct pci_dev *dev, int num_vfs); +static inline void ixgbe_set_vmvir(struct ixgbe_adapter *adapter, +				   u16 vid, u16 qos, u32 vf) +{ +	struct ixgbe_hw *hw = &adapter->hw; +	u32 vmvir = vid | (qos << VLAN_PRIO_SHIFT) | IXGBE_VMVIR_VLANA_DEFAULT; + +	IXGBE_WRITE_REG(hw, IXGBE_VMVIR(vf), vmvir); +}  #endif /* _IXGBE_SRIOV_H_ */ diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c index 16ddf14e8ba..d118def16f3 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_sysfs.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel 10 Gigabit PCI Express Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h index 9cd8a13711d..6652e96c352 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_type.h @@ -1,7 +1,7 @@  /*******************************************************************************    Intel 10 Gigabit PCI Express Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -2822,7 +2822,7 @@ struct ixgbe_mac_operations {  	void (*disable_tx_laser)(struct ixgbe_hw *);  	void (*enable_tx_laser)(struct ixgbe_hw *);  	void (*flap_tx_laser)(struct ixgbe_hw *); -	s32 (*setup_link)(struct ixgbe_hw *, ixgbe_link_speed, bool, bool); +	s32 (*setup_link)(struct ixgbe_hw *, ixgbe_link_speed, bool);  	s32 (*check_link)(struct ixgbe_hw *, ixgbe_link_speed *, bool *, bool);  	s32 (*get_link_capabilities)(struct ixgbe_hw *, ixgbe_link_speed *,  	                             bool *); @@ -2869,12 +2869,12 @@ struct ixgbe_phy_operations {  	s32 (*read_reg)(struct ixgbe_hw *, u32, u32, u16 *);  	s32 (*write_reg)(struct ixgbe_hw *, u32, u32, u16);  	s32 (*setup_link)(struct ixgbe_hw *); -	s32 (*setup_link_speed)(struct ixgbe_hw *, ixgbe_link_speed, bool, -	                        bool); +	s32 (*setup_link_speed)(struct ixgbe_hw *, ixgbe_link_speed, bool);  	s32 (*check_link)(struct ixgbe_hw *, ixgbe_link_speed *, bool *);  	s32 (*get_firmware_version)(struct ixgbe_hw *, u16 *);  	s32 (*read_i2c_byte)(struct ixgbe_hw *, u8, u8, u8 *);  	s32 (*write_i2c_byte)(struct ixgbe_hw *, u8, u8, u8); +	s32 (*read_i2c_sff8472)(struct ixgbe_hw *, u8 , u8 *);  	s32 (*read_i2c_eeprom)(struct ixgbe_hw *, u8 , u8 *);  	s32 (*write_i2c_eeprom)(struct ixgbe_hw *, u8, u8);  	s32 (*check_overtemp)(struct ixgbe_hw *); diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c index c73b9299339..66c5e946284 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_x540.c @@ -1,7 +1,7 @@  /*******************************************************************************    Intel 10 Gigabit PCI Express Linux driver -  Copyright(c) 1999 - 2012 Intel Corporation. +  Copyright(c) 1999 - 2013 Intel Corporation.    This program is free software; you can redistribute it and/or modify it    under the terms and conditions of the GNU General Public License, @@ -72,14 +72,13 @@ static s32 ixgbe_get_invariants_X540(struct ixgbe_hw *hw)   *  ixgbe_setup_mac_link_X540 - Set the auto advertised capabilitires   *  @hw: pointer to hardware structure   *  @speed: new link speed - *  @autoneg: true if autonegotiation enabled   *  @autoneg_wait_to_complete: true when waiting for completion is needed   **/  static s32 ixgbe_setup_mac_link_X540(struct ixgbe_hw *hw, -                                     ixgbe_link_speed speed, bool autoneg, -                                     bool autoneg_wait_to_complete) +				     ixgbe_link_speed speed, +				     bool autoneg_wait_to_complete)  { -	return hw->phy.ops.setup_link_speed(hw, speed, autoneg, +	return hw->phy.ops.setup_link_speed(hw, speed,  	                                    autoneg_wait_to_complete);  } @@ -879,6 +878,7 @@ static struct ixgbe_phy_operations phy_ops_X540 = {  	.setup_link_speed       = &ixgbe_setup_phy_link_speed_generic,  	.read_i2c_byte          = &ixgbe_read_i2c_byte_generic,  	.write_i2c_byte         = &ixgbe_write_i2c_byte_generic, +	.read_i2c_sff8472	= &ixgbe_read_i2c_sff8472_generic,  	.read_i2c_eeprom        = &ixgbe_read_i2c_eeprom_generic,  	.write_i2c_eeprom       = &ixgbe_write_i2c_eeprom_generic,  	.check_overtemp         = &ixgbe_tn_check_overtemp, diff --git a/drivers/net/ethernet/intel/ixgbevf/ethtool.c b/drivers/net/ethernet/intel/ixgbevf/ethtool.c index 8f2070439b5..c9d0c12d6f0 100644 --- a/drivers/net/ethernet/intel/ixgbevf/ethtool.c +++ b/drivers/net/ethernet/intel/ixgbevf/ethtool.c @@ -99,6 +99,7 @@ static int ixgbevf_get_settings(struct net_device *netdev,  	ecmd->transceiver = XCVR_DUMMY1;  	ecmd->port = -1; +	hw->mac.get_link_status = 1;  	hw->mac.ops.check_link(hw, &link_speed, &link_up, false);  	if (link_up) { diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c index 257357ae66c..c3db6cd69b6 100644 --- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c +++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c @@ -750,12 +750,37 @@ static void ixgbevf_set_itr(struct ixgbevf_q_vector *q_vector)  static irqreturn_t ixgbevf_msix_other(int irq, void *data)  {  	struct ixgbevf_adapter *adapter = data; +	struct pci_dev *pdev = adapter->pdev;  	struct ixgbe_hw *hw = &adapter->hw; +	u32 msg; +	bool got_ack = false;  	hw->mac.get_link_status = 1; +	if (!hw->mbx.ops.check_for_ack(hw)) +		got_ack = true; -	if (!test_bit(__IXGBEVF_DOWN, &adapter->state)) -		mod_timer(&adapter->watchdog_timer, jiffies); +	if (!hw->mbx.ops.check_for_msg(hw)) { +		hw->mbx.ops.read(hw, &msg, 1); + +		if ((msg & IXGBE_MBVFICR_VFREQ_MASK) == IXGBE_PF_CONTROL_MSG) { +			mod_timer(&adapter->watchdog_timer, +				  round_jiffies(jiffies + 1)); +			adapter->link_up = false; +		} + +		if (msg & IXGBE_VT_MSGTYPE_NACK) +			dev_info(&pdev->dev, +				 "Last Request of type %2.2x to PF Nacked\n", +				 msg & 0xFF); +		hw->mbx.v2p_mailbox |= IXGBE_VFMAILBOX_PFSTS; +	} + +	/* checking for the ack clears the PFACK bit.  Place +	 * it back in the v2p_mailbox cache so that anyone +	 * polling for an ack will not miss it +	 */ +	if (got_ack) +		hw->mbx.v2p_mailbox |= IXGBE_VFMAILBOX_PFACK;  	IXGBE_WRITE_REG(hw, IXGBE_VTEIMS, adapter->eims_other); @@ -2095,6 +2120,9 @@ void ixgbevf_update_stats(struct ixgbevf_adapter *adapter)  	struct ixgbe_hw *hw = &adapter->hw;  	int i; +	if (!adapter->link_up) +		return; +  	UPDATE_VF_COUNTER_32bit(IXGBE_VFGPRC, adapter->stats.last_vfgprc,  				adapter->stats.vfgprc);  	UPDATE_VF_COUNTER_32bit(IXGBE_VFGPTC, adapter->stats.last_vfgptc, @@ -2217,9 +2245,23 @@ static void ixgbevf_watchdog_task(struct work_struct *work)  	if (link_up) {  		if (!netif_carrier_ok(netdev)) { -			hw_dbg(&adapter->hw, "NIC Link is Up, %u Gbps\n", -			       (link_speed == IXGBE_LINK_SPEED_10GB_FULL) ? -			       10 : 1); +			char *link_speed_string; +			switch (link_speed) { +			case IXGBE_LINK_SPEED_10GB_FULL: +				link_speed_string = "10 Gbps"; +				break; +			case IXGBE_LINK_SPEED_1GB_FULL: +				link_speed_string = "1 Gbps"; +				break; +			case IXGBE_LINK_SPEED_100_FULL: +				link_speed_string = "100 Mbps"; +				break; +			default: +				link_speed_string = "unknown speed"; +				break; +			} +			dev_info(&adapter->pdev->dev, +				"NIC Link is Up, %s\n", link_speed_string);  			netif_carrier_on(netdev);  			netif_tx_wake_all_queues(netdev);  		} @@ -2227,7 +2269,7 @@ static void ixgbevf_watchdog_task(struct work_struct *work)  		adapter->link_up = false;  		adapter->link_speed = 0;  		if (netif_carrier_ok(netdev)) { -			hw_dbg(&adapter->hw, "NIC Link is Down\n"); +			dev_info(&adapter->pdev->dev, "NIC Link is Down\n");  			netif_carrier_off(netdev);  			netif_tx_stop_all_queues(netdev);  		} @@ -3328,8 +3370,6 @@ static int ixgbevf_probe(struct pci_dev *pdev, const struct pci_device_id *ent)  		goto err_sw_init;  	/* The HW MAC address was set and/or determined in sw_init */ -	memcpy(netdev->perm_addr, adapter->hw.mac.addr, netdev->addr_len); -  	if (!is_valid_ether_addr(netdev->dev_addr)) {  		pr_err("invalid MAC address\n");  		err = -EIO;  |