Skip to content

Commit

Permalink
Extend the Mellanox driver to support packet transmit (#490)
Browse files Browse the repository at this point in the history
* `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.
  • Loading branch information
Ramla-I authored Mar 25, 2022
1 parent e9b9d87 commit 700daa0
Show file tree
Hide file tree
Showing 17 changed files with 4,027 additions and 506 deletions.
17 changes: 17 additions & 0 deletions Cargo.lock

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

19 changes: 19 additions & 0 deletions applications/test_mlx5/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
[package]
name = "test_mlx5"
version = "0.1.0"
authors = ["Ramla Ijaz <ijazramla@gmail.com>"]
build = "../../build.rs"

[dependencies]

[dependencies.log]
version = "0.4.8"

[dependencies.terminal_print]
path = "../../kernel/terminal_print"

[dependencies.ixgbe]
path = "../../kernel/ixgbe"

[dependencies.mlx5]
path = "../../kernel/mlx5"
46 changes: 46 additions & 0 deletions applications/test_mlx5/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//! Application which checks the functionality of the mlx5 driver.
//! Currently we use functions directly provided by the driver for sending and receiving packets.

#![no_std]
extern crate alloc;
// #[macro_use] extern crate log;
#[macro_use] extern crate terminal_print;
extern crate mlx5;
extern crate ixgbe;

use alloc::vec::Vec;
use alloc::string::String;
use ixgbe::{
test_packets::create_raw_packet,
};


pub fn main(_args: Vec<String>) -> isize {
println!("mlx5 test application");

match rmain() {
Ok(()) => {
println!("mlx5 test was successful");
return 0;
}
Err(e) => {
println!("mlx5 test failed with error : {:?}", e);
return -1;
}
}
}

fn rmain() -> Result<(), &'static str> {

let mut nic = mlx5::get_mlx5_nic().ok_or("mlx5 nic isn't initialized")?.lock();
let mac_address = nic.mac_address();
let num_packets = 8192;

let buffer = create_raw_packet(&[0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF], &mac_address, &[1;46])?;
let buffer_slice = buffer.as_slice(0, 46)?;

for _ in 0..num_packets {
nic.send_fastpath(buffer.phys_addr, buffer_slice);
}
Ok(())
}
9 changes: 7 additions & 2 deletions kernel/device_manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,9 +159,14 @@ pub fn init(key_producer: Queue<Event>, mouse_producer: Queue<Event>) -> Result<
ixgbe_devs.push(ixgbe_nic);
continue;
}
if dev.vendor_id == mlx5::MLX_VEND && dev.device_id == mlx5::CONNECTX5_DEV {
if dev.vendor_id == mlx5::MLX_VEND && (dev.device_id == mlx5::CONNECTX5_DEV || dev.device_id == mlx5::CONNECTX5_EX_DEV) {
info!("mlx5 PCI device found at: {:?}", dev.location);
mlx5::ConnectX5Nic::init(dev)?;
const RX_DESCS: usize = 512;
const TX_DESCS: usize = 8192;
const MAX_MTU: u16 = 9000;

mlx5::ConnectX5Nic::init(dev, TX_DESCS, RX_DESCS, MAX_MTU)?;
continue;
}

// here: check for and initialize other ethernet cards
Expand Down
12 changes: 12 additions & 0 deletions kernel/mlx5/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ build = "../../build.rs"
[dependencies]
spin = "0.9.0"
owning_ref = { git = "https://github.com/theseus-os/owning-ref-rs" }
libm = "0.2.1"
mpmc = "0.1.6"

[dependencies.log]
version = "0.4.8"
Expand All @@ -30,5 +32,15 @@ path = "../mlx_ethernet"
[dependencies.kernel_config]
path = "../kernel_config"

[dependencies.memory_structs]
path = "../memory_structs"

[dependencies.nic_buffers]
path = "../nic_buffers"

[dependencies.lazy_static]
features = ["spin_no_std"]
version = "1.4.0"

[lib]
crate-type = ["rlib"]
Loading

0 comments on commit 700daa0

Please sign in to comment.