Skip to content

Commit 3943849

Browse files
author
Jakub Kicinski
committed
Merge branch '1GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next-queue
Jeff Kirsher says: ==================== 1GbE Intel Wired LAN Driver Updates 2019-10-21 This series contains updates to e1000e and igc only. Sasha adds stream control transmission protocol (SCTP) CRC checksum support for igc. Also added S0ix support to the e1000e driver. Then added multicast support by adding the address list to the MTA table and providing the option for IPv6 address for igc. In addition, added receive checksum support to igc as well. Lastly, cleaned up some code that was not fully implemented yet for the VLAN filter table array. v2: Dropped patch 1 & 2 from the original series. Patch 1 is being sent to 'net' tree as a fix and patch 2 implementation needs to be re-worked. Updated the patch to add support for S0ix to fix the reverse Xmas tree issues and made the entry/exit functions void since they constantly returned success. All based on community feedback. v3: Cleaned up patch 4 of the series based on feedback from the community. Cleaned up a stray comma in a code comment and removed the 'inline' of a function that would be inlined by the compiler anyways. ==================== Signed-off-by: Jakub Kicinski <[email protected]>
2 parents 985fd98 + 7033257 commit 3943849

File tree

8 files changed

+525
-3
lines changed

8 files changed

+525
-3
lines changed

drivers/net/ethernet/intel/e1000e/netdev.c

Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6294,6 +6294,174 @@ static void e1000e_flush_lpic(struct pci_dev *pdev)
62946294
pm_runtime_put_sync(netdev->dev.parent);
62956295
}
62966296

