Skip to content
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

Add syscall driver support for mctp capsule #59

Merged
merged 7 commits into from
Dec 17, 2024

Conversation

parvathib
Copy link
Collaborator

This PR implements the syscall driver support for the MCTP capsule includes the instantiation of the MCTP capsule driver for SPDM, PLDM, and vendor-defined PCI message types.
I'll incorporate some MCTP MUX layer testing in the kernel in the upcoming PR.

runtime/src/board.rs Outdated Show resolved Hide resolved
}

impl OpContext {
fn for_me(&self, msg_tag: u8, peer_eid: u8, msg_type: u8) -> bool {
Copy link
Collaborator

Choose a reason for hiding this comment

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

for_me is a little confusing. Maybe matches or is_compatible?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Haha, I've been switching between for_me and is_matched before pushing the PR. Thanks for the help with the naming! I'll go with matches.

kernel_msg_buf,
) {
Ok(_) => {
println!("MCTPDriver: send_msg success");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove debugging printlns?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

removed

);
kernel_msg_buf.slice(0..wpayload.len());

match self.sender.send_msg(
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is getting deeply nested -- maybe break up this command function or some parts of it so it is easier to follow along? Some comments probably could help as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I cleaned send message part of command a little and added some comments. This might need further refining once I start testing user apps. Let me know how it looks now.

Comment on lines 264 to 268
match res {
Ok(()) => Ok(()),
Err(e) => Err(e),
}
// Ok(())
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
match res {
Ok(()) => Ok(()),
Err(e) => Err(e),
}
// Ok(())
res

?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Refactored this part of the code. Let me know if this looks okay now.

MctpControl = 0,
Pldm = 1,
Spdm = 5,
SecureSPDM = 6,
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: We're being a bit inconsistent with if we are capitalizing initialisms SPDM or Spdm.

I think Tock in general uses Spdm style, so we should stick with that.

Copy link
Collaborator Author

@parvathib parvathib Dec 17, 2024

Choose a reason for hiding this comment

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

Noted! Changed them accordingly.

/// # Returns
/// True if the message type is expected, false otherwise.
pub fn is_receive_expected(&self, msg_type: MessageType) -> bool {
let msg_types = self.msg_types.get();
Copy link
Collaborator

Choose a reason for hiding this comment

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

I can't decide if this is easier to read, or if the functional style is:

self.msg_types.get().iter().find(|t| *t == msg_type).unwrap_or_default()

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed to self.msg_types.get().iter().any(|&exp_type| exp_type == msg_type)

runtime/capsules/src/mctp/recv.rs Outdated Show resolved Hide resolved
self.msg_terminus.replace(msg_terminus);
})
.unwrap_or_else(|| {
println!(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe panic! in that case?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Right! corrected it.

use zerocopy::IntoBytes;

use core::cell::Cell;

Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: clean up spaces between imports?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

cleaned.

@parvathib parvathib requested a review from swenson December 17, 2024 18:41
Copy link
Collaborator

@swenson swenson left a comment

Choose a reason for hiding this comment

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

LGTM

@parvathib parvathib merged commit c8ec781 into main Dec 17, 2024
1 check passed
@parvathib parvathib deleted the pbhogaraju/mctp_syscall_driver branch December 17, 2024 19:23
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