Skip to content

Conversation

@embediver
Copy link
Contributor

@embediver embediver commented Jan 14, 2026

  • Added some basic unit tests for the I2C codec
  • Fixed a few bugs that surfaced when running the tests
    • The MctpI2cHeader::decode() function has to be called with only the 4-byte header (not the whole packet)
    • The Byte Count header field was checked against the whole packet, which is 3 byte larger than the field (instead of only 1)
    • Checking for empty packets (and returning early) was only done when PEC check was activated
  • Return the complete header when decoding a packet
  • Remove the I2C / SMBus / IPMI specific bits from the address bytes when decoding the header
  • Add doc comments

@embediver embediver force-pushed the fix/mctp-estack-i2c branch from 3715f55 to 71b23c6 Compare January 14, 2026 13:03
@embediver

This comment was marked as outdated.

@jk-ozlabs
Copy link
Member

Thanks! Given the dot-points are fairly independent, can you split this up into those separate changes?

And in the case of bug fixes, would be handy to include some detail about the bug.

MctpI2cHeader::decode(packet.get(..4).ok_or(Error::InvalidInput)?)?;
// total packet len == byte_count + 3 (destination, command code, byte count)
// pec is not included
if header.byte_count + 3 != packet.len() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It sounds like we're getting different packet formats input here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From the MCTP SMBus/I2C Transport Binding Specification:

This value is the count of bytes that follow the Byte Count field up to, but not including, the PEC byte

The packet holds the complete packet at this point (including the 3 bytes for source address , Command Code and Byte Count), with the PEC already stripped if checked.

…acket

Signed-off-by: Marvin Gudel <marvin.gudel@9elements.com>
…ddress when decoding

Signed-off-by: Marvin Gudel <marvin.gudel@9elements.com>
Signed-off-by: Marvin Gudel <marvin.gudel@9elements.com>
@embediver embediver force-pushed the fix/mctp-estack-i2c branch from 71b23c6 to 8ed9a25 Compare January 18, 2026 16:23
@embediver
Copy link
Contributor Author

Thanks! Given the dot-points are fairly independent, can you split this up into those separate changes?

And in the case of bug fixes, would be handy to include some detail about the bug.

I have created individual commits for the separate changes now.

The `MctpI2cHeader::decode(...)` method errors on slices that are not 4-byte.

Signed-off-by: Marvin Gudel <marvin.gudel@9elements.com>
The complete packet includes destination address,
command code, byte count and source address.
The check previously accounted only for the source adddress,
while the checked packet includes the whole header at that point.

Signed-off-by: Marvin Gudel <marvin.gudel@9elements.com>
Signed-off-by: Marvin Gudel <marvin.gudel@9elements.com>
@embediver embediver force-pushed the fix/mctp-estack-i2c branch from 8ed9a25 to 9e83a4f Compare January 18, 2026 16:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants