@@ -7,7 +7,10 @@ use drv_fpga_api::{FpgaError, FpgaUserDesign, ReadOp, WriteOp};
7
7
use drv_transceivers_api:: { ModuleStatus , TransceiversError , NUM_PORTS } ;
8
8
use transceiver_messages:: ModuleId ;
9
9
use userlib:: UnwrapLite ;
10
- use zerocopy:: { byteorder, FromBytes , IntoBytes , Unaligned , U16 } ;
10
+ use zerocopy:: {
11
+ byteorder:: little_endian, FromBytes , Immutable , IntoBytes , KnownLayout ,
12
+ Unaligned ,
13
+ } ;
11
14
12
15
// The transceiver modules are split across two FPGAs on the QSFP Front IO
13
16
// board, so while we present the modules as a unit, the communication is
@@ -732,7 +735,7 @@ impl Transceivers {
732
735
let mask = fpga_masks. get ( fpga_index) ;
733
736
if !mask. is_empty ( ) {
734
737
let fpga = self . fpga ( fpga_index) ;
735
- let wdata: U16 < byteorder :: LittleEndian > = U16 :: new ( mask. get ( ) ) ;
738
+ let wdata = little_endian :: U16 :: new ( mask. get ( ) ) ;
736
739
// mark that an error occurred so we can modify the success mask
737
740
if fpga. write ( op, addr, wdata) . is_err ( ) {
738
741
error |= match fpga_index {
@@ -832,11 +835,11 @@ impl Transceivers {
832
835
/// success: we were able to read from the FPGA
833
836
/// error: an `FpgaError` occurred
834
837
pub fn get_module_status ( & self ) -> ( ModuleStatus , ModuleResultNoFailure ) {
835
- let ldata: Option < [ U16 < byteorder :: LittleEndian > ; 8 ] > = self
838
+ let ldata: Option < [ little_endian :: U16 ; 8 ] > = self
836
839
. fpga ( FpgaController :: Left )
837
840
. read ( Addr :: QSFP_POWER_EN0 )
838
841
. ok ( ) ;
839
- let rdata: Option < [ U16 < byteorder :: LittleEndian > ; 8 ] > = self
842
+ let rdata: Option < [ little_endian :: U16 ; 8 ] > = self
840
843
. fpga ( FpgaController :: Right )
841
844
. read ( Addr :: QSFP_POWER_EN0 )
842
845
. ok ( ) ;
@@ -877,7 +880,8 @@ impl Transceivers {
877
880
let error = !success;
878
881
879
882
(
880
- ModuleStatus :: read_from ( status_masks. as_bytes ( ) ) . unwrap_lite ( ) ,
883
+ ModuleStatus :: read_from_bytes ( status_masks. as_bytes ( ) )
884
+ . unwrap_lite ( ) ,
881
885
ModuleResultNoFailure :: new ( success, error) . unwrap_lite ( ) ,
882
886
)
883
887
}
@@ -988,7 +992,7 @@ impl Transceivers {
988
992
let request = TransceiversI2CRequest {
989
993
reg,
990
994
num_bytes,
991
- mask : U16 :: new ( fpga_masks. left . 0 ) ,
995
+ mask : little_endian :: U16 :: new ( fpga_masks. left . 0 ) ,
992
996
op : i2c_op as u8 ,
993
997
} ;
994
998
@@ -1005,7 +1009,7 @@ impl Transceivers {
1005
1009
let request = TransceiversI2CRequest {
1006
1010
reg,
1007
1011
num_bytes,
1008
- mask : U16 :: new ( fpga_masks. right . 0 ) ,
1012
+ mask : little_endian :: U16 :: new ( fpga_masks. right . 0 ) ,
1009
1013
op : i2c_op as u8 ,
1010
1014
} ;
1011
1015
if self
@@ -1243,7 +1247,7 @@ impl Transceivers {
1243
1247
// The I2C control register looks like:
1244
1248
// [2..1] - Operation (0 - Read, 1 - Write, 2 - RandomRead)
1245
1249
// [0] - Start
1246
- #[ derive( Copy , Clone , Debug , IntoBytes ) ]
1250
+ #[ derive( Copy , Clone , Debug , IntoBytes , Immutable , KnownLayout ) ]
1247
1251
#[ repr( u8 ) ]
1248
1252
pub enum TransceiverI2COperation {
1249
1253
Read = 0x01 ,
@@ -1258,11 +1262,11 @@ impl From<TransceiverI2COperation> for u8 {
1258
1262
}
1259
1263
}
1260
1264
1261
- #[ derive( IntoBytes , FromBytes , Unaligned ) ]
1265
+ #[ derive( IntoBytes , FromBytes , Immutable , KnownLayout , Unaligned ) ]
1262
1266
#[ repr( C ) ]
1263
1267
pub struct TransceiversI2CRequest {
1264
1268
reg : u8 ,
1265
1269
num_bytes : u8 ,
1266
- mask : U16 < byteorder :: LittleEndian > ,
1270
+ mask : little_endian :: U16 ,
1267
1271
op : u8 ,
1268
1272
}
0 commit comments