浏览代码

Now at least compiles

tags/v0.9.3
Michael Brown 16 年前
父节点
当前提交
38a73b55c4

+ 98
- 0
src/drivers/net/mlx_ipoib/bit_ops.h 查看文件

@@ -133,4 +133,102 @@ struct addr_64_st {
133 133
 	field; \
134 134
 })
135 135
 
136
+
137
+
138
+/* Remaining code Copyright Fen Systems Ltd. 2007 */
139
+
140
+/** Bit offset of a field within a pseudo_bit_t structure */
141
+#define MLX_BIT_OFFSET( _structure, _field )				   \
142
+	offsetof ( struct _structure, _field )
143
+
144
+/** Bit width of a field within a pseudo_bit_t structure */
145
+#define MLX_BIT_WIDTH( _structure, _field )				   \
146
+	sizeof ( ( ( struct _structure * ) NULL )->_field )
147
+
148
+/*
149
+ * Assemble native-endian dword from named fields and values
150
+ *
151
+ */
152
+
153
+#define MLX_ASSEMBLE_1( _structure, _index, _field, _value )		   \
154
+	( (_value) <<							   \
155
+	  ( MLX_BIT_OFFSET ( _structure, _field ) - ( 32 * (_index) ) ) )
156
+
157
+#define MLX_ASSEMBLE_2( _structure, _index, _field, _value, ... )	   \
158
+	( MLX_ASSEMBLE_1 ( _structure, _index, _field, _value ) |	   \
159
+	  MLX_ASSEMBLE_1 ( _structure, _index, __VA_ARGS__ ) )
160
+
161
+#define MLX_ASSEMBLE_3( _structure, _index, _field, _value, ... )	   \
162
+	( MLX_ASSEMBLE_1 ( _structure, _index, _field, _value ) |	   \
163
+	  MLX_ASSEMBLE_2 ( _structure, _index, __VA_ARGS__ ) )
164
+
165
+#define MLX_ASSEMBLE_4( _structure, _index, _field, _value, ... )	   \
166
+	( MLX_ASSEMBLE_1 ( _structure, _index, _field, _value ) |	   \
167
+	  MLX_ASSEMBLE_3 ( _structure, _index, __VA_ARGS__ ) )
168
+
169
+/*
170
+ * Build native-endian (positive) dword bitmasks from named fields
171
+ *
172
+ */
173
+
174
+#define MLX_MASK_1( _structure, _index, _field )			   \
175
+	MLX_ASSEMBLE_1 ( _structure, _index, _field,			   \
176
+			 ( ( 1 << MLX_BIT_WIDTH ( _structure,		   \
177
+						  _field ) ) - 1 ) )
178
+
179
+#define MLX_MASK_2( _structure, _index, _field, ... )			   \
180
+	( MLX_MASK_1 ( _structure, _index, _field ) |			   \
181
+	  MLX_MASK_1 ( _structure, _index, __VA_ARGS__ ) )
182
+
183
+#define MLX_MASK_3( _structure, _index, _field, ... )			   \
184
+	( MLX_MASK_1 ( _structure, _index, _field ) |			   \
185
+	  MLX_MASK_2 ( _structure, _index, __VA_ARGS__ ) )
186
+
187
+#define MLX_MASK_4( _structure, _index, _field, ... )			   \
188
+	( MLX_MASK_1 ( _structure, _index, _field ) |			   \
189
+	  MLX_MASK_3 ( _structure, _index, __VA_ARGS__ ) )
190
+
191
+/*
192
+ * Populate big-endian dwords from named fields and values
193
+ *
194
+ */
195
+
196
+#define MLX_POPULATE( _base, _index, _assembled )			   \
197
+	do {								   \
198
+		uint32_t *__ptr = ( ( (uint32_t *) (_base) ) + (_index) ); \
199
+		uint32_t __assembled = (_assembled);			   \
200
+		*__ptr = cpu_to_be32 ( __assembled );			   \
201
+	} while ( 0 )
202
+
203
+#define MLX_POPULATE_1( _base, _structure, _index, ... )		   \
204
+	MLX_POPULATE ( _base, _index,					   \
205
+		       MLX_ASSEMBLE_1 ( _structure, _index, __VA_ARGS__ ) )
206
+
207
+#define MLX_POPULATE_2( _base, _structure, _index, ... )		   \
208
+	MLX_POPULATE ( _base, _index,					   \
209
+		       MLX_ASSEMBLE_2 ( _structure, _index, __VA_ARGS__ ) )
210
+
211
+#define MLX_POPULATE_3( _base, _structure, _index, ... )		   \
212
+	MLX_POPULATE ( _base, _index,					   \
213
+		       MLX_ASSEMBLE_3 ( _structure, _index, __VA_ARGS__ ) )
214
+
215
+#define MLX_POPULATE_4( _base, _structure, _index, ... )		   \
216
+	MLX_POPULATE ( _base, _index,					   \
217
+		       MLX_ASSEMBLE_4 ( _structure, _index, __VA_ARGS__ ) )
218
+
219
+/*
220
+ * Modify big-endian dword using named field and value
221
+ *
222
+ */
223
+
224
+#define MLX_MODIFY( _base, _structure, _index, _field, _value )		   \
225
+	do {								   \
226
+		uint32_t *__ptr = ( ( (uint32_t *) (_base) ) + (_index) ); \
227
+		uint32_t __value = be32_to_cpu ( *__ptr );		   \
228
+		__value &= ~( MLX_MASK_1 ( _structure, _index, _field ) ); \
229
+		__value |= MLX_ASSEMBLE_1 ( _structure, _index,		   \
230
+					    _field, _value );		   \
231
+		*__ptr = cpu_to_be32 ( __value );			   \
232
+	} while ( 0 )
233
+
136 234
 #endif				/* __bit_ops_h__ */

