Enable RXFCS as a feature.
Subsystems (3)
cover Enable RXFCS as a feature.
From: Ben Greear <[email protected]>
These patches are on top of the features work that Michal Miroslaw posted recently.
A small patch to ethtool is needed as well.
These are just for comment until his patches go in.
Ben Greear (2):
net: Support RXFCS feature flag.
e100: Support RXFCS feature flag.
drivers/net/e100.c | 15 ++++++++++++--- include/linux/ethtool.h | 1 + include/linux/netdev_features.h | 2 ++ net/core/ethtool.c | 10 ++++++++-- 4 files changed, 23 insertions(+), 5 deletions(-)
Signature · 1 line
1.7.3.4
PATCH 1/2 net: Support RXFCS feature flag.
From: Ben Greear <[email protected]>
When set, this causes the Ethernet FCS to be appended to the end of the skb.
Useful for sniffing packets.
---
:100644 100644 06a8318... afdc2da... M include/linux/ethtool.h
:100644 100644 d0ab610... 55f359e... M include/linux/netdev_features.h
:100644 100644 80b88fe... 4920c73... M net/core/ethtool.c
include/linux/ethtool.h | 1 + include/linux/netdev_features.h | 2 ++ net/core/ethtool.c | 10 ++++++++-- 3 files changed, 11 insertions(+), 2 deletions(-)
include/linux/ethtool.h +1 -0
@@ -347,6 +347,7 @@ struct ethtool_perm_addr {* flag differs from the read-only value. */ enum ethtool_flags { +ETH_FLAG_RXFCS = (1 <<0 ),/* Append FCS to skb */ ETH_FLAG_TXVLAN = (1 <<7 ),/* TX VLAN offload enabled */ ETH_FLAG_RXVLAN = (1 <<8 ),/* RX VLAN offload enabled */ ETH_FLAG_LRO = (1 <<15 ),/* LRO is enabled */
include/linux/netdev_features.h +2 -0
@@ -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 */ /* * Add your fresh new feature above and remember to update
@@ -98,6 +99,7 @@ enum {#define NETIF_F_RXCSUM __NETIF_F(RXCSUM)#define NETIF_F_NOCACHE_COPY __NETIF_F(NOCACHE_COPY)#define NETIF_F_LOOPBACK __NETIF_F(LOOPBACK) +#define NETIF_F_RXFCS __NETIF_F(RXFCS)/* Features valid for ethtool to change */ /* = all defined minus driver/device-class-related */
net/core/ethtool.c +8 -2
@@ -74,6 +74,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)
@@ -249,9 +250,10 @@ static int ethtool_set_one_feature(struct net_device *dev, }#define ETH_ALL_FLAGS (ETH_FLAG_LRO | ETH_FLAG_RXVLAN | ETH_FLAG_TXVLAN | \ - ETH_FLAG_NTUPLE | ETH_FLAG_RXHASH) + ETH_FLAG_NTUPLE | ETH_FLAG_RXHASH | ETH_FLAG_RXFCS)#define ETH_ALL_FEATURES (NETIF_F_LRO | NETIF_F_HW_VLAN_RX | \ - NETIF_F_HW_VLAN_TX | NETIF_F_NTUPLE | NETIF_F_RXHASH) + NETIF_F_HW_VLAN_TX | NETIF_F_NTUPLE | \ + NETIF_F_RXHASH | NETIF_F_RXFCS)static u32 __ethtool_get_flags (struct net_device *dev) {
@@ -262,6 +264,8 @@ static u32 __ethtool_get_flags(struct net_device *dev)if (dev->features &NETIF_F_HW_VLAN_TX ) flags |=ETH_FLAG_TXVLAN ;if (dev->features &NETIF_F_NTUPLE ) flags |=ETH_FLAG_NTUPLE ;if (dev->features &NETIF_F_RXHASH ) flags |=ETH_FLAG_RXHASH ; +if (dev->features &NETIF_F_RXFCS ) + flags |=ETH_FLAG_RXFCS ;return flags; }
@@ -278,6 +282,8 @@ static int __ethtool_set_flags(struct net_device *dev, u32 data)if (data Ð_FLAG_TXVLAN ) features |=NETIF_F_HW_VLAN_TX ;if (data Ð_FLAG_NTUPLE ) features |=NETIF_F_NTUPLE ;if (data Ð_FLAG_RXHASH ) features |=NETIF_F_RXHASH ; +if (data Ð_FLAG_RXFCS ) + features |=NETIF_F_RXFCS ;/* allow changing only bits set in hw_features */ changed = (features ^ dev->features) Ð_ALL_FEATURES ;
Signature · 1 line
1.7.3.4
Re: [PATCH 1/2] net: Support RXFCS feature flag.
Quoted 6 lines · On Thu, 2011-06-23 at 16:13 -0700, [email protected] wrote:
From: Ben Greear <[email protected]>
When set, this causes the Ethernet FCS to be appended to the end of the skb.
Useful for sniffing packets.
[...]
include/linux/ethtool.h struct ethtool_perm_addr { · line 353
Quoted 10 lines
include/linux/ethtool.h +1
-0@@ -347,6 +347,7 @@ struct ethtool_perm_addr {* flag differs from the read-only value. */ enum ethtool_flags { +ETH_FLAG_RXFCS = (1 <<0 ),/* Append FCS to skb */ ETH_FLAG_TXVLAN = (1 <<7 ),/* TX VLAN offload enabled */ ETH_FLAG_RXVLAN = (1 <<8 ),/* RX VLAN offload enabled */ ETH_FLAG_LRO = (1 <<15 ),/* LRO is enabled */
[...]
No, all new features should be accessed through the ETHTOOL_{G,S}FEATURES commands only.
Ben.
Signature · 3 lines
Ben Hutchings, Senior Software Engineer, Solarflare Not speaking for my employer; that's the marketing department's job. They asked us to note that Solarflare product names are trademarked.
PATCH 2/2 e100: Support RXFCS feature flag.
In reply to [email protected]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 c1352c6... 761f6f5... M drivers/net/e100.c
drivers/net/e100.c | 15 ++++++++++++--- 1 files changed, 12 insertions(+), 3 deletions(-)
drivers/net/e100.c +12 -3
@@ -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 (netdev->wanted_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 (dev->wanted_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);
@@ -2761,6 +2768,8 @@ static int __devinit e100_probe(struct pci_dev *pdev,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