morpheus_core/net/
error.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//! Network initialization errors.
//!
//! Error types for the orchestration layer. Maps errors from underlying
//! crates into a unified error type for the bootloader.

/// Network initialization error.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum NetInitError {
    /// DMA pool initialization failed.
    DmaPoolInit,
    /// No suitable DMA memory found.
    NoDmaMemory,
    /// HAL initialization failed.
    HalInit,
    /// PCI bus scan failed.
    PciScanFailed,
    /// No network device found on PCI bus.
    NoNetworkDevice,
    /// VirtIO device initialization failed.
    VirtioInit,
    /// Network interface creation failed.
    InterfaceCreation,
    /// DHCP discovery failed.
    DhcpFailed,
    /// DHCP timeout - no IP address assigned.
    DhcpTimeout,
    /// Network stack initialization failed.
    StackInit,
    /// Invalid configuration provided.
    InvalidConfig,
    /// Operation timed out.
    Timeout,
    /// API is deprecated - use post-EBS bare_metal_main() instead.
    Deprecated,
}

impl NetInitError {
    /// Get a human-readable description of the error.
    pub fn description(&self) -> &'static str {
        match self {
            Self::DmaPoolInit => "Failed to initialize DMA memory pool",
            Self::NoDmaMemory => "No suitable DMA memory region found",
            Self::HalInit => "Hardware abstraction layer init failed",
            Self::PciScanFailed => "PCI bus scan failed",
            Self::NoNetworkDevice => "No network device found on PCI bus",
            Self::VirtioInit => "VirtIO network device init failed",
            Self::InterfaceCreation => "Network interface creation failed",
            Self::DhcpFailed => "DHCP discovery failed",
            Self::DhcpTimeout => "DHCP timeout - no IP assigned",
            Self::StackInit => "Network stack initialization failed",
            Self::InvalidConfig => "Invalid network configuration",
            Self::Timeout => "Operation timed out",
            Self::Deprecated => "API deprecated - use post-EBS bare_metal_main()",
        }
    }
}

/// Result type for network initialization.
pub type NetInitResult<T> = Result<T, NetInitError>;