ia64/xen-unstable

changeset 6425:488bdf86c686

More cleanups and g/c of unused code.
Signed-off-by: Christian Limpach <Christian.Limpach@cl.cam.ac.uk>
author cl349@firebug.cl.cam.ac.uk
date Thu Aug 25 14:40:15 2005 +0000 (2005-08-25)
parents 4abd299ef2f6
children fab3e2747dc2
files linux-2.6-xen-sparse/drivers/xen/netback/common.h linux-2.6-xen-sparse/drivers/xen/netback/interface.c linux-2.6-xen-sparse/drivers/xen/netback/netback.c linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/common.h	Thu Aug 25 14:16:38 2005 +0000
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/common.h	Thu Aug 25 14:40:15 2005 +0000
     1.3 @@ -83,12 +83,6 @@ typedef struct netif_st {
     1.4      /* Miscellaneous private stuff. */
     1.5      enum { DISCONNECTED, DISCONNECTING, CONNECTED } status;
     1.6      int active;
     1.7 -    /*
     1.8 -     * DISCONNECT response is deferred until pending requests are ack'ed.
     1.9 -     * We therefore need to store the id from the original request.
    1.10 -     */
    1.11 -    u8               disconnect_rspid;
    1.12 -    struct netif_st *hash_next;
    1.13      struct list_head list;  /* scheduling list */
    1.14      atomic_t         refcnt;
    1.15      struct net_device *dev;
    1.16 @@ -97,12 +91,8 @@ typedef struct netif_st {
    1.17      struct work_struct free_work;
    1.18  } netif_t;
    1.19  
    1.20 -int netif_create(netif_t *netif);
    1.21 -void netif_destroy(netif_be_destroy_t *destroy);
    1.22 -void netif_creditlimit(netif_be_creditlimit_t *creditlimit);
    1.23 -int  netif_disconnect(netif_be_disconnect_t *disconnect, u8 rsp_id);
    1.24 -void netif_disconnect_complete(netif_t *netif);
    1.25 -netif_t *netif_find_by_handle(domid_t domid, unsigned int handle);
    1.26 +void netif_creditlimit(netif_t *netif);
    1.27 +int  netif_disconnect(netif_t *netif);
    1.28  
    1.29  netif_t *alloc_netif(domid_t domid, unsigned int handle, u8 be_mac[ETH_ALEN]);
    1.30  void free_netif_callback(netif_t *netif);
    1.31 @@ -116,8 +106,7 @@ int netif_map(netif_t *netif, unsigned l
    1.32              free_netif_callback(_b);              \
    1.33      } while (0)
    1.34  
    1.35 -void netif_interface_init(void);
    1.36 -void netif_ctrlif_init(void);
    1.37 +void netif_xenbus_init(void);
    1.38  
    1.39  void netif_schedule_work(netif_t *netif);
    1.40  void netif_deschedule_work(netif_t *netif);
     2.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/interface.c	Thu Aug 25 14:16:38 2005 +0000
     2.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/interface.c	Thu Aug 25 14:40:15 2005 +0000
     2.3 @@ -9,20 +9,6 @@
     2.4  #include "common.h"
     2.5  #include <linux/rtnetlink.h>
     2.6  
     2.7 -#define NETIF_HASHSZ 1024
     2.8 -#define NETIF_HASH(_d,_h) (((int)(_d)^(int)(_h))&(NETIF_HASHSZ-1))
     2.9 -
    2.10 -static netif_t *netif_hash[NETIF_HASHSZ];
    2.11 -
    2.12 -netif_t *netif_find_by_handle(domid_t domid, unsigned int handle)
    2.13 -{
    2.14 -    netif_t *netif = netif_hash[NETIF_HASH(domid, handle)];
    2.15 -    while ( (netif != NULL) && 
    2.16 -            ((netif->domid != domid) || (netif->handle != handle)) )
    2.17 -        netif = netif->hash_next;
    2.18 -    return netif;
    2.19 -}
    2.20 -
    2.21  static void __netif_up(netif_t *netif)
    2.22  {
    2.23      struct net_device *dev = netif->dev;
    2.24 @@ -47,7 +33,7 @@ static void __netif_down(netif_t *netif)
    2.25  static int net_open(struct net_device *dev)
    2.26  {
    2.27      netif_t *netif = netdev_priv(dev);
    2.28 -    if ( netif->status == CONNECTED )
    2.29 +    if (netif->status == CONNECTED)
    2.30          __netif_up(netif);
    2.31      netif_start_queue(dev);
    2.32      return 0;
    2.33 @@ -57,7 +43,7 @@ static int net_close(struct net_device *
    2.34  {
    2.35      netif_t *netif = netdev_priv(dev);
    2.36      netif_stop_queue(dev);
    2.37 -    if ( netif->status == CONNECTED )
    2.38 +    if (netif->status == CONNECTED)
    2.39          __netif_down(netif);
    2.40      return 0;
    2.41  }
    2.42 @@ -66,15 +52,13 @@ netif_t *alloc_netif(domid_t domid, unsi
    2.43  {
    2.44      int err = 0, i;
    2.45      struct net_device *dev;
    2.46 -    netif_t **pnetif, *netif;
    2.47 +    netif_t *netif;
    2.48      char name[IFNAMSIZ] = {};
    2.49  
    2.50      snprintf(name, IFNAMSIZ - 1, "vif%u.%u", domid, handle);
    2.51      dev = alloc_netdev(sizeof(netif_t), name, ether_setup);
    2.52 -    if ( dev == NULL )
    2.53 -    {
    2.54 +    if (dev == NULL) {
    2.55          DPRINTK("Could not create netif: out of memory\n");
    2.56 -        // create->status = NETIF_BE_STATUS_OUT_OF_MEMORY;
    2.57          return NULL;
    2.58      }
    2.59  
    2.60 @@ -90,19 +74,6 @@ netif_t *alloc_netif(domid_t domid, unsi
    2.61      netif->credit_usec  = 0UL;
    2.62      init_timer(&netif->credit_timeout);
    2.63  
    2.64 -    pnetif = &netif_hash[NETIF_HASH(domid, handle)];
    2.65 -    while ( *pnetif != NULL )
    2.66 -    {
    2.67 -        if ( ((*pnetif)->domid == domid) && ((*pnetif)->handle == handle) )
    2.68 -        {
    2.69 -            DPRINTK("Could not create netif: already exists\n");
    2.70 -            // create->status = NETIF_BE_STATUS_INTERFACE_EXISTS;
    2.71 -            free_netdev(dev);
    2.72 -            return NULL;
    2.73 -        }
    2.74 -        pnetif = &(*pnetif)->hash_next;
    2.75 -    }
    2.76 -
    2.77      dev->hard_start_xmit = netif_be_start_xmit;
    2.78      dev->get_stats       = netif_be_get_stats;
    2.79      dev->open            = net_open;
    2.80 @@ -115,8 +86,7 @@ netif_t *alloc_netif(domid_t domid, unsi
    2.81      for (i = 0; i < ETH_ALEN; i++)
    2.82  	if (be_mac[i] != 0)
    2.83  	    break;
    2.84 -    if (i == ETH_ALEN)
    2.85 -    {
    2.86 +    if (i == ETH_ALEN) {
    2.87          /*
    2.88           * Initialise a dummy MAC address. We choose the numerically largest
    2.89           * non-broadcast address to prevent the address getting stolen by an
    2.90 @@ -124,30 +94,20 @@ netif_t *alloc_netif(domid_t domid, unsi
    2.91           */ 
    2.92          memset(dev->dev_addr, 0xFF, ETH_ALEN);
    2.93          dev->dev_addr[0] &= ~0x01;
    2.94 -    }
    2.95 -    else
    2.96 -    {
    2.97 +    } else
    2.98          memcpy(dev->dev_addr, be_mac, ETH_ALEN);
    2.99 -    }
   2.100  
   2.101      rtnl_lock();
   2.102      err = register_netdevice(dev);
   2.103      rtnl_unlock();
   2.104 -
   2.105 -    if ( err != 0 )
   2.106 -    {
   2.107 +    if (err) {
   2.108          DPRINTK("Could not register new net device %s: err=%d\n",
   2.109                  dev->name, err);
   2.110 -        // create->status = NETIF_BE_STATUS_OUT_OF_MEMORY;
   2.111          free_netdev(dev);
   2.112          return NULL;
   2.113      }
   2.114  
   2.115 -    netif->hash_next = *pnetif;
   2.116 -    *pnetif = netif;
   2.117 -
   2.118      DPRINTK("Successfully created netif\n");
   2.119 -    // create->status = NETIF_BE_STATUS_OKAY;
   2.120      return netif;
   2.121  }
   2.122  
   2.123 @@ -245,17 +205,9 @@ int netif_map(netif_t *netif, unsigned l
   2.124      evtchn_op_t op = { .cmd = EVTCHNOP_bind_interdomain };
   2.125      int err;
   2.126  
   2.127 -#if 0
   2.128 -    if ( netif->status != DISCONNECTED ) {
   2.129 -        connect->status = NETIF_BE_STATUS_INTERFACE_CONNECTED;
   2.130 -        return;
   2.131 -    }
   2.132 -#endif
   2.133 -
   2.134 -    if ( (vma = get_vm_area(2*PAGE_SIZE, VM_IOREMAP)) == NULL ) {
   2.135 -        // connect->status = NETIF_BE_STATUS_OUT_OF_MEMORY;
   2.136 +    vma = get_vm_area(2*PAGE_SIZE, VM_IOREMAP);
   2.137 +    if (vma == NULL)
   2.138          return -ENOMEM;
   2.139 -    }
   2.140  
   2.141      err = map_frontend_page(netif, (unsigned long)vma->addr, tx_ring_ref,
   2.142  			    rx_ring_ref);
   2.143 @@ -278,12 +230,8 @@ int netif_map(netif_t *netif, unsigned l
   2.144      netif->evtchn = op.u.bind_interdomain.port1;
   2.145      netif->remote_evtchn = evtchn;
   2.146  
   2.147 -    netif->tx_shmem_frame = tx_ring_ref;
   2.148 -    netif->rx_shmem_frame = rx_ring_ref;
   2.149 -    netif->tx             = 
   2.150 -        (netif_tx_interface_t *)vma->addr;
   2.151 -    netif->rx             = 
   2.152 -        (netif_rx_interface_t *)((char *)vma->addr + PAGE_SIZE);
   2.153 +    netif->tx = (netif_tx_interface_t *)vma->addr;
   2.154 +    netif->rx = (netif_rx_interface_t *)((char *)vma->addr + PAGE_SIZE);
   2.155      netif->tx->resp_prod = netif->rx->resp_prod = 0;
   2.156      netif_get(netif);
   2.157      wmb(); /* Other CPUs see new state before interface is started. */
   2.158 @@ -291,17 +239,17 @@ int netif_map(netif_t *netif, unsigned l
   2.159      rtnl_lock();
   2.160      netif->status = CONNECTED;
   2.161      wmb();
   2.162 -    if ( netif_running(netif->dev) )
   2.163 +    if (netif_running(netif->dev))
   2.164          __netif_up(netif);
   2.165      rtnl_unlock();
   2.166  
   2.167 -    // connect->status = NETIF_BE_STATUS_OKAY;
   2.168      return 0;
   2.169  }
   2.170  
   2.171  static void free_netif(void *arg)
   2.172  {
   2.173 -    netif_t              *netif = (netif_t *)arg;
   2.174 +    evtchn_op_t op = { .cmd = EVTCHNOP_close };
   2.175 +    netif_t *netif = (netif_t *)arg;
   2.176  
   2.177      /*
   2.178       * These can't be done in netif_disconnect() because at that point there
   2.179 @@ -309,10 +257,21 @@ static void free_netif(void *arg)
   2.180       * responses must still be notified to the remote driver.
   2.181       */
   2.182  
   2.183 -    unmap_frontend_page(netif);
   2.184 -    vfree(netif->tx); /* Frees netif->rx as well. */
   2.185 +    op.u.close.port = netif->evtchn;
   2.186 +    op.u.close.dom = DOMID_SELF;
   2.187 +    HYPERVISOR_event_channel_op(&op);
   2.188 +    op.u.close.port = netif->remote_evtchn;
   2.189 +    op.u.close.dom = netif->domid;
   2.190 +    HYPERVISOR_event_channel_op(&op);
   2.191  
   2.192 -    netif->status = DISCONNECTED;
   2.193 +    unregister_netdev(netif->dev);
   2.194 +
   2.195 +    if (netif->tx) {
   2.196 +	unmap_frontend_page(netif);
   2.197 +	vfree(netif->tx); /* Frees netif->rx as well. */
   2.198 +    }
   2.199 +
   2.200 +    free_netdev(netif->dev);
   2.201  }
   2.202  
   2.203  void free_netif_callback(netif_t *netif)
   2.204 @@ -321,59 +280,14 @@ void free_netif_callback(netif_t *netif)
   2.205      schedule_work(&netif->free_work);
   2.206  }
   2.207  
   2.208 -void netif_destroy(netif_be_destroy_t *destroy)
   2.209 +void netif_creditlimit(netif_t *netif)
   2.210  {
   2.211 -    domid_t       domid  = destroy->domid;
   2.212 -    unsigned int  handle = destroy->netif_handle;
   2.213 -    netif_t     **pnetif, *netif;
   2.214 -
   2.215 -    pnetif = &netif_hash[NETIF_HASH(domid, handle)];
   2.216 -    while ( (netif = *pnetif) != NULL )
   2.217 -    {
   2.218 -        if ( (netif->domid == domid) && (netif->handle == handle) )
   2.219 -        {
   2.220 -            if ( netif->status != DISCONNECTED )
   2.221 -                goto still_connected;
   2.222 -            goto destroy;
   2.223 -        }
   2.224 -        pnetif = &netif->hash_next;
   2.225 -    }
   2.226 -
   2.227 -    destroy->status = NETIF_BE_STATUS_INTERFACE_NOT_FOUND;
   2.228 -    return;
   2.229 -
   2.230 - still_connected:
   2.231 -    destroy->status = NETIF_BE_STATUS_INTERFACE_CONNECTED;
   2.232 -    return;
   2.233 -
   2.234 - destroy:
   2.235 -    *pnetif = netif->hash_next;
   2.236 -    unregister_netdev(netif->dev);
   2.237 -    free_netdev(netif->dev);
   2.238 -    destroy->status = NETIF_BE_STATUS_OKAY;
   2.239 -}
   2.240 -
   2.241 -void netif_creditlimit(netif_be_creditlimit_t *creditlimit)
   2.242 -{
   2.243 -    domid_t       domid  = creditlimit->domid;
   2.244 -    unsigned int  handle = creditlimit->netif_handle;
   2.245 -    netif_t      *netif;
   2.246 -
   2.247 -    netif = netif_find_by_handle(domid, handle);
   2.248 -    if ( unlikely(netif == NULL) )
   2.249 -    {
   2.250 -        DPRINTK("netif_creditlimit attempted for non-existent netif"
   2.251 -                " (%u,%u)\n", creditlimit->domid, creditlimit->netif_handle); 
   2.252 -        creditlimit->status = NETIF_BE_STATUS_INTERFACE_NOT_FOUND;
   2.253 -        return; 
   2.254 -    }
   2.255 -
   2.256 +#if 0
   2.257      /* Set the credit limit (reset remaining credit to new limit). */
   2.258      netif->credit_bytes = netif->remaining_credit = creditlimit->credit_bytes;
   2.259      netif->credit_usec = creditlimit->period_usec;
   2.260  
   2.261 -    if ( netif->status == CONNECTED )
   2.262 -    {
   2.263 +    if (netif->status == CONNECTED) {
   2.264          /*
   2.265           * Schedule work so that any packets waiting under previous credit 
   2.266           * limit are dealt with (acts like a replenishment point).
   2.267 @@ -381,43 +295,22 @@ void netif_creditlimit(netif_be_creditli
   2.268          netif->credit_timeout.expires = jiffies;
   2.269          netif_schedule_work(netif);
   2.270      }
   2.271 -    
   2.272 -    creditlimit->status = NETIF_BE_STATUS_OKAY;
   2.273 +#endif
   2.274  }
   2.275  
   2.276 -int netif_disconnect(netif_be_disconnect_t *disconnect, u8 rsp_id)
   2.277 +int netif_disconnect(netif_t *netif)
   2.278  {
   2.279 -    domid_t       domid  = disconnect->domid;
   2.280 -    unsigned int  handle = disconnect->netif_handle;
   2.281 -    netif_t      *netif;
   2.282  
   2.283 -    netif = netif_find_by_handle(domid, handle);
   2.284 -    if ( unlikely(netif == NULL) )
   2.285 -    {
   2.286 -        DPRINTK("netif_disconnect attempted for non-existent netif"
   2.287 -                " (%u,%u)\n", disconnect->domid, disconnect->netif_handle); 
   2.288 -        disconnect->status = NETIF_BE_STATUS_INTERFACE_NOT_FOUND;
   2.289 -        return 1; /* Caller will send response error message. */
   2.290 -    }
   2.291 -
   2.292 -    if ( netif->status == CONNECTED )
   2.293 -    {
   2.294 +    if (netif->status == CONNECTED) {
   2.295          rtnl_lock();
   2.296          netif->status = DISCONNECTING;
   2.297 -        netif->disconnect_rspid = rsp_id;
   2.298          wmb();
   2.299 -        if ( netif_running(netif->dev) )
   2.300 +        if (netif_running(netif->dev))
   2.301              __netif_down(netif);
   2.302          rtnl_unlock();
   2.303          netif_put(netif);
   2.304          return 0; /* Caller should not send response message. */
   2.305      }
   2.306  
   2.307 -    disconnect->status = NETIF_BE_STATUS_OKAY;
   2.308      return 1;
   2.309  }
   2.310 -
   2.311 -void netif_interface_init(void)
   2.312 -{
   2.313 -    memset(netif_hash, 0, sizeof(netif_hash));
   2.314 -}
     3.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Thu Aug 25 14:16:38 2005 +0000
     3.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/netback.c	Thu Aug 25 14:40:15 2005 +0000
     3.3 @@ -966,8 +966,6 @@ static int __init netback_init(void)
     3.4      net_timer.data = 0;
     3.5      net_timer.function = net_alarm;
     3.6      
     3.7 -    netif_interface_init();
     3.8 -
     3.9      page = balloon_alloc_empty_page_range(MAX_PENDING_REQS);
    3.10      BUG_ON(page == NULL);
    3.11      mmap_vstart = (unsigned long)pfn_to_kaddr(page_to_pfn(page));
     4.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c	Thu Aug 25 14:16:38 2005 +0000
     4.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/xenbus.c	Thu Aug 25 14:40:15 2005 +0000
     4.3 @@ -109,58 +109,18 @@ static void frontend_changed(struct xenb
     4.4  		return;
     4.5  	}
     4.6  
     4.7 -#if 0
     4.8 -	/* Supply the information about the device the frontend needs */
     4.9 -	err = xenbus_transaction_start(be->dev->nodename);
    4.10 -	if (err) {
    4.11 -		xenbus_dev_error(be->dev, err, "starting transaction");
    4.12 -		return;
    4.13 -	}
    4.14 -
    4.15 -	err = xenbus_printf(be->dev->nodename, "sectors", "%lu",
    4.16 -			    vbd_size(&be->blkif->vbd));
    4.17 -	if (err) {
    4.18 -		xenbus_dev_error(be->dev, err, "writing %s/sectors",
    4.19 -				 be->dev->nodename);
    4.20 -		goto abort;
    4.21 -	}
    4.22 -
    4.23 -	/* FIXME: use a typename instead */
    4.24 -	err = xenbus_printf(be->dev->nodename, "info", "%u",
    4.25 -			    vbd_info(&be->blkif->vbd));
    4.26 -	if (err) {
    4.27 -		xenbus_dev_error(be->dev, err, "writing %s/info",
    4.28 -				 be->dev->nodename);
    4.29 -		goto abort;
    4.30 -	}
    4.31 -	err = xenbus_printf(be->dev->nodename, "sector-size", "%lu",
    4.32 -			    vbd_secsize(&be->blkif->vbd));
    4.33 -	if (err) {
    4.34 -		xenbus_dev_error(be->dev, err, "writing %s/sector-size",
    4.35 -				 be->dev->nodename);
    4.36 -		goto abort;
    4.37 -	}
    4.38 -#endif
    4.39 -
    4.40  	/* Map the shared frame, irq etc. */
    4.41  	err = netif_map(be->netif, tx_ring_ref, rx_ring_ref, evtchn);
    4.42  	if (err) {
    4.43  		xenbus_dev_error(be->dev, err,
    4.44  				 "mapping shared-frames %lu/%lu port %u",
    4.45  				 tx_ring_ref, rx_ring_ref, evtchn);
    4.46 -		goto abort;
    4.47 +		return;
    4.48  	}
    4.49  
    4.50 -#if 0
    4.51 -	xenbus_transaction_end(0);
    4.52 -#endif
    4.53  	xenbus_dev_ok(be->dev);
    4.54  
    4.55  	return;
    4.56 -
    4.57 -abort:
    4.58 -	// xenbus_transaction_end(1);
    4.59 -	;
    4.60  }
    4.61  
    4.62  /*