Skip to content

Conversation

@jk-ozlabs
Copy link
Member

Currently, MctpSerialHandler's public API gets passed a mctp::Stack object, and interacts with that for packet receive/transmit.

Newer-style end-usage of the stack objects tends to use the routing infrastructure though, which uses a simpler packet tx/rx interface to the transport (ie, populating [u8]s rather than handling the MCTP packets internally). This change converts the current interface to:

pub async fn recv_async(
    &mut self,
    input: &mut impl Read,
) -> mctp::Result<&[u8]> {

pub async fn send_async(
    &mut self,
    pkt: &[u8],
    output: &mut impl Write,
) -> mctp::Result<()> {

- which is easier to glue into the routing interface.

In doing this, convert the standalone crate to use the new MctpSerialHandler API, where it needs to own the mctp::Stack internally.

@jk-ozlabs jk-ozlabs force-pushed the pr/serial-api branch 2 times, most recently from b671f12 to 42c7f5d Compare June 4, 2025 03:34
Copy link
Member

@mkj mkj left a comment

Choose a reason for hiding this comment

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

Looks good, thanks

let _ = self.mctp.update(self.now());
let cookie = None;
let r = self.mctpserial.send_fill(
let mut fragmenter = self.mctp.start_send(
Copy link
Member

Choose a reason for hiding this comment

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

I'd consider revamping standalone to use Router and then serial.rs would be two simpler loops. That can be done later though.

Copy link
Member Author

Choose a reason for hiding this comment

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

I was debating doing that, but settled on the direct stack approach as a minimum change. Happy to convert later if Router makes more sense in general.

Currently, MctpSerialHandler's public API gets passed a mctp::Stack
object, and interacts with that for packet receive/transmit.

Newer-style end-usage of the stack objects tends to use the routing
infrastructure though, which uses a simpler packet tx/rx interface to the
transport (ie, populating [u8]s rather than handling the MCTP packets
internally). This change converts the current interface to:

    pub async fn recv_async(
        &mut self,
        input: &mut impl Read,
    ) -> mctp::Result<&[u8]> {

    pub async fn send_async(
        &mut self,
        pkt: &[u8],
        output: &mut impl Write,
    ) -> mctp::Result<()> {

- which is easier to glue into the routing interface.

In doing this, convert the standalone crate to use the new
MctpSerialHandler API, where it needs to own the mctp::Stack internally.

Signed-off-by: Jeremy Kerr <[email protected]>
@mkj mkj merged commit 0cc01b1 into CodeConstruct:main Jun 4, 2025
3 checks passed
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