]>
Commit | Line | Data |
---|---|---|
a7b0967d MT |
1 | From 59e0c70c618668522a9431686f7e3a69ef396dff Mon Sep 17 00:00:00 2001 |
2 | From: KY Srinivasan <kys@microsoft.com> | |
3 | Date: Sat, 8 Mar 2014 19:23:16 -0800 | |
4 | Subject: [PATCH 08/25] Drivers: net: hyperv: Enable receive side IP checksum | |
5 | offload | |
6 | ||
7 | Enable receive side checksum offload. | |
8 | ||
9 | Signed-off-by: K. Y. Srinivasan <kys@microsoft.com> | |
10 | Reviewed-by: Haiyang Zhang <haiyangz@microsoft.com> | |
11 | Signed-off-by: David S. Miller <davem@davemloft.net> | |
12 | --- | |
13 | drivers/net/hyperv/hyperv_net.h | 33 ++++++++++++++++++++++++++++++++- | |
14 | drivers/net/hyperv/netvsc_drv.c | 19 +++++++++++++++---- | |
15 | drivers/net/hyperv/rndis_filter.c | 4 +++- | |
16 | 3 files changed, 50 insertions(+), 6 deletions(-) | |
17 | ||
18 | diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h | |
19 | index 8bc4e766589b..faeb74623fbd 100644 | |
20 | --- a/drivers/net/hyperv/hyperv_net.h | |
21 | +++ b/drivers/net/hyperv/hyperv_net.h | |
22 | @@ -30,6 +30,7 @@ | |
23 | ||
24 | /* Fwd declaration */ | |
25 | struct hv_netvsc_packet; | |
26 | +struct ndis_tcp_ip_checksum_info; | |
27 | ||
28 | /* Represent the xfer page packet which contains 1 or more netvsc packet */ | |
29 | struct xferpage_packet { | |
30 | @@ -117,7 +118,8 @@ int netvsc_send(struct hv_device *device, | |
31 | void netvsc_linkstatus_callback(struct hv_device *device_obj, | |
32 | unsigned int status); | |
33 | int netvsc_recv_callback(struct hv_device *device_obj, | |
34 | - struct hv_netvsc_packet *packet); | |
35 | + struct hv_netvsc_packet *packet, | |
36 | + struct ndis_tcp_ip_checksum_info *csum_info); | |
37 | int rndis_filter_open(struct hv_device *dev); | |
38 | int rndis_filter_close(struct hv_device *dev); | |
39 | int rndis_filter_device_add(struct hv_device *dev, | |
40 | @@ -776,9 +778,38 @@ struct ndis_offload_params { | |
41 | }; | |
42 | }; | |
43 | ||
44 | +struct ndis_tcp_ip_checksum_info { | |
45 | + union { | |
46 | + struct { | |
47 | + u32 is_ipv4:1; | |
48 | + u32 is_ipv6:1; | |
49 | + u32 tcp_checksum:1; | |
50 | + u32 udp_checksum:1; | |
51 | + u32 ip_header_checksum:1; | |
52 | + u32 reserved:11; | |
53 | + u32 tcp_header_offset:10; | |
54 | + } transmit; | |
55 | + struct { | |
56 | + u32 tcp_checksum_failed:1; | |
57 | + u32 udp_checksum_failed:1; | |
58 | + u32 ip_checksum_failed:1; | |
59 | + u32 tcp_checksum_succeeded:1; | |
60 | + u32 udp_checksum_succeeded:1; | |
61 | + u32 ip_checksum_succeeded:1; | |
62 | + u32 loopback:1; | |
63 | + u32 tcp_checksum_value_invalid:1; | |
64 | + u32 ip_checksum_value_invalid:1; | |
65 | + } receive; | |
66 | + u32 value; | |
67 | + }; | |
68 | +}; | |
69 | + | |
70 | #define NDIS_VLAN_PPI_SIZE (sizeof(struct rndis_per_packet_info) + \ | |
71 | sizeof(struct ndis_pkt_8021q_info)) | |
72 | ||
73 | +#define NDIS_CSUM_PPI_SIZE (sizeof(struct rndis_per_packet_info) + \ | |
74 | + sizeof(struct ndis_tcp_ip_checksum_info)) | |
75 | + | |
76 | /* Format of Information buffer passed in a SetRequest for the OID */ | |
77 | /* OID_GEN_RNDIS_CONFIG_PARAMETER. */ | |
78 | struct rndis_config_parameter_info { | |
79 | diff --git a/drivers/net/hyperv/netvsc_drv.c b/drivers/net/hyperv/netvsc_drv.c | |
80 | index 87293a15e470..7438360b7a02 100644 | |
81 | --- a/drivers/net/hyperv/netvsc_drv.c | |
82 | +++ b/drivers/net/hyperv/netvsc_drv.c | |
83 | @@ -392,7 +392,8 @@ void netvsc_linkstatus_callback(struct hv_device *device_obj, | |
84 | * "wire" on the specified device. | |
85 | */ | |
86 | int netvsc_recv_callback(struct hv_device *device_obj, | |
87 | - struct hv_netvsc_packet *packet) | |
88 | + struct hv_netvsc_packet *packet, | |
89 | + struct ndis_tcp_ip_checksum_info *csum_info) | |
90 | { | |
91 | struct net_device *net; | |
92 | struct sk_buff *skb; | |
93 | @@ -419,7 +420,17 @@ int netvsc_recv_callback(struct hv_device *device_obj, | |
94 | packet->total_data_buflen); | |
95 | ||
96 | skb->protocol = eth_type_trans(skb, net); | |
97 | - skb->ip_summed = CHECKSUM_NONE; | |
98 | + if (csum_info) { | |
99 | + /* We only look at the IP checksum here. | |
100 | + * Should we be dropping the packet if checksum | |
101 | + * failed? How do we deal with other checksums - TCP/UDP? | |
102 | + */ | |
103 | + if (csum_info->receive.ip_checksum_succeeded) | |
104 | + skb->ip_summed = CHECKSUM_UNNECESSARY; | |
105 | + else | |
106 | + skb->ip_summed = CHECKSUM_NONE; | |
107 | + } | |
108 | + | |
109 | if (packet->vlan_tci & VLAN_TAG_PRESENT) | |
110 | __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), | |
111 | packet->vlan_tci); | |
112 | @@ -581,8 +592,8 @@ static int netvsc_probe(struct hv_device *dev, | |
113 | net->netdev_ops = &device_ops; | |
114 | ||
115 | /* TODO: Add GSO and Checksum offload */ | |
116 | - net->hw_features = NETIF_F_SG; | |
117 | - net->features = NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_SG; | |
118 | + net->hw_features = NETIF_F_RXCSUM | NETIF_F_SG; | |
119 | + net->features = NETIF_F_HW_VLAN_CTAG_TX | NETIF_F_SG | NETIF_F_RXCSUM; | |
120 | ||
121 | SET_ETHTOOL_OPS(net, ðtool_ops); | |
122 | SET_NETDEV_DEV(net, &dev->device); | |
123 | diff --git a/drivers/net/hyperv/rndis_filter.c b/drivers/net/hyperv/rndis_filter.c | |
124 | index 9b02f21097a7..4a37e3db9e32 100644 | |
125 | --- a/drivers/net/hyperv/rndis_filter.c | |
126 | +++ b/drivers/net/hyperv/rndis_filter.c | |
127 | @@ -370,6 +370,7 @@ static void rndis_filter_receive_data(struct rndis_device *dev, | |
128 | struct rndis_packet *rndis_pkt; | |
129 | u32 data_offset; | |
130 | struct ndis_pkt_8021q_info *vlan; | |
131 | + struct ndis_tcp_ip_checksum_info *csum_info; | |
132 | ||
133 | rndis_pkt = &msg->msg.pkt; | |
134 | ||
135 | @@ -408,7 +409,8 @@ static void rndis_filter_receive_data(struct rndis_device *dev, | |
136 | pkt->vlan_tci = 0; | |
137 | } | |
138 | ||
139 | - netvsc_recv_callback(dev->net_dev->dev, pkt); | |
140 | + csum_info = rndis_get_ppi(rndis_pkt, TCPIP_CHKSUM_PKTINFO); | |
141 | + netvsc_recv_callback(dev->net_dev->dev, pkt, csum_info); | |
142 | } | |
143 | ||
144 | int rndis_filter_receive(struct hv_device *dev, | |
145 | -- | |
146 | 2.4.3 | |
147 |