Commit 63890576 authored by Wolfram Joost's avatar Wolfram Joost Committed by Jeff Garzik

[PATCH] mv643xx_eth: Request HW checksum generation only for IPv4

This patch removes the NETIF_F_HW_CSUM flag to be able to use other protocols
than IPv4. Hardware checksums for IPv4 should continue to work because
NETIF_F_IP_CSUM is still set.  The sanity-check has been enhanced to check
the used protocol and to not access skb->iph for non-ipv4-packets.
Signed-off-by: default avatarWolfram Joost <pegasos@frokaschwei.de>
Signed-off-by: default avatarDale Farnsworth <dale@farnsworth.org>

 mv643xx_eth.c |   19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)
Signed-off-by: default avatarJeff Garzik <jgarzik@pobox.com>
parent 8f518703
...@@ -1148,7 +1148,6 @@ static int mv643xx_eth_start_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -1148,7 +1148,6 @@ static int mv643xx_eth_start_xmit(struct sk_buff *skb, struct net_device *dev)
5 << ETH_TX_IHL_SHIFT; 5 << ETH_TX_IHL_SHIFT;
pkt_info.l4i_chk = 0; pkt_info.l4i_chk = 0;
} else { } else {
pkt_info.cmd_sts = ETH_TX_ENABLE_INTERRUPT | pkt_info.cmd_sts = ETH_TX_ENABLE_INTERRUPT |
ETH_TX_FIRST_DESC | ETH_TX_FIRST_DESC |
ETH_TX_LAST_DESC | ETH_TX_LAST_DESC |
...@@ -1156,14 +1155,16 @@ static int mv643xx_eth_start_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -1156,14 +1155,16 @@ static int mv643xx_eth_start_xmit(struct sk_buff *skb, struct net_device *dev)
ETH_GEN_IP_V_4_CHECKSUM | ETH_GEN_IP_V_4_CHECKSUM |
skb->nh.iph->ihl << ETH_TX_IHL_SHIFT; skb->nh.iph->ihl << ETH_TX_IHL_SHIFT;
/* CPU already calculated pseudo header checksum. */ /* CPU already calculated pseudo header checksum. */
if (skb->nh.iph->protocol == IPPROTO_UDP) { if ((skb->protocol == ETH_P_IP) &&
(skb->nh.iph->protocol == IPPROTO_UDP) ) {
pkt_info.cmd_sts |= ETH_UDP_FRAME; pkt_info.cmd_sts |= ETH_UDP_FRAME;
pkt_info.l4i_chk = skb->h.uh->check; pkt_info.l4i_chk = skb->h.uh->check;
} else if (skb->nh.iph->protocol == IPPROTO_TCP) } else if ((skb->protocol == ETH_P_IP) &&
(skb->nh.iph->protocol == IPPROTO_TCP))
pkt_info.l4i_chk = skb->h.th->check; pkt_info.l4i_chk = skb->h.th->check;
else { else {
printk(KERN_ERR printk(KERN_ERR
"%s: chksum proto != TCP or UDP\n", "%s: chksum proto != IPv4 TCP or UDP\n",
dev->name); dev->name);
spin_unlock_irqrestore(&mp->lock, flags); spin_unlock_irqrestore(&mp->lock, flags);
return 1; return 1;
...@@ -1199,14 +1200,16 @@ static int mv643xx_eth_start_xmit(struct sk_buff *skb, struct net_device *dev) ...@@ -1199,14 +1200,16 @@ static int mv643xx_eth_start_xmit(struct sk_buff *skb, struct net_device *dev)
ETH_GEN_IP_V_4_CHECKSUM | ETH_GEN_IP_V_4_CHECKSUM |
skb->nh.iph->ihl << ETH_TX_IHL_SHIFT; skb->nh.iph->ihl << ETH_TX_IHL_SHIFT;
/* CPU already calculated pseudo header checksum. */ /* CPU already calculated pseudo header checksum. */
if (skb->nh.iph->protocol == IPPROTO_UDP) { if ((skb->protocol == ETH_P_IP) &&
(skb->nh.iph->protocol == IPPROTO_UDP)) {
pkt_info.cmd_sts |= ETH_UDP_FRAME; pkt_info.cmd_sts |= ETH_UDP_FRAME;
pkt_info.l4i_chk = skb->h.uh->check; pkt_info.l4i_chk = skb->h.uh->check;
} else if (skb->nh.iph->protocol == IPPROTO_TCP) } else if ((skb->protocol == ETH_P_IP) &&
(skb->nh.iph->protocol == IPPROTO_TCP))
pkt_info.l4i_chk = skb->h.th->check; pkt_info.l4i_chk = skb->h.th->check;
else { else {
printk(KERN_ERR printk(KERN_ERR
"%s: chksum proto != TCP or UDP\n", "%s: chksum proto != IPv4 TCP or UDP\n",
dev->name); dev->name);
spin_unlock_irqrestore(&mp->lock, flags); spin_unlock_irqrestore(&mp->lock, flags);
return 1; return 1;
...@@ -1421,7 +1424,7 @@ static int mv643xx_eth_probe(struct platform_device *pdev) ...@@ -1421,7 +1424,7 @@ static int mv643xx_eth_probe(struct platform_device *pdev)
* Zero copy can only work if we use Discovery II memory. Else, we will * Zero copy can only work if we use Discovery II memory. Else, we will
* have to map the buffers to ISA memory which is only 16 MB * have to map the buffers to ISA memory which is only 16 MB
*/ */
dev->features = NETIF_F_SG | NETIF_F_IP_CSUM | NETIF_F_HW_CSUM; dev->features = NETIF_F_SG | NETIF_F_IP_CSUM;
#endif #endif
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment