diff options
Diffstat (limited to 'drivers/net/igb/igb_main.c')
-rw-r--r-- | drivers/net/igb/igb_main.c | 429 |
1 files changed, 405 insertions, 24 deletions
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c index c7c7eeba3366..b9e7980e3f47 100644 --- a/drivers/net/igb/igb_main.c +++ b/drivers/net/igb/igb_main.c | |||
@@ -122,10 +122,16 @@ static void igb_vlan_rx_register(struct net_device *, struct vlan_group *); | |||
122 | static void igb_vlan_rx_add_vid(struct net_device *, u16); | 122 | static void igb_vlan_rx_add_vid(struct net_device *, u16); |
123 | static void igb_vlan_rx_kill_vid(struct net_device *, u16); | 123 | static void igb_vlan_rx_kill_vid(struct net_device *, u16); |
124 | static void igb_restore_vlan(struct igb_adapter *); | 124 | static void igb_restore_vlan(struct igb_adapter *); |
125 | static void igb_ping_all_vfs(struct igb_adapter *); | ||
126 | static void igb_msg_task(struct igb_adapter *); | ||
127 | static int igb_rcv_msg_from_vf(struct igb_adapter *, u32); | ||
125 | static inline void igb_set_rah_pool(struct e1000_hw *, int , int); | 128 | static inline void igb_set_rah_pool(struct e1000_hw *, int , int); |
126 | static void igb_set_mc_list_pools(struct igb_adapter *, int, u16); | 129 | static void igb_set_mc_list_pools(struct igb_adapter *, int, u16); |
130 | static void igb_vmm_control(struct igb_adapter *); | ||
127 | static inline void igb_set_vmolr(struct e1000_hw *, int); | 131 | static inline void igb_set_vmolr(struct e1000_hw *, int); |
128 | static inline void igb_set_vf_rlpml(struct igb_adapter *, int, int); | 132 | static inline int igb_set_vf_rlpml(struct igb_adapter *, int, int); |
133 | static int igb_set_vf_mac(struct igb_adapter *adapter, int, unsigned char *); | ||
134 | static void igb_restore_vf_multicasts(struct igb_adapter *adapter); | ||
129 | 135 | ||
130 | static int igb_suspend(struct pci_dev *, pm_message_t); | 136 | static int igb_suspend(struct pci_dev *, pm_message_t); |
131 | #ifdef CONFIG_PM | 137 | #ifdef CONFIG_PM |
@@ -768,7 +774,10 @@ static void igb_irq_enable(struct igb_adapter *adapter) | |||
768 | wr32(E1000_EIAC, adapter->eims_enable_mask); | 774 | wr32(E1000_EIAC, adapter->eims_enable_mask); |
769 | wr32(E1000_EIAM, adapter->eims_enable_mask); | 775 | wr32(E1000_EIAM, adapter->eims_enable_mask); |
770 | wr32(E1000_EIMS, adapter->eims_enable_mask); | 776 | wr32(E1000_EIMS, adapter->eims_enable_mask); |
771 | wr32(E1000_IMS, E1000_IMS_LSC | E1000_IMS_DOUTSYNC); | 777 | if (adapter->vfs_allocated_count) |
778 | wr32(E1000_MBVFIMR, 0xFF); | ||
779 | wr32(E1000_IMS, (E1000_IMS_LSC | E1000_IMS_VMMB | | ||
780 | E1000_IMS_DOUTSYNC)); | ||
772 | } else { | 781 | } else { |
773 | wr32(E1000_IMS, IMS_ENABLE_MASK); | 782 | wr32(E1000_IMS, IMS_ENABLE_MASK); |
774 | wr32(E1000_IAM, IMS_ENABLE_MASK); | 783 | wr32(E1000_IAM, IMS_ENABLE_MASK); |
@@ -892,6 +901,7 @@ int igb_up(struct igb_adapter *adapter) | |||
892 | if (adapter->msix_entries) | 901 | if (adapter->msix_entries) |
893 | igb_configure_msix(adapter); | 902 | igb_configure_msix(adapter); |
894 | 903 | ||
904 | igb_vmm_control(adapter); | ||
895 | igb_set_rah_pool(hw, adapter->vfs_allocated_count, 0); | 905 | igb_set_rah_pool(hw, adapter->vfs_allocated_count, 0); |
896 | igb_set_vmolr(hw, adapter->vfs_allocated_count); | 906 | igb_set_vmolr(hw, adapter->vfs_allocated_count); |
897 | 907 | ||
@@ -1047,6 +1057,20 @@ void igb_reset(struct igb_adapter *adapter) | |||
1047 | fc->send_xon = 1; | 1057 | fc->send_xon = 1; |
1048 | fc->type = fc->original_type; | 1058 | fc->type = fc->original_type; |
1049 | 1059 | ||
1060 | /* disable receive for all VFs and wait one second */ | ||
1061 | if (adapter->vfs_allocated_count) { | ||
1062 | int i; | ||
1063 | for (i = 0 ; i < adapter->vfs_allocated_count; i++) | ||
1064 | adapter->vf_data[i].clear_to_send = false; | ||
1065 | |||
1066 | /* ping all the active vfs to let them know we are going down */ | ||
1067 | igb_ping_all_vfs(adapter); | ||
1068 | |||
1069 | /* disable transmits and receives */ | ||
1070 | wr32(E1000_VFRE, 0); | ||
1071 | wr32(E1000_VFTE, 0); | ||
1072 | } | ||
1073 | |||
1050 | /* Allow time for pending master requests to run */ | 1074 | /* Allow time for pending master requests to run */ |
1051 | adapter->hw.mac.ops.reset_hw(&adapter->hw); | 1075 | adapter->hw.mac.ops.reset_hw(&adapter->hw); |
1052 | wr32(E1000_WUC, 0); | 1076 | wr32(E1000_WUC, 0); |
@@ -1624,6 +1648,7 @@ static int igb_open(struct net_device *netdev) | |||
1624 | * clean_rx handler before we do so. */ | 1648 | * clean_rx handler before we do so. */ |
1625 | igb_configure(adapter); | 1649 | igb_configure(adapter); |
1626 | 1650 | ||
1651 | igb_vmm_control(adapter); | ||
1627 | igb_set_rah_pool(hw, adapter->vfs_allocated_count, 0); | 1652 | igb_set_rah_pool(hw, adapter->vfs_allocated_count, 0); |
1628 | igb_set_vmolr(hw, adapter->vfs_allocated_count); | 1653 | igb_set_vmolr(hw, adapter->vfs_allocated_count); |
1629 | 1654 | ||
@@ -2456,6 +2481,8 @@ static void igb_set_multi(struct net_device *netdev) | |||
2456 | mac->rar_entry_count); | 2481 | mac->rar_entry_count); |
2457 | 2482 | ||
2458 | igb_set_mc_list_pools(adapter, i, mac->rar_entry_count); | 2483 | igb_set_mc_list_pools(adapter, i, mac->rar_entry_count); |
2484 | igb_restore_vf_multicasts(adapter); | ||
2485 | |||
2459 | kfree(mta_list); | 2486 | kfree(mta_list); |
2460 | } | 2487 | } |
2461 | 2488 | ||
@@ -2571,6 +2598,8 @@ static void igb_watchdog_task(struct work_struct *work) | |||
2571 | netif_carrier_on(netdev); | 2598 | netif_carrier_on(netdev); |
2572 | netif_tx_wake_all_queues(netdev); | 2599 | netif_tx_wake_all_queues(netdev); |
2573 | 2600 | ||
2601 | igb_ping_all_vfs(adapter); | ||
2602 | |||
2574 | /* link state has changed, schedule phy info update */ | 2603 | /* link state has changed, schedule phy info update */ |
2575 | if (!test_bit(__IGB_DOWN, &adapter->state)) | 2604 | if (!test_bit(__IGB_DOWN, &adapter->state)) |
2576 | mod_timer(&adapter->phy_info_timer, | 2605 | mod_timer(&adapter->phy_info_timer, |
@@ -2586,6 +2615,8 @@ static void igb_watchdog_task(struct work_struct *work) | |||
2586 | netif_carrier_off(netdev); | 2615 | netif_carrier_off(netdev); |
2587 | netif_tx_stop_all_queues(netdev); | 2616 | netif_tx_stop_all_queues(netdev); |
2588 | 2617 | ||
2618 | igb_ping_all_vfs(adapter); | ||
2619 | |||
2589 | /* link state has changed, schedule phy info update */ | 2620 | /* link state has changed, schedule phy info update */ |
2590 | if (!test_bit(__IGB_DOWN, &adapter->state)) | 2621 | if (!test_bit(__IGB_DOWN, &adapter->state)) |
2591 | mod_timer(&adapter->phy_info_timer, | 2622 | mod_timer(&adapter->phy_info_timer, |
@@ -3523,15 +3554,19 @@ static irqreturn_t igb_msix_other(int irq, void *data) | |||
3523 | /* HW is reporting DMA is out of sync */ | 3554 | /* HW is reporting DMA is out of sync */ |
3524 | adapter->stats.doosync++; | 3555 | adapter->stats.doosync++; |
3525 | } | 3556 | } |
3526 | if (!(icr & E1000_ICR_LSC)) | ||
3527 | goto no_link_interrupt; | ||
3528 | hw->mac.get_link_status = 1; | ||
3529 | /* guard against interrupt when we're going down */ | ||
3530 | if (!test_bit(__IGB_DOWN, &adapter->state)) | ||
3531 | mod_timer(&adapter->watchdog_timer, jiffies + 1); | ||
3532 | 3557 | ||
3533 | no_link_interrupt: | 3558 | /* Check for a mailbox event */ |
3534 | wr32(E1000_IMS, E1000_IMS_LSC | E1000_IMS_DOUTSYNC); | 3559 | if (icr & E1000_ICR_VMMB) |
3560 | igb_msg_task(adapter); | ||
3561 | |||
3562 | if (icr & E1000_ICR_LSC) { | ||
3563 | hw->mac.get_link_status = 1; | ||
3564 | /* guard against interrupt when we're going down */ | ||
3565 | if (!test_bit(__IGB_DOWN, &adapter->state)) | ||
3566 | mod_timer(&adapter->watchdog_timer, jiffies + 1); | ||
3567 | } | ||
3568 | |||
3569 | wr32(E1000_IMS, E1000_IMS_LSC | E1000_IMS_DOUTSYNC | E1000_IMS_VMMB); | ||
3535 | wr32(E1000_EIMS, adapter->eims_other); | 3570 | wr32(E1000_EIMS, adapter->eims_other); |
3536 | 3571 | ||
3537 | return IRQ_HANDLED; | 3572 | return IRQ_HANDLED; |
@@ -3719,6 +3754,317 @@ static int igb_notify_dca(struct notifier_block *nb, unsigned long event, | |||
3719 | } | 3754 | } |
3720 | #endif /* CONFIG_IGB_DCA */ | 3755 | #endif /* CONFIG_IGB_DCA */ |
3721 | 3756 | ||
3757 | static void igb_ping_all_vfs(struct igb_adapter *adapter) | ||
3758 | { | ||
3759 | struct e1000_hw *hw = &adapter->hw; | ||
3760 | u32 ping; | ||
3761 | int i; | ||
3762 | |||
3763 | for (i = 0 ; i < adapter->vfs_allocated_count; i++) { | ||
3764 | ping = E1000_PF_CONTROL_MSG; | ||
3765 | if (adapter->vf_data[i].clear_to_send) | ||
3766 | ping |= E1000_VT_MSGTYPE_CTS; | ||
3767 | igb_write_mbx(hw, &ping, 1, i); | ||
3768 | } | ||
3769 | } | ||
3770 | |||
3771 | static int igb_set_vf_multicasts(struct igb_adapter *adapter, | ||
3772 | u32 *msgbuf, u32 vf) | ||
3773 | { | ||
3774 | int n = (msgbuf[0] & E1000_VT_MSGINFO_MASK) >> E1000_VT_MSGINFO_SHIFT; | ||
3775 | u16 *hash_list = (u16 *)&msgbuf[1]; | ||
3776 | struct vf_data_storage *vf_data = &adapter->vf_data[vf]; | ||
3777 | int i; | ||
3778 | |||
3779 | /* only up to 30 hash values supported */ | ||
3780 | if (n > 30) | ||
3781 | n = 30; | ||
3782 | |||
3783 | /* salt away the number of multi cast addresses assigned | ||
3784 | * to this VF for later use to restore when the PF multi cast | ||
3785 | * list changes | ||
3786 | */ | ||
3787 | vf_data->num_vf_mc_hashes = n; | ||
3788 | |||
3789 | /* VFs are limited to using the MTA hash table for their multicast | ||
3790 | * addresses */ | ||
3791 | for (i = 0; i < n; i++) | ||
3792 | vf_data->vf_mc_hashes[i] = hash_list[i];; | ||
3793 | |||
3794 | /* Flush and reset the mta with the new values */ | ||
3795 | igb_set_multi(adapter->netdev); | ||
3796 | |||
3797 | return 0; | ||
3798 | } | ||
3799 | |||
3800 | static void igb_restore_vf_multicasts(struct igb_adapter *adapter) | ||
3801 | { | ||
3802 | struct e1000_hw *hw = &adapter->hw; | ||
3803 | struct vf_data_storage *vf_data; | ||
3804 | int i, j; | ||
3805 | |||
3806 | for (i = 0; i < adapter->vfs_allocated_count; i++) { | ||
3807 | vf_data = &adapter->vf_data[i]; | ||
3808 | for (j = 0; j < vf_data[i].num_vf_mc_hashes; j++) | ||
3809 | igb_mta_set(hw, vf_data->vf_mc_hashes[j]); | ||
3810 | } | ||
3811 | } | ||
3812 | |||
3813 | static void igb_clear_vf_vfta(struct igb_adapter *adapter, u32 vf) | ||
3814 | { | ||
3815 | struct e1000_hw *hw = &adapter->hw; | ||
3816 | u32 pool_mask, reg, vid; | ||
3817 | int i; | ||
3818 | |||
3819 | pool_mask = 1 << (E1000_VLVF_POOLSEL_SHIFT + vf); | ||
3820 | |||
3821 | /* Find the vlan filter for this id */ | ||
3822 | for (i = 0; i < E1000_VLVF_ARRAY_SIZE; i++) { | ||
3823 | reg = rd32(E1000_VLVF(i)); | ||
3824 | |||
3825 | /* remove the vf from the pool */ | ||
3826 | reg &= ~pool_mask; | ||
3827 | |||
3828 | /* if pool is empty then remove entry from vfta */ | ||
3829 | if (!(reg & E1000_VLVF_POOLSEL_MASK) && | ||
3830 | (reg & E1000_VLVF_VLANID_ENABLE)) { | ||
3831 | reg = 0; | ||
3832 | vid = reg & E1000_VLVF_VLANID_MASK; | ||
3833 | igb_vfta_set(hw, vid, false); | ||
3834 | } | ||
3835 | |||
3836 | wr32(E1000_VLVF(i), reg); | ||
3837 | } | ||
3838 | } | ||
3839 | |||
3840 | static s32 igb_vlvf_set(struct igb_adapter *adapter, u32 vid, bool add, u32 vf) | ||
3841 | { | ||
3842 | struct e1000_hw *hw = &adapter->hw; | ||
3843 | u32 reg, i; | ||
3844 | |||
3845 | /* It is an error to call this function when VFs are not enabled */ | ||
3846 | if (!adapter->vfs_allocated_count) | ||
3847 | return -1; | ||
3848 | |||
3849 | /* Find the vlan filter for this id */ | ||
3850 | for (i = 0; i < E1000_VLVF_ARRAY_SIZE; i++) { | ||
3851 | reg = rd32(E1000_VLVF(i)); | ||
3852 | if ((reg & E1000_VLVF_VLANID_ENABLE) && | ||
3853 | vid == (reg & E1000_VLVF_VLANID_MASK)) | ||
3854 | break; | ||
3855 | } | ||
3856 | |||
3857 | if (add) { | ||
3858 | if (i == E1000_VLVF_ARRAY_SIZE) { | ||
3859 | /* Did not find a matching VLAN ID entry that was | ||
3860 | * enabled. Search for a free filter entry, i.e. | ||
3861 | * one without the enable bit set | ||
3862 | */ | ||
3863 | for (i = 0; i < E1000_VLVF_ARRAY_SIZE; i++) { | ||
3864 | reg = rd32(E1000_VLVF(i)); | ||
3865 | if (!(reg & E1000_VLVF_VLANID_ENABLE)) | ||
3866 | break; | ||
3867 | } | ||
3868 | } | ||
3869 | if (i < E1000_VLVF_ARRAY_SIZE) { | ||
3870 | /* Found an enabled/available entry */ | ||
3871 | reg |= 1 << (E1000_VLVF_POOLSEL_SHIFT + vf); | ||
3872 | |||
3873 | /* if !enabled we need to set this up in vfta */ | ||
3874 | if (!(reg & E1000_VLVF_VLANID_ENABLE)) { | ||
3875 | /* add VID to filter table */ | ||
3876 | igb_vfta_set(hw, vid, true); | ||
3877 | reg |= E1000_VLVF_VLANID_ENABLE; | ||
3878 | } | ||
3879 | |||
3880 | wr32(E1000_VLVF(i), reg); | ||
3881 | return 0; | ||
3882 | } | ||
3883 | } else { | ||
3884 | if (i < E1000_VLVF_ARRAY_SIZE) { | ||
3885 | /* remove vf from the pool */ | ||
3886 | reg &= ~(1 << (E1000_VLVF_POOLSEL_SHIFT + vf)); | ||
3887 | /* if pool is empty then remove entry from vfta */ | ||
3888 | if (!(reg & E1000_VLVF_POOLSEL_MASK)) { | ||
3889 | reg = 0; | ||
3890 | igb_vfta_set(hw, vid, false); | ||
3891 | } | ||
3892 | wr32(E1000_VLVF(i), reg); | ||
3893 | return 0; | ||
3894 | } | ||
3895 | } | ||
3896 | return -1; | ||
3897 | } | ||
3898 | |||
3899 | static int igb_set_vf_vlan(struct igb_adapter *adapter, u32 *msgbuf, u32 vf) | ||
3900 | { | ||
3901 | int add = (msgbuf[0] & E1000_VT_MSGINFO_MASK) >> E1000_VT_MSGINFO_SHIFT; | ||
3902 | int vid = (msgbuf[1] & E1000_VLVF_VLANID_MASK); | ||
3903 | |||
3904 | return igb_vlvf_set(adapter, vid, add, vf); | ||
3905 | } | ||
3906 | |||
3907 | static inline void igb_vf_reset_event(struct igb_adapter *adapter, u32 vf) | ||
3908 | { | ||
3909 | struct e1000_hw *hw = &adapter->hw; | ||
3910 | |||
3911 | /* disable mailbox functionality for vf */ | ||
3912 | adapter->vf_data[vf].clear_to_send = false; | ||
3913 | |||
3914 | /* reset offloads to defaults */ | ||
3915 | igb_set_vmolr(hw, vf); | ||
3916 | |||
3917 | /* reset vlans for device */ | ||
3918 | igb_clear_vf_vfta(adapter, vf); | ||
3919 | |||
3920 | /* reset multicast table array for vf */ | ||
3921 | adapter->vf_data[vf].num_vf_mc_hashes = 0; | ||
3922 | |||
3923 | /* Flush and reset the mta with the new values */ | ||
3924 | igb_set_multi(adapter->netdev); | ||
3925 | } | ||
3926 | |||
3927 | static inline void igb_vf_reset_msg(struct igb_adapter *adapter, u32 vf) | ||
3928 | { | ||
3929 | struct e1000_hw *hw = &adapter->hw; | ||
3930 | unsigned char *vf_mac = adapter->vf_data[vf].vf_mac_addresses; | ||
3931 | u32 reg, msgbuf[3]; | ||
3932 | u8 *addr = (u8 *)(&msgbuf[1]); | ||
3933 | |||
3934 | /* process all the same items cleared in a function level reset */ | ||
3935 | igb_vf_reset_event(adapter, vf); | ||
3936 | |||
3937 | /* set vf mac address */ | ||
3938 | igb_rar_set(hw, vf_mac, vf + 1); | ||
3939 | igb_set_rah_pool(hw, vf, vf + 1); | ||
3940 | |||
3941 | /* enable transmit and receive for vf */ | ||
3942 | reg = rd32(E1000_VFTE); | ||
3943 | wr32(E1000_VFTE, reg | (1 << vf)); | ||
3944 | reg = rd32(E1000_VFRE); | ||
3945 | wr32(E1000_VFRE, reg | (1 << vf)); | ||
3946 | |||
3947 | /* enable mailbox functionality for vf */ | ||
3948 | adapter->vf_data[vf].clear_to_send = true; | ||
3949 | |||
3950 | /* reply to reset with ack and vf mac address */ | ||
3951 | msgbuf[0] = E1000_VF_RESET | E1000_VT_MSGTYPE_ACK; | ||
3952 | memcpy(addr, vf_mac, 6); | ||
3953 | igb_write_mbx(hw, msgbuf, 3, vf); | ||
3954 | } | ||
3955 | |||
3956 | static int igb_set_vf_mac_addr(struct igb_adapter *adapter, u32 *msg, int vf) | ||
3957 | { | ||
3958 | unsigned char *addr = (char *)&msg[1]; | ||
3959 | int err = -1; | ||
3960 | |||
3961 | if (is_valid_ether_addr(addr)) | ||
3962 | err = igb_set_vf_mac(adapter, vf, addr); | ||
3963 | |||
3964 | return err; | ||
3965 | |||
3966 | } | ||
3967 | |||
3968 | static void igb_rcv_ack_from_vf(struct igb_adapter *adapter, u32 vf) | ||
3969 | { | ||
3970 | struct e1000_hw *hw = &adapter->hw; | ||
3971 | u32 msg = E1000_VT_MSGTYPE_NACK; | ||
3972 | |||
3973 | /* if device isn't clear to send it shouldn't be reading either */ | ||
3974 | if (!adapter->vf_data[vf].clear_to_send) | ||
3975 | igb_write_mbx(hw, &msg, 1, vf); | ||
3976 | } | ||
3977 | |||
3978 | |||
3979 | static void igb_msg_task(struct igb_adapter *adapter) | ||
3980 | { | ||
3981 | struct e1000_hw *hw = &adapter->hw; | ||
3982 | u32 vf; | ||
3983 | |||
3984 | for (vf = 0; vf < adapter->vfs_allocated_count; vf++) { | ||
3985 | /* process any reset requests */ | ||
3986 | if (!igb_check_for_rst(hw, vf)) { | ||
3987 | adapter->vf_data[vf].clear_to_send = false; | ||
3988 | igb_vf_reset_event(adapter, vf); | ||
3989 | } | ||
3990 | |||
3991 | /* process any messages pending */ | ||
3992 | if (!igb_check_for_msg(hw, vf)) | ||
3993 | igb_rcv_msg_from_vf(adapter, vf); | ||
3994 | |||
3995 | /* process any acks */ | ||
3996 | if (!igb_check_for_ack(hw, vf)) | ||
3997 | igb_rcv_ack_from_vf(adapter, vf); | ||
3998 | |||
3999 | } | ||
4000 | } | ||
4001 | |||
4002 | static int igb_rcv_msg_from_vf(struct igb_adapter *adapter, u32 vf) | ||
4003 | { | ||
4004 | u32 mbx_size = E1000_VFMAILBOX_SIZE; | ||
4005 | u32 msgbuf[mbx_size]; | ||
4006 | struct e1000_hw *hw = &adapter->hw; | ||
4007 | s32 retval; | ||
4008 | |||
4009 | retval = igb_read_mbx(hw, msgbuf, mbx_size, vf); | ||
4010 | |||
4011 | if (retval) | ||
4012 | dev_err(&adapter->pdev->dev, | ||
4013 | "Error receiving message from VF\n"); | ||
4014 | |||
4015 | /* this is a message we already processed, do nothing */ | ||
4016 | if (msgbuf[0] & (E1000_VT_MSGTYPE_ACK | E1000_VT_MSGTYPE_NACK)) | ||
4017 | return retval; | ||
4018 | |||
4019 | /* | ||
4020 | * until the vf completes a reset it should not be | ||
4021 | * allowed to start any configuration. | ||
4022 | */ | ||
4023 | |||
4024 | if (msgbuf[0] == E1000_VF_RESET) { | ||
4025 | igb_vf_reset_msg(adapter, vf); | ||
4026 | |||
4027 | return retval; | ||
4028 | } | ||
4029 | |||
4030 | if (!adapter->vf_data[vf].clear_to_send) { | ||
4031 | msgbuf[0] |= E1000_VT_MSGTYPE_NACK; | ||
4032 | igb_write_mbx(hw, msgbuf, 1, vf); | ||
4033 | return retval; | ||
4034 | } | ||
4035 | |||
4036 | switch ((msgbuf[0] & 0xFFFF)) { | ||
4037 | case E1000_VF_SET_MAC_ADDR: | ||
4038 | retval = igb_set_vf_mac_addr(adapter, msgbuf, vf); | ||
4039 | break; | ||
4040 | case E1000_VF_SET_MULTICAST: | ||
4041 | retval = igb_set_vf_multicasts(adapter, msgbuf, vf); | ||
4042 | break; | ||
4043 | case E1000_VF_SET_LPE: | ||
4044 | retval = igb_set_vf_rlpml(adapter, msgbuf[1], vf); | ||
4045 | break; | ||
4046 | case E1000_VF_SET_VLAN: | ||
4047 | retval = igb_set_vf_vlan(adapter, msgbuf, vf); | ||
4048 | break; | ||
4049 | default: | ||
4050 | dev_err(&adapter->pdev->dev, "Unhandled Msg %08x\n", msgbuf[0]); | ||
4051 | retval = -1; | ||
4052 | break; | ||
4053 | } | ||
4054 | |||
4055 | /* notify the VF of the results of what it sent us */ | ||
4056 | if (retval) | ||
4057 | msgbuf[0] |= E1000_VT_MSGTYPE_NACK; | ||
4058 | else | ||
4059 | msgbuf[0] |= E1000_VT_MSGTYPE_ACK; | ||
4060 | |||
4061 | msgbuf[0] |= E1000_VT_MSGTYPE_CTS; | ||
4062 | |||
4063 | igb_write_mbx(hw, msgbuf, 1, vf); | ||
4064 | |||
4065 | return retval; | ||
4066 | } | ||
4067 | |||
3722 | /** | 4068 | /** |
3723 | * igb_intr_msi - Interrupt Handler | 4069 | * igb_intr_msi - Interrupt Handler |
3724 | * @irq: interrupt number | 4070 | * @irq: interrupt number |
@@ -4582,24 +4928,25 @@ static void igb_vlan_rx_add_vid(struct net_device *netdev, u16 vid) | |||
4582 | { | 4928 | { |
4583 | struct igb_adapter *adapter = netdev_priv(netdev); | 4929 | struct igb_adapter *adapter = netdev_priv(netdev); |
4584 | struct e1000_hw *hw = &adapter->hw; | 4930 | struct e1000_hw *hw = &adapter->hw; |
4585 | u32 vfta, index; | 4931 | int pf_id = adapter->vfs_allocated_count; |
4586 | 4932 | ||
4587 | if ((hw->mng_cookie.status & | 4933 | if ((hw->mng_cookie.status & |
4588 | E1000_MNG_DHCP_COOKIE_STATUS_VLAN) && | 4934 | E1000_MNG_DHCP_COOKIE_STATUS_VLAN) && |
4589 | (vid == adapter->mng_vlan_id)) | 4935 | (vid == adapter->mng_vlan_id)) |
4590 | return; | 4936 | return; |
4591 | /* add VID to filter table */ | 4937 | |
4592 | index = (vid >> 5) & 0x7F; | 4938 | /* add vid to vlvf if sr-iov is enabled, |
4593 | vfta = array_rd32(E1000_VFTA, index); | 4939 | * if that fails add directly to filter table */ |
4594 | vfta |= (1 << (vid & 0x1F)); | 4940 | if (igb_vlvf_set(adapter, vid, true, pf_id)) |
4595 | igb_write_vfta(&adapter->hw, index, vfta); | 4941 | igb_vfta_set(hw, vid, true); |
4942 | |||
4596 | } | 4943 | } |
4597 | 4944 | ||
4598 | static void igb_vlan_rx_kill_vid(struct net_device *netdev, u16 vid) | 4945 | static void igb_vlan_rx_kill_vid(struct net_device *netdev, u16 vid) |
4599 | { | 4946 | { |
4600 | struct igb_adapter *adapter = netdev_priv(netdev); | 4947 | struct igb_adapter *adapter = netdev_priv(netdev); |
4601 | struct e1000_hw *hw = &adapter->hw; | 4948 | struct e1000_hw *hw = &adapter->hw; |
4602 | u32 vfta, index; | 4949 | int pf_id = adapter->vfs_allocated_count; |
4603 | 4950 | ||
4604 | igb_irq_disable(adapter); | 4951 | igb_irq_disable(adapter); |
4605 | vlan_group_set_device(adapter->vlgrp, vid, NULL); | 4952 | vlan_group_set_device(adapter->vlgrp, vid, NULL); |
@@ -4615,11 +4962,10 @@ static void igb_vlan_rx_kill_vid(struct net_device *netdev, u16 vid) | |||
4615 | return; | 4962 | return; |
4616 | } | 4963 | } |
4617 | 4964 | ||
4618 | /* remove VID from filter table */ | 4965 | /* remove vid from vlvf if sr-iov is enabled, |
4619 | index = (vid >> 5) & 0x7F; | 4966 | * if not in vlvf remove from vfta */ |
4620 | vfta = array_rd32(E1000_VFTA, index); | 4967 | if (igb_vlvf_set(adapter, vid, false, pf_id)) |
4621 | vfta &= ~(1 << (vid & 0x1F)); | 4968 | igb_vfta_set(hw, vid, false); |
4622 | igb_write_vfta(&adapter->hw, index, vfta); | ||
4623 | } | 4969 | } |
4624 | 4970 | ||
4625 | static void igb_restore_vlan(struct igb_adapter *adapter) | 4971 | static void igb_restore_vlan(struct igb_adapter *adapter) |
@@ -4950,8 +5296,8 @@ static inline void igb_set_vmolr(struct e1000_hw *hw, int vfn) | |||
4950 | wr32(E1000_VMOLR(vfn), reg_data); | 5296 | wr32(E1000_VMOLR(vfn), reg_data); |
4951 | } | 5297 | } |
4952 | 5298 | ||
4953 | static inline void igb_set_vf_rlpml(struct igb_adapter *adapter, int size, | 5299 | static inline int igb_set_vf_rlpml(struct igb_adapter *adapter, int size, |
4954 | int vfn) | 5300 | int vfn) |
4955 | { | 5301 | { |
4956 | struct e1000_hw *hw = &adapter->hw; | 5302 | struct e1000_hw *hw = &adapter->hw; |
4957 | u32 vmolr; | 5303 | u32 vmolr; |
@@ -4960,6 +5306,8 @@ static inline void igb_set_vf_rlpml(struct igb_adapter *adapter, int size, | |||
4960 | vmolr &= ~E1000_VMOLR_RLPML_MASK; | 5306 | vmolr &= ~E1000_VMOLR_RLPML_MASK; |
4961 | vmolr |= size | E1000_VMOLR_LPE; | 5307 | vmolr |= size | E1000_VMOLR_LPE; |
4962 | wr32(E1000_VMOLR(vfn), vmolr); | 5308 | wr32(E1000_VMOLR(vfn), vmolr); |
5309 | |||
5310 | return 0; | ||
4963 | } | 5311 | } |
4964 | 5312 | ||
4965 | static inline void igb_set_rah_pool(struct e1000_hw *hw, int pool, int entry) | 5313 | static inline void igb_set_rah_pool(struct e1000_hw *hw, int pool, int entry) |
@@ -4985,4 +5333,37 @@ static void igb_set_mc_list_pools(struct igb_adapter *adapter, | |||
4985 | igb_set_rah_pool(hw, adapter->vfs_allocated_count, i); | 5333 | igb_set_rah_pool(hw, adapter->vfs_allocated_count, i); |
4986 | } | 5334 | } |
4987 | 5335 | ||
5336 | static int igb_set_vf_mac(struct igb_adapter *adapter, | ||
5337 | int vf, unsigned char *mac_addr) | ||
5338 | { | ||
5339 | struct e1000_hw *hw = &adapter->hw; | ||
5340 | int rar_entry = vf + 1; /* VF MAC addresses start at entry 1 */ | ||
5341 | |||
5342 | igb_rar_set(hw, mac_addr, rar_entry); | ||
5343 | |||
5344 | memcpy(adapter->vf_data[vf].vf_mac_addresses, mac_addr, 6); | ||
5345 | |||
5346 | igb_set_rah_pool(hw, vf, rar_entry); | ||
5347 | |||
5348 | return 0; | ||
5349 | } | ||
5350 | |||
5351 | static void igb_vmm_control(struct igb_adapter *adapter) | ||
5352 | { | ||
5353 | struct e1000_hw *hw = &adapter->hw; | ||
5354 | u32 reg_data; | ||
5355 | |||
5356 | if (!adapter->vfs_allocated_count) | ||
5357 | return; | ||
5358 | |||
5359 | /* VF's need PF reset indication before they | ||
5360 | * can send/receive mail */ | ||
5361 | reg_data = rd32(E1000_CTRL_EXT); | ||
5362 | reg_data |= E1000_CTRL_EXT_PFRSTD; | ||
5363 | wr32(E1000_CTRL_EXT, reg_data); | ||
5364 | |||
5365 | igb_vmdq_set_loopback_pf(hw, true); | ||
5366 | igb_vmdq_set_replication_pf(hw, true); | ||
5367 | } | ||
5368 | |||
4988 | /* igb_main.c */ | 5369 | /* igb_main.c */ |