All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/10] Low-level Ethernet debugging features.
@ 2012-02-08 19:54 greearb
  2012-02-08 19:54 ` [PATCH v2 01/10] net: Support RXFCS feature flag greearb
                   ` (10 more replies)
  0 siblings, 11 replies; 26+ messages in thread
From: greearb @ 2012-02-08 19:54 UTC (permalink / raw)
  To: netdev; +Cc: Ben Greear

From: Ben Greear <greearb@candelatech.com>

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(-)

-- 
1.7.3.4

^ permalink raw reply	[flat|nested] 26+ messages in thread

* [PATCH v2 01/10] net: Support RXFCS feature flag.
  2012-02-08 19:54 [PATCH v2 00/10] Low-level Ethernet debugging features greearb
@ 2012-02-08 19:54 ` greearb
  2012-02-08 19:54 ` [PATCH v2 02/10] e100: " greearb
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 26+ messages in thread
From: greearb @ 2012-02-08 19:54 UTC (permalink / raw)
  To: netdev; +Cc: Ben Greear

From: Ben Greear <greearb@candelatech.com>

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.

Signed-off-by: Ben Greear <greearb@candelatech.com>
---
: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(-)

diff --git a/Documentation/networking/netdev-features.txt b/Documentation/networking/netdev-features.txt
index 4b1c0dc..7d27812 100644
--- a/Documentation/networking/netdev-features.txt
+++ b/Documentation/networking/netdev-features.txt
@@ -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.
diff --git a/include/linux/netdev_features.h b/include/linux/netdev_features.h
index 77f5202..d133186 100644
--- a/include/linux/netdev_features.h
+++ b/include/linux/netdev_features.h
@@ -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 */
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 3f79db1..0801619 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -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)
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v2 02/10] e100: Support RXFCS feature flag.
  2012-02-08 19:54 [PATCH v2 00/10] Low-level Ethernet debugging features greearb
  2012-02-08 19:54 ` [PATCH v2 01/10] net: Support RXFCS feature flag greearb
@ 2012-02-08 19:54 ` greearb
  2012-02-10 22:56   ` Michał Mirosław
  2012-02-08 19:54 ` [PATCH v2 03/10] e1000e: " greearb
                   ` (8 subsequent siblings)
  10 siblings, 1 reply; 26+ messages in thread
From: greearb @ 2012-02-08 19:54 UTC (permalink / raw)
  To: netdev; +Cc: Ben Greear

From: Ben Greear <greearb@candelatech.com>

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

Useful for sniffing networks.

Signed-off-by: Ben Greear <greearb@candelatech.com>
---
: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(-)

diff --git a/drivers/net/ethernet/intel/e100.c b/drivers/net/ethernet/intel/e100.c
index 485ab8c..943178b 100644
--- a/drivers/net/ethernet/intel/e100.c
+++ b/drivers/net/ethernet/intel/e100.c
@@ -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;
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v2 03/10] e1000e:  Support RXFCS feature flag.
  2012-02-08 19:54 [PATCH v2 00/10] Low-level Ethernet debugging features greearb
  2012-02-08 19:54 ` [PATCH v2 01/10] net: Support RXFCS feature flag greearb
  2012-02-08 19:54 ` [PATCH v2 02/10] e100: " greearb
@ 2012-02-08 19:54 ` greearb
  2012-02-10 22:46   ` Michał Mirosław
  2012-02-08 19:54 ` [PATCH v2 04/10] net: Add framework to allow sending packets with customized CRC greearb
                   ` (7 subsequent siblings)
  10 siblings, 1 reply; 26+ messages in thread
From: greearb @ 2012-02-08 19:54 UTC (permalink / raw)
  To: netdev; +Cc: Ben Greear

From: Ben Greear <greearb@candelatech.com>

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.

Signed-off-by: Ben Greear <greearb@candelatech.com>
---
: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(-)

diff --git a/drivers/net/ethernet/intel/e1000e/e1000.h b/drivers/net/ethernet/intel/e1000e/e1000.h
index 45e5ae8..04a21fc 100644
--- a/drivers/net/ethernet/intel/e1000e/e1000.h
+++ b/drivers/net/ethernet/intel/e1000e/e1000.h
@@ -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]))
diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
index 293a760..e3eefda 100644
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
@@ -936,8 +936,16 @@ static bool e1000_clean_rx_irq(struct e1000_ring *rx_ring, int *work_done,
 		}
 
 		/* adjust length to remove Ethernet CRC */
-		if (!(adapter->flags2 & FLAG2_CRC_STRIPPING))
-			length -= 4;
+		if (!(adapter->flags2 & FLAG2_CRC_STRIPPING)) {
+			/* If configured to store CRC, don't subtract FCS,
+			 * but keep the FCS bytes out of the total_rx_bytes
+			 * counter
+			 */
+			if (netdev->features & NETIF_F_RXFCS)
+				total_rx_bytes -= 4;
+			else
+				length -= 4;
+		}
 
 		total_rx_bytes += length;
 		total_rx_packets++;
@@ -1304,8 +1312,10 @@ static bool e1000_clean_rx_irq_ps(struct e1000_ring *rx_ring, int *work_done,
 							   DMA_FROM_DEVICE);
 
 				/* remove the CRC */
-				if (!(adapter->flags2 & FLAG2_CRC_STRIPPING))
-					l1 -= 4;
+				if (!(adapter->flags2 & FLAG2_CRC_STRIPPING)) {
+					if (!(netdev->features & NETIF_F_RXFCS))
+						l1 -= 4;
+				}
 
 				skb_put(skb, l1);
 				goto copydone;
@@ -1331,8 +1341,10 @@ static bool e1000_clean_rx_irq_ps(struct e1000_ring *rx_ring, int *work_done,
 		/* strip the ethernet crc, problem is we're using pages now so
 		 * this whole operation can get a little cpu intensive
 		 */
-		if (!(adapter->flags2 & FLAG2_CRC_STRIPPING))
-			pskb_trim(skb, skb->len - 4);
+		if (!(adapter->flags2 & FLAG2_CRC_STRIPPING)) {
+			if (!(netdev->features & NETIF_F_RXFCS))
+				pskb_trim(skb, skb->len - 4);
+		}
 
 copydone:
 		total_rx_bytes += skb->len;
@@ -5987,7 +5999,7 @@ 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_RXCSUM | NETIF_F_RXHASH | NETIF_F_RXFCS)))
 		return 0;
 
 	/*
@@ -6001,6 +6013,20 @@ static int e1000_set_features(struct net_device *netdev,
 		return -EINVAL;
 	}
 
+	if (changed & NETIF_F_RXFCS) {
+		if (features & NETIF_F_RXFCS) {
+			adapter->flags2 &= ~FLAG2_CRC_STRIPPING;
+		} else {
+			/* We need to take it back to defaults, which might mean
+			 * stripping is still disabled at the adapter level.
+			 */
+			if (adapter->flags2 & FLAG2_DFLT_CRC_STRIPPING)
+				adapter->flags2 |= FLAG2_CRC_STRIPPING;
+			else
+				adapter->flags2 &= ~FLAG2_CRC_STRIPPING;
+		}
+	}
+
 	netdev->features = features;
 
 	if (netif_running(netdev))
@@ -6199,6 +6225,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;
 
 	if (adapter->flags & FLAG_HAS_HW_VLAN_FILTER)
 		netdev->features |= NETIF_F_HW_VLAN_FILTER;
diff --git a/drivers/net/ethernet/intel/e1000e/param.c b/drivers/net/ethernet/intel/e1000e/param.c
index 9c6a56d..ff796e4 100644
--- a/drivers/net/ethernet/intel/e1000e/param.c
+++ b/drivers/net/ethernet/intel/e1000e/param.c
@@ -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 */
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v2 04/10] net: Add framework to allow sending packets with customized CRC.
  2012-02-08 19:54 [PATCH v2 00/10] Low-level Ethernet debugging features greearb
                   ` (2 preceding siblings ...)
  2012-02-08 19:54 ` [PATCH v2 03/10] e1000e: " greearb
@ 2012-02-08 19:54 ` greearb
  2012-02-08 19:54 ` [PATCH v2 05/10] e100: Support sending custom Ethernet CRC greearb
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 26+ messages in thread
From: greearb @ 2012-02-08 19:54 UTC (permalink / raw)
  To: netdev; +Cc: Ben Greear

From: Ben Greear <greearb@candelatech.com>

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

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

Signed-off-by: Ben Greear <greearb@candelatech.com>
---
: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(-)

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

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v2 05/10] e100: Support sending custom Ethernet CRC
  2012-02-08 19:54 [PATCH v2 00/10] Low-level Ethernet debugging features greearb
                   ` (3 preceding siblings ...)
  2012-02-08 19:54 ` [PATCH v2 04/10] net: Add framework to allow sending packets with customized CRC greearb
@ 2012-02-08 19:54 ` greearb
  2012-02-08 19:54 ` [PATCH v2 06/10] e1000e: " greearb
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 26+ messages in thread
From: greearb @ 2012-02-08 19:54 UTC (permalink / raw)
  To: netdev; +Cc: Ben Greear

From: Ben Greear <greearb@candelatech.com>

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

Signed-off-by: Ben Greear <greearb@candelatech.com>
---
: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(-)

diff --git a/drivers/net/ethernet/intel/e100.c b/drivers/net/ethernet/intel/e100.c
index 943178b..c793939 100644
--- a/drivers/net/ethernet/intel/e100.c
+++ b/drivers/net/ethernet/intel/e100.c
@@ -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);
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v2 06/10] e1000e:  Support sending custom Ethernet CRC.
  2012-02-08 19:54 [PATCH v2 00/10] Low-level Ethernet debugging features greearb
                   ` (4 preceding siblings ...)
  2012-02-08 19:54 ` [PATCH v2 05/10] e100: Support sending custom Ethernet CRC greearb
@ 2012-02-08 19:54 ` greearb
  2012-02-08 19:54 ` [PATCH v2 07/10] net: Support RX-ALL feature flag greearb
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 26+ messages in thread
From: greearb @ 2012-02-08 19:54 UTC (permalink / raw)
  To: netdev; +Cc: Ben Greear

From: Ben Greear <greearb@candelatech.com>

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

Signed-off-by: Ben Greear <greearb@candelatech.com>
---
: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(-)

diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
index e3eefda..2f9434c 100644
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
@@ -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;
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v2 07/10] net:  Support RX-ALL feature flag.
  2012-02-08 19:54 [PATCH v2 00/10] Low-level Ethernet debugging features greearb
                   ` (5 preceding siblings ...)
  2012-02-08 19:54 ` [PATCH v2 06/10] e1000e: " greearb
@ 2012-02-08 19:54 ` greearb
  2012-02-08 19:54 ` [PATCH v2 08/10] e1000e: Support RXALL " greearb
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 26+ messages in thread
From: greearb @ 2012-02-08 19:54 UTC (permalink / raw)
  To: netdev; +Cc: Ben Greear

From: Ben Greear <greearb@candelatech.com>

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.

Signed-off-by: Ben Greear <greearb@candelatech.com>
---
: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(-)

diff --git a/Documentation/networking/netdev-features.txt b/Documentation/networking/netdev-features.txt
index 7d27812..4164f5c 100644
--- a/Documentation/networking/netdev-features.txt
+++ b/Documentation/networking/netdev-features.txt
@@ -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.
diff --git a/include/linux/netdev_features.h b/include/linux/netdev_features.h
index d133186..5ac3212 100644
--- a/include/linux/netdev_features.h
+++ b/include/linux/netdev_features.h
@@ -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 */
diff --git a/net/core/ethtool.c b/net/core/ethtool.c
index 0801619..6d6d7d2 100644
--- a/net/core/ethtool.c
+++ b/net/core/ethtool.c
@@ -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)
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v2 08/10] e1000e:  Support RXALL feature flag.
  2012-02-08 19:54 [PATCH v2 00/10] Low-level Ethernet debugging features greearb
                   ` (6 preceding siblings ...)
  2012-02-08 19:54 ` [PATCH v2 07/10] net: Support RX-ALL feature flag greearb
@ 2012-02-08 19:54 ` greearb
  2012-02-08 19:54 ` [PATCH v2 09/10] e100: " greearb
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 26+ messages in thread
From: greearb @ 2012-02-08 19:54 UTC (permalink / raw)
  To: netdev; +Cc: Ben Greear

From: Ben Greear <greearb@candelatech.com>

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 <greearb@candelatech.com>
---
: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(-)

diff --git a/drivers/net/ethernet/intel/e1000e/defines.h b/drivers/net/ethernet/intel/e1000e/defines.h
index 1af30b9..3a50259 100644
--- a/drivers/net/ethernet/intel/e1000e/defines.h
+++ b/drivers/net/ethernet/intel/e1000e/defines.h
@@ -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 */
diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c
index 2f9434c..9905f45 100644
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
@@ -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;
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v2 09/10] e100:  Support RXALL feature flag.
  2012-02-08 19:54 [PATCH v2 00/10] Low-level Ethernet debugging features greearb
                   ` (7 preceding siblings ...)
  2012-02-08 19:54 ` [PATCH v2 08/10] e1000e: Support RXALL " greearb
@ 2012-02-08 19:54 ` greearb
  2012-02-08 19:54 ` [PATCH v2 10/10] e1000: Support sending custom Ethernet CRC greearb
  2012-02-10  4:31 ` [PATCH v2 00/10] Low-level Ethernet debugging features Jeff Kirsher
  10 siblings, 0 replies; 26+ messages in thread
