Commit 39c38824 authored by Yunsheng Lin's avatar Yunsheng Lin Committed by David S. Miller

net: hns3: fix for tunnel type handling in hns3_rx_checksum

According to hardware user manual, the tunnel packet type is
available in the rx.ol_info field of struct hns3_desc. Currently
the tunnel packet type is decided by the rx.l234_info, which may
cause RX checksum handling error.

This patch fixes it by using the correct field in struct hns3_desc
to decide the tunnel packet type.

Fixes: 76ad4f0e ("net: hns3: Add support of HNS3 Ethernet Driver for hip08 SoC")
Signed-off-by: default avatarYunsheng Lin <linyunsheng@huawei.com>
Signed-off-by: default avatarHuazhong Tan <tanhuazhong@huawei.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent db4970aa
...@@ -2463,7 +2463,7 @@ static int hns3_gro_complete(struct sk_buff *skb) ...@@ -2463,7 +2463,7 @@ static int hns3_gro_complete(struct sk_buff *skb)
} }
static void hns3_rx_checksum(struct hns3_enet_ring *ring, struct sk_buff *skb, static void hns3_rx_checksum(struct hns3_enet_ring *ring, struct sk_buff *skb,
u32 l234info, u32 bd_base_info) u32 l234info, u32 bd_base_info, u32 ol_info)
{ {
struct net_device *netdev = ring->tqp->handle->kinfo.netdev; struct net_device *netdev = ring->tqp->handle->kinfo.netdev;
int l3_type, l4_type; int l3_type, l4_type;
...@@ -2490,7 +2490,7 @@ static void hns3_rx_checksum(struct hns3_enet_ring *ring, struct sk_buff *skb, ...@@ -2490,7 +2490,7 @@ static void hns3_rx_checksum(struct hns3_enet_ring *ring, struct sk_buff *skb,
return; return;
} }
ol4_type = hnae3_get_field(l234info, HNS3_RXD_OL4ID_M, ol4_type = hnae3_get_field(ol_info, HNS3_RXD_OL4ID_M,
HNS3_RXD_OL4ID_S); HNS3_RXD_OL4ID_S);
switch (ol4_type) { switch (ol4_type) {
case HNS3_OL4_TYPE_MAC_IN_UDP: case HNS3_OL4_TYPE_MAC_IN_UDP:
...@@ -2694,7 +2694,7 @@ static int hns3_add_frag(struct hns3_enet_ring *ring, struct hns3_desc *desc, ...@@ -2694,7 +2694,7 @@ static int hns3_add_frag(struct hns3_enet_ring *ring, struct hns3_desc *desc,
static int hns3_set_gro_and_checksum(struct hns3_enet_ring *ring, static int hns3_set_gro_and_checksum(struct hns3_enet_ring *ring,
struct sk_buff *skb, u32 l234info, struct sk_buff *skb, u32 l234info,
u32 bd_base_info) u32 bd_base_info, u32 ol_info)
{ {
u16 gro_count; u16 gro_count;
u32 l3_type; u32 l3_type;
...@@ -2703,7 +2703,7 @@ static int hns3_set_gro_and_checksum(struct hns3_enet_ring *ring, ...@@ -2703,7 +2703,7 @@ static int hns3_set_gro_and_checksum(struct hns3_enet_ring *ring,
HNS3_RXD_GRO_COUNT_S); HNS3_RXD_GRO_COUNT_S);
/* if there is no HW GRO, do not set gro params */ /* if there is no HW GRO, do not set gro params */
if (!gro_count) { if (!gro_count) {
hns3_rx_checksum(ring, skb, l234info, bd_base_info); hns3_rx_checksum(ring, skb, l234info, bd_base_info, ol_info);
return 0; return 0;
} }
...@@ -2743,7 +2743,7 @@ static int hns3_handle_bdinfo(struct hns3_enet_ring *ring, struct sk_buff *skb) ...@@ -2743,7 +2743,7 @@ static int hns3_handle_bdinfo(struct hns3_enet_ring *ring, struct sk_buff *skb)
{ {
struct net_device *netdev = ring->tqp->handle->kinfo.netdev; struct net_device *netdev = ring->tqp->handle->kinfo.netdev;
enum hns3_pkt_l2t_type l2_frame_type; enum hns3_pkt_l2t_type l2_frame_type;
u32 bd_base_info, l234info; u32 bd_base_info, l234info, ol_info;
struct hns3_desc *desc; struct hns3_desc *desc;
unsigned int len; unsigned int len;
int pre_ntc, ret; int pre_ntc, ret;
...@@ -2757,6 +2757,7 @@ static int hns3_handle_bdinfo(struct hns3_enet_ring *ring, struct sk_buff *skb) ...@@ -2757,6 +2757,7 @@ static int hns3_handle_bdinfo(struct hns3_enet_ring *ring, struct sk_buff *skb)
desc = &ring->desc[pre_ntc]; desc = &ring->desc[pre_ntc];
bd_base_info = le32_to_cpu(desc->rx.bd_base_info); bd_base_info = le32_to_cpu(desc->rx.bd_base_info);
l234info = le32_to_cpu(desc->rx.l234_info); l234info = le32_to_cpu(desc->rx.l234_info);
ol_info = le32_to_cpu(desc->rx.ol_info);
/* Based on hw strategy, the tag offloaded will be stored at /* Based on hw strategy, the tag offloaded will be stored at
* ot_vlan_tag in two layer tag case, and stored at vlan_tag * ot_vlan_tag in two layer tag case, and stored at vlan_tag
...@@ -2796,7 +2797,8 @@ static int hns3_handle_bdinfo(struct hns3_enet_ring *ring, struct sk_buff *skb) ...@@ -2796,7 +2797,8 @@ static int hns3_handle_bdinfo(struct hns3_enet_ring *ring, struct sk_buff *skb)
skb->protocol = eth_type_trans(skb, netdev); skb->protocol = eth_type_trans(skb, netdev);
/* This is needed in order to enable forwarding support */ /* This is needed in order to enable forwarding support */
ret = hns3_set_gro_and_checksum(ring, skb, l234info, bd_base_info); ret = hns3_set_gro_and_checksum(ring, skb, l234info,
bd_base_info, ol_info);
if (unlikely(ret)) { if (unlikely(ret)) {
u64_stats_update_begin(&ring->syncp); u64_stats_update_begin(&ring->syncp);
ring->stats.rx_err_cnt++; ring->stats.rx_err_cnt++;
......
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