33 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
45 static void ixgb_mta_set(
struct ixgb_hw *
hw,
u32 hash_value);
47 static void ixgb_get_bus_info(
struct ixgb_hw *
hw);
49 static bool ixgb_link_reset(
struct ixgb_hw *
hw);
51 static void ixgb_optics_reset(
struct ixgb_hw *
hw);
53 static void ixgb_optics_reset_bcm(
struct ixgb_hw *
hw);
57 static void ixgb_clear_hw_cntrs(
struct ixgb_hw *
hw);
59 static void ixgb_clear_vfta(
struct ixgb_hw *
hw);
61 static void ixgb_init_rx_addrs(
struct ixgb_hw *
hw);
68 static bool ixgb_setup_fc(
struct ixgb_hw *
hw);
87 IXGB_WRITE_REG_IO(hw,
CTRL0, ctrl_reg);
108 ixgb_optics_reset_bcm(hw);
112 ixgb_optics_reset(hw);
134 pr_debug(
"Exiting because the adapter is already stopped!!!\n");
144 pr_debug(
"Masking off all interrupts\n");
161 pr_debug(
"Issuing a global reset to MAC\n");
163 ctrl_reg = ixgb_mac_reset(hw);
166 pr_debug(
"Masking off all interrupts\n");
186 ixgb_identify_xpak_vendor(
struct ixgb_hw *hw)
197 for (i = 0; i < 5; i++) {
198 vendor_name[
i] = ixgb_read_phy_reg(hw,
205 if (vendor_name[0] ==
'I' &&
206 vendor_name[1] ==
'N' &&
207 vendor_name[2] ==
'T' &&
208 vendor_name[3] ==
'E' && vendor_name[4] ==
'L') {
226 ixgb_identify_phy(
struct ixgb_hw *hw)
236 pr_debug(
"Identified TXN17401 optics\n");
244 xpak_vendor = ixgb_identify_xpak_vendor(hw);
246 pr_debug(
"Identified TXN17201 optics\n");
249 pr_debug(
"Identified G6005 optics\n");
254 pr_debug(
"Identified G6104 optics\n");
259 xpak_vendor = ixgb_identify_xpak_vendor(hw);
261 pr_debug(
"Identified TXN17201 optics\n");
264 pr_debug(
"Identified G6005 optics\n");
269 pr_debug(
"Unknown physical layer module\n");
312 pr_debug(
"Issuing a global reset to MAC\n");
314 ctrl_reg = ixgb_mac_reset(hw);
316 pr_debug(
"Issuing an EE reset to MAC\n");
332 hw->
phy_type = ixgb_identify_phy(hw);
337 ixgb_init_rx_addrs(hw);
344 pr_debug(
"MAC address invalid after ixgb_init_rx_addrs\n");
352 ixgb_get_bus_info(hw);
363 ixgb_clear_hw_cntrs(hw);
366 status = ixgb_setup_fc(hw);
384 ixgb_init_rx_addrs(
struct ixgb_hw *hw)
400 pr_debug(
"Keeping Permanent MAC Addr = %pM\n",
405 pr_debug(
"Overriding MAC Address in RAR[0]\n");
441 u32 rar_used_count = 1;
463 for (i = 0; i < mc_addr_count; i++) {
464 pr_debug(
"Adding the multicast addresses:\n");
465 pr_debug(
"MC Addr #%d = %pM\n", i, mca);
470 if (rar_used_count < IXGB_RAR_ENTRIES) {
472 pr_debug(
"Added a multicast address to RAR[%d]\n", i);
475 hash_value = ixgb_hash_mc_addr(hw, mca);
477 pr_debug(
"Hash value = 0x%03X\n", hash_value);
479 ixgb_mta_set(hw, hash_value);
498 ixgb_hash_mc_addr(
struct ixgb_hw *hw,
515 ((mc_addr[4] >> 4) | (((
u16) mc_addr[5]) << 4));
519 ((mc_addr[4] >> 3) | (((
u16) mc_addr[5]) << 5));
523 ((mc_addr[4] >> 2) | (((
u16) mc_addr[5]) << 6));
526 hash_value = ((mc_addr[4]) | (((
u16) mc_addr[5]) << 8));
530 pr_debug(
"MC filter type param set incorrectly\n");
546 ixgb_mta_set(
struct ixgb_hw *hw,
549 u32 hash_bit, hash_reg;
560 hash_reg = (hash_value >> 5) & 0x7F;
561 hash_bit = hash_value & 0x1F;
565 mta_reg |= (1 << hash_bit);
582 u32 rar_low, rar_high;
589 rar_low = ((
u32) addr[0] |
590 ((
u32)addr[1] << 8) |
591 ((
u32)addr[2] << 16) |
592 ((
u32)addr[3] << 24));
594 rar_high = ((
u32) addr[4] |
595 ((
u32)addr[5] << 8) |
623 ixgb_clear_vfta(
struct ixgb_hw *hw)
638 ixgb_setup_fc(
struct ixgb_hw *hw)
661 switch (hw->
fc.type) {
677 pap_reg = hw->
fc.pause_time;
684 pap_reg = hw->
fc.pause_time;
688 pr_debug(
"Flow control param set incorrectly\n");
712 if (hw->
fc.send_xon) {
739 ixgb_read_phy_reg(
struct ixgb_hw *hw,
767 for (i = 0; i < 10; i++)
794 for (i = 0; i < 10; i++)
832 ixgb_write_phy_reg(
struct ixgb_hw *hw,
863 for (i = 0; i < 10; i++)
890 for (i = 0; i < 10; i++)
926 }
else if (!(xpcss_reg & IXGB_XPCSS_ALIGN_STATUS) &&
927 (status_reg & IXGB_STATUS_LU)) {
928 pr_debug(
"XPCSS Not Aligned while Status:LU is set\n");
929 hw->
link_up = ixgb_link_reset(hw);
935 hw->
link_up = ixgb_link_reset(hw);
952 bool bad_link_returncode =
false;
957 if ((hw->
lastLFC + 250 < newLFC)
958 || (hw->
lastRFC + 250 < newRFC)) {
959 pr_debug(
"BAD LINK! too many LFC/RFC since last check\n");
960 bad_link_returncode =
true;
966 return bad_link_returncode;
975 ixgb_clear_hw_cntrs(
struct ixgb_hw *hw)
983 pr_debug(
"Exiting because the adapter is stopped!!!\n");
1085 ixgb_get_bus_info(
struct ixgb_hw *hw)
1127 bool is_valid =
true;
1131 if (is_multicast_ether_addr(mac_addr)) {
1132 pr_debug(
"MAC address is multicast\n");
1136 else if (is_broadcast_ether_addr(mac_addr)) {
1137 pr_debug(
"MAC address is broadcast\n");
1141 else if (is_zero_ether_addr(mac_addr)) {
1142 pr_debug(
"MAC address is all zeros\n");
1155 ixgb_link_reset(
struct ixgb_hw *hw)
1173 }
while (!link_status && --wait_retries);
1175 }
while (!link_status && --lrst_retries);
1186 ixgb_optics_reset(
struct ixgb_hw *hw)
1191 ixgb_write_phy_reg(hw,
1197 mdio_reg = ixgb_read_phy_reg(hw,
1210 #define IXGB_BCM8704_USER_PMD_TX_CTRL_REG 0xC803
1211 #define IXGB_BCM8704_USER_PMD_TX_CTRL_REG_VAL 0x0164
1212 #define IXGB_BCM8704_USER_CTRL_REG 0xC800
1213 #define IXGB_BCM8704_USER_CTRL_REG_VAL 0x7FBF
1214 #define IXGB_BCM8704_USER_DEV3_ADDR 0x0003
1215 #define IXGB_SUN_PHY_ADDRESS 0x0000
1216 #define IXGB_SUN_PHY_RESET_DELAY 305
1219 ixgb_optics_reset_bcm(
struct ixgb_hw *hw)
1232 ixgb_write_phy_reg(hw,
1238 ixgb_read_phy_reg(hw,
1242 ixgb_read_phy_reg(hw,
1247 ixgb_write_phy_reg(hw,
1252 ixgb_read_phy_reg(hw,
1256 ixgb_read_phy_reg(hw,