Skip to content

Commit c00cd82

Browse files
cooldaviddavem330
authored andcommitted
jme: Don't show UDP Checksum error if HW misjudged
Some JMicron Chip treat 0 as error checksum for UDP packets. Which should be "No checksum needed". Reported-by: Adam Swift <[email protected]> Confirmed-by: "Aries Lee" <[email protected]> Signed-off-by: Guo-Fu Tseng <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 8b53aba commit c00cd82

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

drivers/net/jme.c

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -956,8 +956,34 @@ jme_disable_rx_engine(struct jme_adapter *jme)
956956
jme_mac_rxclk_off(jme);
957957
}
958958

959+
static u16
960+
jme_udpsum(struct sk_buff *skb)
961+
{
962+
u16 csum = 0xFFFFu;
963+
964+
if (skb->len < (ETH_HLEN + sizeof(struct iphdr)))
965+
return csum;
966+
if (skb->protocol != htons(ETH_P_IP))
967+
return csum;
968+
skb_set_network_header(skb, ETH_HLEN);
969+
if ((ip_hdr(skb)->protocol != IPPROTO_UDP) ||
970+
(skb->len < (ETH_HLEN +
971+
(ip_hdr(skb)->ihl << 2) +
972+
sizeof(struct udphdr)))) {
973+
skb_reset_network_header(skb);
974+
return csum;
975+
}
976+
skb_set_transport_header(skb,
977+
ETH_HLEN + (ip_hdr(skb)->ihl << 2));
978+
csum = udp_hdr(skb)->check;
979+
skb_reset_transport_header(skb);
980+
skb_reset_network_header(skb);
981+
982+
return csum;
983+
}
984+
959985
static int
960-
jme_rxsum_ok(struct jme_adapter *jme, u16 flags)
986+
jme_rxsum_ok(struct jme_adapter *jme, u16 flags, struct sk_buff *skb)
961987
{
962988
if (!(flags & (RXWBFLAG_TCPON | RXWBFLAG_UDPON | RXWBFLAG_IPV4)))
963989
return false;
@@ -970,7 +996,7 @@ jme_rxsum_ok(struct jme_adapter *jme, u16 flags)
970996
}
971997

972998
if (unlikely((flags & (RXWBFLAG_MF | RXWBFLAG_UDPON | RXWBFLAG_UDPCS))
973-
== RXWBFLAG_UDPON)) {
999+
== RXWBFLAG_UDPON) && jme_udpsum(skb)) {
9741000
if (flags & RXWBFLAG_IPV4)
9751001
netif_err(jme, rx_err, jme->dev, "UDP Checksum error\n");
9761002
return false;
@@ -1018,7 +1044,7 @@ jme_alloc_and_feed_skb(struct jme_adapter *jme, int idx)
10181044
skb_put(skb, framesize);
10191045
skb->protocol = eth_type_trans(skb, jme->dev);
10201046

1021-
if (jme_rxsum_ok(jme, le16_to_cpu(rxdesc->descwb.flags)))
1047+
if (jme_rxsum_ok(jme, le16_to_cpu(rxdesc->descwb.flags), skb))
10221048
skb->ip_summed = CHECKSUM_UNNECESSARY;
10231049
else
10241050
skb_checksum_none_assert(skb);

0 commit comments

Comments
 (0)