aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ixgbe/ixgbe_main.c
diff options
context:
space:
mode:
authorJesse Brandeburg <jesse.brandeburg@intel.com>2008-09-11 22:59:59 -0400
committerJeff Garzik <jgarzik@redhat.com>2008-09-24 18:54:59 -0400
commitc44ade9ef8ffd73cb8b026065ade78bc0040f0b4 (patch)
tree4e873bc57bccb30e23cec99ed06ec58ba7251e39 /drivers/net/ixgbe/ixgbe_main.c
parentf08482766b7e3c0b2aaac4b68b30f33a91703aa3 (diff)
ixgbe: update to latest common code module
This is a massive update that includes infrastructure for further patches where we will add support for more phy types and eeprom types. This code is shared as much as possible with other drivers, so the code may seem a little obtuse at times but wherever possible we keep to the linux style and methods. Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/net/ixgbe/ixgbe_main.c')
-rw-r--r--drivers/net/ixgbe/ixgbe_main.c105
1 files changed, 71 insertions, 34 deletions
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c
index e18afa4e195f..df093ec830de 100644
--- a/drivers/net/ixgbe/ixgbe_main.c
+++ b/drivers/net/ixgbe/ixgbe_main.c
@@ -1749,14 +1749,16 @@ static void ixgbe_vlan_rx_register(struct net_device *netdev,
1749static void ixgbe_vlan_rx_add_vid(struct net_device *netdev, u16 vid) 1749static void ixgbe_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
1750{ 1750{
1751 struct ixgbe_adapter *adapter = netdev_priv(netdev); 1751 struct ixgbe_adapter *adapter = netdev_priv(netdev);
1752 struct ixgbe_hw *hw = &adapter->hw;
1752 1753
1753 /* add VID to filter table */ 1754 /* add VID to filter table */
1754 ixgbe_set_vfta(&adapter->hw, vid, 0, true); 1755 hw->mac.ops.set_vfta(&adapter->hw, vid, 0, true);
1755} 1756}
1756 1757
1757static void ixgbe_vlan_rx_kill_vid(struct net_device *netdev, u16 vid) 1758static void ixgbe_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
1758{ 1759{
1759 struct ixgbe_adapter *adapter = netdev_priv(netdev); 1760 struct ixgbe_adapter *adapter = netdev_priv(netdev);
1761 struct ixgbe_hw *hw = &adapter->hw;
1760 1762
1761 if (!test_bit(__IXGBE_DOWN, &adapter->state)) 1763 if (!test_bit(__IXGBE_DOWN, &adapter->state))
1762 ixgbe_irq_disable(adapter); 1764 ixgbe_irq_disable(adapter);
@@ -1767,7 +1769,7 @@ static void ixgbe_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
1767 ixgbe_irq_enable(adapter); 1769 ixgbe_irq_enable(adapter);
1768 1770
1769 /* remove VID from filter table */ 1771 /* remove VID from filter table */
1770 ixgbe_set_vfta(&adapter->hw, vid, 0, false); 1772 hw->mac.ops.set_vfta(&adapter->hw, vid, 0, false);
1771} 1773}
1772 1774
1773static void ixgbe_restore_vlan(struct ixgbe_adapter *adapter) 1775static void ixgbe_restore_vlan(struct ixgbe_adapter *adapter)
@@ -1843,15 +1845,15 @@ static void ixgbe_set_rx_mode(struct net_device *netdev)
1843 addr_count = netdev->uc_count; 1845 addr_count = netdev->uc_count;
1844 if (addr_count) 1846 if (addr_count)
1845 addr_list = netdev->uc_list->dmi_addr; 1847 addr_list = netdev->uc_list->dmi_addr;
1846 ixgbe_update_uc_addr_list(hw, addr_list, addr_count, 1848 hw->mac.ops.update_uc_addr_list(hw, addr_list, addr_count,
1847 ixgbe_addr_list_itr); 1849 ixgbe_addr_list_itr);
1848 1850
1849 /* reprogram multicast list */ 1851 /* reprogram multicast list */
1850 addr_count = netdev->mc_count; 1852 addr_count = netdev->mc_count;
1851 if (addr_count) 1853 if (addr_count)
1852 addr_list = netdev->mc_list->dmi_addr; 1854 addr_list = netdev->mc_list->dmi_addr;
1853 ixgbe_update_mc_addr_list(hw, addr_list, addr_count, 1855 hw->mac.ops.update_mc_addr_list(hw, addr_list, addr_count,
1854 ixgbe_addr_list_itr); 1856 ixgbe_addr_list_itr);
1855} 1857}
1856 1858
1857static void ixgbe_napi_enable_all(struct ixgbe_adapter *adapter) 1859static void ixgbe_napi_enable_all(struct ixgbe_adapter *adapter)
@@ -2016,11 +2018,12 @@ int ixgbe_up(struct ixgbe_adapter *adapter)
2016 2018
2017void ixgbe_reset(struct ixgbe_adapter *adapter) 2019void ixgbe_reset(struct ixgbe_adapter *adapter)
2018{ 2020{
2019 if (ixgbe_init_hw(&adapter->hw)) 2021 struct ixgbe_hw *hw = &adapter->hw;
2020 DPRINTK(PROBE, ERR, "Hardware Error\n"); 2022 if (hw->mac.ops.init_hw(hw))
2023 dev_err(&adapter->pdev->dev, "Hardware Error\n");
2021 2024
2022 /* reprogram the RAR[0] in case user changed it. */ 2025 /* reprogram the RAR[0] in case user changed it. */
2023 ixgbe_set_rar(&adapter->hw, 0, adapter->hw.mac.addr, 0, IXGBE_RAH_AV); 2026 hw->mac.ops.set_rar(hw, 0, hw->mac.addr, 0, IXGBE_RAH_AV);
2024 2027
2025} 2028}
2026 2029
@@ -2637,6 +2640,14 @@ static int __devinit ixgbe_sw_init(struct ixgbe_adapter *adapter)
2637 struct pci_dev *pdev = adapter->pdev; 2640 struct pci_dev *pdev = adapter->pdev;
2638 unsigned int rss; 2641 unsigned int rss;
2639 2642
2643 /* PCI config space info */
2644
2645 hw->vendor_id = pdev->vendor;
2646 hw->device_id = pdev->device;
2647 hw->revision_id = pdev->revision;
2648 hw->subsystem_vendor_id = pdev->subsystem_vendor;
2649 hw->subsystem_device_id = pdev->subsystem_device;
2650
2640 /* Set capability flags */ 2651 /* Set capability flags */
2641 rss = min(IXGBE_MAX_RSS_INDICES, (int)num_online_cpus()); 2652 rss = min(IXGBE_MAX_RSS_INDICES, (int)num_online_cpus());
2642 adapter->ring_feature[RING_F_RSS].indices = rss; 2653 adapter->ring_feature[RING_F_RSS].indices = rss;
@@ -2652,15 +2663,6 @@ static int __devinit ixgbe_sw_init(struct ixgbe_adapter *adapter)
2652 2663
2653 /* select 10G link by default */ 2664 /* select 10G link by default */
2654 hw->mac.link_mode_select = IXGBE_AUTOC_LMS_10G_LINK_NO_AN; 2665 hw->mac.link_mode_select = IXGBE_AUTOC_LMS_10G_LINK_NO_AN;
2655 if (hw->mac.ops.reset(hw)) {
2656 dev_err(&pdev->dev, "HW Init failed\n");
2657 return -EIO;
2658 }
2659 if (hw->mac.ops.setup_link_speed(hw, IXGBE_LINK_SPEED_10GB_FULL, true,
2660 false)) {
2661 dev_err(&pdev->dev, "Link Speed setup failed\n");
2662 return -EIO;
2663 }
2664 2666
2665 /* enable itr by default in dynamic mode */ 2667 /* enable itr by default in dynamic mode */
2666 adapter->itr_setting = 1; 2668 adapter->itr_setting = 1;
@@ -2675,7 +2677,7 @@ static int __devinit ixgbe_sw_init(struct ixgbe_adapter *adapter)
2675 adapter->rx_ring_count = IXGBE_DEFAULT_RXD; 2677 adapter->rx_ring_count = IXGBE_DEFAULT_RXD;
2676 2678
2677 /* initialize eeprom parameters */ 2679 /* initialize eeprom parameters */
2678 if (ixgbe_init_eeprom(hw)) { 2680 if (ixgbe_init_eeprom_params_generic(hw)) {
2679 dev_err(&pdev->dev, "EEPROM initialization failed\n"); 2681 dev_err(&pdev->dev, "EEPROM initialization failed\n");
2680 return -EIO; 2682 return -EIO;
2681 } 2683 }
@@ -3622,7 +3624,7 @@ static int ixgbe_set_mac(struct net_device *netdev, void *p)
3622 memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); 3624 memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len);
3623 memcpy(adapter->hw.mac.addr, addr->sa_data, netdev->addr_len); 3625 memcpy(adapter->hw.mac.addr, addr->sa_data, netdev->addr_len);
3624 3626
3625 ixgbe_set_rar(&adapter->hw, 0, adapter->hw.mac.addr, 0, IXGBE_RAH_AV); 3627 adapter->hw.mac.ops.set_rar(&adapter->hw, 0, adapter->hw.mac.addr, 0, IXGBE_RAH_AV);
3626 3628
3627 return 0; 3629 return 0;
3628} 3630}
@@ -3646,6 +3648,22 @@ static void ixgbe_netpoll(struct net_device *netdev)
3646#endif 3648#endif
3647 3649
3648/** 3650/**
3651 * ixgbe_link_config - set up initial link with default speed and duplex
3652 * @hw: pointer to private hardware struct
3653 *
3654 * Returns 0 on success, negative on failure
3655 **/
3656static int ixgbe_link_config(struct ixgbe_hw *hw)
3657{
3658 u32 autoneg = IXGBE_LINK_SPEED_10GB_FULL;
3659
3660 /* must always autoneg for both 1G and 10G link */
3661 hw->mac.autoneg = true;
3662
3663 return hw->mac.ops.setup_link_speed(hw, autoneg, true, true);
3664}
3665
3666/**
3649 * ixgbe_napi_add_all - prep napi structs for use 3667 * ixgbe_napi_add_all - prep napi structs for use
3650 * @adapter: private struct 3668 * @adapter: private struct
3651 * helper function to napi_add each possible q_vector->napi 3669 * helper function to napi_add each possible q_vector->napi
@@ -3691,7 +3709,7 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
3691 static int cards_found; 3709 static int cards_found;
3692 int i, err, pci_using_dac; 3710 int i, err, pci_using_dac;
3693 u16 link_status, link_speed, link_width; 3711 u16 link_status, link_speed, link_width;
3694 u32 part_num; 3712 u32 part_num, eec;
3695 3713
3696 err = pci_enable_device(pdev); 3714 err = pci_enable_device(pdev);
3697 if (err) 3715 if (err)
@@ -3705,8 +3723,8 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
3705 if (err) { 3723 if (err) {
3706 err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK); 3724 err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK);
3707 if (err) { 3725 if (err) {
3708 dev_err(&pdev->dev, "No usable DMA " 3726 dev_err(&pdev->dev, "No usable DMA configuration, "
3709 "configuration, aborting\n"); 3727 "aborting\n");
3710 goto err_dma; 3728 goto err_dma;
3711 } 3729 }
3712 } 3730 }
@@ -3772,17 +3790,21 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
3772 3790
3773 adapter->bd_number = cards_found; 3791 adapter->bd_number = cards_found;
3774 3792
3775 /* PCI config space info */
3776 hw->vendor_id = pdev->vendor;
3777 hw->device_id = pdev->device;
3778 hw->revision_id = pdev->revision;
3779 hw->subsystem_vendor_id = pdev->subsystem_vendor;
3780 hw->subsystem_device_id = pdev->subsystem_device;
3781
3782 /* Setup hw api */ 3793 /* Setup hw api */
3783 memcpy(&hw->mac.ops, ii->mac_ops, sizeof(hw->mac.ops)); 3794 memcpy(&hw->mac.ops, ii->mac_ops, sizeof(hw->mac.ops));
3784 hw->mac.type = ii->mac; 3795 hw->mac.type = ii->mac;
3785 3796
3797 /* EEPROM */
3798 memcpy(&hw->eeprom.ops, ii->eeprom_ops, sizeof(hw->eeprom.ops));
3799 eec = IXGBE_READ_REG(hw, IXGBE_EEC);
3800 /* If EEPROM is valid (bit 8 = 1), use default otherwise use bit bang */
3801 if (!(eec & (1 << 8)))
3802 hw->eeprom.ops.read = &ixgbe_read_eeprom_bit_bang_generic;
3803
3804 /* PHY */
3805 memcpy(&hw->phy.ops, ii->phy_ops, sizeof(hw->phy.ops));
3806 /* phy->sfp_type = ixgbe_sfp_type_unknown; */
3807
3786 err = ii->get_invariants(hw); 3808 err = ii->get_invariants(hw);
3787 if (err) 3809 if (err)
3788 goto err_hw_init; 3810 goto err_hw_init;
@@ -3792,6 +3814,13 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
3792 if (err) 3814 if (err)
3793 goto err_sw_init; 3815 goto err_sw_init;
3794 3816
3817 /* reset_hw fills in the perm_addr as well */
3818 err = hw->mac.ops.reset_hw(hw);
3819 if (err) {
3820 dev_err(&adapter->pdev->dev, "HW Init failed: %d\n", err);
3821 goto err_sw_init;
3822 }
3823
3795 netdev->features = NETIF_F_SG | 3824 netdev->features = NETIF_F_SG |
3796 NETIF_F_IP_CSUM | 3825 NETIF_F_IP_CSUM |
3797 NETIF_F_HW_VLAN_TX | 3826 NETIF_F_HW_VLAN_TX |
@@ -3812,7 +3841,7 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
3812 netdev->features |= NETIF_F_HIGHDMA; 3841 netdev->features |= NETIF_F_HIGHDMA;
3813 3842
3814 /* make sure the EEPROM is good */ 3843 /* make sure the EEPROM is good */
3815 if (ixgbe_validate_eeprom_checksum(hw, NULL) < 0) { 3844 if (hw->eeprom.ops.validate_checksum(hw, NULL) < 0) {
3816 dev_err(&pdev->dev, "The EEPROM Checksum Is Not Valid\n"); 3845 dev_err(&pdev->dev, "The EEPROM Checksum Is Not Valid\n");
3817 err = -EIO; 3846 err = -EIO;
3818 goto err_eeprom; 3847 goto err_eeprom;
@@ -3821,7 +3850,8 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
3821 memcpy(netdev->dev_addr, hw->mac.perm_addr, netdev->addr_len); 3850 memcpy(netdev->dev_addr, hw->mac.perm_addr, netdev->addr_len);
3822 memcpy(netdev->perm_addr, hw->mac.perm_addr, netdev->addr_len); 3851 memcpy(netdev->perm_addr, hw->mac.perm_addr, netdev->addr_len);
3823 3852
3824 if (ixgbe_validate_mac_addr(netdev->dev_addr)) { 3853 if (ixgbe_validate_mac_addr(netdev->perm_addr)) {
3854 dev_err(&pdev->dev, "invalid MAC address\n");
3825 err = -EIO; 3855 err = -EIO;
3826 goto err_eeprom; 3856 goto err_eeprom;
3827 } 3857 }
@@ -3853,7 +3883,7 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
3853 "Unknown"), 3883 "Unknown"),
3854 netdev->dev_addr[0], netdev->dev_addr[1], netdev->dev_addr[2], 3884 netdev->dev_addr[0], netdev->dev_addr[1], netdev->dev_addr[2],
3855 netdev->dev_addr[3], netdev->dev_addr[4], netdev->dev_addr[5]); 3885 netdev->dev_addr[3], netdev->dev_addr[4], netdev->dev_addr[5]);
3856 ixgbe_read_part_num(hw, &part_num); 3886 ixgbe_read_pba_num_generic(hw, &part_num);
3857 dev_info(&pdev->dev, "MAC: %d, PHY: %d, PBA No: %06x-%03x\n", 3887 dev_info(&pdev->dev, "MAC: %d, PHY: %d, PBA No: %06x-%03x\n",
3858 hw->mac.type, hw->phy.type, 3888 hw->mac.type, hw->phy.type,
3859 (part_num >> 8), (part_num & 0xff)); 3889 (part_num >> 8), (part_num & 0xff));
@@ -3867,7 +3897,14 @@ static int __devinit ixgbe_probe(struct pci_dev *pdev,
3867 } 3897 }
3868 3898
3869 /* reset the hardware with the new settings */ 3899 /* reset the hardware with the new settings */
3870 ixgbe_start_hw(hw); 3900 hw->mac.ops.start_hw(hw);
3901
3902 /* link_config depends on start_hw being called at least once */
3903 err = ixgbe_link_config(hw);
3904 if (err) {
3905 dev_err(&pdev->dev, "setup_link_speed FAILED %d\n", err);
3906 goto err_register;
3907 }
3871 3908
3872 netif_carrier_off(netdev); 3909 netif_carrier_off(netdev);
3873 netif_tx_stop_all_queues(netdev); 3910 netif_tx_stop_all_queues(netdev);