Skip to content

Commit 700daa0

Browse files
authored
Extend the Mellanox driver to support packet transmit (#490)
* `test_mlx5`: an application crate for testing the Mellanox driver * `device_manger`: now initializes the Mellanox NIC * `mlx5_ethernet`: extended the command queue to support more commands and added additional modules for send queues, receive queues, completion queues, flow tables, etc. * `mlx5`: added additional command executions to create the send and receive queues, and supporting objects.
1 parent e9b9d87 commit 700daa0

17 files changed

Lines changed: 4027 additions & 506 deletions

File tree

Cargo.lock

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

applications/test_mlx5/Cargo.toml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[package]
2+
name = "test_mlx5"
3+
version = "0.1.0"
4+
authors = ["Ramla Ijaz <ijazramla@gmail.com>"]
5+
build = "../../build.rs"
6+
7+
[dependencies]
8+
9+
[dependencies.log]
10+
version = "0.4.8"
11+
12+
[dependencies.terminal_print]
13+
path = "../../kernel/terminal_print"
14+
15+
[dependencies.ixgbe]
16+
path = "../../kernel/ixgbe"
17+
18+
[dependencies.mlx5]
19+
path = "../../kernel/mlx5"

applications/test_mlx5/src/lib.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//! Application which checks the functionality of the mlx5 driver.
2+
//! Currently we use functions directly provided by the driver for sending and receiving packets.
3+
4+
#![no_std]
5+
extern crate alloc;
6+
// #[macro_use] extern crate log;
7+
#[macro_use] extern crate terminal_print;
8+
extern crate mlx5;
9+
extern crate ixgbe;
10+
11+
use alloc::vec::Vec;
12+
use alloc::string::String;
13+
use ixgbe::{
14+
test_packets::create_raw_packet,
15+
};
16+
17+
18+
pub fn main(_args: Vec<String>) -> isize {
19+
println!("mlx5 test application");
20+
21+
match rmain() {
22+
Ok(()) => {
23+
println!("mlx5 test was successful");
24+
return 0;
25+
}
26+
Err(e) => {
27+
println!("mlx5 test failed with error : {:?}", e);
28+
return -1;
29+
}
30+
}
31+
}
32+
33+
fn rmain() -> Result<(), &'static str> {
34+
35+
let mut nic = mlx5::get_mlx5_nic().ok_or("mlx5 nic isn't initialized")?.lock();
36+
let mac_address = nic.mac_address();
37+
let num_packets = 8192;
38+
39+
let buffer = create_raw_packet(&[0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF], &mac_address, &[1;46])?;
40+
let buffer_slice = buffer.as_slice(0, 46)?;
41+
42+
for _ in 0..num_packets {
43+
nic.send_fastpath(buffer.phys_addr, buffer_slice);
44+
}
45+
Ok(())
46+
}

kernel/device_manager/src/lib.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,14 @@ pub fn init(key_producer: Queue<Event>, mouse_producer: Queue<Event>) -> Result<
159159
ixgbe_devs.push(ixgbe_nic);
160160
continue;
161161
}
162-
if dev.vendor_id == mlx5::MLX_VEND && dev.device_id == mlx5::CONNECTX5_DEV {
162+
if dev.vendor_id == mlx5::MLX_VEND && (dev.device_id == mlx5::CONNECTX5_DEV || dev.device_id == mlx5::CONNECTX5_EX_DEV) {
163163
info!("mlx5 PCI device found at: {:?}", dev.location);
164-
mlx5::ConnectX5Nic::init(dev)?;
164+
const RX_DESCS: usize = 512;
165+
const TX_DESCS: usize = 8192;
166+
const MAX_MTU: u16 = 9000;
167+
168+
mlx5::ConnectX5Nic::init(dev, TX_DESCS, RX_DESCS, MAX_MTU)?;
169+
continue;
165170
}
166171

167172
// here: check for and initialize other ethernet cards

kernel/mlx5/Cargo.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ build = "../../build.rs"
88
[dependencies]
99
spin = "0.9.0"
1010
owning_ref = { git = "https://github.com/theseus-os/owning-ref-rs" }
11+
libm = "0.2.1"
12+
mpmc = "0.1.6"
1113

1214
[dependencies.log]
1315
version = "0.4.8"
@@ -30,5 +32,15 @@ path = "../mlx_ethernet"
3032
[dependencies.kernel_config]
3133
path = "../kernel_config"
3234

35+
[dependencies.memory_structs]
36+
path = "../memory_structs"
37+
38+
[dependencies.nic_buffers]
39+
path = "../nic_buffers"
40+
41+
[dependencies.lazy_static]
42+
features = ["spin_no_std"]
43+
version = "1.4.0"
44+
3345
[lib]
3446
crate-type = ["rlib"]

0 commit comments

Comments
 (0)