Skip to contentSkip to conversation

Low-level Ethernet debugging features.

PATCH Superseded [email protected] 7 participants 26 messages Feb 8, 2012 – Feb 11, 2012

Subsystems (16)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover Low-level Ethernet debugging features.

From: Ben Greear <[email protected]>

This patch series enables some features designed to make testing ethernet devices and debugging link-level errors easier.

First, support is added for receiving the Ethernet FCS. This allows stock wireshark to show you the actual Ethernet FCS.

Second, allow sending packets with user-specified Ethernet FCS. The user can specify bad FCS in order to test network equipments' handling of FCS errors, or, in strange cases, users might want to implement their own FCS scheme.

Third, allow configuring a NIC to receive errored (and possibly other types of packets not normally passed up the stack). This allows sniffers to show packets with bad FCS, for instance.

These features have been tested on e100 and e1000e. The e1000 patch has not been tested yet.

Changes from first posting:

* Ensure nic reset when changing the rx-fcs and rx-all logic in e100 (e1000e already did this).

* Use priv-flag for the 'send customized CRC' logic and make it non configurable (if NIC supports it, feature is enabled) Please note that this will only be used when the SKB is specifically flagged as wanting this behaviour.

* Use EPROTONOSUPPORT error to indicate the packet-socket's bound NIC does not support the 'send customized CRC' feature.

* Some general cleanup, and patch re-ordering.

There was a suggestion to throw away packets flagged as bad by the NIC. I did not add any additional logic to do this. I think it is not needed, but I am open to other opinions.

Ben Greear (10):
net: Support RXFCS feature flag.
e100: Support RXFCS feature flag.
e1000e: Support RXFCS feature flag.
net: Add framework to allow sending packets with customized CRC.
e100: Support sending custom Ethernet CRC
e1000e: Support sending custom Ethernet CRC.
net: Support RX-ALL feature flag.
e1000e: Support RXALL feature flag.
e100: Support RXALL feature flag.
e1000: Support sending custom Ethernet CRC.

 Documentation/networking/netdev-features.txt  |   13 ++++
 arch/alpha/include/asm/socket.h               |    3 +
 arch/arm/include/asm/socket.h                 |    3 +
 arch/avr32/include/asm/socket.h               |    3 +
 arch/cris/include/asm/socket.h                |    3 +
 arch/frv/include/asm/socket.h                 |    3 +
 arch/h8300/include/asm/socket.h               |    3 +
 arch/ia64/include/asm/socket.h                |    3 +
 arch/m32r/include/asm/socket.h                |    3 +
 arch/m68k/include/asm/socket.h                |    3 +
 arch/mips/include/asm/socket.h                |    3 +
 arch/mn10300/include/asm/socket.h             |    3 +
 arch/parisc/include/asm/socket.h              |    4 +
 arch/powerpc/include/asm/socket.h             |    3 +
 arch/s390/include/asm/socket.h                |    3 +
 arch/sparc/include/asm/socket.h               |    4 +
 arch/xtensa/include/asm/socket.h              |    3 +
 drivers/net/ethernet/intel/e100.c             |   66 +++++++++++++++++++-
 drivers/net/ethernet/intel/e1000/e1000_main.c |   13 ++++
 drivers/net/ethernet/intel/e1000e/defines.h   |    1 +
 drivers/net/ethernet/intel/e1000e/e1000.h     |    1 +
 drivers/net/ethernet/intel/e1000e/netdev.c    |   80 +++++++++++++++++++++---
 drivers/net/ethernet/intel/e1000e/param.c     |    5 +-
 include/asm-generic/socket.h                  |    4 +
 include/linux/if.h                            |    2 +
 include/linux/netdev_features.h               |    4 +
 include/linux/netdevice.h                     |    8 ++-
 include/linux/skbuff.h                        |    4 +-
 include/net/sock.h                            |    4 +
 net/core/ethtool.c                            |    2 +
 net/core/skbuff.c                             |    1 +
 net/core/sock.c                               |    4 +
 net/packet/af_packet.c                        |   32 +++++++++-
 33 files changed, 273 insertions(+), 21 deletions(-)
Signature · 1 line
1.7.3.4
#2 lore raw

PATCH v2 2/10 e100: Support RXFCS feature flag.

From: Ben Greear <[email protected]>

This allows e100 to be configured to append the
Ethernet FCS to the skb.

Useful for sniffing networks.

---
:100644 100644 485ab8c... 943178b... M drivers/net/ethernet/intel/e100.c

 drivers/net/ethernet/intel/e100.c |   30 +++++++++++++++++++++++++++---
 1 files changed, 27 insertions(+), 3 deletions(-)
drivers/net/ethernet/intel/e100.c +27 -3
index 485ab8c..943178b 100644
@@ -1089,6 +1089,7 @@ static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
 {
 	struct config *config = &cb->u.config;
 	u8 *c = (u8 *)config;
+	struct net_device *netdev = nic->netdev;
 
 	cb->command = cpu_to_le16(cb_config);
 
@@ -1132,6 +1133,9 @@ static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
 		config->promiscuous_mode = 0x1;		/* 1=on, 0=off */
 	}
 
+	if (unlikely(netdev->features & NETIF_F_RXFCS))
+		config->rx_crc_transfer = 0x1;	/* 1=save, 0=discard */
+
 	if (nic->flags & multicast_all)
 		config->multicast_all = 0x1;		/* 1=accept, 0=no */
 
@@ -1919,6 +1923,7 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx,
 	struct sk_buff *skb = rx->skb;
 	struct rfd *rfd = (struct rfd *)skb->data;
 	u16 rfd_status, actual_size;
+	u16 fcs_pad = 0;
 
 	if (unlikely(work_done && *work_done >= work_to_do))
 		return -EAGAIN;
@@ -1951,9 +1956,11 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx,
 	}
 
 	/* Get actual data size */
+	if (unlikely(dev->features & NETIF_F_RXFCS))
+		fcs_pad = 4;
 	actual_size = le16_to_cpu(rfd->actual_size) & 0x3FFF;
