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-devel

[Xen-devel] [PATCH 2/6] Network acceleration improvements

To: xen-devel@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH 2/6] Network acceleration improvements
From: Kieran Mansley <kmansley@xxxxxxxxxxxxxx>
Date: Wed, 03 Oct 2007 14:18:24 +0100
Delivery-date: Wed, 03 Oct 2007 06:20:21 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
Signed-off-by: Kieran Mansley <kmansley@xxxxxxxxxxxxxx>

Configure network acceleration using ethernet device name

diff -r 8f2d6ca3b8ff drivers/xen/netback/accel.c
--- a/drivers/xen/netback/accel.c       Wed Oct 03 13:23:41 2007 +0100
+++ b/drivers/xen/netback/accel.c       Wed Oct 03 13:30:02 2007 +0100
@@ -55,15 +55,24 @@ static spinlock_t accelerators_lock;
  * compatible (i.e. if the accelerator should be used by the
  * backend) 
  */
-static int match_accelerator(struct backend_info *be, 
+static int match_accelerator(struct xenbus_device *xendev,
+                            struct backend_info *be, 
                             struct netback_accelerator *accelerator)
 {
-       /*
-        * This could do with being more sophisticated.  For example,
-        * determine which hardware is being used by each backend from
-        * the bridge and network topology of the domain
-        */
-       return be->accelerator == NULL;
+       int rc = 0;
+       char *eth_name = xenbus_read(XBT_NIL, xendev->nodename, "accel", NULL);
+       
+       if (IS_ERR(eth_name)) {
+               /* Probably means not present */
+               DPRINTK("%s: no match due to xenbus_read accel error %d\n", 
+                       __FUNCTION__, PTR_ERR(eth_name));
+               return 0;
+       } else {
+               if (!strcmp(eth_name, accelerator->eth_name))
+                       rc = 1;
+               kfree(eth_name);
+               return rc;
+       }
 }
 
 /*
@@ -80,7 +89,7 @@ static int netback_accelerator_tell_back
        if (!strcmp("vif", xendev->devicetype)) {
                struct backend_info *be = xendev->dev.driver_data;
 
-               if (match_accelerator(be, accelerator)) {
+               if (match_accelerator(xendev, be, accelerator)) {
                        be->accelerator = accelerator;
                        atomic_inc(&be->accelerator->use_count);
                        be->accelerator->hooks->probe(xendev);
@@ -94,12 +103,12 @@ static int netback_accelerator_tell_back
  * Entry point for an netback accelerator plugin module.  Called to
  * advertise its presence, and connect to any suitable backends.
  */
-void netback_connect_accelerator(int id, const char *frontend, 
+void netback_connect_accelerator(int id, const char *eth_name, 
                                 struct netback_accel_hooks *hooks)
 {
        struct netback_accelerator *new_accelerator = 
                kmalloc(sizeof(struct netback_accelerator), GFP_KERNEL);
-       unsigned frontend_len, flags;
+       unsigned eth_name_len, flags;
 
        if (!new_accelerator) {
                DPRINTK("%s: failed to allocate memory for accelerator\n",
@@ -109,15 +118,15 @@ void netback_connect_accelerator(int id,
 
        new_accelerator->id = id;
        
-       frontend_len = strlen(frontend)+1;
-       new_accelerator->frontend = kmalloc(frontend_len, GFP_KERNEL);
-       if (!new_accelerator->frontend) {
-               DPRINTK("%s: failed to allocate memory for frontend string\n",
+       eth_name_len = strlen(eth_name)+1;
+       new_accelerator->eth_name = kmalloc(eth_name_len, GFP_KERNEL);
+       if (!new_accelerator->eth_name) {
+               DPRINTK("%s: failed to allocate memory for eth_name string\n",
                        __FUNCTION__);
                kfree(new_accelerator);
                return;
        }
-       strlcpy(new_accelerator->frontend, frontend, frontend_len);
+       strlcpy(new_accelerator->eth_name, eth_name, eth_name_len);
        
        new_accelerator->hooks = hooks;
 
@@ -136,7 +145,25 @@ EXPORT_SYMBOL_GPL(netback_connect_accele
 
 
 /* 
- * Disconnect an accerator plugin module that has previously been
+ * Remove the link from backend state to a particular accelerator
+ */ 
+static int netback_accelerator_cleanup_backend(struct device *dev, void *arg)
+{
+       struct netback_accelerator *accelerator = 
+               (struct netback_accelerator *)arg;
+       struct xenbus_device *xendev = to_xenbus_device(dev);
+
+       if (!strcmp("vif", xendev->devicetype)) {
+               struct backend_info *be = xendev->dev.driver_data;
+               if (be->accelerator == accelerator)
+                       be->accelerator = NULL;
+       }
+       return 0;
+}
+
+
+/* 
+ * Disconnect an accelerator plugin module that has previously been
  * connected.
  *
  * This should only be allowed when there are no remaining users -
@@ -144,18 +171,22 @@ EXPORT_SYMBOL_GPL(netback_connect_accele
  * they should have already been removed.  This is enforced through a
  * usage count and BUG_ON(use!=0), but should be made more user-friendly
  */
-void netback_disconnect_accelerator(int id, const char *frontend)
+void netback_disconnect_accelerator(int id, const char *eth_name)
 {
        struct netback_accelerator *accelerator, *next;
        unsigned flags;
 
        spin_lock_irqsave(&accelerators_lock, flags);
        list_for_each_entry_safe(accelerator, next, &accelerators_list, link) {
-               if (strcmp(frontend, accelerator->frontend)) {
+               if (strcmp(eth_name, accelerator->eth_name)) {
                        BUG_ON(atomic_read(&accelerator->use_count) != 0);
                        list_del(&accelerator->link);
                        spin_unlock_irqrestore(&accelerators_lock, flags);
-                       kfree(accelerator->frontend);
+
+                       xenbus_for_each_backend(accelerator, 
+                                               
netback_accelerator_cleanup_backend);
+                               
+                       kfree(accelerator->eth_name);
                        kfree(accelerator);
                        return;
                }
@@ -177,7 +208,7 @@ void netback_probe_accelerators(struct b
         */
        spin_lock_irqsave(&accelerators_lock, flags);
        list_for_each_entry(accelerator, &accelerators_list, link) { 
-               if (match_accelerator(be, accelerator)) {
+               if (match_accelerator(dev, be, accelerator)) {
                        be->accelerator = accelerator;
                        atomic_inc(&be->accelerator->use_count);
                        be->accelerator->hooks->probe(dev);
diff -r 8f2d6ca3b8ff drivers/xen/netback/common.h
--- a/drivers/xen/netback/common.h      Wed Oct 03 13:23:41 2007 +0100
+++ b/drivers/xen/netback/common.h      Wed Oct 03 13:23:58 2007 +0100
@@ -133,7 +133,7 @@ struct netback_accelerator {
 struct netback_accelerator {
        struct list_head link;
        int id;
-       char *frontend;
+       char *eth_name;
        atomic_t use_count;
        struct netback_accel_hooks *hooks;
 };
@@ -150,10 +150,10 @@ struct backend_info {
 };
 
 /* Connect an accelerator plugin module to netback */
-extern void netback_connect_accelerator(int id, const char *frontend, 
+extern void netback_connect_accelerator(int id, const char *eth_name, 
                                        struct netback_accel_hooks *hooks);
-/* Disconnect a previously connected accelerator pluging module */
-extern void netback_disconnect_accelerator(int id, const char *frontend);
+/* Disconnect a previously connected accelerator plugin module */
+extern void netback_disconnect_accelerator(int id, const char *eth_name);
 
 
 extern
diff -r 8f2d6ca3b8ff drivers/xen/netfront/netfront.c
--- a/drivers/xen/netfront/netfront.c   Wed Oct 03 13:23:41 2007 +0100
+++ b/drivers/xen/netfront/netfront.c   Wed Oct 03 13:26:35 2007 +0100
@@ -1761,7 +1761,7 @@ static int network_connect(struct net_de
 
        feature_accel = 1;
        accel_frontend = xenbus_read(XBT_NIL, np->xbdev->otherend, 
-                                    "accel", &accel_len);
+                                    "accel-frontend", &accel_len);
        if (IS_ERR(accel_frontend)) 
                feature_accel = 0;
 

Attachment: net_accel_configuration
Description: Text document

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH 2/6] Network acceleration improvements, Kieran Mansley <=