mana_driver/
save_restore.rs

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4//! Types to save and restore the state of a MANA device.
5
6use mesh::payload::Protobuf;
7
8/// Mana saved state
9#[derive(Debug, Protobuf, Clone)]
10#[mesh(package = "mana_driver")]
11pub struct ManaSavedState {
12    /// The saved state of the MANA device driver
13    #[mesh(1)]
14    pub mana_device: ManaDeviceSavedState,
15
16    /// Id of the device
17    #[mesh(2)]
18    pub pci_id: String,
19}
20
21/// Mana device saved state
22#[derive(Debug, Protobuf, Clone)]
23#[mesh(package = "mana_driver")]
24pub struct ManaDeviceSavedState {
25    /// Saved state for restoration of the GDMA driver
26    #[mesh(1)]
27    pub gdma: GdmaDriverSavedState,
28}
29
30/// Top level saved state for the GDMA driver's saved state
31#[derive(Protobuf, Clone, Debug)]
32#[mesh(package = "mana_driver")]
33pub struct GdmaDriverSavedState {
34    /// Memory to be restored by a DMA client
35    #[mesh(1)]
36    pub mem: SavedMemoryState,
37
38    /// EQ to be restored
39    #[mesh(2)]
40    pub eq: CqEqSavedState,
41
42    /// CQ to be restored
43    #[mesh(3)]
44    pub cq: CqEqSavedState,
45
46    /// RQ to be restored
47    #[mesh(4)]
48    pub rq: WqSavedState,
49
50    /// SQ to be restored
51    #[mesh(5)]
52    pub sq: WqSavedState,
53
54    /// Doorbell id
55    #[mesh(6)]
56    pub db_id: u64,
57
58    /// Guest physical address memory key
59    #[mesh(7)]
60    pub gpa_mkey: u32,
61
62    /// Protection domain id
63    #[mesh(8)]
64    pub pdid: u32,
65
66    /// The id of the HWC activity
67    #[mesh(9)]
68    pub hwc_activity_id: u32,
69
70    /// How many msix vectors are available
71    #[mesh(10)]
72    pub num_msix: u32,
73
74    /// Minimum number of queues available
75    #[mesh(11)]
76    pub min_queue_avail: u32,
77    /// Link status by vport index
78    #[mesh(12)]
79    pub link_toggle: Vec<(u32, bool)>,
80
81    /// Whether a VF reconfiguration event is pending
82    #[mesh(13)]
83    pub vf_reconfiguration_pending: bool,
84}
85
86/// The saved state of a completion queue or event queue for restoration
87/// during servicing
88#[derive(Clone, Protobuf, Debug)]
89#[mesh(package = "mana_driver")]
90pub struct CqEqSavedState {
91    /// The doorbell state of the queue, which is how the device is notified
92    #[mesh(1)]
93    pub doorbell: DoorbellSavedState,
94
95    /// The address of the doorbell register
96    #[mesh(2)]
97    pub doorbell_addr: u32,
98
99    /// The id of the queue
100    #[mesh(3)]
101    pub id: u32,
102
103    /// The index of the next entry in the queue
104    #[mesh(4)]
105    pub next: u32,
106
107    /// The total size of the queue
108    #[mesh(5)]
109    pub size: u32,
110
111    /// The bit shift value for the queue
112    #[mesh(6)]
113    pub shift: u32,
114}
115
116/// Saved state of a doorbell for restoration during servicing
117#[derive(Clone, Protobuf, Debug)]
118#[mesh(package = "mana_driver")]
119pub struct DoorbellSavedState {
120    /// The doorbell's id
121    #[mesh(1)]
122    pub doorbell_id: u64,
123
124    /// The number of pages allocated for the doorbell
125    #[mesh(2)]
126    pub page_count: u32,
127}
128
129/// Saved state of a work queue for restoration during servicing
130#[derive(Debug, Protobuf, Clone)]
131#[mesh(package = "mana_driver")]
132pub struct WqSavedState {
133    /// The doorbell state of the queue, which is how the device is notified
134    #[mesh(1)]
135    pub doorbell: DoorbellSavedState,
136
137    /// The address of the doorbell
138    #[mesh(2)]
139    pub doorbell_addr: u32,
140
141    /// The id of the queue
142    #[mesh(3)]
143    pub id: u32,
144
145    /// The head of the queue
146    #[mesh(4)]
147    pub head: u32,
148
149    /// The tail of the queue
150    #[mesh(5)]
151    pub tail: u32,
152
153    /// The bitmask for wrapping queue indices
154    #[mesh(6)]
155    pub mask: u32,
156}
157
158/// Saved state for a memory region used by the driver
159/// to be restored by a DMA client during servicing
160#[derive(Debug, Protobuf, Clone)]
161#[mesh(package = "mana_driver")]
162pub struct SavedMemoryState {
163    /// The base page frame number of the memory region
164    #[mesh(1)]
165    pub base_pfn: u64,
166
167    /// How long the memory region is
168    #[mesh(2)]
169    pub len: usize,
170}