From: greearb @ 2012-02-08 19:54 UTC (permalink / raw)
  To: netdev; +Cc: Ben Greear

From: Ben Greear <greearb@candelatech.com>

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

Signed-off-by: Ben Greear <greearb@candelatech.com>
---
: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(-)

diff --git a/drivers/net/ethernet/intel/e100.c b/drivers/net/ethernet/intel/e100.c
index c793939..a296ec4 100644
--- a/drivers/net/ethernet/intel/e100.c
+++ b/drivers/net/ethernet/intel/e100.c
@@ -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);
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* [PATCH v2 10/10] e1000: Support sending custom Ethernet CRC.
  2012-02-08 19:54 [PATCH v2 00/10] Low-level Ethernet debugging features greearb
                   ` (8 preceding siblings ...)
  2012-02-08 19:54 ` [PATCH v2 09/10] e100: " greearb
@ 2012-02-08 19:54 ` greearb
  2012-02-10  4:31 ` [PATCH v2 00/10] Low-level Ethernet debugging features Jeff Kirsher
  10 siblings, 0 replies; 26+ messages in thread
From: greearb @ 2012-02-08 19:54 UTC (permalink / raw)
  To: netdev; +Cc: Ben Greear

From: Ben Greear <greearb@candelatech.com>

Good for testing the RX logic for bad CRC handling.

Signed-off-by: Ben Greear <greearb@candelatech.com>
---
: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(-)

diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/ethernet/intel/e1000/e1000_main.c
index 1f86a70..64b73bc 100644
--- a/drivers/net/ethernet/intel/e1000/e1000_main.c
+++ b/drivers/net/ethernet/intel/e1000/e1000_main.c
@@ -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);
 
-- 
1.7.3.4

^ permalink raw reply related	[flat|nested] 26+ messages in thread

* Re: [PATCH v2 00/10] Low-level Ethernet debugging features.
  2012-02-08 19:54 [PATCH v2 00/10] Low-level Ethernet debugging features greearb
                   ` (9 preceding siblings ...)
  2012-02-08 19:54 ` [PATCH v2 10/10] e1000: Support sending custom Ethernet CRC greearb
@ 2012-02-10  4:31 ` Jeff Kirsher
  2012-02-10  5:42   ` Ben Greear
  2012-02-10 20:43   ` David Miller
  10 siblings, 2 replies; 26+ messages in thread
From: Jeff Kirsher @ 2012-02-10  4:31 UTC (permalink / raw)
  To: greearb; +Cc: netdev

[-- Attachment #1: Type: text/plain, Size: 4459 bytes --]

On 02/08/2012 11:54 AM, greearb@candelatech.com wrote:
> From: Ben Greear <greearb@candelatech.com>
>
> 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(-)
>
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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 900 bytes --]

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v2 00/10] Low-level Ethernet debugging features.
  2012-02-10  4:31 ` [PATCH v2 00/10] Low-level Ethernet debugging features Jeff Kirsher
@ 2012-02-10  5:42   ` Ben Greear
  2012-02-10  5:52     ` Jeff Kirsher
  2012-02-10 13:25     ` Eric Dumazet
  2012-02-10 20:43   ` David Miller
  1 sibling, 2 replies; 26+ messages in thread
From: Ben Greear @ 2012-02-10  5:42 UTC (permalink / raw)
  To: jeffrey.t.kirsher; +Cc: Jeff Kirsher, netdev

On 02/09/2012 08:31 PM, Jeff Kirsher wrote:

> 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

-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v2 00/10] Low-level Ethernet debugging features.
  2012-02-10  5:42   ` Ben Greear
@ 2012-02-10  5:52     ` Jeff Kirsher
  2012-02-10 13:25     ` Eric Dumazet
  1 sibling, 0 replies; 26+ messages in thread
From: Jeff Kirsher @ 2012-02-10  5:52 UTC (permalink / raw)
  To: Ben Greear, Brown, Aaron F; +Cc: netdev

[-- Attachment #1: Type: text/plain, Size: 747 bytes --]

On Thu, 2012-02-09 at 21:42 -0800, Ben Greear wrote:
> On 02/09/2012 08:31 PM, Jeff Kirsher wrote:
> 
> > 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
> 

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

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v2 00/10] Low-level Ethernet debugging features.
  2012-02-10  5:42   ` Ben Greear
  2012-02-10  5:52     ` Jeff Kirsher
@ 2012-02-10 13:25     ` Eric Dumazet
  2012-02-10 13:45       ` David Laight
  2012-02-10 17:18       ` Ben Greear
  1 sibling, 2 replies; 26+ messages in thread
