Browse Source

[infiniband] Remove the return status code from MAD handlers

MAD handlers have to set the status fields within the MAD itself
anyway, in order to provide a meaningful response MAD; the additional
gPXE return status code is just noise.

Note that we probably don't need to ever explicitly set the status to
IB_MGMT_STATUS_OK, since it should already have this value from the
request.  (By not explicitly setting the status in this way, we can
safely have ib_sma_set_xxx() call ib_sma_get_xxx() in order to
generate the GetResponse MAD without worrying that ib_sma_get_xxx()
will clear any error status set by ib_sma_set_xxx().)
tags/v0.9.8
Michael Brown 15 years ago
parent
commit
94876f4bb6

+ 1
- 2
src/include/gpxe/ib_gma.h View File

@@ -34,13 +34,12 @@ struct ib_gma_handler {
34 34
 	 *
35 35
 	 * @v gma	General management agent
36 36
 	 * @v mad	MAD
37
-	 * @ret rc	Return status code
38 37
 	 *
39 38
 	 * The handler should modify the MAD as applicable.  If the
40 39
 	 * handler returns with a non-zero value in the MAD's @c
41 40
 	 * method field, it will be sent as a response.
42 41
 	 */
43
-	int ( * handle ) ( struct ib_gma *gma, union ib_mad *mad );
42
+	void ( * handle ) ( struct ib_gma *gma, union ib_mad *mad );
44 43
 };
45 44
 
46 45
 /** GMA attribute handlers */

+ 25
- 47
src/net/infiniband/ib_gma.c View File

@@ -86,10 +86,9 @@ static unsigned int next_request_tid;
86 86
  *
87 87
  * @v gma		General management agent
88 88
  * @v mad		MAD
89
- * @ret rc		Return status code
90 89
  */
