igb: Support sending custom Ethernet FCS.
Subsystems (3)
PATCH 1/2 igb: Support sending custom Ethernet FCS.
From: Ben Greear <[email protected]>
Including bad FCS, used generate frames with bad FCS to test other system's handling of RX of bad packets.
---
:100644 100644 fda8247... e4058ac... M drivers/net/ethernet/intel/igb/igb_main.c
drivers/net/ethernet/intel/igb/igb_main.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
drivers/net/ethernet/intel/igb/igb_main.c +4 -0
@@ -1964,6 +1964,8 @@ static int __devinit igb_probe(struct pci_dev *pdev,NETIF_F_IPV6_CSUM |NETIF_F_SG ; + netdev->priv_flags |=IFF_SUPP_NOFCS ; +if (pci_using_dac) { netdev->features |=NETIF_F_HIGHDMA ; netdev->vlan_features |=NETIF_F_HIGHDMA ;
@@ -4292,6 +4294,8 @@ static void igb_tx_map(struct igb_ring *tx_ring,/* write last descriptor with RS and EOP bits */ cmd_type |=cpu_to_le32 (size) |cpu_to_le32 (IGB_TXD_DCMD ); +if (unlikely (skb->no_fcs)) + cmd_type &= ~(cpu_to_le32 (E1000_ADVTXD_DCMD_IFCS )); tx_desc->read.cmd_type_len = cmd_type;/* set the timestamp */
Signature · 1 line
1.7.3.4
PATCH 2/2 igb: Support RX-ALL feature flag.
From: Ben Greear <[email protected]>
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.
---
:100644 100644 aed2174... 89eb1f8... M drivers/net/ethernet/intel/igb/e1000_defines.h
:100644 100644 e4058ac... 41b905d... M drivers/net/ethernet/intel/igb/igb_main.c
drivers/net/ethernet/intel/igb/e1000_defines.h | 2 + drivers/net/ethernet/intel/igb/igb_main.c | 33 ++++++++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/igb/e1000_defines.h +2 -0
@@ -134,6 +134,8 @@#define E1000_RCTL_SZ_256 0x00030000/* rx buffer size 256 */ #define E1000_RCTL_VFE 0x00040000/* vlan filter enable */ #define E1000_RCTL_CFIEN 0x00080000/* canonical form enable */ +#define E1000_RCTL_DPF 0x00400000/* Discard Pause Frames */ +#define E1000_RCTL_PMCF 0x00800000/* pass MAC control frames */ #define E1000_RCTL_SECRC 0x04000000/* Strip Ethernet CRC */ /*
drivers/net/ethernet/intel/igb/igb_main.c +31 -2
@@ -1769,10 +1769,21 @@ static int igb_set_features(struct net_device *netdev, netdev_features_t features) {netdev_features_t changed = netdev->features ^ features; +struct igb_adapter *adapter =netdev_priv (netdev);if (changed &NETIF_F_HW_VLAN_RX )igb_vlan_mode (netdev, features); +if (!(changed &NETIF_F_RXALL )) +return 0 ; + + netdev->features = features; + +if (netif_running (netdev)) +igb_reinit_locked (adapter); +else +igb_reset (adapter); +return 0 ; }
@@ -1954,6 +1965,7 @@ static int __devinit igb_probe(struct pci_dev *pdev,/* copy netdev features into list of user selectable features */ netdev->hw_features |= netdev->features; + netdev->hw_features |=NETIF_F_RXALL ;/* set this bit last since it cannot be part of hw_features */ netdev->features |=NETIF_F_HW_VLAN_FILTER ;
@@ -3003,6 +3015,22 @@ void igb_setup_rctl(struct igb_adapter *adapter)wr32 (E1000_QDE ,ALL_QUEUES ); } +/* This is useful for sniffing bad packets. */ +if (adapter->netdev->features &NETIF_F_RXALL ) { +/* UPE and MPE will be handled by normal PROMISC logic +* in e1000e_set_rx_mode */ + rctl |= (E1000_RCTL_SBP |/* Receive bad packets */ +E1000_RCTL_BAM |/* RX All Bcast Pkts */ +E1000_RCTL_PMCF );/* RX All MAC Ctrl Pkts */ + + rctl &= ~(E1000_RCTL_VFE |/* Disable VLAN filter */ +E1000_RCTL_DPF |/* Allow filtered pause */ +E1000_RCTL_CFIEN );/* Dis VLAN CFIEN Filter */ +/* Do not mess with E1000_CTRL_VME, it affects transmit as well, +* and that breaks VLANs. +*/ + } +wr32 (E1000_RCTL , rctl); }
@@ -6101,8 +6129,9 @@ static bool igb_clean_rx_irq(struct igb_q_vector *q_vector, int budget) goto next_desc; } -if (igb_test_staterr (rx_desc, -E1000_RXDEXT_ERR_FRAME_ERR_MASK )) { +if (unlikely ((igb_test_staterr (rx_desc, +E1000_RXDEXT_ERR_FRAME_ERR_MASK )) + && !(rx_ring->netdev->features &NETIF_F_RXALL ))) {dev_kfree_skb_any (skb); goto next_desc; }
Signature · 1 line
1.7.3.4
Quoted 11 lines · On Mon, 2012-03-05 at 17:30 -0800, [email protected] wrote:
From: Ben Greear <[email protected]>
Including bad FCS, used generate frames with bad FCS to test other system's handling of RX of bad packets.
Signed-off-by Ben Greear <[email protected]>---
:100644 100644 fda8247... e4058ac...
Mdrivers/net/ethernet/intel/igb/igb_main.cdrivers/net/ethernet/intel/igb/igb_main.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
I have added these as well to my queue, thanks Ben!