@@ -3252,20 +3252,20 @@ static int hns3_gro_complete(struct sk_buff *skb, u32 l234info)
3252
3252
return 0 ;
3253
3253
}
3254
3254
3255
- static void hns3_checksum_complete (struct hns3_enet_ring * ring ,
3256
- struct sk_buff * skb , u32 l234info )
3255
+ static bool hns3_checksum_complete (struct hns3_enet_ring * ring ,
3256
+ struct sk_buff * skb , u32 ptype , u16 csum )
3257
3257
{
3258
- u32 lo , hi ;
3258
+ if (ptype == HNS3_INVALID_PTYPE ||
3259
+ hns3_rx_ptype_tbl [ptype ].ip_summed != CHECKSUM_COMPLETE )
3260
+ return false;
3259
3261
3260
3262
u64_stats_update_begin (& ring -> syncp );
3261
3263
ring -> stats .csum_complete ++ ;
3262
3264
u64_stats_update_end (& ring -> syncp );
3263
3265
skb -> ip_summed = CHECKSUM_COMPLETE ;
3264
- lo = hnae3_get_field (l234info , HNS3_RXD_L2_CSUM_L_M ,
3265
- HNS3_RXD_L2_CSUM_L_S );
3266
- hi = hnae3_get_field (l234info , HNS3_RXD_L2_CSUM_H_M ,
3267
- HNS3_RXD_L2_CSUM_H_S );
3268
- skb -> csum = csum_unfold ((__force __sum16 )(lo | hi << 8 ));
3266
+ skb -> csum = csum_unfold ((__force __sum16 )csum );
3267
+
3268
+ return true;
3269
3269
}
3270
3270
3271
3271
static void hns3_rx_handle_csum (struct sk_buff * skb , u32 l234info ,
@@ -3307,7 +3307,8 @@ static void hns3_rx_handle_csum(struct sk_buff *skb, u32 l234info,
3307
3307
}
3308
3308
3309
3309
static void hns3_rx_checksum (struct hns3_enet_ring * ring , struct sk_buff * skb ,
3310
- u32 l234info , u32 bd_base_info , u32 ol_info )
3310
+ u32 l234info , u32 bd_base_info , u32 ol_info ,
3311
+ u16 csum )
3311
3312
{
3312
3313
struct net_device * netdev = ring_to_netdev (ring );
3313
3314
struct hns3_nic_priv * priv = netdev_priv (netdev );
@@ -3324,10 +3325,8 @@ static void hns3_rx_checksum(struct hns3_enet_ring *ring, struct sk_buff *skb,
3324
3325
ptype = hnae3_get_field (ol_info , HNS3_RXD_PTYPE_M ,
3325
3326
HNS3_RXD_PTYPE_S );
3326
3327
3327
- if (l234info & BIT (HNS3_RXD_L2_CSUM_B )) {
3328
- hns3_checksum_complete (ring , skb , l234info );
3328
+ if (hns3_checksum_complete (ring , skb , ptype , csum ))
3329
3329
return ;
3330
- }
3331
3330
3332
3331
/* check if hardware has done checksum */
3333
3332
if (!(bd_base_info & BIT (HNS3_RXD_L3L4P_B )))
@@ -3527,7 +3526,7 @@ static int hns3_add_frag(struct hns3_enet_ring *ring)
3527
3526
3528
3527
static int hns3_set_gro_and_checksum (struct hns3_enet_ring * ring ,
3529
3528
struct sk_buff * skb , u32 l234info ,
3530
- u32 bd_base_info , u32 ol_info )
3529
+ u32 bd_base_info , u32 ol_info , u16 csum )
3531
3530
{
3532
3531
struct net_device * netdev = ring_to_netdev (ring );
3533
3532
struct hns3_nic_priv * priv = netdev_priv (netdev );
@@ -3538,7 +3537,8 @@ static int hns3_set_gro_and_checksum(struct hns3_enet_ring *ring,
3538
3537
HNS3_RXD_GRO_SIZE_S );
3539
3538
/* if there is no HW GRO, do not set gro params */
3540
3539
if (!skb_shinfo (skb )-> gso_size ) {
3541
- hns3_rx_checksum (ring , skb , l234info , bd_base_info , ol_info );
3540
+ hns3_rx_checksum (ring , skb , l234info , bd_base_info , ol_info ,
3541
+ csum );
3542
3542
return 0 ;
3543
3543
}
3544
3544
@@ -3588,6 +3588,7 @@ static int hns3_handle_bdinfo(struct hns3_enet_ring *ring, struct sk_buff *skb)
3588
3588
struct hns3_desc * desc ;
3589
3589
unsigned int len ;
3590
3590
int pre_ntc , ret ;
3591
+ u16 csum ;
3591
3592
3592
3593
/* bdinfo handled below is only valid on the last BD of the
3593
3594
* current packet, and ring->next_to_clean indicates the first
@@ -3599,6 +3600,7 @@ static int hns3_handle_bdinfo(struct hns3_enet_ring *ring, struct sk_buff *skb)
3599
3600
bd_base_info = le32_to_cpu (desc -> rx .bd_base_info );
3600
3601
l234info = le32_to_cpu (desc -> rx .l234_info );
3601
3602
ol_info = le32_to_cpu (desc -> rx .ol_info );
3603
+ csum = le16_to_cpu (desc -> csum );
3602
3604
3603
3605
/* Based on hw strategy, the tag offloaded will be stored at
3604
3606
* ot_vlan_tag in two layer tag case, and stored at vlan_tag
@@ -3631,7 +3633,7 @@ static int hns3_handle_bdinfo(struct hns3_enet_ring *ring, struct sk_buff *skb)
3631
3633
3632
3634
/* This is needed in order to enable forwarding support */
3633
3635
ret = hns3_set_gro_and_checksum (ring , skb , l234info ,
3634
- bd_base_info , ol_info );
3636
+ bd_base_info , ol_info , csum );
3635
3637
if (unlikely (ret )) {
3636
3638
u64_stats_update_begin (& ring -> syncp );
3637
3639
ring -> stats .rx_err_cnt ++ ;
0 commit comments