|
@@ -35,16 +35,18 @@ FILE_LICENCE ( GPL2_OR_LATER );
|
35
|
35
|
*/
|
36
|
36
|
|
37
|
37
|
/**
|
38
|
|
- * Get port information
|
|
38
|
+ * Issue local MAD
|
39
|
39
|
*
|
40
|
40
|
* @v ibdev Infiniband device
|
|
41
|
+ * @v attr_id Attribute ID, in network byte order
|
|
42
|
+ * @v attr_mod Attribute modifier, in network byte order
|
41
|
43
|
* @v local_mad Method for issuing local MADs
|
42
|
44
|
* @v mad Management datagram to fill in
|
43
|
45
|
* @ret rc Return status code
|
44
|
46
|
*/
|
45
|
|
-static int ib_smc_get_port_info ( struct ib_device *ibdev,
|
46
|
|
- ib_local_mad_t local_mad,
|
47
|
|
- union ib_mad *mad ) {
|
|
47
|
+static int ib_smc_mad ( struct ib_device *ibdev, uint16_t attr_id,
|
|
48
|
+ uint32_t attr_mod, ib_local_mad_t local_mad,
|
|
49
|
+ union ib_mad *mad ) {
|
48
|
50
|
int rc;
|
49
|
51
|
|
50
|
52
|
/* Construct MAD */
|
|
@@ -53,10 +55,55 @@ static int ib_smc_get_port_info ( struct ib_device *ibdev,
|
53
|
55
|
mad->hdr.mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED;
|
54
|
56
|
mad->hdr.class_version = 1;
|
55
|
57
|
mad->hdr.method = IB_MGMT_METHOD_GET;
|
56
|
|
- mad->hdr.attr_id = htons ( IB_SMP_ATTR_PORT_INFO );
|
57
|
|
- mad->hdr.attr_mod = htonl ( ibdev->port );
|
|
58
|
+ mad->hdr.attr_id = attr_id;
|
|
59
|
+ mad->hdr.attr_mod = attr_mod;
|
|
60
|
+
|
|
61
|
+ /* Issue MAD */
|
|
62
|
+ if ( ( rc = local_mad ( ibdev, mad ) ) != 0 )
|
|
63
|
+ return rc;
|
|
64
|
+
|
|
65
|
+ return 0;
|
|
66
|
+}
|
|
67
|
+
|
|
68
|
+/**
|
|
69
|
+ * Get node information
|
|
70
|
+ *
|
|
71
|
+ * @v ibdev Infiniband device
|
|
72
|
+ * @v local_mad Method for issuing local MADs
|
|
73
|
+ * @v mad Management datagram to fill in
|
|
74
|
+ * @ret rc Return status code
|
|
75
|
+ */
|
|
76
|
+static int ib_smc_get_node_info ( struct ib_device *ibdev,
|
|
77
|
+ ib_local_mad_t local_mad,
|
|
78
|
+ union ib_mad *mad ) {
|
|
79
|
+ int rc;
|
|
80
|
+
|
|
81
|
+ /* Issue MAD */
|
|
82
|
+ if ( ( rc = ib_smc_mad ( ibdev, htons ( IB_SMP_ATTR_NODE_INFO ), 0,
|
|
83
|
+ local_mad, mad ) ) != 0 ) {
|
|
84
|
+ DBGC ( ibdev, "IBDEV %p could not get node info: %s\n",
|
|
85
|
+ ibdev, strerror ( rc ) );
|
|
86
|
+ return rc;
|
|
87
|
+ }
|
|
88
|
+ return 0;
|
|
89
|
+}
|
58
|
90
|
|
59
|
|
- if ( ( rc = local_mad ( ibdev, mad ) ) != 0 ) {
|
|
91
|
+/**
|
|
92
|
+ * Get port information
|
|
93
|
+ *
|
|
94
|
+ * @v ibdev Infiniband device
|
|
95
|
+ * @v local_mad Method for issuing local MADs
|
|
96
|
+ * @v mad Management datagram to fill in
|
|
97
|
+ * @ret rc Return status code
|
|
98
|
+ */
|
|
99
|
+static int ib_smc_get_port_info ( struct ib_device *ibdev,
|
|
100
|
+ ib_local_mad_t local_mad,
|
|
101
|
+ union ib_mad *mad ) {
|
|
102
|
+ int rc;
|
|
103
|
+
|
|
104
|
+ /* Issue MAD */
|
|
105
|
+ if ( ( rc = ib_smc_mad ( ibdev, htons ( IB_SMP_ATTR_PORT_INFO ),
|
|
106
|
+ htonl ( ibdev->port ), local_mad, mad )) !=0){
|
60
|
107
|
DBGC ( ibdev, "IBDEV %p could not get port info: %s\n",
|
61
|
108
|
ibdev, strerror ( rc ) );
|
62
|
109
|
return rc;
|
|
@@ -77,15 +124,9 @@ static int ib_smc_get_guid_info ( struct ib_device *ibdev,
|
77
|
124
|
union ib_mad *mad ) {
|
78
|
125
|
int rc;
|
79
|
126
|
|
80
|
|
- /* Construct MAD */
|
81
|
|
- memset ( mad, 0, sizeof ( *mad ) );
|
82
|
|
- mad->hdr.base_version = IB_MGMT_BASE_VERSION;
|
83
|
|
- mad->hdr.mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED;
|
84
|
|
- mad->hdr.class_version = 1;
|
85
|
|
- mad->hdr.method = IB_MGMT_METHOD_GET;
|
86
|
|
- mad->hdr.attr_id = htons ( IB_SMP_ATTR_GUID_INFO );
|
87
|
|
-
|
88
|
|
- if ( ( rc = local_mad ( ibdev, mad ) ) != 0 ) {
|
|
127
|
+ /* Issue MAD */
|
|
128
|
+ if ( ( rc = ib_smc_mad ( ibdev, htons ( IB_SMP_ATTR_GUID_INFO ), 0,
|
|
129
|
+ local_mad, mad ) ) != 0 ) {
|
89
|
130
|
DBGC ( ibdev, "IBDEV %p could not get GUID info: %s\n",
|
90
|
131
|
ibdev, strerror ( rc ) );
|
91
|
132
|
return rc;
|
|
@@ -106,15 +147,9 @@ static int ib_smc_get_pkey_table ( struct ib_device *ibdev,
|
106
|
147
|
union ib_mad *mad ) {
|
107
|
148
|
int rc;
|
108
|
149
|
|
109
|
|
- /* Construct MAD */
|
110
|
|
- memset ( mad, 0, sizeof ( *mad ) );
|
111
|
|
- mad->hdr.base_version = IB_MGMT_BASE_VERSION;
|
112
|
|
- mad->hdr.mgmt_class = IB_MGMT_CLASS_SUBN_LID_ROUTED;
|
113
|
|
- mad->hdr.class_version = 1;
|
114
|
|
- mad->hdr.method = IB_MGMT_METHOD_GET;
|
115
|
|
- mad->hdr.attr_id = htons ( IB_SMP_ATTR_PKEY_TABLE );
|
116
|
|
-
|
117
|
|
- if ( ( rc = local_mad ( ibdev, mad ) ) != 0 ) {
|
|
150
|
+ /* Issue MAD */
|
|
151
|
+ if ( ( rc = ib_smc_mad ( ibdev, htons ( IB_SMP_ATTR_PKEY_TABLE ), 0,
|
|
152
|
+ local_mad, mad ) ) != 0 ) {
|
118
|
153
|
DBGC ( ibdev, "IBDEV %p could not get pkey table: %s\n",
|
119
|
154
|
ibdev, strerror ( rc ) );
|
120
|
155
|
return rc;
|
|
@@ -131,11 +166,18 @@ static int ib_smc_get_pkey_table ( struct ib_device *ibdev,
|
131
|
166
|
*/
|
132
|
167
|
static int ib_smc_get ( struct ib_device *ibdev, ib_local_mad_t local_mad ) {
|
133
|
168
|
union ib_mad mad;
|
|
169
|
+ struct ib_node_info *node_info = &mad.smp.smp_data.node_info;
|
134
|
170
|
struct ib_port_info *port_info = &mad.smp.smp_data.port_info;
|
135
|
171
|
struct ib_guid_info *guid_info = &mad.smp.smp_data.guid_info;
|
136
|
172
|
struct ib_pkey_table *pkey_table = &mad.smp.smp_data.pkey_table;
|
137
|
173
|
int rc;
|
138
|
174
|
|
|
175
|
+ /* Node info gives us the node GUID */
|
|
176
|
+ if ( ( rc = ib_smc_get_node_info ( ibdev, local_mad, &mad ) ) != 0 )
|
|
177
|
+ return rc;
|
|
178
|
+ memcpy ( &ibdev->node_guid, &node_info->node_guid,
|
|
179
|
+ sizeof ( ibdev->node_guid ) );
|
|
180
|
+
|
139
|
181
|
/* Port info gives us the link state, the first half of the
|
140
|
182
|
* port GID and the SM LID.
|
141
|
183
|
*/
|