opentitan icon indicating copy to clipboard operation
opentitan copied to clipboard

[i2c] investigate and add MCTP mode to I2C

Open sjgitty opened this issue 6 years ago • 20 comments

@igk8 @tunghoang290780 @martin-lueker

It has been requested for us to look into adding MCTP mode into our I2C functionality. Please research and let us know the ramifications for adding this feature into the existing design.

sjgitty avatar Jun 27 '20 23:06 sjgitty

@sjgitty Are you referring to MCTP 1.2.0 specification? https://www.dmtf.org/sites/default/files/standards/documents/DSP0237_1.2.0.pdf

tunghoang290780 avatar Jun 28 '20 00:06 tunghoang290780

I can check if that is the most appropriate version, but that appears to be the right one.

sjgitty avatar Jun 28 '20 04:06 sjgitty

A quick read of that in section 6.3 it indicates "All MCTP transactions are based on the SMBus Block Write bus protocol". We can support that (example in the util/i2csvg/smbus) so the basics are there. It uses PEC which is an 8-bit CRC we can calculate and check in software (although we need to understand how to react if it does not match).

The spec does (or at least can) make use of the SMBus ARP and UDID framework. I have never delved into this before (or seen it used). From a scan of the SMBus spec we may: (a) want something special to allow the device interface to accept transactions on the couple of special addresses: the default address 1100_001 and smbus host 0001_000, each would need an enable (b) need to look very carefully at the collision detection because that is critical to operation (c) need to think hard about the special cases where late in the transaction the receiver discovers it is for another device and NAK is needed on subsequent bytes.

I did just notice that SMBus defines "Host" as distinct from "Master", a "Host" must be "Master-Slave"

mdhayter avatar Jun 28 '20 22:06 mdhayter

Hi @mdhayter, Thanks for the analysis! I am unfamiliar with the MCTP protocol, but I'm optimistic that we should be able to do this given all the analysis you've already done in helping us support SMBus. I'll continue to look this protocol over. Meanwhile @igk8: Do you think there would be any issue with supporting the special cases (a), (b) & (c) that @mdhayter mentions above?

martin-lueker avatar Jul 03 '20 23:07 martin-lueker

I have never encountered MCTP before, so a deeper review is probably needed than the one I did.

@sjgitty is there anyone who would be coding up the software side of the protocol who should review?

mdhayter avatar Jul 04 '20 01:07 mdhayter

I have never encountered MCTP before, so a deeper review is probably needed than the one I did.

@sjgitty is there anyone who would be coding up the software side of the protocol who should review?

I don't have a name for you at this time. The request was from an external interested party, so not native to our project. I'll see if they can formulate the request a bit more narrowly, but the first request was to keep this spec in mind while working on I2C as it has some features that aren't intrinsically obvious. @gkelly for visibility.

sjgitty avatar Jul 09 '20 18:07 sjgitty

Pinging @igk8 about the MCTP questions posed earlier on this thread.

mateenfaisal avatar Feb 04 '21 21:02 mateenfaisal

MCTP is just a layer on top of SMBus. There is already a Rust implementation available here: https://github.com/westerndigitalcorporation/libmctp

I have tested MCTP on an ARM board with Tock and libMCTP and it works with just a standard I2C master that supports SMBus. There shouldn't be any hardware changes required for MCTP, as long as SMBus works MCTP will work.

alistair23 avatar Feb 04 '21 22:02 alistair23

Does the I2C/SMBUS block need multi-master support to enable MCTP?

gghere avatar Jun 16 '22 19:06 gghere

Does the I2C/SMBUS block need multi-master support to enable MCTP?

Yes. MCTP messages are always transmitted as a block write, so in slave mode to receive messages.

mkj avatar Jun 17 '22 03:06 mkj

MCTP shouldn't required multi-master support, but other layers on top might (Cerberus does for example)

alistair23 avatar Jun 17 '22 04:06 alistair23

From the MCTP smbus/i2c Transport binding spec https://www.dmtf.org/sites/default/files/standards/documents/DSP0237_1.2.0.pdf

It looks like a slave address is required at both ends, spec quoted below.

" 6.11.1 Slave addresses Each device on SMBus/I2C shall have a slave address to be the target of transactions by bus masters. The MCTP transport protocol solely utilizes Master Write transactions to transfer MCTP packets between MCTP endpoints. For endpoint "A" to send an MCTP packet to endpoint "B", endpoint A shall master the bus and issue a Block-Write transaction to the slave address of endpoint B. Similarly, for endpoint B to send an MCTP packet to endpoint A, it shall master the bus and issue a Block-Write transaction to the slave address of endpoint A. Thus, bi-directional transfer of MCTP packets requires that both sides of the communication have slave addresses. "

@alistair23 - do lets know how to get it working without multi-master support - that would be great - thanks

gghere avatar Jun 17 '22 17:06 gghere

Ah you're right! I forgot about that Sorry, it's been ages since I looked at this

alistair23 avatar Jun 17 '22 23:06 alistair23

Inspired by IPMI, looks like.

a-will avatar Jun 17 '22 23:06 a-will

Need to figure out whether this is relevant for PROD. CC @GregAC @jesultra @moidx @moidx for thoughts.

msfschaffner avatar Oct 06 '23 22:10 msfschaffner

I am not sure we will be able to implement this for PROD given our current schedule, hence I am placing this into the backlog. Please let me know if you think otherwise.

msfschaffner avatar Jan 13 '24 00:01 msfschaffner

Moving back to PROD.M2 as this may be precluding the implementation of MCTP in firmware. @a-will can you confirm? I am not sure if there is a separate issue for tracking I2C multi-master support.

moidx avatar Feb 03 '24 00:02 moidx

Moving back to PROD.M2 as this may be precluding the implementation of MCTP in firmware. @a-will can you confirm? I am not sure if there is a separate issue for tracking I2C multi-master support.

That's correct. I2C multi-master support is required for the MCTP over I2C binding. There are additional requirements beyond just that, though, such as needing to be able to time out clock stretching (and following up with NACK for that byte).

For that particular one, this issue is related: https://github.com/lowRISC/opentitan/issues/15227

In addition, the controller and target mode FSMs would likely need to become independent, for simplicity in having them active simultaneously. Semi-related issue: https://github.com/lowRISC/opentitan/issues/18655

a-will avatar Feb 03 '24 00:02 a-will

I'm moving this to M4: The scoping was part of M2 and that is complete. After decisions have been taken, there may be DD and DV work but that comes after M2.

Note that this is currently a scoping issue and as such doesn't directly have DD or DV effort associated with it; those efforts are tracked in separate issues.

andreaskurth avatar Mar 14 '24 07:03 andreaskurth

Closing as this has been used for scoping, which is complete, and https://github.com/lowRISC/opentitan/issues/22569 now tracks MCTP implementation.

andreaskurth avatar May 10 '24 15:05 andreaskurth