From: Eric Dumazet @ 2012-02-10 13:25 UTC (permalink / raw)
  To: Ben Greear; +Cc: jeffrey.t.kirsher, Jeff Kirsher, netdev

Le jeudi 09 février 2012 à 21:42 -0800, Ben Greear a écrit :
> On 02/09/2012 08:31 PM, Jeff Kirsher wrote:
> 
> > 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.

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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* RE: [PATCH v2 00/10] Low-level Ethernet debugging features.
  2012-02-10 13:25     ` Eric Dumazet
@ 2012-02-10 13:45       ` David Laight
  2012-02-10 13:51         ` Eric Dumazet
  2012-02-10 17:18       ` Ben Greear
  1 sibling, 1 reply; 26+ messages in thread
From: David Laight @ 2012-02-10 13:45 UTC (permalink / raw)
  To: Eric Dumazet, Ben Greear; +Cc: jeffrey.t.kirsher, Jeff Kirsher, netdev

 
> > 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 ?

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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* RE: [PATCH v2 00/10] Low-level Ethernet debugging features.
  2012-02-10 13:45       ` David Laight
@ 2012-02-10 13:51         ` Eric Dumazet
  2012-02-10 14:09           ` Eric Dumazet
  0 siblings, 1 reply; 26+ messages in thread
From: Eric Dumazet @ 2012-02-10 13:51 UTC (permalink / raw)
  To: David Laight; +Cc: Ben Greear, jeffrey.t.kirsher, Jeff Kirsher, netdev

Le vendredi 10 février 2012 à 13:45 +0000, David Laight a écrit :
> > > 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 ?
> 
> 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.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* RE: [PATCH v2 00/10] Low-level Ethernet debugging features.
  2012-02-10 13:51         ` Eric Dumazet
@ 2012-02-10 14:09           ` Eric Dumazet
  0 siblings, 0 replies; 26+ messages in thread
From: Eric Dumazet @ 2012-02-10 14:09 UTC (permalink / raw)
  To: David Laight; +Cc: Ben Greear, jeffrey.t.kirsher, Jeff Kirsher, netdev

Le vendredi 10 février 2012 à 14:51 +0100, Eric Dumazet a écrit :

> 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;
	}

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v2 00/10] Low-level Ethernet debugging features.
  2012-02-10 13:25     ` Eric Dumazet
  2012-02-10 13:45       ` David Laight
@ 2012-02-10 17:18       ` Ben Greear
  1 sibling, 0 replies; 26+ messages in thread
