nvme/ds/sgl/
mod.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
use modular_bitfield::prelude::*;

use super::Address;
#[bitfield(bits = 128)]
#[derive(Debug, Clone, Copy)]
pub struct SglDescriptor {
    data0: B120,
    ident: SglIdentifier,
}

#[bitfield(bits = 8)]
#[derive(BitfieldSpecifier, Debug, Clone, Copy)]
struct SglIdentifier {
    sub_type: B4,
    desc_type: SglDescType,
}

#[derive(BitfieldSpecifier, Debug, Clone, Copy)]
#[bits = 4]
enum SglDescType {
    DataBlock,
    BitBucket,
    Segment,
    LastSegment,
    KeyedDataBlock,
    TransportDataBlock,
    VendorSpecific = 0xf,
}

#[derive(BitfieldSpecifier)]
#[bits = 4]
enum SglSubType {
    Address,
    Offset,
    TransportSpecific0 = 0xa,
    TransportSpecific1 = 0xb,
    TransportSpecific2 = 0xc,
    TransportSpecific3 = 0xd,
    TransportSpecific4 = 0xe,
    TransportSpecific5 = 0xf,
}

#[bitfield]
struct SglDataBlock {
    addr: Address,
    len: u32,
    #[skip]
    res: B24,
    id: SglIdentifier,
}

impl From<SglDataBlock> for SglDescriptor {
    fn from(s: SglDataBlock) -> Self {
        Self::from_bytes(s.into_bytes())
    }
}

#[bitfield]
struct SglBitBucket {
    #[skip]
    res0: u64,
    len: u32,
    #[skip]
    res1: B24,
    id: SglIdentifier,
}

impl From<SglBitBucket> for SglDescriptor {
    fn from(s: SglBitBucket) -> Self {
        Self::from_bytes(s.into_bytes())
    }
}

#[bitfield]
struct SglSegment {
    addr: Address,
    len: u32,
    #[skip]
    res: B24,
    id: SglIdentifier,
}

impl From<SglSegment> for SglDescriptor {
    fn from(s: SglSegment) -> Self {
        Self::from_bytes(s.into_bytes())
    }
}

#[bitfield]
struct SglKeyedDataBlock {
    addr: Address,
    len: B24,
    key: u32,
    id: SglIdentifier,
}

impl From<SglKeyedDataBlock> for SglDescriptor {
    fn from(s: SglKeyedDataBlock) -> Self {
        Self::from_bytes(s.into_bytes())
    }
}

#[bitfield]
struct SglTransportDataBlock {
    #[skip]
    res0: u64,
    len: u32,
    #[skip]
    res1: B24,
    id: SglIdentifier,
}

impl From<SglTransportDataBlock> for SglDescriptor {
    fn from(s: SglTransportDataBlock) -> Self {
        Self::from_bytes(s.into_bytes())
    }
}