@@ -572,6 +572,26 @@ static void ftgmac100_tx_complete(struct ftgmac100 *priv)
572
572
}
573
573
}
574
574
575
+ static bool ftgmac100_prep_tx_csum (struct sk_buff * skb , u32 * csum_vlan )
576
+ {
577
+ if (skb -> protocol == cpu_to_be16 (ETH_P_IP )) {
578
+ u8 ip_proto = ip_hdr (skb )-> protocol ;
579
+
580
+ * csum_vlan |= FTGMAC100_TXDES1_IP_CHKSUM ;
581
+ switch (ip_proto ) {
582
+ case IPPROTO_TCP :
583
+ * csum_vlan |= FTGMAC100_TXDES1_TCP_CHKSUM ;
584
+ return true;
585
+ case IPPROTO_UDP :
586
+ * csum_vlan |= FTGMAC100_TXDES1_UDP_CHKSUM ;
587
+ return true;
588
+ case IPPROTO_IP :
589
+ return true;
590
+ }
591
+ }
592
+ return skb_checksum_help (skb ) == 0 ;
593
+ }
594
+
575
595
static int ftgmac100_hard_start_xmit (struct sk_buff * skb ,
576
596
struct net_device * netdev )
577
597
{
@@ -628,19 +648,9 @@ static int ftgmac100_hard_start_xmit(struct sk_buff *skb,
628
648
629
649
/* Setup HW checksumming */
630
650
csum_vlan = 0 ;
631
- if (skb -> ip_summed == CHECKSUM_PARTIAL ) {
632
- __be16 protocol = skb -> protocol ;
633
-
634
- if (protocol == cpu_to_be16 (ETH_P_IP )) {
635
- u8 ip_proto = ip_hdr (skb )-> protocol ;
636
-
637
- csum_vlan |= FTGMAC100_TXDES1_IP_CHKSUM ;
638
- if (ip_proto == IPPROTO_TCP )
639
- csum_vlan |= FTGMAC100_TXDES1_TCP_CHKSUM ;
640
- else if (ip_proto == IPPROTO_UDP )
641
- csum_vlan |= FTGMAC100_TXDES1_UDP_CHKSUM ;
642
- }
643
- }
651
+ if (skb -> ip_summed == CHECKSUM_PARTIAL &&
652
+ !ftgmac100_prep_tx_csum (skb , & csum_vlan ))
653
+ goto drop ;
644
654
txdes -> txdes1 = cpu_to_le32 (csum_vlan );
645
655
646
656
/* Next descriptor */
@@ -1465,11 +1475,11 @@ static int ftgmac100_probe(struct platform_device *pdev)
1465
1475
* when NCSI is enabled on the interface. It doesn't work
1466
1476
* in that case.
1467
1477
*/
1468
- netdev -> features = NETIF_F_RXCSUM | NETIF_F_IP_CSUM |
1478
+ netdev -> features = NETIF_F_RXCSUM | NETIF_F_HW_CSUM |
1469
1479
NETIF_F_GRO | NETIF_F_SG ;
1470
1480
if (priv -> use_ncsi &&
1471
1481
of_get_property (pdev -> dev .of_node , "no-hw-checksum" , NULL ))
1472
- netdev -> features &= ~NETIF_F_IP_CSUM ;
1482
+ netdev -> features &= ~NETIF_F_HW_CSUM ;
1473
1483
1474
1484
/* register network device */
1475
1485
err = register_netdev (netdev );
0 commit comments