-
Notifications
You must be signed in to change notification settings - Fork 1
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 MCTP control command tests #46
Conversation
… into pbhogaraju/mctp_capsule
This maps the internal queues in the I3C emulator peripheral to the interrupt controller, and modifies the tests so that they no longer manually poll. I also added a new package, `romtime`, for drivers and utilities that are useful for both ROM and Runtime. For now, this contains an implementation of `print!` and `println!` that output to the emulator UART immediately, which is useful for both ROM and when running in Tock kernel when `debug!` may not be available (such as during tests or interrupts).
Co-authored-by: Parvathi Bhogaraju <[email protected]>
…cu-sw into pbhogaraju/mctp_capsule
…cu-sw into pbhogaraju/mctp_capsule
… into pbhogaraju/mctp_capsule
…cu-sw into pbhogaraju/mctp_capsule
… into pbhogaraju/mctp_capsule
… into pbhogaraju/mctp_capsule
emulator/app/Cargo.toml
Outdated
@@ -25,8 +25,13 @@ gdbstub.workspace = true | |||
hex.workspace = true | |||
tock-registers.workspace = true | |||
zerocopy.workspace = true | |||
bitfield.workspace = true | |||
crc = "3.2.1" |
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.
minor nit: this is the same package that is used in emulator/bmc/pldm-fw-pkg/Cargo.toml
, so we might as well consolidate them into the main Cargo.toml
so they don't accidentally get out of sync.
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.
Done
tests: Vec<Test>, | ||
) { | ||
let running_clone = running.clone(); | ||
let addr = SocketAddr::from(([127, 0, 0, 1], port)); |
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.
This can be addressed in another PR, but since we are only communicating with the socket locally and not from another program, it might be easier to use the mpsc
channels directly so that we don't have to worry about the ports. (Otherwise, we're going to run into issues where there is a port conflict since we hard code the port and don't check if it's already in use.)
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.
You are right! I did face a port conflict once while testing. I'll change to mpsc
in the next PR when I add more tests.
@@ -0,0 +1,212 @@ | |||
// Licensed under the Apache-2.0 license | |||
|
|||
// use crc; |
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.
Not needed anymore?
// use crc; |
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.
removed.
pub const MCTP_CTRL_MSG_HDR_SIZE: usize = 2; | ||
|
||
#[macro_export] | ||
macro_rules! set_eid_req { |
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.
These macros feel like they could just be simple functions?
Like fn set_eid_req(op: u8, eid: u8) -> Vec<u8>
?
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.
changed to functions
runtime/i3c/src/core.rs
Outdated
@@ -21,6 +21,9 @@ use registers_generated::i3c::I3C_CSR_ADDR; | |||
use tock_registers::register_bitfields; | |||
use tock_registers::LocalRegisterCopy; | |||
|
|||
use core::fmt::Write; | |||
use romtime::println; |
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 think these imports are used anymore?
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.
removed
emulator/periph/src/i3c_protocol.rs
Outdated
@@ -72,6 +72,7 @@ impl I3cController { | |||
let running = self.running.clone(); | |||
let targets = self.targets.clone(); | |||
let counter = self.incoming_counter.clone(); | |||
println!("Starting I3C controller thread"); |
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.
Maybe we don't need this line?
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.
removed
emulator/periph/src/i3c.rs
Outdated
self.i3c_target.send_ibi(self.tti_ibi_buffer[4]); | ||
self.tti_ibi_buffer.drain(0..len + 4); | ||
self.tti_ibi_buffer.drain(0..8); |
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.
Theoretically this length could be more, so maybe (len + 4).next_multiple_of(4)
?
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.
That sounds correct! Changed!
let mut read_cmd = ReguDataTransferCommand::read_from_bytes(&[0; 8]).unwrap(); | ||
read_cmd.set_rnw(1); | ||
read_cmd.set_data_length(0); | ||
let cmd_words: [u32; 2] = transmute!(read_cmd); |
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 a little worried about endianness biting us, especially in the (unlikely) event we ever run this code with a big endian host.
Could we add a test at least that checks that the packets generated have the bytes that we expect? (That way if something weird happens with endianness in the future, we'll at least have a test to let us know.)
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.
Good idea! Added tests for prepare_private_read and prepare_private_write functions.
… into pbhogaraju/mctp_capsule
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.
LGTM
This PR adds MCTP mux component and instantiate it in the board configuration
Allocate resources just enough for instantiating the MCTP MUX driver. There'll be new additions in the future.
The static reference in the platform structure is temporarily added until the driver layer is implemented.
This should set up the stack for testing the MCTP control messages with integration test framework.