Kaynağa Gözat

[infiniband] Report IB link status as IPoIB netdevice status

tags/v1.0.0-rc1
Michael Brown 15 yıl önce
ebeveyn
işleme
bbc530c0dd
3 değiştirilmiş dosya ile 41 ekleme ve 5 silme
  1. 12
    5
      src/drivers/net/ipoib.c
  2. 1
    0
      src/include/gpxe/infiniband.h
  3. 28
    0
      src/net/infiniband.c

+ 12
- 5
src/drivers/net/ipoib.c Dosyayı Görüntüle

@@ -24,6 +24,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
24 24
 #include <string.h>
25 25
 #include <byteswap.h>
26 26
 #include <errno.h>
27
+#include <gpxe/errortab.h>
27 28
 #include <gpxe/if_arp.h>
28 29
 #include <gpxe/iobuf.h>
29 30
 #include <gpxe/netdevice.h>
@@ -75,6 +76,14 @@ static struct ipoib_mac ipoib_broadcast = {
75 76
 			  0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff },
76 77
 };
77 78
 
79
+/** Link status for "broadcast join in progress" */
80
+#define EINPROGRESS_JOINING ( EINPROGRESS | EUNIQ_01 )
81
+
82
+/** Human-readable message for the link status */
83
+struct errortab ipoib_errors[] __errortab = {
84
+	{ EINPROGRESS_JOINING, "Joining" },
85
+};
86
+
78 87
 /****************************************************************************
79 88
  *
80 89
  * IPoIB peer cache
@@ -702,17 +711,15 @@ void ipoib_link_state_changed ( struct ib_device *ibdev ) {
702 711
 	ipoib->broadcast.gid.u.words[2] = htons ( ibdev->pkey );
703 712
 
704 713
 	/* Set net device link state to reflect Infiniband link state */
705
-	if ( ib_link_ok ( ibdev ) ) {
706
-		netdev_link_up ( netdev );
707
-	} else {
708
-		netdev_link_down ( netdev );
709
-	}
714
+	rc = ib_link_rc ( ibdev );
715
+	netdev_link_err ( netdev, ( rc ? rc : -EINPROGRESS_JOINING ) );
710 716
 
711 717
 	/* Join new broadcast group */
712 718
 	if ( ib_link_ok ( ibdev ) &&
713 719
 	     ( ( rc = ipoib_join_broadcast_group ( ipoib ) ) != 0 ) ) {
714 720
 		DBGC ( ipoib, "IPoIB %p could not rejoin broadcast group: "
715 721
 		       "%s\n", ipoib, strerror ( rc ) );
722
+		netdev_link_err ( netdev, rc );
716 723
 		return;
717 724
 	}
718 725
 }

+ 1
- 0
src/include/gpxe/infiniband.h Dosyayı Görüntüle

@@ -463,6 +463,7 @@ extern void ib_refill_recv ( struct ib_device *ibdev,
463 463
 			     struct ib_queue_pair *qp );
464 464
 extern int ib_open ( struct ib_device *ibdev );
465 465
 extern void ib_close ( struct ib_device *ibdev );
466
+extern int ib_link_rc ( struct ib_device *ibdev );
466 467
 extern int ib_mcast_attach ( struct ib_device *ibdev, struct ib_queue_pair *qp,
467 468
 			     struct ib_gid *gid );
468 469
 extern void ib_mcast_detach ( struct ib_device *ibdev,

+ 28
- 0
src/net/infiniband.c Dosyayı Görüntüle

@@ -27,6 +27,7 @@ FILE_LICENCE ( GPL2_OR_LATER );
27 27
 #include <errno.h>
28 28
 #include <assert.h>
29 29
 #include <gpxe/list.h>
30
+#include <gpxe/errortab.h>
30 31
 #include <gpxe/if_arp.h>
31 32
 #include <gpxe/netdevice.h>
32 33
 #include <gpxe/iobuf.h>
@@ -48,6 +49,16 @@ struct list_head ib_devices = LIST_HEAD_INIT ( ib_devices );
48 49
 /** List of open Infiniband devices, in reverse order of opening */
49 50
 static struct list_head open_ib_devices = LIST_HEAD_INIT ( open_ib_devices );
50 51
 
52
+/* Disambiguate the various possible EINPROGRESSes */
53
+#define EINPROGRESS_INIT ( EINPROGRESS | EUNIQ_01 )
54
+#define EINPROGRESS_ARMED ( EINPROGRESS | EUNIQ_02 )
55
+
56
+/** Human-readable message for the link statuses */
57
+struct errortab infiniband_errors[] __errortab = {
58
+	{ EINPROGRESS_INIT, "Initialising" },
59
+	{ EINPROGRESS_ARMED, "Armed" },
60
+};
61
+
51 62
 /***************************************************************************
52 63
  *
53 64
  * Completion queues
@@ -607,6 +618,22 @@ void ib_close ( struct ib_device *ibdev ) {
607 618
 	}
608 619
 }
609 620
 
621
+/**
622
+ * Get link state
623
+ *
624
+ * @v ibdev		Infiniband device
625
+ * @ret rc		Link status code
626
+ */
627
+int ib_link_rc ( struct ib_device *ibdev ) {
628
+	switch ( ibdev->port_state ) {
629
+	case IB_PORT_STATE_DOWN:	return -ENOTCONN;
630
+	case IB_PORT_STATE_INIT:	return -EINPROGRESS_INIT;
631
+	case IB_PORT_STATE_ARMED:	return -EINPROGRESS_ARMED;
632
+	case IB_PORT_STATE_ACTIVE:	return 0;
633
+	default:			return -EINVAL;
634
+	}
635
+}
636
+
610 637
 /***************************************************************************
611 638
  *
612 639
  * Multicast
@@ -838,6 +865,7 @@ struct ib_device * alloc_ibdev ( size_t priv_size ) {
838 865
 		ib_set_drvdata ( ibdev, drv_priv );
839 866
 		INIT_LIST_HEAD ( &ibdev->cqs );
840 867
 		INIT_LIST_HEAD ( &ibdev->qps );
868
+		ibdev->port_state = IB_PORT_STATE_DOWN;
841 869
 		ibdev->lid = IB_LID_NONE;
842 870
 		ibdev->pkey = IB_PKEY_NONE;
843 871
 	}

Loading…
İptal
Kaydet