netvsp/
saved_state.rs

1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4//! Saved state definitions.
5
6use mesh::payload::Protobuf;
7use vmbus_channel::gpadl::GpadlId;
8use vmcore::save_restore::SavedStateRoot;
9
10#[derive(Debug, Protobuf, SavedStateRoot)]
11#[mesh(package = "net.netvsp")]
12pub struct SavedState {
13    #[mesh(1)]
14    pub open: Option<OpenState>,
15}
16
17#[derive(Debug, Protobuf)]
18#[mesh(package = "net.netvsp")]
19pub struct OpenState {
20    #[mesh(1)]
21    pub primary: Primary,
22}
23
24#[derive(Debug, Protobuf)]
25#[mesh(package = "net.netvsp")]
26pub enum Primary {
27    #[mesh(1)]
28    Version,
29    #[mesh(2)]
30    Init(#[mesh(1)] InitPrimary),
31    #[mesh(3)]
32    Ready(#[mesh(1)] ReadyPrimary),
33}
34
35#[derive(Debug, Protobuf)]
36#[mesh(package = "net.netvsp")]
37pub struct InitPrimary {
38    #[mesh(1)]
39    pub version: u32,
40    #[mesh(2)]
41    pub ndis_config: Option<NdisConfig>,
42    #[mesh(3)]
43    pub ndis_version: Option<NdisVersion>,
44    #[mesh(4)]
45    pub receive_buffer: Option<ReceiveBuffer>,
46    #[mesh(5)]
47    pub send_buffer: Option<SendBuffer>,
48}
49
50#[derive(Debug, Protobuf)]
51#[mesh(package = "net.netvsp")]
52pub struct NdisVersion {
53    #[mesh(1)]
54    pub major: u32,
55    #[mesh(2)]
56    pub minor: u32,
57}
58
59#[derive(Debug, Protobuf)]
60#[mesh(package = "net.netvsp")]
61pub struct NdisConfig {
62    #[mesh(1)]
63    pub mtu: u32,
64    #[mesh(2)]
65    pub capabilities: u64,
66}
67
68#[derive(Copy, Clone, Debug, Protobuf)]
69#[mesh(package = "net.netvsp")]
70pub enum GuestVfState {
71    #[mesh(1)]
72    NoState,
73    #[mesh(2)]
74    AvailableAdvertised,
75    #[mesh(3)]
76    Ready,
77    #[mesh(4)]
78    DataPathSwitchPending {
79        #[mesh(1)]
80        to_guest: bool,
81        #[mesh(2)]
82        id: Option<u64>,
83        #[mesh(3)]
84        result: Option<bool>,
85    },
86    #[mesh(5)]
87    DataPathSwitched,
88}
89
90#[derive(Debug, Protobuf)]
91#[mesh(package = "net.netvsp")]
92pub struct ReadyPrimary {
93    #[mesh(1)]
94    pub version: u32,
95    #[mesh(2)]
96    pub receive_buffer: ReceiveBuffer,
97    #[mesh(3)]
98    pub send_buffer: Option<SendBuffer>,
99    #[mesh(4)]
100    pub ndis_config: NdisConfig,
101    #[mesh(5)]
102    pub ndis_version: NdisVersion,
103    #[mesh(6)]
104    pub rndis_state: RndisState,
105    #[mesh(7)]
106    pub guest_vf_state: GuestVfState,
107    #[mesh(8)]
108    pub offload_config: OffloadConfig,
109    #[mesh(9)]
110    pub pending_offload_change: bool,
111    #[mesh(10)]
112    pub control_messages: Vec<IncomingControlMessage>,
113    #[mesh(11)]
114    pub rss_state: Option<RssState>,
115    #[mesh(12)]
116    pub channels: Vec<Option<Channel>>,
117    #[mesh(13)]
118    pub tx_spread_sent: bool,
119    #[mesh(14)]
120    pub guest_link_down: bool,
121    #[mesh(15)]
122    pub pending_link_action: Option<bool>,
123}
124
125#[derive(Debug, Protobuf)]
126#[mesh(package = "net.netvsp")]
127pub enum RndisState {
128    #[mesh(1)]
129    Initializing,
130    #[mesh(2)]
131    Operational,
132    #[mesh(3)]
133    Halted,
134}
135
136#[derive(Debug, Protobuf)]
137#[mesh(package = "net.netvsp")]
138pub struct OffloadConfig {
139    #[mesh(1)]
140    pub checksum_tx: ChecksumOffloadConfig,
141    #[mesh(2)]
142    pub checksum_rx: ChecksumOffloadConfig,
143    #[mesh(3)]
144    pub lso4: bool,
145    #[mesh(4)]
146    pub lso6: bool,
147}
148
149#[derive(Debug, Protobuf)]
150#[mesh(package = "net.netvsp")]
151pub struct ChecksumOffloadConfig {
152    #[mesh(1)]
153    pub ipv4_header: bool,
154    #[mesh(2)]
155    pub tcp4: bool,
156    #[mesh(3)]
157    pub udp4: bool,
158    #[mesh(4)]
159    pub tcp6: bool,
160    #[mesh(5)]
161    pub udp6: bool,
162}
163
164#[derive(Debug, Protobuf)]
165#[mesh(package = "net.netvsp")]
166pub struct RssState {
167    #[mesh(1)]
168    pub key: Vec<u8>,
169    #[mesh(2)]
170    pub indirection_table: Vec<u16>,
171}
172
173#[derive(Debug, Protobuf)]
174#[mesh(package = "net.netvsp")]
175pub struct IncomingControlMessage {
176    #[mesh(1)]
177    pub message_type: u32,
178    #[mesh(2)]
179    pub data: Vec<u8>,
180}
181
182#[derive(Debug, Protobuf)]
183#[mesh(package = "net.netvsp")]
184pub struct ReceiveBuffer {
185    #[mesh(1)]
186    pub gpadl_id: GpadlId,
187    #[mesh(2)]
188    pub id: u16,
189    #[mesh(3)]
190    pub sub_allocation_size: u32,
191}
192
193#[derive(Debug, Protobuf)]
194#[mesh(package = "net.netvsp")]
195pub struct SendBuffer {
196    #[mesh(1)]
197    pub gpadl_id: GpadlId,
198}
199
200#[derive(Debug, Protobuf)]
201#[mesh(package = "net.netvsp")]
202pub struct Channel {
203    #[mesh(1)]
204    pub pending_tx_completions: Vec<u64>,
205    #[mesh(2)]
206    pub in_use_rx: Vec<Rx>,
207}
208
209#[derive(Debug, Protobuf)]
210#[mesh(package = "net.netvsp")]
211pub struct Rx {
212    #[mesh(1)]
213    pub buffers: Vec<u32>,
214}