@@ -8,6 +8,7 @@ use crate::{
88 coalesce:: { parse_coalesce_nlas, EthtoolCoalesceAttr } ,
99 feature:: { parse_feature_nlas, EthtoolFeatureAttr } ,
1010 fec:: { parse_fec_nlas, EthtoolFecAttr } ,
11+ eeprom:: { parse_module_eeprom_nlas, EthtoolModuleEEPROMAttr } ,
1112 link_mode:: { parse_link_mode_nlas, EthtoolLinkModeAttr } ,
1213 pause:: { parse_pause_nlas, EthtoolPauseAttr } ,
1314 ring:: { parse_ring_nlas, EthtoolRingAttr } ,
@@ -32,6 +33,8 @@ const ETHTOOL_MSG_FEC_GET_REPLY: u8 = 30;
3233const ETHTOOL_MSG_CHANNELS_GET : u8 = 17 ;
3334const ETHTOOL_MSG_CHANNELS_GET_REPLY : u8 = 18 ;
3435const ETHTOOL_MSG_CHANNELS_SET : u8 = 18 ;
36+ const ETHTOOL_MSG_MODULE_EEPROM_GET : u8 = 31 ;
37+ const ETHTOOL_MSG_MODULE_EEPROM_GET_REPLY : u8 = 32 ;
3538
3639#[ derive( Debug , PartialEq , Eq , Clone , Copy ) ]
3740pub enum EthtoolCmd {
@@ -52,6 +55,8 @@ pub enum EthtoolCmd {
5255 ChannelGet ,
5356 ChannelGetReply ,
5457 ChannelSet ,
58+ ModuleEEPROMGet ,
59+ ModuleEEPROMGetReply ,
5560}
5661
5762impl From < EthtoolCmd > for u8 {
@@ -74,6 +79,8 @@ impl From<EthtoolCmd> for u8 {
7479 EthtoolCmd :: ChannelGet => ETHTOOL_MSG_CHANNELS_GET ,
7580 EthtoolCmd :: ChannelGetReply => ETHTOOL_MSG_CHANNELS_GET_REPLY ,
7681 EthtoolCmd :: ChannelSet => ETHTOOL_MSG_CHANNELS_SET ,
82+ EthtoolCmd :: ModuleEEPROMGet => ETHTOOL_MSG_MODULE_EEPROM_GET ,
83+ EthtoolCmd :: ModuleEEPROMGetReply => ETHTOOL_MSG_MODULE_EEPROM_GET_REPLY ,
7784 }
7885 }
7986}
@@ -88,6 +95,7 @@ pub enum EthtoolAttr {
8895 TsInfo ( EthtoolTsInfoAttr ) ,
8996 Fec ( EthtoolFecAttr ) ,
9097 Channel ( EthtoolChannelAttr ) ,
98+ ModuleEEPROM ( EthtoolModuleEEPROMAttr ) ,
9199}
92100
93101impl Nla for EthtoolAttr {
@@ -101,6 +109,7 @@ impl Nla for EthtoolAttr {
101109 Self :: TsInfo ( attr) => attr. value_len ( ) ,
102110 Self :: Fec ( attr) => attr. value_len ( ) ,
103111 Self :: Channel ( attr) => attr. value_len ( ) ,
112+ Self :: ModuleEEPROM ( attr) => attr. value_len ( ) ,
104113 }
105114 }
106115
@@ -114,6 +123,7 @@ impl Nla for EthtoolAttr {
114123 Self :: TsInfo ( attr) => attr. kind ( ) ,
115124 Self :: Fec ( attr) => attr. kind ( ) ,
116125 Self :: Channel ( attr) => attr. kind ( ) ,
126+ Self :: ModuleEEPROM ( attr) => attr. kind ( ) ,
117127 }
118128 }
119129
@@ -127,6 +137,7 @@ impl Nla for EthtoolAttr {
127137 Self :: TsInfo ( attr) => attr. emit_value ( buffer) ,
128138 Self :: Fec ( attr) => attr. emit_value ( buffer) ,
129139 Self :: Channel ( attr) => attr. emit_value ( buffer) ,
140+ Self :: ModuleEEPROM ( attr) => attr. emit_value ( buffer) ,
130141 }
131142 }
132143}
@@ -287,11 +298,41 @@ impl EthtoolMessage {
287298 vec ! [ EthtoolAttr :: Channel ( EthtoolChannelAttr :: Header ( vec![
288299 EthtoolHeader :: DevName ( iface_name. to_string( ) ) ,
289300 ] ) ) ] ;
301+
290302 EthtoolMessage {
291303 cmd : EthtoolCmd :: ChannelSet ,
292304 nlas,
293305 }
294306 }
307+
308+
309+ pub fn new_module_eeprom_get (
310+ iface_name : Option < & str > ,
311+ offset : u32 ,
312+ length : u32 ,
313+ page : u8 ,
314+ bank : u8 ,
315+ i2c_address : u8 ) -> Self {
316+ let mut nlas = match iface_name {
317+ Some ( s) => {
318+ vec ! [ EthtoolAttr :: ModuleEEPROM ( EthtoolModuleEEPROMAttr :: Header ( vec![
319+ EthtoolHeader :: DevName ( s. to_string( ) ) ,
320+ ] ) ) ]
321+ }
322+ None => {
323+ vec ! [ EthtoolAttr :: ModuleEEPROM ( EthtoolModuleEEPROMAttr :: Header ( vec![ ] ) ) ]
324+ }
325+ } ;
326+ nlas. push ( EthtoolAttr :: ModuleEEPROM ( EthtoolModuleEEPROMAttr :: Offset ( offset) ) ) ;
327+ nlas. push ( EthtoolAttr :: ModuleEEPROM ( EthtoolModuleEEPROMAttr :: Length ( length) ) ) ;
328+ nlas. push ( EthtoolAttr :: ModuleEEPROM ( EthtoolModuleEEPROMAttr :: Page ( page) ) ) ;
329+ nlas. push ( EthtoolAttr :: ModuleEEPROM ( EthtoolModuleEEPROMAttr :: Bank ( bank) ) ) ;
330+ nlas. push ( EthtoolAttr :: ModuleEEPROM ( EthtoolModuleEEPROMAttr :: I2CAddress ( i2c_address) ) ) ;
331+ EthtoolMessage {
332+ cmd : EthtoolCmd :: ModuleEEPROMGet ,
333+ nlas,
334+ }
335+ }
295336}
296337
297338impl Emitable for EthtoolMessage {
@@ -342,6 +383,10 @@ impl ParseableParametrized<[u8], GenlHeader> for EthtoolMessage {
342383 cmd : EthtoolCmd :: ChannelGetReply ,
343384 nlas : parse_channel_nlas ( buffer) ?,
344385 } ,
386+ ETHTOOL_MSG_MODULE_EEPROM_GET_REPLY => Self {
387+ cmd : EthtoolCmd :: ModuleEEPROMGetReply ,
388+ nlas : parse_module_eeprom_nlas ( buffer) ?,
389+ } ,
345390 cmd => {
346391 return Err ( DecodeError :: from ( format ! (
347392 "Unsupported ethtool reply command: {cmd}"
0 commit comments