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] More cleanups and g/c of unused code.

# HG changeset patch
# User cl349@xxxxxxxxxxxxxxxxxxxx
# Node ID 488bdf86c686a8ec7bccefe706417b08940f02d2
# Parent  4abd299ef2f6047d7205bebc127a5883d6ec6792
More cleanups and g/c of unused code.
Signed-off-by: Christian Limpach <Christian.Limpach@xxxxxxxxxxxx>

diff -r 4abd299ef2f6 -r 488bdf86c686 
linux-2.6-xen-sparse/drivers/xen/netback/common.h
--- a/linux-2.6-xen-sparse/drivers/xen/netback/common.h Thu Aug 25 14:16:38 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/common.h Thu Aug 25 14:40:15 2005
@@ -83,12 +83,6 @@
     /* Miscellaneous private stuff. */
     enum { DISCONNECTED, DISCONNECTING, CONNECTED } status;
     int active;
-    /*
-     * DISCONNECT response is deferred until pending requests are ack'ed.
-     * We therefore need to store the id from the original request.
-     */
-    u8               disconnect_rspid;
-    struct netif_st *hash_next;
     struct list_head list;  /* scheduling list */
     atomic_t         refcnt;
     struct net_device *dev;
@@ -97,12 +91,8 @@
     struct work_struct free_work;
 } netif_t;
 
-int netif_create(netif_t *netif);
-void netif_destroy(netif_be_destroy_t *destroy);
-void netif_creditlimit(netif_be_creditlimit_t *creditlimit);
-int  netif_disconnect(netif_be_disconnect_t *disconnect, u8 rsp_id);
-void netif_disconnect_complete(netif_t *netif);
-netif_t *netif_find_by_handle(domid_t domid, unsigned int handle);
+void netif_creditlimit(netif_t *netif);
+int  netif_disconnect(netif_t *netif);
 
 netif_t *alloc_netif(domid_t domid, unsigned int handle, u8 be_mac[ETH_ALEN]);
 void free_netif_callback(netif_t *netif);
@@ -116,8 +106,7 @@
             free_netif_callback(_b);              \
     } while (0)
 
-void netif_interface_init(void);
-void netif_ctrlif_init(void);
+void netif_xenbus_init(void);
 
 void netif_schedule_work(netif_t *netif);
 void netif_deschedule_work(netif_t *netif);
diff -r 4abd299ef2f6 -r 488bdf86c686 
linux-2.6-xen-sparse/drivers/xen/netback/interface.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/interface.c      Thu Aug 25 
14:16:38 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/interface.c      Thu Aug 25 
14:40:15 2005
@@ -9,20 +9,6 @@
 #include "common.h"
 #include <linux/rtnetlink.h>
 
