|
@@ -267,6 +267,12 @@ struct net_device {
|
267
|
267
|
* This is the bitwise-OR of zero or more NETDEV_XXX constants.
|
268
|
268
|
*/
|
269
|
269
|
unsigned int state;
|
|
270
|
+ /** Link status code
|
|
271
|
+ *
|
|
272
|
+ * Zero indicates that the link is up; any other value
|
|
273
|
+ * indicates the error preventing link-up.
|
|
274
|
+ */
|
|
275
|
+ int link_rc;
|
270
|
276
|
/** Maximum packet length
|
271
|
277
|
*
|
272
|
278
|
* This length includes any link-layer headers.
|
|
@@ -291,9 +297,6 @@ struct net_device {
|
291
|
297
|
/** Network device is open */
|
292
|
298
|
#define NETDEV_OPEN 0x0001
|
293
|
299
|
|
294
|
|
-/** Network device has link */
|
295
|
|
-#define NETDEV_LINK_UP 0x0002
|
296
|
|
-
|
297
|
300
|
/** Link-layer protocol table */
|
298
|
301
|
#define LL_PROTOCOLS __table ( struct ll_protocol, "ll_protocols" )
|
299
|
302
|
|
|
@@ -420,17 +423,18 @@ netdev_settings_init ( struct net_device *netdev ) {
|
420
|
423
|
*/
|
421
|
424
|
static inline __attribute__ (( always_inline )) void
|
422
|
425
|
netdev_link_up ( struct net_device *netdev ) {
|
423
|
|
- netdev->state |= NETDEV_LINK_UP;
|
|
426
|
+ netdev->link_rc = 0;
|
424
|
427
|
}
|
425
|
428
|
|
426
|
429
|
/**
|
427
|
|
- * Mark network device as having link down
|
|
430
|
+ * Mark network device as having link down due to a specific error
|
428
|
431
|
*
|
429
|
432
|
* @v netdev Network device
|
|
433
|
+ * @v rc Link status code
|
430
|
434
|
*/
|
431
|
435
|
static inline __attribute__ (( always_inline )) void
|
432
|
|
-netdev_link_down ( struct net_device *netdev ) {
|
433
|
|
- netdev->state &= ~NETDEV_LINK_UP;
|
|
436
|
+netdev_link_err ( struct net_device *netdev, int rc ) {
|
|
437
|
+ netdev->link_rc = rc;
|
434
|
438
|
}
|
435
|
439
|
|
436
|
440
|
/**
|
|
@@ -441,9 +445,10 @@ netdev_link_down ( struct net_device *netdev ) {
|
441
|
445
|
*/
|
442
|
446
|
static inline __attribute__ (( always_inline )) int
|
443
|
447
|
netdev_link_ok ( struct net_device *netdev ) {
|
444
|
|
- return ( netdev->state & NETDEV_LINK_UP );
|
|
448
|
+ return ( netdev->link_rc == 0 );
|
445
|
449
|
}
|
446
|
450
|
|
|
451
|
+extern void netdev_link_down ( struct net_device *netdev );
|
447
|
452
|
extern int netdev_tx ( struct net_device *netdev, struct io_buffer *iobuf );
|
448
|
453
|
extern void netdev_tx_complete_err ( struct net_device *netdev,
|
449
|
454
|
struct io_buffer *iobuf, int rc );
|