macros for blkif frame_and_sectors
PATCH 1/1 macros for blkif frame_and_sectors
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.
Matt
Signed-off-by Matthew Chapman <[email protected]>
linux-2.6-xen-sparse/drivers/xen/blkfront/blkfront.c +7 -7
@@ -329,11 +329,11 @@ buffer_ma >>PAGE_SHIFT ; ring_req->frame_and_sects[ring_req->nr_segments++] = - (((u32 ) ref) <<16 ) | (fsect <<3 ) | lsect; +blkif_fas_from_gref (ref, fsect, lsect);#else ring_req->frame_and_sects[ring_req->nr_segments++] = - buffer_ma | (fsect <<3 ) | lsect; +blkif_fas (buffer_ma, fsect, lsect);#endif } }
@@ -832,10 +832,10 @@ buffer_ma >>PAGE_SHIFT ; req->frame_and_sects[req->nr_segments] = - (((u32 ) ref ) <<16 ) | (fsect <<3 ) | lsect; +blkif_fas_from_gref (ref, fsect, lsect);#else req->frame_and_sects[req->nr_segments] = - buffer_ma | (fsect <<3 ) | lsect; +blkif_fas (buffer_ma, fsect, lsect);#endif if ( ++req->nr_segments <BLKIF_MAX_SEGMENTS_PER_REQUEST ) sg_next_sect += nr_sectors;
@@ -887,9 +887,9 @@ blk_shadow[xid].frame[0 ] = buffer_ma >>PAGE_SHIFT ; - req->frame_and_sects[0 ] = (((u32 ) ref)<<16 ) | (fsect<<3 ) | lsect; + req->frame_and_sects[0 ] =blkif_fas_from_gref (ref, fsect, lsect);#else - req->frame_and_sects[0 ] = buffer_ma | (fsect<<3 ) | lsect; + req->frame_and_sects[0 ] =blkif_fas (buffer_ma, fsect, lsect);#endif /* Keep a private copy so we can reissue requests when recovering. */
@@ -1057,7 +1057,7 @@gnttab_grant_foreign_access_ref ( ref, rdomid, address >>PAGE_SHIFT ,0 ); - req->frame_and_sects[0 ] = (((u32 ) ref) <<16 ) |7 ; + req->frame_and_sects[0 ] =blkif_fas_from_gref (ref,0 , (PAGE_SIZE /512 )-1 );blkif_control_send (req, rsp); }
linux-2.6-xen-sparse/drivers/xen/blkfront/vbd.c +1 -1
@@ -137,7 +137,7 @@blkif_control_probe_send (&req, &rsp, (unsigned long )(virt_to_machine (buf)));#else - req.frame_and_sects[0 ] =virt_to_machine (buf) |7 ; + req.frame_and_sects[0] = blkif_fas(virt_to_machine(buf), 0, ((PAGE_SIZE/512)-1);blkif_control_send (&req, &rsp);#endif
xen/include/public/io/blkif.h +5 -3
@@ -36,7 +36,7 @@blkif_vdev_t device;/* only for read/write requests */ unsigned long id;/* private guest value, echoed in resp */ blkif_sector_t sector_number;/* start sector idx on disk (r/w only) */ -/* @f_a_s[2:0]=last_sect ; @f_a_s[5:3]=first_sect */ +/* @f_a_s[4:0]=last_sect ; @f_a_s[9:5]=first_sect */ #ifdef CONFIG_XEN_BLKDEV_GRANT /* @f_a_s[:16]= grant reference (16 bits) */ #else
@@ -47,10 +47,12 @@unsigned long frame_and_sects[BLKIF_MAX_SEGMENTS_PER_REQUEST ]; } blkif_request_t; -#define blkif_first_sect (_fas) (((_fas)>>3)&7) -#define blkif_last_sect (_fas) ((_fas)&7) +#define blkif_fas (_addr, _fs, _ls) ((addr)|((_fs)<<5)|(_ls)) +#define blkif_first_sect (_fas) (((_fas)>>5)&31) +#define blkif_last_sect (_fas) ((_fas)&31)#ifdef CONFIG_XEN_BLKDEV_GRANT +#define blkif_fas_from_gref (_gref, _fs, _ls) (((_gref)<<16)|((_fs)<<5)|(_ls))#define blkif_gref_from_fas (_fas) ((_fas)>>16)#endif
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel