ia64/xen-unstable

changeset 4429:b0da7900bbbb

bitkeeper revision 1.1236.1.189 (424d776cRx8rE1fz0drKAs8qp8AVVw)

I/O rings may now be dynamically sized: instead of declaring size
at struct definition time, declare it in FRONT/BACK_RING_INIT().
Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Fri Apr 01 16:31:40 2005 +0000 (2005-04-01)
parents c2f2989b8637
children 344290c77cab
files freebsd-5.3-xen-sparse/i386-xen/i386-xen/ctrl_if.c freebsd-5.3-xen-sparse/i386-xen/xen/blkfront/xb_blkfront.c linux-2.6.11-xen-sparse/arch/xen/kernel/ctrl_if.c linux-2.6.11-xen-sparse/drivers/xen/blkback/interface.c linux-2.6.11-xen-sparse/drivers/xen/blkfront/blkfront.c linux-2.6.11-xen-sparse/drivers/xen/blktap/blktap_controlmsg.c linux-2.6.11-xen-sparse/drivers/xen/blktap/blktap_userdev.c linux-2.6.11-xen-sparse/drivers/xen/usbback/interface.c linux-2.6.11-xen-sparse/drivers/xen/usbfront/usbfront.c tools/blktap/blktaplib.c tools/xcs/ctrl_interface.c xen/include/public/io/blkif.h xen/include/public/io/domain_controller.h xen/include/public/io/ring.h xen/include/public/io/usbif.h
line diff
     1.1 --- a/freebsd-5.3-xen-sparse/i386-xen/i386-xen/ctrl_if.c	Fri Apr 01 14:41:31 2005 +0000
     1.2 +++ b/freebsd-5.3-xen-sparse/i386-xen/i386-xen/ctrl_if.c	Fri Apr 01 16:31:40 2005 +0000
     1.3 @@ -470,8 +470,8 @@ ctrl_if_resume(void)
     1.4      
     1.5  
     1.6      /* Sync up with shared indexes. */
     1.7 -    FRONT_RING_ATTACH(&ctrl_if_tx_ring, &ctrl_if->tx_ring);
     1.8 -    BACK_RING_ATTACH(&ctrl_if_rx_ring, &ctrl_if->rx_ring);
     1.9 +    FRONT_RING_ATTACH(&ctrl_if_tx_ring, &ctrl_if->tx_ring, CONTROL_RING_MEM);
    1.10 +    BACK_RING_ATTACH(&ctrl_if_rx_ring, &ctrl_if->rx_ring, CONTROL_RING_MEM);
    1.11  
    1.12      ctrl_if_evtchn = xen_start_info->domain_controller_evtchn;
    1.13      ctrl_if_irq    = bind_evtchn_to_irq(ctrl_if_evtchn);
    1.14 @@ -498,8 +498,8 @@ ctrl_if_init(void *dummy __unused)
    1.15      for ( i = 0; i < 256; i++ )
    1.16          ctrl_if_rxmsg_handler[i] = ctrl_if_rxmsg_default_handler;
    1.17      
    1.18 -    FRONT_RING_ATTACH(&ctrl_if_tx_ring, &ctrl_if->tx_ring);
    1.19 -    BACK_RING_ATTACH(&ctrl_if_rx_ring, &ctrl_if->rx_ring);
    1.20 +    FRONT_RING_ATTACH(&ctrl_if_tx_ring, &ctrl_if->tx_ring, CONTROL_RING_MEM);
    1.21 +    BACK_RING_ATTACH(&ctrl_if_rx_ring, &ctrl_if->rx_ring, CONTROL_RING_MEM);
    1.22  
    1.23      mtx_init(&ctrl_if_lock, "ctrlif", NULL, MTX_SPIN | MTX_NOWITNESS);
    1.24      
     2.1 --- a/freebsd-5.3-xen-sparse/i386-xen/xen/blkfront/xb_blkfront.c	Fri Apr 01 14:41:31 2005 +0000
     2.2 +++ b/freebsd-5.3-xen-sparse/i386-xen/xen/blkfront/xb_blkfront.c	Fri Apr 01 16:31:40 2005 +0000
     2.3 @@ -102,8 +102,10 @@ static blkif_response_t blkif_control_rs
     2.4  
     2.5  static blkif_front_ring_t   blk_ring;
     2.6  
     2.7 +#define BLK_RING_SIZE __RING_SIZE((blkif_sring_t *)0, PAGE_SIZE)
     2.8 +
     2.9  static unsigned long rec_ring_free;		
    2.10 -blkif_request_t rec_ring[RING_SIZE(&blk_ring)];	/* shadow recovery ring */
    2.11 +blkif_request_t rec_ring[BLK_RING_SIZE];
    2.12  
    2.13  /* XXX move to xb_vbd.c when VBD update support is added */
    2.14  #define MAX_VBDS 64
    2.15 @@ -133,7 +135,7 @@ GET_ID_FROM_FREELIST( void )
    2.16  {
    2.17      unsigned long free = rec_ring_free;
    2.18  
    2.19 -    KASSERT(free <= RING_SIZE(&blk_ring), ("free %lu > RING_SIZE", free));
    2.20 +    KASSERT(free <= BLK_RING_SIZE, ("free %lu > RING_SIZE", free));
    2.21  
    2.22      rec_ring_free = rec_ring[free].id;
    2.23  
    2.24 @@ -638,7 +640,7 @@ blkif_disconnect(void)
    2.25      if (blk_ring.sring) free(blk_ring.sring, M_DEVBUF);
    2.26      blk_ring.sring = (blkif_sring_t *)malloc(PAGE_SIZE, M_DEVBUF, M_WAITOK);
    2.27      SHARED_RING_INIT(blk_ring.sring);
    2.28 -    FRONT_RING_INIT(&blk_ring, blk_ring.sring);
    2.29 +    FRONT_RING_INIT(&blk_ring, blk_ring.sring, PAGE_SIZE);
    2.30      blkif_state  = BLKIF_STATE_DISCONNECTED;
    2.31      blkif_send_interface_connect();
    2.32  }
    2.33 @@ -662,7 +664,7 @@ blkif_recover(void)
    2.34       * This will need to be fixed once we have barriers */
    2.35  
    2.36      /* Stage 1 : Find active and move to safety. */
    2.37 -    for ( i = 0; i < RING_SIZE(&blk_ring); i++ ) {
    2.38 +    for ( i = 0; i < BLK_RING_SIZE; i++ ) {
    2.39          if ( rec_ring[i].id >= KERNBASE ) {
    2.40  	    req = RING_GET_REQUEST(&blk_ring, 
    2.41                                     blk_ring.req_prod_pvt);
    2.42 @@ -682,11 +684,11 @@ blkif_recover(void)
    2.43      }
    2.44  
    2.45      /* Stage 3 : Set up free list. */
    2.46 -    for ( ; i < RING_SIZE(&blk_ring); i++ ){
    2.47 +    for ( ; i < BLK_RING_SIZE; i++ ){
    2.48          rec_ring[i].id = i+1;
    2.49      }
    2.50      rec_ring_free = blk_ring.req_prod_pvt;
    2.51 -    rec_ring[RING_SIZE(&blk_ring)-1].id = 0x0fffffff;
    2.52 +    rec_ring[BLK_RING_SIZE-1].id = 0x0fffffff;
    2.53  
    2.54      /* blk_ring.req_prod will be set when we flush_requests().*/
    2.55      wmb();
    2.56 @@ -874,10 +876,10 @@ xb_init(void *unused)
    2.57      printk("[XEN] Initialising virtual block device driver\n");
    2.58  
    2.59      rec_ring_free = 0;
    2.60 -    for (i = 0; i < RING_SIZE(&blk_ring); i++) {
    2.61 +    for (i = 0; i < BLK_RING_SIZE; i++) {
    2.62  	rec_ring[i].id = i+1;
    2.63      }
    2.64 -    rec_ring[RING_SIZE(&blk_ring)-1].id = 0x0fffffff;
    2.65 +    rec_ring[BLK_RING_SIZE-1].id = 0x0fffffff;
    2.66  
    2.67      (void)ctrl_if_register_receiver(CMSG_BLKIF_FE, blkif_ctrlif_rx, 0);
    2.68  
     3.1 --- a/linux-2.6.11-xen-sparse/arch/xen/kernel/ctrl_if.c	Fri Apr 01 14:41:31 2005 +0000
     3.2 +++ b/linux-2.6.11-xen-sparse/arch/xen/kernel/ctrl_if.c	Fri Apr 01 16:31:40 2005 +0000
     3.3 @@ -503,8 +503,8 @@ void ctrl_if_resume(void)
     3.4      }
     3.5  
     3.6      /* Sync up with shared indexes. */
     3.7 -    FRONT_RING_ATTACH(&ctrl_if_tx_ring, &ctrl_if->tx_ring);
     3.8 -    BACK_RING_ATTACH(&ctrl_if_rx_ring, &ctrl_if->rx_ring);
     3.9 +    FRONT_RING_ATTACH(&ctrl_if_tx_ring, &ctrl_if->tx_ring, CONTROL_RING_MEM);
    3.10 +    BACK_RING_ATTACH(&ctrl_if_rx_ring, &ctrl_if->rx_ring, CONTROL_RING_MEM);
    3.11  
    3.12      ctrl_if_evtchn = xen_start_info.domain_controller_evtchn;
    3.13      ctrl_if_irq    = bind_evtchn_to_irq(ctrl_if_evtchn);
    3.14 @@ -523,8 +523,8 @@ void __init ctrl_if_init(void)
    3.15      for ( i = 0; i < 256; i++ )
    3.16          ctrl_if_rxmsg_handler[i] = ctrl_if_rxmsg_default_handler;
    3.17  
    3.18 -    FRONT_RING_ATTACH(&ctrl_if_tx_ring, &ctrl_if->tx_ring);
    3.19 -    BACK_RING_ATTACH(&ctrl_if_rx_ring, &ctrl_if->rx_ring);
    3.20 +    FRONT_RING_ATTACH(&ctrl_if_tx_ring, &ctrl_if->tx_ring, CONTROL_RING_MEM);
    3.21 +    BACK_RING_ATTACH(&ctrl_if_rx_ring, &ctrl_if->rx_ring, CONTROL_RING_MEM);
    3.22      
    3.23      spin_lock_init(&ctrl_if_lock);
    3.24  
     4.1 --- a/linux-2.6.11-xen-sparse/drivers/xen/blkback/interface.c	Fri Apr 01 14:41:31 2005 +0000
     4.2 +++ b/linux-2.6.11-xen-sparse/drivers/xen/blkback/interface.c	Fri Apr 01 16:31:40 2005 +0000
     4.3 @@ -198,7 +198,7 @@ void blkif_connect(blkif_be_connect_t *c
     4.4      }
     4.5      sring = (blkif_sring_t *)vma->addr;
     4.6      SHARED_RING_INIT(sring);
     4.7 -    BACK_RING_INIT(&blkif->blk_ring, sring);
     4.8 +    BACK_RING_INIT(&blkif->blk_ring, sring, PAGE_SIZE);
     4.9      
    4.10      blkif->evtchn        = evtchn;
    4.11      blkif->irq           = bind_evtchn_to_irq(evtchn);
     5.1 --- a/linux-2.6.11-xen-sparse/drivers/xen/blkfront/blkfront.c	Fri Apr 01 14:41:31 2005 +0000
     5.2 +++ b/linux-2.6.11-xen-sparse/drivers/xen/blkfront/blkfront.c	Fri Apr 01 16:31:40 2005 +0000
     5.3 @@ -74,8 +74,10 @@ static blkif_response_t blkif_control_rs
     5.4  
     5.5  static blkif_front_ring_t blk_ring;
     5.6  
     5.7 +#define BLK_RING_SIZE __RING_SIZE((blkif_sring_t *)0, PAGE_SIZE)
     5.8 +
     5.9  unsigned long rec_ring_free;
    5.10 -blkif_request_t rec_ring[RING_SIZE(&blk_ring)];
    5.11 +blkif_request_t rec_ring[BLK_RING_SIZE];
    5.12  
    5.13  static int recovery = 0;           /* "Recovery in progress" flag.  Protected
    5.14                                      * by the blkif_io_lock */
    5.15 @@ -90,8 +92,7 @@ static inline int GET_ID_FROM_FREELIST( 
    5.16  {
    5.17      unsigned long free = rec_ring_free;
    5.18  
    5.19 -    if ( free > RING_SIZE(&blk_ring) )
    5.20 -        BUG();
    5.21 +    BUG_ON(free > BLK_RING_SIZE);
    5.22  
    5.23      rec_ring_free = rec_ring[free].id;
    5.24  
    5.25 @@ -522,8 +523,7 @@ static void kick_pending_request_queues(
    5.26  {
    5.27      /* We kick pending request queues if the ring is reasonably empty. */
    5.28      if ( (nr_pending != 0) && 
    5.29 -         (RING_PENDING_REQUESTS(&blk_ring) < 
    5.30 -          (RING_SIZE(&blk_ring) >> 1)) )
    5.31 +         (RING_PENDING_REQUESTS(&blk_ring) < (BLK_RING_SIZE >> 1)) )
    5.32      {
    5.33          /* Attempt to drain the queue, but bail if the ring becomes full. */
    5.34          while ( (nr_pending != 0) && !RING_FULL(&blk_ring) )
    5.35 @@ -1138,7 +1138,7 @@ static void blkif_disconnect(void)
    5.36      
    5.37      sring = (blkif_sring_t *)__get_free_page(GFP_KERNEL);
    5.38      SHARED_RING_INIT(sring);
    5.39 -    FRONT_RING_INIT(&blk_ring, sring);
    5.40 +    FRONT_RING_INIT(&blk_ring, sring, PAGE_SIZE);
    5.41      blkif_state  = BLKIF_STATE_DISCONNECTED;
    5.42      blkif_send_interface_connect();
    5.43  }
    5.44 @@ -1158,7 +1158,7 @@ static void blkif_recover(void)
    5.45       * This will need to be fixed once we have barriers */
    5.46  
    5.47      /* Stage 1 : Find active and move to safety. */
    5.48 -    for ( i = 0; i < RING_SIZE(&blk_ring); i++ )
    5.49 +    for ( i = 0; i < BLK_RING_SIZE; i++ )
    5.50      {
    5.51          if ( rec_ring[i].id >= PAGE_OFFSET )
    5.52          {
    5.53 @@ -1179,10 +1179,10 @@ static void blkif_recover(void)
    5.54      }
    5.55  
    5.56      /* Stage 3 : Set up free list. */
    5.57 -    for ( ; i < RING_SIZE(&blk_ring); i++ )
    5.58 +    for ( ; i < BLK_RING_SIZE; i++ )
    5.59          rec_ring[i].id = i+1;
    5.60      rec_ring_free = blk_ring.req_prod_pvt;
    5.61 -    rec_ring[RING_SIZE(&blk_ring)-1].id = 0x0fffffff;
    5.62 +    rec_ring[BLK_RING_SIZE-1].id = 0x0fffffff;
    5.63  
    5.64      /* blk_ring->req_prod will be set when we flush_requests().*/
    5.65      wmb();
    5.66 @@ -1369,9 +1369,9 @@ int __init xlblk_init(void)
    5.67      printk(KERN_INFO "xen_blk: Initialising virtual block device driver\n");
    5.68  
    5.69      rec_ring_free = 0;
    5.70 -    for ( i = 0; i < RING_SIZE(&blk_ring); i++ )
    5.71 +    for ( i = 0; i < BLK_RING_SIZE; i++ )
    5.72          rec_ring[i].id = i+1;
    5.73 -    rec_ring[RING_SIZE(&blk_ring)-1].id = 0x0fffffff;
    5.74 +    rec_ring[BLK_RING_SIZE-1].id = 0x0fffffff;
    5.75  
    5.76      (void)ctrl_if_register_receiver(CMSG_BLKIF_FE, blkif_ctrlif_rx,
    5.77                                      CALLBACK_IN_BLOCKING_CONTEXT);
     6.1 --- a/linux-2.6.11-xen-sparse/drivers/xen/blktap/blktap_controlmsg.c	Fri Apr 01 14:41:31 2005 +0000
     6.2 +++ b/linux-2.6.11-xen-sparse/drivers/xen/blktap/blktap_controlmsg.c	Fri Apr 01 16:31:40 2005 +0000
     6.3 @@ -229,7 +229,7 @@ void blkif_ptfe_connect(blkif_be_connect
     6.4  
     6.5      sring = (blkif_sring_t *)vma->addr;
     6.6      SHARED_RING_INIT(sring);
     6.7 -    BACK_RING_INIT(&blkif->blk_ring, sring);
     6.8 +    BACK_RING_INIT(&blkif->blk_ring, sring, PAGE_SIZE);
     6.9      
    6.10      blkif->evtchn        = evtchn;
    6.11      blkif->irq           = bind_evtchn_to_irq(evtchn);
    6.12 @@ -302,7 +302,7 @@ static void blkif_ptbe_disconnect(void)
    6.13      
    6.14      sring = (blkif_sring_t *)__get_free_page(GFP_KERNEL);
    6.15      SHARED_RING_INIT(sring);
    6.16 -    FRONT_RING_INIT(&blktap_be_ring, sring);
    6.17 +    FRONT_RING_INIT(&blktap_be_ring, sring, PAGE_SIZE);
    6.18      blktap_be_state  = BLKIF_STATE_DISCONNECTED;
    6.19      DPRINTK("Blkif-Passthrough-BE is now DISCONNECTED.\n");
    6.20      blkif_ptbe_send_interface_connect();
     7.1 --- a/linux-2.6.11-xen-sparse/drivers/xen/blktap/blktap_userdev.c	Fri Apr 01 14:41:31 2005 +0000
     7.2 +++ b/linux-2.6.11-xen-sparse/drivers/xen/blktap/blktap_userdev.c	Fri Apr 01 16:31:40 2005 +0000
     7.3 @@ -87,8 +87,7 @@ static int blktap_open(struct inode *ino
     7.4      SetPageReserved(virt_to_page(csring));
     7.5      
     7.6      SHARED_RING_INIT(csring);
     7.7 -    FRONT_RING_INIT(&blktap_uctrl_ring, csring);
     7.8 -
     7.9 +    FRONT_RING_INIT(&blktap_uctrl_ring, csring, PAGE_SIZE);
    7.10  
    7.11      /* Allocate the fe ring. */
    7.12      sring = (blkif_sring_t *)get_zeroed_page(GFP_KERNEL);
    7.13 @@ -98,7 +97,7 @@ static int blktap_open(struct inode *ino
    7.14      SetPageReserved(virt_to_page(sring));
    7.15      
    7.16      SHARED_RING_INIT(sring);
    7.17 -    FRONT_RING_INIT(&blktap_ufe_ring, sring);
    7.18 +    FRONT_RING_INIT(&blktap_ufe_ring, sring, PAGE_SIZE);
    7.19  
    7.20      /* Allocate the be ring. */
    7.21      sring = (blkif_sring_t *)get_zeroed_page(GFP_KERNEL);
    7.22 @@ -108,7 +107,7 @@ static int blktap_open(struct inode *ino
    7.23      SetPageReserved(virt_to_page(sring));
    7.24      
    7.25      SHARED_RING_INIT(sring);
    7.26 -    BACK_RING_INIT(&blktap_ube_ring, sring);
    7.27 +    BACK_RING_INIT(&blktap_ube_ring, sring, PAGE_SIZE);
    7.28  
    7.29      DPRINTK(KERN_ALERT "blktap open.\n");
    7.30  
     8.1 --- a/linux-2.6.11-xen-sparse/drivers/xen/usbback/interface.c	Fri Apr 01 14:41:31 2005 +0000
     8.2 +++ b/linux-2.6.11-xen-sparse/drivers/xen/usbback/interface.c	Fri Apr 01 16:31:40 2005 +0000
     8.3 @@ -195,7 +195,7 @@ void usbif_connect(usbif_be_connect_t *c
     8.4  
     8.5      sring = (usbif_sring_t *)vma->addr;
     8.6      SHARED_RING_INIT(sring);
     8.7 -    BACK_RING_INIT(&up->usb_ring, sring);
     8.8 +    BACK_RING_INIT(&up->usb_ring, sring, PAGE_SIZE);
     8.9  
    8.10      up->evtchn        = evtchn;
    8.11      up->irq           = bind_evtchn_to_irq(evtchn);
     9.1 --- a/linux-2.6.11-xen-sparse/drivers/xen/usbfront/usbfront.c	Fri Apr 01 14:41:31 2005 +0000
     9.2 +++ b/linux-2.6.11-xen-sparse/drivers/xen/usbfront/usbfront.c	Fri Apr 01 16:31:40 2005 +0000
     9.3 @@ -1549,7 +1549,7 @@ static void usbif_status_change(usbif_fe
     9.4          /* Move from CLOSED to DISCONNECTED state. */
     9.5          sring = (usbif_sring_t *)__get_free_page(GFP_KERNEL);
     9.6          SHARED_RING_INIT(sring);
     9.7 -        FRONT_RING_INIT(&xhci->usb_ring, sring);
     9.8 +        FRONT_RING_INIT(&xhci->usb_ring, sring, PAGE_SIZE);
     9.9          xhci->state  = USBIF_STATE_DISCONNECTED;
    9.10  
    9.11          /* Construct an interface-CONNECT message for the domain controller. */
    10.1 --- a/tools/blktap/blktaplib.c	Fri Apr 01 14:41:31 2005 +0000
    10.2 +++ b/tools/blktap/blktaplib.c	Fri Apr 01 16:31:40 2005 +0000
    10.3 @@ -385,13 +385,13 @@ int blktap_listen(void)
    10.4  
    10.5      /* assign the rings to the mapped memory */
    10.6      csring = (ctrl_sring_t *)blktap_mem;
    10.7 -    BACK_RING_INIT(&ctrl_ring, csring);
    10.8 +    BACK_RING_INIT(&ctrl_ring, csring, CONTROL_RING_MEM);
    10.9      
   10.10      sring = (blkif_sring_t *)((unsigned long)blktap_mem + PAGE_SIZE);
   10.11 -    FRONT_RING_INIT(&be_ring, sring);
   10.12 +    FRONT_RING_INIT(&be_ring, sring, PAGE_SIZE);
   10.13      
   10.14      sring = (blkif_sring_t *)((unsigned long)blktap_mem + (2 *PAGE_SIZE));
   10.15 -    BACK_RING_INIT(&fe_ring, sring);
   10.16 +    BACK_RING_INIT(&fe_ring, sring, PAGE_SIZE);
   10.17  
   10.18      mmap_vstart = (unsigned long)blktap_mem + (BLKTAP_RING_PAGES << PAGE_SHIFT);
   10.19      
    11.1 --- a/tools/xcs/ctrl_interface.c	Fri Apr 01 14:41:31 2005 +0000
    11.2 +++ b/tools/xcs/ctrl_interface.c	Fri Apr 01 16:31:40 2005 +0000
    11.3 @@ -186,8 +186,8 @@ int ctrl_chan_connect(control_channel_t 
    11.4      }
    11.5  
    11.6      /* Synchronise ring indexes. */
    11.7 -    BACK_RING_ATTACH(&cc->tx_ring, &cc->interface->tx_ring);
    11.8 -    FRONT_RING_ATTACH(&cc->rx_ring, &cc->interface->rx_ring);
    11.9 +    BACK_RING_ATTACH(&cc->tx_ring, &cc->interface->tx_ring, CONTROL_RING_MEM);
   11.10 +    FRONT_RING_ATTACH(&cc->rx_ring, &cc->interface->rx_ring, CONTROL_RING_MEM);
   11.11  
   11.12      cc->connected = 1;
   11.13  
    12.1 --- a/xen/include/public/io/blkif.h	Fri Apr 01 14:41:31 2005 +0000
    12.2 +++ b/xen/include/public/io/blkif.h	Fri Apr 01 16:31:40 2005 +0000
    12.3 @@ -57,7 +57,7 @@ typedef struct {
    12.4   * Generate blkif ring structures and types.
    12.5   */
    12.6  
    12.7 -DEFINE_RING_TYPES(blkif, blkif_request_t, blkif_response_t, PAGE_SIZE);
    12.8 +DEFINE_RING_TYPES(blkif, blkif_request_t, blkif_response_t);
    12.9  
   12.10  /*
   12.11   * BLKIF_OP_PROBE:
    13.1 --- a/xen/include/public/io/domain_controller.h	Fri Apr 01 14:41:31 2005 +0000
    13.2 +++ b/xen/include/public/io/domain_controller.h	Fri Apr 01 16:31:40 2005 +0000
    13.3 @@ -36,11 +36,17 @@ typedef u32 CONTROL_RING_IDX;
    13.4   * two 32-bit counters:  (64 * 8) + (2 * 4) = 520
    13.5   */
    13.6  #define CONTROL_RING_MEM 520
    13.7 -DEFINE_RING_TYPES(ctrl, control_msg_t, control_msg_t, CONTROL_RING_MEM);
    13.8 +DEFINE_RING_TYPES(ctrl, control_msg_t, control_msg_t);
    13.9  
   13.10  typedef struct {
   13.11 -    ctrl_sring_t tx_ring; /*    0: guest -> controller  */
   13.12 -    ctrl_sring_t rx_ring; /*  520: controller -> guest  */
   13.13 +    union {
   13.14 +        ctrl_sring_t tx_ring; /*    0: guest -> controller  */
   13.15 +        char __x[CONTROL_RING_MEM];
   13.16 +    } PACKED;
   13.17 +    union {
   13.18 +        ctrl_sring_t rx_ring; /*  520: controller -> guest  */
   13.19 +        char __y[CONTROL_RING_MEM];
   13.20 +    } PACKED;
   13.21  } PACKED control_if_t; /* 1040 bytes */
   13.22  
   13.23  /*
    14.1 --- a/xen/include/public/io/ring.h	Fri Apr 01 14:41:31 2005 +0000
    14.2 +++ b/xen/include/public/io/ring.h	Fri Apr 01 16:31:40 2005 +0000
    14.3 @@ -18,23 +18,21 @@ typedef unsigned int RING_IDX;
    14.4  /*
    14.5   * Calculate size of a shared ring, given the total available space for the
    14.6   * ring and indexes (_sz), and the name tag of the request/response structure.
    14.7 - * S ring contains as many entries as will fit, rounded down to the nearest 
    14.8 + * A ring contains as many entries as will fit, rounded down to the nearest 
    14.9   * power of two (so we can mask with (size-1) to loop around).
   14.10   */
   14.11 -#define __RING_SIZE(_name, _sz)                                         \
   14.12 -    (__RD32(((_sz) - 2*sizeof(RING_IDX)) / sizeof(union _name##_sring_entry)))
   14.13 +#define __RING_SIZE(_s, _sz) \
   14.14 +    (__RD32(((_sz) - 2*sizeof(RING_IDX)) / sizeof((_s)->ring[0])))
   14.15  
   14.16  /*
   14.17   *  Macros to make the correct C datatypes for a new kind of ring.
   14.18   * 
   14.19   *  To make a new ring datatype, you need to have two message structures,
   14.20 - *  let's say request_t, and response_t already defined.  You also need to
   14.21 - *  know how big the shared memory region you want the ring to occupy is
   14.22 - *  (PAGE_SIZE, of instance).
   14.23 + *  let's say request_t, and response_t already defined.
   14.24   *
   14.25   *  In a header where you want the ring datatype declared, you then do:
   14.26   *
   14.27 - *     DEFINE_RING_TYPES(mytag, request_t, response_t, PAGE_SIZE);
   14.28 + *     DEFINE_RING_TYPES(mytag, request_t, response_t);
   14.29   *
   14.30   *  These expand out to give you a set of types, as you can see below.
   14.31   *  The most important of these are:
   14.32 @@ -43,35 +41,38 @@ typedef unsigned int RING_IDX;
   14.33   *     mytag_front_ring_t - The 'front' half of the ring.
   14.34   *     mytag_back_ring_t  - The 'back' half of the ring.
   14.35   *
   14.36 - *  To initialize a ring in your code, on the front half, you do:
   14.37 + *  To initialize a ring in your code you need to know the location and size
   14.38 + *  of the shared memory area (PAGE_SIZE, for instance). To initialise
   14.39 + *  the front half:
   14.40   *
   14.41   *      mytag_front_ring_t front_ring;
   14.42   *
   14.43   *      SHARED_RING_INIT((mytag_sring_t *)shared_page);
   14.44 - *      FRONT_RING_INIT(&front_ring, (mytag_sring_t *)shared_page);
   14.45 + *      FRONT_RING_INIT(&front_ring, (mytag_sring_t *)shared_page, PAGE_SIZE);
   14.46   *
   14.47   *  Initializing the back follows similarly...
   14.48   */
   14.49           
   14.50 -#define DEFINE_RING_TYPES(__name, __req_t, __rsp_t, __size)             \
   14.51 +#define DEFINE_RING_TYPES(__name, __req_t, __rsp_t)                     \
   14.52                                                                          \
   14.53  /* Shared ring entry */                                                 \
   14.54  union __name##_sring_entry {                                            \
   14.55      __req_t req;                                                        \
   14.56      __rsp_t rsp;                                                        \
   14.57 -} PACKED;                                                               \
   14.58 +};                                                                      \
   14.59                                                                          \
   14.60  /* Shared ring page */                                                  \
   14.61  struct __name##_sring {                                                 \
   14.62      RING_IDX req_prod;                                                  \
   14.63      RING_IDX rsp_prod;                                                  \
   14.64 -    union __name##_sring_entry ring[__RING_SIZE(__name, __size)];       \
   14.65 -} PACKED;                                                               \
   14.66 +    union __name##_sring_entry ring[1]; /* variable-length */           \
   14.67 +};                                                                      \
   14.68                                                                          \
   14.69  /* "Front" end's private variables */                                   \
   14.70  struct __name##_front_ring {                                            \
   14.71      RING_IDX req_prod_pvt;                                              \
   14.72      RING_IDX rsp_cons;                                                  \
   14.73 +    unsigned int nr_ents;                                               \
   14.74      struct __name##_sring *sring;                                       \
   14.75  };                                                                      \
   14.76                                                                          \
   14.77 @@ -79,6 +80,7 @@ struct __name##_front_ring {            
   14.78  struct __name##_back_ring {                                             \
   14.79      RING_IDX rsp_prod_pvt;                                              \
   14.80      RING_IDX req_cons;                                                  \
   14.81 +    unsigned int nr_ents;                                               \
   14.82      struct __name##_sring *sring;                                       \
   14.83  };                                                                      \
   14.84                                                                          \
   14.85 @@ -102,41 +104,44 @@ typedef struct __name##_back_ring __name
   14.86   *   outstanding requests.
   14.87   */
   14.88  
   14.89 -
   14.90  /* Initialising empty rings */
   14.91  #define SHARED_RING_INIT(_s) do {                                       \
   14.92      (_s)->req_prod = 0;                                                 \
   14.93      (_s)->rsp_prod = 0;                                                 \
   14.94  } while(0)
   14.95  
   14.96 -#define FRONT_RING_INIT(_r, _s) do {                                    \
   14.97 +#define FRONT_RING_INIT(_r, _s, __size) do {                            \
   14.98      (_r)->req_prod_pvt = 0;                                             \
   14.99      (_r)->rsp_cons = 0;                                                 \
  14.100 +    (_r)->nr_ents = __RING_SIZE(_s, __size);                            \
  14.101      (_r)->sring = (_s);                                                 \
  14.102  } while (0)
  14.103  
  14.104 -#define BACK_RING_INIT(_r, _s) do {                                     \
  14.105 +#define BACK_RING_INIT(_r, _s, __size) do {                             \
  14.106      (_r)->rsp_prod_pvt = 0;                                             \
  14.107      (_r)->req_cons = 0;                                                 \
  14.108 +    (_r)->nr_ents = __RING_SIZE(_s, __size);                            \
  14.109      (_r)->sring = (_s);                                                 \
  14.110  } while (0)
  14.111  
  14.112  /* Initialize to existing shared indexes -- for recovery */
  14.113 -#define FRONT_RING_ATTACH(_r, _s) do {                                  \
  14.114 +#define FRONT_RING_ATTACH(_r, _s, __size) do {                          \
  14.115      (_r)->sring = (_s);                                                 \
  14.116      (_r)->req_prod_pvt = (_s)->req_prod;                                \
  14.117      (_r)->rsp_cons = (_s)->rsp_prod;                                    \
  14.118 +    (_r)->nr_ents = __RING_SIZE(_s, __size);                            \
  14.119  } while (0)
  14.120  
  14.121 -#define BACK_RING_ATTACH(_r, _s) do {                                   \
  14.122 +#define BACK_RING_ATTACH(_r, _s, __size) do {                           \
  14.123      (_r)->sring = (_s);                                                 \
  14.124      (_r)->rsp_prod_pvt = (_s)->rsp_prod;                                \
  14.125      (_r)->req_cons = (_s)->req_prod;                                    \
  14.126 +    (_r)->nr_ents = __RING_SIZE(_s, __size);                            \
  14.127  } while (0)
  14.128  
  14.129  /* How big is this ring? */
  14.130  #define RING_SIZE(_r)                                                   \
  14.131 -    (sizeof((_r)->sring->ring)/sizeof((_r)->sring->ring[0]))
  14.132 +    ((_r)->nr_ents)
  14.133  
  14.134  /* How many empty slots are on a ring? */
  14.135  #define RING_PENDING_REQUESTS(_r)                                       \
    15.1 --- a/xen/include/public/io/usbif.h	Fri Apr 01 14:41:31 2005 +0000
    15.2 +++ b/xen/include/public/io/usbif.h	Fri Apr 01 16:31:40 2005 +0000
    15.3 @@ -17,44 +17,44 @@
    15.4  #define USBIF_OP_RESET   2 /* Reset a virtual USB port.       */
    15.5  
    15.6  typedef struct {
    15.7 -    unsigned long  id;           /*  0: private guest value, echoed in resp  */
    15.8 -    u8             operation;    /*  4: USBIF_OP_???                         */
    15.9 +    unsigned long  id;           /* private guest value, echoed in resp  */
   15.10 +    u8             operation;    /* USBIF_OP_???                         */
   15.11      u8  __pad1;
   15.12 -    usbif_vdev_t   port;         /* 6 : guest virtual USB port               */
   15.13 -    unsigned long  devnum :7;    /* 8 : Device address, as seen by the guest.*/
   15.14 +    usbif_vdev_t   port;         /* guest virtual USB port               */
   15.15 +    unsigned long  devnum :7;    /* Device address, as seen by the guest.*/
   15.16      unsigned long  endpoint :4;  /* Device endpoint.                         */
   15.17      unsigned long  direction :1; /* Pipe direction.                          */
   15.18      unsigned long  speed :1;     /* Pipe speed.                              */
   15.19      unsigned long  pipe_type :2; /* Pipe type (iso, bulk, int, ctrl)         */
   15.20      unsigned long  __pad2 :18;
   15.21 -    unsigned long  transfer_buffer; /* 12: Machine address */
   15.22 -    unsigned long  length;          /* 16: Buffer length */
   15.23 -    unsigned long  transfer_flags;  /* 20: For now just pass Linux transfer
   15.24 +    unsigned long  transfer_buffer; /* Machine address */
   15.25 +    unsigned long  length;          /* Buffer length */
   15.26 +    unsigned long  transfer_flags;  /* For now just pass Linux transfer
   15.27                                       * flags - this may change. */
   15.28 -    unsigned char setup[8];         /* 22 Embed setup packets directly. */
   15.29 -    unsigned long  iso_schedule;    /* 30 Machine address of transfer sched (iso
   15.30 +    unsigned char setup[8];         /* Embed setup packets directly. */
   15.31 +    unsigned long  iso_schedule;    /* Machine address of transfer sched (iso
   15.32                                       * only) */
   15.33 -    unsigned long num_iso;        /* 34 : length of iso schedule */
   15.34 -    unsigned long timeout;        /* 38: timeout in ms */
   15.35 -} PACKED usbif_request_t; /* 42 */
   15.36 +    unsigned long num_iso;        /* length of iso schedule */
   15.37 +    unsigned long timeout;        /* timeout in ms */
   15.38 +} usbif_request_t;
   15.39  
   15.40  /* Data we need to pass:
   15.41   * - Transparently handle short packets or complain at us?
   15.42   */
   15.43  
   15.44  typedef struct {
   15.45 -    unsigned long   id;              /* 0: copied from request         */
   15.46 -    u8              operation;       /* 4: copied from request         */
   15.47 -    u8              data;            /* 5: Small chunk of in-band data */
   15.48 -    s16             status;          /* 6: USBIF_RSP_???               */
   15.49 +    unsigned long   id;              /* copied from request         */
   15.50 +    u8              operation;       /* copied from request         */
   15.51 +    u8              data;            /* Small chunk of in-band data */
   15.52 +    s16             status;          /* USBIF_RSP_???               */
   15.53      unsigned long   transfer_mutex;  /* Used for cancelling requests atomically. */
   15.54 -    unsigned long    length;          /* 8: How much data we really got */
   15.55 -} PACKED usbif_response_t;
   15.56 +    unsigned long    length;         /* How much data we really got */
   15.57 +} usbif_response_t;
   15.58  
   15.59  #define USBIF_RSP_ERROR  -1 /* non-specific 'error' */
   15.60  #define USBIF_RSP_OKAY    0 /* non-specific 'okay'  */
   15.61  
   15.62 -DEFINE_RING_TYPES(usbif, usbif_request_t, usbif_response_t, PAGE_SIZE);
   15.63 +DEFINE_RING_TYPES(usbif, usbif_request_t, usbif_response_t);
   15.64  
   15.65  typedef struct {
   15.66      unsigned long length; /* IN = expected, OUT = actual */