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
60
61
62
63
64
65
66
67
68
69
//! InfiniBand Device Path
//!
//! This module implements the InfiniBand device path node as defined in UEFI 2.11 specification
//! section 10.3.4.5. This device path describes an InfiniBand fabric device.
use crate::parser::{ByteOrder, Parser};
use crate::{Error, Head};
/// InfiniBand Resource Flags as defined in UEFI 2.11 spec
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct ResourceFlags(pub u32);
impl ResourceFlags {
/// IOC/Service flag
pub const SERVICE: Self = Self(1 << 0);
/// Extended boot flag
pub const EXTENDED_BOOT: Self = Self(1 << 1);
/// Console protocol flag
pub const CONSOLE_PROTOCOL: Self = Self(1 << 2);
/// Storage protocol flag
pub const STORAGE_PROTOCOL: Self = Self(1 << 3);
/// Network protocol flag
pub const NETWORK_PROTOCOL: Self = Self(1 << 4);
}
/// InfiniBand Device Path (SubType 0x09)
///
/// According to UEFI 2.11 spec section 10.3.4.14:
/// - Length: 48 bytes
/// - Resource Flags: 4 bytes (flags indicating the resource type)
/// - Port GID: 16 bytes (Global Identifier for the IB port)
/// - IOC GUID/Service ID: 16 bytes (either IOC GUID or Service ID)
/// - Target Port ID: 8 bytes (Target port identifier)
/// - Device ID: 8 bytes (Device identifier)
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct InfiniBand {
/// Resource flags indicating resource type
pub flags: ResourceFlags,
/// Port Global Identifier (16 bytes)
pub gid: [u8; 16],
/// IOC GUID or Service ID (16 bytes)
pub sid: u64,
/// Target Port ID (8 bytes)
pub tid: u64,
/// Device ID (8 bytes)
pub did: u64,
}
impl<'a> TryFrom<Head<'a>> for InfiniBand {
type Error = Error;
fn try_from(mut node: Head<'a>) -> Result<Self, Self::Error> {
Ok(Self {
flags: ResourceFlags(node.data.parse(ByteOrder::Little)?),
gid: node.data.parse(())?,
sid: node.data.parse(ByteOrder::Little)?,
tid: node.data.parse(ByteOrder::Little)?,
did: node.data.finish(ByteOrder::Little)?,
})
}
}