Преглед изворни кода

Updated MLX_* accessor macros to use implicit type information.

tags/v0.9.3
Michael Brown пре 16 година
родитељ
комит
6a791649f0

+ 39
- 0
src/drivers/net/mlx_ipoib/arbel.h Прегледај датотеку

@@ -0,0 +1,39 @@
1
+#ifndef _ARBEL_H
2
+#define _ARBEL_H
3
+
4
+struct MLX_DECLARE_STRUCT ( arbelprm_completion_queue_entry );
5
+struct MLX_DECLARE_STRUCT ( arbelprm_completion_with_error );
6
+struct MLX_DECLARE_STRUCT ( arbelprm_cq_ci_db_record );
7
+struct MLX_DECLARE_STRUCT ( arbelprm_qp_db_record );
8
+struct MLX_DECLARE_STRUCT ( arbelprm_send_doorbell );
9
+struct MLX_DECLARE_STRUCT ( arbelprm_ud_address_vector );
10
+struct MLX_DECLARE_STRUCT ( arbelprm_wqe_segment_ctrl_send );
11
+struct MLX_DECLARE_STRUCT ( arbelprm_wqe_segment_data_ptr );
12
+struct MLX_DECLARE_STRUCT ( arbelprm_wqe_segment_next );
13
+struct MLX_DECLARE_STRUCT ( arbelprm_wqe_segment_ud );
14
+
15
+#define ARBELPRM_MAX_GATHER 1
16
+
17
+struct arbelprm_ud_send_wqe {
18
+	struct arbelprm_wqe_segment_next next;
19
+	struct arbelprm_wqe_segment_ctrl_send ctrl;
20
+	struct arbelprm_wqe_segment_ud ud;
21
+	struct arbelprm_wqe_segment_data_ptr data[ARBELPRM_MAX_GATHER];
22
+} __attribute__ (( packed ));
23
+
24
+union arbelprm_completion_entry {
25
+	struct arbelprm_completion_queue_entry normal;
26
+	struct arbelprm_completion_with_error error;
27
+} __attribute__ (( packed ));
28
+
29
+union arbelprm_doorbell_record {
30
+	struct arbelprm_cq_ci_db_record cq_ci;
31
+	struct arbelprm_qp_db_record qp;
32
+} __attribute__ (( packed ));
33
+
34
+union arbelprm_doorbell_register {
35
+	struct arbelprm_send_doorbell send;
36
+	uint32_t dword[2];
37
+} __attribute__ (( packed ));
38
+
39
+#endif /* _ARBEL_H */

+ 25
- 25
src/drivers/net/mlx_ipoib/bit_ops.h Прегледај датотеку

