提交 565cab0a 编写于 作者: H hayeswang 提交者: David S. Miller

r8152: support rx checksum

Support hw rx checksum for TCP and UDP packets.
Signed-off-by: NHayes Wang <hayeswang@realtek.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 5e2f7485
...@@ -467,8 +467,17 @@ enum rtl8152_flags { ...@@ -467,8 +467,17 @@ enum rtl8152_flags {
struct rx_desc { struct rx_desc {
__le32 opts1; __le32 opts1;
#define RX_LEN_MASK 0x7fff #define RX_LEN_MASK 0x7fff
__le32 opts2; __le32 opts2;
#define RD_UDP_CS (1 << 23)
#define RD_TCP_CS (1 << 22)
#define RD_IPV4_CS (1 << 19)
__le32 opts3; __le32 opts3;
#define IPF (1 << 23) /* IP checksum fail */
#define UDPF (1 << 22) /* UDP checksum fail */
#define TCPF (1 << 21) /* TCP checksum fail */
__le32 opts4; __le32 opts4;
__le32 opts5; __le32 opts5;
__le32 opts6; __le32 opts6;
...@@ -1404,6 +1413,32 @@ static int r8152_tx_agg_fill(struct r8152 *tp, struct tx_agg *agg) ...@@ -1404,6 +1413,32 @@ static int r8152_tx_agg_fill(struct r8152 *tp, struct tx_agg *agg)
return ret; return ret;
} }
static u8 r8152_rx_csum(struct r8152 *tp, struct rx_desc *rx_desc)
{
u8 checksum = CHECKSUM_NONE;
u32 opts2, opts3;
if (tp->version == RTL_VER_01)
goto return_result;
opts2 = le32_to_cpu(rx_desc->opts2);
opts3 = le32_to_cpu(rx_desc->opts3);
if (opts2 & RD_IPV4_CS) {
if (opts3 & IPF)
checksum = CHECKSUM_NONE;
else if ((opts2 & RD_UDP_CS) && (opts3 & UDPF))
checksum = CHECKSUM_NONE;
else if ((opts2 & RD_TCP_CS) && (opts3 & TCPF))
checksum = CHECKSUM_NONE;
else
checksum = CHECKSUM_UNNECESSARY;
}
return_result:
return checksum;
}
static void rx_bottom(struct r8152 *tp) static void rx_bottom(struct r8152 *tp)
{ {
unsigned long flags; unsigned long flags;
...@@ -1458,6 +1493,8 @@ static void rx_bottom(struct r8152 *tp) ...@@ -1458,6 +1493,8 @@ static void rx_bottom(struct r8152 *tp)
stats->rx_dropped++; stats->rx_dropped++;
goto find_next_rx; goto find_next_rx;
} }
skb->ip_summed = r8152_rx_csum(tp, rx_desc);
memcpy(skb->data, rx_data, pkt_len); memcpy(skb->data, rx_data, pkt_len);
skb_put(skb, pkt_len); skb_put(skb, pkt_len);
skb->protocol = eth_type_trans(skb, netdev); skb->protocol = eth_type_trans(skb, netdev);
...@@ -3103,8 +3140,8 @@ static int rtl8152_probe(struct usb_interface *intf, ...@@ -3103,8 +3140,8 @@ static int rtl8152_probe(struct usb_interface *intf,
netdev->netdev_ops = &rtl8152_netdev_ops; netdev->netdev_ops = &rtl8152_netdev_ops;
netdev->watchdog_timeo = RTL8152_TX_TIMEOUT; netdev->watchdog_timeo = RTL8152_TX_TIMEOUT;
netdev->features |= NETIF_F_IP_CSUM; netdev->features |= NETIF_F_RXCSUM | NETIF_F_IP_CSUM;
netdev->hw_features = NETIF_F_IP_CSUM; netdev->hw_features = NETIF_F_RXCSUM | NETIF_F_IP_CSUM;
SET_ETHTOOL_OPS(netdev, &ops); SET_ETHTOOL_OPS(netdev, &ops);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册