diff options
-rw-r--r-- | drivers/net/ixgbe/ixgbe_82599.c | 2 | ||||
-rw-r--r-- | drivers/net/ixgbe/ixgbe_common.c | 64 | ||||
-rw-r--r-- | drivers/net/ixgbe/ixgbe_common.h | 2 | ||||
-rw-r--r-- | drivers/net/ixgbe/ixgbe_main.c | 24 | ||||
-rw-r--r-- | drivers/net/ixgbe/ixgbe_sriov.c | 12 | ||||
-rw-r--r-- | drivers/net/ixgbe/ixgbe_type.h | 13 |
6 files changed, 114 insertions, 3 deletions
diff --git a/drivers/net/ixgbe/ixgbe_82599.c b/drivers/net/ixgbe/ixgbe_82599.c index 6827dddc383e..bfd3c227cd4a 100644 --- a/drivers/net/ixgbe/ixgbe_82599.c +++ b/drivers/net/ixgbe/ixgbe_82599.c | |||
@@ -2165,6 +2165,8 @@ static struct ixgbe_mac_operations mac_ops_82599 = { | |||
2165 | .fc_enable = &ixgbe_fc_enable_generic, | 2165 | .fc_enable = &ixgbe_fc_enable_generic, |
2166 | .init_uta_tables = &ixgbe_init_uta_tables_generic, | 2166 | .init_uta_tables = &ixgbe_init_uta_tables_generic, |
2167 | .setup_sfp = &ixgbe_setup_sfp_modules_82599, | 2167 | .setup_sfp = &ixgbe_setup_sfp_modules_82599, |
2168 | .set_mac_anti_spoofing = &ixgbe_set_mac_anti_spoofing, | ||
2169 | .set_vlan_anti_spoofing = &ixgbe_set_vlan_anti_spoofing, | ||
2168 | }; | 2170 | }; |
2169 | 2171 | ||
2170 | static struct ixgbe_eeprom_operations eeprom_ops_82599 = { | 2172 | static struct ixgbe_eeprom_operations eeprom_ops_82599 = { |
diff --git a/drivers/net/ixgbe/ixgbe_common.c b/drivers/net/ixgbe/ixgbe_common.c index cc11e422ce9b..d5ede2df3e42 100644 --- a/drivers/net/ixgbe/ixgbe_common.c +++ b/drivers/net/ixgbe/ixgbe_common.c | |||
@@ -2809,3 +2809,67 @@ s32 ixgbe_get_wwn_prefix_generic(struct ixgbe_hw *hw, u16 *wwnn_prefix, | |||
2809 | wwn_prefix_out: | 2809 | wwn_prefix_out: |
2810 | return 0; | 2810 | return 0; |
2811 | } | 2811 | } |
2812 | |||
2813 | /** | ||
2814 | * ixgbe_set_mac_anti_spoofing - Enable/Disable MAC anti-spoofing | ||
2815 | * @hw: pointer to hardware structure | ||
2816 | * @enable: enable or disable switch for anti-spoofing | ||
2817 | * @pf: Physical Function pool - do not enable anti-spoofing for the PF | ||
2818 | * | ||
2819 | **/ | ||
2820 | void ixgbe_set_mac_anti_spoofing(struct ixgbe_hw *hw, bool enable, int pf) | ||
2821 | { | ||
2822 | int j; | ||
2823 | int pf_target_reg = pf >> 3; | ||
2824 | int pf_target_shift = pf % 8; | ||
2825 | u32 pfvfspoof = 0; | ||
2826 | |||
2827 | if (hw->mac.type == ixgbe_mac_82598EB) | ||
2828 | return; | ||
2829 | |||
2830 | if (enable) | ||
2831 | pfvfspoof = IXGBE_SPOOF_MACAS_MASK; | ||
2832 | |||
2833 | /* | ||
2834 | * PFVFSPOOF register array is size 8 with 8 bits assigned to | ||
2835 | * MAC anti-spoof enables in each register array element. | ||
2836 | */ | ||
2837 | for (j = 0; j < IXGBE_PFVFSPOOF_REG_COUNT; j++) | ||
2838 | IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(j), pfvfspoof); | ||
2839 | |||
2840 | /* If not enabling anti-spoofing then done */ | ||
2841 | if (!enable) | ||
2842 | return; | ||
2843 | |||
2844 | /* | ||
2845 | * The PF should be allowed to spoof so that it can support | ||
2846 | * emulation mode NICs. Reset the bit assigned to the PF | ||
2847 | */ | ||
2848 | pfvfspoof = IXGBE_READ_REG(hw, IXGBE_PFVFSPOOF(pf_target_reg)); | ||
2849 | pfvfspoof ^= (1 << pf_target_shift); | ||
2850 | IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(pf_target_reg), pfvfspoof); | ||
2851 | } | ||
2852 | |||
2853 | /** | ||
2854 | * ixgbe_set_vlan_anti_spoofing - Enable/Disable VLAN anti-spoofing | ||
2855 | * @hw: pointer to hardware structure | ||
2856 | * @enable: enable or disable switch for VLAN anti-spoofing | ||
2857 | * @pf: Virtual Function pool - VF Pool to set for VLAN anti-spoofing | ||
2858 | * | ||
2859 | **/ | ||
2860 | void ixgbe_set_vlan_anti_spoofing(struct ixgbe_hw *hw, bool enable, int vf) | ||
2861 | { | ||
2862 | int vf_target_reg = vf >> 3; | ||
2863 | int vf_target_shift = vf % 8 + IXGBE_SPOOF_VLANAS_SHIFT; | ||
2864 | u32 pfvfspoof; | ||
2865 | |||
2866 | if (hw->mac.type == ixgbe_mac_82598EB) | ||
2867 | return; | ||
2868 | |||
2869 | pfvfspoof = IXGBE_READ_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg)); | ||
2870 | if (enable) | ||
2871 | pfvfspoof |= (1 << vf_target_shift); | ||
2872 | else | ||
2873 | pfvfspoof &= ~(1 << vf_target_shift); | ||
2874 | IXGBE_WRITE_REG(hw, IXGBE_PFVFSPOOF(vf_target_reg), pfvfspoof); | ||
2875 | } | ||
diff --git a/drivers/net/ixgbe/ixgbe_common.h b/drivers/net/ixgbe/ixgbe_common.h index e1f980a8a09d..66ed045a8cf0 100644 --- a/drivers/net/ixgbe/ixgbe_common.h +++ b/drivers/net/ixgbe/ixgbe_common.h | |||
@@ -88,6 +88,8 @@ s32 ixgbe_get_wwn_prefix_generic(struct ixgbe_hw *hw, u16 *wwnn_prefix, | |||
88 | u16 *wwpn_prefix); | 88 | u16 *wwpn_prefix); |
89 | s32 ixgbe_blink_led_start_generic(struct ixgbe_hw *hw, u32 index); | 89 | s32 ixgbe_blink_led_start_generic(struct ixgbe_hw *hw, u32 index); |
90 | s32 ixgbe_blink_led_stop_generic(struct ixgbe_hw *hw, u32 index); | 90 | s32 ixgbe_blink_led_stop_generic(struct ixgbe_hw *hw, u32 index); |
91 | void ixgbe_set_mac_anti_spoofing(struct ixgbe_hw *hw, bool enable, int pf); | ||
92 | void ixgbe_set_vlan_anti_spoofing(struct ixgbe_hw *hw, bool enable, int vf); | ||
91 | 93 | ||
92 | #define IXGBE_WRITE_REG(a, reg, value) writel((value), ((a)->hw_addr + (reg))) | 94 | #define IXGBE_WRITE_REG(a, reg, value) writel((value), ((a)->hw_addr + (reg))) |
93 | 95 | ||
diff --git a/drivers/net/ixgbe/ixgbe_main.c b/drivers/net/ixgbe/ixgbe_main.c index c90562530202..38ab4f3f8197 100644 --- a/drivers/net/ixgbe/ixgbe_main.c +++ b/drivers/net/ixgbe/ixgbe_main.c | |||
@@ -3132,6 +3132,9 @@ static void ixgbe_configure_virtualization(struct ixgbe_adapter *adapter) | |||
3132 | 3132 | ||
3133 | /* enable Tx loopback for VF/PF communication */ | 3133 | /* enable Tx loopback for VF/PF communication */ |
3134 | IXGBE_WRITE_REG(hw, IXGBE_PFDTXGSWC, IXGBE_PFDTXGSWC_VT_LBEN); | 3134 | IXGBE_WRITE_REG(hw, IXGBE_PFDTXGSWC, IXGBE_PFDTXGSWC_VT_LBEN); |
3135 | /* Enable MAC Anti-Spoofing */ | ||
3136 | hw->mac.ops.set_mac_anti_spoofing(hw, (adapter->num_vfs != 0), | ||
3137 | adapter->num_vfs); | ||
3135 | } | 3138 | } |
3136 | 3139 | ||
3137 | static void ixgbe_set_rx_buffer_len(struct ixgbe_adapter *adapter) | 3140 | static void ixgbe_set_rx_buffer_len(struct ixgbe_adapter *adapter) |
@@ -5960,6 +5963,26 @@ static void ixgbe_fdir_reinit_task(struct work_struct *work) | |||
5960 | netif_tx_start_all_queues(adapter->netdev); | 5963 | netif_tx_start_all_queues(adapter->netdev); |
5961 | } | 5964 | } |
5962 | 5965 | ||
5966 | static void ixgbe_spoof_check(struct ixgbe_adapter *adapter) | ||
5967 | { | ||
5968 | u32 ssvpc; | ||
5969 | |||
5970 | /* Do not perform spoof check for 82598 */ | ||
5971 | if (adapter->hw.mac.type == ixgbe_mac_82598EB) | ||
5972 | return; | ||
5973 | |||
5974 | ssvpc = IXGBE_READ_REG(&adapter->hw, IXGBE_SSVPC); | ||
5975 | |||
5976 | /* | ||
5977 | * ssvpc register is cleared on read, if zero then no | ||
5978 | * spoofed packets in the last interval. | ||
5979 | */ | ||
5980 | if (!ssvpc) | ||
5981 | return; | ||
5982 | |||
5983 | e_warn(drv, "%d Spoofed packets detected\n", ssvpc); | ||
5984 | } | ||
5985 | |||
5963 | static DEFINE_MUTEX(ixgbe_watchdog_lock); | 5986 | static DEFINE_MUTEX(ixgbe_watchdog_lock); |
5964 | 5987 | ||
5965 | /** | 5988 | /** |
@@ -6080,6 +6103,7 @@ static void ixgbe_watchdog_task(struct work_struct *work) | |||
6080 | } | 6103 | } |
6081 | } | 6104 | } |
6082 | 6105 | ||
6106 | ixgbe_spoof_check(adapter); | ||
6083 | ixgbe_update_stats(adapter); | 6107 | ixgbe_update_stats(adapter); |
6084 | mutex_unlock(&ixgbe_watchdog_lock); | 6108 | mutex_unlock(&ixgbe_watchdog_lock); |
6085 | } | 6109 | } |
diff --git a/drivers/net/ixgbe/ixgbe_sriov.c b/drivers/net/ixgbe/ixgbe_sriov.c index e01d0db8b517..47b15738b009 100644 --- a/drivers/net/ixgbe/ixgbe_sriov.c +++ b/drivers/net/ixgbe/ixgbe_sriov.c | |||
@@ -215,6 +215,11 @@ static inline void ixgbe_vf_reset_msg(struct ixgbe_adapter *adapter, u32 vf) | |||
215 | reg |= (reg | (1 << vf_shift)); | 215 | reg |= (reg | (1 << vf_shift)); |
216 | IXGBE_WRITE_REG(hw, IXGBE_VFRE(reg_offset), reg); | 216 | IXGBE_WRITE_REG(hw, IXGBE_VFRE(reg_offset), reg); |
217 | 217 | ||
218 | /* Enable counting of spoofed packets in the SSVPC register */ | ||
219 | reg = IXGBE_READ_REG(hw, IXGBE_VMECM(reg_offset)); | ||
220 | reg |= (1 << vf_shift); | ||
221 | IXGBE_WRITE_REG(hw, IXGBE_VMECM(reg_offset), reg); | ||
222 | |||
218 | ixgbe_vf_reset_event(adapter, vf); | 223 | ixgbe_vf_reset_event(adapter, vf); |
219 | } | 224 | } |
220 | 225 | ||
@@ -412,6 +417,7 @@ int ixgbe_ndo_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, u8 qos) | |||
412 | { | 417 | { |
413 | int err = 0; | 418 | int err = 0; |
414 | struct ixgbe_adapter *adapter = netdev_priv(netdev); | 419 | struct ixgbe_adapter *adapter = netdev_priv(netdev); |
420 | struct ixgbe_hw *hw = &adapter->hw; | ||
415 | 421 | ||
416 | if ((vf >= adapter->num_vfs) || (vlan > 4095) || (qos > 7)) | 422 | if ((vf >= adapter->num_vfs) || (vlan > 4095) || (qos > 7)) |
417 | return -EINVAL; | 423 | return -EINVAL; |
@@ -420,7 +426,8 @@ int ixgbe_ndo_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, u8 qos) | |||
420 | if (err) | 426 | if (err) |
421 | goto out; | 427 | goto out; |
422 | ixgbe_set_vmvir(adapter, vlan | (qos << VLAN_PRIO_SHIFT), vf); | 428 | ixgbe_set_vmvir(adapter, vlan | (qos << VLAN_PRIO_SHIFT), vf); |
423 | ixgbe_set_vmolr(&adapter->hw, vf, false); | 429 | ixgbe_set_vmolr(hw, vf, false); |
430 | hw->mac.ops.set_vlan_anti_spoofing(hw, true, vf); | ||
424 | adapter->vfinfo[vf].pf_vlan = vlan; | 431 | adapter->vfinfo[vf].pf_vlan = vlan; |
425 | adapter->vfinfo[vf].pf_qos = qos; | 432 | adapter->vfinfo[vf].pf_qos = qos; |
426 | dev_info(&adapter->pdev->dev, | 433 | dev_info(&adapter->pdev->dev, |
@@ -437,7 +444,8 @@ int ixgbe_ndo_set_vf_vlan(struct net_device *netdev, int vf, u16 vlan, u8 qos) | |||
437 | err = ixgbe_set_vf_vlan(adapter, false, | 444 | err = ixgbe_set_vf_vlan(adapter, false, |
438 | adapter->vfinfo[vf].pf_vlan, vf); | 445 | adapter->vfinfo[vf].pf_vlan, vf); |
439 | ixgbe_set_vmvir(adapter, vlan, vf); | 446 | ixgbe_set_vmvir(adapter, vlan, vf); |
440 | ixgbe_set_vmolr(&adapter->hw, vf, true); | 447 | ixgbe_set_vmolr(hw, vf, true); |
448 | hw->mac.ops.set_vlan_anti_spoofing(hw, false, vf); | ||
441 | adapter->vfinfo[vf].pf_vlan = 0; | 449 | adapter->vfinfo[vf].pf_vlan = 0; |
442 | adapter->vfinfo[vf].pf_qos = 0; | 450 | adapter->vfinfo[vf].pf_qos = 0; |
443 | } | 451 | } |
diff --git a/drivers/net/ixgbe/ixgbe_type.h b/drivers/net/ixgbe/ixgbe_type.h index 59f6d0afe0fe..446f3467d3c7 100644 --- a/drivers/net/ixgbe/ixgbe_type.h +++ b/drivers/net/ixgbe/ixgbe_type.h | |||
@@ -230,6 +230,7 @@ | |||
230 | #define IXGBE_VT_CTL 0x051B0 | 230 | #define IXGBE_VT_CTL 0x051B0 |
231 | #define IXGBE_VFRE(_i) (0x051E0 + ((_i) * 4)) | 231 | #define IXGBE_VFRE(_i) (0x051E0 + ((_i) * 4)) |
232 | #define IXGBE_VFTE(_i) (0x08110 + ((_i) * 4)) | 232 | #define IXGBE_VFTE(_i) (0x08110 + ((_i) * 4)) |
233 | #define IXGBE_VMECM(_i) (0x08790 + ((_i) * 4)) | ||
233 | #define IXGBE_QDE 0x2F04 | 234 | #define IXGBE_QDE 0x2F04 |
234 | #define IXGBE_VMOLR(_i) (0x0F000 + ((_i) * 4)) /* 64 total */ | 235 | #define IXGBE_VMOLR(_i) (0x0F000 + ((_i) * 4)) /* 64 total */ |
235 | #define IXGBE_UTA(_i) (0x0F400 + ((_i) * 4)) | 236 | #define IXGBE_UTA(_i) (0x0F400 + ((_i) * 4)) |
@@ -284,7 +285,8 @@ | |||
284 | #define IXGBE_TDWBAH(_i) (0x0603C + ((_i) * 0x40)) | 285 | #define IXGBE_TDWBAH(_i) (0x0603C + ((_i) * 0x40)) |
285 | #define IXGBE_DTXCTL 0x07E00 | 286 | #define IXGBE_DTXCTL 0x07E00 |
286 | 287 | ||
287 | #define IXGBE_DMATXCTL 0x04A80 | 288 | #define IXGBE_DMATXCTL 0x04A80 |
289 | #define IXGBE_PFVFSPOOF(_i) (0x08200 + ((_i) * 4)) /* 8 of these 0 - 7 */ | ||
288 | #define IXGBE_PFDTXGSWC 0x08220 | 290 | #define IXGBE_PFDTXGSWC 0x08220 |
289 | #define IXGBE_DTXMXSZRQ 0x08100 | 291 | #define IXGBE_DTXMXSZRQ 0x08100 |
290 | #define IXGBE_DTXTCPFLGL 0x04A88 | 292 | #define IXGBE_DTXTCPFLGL 0x04A88 |
@@ -298,6 +300,13 @@ | |||
298 | #define IXGBE_DMATXCTL_VT_SHIFT 16 /* VLAN EtherType */ | 300 | #define IXGBE_DMATXCTL_VT_SHIFT 16 /* VLAN EtherType */ |
299 | 301 | ||
300 | #define IXGBE_PFDTXGSWC_VT_LBEN 0x1 /* Local L2 VT switch enable */ | 302 | #define IXGBE_PFDTXGSWC_VT_LBEN 0x1 /* Local L2 VT switch enable */ |
303 | |||
304 | /* Anti-spoofing defines */ | ||
305 | #define IXGBE_SPOOF_MACAS_MASK 0xFF | ||
306 | #define IXGBE_SPOOF_VLANAS_MASK 0xFF00 | ||
307 | #define IXGBE_SPOOF_VLANAS_SHIFT 8 | ||
308 | #define IXGBE_PFVFSPOOF_REG_COUNT 8 | ||
309 | |||
301 | #define IXGBE_DCA_TXCTRL(_i) (0x07200 + ((_i) * 4)) /* 16 of these (0-15) */ | 310 | #define IXGBE_DCA_TXCTRL(_i) (0x07200 + ((_i) * 4)) /* 16 of these (0-15) */ |
302 | /* Tx DCA Control register : 128 of these (0-127) */ | 311 | /* Tx DCA Control register : 128 of these (0-127) */ |
303 | #define IXGBE_DCA_TXCTRL_82599(_i) (0x0600C + ((_i) * 0x40)) | 312 | #define IXGBE_DCA_TXCTRL_82599(_i) (0x0600C + ((_i) * 0x40)) |
@@ -2482,6 +2491,8 @@ struct ixgbe_mac_operations { | |||
2482 | s32 (*clear_vfta)(struct ixgbe_hw *); | 2491 | s32 (*clear_vfta)(struct ixgbe_hw *); |
2483 | s32 (*set_vfta)(struct ixgbe_hw *, u32, u32, bool); | 2492 | s32 (*set_vfta)(struct ixgbe_hw *, u32, u32, bool); |
2484 | s32 (*init_uta_tables)(struct ixgbe_hw *); | 2493 | s32 (*init_uta_tables)(struct ixgbe_hw *); |
2494 | void (*set_mac_anti_spoofing)(struct ixgbe_hw *, bool, int); | ||
2495 | void (*set_vlan_anti_spoofing)(struct ixgbe_hw *, bool, int); | ||
2485 | 2496 | ||
2486 | /* Flow Control */ | 2497 | /* Flow Control */ |
2487 | s32 (*fc_enable)(struct ixgbe_hw *, s32); | 2498 | s32 (*fc_enable)(struct ixgbe_hw *, s32); |