6297+
/* S0ix implementation */
6298+
static void e1000e_s0ix_entry_flow(struct e1000_adapter *adapter)
6299+
{
6300+
struct e1000_hw *hw = &adapter->hw;
6301+
u32 mac_data;
6302+
u16 phy_data;
6303+
6304+
/* Disable the periodic inband message,
6305+
* don't request PCIe clock in K1 page770_17[10:9] = 10b
6306+
*/
6307+
e1e_rphy(hw, HV_PM_CTRL, &phy_data);
6308+
phy_data &= ~HV_PM_CTRL_K1_CLK_REQ;
6309+
phy_data |= BIT(10);
6310+
e1e_wphy(hw, HV_PM_CTRL, phy_data);
6311+
6312+
/* Make sure we don't exit K1 every time a new packet arrives
6313+
* 772_29[5] = 1 CS_Mode_Stay_In_K1
6314+
*/
6315+
e1e_rphy(hw, I217_CGFREG, &phy_data);
6316+
phy_data |= BIT(5);
6317+
e1e_wphy(hw, I217_CGFREG, phy_data);
6318+
6319+
/* Change the MAC/PHY interface to SMBus
6320+
* Force the SMBus in PHY page769_23[0] = 1
6321+
* Force the SMBus in MAC CTRL_EXT[11] = 1
6322+
*/
6323+
e1e_rphy(hw, CV_SMB_CTRL, &phy_data);
6324+
phy_data |= CV_SMB_CTRL_FORCE_SMBUS;
6325+
e1e_wphy(hw, CV_SMB_CTRL, phy_data);
6326+
mac_data = er32(CTRL_EXT);
6327+
mac_data |= E1000_CTRL_EXT_FORCE_SMBUS;
6328+
ew32(CTRL_EXT, mac_data);
6329+
6330+
/* DFT control: PHY bit: page769_20[0] = 1
6331+
* Gate PPW via EXTCNF_CTRL - set 0x0F00[7] = 1
6332+
*/
6333+
e1e_rphy(hw, I82579_DFT_CTRL, &phy_data);
6334+
phy_data |= BIT(0);
6335+
e1e_wphy(hw, I82579_DFT_CTRL, phy_data);
6336+
6337+
mac_data = er32(EXTCNF_CTRL);
6338+
mac_data |= E1000_EXTCNF_CTRL_GATE_PHY_CFG;
6339+
ew32(EXTCNF_CTRL, mac_data);
6340+
6341+
/* Check MAC Tx/Rx packet buffer pointers.
6342+
* Reset MAC Tx/Rx packet buffer pointers to suppress any
6343+
* pending traffic indication that would prevent power gating.
6344+
*/
6345+
mac_data = er32(TDFH);
6346+
if (mac_data)
6347+
ew32(TDFH, 0);
6348+
mac_data = er32(TDFT);
6349+
if (mac_data)
6350+
ew32(TDFT, 0);
6351+
mac_data = er32(TDFHS);
6352+
if (mac_data)
6353+
ew32(TDFHS, 0);
6354+
mac_data = er32(TDFTS);
6355+
if (mac_data)
6356+
ew32(TDFTS, 0);
6357+
mac_data = er32(TDFPC);
6358+
if (mac_data)
6359+
ew32(TDFPC, 0);
6360+
mac_data = er32(RDFH);
6361+
if (mac_data)
6362+
ew32(RDFH, 0);
6363+
mac_data = er32(RDFT);
6364+
if (mac_data)
6365+
ew32(RDFT, 0);
6366+
mac_data = er32(RDFHS);
6367+
if (mac_data)
6368+
ew32(RDFHS, 0);
6369+
mac_data = er32(RDFTS);
6370+
if (mac_data)
6371+
ew32(RDFTS, 0);
6372+
mac_data = er32(RDFPC);
6373+
if (mac_data)
6374+
ew32(RDFPC, 0);
6375+
6376+
/* Enable the Dynamic Power Gating in the MAC */
6377+
mac_data = er32(FEXTNVM7);
6378+
mac_data |= BIT(22);
6379+
ew32(FEXTNVM7, mac_data);
6380+
6381+
/* Disable the time synchronization clock */
6382+
mac_data = er32(FEXTNVM7);
6383+
mac_data |= BIT(31);
6384+
mac_data &= ~BIT(0);
6385+
ew32(FEXTNVM7, mac_data);
6386+
6387+
/* Dynamic Power Gating Enable */
6388+
mac_data = er32(CTRL_EXT);
6389+
mac_data |= BIT(3);
6390+
ew32(CTRL_EXT, mac_data);
6391+
6392+
/* Enable the Dynamic Clock Gating in the DMA and MAC */
6393+
mac_data = er32(CTRL_EXT);
6394+
mac_data |= E1000_CTRL_EXT_DMA_DYN_CLK_EN;
6395+
ew32(CTRL_EXT, mac_data);
6396+
6397+
/* No MAC DPG gating SLP_S0 in modern standby
6398+
* Switch the logic of the lanphypc to use PMC counter
6399+
*/
6400+
mac_data = er32(FEXTNVM5);
6401+
mac_data |= BIT(7);
6402+
ew32(FEXTNVM5, mac_data);
6403+
}
6404+
6405+
static void e1000e_s0ix_exit_flow(struct e1000_adapter *adapter)
6406+
{
6407+
struct e1000_hw *hw = &adapter->hw;
6408+
u32 mac_data;
6409+
u16 phy_data;
6410+
6411+
/* Disable the Dynamic Power Gating in the MAC */
6412+
mac_data = er32(FEXTNVM7);
6413+
mac_data &= 0xFFBFFFFF;
6414+
ew32(FEXTNVM7, mac_data);
6415+
6416+
/* Enable the time synchronization clock */
6417+
mac_data = er32(FEXTNVM7);
6418+
mac_data |= BIT(0);
6419+
ew32(FEXTNVM7, mac_data);
6420+
6421+
/* Disable Dynamic Power Gating */
6422+
mac_data = er32(CTRL_EXT);
6423+
mac_data &= 0xFFFFFFF7;
6424+
ew32(CTRL_EXT, mac_data);
6425+
6426+
/* Disable the Dynamic Clock Gating in the DMA and MAC */
6427+
mac_data = er32(CTRL_EXT);
6428+
mac_data &= 0xFFF7FFFF;
6429+
ew32(CTRL_EXT, mac_data);
6430+
6431+
/* Revert the lanphypc logic to use the internal Gbe counter
6432+
* and not the PMC counter
6433+
*/
6434+
mac_data = er32(FEXTNVM5);
6435+
mac_data &= 0xFFFFFF7F;
6436+
ew32(FEXTNVM5, mac_data);
6437+
6438+
/* Enable the periodic inband message,
6439+
* Request PCIe clock in K1 page770_17[10:9] =01b
6440+
*/
6441+
e1e_rphy(hw, HV_PM_CTRL, &phy_data);
6442+
phy_data &= 0xFBFF;
6443+
phy_data |= HV_PM_CTRL_K1_CLK_REQ;
6444+
e1e_wphy(hw, HV_PM_CTRL, phy_data);
6445+
6446+
/* Return back configuration
6447+
* 772_29[5] = 0 CS_Mode_Stay_In_K1
6448+
*/
6449+
e1e_rphy(hw, I217_CGFREG, &phy_data);
6450+
phy_data &= 0xFFDF;
6451+
e1e_wphy(hw, I217_CGFREG, phy_data);
6452+
6453+
/* Change the MAC/PHY interface to Kumeran
6454+
* Unforce the SMBus in PHY page769_23[0] = 0
6455+
* Unforce the SMBus in MAC CTRL_EXT[11] = 0
6456+
*/
6457+
e1e_rphy(hw, CV_SMB_CTRL, &phy_data);
6458+
phy_data &= ~CV_SMB_CTRL_FORCE_SMBUS;
6459+
e1e_wphy(hw, CV_SMB_CTRL, phy_data);
6460+
mac_data = er32(CTRL_EXT);
6461+
mac_data &= ~E1000_CTRL_EXT_FORCE_SMBUS;
6462+
ew32(CTRL_EXT, mac_data);
6463+
}
6464+
62976465
static int e1000e_pm_freeze(struct device *dev)
62986466
{
62996467
struct net_device *netdev = dev_get_drvdata(dev);
@@ -6649,7 +6817,10 @@ static int e1000e_pm_thaw(struct device *dev)
66496817

66506818
static int e1000e_pm_suspend(struct device *dev)
66516819
{
6820+
struct net_device *netdev = pci_get_drvdata(to_pci_dev(dev));
6821+
struct e1000_adapter *adapter = netdev_priv(netdev);
66526822
struct pci_dev *pdev = to_pci_dev(dev);
6823+
struct e1000_hw *hw = &adapter->hw;
66536824
int rc;
66546825

66556826
e1000e_flush_lpic(pdev);
@@ -6660,14 +6831,25 @@ static int e1000e_pm_suspend(struct device *dev)
66606831
if (rc)
66616832
e1000e_pm_thaw(dev);
66626833

6834+
/* Introduce S0ix implementation */
6835+
if (hw->mac.type >= e1000_pch_cnp)
6836+
e1000e_s0ix_entry_flow(adapter);
6837+
66636838
return rc;
66646839
}
66656840

66666841
static int e1000e_pm_resume(struct device *dev)
66676842
{
6843+
struct net_device *netdev = pci_get_drvdata(to_pci_dev(dev));
6844+
struct e1000_adapter *adapter = netdev_priv(netdev);
66686845
struct pci_dev *pdev = to_pci_dev(dev);
6846+
struct e1000_hw *hw = &adapter->hw;
66696847
int rc;
66706848

6849+
/* Introduce S0ix implementation */
6850+
if (hw->mac.type >= e1000_pch_cnp)
6851+
e1000e_s0ix_exit_flow(adapter);
6852+
66716853
rc = __e1000_resume(pdev);
66726854
if (rc)
66736855
return rc;

drivers/net/ethernet/intel/e1000e/regs.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#define E1000_FEXTNVM 0x00028 /* Future Extended NVM - RW */
1919
#define E1000_FEXTNVM3 0x0003C /* Future Extended NVM 3 - RW */
2020
#define E1000_FEXTNVM4 0x00024 /* Future Extended NVM 4 - RW */
21+
#define E1000_FEXTNVM5 0x00014 /* Future Extended NVM 5 - RW */
2122
#define E1000_FEXTNVM6 0x00010 /* Future Extended NVM 6 - RW */
2223
#define E1000_FEXTNVM7 0x000E4 /* Future Extended NVM 7 - RW */
2324
#define E1000_FEXTNVM9 0x5BB4 /* Future Extended NVM 9 - RW */
@@ -234,4 +235,7 @@
234235
#define E1000_RXMTRL 0x0B634 /* Time sync Rx EtherType and Msg Type - RW */
235236
#define E1000_RXUDP 0x0B638 /* Time Sync Rx UDP Port - RW */
236237

238+
/* PHY registers */
239+
#define I82579_DFT_CTRL PHY_REG(769, 20)
240+
237241
#endif

drivers/net/ethernet/intel/igc/igc.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,6 @@ struct igc_adapter {
411411
u32 tx_hwtstamp_timeouts;
412412
u32 tx_hwtstamp_skipped;
413413
u32 rx_hwtstamp_cleared;
414-
u32 *shadow_vfta;
415414

416415
u32 rss_queues;
417416
u32 rss_indir_tbl_init;

drivers/net/ethernet/intel/igc/igc_defines.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,10 @@
282282
#define IGC_RCTL_BAM 0x00008000 /* broadcast enable */
283283

284284
/* Receive Descriptor bit definitions */
285-
#define IGC_RXD_STAT_EOP 0x02 /* End of Packet */
285+
#define IGC_RXD_STAT_EOP 0x02 /* End of Packet */
286+
#define IGC_RXD_STAT_IXSM 0x04 /* Ignore checksum */
287+
#define IGC_RXD_STAT_UDPCS 0x10 /* UDP xsum calculated */
288+
#define IGC_RXD_STAT_TCPCS 0x20 /* TCP xsum calculated */
286289

287290
#define IGC_RXDEXT_STATERR_CE 0x01000000
288291
#define IGC_RXDEXT_STATERR_SE 0x02000000
@@ -402,4 +405,7 @@
402405
#define IGC_ADVTXD_TUCMD_L4T_TCP 0x00000800 /* L4 Packet Type of TCP */
403406
#define IGC_ADVTXD_TUCMD_L4T_SCTP 0x00001000 /* L4 packet TYPE of SCTP */
404407

408+
/* Maximum size of the MTA register table in all supported adapters */
409+
#define MAX_MTA_REG 128
410+
405411
#endif /* _IGC_DEFINES_H_ */

drivers/net/ethernet/intel/igc/igc_hw.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ struct igc_mac_info {
9191
u16 mta_reg_count;
9292
u16 uta_reg_count;
9393

94+
u32 mta_shadow[MAX_MTA_REG];
9495
u16 rar_entry_count;
9596

9697
u8 forced_speed_duplex;

drivers/net/ethernet/intel/igc/igc_mac.c

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,3 +784,107 @@ bool igc_enable_mng_pass_thru(struct igc_hw *hw)
784784
out:
785785
return ret_val;
786786
}
787+
788+
/**
789+
* igc_hash_mc_addr - Generate a multicast hash value
790+
* @hw: pointer to the HW structure
791+
* @mc_addr: pointer to a multicast address
792+
*
793+
* Generates a multicast address hash value which is used to determine
794+
* the multicast filter table array address and new table value. See
795+
* igc_mta_set()
796+
**/
797+
static u32 igc_hash_mc_addr(struct igc_hw *hw, u8 *mc_addr)
798+
{
799+
u32 hash_value, hash_mask;
800+
u8 bit_shift = 0;
801+
802+
/* Register count multiplied by bits per register */
803+
hash_mask = (hw->mac.mta_reg_count * 32) - 1;
804+
805+
/* For a mc_filter_type of 0, bit_shift is the number of left-shifts
806+
* where 0xFF would still fall within the hash mask.
807+
*/
808+
while (hash_mask >> bit_shift != 0xFF)
809+
bit_shift++;
810+
811+
/* The portion of the address that is used for the hash table
812+
* is determined by the mc_filter_type setting.
813+
* The algorithm is such that there is a total of 8 bits of shifting.
814+
* The bit_shift for a mc_filter_type of 0 represents the number of
815+
* left-shifts where the MSB of mc_addr[5] would still fall within
816+
* the hash_mask. Case 0 does this exactly. Since there are a total
817+
* of 8 bits of shifting, then mc_addr[4] will shift right the
818+
* remaining number of bits. Thus 8 - bit_shift. The rest of the
819+
* cases are a variation of this algorithm...essentially raising the
820+
* number of bits to shift mc_addr[5] left, while still keeping the
821+
* 8-bit shifting total.
822+
*
823+
* For example, given the following Destination MAC Address and an
824+
* MTA register count of 128 (thus a 4096-bit vector and 0xFFF mask),
825+
* we can see that the bit_shift for case 0 is 4. These are the hash
826+
* values resulting from each mc_filter_type...
827+
* [0] [1] [2] [3] [4] [5]
828+
* 01 AA 00 12 34 56
829+
* LSB MSB
830+
*
831+
* case 0: hash_value = ((0x34 >> 4) | (0x56 << 4)) & 0xFFF = 0x563
832+
* case 1: hash_value = ((0x34 >> 3) | (0x56 << 5)) & 0xFFF = 0xAC6
833+
* case 2: hash_value = ((0x34 >> 2) | (0x56 << 6)) & 0xFFF = 0x163
834+
* case 3: hash_value = ((0x34 >> 0) | (0x56 << 8)) & 0xFFF = 0x634
835+
*/
836+
switch (hw->mac.mc_filter_type) {
837+
default:
838+
case 0:
839+
break;
840+
case 1:
841+
bit_shift += 1;
842+
break;
843+
case 2:
844+
bit_shift += 2;
845+
break;
846+
case 3:
847+
bit_shift += 4;
848+
break;
849+
}
850+
851+
hash_value = hash_mask & (((mc_addr[4] >> (8 - bit_shift)) |
852+
(((u16)mc_addr[5]) << bit_shift)));
853+
854+
return hash_value;
855+
}
856+
857+
/**
858+
* igc_update_mc_addr_list - Update Multicast addresses
859+
* @hw: pointer to the HW structure
860+
* @mc_addr_list: array of multicast addresses to program
861+
* @mc_addr_count: number of multicast addresses to program
862+
*
863+
* Updates entire Multicast Table Array.
864+
* The caller must have a packed mc_addr_list of multicast addresses.
865+
**/
866+
void igc_update_mc_addr_list(struct igc_hw *hw,
867+
u8 *mc_addr_list, u32 mc_addr_count)
868+
{
869+
u32 hash_value, hash_bit, hash_reg;
870+
int i;
871+
872+
/* clear mta_shadow */
873+
memset(&hw->mac.mta_shadow, 0, sizeof(hw->mac.mta_shadow));
874+
875+
/* update mta_shadow from mc_addr_list */
876+
for (i = 0; (u32)i < mc_addr_count; i++) {
877+
hash_value = igc_hash_mc_addr(hw, mc_addr_list);
878+
879+
hash_reg = (hash_value >> 5) & (hw->mac.mta_reg_count - 1);
880+
hash_bit = hash_value & 0x1F;
881+
882+
hw->mac.mta_shadow[hash_reg] |= BIT(hash_bit);
883+
mc_addr_list += ETH_ALEN;
884+
}
885+
886+
/* replace the entire MTA table */
887+
for (i = hw->mac.mta_reg_count - 1; i >= 0; i--)
888+
array_wr32(IGC_MTA, i, hw->mac.mta_shadow[i]);
889+
wrfl();
890+
}

drivers/net/ethernet/intel/igc/igc_mac.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ s32 igc_get_speed_and_duplex_copper(struct igc_hw *hw, u16 *speed,
2929
u16 *duplex);
3030

3131
bool igc_enable_mng_pass_thru(struct igc_hw *hw);
32+
void igc_update_mc_addr_list(struct igc_hw *hw,
33+
u8 *mc_addr_list, u32 mc_addr_count);
3234

3335
enum igc_mng_mode {
3436
igc_mng_mode_none = 0,

0 commit comments

Comments
 (0)