6 * Remote Network Driver Interface Specification
10 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
13 #include <ipxe/netdevice.h>
14 #include <ipxe/iobuf.h>
16 /** Maximum time to wait for a transaction to complete
18 * This is a policy decision.
20 #define RNDIS_MAX_WAIT_MS 1000
22 /** RNDIS message header */
28 } __attribute__ (( packed ));
30 /** RNDIS initialise message */
31 #define RNDIS_INITIALISE_MSG 0x00000002UL
33 /** RNDIS initialise message */
34 struct rndis_initialise_message {
41 /** Maximum transfer size */
43 } __attribute__ (( packed ));
45 /** Request ID used for initialisation
47 * This is a policy decision.
49 #define RNDIS_INIT_ID 0xe110e110UL
51 /** RNDIS major version */
52 #define RNDIS_VERSION_MAJOR 1
54 /** RNDIS minor version */
55 #define RNDIS_VERSION_MINOR 0
57 /** RNDIS maximum transfer size
59 * This is a policy decision.
61 #define RNDIS_MTU 2048
63 /** RNDIS initialise completion */
64 #define RNDIS_INITIALISE_CMPLT 0x80000002UL
66 /** RNDIS initialise completion */
67 struct rndis_initialise_completion {
80 /** Maximum packets per transfer */
82 /** Maximum transfer size */
84 /** Packet alignment factor */
88 } __attribute__ (( packed ));
90 /** RNDIS halt message */
91 #define RNDIS_HALT_MSG 0x00000003UL
93 /** RNDIS halt message */
94 struct rndis_halt_message {
97 } __attribute__ (( packed ));
99 /** RNDIS query OID message */
100 #define RNDIS_QUERY_MSG 0x00000004UL
102 /** RNDIS set OID message */
103 #define RNDIS_SET_MSG 0x00000005UL
105 /** RNDIS query or set OID message */
106 struct rndis_oid_message {
111 /** Information buffer length */
113 /** Information buffer offset */
117 } __attribute__ (( packed ));
119 /** RNDIS query OID completion */
120 #define RNDIS_QUERY_CMPLT 0x80000004UL
122 /** RNDIS query OID completion */
123 struct rndis_query_completion {
128 /** Information buffer length */
130 /** Information buffer offset */
132 } __attribute__ (( packed ));
134 /** RNDIS set OID completion */
135 #define RNDIS_SET_CMPLT 0x80000005UL
137 /** RNDIS set OID completion */
138 struct rndis_set_completion {
143 } __attribute__ (( packed ));
145 /** RNDIS reset message */
146 #define RNDIS_RESET_MSG 0x00000006UL
148 /** RNDIS reset message */
149 struct rndis_reset_message {
152 } __attribute__ (( packed ));
154 /** RNDIS reset completion */
155 #define RNDIS_RESET_CMPLT 0x80000006UL
157 /** RNDIS reset completion */
158 struct rndis_reset_completion {
161 /** Addressing reset */
163 } __attribute__ (( packed ));
165 /** RNDIS indicate status message */
166 #define RNDIS_INDICATE_STATUS_MSG 0x00000007UL
168 /** RNDIS diagnostic information */
169 struct rndis_diagnostic_info {
174 } __attribute__ (( packed ));
176 /** RNDIS indicate status message */
177 struct rndis_indicate_status_message {
180 /** Status buffer length */
182 /** Status buffer offset */
184 /** Diagnostic information (optional) */
185 struct rndis_diagnostic_info diag[0];
186 } __attribute__ (( packed ));
188 /** RNDIS status codes */
190 /** Device is connected to a network medium */
191 RNDIS_STATUS_MEDIA_CONNECT = 0x4001000bUL,
192 /** Device is disconnected from the medium */
193 RNDIS_STATUS_MEDIA_DISCONNECT = 0x4001000cUL,
194 /** Unknown start-of-day status code */
195 RNDIS_STATUS_WTF_WORLD = 0x40020006UL,
198 /** RNDIS keepalive message */
199 #define RNDIS_KEEPALIVE_MSG 0x00000008UL
201 /** RNDIS keepalive message */
202 struct rndis_keepalive_message {
205 } __attribute__ (( packed ));
207 /** RNDIS keepalive completion */
208 #define RNDIS_KEEPALIVE_CMPLT 0x80000008UL
210 /** RNDIS keepalive completion */
211 struct rndis_keepalive_completion {
216 } __attribute__ (( packed ));
218 /** RNDIS packet message */
219 #define RNDIS_PACKET_MSG 0x00000001UL
221 /** RNDIS packet field */
222 struct rndis_packet_field {
227 } __attribute__ (( packed ));
229 /** RNDIS packet message */
230 struct rndis_packet_message {
232 struct rndis_packet_field data;
233 /** Out-of-band data records */
234 struct rndis_packet_field oob;
235 /** Number of out-of-band data records */
237 /** Per-packet information record */
238 struct rndis_packet_field ppi;
241 } __attribute__ (( packed ));
243 /** RNDIS packet record */
244 struct rndis_packet_record {
251 } __attribute__ (( packed ));
253 /** OID for packet filter */
254 #define RNDIS_OID_GEN_CURRENT_PACKET_FILTER 0x0001010eUL
256 /** Packet filter bits */
257 enum rndis_packet_filter {
258 /** Unicast packets */
259 RNDIS_FILTER_UNICAST = 0x00000001UL,
260 /** Multicast packets */
261 RNDIS_FILTER_MULTICAST = 0x00000002UL,
262 /** All multicast packets */
263 RNDIS_FILTER_ALL_MULTICAST = 0x00000004UL,
264 /** Broadcast packets */
265 RNDIS_FILTER_BROADCAST = 0x00000008UL,
267 RNDIS_FILTER_PROMISCUOUS = 0x00000020UL
270 /** OID for media status */
271 #define RNDIS_OID_GEN_MEDIA_CONNECT_STATUS 0x00010114UL
273 /** OID for permanent MAC address */
274 #define RNDIS_OID_802_3_PERMANENT_ADDRESS 0x01010101UL
276 /** OID for current MAC address */
277 #define RNDIS_OID_802_3_CURRENT_ADDRESS 0x01010102UL
281 /** RNDIS device operations */
282 struct rndis_operations {
286 * @v rndis RNDIS device
287 * @ret rc Return status code
289 int ( * open ) ( struct rndis_device *rndis );
293 * @v rndis RNDIS device
295 void ( * close ) ( struct rndis_device *rndis );
299 * @v rndis RNDIS device
300 * @v iobuf I/O buffer
301 * @ret rc Return status code
303 * If this method returns success then the RNDIS device must
304 * eventually report completion via rndis_tx_complete().
306 int ( * transmit ) ( struct rndis_device *rndis,
307 struct io_buffer *iobuf );
309 * Poll for completed and received packets
311 * @v rndis RNDIS device
313 void ( * poll ) ( struct rndis_device *rndis );
316 /** An RNDIS device */
317 struct rndis_device {
318 /** Network device */
319 struct net_device *netdev;
322 /** RNDIS operations */
323 struct rndis_operations *op;
324 /** Driver private data */
327 /** Request ID for current blocking request */
328 unsigned int wait_id;
329 /** Return status code for current blocking request */
334 * Initialise an RNDIS device
336 * @v rndis RNDIS device
337 * @v op RNDIS device operations
339 static inline void rndis_init ( struct rndis_device *rndis,
340 struct rndis_operations *op ) {
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,
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 );
359 * Complete message transmission
361 * @v rndis RNDIS device
362 * @v iobuf I/O buffer
364 static inline void rndis_tx_complete ( struct rndis_device *rndis,
365 struct io_buffer *iobuf ) {
367 rndis_tx_complete_err ( rndis, iobuf, 0 );
370 #endif /* _IPXE_RNDIS_H */