diff options
author | Cyrille Pitchen <cyrille.pitchen@atmel.com> | 2014-07-24 13:51:01 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-07-24 23:39:55 -0700 |
commit | 924ec53c4130a5013161c463330ddbb12ef306cf (patch) | |
tree | 0a0134461a301628ea5faa747c84cbae23a94cb8 /drivers/net/ethernet/cadence/macb.h | |
parent | 85ff3d87bf2ef1fadcde8553628c60f79806fdb4 (diff) |
net/macb: add RX checksum offload feature
When RX checksum offload is enabled at GEM level (bit 24 set in the Network
Control Register), frames with invalid IP, TCP or UDP checksums are
discarted even if promiscuous mode is enabled (bit 4 set in the Network Control
Register).
This was verified with a simple userspace program, which corrupts UDP checksum
using libnetfilter_queue.
Then both IFF_PROMISC bit must be clear in dev->flags and NETIF_F_RXCSUM bit
must be set in dev->features to enable RX checksum offload at GEM level. This
way tcpdump is still able to capture corrupted frames.
Also skb->ip_summed is set to CHECKSUM_UNNECESSARY only when both TCP/IP or
UDP/IP checksums were verified by the GEM. Indeed the GEM may verify only IP
checksum but not the one for ICMP (or other protocol than TCP or UDP).
Signed-off-by: Cyrille Pitchen <cyrille.pitchen@atmel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/cadence/macb.h')
-rw-r--r-- | drivers/net/ethernet/cadence/macb.h | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/net/ethernet/cadence/macb.h b/drivers/net/ethernet/cadence/macb.h index 7bf82856043e..517c09d72c4a 100644 --- a/drivers/net/ethernet/cadence/macb.h +++ b/drivers/net/ethernet/cadence/macb.h @@ -164,6 +164,8 @@ #define GEM_CLK_SIZE 3 #define GEM_DBW_OFFSET 21 #define GEM_DBW_SIZE 2 +#define GEM_RXCOEN_OFFSET 24 +#define GEM_RXCOEN_SIZE 1 /* Constants for data bus width. */ #define GEM_DBW32 0 @@ -452,6 +454,14 @@ struct macb_dma_desc { #define MACB_RX_BROADCAST_OFFSET 31 #define MACB_RX_BROADCAST_SIZE 1 +/* RX checksum offload disabled: bit 24 clear in NCFGR */ +#define GEM_RX_TYPEID_MATCH_OFFSET 22 +#define GEM_RX_TYPEID_MATCH_SIZE 2 + +/* RX checksum offload enabled: bit 24 set in NCFGR */ +#define GEM_RX_CSUM_OFFSET 22 +#define GEM_RX_CSUM_SIZE 2 + #define MACB_TX_FRMLEN_OFFSET 0 #define MACB_TX_FRMLEN_SIZE 11 #define MACB_TX_LAST_OFFSET 15 @@ -472,6 +482,15 @@ struct macb_dma_desc { #define GEM_TX_FRMLEN_OFFSET 0 #define GEM_TX_FRMLEN_SIZE 14 +/* Buffer descriptor constants */ +#define GEM_RX_CSUM_NONE 0 +#define GEM_RX_CSUM_IP_ONLY 1 +#define GEM_RX_CSUM_IP_TCP 2 +#define GEM_RX_CSUM_IP_UDP 3 + +/* limit RX checksum offload to TCP and UDP packets */ +#define GEM_RX_CSUM_CHECKED_MASK 2 + /** * struct macb_tx_skb - data about an skb which is being transmitted * @skb: skb currently being transmitted, only set for the last buffer |