Skip to content

Commit 3627f8f

Browse files
Joe SchultzJeff Kirsher
authored andcommitted
igb: Improve cable length function for I210, etc.
Previously, the PHY-specific code to get the cable length for the I210 internal and related PHYs was reporting the cable length of a single pair and reporting it as the min, max, and total cable length. Update it so that all four pairs are checked so the true min, max, and average cable lengths are reported. Signed-off-by: Joe Schultz <[email protected]> Signed-off-by: Aaron Sierra <[email protected]> Tested-by: Aaron Brown <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 06b0dd6 commit 3627f8f

File tree

3 files changed

+51
-9
lines changed

3 files changed

+51
-9
lines changed

drivers/net/ethernet/intel/igb/e1000_defines.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -927,7 +927,10 @@
927927

928928
/* Intel i347-AT4 Registers */
929929

930-
#define I347AT4_PCDL 0x10 /* PHY Cable Diagnostics Length */
930+
#define I347AT4_PCDL0 0x10 /* Pair 0 PHY Cable Diagnostics Length */
931+
#define I347AT4_PCDL1 0x11 /* Pair 1 PHY Cable Diagnostics Length */
932+
#define I347AT4_PCDL2 0x12 /* Pair 2 PHY Cable Diagnostics Length */
933+
#define I347AT4_PCDL3 0x13 /* Pair 3 PHY Cable Diagnostics Length */
931934
#define I347AT4_PCDC 0x15 /* PHY Cable Diagnostics Control */
932935
#define I347AT4_PAGE_SELECT 0x16
933936

drivers/net/ethernet/intel/igb/e1000_hw.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,7 @@ struct e1000_phy_info {
441441
u16 cable_length;
442442
u16 max_cable_length;
443443
u16 min_cable_length;
444+
u16 pair_length[4];
444445

445446
u8 mdix;
446447

drivers/net/ethernet/intel/igb/e1000_phy.c

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1717,6 +1717,9 @@ s32 igb_get_cable_length_m88_gen2(struct e1000_hw *hw)
17171717
struct e1000_phy_info *phy = &hw->phy;
17181718
s32 ret_val;
17191719
u16 phy_data, phy_data2, index, default_page, is_cm;
1720+
int len_tot = 0;
1721+
u16 len_min;
1722+
u16 len_max;
17201723

17211724
switch (hw->phy.id) {
17221725
case M88E1543_E_PHY_ID:
@@ -1733,22 +1736,57 @@ s32 igb_get_cable_length_m88_gen2(struct e1000_hw *hw)
17331736
if (ret_val)
17341737
goto out;
17351738

1736-
/* Get cable length from PHY Cable Diagnostics Control Reg */
1737-
ret_val = phy->ops.read_reg(hw, I347AT4_PCDL, &phy_data);
1738-
if (ret_val)
1739-
goto out;
1740-
17411739
/* Check if the unit of cable length is meters or cm */
17421740
ret_val = phy->ops.read_reg(hw, I347AT4_PCDC, &phy_data2);
17431741
if (ret_val)
17441742
goto out;
17451743

17461744
is_cm = !(phy_data2 & I347AT4_PCDC_CABLE_LENGTH_UNIT);
17471745

1746+
/* Get cable length from Pair 0 length Regs */
1747+
ret_val = phy->ops.read_reg(hw, I347AT4_PCDL0, &phy_data);
1748+
if (ret_val)
1749+
goto out;
1750+
1751+
phy->pair_length[0] = phy_data / (is_cm ? 100 : 1);
1752+
len_tot = phy->pair_length[0];
1753+
len_min = phy->pair_length[0];
1754+
len_max = phy->pair_length[0];
1755+
1756+
/* Get cable length from Pair 1 length Regs */
1757+
ret_val = phy->ops.read_reg(hw, I347AT4_PCDL1, &phy_data);
1758+
if (ret_val)
1759+
goto out;
1760+
1761+
phy->pair_length[1] = phy_data / (is_cm ? 100 : 1);
1762+
len_tot += phy->pair_length[1];
1763+
len_min = min(len_min, phy->pair_length[1]);
1764+
len_max = max(len_max, phy->pair_length[1]);
1765+
1766+
/* Get cable length from Pair 2 length Regs */
1767+
ret_val = phy->ops.read_reg(hw, I347AT4_PCDL2, &phy_data);
1768+
if (ret_val)
1769+
goto out;
1770+
1771+
phy->pair_length[2] = phy_data / (is_cm ? 100 : 1);
1772+
len_tot += phy->pair_length[2];
1773+
len_min = min(len_min, phy->pair_length[2]);
1774+
len_max = max(len_max, phy->pair_length[2]);
1775+
1776+
/* Get cable length from Pair 3 length Regs */
1777+
ret_val = phy->ops.read_reg(hw, I347AT4_PCDL3, &phy_data);
1778+
if (ret_val)
1779+
goto out;
1780+
1781+
phy->pair_length[3] = phy_data / (is_cm ? 100 : 1);
1782+
len_tot += phy->pair_length[3];
1783+
len_min = min(len_min, phy->pair_length[3]);
1784+
len_max = max(len_max, phy->pair_length[3]);
1785+
17481786
/* Populate the phy structure with cable length in meters */
1749-
phy->min_cable_length = phy_data / (is_cm ? 100 : 1);
1750-
phy->max_cable_length = phy_data / (is_cm ? 100 : 1);
1751-
phy->cable_length = phy_data / (is_cm ? 100 : 1);
1787+
phy->min_cable_length = len_min;
1788+
phy->max_cable_length = len_max;
1789+
phy->cable_length = len_tot / 4;
17521790

17531791
/* Reset the page selec to its original value */
17541792
ret_val = phy->ops.write_reg(hw, I347AT4_PAGE_SELECT,

0 commit comments

Comments
 (0)