forked from theseus-os/Theseus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ixgbe driver to support the Intel 82599 NIC, and support language…
…-level NIC virtualization (theseus-os#332) This commit also generally refactors networking driver code to deduplicate it and condense shared functionality. Below is a description of changes to certain crates. * `device_manager` - added detection of the 82599 NIC * `nic_initialization` - removed register types and replaced with a register struct * `nic_queues` - Added QueueRegister traits so that queues can store their own registers, and we can create these queue objects for all drivers. Refactored common code between the NIC drivers into send and receive functions for the queue. * `intel_ethernet` - added advanced transmit descriptor and removed register types since we now have a register trait. * `e1000` - moved register struct definitions to a separate file. Registers are divided into four sets so that we can separate the Rx and Tx registers. * `physcial_nic` - a NIC must implement this trait if it wants to support virtualization. This trait defines functions that return Rx and Tx queues to the original NIC when dropped. * `virtual_nic` - a struct which contains a set of queues, and implements the `NetworkInterfaceCard` trait. Its drop handler returns the queues to the physical NIC.
- Loading branch information
Showing
27 changed files
with
3,277 additions
and
290 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
[package] | ||
name = "test_ixgbe" | ||
version = "0.1.0" | ||
authors = ["Ramla Ijaz <[email protected]>"] | ||
build = "../../build.rs" | ||
|
||
[dependencies] | ||
|
||
[dependencies.log] | ||
version = "0.4.8" | ||
|
||
[dependencies.terminal_print] | ||
path = "../../kernel/terminal_print" | ||
|
||
[dependencies.ixgbe] | ||
path = "../../kernel/ixgbe" | ||
|
||
[dependencies.spawn] | ||
path = "../../kernel/spawn" | ||
|
||
[dependencies.network_interface_card] | ||
path = "../../kernel/network_interface_card" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
//! Application which checks the functionality of the ixgbe driver by creating multiple virtual NICs | ||
//! and sending and receiving packets with them. | ||
//! | ||
//! For the receiving functionality, you will have to set up a program on another machine that | ||
//! sends packets to the IP addresses assigned to the virtual NICs. | ||
//! Since we are not going through the network stack, I manually add the (mac address, ip address) pair | ||
//! to the ARP table of the sending machine: "sudo arp -i interface_name -s ip_address mac_address" | ||
//! e.g."sudo arp -i eno1 -s 192.168.0.20 0c:c4:7a:d2:ee:1a" | ||
#![no_std] | ||
#[macro_use] extern crate alloc; | ||
// #[macro_use] extern crate log; | ||
#[macro_use] extern crate terminal_print; | ||
extern crate network_interface_card; | ||
extern crate ixgbe; | ||
extern crate spawn; | ||
|
||
use alloc::vec::Vec; | ||
use alloc::string::String; | ||
use ixgbe::{ | ||
virtual_function, get_ixgbe_nics_list, | ||
test_packets::create_raw_packet, | ||
}; | ||
use network_interface_card::NetworkInterfaceCard; | ||
|
||
pub fn main(_args: Vec<String>) -> isize { | ||
println!("Ixgbe test application"); | ||
|
||
match rmain() { | ||
Ok(()) => { | ||
println!("Ixgbe test was successful"); | ||
return 0; | ||
} | ||
Err(e) => { | ||
println!("Ixgbe test failed with error : {:?}", e); | ||
return -1; | ||
} | ||
} | ||
} | ||
|
||
fn rmain() -> Result<(), &'static str> { | ||
|
||
let dev_id = { | ||
let ixgbe_devs = get_ixgbe_nics_list().ok_or("Ixgbe NICs list not initialized")?; | ||
if ixgbe_devs.is_empty() { return Err("No ixgbe device available"); } | ||
ixgbe_devs[0].lock().device_id() | ||
}; | ||
|
||
let num_nics = 63; | ||
let mut nics = Vec::with_capacity(num_nics); | ||
|
||
for i in 0..num_nics { | ||
nics.push(virtual_function::create_virtual_nic(dev_id, vec!([192,168,0,i as u8 + 14]), 0, 0)?); | ||
} | ||
|
||
for nic in &mut nics { | ||
let mac_address = nic.mac_address(); | ||
let buffer = create_raw_packet(&[0x0, 0x1F, 0xC6, 0x9C, 0xB2, 0x07], &mac_address, &[1;46])?; | ||
nic.send_packet(buffer)?; | ||
} | ||
|
||
// loop { | ||
// for nic in &mut nics { | ||
// nic.poll_receive()?; | ||
// if let Some(_buffer) = nic.get_received_frame() { | ||
// println!("Received packet on vnic {}", nic.id()); | ||
// } | ||
// } | ||
// } | ||
|
||
Ok(()) | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.