ia64/xen-unstable

changeset 4001:d174682dedf2

bitkeeper revision 1.1236.12.1 (422d6eadP8rlqEFriOCwM-dW2OyQTA)

Fix ring definitions to not use typeof. The accessor macros no longer
take a 'params' argument.
Signed-off-by: Keir Fraser <keir.fraser@cl.cam.ac.uk>
author kaf24@firebug.cl.cam.ac.uk
date Tue Mar 08 09:21:49 2005 +0000 (2005-03-08)
parents 205e127344e9
children 17d3d7dd527c
files linux-2.6.10-xen-sparse/arch/xen/kernel/ctrl_if.c linux-2.6.10-xen-sparse/drivers/xen/blkback/blkback.c linux-2.6.10-xen-sparse/drivers/xen/blkback/interface.c linux-2.6.10-xen-sparse/drivers/xen/blkfront/blkfront.c linux-2.6.10-xen-sparse/drivers/xen/blktap/blktap_controlmsg.c linux-2.6.10-xen-sparse/drivers/xen/blktap/blktap_datapath.c linux-2.6.10-xen-sparse/drivers/xen/blktap/blktap_userdev.c linux-2.6.10-xen-sparse/drivers/xen/usbback/interface.c linux-2.6.10-xen-sparse/drivers/xen/usbback/usbback.c linux-2.6.10-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/linux-2.6.10-xen-sparse/arch/xen/kernel/ctrl_if.c	Mon Mar 07 17:49:21 2005 +0000
     1.2 +++ b/linux-2.6.10-xen-sparse/arch/xen/kernel/ctrl_if.c	Tue Mar 08 09:21:49 2005 +0000
     1.3 @@ -50,11 +50,11 @@
     1.4   * Extra ring macros to sync a consumer index up to the public producer index. 
     1.5   * Generally UNSAFE, but we use it for recovery and shutdown in some cases.
     1.6   */
     1.7 -#define RING_DROP_PENDING_REQUESTS(_p, _r)                              \
     1.8 +#define RING_DROP_PENDING_REQUESTS(_r)                                  \
     1.9      do {                                                                \
    1.10          (_r)->req_cons = (_r)->sring->req_prod;                         \
    1.11      } while (0)
    1.12 -#define RING_DROP_PENDING_RESPONSES(_p, _r)                             \
    1.13 +#define RING_DROP_PENDING_RESPONSES(_r)                                 \
    1.14      do {                                                                \
    1.15          (_r)->rsp_cons = (_r)->sring->rsp_prod;                         \
    1.16      } while (0)
    1.17 @@ -125,7 +125,7 @@ static void ctrl_if_rxmsg_default_handle
    1.18  static void __ctrl_if_tx_tasklet(unsigned long data)
    1.19  {
    1.20      ctrl_msg_t *msg;
    1.21 -    int         was_full = RING_FULL(CTRL_RING, &ctrl_if_tx_ring);
    1.22 +    int         was_full = RING_FULL(&ctrl_if_tx_ring);
    1.23      RING_IDX    i, rp;
    1.24  
    1.25      i  = ctrl_if_tx_ring.rsp_cons;
    1.26 @@ -134,7 +134,7 @@ static void __ctrl_if_tx_tasklet(unsigne
    1.27  
    1.28      for ( ; i != rp; i++ )
    1.29      {
    1.30 -        msg = RING_GET_RESPONSE(CTRL_RING, &ctrl_if_tx_ring, i);
    1.31 +        msg = RING_GET_RESPONSE(&ctrl_if_tx_ring, i);
    1.32          
    1.33          DPRINTK("Rx-Rsp %u/%u :: %d/%d\n", i-1,
    1.34                  ctrl_if_tx_ring.sring->rsp_prod,
    1.35 @@ -157,7 +157,7 @@ static void __ctrl_if_tx_tasklet(unsigne
    1.36      smp_mb();
    1.37      ctrl_if_tx_ring.rsp_cons = i;
    1.38              
    1.39 -    if ( was_full && !RING_FULL(CTRL_RING, &ctrl_if_tx_ring) )
    1.40 +    if ( was_full && !RING_FULL(&ctrl_if_tx_ring) )
    1.41      {
    1.42          wake_up(&ctrl_if_tx_wait);
    1.43          run_task_queue(&ctrl_if_tx_tq);
    1.44 @@ -193,7 +193,7 @@ static void __ctrl_if_rx_tasklet(unsigne
    1.45   
    1.46      for ( ; i != rp; i++) 
    1.47      {
    1.48 -        pmsg = RING_GET_REQUEST(CTRL_RING, &ctrl_if_rx_ring, i);
    1.49 +        pmsg = RING_GET_REQUEST(&ctrl_if_rx_ring, i);
    1.50          memcpy(&msg, pmsg, offsetof(ctrl_msg_t, msg));
    1.51  
    1.52          DPRINTK("Rx-Req %u/%u :: %d/%d\n", i-1,
    1.53 @@ -227,10 +227,10 @@ static void __ctrl_if_rx_tasklet(unsigne
    1.54  static irqreturn_t ctrl_if_interrupt(int irq, void *dev_id,
    1.55                                       struct pt_regs *regs)
    1.56  {
    1.57 -    if ( RING_HAS_UNCONSUMED_RESPONSES(CTRL_RING, &ctrl_if_tx_ring) )
    1.58 +    if ( RING_HAS_UNCONSUMED_RESPONSES(&ctrl_if_tx_ring) )
    1.59          tasklet_schedule(&ctrl_if_tx_tasklet);
    1.60  
    1.61 -    if ( RING_HAS_UNCONSUMED_REQUESTS(CTRL_RING, &ctrl_if_rx_ring) )
    1.62 +    if ( RING_HAS_UNCONSUMED_REQUESTS(&ctrl_if_rx_ring) )
    1.63          tasklet_schedule(&ctrl_if_rx_tasklet);
    1.64  
    1.65      return IRQ_HANDLED;
    1.66 @@ -248,7 +248,7 @@ ctrl_if_send_message_noblock(
    1.67  
    1.68      spin_lock_irqsave(&ctrl_if_lock, flags);
    1.69  
    1.70 -    if ( RING_FULL(CTRL_RING, &ctrl_if_tx_ring) )
    1.71 +    if ( RING_FULL(&ctrl_if_tx_ring) )
    1.72      {
    1.73          spin_unlock_irqrestore(&ctrl_if_lock, flags);
    1.74          return -EAGAIN;
    1.75 @@ -269,11 +269,11 @@ ctrl_if_send_message_noblock(
    1.76              ctrl_if_tx_ring.rsp_cons,
    1.77              msg->type, msg->subtype);
    1.78  
    1.79 -    dmsg = RING_GET_REQUEST(CTRL_RING, &ctrl_if_tx_ring, 
    1.80 +    dmsg = RING_GET_REQUEST(&ctrl_if_tx_ring, 
    1.81              ctrl_if_tx_ring.req_prod_pvt);
    1.82      memcpy(dmsg, msg, sizeof(*msg));
    1.83      ctrl_if_tx_ring.req_prod_pvt++;
    1.84 -    RING_PUSH_REQUESTS(CTRL_RING, &ctrl_if_tx_ring);
    1.85 +    RING_PUSH_REQUESTS(&ctrl_if_tx_ring);
    1.86  
    1.87      spin_unlock_irqrestore(&ctrl_if_lock, flags);
    1.88  
    1.89 @@ -373,7 +373,7 @@ ctrl_if_enqueue_space_callback(
    1.90      struct tq_struct *task)
    1.91  {
    1.92      /* Fast path. */
    1.93 -    if ( !RING_FULL(CTRL_RING, &ctrl_if_tx_ring) )
    1.94 +    if ( !RING_FULL(&ctrl_if_tx_ring) )
    1.95          return 0;
    1.96  
    1.97      (void)queue_task(task, &ctrl_if_tx_tq);
    1.98 @@ -384,7 +384,7 @@ ctrl_if_enqueue_space_callback(
    1.99       * certainly return 'not full'.
   1.100       */
   1.101      smp_mb();
   1.102 -    return RING_FULL(CTRL_RING, &ctrl_if_tx_ring);
   1.103 +    return RING_FULL(&ctrl_if_tx_ring);
   1.104  }
   1.105  
   1.106  void
   1.107 @@ -404,13 +404,13 @@ ctrl_if_send_response(
   1.108              ctrl_if_rx_ring.rsp_prod_pvt, 
   1.109              msg->type, msg->subtype);
   1.110  
   1.111 -    dmsg = RING_GET_RESPONSE(CTRL_RING, &ctrl_if_rx_ring, 
   1.112 +    dmsg = RING_GET_RESPONSE(&ctrl_if_rx_ring, 
   1.113              ctrl_if_rx_ring.rsp_prod_pvt);
   1.114      if ( dmsg != msg )
   1.115          memcpy(dmsg, msg, sizeof(*msg));
   1.116  
   1.117      ctrl_if_rx_ring.rsp_prod_pvt++;
   1.118 -    RING_PUSH_RESPONSES(CTRL_RING, &ctrl_if_rx_ring);
   1.119 +    RING_PUSH_RESPONSES(&ctrl_if_rx_ring);
   1.120  
   1.121      spin_unlock_irqrestore(&ctrl_if_lock, flags);
   1.122  
   1.123 @@ -501,8 +501,8 @@ void ctrl_if_resume(void)
   1.124      }
   1.125  
   1.126      /* Sync up with shared indexes. */
   1.127 -    RING_DROP_PENDING_RESPONSES(CTRL_RING, &ctrl_if_tx_ring);
   1.128 -    RING_DROP_PENDING_REQUESTS(CTRL_RING, &ctrl_if_rx_ring);
   1.129 +    RING_DROP_PENDING_RESPONSES(&ctrl_if_tx_ring);
   1.130 +    RING_DROP_PENDING_REQUESTS(&ctrl_if_rx_ring);
   1.131  
   1.132      ctrl_if_evtchn = xen_start_info.domain_controller_evtchn;
   1.133      ctrl_if_irq    = bind_evtchn_to_irq(ctrl_if_evtchn);
   1.134 @@ -521,8 +521,8 @@ void __init ctrl_if_init(void)
   1.135      for ( i = 0; i < 256; i++ )
   1.136          ctrl_if_rxmsg_handler[i] = ctrl_if_rxmsg_default_handler;
   1.137  
   1.138 -    FRONT_RING_ATTACH(CTRL_RING, &ctrl_if_tx_ring, &ctrl_if->tx_ring);
   1.139 -    BACK_RING_ATTACH(CTRL_RING, &ctrl_if_rx_ring, &ctrl_if->rx_ring);
   1.140 +    FRONT_RING_ATTACH(&ctrl_if_tx_ring, &ctrl_if->tx_ring);
   1.141 +    BACK_RING_ATTACH(&ctrl_if_rx_ring, &ctrl_if->rx_ring);
   1.142      
   1.143      spin_lock_init(&ctrl_if_lock);
   1.144  
   1.145 @@ -552,7 +552,7 @@ int ctrl_if_transmitter_empty(void)
   1.146  
   1.147  void ctrl_if_discard_responses(void)
   1.148  {
   1.149 -    RING_DROP_PENDING_RESPONSES(CTRL_RING, &ctrl_if_tx_ring);
   1.150 +    RING_DROP_PENDING_RESPONSES(&ctrl_if_tx_ring);
   1.151  }
   1.152  
   1.153  EXPORT_SYMBOL(ctrl_if_send_message_noblock);
     2.1 --- a/linux-2.6.10-xen-sparse/drivers/xen/blkback/blkback.c	Mon Mar 07 17:49:21 2005 +0000
     2.2 +++ b/linux-2.6.10-xen-sparse/drivers/xen/blkback/blkback.c	Tue Mar 08 09:21:49 2005 +0000
     2.3 @@ -287,7 +287,7 @@ static int do_block_io_op(blkif_t *blkif
     2.4      rmb(); /* Ensure we see queued requests up to 'rp'. */
     2.5  
     2.6      for ( i = blk_ring->req_cons; 
     2.7 -         (i != rp) && !RING_REQUEST_CONS_OVERFLOW(BLKIF_RING, blk_ring, i);
     2.8 +         (i != rp) && !RING_REQUEST_CONS_OVERFLOW(blk_ring, i);
     2.9            i++ )
    2.10      {
    2.11          if ( (max_to_do-- == 0) || (NR_PENDING_REQS == MAX_PENDING_REQS) )
    2.12 @@ -296,7 +296,7 @@ static int do_block_io_op(blkif_t *blkif
    2.13              break;
    2.14          }
    2.15          
    2.16 -        req = RING_GET_REQUEST(BLKIF_RING, blk_ring, i);
    2.17 +        req = RING_GET_REQUEST(blk_ring, i);
    2.18          switch ( req->operation )
    2.19          {
    2.20          case BLKIF_OP_READ:
    2.21 @@ -561,13 +561,13 @@ static void make_response(blkif_t *blkif
    2.22  
    2.23      /* Place on the response ring for the relevant domain. */ 
    2.24      spin_lock_irqsave(&blkif->blk_ring_lock, flags);
    2.25 -    resp = RING_GET_RESPONSE(BLKIF_RING, blk_ring, blk_ring->rsp_prod_pvt);
    2.26 +    resp = RING_GET_RESPONSE(blk_ring, blk_ring->rsp_prod_pvt);
    2.27      resp->id        = id;
    2.28      resp->operation = op;
    2.29      resp->status    = st;
    2.30      wmb(); /* Ensure other side can see the response fields. */
    2.31      blk_ring->rsp_prod_pvt++;
    2.32 -    RING_PUSH_RESPONSES(BLKIF_RING, blk_ring);
    2.33 +    RING_PUSH_RESPONSES(blk_ring);
    2.34      spin_unlock_irqrestore(&blkif->blk_ring_lock, flags);
    2.35  
    2.36      /* Kick the relevant domain. */
     3.1 --- a/linux-2.6.10-xen-sparse/drivers/xen/blkback/interface.c	Mon Mar 07 17:49:21 2005 +0000
     3.2 +++ b/linux-2.6.10-xen-sparse/drivers/xen/blkback/interface.c	Tue Mar 08 09:21:49 2005 +0000
     3.3 @@ -197,8 +197,8 @@ void blkif_connect(blkif_be_connect_t *c
     3.4          return;
     3.5      }
     3.6      sring = (blkif_sring_t *)vma->addr;
     3.7 -    SHARED_RING_INIT(BLKIF_RING, sring);
     3.8 -    BACK_RING_INIT(BLKIF_RING, &blkif->blk_ring, sring);
     3.9 +    SHARED_RING_INIT(sring);
    3.10 +    BACK_RING_INIT(&blkif->blk_ring, sring);
    3.11      
    3.12      blkif->evtchn        = evtchn;
    3.13      blkif->irq           = bind_evtchn_to_irq(evtchn);
     4.1 --- a/linux-2.6.10-xen-sparse/drivers/xen/blkfront/blkfront.c	Mon Mar 07 17:49:21 2005 +0000
     4.2 +++ b/linux-2.6.10-xen-sparse/drivers/xen/blkfront/blkfront.c	Tue Mar 08 09:21:49 2005 +0000
     4.3 @@ -75,7 +75,7 @@ static blkif_response_t blkif_control_rs
     4.4  static blkif_front_ring_t blk_ring;
     4.5  
     4.6  unsigned long rec_ring_free;
     4.7 -blkif_request_t rec_ring[RING_SIZE(BLKIF_RING, &blk_ring)];
     4.8 +blkif_request_t rec_ring[RING_SIZE(&blk_ring)];
     4.9  
    4.10  static int recovery = 0;           /* "Recovery in progress" flag.  Protected
    4.11                                      * by the blkif_io_lock */
    4.12 @@ -90,7 +90,7 @@ static inline int GET_ID_FROM_FREELIST( 
    4.13  {
    4.14      unsigned long free = rec_ring_free;
    4.15  
    4.16 -    if ( free > RING_SIZE(BLKIF_RING, &blk_ring) )
    4.17 +    if ( free > RING_SIZE(&blk_ring) )
    4.18          BUG();
    4.19  
    4.20      rec_ring_free = rec_ring[free].id;
    4.21 @@ -151,7 +151,7 @@ static inline void translate_req_to_mfn(
    4.22  static inline void flush_requests(void)
    4.23  {
    4.24      DISABLE_SCATTERGATHER();
    4.25 -    RING_PUSH_REQUESTS(BLKIF_RING, &blk_ring);
    4.26 +    RING_PUSH_REQUESTS(&blk_ring);
    4.27      notify_via_evtchn(blkif_evtchn);
    4.28  }
    4.29  
    4.30 @@ -331,7 +331,7 @@ static int blkif_queue_request(struct re
    4.31          return 1;
    4.32  
    4.33      /* Fill out a communications ring structure. */
    4.34 -    ring_req = RING_GET_REQUEST(BLKIF_RING, &blk_ring, blk_ring.req_prod_pvt);
    4.35 +    ring_req = RING_GET_REQUEST(&blk_ring, blk_ring.req_prod_pvt);
    4.36      id = GET_ID_FROM_FREELIST();
    4.37      rec_ring[id].id = (unsigned long) req;
    4.38  
    4.39 @@ -384,7 +384,7 @@ void do_blkif_request(request_queue_t *r
    4.40              continue;
    4.41          }
    4.42  
    4.43 -        if ( RING_FULL(BLKIF_RING, &blk_ring) )
    4.44 +        if ( RING_FULL(&blk_ring) )
    4.45          {
    4.46              blk_stop_queue(rq);
    4.47              break;
    4.48 @@ -429,7 +429,7 @@ static irqreturn_t blkif_int(int irq, vo
    4.49      {
    4.50          unsigned long id;
    4.51  
    4.52 -        bret = RING_GET_RESPONSE(BLKIF_RING, &blk_ring, i);
    4.53 +        bret = RING_GET_RESPONSE(&blk_ring, i);
    4.54          id = bret->id;
    4.55          req = (struct request *)rec_ring[id].id;
    4.56          blkif_completion( &rec_ring[id] );
    4.57 @@ -515,11 +515,11 @@ static void kick_pending_request_queues(
    4.58  {
    4.59      /* We kick pending request queues if the ring is reasonably empty. */
    4.60      if ( (nr_pending != 0) && 
    4.61 -         (RING_PENDING_REQUESTS(BLKIF_RING, &blk_ring) < 
    4.62 -          (RING_SIZE(BLKIF_RING, &blk_ring) >> 1)) )
    4.63 +         (RING_PENDING_REQUESTS(&blk_ring) < 
    4.64 +          (RING_SIZE(&blk_ring) >> 1)) )
    4.65      {
    4.66          /* Attempt to drain the queue, but bail if the ring becomes full. */
    4.67 -        while ( (nr_pending != 0) && !RING_FULL(BLKIF_RING, &blk_ring) )
    4.68 +        while ( (nr_pending != 0) && !RING_FULL(&blk_ring) )
    4.69              do_blkif_request(pending_queues[--nr_pending]);
    4.70      }
    4.71  }
    4.72 @@ -813,7 +813,7 @@ static int blkif_queue_request(unsigned 
    4.73               (sg_dev == device) &&
    4.74               (sg_next_sect == sector_number) )
    4.75          {
    4.76 -            req = RING_GET_REQUEST(BLKIF_RING, &blk_ring, 
    4.77 +            req = RING_GET_REQUEST(&blk_ring, 
    4.78                                     blk_ring.req_prod_pvt - 1);
    4.79              bh = (struct buffer_head *)id;
    4.80       
    4.81 @@ -834,7 +834,7 @@ static int blkif_queue_request(unsigned 
    4.82  
    4.83              return 0;
    4.84          }
    4.85 -        else if ( RING_FULL(BLKIF_RING, &blk_ring) )
    4.86 +        else if ( RING_FULL(&blk_ring) )
    4.87          {
    4.88              return 1;
    4.89          }
    4.90 @@ -851,7 +851,7 @@ static int blkif_queue_request(unsigned 
    4.91      }
    4.92  
    4.93      /* Fill out a communications ring structure. */
    4.94 -    req = RING_GET_REQUEST(BLKIF_RING, &blk_ring, blk_ring.req_prod_pvt);
    4.95 +    req = RING_GET_REQUEST(&blk_ring, blk_ring.req_prod_pvt);
    4.96  
    4.97      xid = GET_ID_FROM_FREELIST();
    4.98      rec_ring[xid].id = id;
    4.99 @@ -976,7 +976,7 @@ static void blkif_int(int irq, void *dev
   4.100          unsigned long id;
   4.101          blkif_response_t *bret;
   4.102          
   4.103 -        bret = RING_GET_RESPONSE(BLKIF_RING, &blk_ring, i);
   4.104 +        bret = RING_GET_RESPONSE(&blk_ring, i);
   4.105          id = bret->id;
   4.106          bh = (struct buffer_head *)rec_ring[id].id; 
   4.107  
   4.108 @@ -1026,21 +1026,21 @@ void blkif_control_send(blkif_request_t 
   4.109      blkif_request_t *req_d;
   4.110  
   4.111   retry:
   4.112 -    while ( RING_FULL(BLKIF_RING, &blk_ring) )
   4.113 +    while ( RING_FULL(&blk_ring) )
   4.114      {
   4.115          set_current_state(TASK_INTERRUPTIBLE);
   4.116          schedule_timeout(1);
   4.117      }
   4.118  
   4.119      spin_lock_irqsave(&blkif_io_lock, flags);
   4.120 -    if ( RING_FULL(BLKIF_RING, &blk_ring) )
   4.121 +    if ( RING_FULL(&blk_ring) )
   4.122      {
   4.123          spin_unlock_irqrestore(&blkif_io_lock, flags);
   4.124          goto retry;
   4.125      }
   4.126  
   4.127      DISABLE_SCATTERGATHER();
   4.128 -    req_d = RING_GET_REQUEST(BLKIF_RING, &blk_ring, blk_ring.req_prod_pvt);
   4.129 +    req_d = RING_GET_REQUEST(&blk_ring, blk_ring.req_prod_pvt);
   4.130      *req_d = *req;    
   4.131  
   4.132      id = GET_ID_FROM_FREELIST();
   4.133 @@ -1130,8 +1130,8 @@ static void blkif_disconnect(void)
   4.134          free_page((unsigned long)blk_ring.sring);
   4.135      
   4.136      sring = (blkif_sring_t *)__get_free_page(GFP_KERNEL);
   4.137 -    SHARED_RING_INIT(BLKIF_RING, sring);
   4.138 -    FRONT_RING_INIT(BLKIF_RING, &blk_ring, sring);
   4.139 +    SHARED_RING_INIT(sring);
   4.140 +    FRONT_RING_INIT(&blk_ring, sring);
   4.141      blkif_state  = BLKIF_STATE_DISCONNECTED;
   4.142      blkif_send_interface_connect();
   4.143  }
   4.144 @@ -1151,11 +1151,11 @@ static void blkif_recover(void)
   4.145       * This will need to be fixed once we have barriers */
   4.146  
   4.147      /* Stage 1 : Find active and move to safety. */
   4.148 -    for ( i = 0; i < RING_SIZE(BLKIF_RING, &blk_ring); i++ )
   4.149 +    for ( i = 0; i < RING_SIZE(&blk_ring); i++ )
   4.150      {
   4.151          if ( rec_ring[i].id >= PAGE_OFFSET )
   4.152          {
   4.153 -            req = RING_GET_REQUEST(BLKIF_RING, &blk_ring, 
   4.154 +            req = RING_GET_REQUEST(&blk_ring, 
   4.155                                     blk_ring.req_prod_pvt);
   4.156              translate_req_to_mfn(req, &rec_ring[i]);
   4.157              blk_ring.req_prod_pvt++;
   4.158 @@ -1165,17 +1165,17 @@ static void blkif_recover(void)
   4.159      /* Stage 2 : Set up shadow list. */
   4.160      for ( i = 0; i < blk_ring.req_prod_pvt; i++ ) 
   4.161      {
   4.162 -        req = RING_GET_REQUEST(BLKIF_RING, &blk_ring, i);
   4.163 +        req = RING_GET_REQUEST(&blk_ring, i);
   4.164          rec_ring[i].id = req->id;  
   4.165          req->id = i;
   4.166          translate_req_to_pfn(&rec_ring[i], req);
   4.167      }
   4.168  
   4.169      /* Stage 3 : Set up free list. */
   4.170 -    for ( ; i < RING_SIZE(BLKIF_RING, &blk_ring); i++ )
   4.171 +    for ( ; i < RING_SIZE(&blk_ring); i++ )
   4.172          rec_ring[i].id = i+1;
   4.173      rec_ring_free = blk_ring.req_prod_pvt;
   4.174 -    rec_ring[RING_SIZE(BLKIF_RING, &blk_ring)-1].id = 0x0fffffff;
   4.175 +    rec_ring[RING_SIZE(&blk_ring)-1].id = 0x0fffffff;
   4.176  
   4.177      /* blk_ring->req_prod will be set when we flush_requests().*/
   4.178      wmb();
   4.179 @@ -1368,9 +1368,9 @@ int __init xlblk_init(void)
   4.180      printk(KERN_INFO "xen_blk: Initialising virtual block device driver\n");
   4.181  
   4.182      rec_ring_free = 0;
   4.183 -    for ( i = 0; i < RING_SIZE(BLKIF_RING, &blk_ring); i++ )
   4.184 +    for ( i = 0; i < RING_SIZE(&blk_ring); i++ )
   4.185          rec_ring[i].id = i+1;
   4.186 -    rec_ring[RING_SIZE(BLKIF_RING, &blk_ring)-1].id = 0x0fffffff;
   4.187 +    rec_ring[RING_SIZE(&blk_ring)-1].id = 0x0fffffff;
   4.188  
   4.189      (void)ctrl_if_register_receiver(CMSG_BLKIF_FE, blkif_ctrlif_rx,
   4.190                                      CALLBACK_IN_BLOCKING_CONTEXT);
     5.1 --- a/linux-2.6.10-xen-sparse/drivers/xen/blktap/blktap_controlmsg.c	Mon Mar 07 17:49:21 2005 +0000
     5.2 +++ b/linux-2.6.10-xen-sparse/drivers/xen/blktap/blktap_controlmsg.c	Tue Mar 08 09:21:49 2005 +0000
     5.3 @@ -228,8 +228,8 @@ void blkif_ptfe_connect(blkif_be_connect
     5.4      }
     5.5  
     5.6      sring = (blkif_sring_t *)vma->addr;
     5.7 -    SHARED_RING_INIT(BLKIF_RING, sring);
     5.8 -    BACK_RING_INIT(BLKIF_RING, &blkif->blk_ring, sring);
     5.9 +    SHARED_RING_INIT(sring);
    5.10 +    BACK_RING_INIT(&blkif->blk_ring, sring);
    5.11      
    5.12      blkif->evtchn        = evtchn;
    5.13      blkif->irq           = bind_evtchn_to_irq(evtchn);
    5.14 @@ -301,8 +301,8 @@ static void blkif_ptbe_disconnect(void)
    5.15      blkif_sring_t *sring;
    5.16      
    5.17      sring = (blkif_sring_t *)__get_free_page(GFP_KERNEL);
    5.18 -    SHARED_RING_INIT(BLKIF_RING, sring);
    5.19 -    FRONT_RING_INIT(BLKIF_RING, &blktap_be_ring, sring);
    5.20 +    SHARED_RING_INIT(sring);
    5.21 +    FRONT_RING_INIT(&blktap_be_ring, sring);
    5.22      blktap_be_state  = BLKIF_STATE_DISCONNECTED;
    5.23      DPRINTK("Blkif-Passthrough-BE is now DISCONNECTED.\n");
    5.24      blkif_ptbe_send_interface_connect();
     6.1 --- a/linux-2.6.10-xen-sparse/drivers/xen/blktap/blktap_datapath.c	Mon Mar 07 17:49:21 2005 +0000
     6.2 +++ b/linux-2.6.10-xen-sparse/drivers/xen/blktap/blktap_datapath.c	Tue Mar 08 09:21:49 2005 +0000
     6.3 @@ -97,7 +97,7 @@ inline int write_resp_to_fe_ring(blkif_t
     6.4      ar = &active_reqs[ID_TO_IDX(rsp->id)];
     6.5      rsp->id = ar->id;
     6.6              
     6.7 -    resp_d = RING_GET_RESPONSE(BLKIF_RING, &blkif->blk_ring,
     6.8 +    resp_d = RING_GET_RESPONSE(&blkif->blk_ring,
     6.9              blkif->blk_ring.rsp_prod_pvt);
    6.10      memcpy(resp_d, rsp, sizeof(blkif_response_t));
    6.11      wmb();
    6.12 @@ -118,7 +118,7 @@ inline int write_req_to_be_ring(blkif_re
    6.13          return 0;
    6.14      }
    6.15      
    6.16 -    req_d = RING_GET_REQUEST(BLKIF_RING, &blktap_be_ring,
    6.17 +    req_d = RING_GET_REQUEST(&blktap_be_ring,
    6.18              blktap_be_ring.req_prod_pvt);
    6.19      memcpy(req_d, req, sizeof(blkif_request_t));
    6.20      wmb();
    6.21 @@ -129,7 +129,7 @@ inline int write_req_to_be_ring(blkif_re
    6.22  
    6.23  inline void kick_fe_domain(blkif_t *blkif) 
    6.24  {
    6.25 -    RING_PUSH_RESPONSES(BLKIF_RING, &blkif->blk_ring);
    6.26 +    RING_PUSH_RESPONSES(&blkif->blk_ring);
    6.27      notify_via_evtchn(blkif->evtchn);
    6.28      DPRINTK("notified FE(dom %u)\n", blkif->domid);
    6.29      
    6.30 @@ -141,7 +141,7 @@ inline void kick_be_domain(void)
    6.31          return;
    6.32      
    6.33      wmb(); /* Ensure that the frontend can see the requests. */
    6.34 -    RING_PUSH_REQUESTS(BLKIF_RING, &blktap_be_ring);
    6.35 +    RING_PUSH_REQUESTS(&blktap_be_ring);
    6.36      notify_via_evtchn(blktap_be_evtchn);
    6.37      DPRINTK("notified BE\n");
    6.38  }
    6.39 @@ -299,7 +299,7 @@ static int do_block_io_op(blkif_t *blkif
    6.40      
    6.41      for ( i = blkif->blk_ring.req_cons; 
    6.42           (i != rp) && 
    6.43 -            !RING_REQUEST_CONS_OVERFLOW(BLKIF_RING, &blkif->blk_ring, i);
    6.44 +            !RING_REQUEST_CONS_OVERFLOW(&blkif->blk_ring, i);
    6.45            i++ )
    6.46      {
    6.47          
    6.48 @@ -309,7 +309,7 @@ static int do_block_io_op(blkif_t *blkif
    6.49              break;
    6.50          }
    6.51          
    6.52 -        req_s = RING_GET_REQUEST(BLKIF_RING, &blkif->blk_ring, i);
    6.53 +        req_s = RING_GET_REQUEST(&blkif->blk_ring, i);
    6.54          /* This is a new request:  
    6.55           * Assign an active request record, and remap the id. 
    6.56           */
    6.57 @@ -354,10 +354,9 @@ static int do_block_io_op(blkif_t *blkif
    6.58              /* copy the request message to the BERing */
    6.59  
    6.60              DPRINTK("blktap: FERing[%u] -> BERing[%u]\n", 
    6.61 -                    (unsigned)__SHARED_RING_MASK(BLKIF_RING, 
    6.62 -                        blktap_be_ring.sring, i), 
    6.63 -                    (unsigned)__SHARED_RING_MASK(BLKIF_RING, 
    6.64 -                        blktap_be_ring.sring, blktap_be_ring.req_prod_pvt));
    6.65 +                    (unsigned)i & (RING_SIZE(&blktap_be_ring)-1),
    6.66 +                    (unsigned)blktap_be_ring.req_prod_pvt & 
    6.67 +                    (RING_SIZE((&blktap_be_ring)-1)));
    6.68              
    6.69              write_req_to_be_ring(req_s);
    6.70              notify_be = 1;
    6.71 @@ -398,7 +397,7 @@ irqreturn_t blkif_ptbe_int(int irq, void
    6.72        
    6.73      for ( i = blktap_be_ring.rsp_cons; i != rp; i++)
    6.74      {
    6.75 -        resp_s = RING_GET_RESPONSE(BLKIF_RING, &blktap_be_ring, i);
    6.76 +        resp_s = RING_GET_RESPONSE(&blktap_be_ring, i);
    6.77          
    6.78          /* BE -> FE interposition point is here. */
    6.79      
    6.80 @@ -426,11 +425,9 @@ irqreturn_t blkif_ptbe_int(int irq, void
    6.81              /* Copy the response message to FERing */
    6.82           
    6.83              DPRINTK("blktap: BERing[%u] -> FERing[%u]\n", 
    6.84 -                    (unsigned)__SHARED_RING_MASK(BLKIF_RING, 
    6.85 -                        blkif->blk_ring.sring, i), 
    6.86 -                    (unsigned)__SHARED_RING_MASK(BLKIF_RING, 
    6.87 -                        blkif->blk_ring.sring, 
    6.88 -                        blkif->blk_ring.rsp_prod_pvt));
    6.89 +                    (unsigned)i & (RING_SIZE(&blkif->blk_ring)-1),
    6.90 +                    (unsigned)blkif->blk_ring.rsp_prod_pvt & 
    6.91 +                    (RING_SIZE((&blkif->blk_ring)-1)));
    6.92  
    6.93              write_resp_to_fe_ring(blkif, resp_s);
    6.94              kick_fe_domain(blkif);
     7.1 --- a/linux-2.6.10-xen-sparse/drivers/xen/blktap/blktap_userdev.c	Mon Mar 07 17:49:21 2005 +0000
     7.2 +++ b/linux-2.6.10-xen-sparse/drivers/xen/blktap/blktap_userdev.c	Tue Mar 08 09:21:49 2005 +0000
     7.3 @@ -86,8 +86,8 @@ static int blktap_open(struct inode *ino
     7.4  
     7.5      SetPageReserved(virt_to_page(csring));
     7.6      
     7.7 -    SHARED_RING_INIT(CTRL_RING, csring);
     7.8 -    FRONT_RING_INIT(CTRL_RING, &blktap_uctrl_ring, csring);
     7.9 +    SHARED_RING_INIT(csring);
    7.10 +    FRONT_RING_INIT(&blktap_uctrl_ring, csring);
    7.11  
    7.12  
    7.13      /* Allocate the fe ring. */
    7.14 @@ -97,8 +97,8 @@ static int blktap_open(struct inode *ino
    7.15  
    7.16      SetPageReserved(virt_to_page(sring));
    7.17      
    7.18 -    SHARED_RING_INIT(BLKIF_RING, sring);
    7.19 -    FRONT_RING_INIT(BLKIF_RING, &blktap_ufe_ring, sring);
    7.20 +    SHARED_RING_INIT(sring);
    7.21 +    FRONT_RING_INIT(&blktap_ufe_ring, sring);
    7.22  
    7.23      /* Allocate the be ring. */
    7.24      sring = (blkif_sring_t *)get_zeroed_page(GFP_KERNEL);
    7.25 @@ -107,8 +107,8 @@ static int blktap_open(struct inode *ino
    7.26  
    7.27      SetPageReserved(virt_to_page(sring));
    7.28      
    7.29 -    SHARED_RING_INIT(BLKIF_RING, sring);
    7.30 -    BACK_RING_INIT(BLKIF_RING, &blktap_ube_ring, sring);
    7.31 +    SHARED_RING_INIT(sring);
    7.32 +    BACK_RING_INIT(&blktap_ube_ring, sring);
    7.33  
    7.34      DPRINTK(KERN_ALERT "blktap open.\n");
    7.35  
    7.36 @@ -252,13 +252,13 @@ static unsigned int blktap_poll(struct f
    7.37  {
    7.38          poll_wait(file, &blktap_wait, wait);
    7.39  
    7.40 -        if ( RING_HAS_UNPUSHED_REQUESTS(BLKIF_RING, &blktap_uctrl_ring) ||
    7.41 -             RING_HAS_UNPUSHED_REQUESTS(BLKIF_RING, &blktap_ufe_ring)   ||
    7.42 -             RING_HAS_UNPUSHED_RESPONSES(BLKIF_RING, &blktap_ube_ring) ) {
    7.43 +        if ( RING_HAS_UNPUSHED_REQUESTS(&blktap_uctrl_ring) ||
    7.44 +             RING_HAS_UNPUSHED_REQUESTS(&blktap_ufe_ring)   ||
    7.45 +             RING_HAS_UNPUSHED_RESPONSES(&blktap_ube_ring) ) {
    7.46  
    7.47 -            RING_PUSH_REQUESTS(BLKIF_RING, &blktap_uctrl_ring);
    7.48 -            RING_PUSH_REQUESTS(BLKIF_RING, &blktap_ufe_ring);
    7.49 -            RING_PUSH_RESPONSES(BLKIF_RING, &blktap_ube_ring);
    7.50 +            RING_PUSH_REQUESTS(&blktap_uctrl_ring);
    7.51 +            RING_PUSH_REQUESTS(&blktap_ufe_ring);
    7.52 +            RING_PUSH_RESPONSES(&blktap_ube_ring);
    7.53              return POLLIN | POLLRDNORM;
    7.54          }
    7.55  
    7.56 @@ -298,12 +298,12 @@ int blktap_write_fe_ring(blkif_request_t
    7.57          return 0;
    7.58      }
    7.59  
    7.60 -    if ( RING_FULL(BLKIF_RING, &blktap_ufe_ring) ) {
    7.61 +    if ( RING_FULL(&blktap_ufe_ring) ) {
    7.62          DPRINTK("blktap: fe_ring is full, can't add.\n");
    7.63          return 0;
    7.64      }
    7.65  
    7.66 -    target = RING_GET_REQUEST(BLKIF_RING, &blktap_ufe_ring,
    7.67 +    target = RING_GET_REQUEST(&blktap_ufe_ring,
    7.68              blktap_ufe_ring.req_prod_pvt);
    7.69      memcpy(target, req, sizeof(*req));
    7.70  
    7.71 @@ -344,7 +344,7 @@ int blktap_write_be_ring(blkif_response_
    7.72  
    7.73      /* No test for fullness in the response direction. */
    7.74  
    7.75 -    target = RING_GET_RESPONSE(BLKIF_RING, &blktap_ube_ring,
    7.76 +    target = RING_GET_RESPONSE(&blktap_ube_ring,
    7.77              blktap_ube_ring.rsp_prod_pvt);
    7.78      memcpy(target, rsp, sizeof(*rsp));
    7.79  
    7.80 @@ -375,7 +375,7 @@ static int blktap_read_fe_ring(void)
    7.81          
    7.82          for ( i = blktap_ufe_ring.rsp_cons; i != rp; i++ )
    7.83          {
    7.84 -            resp_s = RING_GET_RESPONSE(BLKIF_RING, &blktap_ufe_ring, i);
    7.85 +            resp_s = RING_GET_RESPONSE(&blktap_ufe_ring, i);
    7.86              
    7.87              DPRINTK("resp->fe_ring\n");
    7.88              ar = lookup_active_req(ID_TO_IDX(resp_s->id));
    7.89 @@ -406,7 +406,7 @@ static int blktap_read_be_ring(void)
    7.90          rmb();
    7.91          for ( i = blktap_ube_ring.req_cons; i != rp; i++ )
    7.92          {
    7.93 -            req_s = RING_GET_REQUEST(BLKIF_RING, &blktap_ube_ring, i);
    7.94 +            req_s = RING_GET_REQUEST(&blktap_ube_ring, i);
    7.95  
    7.96              DPRINTK("req->be_ring\n");
    7.97              write_req_to_be_ring(req_s);
    7.98 @@ -430,7 +430,7 @@ int blktap_write_ctrl_ring(ctrl_msg_t *m
    7.99  
   7.100      /* No test for fullness in the response direction. */
   7.101  
   7.102 -    target = RING_GET_REQUEST(CTRL_RING, &blktap_uctrl_ring,
   7.103 +    target = RING_GET_REQUEST(&blktap_uctrl_ring,
   7.104              blktap_uctrl_ring.req_prod_pvt);
   7.105      memcpy(target, msg, sizeof(*msg));
   7.106  
     8.1 --- a/linux-2.6.10-xen-sparse/drivers/xen/usbback/interface.c	Mon Mar 07 17:49:21 2005 +0000
     8.2 +++ b/linux-2.6.10-xen-sparse/drivers/xen/usbback/interface.c	Tue Mar 08 09:21:49 2005 +0000
     8.3 @@ -194,8 +194,8 @@ void usbif_connect(usbif_be_connect_t *c
     8.4      }
     8.5  
     8.6      sring = (usbif_sring_t *)vma->addr;
     8.7 -    SHARED_RING_INIT(USBIF_RING, sring);
     8.8 -    BACK_RING_INIT(USBIF_RING, &up->usb_ring, sring);
     8.9 +    SHARED_RING_INIT(sring);
    8.10 +    BACK_RING_INIT(&up->usb_ring, sring);
    8.11  
    8.12      up->evtchn        = evtchn;
    8.13      up->irq           = bind_evtchn_to_irq(evtchn);
     9.1 --- a/linux-2.6.10-xen-sparse/drivers/xen/usbback/usbback.c	Mon Mar 07 17:49:21 2005 +0000
     9.2 +++ b/linux-2.6.10-xen-sparse/drivers/xen/usbback/usbback.c	Tue Mar 08 09:21:49 2005 +0000
     9.3 @@ -398,7 +398,7 @@ static int do_usb_io_op(usbif_priv_t *up
     9.4      
     9.5      /* Take items off the comms ring, taking care not to overflow. */
     9.6      for ( i = usb_ring->req_cons; 
     9.7 -          (i != rp) && !RING_REQUEST_CONS_OVERFLOW(USBIF_RING, usb_ring, i);
     9.8 +          (i != rp) && !RING_REQUEST_CONS_OVERFLOW(usb_ring, i);
     9.9            i++ )
    9.10      {
    9.11          if ( (max_to_do-- == 0) || (NR_PENDING_REQS == MAX_PENDING_REQS) )
    9.12 @@ -407,7 +407,7 @@ static int do_usb_io_op(usbif_priv_t *up
    9.13              break;
    9.14          }
    9.15  
    9.16 -        req = RING_GET_REQUEST(USBIF_RING, usb_ring, i);
    9.17 +        req = RING_GET_REQUEST(usb_ring, i);
    9.18          
    9.19          switch ( req->operation )
    9.20          {
    9.21 @@ -808,7 +808,7 @@ static void make_response(usbif_priv_t *
    9.22  
    9.23      /* Place on the response ring for the relevant domain. */ 
    9.24      spin_lock_irqsave(&up->usb_ring_lock, flags);
    9.25 -    resp = RING_GET_RESPONSE(USBIF_RING, usb_ring, usb_ring->rsp_prod_pvt);
    9.26 +    resp = RING_GET_RESPONSE(usb_ring, usb_ring->rsp_prod_pvt);
    9.27      resp->id        = id;
    9.28      resp->operation = op;
    9.29      resp->status    = st;
    9.30 @@ -819,7 +819,7 @@ static void make_response(usbif_priv_t *
    9.31      dump_response(resp);
    9.32  
    9.33      usb_ring->rsp_prod_pvt++;
    9.34 -    RING_PUSH_RESPONSES(USBIF_RING, usb_ring);
    9.35 +    RING_PUSH_RESPONSES(usb_ring);
    9.36      spin_unlock_irqrestore(&up->usb_ring_lock, flags);
    9.37  
    9.38      /* Kick the relevant domain. */
    10.1 --- a/linux-2.6.10-xen-sparse/drivers/xen/usbfront/usbfront.c	Mon Mar 07 17:49:21 2005 +0000
    10.2 +++ b/linux-2.6.10-xen-sparse/drivers/xen/usbfront/usbfront.c	Tue Mar 08 09:21:49 2005 +0000
    10.3 @@ -214,7 +214,7 @@ static int xhci_queue_req(struct urb *ur
    10.4  #endif
    10.5          
    10.6  
    10.7 -        if ( RING_FULL(USBIF_RING, usb_ring) )
    10.8 +        if ( RING_FULL(usb_ring) )
    10.9          {
   10.10                  printk(KERN_WARNING
   10.11                         "xhci_queue_req(): USB ring full, not queuing request\n");
   10.12 @@ -222,7 +222,7 @@ static int xhci_queue_req(struct urb *ur
   10.13          }
   10.14  
   10.15          /* Stick something in the shared communications ring. */
   10.16 -	req = RING_GET_REQUEST(USBIF_RING, usb_ring, usb_ring->req_prod_pvt);
   10.17 +	req = RING_GET_REQUEST(usb_ring, usb_ring->req_prod_pvt);
   10.18  
   10.19          req->operation       = USBIF_OP_IO;
   10.20          req->port            = 0; /* We don't care what the port is. */
   10.21 @@ -251,7 +251,7 @@ static int xhci_queue_req(struct urb *ur
   10.22                  memset(req->setup, 0, 8);
   10.23          
   10.24          usb_ring->req_prod_pvt++;
   10.25 -        RING_PUSH_REQUESTS(USBIF_RING, usb_ring);
   10.26 +        RING_PUSH_REQUESTS(usb_ring);
   10.27  
   10.28  	notify_via_evtchn(xhci->evtchn);
   10.29  
   10.30 @@ -277,7 +277,7 @@ static inline usbif_request_t *xhci_queu
   10.31  	       usbif->resp_prod, xhci->usb_resp_cons);
   10.32  #endif
   10.33          
   10.34 -        if ( RING_FULL(USBIF_RING, usb_ring) )
   10.35 +        if ( RING_FULL(usb_ring) )
   10.36          {
   10.37                  printk(KERN_WARNING
   10.38                         "xhci_queue_probe(): ring full, not queuing request\n");
   10.39 @@ -285,7 +285,7 @@ static inline usbif_request_t *xhci_queu
   10.40          }
   10.41  
   10.42          /* Stick something in the shared communications ring. */
   10.43 -        req = RING_GET_REQUEST(USBIF_RING, usb_ring, usb_ring->req_prod_pvt);
   10.44 +        req = RING_GET_REQUEST(usb_ring, usb_ring->req_prod_pvt);
   10.45  
   10.46          memset(req, sizeof(*req), 0);
   10.47  
   10.48 @@ -293,7 +293,7 @@ static inline usbif_request_t *xhci_queu
   10.49          req->port            = port;
   10.50  
   10.51          usb_ring->req_prod_pvt++;
   10.52 -        RING_PUSH_REQUESTS(USBIF_RING, usb_ring);
   10.53 +        RING_PUSH_REQUESTS(usb_ring);
   10.54  
   10.55  	notify_via_evtchn(xhci->evtchn);
   10.56  
   10.57 @@ -313,7 +313,7 @@ static int xhci_port_reset(usbif_vdev_t 
   10.58          xhci->awaiting_reset = 1;
   10.59          
   10.60          /* Stick something in the shared communications ring. */
   10.61 -	req = RING_GET_REQUEST(USBIF_RING, usb_ring, usb_ring->req_prod_pvt);
   10.62 +	req = RING_GET_REQUEST(usb_ring, usb_ring->req_prod_pvt);
   10.63  
   10.64          memset(req, sizeof(*req), 0);
   10.65  
   10.66 @@ -321,7 +321,7 @@ static int xhci_port_reset(usbif_vdev_t 
   10.67          req->port            = port;
   10.68          
   10.69          usb_ring->req_prod_pvt++;
   10.70 -	RING_PUSH_REQUESTS(USBIF_RING, usb_ring);
   10.71 +	RING_PUSH_REQUESTS(usb_ring);
   10.72  
   10.73  	notify_via_evtchn(xhci->evtchn);
   10.74  
   10.75 @@ -427,7 +427,7 @@ static void xhci_drain_ring(void)
   10.76          /* Take items off the comms ring, taking care not to overflow. */
   10.77          for ( i = usb_ring->rsp_cons; i != rp; i++ )
   10.78          {
   10.79 -            resp = RING_GET_RESPONSE(USBIF_RING, usb_ring, i);
   10.80 +            resp = RING_GET_RESPONSE(usb_ring, i);
   10.81              
   10.82              /* May need to deal with batching and with putting a ceiling on
   10.83                 the number dispatched for performance and anti-dos reasons */
   10.84 @@ -1497,8 +1497,8 @@ static void usbif_status_change(usbif_fe
   10.85  
   10.86          /* Move from CLOSED to DISCONNECTED state. */
   10.87          sring = (usbif_sring_t *)__get_free_page(GFP_KERNEL);
   10.88 -        SHARED_RING_INIT(USBIF_RING, sring);
   10.89 -        FRONT_RING_INIT(USBIF_RING, &xhci->usb_ring, sring);
   10.90 +        SHARED_RING_INIT(sring);
   10.91 +        FRONT_RING_INIT(&xhci->usb_ring, sring);
   10.92          xhci->state  = USBIF_STATE_DISCONNECTED;
   10.93  
   10.94          /* Construct an interface-CONNECT message for the domain controller. */
    11.1 --- a/tools/blktap/blktaplib.c	Mon Mar 07 17:49:21 2005 +0000
    11.2 +++ b/tools/blktap/blktaplib.c	Tue Mar 08 09:21:49 2005 +0000
    11.3 @@ -22,7 +22,6 @@
    11.4  #include <string.h>
    11.5  #include <unistd.h>
    11.6                                                                       
    11.7 -
    11.8  #define __COMPILING_BLKTAP_LIB
    11.9  #include "blktaplib.h"
   11.10  
   11.11 @@ -37,20 +36,14 @@
   11.12  
   11.13  #define BLKTAP_IOCTL_KICK 1
   11.14  
   11.15 -// this is in the header now
   11.16 -//DEFINE_RING_TYPES(blkif, blkif_request_t, blkif_response_t);
   11.17 -
   11.18  void got_sig_bus();
   11.19  void got_sig_int();
   11.20  
   11.21 -
   11.22  /* in kernel these are opposite, but we are a consumer now. */
   11.23  blkif_back_ring_t  fe_ring; /* slightly counterintuitive ;) */
   11.24  blkif_front_ring_t be_ring; 
   11.25  ctrl_back_ring_t   ctrl_ring;
   11.26  
   11.27 -
   11.28 -
   11.29  unsigned long mmap_vstart = 0;
   11.30  char *blktap_mem;
   11.31  int fd = 0;
   11.32 @@ -60,8 +53,6 @@ int fd = 0;
   11.33  #define BLKTAP_MMAP_PAGES \
   11.34      ((BLKIF_MAX_SEGMENTS_PER_REQUEST + 1) * BLKIF_RING_SIZE)
   11.35  #define BLKTAP_MMAP_REGION_SIZE (BLKTAP_RING_PAGES + BLKTAP_MMAP_PAGES)
   11.36 -
   11.37 -
   11.38      
   11.39  int bad_count = 0;
   11.40  void bad(void)
   11.41 @@ -208,7 +199,7 @@ inline int write_req_to_be_ring(blkif_re
   11.42      blkif_request_t *req_d;
   11.43  
   11.44      //req_d = FRONT_RING_NEXT_EMPTY_REQUEST(&be_ring);
   11.45 -    req_d = RING_GET_REQUEST(BLKIF_RING, &be_ring, be_ring.req_prod_pvt);
   11.46 +    req_d = RING_GET_REQUEST(&be_ring, be_ring.req_prod_pvt);
   11.47      memcpy(req_d, req, sizeof(blkif_request_t));
   11.48      wmb();
   11.49      be_ring.req_prod_pvt++;
   11.50 @@ -221,7 +212,7 @@ inline int write_rsp_to_fe_ring(blkif_re
   11.51      blkif_response_t *rsp_d;
   11.52  
   11.53      //rsp_d = BACK_RING_NEXT_EMPTY_RESPONSE(&fe_ring);
   11.54 -    rsp_d = RING_GET_RESPONSE(BLKIF_RING, &fe_ring, fe_ring.rsp_prod_pvt);
   11.55 +    rsp_d = RING_GET_RESPONSE(&fe_ring, fe_ring.rsp_prod_pvt);
   11.56      memcpy(rsp_d, rsp, sizeof(blkif_response_t));
   11.57      wmb();
   11.58      fe_ring.rsp_prod_pvt++;
   11.59 @@ -251,7 +242,7 @@ void blktap_inject_response(blkif_respon
   11.60  {
   11.61      apply_rsp_hooks(rsp);
   11.62      write_rsp_to_fe_ring(rsp);
   11.63 -    RING_PUSH_RESPONSES(BLKIF_RING, &fe_ring);
   11.64 +    RING_PUSH_RESPONSES(&fe_ring);
   11.65      ioctl(fd, BLKTAP_IOCTL_KICK_FE);
   11.66  }
   11.67  
   11.68 @@ -371,13 +362,13 @@ int blktap_listen(void)
   11.69  
   11.70      /* assign the rings to the mapped memory */
   11.71      csring = (ctrl_sring_t *)blktap_mem;
   11.72 -    BACK_RING_INIT(CTRL_RING, &ctrl_ring, csring);
   11.73 +    BACK_RING_INIT(&ctrl_ring, csring);
   11.74      
   11.75      sring = (blkif_sring_t *)((unsigned long)blktap_mem + PAGE_SIZE);
   11.76 -    FRONT_RING_INIT(BLKIF_RING, &be_ring, sring);
   11.77 +    FRONT_RING_INIT(&be_ring, sring);
   11.78      
   11.79      sring = (blkif_sring_t *)((unsigned long)blktap_mem + (2 *PAGE_SIZE));
   11.80 -    BACK_RING_INIT(BLKIF_RING, &fe_ring, sring);
   11.81 +    BACK_RING_INIT(&fe_ring, sring);
   11.82  
   11.83      mmap_vstart = (unsigned long)blktap_mem + (BLKTAP_RING_PAGES << PAGE_SHIFT);
   11.84      
   11.85 @@ -431,7 +422,7 @@ int blktap_listen(void)
   11.86              rmb();
   11.87              for (i = ctrl_ring.req_cons; i < rp; i++)
   11.88              {
   11.89 -                msg = RING_GET_REQUEST(CTRL_RING, &ctrl_ring, i);
   11.90 +                msg = RING_GET_REQUEST(&ctrl_ring, i);
   11.91  
   11.92                  ctrl_hook = ctrl_hook_chain;
   11.93                  while (ctrl_hook != NULL)
   11.94 @@ -444,18 +435,18 @@ int blktap_listen(void)
   11.95              }
   11.96              /* Using this as a unidirectional ring. */
   11.97              ctrl_ring.req_cons = ctrl_ring.rsp_prod_pvt = i;
   11.98 -            RING_PUSH_RESPONSES(CTRL_RING, &ctrl_ring);
   11.99 +            RING_PUSH_RESPONSES(&ctrl_ring);
  11.100              
  11.101              /* empty the fe_ring */
  11.102              notify_fe = 0;
  11.103 -            notify_be = RING_HAS_UNCONSUMED_REQUESTS(BLKIF_RING, &fe_ring);
  11.104 +            notify_be = RING_HAS_UNCONSUMED_REQUESTS(&fe_ring);
  11.105              rp = fe_ring.sring->req_prod;
  11.106              rmb();
  11.107              for (i = fe_ring.req_cons; i != rp; i++)
  11.108              {
  11.109                  int done = 0; /* stop forwarding this request */
  11.110  
  11.111 -                req = RING_GET_REQUEST(BLKIF_RING, &fe_ring, i);
  11.112 +                req = RING_GET_REQUEST(&fe_ring, i);
  11.113  
  11.114                  DPRINTF("copying an fe request\n");
  11.115  
  11.116 @@ -489,13 +480,13 @@ int blktap_listen(void)
  11.117              fe_ring.req_cons = i;
  11.118  
  11.119              /* empty the be_ring */
  11.120 -            notify_fe |= RING_HAS_UNCONSUMED_RESPONSES(BLKIF_RING, &be_ring);
  11.121 +            notify_fe |= RING_HAS_UNCONSUMED_RESPONSES(&be_ring);
  11.122              rp = be_ring.sring->rsp_prod;
  11.123              rmb();
  11.124              for (i = be_ring.rsp_cons; i != rp; i++)
  11.125              {
  11.126  
  11.127 -                rsp = RING_GET_RESPONSE(BLKIF_RING, &be_ring, i);
  11.128 +                rsp = RING_GET_RESPONSE(&be_ring, i);
  11.129  
  11.130                  DPRINTF("copying a be request\n");
  11.131  
  11.132 @@ -508,13 +499,13 @@ int blktap_listen(void)
  11.133  
  11.134              if (notify_be) {
  11.135                  DPRINTF("notifying be\n");
  11.136 -                RING_PUSH_REQUESTS(BLKIF_RING, &be_ring);
  11.137 +                RING_PUSH_REQUESTS(&be_ring);
  11.138                  ioctl(fd, BLKTAP_IOCTL_KICK_BE);
  11.139              }
  11.140  
  11.141              if (notify_fe) {
  11.142                  DPRINTF("notifying fe\n");
  11.143 -                RING_PUSH_RESPONSES(BLKIF_RING, &fe_ring);
  11.144 +                RING_PUSH_RESPONSES(&fe_ring);
  11.145                  ioctl(fd, BLKTAP_IOCTL_KICK_FE);
  11.146              }
  11.147          }        
    12.1 --- a/tools/xcs/ctrl_interface.c	Mon Mar 07 17:49:21 2005 +0000
    12.2 +++ b/tools/xcs/ctrl_interface.c	Tue Mar 08 09:21:49 2005 +0000
    12.3 @@ -57,14 +57,14 @@ int ctrl_chan_read_request(control_chann
    12.4      control_msg_t     *smsg;
    12.5      RING_IDX          c = cc->tx_ring.req_cons;
    12.6  
    12.7 -    if ( !RING_HAS_UNCONSUMED_REQUESTS(CTRL_RING, &cc->tx_ring) )
    12.8 +    if ( !RING_HAS_UNCONSUMED_REQUESTS(&cc->tx_ring) )
    12.9      {
   12.10          DPRINTF("no request to read\n");
   12.11          return -1;
   12.12      }
   12.13      
   12.14      rmb(); /* make sure we see the data associated with the request */
   12.15 -    smsg = RING_GET_REQUEST(CTRL_RING, &cc->tx_ring, c);
   12.16 +    smsg = RING_GET_REQUEST(&cc->tx_ring, c);
   12.17      memcpy(&dmsg->msg, smsg, sizeof(*smsg));
   12.18      if ( dmsg->msg.length > sizeof(dmsg->msg.msg) )
   12.19          dmsg->msg.length = sizeof(dmsg->msg.msg);
   12.20 @@ -78,18 +78,18 @@ int ctrl_chan_write_request(control_chan
   12.21      control_msg_t *dmsg;
   12.22      RING_IDX       p = cc->rx_ring.req_prod_pvt;
   12.23      
   12.24 -    if ( RING_FULL(CTRL_RING, &cc->rx_ring) )
   12.25 +    if ( RING_FULL(&cc->rx_ring) )
   12.26      {
   12.27          DPRINTF("no space to write request");
   12.28          return -ENOSPC;
   12.29      }
   12.30  
   12.31 -    dmsg = RING_GET_REQUEST(CTRL_RING, &cc->rx_ring, p);
   12.32 +    dmsg = RING_GET_REQUEST(&cc->rx_ring, p);
   12.33      memcpy(dmsg, &smsg->msg, sizeof(*dmsg));
   12.34  
   12.35      wmb();
   12.36      cc->rx_ring.req_prod_pvt++;
   12.37 -    RING_PUSH_REQUESTS(CTRL_RING, &cc->rx_ring);
   12.38 +    RING_PUSH_REQUESTS(&cc->rx_ring);
   12.39      
   12.40      return 0;
   12.41  }
   12.42 @@ -99,14 +99,14 @@ int ctrl_chan_read_response(control_chan
   12.43      control_msg_t     *smsg;
   12.44      RING_IDX          c = cc->rx_ring.rsp_cons;
   12.45      
   12.46 -    if ( !RING_HAS_UNCONSUMED_RESPONSES(CTRL_RING, &cc->rx_ring) )
   12.47 +    if ( !RING_HAS_UNCONSUMED_RESPONSES(&cc->rx_ring) )
   12.48      {
   12.49          DPRINTF("no response to read");
   12.50          return -1;
   12.51      }
   12.52  
   12.53      rmb(); /* make sure we see the data associated with the request */
   12.54 -    smsg = RING_GET_RESPONSE(CTRL_RING, &cc->rx_ring, c);
   12.55 +    smsg = RING_GET_RESPONSE(&cc->rx_ring, c);
   12.56      memcpy(&dmsg->msg, smsg, sizeof(*smsg));
   12.57      if ( dmsg->msg.length > sizeof(dmsg->msg.msg) )
   12.58          dmsg->msg.length = sizeof(dmsg->msg.msg);
   12.59 @@ -128,29 +128,29 @@ int ctrl_chan_write_response(control_cha
   12.60          return -ENOSPC;
   12.61      }
   12.62  
   12.63 -    dmsg = RING_GET_RESPONSE(CTRL_RING, &cc->tx_ring, p);
   12.64 +    dmsg = RING_GET_RESPONSE(&cc->tx_ring, p);
   12.65      memcpy(dmsg, &smsg->msg, sizeof(*dmsg));
   12.66  
   12.67      wmb();
   12.68      cc->tx_ring.rsp_prod_pvt++;
   12.69 -    RING_PUSH_RESPONSES(CTRL_RING, &cc->tx_ring);
   12.70 +    RING_PUSH_RESPONSES(&cc->tx_ring);
   12.71      
   12.72      return 0;
   12.73  }
   12.74  
   12.75  int ctrl_chan_request_to_read(control_channel_t *cc)
   12.76  {
   12.77 -    return (RING_HAS_UNCONSUMED_REQUESTS(CTRL_RING, &cc->tx_ring));
   12.78 +    return (RING_HAS_UNCONSUMED_REQUESTS(&cc->tx_ring));
   12.79  }
   12.80  
   12.81  int ctrl_chan_space_to_write_request(control_channel_t *cc)
   12.82  {
   12.83 -    return (!(RING_FULL(CTRL_RING, &cc->rx_ring)));
   12.84 +    return (!(RING_FULL(&cc->rx_ring)));
   12.85  }
   12.86  
   12.87  int ctrl_chan_response_to_read(control_channel_t *cc)
   12.88  {
   12.89 -    return (RING_HAS_UNCONSUMED_RESPONSES(CTRL_RING, &cc->rx_ring));
   12.90 +    return (RING_HAS_UNCONSUMED_RESPONSES(&cc->rx_ring));
   12.91  }
   12.92  
   12.93  int ctrl_chan_space_to_write_response(control_channel_t *cc)
   12.94 @@ -186,8 +186,8 @@ int ctrl_chan_connect(control_channel_t 
   12.95      }
   12.96  
   12.97      /* Synchronise ring indexes. */
   12.98 -    BACK_RING_ATTACH(CTRL_RING, &cc->tx_ring, &cc->interface->tx_ring);
   12.99 -    FRONT_RING_ATTACH(CTRL_RING, &cc->rx_ring, &cc->interface->rx_ring);
  12.100 +    BACK_RING_ATTACH(&cc->tx_ring, &cc->interface->tx_ring);
  12.101 +    FRONT_RING_ATTACH(&cc->rx_ring, &cc->interface->rx_ring);
  12.102  
  12.103      cc->connected = 1;
  12.104  
    13.1 --- a/xen/include/public/io/blkif.h	Mon Mar 07 17:49:21 2005 +0000
    13.2 +++ b/xen/include/public/io/blkif.h	Tue Mar 08 09:21:49 2005 +0000
    13.3 @@ -57,8 +57,7 @@ typedef struct {
    13.4   * Generate blkif ring structures and types.
    13.5   */
    13.6  
    13.7 -#define BLKIF_RING RING_PARAMS(blkif_request_t, blkif_response_t, PAGE_SIZE)
    13.8 -DEFINE_RING_TYPES(blkif, BLKIF_RING);
    13.9 +DEFINE_RING_TYPES(blkif, blkif_request_t, blkif_response_t, PAGE_SIZE);
   13.10  
   13.11  /*
   13.12   * BLKIF_OP_PROBE:
    14.1 --- a/xen/include/public/io/domain_controller.h	Mon Mar 07 17:49:21 2005 +0000
    14.2 +++ b/xen/include/public/io/domain_controller.h	Tue Mar 08 09:21:49 2005 +0000
    14.3 @@ -45,9 +45,8 @@ typedef u32 CONTROL_RING_IDX;
    14.4   * CONTROL_RING_MEM is currently an 8-slot ring of ctrl_msg_t structs and
    14.5   * two 32-bit counters:  (64 * 8) + (2 * 4) = 520
    14.6   */
    14.7 -#define CONTROL_RING_MEM 520 
    14.8 -#define CTRL_RING RING_PARAMS(control_msg_t, control_msg_t, CONTROL_RING_MEM)
    14.9 -DEFINE_RING_TYPES(ctrl, CTRL_RING);
   14.10 +#define CONTROL_RING_MEM 520
   14.11 +DEFINE_RING_TYPES(ctrl, control_msg_t, control_msg_t, CONTROL_RING_MEM);
   14.12  
   14.13  typedef struct {
   14.14      ctrl_sring_t tx_ring; /*    0: guest -> controller  */
    15.1 --- a/xen/include/public/io/ring.h	Mon Mar 07 17:49:21 2005 +0000
    15.2 +++ b/xen/include/public/io/ring.h	Tue Mar 08 09:21:49 2005 +0000
    15.3 @@ -8,49 +8,21 @@
    15.4  
    15.5  typedef unsigned int RING_IDX;
    15.6  
    15.7 -/* This is horrible: it rounds a 32-bit unsigned constant down to the
    15.8 - * nearest power of two, by finding the highest set bit. */
    15.9 -#define __RD2PO2(_x) (((_x) & 0x80000000) ? 0x80000000 :                \
   15.10 -                      ((_x) & 0x40000000) ? 0x40000000 :                \
   15.11 -                      ((_x) & 0x20000000) ? 0x20000000 :                \
   15.12 -                      ((_x) & 0x10000000) ? 0x10000000 :                \
   15.13 -                      ((_x) & 0x08000000) ? 0x08000000 :                \
   15.14 -                      ((_x) & 0x04000000) ? 0x04000000 :                \
   15.15 -                      ((_x) & 0x02000000) ? 0x02000000 :                \
   15.16 -                      ((_x) & 0x01000000) ? 0x01000000 :                \
   15.17 -                      ((_x) & 0x00800000) ? 0x00800000 :                \
   15.18 -                      ((_x) & 0x00400000) ? 0x00400000 :                \
   15.19 -                      ((_x) & 0x00200000) ? 0x00200000 :                \
   15.20 -                      ((_x) & 0x00100000) ? 0x00100000 :                \
   15.21 -                      ((_x) & 0x00080000) ? 0x00080000 :                \
   15.22 -                      ((_x) & 0x00040000) ? 0x00040000 :                \
   15.23 -                      ((_x) & 0x00020000) ? 0x00020000 :                \
   15.24 -                      ((_x) & 0x00010000) ? 0x00010000 :                \
   15.25 -                      ((_x) & 0x00008000) ? 0x00008000 :                \
   15.26 -                      ((_x) & 0x00004000) ? 0x00004000 :                \
   15.27 -                      ((_x) & 0x00002000) ? 0x00002000 :                \
   15.28 -                      ((_x) & 0x00001000) ? 0x00001000 :                \
   15.29 -                      ((_x) & 0x00000800) ? 0x00000800 :                \
   15.30 -                      ((_x) & 0x00000400) ? 0x00000400 :                \
   15.31 -                      ((_x) & 0x00000200) ? 0x00000200 :                \
   15.32 -                      ((_x) & 0x00000100) ? 0x00000100 :                \
   15.33 -                      ((_x) & 0x00000080) ? 0x00000080 :                \
   15.34 -                      ((_x) & 0x00000040) ? 0x00000040 :                \
   15.35 -                      ((_x) & 0x00000020) ? 0x00000020 :                \
   15.36 -                      ((_x) & 0x00000010) ? 0x00000010 :                \
   15.37 -                      ((_x) & 0x00000008) ? 0x00000008 :                \
   15.38 -                      ((_x) & 0x00000004) ? 0x00000004 :                \
   15.39 -                      ((_x) & 0x00000002) ? 0x00000002 :                \
   15.40 -                      ((_x) & 0x00000001) ? 0x00000001 : 0x00000000)
   15.41 +/* Round a 32-bit unsigned constant down to the nearest power of two. */
   15.42 +#define __RD2(_x)  (((_x) & 0x00000002) ? 0x2                  : ((_x) & 0x1))
   15.43 +#define __RD4(_x)  (((_x) & 0x0000000c) ? __RD2((_x)>>2)<<2    : __RD2(_x))
   15.44 +#define __RD8(_x)  (((_x) & 0x000000f0) ? __RD4((_x)>>4)<<4    : __RD4(_x))
   15.45 +#define __RD16(_x) (((_x) & 0x0000ff00) ? __RD8((_x)>>8)<<8    : __RD8(_x))
   15.46 +#define __RD32(_x) (((_x) & 0xffff0000) ? __RD16((_x)>>16)<<16 : __RD16(_x))
   15.47  
   15.48 -/* Given a shared ring, tell me how many entries there are in it.  The
   15.49 - * rule is: a ring contains as many entries as will fit, rounded down to
   15.50 - * the nearest power of two (so we can mask with (size-1) to loop
   15.51 - * around) */
   15.52 -#define __SRING_SIZE(__params, __esize)                                 \
   15.53 -    __RD2PO2((sizeof((__params)->size) - (2 * sizeof(RING_IDX))) / (__esize))
   15.54 -#define SRING_SIZE(__params, __sringp)                                  \
   15.55 -    __SRING_SIZE(__params, sizeof (__sringp)->ring[0])
   15.56 +/*
   15.57 + * Calculate size of a shared ring, given the total available space for the
   15.58 + * ring and indexes (_sz), and the name tag of the request/response structure.
   15.59 + * S ring contains as many entries as will fit, rounded down to the nearest 
   15.60 + * power of two (so we can mask with (size-1) to loop around).
   15.61 + */
   15.62 +#define __RING_SIZE(_name, _sz)                                         \
   15.63 +    (__RD32(((_sz) - 2*sizeof(RING_IDX)) / sizeof(union _name##_sring_entry)))
   15.64  
   15.65  /*
   15.66   *  Macros to make the correct C datatypes for a new kind of ring.
   15.67 @@ -62,8 +34,7 @@ typedef unsigned int RING_IDX;
   15.68   *
   15.69   *  In a header where you want the ring datatype declared, you then do:
   15.70   *
   15.71 - *   #define MY_RING RING_PARAMS(request_t, response_t, PAGE_SIZE)
   15.72 - *   DEFINE_RING_TYPES(mytag, MY_RING);
   15.73 + *     DEFINE_RING_TYPES(mytag, request_t, response_t, PAGE_SIZE);
   15.74   *
   15.75   *  These expand out to give you a set of types, as you can see below.
   15.76   *  The most important of these are:
   15.77 @@ -72,51 +43,29 @@ typedef unsigned int RING_IDX;
   15.78   *     mytag_front_ring_t - The 'front' half of the ring.
   15.79   *     mytag_back_ring_t  - The 'back' half of the ring.
   15.80   *
   15.81 - *  Use the RING_PARAMS define (MY_RING above) as a first parameter on all
   15.82 - *  the ring functions.  To initialize a ring in your code, on the front 
   15.83 - *  half, you do a:
   15.84 + *  To initialize a ring in your code, on the front half, you do:
   15.85   *
   15.86   *      mytag_front_ring_t front_ring;
   15.87   *
   15.88 - *      SHARED_RING_INIT(MY_RING, (mytag_sring_t *)shared_page)
   15.89 - *      FRONT_RING_INIT(MY_RING, &front_ring, (mytag_sring_t *)shared_page)
   15.90 + *      SHARED_RING_INIT((mytag_sring_t *)shared_page);
   15.91 + *      FRONT_RING_INIT(&front_ring, (mytag_sring_t *)shared_page);
   15.92   *
   15.93   *  Initializing the back follows similarly...
   15.94   */
   15.95           
   15.96 -/*  NB: RING SIZING. (a note to ease future debugging...)
   15.97 - *
   15.98 - *  Passing size information into the ring macros is made difficult by 
   15.99 - *  the lack of a reasonable constant declaration in C.  To get around this,
  15.100 - *  the RING_PARAMS define places the requested size of the ring as the 
  15.101 - *  static size of the 'size' array in the anonymous RING_PARAMS struct.
  15.102 - *  While this struct is never actually instantiated, __SRING_SIZE is 
  15.103 - *  able to use sizeof() to get at the constant size.
  15.104 - */
  15.105 -
  15.106 -#define RING_PARAMS(__req_t, __rsp_t, __size)                           \
  15.107 -((struct {                                                              \
  15.108 -    char size[__size];                                                  \
  15.109 -    __req_t req;                                                        \
  15.110 -    __rsp_t rsp;                                                        \
  15.111 -                                                                        \
  15.112 -} *) 0)
  15.113 -
  15.114 -
  15.115 -#define DEFINE_RING_TYPES(__name, __params)                             \
  15.116 +#define DEFINE_RING_TYPES(__name, __req_t, __rsp_t, __size)             \
  15.117                                                                          \
  15.118  /* Shared ring entry */                                                 \
  15.119  union __name##_sring_entry {                                            \
  15.120 -    typeof ((__params)->req) req;                                       \
  15.121 -    typeof ((__params)->rsp) rsp;                                       \
  15.122 +    __req_t req;                                                        \
  15.123 +    __rsp_t rsp;                                                        \
  15.124  } PACKED;                                                               \
  15.125                                                                          \
  15.126  /* Shared ring page */                                                  \
  15.127  struct __name##_sring {                                                 \
  15.128      RING_IDX req_prod;                                                  \
  15.129      RING_IDX rsp_prod;                                                  \
  15.130 -    union __name##_sring_entry                                          \
  15.131 -        ring[__SRING_SIZE(__params, sizeof (union __name##_sring_entry))];        \
  15.132 +    union __name##_sring_entry ring[__RING_SIZE(__name, __size)];       \
  15.133  } PACKED;                                                               \
  15.134                                                                          \
  15.135  /* "Front" end's private variables */                                   \
  15.136 @@ -149,106 +98,97 @@ typedef struct __name##_back_ring __name
  15.137   * 
  15.138   *   N.B. these macros do NO INTERLOCKS OR FLOW CONTROL.  
  15.139   *   This is OK in 1-for-1 request-response situations where the 
  15.140 - *   requestor (front end) never has more than SRING_SIZE()-1
  15.141 + *   requestor (front end) never has more than RING_SIZE()-1
  15.142   *   outstanding requests.
  15.143   */
  15.144  
  15.145  
  15.146  /* Initialising empty rings */
  15.147 -#define SHARED_RING_INIT(_p, _s) do {                                   \
  15.148 +#define SHARED_RING_INIT(_s) do {                                       \
  15.149      (_s)->req_prod = 0;                                                 \
  15.150      (_s)->rsp_prod = 0;                                                 \
  15.151  } while(0)
  15.152  
  15.153 -#define FRONT_RING_INIT(_p, _r, _s) do {                                \
  15.154 +#define FRONT_RING_INIT(_r, _s) do {                                    \
  15.155      (_r)->req_prod_pvt = 0;                                             \
  15.156      (_r)->rsp_cons = 0;                                                 \
  15.157      (_r)->sring = (_s);                                                 \
  15.158  } while (0)
  15.159  
  15.160 -#define BACK_RING_INIT(_p, _r, _s) do {                                 \
  15.161 +#define BACK_RING_INIT(_r, _s) do {                                     \
  15.162      (_r)->rsp_prod_pvt = 0;                                             \
  15.163      (_r)->req_cons = 0;                                                 \
  15.164      (_r)->sring = (_s);                                                 \
  15.165  } while (0)
  15.166  
  15.167  /* Initialize to existing shared indexes -- for recovery */
  15.168 -#define FRONT_RING_ATTACH(_p, _r, _s) do {                              \
  15.169 +#define FRONT_RING_ATTACH(_r, _s) do {                                  \
  15.170      (_r)->sring = (_s);                                                 \
  15.171      (_r)->req_prod_pvt = (_s)->req_prod;                                \
  15.172      (_r)->rsp_cons = (_s)->rsp_prod;                                    \
  15.173  } while (0)
  15.174  
  15.175 -#define BACK_RING_ATTACH(_p, _r, _s) do {                               \
  15.176 +#define BACK_RING_ATTACH(_r, _s) do {                                   \
  15.177      (_r)->sring = (_s);                                                 \
  15.178      (_r)->rsp_prod_pvt = (_s)->rsp_prod;                                \
  15.179      (_r)->req_cons = (_s)->req_prod;                                    \
  15.180  } while (0)
  15.181  
  15.182 -
  15.183 -/* How to mask off a number for use as an offset into a ring 
  15.184 - * N.B. This evalutes its second argument once but its first often */
  15.185 -#define __SHARED_RING_MASK(_p, _s, _i)                                  \
  15.186 -    ((_i) & (SRING_SIZE((_p), (_s)) - 1))
  15.187 -
  15.188  /* How big is this ring? */
  15.189 -#define RING_SIZE(_p, _r) SRING_SIZE((_p), (_r)->sring)
  15.190 +#define RING_SIZE(_r)                                                   \
  15.191 +    (sizeof((_r)->sring->ring)/sizeof((_r)->sring->ring[0]))
  15.192  
  15.193  /* How many empty slots are on a ring? */
  15.194 -#define RING_PENDING_REQUESTS(_p, _r)                                   \
  15.195 +#define RING_PENDING_REQUESTS(_r)                                       \
  15.196     ( ((_r)->req_prod_pvt - (_r)->rsp_cons) )
  15.197     
  15.198  /* Test if there is an empty slot available on the front ring. 
  15.199   * (This is only meaningful from the front. )
  15.200   */
  15.201 -#define RING_FULL(_p, _r)                                               \
  15.202 -    (((_r)->req_prod_pvt - (_r)->rsp_cons) == SRING_SIZE((_p), (_r)->sring))
  15.203 +#define RING_FULL(_r)                                                   \
  15.204 +    (((_r)->req_prod_pvt - (_r)->rsp_cons) == RING_SIZE(_r))
  15.205  
  15.206  /* Test if there are outstanding messages to be processed on a ring. */
  15.207 -#define RING_HAS_UNCONSUMED_RESPONSES(_p, _r)                           \
  15.208 +#define RING_HAS_UNCONSUMED_RESPONSES(_r)                               \
  15.209     ( (_r)->rsp_cons != (_r)->sring->rsp_prod )
  15.210     
  15.211 -#define RING_HAS_UNCONSUMED_REQUESTS(_p, _r)                            \
  15.212 +#define RING_HAS_UNCONSUMED_REQUESTS(_r)                                \
  15.213     ( ((_r)->req_cons != (_r)->sring->req_prod ) &&                      \
  15.214       (((_r)->req_cons - (_r)->rsp_prod_pvt) !=                          \
  15.215 -      SRING_SIZE((_p), (_r)->sring)) )
  15.216 +      RING_SIZE(_r)) )
  15.217        
  15.218  /* Test if there are messages waiting to be pushed. */
  15.219 -#define RING_HAS_UNPUSHED_REQUESTS(_p, _r)                              \
  15.220 +#define RING_HAS_UNPUSHED_REQUESTS(_r)                                  \
  15.221     ( (_r)->req_prod_pvt != (_r)->sring->req_prod )
  15.222     
  15.223 -#define RING_HAS_UNPUSHED_RESPONSES(_p, _r)                             \
  15.224 +#define RING_HAS_UNPUSHED_RESPONSES(_r)                                 \
  15.225     ( (_r)->rsp_prod_pvt != (_r)->sring->rsp_prod )
  15.226 -   
  15.227  
  15.228  /* Copy the private producer pointer into the shared ring so the other end 
  15.229   * can see the updates we've made. */
  15.230 -#define RING_PUSH_REQUESTS(_p, _r) do {                                 \
  15.231 +#define RING_PUSH_REQUESTS(_r) do {                                     \
  15.232      wmb();                                                              \
  15.233      (_r)->sring->req_prod = (_r)->req_prod_pvt;                         \
  15.234  } while (0)
  15.235  
  15.236 -#define RING_PUSH_RESPONSES(_p, _r) do {                                \
  15.237 +#define RING_PUSH_RESPONSES(_r) do {                                    \
  15.238      wmb();                                                              \
  15.239      (_r)->sring->rsp_prod = (_r)->rsp_prod_pvt;                         \
  15.240  } while (0)
  15.241  
  15.242 -/* Direct access to individual ring elements, by index.  
  15.243 - */
  15.244 -#define RING_GET_REQUEST(_p, _r, _idx)                                  \
  15.245 +/* Direct access to individual ring elements, by index. */
  15.246 +#define RING_GET_REQUEST(_r, _idx)                                      \
  15.247   (&((_r)->sring->ring[                                                  \
  15.248 -     __SHARED_RING_MASK((_p), (_r)->sring, (_idx))                      \
  15.249 +     ((_idx) & (RING_SIZE(_r) - 1))                                     \
  15.250       ].req))
  15.251  
  15.252 -#define RING_GET_RESPONSE(_p, _r, _idx)                                 \
  15.253 +#define RING_GET_RESPONSE(_r, _idx)                                     \
  15.254   (&((_r)->sring->ring[                                                  \
  15.255 -     __SHARED_RING_MASK((_p), (_r)->sring, (_idx))                      \
  15.256 +     ((_idx) & (RING_SIZE(_r) - 1))                                     \
  15.257       ].rsp))   
  15.258      
  15.259 -/* Loop termination condition: Would the specified index overflow the 
  15.260 - * ring? 
  15.261 - */
  15.262 -#define RING_REQUEST_CONS_OVERFLOW(_p, _r, _cons)                      \
  15.263 -    (((_cons) - (_r)->rsp_prod_pvt) >= SRING_SIZE((_p), (_r)->sring))
  15.264 +/* Loop termination condition: Would the specified index overflow the ring? */
  15.265 +#define RING_REQUEST_CONS_OVERFLOW(_r, _cons)                           \
  15.266 +    (((_cons) - (_r)->rsp_prod_pvt) >= RING_SIZE(_r))
  15.267  
  15.268  #endif /* __XEN_PUBLIC_IO_RING_H__ */
    16.1 --- a/xen/include/public/io/usbif.h	Mon Mar 07 17:49:21 2005 +0000
    16.2 +++ b/xen/include/public/io/usbif.h	Tue Mar 08 09:21:49 2005 +0000
    16.3 @@ -54,8 +54,7 @@ typedef struct {
    16.4  #define USBIF_RSP_ERROR  -1 /* non-specific 'error' */
    16.5  #define USBIF_RSP_OKAY    0 /* non-specific 'okay'  */
    16.6  
    16.7 -#define USBIF_RING RING_PARAMS(usbif_request_t, usbif_response_t, PAGE_SIZE)
    16.8 -DEFINE_RING_TYPES(usbif, USBIF_RING);
    16.9 +DEFINE_RING_TYPES(usbif, usbif_request_t, usbif_response_t, PAGE_SIZE);
   16.10  
   16.11  typedef struct {
   16.12      unsigned long length; /* IN = expected, OUT = actual */