diff options
author | Jacob Keller <jacob.e.keller@intel.com> | 2013-02-15 04:18:15 -0500 |
---|---|---|
committer | Jeff Kirsher <jeffrey.t.kirsher@intel.com> | 2013-04-18 00:42:57 -0400 |
commit | ef1889d586a84ee17cf16fe48bfec03ace6eab2a (patch) | |
tree | 091285d43a549ebf70f843310e097f65bcc4aca2 /drivers/net/ethernet | |
parent | e8710a5fbf903d514c8b93294e16eaaff954ffed (diff) |
ixgbe: create conversion functions from link_status to bus/speed
This patch cleans up ixgbe_get_bus_info_generic to call some conversion
functions, which are used also in a follow on patch that needs to convert
between the link_status PCIe config values into ixgbe's internal enum
representations.
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Phil Schmitt <phillip.j.schmitt@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/ethernet')
-rw-r--r-- | drivers/net/ethernet/intel/ixgbe/ixgbe_common.c | 64 | ||||
-rw-r--r-- | drivers/net/ethernet/intel/ixgbe/ixgbe_common.h | 2 |
2 files changed, 34 insertions, 32 deletions
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c index 3f66abc45a2e..9bcdeb89af5a 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.c | |||
@@ -592,6 +592,36 @@ s32 ixgbe_get_mac_addr_generic(struct ixgbe_hw *hw, u8 *mac_addr) | |||
592 | return 0; | 592 | return 0; |
593 | } | 593 | } |
594 | 594 | ||
595 | enum ixgbe_bus_width ixgbe_convert_bus_width(u16 link_status) | ||
596 | { | ||
597 | switch (link_status & IXGBE_PCI_LINK_WIDTH) { | ||
598 | case IXGBE_PCI_LINK_WIDTH_1: | ||
599 | return ixgbe_bus_width_pcie_x1; | ||
600 | case IXGBE_PCI_LINK_WIDTH_2: | ||
601 | return ixgbe_bus_width_pcie_x2; | ||
602 | case IXGBE_PCI_LINK_WIDTH_4: | ||
603 | return ixgbe_bus_width_pcie_x4; | ||
604 | case IXGBE_PCI_LINK_WIDTH_8: | ||
605 | return ixgbe_bus_width_pcie_x8; | ||
606 | default: | ||
607 | return ixgbe_bus_width_unknown; | ||
608 | } | ||
609 | } | ||
610 | |||
611 | enum ixgbe_bus_speed ixgbe_convert_bus_speed(u16 link_status) | ||
612 | { | ||
613 | switch (link_status & IXGBE_PCI_LINK_SPEED) { | ||
614 | case IXGBE_PCI_LINK_SPEED_2500: | ||
615 | return ixgbe_bus_speed_2500; | ||
616 | case IXGBE_PCI_LINK_SPEED_5000: | ||
617 | return ixgbe_bus_speed_5000; | ||
618 | case IXGBE_PCI_LINK_SPEED_8000: | ||
619 | return ixgbe_bus_speed_8000; | ||
620 | default: | ||
621 | return ixgbe_bus_speed_unknown; | ||
622 | } | ||
623 | } | ||
624 | |||
595 | /** | 625 | /** |
596 | * ixgbe_get_bus_info_generic - Generic set PCI bus info | 626 | * ixgbe_get_bus_info_generic - Generic set PCI bus info |
597 | * @hw: pointer to hardware structure | 627 | * @hw: pointer to hardware structure |
@@ -610,38 +640,8 @@ s32 ixgbe_get_bus_info_generic(struct ixgbe_hw *hw) | |||
610 | pci_read_config_word(adapter->pdev, IXGBE_PCI_LINK_STATUS, | 640 | pci_read_config_word(adapter->pdev, IXGBE_PCI_LINK_STATUS, |
611 | &link_status); | 641 | &link_status); |
612 | 642 | ||
613 | switch (link_status & IXGBE_PCI_LINK_WIDTH) { | 643 | hw->bus.width = ixgbe_convert_bus_width(link_status); |
614 | case IXGBE_PCI_LINK_WIDTH_1: | 644 | hw->bus.speed = ixgbe_convert_bus_speed(link_status); |
615 | hw->bus.width = ixgbe_bus_width_pcie_x1; | ||
616 | break; | ||
617 | case IXGBE_PCI_LINK_WIDTH_2: | ||
618 | hw->bus.width = ixgbe_bus_width_pcie_x2; | ||
619 | break; | ||
620 | case IXGBE_PCI_LINK_WIDTH_4: | ||
621 | hw->bus.width = ixgbe_bus_width_pcie_x4; | ||
622 | break; | ||
623 | case IXGBE_PCI_LINK_WIDTH_8: | ||
624 | hw->bus.width = ixgbe_bus_width_pcie_x8; | ||
625 | break; | ||
626 | default: | ||
627 | hw->bus.width = ixgbe_bus_width_unknown; | ||
628 | break; | ||
629 | } | ||
630 | |||
631 | switch (link_status & IXGBE_PCI_LINK_SPEED) { | ||
632 | case IXGBE_PCI_LINK_SPEED_2500: | ||
633 | hw->bus.speed = ixgbe_bus_speed_2500; | ||
634 | break; | ||
635 | case IXGBE_PCI_LINK_SPEED_5000: | ||
636 | hw->bus.speed = ixgbe_bus_speed_5000; | ||
637 | break; | ||
638 | case IXGBE_PCI_LINK_SPEED_8000: | ||
639 | hw->bus.speed = ixgbe_bus_speed_8000; | ||
640 | break; | ||
641 | default: | ||
642 | hw->bus.speed = ixgbe_bus_speed_unknown; | ||
643 | break; | ||
644 | } | ||
645 | 645 | ||
646 | mac->ops.set_lan_id(hw); | 646 | mac->ops.set_lan_id(hw); |
647 | 647 | ||
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h index bc3948ead6e0..22eee38868f1 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_common.h | |||
@@ -40,6 +40,8 @@ s32 ixgbe_clear_hw_cntrs_generic(struct ixgbe_hw *hw); | |||
40 | s32 ixgbe_read_pba_string_generic(struct ixgbe_hw *hw, u8 *pba_num, | 40 | s32 ixgbe_read_pba_string_generic(struct ixgbe_hw *hw, u8 *pba_num, |
41 | u32 pba_num_size); | 41 | u32 pba_num_size); |
42 | s32 ixgbe_get_mac_addr_generic(struct ixgbe_hw *hw, u8 *mac_addr); | 42 | s32 ixgbe_get_mac_addr_generic(struct ixgbe_hw *hw, u8 *mac_addr); |
43 | enum ixgbe_bus_width ixgbe_convert_bus_width(u16 link_status); | ||
44 | enum ixgbe_bus_speed ixgbe_convert_bus_speed(u16 link_status); | ||
43 | s32 ixgbe_get_bus_info_generic(struct ixgbe_hw *hw); | 45 | s32 ixgbe_get_bus_info_generic(struct ixgbe_hw *hw); |
44 | void ixgbe_set_lan_id_multi_port_pcie(struct ixgbe_hw *hw); | 46 | void ixgbe_set_lan_id_multi_port_pcie(struct ixgbe_hw *hw); |
45 | s32 ixgbe_stop_adapter_generic(struct ixgbe_hw *hw); | 47 | s32 ixgbe_stop_adapter_generic(struct ixgbe_hw *hw); |