ia64/xen-unstable

changeset 5941:ae51fa1d32b2

This patch adds two macros for construction of the
frame_and_sectors field in blkif messages, to eliminate the
"magic shifts" in the blkif code.

It also increases the number of bits representing the sector
number within a page, from 3 to 5, to allow page sizes up to
16K (needed for IA64).

Tested to still work on x86.

Signed-off-by: Matthew Chapman <matthewc@hp.com>
author kaf24@firebug.cl.cam.ac.uk
date Mon Aug 01 09:26:51 2005 +0000 (2005-08-01)
parents ac7176771024
children 6a83d157a391
files linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c xen/include/public/io/blkif.h
line diff
     1.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Mon Aug 01 09:16:25 2005 +0000
     1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c	Mon Aug 01 09:26:51 2005 +0000
     1.3 @@ -329,11 +329,11 @@ static int blkif_queue_request(struct re
     1.4                  buffer_ma >> PAGE_SHIFT;
     1.5  
     1.6              ring_req->frame_and_sects[ring_req->nr_segments++] =
     1.7 -                (((u32) ref) << 16) | (fsect << 3) | lsect;
     1.8 +                blkif_fas_from_gref(ref, fsect, lsect);
     1.9  
    1.10  #else
    1.11              ring_req->frame_and_sects[ring_req->nr_segments++] =
    1.12 -                buffer_ma | (fsect << 3) | lsect;
    1.13 +                blkif_fas(buffer_ma, fsect, lsect);
    1.14  #endif
    1.15          }
    1.16      }
    1.17 @@ -832,10 +832,10 @@ static int blkif_queue_request(unsigned 
    1.18                  buffer_ma >> PAGE_SHIFT;
    1.19  
    1.20              req->frame_and_sects[req->nr_segments] =
    1.21 -                (((u32) ref ) << 16) | (fsect << 3) | lsect;
    1.22 +                blkif_fas_from_gref(ref, fsect, lsect);
    1.23  #else
    1.24              req->frame_and_sects[req->nr_segments] =
    1.25 -                buffer_ma | (fsect << 3) | lsect;
    1.26 +                blkif_fas(buffer_ma, fsect, lsect);
    1.27  #endif
    1.28              if ( ++req->nr_segments < BLKIF_MAX_SEGMENTS_PER_REQUEST )
    1.29                  sg_next_sect += nr_sectors;
    1.30 @@ -887,9 +887,9 @@ static int blkif_queue_request(unsigned 
    1.31  
    1.32      blk_shadow[xid].frame[0] = buffer_ma >> PAGE_SHIFT;
    1.33  
    1.34 -    req->frame_and_sects[0] = (((u32) ref)<<16)  | (fsect<<3) | lsect;
    1.35 +    req->frame_and_sects[0] = blkif_fas_from_gref(ref, fsect, lsect);
    1.36  #else
    1.37 -    req->frame_and_sects[0] = buffer_ma | (fsect<<3) | lsect;
    1.38 +    req->frame_and_sects[0] = blkif_fas(buffer_ma, fsect, lsect);
    1.39  #endif
    1.40  
    1.41      /* Keep a private copy so we can reissue requests when recovering. */    
    1.42 @@ -1057,7 +1057,7 @@ void blkif_control_probe_send(blkif_requ
    1.43  
    1.44      gnttab_grant_foreign_access_ref( ref, rdomid, address >> PAGE_SHIFT, 0 );
    1.45  
    1.46 -    req->frame_and_sects[0] = (((u32) ref) << 16) | 7;
    1.47 +    req->frame_and_sects[0] = blkif_fas_from_gref(ref, 0, (PAGE_SIZE/512)-1);
    1.48  
    1.49      blkif_control_send(req, rsp);
    1.50  }
     2.1 --- a/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c	Mon Aug 01 09:16:25 2005 +0000
     2.2 +++ b/linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c	Mon Aug 01 09:26:51 2005 +0000
     2.3 @@ -137,7 +137,7 @@ static vdisk_t *xlvbd_probe(int *ret)
     2.4      blkif_control_probe_send(&req, &rsp,
     2.5                               (unsigned long)(virt_to_machine(buf)));
     2.6  #else
     2.7 -    req.frame_and_sects[0] = virt_to_machine(buf) | 7;
     2.8 +    req.frame_and_sects[0] = blkif_fas(virt_to_machine(buf), 0, ((PAGE_SIZE/512)-1);
     2.9  
    2.10      blkif_control_send(&req, &rsp);
    2.11  #endif
     3.1 --- a/xen/include/public/io/blkif.h	Mon Aug 01 09:16:25 2005 +0000
     3.2 +++ b/xen/include/public/io/blkif.h	Mon Aug 01 09:26:51 2005 +0000
     3.3 @@ -36,7 +36,7 @@ typedef struct blkif_request {
     3.4      blkif_vdev_t   device;       /* only for read/write requests         */
     3.5      unsigned long  id;           /* private guest value, echoed in resp  */
     3.6      blkif_sector_t sector_number;/* start sector idx on disk (r/w only)  */
     3.7 -    /* @f_a_s[2:0]=last_sect ; @f_a_s[5:3]=first_sect                        */
     3.8 +    /* @f_a_s[4:0]=last_sect ; @f_a_s[9:5]=first_sect                        */
     3.9  #ifdef CONFIG_XEN_BLKDEV_GRANT
    3.10      /* @f_a_s[:16]= grant reference (16 bits)                                */
    3.11  #else
    3.12 @@ -47,10 +47,12 @@ typedef struct blkif_request {
    3.13      unsigned long  frame_and_sects[BLKIF_MAX_SEGMENTS_PER_REQUEST];
    3.14  } blkif_request_t;
    3.15  
    3.16 -#define blkif_first_sect(_fas) (((_fas)>>3)&7)
    3.17 -#define blkif_last_sect(_fas)  ((_fas)&7)
    3.18 +#define blkif_fas(_addr, _fs, _ls) ((addr)|((_fs)<<5)|(_ls))
    3.19 +#define blkif_first_sect(_fas) (((_fas)>>5)&31)
    3.20 +#define blkif_last_sect(_fas)  ((_fas)&31)
    3.21  
    3.22  #ifdef CONFIG_XEN_BLKDEV_GRANT
    3.23 +#define blkif_fas_from_gref(_gref, _fs, _ls) (((_gref)<<16)|((_fs)<<5)|(_ls))
    3.24  #define blkif_gref_from_fas(_fas) ((_fas)>>16)
    3.25  #endif
    3.26