-#define NETIF_HASHSZ 1024
-#define NETIF_HASH(_d,_h) (((int)(_d)^(int)(_h))&(NETIF_HASHSZ-1))
-
-static netif_t *netif_hash[NETIF_HASHSZ];
-
-netif_t *netif_find_by_handle(domid_t domid, unsigned int handle)
-{
-    netif_t *netif = netif_hash[NETIF_HASH(domid, handle)];
-    while ( (netif != NULL) && 
-            ((netif->domid != domid) || (netif->handle != handle)) )
-        netif = netif->hash_next;
-    return netif;
-}
-
 static void __netif_up(netif_t *netif)
 {
     struct net_device *dev = netif->dev;
@@ -47,7 +33,7 @@
 static int net_open(struct net_device *dev)
 {
     netif_t *netif = netdev_priv(dev);
-    if ( netif->status == CONNECTED )
+    if (netif->status == CONNECTED)
         __netif_up(netif);
     netif_start_queue(dev);
     return 0;
@@ -57,7 +43,7 @@
 {
     netif_t *netif = netdev_priv(dev);
     netif_stop_queue(dev);
-    if ( netif->status == CONNECTED )
+    if (netif->status == CONNECTED)
         __netif_down(netif);
     return 0;
 }
@@ -66,15 +52,13 @@
 {
     int err = 0, i;
     struct net_device *dev;
-    netif_t **pnetif, *netif;
+    netif_t *netif;
     char name[IFNAMSIZ] = {};
 
     snprintf(name, IFNAMSIZ - 1, "vif%u.%u", domid, handle);
     dev = alloc_netdev(sizeof(netif_t), name, ether_setup);
-    if ( dev == NULL )
-    {
+    if (dev == NULL) {
         DPRINTK("Could not create netif: out of memory\n");
-        // create->status = NETIF_BE_STATUS_OUT_OF_MEMORY;
         return NULL;
     }
 
@@ -90,19 +74,6 @@
     netif->credit_usec  = 0UL;
     init_timer(&netif->credit_timeout);
 
-    pnetif = &netif_hash[NETIF_HASH(domid, handle)];
-    while ( *pnetif != NULL )
-    {
-        if ( ((*pnetif)->domid == domid) && ((*pnetif)->handle == handle) )
-        {
-            DPRINTK("Could not create netif: already exists\n");
-            // create->status = NETIF_BE_STATUS_INTERFACE_EXISTS;
-            free_netdev(dev);
-            return NULL;
-        }
-        pnetif = &(*pnetif)->hash_next;
-    }
-
     dev->hard_start_xmit = netif_be_start_xmit;
     dev->get_stats       = netif_be_get_stats;
     dev->open            = net_open;
@@ -115,8 +86,7 @@
     for (i = 0; i < ETH_ALEN; i++)
        if (be_mac[i] != 0)
            break;
-    if (i == ETH_ALEN)
-    {
+    if (i == ETH_ALEN) {
         /*
          * Initialise a dummy MAC address. We choose the numerically largest
          * non-broadcast address to prevent the address getting stolen by an
@@ -124,30 +94,20 @@
          */ 
         memset(dev->dev_addr, 0xFF, ETH_ALEN);
         dev->dev_addr[0] &= ~0x01;
-    }
-    else
-    {
+    } else
         memcpy(dev->dev_addr, be_mac, ETH_ALEN);
-    }
 
     rtnl_lock();
     err = register_netdevice(dev);
     rtnl_unlock();
-
-    if ( err != 0 )
-    {
+    if (err) {
         DPRINTK("Could not register new net device %s: err=%d\n",
                 dev->name, err);
-        // create->status = NETIF_BE_STATUS_OUT_OF_MEMORY;
         free_netdev(dev);
         return NULL;
     }
 
-    netif->hash_next = *pnetif;
-    *pnetif = netif;
-
     DPRINTK("Successfully created netif\n");
-    // create->status = NETIF_BE_STATUS_OKAY;
     return netif;
 }
 
@@ -245,17 +205,9 @@
     evtchn_op_t op = { .cmd = EVTCHNOP_bind_interdomain };
     int err;
 
-#if 0
-    if ( netif->status != DISCONNECTED ) {
-        connect->status = NETIF_BE_STATUS_INTERFACE_CONNECTED;
-        return;
-    }
-#endif
-
-    if ( (vma = get_vm_area(2*PAGE_SIZE, VM_IOREMAP)) == NULL ) {
-        // connect->status = NETIF_BE_STATUS_OUT_OF_MEMORY;
+    vma = get_vm_area(2*PAGE_SIZE, VM_IOREMAP);
+    if (vma == NULL)
         return -ENOMEM;
-    }
 
     err = map_frontend_page(netif, (unsigned long)vma->addr, tx_ring_ref,
                            rx_ring_ref);
@@ -278,12 +230,8 @@
     netif->evtchn = op.u.bind_interdomain.port1;
     netif->remote_evtchn = evtchn;
 
-    netif->tx_shmem_frame = tx_ring_ref;
-    netif->rx_shmem_frame = rx_ring_ref;
-    netif->tx             = 
-        (netif_tx_interface_t *)vma->addr;
-    netif->rx             = 
-        (netif_rx_interface_t *)((char *)vma->addr + PAGE_SIZE);
+    netif->tx = (netif_tx_interface_t *)vma->addr;
+    netif->rx = (netif_rx_interface_t *)((char *)vma->addr + PAGE_SIZE);
     netif->tx->resp_prod = netif->rx->resp_prod = 0;
     netif_get(netif);
     wmb(); /* Other CPUs see new state before interface is started. */
@@ -291,17 +239,17 @@
     rtnl_lock();
     netif->status = CONNECTED;
     wmb();
-    if ( netif_running(netif->dev) )
+    if (netif_running(netif->dev))
         __netif_up(netif);
     rtnl_unlock();
 
-    // connect->status = NETIF_BE_STATUS_OKAY;
     return 0;
 }
 
 static void free_netif(void *arg)
 {
-    netif_t              *netif = (netif_t *)arg;
+    evtchn_op_t op = { .cmd = EVTCHNOP_close };
+    netif_t *netif = (netif_t *)arg;
 
     /*
      * These can't be done in netif_disconnect() because at that point there
@@ -309,10 +257,21 @@
      * responses must still be notified to the remote driver.
      */
 
-    unmap_frontend_page(netif);
-    vfree(netif->tx); /* Frees netif->rx as well. */
-
-    netif->status = DISCONNECTED;
+    op.u.close.port = netif->evtchn;
+    op.u.close.dom = DOMID_SELF;
+    HYPERVISOR_event_channel_op(&op);
+    op.u.close.port = netif->remote_evtchn;
+    op.u.close.dom = netif->domid;
+    HYPERVISOR_event_channel_op(&op);
+
+    unregister_netdev(netif->dev);
+
+    if (netif->tx) {
+       unmap_frontend_page(netif);
+       vfree(netif->tx); /* Frees netif->rx as well. */
+    }
+
+    free_netdev(netif->dev);
 }
 
 void free_netif_callback(netif_t *netif)
@@ -321,59 +280,14 @@
     schedule_work(&netif->free_work);
 }
 
-void netif_destroy(netif_be_destroy_t *destroy)
-{
-    domid_t       domid  = destroy->domid;
-    unsigned int  handle = destroy->netif_handle;
-    netif_t     **pnetif, *netif;
-
-    pnetif = &netif_hash[NETIF_HASH(domid, handle)];
-    while ( (netif = *pnetif) != NULL )
-    {
-        if ( (netif->domid == domid) && (netif->handle == handle) )
-        {
-            if ( netif->status != DISCONNECTED )
-                goto still_connected;
-            goto destroy;
-        }
-        pnetif = &netif->hash_next;
-    }
-
-    destroy->status = NETIF_BE_STATUS_INTERFACE_NOT_FOUND;
-    return;
-
- still_connected:
-    destroy->status = NETIF_BE_STATUS_INTERFACE_CONNECTED;
-    return;
-
- destroy:
-    *pnetif = netif->hash_next;
-    unregister_netdev(netif->dev);
-    free_netdev(netif->dev);
-    destroy->status = NETIF_BE_STATUS_OKAY;
-}
-
-void netif_creditlimit(netif_be_creditlimit_t *creditlimit)
-{
-    domid_t       domid  = creditlimit->domid;
-    unsigned int  handle = creditlimit->netif_handle;
-    netif_t      *netif;
-
-    netif = netif_find_by_handle(domid, handle);
-    if ( unlikely(netif == NULL) )
-    {
-        DPRINTK("netif_creditlimit attempted for non-existent netif"
-                " (%u,%u)\n", creditlimit->domid, creditlimit->netif_handle); 
-        creditlimit->status = NETIF_BE_STATUS_INTERFACE_NOT_FOUND;
-        return; 
-    }
-
+void netif_creditlimit(netif_t *netif)
+{
+#if 0
     /* Set the credit limit (reset remaining credit to new limit). */
     netif->credit_bytes = netif->remaining_credit = creditlimit->credit_bytes;
     netif->credit_usec = creditlimit->period_usec;
 
-    if ( netif->status == CONNECTED )
-    {
+    if (netif->status == CONNECTED) {
         /*
          * Schedule work so that any packets waiting under previous credit 
          * limit are dealt with (acts like a replenishment point).
@@ -381,43 +295,22 @@
         netif->credit_timeout.expires = jiffies;
         netif_schedule_work(netif);
     }
-    
-    creditlimit->status = NETIF_BE_STATUS_OKAY;
-}
-
-int netif_disconnect(netif_be_disconnect_t *disconnect, u8 rsp_id)
-{
-    domid_t       domid  = disconnect->domid;
-    unsigned int  handle = disconnect->netif_handle;
-    netif_t      *netif;
-
-    netif = netif_find_by_handle(domid, handle);
-    if ( unlikely(netif == NULL) )
-    {
-        DPRINTK("netif_disconnect attempted for non-existent netif"
-                " (%u,%u)\n", disconnect->domid, disconnect->netif_handle); 
-        disconnect->status = NETIF_BE_STATUS_INTERFACE_NOT_FOUND;
-        return 1; /* Caller will send response error message. */
-    }
-
-    if ( netif->status == CONNECTED )
-    {
+#endif
+}
+
+int netif_disconnect(netif_t *netif)
+{
+
+    if (netif->status == CONNECTED) {
         rtnl_lock();
         netif->status = DISCONNECTING;
-        netif->disconnect_rspid = rsp_id;
         wmb();
-        if ( netif_running(netif->dev) )
+        if (netif_running(netif->dev))
             __netif_down(netif);
         rtnl_unlock();
         netif_put(netif);
         return 0; /* Caller should not send response message. */
     }
 
-    disconnect->status = NETIF_BE_STATUS_OKAY;
     return 1;
 }
-
-void netif_interface_init(void)
-{
-    memset(netif_hash, 0, sizeof(netif_hash));
-}
diff -r 4abd299ef2f6 -r 488bdf86c686 
linux-2.6-xen-sparse/drivers/xen/netback/netback.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c        Thu Aug 25 
14:16:38 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c        Thu Aug 25 
14:40:15 2005
@@ -966,8 +966,6 @@
     net_timer.data = 0;
     net_timer.function = net_alarm;
     
-    netif_interface_init();
-
     page = balloon_alloc_empty_page_range(MAX_PENDING_REQS);
     BUG_ON(page == NULL);
     mmap_vstart = (unsigned long)pfn_to_kaddr(page_to_pfn(page));
diff -r 4abd299ef2f6 -r 488bdf86c686 
linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c
--- a/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c Thu Aug 25 14:16:38 2005
+++ b/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c Thu Aug 25 14:40:15 2005
@@ -109,58 +109,18 @@
                return;
        }
 
-#if 0
-       /* Supply the information about the device the frontend needs */
-       err = xenbus_transaction_start(be->dev->nodename);
-       if (err) {
-               xenbus_dev_error(be->dev, err, "starting transaction");
-               return;
-       }
-
-       err = xenbus_printf(be->dev->nodename, "sectors", "%lu",
-                           vbd_size(&be->blkif->vbd));
-       if (err) {
-               xenbus_dev_error(be->dev, err, "writing %s/sectors",
-                                be->dev->nodename);
-               goto abort;
-       }
-
-       /* FIXME: use a typename instead */
-       err = xenbus_printf(be->dev->nodename, "info", "%u",
-                           vbd_info(&be->blkif->vbd));
-       if (err) {
-               xenbus_dev_error(be->dev, err, "writing %s/info",
-                                be->dev->nodename);
-               goto abort;
-       }
-       err = xenbus_printf(be->dev->nodename, "sector-size", "%lu",
-                           vbd_secsize(&be->blkif->vbd));
-       if (err) {
-               xenbus_dev_error(be->dev, err, "writing %s/sector-size",
-                                be->dev->nodename);
-               goto abort;
-       }
-#endif
-
        /* Map the shared frame, irq etc. */
        err = netif_map(be->netif, tx_ring_ref, rx_ring_ref, evtchn);
        if (err) {
                xenbus_dev_error(be->dev, err,
                                 "mapping shared-frames %lu/%lu port %u",
                                 tx_ring_ref, rx_ring_ref, evtchn);
-               goto abort;
-       }
-
-#if 0
-       xenbus_transaction_end(0);
-#endif
+               return;
+       }
+
        xenbus_dev_ok(be->dev);
 
        return;
-
-abort:
-       // xenbus_transaction_end(1);
-       ;
 }
 
 /* 

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] More cleanups and g/c of unused code., Xen patchbot -unstable <=