Skip to content

Commit c8dce06

Browse files
committed
pldm: Add basic pldm-file support
Catch events from the mctp control core, and start a PLDM File Transfer when we have an EID assigned. We will add proper PDR support in an upcoming change. Signed-off-by: Jeremy Kerr <[email protected]>
1 parent d55b50d commit c8dce06

File tree

6 files changed

+265
-11
lines changed

6 files changed

+265
-11
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
1010

1111
1. Added support for NVMe-MI responder, gated on a new `nvme-mi` cargo feature
1212

13+
2. Added support for a PLDM for File Transfer requester, triggered on MCTP
14+
address assignment.
1315

1416
### Changed
1517

Cargo.lock

Lines changed: 115 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ categories = ["network-programming", "hardware-support"]
99

1010
[features]
1111
nvme-mi = ["dep:nvme-mi-dev"]
12+
pldm = ["dep:pldm", "dep:pldm-file"]
1213

1314
[dependencies]
1415
anyhow = "1.0.86"
@@ -26,6 +27,8 @@ mctp = "0.2.0"
2627
mctp-estack = { git = "https://github.com/CodeConstruct/mctp-rs", rev = "851360ed19ef78f2e7672daa90900cb4f38ad0b6", package = "mctp-estack" }
2728
nvme-mi-dev = { git = "https://github.com/CodeConstruct/nvme-mi-dev", branch = "main", optional = true }
2829
polling = "3.7.4"
30+
pldm = { git = "https://github.com/CodeConstruct/mctp-rs", rev = "851360ed19ef78f2e7672daa90900cb4f38ad0b6", package = "pldm", optional = true }
31+
pldm-file = { git = "https://github.com/CodeConstruct/mctp-rs", rev = "851360ed19ef78f2e7672daa90900cb4f38ad0b6", package = "pldm-file", optional = true }
2932
simplelog = "0.12.2"
3033
smol = "2.0.0"
3134
usbredirparser = { git = "https://github.com/CodeConstruct/usbredir-rs", branch = "main", package = "usbredirparser" }

ci/runtests.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ cargo test
1717
sets=(
1818
""
1919
"nvme-mi"
20+
"pldm"
21+
"nvme-mi,pldm"
2022
)
2123

2224
for features in "${sets[@]}"

src/main.rs

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,19 @@ use argh::FromArgs;
55
use futures::{select, FutureExt};
66
use log::{debug, info, warn, LevelFilter};
77
use mctp::{AsyncListener, AsyncRespChannel, Eid};
8-
use mctp_estack::router::{
9-
PortBottom, PortBuilder, PortId, PortLookup, PortStorage, Router,
8+
use mctp_estack::{
9+
control::{ControlEvent, MctpControl},
10+
router::{
11+
PortBottom, PortBuilder, PortId, PortLookup, PortStorage, Router,
12+
},
1013
};
14+
use std::time::Instant;
15+
1116
#[cfg(feature = "nvme-mi")]
1217
use nvme_mi_dev::nvme::{
1318
ManagementEndpoint, PciePort, PortType, Subsystem, SubsystemInfo,
1419
TwoWirePort,
1520
};
16-
use std::time::Instant;
1721

1822
mod serial;
1923
mod usbredir;
@@ -142,9 +146,12 @@ async fn echo<'a>(router: &'a Router<'a>) -> std::io::Result<()> {
142146
}
143147
}
144148

145-
async fn control<'a>(router: &'a Router<'a>) -> std::io::Result<()> {
149+
async fn control<'a>(
150+
router: &'a Router<'a>,
151+
ctrl_ev_sender: async_channel::Sender<ControlEvent>,
152+
) -> std::io::Result<()> {
146153
let mut l = router.listener(mctp::MCTP_TYPE_CONTROL)?;
147-
let mut c = mctp_estack::control::MctpControl::new(router);
154+
let mut c = MctpControl::new(router);
148155
let u = uuid::Uuid::new_v4();
149156

150157
let types = [
@@ -165,8 +172,12 @@ async fn control<'a>(router: &'a Router<'a>) -> std::io::Result<()> {
165172

166173
let r = c.handle_async(msg, resp).await;
167174

168-
if let Err(e) = r {
169-
info!("control handler failure: {e}");
175+
match r {
176+
Err(e) => info!("control handler failure: {e}"),
177+
Ok(Some(ev)) => {
178+
let _ = ctrl_ev_sender.force_send(ev);
179+
}
180+
Ok(None) => (),
170181
}
171182
}
172183
}
@@ -219,6 +230,18 @@ async fn nvme_mi<'a>(_router: &'a Router<'a>) -> std::io::Result<()> {
219230
futures::future::pending().await
220231
}
221232

233+
#[cfg(feature = "pldm")]
234+
mod pldm;
235+
#[cfg(not(feature = "pldm"))]
236+
mod pldm {
237+
pub async fn pldm<'a>(
238+
_router: &'a super::Router<'a>,
239+
_recv: async_channel::Receiver<super::ControlEvent>,
240+
) -> std::io::Result<()> {
241+
futures::future::pending().await
242+
}
243+
}
244+
222245
fn main() -> Result<()> {
223246
let opts: Options = argh::from_env();
224247

@@ -260,12 +283,15 @@ fn main() -> Result<()> {
260283
None => futures::future::Either::Right(futures::future::pending()),
261284
};
262285

286+
let (ctrl_ev_tx, ctrl_ev_rx) = async_channel::bounded(1);
287+
263288
smol::block_on(async {
264289
select!(
265290
_ = fut.fuse() => (),
266291
_ = run(transport, port_bottom, &router, start_time).fuse() => (),
267-
_ = control(&router).fuse() => (),
268-
_ = nvme_mi(&router).fuse() => ()
292+
_ = control(&router, ctrl_ev_tx).fuse() => (),
293+
_ = nvme_mi(&router).fuse() => (),
294+
_ = pldm::pldm(&router, ctrl_ev_rx).fuse() => (),
269295
)
270296
});
271297

0 commit comments

Comments
 (0)