diff options
author | Mallikarjuna R Chilakala <mallikarjuna.chilakala@intel.com> | 2009-09-01 09:49:35 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-09-01 20:40:14 -0400 |
commit | 8620a103b5e38d952280f3d97b5e1bcce8d7874c (patch) | |
tree | edb7b63d24fe6208529cef8fadffbdcd12972f6e /drivers/net/ixgbe/ixgbe_82599.c | |
parent | fd38d7a0a0618656e491ed67af735bc4e3600367 (diff) |
ixgbe: refactor link setup code
Link code cleanup: a number of redundant functions and MAC variables are cleaned up,
with some functions being consolidated into a single-purpose code path.
Removed following deprecated link functions and mac variables
* ixgbe_setup_copper_link_speed_82598
* ixgbe_setup_mac_link_speed_multispeed_fiber
* ixgbe_setup_mac_link_speed_82599
* mac.autoneg, mac.autoneg_succeeded, phy.autoneg_wait_to_complete
Signed-off-by: Mallikarjuna R Chilakala <mallikarjuna.chilakala@intel.com>
Acked-by: Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ixgbe/ixgbe_82599.c')
-rw-r--r-- | drivers/net/ixgbe/ixgbe_82599.c | 135 |
1 files changed, 45 insertions, 90 deletions
diff --git a/drivers/net/ixgbe/ixgbe_82599.c b/drivers/net/ixgbe/ixgbe_82599.c index 364b6d2279e..5ee56085526 100644 --- a/drivers/net/ixgbe/ixgbe_82599.c +++ b/drivers/net/ixgbe/ixgbe_82599.c | |||
@@ -38,23 +38,23 @@ | |||
38 | #define IXGBE_82599_MC_TBL_SIZE 128 | 38 | #define IXGBE_82599_MC_TBL_SIZE 128 |
39 | #define IXGBE_82599_VFT_TBL_SIZE 128 | 39 | #define IXGBE_82599_VFT_TBL_SIZE 128 |
40 | 40 | ||
41 | static s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw); | 41 | s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw, |
42 | static s32 ixgbe_setup_mac_link_speed_multispeed_fiber(struct ixgbe_hw *hw, | 42 | ixgbe_link_speed speed, |
43 | ixgbe_link_speed speed, bool autoneg, | 43 | bool autoneg, |
44 | bool autoneg_wait_to_complete); | 44 | bool autoneg_wait_to_complete); |
45 | static s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw); | 45 | s32 ixgbe_start_mac_link_82599(struct ixgbe_hw *hw, |
46 | static s32 ixgbe_setup_mac_link_speed_82599(struct ixgbe_hw *hw, | 46 | bool autoneg_wait_to_complete); |
47 | ixgbe_link_speed speed, | 47 | s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw, |
48 | bool autoneg, | 48 | ixgbe_link_speed speed, |
49 | bool autoneg_wait_to_complete); | 49 | bool autoneg, |
50 | bool autoneg_wait_to_complete); | ||
50 | static s32 ixgbe_get_copper_link_capabilities_82599(struct ixgbe_hw *hw, | 51 | static s32 ixgbe_get_copper_link_capabilities_82599(struct ixgbe_hw *hw, |
51 | ixgbe_link_speed *speed, | 52 | ixgbe_link_speed *speed, |
52 | bool *autoneg); | 53 | bool *autoneg); |
53 | static s32 ixgbe_setup_copper_link_82599(struct ixgbe_hw *hw); | 54 | static s32 ixgbe_setup_copper_link_82599(struct ixgbe_hw *hw, |
54 | static s32 ixgbe_setup_copper_link_speed_82599(struct ixgbe_hw *hw, | 55 | ixgbe_link_speed speed, |
55 | ixgbe_link_speed speed, | 56 | bool autoneg, |
56 | bool autoneg, | 57 | bool autoneg_wait_to_complete); |
57 | bool autoneg_wait_to_complete); | ||
58 | static s32 ixgbe_verify_fw_version_82599(struct ixgbe_hw *hw); | 58 | static s32 ixgbe_verify_fw_version_82599(struct ixgbe_hw *hw); |
59 | 59 | ||
60 | static void ixgbe_init_mac_link_ops_82599(struct ixgbe_hw *hw) | 60 | static void ixgbe_init_mac_link_ops_82599(struct ixgbe_hw *hw) |
@@ -62,15 +62,9 @@ static void ixgbe_init_mac_link_ops_82599(struct ixgbe_hw *hw) | |||
62 | struct ixgbe_mac_info *mac = &hw->mac; | 62 | struct ixgbe_mac_info *mac = &hw->mac; |
63 | if (hw->phy.multispeed_fiber) { | 63 | if (hw->phy.multispeed_fiber) { |
64 | /* Set up dual speed SFP+ support */ | 64 | /* Set up dual speed SFP+ support */ |
65 | mac->ops.setup_link = | 65 | mac->ops.setup_link = &ixgbe_setup_mac_link_multispeed_fiber; |
66 | &ixgbe_setup_mac_link_multispeed_fiber; | ||
67 | mac->ops.setup_link_speed = | ||
68 | &ixgbe_setup_mac_link_speed_multispeed_fiber; | ||
69 | } else { | 66 | } else { |
70 | mac->ops.setup_link = | 67 | mac->ops.setup_link = &ixgbe_setup_mac_link_82599; |
71 | &ixgbe_setup_mac_link_82599; | ||
72 | mac->ops.setup_link_speed = | ||
73 | &ixgbe_setup_mac_link_speed_82599; | ||
74 | } | 68 | } |
75 | } | 69 | } |
76 | 70 | ||
@@ -178,8 +172,6 @@ static s32 ixgbe_init_phy_ops_82599(struct ixgbe_hw *hw) | |||
178 | /* If copper media, overwrite with copper function pointers */ | 172 | /* If copper media, overwrite with copper function pointers */ |
179 | if (mac->ops.get_media_type(hw) == ixgbe_media_type_copper) { | 173 | if (mac->ops.get_media_type(hw) == ixgbe_media_type_copper) { |
180 | mac->ops.setup_link = &ixgbe_setup_copper_link_82599; | 174 | mac->ops.setup_link = &ixgbe_setup_copper_link_82599; |
181 | mac->ops.setup_link_speed = | ||
182 | &ixgbe_setup_copper_link_speed_82599; | ||
183 | mac->ops.get_link_capabilities = | 175 | mac->ops.get_link_capabilities = |
184 | &ixgbe_get_copper_link_capabilities_82599; | 176 | &ixgbe_get_copper_link_capabilities_82599; |
185 | } | 177 | } |
@@ -354,13 +346,15 @@ out: | |||
354 | } | 346 | } |
355 | 347 | ||
356 | /** | 348 | /** |
357 | * ixgbe_setup_mac_link_82599 - Setup MAC link settings | 349 | * ixgbe_start_mac_link_82599 - Setup MAC link settings |
358 | * @hw: pointer to hardware structure | 350 | * @hw: pointer to hardware structure |
351 | * @autoneg_wait_to_complete: true when waiting for completion is needed | ||
359 | * | 352 | * |
360 | * Configures link settings based on values in the ixgbe_hw struct. | 353 | * Configures link settings based on values in the ixgbe_hw struct. |
361 | * Restarts the link. Performs autonegotiation if needed. | 354 | * Restarts the link. Performs autonegotiation if needed. |
362 | **/ | 355 | **/ |
363 | static s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw) | 356 | s32 ixgbe_start_mac_link_82599(struct ixgbe_hw *hw, |
357 | bool autoneg_wait_to_complete) | ||
364 | { | 358 | { |
365 | u32 autoc_reg; | 359 | u32 autoc_reg; |
366 | u32 links_reg; | 360 | u32 links_reg; |
@@ -373,7 +367,7 @@ static s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw) | |||
373 | IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg); | 367 | IXGBE_WRITE_REG(hw, IXGBE_AUTOC, autoc_reg); |
374 | 368 | ||
375 | /* Only poll for autoneg to complete if specified to do so */ | 369 | /* Only poll for autoneg to complete if specified to do so */ |
376 | if (hw->phy.autoneg_wait_to_complete) { | 370 | if (autoneg_wait_to_complete) { |
377 | if ((autoc_reg & IXGBE_AUTOC_LMS_MASK) == | 371 | if ((autoc_reg & IXGBE_AUTOC_LMS_MASK) == |
378 | IXGBE_AUTOC_LMS_KX4_KX_KR || | 372 | IXGBE_AUTOC_LMS_KX4_KX_KR || |
379 | (autoc_reg & IXGBE_AUTOC_LMS_MASK) == | 373 | (autoc_reg & IXGBE_AUTOC_LMS_MASK) == |
@@ -401,25 +395,7 @@ static s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw) | |||
401 | } | 395 | } |
402 | 396 | ||
403 | /** | 397 | /** |
404 | * ixgbe_setup_mac_link_multispeed_fiber - Setup MAC link settings | 398 | * ixgbe_setup_mac_link_multispeed_fiber - Set MAC link speed |
405 | * @hw: pointer to hardware structure | ||
406 | * | ||
407 | * Configures link settings based on values in the ixgbe_hw struct. | ||
408 | * Restarts the link for multi-speed fiber at 1G speed, if link | ||
409 | * fails at 10G. | ||
410 | * Performs autonegotiation if needed. | ||
411 | **/ | ||
412 | static s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw) | ||
413 | { | ||
414 | s32 status = 0; | ||
415 | ixgbe_link_speed link_speed = IXGBE_LINK_SPEED_82599_AUTONEG; | ||
416 | status = ixgbe_setup_mac_link_speed_multispeed_fiber(hw, link_speed, | ||
417 | true, true); | ||
418 | return status; | ||
419 | } | ||
420 | |||
421 | /** | ||
422 | * ixgbe_setup_mac_link_speed_multispeed_fiber - Set MAC link speed | ||
423 | * @hw: pointer to hardware structure | 399 | * @hw: pointer to hardware structure |
424 | * @speed: new link speed | 400 | * @speed: new link speed |
425 | * @autoneg: true if autonegotiation enabled | 401 | * @autoneg: true if autonegotiation enabled |
@@ -427,10 +403,10 @@ static s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw) | |||
427 | * | 403 | * |
428 | * Set the link speed in the AUTOC register and restarts link. | 404 | * Set the link speed in the AUTOC register and restarts link. |
429 | **/ | 405 | **/ |
430 | static s32 ixgbe_setup_mac_link_speed_multispeed_fiber(struct ixgbe_hw *hw, | 406 | s32 ixgbe_setup_mac_link_multispeed_fiber(struct ixgbe_hw *hw, |
431 | ixgbe_link_speed speed, | 407 | ixgbe_link_speed speed, |
432 | bool autoneg, | 408 | bool autoneg, |
433 | bool autoneg_wait_to_complete) | 409 | bool autoneg_wait_to_complete) |
434 | { | 410 | { |
435 | s32 status = 0; | 411 | s32 status = 0; |
436 | ixgbe_link_speed phy_link_speed; | 412 | ixgbe_link_speed phy_link_speed; |
@@ -485,10 +461,10 @@ static s32 ixgbe_setup_mac_link_speed_multispeed_fiber(struct ixgbe_hw *hw, | |||
485 | /* Allow module to change analog characteristics (1G->10G) */ | 461 | /* Allow module to change analog characteristics (1G->10G) */ |
486 | msleep(40); | 462 | msleep(40); |
487 | 463 | ||
488 | status = ixgbe_setup_mac_link_speed_82599(hw, | 464 | status = ixgbe_setup_mac_link_82599(hw, |
489 | IXGBE_LINK_SPEED_10GB_FULL, | 465 | IXGBE_LINK_SPEED_10GB_FULL, |
490 | autoneg, | 466 | autoneg, |
491 | autoneg_wait_to_complete); | 467 | autoneg_wait_to_complete); |
492 | if (status != 0) | 468 | if (status != 0) |
493 | goto out; | 469 | goto out; |
494 | 470 | ||
@@ -539,7 +515,7 @@ static s32 ixgbe_setup_mac_link_speed_multispeed_fiber(struct ixgbe_hw *hw, | |||
539 | /* Allow module to change analog characteristics (10G->1G) */ | 515 | /* Allow module to change analog characteristics (10G->1G) */ |
540 | msleep(40); | 516 | msleep(40); |
541 | 517 | ||
542 | status = ixgbe_setup_mac_link_speed_82599(hw, | 518 | status = ixgbe_setup_mac_link_82599(hw, |
543 | IXGBE_LINK_SPEED_1GB_FULL, | 519 | IXGBE_LINK_SPEED_1GB_FULL, |
544 | autoneg, | 520 | autoneg, |
545 | autoneg_wait_to_complete); | 521 | autoneg_wait_to_complete); |
@@ -576,10 +552,10 @@ static s32 ixgbe_setup_mac_link_speed_multispeed_fiber(struct ixgbe_hw *hw, | |||
576 | * single highest speed that the user requested. | 552 | * single highest speed that the user requested. |
577 | */ | 553 | */ |
578 | if (speedcnt > 1) | 554 | if (speedcnt > 1) |
579 | status = ixgbe_setup_mac_link_speed_multispeed_fiber(hw, | 555 | status = ixgbe_setup_mac_link_multispeed_fiber(hw, |
580 | highest_link_speed, | 556 | highest_link_speed, |
581 | autoneg, | 557 | autoneg, |
582 | autoneg_wait_to_complete); | 558 | autoneg_wait_to_complete); |
583 | 559 | ||
584 | out: | 560 | out: |
585 | return status; | 561 | return status; |
@@ -640,7 +616,7 @@ static s32 ixgbe_check_mac_link_82599(struct ixgbe_hw *hw, | |||
640 | } | 616 | } |
641 | 617 | ||
642 | /** | 618 | /** |
643 | * ixgbe_setup_mac_link_speed_82599 - Set MAC link speed | 619 | * ixgbe_setup_mac_link_82599 - Set MAC link speed |
644 | * @hw: pointer to hardware structure | 620 | * @hw: pointer to hardware structure |
645 | * @speed: new link speed | 621 | * @speed: new link speed |
646 | * @autoneg: true if autonegotiation enabled | 622 | * @autoneg: true if autonegotiation enabled |
@@ -648,10 +624,9 @@ static s32 ixgbe_check_mac_link_82599(struct ixgbe_hw *hw, | |||
648 | * | 624 | * |
649 | * Set the link speed in the AUTOC register and restarts link. | 625 | * Set the link speed in the AUTOC register and restarts link. |
650 | **/ | 626 | **/ |
651 | static s32 ixgbe_setup_mac_link_speed_82599(struct ixgbe_hw *hw, | 627 | s32 ixgbe_setup_mac_link_82599(struct ixgbe_hw *hw, |
652 | ixgbe_link_speed speed, | 628 | ixgbe_link_speed speed, bool autoneg, |
653 | bool autoneg, | 629 | bool autoneg_wait_to_complete) |
654 | bool autoneg_wait_to_complete) | ||
655 | { | 630 | { |
656 | s32 status = 0; | 631 | s32 status = 0; |
657 | u32 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC); | 632 | u32 autoc = IXGBE_READ_REG(hw, IXGBE_AUTOC); |
@@ -751,26 +726,7 @@ out: | |||
751 | } | 726 | } |
752 | 727 | ||
753 | /** | 728 | /** |
754 | * ixgbe_setup_copper_link_82599 - Setup copper link settings | 729 | * ixgbe_setup_copper_link_82599 - Set the PHY autoneg advertised field |
755 | * @hw: pointer to hardware structure | ||
756 | * | ||
757 | * Restarts the link on PHY and then MAC. Performs autonegotiation if needed. | ||
758 | **/ | ||
759 | static s32 ixgbe_setup_copper_link_82599(struct ixgbe_hw *hw) | ||
760 | { | ||
761 | s32 status; | ||
762 | |||
763 | /* Restart autonegotiation on PHY */ | ||
764 | status = hw->phy.ops.setup_link(hw); | ||
765 | |||
766 | /* Set up MAC */ | ||
767 | ixgbe_setup_mac_link_82599(hw); | ||
768 | |||
769 | return status; | ||
770 | } | ||
771 | |||
772 | /** | ||
773 | * ixgbe_setup_copper_link_speed_82599 - Set the PHY autoneg advertised field | ||
774 | * @hw: pointer to hardware structure | 730 | * @hw: pointer to hardware structure |
775 | * @speed: new link speed | 731 | * @speed: new link speed |
776 | * @autoneg: true if autonegotiation enabled | 732 | * @autoneg: true if autonegotiation enabled |
@@ -778,10 +734,10 @@ static s32 ixgbe_setup_copper_link_82599(struct ixgbe_hw *hw) | |||
778 | * | 734 | * |
779 | * Restarts link on PHY and MAC based on settings passed in. | 735 | * Restarts link on PHY and MAC based on settings passed in. |
780 | **/ | 736 | **/ |
781 | static s32 ixgbe_setup_copper_link_speed_82599(struct ixgbe_hw *hw, | 737 | static s32 ixgbe_setup_copper_link_82599(struct ixgbe_hw *hw, |
782 | ixgbe_link_speed speed, | 738 | ixgbe_link_speed speed, |
783 | bool autoneg, | 739 | bool autoneg, |
784 | bool autoneg_wait_to_complete) | 740 | bool autoneg_wait_to_complete) |
785 | { | 741 | { |
786 | s32 status; | 742 | s32 status; |
787 | 743 | ||
@@ -789,7 +745,7 @@ static s32 ixgbe_setup_copper_link_speed_82599(struct ixgbe_hw *hw, | |||
789 | status = hw->phy.ops.setup_link_speed(hw, speed, autoneg, | 745 | status = hw->phy.ops.setup_link_speed(hw, speed, autoneg, |
790 | autoneg_wait_to_complete); | 746 | autoneg_wait_to_complete); |
791 | /* Set up MAC */ | 747 | /* Set up MAC */ |
792 | ixgbe_setup_mac_link_82599(hw); | 748 | ixgbe_start_mac_link_82599(hw, autoneg_wait_to_complete); |
793 | 749 | ||
794 | return status; | 750 | return status; |
795 | } | 751 | } |
@@ -2470,7 +2426,6 @@ static struct ixgbe_mac_operations mac_ops_82599 = { | |||
2470 | .read_analog_reg8 = &ixgbe_read_analog_reg8_82599, | 2426 | .read_analog_reg8 = &ixgbe_read_analog_reg8_82599, |
2471 | .write_analog_reg8 = &ixgbe_write_analog_reg8_82599, | 2427 | .write_analog_reg8 = &ixgbe_write_analog_reg8_82599, |
2472 | .setup_link = &ixgbe_setup_mac_link_82599, | 2428 | .setup_link = &ixgbe_setup_mac_link_82599, |
2473 | .setup_link_speed = &ixgbe_setup_mac_link_speed_82599, | ||
2474 | .check_link = &ixgbe_check_mac_link_82599, | 2429 | .check_link = &ixgbe_check_mac_link_82599, |
2475 | .get_link_capabilities = &ixgbe_get_link_capabilities_82599, | 2430 | .get_link_capabilities = &ixgbe_get_link_capabilities_82599, |
2476 | .led_on = &ixgbe_led_on_generic, | 2431 | .led_on = &ixgbe_led_on_generic, |