File tree Expand file tree Collapse file tree 3 files changed +14
-14
lines changed Expand file tree Collapse file tree 3 files changed +14
-14
lines changed Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ const _TXDESC_SIZE: usize = core::mem::size_of::<TxDescriptor>();
39
39
/// value which applies to both TX and RX descriptors.
40
40
const _ASSERT_DESCRIPTOR_SIZES: ( ) = assert ! ( _RXDESC_SIZE == _TXDESC_SIZE) ;
41
41
42
- const DESC_WORD_SKIP : u8 = ( core :: mem :: size_of :: < RxDescriptor > ( ) / 4 - DESC_SIZE ) as u8 ;
42
+ const DESC_WORD_SKIP : u8 = ( ( _RXDESC_SIZE / 4 ) - DESC_SIZE ) as u8 ;
43
43
44
44
const _ASSERT_DESC_WORD_SKIP_SIZE: ( ) = assert ! ( DESC_WORD_SKIP <= 0b111 ) ;
45
45
Original file line number Diff line number Diff line change @@ -144,17 +144,26 @@ impl TxDescriptor {
144
144
}
145
145
}
146
146
147
+ #[ allow( unused) ]
147
148
fn is_last ( & self ) -> bool {
148
149
( self . inner_raw . read ( 3 ) & TXDESC_3_LD ) == TXDESC_3_LD
149
150
}
150
151
151
152
// Placeholder for API parity with f-series descriptor.
152
- pub ( super ) fn setup ( & mut self , _: & [ u8 ] ) { }
153
+ pub ( super ) fn setup ( & mut self , _: & [ u8 ] ) {
154
+ // Zero-out all fields in the descriptor
155
+ ( 0 ..4 ) . for_each ( |n| unsafe { self . inner_raw . write ( n, 0 ) } ) ;
156
+ }
153
157
154
158
pub ( super ) fn is_owned ( & self ) -> bool {
155
159
( self . inner_raw . read ( 3 ) & TXDESC_3_OWN ) == TXDESC_3_OWN
156
160
}
157
161
162
+ #[ allow( unused) ]
163
+ pub ( super ) fn is_context ( & self ) -> bool {
164
+ ( self . inner_raw . read ( 3 ) & TXDESC_3_CTXT ) == TXDESC_3_CTXT
165
+ }
166
+
158
167
#[ allow( unused) ]
159
168
pub ( super ) fn packet_id ( & self ) -> Option < & PacketId > {
160
169
self . packet_id . as_ref ( )
@@ -238,12 +247,3 @@ impl TxDescriptor {
238
247
self . cached_timestamp . as_ref ( )
239
248
}
240
249
}
241
-
242
- impl TxDescriptor {
243
- /// The initial value for a TxDescriptor
244
- pub const TX_INIT : Self = Self :: new ( ) ;
245
-
246
- pub ( crate ) fn prepare_packet ( & mut self ) -> bool {
247
- !self . is_owned ( )
248
- }
249
- }
Original file line number Diff line number Diff line change @@ -117,8 +117,8 @@ impl<'data> TxRing<'data, NotRunning> {
117
117
// Assert that the descriptors are properly aligned.
118
118
assert ! ( ring_ptr as u32 & !0b11 == ring_ptr as u32 ) ;
119
119
assert ! (
120
- self . ring. last_descriptor_mut ( ) as * const _ as u32 & !0b11
121
- == self . ring. last_descriptor_mut ( ) as * const _ as u32
120
+ self . ring. last_descriptor ( ) as * const _ as u32 & !0b11
121
+ == self . ring. last_descriptor ( ) as * const _ as u32
122
122
) ;
123
123
124
124
// Set the start pointer.
@@ -175,7 +175,7 @@ impl<'data> TxRing<'data, Running> {
175
175
176
176
assert ! ( length <= buffer. len( ) ) ;
177
177
178
- if descriptor. prepare_packet ( ) {
178
+ if ! descriptor. is_owned ( ) {
179
179
let r = f ( & mut buffer[ 0 ..length] ) ;
180
180
181
181
descriptor. send ( packet_id, & buffer[ 0 ..length] ) ;
You can’t perform that action at this time.
0 commit comments