From: Ben Greear @ 2012-02-10 17:18 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: jeffrey.t.kirsher, Jeff Kirsher, netdev

On 02/10/2012 05:25 AM, Eric Dumazet wrote:
> Le jeudi 09 février 2012 à 21:42 -0800, Ben Greear a écrit :
>> On 02/09/2012 08:31 PM, Jeff Kirsher wrote:
>>
>>> 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.
>
> 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


-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v2 00/10] Low-level Ethernet debugging features.
  2012-02-10  4:31 ` [PATCH v2 00/10] Low-level Ethernet debugging features Jeff Kirsher
  2012-02-10  5:42   ` Ben Greear
@ 2012-02-10 20:43   ` David Miller
  1 sibling, 0 replies; 26+ messages in thread
From: David Miller @ 2012-02-10 20:43 UTC (permalink / raw)
  To: jeffrey.t.kirsher, tarbal; +Cc: greearb, netdev

From: Jeff Kirsher <tarbal@gmail.com>
Date: Thu, 09 Feb 2012 20:31:44 -0800

> 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.

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v2 03/10] e1000e: Support RXFCS feature flag.
  2012-02-08 19:54 ` [PATCH v2 03/10] e1000e: " greearb
@ 2012-02-10 22:46   ` Michał Mirosław
  2012-02-10 22:57     ` Ben Greear
  0 siblings, 1 reply; 26+ messages in thread
From: Michał Mirosław @ 2012-02-10 22:46 UTC (permalink / raw)
  To: greearb; +Cc: netdev

2012/2/8  <greearb@candelatech.com>:
> From: Ben Greear <greearb@candelatech.com>
>
> 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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v2 02/10] e100: Support RXFCS feature flag.
  2012-02-08 19:54 ` [PATCH v2 02/10] e100: " greearb
@ 2012-02-10 22:56   ` Michał Mirosław
  2012-02-11  0:17     ` Ben Greear
  0 siblings, 1 reply; 26+ messages in thread
From: Michał Mirosław @ 2012-02-10 22:56 UTC (permalink / raw)
  To: greearb; +Cc: netdev

2012/2/8  <greearb@candelatech.com>:
> From: Ben Greear <greearb@candelatech.com>
>
> This allows e100 to be configured to append the
> Ethernet FCS to the skb.
[...]
> @@ -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.

> @@ -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.

>        actual_size = le16_to_cpu(rfd->actual_size) & 0x3FFF;

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

> -       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);
...

> @@ -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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v2 03/10] e1000e: Support RXFCS feature flag.
  2012-02-10 22:46   ` Michał Mirosław
@ 2012-02-10 22:57     ` Ben Greear
  2012-02-10 23:09       ` Michał Mirosław
  0 siblings, 1 reply; 26+ messages in thread
From: Ben Greear @ 2012-02-10 22:57 UTC (permalink / raw)
  To: Michał Mirosław; +Cc: netdev

On 02/10/2012 02:46 PM, Michał Mirosław wrote:
> 2012/2/8<greearb@candelatech.com>:
>> From: Ben Greear<greearb@candelatech.com>
>>
>> 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.

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

-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v2 03/10] e1000e: Support RXFCS feature flag.
  2012-02-10 22:57     ` Ben Greear
@ 2012-02-10 23:09       ` Michał Mirosław
  2012-02-11  0:06         ` Ben Greear
  0 siblings, 1 reply; 26+ messages in thread
From: Michał Mirosław @ 2012-02-10 23:09 UTC (permalink / raw)
  To: Ben Greear; +Cc: netdev

W dniu 10 lutego 2012 23:57 użytkownik Ben Greear
<greearb@candelatech.com> napisał:
> On 02/10/2012 02:46 PM, Michał Mirosław wrote:
>>
>> 2012/2/8<greearb@candelatech.com>:
>>>
>>> From: Ben Greear<greearb@candelatech.com>
>>>
>>> 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.
> 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.

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

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v2 03/10] e1000e: Support RXFCS feature flag.
  2012-02-10 23:09       ` Michał Mirosław
