Skip to content

Commit 89eaefb

Browse files
greearbJeff Kirsher
authored andcommitted
igb: Support RX-ALL feature flag.
This allows the NIC to receive all frames available, including those with bad FCS, un-matched vlans, ethernet control frames, and more. Tested by sending frames with bad FCS. Signed-off-by: Ben Greear <[email protected]> Tested-by: Jeff Pieper <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 6b8f092 commit 89eaefb

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

drivers/net/ethernet/intel/igb/e1000_defines.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@
134134
#define E1000_RCTL_SZ_256 0x00030000 /* rx buffer size 256 */
135135
#define E1000_RCTL_VFE 0x00040000 /* vlan filter enable */
136136
#define E1000_RCTL_CFIEN 0x00080000 /* canonical form enable */
137+
#define E1000_RCTL_DPF 0x00400000 /* Discard Pause Frames */
138+
#define E1000_RCTL_PMCF 0x00800000 /* pass MAC control frames */
137139
#define E1000_RCTL_SECRC 0x04000000 /* Strip Ethernet CRC */
138140

139141
/*

drivers/net/ethernet/intel/igb/igb_main.c

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1769,10 +1769,21 @@ static int igb_set_features(struct net_device *netdev,
17691769
netdev_features_t features)
17701770
{
17711771
netdev_features_t changed = netdev->features ^ features;
1772+
struct igb_adapter *adapter = netdev_priv(netdev);
17721773

17731774
if (changed & NETIF_F_HW_VLAN_RX)
17741775
igb_vlan_mode(netdev, features);
17751776

1777+
if (!(changed & NETIF_F_RXALL))
1778+
return 0;
1779+
1780+
netdev->features = features;
1781+
1782+
if (netif_running(netdev))
1783+
igb_reinit_locked(adapter);
1784+
else
1785+
igb_reset(adapter);
1786+
17761787
return 0;
17771788
}
17781789

@@ -1954,6 +1965,7 @@ static int __devinit igb_probe(struct pci_dev *pdev,
19541965

19551966
/* copy netdev features into list of user selectable features */
19561967
netdev->hw_features |= netdev->features;
1968+
netdev->hw_features |= NETIF_F_RXALL;
19571969

19581970
/* set this bit last since it cannot be part of hw_features */
19591971
netdev->features |= NETIF_F_HW_VLAN_FILTER;
@@ -3005,6 +3017,22 @@ void igb_setup_rctl(struct igb_adapter *adapter)
30053017
wr32(E1000_QDE, ALL_QUEUES);
30063018
}
30073019

3020+
/* This is useful for sniffing bad packets. */
3021+
if (adapter->netdev->features & NETIF_F_RXALL) {
3022+
/* UPE and MPE will be handled by normal PROMISC logic
3023+
* in e1000e_set_rx_mode */
3024+
rctl |= (E1000_RCTL_SBP | /* Receive bad packets */
3025+
E1000_RCTL_BAM | /* RX All Bcast Pkts */
3026+
E1000_RCTL_PMCF); /* RX All MAC Ctrl Pkts */
3027+
3028+
rctl &= ~(E1000_RCTL_VFE | /* Disable VLAN filter */
3029+
E1000_RCTL_DPF | /* Allow filtered pause */
3030+
E1000_RCTL_CFIEN); /* Dis VLAN CFIEN Filter */
3031+
/* Do not mess with E1000_CTRL_VME, it affects transmit as well,
3032+
* and that breaks VLANs.
3033+
*/
3034+
}
3035+
30083036
wr32(E1000_RCTL, rctl);
30093037
}
30103038

@@ -6102,8 +6130,9 @@ static bool igb_clean_rx_irq(struct igb_q_vector *q_vector, int budget)
61026130
goto next_desc;
61036131
}
61046132

6105-
if (igb_test_staterr(rx_desc,
6106-
E1000_RXDEXT_ERR_FRAME_ERR_MASK)) {
6133+
if (unlikely((igb_test_staterr(rx_desc,
6134+
E1000_RXDEXT_ERR_FRAME_ERR_MASK))
6135+
&& !(rx_ring->netdev->features & NETIF_F_RXALL))) {
61076136
dev_kfree_skb_any(skb);
61086137
goto next_desc;
61096138
}

0 commit comments

Comments
 (0)