WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] [NET] front: Add TSO support

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] [NET] front: Add TSO support
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 01 Aug 2006 19:20:19 +0000
Delivery-date: Tue, 01 Aug 2006 12:23:25 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Node ID 485616ab73e380e11791fd43d1d90133fff8c8a0
# Parent  9f29252c23b6166b6327d65a32f16e85504636d1
[NET] front: Add TSO support

This patch adds TCP Segmentation Offload (TSO) support to the
frontend.
It also advertises this fact through xenbus so that the frontend can
detect this and send through TSO requests only if it is supported.

This is done using an extra request slot which is indicated by a flag
in the first slot.  In future checksum offload can be done in the same
way.

Even though only TSO is supported for now the code actually supports
GSO so it can be applied to any other protocol.  The only missing bit
is the detection of host support for a specific GSO protocol.  Once
that is added we can advertise all supported protocols to the guest.

Signed-off-by: Herbert Xu <herbert@xxxxxxxxxxxxxxxxxxx>

Disable for now, as in domU->dom0 direction.

Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c |  109 ++++++++++++++++++-
 xen/include/public/io/netif.h                        |    4 
 2 files changed, 108 insertions(+), 5 deletions(-)

diff -r 9f29252c23b6 -r 485616ab73e3 
linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c
--- a/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c      Mon Jul 31 
17:42:13 2006 +0100
+++ b/linux-2.6-xen-sparse/drivers/xen/netfront/netfront.c      Mon Jul 31 
17:45:22 2006 +0100
@@ -116,6 +116,11 @@ struct netfront_info {
        struct mmu_update rx_mmu[NET_RX_RING_SIZE];
 };
 
+struct netfront_rx_info {
+       struct netif_rx_response rx;
+       struct netif_extra_info extras[XEN_NETIF_EXTRA_TYPE_MAX - 1];
+};
+
 /*
  * Access macros for acquiring freeing slots in tx_skbs[].
  */
@@ -332,6 +337,14 @@ again:
                message = "writing feature-sg";
                goto abort_transaction;
        }
