@@ -29,13 +29,13 @@ struct ScratchTopMetadata {
2929 /// Number of pages reserved for the H2G pool.
3030 h2g_pool_pages : u64 ,
3131 /// Host-published H2G descriptor count.
32- h2g_queue_depth : u64 ,
32+ h2g_queue_size : u64 ,
3333 /// Host-published capacity of each G2H upper-tier buffer.
3434 g2h_buffer_size : u64 ,
3535 /// Number of pages reserved for the G2H pool.
3636 g2h_pool_pages : u64 ,
3737 /// Host-published G2H descriptor count.
38- g2h_queue_depth : u64 ,
38+ g2h_queue_size : u64 ,
3939 /// Host-published GPA of the fixed transport arena.
4040 transport_arena_gpa : u64 ,
4141 /// Seed request for libc's pseudorandom number generator.
@@ -54,14 +54,14 @@ const fn scratch_top_offset(field_offset: usize) -> u64 {
5454 ( size_of :: < ScratchTopMetadata > ( ) - field_offset) as u64
5555}
5656
57- pub const SCRATCH_TOP_G2H_QUEUE_DEPTH_OFFSET : u64 =
58- scratch_top_offset ( offset_of ! ( ScratchTopMetadata , g2h_queue_depth ) ) ;
57+ pub const SCRATCH_TOP_G2H_QUEUE_SIZE_OFFSET : u64 =
58+ scratch_top_offset ( offset_of ! ( ScratchTopMetadata , g2h_queue_size ) ) ;
5959pub const SCRATCH_TOP_G2H_POOL_PAGES_OFFSET : u64 =
6060 scratch_top_offset ( offset_of ! ( ScratchTopMetadata , g2h_pool_pages) ) ;
6161pub const SCRATCH_TOP_G2H_BUFFER_SIZE_OFFSET : u64 =
6262 scratch_top_offset ( offset_of ! ( ScratchTopMetadata , g2h_buffer_size) ) ;
63- pub const SCRATCH_TOP_H2G_QUEUE_DEPTH_OFFSET : u64 =
64- scratch_top_offset ( offset_of ! ( ScratchTopMetadata , h2g_queue_depth ) ) ;
63+ pub const SCRATCH_TOP_H2G_QUEUE_SIZE_OFFSET : u64 =
64+ scratch_top_offset ( offset_of ! ( ScratchTopMetadata , h2g_queue_size ) ) ;
6565pub const SCRATCH_TOP_H2G_POOL_PAGES_OFFSET : u64 =
6666 scratch_top_offset ( offset_of ! ( ScratchTopMetadata , h2g_pool_pages) ) ;
6767pub const SCRATCH_TOP_H2G_BUFFER_SIZE_OFFSET : u64 =
@@ -88,10 +88,10 @@ const _: () = {
8888 assert ! ( SCRATCH_TOP_SNAPSHOT_GENERATION_OFFSET == 0x20 ) ;
8989 assert ! ( SCRATCH_TOP_LIBC_RNG_SEED_OFFSET == 0x28 ) ;
9090 assert ! ( SCRATCH_TOP_TRANSPORT_ARENA_GPA_OFFSET == 0x30 ) ;
91- assert ! ( SCRATCH_TOP_G2H_QUEUE_DEPTH_OFFSET == 0x38 ) ;
91+ assert ! ( SCRATCH_TOP_G2H_QUEUE_SIZE_OFFSET == 0x38 ) ;
9292 assert ! ( SCRATCH_TOP_G2H_POOL_PAGES_OFFSET == 0x40 ) ;
9393 assert ! ( SCRATCH_TOP_G2H_BUFFER_SIZE_OFFSET == 0x48 ) ;
94- assert ! ( SCRATCH_TOP_H2G_QUEUE_DEPTH_OFFSET == 0x50 ) ;
94+ assert ! ( SCRATCH_TOP_H2G_QUEUE_SIZE_OFFSET == 0x50 ) ;
9595 assert ! ( SCRATCH_TOP_H2G_POOL_PAGES_OFFSET == 0x58 ) ;
9696 assert ! ( SCRATCH_TOP_H2G_BUFFER_SIZE_OFFSET == 0x60 ) ;
9797 assert ! ( SCRATCH_TOP_EXN_STACK_OFFSET == 0x70 ) ;
@@ -116,14 +116,14 @@ pub fn scratch_base_gva(size: usize) -> u64 {
116116pub fn min_scratch_size (
117117 input_data_size : usize ,
118118 output_data_size : usize ,
119- g2h_queue_depth : usize ,
120- h2g_queue_depth : usize ,
119+ g2h_queue_size : usize ,
120+ h2g_queue_size : usize ,
121121 g2h_pool_pages : usize ,
122122 h2g_pool_pages : usize ,
123123) -> usize {
124124 let size = arch:: min_scratch_size ( input_data_size, output_data_size) . and_then ( |fixed| {
125- let g2h = QueueDims :: new ( g2h_queue_depth , g2h_pool_pages) ?;
126- let h2g = QueueDims :: new ( h2g_queue_depth , h2g_pool_pages) ?;
125+ let g2h = QueueDims :: new ( g2h_queue_size , g2h_pool_pages) ?;
126+ let h2g = QueueDims :: new ( h2g_queue_size , h2g_pool_pages) ?;
127127
128128 let transport_len = TransportArena :: checked_query_size ( g2h, h2g) ?;
129129 fixed. checked_add ( transport_len)
@@ -135,27 +135,27 @@ pub fn min_scratch_size(
135135/// Validated address independent dimensions for one transport queue.
136136#[ derive( Clone , Copy , Debug , PartialEq , Eq ) ]
137137pub struct QueueDims {
138- depth : NonZeroU16 ,
138+ size : NonZeroU16 ,
139139 pool_pages : NonZeroUsize ,
140140}
141141
142142impl QueueDims {
143143 /// Validate one queue descriptor count and pool page count.
144- pub fn new ( depth : usize , pool_pages : usize ) -> Option < Self > {
145- let depth = u16:: try_from ( depth ) . ok ( ) ?;
146- let depth = NonZeroU16 :: new ( depth ) ?;
144+ pub fn new ( size : usize , pool_pages : usize ) -> Option < Self > {
145+ let size = u16:: try_from ( size ) . ok ( ) ?;
146+ let size = NonZeroU16 :: new ( size ) ?;
147147
148- if !depth . get ( ) . is_power_of_two ( ) {
148+ if !size . get ( ) . is_power_of_two ( ) {
149149 return None ;
150150 }
151151
152152 let pool_pages = NonZeroUsize :: new ( pool_pages) ?;
153- Some ( Self { depth , pool_pages } )
153+ Some ( Self { size , pool_pages } )
154154 }
155155
156156 /// Number of descriptors in the queue.
157- pub const fn depth ( & self ) -> NonZeroU16 {
158- self . depth
157+ pub const fn size ( & self ) -> NonZeroU16 {
158+ self . size
159159 }
160160
161161 /// Number of pages in the queue's buffer pool.
@@ -165,7 +165,7 @@ impl QueueDims {
165165
166166 /// Compute the ring length, returning `None` on arithmetic overflow.
167167 pub fn checked_ring_len ( & self ) -> Option < usize > {
168- virtq:: Layout :: checked_query_size ( usize:: from ( self . depth . get ( ) ) )
168+ virtq:: Layout :: checked_query_size ( usize:: from ( self . size . get ( ) ) )
169169 }
170170
171171 /// Compute the pool length, returning `None` on arithmetic overflow.
@@ -281,7 +281,7 @@ impl TransportArena {
281281
282282 /// Convert the arena's absolute addresses into offsets from the arena base.
283283 pub fn to_offsets ( & self ) -> ( usize , usize , usize , usize ) {
284- // Already validated by `TransportArena::new `.
284+ # [ allow ( clippy :: unwrap_used ) ] // `new` proves every stored offset fits in `usize `.
285285 let to_offset = |addr| usize:: try_from ( addr - self . g2h_ring_addr ) . unwrap ( ) ;
286286
287287 (
0 commit comments