diff --git a/Cargo.lock b/Cargo.lock index b539e5d1d3..d497dd3898 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -665,6 +665,7 @@ dependencies = [ "bitflags 1.3.2", "common", "netutils", + "pcid", "redox-daemon", "redox_event 0.1.0", "redox_syscall 0.4.1", diff --git a/ixgbed/Cargo.toml b/ixgbed/Cargo.toml index 94d0af3ed1..1760a676bc 100644 --- a/ixgbed/Cargo.toml +++ b/ixgbed/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "ixgbed" version = "1.0.0" +edition = "2021" [dependencies] bitflags = "1.0" @@ -10,3 +11,4 @@ redox_syscall = "0.4" redox-daemon = "0.1" common = { path = "../common" } +pcid = { path = "../pcid" } diff --git a/ixgbed/config.toml b/ixgbed/config.toml index f0921b6008..67577f22d9 100644 --- a/ixgbed/config.toml +++ b/ixgbed/config.toml @@ -2,5 +2,5 @@ name = "Intel 10G NIC" class = 0x02 ids = { 0x8086 = [0x10F7, 0x1514, 0x1517, 0x151C, 0x10F9, 0x10FB, 0x152a, 0x1529, 0x1507, 0x154D, 0x1557, 0x10FC, 0x10F8, 0x154F, 0x1528, 0x154A, 0x1558, 0x1560, 0x1563, 0x15D1, 0x15AA, 0x15AB, 0x15AC, 0x15AD, 0x15AE, 0x15B0, 0x15C2, 0x15C3, 0x15C4, 0x15C6, 0x15C7, 0x15C8, 0x15CE, 0x15E4, 0x15E5, 0x10ED, 0x1515, 0x1565, 0x15A8, 0x15C5] } -command = ["ixgbed", "$NAME", "$BAR0", "$IRQ"] - +command = ["ixgbed"] +use_channel = true diff --git a/ixgbed/src/device.rs b/ixgbed/src/device.rs index 2803ccca5f..9d0f59abd4 100644 --- a/ixgbed/src/device.rs +++ b/ixgbed/src/device.rs @@ -10,7 +10,7 @@ use syscall::scheme::SchemeBlockMut; use common::dma::Dma; use netutils::setcfg; -use ixgbe::*; +use crate::ixgbe::*; pub struct Intel8259x { base: usize, diff --git a/ixgbed/src/main.rs b/ixgbed/src/main.rs index b192450af0..b60cfb9982 100644 --- a/ixgbed/src/main.rs +++ b/ixgbed/src/main.rs @@ -10,9 +10,10 @@ use std::fs::File; use std::io::{ErrorKind, Read, Result, Write}; use std::os::unix::io::{AsRawFd, FromRawFd, RawFd}; use std::sync::Arc; -use std::{env, thread}; +use std::thread; use event::EventQueue; +use pcid_interface::{PciBar, PcidServerHandle}; use std::time::Duration; use syscall::{EventFlags, Packet, SchemeBlockMut}; @@ -66,16 +67,22 @@ fn handle_update( } fn main() { - let mut args = env::args().skip(1); + let mut pcid_handle = + PcidServerHandle::connect_default().expect("ixgbed: failed to setup channel to pcid"); + let pci_config = pcid_handle + .fetch_config() + .expect("ixgbed: failed to fetch config"); - let mut name = args.next().expect("ixgbed: no name provided"); + let mut name = pci_config.func.name(); name.push_str("_ixgbe"); - let bar_str = args.next().expect("ixgbed: no address provided"); - let bar = usize::from_str_radix(&bar_str, 16).expect("ixgbed: failed to parse address"); + let bar = match pci_config.func.bars[0] { + PciBar::Memory32(addr) => addr as usize, + PciBar::Memory64(addr) => addr as usize, + PciBar::None | PciBar::Port(_) => unreachable!(), + }; - let irq_str = args.next().expect("ixgbed: no irq provided"); - let irq = irq_str.parse::().expect("ixgbed: failed to parse irq"); + let irq = pci_config.func.legacy_interrupt_line; println!(" + IXGBE {} on: {:X} IRQ: {}", name, bar, irq);