@@ -871,19 +871,19 @@ mod tests {
871
871
let mut q: Queue = vq. create_queue ( ) . unwrap ( ) ;
872
872
873
873
assert_eq ! ( q. used_idx( mem, Ordering :: Acquire ) . unwrap( ) , Wrapping ( 0 ) ) ;
874
- assert_eq ! ( u16 :: from_le ( vq. used( ) . idx ( ) . load ( ) ) , 0 ) ;
874
+ assert_eq ! ( vq. used( ) . load_idx ( ) , 0 ) ;
875
875
876
876
// index too large
877
877
assert ! ( q. add_used( mem, 16 , 0x1000 ) . is_err( ) ) ;
878
- assert_eq ! ( u16 :: from_le ( vq. used( ) . idx ( ) . load ( ) ) , 0 ) ;
878
+ assert_eq ! ( vq. used( ) . load_idx ( ) , 0 ) ;
879
879
880
880
// should be ok
881
881
q. add_used ( mem, 1 , 0x1000 ) . unwrap ( ) ;
882
882
assert_eq ! ( q. next_used, Wrapping ( 1 ) ) ;
883
883
assert_eq ! ( q. used_idx( mem, Ordering :: Acquire ) . unwrap( ) , Wrapping ( 1 ) ) ;
884
- assert_eq ! ( u16 :: from_le ( vq. used( ) . idx ( ) . load ( ) ) , 1 ) ;
884
+ assert_eq ! ( vq. used( ) . load_idx ( ) , 1 ) ;
885
885
886
- let x = vq. used ( ) . ring ( ) . ref_at ( 0 ) . unwrap ( ) . load ( ) ;
886
+ let x = vq. used ( ) . load_ring_entry ( 0 ) . unwrap ( ) ;
887
887
assert_eq ! ( x. id( ) , 1 ) ;
888
888
assert_eq ! ( x. len( ) , 0x1000 ) ;
889
889
}
@@ -1075,7 +1075,7 @@ mod tests {
1075
1075
// Update the index of the chain that can be consumed to not be the last one.
1076
1076
// This enables us to consume chains in multiple iterations as opposed to consuming
1077
1077
// all the driver written chains at once.
1078
- vq. avail ( ) . idx ( ) . store ( u16 :: to_le ( 2 ) ) ;
1078
+ vq. avail ( ) . store_idx ( 2 ) ;
1079
1079
// No descriptor chains are consumed at this point.
1080
1080
assert_eq ! ( q. next_avail( ) , 0 ) ;
1081
1081
@@ -1108,7 +1108,7 @@ mod tests {
1108
1108
assert_eq ! ( q. next_avail( ) , 2 ) ;
1109
1109
assert_eq ! ( q. next_used( ) , 2 ) ;
1110
1110
// Let the device know it can consume one more chain.
1111
- vq. avail ( ) . idx ( ) . store ( u16 :: to_le ( 3 ) ) ;
1111
+ vq. avail ( ) . store_idx ( 3 ) ;
1112
1112
i = 0 ;
1113
1113
1114
1114
loop {
@@ -1132,7 +1132,7 @@ mod tests {
1132
1132
// ring. Ideally this should be done on a separate thread.
1133
1133
// Because of this update, the loop should be iterated again to consume the new
1134
1134
// available descriptor chains.
1135
- vq. avail ( ) . idx ( ) . store ( u16 :: to_le ( 4 ) ) ;
1135
+ vq. avail ( ) . store_idx ( 4 ) ;
1136
1136
if !q. enable_notification ( mem) . unwrap ( ) {
1137
1137
break ;
1138
1138
}
@@ -1144,7 +1144,7 @@ mod tests {
1144
1144
1145
1145
// Set an `idx` that is bigger than the number of entries added in the ring.
1146
1146
// This is an allowed scenario, but the indexes of the chain will have unexpected values.
1147
- vq. avail ( ) . idx ( ) . store ( u16 :: to_le ( 7 ) ) ;
1147
+ vq. avail ( ) . store_idx ( 7 ) ;
1148
1148
loop {
1149
1149
q. disable_notification ( mem) . unwrap ( ) ;
1150
1150
@@ -1199,7 +1199,7 @@ mod tests {
1199
1199
1200
1200
vq. add_desc_chains ( & descs, 0 ) . unwrap ( ) ;
1201
1201
// Let the device know it can consume chains with the index < 2.
1202
- vq. avail ( ) . idx ( ) . store ( u16 :: to_le ( 3 ) ) ;
1202
+ vq. avail ( ) . store_idx ( 3 ) ;
1203
1203
// No descriptor chains are consumed at this point.
1204
1204
assert_eq ! ( q. next_avail( ) , 0 ) ;
1205
1205
assert_eq ! ( q. next_used( ) , 0 ) ;
@@ -1232,7 +1232,7 @@ mod tests {
1232
1232
1233
1233
// Decrement `idx` which should be forbidden. We don't enforce this thing, but we should
1234
1234
// test that we don't panic in case the driver decrements it.
1235
- vq. avail ( ) . idx ( ) . store ( u16 :: to_le ( 1 ) ) ;
1235
+ vq. avail ( ) . store_idx ( 1 ) ;
1236
1236
// Invalid available ring index
1237
1237
assert ! ( q. iter( mem) . is_err( ) ) ;
1238
1238
}
@@ -1269,16 +1269,16 @@ mod tests {
1269
1269
// When the number of chains exposed by the driver is equal to or less than the queue
1270
1270
// size, the available ring index is valid and constructs an iterator successfully.
1271
1271
let avail_idx = Wrapping ( q. next_avail ( ) ) + Wrapping ( queue_size) ;
1272
- vq. avail ( ) . idx ( ) . store ( u16 :: to_le ( avail_idx. 0 ) ) ;
1272
+ vq. avail ( ) . store_idx ( avail_idx. 0 ) ;
1273
1273
assert ! ( q. iter( mem) . is_ok( ) ) ;
1274
1274
let avail_idx = Wrapping ( q. next_avail ( ) ) + Wrapping ( queue_size - 1 ) ;
1275
- vq. avail ( ) . idx ( ) . store ( u16 :: to_le ( avail_idx. 0 ) ) ;
1275
+ vq. avail ( ) . store_idx ( avail_idx. 0 ) ;
1276
1276
assert ! ( q. iter( mem) . is_ok( ) ) ;
1277
1277
1278
1278
// When the number of chains exposed by the driver is larger than the queue size, the
1279
1279
// available ring index is invalid and produces an error from constructing an iterator.
1280
1280
let avail_idx = Wrapping ( q. next_avail ( ) ) + Wrapping ( queue_size + 1 ) ;
1281
- vq. avail ( ) . idx ( ) . store ( u16 :: to_le ( avail_idx. 0 ) ) ;
1281
+ vq. avail ( ) . store_idx ( avail_idx. 0 ) ;
1282
1282
assert ! ( q. iter( mem) . is_err( ) ) ;
1283
1283
}
1284
1284
0 commit comments