aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ixgbe/ixgbe_82599.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/ixgbe/ixgbe_82599.c')
-rw-r--r--drivers/net/ixgbe/ixgbe_82599.c120
1 files changed, 99 insertions, 21 deletions
diff --git a/drivers/net/ixgbe/ixgbe_82599.c b/drivers/net/ixgbe/ixgbe_82599.c
index a7611bbf3873..84b83f7b473f 100644
--- a/drivers/net/ixgbe/ixgbe_82599.c
+++ b/drivers/net/ixgbe/ixgbe_82599.c
@@ -461,12 +461,23 @@ s32 ixgbe_setup_mac_link_speed_multispeed_fiber(struct ixgbe_hw *hw,
461 u32 esdp_reg = IXGBE_READ_REG(hw, IXGBE_ESDP); 461 u32 esdp_reg = IXGBE_READ_REG(hw, IXGBE_ESDP);
462 bool link_up = false; 462 bool link_up = false;
463 bool negotiation; 463 bool negotiation;
464 int i;
464 465
465 /* Mask off requested but non-supported speeds */ 466 /* Mask off requested but non-supported speeds */
466 hw->mac.ops.get_link_capabilities(hw, &phy_link_speed, &negotiation); 467 hw->mac.ops.get_link_capabilities(hw, &phy_link_speed, &negotiation);
467 speed &= phy_link_speed; 468 speed &= phy_link_speed;
468 469
469 /* 470 /*
471 * When the driver changes the link speeds that it can support,
472 * it sets autotry_restart to true to indicate that we need to
473 * initiate a new autotry session with the link partner. To do
474 * so, we set the speed then disable and re-enable the tx laser, to
475 * alert the link partner that it also needs to restart autotry on its
476 * end. This is consistent with true clause 37 autoneg, which also
477 * involves a loss of signal.
478 */
479
480 /*
470 * Try each speed one by one, highest priority first. We do this in 481 * Try each speed one by one, highest priority first. We do this in
471 * software because 10gb fiber doesn't support speed autonegotiation. 482 * software because 10gb fiber doesn't support speed autonegotiation.
472 */ 483 */
@@ -474,21 +485,52 @@ s32 ixgbe_setup_mac_link_speed_multispeed_fiber(struct ixgbe_hw *hw,
474 speedcnt++; 485 speedcnt++;
475 highest_link_speed = IXGBE_LINK_SPEED_10GB_FULL; 486 highest_link_speed = IXGBE_LINK_SPEED_10GB_FULL;
476 487
477 /* Set hardware SDP's */ 488 /* If we already have link at this speed, just jump out */
489 hw->mac.ops.check_link(hw, &phy_link_speed, &link_up, false);
490
491 if ((phy_link_speed == IXGBE_LINK_SPEED_10GB_FULL) && link_up)
492 goto out;
493
494 /* Set the module link speed */
478 esdp_reg |= (IXGBE_ESDP_SDP5_DIR | IXGBE_ESDP_SDP5); 495 esdp_reg |= (IXGBE_ESDP_SDP5_DIR | IXGBE_ESDP_SDP5);
479 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg); 496 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
480 497
481 ixgbe_setup_mac_link_speed_82599(hw, 498 /* Allow module to change analog characteristics (1G->10G) */
482 IXGBE_LINK_SPEED_10GB_FULL, 499 msleep(40);
483 autoneg,
484 autoneg_wait_to_complete);
485
486 msleep(50);
487 500
488 /* If we have link, just jump out */ 501 status = ixgbe_setup_mac_link_speed_82599(hw,
489 hw->mac.ops.check_link(hw, &phy_link_speed, &link_up, false); 502 IXGBE_LINK_SPEED_10GB_FULL,
490 if (link_up) 503 autoneg,
504 autoneg_wait_to_complete);
505 if (status != 0)
491 goto out; 506 goto out;
507
508 /* Flap the tx laser if it has not already been done */
509 if (hw->mac.autotry_restart) {
510 /* Disable tx laser; allow 100us to go dark per spec */
511 esdp_reg |= IXGBE_ESDP_SDP3;
512 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
513 udelay(100);
514
515 /* Enable tx laser; allow 2ms to light up per spec */
516 esdp_reg &= ~IXGBE_ESDP_SDP3;
517 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
518 msleep(2);
519
520 hw->mac.autotry_restart = false;
521 }
522
523 /* The controller may take up to 500ms at 10g to acquire link */
524 for (i = 0; i < 5; i++) {
525 /* Wait for the link partner to also set speed */
526 msleep(100);
527
528 /* If we have link, just jump out */
529 hw->mac.ops.check_link(hw, &phy_link_speed,
530 &link_up, false);
531 if (link_up)
532 goto out;
533 }
492 } 534 }
493 535
494 if (speed & IXGBE_LINK_SPEED_1GB_FULL) { 536 if (speed & IXGBE_LINK_SPEED_1GB_FULL) {
@@ -496,16 +538,44 @@ s32 ixgbe_setup_mac_link_speed_multispeed_fiber(struct ixgbe_hw *hw,
496 if (highest_link_speed == IXGBE_LINK_SPEED_UNKNOWN) 538 if (highest_link_speed == IXGBE_LINK_SPEED_UNKNOWN)
497 highest_link_speed = IXGBE_LINK_SPEED_1GB_FULL; 539 highest_link_speed = IXGBE_LINK_SPEED_1GB_FULL;
498 540
499 /* Set hardware SDP's */ 541 /* If we already have link at this speed, just jump out */
542 hw->mac.ops.check_link(hw, &phy_link_speed, &link_up, false);
543
544 if ((phy_link_speed == IXGBE_LINK_SPEED_1GB_FULL) && link_up)
545 goto out;
546
547 /* Set the module link speed */
500 esdp_reg &= ~IXGBE_ESDP_SDP5; 548 esdp_reg &= ~IXGBE_ESDP_SDP5;
501 esdp_reg |= IXGBE_ESDP_SDP5_DIR; 549 esdp_reg |= IXGBE_ESDP_SDP5_DIR;
502 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg); 550 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
503 551
504 ixgbe_setup_mac_link_speed_82599( 552 /* Allow module to change analog characteristics (10G->1G) */
505 hw, IXGBE_LINK_SPEED_1GB_FULL, autoneg, 553 msleep(40);
506 autoneg_wait_to_complete);
507 554
508 msleep(50); 555 status = ixgbe_setup_mac_link_speed_82599(hw,
556 IXGBE_LINK_SPEED_1GB_FULL,
557 autoneg,
558 autoneg_wait_to_complete);
559 if (status != 0)
560 goto out;
561
562 /* Flap the tx laser if it has not already been done */
563 if (hw->mac.autotry_restart) {
564 /* Disable tx laser; allow 100us to go dark per spec */
565 esdp_reg |= IXGBE_ESDP_SDP3;
566 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
567 udelay(100);
568
569 /* Enable tx laser; allow 2ms to light up per spec */
570 esdp_reg &= ~IXGBE_ESDP_SDP3;
571 IXGBE_WRITE_REG(hw, IXGBE_ESDP, esdp_reg);
572 msleep(2);
573
574 hw->mac.autotry_restart = false;
575 }
576
577 /* Wait for the link partner to also set speed */
578 msleep(100);
509 579
510 /* If we have link, just jump out */ 580 /* If we have link, just jump out */
511 hw->mac.ops.check_link(hw, &phy_link_speed, &link_up, false); 581 hw->mac.ops.check_link(hw, &phy_link_speed, &link_up, false);
@@ -591,6 +661,7 @@ s32 ixgbe_setup_mac_link_speed_82599(struct ixgbe_hw *hw,
591 s32 status = 0; 661 s32 status = 0;
592 u32 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC); 662 u32 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC);
593 u32 autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2); 663 u32 autoc2 = IXGBE_READ_REG(hw, IXGBE_AUTOC2);
664 u32 start_autoc = autoc;
594 u32 orig_autoc = 0; 665 u32 orig_autoc = 0;
595 u32 link_mode = autoc & IXGBE_AUTOC_LMS_MASK; 666 u32 link_mode = autoc & IXGBE_AUTOC_LMS_MASK;
596 u32 pma_pmd_1g = autoc & IXGBE_AUTOC_1G_PMA_PMD_MASK; 667 u32 pma_pmd_1g = autoc & IXGBE_AUTOC_1G_PMA_PMD_MASK;
@@ -603,6 +674,11 @@ s32 ixgbe_setup_mac_link_speed_82599(struct ixgbe_hw *hw,
603 hw->mac.ops.get_link_capabilities(hw, &link_capabilities, &autoneg); 674 hw->mac.ops.get_link_capabilities(hw, &link_capabilities, &autoneg);
604 speed &= link_capabilities; 675 speed &= link_capabilities;
605 676
677 if (speed == IXGBE_LINK_SPEED_UNKNOWN) {
678 status = IXGBE_ERR_LINK_SETUP;
679 goto out;
680 }
681
606 /* Use stored value (EEPROM defaults) of AUTOC to find KR/KX4 support*/ 682 /* Use stored value (EEPROM defaults) of AUTOC to find KR/KX4 support*/
607 if (hw->mac.orig_link_settings_stored) 683 if (hw->mac.orig_link_settings_stored)
608 orig_autoc = hw->mac.orig_autoc; 684 orig_autoc = hw->mac.orig_autoc;
@@ -610,11 +686,9 @@ s32 ixgbe_setup_mac_link_speed_82599(struct ixgbe_hw *hw,
610 orig_autoc = autoc; 686 orig_autoc = autoc;
611 687
612 688
613 if (speed == IXGBE_LINK_SPEED_UNKNOWN) { 689 if (link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR ||
614 status = IXGBE_ERR_LINK_SETUP; 690 link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN ||
615 } else if (link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR || 691 link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII) {
616 link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR_1G_AN ||
617 link_mode == IXGBE_AUTOC_LMS_KX4_KX_KR_SGMII) {
618 /* Set KX4/KX/KR support according to speed requested */ 692 /* Set KX4/KX/KR support according to speed requested */
619 autoc &= ~(IXGBE_AUTOC_KX4_KX_SUPP_MASK | IXGBE_AUTOC_KR_SUPP); 693 autoc &= ~(IXGBE_AUTOC_KX4_KX_SUPP_MASK | IXGBE_AUTOC_KR_SUPP);
620 if (speed & IXGBE_LINK_SPEED_10GB_FULL) 694 if (speed & IXGBE_LINK_SPEED_10GB_FULL)
@@ -646,7 +720,7 @@ s32 ixgbe_setup_mac_link_speed_82599(struct ixgbe_hw *hw,
646 } 720 }
647 } 721 }
648 722
649 if (status == 0) { 723 if (autoc != start_autoc) {
650 /* Restart link */ 724 /* Restart link */
651 autoc |= IXGBE_AUTOC_AN_RESTART; 725 autoc |= IXGBE_AUTOC_AN_RESTART;
652 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc); 726 IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc);
@@ -680,6 +754,7 @@ s32 ixgbe_setup_mac_link_speed_82599(struct ixgbe_hw *hw,
680 msleep(50); 754 msleep(50);
681 } 755 }
682 756
757out:
683 return status; 758 return status;
684} 759}
685 760
@@ -1144,6 +1219,9 @@ s32 ixgbe_start_hw_82599(struct ixgbe_hw *hw)
1144 } 1219 }
1145 IXGBE_WRITE_FLUSH(hw); 1220 IXGBE_WRITE_FLUSH(hw);
1146 1221
1222 /* We need to run link autotry after the driver loads */
1223 hw->mac.autotry_restart = true;
1224
1147 return 0; 1225 return 0;
1148} 1226}
1149 1227