-	if (unlikely(actual_size > RFD_BUF_LEN - sizeof(struct rfd)))
-		actual_size = RFD_BUF_LEN - sizeof(struct rfd);
+	if (unlikely(actual_size > RFD_BUF_LEN + fcs_pad - sizeof(struct rfd)))
+		actual_size = RFD_BUF_LEN + fcs_pad - sizeof(struct rfd);
 
 	/* Get data */
 	pci_unmap_single(nic->pdev, rx->dma_addr,
@@ -1980,7 +1987,7 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx,
 	if (unlikely(!(rfd_status & cb_ok))) {
 		/* Don't indicate if hardware indicates errors */
 		dev_kfree_skb_any(skb);
-	} else if (actual_size > ETH_DATA_LEN + VLAN_ETH_HLEN) {
+	} else if (actual_size > ETH_DATA_LEN + VLAN_ETH_HLEN + fcs_pad) {
 		/* Don't indicate oversized frames */
 		nic->rx_over_length_errors++;
 		dev_kfree_skb_any(skb);
@@ -2729,6 +2736,20 @@ static int e100_close(struct net_device *netdev)
 	return 0;
 }
 
+static int e100_set_features(struct net_device *netdev,
+			     netdev_features_t features)
+{
+	struct nic *nic = netdev_priv(netdev);
+	netdev_features_t changed = features ^ netdev->features;
+
+	if (!(changed & (NETIF_F_RXFCS)))
+		return 0;
+
+	netdev->features = features;
+	e100_exec_cb(nic, NULL, e100_configure);
+	return 0;
+}
+
 static const struct net_device_ops e100_netdev_ops = {
 	.ndo_open		= e100_open,
 	.ndo_stop		= e100_close,
@@ -2742,6 +2763,7 @@ static const struct net_device_ops e100_netdev_ops = {
 #ifdef CONFIG_NET_POLL_CONTROLLER
 	.ndo_poll_controller	= e100_netpoll,
 #endif
+	.ndo_set_features	= e100_set_features,
 };
 
 static int __devinit e100_probe(struct pci_dev *pdev,
@@ -2754,6 +2776,8 @@ static int __devinit e100_probe(struct pci_dev *pdev,
 	if (!(netdev = alloc_etherdev(sizeof(struct nic))))
 		return -ENOMEM;
 
+	netdev->hw_features |= NETIF_F_RXFCS;
+
 	netdev->netdev_ops = &e100_netdev_ops;
 	SET_ETHTOOL_OPS(netdev, &e100_ethtool_ops);
 	netdev->watchdog_timeo = E100_WATCHDOG_PERIOD;
Signature · 1 line
1.7.3.4
#1 lore raw

PATCH v2 1/10 net: Support RXFCS feature flag.

In reply to [email protected]

From: Ben Greear <[email protected]>

When set on hardware that supports the feature,
this causes the Ethernet FCS to be appended
to the end of the skb.

Useful for sniffing packets.

---
:100644 100644 4b1c0dc... 7d27812... M Documentation/networking/netdev-features.txt
:100644 100644 77f5202... d133186... M include/linux/netdev_features.h
:100644 100644 3f79db1... 0801619... M net/core/ethtool.c

 Documentation/networking/netdev-features.txt |    6 ++++++
 include/linux/netdev_features.h              |    2 ++
 net/core/ethtool.c                           |    1 +
 3 files changed, 9 insertions(+), 0 deletions(-)
Documentation/networking/netdev-features.txt +6 -0
index 4b1c0dc..7d27812 100644
@@ -152,3 +152,9 @@ NETIF_F_VLAN_CHALLENGED should be set for devices which can't cope with VLAN
 headers. Some drivers set this because the cards can't handle the bigger MTU.
 [FIXME: Those cases could be fixed in VLAN code by allowing only reduced-MTU
 VLANs. This may be not useful, though.]
+
+*  rx-fcs
+
+This requests that the NIC append the Ethernet Frame Checksum (FCS)
+to the end of the skb data.  This allows sniffers and other tools to
+read the CRC recorded by the NIC on receipt of the packet.
include/linux/netdev_features.h +2 -0
index 77f5202..d133186 100644
@@ -54,6 +54,7 @@ enum {
 	NETIF_F_RXCSUM_BIT,		/* Receive checksumming offload */
 	NETIF_F_NOCACHE_COPY_BIT,	/* Use no-cache copyfromuser */
 	NETIF_F_LOOPBACK_BIT,		/* Enable loopback */
+	NETIF_F_RXFCS_BIT,		/* Append FCS to skb pkt data */
 
 	/*
 	 * Add your fresh new feature above and remember to update
@@ -98,6 +99,7 @@ enum {
 #define NETIF_F_TSO		__NETIF_F(TSO)
 #define NETIF_F_UFO		__NETIF_F(UFO)
 #define NETIF_F_VLAN_CHALLENGED	__NETIF_F(VLAN_CHALLENGED)
+#define NETIF_F_RXFCS		__NETIF_F(RXFCS)
 
 /* Features valid for ethtool to change */
 /* = all defined minus driver/device-class-related */
net/core/ethtool.c +1 -0
index 3f79db1..0801619 100644
@@ -73,6 +73,7 @@ static const char netdev_features_strings[NETDEV_FEATURE_COUNT][ETH_GSTRING_LEN]
 	[NETIF_F_RXCSUM_BIT] =           "rx-checksum",
 	[NETIF_F_NOCACHE_COPY_BIT] =     "tx-nocache-copy",
 	[NETIF_F_LOOPBACK_BIT] =         "loopback",
+	[NETIF_F_RXFCS_BIT] =            "rx-fcs",
 };
 
 static int ethtool_get_features(struct net_device *dev, void __user *useraddr)
Signature · 1 line
1.7.3.4
#5 lore raw

PATCH v2 3/10 e1000e: Support RXFCS feature flag.

In reply to [email protected]

From: Ben Greear <[email protected]>

This enables enabling/disabling reception of the Ethernet FCS. This can be useful when sniffing packets.

For e1000e, enabling RXFCS can change the default behaviour for how the NIC handles CRC. Disabling RXFCS will take the NIC back to defaults, which can be configured as part of the module options.

---
:100644 100644 45e5ae8... 04a21fc... M drivers/net/ethernet/intel/e1000e/e1000.h
:100644 100644 293a760... e3eefda... M drivers/net/ethernet/intel/e1000e/netdev.c
:100644 100644 9c6a56d... ff796e4... M drivers/net/ethernet/intel/e1000e/param.c

 drivers/net/ethernet/intel/e1000e/e1000.h  |    1 +
 drivers/net/ethernet/intel/e1000e/netdev.c |   41 +++++++++++++++++++++++-----
 drivers/net/ethernet/intel/e1000e/param.c  |    5 +++-
 3 files changed, 39 insertions(+), 8 deletions(-)
drivers/net/ethernet/intel/e1000e/e1000.h +1 -0
index 45e5ae8..04a21fc 100644
@@ -461,6 +461,7 @@ struct e1000_info {
 #define FLAG2_CHECK_PHY_HANG              (1 << 9)
 #define FLAG2_NO_DISABLE_RX               (1 << 10)
 #define FLAG2_PCIM2PCI_ARBITER_WA         (1 << 11)
+#define FLAG2_DFLT_CRC_STRIPPING          (1 << 12)
 
 #define E1000_RX_DESC_PS(R, i)	    \
 	(&(((union e1000_rx_desc_packet_split *)((R).desc))[i]))
drivers/net/ethernet/intel/e1000e/netdev.c +34 -7

77 lines not on this page · raw message

drivers/net/ethernet/intel/e1000e/param.c +4 -1
index 9c6a56d..ff796e4 100644
@@ -463,10 +463,13 @@ void __devinit e1000e_check_options(struct e1000_adapter *adapter)
 		if (num_CrcStripping > bd) {
 			unsigned int crc_stripping = CrcStripping[bd];
 			e1000_validate_option(&crc_stripping, &opt, adapter);
-			if (crc_stripping == OPTION_ENABLED)
+			if (crc_stripping == OPTION_ENABLED) {
 				adapter->flags2 |= FLAG2_CRC_STRIPPING;
+				adapter->flags2 |= FLAG2_DFLT_CRC_STRIPPING;
+			}
 		} else {
 			adapter->flags2 |= FLAG2_CRC_STRIPPING;
+			adapter->flags2 |= FLAG2_DFLT_CRC_STRIPPING;
 		}
 	}
 	{ /* Kumeran Lock Loss Workaround */
Signature · 1 line
1.7.3.4
#10 lore raw

PATCH v2 4/10 net: Add framework to allow sending packets with customized CRC.

In reply to [email protected]

From: Ben Greear <[email protected]>

This is useful for testing RX handling of frames with bad CRCs.

Requires driver support to actually put the packet on the wire properly.

---
:100644 100644 082355f... 87ba870... M arch/alpha/include/asm/socket.h
:100644 100644 dec6f9a... ea7629e... M arch/arm/include/asm/socket.h
:100644 100644 247b88c... 6d2e448... M arch/avr32/include/asm/socket.h
:100644 100644 e269264... 9ba1079... M arch/cris/include/asm/socket.h
:100644 100644 ce80fda... ff8a4c3... M arch/frv/include/asm/socket.h
:100644 100644 cf1daab... 8be2267... M arch/h8300/include/asm/socket.h
:100644 100644 4b03664... 17664c9... M arch/ia64/include/asm/socket.h
:100644 100644 e8b8c5b... 20de3ac... M arch/m32r/include/asm/socket.h
:100644 100644 d4708ce... 98bf770... M arch/m68k/include/asm/socket.h
:100644 100644 ad5c0a7... d97c83a... M arch/mips/include/asm/socket.h
:100644 100644 876356d... 545cbbe... M arch/mn10300/include/asm/socket.h
:100644 100644 d28c51b... 15d2d90... M arch/parisc/include/asm/socket.h
:100644 100644 2fc2af8... 29bbe62... M arch/powerpc/include/asm/socket.h
:100644 100644 67b5c1b... 237b1e7... M arch/s390/include/asm/socket.h
:100644 100644 8af1b64... 18d523a... M arch/sparc/include/asm/socket.h
:100644 100644 bb06968... 00af4e6... M arch/xtensa/include/asm/socket.h
:100644 100644 49c1704... 3c59235... M include/asm-generic/socket.h
:100644 100644 06b6ef6... f995c66... M include/linux/if.h
:100644 100644 0eac07c... f1b7d03... M include/linux/netdevice.h
:100644 100644 50db9b0... cc614a9... M include/linux/skbuff.h
:100644 100644 91c1c8b... 5d8ecbc... M include/net/sock.h
:100644 100644 da0c97f... 36e7b7c... M net/core/skbuff.c
:100644 100644 3e81fd2... 1db3096... M net/core/sock.c
:100644 100644 2dbb32b... ae2d484... M net/packet/af_packet.c

 arch/alpha/include/asm/socket.h   |    3 +++
 arch/arm/include/asm/socket.h     |    3 +++
 arch/avr32/include/asm/socket.h   |    3 +++
 arch/cris/include/asm/socket.h    |    3 +++
 arch/frv/include/asm/socket.h     |    3 +++
 arch/h8300/include/asm/socket.h   |    3 +++
 arch/ia64/include/asm/socket.h    |    3 +++
 arch/m32r/include/asm/socket.h    |    3 +++
 arch/m68k/include/asm/socket.h    |    3 +++
 arch/mips/include/asm/socket.h    |    3 +++
 arch/mn10300/include/asm/socket.h |    3 +++
 arch/parisc/include/asm/socket.h  |    4 ++++
 arch/powerpc/include/asm/socket.h |    3 +++
 arch/s390/include/asm/socket.h    |    3 +++
 arch/sparc/include/asm/socket.h   |    4 ++++
 arch/xtensa/include/asm/socket.h  |    3 +++
 include/asm-generic/socket.h      |    4 ++++
 include/linux/if.h                |    2 ++
 include/linux/netdevice.h         |    8 +++++++-
 include/linux/skbuff.h            |    4 +++-
 include/net/sock.h                |    4 ++++
 net/core/skbuff.c                 |    1 +
 net/core/sock.c                   |    4 ++++
 net/packet/af_packet.c            |   32 ++++++++++++++++++++++++++++----
 24 files changed, 103 insertions(+), 6 deletions(-)
arch/alpha/include/asm/socket.h +3 -0
index 082355f..87ba870 100644
@@ -72,6 +72,9 @@
 #define SO_WIFI_STATUS		41
 #define SCM_WIFI_STATUS		SO_WIFI_STATUS
 
+/* Instruct lower device to use last 4-bytes of skb data as FCS */
+#define SO_NOFCS		42
+
 /* O_NONBLOCK clashes with the bits used for socket types.  Therefore we
  * have to define SOCK_NONBLOCK to a different value here.
  */
arch/arm/include/asm/socket.h +3 -0
index dec6f9a..ea7629e 100644
@@ -65,4 +65,7 @@
 #define SO_WIFI_STATUS		41
 #define SCM_WIFI_STATUS		SO_WIFI_STATUS
 
+/* Instruct lower device to use last 4-bytes of skb data as FCS */
+#define SO_NOFCS		42
+
 #endif /* _ASM_SOCKET_H */
arch/avr32/include/asm/socket.h +3 -0
index 247b88c..6d2e448 100644
@@ -65,4 +65,7 @@
 #define SO_WIFI_STATUS		41
 #define SCM_WIFI_STATUS		SO_WIFI_STATUS
 
+/* Instruct lower device to use last 4-bytes of skb data as FCS */
+#define SO_NOFCS		42
+
 #endif /* __ASM_AVR32_SOCKET_H */
arch/cris/include/asm/socket.h +3 -0
index e269264..9ba1079 100644
@@ -67,6 +67,9 @@
 #define SO_WIFI_STATUS		41
 #define SCM_WIFI_STATUS		SO_WIFI_STATUS
 
+/* Instruct lower device to use last 4-bytes of skb data as FCS */
+#define SO_NOFCS		42
+
 #endif /* _ASM_SOCKET_H */
 
 
arch/frv/include/asm/socket.h +3 -0
index ce80fda..ff8a4c3 100644
@@ -65,5 +65,8 @@
 #define SO_WIFI_STATUS		41
 #define SCM_WIFI_STATUS		SO_WIFI_STATUS
 
+/* Instruct lower device to use last 4-bytes of skb data as FCS */
+#define SO_NOFCS		42
+
 #endif /* _ASM_SOCKET_H */
 
arch/h8300/include/asm/socket.h +3 -0
index cf1daab..8be2267 100644
@@ -65,4 +65,7 @@
 #define SO_WIFI_STATUS		41
 #define SCM_WIFI_STATUS		SO_WIFI_STATUS
 
+/* Instruct lower device to use last 4-bytes of skb data as FCS */
+#define SO_NOFCS		42
+
 #endif /* _ASM_SOCKET_H */
arch/ia64/include/asm/socket.h +3 -0
index 4b03664..17664c9 100644
@@ -74,4 +74,7 @@
 #define SO_WIFI_STATUS		41
 #define SCM_WIFI_STATUS		SO_WIFI_STATUS
 
+/* Instruct lower device to use last 4-bytes of skb data as FCS */
+#define SO_NOFCS		42
+
 #endif /* _ASM_IA64_SOCKET_H */
arch/m32r/include/asm/socket.h +3 -0
index e8b8c5b..20de3ac 100644
@@ -65,4 +65,7 @@
 #define SO_WIFI_STATUS		41
 #define SCM_WIFI_STATUS		SO_WIFI_STATUS
 
+/* Instruct lower device to use last 4-bytes of skb data as FCS */
+#define SO_NOFCS		42
+
 #endif /* _ASM_M32R_SOCKET_H */
arch/m68k/include/asm/socket.h +3 -0
index d4708ce..98bf770 100644
@@ -65,4 +65,7 @@
 #define SO_WIFI_STATUS		41
 #define SCM_WIFI_STATUS		SO_WIFI_STATUS
 
+/* Instruct lower device to use last 4-bytes of skb data as FCS */
+#define SO_NOFCS		42
+
 #endif /* _ASM_SOCKET_H */
arch/mips/include/asm/socket.h +3 -0
index ad5c0a7..d97c83a 100644
@@ -85,6 +85,9 @@ To add: #define SO_REUSEPORT 0x0200	/* Allow local address and port reuse.  */
 #define SO_WIFI_STATUS		41
 #define SCM_WIFI_STATUS		SO_WIFI_STATUS
 
+/* Instruct lower device to use last 4-bytes of skb data as FCS */
+#define SO_NOFCS		42
+
 #ifdef __KERNEL__
 
 /** sock_type - Socket types
arch/mn10300/include/asm/socket.h +3 -0
index 876356d..545cbbe 100644
@@ -65,4 +65,7 @@
 #define SO_WIFI_STATUS		41
 #define SCM_WIFI_STATUS		SO_WIFI_STATUS
 
+/* Instruct lower device to use last 4-bytes of skb data as FCS */
+#define SO_NOFCS		42
+
 #endif /* _ASM_SOCKET_H */
arch/parisc/include/asm/socket.h +4 -0
index d28c51b..15d2d90 100644
@@ -64,6 +64,10 @@
 #define SO_WIFI_STATUS		0x4022
 #define SCM_WIFI_STATUS		SO_WIFI_STATUS
 
+/* Instruct lower device to use last 4-bytes of skb data as FCS */
+#define SO_NOFCS		0x4023
+
+
 /* O_NONBLOCK clashes with the bits used for socket types.  Therefore we
  * have to define SOCK_NONBLOCK to a different value here.
  */
arch/powerpc/include/asm/socket.h +3 -0
index 2fc2af8..29bbe62 100644
@@ -72,4 +72,7 @@
 #define SO_WIFI_STATUS		41
 #define SCM_WIFI_STATUS		SO_WIFI_STATUS
 
+/* Instruct lower device to use last 4-bytes of skb data as FCS */
+#define SO_NOFCS		42
+
 #endif	/* _ASM_POWERPC_SOCKET_H */
arch/s390/include/asm/socket.h +3 -0
index 67b5c1b..237b1e7 100644
@@ -73,4 +73,7 @@
 #define SO_WIFI_STATUS		41
 #define SCM_WIFI_STATUS		SO_WIFI_STATUS
 
+/* Instruct lower device to use last 4-bytes of skb data as FCS */
+#define SO_NOFCS		42
+
 #endif /* _ASM_SOCKET_H */
arch/sparc/include/asm/socket.h +4 -0
index 8af1b64..18d523a 100644
@@ -61,6 +61,10 @@
 #define SO_WIFI_STATUS		0x0025
 #define SCM_WIFI_STATUS		SO_WIFI_STATUS
 
+/* Instruct lower device to use last 4-bytes of skb data as FCS */
+#define SO_NOFCS		0x0026
+
+
 /* Security levels - as per NRL IPv6 - don't actually do anything */
 #define SO_SECURITY_AUTHENTICATION		0x5001
 #define SO_SECURITY_ENCRYPTION_TRANSPORT	0x5002
arch/xtensa/include/asm/socket.h +3 -0
index bb06968..00af4e6 100644
@@ -76,4 +76,7 @@
 #define SO_WIFI_STATUS		41
 #define SCM_WIFI_STATUS		SO_WIFI_STATUS
 
+/* Instruct lower device to use last 4-bytes of skb data as FCS */
+#define SO_NOFCS		42
+
 #endif	/* _XTENSA_SOCKET_H */
include/asm-generic/socket.h +4 -0
index 49c1704..3c59235 100644
@@ -67,4 +67,8 @@
 
 #define SO_WIFI_STATUS		41
 #define SCM_WIFI_STATUS	SO_WIFI_STATUS
+
+/* Instruct lower device to use last 4-bytes of skb data as FCS */
+#define SO_NOFCS		42
+
 #endif /* __ASM_GENERIC_SOCKET_H */
include/linux/if.h +2 -0
index 06b6ef6..f995c66 100644
@@ -80,6 +80,8 @@
 					 * skbs on transmit */
 #define IFF_UNICAST_FLT	0x20000		/* Supports unicast filtering	*/
 #define IFF_TEAM_PORT	0x40000		/* device used as team port */
+#define IFF_SUPP_NOFCS	0x80000		/* device supports sending custom FCS */
+
 
 #define IF_GET_IFACE	0x0001		/* for querying only */
 #define IF_GET_PROTO	0x0002
include/linux/netdevice.h +7 -1
index 0eac07c..f1b7d03 100644
@@ -1082,7 +1082,8 @@ struct net_device {
 	const struct header_ops *header_ops;
 
 	unsigned int		flags;	/* interface flags (a la BSD)	*/
-	unsigned int		priv_flags; /* Like 'flags' but invisible to userspace. */
+	unsigned int		priv_flags; /* Like 'flags' but invisible to userspace.
+					     * See if.h for definitions. */
 	unsigned short		gflags;
 	unsigned short		padded;	/* How much padding added by alloc_netdev() */
 
@@ -2650,6 +2651,11 @@ static inline int netif_is_bond_slave(struct net_device *dev)
 	return dev->flags & IFF_SLAVE && dev->priv_flags & IFF_BONDING;
 }
 
+static inline bool netif_supports_nofcs(struct net_device *dev)
+{
+	return dev->priv_flags & IFF_SUPP_NOFCS;
+}
+
 extern struct pernet_operations __net_initdata loopback_net_ops;
 
 /* Logging, debugging and troubleshooting/diagnostic helpers. */
include/linux/skbuff.h +3 -1
index 50db9b0..cc614a9 100644
@@ -361,6 +361,7 @@ typedef unsigned char *sk_buff_data_t;
  *		ports.
  *	@wifi_acked_valid: wifi_acked was set
  *	@wifi_acked: whether frame was acked on wifi or not
+ *	@no_fcs:  Request NIC to treat last 4 bytes as Ethernet FCS
  *	@dma_cookie: a cookie to one of several possible DMA operations
  *		done by skb DMA functions
  *	@secmark: security marking
@@ -456,7 +457,8 @@ struct sk_buff {
 	__u8			l4_rxhash:1;
 	__u8			wifi_acked_valid:1;
 	__u8			wifi_acked:1;
-	/* 10/12 bit hole (depending on ndisc_nodetype presence) */
+	__u8			no_fcs:1;
+	/* 9/11 bit hole (depending on ndisc_nodetype presence) */
 	kmemcheck_bitfield_end(flags2);
 
 #ifdef CONFIG_NET_DMA
include/net/sock.h +4 -0
index 91c1c8b..5d8ecbc 100644
@@ -590,6 +590,10 @@ enum sock_flags {
 	SOCK_RXQ_OVFL,
 	SOCK_ZEROCOPY, /* buffers from userspace */
 	SOCK_WIFI_STATUS, /* push wifi status to userspace */
+	SOCK_NOFCS, /* Tell NIC not to do the Ethernet FCS.
+		     * Will use last 4 bytes of packet sent from
+		     * user-space instead.
+		     */
 };
 
 static inline void sock_copy_flags(struct sock *nsk, struct sock *osk)
net/core/skbuff.c +1 -0
index da0c97f..36e7b7c 100644
@@ -592,6 +592,7 @@ static void __copy_skb_header(struct sk_buff *new, const struct sk_buff *old)
 	new->rxhash		= old->rxhash;
 	new->ooo_okay		= old->ooo_okay;
 	new->l4_rxhash		= old->l4_rxhash;
+	new->no_fcs		= old->no_fcs;
 #ifdef CONFIG_XFRM
 	new->sp			= secpath_get(old->sp);
 #endif
net/core/sock.c +4 -0
index 3e81fd2..1db3096 100644
@@ -793,6 +793,10 @@ set_rcvbuf:
 		sock_valbool_flag(sk, SOCK_WIFI_STATUS, valbool);
 		break;
 
+	case SO_NOFCS:
+		sock_valbool_flag(sk, SOCK_NOFCS, valbool);
+		break;
+
 	default:
 		ret = -ENOPROTOOPT;
 		break;
net/packet/af_packet.c +28 -4
index 2dbb32b..ae2d484 100644
@@ -1459,6 +1459,7 @@ static int packet_sendmsg_spkt(struct kiocb *iocb, struct socket *sock,
 	struct net_device *dev;
 	__be16 proto = 0;
 	int err;
+	int extra_len = 0;
 
 	/*
 	 *	Get and verify the address.
@@ -1493,8 +1494,16 @@ retry:
 	 * raw protocol and you must do your own fragmentation at this level.
 	 */
 
+	if (unlikely(sock_flag(sk, SOCK_NOFCS))) {
+		if (!netif_supports_nofcs(dev)) {
+			err = -EPROTONOSUPPORT;
+			goto out_unlock;
+		}
+		extra_len = 4; /* We're doing our own CRC */
+	}
+
 	err = -EMSGSIZE;
-	if (len > dev->mtu + dev->hard_header_len + VLAN_HLEN)
+	if (len > dev->mtu + dev->hard_header_len + VLAN_HLEN + extra_len)
 		goto out_unlock;
 
 	if (!skb) {
@@ -1526,7 +1535,7 @@ retry:
 		goto retry;
 	}
 
-	if (len > (dev->mtu + dev->hard_header_len)) {
+	if (len > (dev->mtu + dev->hard_header_len + extra_len)) {
 		/* Earlier code assumed this would be a VLAN pkt,
 		 * double-check this now that we have the actual
 		 * packet in hand.
@@ -1548,6 +1557,9 @@ retry:
 	if (err < 0)
 		goto out_unlock;
 
+	if (unlikely(extra_len == 4))
+		skb->no_fcs = 1;
+
 	dev_queue_xmit(skb);
 	rcu_read_unlock();
 	return len;
@@ -2209,6 +2221,7 @@ static int packet_snd(struct socket *sock,
 	struct packet_sock *po = pkt_sk(sk);
 	unsigned short gso_type = 0;
 	int hlen, tlen;
+	int extra_len = 0;
 
 	/*
 	 *	Get and verify the address.
@@ -2288,8 +2301,16 @@ static int packet_snd(struct socket *sock,
 		}
 	}
 
+	if (unlikely(sock_flag(sk, SOCK_NOFCS))) {
+		if (!netif_supports_nofcs(dev)) {
+			err = -EPROTONOSUPPORT;
+			goto out_unlock;
+		}
+		extra_len = 4; /* We're doing our own CRC */
+	}
+
 	err = -EMSGSIZE;
-	if (!gso_type && (len > dev->mtu + reserve + VLAN_HLEN))
+	if (!gso_type && (len > dev->mtu + reserve + VLAN_HLEN + extra_len))
 		goto out_unlock;
 
 	err = -ENOBUFS;
@@ -2315,7 +2336,7 @@ static int packet_snd(struct socket *sock,
 	if (err < 0)
 		goto out_free;
 
-	if (!gso_type && (len > dev->mtu + reserve)) {
+	if (!gso_type && (len > dev->mtu + reserve + extra_len)) {
 		/* Earlier code assumed this would be a VLAN pkt,
 		 * double-check this now that we have the actual
 		 * packet in hand.
@@ -2353,6 +2374,9 @@ static int packet_snd(struct socket *sock,
 		len += vnet_hdr_len;
 	}
 
+	if (unlikely(extra_len == 4))
+		skb->no_fcs = 1;
+
 	/*
 	 *	Now send it
 	 */
Signature · 1 line
1.7.3.4
#11 lore raw

PATCH v2 5/10 e100: Support sending custom Ethernet CRC

In reply to [email protected]

From: Ben Greear <[email protected]>

This can aid with testing the RX logic for bad
CRCs.

---
:100644 100644 943178b... c793939... M drivers/net/ethernet/intel/e100.c

 drivers/net/ethernet/intel/e100.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)
drivers/net/ethernet/intel/e100.c +16 -0
index 943178b..c793939 100644
@@ -412,6 +412,10 @@ enum cb_status {
 	cb_ok       = 0x2000,
 };
 
+/**
+ * cb_command - Command Block flags
+ * @cb_tx_nc:  0: controler does CRC (normal),  1: CRC from skb memory
+ */
 enum cb_command {
 	cb_nop    = 0x0000,
 	cb_iaaddr = 0x0001,
@@ -421,6 +425,7 @@ enum cb_command {
 	cb_ucode  = 0x0005,
 	cb_dump   = 0x0006,
 	cb_tx_sf  = 0x0008,
+	cb_tx_nc  = 0x0010,
 	cb_cid    = 0x1f00,
 	cb_i      = 0x2000,
 	cb_s      = 0x4000,
@@ -1724,6 +1729,16 @@ static void e100_xmit_prepare(struct nic *nic, struct cb *cb,
 	struct sk_buff *skb)
 {
 	cb->command = nic->tx_command;
+
+	/*
+	 * Use the last 4 bytes of the SKB payload packet as the CRC, used for
+	 * testing, ie sending frames with bad CRC.
+	 */
+	if (unlikely(skb->no_fcs))
+		cb->command |= __constant_cpu_to_le16(cb_tx_nc);
+	else
+		cb->command &= ~__constant_cpu_to_le16(cb_tx_nc);
+
 	/* interrupt every 16 packets regardless of delay */
 	if ((nic->cbs_avail & ~15) == nic->cbs_avail)
 		cb->command |= cpu_to_le16(cb_i);
@@ -2777,6 +2792,7 @@ static int __devinit e100_probe(struct pci_dev *pdev,
 		return -ENOMEM;
 
 	netdev->hw_features |= NETIF_F_RXFCS;
+	netdev->priv_flags |= IFF_SUPP_NOFCS;
 
 	netdev->netdev_ops = &e100_netdev_ops;
 	SET_ETHTOOL_OPS(netdev, &e100_ethtool_ops);
Signature · 1 line
1.7.3.4
#12 lore raw

PATCH v2 6/10 e1000e: Support sending custom Ethernet CRC.

In reply to [email protected]

From: Ben Greear <[email protected]>

This can aid with testing the RX logic for bad
CRCs.

---
:100644 100644 e3eefda... 2f9434c... M drivers/net/ethernet/intel/e1000e/netdev.c

 drivers/net/ethernet/intel/e1000e/netdev.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
drivers/net/ethernet/intel/e1000e/netdev.c +12 -0
index e3eefda..2f9434c 100644
@@ -4618,6 +4618,7 @@ link_up:
 #define E1000_TX_FLAGS_VLAN		0x00000002
 #define E1000_TX_FLAGS_TSO		0x00000004
 #define E1000_TX_FLAGS_IPV4		0x00000008
+#define E1000_TX_FLAGS_NO_FCS		0x00000010
 #define E1000_TX_FLAGS_VLAN_MASK	0xffff0000
 #define E1000_TX_FLAGS_VLAN_SHIFT	16
 
@@ -4877,6 +4878,9 @@ static void e1000_tx_queue(struct e1000_ring *tx_ring, int tx_flags, int count)
 		txd_upper |= (tx_flags & E1000_TX_FLAGS_VLAN_MASK);
 	}
 
+	if (unlikely(tx_flags & E1000_TX_FLAGS_NO_FCS))
+		txd_lower &= ~(E1000_TXD_CMD_IFCS);
+
 	i = tx_ring->next_to_use;
 
 	do {
@@ -4894,6 +4898,10 @@ static void e1000_tx_queue(struct e1000_ring *tx_ring, int tx_flags, int count)
 
 	tx_desc->lower.data |= cpu_to_le32(adapter->txd_cmd);
 
+	/* txd_cmd re-enables FCS, so we'll re-disable it here as desired. */
+	if (unlikely(tx_flags & E1000_TX_FLAGS_NO_FCS))
+		tx_desc->lower.data &= ~(cpu_to_le32(E1000_TXD_CMD_IFCS));
+
 	/*
 	 * Force memory writes to complete before letting h/w
 	 * know there are new descriptors to fetch.  (Only
@@ -5099,6 +5107,9 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
 	if (skb->protocol == htons(ETH_P_IP))
 		tx_flags |= E1000_TX_FLAGS_IPV4;
 
+	if (unlikely(skb->no_fcs))
+		tx_flags |= E1000_TX_FLAGS_NO_FCS;
+
 	/* if count is 0 then mapping error has occurred */
 	count = e1000_tx_map(tx_ring, skb, first, max_per_txd, nr_frags, mss);
 	if (count) {
@@ -6226,6 +6237,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
 	/* Set user-changeable features (subset of all device features) */
 	netdev->hw_features = netdev->features;
 	netdev->hw_features |= NETIF_F_RXFCS;
+	netdev->priv_flags |= IFF_SUPP_NOFCS;
 
 	if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER)
 		netdev->features |= NETIF_F_HW_VLAN_FILTER;
Signature · 1 line
1.7.3.4
#13 lore raw

PATCH v2 7/10 net: Support RX-ALL feature flag.

In reply to [email protected]

From: Ben Greear <[email protected]>

This flag requests that network devices pass all received frames up the stack, even ones with errors such as invalid FCS (frame check sum). This will allow sniffers to see bad packets and perhaps give the user some idea how to fix the problem.

---
:100644 100644 7d27812... 4164f5c... M Documentation/networking/netdev-features.txt
:100644 100644 d133186... 5ac3212... M include/linux/netdev_features.h
:100644 100644 0801619... 6d6d7d2... M net/core/ethtool.c

 Documentation/networking/netdev-features.txt |    7 +++++++
 include/linux/netdev_features.h              |    2 ++
 net/core/ethtool.c                           |    1 +
 3 files changed, 10 insertions(+), 0 deletions(-)
Documentation/networking/netdev-features.txt +7 -0
index 7d27812..4164f5c 100644
@@ -158,3 +158,10 @@ VLANs. This may be not useful, though.]
 This requests that the NIC append the Ethernet Frame Checksum (FCS)
 to the end of the skb data.  This allows sniffers and other tools to
 read the CRC recorded by the NIC on receipt of the packet.
+
+*  rx-all
+
+This requests that the NIC receive all possible frames, including errored
+frames (such as bad FCS, etc).  This can be helpful when sniffing a link with
+bad packets on it.  Some NICs may receive more packets if also put into normal
+PROMISC mdoe.
include/linux/netdev_features.h +2 -0
index d133186..5ac3212 100644
@@ -55,6 +55,7 @@ enum {
 	NETIF_F_NOCACHE_COPY_BIT,	/* Use no-cache copyfromuser */
 	NETIF_F_LOOPBACK_BIT,		/* Enable loopback */
 	NETIF_F_RXFCS_BIT,		/* Append FCS to skb pkt data */
+	NETIF_F_RXALL_BIT,		/* Receive errored frames too */
 
 	/*
 	 * Add your fresh new feature above and remember to update
@@ -100,6 +101,7 @@ enum {
 #define NETIF_F_UFO		__NETIF_F(UFO)
 #define NETIF_F_VLAN_CHALLENGED	__NETIF_F(VLAN_CHALLENGED)
 #define NETIF_F_RXFCS		__NETIF_F(RXFCS)
+#define NETIF_F_RXALL		__NETIF_F(RXALL)
 
 /* Features valid for ethtool to change */
 /* = all defined minus driver/device-class-related */
net/core/ethtool.c +1 -0
index 0801619..6d6d7d2 100644
@@ -74,6 +74,7 @@ static const char netdev_features_strings[NETDEV_FEATURE_COUNT][ETH_GSTRING_LEN]
 	[NETIF_F_NOCACHE_COPY_BIT] =     "tx-nocache-copy",
 	[NETIF_F_LOOPBACK_BIT] =         "loopback",
 	[NETIF_F_RXFCS_BIT] =            "rx-fcs",
+	[NETIF_F_RXALL_BIT] =            "rx-all",
 };
 
 static int ethtool_get_features(struct net_device *dev, void __user *useraddr)
Signature · 1 line
1.7.3.4
#14 lore raw

PATCH v2 8/10 e1000e: Support RXALL feature flag.

In reply to [email protected]

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 1af30b9... 3a50259... M drivers/net/ethernet/intel/e1000e/defines.h
:100644 100644 2f9434c... 9905f45... M drivers/net/ethernet/intel/e1000e/netdev.c

 drivers/net/ethernet/intel/e1000e/defines.h |    1 +
 drivers/net/ethernet/intel/e1000e/netdev.c  |   29 +++++++++++++++++++++++---
 2 files changed, 26 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/e1000e/defines.h +1 -0
index 1af30b9..3a50259 100644
@@ -177,6 +177,7 @@
 #define E1000_RCTL_VFE            0x00040000    /* vlan filter enable */
 #define E1000_RCTL_CFIEN          0x00080000    /* canonical form enable */
 #define E1000_RCTL_CFI            0x00100000    /* canonical form indicator */
+#define E1000_RCTL_DPF            0x00400000    /* Discard Pause Frames */
 #define E1000_RCTL_PMCF           0x00800000    /* pass MAC control frames */
 #define E1000_RCTL_BSEX           0x02000000    /* Buffer size extension */
 #define E1000_RCTL_SECRC          0x04000000    /* Strip Ethernet CRC */
drivers/net/ethernet/intel/e1000e/netdev.c +25 -4
index 2f9434c..9905f45 100644
@@ -929,7 +929,8 @@ static bool e1000_clean_rx_irq(struct e1000_ring *rx_ring, int *work_done,
 			goto next_desc;
 		}
 
-		if (staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK) {
+		if (unlikely((staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK) &&
+			     !(netdev->features & NETIF_F_RXALL))) {
 			/* recycle */
 			buffer_info->skb = skb;
 			goto next_desc;
@@ -1258,7 +1259,8 @@ static bool e1000_clean_rx_irq_ps(struct e1000_ring *rx_ring, int *work_done,
 			goto next_desc;
 		}
 
-		if (staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK) {
+		if (unlikely((staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK) &&
+			     !(netdev->features & NETIF_F_RXALL))) {
 			dev_kfree_skb_irq(skb);
 			goto next_desc;
 		}
@@ -1457,7 +1459,8 @@ static bool e1000_clean_jumbo_rx_irq(struct e1000_ring *rx_ring, int *work_done,
 
 		/* errors is only valid for DD + EOP descriptors */
 		if (unlikely((staterr & E1000_RXD_STAT_EOP) &&
-			     (staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK))) {
+			     ((staterr & E1000_RXDEXT_ERR_FRAME_ERR_MASK) &&
+			      !(netdev->features & NETIF_F_RXALL)))) {
 			/* recycle both page and skb */
 			buffer_info->skb = skb;
 			/* an error means any chain goes out the window too */
@@ -3002,6 +3005,22 @@ static void e1000_setup_rctl(struct e1000_adapter *adapter)
 		ew32(PSRCTL, psrctl);
 	}
 
+	/* 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.
+		 */
+	}
+
 	ew32(RFCTL, rfctl);
 	ew32(RCTL, rctl);
 	/* just started the receive unit, no need to restart */
@@ -6010,7 +6029,8 @@ static int e1000_set_features(struct net_device *netdev,
 		adapter->flags |= FLAG_TSO_FORCE;
 
 	if (!(changed & (NETIF_F_HW_VLAN_RX | NETIF_F_HW_VLAN_TX |
-			 NETIF_F_RXCSUM | NETIF_F_RXHASH | NETIF_F_RXFCS)))
+			 NETIF_F_RXCSUM | NETIF_F_RXHASH | NETIF_F_RXFCS |
+			 NETIF_F_RXALL)))
 		return 0;
 
 	/*
@@ -6238,6 +6258,7 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
 	netdev->hw_features = netdev->features;
 	netdev->hw_features |= NETIF_F_RXFCS;
 	netdev->priv_flags |= IFF_SUPP_NOFCS;
+	netdev->hw_features |= NETIF_F_RXALL;
 
 	if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER)
 		netdev->features |= NETIF_F_HW_VLAN_FILTER;
Signature · 1 line
1.7.3.4
#15 lore raw

PATCH v2 9/10 e100: Support RXALL feature flag.

In reply to [email protected]

From: Ben Greear <[email protected]>

This allows the NIC to receive packets with bad FCS and other errors. Good for sniffing packets on flakey networks.

---
:100644 100644 c793939... a296ec4... M drivers/net/ethernet/intel/e100.c

 drivers/net/ethernet/intel/e100.c |   22 ++++++++++++++++++++--
 1 files changed, 20 insertions(+), 2 deletions(-)
drivers/net/ethernet/intel/e100.c +20 -2
index c793939..a296ec4 100644
@@ -462,7 +462,7 @@ struct config {
 /*5*/	u8 X(tx_dma_max_count:7, dma_max_count_enable:1);
 /*6*/	u8 X(X(X(X(X(X(X(late_scb_update:1, direct_rx_dma:1),
 	   tno_intr:1), cna_intr:1), standard_tcb:1), standard_stat_counter:1),
-	   rx_discard_overruns:1), rx_save_bad_frames:1);
+	   rx_save_overruns : 1), rx_save_bad_frames : 1);
 /*7*/	u8 X(X(X(X(X(rx_discard_short_frames:1, tx_underrun_retry:2),
 	   pad7:2), rx_extended_rfd:1), tx_two_frames_in_fifo:1),
 	   tx_dynamic_tbd:1);
@@ -1165,6 +1165,12 @@ static void e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
 		}
 	}
 
+	if (netdev->features & NETIF_F_RXALL) {
+		config->rx_save_overruns = 0x1; /* 1=save, 0=discard */
+		config->rx_save_bad_frames = 0x1;       /* 1=save, 0=discard */
+		config->rx_discard_short_frames = 0x0;  /* 1=discard, 0=save */
+	}
+
 	netif_printk(nic, hw, KERN_DEBUG, nic->netdev,
 		     "[00-07]=%02X:%02X:%02X:%02X:%02X:%02X:%02X:%02X\n",
 		     c[0], c[1], c[2], c[3], c[4], c[5], c[6], c[7]);
@@ -1999,6 +2005,16 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx,
 	skb_put(skb, actual_size);
 	skb->protocol = eth_type_trans(skb, nic->netdev);
 
+	/* If we are receiving all frames, then don't bother
+	 * checking for errors.
+	 */
+	if (unlikely(dev->features & NETIF_F_RXALL)) {
+		if (actual_size > nic->netdev->mtu + VLAN_ETH_HLEN)
+			/* Received oversized frame */
+			dev->stats.rx_over_errors++;
+		goto process_skb;
+	}
+
 	if (unlikely(!(rfd_status & cb_ok))) {
 		/* Don't indicate if hardware indicates errors */
 		dev_kfree_skb_any(skb);
@@ -2007,6 +2023,7 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx,
 		nic->rx_over_length_errors++;
 		dev_kfree_skb_any(skb);
 	} else {
+process_skb:
 		dev->stats.rx_packets++;
 		dev->stats.rx_bytes += actual_size;
 		netif_receive_skb(skb);
@@ -2757,7 +2774,7 @@ static int e100_set_features(struct net_device *netdev,
 	struct nic *nic = netdev_priv(netdev);
 	netdev_features_t changed = features ^ netdev->features;
 
-	if (!(changed & (NETIF_F_RXFCS)))
+	if (!(changed & (NETIF_F_RXFCS | NETIF_F_RXALL)))
 		return 0;
 
 	netdev->features = features;
@@ -2793,6 +2810,7 @@ static int __devinit e100_probe(struct pci_dev *pdev,
 
 	netdev->hw_features |= NETIF_F_RXFCS;
 	netdev->priv_flags |= IFF_SUPP_NOFCS;
+	netdev->hw_features |= NETIF_F_RXALL;
 
 	netdev->netdev_ops = &e100_netdev_ops;
 	SET_ETHTOOL_OPS(netdev, &e100_ethtool_ops);
Signature · 1 line
1.7.3.4
#16 lore raw

PATCH v2 10/10 e1000: Support sending custom Ethernet CRC.

In reply to [email protected]

From: Ben Greear <[email protected]>

Good for testing the RX logic for bad CRC handling.

---
:100644 100644 1f86a70... 64b73bc... M drivers/net/ethernet/intel/e1000/e1000_main.c

 drivers/net/ethernet/intel/e1000/e1000_main.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
drivers/net/ethernet/intel/e1000/e1000_main.c +13 -0
index 1f86a70..64b73bc 100644
@@ -1067,6 +1067,8 @@ static int __devinit e1000_probe(struct pci_dev *pdev,
 	   (hw->mac_type != e1000_82547))
 		netdev->hw_features |= NETIF_F_TSO;
 
+	netdev->priv_flags |= IFF_SUPP_NOFCS;
+
 	netdev->features |= netdev->hw_features;
 	netdev->hw_features |= NETIF_F_RXCSUM;
 
@@ -2692,6 +2694,7 @@ set_itr_now:
 #define E1000_TX_FLAGS_VLAN		0x00000002
 #define E1000_TX_FLAGS_TSO		0x00000004
 #define E1000_TX_FLAGS_IPV4		0x00000008
+#define E1000_TX_FLAGS_NO_FCS		0x00000010
 #define E1000_TX_FLAGS_VLAN_MASK	0xffff0000
 #define E1000_TX_FLAGS_VLAN_SHIFT	16
 
@@ -2993,6 +2996,9 @@ static void e1000_tx_queue(struct e1000_adapter *adapter,
 		txd_upper |= (tx_flags & E1000_TX_FLAGS_VLAN_MASK);
 	}
 
+	if (unlikely(tx_flags & E1000_TX_FLAGS_NO_FCS))
+		txd_lower &= ~(E1000_TXD_CMD_IFCS);
+
 	i = tx_ring->next_to_use;
 
 	while (count--) {
@@ -3007,6 +3013,10 @@ static void e1000_tx_queue(struct e1000_adapter *adapter,
 
 	tx_desc->lower.data |= cpu_to_le32(adapter->txd_cmd);
 
+	/* txd_cmd re-enables FCS, so we'll re-disable it here as desired. */
+	if (unlikely(tx_flags & E1000_TX_FLAGS_NO_FCS))
+		tx_desc->lower.data &= ~(cpu_to_le32(E1000_TXD_CMD_IFCS));
+
 	/* Force memory writes to complete before letting h/w
 	 * know there are new descriptors to fetch.  (Only
 	 * applicable for weak-ordered memory model archs,
@@ -3222,6 +3232,9 @@ static netdev_tx_t e1000_xmit_frame(struct sk_buff *skb,
 	if (likely(skb->protocol == htons(ETH_P_IP)))
 		tx_flags |= E1000_TX_FLAGS_IPV4;
 
+	if (unlikely(skb->no_fcs))
+		tx_flags |= E1000_TX_FLAGS_NO_FCS;
+
 	count = e1000_tx_map(adapter, tx_ring, skb, first, max_per_txd,
 	                     nr_frags, mss);
 
Signature · 1 line
1.7.3.4
#17 lore raw
In reply to [email protected]
Quoted 80 lines · On 02/08/2012 11:54 AM, [email protected] wrote:

From: Ben Greear <[email protected]>

This patch series enables some features designed to make testing ethernet devices and debugging link-level errors easier.

First, support is added for receiving the Ethernet FCS. This allows stock wireshark to show you the actual Ethernet FCS.

Second, allow sending packets with user-specified Ethernet FCS. The user can specify bad FCS in order to test network equipments' handling of FCS errors, or, in strange cases, users might want to implement their own FCS scheme.

Third, allow configuring a NIC to receive errored (and possibly other types of packets not normally passed up the stack). This allows sniffers to show packets with bad FCS, for instance.

These features have been tested on e100 and e1000e. The e1000 patch has not been tested yet.

Changes from first posting:

* Ensure nic reset when changing the rx-fcs and rx-all logic in e100 (e1000e already did this).

* Use priv-flag for the 'send customized CRC' logic and make it non configurable (if NIC supports it, feature is enabled) Please note that this will only be used when the SKB is specifically flagged as wanting this behaviour.

* Use EPROTONOSUPPORT error to indicate the packet-socket's bound NIC does not support the 'send customized CRC' feature.

* Some general cleanup, and patch re-ordering.

There was a suggestion to throw away packets flagged as bad by the NIC. I did not add any additional logic to do this. I think it is not needed, but I am open to other opinions.

Ben Greear (10):
net: Support RXFCS feature flag.
e100: Support RXFCS feature flag.
e1000e: Support RXFCS feature flag.
net: Add framework to allow sending packets with customized CRC.
e100: Support sending custom Ethernet CRC
e1000e: Support sending custom Ethernet CRC.
net: Support RX-ALL feature flag.
e1000e: Support RXALL feature flag.
e100: Support RXALL feature flag.
e1000: Support sending custom Ethernet CRC.

 Documentation/networking/netdev-features.txt  |   13 ++++
 arch/alpha/include/asm/socket.h               |    3 +
 arch/arm/include/asm/socket.h                 |    3 +
 arch/avr32/include/asm/socket.h               |    3 +
 arch/cris/include/asm/socket.h                |    3 +
 arch/frv/include/asm/socket.h                 |    3 +
 arch/h8300/include/asm/socket.h               |    3 +
 arch/ia64/include/asm/socket.h                |    3 +
 arch/m32r/include/asm/socket.h                |    3 +
 arch/m68k/include/asm/socket.h                |    3 +
 arch/mips/include/asm/socket.h                |    3 +
 arch/mn10300/include/asm/socket.h             |    3 +
 arch/parisc/include/asm/socket.h              |    4 +
 arch/powerpc/include/asm/socket.h             |    3 +
 arch/s390/include/asm/socket.h                |    3 +
 arch/sparc/include/asm/socket.h               |    4 +
 arch/xtensa/include/asm/socket.h              |    3 +
 drivers/net/ethernet/intel/e100.c             |   66 +++++++++++++++++++-
 drivers/net/ethernet/intel/e1000/e1000_main.c |   13 ++++
 drivers/net/ethernet/intel/e1000e/defines.h   |    1 +
 drivers/net/ethernet/intel/e1000e/e1000.h     |    1 +
 drivers/net/ethernet/intel/e1000e/netdev.c    |   80 +++++++++++++++++++++---
 drivers/net/ethernet/intel/e1000e/param.c     |    5 +-
 include/asm-generic/socket.h                  |    4 +
 include/linux/if.h                            |    2 +
 include/linux/netdev_features.h               |    4 +
Quoted 9 lines
 include/linux/netdevice.h                     |    8 ++-
 include/linux/skbuff.h                        |    4 +-
 include/net/sock.h                            |    4 +
 net/core/ethtool.c                            |    2 +
 net/core/skbuff.c                             |    1 +
 net/core/sock.c                               |    4 +
 net/packet/af_packet.c                        |   32 +++++++++-
 33 files changed, 273 insertions(+), 21 deletions(-)

Thanks Ben!

I have applied the series of 10 patches to my queue. I would like to have our validation team validate the e100, e1000 and e1000e patches (and in-directly the net patches).

Cheers,
Jeff

author
#18 lore raw
Quoted 5 lines · Jeff Kirsher

Thanks Ben!

I have applied the series of 10 patches to my queue. I would like to have our validation team validate the e100, e1000 and e1000e patches (and in-directly the net patches).

Just in case you can generate errored frames other than ones with just bad FCS, I'm curious to know if rx-all logic works with them.

I was thinking I might could get at least some NICs to generate Runt frames by sending small pkts and disabling frame padding, but haven't looked into it too hard yet.

Thanks,
Ben

Signature · 2 lines
Ben Greear <[email protected]>
Candela Technologies Inc  http://www.candelatech.com
#19 lore raw
Quoted 11 lines · Ben Greear
Quoted 5 lines · Jeff Kirsher

Thanks Ben!

I have applied the series of 10 patches to my queue. I would like to have our validation team validate the e100, e1000 and e1000e patches (and in-directly the net patches).

Just in case you can generate errored frames other than ones with just bad FCS, I'm curious to know if rx-all logic works with them.

Quoted 7 lines

I was thinking I might could get at least some NICs to generate Runt frames by sending small pkts and disabling frame padding, but haven't looked into it too hard yet.

Thanks,
Ben

Thanks for the info Ben! I or Aaron will let you know what we come up with.

#20 lore raw
In reply to Ben Greear
Quoted 8 lines · Ben Greear
Quoted 5 lines · Jeff Kirsher

Thanks Ben!

I have applied the series of 10 patches to my queue. I would like to have our validation team validate the e100, e1000 and e1000e patches (and in-directly the net patches).

Quoted 6 lines

Just in case you can generate errored frames other than ones with just bad FCS, I'm curious to know if rx-all logic works with them.

I was thinking I might could get at least some NICs to generate Runt frames by sending small pkts and disabling frame padding, but haven't looked into it too hard yet.

I am interested by this, do you know some NICs able to disable frame padding ?

#21 lore raw
Quoted 2 lines
Quoted 2 lines

I was thinking I might could get at least some NICs to generate Runt

frames

Quoted 1 line
Quoted 1 line

by sending small pkts and disabling frame padding, but haven't

looked into

Quoted 4 lines
Quoted 1 line

it too hard yet.

I am interested by this, do you know some NICs able to disable frame padding ?

I'm reasonably sure some old NICs like the AMD lance will send runts. Quite likely any that require the drives to set the padded frame length.

The same will be true when semi-generic HDLC controllers are used to send packets from DSPs, FPGAs and SOCs.

David

#22 lore raw
Quoted 6 lines · David Laight
Quoted 1 line
Quoted 1 line

I was thinking I might could get at least some NICs to generate Runt

frames

Quoted 1 line
Quoted 1 line

by sending small pkts and disabling frame padding, but haven't

looked into

Quoted 2 lines
Quoted 1 line

it too hard yet.

Quoted 9 lines
Quoted 2 lines

I am interested by this, do you know some NICs able to disable frame padding ?

I'm reasonably sure some old NICs like the AMD lance will send runts. Quite likely any that require the drives to set the padded frame length.

The same will be true when semi-generic HDLC controllers are used to send packets from DSPs, FPGAs and SOCs.

Apparently, drivers/net/ethernet/dlink/de620.c does this in its de620_start_xmit() function :

	if ((len = skb->len) < RUNT)
		len = RUNT;

Thats interesting for two reasons :

1) We probably can remove the test to send runts if we want to test things...

2) As is, we can leak kernel memory content to wire since we dont initialize the padding data.

#23 lore raw
Quoted 4 lines · Eric Dumazet

2) As is, we can leak kernel memory content to wire since we dont initialize the padding data.

False alarm, this is properly handled by de620_write_block( ... , pad);

Other drivers do :

	if (skb->len < ETH_ZLEN) {
		if (skb_padto(skb, ETH_ZLEN))
			goto out;
	}
author
#24 lore raw
In reply to Eric Dumazet
Quoted 12 lines · Eric Dumazet
Quoted 11 lines · Ben Greear
Quoted 5 lines · Jeff Kirsher

Thanks Ben!

I have applied the series of 10 patches to my queue. I would like to have our validation team validate the e100, e1000 and e1000e patches (and in-directly the net patches).

Just in case you can generate errored frames other than ones with just bad FCS, I'm curious to know if rx-all logic works with them.

Quoted 6 lines
Quoted 3 lines

I was thinking I might could get at least some NICs to generate Runt frames by sending small pkts and disabling frame padding, but haven't looked into it too hard yet.

I am interested by this, do you know some NICs able to disable frame padding ?

It looks like e1000e driver can send frames at down to 32 bytes, which should be considered a runt. I think we'd just need to disable any padding in the software stacks (not sure it's there now or not), and then twiddle the 'PSP' but in the "Transmit Control Register".

I'm not sure the best way to enable this feature up at user-space level, but we could piggy-back on the no-fcs socket option and extend that flag to mean don't pad packets as well.

Or, could add a new sock-opt perhaps.

Thanks,
Ben

Signature · 2 lines
Ben Greear <[email protected]>
Candela Technologies Inc  http://www.candelatech.com
maintainer
#25 lore raw
In reply to Jeff Kirsher

From: Jeff Kirsher <[email protected]>
Date: Thu, 09 Feb 2012 20:31:44 -0800

Quoted 3 lines

I have applied the series of 10 patches to my queue. I would like to have our validation team validate the e100, e1000 and e1000e patches (and in-directly the net patches).

You can merge all of this to me via your tree once you've done this validation, thanks.

#6 lore raw

Re: [PATCH v2 03/10] e1000e: Support RXFCS feature flag.

In reply to [email protected]

2012/2/8 <[email protected]>:

Quoted 9 lines

From: Ben Greear <[email protected]>

This enables enabling/disabling reception of the Ethernet FCS.  This can be useful when sniffing packets.

For e1000e, enabling RXFCS can change the default behaviour for how the NIC handles CRC.  Disabling RXFCS will take the NIC back to defaults, which can be configured as part of the module options.

[...]

This is not how I would expect the features to behave. Default value should be set on probe() time, and when you disable RXFCS it should just get disabled.

Best Regards,
Michał Mirosław

#3 lore raw

Re: [PATCH v2 02/10] e100: Support RXFCS feature flag.

In reply to [email protected]

2012/2/8 <[email protected]>:

Quoted 4 lines

From: Ben Greear <[email protected]>

This allows e100 to be configured to append the
Ethernet FCS to the skb.

[...]

drivers/net/ethernet/intel/e100.c static int e100_rx_indicate(struct nic *nic, struct rx *rx, · line 1929

Quoted 8 lines
drivers/net/ethernet/intel/e100.c +1 -0
@@ -1919,6 +1923,7 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx,
        struct sk_buff *skb = rx->skb;
        struct rfd *rfd = (struct rfd *)skb->data;
        u16 rfd_status, actual_size;
+       u16 fcs_pad = 0;
 
        if (unlikely(work_done && *work_done >= work_to_do))
                return -EAGAIN;

Remove this part.

drivers/net/ethernet/intel/e100.c static int e100_rx_indicate(struct nic *nic, struct rx *rx, · line 1960

Quoted 6 lines
drivers/net/ethernet/intel/e100.c +2 -0
@@ -1951,9 +1956,11 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx,
        }
 
        /* Get actual data size */
+       if (unlikely(dev->features & NETIF_F_RXFCS))
+               fcs_pad = 4;

Remove part above.

drivers/net/ethernet/intel/e100.c static int e100_rx_indicate(struct nic *nic, struct rx *rx, · line 1961

Quoted 1 line
drivers/net/ethernet/intel/e100.c +0 -0
        actual_size = le16_to_cpu(rfd->actual_size) & 0x3FFF;

u16 data_size = actual_size;
if (unlikely(dev->features & NETIF_F_RXFCS))

    actual_size -= 4;

drivers/net/ethernet/intel/e100.c static int e100_rx_indicate(struct nic *nic, struct rx *rx, · line 1966

Quoted 7 lines
drivers/net/ethernet/intel/e100.c +2 -2
-       if (unlikely(actual_size > RFD_BUF_LEN - sizeof(struct rfd)))
-               actual_size = RFD_BUF_LEN - sizeof(struct rfd);
+       if (unlikely(actual_size > RFD_BUF_LEN + fcs_pad - sizeof(struct rfd)))
+               actual_size = RFD_BUF_LEN + fcs_pad - sizeof(struct rfd);
 
        /* Get data */
        pci_unmap_single(nic->pdev, rx->dma_addr,

Remove this part.

...
skb_put(skb, data_size);
...

drivers/net/ethernet/intel/e100.c static int e100_rx_indicate(struct nic *nic, struct rx *rx, · line 1993

Quoted 9 lines
drivers/net/ethernet/intel/e100.c +1 -1
@@ -1980,7 +1987,7 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx,
        if (unlikely(!(rfd_status & cb_ok))) {
                /* Don't indicate if hardware indicates errors */
                dev_kfree_skb_any(skb);
-       } else if (actual_size > ETH_DATA_LEN + VLAN_ETH_HLEN) {
+       } else if (actual_size > ETH_DATA_LEN + VLAN_ETH_HLEN + fcs_pad) {
                /* Don't indicate oversized frames */
                nic->rx_over_length_errors++;
                dev_kfree_skb_any(skb);

Remove this part.

Those changes will keep RX bytes counter behaviour consistent regardles if RXFCS is on or not. It's less code, BTW. ;-)

Best Regards,
Michał Mirosław

author
#7 lore raw

Re: [PATCH v2 03/10] e1000e: Support RXFCS feature flag.

In reply to Michał Mirosław
Quoted 10 lines · Michał Mirosław

2012/2/8<[email protected]>:

Quoted 9 lines

From: Ben Greear<[email protected]>

This enables enabling/disabling reception of the Ethernet FCS. This can be useful when sniffing packets.

For e1000e, enabling RXFCS can change the default behaviour for how the NIC handles CRC. Disabling RXFCS will take the NIC back to defaults, which can be configured as part of the module options.

Quoted 5 lines

[...]

This is not how I would expect the features to behave. Default value should be set on probe() time, and when you disable RXFCS it should just get disabled.

The NIC itself may still receive the FCS, but it will be removed before the pkt is sent up the stack once you disable the 'rx-fcs' flag.

My goal was to make sure that if you enabled and then disabled the new rx-fcs flag, then you would be back at the original behaviour.

I think that if the "rx-fcs off" logic is to change the default behaviour, then the Intel folks probably need to make those changes:
It seems that there are some tricky work-arounds regarding fcs and segmented packets for at least some versions of the e1000e chipsets.

Thanks,
Ben

Signature · 2 lines
Ben Greear <[email protected]>
Candela Technologies Inc  http://www.candelatech.com
#8 lore raw

Re: [PATCH v2 03/10] e1000e: Support RXFCS feature flag.

W dniu 10 lutego 2012 23:57 użytkownik Ben Greear

Quoted 22 lines · <[email protected]> napisał:
Quoted 13 lines · Michał Mirosław

2012/2/8<[email protected]>:

Quoted 10 lines

From: Ben Greear<[email protected]>

This enables enabling/disabling reception of the Ethernet FCS.  This can be useful when sniffing packets.

For e1000e, enabling RXFCS can change the default behaviour for how the NIC handles CRC.  Disabling RXFCS will take the NIC back to defaults, which can be configured as part of the module options.

Quoted 5 lines

[...]

This is not how I would expect the features to behave. Default value should be set on probe() time, and when you disable RXFCS it should just get disabled.

The NIC itself may still receive the FCS, but it will be removed before the pkt is sent up the stack once you disable the 'rx-fcs' flag.

Quoted 7 lines

My goal was to make sure that if you enabled and then disabled the new rx-fcs flag, then you would be back at the original behaviour.

I think that if the "rx-fcs off" logic is to change the default behaviour, then the Intel folks probably need to make those changes:
It seems that there are some tricky work-arounds regarding fcs and segmented packets for at least some versions of the e1000e chipsets.

That makes sense. The flag FLAG2_DFLT_CRC_STRIPPING should be called FLAG2_FORCE_CRC_STRIPPING_OFF or something if that's the case. "Default" doesn't tell if that's a strong preference or just because.

Best Regards,
Michał Mirosław

author
#9 lore raw

Re: [PATCH v2 03/10] e1000e: Support RXFCS feature flag.

Quoted 27 lines · Michał Mirosław

W dniu 10 lutego 2012 23:57 użytkownik Ben Greear

Quoted 25 lines · <[email protected]> napisał:
Quoted 13 lines · Michał Mirosław

2012/2/8<[email protected]>:

Quoted 10 lines

From: Ben Greear<[email protected]>

This enables enabling/disabling reception of the Ethernet FCS. This can be useful when sniffing packets.

For e1000e, enabling RXFCS can change the default behaviour for how the NIC handles CRC. Disabling RXFCS will take the NIC back to defaults, which can be configured as part of the module options.

Quoted 5 lines

[...]

This is not how I would expect the features to behave. Default value should be set on probe() time, and when you disable RXFCS it should just get disabled.

The NIC itself may still receive the FCS, but it will be removed before the pkt is sent up the stack once you disable the 'rx-fcs' flag.

My goal was to make sure that if you enabled and then disabled the new rx-fcs flag, then you would be back at the original behaviour.

Quoted 8 lines
Quoted 4 lines

I think that if the "rx-fcs off" logic is to change the default behaviour, then the Intel folks probably need to make those changes:
It seems that there are some tricky work-arounds regarding fcs and segmented packets for at least some versions of the e1000e chipsets.

That makes sense. The flag FLAG2_DFLT_CRC_STRIPPING should be called FLAG2_FORCE_CRC_STRIPPING_OFF or something if that's the case. "Default" doesn't tell if that's a strong preference or just because.

The new flag is just to store the original crc-stripping preference configured by the module options. It's not really forcing anything, it is just the 'default' value.

So, I don't think it should be changed. However, I will defer to the driver maintainers...if they think I should change it, then I will, otherwise, I'm going to leave it as is.

Thanks,
Ben

Signature · 2 lines
Ben Greear <[email protected]>
Candela Technologies Inc  http://www.candelatech.com
author
#4 lore raw

Re: [PATCH v2 02/10] e100: Support RXFCS feature flag.

In reply to Michał Mirosław
Quoted 37 lines · Michał Mirosław

2012/2/8<[email protected]>:

Quoted 4 lines

From: Ben Greear<[email protected]>

This allows e100 to be configured to append the
Ethernet FCS to the skb.

[...]

drivers/net/ethernet/intel/e100.c static int e100_rx_indicate(struct nic *nic, struct rx *rx, · line 1929

Quoted 8 lines
drivers/net/ethernet/intel/e100.c +1 -0
@@ -1919,6 +1923,7 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx,
        struct sk_buff *skb = rx->skb;
        struct rfd *rfd = (struct rfd *)skb->data;
        u16 rfd_status, actual_size;
+       u16 fcs_pad = 0;
 
        if (unlikely(work_done&&  *work_done>= work_to_do))
                return -EAGAIN;

Remove this part.

drivers/net/ethernet/intel/e100.c static int e100_rx_indicate(struct nic *nic, struct rx *rx, · line 1960

Quoted 6 lines
drivers/net/ethernet/intel/e100.c +2 -0
@@ -1951,9 +1956,11 @@ static int e100_rx_indicate(struct nic *nic, struct rx *rx,
        }
 
        /* Get actual data size */
+       if (unlikely(dev->features&  NETIF_F_RXFCS))
+               fcs_pad = 4;

Remove part above.

Review static int e100_rx_indicate(struct nic *nic, struct rx *rx, · line 1961

Quoted 1 line
(quoted diff) +0 -0
        actual_size = le16_to_cpu(rfd->actual_size)&  0x3FFF;

u16 data_size = actual_size;
if (unlikely(dev->features& NETIF_F_RXFCS))

     actual_size -= 4;
Quoted 5 lines
drivers/net/ethernet/intel/e100.c +2 -2
-       if (unlikely(actual_size>  RFD_BUF_LEN - sizeof(struct rfd)))
-               actual_size = RFD_BUF_LEN - sizeof(struct rfd);
+       if (unlikely(actual_size>  RFD_BUF_LEN + fcs_pad - sizeof(struct rfd)))
+               actual_size = RFD_BUF_LEN + fcs_pad - sizeof(struct rfd);
 
Quoted 8 lines

drivers/net/ethernet/intel/e100.c static int e100_rx_indicate(struct nic *nic, struct rx *rx, · line 1966

Quoted 2 lines
drivers/net/ethernet/intel/e100.c +0 -0
        /* Get data */
        pci_unmap_single(nic->pdev, rx->dma_addr,

Remove this part.

...
skb_put(skb, data_size);
...

Well, that breaks if the unlikely() branch hits above..now 'data_size' will be larger than it should be. I can add more logic to fix that up, but then code size is going to be larger again, and we also have the potential confusion between what data-size and actual-size variables mean.

I will double-check that the counter works properly, but I think I'll leave the rest as it is, at least for now.

Ben

Signature · 2 lines
Ben Greear <[email protected]>
Candela Technologies Inc  http://www.candelatech.com