aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/ethernet/ibm
diff options
context:
space:
mode:
authorThomas Falcon <tlfalcon@linux.vnet.ibm.com>2016-12-08 17:40:03 -0500
committerDavid S. Miller <davem@davemloft.net>2016-12-09 22:47:22 -0500
commit7b5967389f5a8dfb9d32843830f5e2717e20995d (patch)
treec87b44a7b13809b0db95357639f25a47e5ac8707 /drivers/net/ethernet/ibm
parent1472d599a8d30429bf322fdc53bae3bec382308d (diff)
ibmveth: set correct gso_size and gso_type
This patch is based on an earlier one submitted by Jon Maxwell with the following commit message: "We recently encountered a bug where a few customers using ibmveth on the same LPAR hit an issue where a TCP session hung when large receive was enabled. Closer analysis revealed that the session was stuck because the one side was advertising a zero window repeatedly. We narrowed this down to the fact the ibmveth driver did not set gso_size which is translated by TCP into the MSS later up the stack. The MSS is used to calculate the TCP window size and as that was abnormally large, it was calculating a zero window, even although the sockets receive buffer was completely empty." We rely on the Virtual I/O Server partition in a pseries environment to provide the MSS through the TCP header checksum field. The stipulation is that users should not disable checksum offloading if rx packet aggregation is enabled through VIOS. Some firmware offerings provide the MSS in the RX buffer. This is signalled by a bit in the RX queue descriptor. Reviewed-by: Brian King <brking@linux.vnet.ibm.com> Reviewed-by: Pradeep Satyanarayana <pradeeps@linux.vnet.ibm.com> Reviewed-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com> Reviewed-by: Jonathan Maxwell <jmaxwell37@gmail.com> Reviewed-by: David Dai <zdai@us.ibm.com> Signed-off-by: Thomas Falcon <tlfalcon@linux.vnet.ibm.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/ibm')
-rw-r--r--drivers/net/ethernet/ibm/ibmveth.c65
-rw-r--r--drivers/net/ethernet/ibm/ibmveth.h1
2 files changed, 64 insertions, 2 deletions
diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c
index ebe60719e489..a36022ba4e42 100644
--- a/drivers/net/ethernet/ibm/ibmveth.c
+++ b/drivers/net/ethernet/ibm/ibmveth.c
@@ -58,7 +58,7 @@ static struct kobj_type ktype_veth_pool;
58 58
59static const char ibmveth_driver_name[] = "ibmveth"; 59static const char ibmveth_driver_name[] = "ibmveth";
60static const char ibmveth_driver_string[] = "IBM Power Virtual Ethernet Driver"; 60static const char ibmveth_driver_string[] = "IBM Power Virtual Ethernet Driver";
61#define ibmveth_driver_version "1.05" 61#define ibmveth_driver_version "1.06"
62 62
63MODULE_AUTHOR("Santiago Leon <santil@linux.vnet.ibm.com>"); 63MODULE_AUTHOR("Santiago Leon <santil@linux.vnet.ibm.com>");
64MODULE_DESCRIPTION("IBM Power Virtual Ethernet Driver"); 64MODULE_DESCRIPTION("IBM Power Virtual Ethernet Driver");
@@ -137,6 +137,11 @@ static inline int ibmveth_rxq_frame_offset(struct ibmveth_adapter *adapter)
137 return ibmveth_rxq_flags(adapter) & IBMVETH_RXQ_OFF_MASK; 137 return ibmveth_rxq_flags(adapter) & IBMVETH_RXQ_OFF_MASK;
138} 138}
139 139
140static inline int ibmveth_rxq_large_packet(struct ibmveth_adapter *adapter)
141{
142 return ibmveth_rxq_flags(adapter) & IBMVETH_RXQ_LRG_PKT;
143}
144
140static inline int ibmveth_rxq_frame_length(struct ibmveth_adapter *adapter) 145static inline int ibmveth_rxq_frame_length(struct ibmveth_adapter *adapter)
141{ 146{
142 return be32_to_cpu(adapter->rx_queue.queue_addr[adapter->rx_queue.index].length); 147 return be32_to_cpu(adapter->rx_queue.queue_addr[adapter->rx_queue.index].length);
@@ -1174,6 +1179,45 @@ map_failed:
1174 goto retry_bounce; 1179 goto retry_bounce;
1175} 1180}
1176 1181
1182static void ibmveth_rx_mss_helper(struct sk_buff *skb, u16 mss, int lrg_pkt)
1183{
1184 int offset = 0;
1185
1186 /* only TCP packets will be aggregated */
1187 if (skb->protocol == htons(ETH_P_IP)) {
1188 struct iphdr *iph = (struct iphdr *)skb->data;
1189
1190 if (iph->protocol == IPPROTO_TCP) {
1191 offset = iph->ihl * 4;
1192 skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4;
1193 } else {
1194 return;
1195 }
1196 } else if (skb->protocol == htons(ETH_P_IPV6)) {
1197 struct ipv6hdr *iph6 = (struct ipv6hdr *)skb->data;
1198
1199 if (iph6->nexthdr == IPPROTO_TCP) {
1200 offset = sizeof(struct ipv6hdr);
1201 skb_shinfo(skb)->gso_type = SKB_GSO_TCPV6;
1202 } else {
1203 return;
1204 }
1205 } else {
1206 return;
1207 }
1208 /* if mss is not set through Large Packet bit/mss in rx buffer,
1209 * expect that the mss will be written to the tcp header checksum.
1210 */
1211 if (lrg_pkt) {
1212 skb_shinfo(skb)->gso_size = mss;
1213 } else if (offset) {
1214 struct tcphdr *tcph = (struct tcphdr *)(skb->data + offset);
1215
1216 skb_shinfo(skb)->gso_size = ntohs(tcph->check);
1217 tcph->check = 0;
1218 }
1219}
1220
1177static int ibmveth_poll(struct napi_struct *napi, int budget) 1221static int ibmveth_poll(struct napi_struct *napi, int budget)
1178{ 1222{
1179 struct ibmveth_adapter *adapter = 1223 struct ibmveth_adapter *adapter =
@@ -1182,6 +1226,7 @@ static int ibmveth_poll(struct napi_struct *napi, int budget)
1182 int frames_processed = 0; 1226 int frames_processed = 0;
1183 unsigned long lpar_rc; 1227 unsigned long lpar_rc;
1184 struct iphdr *iph; 1228 struct iphdr *iph;
1229 u16 mss = 0;
1185 1230
1186restart_poll: 1231restart_poll:
1187 while (frames_processed < budget) { 1232 while (frames_processed < budget) {
@@ -1199,9 +1244,21 @@ restart_poll:
1199 int length = ibmveth_rxq_frame_length(adapter); 1244 int length = ibmveth_rxq_frame_length(adapter);
1200 int offset = ibmveth_rxq_frame_offset(adapter); 1245 int offset = ibmveth_rxq_frame_offset(adapter);
1201 int csum_good = ibmveth_rxq_csum_good(adapter); 1246 int csum_good = ibmveth_rxq_csum_good(adapter);
1247 int lrg_pkt = ibmveth_rxq_large_packet(adapter);
1202 1248
1203 skb = ibmveth_rxq_get_buffer(adapter); 1249 skb = ibmveth_rxq_get_buffer(adapter);
1204 1250
1251 /* if the large packet bit is set in the rx queue
1252 * descriptor, the mss will be written by PHYP eight
1253 * bytes from the start of the rx buffer, which is
1254 * skb->data at this stage
1255 */
1256 if (lrg_pkt) {
1257 __be64 *rxmss = (__be64 *)(skb->data + 8);
1258
1259 mss = (u16)be64_to_cpu(*rxmss);
1260 }
1261
1205 new_skb = NULL; 1262 new_skb = NULL;
1206 if (length < rx_copybreak) 1263 if (length < rx_copybreak)
1207 new_skb = netdev_alloc_skb(netdev, length); 1264 new_skb = netdev_alloc_skb(netdev, length);
@@ -1235,11 +1292,15 @@ restart_poll:
1235 if (iph->check == 0xffff) { 1292 if (iph->check == 0xffff) {
1236 iph->check = 0; 1293 iph->check = 0;
1237 iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl); 1294 iph->check = ip_fast_csum((unsigned char *)iph, iph->ihl);
1238 adapter->rx_large_packets++;
1239 } 1295 }
1240 } 1296 }
1241 } 1297 }
1242 1298
1299 if (length > netdev->mtu + ETH_HLEN) {
1300 ibmveth_rx_mss_helper(skb, mss, lrg_pkt);
1301 adapter->rx_large_packets++;
1302 }
1303
1243 napi_gro_receive(napi, skb); /* send it up */ 1304 napi_gro_receive(napi, skb); /* send it up */
1244 1305
1245 netdev->stats.rx_packets++; 1306 netdev->stats.rx_packets++;
diff --git a/drivers/net/ethernet/ibm/ibmveth.h b/drivers/net/ethernet/ibm/ibmveth.h
index 4eade67fe30c..7acda04d034e 100644
--- a/drivers/net/ethernet/ibm/ibmveth.h
+++ b/drivers/net/ethernet/ibm/ibmveth.h
@@ -209,6 +209,7 @@ struct ibmveth_rx_q_entry {
209#define IBMVETH_RXQ_TOGGLE 0x80000000 209#define IBMVETH_RXQ_TOGGLE 0x80000000
210#define IBMVETH_RXQ_TOGGLE_SHIFT 31 210#define IBMVETH_RXQ_TOGGLE_SHIFT 31
211#define IBMVETH_RXQ_VALID 0x40000000 211#define IBMVETH_RXQ_VALID 0x40000000
212#define IBMVETH_RXQ_LRG_PKT 0x04000000
212#define IBMVETH_RXQ_NO_CSUM 0x02000000 213#define IBMVETH_RXQ_NO_CSUM 0x02000000
213#define IBMVETH_RXQ_CSUM_GOOD 0x01000000 214#define IBMVETH_RXQ_CSUM_GOOD 0x01000000
214#define IBMVETH_RXQ_OFF_MASK 0x0000FFFF 215#define IBMVETH_RXQ_OFF_MASK 0x0000FFFF