Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,16 @@ embassy-executor = { git = "https://github.com/embassy-rs/embassy/", rev = "0290


# Updated for embassy-usb api change
mctp-usb-embassy = { git = "https://github.com/CodeConstruct/mctp-rs", rev = "8051f2ee30e83efea8cadc1cfdc6d976dba41ed3" }
mctp-usb-embassy = { git = "https://github.com/CodeConstruct/mctp-rs", rev = "88c9eba20c6ac62025438bb7ca9b9578c9f2679c" }
# Updated to match mtp-usb-embassy. Also has performance and stack size improvements.
# Includes ControlEvent change.
mctp-estack = { git = "https://github.com/CodeConstruct/mctp-rs", rev = "8051f2ee30e83efea8cadc1cfdc6d976dba41ed3" }
mctp = { git = "https://github.com/CodeConstruct/mctp-rs", rev = "8051f2ee30e83efea8cadc1cfdc6d976dba41ed3" }
mctp-estack = { git = "https://github.com/CodeConstruct/mctp-rs", rev = "88c9eba20c6ac62025438bb7ca9b9578c9f2679c" }
mctp = { git = "https://github.com/CodeConstruct/mctp-rs", rev = "88c9eba20c6ac62025438bb7ca9b9578c9f2679c" }

# pldm-file and pldm-platform are not yet published
pldm = { git = "https://github.com/CodeConstruct/mctp-rs", rev = "8051f2ee30e83efea8cadc1cfdc6d976dba41ed3" }
pldm-file = { git = "https://github.com/CodeConstruct/mctp-rs", rev = "8051f2ee30e83efea8cadc1cfdc6d976dba41ed3" }
pldm-platform = { git = "https://github.com/CodeConstruct/mctp-rs", rev = "8051f2ee30e83efea8cadc1cfdc6d976dba41ed3" }
pldm = { git = "https://github.com/CodeConstruct/mctp-rs", rev = "88c9eba20c6ac62025438bb7ca9b9578c9f2679c" }
pldm-file = { git = "https://github.com/CodeConstruct/mctp-rs", rev = "88c9eba20c6ac62025438bb7ca9b9578c9f2679c" }
pldm-platform = { git = "https://github.com/CodeConstruct/mctp-rs", rev = "88c9eba20c6ac62025438bb7ca9b9578c9f2679c" }

[features]
default = ["log-usbserial", "nvme-mi", "pldm-file"]
Expand Down
41 changes: 14 additions & 27 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@ use embassy_sync::blocking_mutex::raw::CriticalSectionRawMutex;
use mctp::{AsyncListener, AsyncRespChannel};
use mctp::{Eid, MsgType};
use mctp_estack::control::ControlEvent;
use mctp_estack::router::{
PortBottom, PortBuilder, PortId, PortLookup, PortStorage, PortTop, Router,
};
use mctp_estack::router::{Port, PortId, PortLookup, PortTop, Router};

mod ccvendor;
mod multilog;
Expand Down Expand Up @@ -125,16 +123,16 @@ impl Routes {

impl PortLookup for Routes {
fn by_eid(
&mut self,
&self,
_eid: Eid,
src_port: Option<PortId>,
) -> Option<PortId> {
) -> (Option<PortId>, Option<usize>) {
if src_port == Some(Self::USB_INDEX) {
// Avoid routing loops
return None;
return (None, None);
}
// All packets out USB
Some(Self::USB_INDEX)
(Some(Self::USB_INDEX), Some(USB_MTU))
}
}

Expand Down Expand Up @@ -171,31 +169,23 @@ fn main() -> ! {
executor.run(|spawner| run(spawner, logger))
}

fn setup_mctp() -> (&'static mut Router<'static>, PortBottom<'static>) {
static USB_PORT_STORAGE: StaticCell<PortStorage<4>> = StaticCell::new();
static USB_PORT: StaticCell<PortBuilder> = StaticCell::new();

static PORTS: StaticCell<[PortTop; 1]> = StaticCell::new();
fn setup_mctp() -> (&'static Router<'static>, Port<'static>) {
static USB_TOP: StaticCell<PortTop> = StaticCell::new();
static LOOKUP: StaticCell<Routes> = StaticCell::new();
static ROUTER: StaticCell<Router> = StaticCell::new();

// USB port for the MCTP router
let usb_port_storage = USB_PORT_STORAGE.init_with(PortStorage::new);
let usb_port = USB_PORT.init_with(|| PortBuilder::new(usb_port_storage));
let (mctp_usb_top, mctp_usb_bottom) = usb_port.build(USB_MTU).unwrap();

let ports = PORTS.init([mctp_usb_top]);
let usb_top = USB_TOP.init_with(PortTop::new);

// MCTP stack
let max_mtu = USB_MTU;
let lookup = LOOKUP.init(Routes {});
// Router+Stack is large, using init_with() is important to construct in-place
let router = ROUTER.init_with(|| {
let stack = mctp_estack::Stack::new(Eid(0), max_mtu, now());
Router::new(stack, ports, lookup)
});
// Router is large, using init_with() is important to construct in-place
let router = ROUTER.init_with(|| Router::new(Eid(0), lookup, now()));
let usb_id = router.add_port(usb_top).unwrap();
debug_assert_eq!(usb_id, Routes::USB_INDEX);
let usb_port = router.port(Routes::USB_INDEX).unwrap();

(router, mctp_usb_bottom)
(router, usb_port)
}

type SignalCS<T> = embassy_sync::signal::Signal<CriticalSectionRawMutex, T>;
Expand Down Expand Up @@ -484,9 +474,6 @@ async fn bench_task(
};

select(send, stopped).await;

// required by tag_noexpire()
req.async_drop().await;
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/usb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use embassy_sync::signal::Signal;
use embassy_usb::class::cdc_acm;
use embassy_usb::Builder;
use heapless::String;
use mctp_estack::router::{PortBottom, PortId, Router};
use mctp_estack::router::{Port, PortId, Router};
use mctp_usb_embassy::{MctpUsbClass, MCTP_USB_MAX_PACKET};
use static_cell::StaticCell;

Expand Down Expand Up @@ -126,7 +126,7 @@ pub async fn usb_recv_task(

#[embassy_executor::task]
pub async fn usb_send_task(
mctp_usb_bottom: PortBottom<'static>,
mctp_usb_bottom: Port<'static>,
usb_sender: mctp_usb_embassy::Sender<'static, Driver<'static, USB_OTG_HS>>,
) -> ! {
usb_sender.run(mctp_usb_bottom).await;
Expand Down