aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ixgbe/ixgbe_82598.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ixgbe/ixgbe_82598.c')
-rw-r--r--drivers/net/ixgbe/ixgbe_82598.c330
1 files changed, 180 insertions, 150 deletions
diff --git a/drivers/net/ixgbe/ixgbe_82598.c b/drivers/net/ixgbe/ixgbe_82598.c
index 4791238c3f6e..b9923047ce11 100644
--- a/drivers/net/ixgbe/ixgbe_82598.c
+++ b/drivers/net/ixgbe/ixgbe_82598.c
@@ -75,18 +75,49 @@ static u16 ixgbe_get_pcie_msix_count_82598(struct ixgbe_hw *hw)
75static s32 ixgbe_get_invariants_82598(struct ixgbe_hw *hw) 75static s32 ixgbe_get_invariants_82598(struct ixgbe_hw *hw)
76{ 76{
77 struct ixgbe_mac_info *mac = &hw->mac; 77 struct ixgbe_mac_info *mac = &hw->mac;
78
79 /* Call PHY identify routine to get the phy type */
80 ixgbe_identify_phy_generic(hw);
81
82 mac->mcft_size = IXGBE_82598_MC_TBL_SIZE;
83 mac->vft_size = IXGBE_82598_VFT_TBL_SIZE;
84 mac->num_rar_entries = IXGBE_82598_RAR_ENTRIES;
85 mac->max_rx_queues = IXGBE_82598_MAX_RX_QUEUES;
86 mac->max_tx_queues = IXGBE_82598_MAX_TX_QUEUES;
87 mac->max_msix_vectors = ixgbe_get_pcie_msix_count_82598(hw);
88
89 return 0;
90}
91
92/**
93 * ixgbe_init_phy_ops_82598 - PHY/SFP specific init
94 * @hw: pointer to hardware structure
95 *
96 * Initialize any function pointers that were not able to be
97 * set during get_invariants because the PHY/SFP type was
98 * not known. Perform the SFP init if necessary.
99 *
100 **/
101s32 ixgbe_init_phy_ops_82598(struct ixgbe_hw *hw)
102{
103 struct ixgbe_mac_info *mac = &hw->mac;
78 struct ixgbe_phy_info *phy = &hw->phy; 104 struct ixgbe_phy_info *phy = &hw->phy;
79 s32 ret_val = 0; 105 s32 ret_val = 0;
80 u16 list_offset, data_offset; 106 u16 list_offset, data_offset;
81 107
82 /* Set the bus information prior to PHY identification */ 108 /* Identify the PHY */
83 mac->ops.get_bus_info(hw); 109 phy->ops.identify(hw);
84 110
85 /* Call PHY identify routine to get the phy type */ 111 /* Overwrite the link function pointers if copper PHY */
86 ixgbe_identify_phy_generic(hw); 112 if (mac->ops.get_media_type(hw) == ixgbe_media_type_copper) {
113 mac->ops.setup_link = &ixgbe_setup_copper_link_82598;
114 mac->ops.setup_link_speed =
115 &ixgbe_setup_copper_link_speed_82598;
116 mac->ops.get_link_capabilities =
117 &ixgbe_get_copper_link_capabilities_82598;
118 }
87 119
88 /* PHY Init */ 120 switch (hw->phy.type) {
89 switch (phy->type) {
90 case ixgbe_phy_tn: 121 case ixgbe_phy_tn:
91 phy->ops.check_link = &ixgbe_check_phy_link_tnx; 122 phy->ops.check_link = &ixgbe_check_phy_link_tnx;
92 phy->ops.get_firmware_version = 123 phy->ops.get_firmware_version =
@@ -106,8 +137,8 @@ static s32 ixgbe_get_invariants_82598(struct ixgbe_hw *hw)
106 137
107 /* Check to see if SFP+ module is supported */ 138 /* Check to see if SFP+ module is supported */
108 ret_val = ixgbe_get_sfp_init_sequence_offsets(hw, 139 ret_val = ixgbe_get_sfp_init_sequence_offsets(hw,
109 &list_offset, 140 &list_offset,
110 &data_offset); 141 &data_offset);
111 if (ret_val != 0) { 142 if (ret_val != 0) {
112 ret_val = IXGBE_ERR_SFP_NOT_SUPPORTED; 143 ret_val = IXGBE_ERR_SFP_NOT_SUPPORTED;
113 goto out; 144 goto out;
@@ -117,21 +148,6 @@ static s32 ixgbe_get_invariants_82598(struct ixgbe_hw *hw)
117 break; 148 break;
118 } 149 }
119 150
120 if (mac->ops.get_media_type(hw) == ixgbe_media_type_copper) {
121 mac->ops.setup_link = &ixgbe_setup_copper_link_82598;
122 mac->ops.setup_link_speed =
123 &ixgbe_setup_copper_link_speed_82598;
124 mac->ops.get_link_capabilities =
125 &ixgbe_get_copper_link_capabilities_82598;
126 }
127
128 mac->mcft_size = IXGBE_82598_MC_TBL_SIZE;
129 mac->vft_size = IXGBE_82598_VFT_TBL_SIZE;
130 mac->num_rar_entries = IXGBE_82598_RAR_ENTRIES;
131 mac->max_rx_queues = IXGBE_82598_MAX_RX_QUEUES;
132 mac->max_tx_queues = IXGBE_82598_MAX_TX_QUEUES;
133 mac->max_msix_vectors = ixgbe_get_pcie_msix_count_82598(hw);
134
135out: 151out:
136 return ret_val; 152 return ret_val;
137} 153}
@@ -149,12 +165,19 @@ static s32 ixgbe_get_link_capabilities_82598(struct ixgbe_hw *hw,
149 bool *autoneg) 165 bool *autoneg)
150{ 166{
151 s32 status = 0; 167 s32 status = 0;
168 u32 autoc = 0;
152 169
153 /* 170 /*
154 * Determine link capabilities based on the stored value of AUTOC, 171 * Determine link capabilities based on the stored value of AUTOC,
155 * which represents EEPROM defaults. 172 * which represents EEPROM defaults. If AUTOC value has not been
173 * stored, use the current register value.
156 */ 174 */
157 switch (hw->mac.orig_autoc & IXGBE_AUTOC_LMS_MASK) { 175 if (hw->mac.orig_link_settings_stored)
176 autoc = hw->mac.orig_autoc;
177 else
178 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
179
180 switch (autoc & IXGBE_AUTOC_LMS_MASK) {
158 case IXGBE_AUTOC_LMS_1G_LINK_NO_AN: 181 case IXGBE_AUTOC_LMS_1G_LINK_NO_AN:
159 *speed = IXGBE_LINK_SPEED_1GB_FULL; 182 *speed = IXGBE_LINK_SPEED_1GB_FULL;
160 *autoneg = false; 183 *autoneg = false;
@@ -173,9 +196,9 @@ static s32 ixgbe_get_link_capabilities_82598(struct ixgbe_hw *hw,
173 case IXGBE_AUTOC_LMS_KX4_AN: 196 case IXGBE_AUTOC_LMS_KX4_AN:
174 case IXGBE_AUTOC_LMS_KX4_AN_1G_AN: 197 case IXGBE_AUTOC_LMS_KX4_AN_1G_AN:
175 *speed = IXGBE_LINK_SPEED_UNKNOWN; 198 *speed = IXGBE_LINK_SPEED_UNKNOWN;
176 if (hw->mac.orig_autoc & IXGBE_AUTOC_KX4_SUPP) 199 if (autoc & IXGBE_AUTOC_KX4_SUPP)
177 *speed |= IXGBE_LINK_SPEED_10GB_FULL; 200 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
178 if (hw->mac.orig_autoc & IXGBE_AUTOC_KX_SUPP) 201 if (autoc & IXGBE_AUTOC_KX_SUPP)
179 *speed |= IXGBE_LINK_SPEED_1GB_FULL; 202 *speed |= IXGBE_LINK_SPEED_1GB_FULL;
180 *autoneg = true; 203 *autoneg = true;
181 break; 204 break;
@@ -206,14 +229,13 @@ static s32 ixgbe_get_copper_link_capabilities_82598(struct ixgbe_hw *hw,
206 *speed = 0; 229 *speed = 0;
207 *autoneg = true; 230 *autoneg = true;
208 231
209 status = hw->phy.ops.read_reg(hw, IXGBE_MDIO_PHY_SPEED_ABILITY, 232 status = hw->phy.ops.read_reg(hw, MDIO_SPEED, MDIO_MMD_PMAPMD,
210 IXGBE_MDIO_PMA_PMD_DEV_TYPE,
211 &speed_ability); 233 &speed_ability);
212 234
213 if (status == 0) { 235 if (status == 0) {
214 if (speed_ability & IXGBE_MDIO_PHY_SPEED_10G) 236 if (speed_ability & MDIO_SPEED_10G)
215 *speed |= IXGBE_LINK_SPEED_10GB_FULL; 237 *speed |= IXGBE_LINK_SPEED_10GB_FULL;
216 if (speed_ability & IXGBE_MDIO_PHY_SPEED_1G) 238 if (speed_ability & MDIO_PMA_SPEED_1000)
217 *speed |= IXGBE_LINK_SPEED_1GB_FULL; 239 *speed |= IXGBE_LINK_SPEED_1GB_FULL;
218 } 240 }
219 241
@@ -271,6 +293,17 @@ static s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw, s32 packetbuf_num)
271 u32 rmcs_reg; 293 u32 rmcs_reg;
272 u32 reg; 294 u32 reg;
273 295
296#ifdef CONFIG_DCB
297 if (hw->fc.requested_mode == ixgbe_fc_pfc)
298 goto out;
299
300#endif /* CONFIG_DCB */
301 /* Negotiate the fc mode to use */
302 ret_val = ixgbe_fc_autoneg(hw);
303 if (ret_val)
304 goto out;
305
306 /* Disable any previous flow control settings */
274 fctrl_reg = IXGBE_READ_REG(hw, IXGBE_FCTRL); 307 fctrl_reg = IXGBE_READ_REG(hw, IXGBE_FCTRL);
275 fctrl_reg &= ~(IXGBE_FCTRL_RFCE | IXGBE_FCTRL_RPFCE); 308 fctrl_reg &= ~(IXGBE_FCTRL_RFCE | IXGBE_FCTRL_RPFCE);
276 309
@@ -282,14 +315,20 @@ static s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw, s32 packetbuf_num)
282 * 0: Flow control is completely disabled 315 * 0: Flow control is completely disabled
283 * 1: Rx flow control is enabled (we can receive pause frames, 316 * 1: Rx flow control is enabled (we can receive pause frames,
284 * but not send pause frames). 317 * but not send pause frames).
285 * 2: Tx flow control is enabled (we can send pause frames but 318 * 2: Tx flow control is enabled (we can send pause frames but
286 * we do not support receiving pause frames). 319 * we do not support receiving pause frames).
287 * 3: Both Rx and Tx flow control (symmetric) are enabled. 320 * 3: Both Rx and Tx flow control (symmetric) are enabled.
288 * other: Invalid. 321 * other: Invalid.
322#ifdef CONFIG_DCB
323 * 4: Priority Flow Control is enabled.
324#endif
289 */ 325 */
290 switch (hw->fc.current_mode) { 326 switch (hw->fc.current_mode) {
291 case ixgbe_fc_none: 327 case ixgbe_fc_none:
292 /* Flow control completely disabled by software override. */ 328 /*
329 * Flow control is disabled by software override or autoneg.
330 * The code below will actually disable it in the HW.
331 */
293 break; 332 break;
294 case ixgbe_fc_rx_pause: 333 case ixgbe_fc_rx_pause:
295 /* 334 /*
@@ -314,6 +353,11 @@ static s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw, s32 packetbuf_num)
314 fctrl_reg |= IXGBE_FCTRL_RFCE; 353 fctrl_reg |= IXGBE_FCTRL_RFCE;
315 rmcs_reg |= IXGBE_RMCS_TFCE_802_3X; 354 rmcs_reg |= IXGBE_RMCS_TFCE_802_3X;
316 break; 355 break;
356#ifdef CONFIG_DCB
357 case ixgbe_fc_pfc:
358 goto out;
359 break;
360#endif /* CONFIG_DCB */
317 default: 361 default:
318 hw_dbg(hw, "Flow control param set incorrectly\n"); 362 hw_dbg(hw, "Flow control param set incorrectly\n");
319 ret_val = -IXGBE_ERR_CONFIG; 363 ret_val = -IXGBE_ERR_CONFIG;
@@ -321,7 +365,8 @@ static s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw, s32 packetbuf_num)
321 break; 365 break;
322 } 366 }
323 367
324 /* Enable 802.3x based flow control settings. */ 368 /* Set 802.3x based flow control settings. */
369 fctrl_reg |= IXGBE_FCTRL_DPF;
325 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl_reg); 370 IXGBE_WRITE_REG(hw, IXGBE_FCTRL, fctrl_reg);
326 IXGBE_WRITE_REG(hw, IXGBE_RMCS, rmcs_reg); 371 IXGBE_WRITE_REG(hw, IXGBE_RMCS, rmcs_reg);
327 372
@@ -340,7 +385,7 @@ static s32 ixgbe_fc_enable_82598(struct ixgbe_hw *hw, s32 packetbuf_num)
340 } 385 }
341 386
342 /* Configure pause time (2 TCs per register) */ 387 /* Configure pause time (2 TCs per register) */
343 reg = IXGBE_READ_REG(hw, IXGBE_FCTTV(packetbuf_num)); 388 reg = IXGBE_READ_REG(hw, IXGBE_FCTTV(packetbuf_num / 2));
344 if ((packetbuf_num & 1) == 0) 389 if ((packetbuf_num & 1) == 0)
345 reg = (reg & 0xFFFF0000) | hw->fc.pause_time; 390 reg = (reg & 0xFFFF0000) | hw->fc.pause_time;
346 else 391 else
@@ -354,77 +399,6 @@ out:
354} 399}
355 400
356/** 401/**
357 * ixgbe_setup_fc_82598 - Configure flow control settings
358 * @hw: pointer to hardware structure
359 * @packetbuf_num: packet buffer number (0-7)
360 *
361 * Configures the flow control settings based on SW configuration. This
362 * function is used for 802.3x flow control configuration only.
363 **/
364static s32 ixgbe_setup_fc_82598(struct ixgbe_hw *hw, s32 packetbuf_num)
365{
366 s32 ret_val = 0;
367 ixgbe_link_speed speed;
368 bool link_up;
369
370 /* Validate the packetbuf configuration */
371 if (packetbuf_num < 0 || packetbuf_num > 7) {
372 hw_dbg(hw, "Invalid packet buffer number [%d], expected range is"
373 " 0-7\n", packetbuf_num);
374 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
375 goto out;
376 }
377
378 /*
379 * Validate the water mark configuration. Zero water marks are invalid
380 * because it causes the controller to just blast out fc packets.
381 */
382 if (!hw->fc.low_water || !hw->fc.high_water || !hw->fc.pause_time) {
383 hw_dbg(hw, "Invalid water mark configuration\n");
384 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
385 goto out;
386 }
387
388 /*
389 * Validate the requested mode. Strict IEEE mode does not allow
390 * ixgbe_fc_rx_pause because it will cause testing anomalies.
391 */
392 if (hw->fc.strict_ieee && hw->fc.requested_mode == ixgbe_fc_rx_pause) {
393 hw_dbg(hw, "ixgbe_fc_rx_pause not valid in strict IEEE mode\n");
394 ret_val = IXGBE_ERR_INVALID_LINK_SETTINGS;
395 goto out;
396 }
397
398 /*
399 * 10gig parts do not have a word in the EEPROM to determine the
400 * default flow control setting, so we explicitly set it to full.
401 */
402 if (hw->fc.requested_mode == ixgbe_fc_default)
403 hw->fc.requested_mode = ixgbe_fc_full;
404
405 /*
406 * Save off the requested flow control mode for use later. Depending
407 * on the link partner's capabilities, we may or may not use this mode.
408 */
409
410 hw->fc.current_mode = hw->fc.requested_mode;
411
412 /* Decide whether to use autoneg or not. */
413 hw->mac.ops.check_link(hw, &speed, &link_up, false);
414 if (!hw->fc.disable_fc_autoneg && hw->phy.multispeed_fiber &&
415 (speed == IXGBE_LINK_SPEED_1GB_FULL))
416 ret_val = ixgbe_fc_autoneg(hw);
417
418 if (ret_val)
419 goto out;
420
421 ret_val = ixgbe_fc_enable_82598(hw, packetbuf_num);
422
423out:
424 return ret_val;
425}
426
427/**
428 * ixgbe_setup_mac_link_82598 - Configures MAC link settings 402 * ixgbe_setup_mac_link_82598 - Configures MAC link settings
429 * @hw: pointer to hardware structure 403 * @hw: pointer to hardware structure
430 * 404 *
@@ -463,13 +437,6 @@ static s32 ixgbe_setup_mac_link_82598(struct ixgbe_hw *hw)
463 } 437 }
464 } 438 }
465 439
466 /*
467 * We want to save off the original Flow Control configuration just in
468 * case we get disconnected and then reconnected into a different hub
469 * or switch with different Flow Control capabilities.
470 */
471 ixgbe_setup_fc_82598(hw, 0);
472
473 /* Add delay to filter out noises during initial link setup */ 440 /* Add delay to filter out noises during initial link setup */
474 msleep(50); 441 msleep(50);
475 442
@@ -500,9 +467,9 @@ static s32 ixgbe_check_mac_link_82598(struct ixgbe_hw *hw,
500 * clear indicates active; set indicates inactive. 467 * clear indicates active; set indicates inactive.
501 */ 468 */
502 if (hw->phy.type == ixgbe_phy_nl) { 469 if (hw->phy.type == ixgbe_phy_nl) {
503 hw->phy.ops.read_reg(hw, 0xC79F, IXGBE_TWINAX_DEV, &link_reg); 470 hw->phy.ops.read_reg(hw, 0xC79F, MDIO_MMD_PMAPMD, &link_reg);
504 hw->phy.ops.read_reg(hw, 0xC79F, IXGBE_TWINAX_DEV, &link_reg); 471 hw->phy.ops.read_reg(hw, 0xC79F, MDIO_MMD_PMAPMD, &link_reg);
505 hw->phy.ops.read_reg(hw, 0xC00C, IXGBE_TWINAX_DEV, 472 hw->phy.ops.read_reg(hw, 0xC00C, MDIO_MMD_PMAPMD,
506 &adapt_comp_reg); 473 &adapt_comp_reg);
507 if (link_up_wait_to_complete) { 474 if (link_up_wait_to_complete) {
508 for (i = 0; i < IXGBE_LINK_UP_TIME; i++) { 475 for (i = 0; i < IXGBE_LINK_UP_TIME; i++) {
@@ -515,10 +482,10 @@ static s32 ixgbe_check_mac_link_82598(struct ixgbe_hw *hw,
515 } 482 }
516 msleep(100); 483 msleep(100);
517 hw->phy.ops.read_reg(hw, 0xC79F, 484 hw->phy.ops.read_reg(hw, 0xC79F,
518 IXGBE_TWINAX_DEV, 485 MDIO_MMD_PMAPMD,
519 &link_reg); 486 &link_reg);
520 hw->phy.ops.read_reg(hw, 0xC00C, 487 hw->phy.ops.read_reg(hw, 0xC00C,
521 IXGBE_TWINAX_DEV, 488 MDIO_MMD_PMAPMD,
522 &adapt_comp_reg); 489 &adapt_comp_reg);
523 } 490 }
524 } else { 491 } else {
@@ -556,6 +523,11 @@ static s32 ixgbe_check_mac_link_82598(struct ixgbe_hw *hw,
556 else 523 else
557 *speed = IXGBE_LINK_SPEED_1GB_FULL; 524 *speed = IXGBE_LINK_SPEED_1GB_FULL;
558 525
526 /* if link is down, zero out the current_mode */
527 if (*link_up == false) {
528 hw->fc.current_mode = ixgbe_fc_none;
529 hw->fc.fc_was_autonegged = false;
530 }
559out: 531out:
560 return 0; 532 return 0;
561} 533}
@@ -673,6 +645,7 @@ static s32 ixgbe_setup_copper_link_speed_82598(struct ixgbe_hw *hw,
673static s32 ixgbe_reset_hw_82598(struct ixgbe_hw *hw) 645static s32 ixgbe_reset_hw_82598(struct ixgbe_hw *hw)
674{ 646{
675 s32 status = 0; 647 s32 status = 0;
648 s32 phy_status = 0;
676 u32 ctrl; 649 u32 ctrl;
677 u32 gheccr; 650 u32 gheccr;
678 u32 i; 651 u32 i;
@@ -716,14 +689,27 @@ static s32 ixgbe_reset_hw_82598(struct ixgbe_hw *hw)
716 } 689 }
717 690
718 /* Reset PHY */ 691 /* Reset PHY */
719 if (hw->phy.reset_disable == false) 692 if (hw->phy.reset_disable == false) {
693 /* PHY ops must be identified and initialized prior to reset */
694
695 /* Init PHY and function pointers, perform SFP setup */
696 phy_status = hw->phy.ops.init(hw);
697 if (phy_status == IXGBE_ERR_SFP_NOT_SUPPORTED)
698 goto reset_hw_out;
699 else if (phy_status == IXGBE_ERR_SFP_NOT_PRESENT)
700 goto no_phy_reset;
701
702
720 hw->phy.ops.reset(hw); 703 hw->phy.ops.reset(hw);
704 }
721 705
706no_phy_reset:
722 /* 707 /*
723 * Prevent the PCI-E bus from from hanging by disabling PCI-E master 708 * Prevent the PCI-E bus from from hanging by disabling PCI-E master
724 * access and verify no pending requests before reset 709 * access and verify no pending requests before reset
725 */ 710 */
726 if (ixgbe_disable_pcie_master(hw) != 0) { 711 status = ixgbe_disable_pcie_master(hw);
712 if (status != 0) {
727 status = IXGBE_ERR_MASTER_REQUESTS_PENDING; 713 status = IXGBE_ERR_MASTER_REQUESTS_PENDING;
728 hw_dbg(hw, "PCI-E Master disable polling has failed.\n"); 714 hw_dbg(hw, "PCI-E Master disable polling has failed.\n");
729 } 715 }
@@ -767,9 +753,19 @@ static s32 ixgbe_reset_hw_82598(struct ixgbe_hw *hw)
767 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, hw->mac.orig_autoc); 753 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, hw->mac.orig_autoc);
768 } 754 }
769 755
756 /*
757 * Store MAC address from RAR0, clear receive address registers, and
758 * clear the multicast table
759 */
760 hw->mac.ops.init_rx_addrs(hw);
761
770 /* Store the permanent mac address */ 762 /* Store the permanent mac address */
771 hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr); 763 hw->mac.ops.get_mac_addr(hw, hw->mac.perm_addr);
772 764
765reset_hw_out:
766 if (phy_status)
767 status = phy_status;
768
773 return status; 769 return status;
774} 770}
775 771
@@ -954,14 +950,14 @@ static s32 ixgbe_read_i2c_eeprom_82598(struct ixgbe_hw *hw, u8 byte_offset,
954 sfp_addr = (sfp_addr | IXGBE_I2C_EEPROM_READ_MASK); 950 sfp_addr = (sfp_addr | IXGBE_I2C_EEPROM_READ_MASK);
955 hw->phy.ops.write_reg(hw, 951 hw->phy.ops.write_reg(hw,
956 IXGBE_MDIO_PMA_PMD_SDA_SCL_ADDR, 952 IXGBE_MDIO_PMA_PMD_SDA_SCL_ADDR,
957 IXGBE_MDIO_PMA_PMD_DEV_TYPE, 953 MDIO_MMD_PMAPMD,
958 sfp_addr); 954 sfp_addr);
959 955
960 /* Poll status */ 956 /* Poll status */
961 for (i = 0; i < 100; i++) { 957 for (i = 0; i < 100; i++) {
962 hw->phy.ops.read_reg(hw, 958 hw->phy.ops.read_reg(hw,
963 IXGBE_MDIO_PMA_PMD_SDA_SCL_STAT, 959 IXGBE_MDIO_PMA_PMD_SDA_SCL_STAT,
964 IXGBE_MDIO_PMA_PMD_DEV_TYPE, 960 MDIO_MMD_PMAPMD,
965 &sfp_stat); 961 &sfp_stat);
966 sfp_stat = sfp_stat & IXGBE_I2C_EEPROM_STATUS_MASK; 962 sfp_stat = sfp_stat & IXGBE_I2C_EEPROM_STATUS_MASK;
967 if (sfp_stat != IXGBE_I2C_EEPROM_STATUS_IN_PROGRESS) 963 if (sfp_stat != IXGBE_I2C_EEPROM_STATUS_IN_PROGRESS)
@@ -977,7 +973,7 @@ static s32 ixgbe_read_i2c_eeprom_82598(struct ixgbe_hw *hw, u8 byte_offset,
977 973
978 /* Read data */ 974 /* Read data */
979 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PMA_PMD_SDA_SCL_DATA, 975 hw->phy.ops.read_reg(hw, IXGBE_MDIO_PMA_PMD_SDA_SCL_DATA,
980 IXGBE_MDIO_PMA_PMD_DEV_TYPE, &sfp_data); 976 MDIO_MMD_PMAPMD, &sfp_data);
981 977
982 *eeprom_data = (u8)(sfp_data >> 8); 978 *eeprom_data = (u8)(sfp_data >> 8);
983 } else { 979 } else {
@@ -998,35 +994,56 @@ out:
998static u32 ixgbe_get_supported_physical_layer_82598(struct ixgbe_hw *hw) 994static u32 ixgbe_get_supported_physical_layer_82598(struct ixgbe_hw *hw)
999{ 995{
1000 u32 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN; 996 u32 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
997 u32 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
998 u32 pma_pmd_10g = autoc & IXGBE_AUTOC_10G_PMA_PMD_MASK;
999 u32 pma_pmd_1g = autoc & IXGBE_AUTOC_1G_PMA_PMD_MASK;
1000 u16 ext_ability = 0;
1001
1002 hw->phy.ops.identify(hw);
1003
1004 /* Copper PHY must be checked before AUTOC LMS to determine correct
1005 * physical layer because 10GBase-T PHYs use LMS = KX4/KX */
1006 if (hw->phy.type == ixgbe_phy_tn ||
1007 hw->phy.type == ixgbe_phy_cu_unknown) {
1008 hw->phy.ops.read_reg(hw, MDIO_PMA_EXTABLE, MDIO_MMD_PMAPMD,
1009 &ext_ability);
1010 if (ext_ability & MDIO_PMA_EXTABLE_10GBT)
1011 physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_T;
1012 if (ext_ability & MDIO_PMA_EXTABLE_1000BT)
1013 physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_T;
1014 if (ext_ability & MDIO_PMA_EXTABLE_100BTX)
1015 physical_layer |= IXGBE_PHYSICAL_LAYER_100BASE_TX;
1016 goto out;
1017 }
1001 1018
1002 switch (hw->device_id) { 1019 switch (autoc & IXGBE_AUTOC_LMS_MASK) {
1003 case IXGBE_DEV_ID_82598: 1020 case IXGBE_AUTOC_LMS_1G_AN:
1004 /* Default device ID is mezzanine card KX/KX4 */ 1021 case IXGBE_AUTOC_LMS_1G_LINK_NO_AN:
1005 physical_layer = (IXGBE_PHYSICAL_LAYER_10GBASE_KX4 | 1022 if (pma_pmd_1g == IXGBE_AUTOC_1G_KX)
1006 IXGBE_PHYSICAL_LAYER_1000BASE_KX); 1023 physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_KX;
1007 break; 1024 else
1008 case IXGBE_DEV_ID_82598_BX: 1025 physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_BX;
1009 physical_layer = IXGBE_PHYSICAL_LAYER_1000BASE_BX;
1010 case IXGBE_DEV_ID_82598EB_CX4:
1011 case IXGBE_DEV_ID_82598_CX4_DUAL_PORT:
1012 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_CX4;
1013 break;
1014 case IXGBE_DEV_ID_82598_DA_DUAL_PORT:
1015 physical_layer = IXGBE_PHYSICAL_LAYER_SFP_PLUS_CU;
1016 break; 1026 break;
1017 case IXGBE_DEV_ID_82598AF_DUAL_PORT: 1027 case IXGBE_AUTOC_LMS_10G_LINK_NO_AN:
1018 case IXGBE_DEV_ID_82598AF_SINGLE_PORT: 1028 if (pma_pmd_10g == IXGBE_AUTOC_10G_CX4)
1019 case IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM: 1029 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_CX4;
1020 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_SR; 1030 else if (pma_pmd_10g == IXGBE_AUTOC_10G_KX4)
1031 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_KX4;
1032 else /* XAUI */
1033 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
1021 break; 1034 break;
1022 case IXGBE_DEV_ID_82598EB_XF_LR: 1035 case IXGBE_AUTOC_LMS_KX4_AN:
1023 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_LR; 1036 case IXGBE_AUTOC_LMS_KX4_AN_1G_AN:
1037 if (autoc & IXGBE_AUTOC_KX_SUPP)
1038 physical_layer |= IXGBE_PHYSICAL_LAYER_1000BASE_KX;
1039 if (autoc & IXGBE_AUTOC_KX4_SUPP)
1040 physical_layer |= IXGBE_PHYSICAL_LAYER_10GBASE_KX4;
1024 break; 1041 break;
1025 case IXGBE_DEV_ID_82598AT: 1042 default:
1026 physical_layer = (IXGBE_PHYSICAL_LAYER_10GBASE_T |
1027 IXGBE_PHYSICAL_LAYER_1000BASE_T);
1028 break; 1043 break;
1029 case IXGBE_DEV_ID_82598EB_SFP_LOM: 1044 }
1045
1046 if (hw->phy.type == ixgbe_phy_nl) {
1030 hw->phy.ops.identify_sfp(hw); 1047 hw->phy.ops.identify_sfp(hw);
1031 1048
1032 switch (hw->phy.sfp_type) { 1049 switch (hw->phy.sfp_type) {
@@ -1043,13 +1060,25 @@ static u32 ixgbe_get_supported_physical_layer_82598(struct ixgbe_hw *hw)
1043 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN; 1060 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
1044 break; 1061 break;
1045 } 1062 }
1046 break; 1063 }
1047 1064
1065 switch (hw->device_id) {
1066 case IXGBE_DEV_ID_82598_DA_DUAL_PORT:
1067 physical_layer = IXGBE_PHYSICAL_LAYER_SFP_PLUS_CU;
1068 break;
1069 case IXGBE_DEV_ID_82598AF_DUAL_PORT:
1070 case IXGBE_DEV_ID_82598AF_SINGLE_PORT:
1071 case IXGBE_DEV_ID_82598_SR_DUAL_PORT_EM:
1072 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_SR;
1073 break;
1074 case IXGBE_DEV_ID_82598EB_XF_LR:
1075 physical_layer = IXGBE_PHYSICAL_LAYER_10GBASE_LR;
1076 break;
1048 default: 1077 default:
1049 physical_layer = IXGBE_PHYSICAL_LAYER_UNKNOWN;
1050 break; 1078 break;
1051 } 1079 }
1052 1080
1081out:
1053 return physical_layer; 1082 return physical_layer;
1054} 1083}
1055 1084
@@ -1086,7 +1115,7 @@ static struct ixgbe_mac_operations mac_ops_82598 = {
1086 .disable_mc = &ixgbe_disable_mc_generic, 1115 .disable_mc = &ixgbe_disable_mc_generic,
1087 .clear_vfta = &ixgbe_clear_vfta_82598, 1116 .clear_vfta = &ixgbe_clear_vfta_82598,
1088 .set_vfta = &ixgbe_set_vfta_82598, 1117 .set_vfta = &ixgbe_set_vfta_82598,
1089 .setup_fc = &ixgbe_setup_fc_82598, 1118 .fc_enable = &ixgbe_fc_enable_82598,
1090}; 1119};
1091 1120
1092static struct ixgbe_eeprom_operations eeprom_ops_82598 = { 1121static struct ixgbe_eeprom_operations eeprom_ops_82598 = {
@@ -1099,6 +1128,7 @@ static struct ixgbe_eeprom_operations eeprom_ops_82598 = {
1099static struct ixgbe_phy_operations phy_ops_82598 = { 1128static struct ixgbe_phy_operations phy_ops_82598 = {
1100 .identify = &ixgbe_identify_phy_generic, 1129 .identify = &ixgbe_identify_phy_generic,
1101 .identify_sfp = &ixgbe_identify_sfp_module_generic, 1130 .identify_sfp = &ixgbe_identify_sfp_module_generic,
1131 .init = &ixgbe_init_phy_ops_82598,
1102 .reset = &ixgbe_reset_phy_generic, 1132 .reset = &ixgbe_reset_phy_generic,
1103 .read_reg = &ixgbe_read_phy_reg_generic, 1133 .read_reg = &ixgbe_read_phy_reg_generic,
1104 .write_reg = &ixgbe_write_phy_reg_generic, 1134 .write_reg = &ixgbe_write_phy_reg_generic,