iPXE
rndis.h
Go to the documentation of this file.
1 #ifndef _IPXE_RNDIS_H
2 #define _IPXE_RNDIS_H
3 
4 /** @file
5  *
6  * Remote Network Driver Interface Specification
7  *
8  */
9 
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
11 
12 #include <stdint.h>
13 #include <ipxe/netdevice.h>
14 #include <ipxe/iobuf.h>
15 
16 /** Maximum time to wait for a transaction to complete
17  *
18  * This is a policy decision.
19  */
20 #define RNDIS_MAX_WAIT_MS 1000
21 
22 /** RNDIS message header */
23 struct rndis_header {
24  /** Message type */
26  /** Message length */
28 } __attribute__ (( packed ));
29 
30 /** RNDIS initialise message */
31 #define RNDIS_INITIALISE_MSG 0x00000002UL
32 
33 /** RNDIS initialise message */
35  /** Request ID */
37  /** Major version */
39  /** Minor version */
41  /** Maximum transfer size */
43 } __attribute__ (( packed ));
44 
45 /** Request ID used for initialisation
46  *
47  * This is a policy decision.
48  */
49 #define RNDIS_INIT_ID 0xe110e110UL
50 
51 /** RNDIS major version */
52 #define RNDIS_VERSION_MAJOR 1
53 
54 /** RNDIS minor version */
55 #define RNDIS_VERSION_MINOR 0
56 
57 /** RNDIS maximum transfer size
58  *
59  * This is a policy decision.
60  */
61 #define RNDIS_MTU 2048
62 
63 /** RNDIS initialise completion */
64 #define RNDIS_INITIALISE_CMPLT 0x80000002UL
65 
66 /** RNDIS initialise completion */
68  /** Request ID */
70  /** Status */
72  /** Major version */
74  /** Minor version */
76  /** Device flags */
78  /** Medium */
80  /** Maximum packets per transfer */
82  /** Maximum transfer size */
84  /** Packet alignment factor */
86  /** Reserved */
88 } __attribute__ (( packed ));
89 
90 /** RNDIS halt message */
91 #define RNDIS_HALT_MSG 0x00000003UL
92 
93 /** RNDIS halt message */
95  /** Request ID */
97 } __attribute__ (( packed ));
98 
99 /** RNDIS query OID message */
100 #define RNDIS_QUERY_MSG 0x00000004UL
101 
102 /** RNDIS set OID message */
103 #define RNDIS_SET_MSG 0x00000005UL
104 
105 /** RNDIS query or set OID message */
107  /** Request ID */
109  /** Object ID */
111  /** Information buffer length */
113  /** Information buffer offset */
115  /** Reserved */
117 } __attribute__ (( packed ));
118 
119 /** RNDIS query OID completion */
120 #define RNDIS_QUERY_CMPLT 0x80000004UL
121 
122 /** RNDIS query OID completion */
124  /** Request ID */
126  /** Status */
128  /** Information buffer length */
130  /** Information buffer offset */
132 } __attribute__ (( packed ));
133 
134 /** RNDIS set OID completion */
135 #define RNDIS_SET_CMPLT 0x80000005UL
136 
137 /** RNDIS set OID completion */
139  /** Request ID */
141  /** Status */
143 } __attribute__ (( packed ));
144 
145 /** RNDIS reset message */
146 #define RNDIS_RESET_MSG 0x00000006UL
147 
148 /** RNDIS reset message */
150  /** Reserved */
152 } __attribute__ (( packed ));
153 
154 /** RNDIS reset completion */
155 #define RNDIS_RESET_CMPLT 0x80000006UL
156 
157 /** RNDIS reset completion */
159  /** Status */
161  /** Addressing reset */
163 } __attribute__ (( packed ));
164 
165 /** RNDIS indicate status message */
166 #define RNDIS_INDICATE_STATUS_MSG 0x00000007UL
167 
168 /** RNDIS diagnostic information */
170  /** Status */
172  /** Error offset */
174 } __attribute__ (( packed ));
175 
176 /** RNDIS indicate status message */
178  /** Status */
180  /** Status buffer length */
182  /** Status buffer offset */
184  /** Diagnostic information (optional) */
186 } __attribute__ (( packed ));
187 
188 /** RNDIS status codes */
190  /** Device is connected to a network medium */
192  /** Device is disconnected from the medium */
194  /** Unknown start-of-day status code */
195  RNDIS_STATUS_WTF_WORLD = 0x40020006UL,
196 };
197 
198 /** RNDIS keepalive message */
199 #define RNDIS_KEEPALIVE_MSG 0x00000008UL
200 
201 /** RNDIS keepalive message */
203  /** Request ID */
205 } __attribute__ (( packed ));
206 
207 /** RNDIS keepalive completion */
208 #define RNDIS_KEEPALIVE_CMPLT 0x80000008UL
209 
210 /** RNDIS keepalive completion */
212  /** Request ID */
214  /** Status */
216 } __attribute__ (( packed ));
217 
218 /** RNDIS packet message */
219 #define RNDIS_PACKET_MSG 0x00000001UL
220 
221 /** RNDIS packet field */
223  /** Offset */
225  /** Length */
227 } __attribute__ (( packed ));
228 
229 /** RNDIS packet message */
231  /** Data */
233  /** Out-of-band data records */
235  /** Number of out-of-band data records */
237  /** Per-packet information record */
239  /** Reserved */
241 } __attribute__ (( packed ));
242 
243 /** RNDIS packet record */
245  /** Length */
247  /** Type */
249  /** Offset */
251 } __attribute__ (( packed ));
252 
253 /** OID for packet filter */
254 #define RNDIS_OID_GEN_CURRENT_PACKET_FILTER 0x0001010eUL
255 
256 /** Packet filter bits */
258  /** Unicast packets */
259  RNDIS_FILTER_UNICAST = 0x00000001UL,
260  /** Multicast packets */
261  RNDIS_FILTER_MULTICAST = 0x00000002UL,
262  /** All multicast packets */
264  /** Broadcast packets */
265  RNDIS_FILTER_BROADCAST = 0x00000008UL,
266  /** All packets */
268 };
269 
270 /** OID for media status */
271 #define RNDIS_OID_GEN_MEDIA_CONNECT_STATUS 0x00010114UL
272 
273 /** OID for permanent MAC address */
274 #define RNDIS_OID_802_3_PERMANENT_ADDRESS 0x01010101UL
275 
276 /** OID for current MAC address */
277 #define RNDIS_OID_802_3_CURRENT_ADDRESS 0x01010102UL
278 
279 struct rndis_device;
280 
281 /** RNDIS device operations */
283  /**
284  * Open RNDIS device
285  *
286  * @v rndis RNDIS device
287  * @ret rc Return status code
288  */
289  int ( * open ) ( struct rndis_device *rndis );
290  /**
291  * Close RNDIS device
292  *
293  * @v rndis RNDIS device
294  */
295  void ( * close ) ( struct rndis_device *rndis );
296  /**
297  * Transmit packet
298  *
299  * @v rndis RNDIS device
300  * @v iobuf I/O buffer
301  * @ret rc Return status code
302  *
303  * If this method returns success then the RNDIS device must
304  * eventually report completion via rndis_tx_complete().
305  */
306  int ( * transmit ) ( struct rndis_device *rndis,
307  struct io_buffer *iobuf );
308  /**
309  * Poll for completed and received packets
310  *
311  * @v rndis RNDIS device
312  */
313  void ( * poll ) ( struct rndis_device *rndis );
314 };
315 
316 /** An RNDIS device */
317 struct rndis_device {
318  /** Network device */
320  /** Device name */
321  const char *name;
322  /** RNDIS operations */
324  /** Driver private data */
325  void *priv;
326 
327  /** Request ID for current blocking request */
328  unsigned int wait_id;
329  /** Return status code for current blocking request */
330  int wait_rc;
331 };
332 
333 /**
334  * Initialise an RNDIS device
335  *
336  * @v rndis RNDIS device
337  * @v op RNDIS device operations
338  */
339 static inline void rndis_init ( struct rndis_device *rndis,
340  struct rndis_operations *op ) {
341 
342  rndis->op = op;
343 }
344 
345 extern void rndis_tx_complete_err ( struct rndis_device *rndis,
346  struct io_buffer *iobuf, int rc );
347 extern int rndis_tx_defer ( struct rndis_device *rndis,
348  struct io_buffer *iobuf );
349 extern void rndis_rx ( struct rndis_device *rndis, struct io_buffer *iobuf );
350 extern void rndis_rx_err ( struct rndis_device *rndis, struct io_buffer *iobuf,
351  int rc );
352 
353 extern struct rndis_device * alloc_rndis ( size_t priv_len );
354 extern int register_rndis ( struct rndis_device *rndis );
355 extern void unregister_rndis ( struct rndis_device *rndis );
356 extern void free_rndis ( struct rndis_device *rndis );
357 
358 /**
359  * Complete message transmission
360  *
361  * @v rndis RNDIS device
362  * @v iobuf I/O buffer
363  */
364 static inline void rndis_tx_complete ( struct rndis_device *rndis,
365  struct io_buffer *iobuf ) {
366 
367  rndis_tx_complete_err ( rndis, iobuf, 0 );
368 }
369 
370 #endif /* _IPXE_RNDIS_H */
#define __attribute__(x)
Definition: compiler.h:10
Unknown start-of-day status code.
Definition: rndis.h:195
struct arbelprm_rc_send_wqe rc
Definition: arbel.h:14
rndis_packet_filter
Packet filter bits.
Definition: rndis.h:257
int(* open)(struct rndis_device *rndis)
Open RNDIS device.
Definition: rndis.h:289
const char * name
Device name.
Definition: rndis.h:321
void rndis_rx_err(struct rndis_device *rndis, struct io_buffer *iobuf, int rc)
Discard packet from underlying transport layer.
Definition: rndis.c:866
uint32_t oid
Object ID.
Definition: rndis.h:110
uint32_t flags
Device flags.
Definition: rndis.h:77
uint32_t status
Status.
Definition: rndis.h:215
Multicast packets.
Definition: rndis.h:261
void free_rndis(struct rndis_device *rndis)
Free RNDIS device.
Definition: rndis.c:1066
static void rndis_tx_complete(struct rndis_device *rndis, struct io_buffer *iobuf)
Complete message transmission.
Definition: rndis.h:364
I/O buffers.
RNDIS query OID completion.
Definition: rndis.h:123
uint32_t len
Message length.
Definition: rndis.h:27
uint32_t minor
Minor version.
Definition: rndis.h:40
uint32_t status
Status.
Definition: rndis.h:171
uint32_t major
Major version.
Definition: rndis.h:38
Unicast packets.
Definition: rndis.h:259
RNDIS query or set OID message.
Definition: rndis.h:106
RNDIS initialise message.
Definition: rndis.h:34
void(* close)(struct rndis_device *rndis)
Close RNDIS device.
Definition: rndis.h:295
uint32_t addr
Addressing reset.
Definition: rndis.h:162
RNDIS initialise completion.
Definition: rndis.h:67
struct rndis_diagnostic_info diag[0]
Diagnostic information (optional)
Definition: rndis.h:185
void unregister_rndis(struct rndis_device *rndis)
Unregister RNDIS device.
Definition: rndis.c:1054
uint32_t id
Request ID.
Definition: rndis.h:69
Device is connected to a network medium.
Definition: rndis.h:191
uint32_t max_pkts
Maximum packets per transfer.
Definition: rndis.h:81
uint32_t offset
Error offset.
Definition: rndis.h:173
RNDIS diagnostic information.
Definition: rndis.h:169
RNDIS keepalive completion.
Definition: rndis.h:211
uint32_t len
Length.
Definition: rndis.h:246
int(* transmit)(struct rndis_device *rndis, struct io_buffer *iobuf)
Transmit packet.
Definition: rndis.h:306
uint32_t status
Status.
Definition: rndis.h:179
uint32_t offset
Offset.
Definition: rndis.h:250
RNDIS packet field.
Definition: rndis.h:222
uint32_t offset
Status buffer offset.
Definition: rndis.h:183
uint32_t type
Message type.
Definition: rndis.h:25
uint32_t id
Request ID.
Definition: rndis.h:125
uint32_t status
Status.
Definition: rndis.h:127
struct rndis_packet_field oob
Out-of-band data records.
Definition: rndis.h:234
struct net_device * netdev
Network device.
Definition: rndis.h:319
unsigned int wait_id
Request ID for current blocking request.
Definition: rndis.h:328
struct rndis_operations * op
RNDIS operations.
Definition: rndis.h:323
uint32_t type
Type.
Definition: rndis.h:248
An RNDIS device.
Definition: rndis.h:317
RNDIS reset message.
Definition: rndis.h:149
uint32_t mtu
Maximum transfer size.
Definition: rndis.h:83
struct rndis_packet_field ppi
Per-packet information record.
Definition: rndis.h:238
FILE_LICENCE(GPL2_OR_LATER_OR_UBDL)
rndis_status
RNDIS status codes.
Definition: rndis.h:189
uint32_t offset
Offset.
Definition: rndis.h:224
void rndis_rx(struct rndis_device *rndis, struct io_buffer *iobuf)
Receive packet from underlying transport layer.
Definition: rndis.c:829
RNDIS keepalive message.
Definition: rndis.h:202
uint32_t id
Request ID.
Definition: rndis.h:204
int register_rndis(struct rndis_device *rndis)
Register RNDIS device.
Definition: rndis.c:1026
uint32_t len
Information buffer length.
Definition: rndis.h:112
RNDIS packet message.
Definition: rndis.h:230
All multicast packets.
Definition: rndis.h:263
uint32_t len
Length.
Definition: rndis.h:226
uint32_t len
Status buffer length.
Definition: rndis.h:181
uint32_t reserved
Reserved.
Definition: rndis.h:116
A network device.
Definition: netdevice.h:348
uint32_t id
Request ID.
Definition: rndis.h:140
void(* poll)(struct rndis_device *rndis)
Poll for completed and received packets.
Definition: rndis.h:313
uint32_t medium
Medium.
Definition: rndis.h:79
uint32_t len
Information buffer length.
Definition: rndis.h:129
RNDIS device operations.
Definition: rndis.h:282
uint32_t id
Request ID.
Definition: rndis.h:36
uint32_t reserved
Reserved.
Definition: rndis.h:87
unsigned int uint32_t
Definition: stdint.h:12
static void rndis_init(struct rndis_device *rndis, struct rndis_operations *op)
Initialise an RNDIS device.
Definition: rndis.h:339
uint32_t id
Request ID.
Definition: rndis.h:96
uint32_t offset
Information buffer offset.
Definition: rndis.h:131
Network device management.
RNDIS halt message.
Definition: rndis.h:94
RNDIS message header.
Definition: rndis.h:23
static uint16_t struct vmbus_xfer_pages_operations * op
Definition: netvsc.h:327
All packets.
Definition: rndis.h:267
int rndis_tx_defer(struct rndis_device *rndis, struct io_buffer *iobuf)
Defer transmitted packet.
Definition: rndis.c:190
uint32_t align
Packet alignment factor.
Definition: rndis.h:85
void * priv
Driver private data.
Definition: rndis.h:325
uint32_t status
Status.
Definition: rndis.h:71
int wait_rc
Return status code for current blocking request.
Definition: rndis.h:330
struct rndis_packet_field data
Data.
Definition: rndis.h:232
uint32_t status
Status.
Definition: rndis.h:160
RNDIS packet record.
Definition: rndis.h:244
uint32_t reserved
Reserved.
Definition: rndis.h:240
Broadcast packets.
Definition: rndis.h:265
void rndis_tx_complete_err(struct rndis_device *rndis, struct io_buffer *iobuf, int rc)
Complete message transmission.
Definition: rndis.c:127
uint32_t reserved
Reserved.
Definition: rndis.h:151
RNDIS reset completion.
Definition: rndis.h:158
uint32_t mtu
Maximum transfer size.
Definition: rndis.h:42
uint32_t minor
Minor version.
Definition: rndis.h:75
uint32_t id
Request ID.
Definition: rndis.h:108
RNDIS set OID completion.
Definition: rndis.h:138
uint32_t id
Request ID.
Definition: rndis.h:213
Device is disconnected from the medium.
Definition: rndis.h:193
struct rndis_device * alloc_rndis(size_t priv_len)
Allocate RNDIS device.
Definition: rndis.c:1000
uint32_t offset
Information buffer offset.
Definition: rndis.h:114
RNDIS indicate status message.
Definition: rndis.h:177
uint32_t major
Major version.
Definition: rndis.h:73
uint32_t oob_count
Number of out-of-band data records.
Definition: rndis.h:236
uint32_t status
Status.
Definition: rndis.h:142
A persistent I/O buffer.
Definition: iobuf.h:32