From: greearb@candelatech.com
To: netdev@vger.kernel.org
Cc: Ben Greear <greearb@candelatech.com>
Subject: [PATCH v2 03/10] e1000e: Support RXFCS feature flag.
Date: Wed, 8 Feb 2012 11:54:38 -0800 [thread overview]
Message-ID: <1328730885-10941-4-git-send-email-greearb@candelatech.com> (raw)
In-Reply-To: <1328730885-10941-1-git-send-email-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.
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
next prev parent reply other threads:[~2012-02-08 19:55 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
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 ` greearb [this message]
2012-02-10 22:46 ` [PATCH v2 03/10] e1000e: " 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1328730885-10941-4-git-send-email-greearb@candelatech.com \
--to=greearb@candelatech.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).