Skip to content

Commit

Permalink
jme: Don't show UDP Checksum error if HW misjudged
Browse files Browse the repository at this point in the history
Some JMicron Chip treat 0 as error checksum for UDP packets.
Which should be "No checksum needed".

Reported-by: Adam Swift <Adam.Swift@omnitude.net>
Confirmed-by: "Aries Lee" <arieslee@jmicron.com>
Signed-off-by: Guo-Fu Tseng <cooldavid@cooldavid.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Guo-Fu Tseng authored and David S. Miller committed Feb 14, 2011
1 parent 8b53aba commit c00cd82
Showing 1 changed file with 29 additions and 3 deletions.
32 changes: 29 additions & 3 deletions drivers/net/jme.c
Original file line number Diff line number Diff line change
Expand Up @@ -956,8 +956,34 @@ jme_disable_rx_engine(struct jme_adapter *jme)
jme_mac_rxclk_off(jme);
}

static u16
jme_udpsum(struct sk_buff *skb)
{
u16 csum = 0xFFFFu;

if (skb->len < (ETH_HLEN + sizeof(struct iphdr)))
return csum;
if (skb->protocol != htons(ETH_P_IP))
return csum;
skb_set_network_header(skb, ETH_HLEN);
if ((ip_hdr(skb)->protocol != IPPROTO_UDP) ||
(skb->len < (ETH_HLEN +
(ip_hdr(skb)->ihl << 2) +
sizeof(struct udphdr)))) {
skb_reset_network_header(skb);
return csum;
}
skb_set_transport_header(skb,
ETH_HLEN + (ip_hdr(skb)->ihl << 2));
csum = udp_hdr(skb)->check;
skb_reset_transport_header(skb);
skb_reset_network_header(skb);

return csum;
}

static int
jme_rxsum_ok(struct jme_adapter *jme, u16 flags)
jme_rxsum_ok(struct jme_adapter *jme, u16 flags, struct sk_buff *skb)
{
if (!(flags & (RXWBFLAG_TCPON | RXWBFLAG_UDPON | RXWBFLAG_IPV4)))
return false;
Expand All @@ -970,7 +996,7 @@ jme_rxsum_ok(struct jme_adapter *jme, u16 flags)
}

if (unlikely((flags & (RXWBFLAG_MF | RXWBFLAG_UDPON | RXWBFLAG_UDPCS))
== RXWBFLAG_UDPON)) {
== RXWBFLAG_UDPON) && jme_udpsum(skb)) {
if (flags & RXWBFLAG_IPV4)
netif_err(jme, rx_err, jme->dev, "UDP Checksum error\n");
return false;
Expand Down Expand Up @@ -1018,7 +1044,7 @@ jme_alloc_and_feed_skb(struct jme_adapter *jme, int idx)
skb_put(skb, framesize);
skb->protocol = eth_type_trans(skb, jme->dev);

if (jme_rxsum_ok(jme, le16_to_cpu(rxdesc->descwb.flags)))
if (jme_rxsum_ok(jme, le16_to_cpu(rxdesc->descwb.flags), skb))
skb->ip_summed = CHECKSUM_UNNECESSARY;
else
skb_checksum_none_assert(skb);
Expand Down

0 comments on commit c00cd82

Please sign in to comment.