91
-static int ib_sma_get_node_info ( struct ib_gma *gma,
92
-				  union ib_mad *mad ) {
90
+static void ib_sma_get_node_info ( struct ib_gma *gma,
91
+				   union ib_mad *mad ) {
93 92
 	struct ib_device *ibdev = gma->ibdev;
94 93
 	struct ib_node_info *node_info = &mad->smp.smp_data.node_info;
95 94
 
@@ -104,8 +103,6 @@ static int ib_sma_get_node_info ( struct ib_gma *gma,
104 103
 		 sizeof ( node_info->port_guid ) );
105 104
 	node_info->partition_cap = htons ( 1 );
106 105
 	node_info->local_port_num = ibdev->port;
107
-
108
-	return 0;
109 106
 }
110 107
 
111 108
 /**
@@ -113,10 +110,9 @@ static int ib_sma_get_node_info ( struct ib_gma *gma,
113 110
  *
114 111
  * @v gma		General management agent
115 112
  * @v mad		MAD
116
- * @ret rc		Return status code
117 113
  */
118
-static int ib_sma_get_node_desc ( struct ib_gma *gma,
119
-				  union ib_mad *mad ) {
114
+static void ib_sma_get_node_desc ( struct ib_gma *gma,
115
+				   union ib_mad *mad ) {
120 116
 	struct ib_device *ibdev = gma->ibdev;
121 117
 	struct ib_node_desc *node_desc = &mad->smp.smp_data.node_desc;
122 118
 	struct ib_gid_half *guid = &ibdev->gid.u.half[1];
@@ -127,8 +123,6 @@ static int ib_sma_get_node_desc ( struct ib_gma *gma,
127 123
 		   guid->bytes[0], guid->bytes[1], guid->bytes[2],
128 124
 		   guid->bytes[3], guid->bytes[4], guid->bytes[5],
129 125
 		   guid->bytes[6], guid->bytes[7], ibdev->dev->name );
130
-
131
-	return 0;
132 126
 }
133 127
 
134 128
 /**
@@ -136,18 +130,15 @@ static int ib_sma_get_node_desc ( struct ib_gma *gma,
136 130
  *
137 131
  * @v gma		General management agent
138 132
  * @v mad		MAD
139
- * @ret rc		Return status code
140 133
  */
141
-static int ib_sma_get_guid_info ( struct ib_gma *gma,
142
-				  union ib_mad *mad ) {
134
+static void ib_sma_get_guid_info ( struct ib_gma *gma,
135
+				   union ib_mad *mad ) {
143 136
 	struct ib_device *ibdev = gma->ibdev;
144 137
 	struct ib_guid_info *guid_info = &mad->smp.smp_data.guid_info;
145 138
 
146 139
 	memset ( guid_info, 0, sizeof ( *guid_info ) );
147 140
 	memcpy ( guid_info->guid[0], &ibdev->gid.u.half[1],
148 141
 		 sizeof ( guid_info->guid[0] ) );
149
-
150
-	return 0;
151 142
 }
152 143
 
153 144
 /**
@@ -155,10 +146,9 @@ static int ib_sma_get_guid_info ( struct ib_gma *gma,
155 146
  *
156 147
  * @v gma		General management agent
157 148
  * @v mad		MAD
158
- * @ret rc		Return status code
159 149
  */
160
-static int ib_sma_get_port_info ( struct ib_gma *gma,
161
-				  union ib_mad *mad ) {
150
+static void ib_sma_get_port_info ( struct ib_gma *gma,
151
+				   union ib_mad *mad ) {
162 152
 	struct ib_device *ibdev = gma->ibdev;
163 153
 	struct ib_port_info *port_info = &mad->smp.smp_data.port_info;
164 154
 
@@ -184,8 +174,6 @@ static int ib_sma_get_port_info ( struct ib_gma *gma,
184 174
 	port_info->init_type_reply__mtu_cap = IB_MTU_2048;
185 175
 	port_info->operational_vls__enforcement = ( IB_VL_0 << 4 );
186 176
 	port_info->guid_cap = 1;
187
-
188
-	return 0;
189 177
 }
190 178
 
191 179
 /**
@@ -193,10 +181,9 @@ static int ib_sma_get_port_info ( struct ib_gma *gma,
193 181
  *
194 182
  * @v gma		General management agent
195 183
  * @v mad		MAD
196
- * @ret rc		Return status code
197 184
  */
198
-static int ib_sma_set_port_info ( struct ib_gma *gma,
199
-				  union ib_mad *mad ) {
185
+static void ib_sma_set_port_info ( struct ib_gma *gma,
186
+				   union ib_mad *mad ) {
200 187
 	struct ib_device *ibdev = gma->ibdev;
201 188
 	const struct ib_port_info *port_info = &mad->smp.smp_data.port_info;
202 189
 	int rc;
@@ -214,7 +201,7 @@ static int ib_sma_set_port_info ( struct ib_gma *gma,
214 201
 			htons ( IB_MGMT_STATUS_UNSUPPORTED_METHOD_ATTR );
215 202
 	}
216 203
 
217
-	return ib_sma_get_port_info ( gma, mad );
204
+	ib_sma_get_port_info ( gma, mad );
218 205
 }
219 206
 
220 207
 /**
@@ -222,17 +209,14 @@ static int ib_sma_set_port_info ( struct ib_gma *gma,
222 209
  *
223 210
  * @v gma		General management agent
224 211
  * @v mad		MAD
225
- * @ret rc		Return status code
226 212
  */
227
-static int ib_sma_get_pkey_table ( struct ib_gma *gma,
228
-				   union ib_mad *mad ) {
213
+static void ib_sma_get_pkey_table ( struct ib_gma *gma,
214
+				    union ib_mad *mad ) {
229 215
 	struct ib_device *ibdev = gma->ibdev;
230 216
 	struct ib_pkey_table *pkey_table = &mad->smp.smp_data.pkey_table;
231 217
 
232 218
 	memset ( pkey_table, 0, sizeof ( *pkey_table ) );
233 219
 	pkey_table->pkey[0] = htons ( ibdev->pkey );
234
-
235
-	return 0;
236 220
 }
237 221
 
238 222
 /**
@@ -240,16 +224,15 @@ static int ib_sma_get_pkey_table ( struct ib_gma *gma,
240 224
  *
241 225
  * @v gma		General management agent
242 226
  * @v mad		MAD
243
- * @ret rc		Return status code
244 227
  */
245
-static int ib_sma_set_pkey_table ( struct ib_gma *gma,
246
-				   union ib_mad *mad ) {
228
+static void ib_sma_set_pkey_table ( struct ib_gma *gma,
229
+				    union ib_mad *mad ) {
247 230
 	struct ib_device *ibdev = gma->ibdev;
248 231
 	struct ib_pkey_table *pkey_table = &mad->smp.smp_data.pkey_table;
249 232
 
250 233
 	ibdev->pkey = ntohs ( pkey_table->pkey[0] );
251 234
 
252
-	return ib_sma_get_pkey_table ( gma, mad );
235
+	ib_sma_get_pkey_table ( gma, mad );
253 236
 }
254 237
 
255 238
 /** List of attribute handlers */
@@ -331,9 +314,8 @@ struct ib_gma_handler ib_sma_handlers[] __ib_gma_handler = {
331 314
  *
332 315
  * @v gma		General management agent
333 316
  * @v mad		MAD
334
- * @ret rc		Return status code
335 317
  */
336
-static int ib_handle_mad ( struct ib_gma *gma, union ib_mad *mad ) {
318
+static void ib_handle_mad ( struct ib_gma *gma, union ib_mad *mad ) {
337 319
 	struct ib_mad_hdr *hdr = &mad->hdr;
338 320
 	struct ib_gma_handler *handler;
339 321
 
@@ -344,13 +326,13 @@ static int ib_handle_mad ( struct ib_gma *gma, union ib_mad *mad ) {
344 326
 		     ( handler->method == hdr->method ) &&
345 327
 		     ( handler->attr_id == hdr->attr_id ) ) {
346 328
 			hdr->method = handler->resp_method;
347
-			return handler->handle ( gma, mad );
329
+			handler->handle ( gma, mad );
330
+			return;
348 331
 		}
349 332
 	}
350 333
 
351 334
 	hdr->method = IB_MGMT_METHOD_TRAP;
352 335
 	hdr->status = htons ( IB_MGMT_STATUS_UNSUPPORTED_METHOD_ATTR );
353
-	return -ENOTSUP;
354 336
 }
355 337
 
356 338
 /**
@@ -412,21 +394,17 @@ static void ib_gma_complete_recv ( struct ib_device *ibdev,
412 394
 		}
413 395
 	}
414 396
 
415
-	/* Handle MAD, if possible */
416
-	if ( ( rc = ib_handle_mad ( gma, mad ) ) != 0 ) {
417
-		DBGC ( gma, "GMA %p could not handle TID %08x%08x: %s\n",
418
-		       gma, ntohl ( hdr->tid[0] ), ntohl ( hdr->tid[1] ),
419
-		       strerror ( rc ) );
420
-		/* Do not abort; we may want to send an error response */
421
-	}
397
+	/* Handle MAD */
398
+	ib_handle_mad ( gma, mad );
422 399
 
423 400
 	/* Finish processing if we have no response to send */
424 401
 	if ( ! hdr->method )
425 402
 		goto out;
426 403
 
427
-	DBGC ( gma, "GMA %p TX TID %08x%08x (%02x,%02x,%02x,%04x)\n", gma,
428
-	       ntohl ( hdr->tid[0] ), ntohl ( hdr->tid[1] ), hdr->mgmt_class,
429
-	       hdr->class_version, hdr->method, ntohs ( hdr->attr_id ) );
404
+	DBGC ( gma, "GMA %p TX TID %08x%08x (%02x,%02x,%02x,%04x) status "
405
+	       "%04x\n", gma, ntohl ( hdr->tid[0] ), ntohl ( hdr->tid[1] ),
406
+	       hdr->mgmt_class, hdr->class_version, hdr->method,
407
+	       ntohs ( hdr->attr_id ), ntohs ( hdr->status ) );
430 408
 	DBGC2_HDA ( gma, 0, mad, sizeof ( *mad ) );
431 409
 
432 410
 	/* Set response fields for directed route SMPs */

+ 8
- 14
src/net/infiniband/ib_mcast.c View File

@@ -139,10 +139,9 @@ void ib_mcast_leave ( struct ib_device *ibdev, struct ib_queue_pair *qp,
139 139
  *
140 140
  * @v gma		General management agent
141 141
  * @v mad		MAD
142
- * @ret rc		Return status code
143 142
  */
144
-static int ib_handle_mc_member_join ( struct ib_gma *gma,
145
-				      union ib_mad *mad ) {
143
+static void ib_handle_mc_member_join ( struct ib_gma *gma,
144
+				       union ib_mad *mad ) {
146 145
 	struct ib_device *ibdev = gma->ibdev;
147 146
 	struct ib_mc_member_record *mc_member_record =
148 147
 		&mad->sa.sa_data.mc_member_record;
@@ -155,7 +154,7 @@ static int ib_handle_mc_member_join ( struct ib_gma *gma,
155 154
 	if ( mad->hdr.status != htons ( IB_MGMT_STATUS_OK ) ) {
156 155
 		DBGC ( gma, "GMA %p join failed with status %04x\n",
157 156
 		       gma, ntohs ( mad->hdr.status ) );
158
-		return -EINVAL;
157
+		return;
159 158
 	}
160 159
 
161 160
 	/* Extract MAD parameters */
@@ -170,7 +169,7 @@ static int ib_handle_mc_member_join ( struct ib_gma *gma,
170 169
 		       ntohl ( gid->u.dwords[1] ),
171 170
 		       ntohl ( gid->u.dwords[2] ),
172 171
 		       ntohl ( gid->u.dwords[3] ) );
173
-		return -ENOENT;
172
+		return;
174 173
 	}
175 174
 	DBGC ( gma, "GMA %p QPN %lx joined %08x:%08x:%08x:%08x qkey %lx\n",
176 175
 	       gma, qp->qpn, ntohl ( gid->u.dwords[0] ),
@@ -181,10 +180,8 @@ static int ib_handle_mc_member_join ( struct ib_gma *gma,
181 180
 	if ( ( rc = ib_modify_qp ( ibdev, qp, IB_MODIFY_QKEY, qkey ) ) != 0 ) {
182 181
 		DBGC ( gma, "GMA %p QPN %lx could not modify qkey: %s\n",
183 182
 		       gma, qp->qpn, strerror ( rc ) );
184
-		return rc;
183
+		return;
185 184
 	}
186
-
187
-	return 0;
188 185
 }
189 186
 
190 187
 /**
@@ -192,10 +189,9 @@ static int ib_handle_mc_member_join ( struct ib_gma *gma,
192 189
  *
193 190
  * @v gma		General management agent
194 191
  * @v mad		MAD
195
- * @ret rc		Return status code
196 192
  */
197
-static int ib_handle_mc_member_leave ( struct ib_gma *gma,
198
-				       union ib_mad *mad ) {
193
+static void ib_handle_mc_member_leave ( struct ib_gma *gma,
194
+					union ib_mad *mad ) {
199 195
 	struct ib_mc_member_record *mc_member_record =
200 196
 		&mad->sa.sa_data.mc_member_record;
201 197
 	struct ib_gid *gid;
@@ -204,7 +200,7 @@ static int ib_handle_mc_member_leave ( struct ib_gma *gma,
204 200
 	if ( mad->hdr.status != htons ( IB_MGMT_STATUS_OK ) ) {
205 201
 		DBGC ( gma, "GMA %p leave failed with status %04x\n",
206 202
 		       gma, ntohs ( mad->hdr.status ) );
207
-		return -EINVAL;
203
+		return;
208 204
 	}
209 205
 
210 206
 	/* Extract MAD parameters */
@@ -212,8 +208,6 @@ static int ib_handle_mc_member_leave ( struct ib_gma *gma,
212 208
 	DBGC ( gma, "GMA %p left %08x:%08x:%08x:%08x\n", gma,
213 209
 	       ntohl ( gid->u.dwords[0] ), ntohl ( gid->u.dwords[1] ),
214 210
 	       ntohl ( gid->u.dwords[2] ), ntohl ( gid->u.dwords[3] ) );
215
-
216
-	return 0;
217 211
 }
218 212
 
219 213
 /** Multicast membership record response handler */

+ 3
- 6
src/net/infiniband/ib_pathrec.c View File

@@ -170,10 +170,9 @@ int ib_resolve_path ( struct ib_device *ibdev,
170 170
  *
171 171
  * @v gma		General management agent
172 172
  * @v mad		MAD
173
- * @ret rc		Return status code
174 173
  */
175
-static int ib_handle_path_record ( struct ib_gma *gma,
176
-				   union ib_mad *mad ) {
174
+static void ib_handle_path_record ( struct ib_gma *gma,
175
+				    union ib_mad *mad ) {
177 176
 	struct ib_device *ibdev = gma->ibdev;
178 177
 	struct ib_path_record *path_record = &mad->sa.sa_data.path_record;
179 178
 	struct ib_gid *dgid = &path_record->dgid;
@@ -186,7 +185,7 @@ static int ib_handle_path_record ( struct ib_gma *gma,
186 185
 	if ( mad->hdr.status != htons ( IB_MGMT_STATUS_OK ) ) {
187 186
 		DBGC ( gma, "GMA %p path record lookup failed with status "
188 187
 		       "%04x\n", gma, ntohs ( mad->hdr.status ) );
189
-		return -EINVAL;
188
+		return;
190 189
 	}
191 190
 
192 191
 	/* Extract values from MAD */
@@ -209,8 +208,6 @@ static int ib_handle_path_record ( struct ib_gma *gma,
209 208
 		cached->rate = rate;
210 209
 		cached->sl = sl;
211 210
 	}
212
-
213
-	return 0;
214 211
 }
215 212
 
216 213
 /** Path record response handler */

Loading…
Cancel
Save