Skip to content

Commit 05690d6

Browse files
ozbenhdavem330
authored andcommitted
ftgmac100: Upgrade to NETIF_F_HW_CSUM
The documentation describes NETIF_F_IP_CSUM as deprecated so let's switch to NETIF_F_HW_CSUM and use the helper to handle unhandled protocols. Signed-off-by: Benjamin Herrenschmidt <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f221dcd commit 05690d6

File tree

1 file changed

+25
-15
lines changed

1 file changed

+25
-15
lines changed

drivers/net/ethernet/faraday/ftgmac100.c

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,26 @@ static void ftgmac100_tx_complete(struct ftgmac100 *priv)
572572
}
573573
}
574574

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+
575595
static int ftgmac100_hard_start_xmit(struct sk_buff *skb,
576596
struct net_device *netdev)
577597
{
@@ -628,19 +648,9 @@ static int ftgmac100_hard_start_xmit(struct sk_buff *skb,
628648

629649
/* Setup HW checksumming */
630650
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;
644654
txdes->txdes1 = cpu_to_le32(csum_vlan);
645655

646656
/* Next descriptor */
@@ -1465,11 +1475,11 @@ static int ftgmac100_probe(struct platform_device *pdev)
14651475
* when NCSI is enabled on the interface. It doesn't work
14661476
* in that case.
14671477
*/
1468-
netdev->features = NETIF_F_RXCSUM | NETIF_F_IP_CSUM |
1478+
netdev->features = NETIF_F_RXCSUM | NETIF_F_HW_CSUM |
14691479
NETIF_F_GRO | NETIF_F_SG;
14701480
if (priv->use_ncsi &&
14711481
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;
14731483

14741484
/* register network device */
14751485
err = register_netdev(netdev);

0 commit comments

Comments
 (0)