@@ -406,113 +406,13 @@ netdev_tx_t hns_nic_net_xmit_hw(struct net_device *ndev,
406
406
return NETDEV_TX_BUSY ;
407
407
}
408
408
409
- /**
410
- * hns_nic_get_headlen - determine size of header for RSC/LRO/GRO/FCOE
411
- * @data: pointer to the start of the headers
412
- * @max: total length of section to find headers in
413
- *
414
- * This function is meant to determine the length of headers that will
415
- * be recognized by hardware for LRO, GRO, and RSC offloads. The main
416
- * motivation of doing this is to only perform one pull for IPv4 TCP
417
- * packets so that we can do basic things like calculating the gso_size
418
- * based on the average data per packet.
419
- **/
420
- static unsigned int hns_nic_get_headlen (unsigned char * data , u32 flag ,
421
- unsigned int max_size )
422
- {
423
- unsigned char * network ;
424
- u8 hlen ;
425
-
426
- /* this should never happen, but better safe than sorry */
427
- if (max_size < ETH_HLEN )
428
- return max_size ;
429
-
430
- /* initialize network frame pointer */
431
- network = data ;
432
-
433
- /* set first protocol and move network header forward */
434
- network += ETH_HLEN ;
435
-
436
- /* handle any vlan tag if present */
437
- if (hnae_get_field (flag , HNS_RXD_VLAN_M , HNS_RXD_VLAN_S )
438
- == HNS_RX_FLAG_VLAN_PRESENT ) {
439
- if ((typeof (max_size ))(network - data ) > (max_size - VLAN_HLEN ))
440
- return max_size ;
441
-
442
- network += VLAN_HLEN ;
443
- }
444
-
445
- /* handle L3 protocols */
446
- if (hnae_get_field (flag , HNS_RXD_L3ID_M , HNS_RXD_L3ID_S )
447
- == HNS_RX_FLAG_L3ID_IPV4 ) {
448
- if ((typeof (max_size ))(network - data ) >
449
- (max_size - sizeof (struct iphdr )))
450
- return max_size ;
451
-
452
- /* access ihl as a u8 to avoid unaligned access on ia64 */
453
- hlen = (network [0 ] & 0x0F ) << 2 ;
454
-
455
- /* verify hlen meets minimum size requirements */
456
- if (hlen < sizeof (struct iphdr ))
457
- return network - data ;
458
-
459
- /* record next protocol if header is present */
460
- } else if (hnae_get_field (flag , HNS_RXD_L3ID_M , HNS_RXD_L3ID_S )
461
- == HNS_RX_FLAG_L3ID_IPV6 ) {
462
- if ((typeof (max_size ))(network - data ) >
463
- (max_size - sizeof (struct ipv6hdr )))
464
- return max_size ;
465
-
466
- /* record next protocol */
467
- hlen = sizeof (struct ipv6hdr );
468
- } else {
469
- return network - data ;
470
- }
471
-
472
- /* relocate pointer to start of L4 header */
473
- network += hlen ;
474
-
475
- /* finally sort out TCP/UDP */
476
- if (hnae_get_field (flag , HNS_RXD_L4ID_M , HNS_RXD_L4ID_S )
477
- == HNS_RX_FLAG_L4ID_TCP ) {
478
- if ((typeof (max_size ))(network - data ) >
479
- (max_size - sizeof (struct tcphdr )))
480
- return max_size ;
481
-
482
- /* access doff as a u8 to avoid unaligned access on ia64 */
483
- hlen = (network [12 ] & 0xF0 ) >> 2 ;
484
-
485
- /* verify hlen meets minimum size requirements */
486
- if (hlen < sizeof (struct tcphdr ))
487
- return network - data ;
488
-
489
- network += hlen ;
490
- } else if (hnae_get_field (flag , HNS_RXD_L4ID_M , HNS_RXD_L4ID_S )
491
- == HNS_RX_FLAG_L4ID_UDP ) {
492
- if ((typeof (max_size ))(network - data ) >
493
- (max_size - sizeof (struct udphdr )))
494
- return max_size ;
495
-
496
- network += sizeof (struct udphdr );
497
- }
498
-
499
- /* If everything has gone correctly network should be the
500
- * data section of the packet and will be the end of the header.
501
- * If not then it probably represents the end of the last recognized
502
- * header.
503
- */
504
- if ((typeof (max_size ))(network - data ) < max_size )
505
- return network - data ;
506
- else
507
- return max_size ;
508
- }
509
-
510
409
static void hns_nic_reuse_page (struct sk_buff * skb , int i ,
511
410
struct hnae_ring * ring , int pull_len ,
512
411
struct hnae_desc_cb * desc_cb )
513
412
{
514
413
struct hnae_desc * desc ;
515
- int truesize , size ;
414
+ u32 truesize ;
415
+ int size ;
516
416
int last_offset ;
517
417
bool twobufs ;
518
418
@@ -530,7 +430,7 @@ static void hns_nic_reuse_page(struct sk_buff *skb, int i,
530
430
}
531
431
532
432
skb_add_rx_frag (skb , i , desc_cb -> priv , desc_cb -> page_offset + pull_len ,
533
- size - pull_len , truesize - pull_len );
433
+ size - pull_len , truesize );
534
434
535
435
/* avoid re-using remote pages,flag default unreuse */
536
436
if (unlikely (page_to_nid (desc_cb -> priv ) != numa_node_id ()))
@@ -695,7 +595,7 @@ static int hns_nic_poll_rx_skb(struct hns_nic_ring_data *ring_data,
695
595
} else {
696
596
ring -> stats .seg_pkt_cnt ++ ;
697
597
698
- pull_len = hns_nic_get_headlen (va , bnum_flag , HNS_RX_HEAD_SIZE );
598
+ pull_len = eth_get_headlen (va , HNS_RX_HEAD_SIZE );
699
599
memcpy (__skb_put (skb , pull_len ), va ,
700
600
ALIGN (pull_len , sizeof (long )));
701
601
0 commit comments