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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
//! # ixgbe-driver
//!
//! A `no_std` driver implementation for Intel 82599+ 10 Gigabit Ethernet NICs.
//!
//! This crate provides a safe, low-level driver for the Intel 82599 (ixgbe) family of
//! network interface cards. It is designed to be used in embedded and bare-metal environments
//! where the standard library is not available.
//!
//! ## Features
//!
//! - `no_std` compatible - works without the standard library
//! - Multi-queue support for both RX and TX
//! - MSI/MSI-X interrupt support (with `irq` feature)
//! - Memory pool management for efficient packet buffer allocation
//! - Zero-copy packet handling
//!
//! ## Basic Usage
//!
//! ```rust,ignore
//! use ixgbe_driver::{IxgbeDevice, IxgbeHal, MemPool, NicDevice};
//!
//! // First, implement the IxgbeHal trait for your platform
//! struct MyHal;
//!
//! unsafe impl IxgbeHal for MyHal {
//! // Implement required methods...
//! }
//!
//! // Initialize the device
//! let pool = MemPool::allocate::<MyHal>(4096, 2048)?;
//! let device = IxgbeDevice::<MyHal, 512>::init(
//! pci_bar_addr,
//! pci_bar_size,
//! num_rx_queues,
//! num_tx_queues,
//! &pool,
//! )?;
//!
//! // Send and receive packets
//! let tx_buf = IxgbeNetBuf::alloc(&pool, packet_size)?;
//! device.send(queue_id, tx_buf)?;
//!
//! device.receive_packets(queue_id, num_packets, |rx_buf| {
//! // Handle received packet
//! })?;
//! ```
//!
//! ## Hardware Abstraction Layer (HAL)
//!
//! This driver requires the user to implement the [`IxgbeHal`] trait, which provides
//! platform-specific operations such as:
//! - DMA memory allocation/deallocation
//! - MMIO address translation
//! - Timing/waiting operations
//!
//! ## Platform Support
//!
//! The ixgbe driver supports Intel 82599 and compatible 10GbE controllers including:
//! - Intel 82599ES
//! - Intel X540
//! - Intel X550/X552
//!
//! ## Interrupt Modes
//!
//! The driver supports three operation modes:
//! - **Polling mode** (default): No interrupts, the driver continuously polls for packets
//! - **MSI mode**: Message Signaled Interrupts (with `irq` feature)
//! - **MSI-X mode**: Extended MSI with multiple vectors (with `irq` feature)
extern crate alloc;
extern crate log;
pub use IxgbeHal;
pub use ;
pub use ;
/// Vendor ID for Intel.
pub const INTEL_VEND: u16 = 0x8086;
/// Device ID for the 82599ES, used to identify the device from the PCI space.
pub const INTEL_82599: u16 = 0x10FB;
/// Error type for ixgbe driver operations.
///
/// This enum represents the various error conditions that can occur when
/// interacting with the ixgbe device.
/// Result type for ixgbe driver functions.
///
/// A type alias for `Result` with [`IxgbeError`] as the error type.
pub type IxgbeResult<T = > = ;
/// Generic network device interface.
///
/// This trait provides a common interface for network device drivers, allowing
/// protocol stacks to be implemented independently of the specific NIC hardware.
/// It is inspired by the ixy driver approach and provides methods for:
///
/// - Device identification and configuration
/// - Packet transmission and reception
/// - Queue management
/// - Statistics tracking
///
/// # Example
///
/// ```rust,ignore
/// use ixgbe_driver::{IxgbeDevice, NicDevice};
///
/// let mut device = IxgbeDevice::<MyHal, 512>::init(...)?;
///
/// // Check device info
/// println!("Driver: {}", device.get_driver_name());
/// println!("MAC: {:02x?}", device.get_mac_addr());
/// println!("Speed: {} Mbit/s", device.get_link_speed());
///
/// // Send and receive
/// while device.can_receive(0)? {
/// device.receive_packets(0, 32, |packet| {
/// // Process packet
/// })?;
/// }
/// ```