-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
basic osfp support, combine the powers of reads/parse #305
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for putting this up! I've got a few nits and one bigger question, let me know if something isn't clear.
@@ -57,4 +57,14 @@ pub trait ParseFromModule: Sized { | |||
|
|||
/// Parse the result of the above reads into `Self`. | |||
fn parse<'a>(id: Identifier, reads: impl Iterator<Item = &'a [u8]>) -> Result<Self, Error>; | |||
|
|||
/// Use `reads` and `parse` together to collect data from a buffer. | |||
fn from_buf(id: Identifier, data: &[u8]) -> Result<Self, Error> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is this being or going to be used? It looks like data
needs to already have the entire memory map of the module in order for the offsets in the reads to correctly index it. Also, this doesn't take into account the page information in the reads, so I'm not sure how this would be used to parse that spans more than one page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm currently using this to parse EEPROM data made available by a Linux kernel driver as a file in sysfs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know the details of the Linux implementation there, but I don't understand how that can work. The datapath information is spread across many different pages, for example. How does the driver expose the idea of a page?
This PR adds
from_buf
convenience method toParseFromModule
to simplify client code a bit.Also makes a correction to Identifier value
0x19
QSFP 8X -> OSFP 8X from SFF-8024 table 4.2.Example use can be found here. I've tested this on an Nvidia MCP7Y00-N001 DAC and it seems to be working well.