@@ -143,8 +143,8 @@ struct addr_64_st {
143 143
  * This structure provides a wrapper around the autogenerated
144 144
  * pseudo_bit_t structures.  It has the correct size, and also
145 145
  * encapsulates type information about the underlying pseudo_bit_t
146
- * structure, which allows the MLX_POPULATE etc. macros to work
147
- * without requiring explicit type information.
146
+ * structure, which allows the MLX_FILL etc. macros to work without
147
+ * requiring explicit type information.
148 148
  */
149 149
 #define MLX_DECLARE_STRUCT( _structure )				     \
150 150
 	_structure {							     \
@@ -181,7 +181,8 @@ struct addr_64_st {
181 181
 
182 182
 /** Bit mask for a field within a pseudo_bit_t structure */
183 183
 #define MLX_BIT_MASK( _structure_st, _field )				     \
184
-	( ( 1 << MLX_BIT_WIDTH ( _structure_st, _field ) ) - 1 )
184
+	( ( ~( ( uint32_t ) 0 ) ) >>					     \
185
+	  ( 32 - MLX_BIT_WIDTH ( _structure_st, _field ) ) )
185 186
 
186 187
 /*
187 188
  * Assemble native-endian dword from named fields and values
@@ -229,46 +230,45 @@ struct addr_64_st {
229 230
  *
230 231
  */
231 232
 
232
-#define MLX_POPULATE( _ptr, _index, _assembled )			     \
233
+#define MLX_FILL( _ptr, _index, _assembled )				     \
233 234
 	do {								     \
234 235
 		uint32_t *__ptr = &(_ptr)->u.dwords[(_index)];		     \
235 236
 		uint32_t __assembled = (_assembled);			     \
236 237
 		*__ptr = cpu_to_be32 ( __assembled );			     \
237 238
 	} while ( 0 )
238 239
 
239
-#define MLX_POPULATE_1( _ptr, _index, ... )				     \
240
-	MLX_POPULATE ( _ptr, _index,					     \
241
-		       MLX_ASSEMBLE_1 ( MLX_PSEUDO_STRUCT ( _ptr ),	     \
242
-					_index, __VA_ARGS__ ) )
240
+#define MLX_FILL_1( _ptr, _index, ... )					     \
241
+	MLX_FILL ( _ptr, _index, MLX_ASSEMBLE_1 ( MLX_PSEUDO_STRUCT ( _ptr ),\
242
+						  _index, __VA_ARGS__ ) )
243 243
 
244
-#define MLX_POPULATE_2( _ptr, _index, ... )				     \
245
-	MLX_POPULATE ( _ptr, _index,					     \
246
-		       MLX_ASSEMBLE_2 ( MLX_PSEUDO_STRUCT ( _ptr ),	     \
247
-					_index, __VA_ARGS__ ) )
244
+#define MLX_FILL_2( _ptr, _index, ... )					     \
245
+	MLX_FILL ( _ptr, _index, MLX_ASSEMBLE_2 ( MLX_PSEUDO_STRUCT ( _ptr ),\
246
+						  _index, __VA_ARGS__ ) )
248 247
 
249
-#define MLX_POPULATE_3( _ptr, _index, ... )				     \
250
-	MLX_POPULATE ( _ptr, _index,					     \
251
-		       MLX_ASSEMBLE_3 ( MLX_PSEUDO_STRUCT ( _ptr ),	     \
252
-					_index, __VA_ARGS__ ) )
248
+#define MLX_FILL_3( _ptr, _index, ... )					     \
249
+	MLX_FILL ( _ptr, _index, MLX_ASSEMBLE_3 ( MLX_PSEUDO_STRUCT ( _ptr ),\
250
+						  _index, __VA_ARGS__ ) )
251
+
252
+#define MLX_FILL_4( _ptr, _index, ... )					     \
253
+	MLX_FILL ( _ptr, _index, MLX_ASSEMBLE_4 ( MLX_PSEUDO_STRUCT ( _ptr ),\
254
+						  _index, __VA_ARGS__ ) )
253 255
 
254
-#define MLX_POPULATE_4( _ptr, _index, ... )				     \
255
-	MLX_POPULATE ( _ptr, _index,					     \
256
-		       MLX_ASSEMBLE_4 ( MLX_PSEUDO_STRUCT ( _ptr ),	     \
257
-					_index, __VA_ARGS__ ) )
258 256
 
259 257
 /*
260 258
  * Modify big-endian dword using named field and value
261 259
  *
262 260
  */
263 261
 
264
-#define MLX_MODIFY( _ptr, _index, _field, _value )			     \
262
+#define MLX_SET( _ptr, _field, _value )					     \
265 263
 	do {								     \
266
-		uint32_t *__ptr = &(_ptr)->u.dwords[(_index)];		     \
264
+		unsigned int __index = 					     \
265
+		    MLX_DWORD_OFFSET ( MLX_PSEUDO_STRUCT ( _ptr ), _field ); \
266
+		uint32_t *__ptr = &(_ptr)->u.dwords[__index];		     \
267 267
 		uint32_t __value = be32_to_cpu ( *__ptr );		     \
268 268
 		__value &= ~( MLX_MASK_1 ( MLX_PSEUDO_STRUCT ( _ptr ),	     \
269
-					   _index, _field ) );		     \
269
+					   __index, _field ) );		     \
270 270
 		__value |= MLX_ASSEMBLE_1 ( MLX_PSEUDO_STRUCT ( _ptr ),	     \
271
-					    _index, _field, _value );	     \
271
+					    __index, _field, _value );	     \
272 272
 		*__ptr = cpu_to_be32 ( __value );			     \
273 273
 	} while ( 0 )
