summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorhayeswang <hayeswang@realtek.com>2014-03-06 22:04:38 -0500
committerVladislav Zhurba <vzhurba@nvidia.com>2018-02-01 16:58:00 -0500
commit2fdab93e71896e888891e87efc2048c7adda74ec (patch)
treebb4822bd916f91eb4345f1f0e326e6a77a295771
parentf239ad1f5df97cf5949b2b521702d394dd88a5b3 (diff)
r8152: support rx checksum
Support hw rx checksum for TCP and UDP packets. Change-Id: I3bb3cefe4d9dbd98996fa975256545f35f393eae Signed-off-by: Hayes Wang <hayeswang@realtek.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Aly Hirani <ahirani@nvidia.com> Reviewed-on: http://git-master/r/390296 (cherry picked from commit 930a7af20283f78e3f5e5e4c70615c84c1ee29f6) Reviewed-on: http://git-master/r/396898 Reviewed-by: Preetham Chandru <pchandru@nvidia.com> Tested-by: Preetham Chandru <pchandru@nvidia.com> Reviewed-by: Bitan Biswas <bbiswas@nvidia.com>
-rw-r--r--drivers/net/usb/r8152_shield.c41
1 files changed, 39 insertions, 2 deletions
diff --git a/drivers/net/usb/r8152_shield.c b/drivers/net/usb/r8152_shield.c
index 9c3ca4c38..571a2af3c 100644
--- a/drivers/net/usb/r8152_shield.c
+++ b/drivers/net/usb/r8152_shield.c
@@ -465,8 +465,17 @@ enum rtl8152_flags {
465struct rx_desc { 465struct rx_desc {
466 __le32 opts1; 466 __le32 opts1;
467#define RX_LEN_MASK 0x7fff 467#define RX_LEN_MASK 0x7fff
468
468 __le32 opts2; 469 __le32 opts2;
470#define RD_UDP_CS (1 << 23)
471#define RD_TCP_CS (1 << 22)
472#define RD_IPV4_CS (1 << 19)
473
469 __le32 opts3; 474 __le32 opts3;
475#define IPF (1 << 23) /* IP checksum fail */
476#define UDPF (1 << 22) /* UDP checksum fail */
477#define TCPF (1 << 21) /* TCP checksum fail */
478
470 __le32 opts4; 479 __le32 opts4;
471 __le32 opts5; 480 __le32 opts5;
472 __le32 opts6; 481 __le32 opts6;
@@ -1402,6 +1411,32 @@ out_tx_fill:
1402 return ret; 1411 return ret;
1403} 1412}
1404 1413
1414static u8 r8152_rx_csum(struct r8152 *tp, struct rx_desc *rx_desc)
1415{
1416 u8 checksum = CHECKSUM_NONE;
1417 u32 opts2, opts3;
1418
1419 if (tp->version == RTL_VER_01)
1420 goto return_result;
1421
1422 opts2 = le32_to_cpu(rx_desc->opts2);
1423 opts3 = le32_to_cpu(rx_desc->opts3);
1424
1425 if (opts2 & RD_IPV4_CS) {
1426 if (opts3 & IPF)
1427 checksum = CHECKSUM_NONE;
1428 else if ((opts2 & RD_UDP_CS) && (opts3 & UDPF))
1429 checksum = CHECKSUM_NONE;
1430 else if ((opts2 & RD_TCP_CS) && (opts3 & TCPF))
1431 checksum = CHECKSUM_NONE;
1432 else
1433 checksum = CHECKSUM_UNNECESSARY;
1434 }
1435
1436return_result:
1437 return checksum;
1438}
1439
1405static void rx_bottom(struct r8152 *tp) 1440static void rx_bottom(struct r8152 *tp)
1406{ 1441{
1407 unsigned long flags; 1442 unsigned long flags;
@@ -1456,6 +1491,8 @@ static void rx_bottom(struct r8152 *tp)
1456 stats->rx_dropped++; 1491 stats->rx_dropped++;
1457 goto find_next_rx; 1492 goto find_next_rx;
1458 } 1493 }
1494
1495 skb->ip_summed = r8152_rx_csum(tp, rx_desc);
1459 memcpy(skb->data, rx_data, pkt_len); 1496 memcpy(skb->data, rx_data, pkt_len);
1460 skb_put(skb, pkt_len); 1497 skb_put(skb, pkt_len);
1461 skb->protocol = eth_type_trans(skb, netdev); 1498 skb->protocol = eth_type_trans(skb, netdev);
@@ -3106,8 +3143,8 @@ static int rtl8152_probe(struct usb_interface *intf,
3106 netdev->netdev_ops = &rtl8152_netdev_ops; 3143 netdev->netdev_ops = &rtl8152_netdev_ops;
3107 netdev->watchdog_timeo = RTL8152_TX_TIMEOUT; 3144 netdev->watchdog_timeo = RTL8152_TX_TIMEOUT;
3108 3145
3109 netdev->features |= NETIF_F_IP_CSUM; 3146 netdev->features |= NETIF_F_RXCSUM | NETIF_F_IP_CSUM;
3110 netdev->hw_features = NETIF_F_IP_CSUM; 3147 netdev->hw_features = NETIF_F_RXCSUM | NETIF_F_IP_CSUM;
3111 3148
3112 SET_ETHTOOL_OPS(netdev, &ops); 3149 SET_ETHTOOL_OPS(netdev, &ops);
3113 3150