Browse Source

[infiniband] Report IB link status as IPoIB netdevice status

tags/v1.0.0-rc1
Michael Brown 15 years ago
parent
commit
bbc530c0dd
3 changed files with 41 additions and 5 deletions
  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 View File

24
 #include <string.h>
24
 #include <string.h>
25
 #include <byteswap.h>
25
 #include <byteswap.h>
26
 #include <errno.h>
26
 #include <errno.h>
27
+#include <gpxe/errortab.h>
27
 #include <gpxe/if_arp.h>
28
 #include <gpxe/if_arp.h>
28
 #include <gpxe/iobuf.h>
29
 #include <gpxe/iobuf.h>
29
 #include <gpxe/netdevice.h>
30
 #include <gpxe/netdevice.h>
75
 			  0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff },
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
  * IPoIB peer cache
89
  * IPoIB peer cache
702
 	ipoib->broadcast.gid.u.words[2] = htons ( ibdev->pkey );
711
 	ipoib->broadcast.gid.u.words[2] = htons ( ibdev->pkey );
703
 
712
 
704
 	/* Set net device link state to reflect Infiniband link state */
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
 	/* Join new broadcast group */
717
 	/* Join new broadcast group */
712
 	if ( ib_link_ok ( ibdev ) &&
718
 	if ( ib_link_ok ( ibdev ) &&
713
 	     ( ( rc = ipoib_join_broadcast_group ( ipoib ) ) != 0 ) ) {
719
 	     ( ( rc = ipoib_join_broadcast_group ( ipoib ) ) != 0 ) ) {
714
 		DBGC ( ipoib, "IPoIB %p could not rejoin broadcast group: "
720
 		DBGC ( ipoib, "IPoIB %p could not rejoin broadcast group: "
715
 		       "%s\n", ipoib, strerror ( rc ) );
721
 		       "%s\n", ipoib, strerror ( rc ) );
722
+		netdev_link_err ( netdev, rc );
716
 		return;
723
 		return;
717
 	}
724
 	}
718
 }
725
 }

+ 1
- 0
src/include/gpxe/infiniband.h View File

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

+ 28
- 0
src/net/infiniband.c View File

27
 #include <errno.h>
27
 #include <errno.h>
28
 #include <assert.h>
28
 #include <assert.h>
29
 #include <gpxe/list.h>
29
 #include <gpxe/list.h>
30
+#include <gpxe/errortab.h>
30
 #include <gpxe/if_arp.h>
31
 #include <gpxe/if_arp.h>
31
 #include <gpxe/netdevice.h>
32
 #include <gpxe/netdevice.h>
32
 #include <gpxe/iobuf.h>
33
 #include <gpxe/iobuf.h>
48
 /** List of open Infiniband devices, in reverse order of opening */
49
 /** List of open Infiniband devices, in reverse order of opening */
49
 static struct list_head open_ib_devices = LIST_HEAD_INIT ( open_ib_devices );
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
  * Completion queues
64
  * Completion queues
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
  * Multicast
639
  * Multicast
838
 		ib_set_drvdata ( ibdev, drv_priv );
865
 		ib_set_drvdata ( ibdev, drv_priv );
839
 		INIT_LIST_HEAD ( &ibdev->cqs );
866
 		INIT_LIST_HEAD ( &ibdev->cqs );
840
 		INIT_LIST_HEAD ( &ibdev->qps );
867
 		INIT_LIST_HEAD ( &ibdev->qps );
868
+		ibdev->port_state = IB_PORT_STATE_DOWN;
841
 		ibdev->lid = IB_LID_NONE;
869
 		ibdev->lid = IB_LID_NONE;
842
 		ibdev->pkey = IB_PKEY_NONE;
870
 		ibdev->pkey = IB_PKEY_NONE;
843
 	}
871
 	}

Loading…
Cancel
Save