aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/igb/igb_main.c
diff options
context:
space:
mode:
authorGreg Rose <gregory.v.rose@intel.com>2010-11-05 22:08:26 -0400
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>2010-12-25 00:36:51 -0500
commit13800469d40bf4dc9fbed17f4692b2ebe94d4526 (patch)
treed14fda8702cb36ca4039941b254e462b31f32f1c /drivers/net/igb/igb_main.c
parent1b5dda331ff8646a70d247cace45a60035937a9b (diff)
igb: Add Anti-spoofing feature support
Add support for the anti-spoofing feature in the HW. Packets from VF devices with spoofed MAC addresses or VLAN tags will be blocked and an event generated. When the watchdog task runs it will call a function to check if any spoof events occurred. If an event was detected then a warning message is dumped to the system log. Signed-off-by: Greg Rose <gregory.v.rose@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Diffstat (limited to 'drivers/net/igb/igb_main.c')
-rw-r--r--drivers/net/igb/igb_main.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/drivers/net/igb/igb_main.c b/drivers/net/igb/igb_main.c
index a364ae69ab3..58c665b7513 100644
--- a/drivers/net/igb/igb_main.c
+++ b/drivers/net/igb/igb_main.c
@@ -3366,6 +3366,45 @@ static void igb_set_rx_mode(struct net_device *netdev)
3366 igb_restore_vf_multicasts(adapter); 3366 igb_restore_vf_multicasts(adapter);
3367} 3367}
3368 3368
3369static void igb_check_wvbr(struct igb_adapter *adapter)
3370{
3371 struct e1000_hw *hw = &adapter->hw;
3372 u32 wvbr = 0;
3373
3374 switch (hw->mac.type) {
3375 case e1000_82576:
3376 case e1000_i350:
3377 if (!(wvbr = rd32(E1000_WVBR)))
3378 return;
3379 break;
3380 default:
3381 break;
3382 }
3383
3384 adapter->wvbr |= wvbr;
3385}
3386
3387#define IGB_STAGGERED_QUEUE_OFFSET 8
3388
3389static void igb_spoof_check(struct igb_adapter *adapter)
3390{
3391 int j;
3392
3393 if (!adapter->wvbr)
3394 return;
3395
3396 for(j = 0; j < adapter->vfs_allocated_count; j++) {
3397 if (adapter->wvbr & (1 << j) ||
3398 adapter->wvbr & (1 << (j + IGB_STAGGERED_QUEUE_OFFSET))) {
3399 dev_warn(&adapter->pdev->dev,
3400 "Spoof event(s) detected on VF %d\n", j);
3401 adapter->wvbr &=
3402 ~((1 << j) |
3403 (1 << (j + IGB_STAGGERED_QUEUE_OFFSET)));
3404 }
3405 }
3406}
3407
3369/* Need to wait a few seconds after link up to get diagnostic information from 3408/* Need to wait a few seconds after link up to get diagnostic information from
3370 * the phy */ 3409 * the phy */
3371static void igb_update_phy_info(unsigned long data) 3410static void igb_update_phy_info(unsigned long data)
@@ -3525,6 +3564,8 @@ static void igb_watchdog_task(struct work_struct *work)
3525 wr32(E1000_ICS, E1000_ICS_RXDMT0); 3564 wr32(E1000_ICS, E1000_ICS_RXDMT0);
3526 } 3565 }
3527 3566
3567 igb_spoof_check(adapter);
3568
3528 /* Reset the timer */ 3569 /* Reset the timer */
3529 if (!test_bit(__IGB_DOWN, &adapter->state)) 3570 if (!test_bit(__IGB_DOWN, &adapter->state))
3530 mod_timer(&adapter->watchdog_timer, 3571 mod_timer(&adapter->watchdog_timer,
@@ -4521,6 +4562,10 @@ static irqreturn_t igb_msix_other(int irq, void *data)
4521 if (icr & E1000_ICR_DOUTSYNC) { 4562 if (icr & E1000_ICR_DOUTSYNC) {
4522 /* HW is reporting DMA is out of sync */ 4563 /* HW is reporting DMA is out of sync */
4523 adapter->stats.doosync++; 4564 adapter->stats.doosync++;
4565 /* The DMA Out of Sync is also indication of a spoof event
4566 * in IOV mode. Check the Wrong VM Behavior register to
4567 * see if it is really a spoof event. */
4568 igb_check_wvbr(adapter);
4524 } 4569 }
4525 4570
4526 /* Check for a mailbox event */ 4571 /* Check for a mailbox event */
@@ -6595,6 +6640,8 @@ static void igb_vmm_control(struct igb_adapter *adapter)
6595 if (adapter->vfs_allocated_count) { 6640 if (adapter->vfs_allocated_count) {
6596 igb_vmdq_set_loopback_pf(hw, true); 6641 igb_vmdq_set_loopback_pf(hw, true);
6597 igb_vmdq_set_replication_pf(hw, true); 6642 igb_vmdq_set_replication_pf(hw, true);
6643 igb_vmdq_set_anti_spoofing_pf(hw, true,
6644 adapter->vfs_allocated_count);
6598 } else { 6645 } else {
6599 igb_vmdq_set_loopback_pf(hw, false); 6646 igb_vmdq_set_loopback_pf(hw, false);
6600 igb_vmdq_set_replication_pf(hw, false); 6647 igb_vmdq_set_replication_pf(hw, false);