|
@@ -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
|
}
|