Skip to content

Commit 82cada2

Browse files
Paul Durrantdavem330
authored andcommitted
xen-netback: enable IPv6 TCP GSO to the guest
This patch adds code to handle SKB_GSO_TCPV6 skbs and construct appropriate extra or prefix segments to pass the large packet to the frontend. New xenstore flags, feature-gso-tcpv6 and feature-gso-tcpv6-prefix, are sampled to determine if the frontend is capable of handling such packets. Signed-off-by: Paul Durrant <paul.durrant@citrix.com> Cc: Wei Liu <wei.liu2@citrix.com> Cc: David Vrabel <david.vrabel@citrix.com> Cc: Ian Campbell <ian.campbell@citrix.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent a946858 commit 82cada2

5 files changed

Lines changed: 77 additions & 16 deletions

File tree

‎drivers/net/xen-netback/common.h‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,13 @@ struct pending_tx_info {
8787
struct xenvif_rx_meta {
8888
int id;
8989
int size;
90+
int gso_type;
9091
int gso_size;
9192
};
9293

94+
#define GSO_BIT(type) \
95+
(1 << XEN_NETIF_GSO_TYPE_ ## type)
96+
9397
/* Discriminate from any valid pending_idx value. */
9498
#define INVALID_PENDING_IDX 0xFFFF
9599

@@ -150,9 +154,10 @@ struct xenvif {
150154
u8 fe_dev_addr[6];
151155

152156
/* Frontend feature information. */
157+
int gso_mask;
158+
int gso_prefix_mask;
159+
153160
u8 can_sg:1;
154-
u8 gso:1;
155-
u8 gso_prefix:1;
156161
u8 ip_csum:1;
157162
u8 ipv6_csum:1;
158163

‎drivers/net/xen-netback/interface.c‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,10 @@ static netdev_features_t xenvif_fix_features(struct net_device *dev,
214214

215215
if (!vif->can_sg)
216216
features &= ~NETIF_F_SG;
217-
if (!vif->gso && !vif->gso_prefix)
217+
if (~(vif->gso_mask | vif->gso_prefix_mask) & GSO_BIT(TCPV4))
218218
features &= ~NETIF_F_TSO;
219+
if (~(vif->gso_mask | vif->gso_prefix_mask) & GSO_BIT(TCPV6))
220+
features &= ~NETIF_F_TSO6;
219221
if (!vif->ip_csum)
220222
features &= ~NETIF_F_IP_CSUM;
221223
if (!vif->ipv6_csum)
@@ -320,7 +322,7 @@ struct xenvif *xenvif_alloc(struct device *parent, domid_t domid,
320322
dev->netdev_ops = &xenvif_netdev_ops;
321323
dev->hw_features = NETIF_F_SG |
322324
NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM |
323-
NETIF_F_TSO;
325+
NETIF_F_TSO | NETIF_F_TSO6;
324326
dev->features = dev->hw_features | NETIF_F_RXCSUM;
325327
SET_ETHTOOL_OPS(dev, &xenvif_ethtool_ops);
326328

‎drivers/net/xen-netback/netback.c‎

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ static int max_required_rx_slots(struct xenvif *vif)
142142
int max = DIV_ROUND_UP(vif->dev->mtu, PAGE_SIZE);
143143

144144
/* XXX FIXME: RX path dependent on MAX_SKB_FRAGS */
145-
if (vif->can_sg || vif->gso || vif->gso_prefix)
145+
if (vif->can_sg || vif->gso_mask || vif->gso_prefix_mask)
146146
max += MAX_SKB_FRAGS + 1; /* extra_info + frags */
147147

148148
return max;
@@ -314,6 +314,7 @@ static struct xenvif_rx_meta *get_next_rx_buffer(struct xenvif *vif,
314314
req = RING_GET_REQUEST(&vif->rx, vif->rx.req_cons++);
315315

316316
meta = npo->meta + npo->meta_prod++;
317+
meta->gso_type = XEN_NETIF_GSO_TYPE_NONE;
317318
meta->gso_size = 0;
318319
meta->size = 0;
319320
meta->id = req->id;
@@ -336,6 +337,7 @@ static void xenvif_gop_frag_copy(struct xenvif *vif, struct sk_buff *skb,
336337
struct gnttab_copy *copy_gop;
337338
struct xenvif_rx_meta *meta;
338339
unsigned long bytes;
340+
int gso_type;
339341

340342
/* Data must not cross a page boundary. */
341343
BUG_ON(size + offset > PAGE_SIZE<<compound_order(page));
@@ -394,7 +396,14 @@ static void xenvif_gop_frag_copy(struct xenvif *vif, struct sk_buff *skb,
394396
}
395397

396398
/* Leave a gap for the GSO descriptor. */
397-
if (*head && skb_shinfo(skb)->gso_size && !vif->gso_prefix)
399+
if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV4)
400+
gso_type = XEN_NETIF_GSO_TYPE_TCPV4;
401+
else if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6)
402+
gso_type = XEN_NETIF_GSO_TYPE_TCPV6;
403+
else
404+
gso_type = XEN_NETIF_GSO_TYPE_NONE;
405+
406+
if (*head && ((1 << gso_type) & vif->gso_mask))
398407
vif->rx.req_cons++;
399408

400409
*head = 0; /* There must be something in this buffer now. */
@@ -425,25 +434,42 @@ static int xenvif_gop_skb(struct sk_buff *skb,
425434
unsigned char *data;
426435
int head = 1;
427436
int old_meta_prod;
437+
int gso_type;
438+
int gso_size;
428439

429440
old_meta_prod = npo->meta_prod;
430441

442+
if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV4) {
443+
gso_type = XEN_NETIF_GSO_TYPE_TCPV4;
444+
gso_size = skb_shinfo(skb)->gso_size;
445+
} else if (skb_shinfo(skb)->gso_type & SKB_GSO_TCPV6) {
446+
gso_type = XEN_NETIF_GSO_TYPE_TCPV6;
447+
gso_size = skb_shinfo(skb)->gso_size;
448+
} else {
449+
gso_type = XEN_NETIF_GSO_TYPE_NONE;
450+
gso_size = 0;
451+
}
452+
431453
/* Set up a GSO prefix descriptor, if necessary */
432-
if (skb_shinfo(skb)->gso_size && vif->gso_prefix) {
454+
if ((1 << skb_shinfo(skb)->gso_type) & vif->gso_prefix_mask) {
433455
req = RING_GET_REQUEST(&vif->rx, vif->rx.req_cons++);
434456
meta = npo->meta + npo->meta_prod++;
435-
meta->gso_size = skb_shinfo(skb)->gso_size;
457+
meta->gso_type = gso_type;
458+
meta->gso_size = gso_size;
436459
meta->size = 0;
437460
meta->id = req->id;
438461
}
439462

440463
req = RING_GET_REQUEST(&vif->rx, vif->rx.req_cons++);
441464
meta = npo->meta + npo->meta_prod++;
442465

443-
if (!vif->gso_prefix)
444-
meta->gso_size = skb_shinfo(skb)->gso_size;
445-
else
466+
if ((1 << gso_type) & vif->gso_mask) {
467+
meta->gso_type = gso_type;
468+
meta->gso_size = gso_size;
469+
} else {
470+
meta->gso_type = XEN_NETIF_GSO_TYPE_NONE;
446471
meta->gso_size = 0;
472+
}
447473

448474
meta->size = 0;
449475
meta->id = req->id;
@@ -589,7 +615,8 @@ void xenvif_rx_action(struct xenvif *vif)
589615

590616
vif = netdev_priv(skb->dev);
591617

592-
if (vif->meta[npo.meta_cons].gso_size && vif->gso_prefix) {
618+
if ((1 << vif->meta[npo.meta_cons].gso_type) &
619+
vif->gso_prefix_mask) {
593620
resp = RING_GET_RESPONSE(&vif->rx,
594621
vif->rx.rsp_prod_pvt++);
595622

@@ -626,16 +653,17 @@ void xenvif_rx_action(struct xenvif *vif)
626653
vif->meta[npo.meta_cons].size,
627654
flags);
628655

629-
if (vif->meta[npo.meta_cons].gso_size && !vif->gso_prefix) {
656+
if ((1 << vif->meta[npo.meta_cons].gso_type) &
657+
vif->gso_mask) {
630658
struct xen_netif_extra_info *gso =
631659
(struct xen_netif_extra_info *)
632660
RING_GET_RESPONSE(&vif->rx,
633661
vif->rx.rsp_prod_pvt++);
634662

635663
resp->flags |= XEN_NETRXF_extra_info;
636664

665+
gso->u.gso.type = vif->meta[npo.meta_cons].gso_type;
637666
gso->u.gso.size = vif->meta[npo.meta_cons].gso_size;
638-
gso->u.gso.type = XEN_NETIF_GSO_TYPE_TCPV4;
639667
gso->u.gso.pad = 0;
640668
gso->u.gso.features = 0;
641669

‎drivers/net/xen-netback/xenbus.c‎

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,15 +577,40 @@ static int connect_rings(struct backend_info *be)
577577
val = 0;
578578
vif->can_sg = !!val;
579579

580+
vif->gso_mask = 0;
581+
vif->gso_prefix_mask = 0;
582+
580583
if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-gso-tcpv4",
581584
"%d", &val) < 0)
582585
val = 0;
583-
vif->gso = !!val;
586+
if (val)
587+
vif->gso_mask |= GSO_BIT(TCPV4);
584588

585589
if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-gso-tcpv4-prefix",
586590
"%d", &val) < 0)
587591
val = 0;
588-
vif->gso_prefix = !!val;
592+
if (val)
593+
vif->gso_prefix_mask |= GSO_BIT(TCPV4);
594+
595+
if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-gso-tcpv6",
596+
"%d", &val) < 0)
597+
val = 0;
598+
if (val)
599+
vif->gso_mask |= GSO_BIT(TCPV6);
600+
601+
if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-gso-tcpv6-prefix",
602+
"%d", &val) < 0)
603+
val = 0;
604+
if (val)
605+
vif->gso_prefix_mask |= GSO_BIT(TCPV6);
606+
607+
if (vif->gso_mask & vif->gso_prefix_mask) {
608+
xenbus_dev_fatal(dev, err,
609+
"%s: gso and gso prefix flags are not "
610+
"mutually exclusive",
611+
dev->otherend);
612+
return -EOPNOTSUPP;
613+
}
589614

590615
if (xenbus_scanf(XBT_NIL, dev->otherend, "feature-no-csum-offload",
591616
"%d", &val) < 0)

‎include/xen/interface/io/netif.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ struct xen_netif_tx_request {
110110
#define XEN_NETIF_EXTRA_FLAG_MORE (1U<<_XEN_NETIF_EXTRA_FLAG_MORE)
111111

112112
/* GSO types */
113+
#define XEN_NETIF_GSO_TYPE_NONE (0)
113114
#define XEN_NETIF_GSO_TYPE_TCPV4 (1)
114115
#define XEN_NETIF_GSO_TYPE_TCPV6 (2)
115116

0 commit comments

Comments
 (0)