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>();
3939/// value which applies to both TX and RX descriptors.
4040const _ASSERT_DESCRIPTOR_SIZES: ( ) = assert ! ( _RXDESC_SIZE == _TXDESC_SIZE) ;
4141
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 ;
4343
4444const _ASSERT_DESC_WORD_SKIP_SIZE: ( ) = assert ! ( DESC_WORD_SKIP <= 0b111 ) ;
4545
Original file line number Diff line number Diff line change @@ -144,17 +144,26 @@ impl TxDescriptor {
144144 }
145145 }
146146
147+ #[ allow( unused) ]
147148 fn is_last ( & self ) -> bool {
148149 ( self . inner_raw . read ( 3 ) & TXDESC_3_LD ) == TXDESC_3_LD
149150 }
150151
151152 // 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+ }
153157
154158 pub ( super ) fn is_owned ( & self ) -> bool {
155159 ( self . inner_raw . read ( 3 ) & TXDESC_3_OWN ) == TXDESC_3_OWN
156160 }
157161
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+
158167 #[ allow( unused) ]
159168 pub ( super ) fn packet_id ( & self ) -> Option < & PacketId > {
160169 self . packet_id . as_ref ( )
@@ -238,12 +247,3 @@ impl TxDescriptor {
238247 self . cached_timestamp . as_ref ( )
239248 }
240249}
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> {
117117 // Assert that the descriptors are properly aligned.
118118 assert ! ( ring_ptr as u32 & !0b11 == ring_ptr as u32 ) ;
119119 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
122122 ) ;
123123
124124 // Set the start pointer.
@@ -175,7 +175,7 @@ impl<'data> TxRing<'data, Running> {
175175
176176 assert ! ( length <= buffer. len( ) ) ;
177177
178- if descriptor. prepare_packet ( ) {
178+ if ! descriptor. is_owned ( ) {
179179 let r = f ( & mut buffer[ 0 ..length] ) ;
180180
181181 descriptor. send ( packet_id, & buffer[ 0 ..length] ) ;
You can’t perform that action at this time.
0 commit comments