diff options
author | Emil Tantilov <emil.s.tantilov@intel.com> | 2011-02-25 02:49:39 -0500 |
---|---|---|
committer | Jeff Kirsher <jeffrey.t.kirsher@intel.com> | 2011-03-07 21:05:02 -0500 |
commit | 037c6d0a33453bf025c6d6b21e5a0fabe117a797 (patch) | |
tree | 008d21bef2889b7915850d9dddfa7ce110ee05f5 /drivers/net/ixgbe/ixgbe_82599.c | |
parent | 68a683cf6a5ff09faa366fc1fcf967add0211fe8 (diff) |
ixgbe: cleanup PHY init
This change cleans up several situations in which we were either stepping
over possible errors, or calling initialization routines multiple times.
Also includes whitespace fixes where applicable.
Signed-off-by: Emil Tantilov <emil.s.tantilov@intel.com>
Tested-by: Stephen Ko <stephen.s.ko@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ixgbe/ixgbe_82599.c')
-rw-r--r-- | drivers/net/ixgbe/ixgbe_82599.c | 121 |
1 files changed, 71 insertions, 50 deletions
diff --git a/drivers/net/ixgbe/ixgbe_82599.c b/drivers/net/ixgbe/ixgbe_82599.c index 5ef968a10d42..2f8b9f41714f 100644 --- a/drivers/net/ixgbe/ixgbe_82599.c +++ b/drivers/net/ixgbe/ixgbe_82599.c | |||
@@ -470,8 +470,6 @@ static void ixgbe_enable_tx_laser_multispeed_fiber(struct ixgbe_hw *hw) | |||
470 | **/ | 470 | **/ |
471 | static void ixgbe_flap_tx_laser_multispeed_fiber(struct ixgbe_hw *hw) | 471 | static void ixgbe_flap_tx_laser_multispeed_fiber(struct ixgbe_hw *hw) |
472 | { | 472 | { |
473 | hw_dbg(hw, "ixgbe_flap_tx_laser_multispeed_fiber\n"); | ||
474 | |||
475 | if (hw->mac.autotry_restart) { | 473 | if (hw->mac.autotry_restart) { |
476 | ixgbe_disable_tx_laser_multispeed_fiber(hw); | 474 | ixgbe_disable_tx_laser_multispeed_fiber(hw); |
477 | ixgbe_enable_tx_laser_multispeed_fiber(hw); | 475 | ixgbe_enable_tx_laser_multispeed_fiber(hw); |
@@ -494,17 +492,21 @@ s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw, | |||
494 | bool autoneg_wait_to_complete) | 492 | bool autoneg_wait_to_complete) |
495 | { | 493 | { |
496 | s32 status = 0; | 494 | s32 status = 0; |
497 | ixgbe_link_speed phy_link_speed; | 495 | ixgbe_link_speed link_speed = IXGBE_LINK_SPEED_UNKNOWN; |
498 | ixgbe_link_speed highest_link_speed = IXGBE_LINK_SPEED_UNKNOWN; | 496 | ixgbe_link_speed highest_link_speed = IXGBE_LINK_SPEED_UNKNOWN; |
499 | u32 speedcnt = 0; | 497 | u32 speedcnt = 0; |
500 | u32 esdp_reg = IXGBE_READ_REG(hw, IXGBE_ESDP); | 498 | u32 esdp_reg = IXGBE_READ_REG(hw, IXGBE_ESDP); |
499 | u32 i = 0; | ||
501 | bool link_up = false; | 500 | bool link_up = false; |
502 | bool negotiation; | 501 | bool negotiation; |
503 | int i; | ||
504 | 502 | ||
505 | /* Mask off requested but non-supported speeds */ | 503 | /* Mask off requested but non-supported speeds */ |
506 | hw->mac.ops.get_link_capabilities(hw, &phy_link_speed, &negotiation); | 504 | status = hw->mac.ops.get_link_capabilities(hw, &link_speed, |
507 | speed &= phy_link_speed; | 505 | &negotiation); |
506 | if (status != 0) | ||
507 | return status; | ||
508 | |||
509 | speed &= link_speed; | ||
508 | 510 | ||
509 | /* | 511 | /* |
510 | * Try each speed one by one, highest priority first. We do this in | 512 | * Try each speed one by one, highest priority first. We do this in |
@@ -515,9 +517,12 @@ s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw, | |||
515 | highest_link_speed = IXGBE_LINK_SPEED_10GB_FULL; | 517 | highest_link_speed = IXGBE_LINK_SPEED_10GB_FULL; |
516 | 518 | ||
517 | /* If we already have link at this speed, just jump out */ | 519 | /* If we already have link at this speed, just jump out */ |
518 | hw->mac.ops.check_link(hw, &phy_link_speed, &link_up, false); | 520 | status = hw->mac.ops.check_link(hw, &link_speed, &link_up, |
521 | false); | ||
522 | if (status != 0) | ||
523 | return status; | ||
519 | 524 | ||
520 | if ((phy_link_speed == IXGBE_LINK_SPEED_10GB_FULL) && link_up) | 525 | if ((link_speed == IXGBE_LINK_SPEED_10GB_FULL) && link_up) |
521 | goto out; | 526 | goto out; |
522 | 527 | ||
523 | /* Set the module link speed */ | 528 | /* Set the module link speed */ |
@@ -529,9 +534,9 @@ s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw, | |||
529 | msleep(40); | 534 | msleep(40); |
530 | 535 | ||
531 | status = ixgbe_setup_mac_link_82599(hw, | 536 | status = ixgbe_setup_mac_link_82599(hw, |
532 | IXGBE_LINK_SPEED_10GB_FULL, | 537 | IXGBE_LINK_SPEED_10GB_FULL, |
533 | autoneg, | 538 | autoneg, |
534 | autoneg_wait_to_complete); | 539 | autoneg_wait_to_complete); |
535 | if (status != 0) | 540 | if (status != 0) |
536 | return status; | 541 | return status; |
537 | 542 | ||
@@ -548,8 +553,11 @@ s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw, | |||
548 | msleep(100); | 553 | msleep(100); |
549 | 554 | ||
550 | /* If we have link, just jump out */ | 555 | /* If we have link, just jump out */ |
551 | hw->mac.ops.check_link(hw, &phy_link_speed, | 556 | status = hw->mac.ops.check_link(hw, &link_speed, |
552 | &link_up, false); | 557 | &link_up, false); |
558 | if (status != 0) | ||
559 | return status; | ||
560 | |||
553 | if (link_up) | 561 | if (link_up) |
554 | goto out; | 562 | goto out; |
555 | } | 563 | } |
@@ -561,9 +569,12 @@ s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw, | |||
561 | highest_link_speed = IXGBE_LINK_SPEED_1GB_FULL; | 569 | highest_link_speed = IXGBE_LINK_SPEED_1GB_FULL; |
562 | 570 | ||
563 | /* If we already have link at this speed, just jump out */ | 571 | /* If we already have link at this speed, just jump out */ |
564 | hw->mac.ops.check_link(hw, &phy_link_speed, &link_up, false); | 572 | status = hw->mac.ops.check_link(hw, &link_speed, &link_up, |
573 | false); | ||
574 | if (status != 0) | ||
575 | return status; | ||
565 | 576 | ||
566 | if ((phy_link_speed == IXGBE_LINK_SPEED_1GB_FULL) && link_up) | 577 | if ((link_speed == IXGBE_LINK_SPEED_1GB_FULL) && link_up) |
567 | goto out; | 578 | goto out; |
568 | 579 | ||
569 | /* Set the module link speed */ | 580 | /* Set the module link speed */ |
@@ -576,9 +587,9 @@ s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw, | |||
576 | msleep(40); | 587 | msleep(40); |
577 | 588 | ||
578 | status = ixgbe_setup_mac_link_82599(hw, | 589 | status = ixgbe_setup_mac_link_82599(hw, |
579 | IXGBE_LINK_SPEED_1GB_FULL, | 590 | IXGBE_LINK_SPEED_1GB_FULL, |
580 | autoneg, | 591 | autoneg, |
581 | autoneg_wait_to_complete); | 592 | autoneg_wait_to_complete); |
582 | if (status != 0) | 593 | if (status != 0) |
583 | return status; | 594 | return status; |
584 | 595 | ||
@@ -589,7 +600,11 @@ s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw, | |||
589 | msleep(100); | 600 | msleep(100); |
590 | 601 | ||
591 | /* If we have link, just jump out */ | 602 | /* If we have link, just jump out */ |
592 | hw->mac.ops.check_link(hw, &phy_link_speed, &link_up, false); | 603 | status = hw->mac.ops.check_link(hw, &link_speed, &link_up, |
604 | false); | ||
605 | if (status != 0) | ||
606 | return status; | ||
607 | |||
593 | if (link_up) | 608 | if (link_up) |
594 | goto out; | 609 | goto out; |
595 | } | 610 | } |
@@ -632,13 +647,10 @@ static s32 ixgbe_setup_mac_link_smartspeed(struct ixgbe_hw *hw, | |||
632 | bool autoneg_wait_to_complete) | 647 | bool autoneg_wait_to_complete) |
633 | { | 648 | { |
634 | s32 status = 0; | 649 | s32 status = 0; |
635 | ixgbe_link_speed link_speed; | 650 | ixgbe_link_speed link_speed = IXGBE_LINK_SPEED_UNKNOWN; |
636 | s32 i, j; | 651 | s32 i, j; |
637 | bool link_up = false; | 652 | bool link_up = false; |
638 | u32 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC); | 653 | u32 autoc_reg = IXGBE_READ_REG(hw, IXGBE_AUTOC); |
639 | struct ixgbe_adapter *adapter = hw->back; | ||
640 | |||
641 | hw_dbg(hw, "ixgbe_setup_mac_link_smartspeed.\n"); | ||
642 | 654 | ||
643 | /* Set autoneg_advertised value based on input link speed */ | 655 | /* Set autoneg_advertised value based on input link speed */ |
644 | hw->phy.autoneg_advertised = 0; | 656 | hw->phy.autoneg_advertised = 0; |
@@ -664,7 +676,7 @@ static s32 ixgbe_setup_mac_link_smartspeed(struct ixgbe_hw *hw, | |||
664 | for (j = 0; j < IXGBE_SMARTSPEED_MAX_RETRIES; j++) { | 676 | for (j = 0; j < IXGBE_SMARTSPEED_MAX_RETRIES; j++) { |
665 | status = ixgbe_setup_mac_link_82599(hw, speed, autoneg, | 677 | status = ixgbe_setup_mac_link_82599(hw, speed, autoneg, |
666 | autoneg_wait_to_complete); | 678 | autoneg_wait_to_complete); |
667 | if (status) | 679 | if (status != 0) |
668 | goto out; | 680 | goto out; |
669 | 681 | ||
670 | /* | 682 | /* |
@@ -677,8 +689,11 @@ static s32 ixgbe_setup_mac_link_smartspeed(struct ixgbe_hw *hw, | |||
677 | mdelay(100); | 689 | mdelay(100); |
678 | 690 | ||
679 | /* If we have link, just jump out */ | 691 | /* If we have link, just jump out */ |
680 | hw->mac.ops.check_link(hw, &link_speed, | 692 | status = hw->mac.ops.check_link(hw, &link_speed, |
681 | &link_up, false); | 693 | &link_up, false); |
694 | if (status != 0) | ||
695 | goto out; | ||
696 | |||
682 | if (link_up) | 697 | if (link_up) |
683 | goto out; | 698 | goto out; |
684 | } | 699 | } |
@@ -696,7 +711,7 @@ static s32 ixgbe_setup_mac_link_smartspeed(struct ixgbe_hw *hw, | |||
696 | hw->phy.smart_speed_active = true; | 711 | hw->phy.smart_speed_active = true; |
697 | status = ixgbe_setup_mac_link_82599(hw, speed, autoneg, | 712 | status = ixgbe_setup_mac_link_82599(hw, speed, autoneg, |
698 | autoneg_wait_to_complete); | 713 | autoneg_wait_to_complete); |
699 | if (status) | 714 | if (status != 0) |
700 | goto out; | 715 | goto out; |
701 | 716 | ||
702 | /* | 717 | /* |
@@ -709,8 +724,11 @@ static s32 ixgbe_setup_mac_link_smartspeed(struct ixgbe_hw *hw, | |||
709 | mdelay(100); | 724 | mdelay(100); |
710 | 725 | ||
711 | /* If we have link, just jump out */ | 726 | /* If we have link, just jump out */ |
712 | hw->mac.ops.check_link(hw, &link_speed, | 727 | status = hw->mac.ops.check_link(hw, &link_speed, |
713 | &link_up, false); | 728 | &link_up, false); |
729 | if (status != 0) | ||
730 | goto out; | ||
731 | |||
714 | if (link_up) | 732 | if (link_up) |
715 | goto out; | 733 | goto out; |
716 | } | 734 | } |
@@ -722,7 +740,7 @@ static s32 ixgbe_setup_mac_link_smartspeed(struct ixgbe_hw *hw, | |||
722 | 740 | ||
723 | out: | 741 | out: |
724 | if (link_up && (link_speed == IXGBE_LINK_SPEED_1GB_FULL)) | 742 | if (link_up && (link_speed == IXGBE_LINK_SPEED_1GB_FULL)) |
725 | e_info(hw, "Smartspeed has downgraded the link speed from " | 743 | hw_dbg(hw, "Smartspeed has downgraded the link speed from " |
726 | "the maximum advertised\n"); | 744 | "the maximum advertised\n"); |
727 | return status; | 745 | return status; |
728 | } | 746 | } |
@@ -883,7 +901,7 @@ static s32 ixgbe_reset_hw_82599(struct ixgbe_hw *hw) | |||
883 | 901 | ||
884 | /* PHY ops must be identified and initialized prior to reset */ | 902 | /* PHY ops must be identified and initialized prior to reset */ |
885 | 903 | ||
886 | /* Init PHY and function pointers, perform SFP setup */ | 904 | /* Identify PHY and related function pointers */ |
887 | status = hw->phy.ops.init(hw); | 905 | status = hw->phy.ops.init(hw); |
888 | 906 | ||
889 | if (status == IXGBE_ERR_SFP_NOT_SUPPORTED) | 907 | if (status == IXGBE_ERR_SFP_NOT_SUPPORTED) |
@@ -895,6 +913,9 @@ static s32 ixgbe_reset_hw_82599(struct ixgbe_hw *hw) | |||
895 | hw->phy.sfp_setup_needed = false; | 913 | hw->phy.sfp_setup_needed = false; |
896 | } | 914 | } |
897 | 915 | ||
916 | if (status == IXGBE_ERR_SFP_NOT_SUPPORTED) | ||
917 | goto reset_hw_out; | ||
918 | |||
898 | /* Reset PHY */ | 919 | /* Reset PHY */ |
899 | if (hw->phy.reset_disable == false && hw->phy.ops.reset != NULL) | 920 | if (hw->phy.reset_disable == false && hw->phy.ops.reset != NULL) |
900 | hw->phy.ops.reset(hw); | 921 | hw->phy.ops.reset(hw); |
@@ -2051,28 +2072,28 @@ static struct ixgbe_mac_operations mac_ops_82599 = { | |||
2051 | }; | 2072 | }; |
2052 | 2073 | ||
2053 | static struct ixgbe_eeprom_operations eeprom_ops_82599 = { | 2074 | static struct ixgbe_eeprom_operations eeprom_ops_82599 = { |
2054 | .init_params = &ixgbe_init_eeprom_params_generic, | 2075 | .init_params = &ixgbe_init_eeprom_params_generic, |
2055 | .read = &ixgbe_read_eerd_generic, | 2076 | .read = &ixgbe_read_eerd_generic, |
2056 | .write = &ixgbe_write_eeprom_generic, | 2077 | .write = &ixgbe_write_eeprom_generic, |
2057 | .calc_checksum = &ixgbe_calc_eeprom_checksum_generic, | 2078 | .calc_checksum = &ixgbe_calc_eeprom_checksum_generic, |
2058 | .validate_checksum = &ixgbe_validate_eeprom_checksum_generic, | 2079 | .validate_checksum = &ixgbe_validate_eeprom_checksum_generic, |
2059 | .update_checksum = &ixgbe_update_eeprom_checksum_generic, | 2080 | .update_checksum = &ixgbe_update_eeprom_checksum_generic, |
2060 | }; | 2081 | }; |
2061 | 2082 | ||
2062 | static struct ixgbe_phy_operations phy_ops_82599 = { | 2083 | static struct ixgbe_phy_operations phy_ops_82599 = { |
2063 | .identify = &ixgbe_identify_phy_82599, | 2084 | .identify = &ixgbe_identify_phy_82599, |
2064 | .identify_sfp = &ixgbe_identify_sfp_module_generic, | 2085 | .identify_sfp = &ixgbe_identify_sfp_module_generic, |
2065 | .init = &ixgbe_init_phy_ops_82599, | 2086 | .init = &ixgbe_init_phy_ops_82599, |
2066 | .reset = &ixgbe_reset_phy_generic, | 2087 | .reset = &ixgbe_reset_phy_generic, |
2067 | .read_reg = &ixgbe_read_phy_reg_generic, | 2088 | .read_reg = &ixgbe_read_phy_reg_generic, |
2068 | .write_reg = &ixgbe_write_phy_reg_generic, | 2089 | .write_reg = &ixgbe_write_phy_reg_generic, |
2069 | .setup_link = &ixgbe_setup_phy_link_generic, | 2090 | .setup_link = &ixgbe_setup_phy_link_generic, |
2070 | .setup_link_speed = &ixgbe_setup_phy_link_speed_generic, | 2091 | .setup_link_speed = &ixgbe_setup_phy_link_speed_generic, |
2071 | .read_i2c_byte = &ixgbe_read_i2c_byte_generic, | 2092 | .read_i2c_byte = &ixgbe_read_i2c_byte_generic, |
2072 | .write_i2c_byte = &ixgbe_write_i2c_byte_generic, | 2093 | .write_i2c_byte = &ixgbe_write_i2c_byte_generic, |
2073 | .read_i2c_eeprom = &ixgbe_read_i2c_eeprom_generic, | 2094 | .read_i2c_eeprom = &ixgbe_read_i2c_eeprom_generic, |
2074 | .write_i2c_eeprom = &ixgbe_write_i2c_eeprom_generic, | 2095 | .write_i2c_eeprom = &ixgbe_write_i2c_eeprom_generic, |
2075 | .check_overtemp = &ixgbe_tn_check_overtemp, | 2096 | .check_overtemp = &ixgbe_tn_check_overtemp, |
2076 | }; | 2097 | }; |
2077 | 2098 | ||
2078 | struct ixgbe_info ixgbe_82599_info = { | 2099 | struct ixgbe_info ixgbe_82599_info = { |