+ 42
- 58
src/drivers/net/mlx_ipoib/mt25218.c 查看文件

@@ -224,28 +224,32 @@ static struct net_device_operations mlx_operations = {
224 224
 };
225 225
 
226 226
 
227
+struct mlx_send_work_queue {
228
+	/** Doorbell number */
229
+	unsigned int doorbell_idx;
230
+	/** Work queue entries */
231
+	struct ud_send_wqe_st *wqe;
232
+};
227 233
 
228
-int ib_alloc_wqe ( struct ib_work_queue *wq, struct io_buffer *iobuf ) {
229
-	unsigned int wqe_idx;
230
-	unsigned int new_write_ptr;
231
-
232
-	/* Allocate queue entry */
233
-	wqe_idx = new_write_ptr = wq->write_ptr;
234
-	if ( wq->iobuf[wqe_idx] )
235
-		return -ENOBUFS;
236
-	wq->iobuf[wqe_idx] = iobuf;
234
+struct mlx {
235
+	/** User Access Region */
236
+	unsigned long uar;
237
+	/** Doorbell records */
238
+	union db_record_st *db_rec;
239
+};
237 240
 
238
-	/* Update write pointer */
239
-	new_write_ptr++;
240
-	new_write_ptr &= ( wq->num_wqes - 1 );
241
-	wq->write_ptr = new_write_ptr;
241
+static struct ib_gid mlx_no_gid = {
242
+	{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2 }
243
+};
242 244
 
243
-	return wqe_idx;
244
-}
245
+static void mlx_ring_doorbell ( struct mlx *mlx, void *db_reg,
246
+				unsigned int offset ) {
247
+	uint32_t *db_reg_dword = db_reg;
245 248
 
246
-static inline void ib_free_wqe ( struct ib_work_queue *wq, int wqe_idx ) {
247
-	assert ( wq->iobuf[wqe_idx] != NULL );
248
-	wq->iobuf[wqe_idx] = NULL;
249
+	barrier();
250
+	writel ( db_reg_dword[0], ( mlx->uar + offset + 0 ) );
251
+	barrier();
252
+	writel ( db_reg_dword[1], ( mlx->uar + offset + 4 ) );
249 253
 }
250 254
 
251 255
 static int mlx_post_send ( struct ib_device *ibdev, struct io_buffer *iobuf,
@@ -253,7 +257,7 @@ static int mlx_post_send ( struct ib_device *ibdev, struct io_buffer *iobuf,
253 257
 			   struct ib_queue_pair *qp ) {
254 258
 	struct mlx *mlx = ibdev->priv;
255 259
 	struct ib_work_queue *wq = &qp->send;
256
-	struct mlx_work_queue *mlx_wq = wq->priv;
260
+	struct mlx_send_work_queue *mlx_wq = wq->priv;
257 261
 	unsigned int wqe_idx_mask = ( wq->num_wqes - 1 );
258 262
 	unsigned int prev_wqe_idx;
259 263
 	struct ud_send_wqe_st *prev_wqe;
@@ -261,11 +265,12 @@ static int mlx_post_send ( struct ib_device *ibdev, struct io_buffer *iobuf,
261 265
 	struct ud_send_wqe_st *wqe;
262 266
 	struct ib_gid *gid;
263 267
 	size_t nds;
264
-	struct send_doorbell_st doorbell;
268
+	union db_record_st *db_rec;
269
+	struct send_doorbell_st db_reg;
265 270
 
266 271
 	/* Allocate work queue entry */
267 272
 	prev_wqe_idx = wq->posted;
268
-	wqe_idx = ( prev_wqe_index + 1 );
273
+	wqe_idx = ( prev_wqe_idx + 1 );
269 274
 	if ( wq->iobuf[wqe_idx & wqe_idx_mask] ) {
270 275
 		DBGC ( mlx, "MLX %p send queue full", mlx );
271 276
 		return -ENOBUFS;
@@ -282,16 +287,16 @@ static int mlx_post_send ( struct ib_device *ibdev, struct io_buffer *iobuf,
282 287
 	memset ( &wqe->udseg, 0, sizeof ( wqe->udseg ) );
283 288
 	MLX_POPULATE_2 ( &wqe->udseg, arbelprm_ud_address_vector_st, 0,
284 289
 			 pd, GLOBAL_PD,
285
-			 port_number, mlx->port );
290
+			 port_number, PXE_IB_PORT );
286 291
 	MLX_POPULATE_2 ( &wqe->udseg, arbelprm_ud_address_vector_st, 1,
287
-			 rlid, av->remote_lid,
292
+			 rlid, av->dlid,
288 293
 			 g, av->gid_present );
289 294
 	MLX_POPULATE_2 ( &wqe->udseg, arbelprm_ud_address_vector_st, 2,
290 295
 			 max_stat_rate, ( ( av->rate >= 3 ) ? 0 : 1 ),
291 296
 			 msg, 3 );
292 297
 	MLX_POPULATE_1 ( &wqe->udseg, arbelprm_ud_address_vector_st, 3,
293 298
 			 sl, av->sl );
294
-	gid = ( av->gid_present ? av->gid : &ib_no_gid );
299
+	gid = ( av->gid_present ? &av->gid : &mlx_no_gid );
295 300
 	memcpy ( ( ( ( void * ) &wqe->udseg ) + 16 ),
296 301
 		 gid, sizeof ( *gid ) );
297 302
 	MLX_POPULATE_1 ( &wqe->udseg, arbelprm_wqe_segment_ud_st, 8,
@@ -305,55 +310,34 @@ static int mlx_post_send ( struct ib_device *ibdev, struct io_buffer *iobuf,
305 310
 	/* Update previous work queue entry's "next" field */
306 311
 	nds = ( offsetof ( typeof ( *wqe ), mpointer ) +
307 312
 		sizeof ( wqe->mpointer[0] ) );
308
-	MLX_MODIFY_1 ( &prev_wqe->next.next, arbelprm_wqe_segment_next_st, 0,
309
-		       nopcode, XDEV_NOPCODE_SEND );
313
+	MLX_MODIFY ( &prev_wqe->next.next, arbelprm_wqe_segment_next_st, 0,
314
+		     nopcode, XDEV_NOPCODE_SEND );
310 315
 	MLX_POPULATE_3 ( &prev_wqe->next.next, arbelprm_wqe_segment_next_st, 1,
311 316
 			 nds, nds,
312 317
 			 f, 1,
313 318
 			 always1, 1 );
314 319
 
315
-	/* Ring doorbell */
316
-
317
-	doorbell index is a property of the queue pair
318
-
319
-
320
-	MLX_POPULATE_1 ( mlx_wq->send_uar_context, arbelprm_qp_db_record_st, 0, 
320
+	/* Update doorbell record */
321
+	db_rec = &mlx->db_rec[mlx_wq->doorbell_idx];
322
+	MLX_POPULATE_1 ( db_rec, arbelprm_qp_db_record_st, 0, 
321 323
 			 counter, ( wqe_idx & 0xffff ) );
322
-	memset ( &doorbell, 0, sizeof ( doorbell ) );
323
-	MLX_POPULATE_4 ( &doorbell, arbelprm_send_doorbell_st, 0,
324
+	barrier();
325
+
326
+	/* Ring doorbell register */
327
+	MLX_POPULATE_4 ( &db_reg, arbelprm_send_doorbell_st, 0,
324 328
 			 nopcode, XDEV_NOPCODE_SEND,
325 329
 			 f, 1,
326 330
 			 wqe_counter, ( prev_wqe_idx & 0xffff ),
327 331
 			 wqe_cnt, 1 );
328
-	MLX_POPULATE_2 ( &doorbell, arbelprm_send_doorbell_st, 1,
332
+	MLX_POPULATE_2 ( &db_reg, arbelprm_send_doorbell_st, 1,
329 333
 			 nds, nds,
330 334
 			 qpn, qp->qpn );
331
-	barrier();
335
+	mlx_ring_doorbell ( mlx, &db_reg, POST_SND_OFFSET );
332 336
 
337
+	/* Update work queue's posted index */
333 338
 	wq->posted = wqe_idx;
334 339
 
335
-
336
-	struct mlx_nic *mlx = netdev->priv;
337
-	ud_av_t av = iobuf->data;
338
-	ud_send_wqe_t snd_wqe;
339
-	int rc;
340
-
341
-	snd_wqe = alloc_send_wqe ( mlx->ipoib_qph );
342
-	if ( ! snd_wqe ) {
343
-		DBGC ( mlx, "MLX %p out of TX WQEs\n", mlx );
344
-		return -ENOBUFS;
345
-	}
346
-
347
-	prep_send_wqe_buf ( mlx->ipoib_qph, mlx->bcast_av, snd_wqe,
348
-			    iobuf->data, 0, iob_len ( iobuf ), 0 );
349
-	if ( ( rc = post_send_req ( mlx->ipoib_qph, snd_wqe, 1 ) ) != 0 ) {
350
-		DBGC ( mlx, "MLX %p could not post TX WQE %p: %s\n",
351
-		       mlx, snd_wqe, strerror ( rc ) );
352
-		free_wqe ( snd_wqe );
353
-		return rc;
354
-	}
355
-
356
-
340
+	return 0;
357 341
 }
358 342
 
359 343
 static struct ib_device_operations mlx_ib_operations = {

+ 18
- 0
src/drivers/net/mlx_ipoib/mt25218.h 查看文件

@@ -342,6 +342,24 @@ struct cq_dbell_st {
342 342
 	__u8 raw[MT_STRUCT_SIZE(arbelprm_cq_cmd_doorbell_st)];
343 343
 } __attribute__ ((packed));
344 344
 
345
+struct qp_db_record_st {
346
+	__u8 raw[MT_STRUCT_SIZE(arbelprm_qp_db_record_st)];
347
+} __attribute__ ((packed));
348
+
349
+struct cq_arm_db_record_st {
350
+	__u8 raw[MT_STRUCT_SIZE(arbelprm_cq_arm_db_record_st)];
351
+} __attribute__ ((packed));
352
+
353
+struct cq_ci_db_record_st {
354
+	__u8 raw[MT_STRUCT_SIZE(arbelprm_cq_ci_db_record_st)];
355
+} __attribute__ ((packed));
356
+
357
+union db_record_st {
358
+	struct qp_db_record_st qp;
359
+	struct cq_arm_db_record_st cq_arm;
360
+	struct cq_ci_db_record_st cq_ci;
361
+} __attribute__ ((packed));
362
+
345 363
 struct mad_ifc_inprm_st {
346 364
 	union mad_u mad;
347 365
 } __attribute__ ((packed));

+ 27
- 6
src/include/gpxe/infiniband.h 查看文件

@@ -61,6 +61,9 @@ struct ibhdr {
61 61
 	uint16_t reserved;
62 62
 } __attribute__ (( packed ));
63 63
 
64
+
65
+
66
+
64 67
 /** An Infiniband Work Queue */
65 68
 struct ib_work_queue {
66 69
 	/** Number of work queue entries */
@@ -70,10 +73,7 @@ struct ib_work_queue {
70 73
 	 * This is the index of the most recently posted entry.
71 74
 	 */
72 75
 	unsigned int posted;
73
-	/** Driver-private data
74
-	 *
75
-	 * Typically used to hold the address of the work queue.
76
-	 */
76
+	/** Driver private data */
77 77
 	void *priv;
78 78
 	/** I/O buffers assigned to work queue */
79 79
 	struct io_buffer *iobuf[0];
@@ -87,13 +87,30 @@ struct ib_queue_pair {
87 87
 	struct ib_work_queue send;
88 88
 	/** Receive queue */
89 89
 	struct ib_work_queue recv;
90
+	/** Driver private data */
91
+	void *priv;
90 92
 };
91 93
 
92 94
 /** An Infiniband Address Vector */
93 95
 struct ib_address_vector {
94
-	
96
+	/** Destination Queue Pair */
97
+	unsigned int dest_qp;
98
+	/** Queue key */
99
+	unsigned int qkey;
100
+	/** Destination Local ID */
101
+	unsigned int dlid;
102
+	/** Rate */
103
+	unsigned int rate;
104
+	/** Service level */
105
+	unsigned int sl;
106
+	/** GID is present */
107
+	unsigned int gid_present;
108
+	/** GID */
109
+	struct ib_gid gid;
95 110
 };
96 111
 
112
+struct ib_device;
113
+
97 114
 /**
98 115
  * Infiniband device operations
99 116
  *
@@ -119,7 +136,11 @@ struct ib_device_operations {
119 136
 			      struct ib_queue_pair *qp );
120 137
 };
121 138
 
122
-
139
+/** An Infiniband device */
140
+struct ib_device {	
141
+	/** Driver private data */
142
+	void *priv;
143
+};
123 144
 
124 145
 
125 146
 

正在加载...
取消
保存