+
+#if 0 /* KAF: After the protocol is finalised. */
+       err = xenbus_printf(xbt, dev->nodename, "feature-gso-tcpv4", "%d", 1);
+       if (err) {
+               message = "writing feature-gso-tcpv4";
+               goto abort_transaction;
+       }
+#endif
 
        err = xenbus_transaction_end(xbt, 0);
        if (err) {
@@ -899,18 +912,65 @@ static void xennet_move_rx_slot(struct n
        np->rx.req_prod_pvt++;
 }
 
+int xennet_get_extras(struct netfront_info *np,
+                     struct netif_extra_info *extras, RING_IDX rp)
+
+{
+       struct netif_extra_info *extra;
+       RING_IDX cons = np->rx.rsp_cons;
+       int err = 0;
+
+       do {
+               struct sk_buff *skb;
+               grant_ref_t ref;
+
+               if (unlikely(cons + 1 == rp)) {
+                       if (net_ratelimit())
+                               WPRINTK("Missing extra info\n");
+                       err = -EBADR;
+                       break;
+               }
+
+               extra = (struct netif_extra_info *)
+                       RING_GET_RESPONSE(&np->rx, ++cons);
+
+               if (unlikely(!extra->type ||
+                            extra->type >= XEN_NETIF_EXTRA_TYPE_MAX)) {
+                       if (net_ratelimit())
+                               WPRINTK("Invalid extra type: %d\n",
+                                       extra->type);
+                       err = -EINVAL;
+               } else
+                       memcpy(&extras[extra->type - 1], extra, sizeof(*extra));
+
+               skb = xennet_get_rx_skb(np, cons);
+               ref = xennet_get_rx_ref(np, cons);
+               xennet_move_rx_slot(np, skb, ref);
+       } while (extra->flags & XEN_NETIF_EXTRA_FLAG_MORE);
+
+       np->rx.rsp_cons = cons;
+       return err;
+}
+
 static int xennet_get_responses(struct netfront_info *np,
-                               struct netif_rx_response *rx, RING_IDX rp,
+                               struct netfront_rx_info *rinfo, RING_IDX rp,
                                struct sk_buff_head *list, int count)
 {
        struct mmu_update *mmu = np->rx_mmu + count;
        struct multicall_entry *mcl = np->rx_mcl + count;
+       struct netif_rx_response *rx = &rinfo->rx;
+       struct netif_extra_info *extras = rinfo->extras;
        RING_IDX cons = np->rx.rsp_cons;
        struct sk_buff *skb = xennet_get_rx_skb(np, cons);
        grant_ref_t ref = xennet_get_rx_ref(np, cons);
        int max = MAX_SKB_FRAGS + (rx->status <= RX_COPY_THRESHOLD);
        int frags = 1;
        int err = 0;
+
+       if (rx->flags & NETRXF_extra_info) {
+               err = xennet_get_extras(np, extras, rp);
+               cons = np->rx.rsp_cons;
+       }
 
        for (;;) {
                unsigned long mfn;
@@ -1023,11 +1083,38 @@ static RING_IDX xennet_fill_frags(struct
        return cons;
 }
 
+static int xennet_set_skb_gso(struct sk_buff *skb, struct netif_extra_info 
*gso)
+{
+       if (!gso->u.gso.size) {
+               if (net_ratelimit())
+                       WPRINTK("GSO size must not be zero.\n");
+               return -EINVAL;
+       }
+
+       /* Currently only TCPv4 S.O. is supported. */
+       if (gso->u.gso.type != XEN_NETIF_GSO_TYPE_TCPV4) {
+               if (net_ratelimit())
+                       WPRINTK("Bad GSO type %d.\n", gso->u.gso.type);
+               return -EINVAL;
+       }
+
+       skb_shinfo(skb)->gso_size = gso->u.gso.size;
+       skb_shinfo(skb)->gso_type = SKB_GSO_TCPV4;
+
+       /* Header must be checked, and gso_segs computed. */
+       skb_shinfo(skb)->gso_type |= SKB_GSO_DODGY;
+       skb_shinfo(skb)->gso_segs = 0;
+
+       return 0;
+}
+
 static int netif_poll(struct net_device *dev, int *pbudget)
 {
        struct netfront_info *np = netdev_priv(dev);
        struct sk_buff *skb;
-       struct netif_rx_response *rx;
+       struct netfront_rx_info rinfo;
+       struct netif_rx_response *rx = &rinfo.rx;
+       struct netif_extra_info *extras = rinfo.extras;
        RING_IDX i, rp;
        struct multicall_entry *mcl;
        int work_done, budget, more_to_do = 1;
@@ -1058,12 +1145,14 @@ static int netif_poll(struct net_device 
        for (i = np->rx.rsp_cons, work_done = 0, pages_done = 0;
             (i != rp) && (work_done < budget);
             np->rx.rsp_cons = ++i, work_done++) {
-               rx = RING_GET_RESPONSE(&np->rx, i);
-
-               err = xennet_get_responses(np, rx, rp, &tmpq, pages_done);
+               memcpy(rx, RING_GET_RESPONSE(&np->rx, i), sizeof(*rx));
+               memset(extras, 0, sizeof(extras));
+
+               err = xennet_get_responses(np, &rinfo, rp, &tmpq, pages_done);
                pages_done += skb_queue_len(&tmpq);
 
                if (unlikely(err)) {
+err:
                        i = np->rx.rsp_cons + skb_queue_len(&tmpq) - 1;
                        work_done--;
                        while ((skb = __skb_dequeue(&tmpq)))
@@ -1073,6 +1162,16 @@ static int netif_poll(struct net_device 
                }
 
                skb = __skb_dequeue(&tmpq);
+
+               if (extras[XEN_NETIF_EXTRA_TYPE_GSO - 1].type) {
+                       struct netif_extra_info *gso;
+                       gso = &extras[XEN_NETIF_EXTRA_TYPE_GSO - 1];
+
+                       if (unlikely(xennet_set_skb_gso(skb, gso))) {
+                               __skb_queue_head(&tmpq, skb);
+                               goto err;
+                       }
+               }
 
                skb->nh.raw = (void *)skb_shinfo(skb)->frags[0].page;
                skb->h.raw = skb->nh.raw + rx->offset;
diff -r 9f29252c23b6 -r 485616ab73e3 xen/include/public/io/netif.h
--- a/xen/include/public/io/netif.h     Mon Jul 31 17:42:13 2006 +0100
+++ b/xen/include/public/io/netif.h     Mon Jul 31 17:45:22 2006 +0100
@@ -128,6 +128,10 @@ typedef struct netif_rx_request netif_rx
 #define _NETRXF_more_data      (2)
 #define  NETRXF_more_data      (1U<<_NETRXF_more_data)
 
+/* Packet to be followed by extra descriptor(s). */
+#define _NETRXF_extra_info     (3)
+#define  NETRXF_extra_info     (1U<<_NETRXF_extra_info)
+
 struct netif_rx_response {
     uint16_t id;
     uint16_t offset;       /* Offset in page of start of received packet  */

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] [NET] front: Add TSO support, Xen patchbot-unstable <=