nvme/ds/queue/
mod.rs

1use modular_bitfield::bitfield;
2
3pub mod comentry;
4pub mod subentry;
5
6use modular_bitfield::prelude::*;
7
8#[bitfield]
9#[derive(BitfieldSpecifier, Clone, Copy, Debug)]
10#[repr(transparent)]
11pub struct QueueSize(u16);
12
13#[bitfield]
14#[derive(BitfieldSpecifier, Clone, Copy, Debug)]
15#[repr(transparent)]
16pub struct QueueId(u16);
17
18impl QueueId {
19    pub const ADMIN: Self = Self::new();
20}
21
22impl From<u16> for QueueId {
23    fn from(x: u16) -> Self {
24        QueueId::new().with_0(x)
25    }
26}
27
28impl From<QueueId> for usize {
29    fn from(qi: QueueId) -> Self {
30        qi.get_0().into()
31    }
32}
33
34impl From<QueueId> for u16 {
35    fn from(qi: QueueId) -> Self {
36        qi.get_0()
37    }
38}
39
40#[bitfield]
41#[derive(BitfieldSpecifier, Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
42#[repr(transparent)]
43pub struct CommandId(u16);
44
45impl From<u16> for CommandId {
46    fn from(x: u16) -> Self {
47        CommandId::new().with_0(x)
48    }
49}
50
51impl From<CommandId> for u16 {
52    fn from(x: CommandId) -> Self {
53        x.get_0()
54    }
55}
56
57impl From<u16> for QueueSize {
58    fn from(x: u16) -> Self {
59        QueueSize::new().with_0(x)
60    }
61}
62
63impl From<QueueSize> for u16 {
64    fn from(x: QueueSize) -> Self {
65        x.get_0()
66    }
67}
68
69#[derive(BitfieldSpecifier)]
70#[bits = 2]
71pub enum QueuePriority {
72    Urgent,
73    High,
74    Medium,
75    Low,
76}