@ 2012-02-11  0:06         ` Ben Greear
  0 siblings, 0 replies; 26+ messages in thread
From: Ben Greear @ 2012-02-11  0:06 UTC (permalink / raw)
  To: Michał Mirosław; +Cc: netdev

On 02/10/2012 03:09 PM, Michał Mirosław wrote:
> W dniu 10 lutego 2012 23:57 użytkownik Ben Greear
> <greearb@candelatech.com>  napisał:
>> On 02/10/2012 02:46 PM, Michał Mirosław wrote:
>>>
>>> 2012/2/8<greearb@candelatech.com>:
>>>>
>>>> From: Ben Greear<greearb@candelatech.com>
>>>>
>>>> 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.
>> 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.
>
> 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

-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com

^ permalink raw reply	[flat|nested] 26+ messages in thread

* Re: [PATCH v2 02/10] e100: Support RXFCS feature flag.
  2012-02-10 22:56   ` Michał Mirosław
@ 2012-02-11  0:17     ` Ben Greear
  0 siblings, 0 replies; 26+ messages in thread
From: Ben Greear @ 2012-02-11  0:17 UTC (permalink / raw)
  To: Michał Mirosław; +Cc: netdev

On 02/10/2012 02:56 PM, Michał Mirosław wrote:
> 2012/2/8<greearb@candelatech.com>:
>> From: Ben Greear<greearb@candelatech.com>
>>
>> This allows e100 to be configured to append the
>> Ethernet FCS to the skb.
> [...]
>> @@ -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.
>
>> @@ -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.
>
>>         actual_size = le16_to_cpu(rfd->actual_size)&  0x3FFF;
>
> u16 data_size = actual_size;
> if (unlikely(dev->features&  NETIF_F_RXFCS))
>      actual_size -= 4;
>
>> -       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);
> ...

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

-- 
Ben Greear <greearb@candelatech.com>
Candela Technologies Inc  http://www.candelatech.com

^ permalink raw reply	[flat|nested] 26+ messages in thread

end of thread, other threads:[~2012-02-11  0:17 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-08 19:54 [PATCH v2 00/10] Low-level Ethernet debugging features greearb
2012-02-08 19:54 ` [PATCH v2 01/10] net: Support RXFCS feature flag greearb
2012-02-08 19:54 ` [PATCH v2 02/10] e100: " greearb
2012-02-10 22:56   ` Michał Mirosław
2012-02-11  0:17     ` Ben Greear
2012-02-08 19:54 ` [PATCH v2 03/10] e1000e: " greearb
2012-02-10 22:46   ` Michał Mirosław
2012-02-10 22:57     ` Ben Greear
2012-02-10 23:09       ` Michał Mirosław
2012-02-11  0:06         ` Ben Greear
2012-02-08 19:54 ` [PATCH v2 04/10] net: Add framework to allow sending packets with customized CRC greearb
2012-02-08 19:54 ` [PATCH v2 05/10] e100: Support sending custom Ethernet CRC greearb
2012-02-08 19:54 ` [PATCH v2 06/10] e1000e: " greearb
2012-02-08 19:54 ` [PATCH v2 07/10] net: Support RX-ALL feature flag greearb
2012-02-08 19:54 ` [PATCH v2 08/10] e1000e: Support RXALL " greearb
2012-02-08 19:54 ` [PATCH v2 09/10] e100: " greearb
2012-02-08 19:54 ` [PATCH v2 10/10] e1000: Support sending custom Ethernet CRC greearb
2012-02-10  4:31 ` [PATCH v2 00/10] Low-level Ethernet debugging features Jeff Kirsher
2012-02-10  5:42   ` Ben Greear
2012-02-10  5:52     ` Jeff Kirsher
2012-02-10 13:25     ` Eric Dumazet
2012-02-10 13:45       ` David Laight
2012-02-10 13:51         ` Eric Dumazet
2012-02-10 14:09           ` Eric Dumazet
2012-02-10 17:18       ` Ben Greear
2012-02-10 20:43   ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.