274 274
 
@@ -277,7 +277,7 @@ struct addr_64_st {
277 277
  *
278 278
  */
279 279
 
280
-#define MLX_EXTRACT( _ptr, _field )					     \
280
+#define MLX_GET( _ptr, _field )						     \
281 281
 	( {								     \
282 282
 		unsigned int __index = 					     \
283 283
 		    MLX_DWORD_OFFSET ( MLX_PSEUDO_STRUCT ( _ptr ), _field ); \

+ 66
- 75
src/drivers/net/mlx_ipoib/mt25218.c Прегледај датотеку

@@ -37,14 +37,14 @@ struct arbel_completion_queue {
37 37
 	/** Doorbell record number */
38 38
 	unsigned int doorbell_idx;
39 39
 	/** Completion queue entries */
40
-	union cqe_st *cqe;
40
+	union arbelprm_completion_entry *cqe;
41 41
 };
42 42
 
43 43
 struct arbel {
44 44
 	/** User Access Region */
45 45
 	void *uar;
46 46
 	/** Doorbell records */
47
-	union db_record_st *db_rec;
47
+	union arbelprm_doorbell_record *db_rec;
48 48
 };
49 49
 
50 50
 
@@ -157,9 +157,9 @@ static int mlx_transmit_direct ( struct net_device *netdev,
157 157
 	struct ib_address_vector av = {
158 158
 		.dest_qp = bcast_av->dest_qp,
159 159
 		.qkey = bcast_av->qkey,
160
-		.dlid = MLX_EXTRACT ( bav, rlid ),
161
-		.rate = ( MLX_EXTRACT ( bav, max_stat_rate ) ? 1 : 4 ),
162
-		.sl = MLX_EXTRACT ( bav, sl ),
160
+		.dlid = MLX_GET ( bav, rlid ),
161
+		.rate = ( MLX_GET ( bav, max_stat_rate ) ? 1 : 4 ),
162
+		.sl = MLX_GET ( bav, sl ),
163 163
 		.gid_present = 1,
164 164
 	};
165 165
 	memcpy ( &av.gid, ( ( void * ) bav ) + 16, 16 );
@@ -318,18 +318,18 @@ static struct ib_gid arbel_no_gid = {
318 318
  * @v db_reg		Doorbell register structure
319 319
  * @v offset		Address of doorbell
320 320
  */
321
-static void arbel_ring_doorbell ( struct arbel *arbel, void *db_reg,
321
+static void arbel_ring_doorbell ( struct arbel *arbel,
322
+				  union arbelprm_doorbell_register *db_reg,
322 323
 				  unsigned int offset ) {
323
-	uint32_t *db_reg_dword = db_reg;
324 324
 
325 325
 	DBG ( "arbel_ring_doorbell %08lx:%08lx to %lx\n",
326
-	      db_reg_dword[0], db_reg_dword[1],
326
+	      db_reg->dword[0], db_reg->dword[1],
327 327
 	      virt_to_phys ( arbel->uar + offset ) );
328 328
 
329 329
 	barrier();
330
-	writel ( db_reg_dword[0], ( arbel->uar + offset + 0 ) );
330
+	writel ( db_reg->dword[0], ( arbel->uar + offset + 0 ) );
331 331
 	barrier();
332
-	writel ( db_reg_dword[1], ( arbel->uar + offset + 4 ) );
332
+	writel ( db_reg->dword[1], ( arbel->uar + offset + 4 ) );
333 333
 }
334 334
 
335 335
 /**
@@ -347,15 +347,16 @@ static int arbel_post_send ( struct ib_device *ibdev, struct io_buffer *iobuf,
347 347
 	struct arbel *arbel = ibdev->priv;
348 348
 	struct ib_work_queue *wq = &qp->send;
349 349
 	struct arbel_send_work_queue *arbel_wq = wq->priv;
350
-	unsigned int wqe_idx_mask = ( wq->num_wqes - 1 );
351
-	struct ud_send_wqe_st *prev_wqe;
352
-	struct ud_send_wqe_st *wqe;
350
+	struct arbelprm_ud_send_wqe *prev_wqe;
351
+	struct arbelprm_ud_send_wqe *wqe;
352
+	union arbelprm_doorbell_record *db_rec;
353
+	union arbelprm_doorbell_register db_reg;
353 354
 	struct ib_gid *gid;
355
+	unsigned int wqe_idx_mask;
354 356
 	size_t nds;
355
-	union db_record_st *db_rec;
356
-	struct send_doorbell_st db_reg;
357 357
 
358 358
 	/* Allocate work queue entry */
359
+	wqe_idx_mask = ( wq->num_wqes - 1 );
359 360
 	if ( wq->iobufs[wq->next_idx & wqe_idx_mask] ) {
360 361
 		DBGC ( arbel, "ARBEL %p send queue full", arbel );
361 362
 		return -ENOBUFS;
@@ -365,69 +366,61 @@ static int arbel_post_send ( struct ib_device *ibdev, struct io_buffer *iobuf,
365 366
 	wqe = &arbel_wq->wqe_u[wq->next_idx & wqe_idx_mask].wqe_cont.wqe;
366 367
 
367 368
 	/* Construct work queue entry */
368
-	MLX_POPULATE_1 ( &wqe->next.next, arbelprm_wqe_segment_next_st, 1,
369
-			 always1, 1 );
370
-	memset ( &wqe->next.control, 0,
371
-		 sizeof ( wqe->next.control ) );
372
-	MLX_POPULATE_1 ( &wqe->next.control,
373
-			 arbelprm_wqe_segment_ctrl_send_st, 0,
374
-			 always1, 1 );
375
-	memset ( &wqe->udseg, 0, sizeof ( wqe->udseg ) );
376
-	MLX_POPULATE_2 ( &wqe->udseg, arbelprm_ud_address_vector_st, 0,
377
-			 pd, GLOBAL_PD,
378
-			 port_number, PXE_IB_PORT );
379
-	MLX_POPULATE_2 ( &wqe->udseg, arbelprm_ud_address_vector_st, 1,
380
-			 rlid, av->dlid,
381
-			 g, av->gid_present );
382
-	MLX_POPULATE_2 ( &wqe->udseg, arbelprm_ud_address_vector_st, 2,
383
-			 max_stat_rate, ( ( av->rate >= 3 ) ? 0 : 1 ),
384
-			 msg, 3 );
385
-	MLX_POPULATE_1 ( &wqe->udseg, arbelprm_ud_address_vector_st, 3,
386
-			 sl, av->sl );
369
+	MLX_FILL_1 ( &wqe->next, 1, always1, 1 );
370
+	memset ( &wqe->ctrl, 0, sizeof ( wqe->ctrl ) );
371
+	MLX_FILL_1 ( &wqe->ctrl, 0, always1, 1 );
372
+	memset ( &wqe->ud, 0, sizeof ( wqe->ud ) );
373
+	MLX_FILL_2 ( &wqe->ud, 0,
374
+		     ud_address_vector.pd, GLOBAL_PD,
375
+		     ud_address_vector.port_number, PXE_IB_PORT );
376
+	MLX_FILL_2 ( &wqe->ud, 1,
377
+		     ud_address_vector.rlid, av->dlid,
378
+		     ud_address_vector.g, av->gid_present );
379
+	MLX_FILL_2 ( &wqe->ud, 2,
380
+		     ud_address_vector.max_stat_rate,
381
+			 ( ( av->rate >= 3 ) ? 0 : 1 ),
382
+		     ud_address_vector.msg, 3 );
383
+	MLX_FILL_1 ( &wqe->ud, 3, ud_address_vector.sl, av->sl );
387 384
 	gid = ( av->gid_present ? &av->gid : &arbel_no_gid );
388
-	memcpy ( ( ( ( void * ) &wqe->udseg ) + 16 ),
389
-		 gid, sizeof ( *gid ) );
390
-	MLX_POPULATE_1 ( &wqe->udseg, arbelprm_wqe_segment_ud_st, 8,
391
-			 destination_qp, av->dest_qp );
392
-	MLX_POPULATE_1 ( &wqe->udseg, arbelprm_wqe_segment_ud_st, 9,
393
-			 q_key, av->qkey );
394
-	wqe->mpointer[0].local_addr_l =
395
-		cpu_to_be32 ( virt_to_bus ( iobuf->data ) );
396
-	wqe->mpointer[0].byte_count = cpu_to_be32 ( iob_len ( iobuf ) );
385
+	memcpy ( &wqe->ud.u.dwords[4], gid, sizeof ( *gid ) );
386
+	MLX_FILL_1 ( &wqe->ud, 8, destination_qp, av->dest_qp );
387
+	MLX_FILL_1 ( &wqe->ud, 9, q_key, av->qkey );
388
+	MLX_FILL_1 ( &wqe->data[0], 3,
389
+		     local_address_l, virt_to_bus ( iobuf->data ) );
390
+	MLX_FILL_1 ( &wqe->data[0], 0, byte_count, iob_len ( iobuf ) );
397 391
 
398 392
 	DBG ( "Work queue entry:\n" );
399 393
 	DBG_HD ( wqe, sizeof ( *wqe ) );
400 394
 
401 395
 	/* Update previous work queue entry's "next" field */
402
-	nds = ( ( offsetof ( typeof ( *wqe ), mpointer ) +
403
-		  sizeof ( wqe->mpointer[0] ) ) >> 4 );
404
-	MLX_MODIFY ( &prev_wqe->next.next, arbelprm_wqe_segment_next_st, 0,
405
-		     nopcode, XDEV_NOPCODE_SEND );
406
-	MLX_POPULATE_3 ( &prev_wqe->next.next, arbelprm_wqe_segment_next_st, 1,
407
-			 nds, nds,
408
-			 f, 1,
409
-			 always1, 1 );
396
+	nds = ( ( offsetof ( typeof ( *wqe ), data ) +
397
+		  sizeof ( wqe->data[0] ) ) >> 4 );
398
+	MLX_SET ( &prev_wqe->next, nopcode, XDEV_NOPCODE_SEND );
399
+	MLX_FILL_3 ( &prev_wqe->next, 1,
400
+		     nds, nds,
401
+		     f, 1,
402
+		     always1, 1 );
410 403
 
411 404
 	DBG ( "Previous work queue entry's next field:\n" );
412
-	DBG_HD ( &prev_wqe->next.next, sizeof ( prev_wqe->next.next ) );
405
+	DBG_HD ( &prev_wqe->next, sizeof ( prev_wqe->next ) );
413 406
 
414 407
 	/* Update doorbell record */
415 408
 	db_rec = &arbel->db_rec[arbel_wq->doorbell_idx];
416
-	MLX_POPULATE_1 ( db_rec, arbelprm_qp_db_record_st, 0, 
417
-			 counter, ( ( wq->next_idx + 1 ) & 0xffff ) );
409
+	MLX_FILL_1 ( &db_rec->qp, 0,
410
+		     counter, ( ( wq->next_idx + 1 ) & 0xffff ) );
418 411
 	barrier();
419 412
 	DBG ( "Doorbell record:\n" );
420 413
 	DBG_HD ( db_rec, 8 );
421 414
 
422 415
 	/* Ring doorbell register */
423
-	MLX_POPULATE_4 ( &db_reg, arbelprm_send_doorbell_st, 0,
424
-			 nopcode, XDEV_NOPCODE_SEND,
425
-			 f, 1,
426
-			 wqe_counter, ( wq->next_idx & 0xffff ),
427
-			 wqe_cnt, 1 );
428
-	MLX_POPULATE_2 ( &db_reg, arbelprm_send_doorbell_st, 1,
429
-			 nds, nds,
430
-			 qpn, qp->qpn );
416
+	MLX_FILL_4 ( &db_reg.send, 0,
417
+		     nopcode, XDEV_NOPCODE_SEND,
418
+		     f, 1,
419
+		     wqe_counter, ( wq->next_idx & 0xffff ),
420
+		     wqe_cnt, 1 );
421
+	MLX_FILL_2 ( &db_reg.send, 1,
422
+		     nds, nds,
423
+		     qpn, qp->qpn );
431 424
 	arbel_ring_doorbell ( arbel, &db_reg, POST_SND_OFFSET );
432 425
 
433 426
 	/* Update work queue's index */
@@ -437,13 +430,12 @@ static int arbel_post_send ( struct ib_device *ibdev, struct io_buffer *iobuf,
437 430
 }
438 431
 
439 432
 static void arbel_parse_completion ( struct arbel *arbel,
440
-				     union cqe_st *cqe,
433
+				     union arbelprm_completion_entry *cqe,
441 434
 				     struct ib_completion *completion ) {
442 435
 	memset ( completion, 0, sizeof ( *completion ) );
443
-	is_send = MLX_EXTRACT ( cqe, arbelprm_completion_queue_entry_st, s );					
444
-	completion->len =
445
-		MLX_EXTRACT ( cqe, arbelprm_completion_queue_entry_st,
446
-			      byte_cnt );}
436
+	completion->is_send = MLX_GET ( &cqe->normal, s );
437
+	completion->len = MLX_GET ( &cqe->normal, byte_cnt );
438
+}
447 439
 
448 440
 /**
449 441
  * Poll completion queue
@@ -459,8 +451,8 @@ static void arbel_poll_cq ( struct ib_device *ibdev,
459 451
 	struct arbel *arbel = ibdev->priv;
460 452
 	struct arbel_completion_queue *arbel_cq = cq->priv;
461 453
 	unsigned int cqe_idx_mask = ( cq->num_cqes - 1 );
462
-	union db_record_st *db_rec = &arbel->db_rec[arbel_cq->doorbell_idx];
463
-	union cqe_st *cqe;
454
+	union arbelprm_doorbell_record *db_rec;
455
+	union arbelprm_completion_entry *cqe;
464 456
 	struct ib_completion completion;
465 457
 	struct io_buffer *iobuf;
466 458
 	int is_send;
@@ -468,8 +460,7 @@ static void arbel_poll_cq ( struct ib_device *ibdev,
468 460
 	while ( 1 ) {
469 461
 		/* Look for completion entry */
470 462
 		cqe = &arbel_cq->cqe[cq->next_idx & cqe_idx_mask];
471
-		if ( MLX_EXTRACT ( cqe, arbelprm_completion_queue_entry_st,
472
-				   owner ) != 0 ) {
463
+		if ( MLX_GET ( &cqe->normal, owner ) != 0 ) {
473 464
 			/* Entry still owned by hardware; end of poll */
474 465
 			break;
475 466
 		}
@@ -484,14 +475,14 @@ static void arbel_poll_cq ( struct ib_device *ibdev,
484 475
 							      iobuf );
485 476
 
486 477
 		/* Return ownership to hardware */
487
-		MLX_POPULATE_1 ( cqe, arbelprm_completion_queue_entry_st, 7,
488
-				 owner, 1 );
478
+		MLX_FILL_1 ( &cqe->normal, 7, owner, 1 );
489 479
 		barrier();
490 480
 		/* Update completion queue's index */
491 481
 		cq->next_idx++;
492 482
 		/* Update doorbell record */
493
-		MLX_POPULATE_1 ( db_rec, arbelprm_cq_ci_db_record_st, 0,
494
-				 counter, ( cq->next_idx & 0xffffffffUL ) );
483
+		db_rec = &arbel->db_rec[arbel_cq->doorbell_idx];
484
+		MLX_FILL_1 ( &db_rec->cq_ci, 0,
485
+			     counter, ( cq->next_idx & 0xffffffffUL ) );
495 486
 	}
496 487
 }
497 488
 

+ 2
- 0
src/include/gpxe/infiniband.h Прегледај датотеку

@@ -113,6 +113,8 @@ struct ib_completion_queue {
113 113
 
114 114
 /** An Infiniband completion */
115 115
 struct ib_completion {
116
+	/** Completion is for send queue */
117
+	int is_send;
116 118
 	/** Length */
117 119
 	size_t len;
118 120
 };

Loading…
Откажи
Сачувај