Browse Source

[MTNIC] Minor cleanups of vendor-provided driver for Mellanox 10GigE cards

Drivers are not allowed to call printf().  Converted eprintf() to DBG(),
and removed spurious startup banner.

Fixed hardcoded inclusion of little_bswap.h

Use EIO rather than 1 as an error number.
tags/v0.9.4
Michael Brown 16 years ago
parent
commit
3430226d40
3 changed files with 78 additions and 88 deletions
  1. 77
    80
      src/drivers/net/mtnic.c
  2. 0
    8
      src/drivers/net/mtnic.h
  3. 1
    0
      src/include/gpxe/errfile.h

+ 77
- 80
src/drivers/net/mtnic.c View File

35
 #include <errno.h>
35
 #include <errno.h>
36
 #include <gpxe/malloc.h>
36
 #include <gpxe/malloc.h>
37
 #include <gpxe/umalloc.h>
37
 #include <gpxe/umalloc.h>
38
-#include <bits/byteswap.h>
39
-#include <little_bswap.h>
38
+#include <byteswap.h>
40
 #include <unistd.h>
39
 #include <unistd.h>
41
 #include <gpxe/pci.h>
40
 #include <gpxe/pci.h>
42
 #include <gpxe/ethernet.h>
41
 #include <gpxe/ethernet.h>
54
 */
53
 */
55
 
54
 
56
 
55
 
56
+/* (mcb30) - The Mellanox driver used "1" as a universal error code;
57
+ * this at least makes it a valid error number.
58
+ */
59
+#define MTNIC_ERROR -EIO
57
 
60
 
58
 
61
 
59
 /** Set port number to use
62
 /** Set port number to use
108
 
111
 
109
 	priv->hcr = ioremap(bar + MTNIC_HCR_BASE, MTNIC_HCR_SIZE);
112
 	priv->hcr = ioremap(bar + MTNIC_HCR_BASE, MTNIC_HCR_SIZE);
110
 	if (!priv->hcr) {
113
 	if (!priv->hcr) {
111
-		eprintf("Couldn't map command register.");
114
+		DBG("Couldn't map command register.");
112
 		return MTNIC_ERROR;
115
 		return MTNIC_ERROR;
113
 	}
116
 	}
114
 	mtnic_alloc_aligned(PAGE_SIZE, (void *)&priv->cmd.buf, &priv->cmd.mapping, PAGE_SIZE);
117
 	mtnic_alloc_aligned(PAGE_SIZE, (void *)&priv->cmd.buf, &priv->cmd.mapping, PAGE_SIZE);
115
 	if (!priv->cmd.buf) {
118
 	if (!priv->cmd.buf) {
116
-		eprintf("Error in allocating buffer for command interface\n");
119
+		DBG("Error in allocating buffer for command interface\n");
117
 		return MTNIC_ERROR;
120
 		return MTNIC_ERROR;
118
 	}
121
 	}
119
         return 0;
122
         return 0;
153
 		ring->iobuf[index] = alloc_iob(size);
156
 		ring->iobuf[index] = alloc_iob(size);
154
 		if (!&ring->iobuf[index]) {
157
 		if (!&ring->iobuf[index]) {
155
 			if (ring->prod <= (ring->cons + 1)) {
158
 			if (ring->prod <= (ring->cons + 1)) {
156
-				eprintf("Error allocating Rx io "
157
-					"buffer number %lx", index);
159
+				DBG("Error allocating Rx io "
160
+				    "buffer number %lx", index);
158
 				/* In case of error freeing io buffer */
161
 				/* In case of error freeing io buffer */
159
 				mtnic_free_io_buffers(ring);
162
 				mtnic_free_io_buffers(ring);
160
 				return MTNIC_ERROR;
163
 				return MTNIC_ERROR;
208
 	err = mtnic_alloc_aligned(ring->buf_size, (void *)&ring->buf,
211
 	err = mtnic_alloc_aligned(ring->buf_size, (void *)&ring->buf,
209
 			    &ring->dma, PAGE_SIZE);
212
 			    &ring->dma, PAGE_SIZE);
210
         if (err) {
213
         if (err) {
211
-		eprintf("Failed allocating descriptor ring sizeof %lx\n",
212
-			ring->buf_size);
214
+		DBG("Failed allocating descriptor ring sizeof %lx\n",
215
+		    ring->buf_size);
213
 		return MTNIC_ERROR;
216
 		return MTNIC_ERROR;
214
 	}
217
 	}
215
         memset(ring->buf, 0, ring->buf_size);
218
         memset(ring->buf, 0, ring->buf_size);
225
 		err = mtnic_alloc_aligned(sizeof(struct mtnic_cq_db_record),
228
 		err = mtnic_alloc_aligned(sizeof(struct mtnic_cq_db_record),
226
 				    (void *)&ring->db, &ring->db_dma, 32);
229
 				    (void *)&ring->db, &ring->db_dma, 32);
227
 		if (err) {
230
 		if (err) {
228
-			eprintf("Failed allocating Rx ring doorbell record\n");
231
+			DBG("Failed allocating Rx ring doorbell record\n");
229
 			free(ring->buf);
232
 			free(ring->buf);
230
 			return MTNIC_ERROR;
233
 			return MTNIC_ERROR;
231
 		}
234
 		}
243
 		/* Alloc IO_BUFFERS */
246
 		/* Alloc IO_BUFFERS */
244
 		err = mtnic_alloc_iobuf(priv, ring, DEF_IOBUF_SIZE);
247
 		err = mtnic_alloc_iobuf(priv, ring, DEF_IOBUF_SIZE);
245
 		if (err) {
248
 		if (err) {
246
-			eprintf("ERROR Allocating io buffer");
249
+			DBG("ERROR Allocating io buffer");
247
 			free(ring->buf);
250
 			free(ring->buf);
248
 			return MTNIC_ERROR;
251
 			return MTNIC_ERROR;
249
 		}
252
 		}
260
 
263
 
261
 		/* Map Tx+CQ doorbells */
264
 		/* Map Tx+CQ doorbells */
262
 		DBG("Mapping TxCQ doorbell at offset:0x%lx\n",
265
 		DBG("Mapping TxCQ doorbell at offset:0x%lx\n",
263
-			priv->fw.txcq_db_offset);
266
+		    priv->fw.txcq_db_offset);
264
 		ring->txcq_db = ioremap(mtnic_pci_dev.dev.bar[2] +
267
 		ring->txcq_db = ioremap(mtnic_pci_dev.dev.bar[2] +
265
 				priv->fw.txcq_db_offset, PAGE_SIZE);
268
 				priv->fw.txcq_db_offset, PAGE_SIZE);
266
 		if (!ring->txcq_db) {
269
 		if (!ring->txcq_db) {
267
-			eprintf("Couldn't map txcq doorbell, aborting...\n");
270
+			DBG("Couldn't map txcq doorbell, aborting...\n");
268
 			free(ring->buf);
271
 			free(ring->buf);
269
 			return MTNIC_ERROR;
272
 			return MTNIC_ERROR;
270
 		}
273
 		}
299
 	err = mtnic_alloc_aligned(sizeof(struct mtnic_cq_db_record),
302
 	err = mtnic_alloc_aligned(sizeof(struct mtnic_cq_db_record),
300
 			    (void *)&cq->db, &cq->db_dma, 32);
303
 			    (void *)&cq->db, &cq->db_dma, 32);
301
 	if (err) {
304
 	if (err) {
302
-		eprintf("Failed allocating CQ doorbell record\n");
305
+		DBG("Failed allocating CQ doorbell record\n");
303
 		return MTNIC_ERROR;
306
 		return MTNIC_ERROR;
304
 	}
307
 	}
305
 	memset(cq->db, 0, sizeof(struct mtnic_cq_db_record));
308
 	memset(cq->db, 0, sizeof(struct mtnic_cq_db_record));
309
 	err = mtnic_alloc_aligned(cq->buf_size,
312
 	err = mtnic_alloc_aligned(cq->buf_size,
310
 			    (void *)&cq->buf, &cq->dma, PAGE_SIZE);
313
 			    (void *)&cq->buf, &cq->dma, PAGE_SIZE);
311
 	if (err) {
314
 	if (err) {
312
-		eprintf("Failed allocating CQ buffer\n");
315
+		DBG("Failed allocating CQ buffer\n");
313
 		free(cq->db);
316
 		free(cq->db);
314
 		return MTNIC_ERROR;
317
 		return MTNIC_ERROR;
315
 	}
318
 	}
316
         memset(cq->buf, 0, cq->buf_size);
319
         memset(cq->buf, 0, cq->buf_size);
317
         DBG("Allocated CQ (addr:%p) - size:%lx buf:%p buf_size:%lx "
320
         DBG("Allocated CQ (addr:%p) - size:%lx buf:%p buf_size:%lx "
318
-		"dma:%lx db:%p db_dma:%lx\n"
319
-		"cqn offset:%lx \n", cq, cq->size, cq->buf,
320
-		cq->buf_size, cq->dma, cq->db,
321
-		cq->db_dma, offset_ind);
321
+	    "dma:%lx db:%p db_dma:%lx\n"
322
+	    "cqn offset:%lx \n", cq, cq->size, cq->buf,
323
+	    cq->buf_size, cq->dma, cq->db,
324
+	    cq->db_dma, offset_ind);
322
 
325
 
323
 
326
 
324
 	/* Set ownership of all CQEs to HW */
327
 	/* Set ownership of all CQEs to HW */
349
         err = mtnic_alloc_cq(dev, cq_ind, &priv->cq[cq_ind], 1 /* RX */,
352
         err = mtnic_alloc_cq(dev, cq_ind, &priv->cq[cq_ind], 1 /* RX */,
350
 			     UNITS_BUFFER_SIZE, cq_offset + cq_ind);
353
 			     UNITS_BUFFER_SIZE, cq_offset + cq_ind);
351
 	if (err) {
354
 	if (err) {
352
-		eprintf("Failed allocating Rx CQ\n");
355
+		DBG("Failed allocating Rx CQ\n");
353
 		return MTNIC_ERROR;
356
 		return MTNIC_ERROR;
354
 	}
357
 	}
355
 
358
 
357
 	err = mtnic_alloc_ring(priv, &priv->rx_ring, UNITS_BUFFER_SIZE,
360
 	err = mtnic_alloc_ring(priv, &priv->rx_ring, UNITS_BUFFER_SIZE,
358
 			       sizeof(struct mtnic_rx_desc), cq_ind, /* RX */1);
361
 			       sizeof(struct mtnic_rx_desc), cq_ind, /* RX */1);
359
 	if (err) {
362
 	if (err) {
360
-		eprintf("Failed allocating Rx Ring\n");
363
+		DBG("Failed allocating Rx Ring\n");
361
 		goto cq0_error;
364
 		goto cq0_error;
362
 	}
365
 	}
363
 
366
 
367
 	err = mtnic_alloc_cq(dev, cq_ind, &priv->cq[cq_ind], 0 /* TX */,
370
 	err = mtnic_alloc_cq(dev, cq_ind, &priv->cq[cq_ind], 0 /* TX */,
368
 			     UNITS_BUFFER_SIZE, cq_offset + cq_ind);
371
 			     UNITS_BUFFER_SIZE, cq_offset + cq_ind);
369
 	if (err) {
372
 	if (err) {
370
-		eprintf("Failed allocating Tx CQ\n");
373
+		DBG("Failed allocating Tx CQ\n");
371
 		goto rx_error;
374
 		goto rx_error;
372
 	}
375
 	}
373
 
376
 
375
 	err = mtnic_alloc_ring(priv, &priv->tx_ring, UNITS_BUFFER_SIZE,
378
 	err = mtnic_alloc_ring(priv, &priv->tx_ring, UNITS_BUFFER_SIZE,
376
 			       sizeof(struct mtnic_tx_desc), cq_ind, /* TX */ 0);
379
 			       sizeof(struct mtnic_tx_desc), cq_ind, /* TX */ 0);
377
 	if (err) {
380
 	if (err) {
378
-		eprintf("Failed allocating Tx ring\n");
381
+		DBG("Failed allocating Tx ring\n");
379
 		goto cq1_error;
382
 		goto cq1_error;
380
 	}
383
 	}
381
 
384
 
412
 	priv->eq_db = ioremap(mtnic_pci_dev.dev.bar[2] +
415
 	priv->eq_db = ioremap(mtnic_pci_dev.dev.bar[2] +
413
 			      priv->fw.eq_db_offset, sizeof(u32));
416
 			      priv->fw.eq_db_offset, sizeof(u32));
414
 	if (!priv->eq_db) {
417
 	if (!priv->eq_db) {
415
-		eprintf("Couldn't map EQ doorbell, aborting...\n");
418
+		DBG("Couldn't map EQ doorbell, aborting...\n");
416
 		return MTNIC_ERROR;
419
 		return MTNIC_ERROR;
417
 	}
420
 	}
418
 
421
 
422
         err = mtnic_alloc_aligned(priv->eq.buf_size, (void *)&priv->eq.buf,
425
         err = mtnic_alloc_aligned(priv->eq.buf_size, (void *)&priv->eq.buf,
423
 			    &priv->eq.dma, PAGE_SIZE);
426
 			    &priv->eq.dma, PAGE_SIZE);
424
 	if (err) {
427
 	if (err) {
425
-		eprintf("Failed allocating EQ buffer\n");
428
+		DBG("Failed allocating EQ buffer\n");
426
 		iounmap(priv->eq_db);
429
 		iounmap(priv->eq_db);
427
 		return MTNIC_ERROR;
430
 		return MTNIC_ERROR;
428
 	}
431
 	}
470
 		}
473
 		}
471
 	}
474
 	}
472
 
475
 
473
-	eprintf("Invalid tbit after %d retries!\n", TBIT_RETRIES);
476
+	DBG("Invalid tbit after %d retries!\n", TBIT_RETRIES);
474
 	return 1; /* Return busy... */
477
 	return 1; /* Return busy... */
475
 }
478
 }
476
 
479
 
495
 	token++;
498
 	token++;
496
 
499
 
497
 	if (cmdif_go_bit(priv)) {
500
 	if (cmdif_go_bit(priv)) {
498
-		eprintf("GO BIT BUSY:%p.\n", hcr + 6);
501
+		DBG("GO BIT BUSY:%p.\n", hcr + 6);
499
 		err = MTNIC_ERROR;
502
 		err = MTNIC_ERROR;
500
 		goto out;
503
 		goto out;
501
 	}
504
 	}
529
 	}
532
 	}
530
 
533
 
531
 	if (cmdif_go_bit(priv)) {
534
 	if (cmdif_go_bit(priv)) {
532
-		eprintf("Command opcode:0x%x token:0x%x TIMEOUT.\n", op, token);
535
+		DBG("Command opcode:0x%x token:0x%x TIMEOUT.\n", op, token);
533
 		err = MTNIC_ERROR;
536
 		err = MTNIC_ERROR;
534
 		goto out;
537
 		goto out;
535
 	}
538
 	}
570
 	DBG("Mapping pages: size: %lx address: %p\n", pages.num, pages.buf);
573
 	DBG("Mapping pages: size: %lx address: %p\n", pages.num, pages.buf);
571
 
574
 
572
 	if (addr & (PAGE_MASK)) {
575
 	if (addr & (PAGE_MASK)) {
573
-		eprintf("Got FW area not aligned to %d (%llx/%x)\n",
574
-			   PAGE_SIZE, (u64) addr, len);
576
+		DBG("Got FW area not aligned to %d (%llx/%x)\n",
577
+		    PAGE_SIZE, (u64) addr, len);
575
 		return MTNIC_ERROR;
578
 		return MTNIC_ERROR;
576
 	}
579
 	}
577
 
580
 
687
 	if (!err) {
690
 	if (!err) {
688
 		flags = be32_to_cpu(heart_beat.flags);
691
 		flags = be32_to_cpu(heart_beat.flags);
689
 		if (flags & MTNIC_BC_MASK(MTNIC_MASK_HEAR_BEAT_INT_ERROR)) {
692
 		if (flags & MTNIC_BC_MASK(MTNIC_MASK_HEAR_BEAT_INT_ERROR)) {
690
-			eprintf("Internal error detected\n");
693
+			DBG("Internal error detected\n");
691
 			return MTNIC_ERROR;
694
 			return MTNIC_ERROR;
692
 		}
695
 		}
693
 		*link_state = flags &
696
 		*link_state = flags &
746
 	config_cq->db_record_addr_l = cpu_to_be32(cq->db_dma);
749
 	config_cq->db_record_addr_l = cpu_to_be32(cq->db_dma);
747
         config_cq->page_address[1] = cpu_to_be32(cq->dma);
750
         config_cq->page_address[1] = cpu_to_be32(cq->dma);
748
 	DBG("config cq address: %lx dma_address: %lx"
751
 	DBG("config cq address: %lx dma_address: %lx"
749
-		"offset: %d size %d index: %d "
750
-		, config_cq->page_address[1],cq->dma,
751
-		config_cq->offset, config_cq->size, config_cq->cq );
752
+	    "offset: %d size %d index: %d "
753
+	    , config_cq->page_address[1],cq->dma,
754
+	    config_cq->offset, config_cq->size, config_cq->cq );
752
 
755
 
753
 	return mtnic_cmd(priv, NULL, NULL, port + 1,
756
 	return mtnic_cmd(priv, NULL, NULL, port + 1,
754
 			       MTNIC_IF_CMD_CONFIG_CQ);
757
 			       MTNIC_IF_CMD_CONFIG_CQ);
798
 	struct mtnic_if_config_eq_in_mbox *eq = priv->cmd.buf;
801
 	struct mtnic_if_config_eq_in_mbox *eq = priv->cmd.buf;
799
 
802
 
800
 	if (priv->eq.dma & (PAGE_MASK)) {
803
 	if (priv->eq.dma & (PAGE_MASK)) {
801
-		eprintf("misalligned eq buffer:%lx\n",
802
-			priv->eq.dma);
804
+		DBG("misalligned eq buffer:%lx\n",
805
+		    priv->eq.dma);
803
 		return MTNIC_ERROR;
806
 		return MTNIC_ERROR;
804
         }
807
         }
805
 
808
 
897
 	*((u32*)result + 1) = be32_to_cpu(*out_imm);
900
 	*((u32*)result + 1) = be32_to_cpu(*out_imm);
898
 
901
 
899
 	DBG("Called Query cap with index:0x%x mod:%d result:0x%llx"
902
 	DBG("Called Query cap with index:0x%x mod:%d result:0x%llx"
900
-		  " error:%d\n", index, mod, *result, err);
903
+	    " error:%d\n", index, mod, *result, err);
901
 	return err;
904
 	return err;
902
 }
905
 }
903
 
906
 
1028
 					   &mtnic_pci_dev.dev.
1031
 					   &mtnic_pci_dev.dev.
1029
 					   dev_config_space[i]);
1032
 					   dev_config_space[i]);
1030
 		if (err) {
1033
 		if (err) {
1031
-			eprintf("Can not save configuration space");
1034
+			DBG("Can not save configuration space");
1032
 			return err;
1035
 			return err;
1033
 		}
1036
 		}
1034
 	}
1037
 	}
1056
         /* Alloc command interface */
1059
         /* Alloc command interface */
1057
 	err = mtnic_alloc_cmdif(priv);
1060
 	err = mtnic_alloc_cmdif(priv);
1058
 	if (err) {
1061
 	if (err) {
1059
-		eprintf("Failed to init command interface, aborting.\n");
1062
+		DBG("Failed to init command interface, aborting.\n");
1060
 		return MTNIC_ERROR;
1063
 		return MTNIC_ERROR;
1061
 	}
1064
 	}
1062
 
1065
 
1067
 	 */
1070
 	 */
1068
 	err = mtnic_QUERY_FW(priv);
1071
 	err = mtnic_QUERY_FW(priv);
1069
 	if (err) {
1072
 	if (err) {
1070
-		eprintf("QUERY_FW command failed, aborting.\n");
1073
+		DBG("QUERY_FW command failed, aborting.\n");
1071
 		goto cmd_error;
1074
 		goto cmd_error;
1072
 	}
1075
 	}
1073
 
1076
 
1076
 	/* Allocate memory for FW and start it */
1079
 	/* Allocate memory for FW and start it */
1077
 	err = mtnic_map_cmd(priv, MTNIC_IF_CMD_MAP_FW, priv->fw.fw_pages);
1080
 	err = mtnic_map_cmd(priv, MTNIC_IF_CMD_MAP_FW, priv->fw.fw_pages);
1078
 	if (err) {
1081
 	if (err) {
1079
-		eprintf("Eror In MAP_FW\n");
1082
+		DBG("Eror In MAP_FW\n");
1080
 		if (priv->fw.fw_pages.buf)
1083
 		if (priv->fw.fw_pages.buf)
1081
 			free(priv->fw.fw_pages.buf);
1084
 			free(priv->fw.fw_pages.buf);
1082
 		goto cmd_error;
1085
 		goto cmd_error;
1085
 	/* Run firmware */
1088
 	/* Run firmware */
1086
 	err = mtnic_cmd(priv, NULL, NULL, 0, MTNIC_IF_CMD_RUN_FW);
1089
 	err = mtnic_cmd(priv, NULL, NULL, 0, MTNIC_IF_CMD_RUN_FW);
1087
 	if (err) {
1090
 	if (err) {
1088
-		eprintf("Eror In RUN FW\n");
1091
+		DBG("Eror In RUN FW\n");
1089
 		goto map_fw_error;
1092
 		goto map_fw_error;
1090
 	}
1093
 	}
1091
 
1094
 
1092
         DBG("FW version:%d.%d.%d\n",
1095
         DBG("FW version:%d.%d.%d\n",
1093
-		(u16) (priv->fw_ver >> 32),
1096
+	    (u16) (priv->fw_ver >> 32),
1094
 		(u16) ((priv->fw_ver >> 16) & 0xffff),
1097
 		(u16) ((priv->fw_ver >> 16) & 0xffff),
1095
 		(u16) (priv->fw_ver & 0xffff));
1098
 		(u16) (priv->fw_ver & 0xffff));
1096
 
1099
 
1098
 	/* Get device information */
1101
 	/* Get device information */
1099
 	err = mtnic_query_cap(priv);
1102
 	err = mtnic_query_cap(priv);
1100
 	if (err) {
1103
 	if (err) {
1101
-		eprintf("Insufficient resources, aborting.\n");
1104
+		DBG("Insufficient resources, aborting.\n");
1102
 		goto map_fw_error;
1105
 		goto map_fw_error;
1103
 	}
1106
 	}
1104
 
1107
 
1105
 	/* Open NIC */
1108
 	/* Open NIC */
1106
 	err = mtnic_OPEN_NIC(priv);
1109
 	err = mtnic_OPEN_NIC(priv);
1107
 	if (err) {
1110
 	if (err) {
1108
-		eprintf("Failed opening NIC, aborting.\n");
1111
+		DBG("Failed opening NIC, aborting.\n");
1109
 		goto map_fw_error;
1112
 		goto map_fw_error;
1110
 	}
1113
 	}
1111
 
1114
 
1112
 	/* Allocate and map pages worksace */
1115
 	/* Allocate and map pages worksace */
1113
 	err = mtnic_map_cmd(priv, MTNIC_IF_CMD_MAP_PAGES, priv->fw.extra_pages);
1116
 	err = mtnic_map_cmd(priv, MTNIC_IF_CMD_MAP_PAGES, priv->fw.extra_pages);
1114
 	if (err) {
1117
 	if (err) {
1115
-		eprintf("Couldn't allocate %lx FW extra pages, aborting.\n",
1116
-			priv->fw.extra_pages.num);
1118
+		DBG("Couldn't allocate %lx FW extra pages, aborting.\n",
1119
+		    priv->fw.extra_pages.num);
1117
 		if (priv->fw.extra_pages.buf)
1120
 		if (priv->fw.extra_pages.buf)
1118
 			free(priv->fw.extra_pages.buf);
1121
 			free(priv->fw.extra_pages.buf);
1119
 		goto map_fw_error;
1122
 		goto map_fw_error;
1122
 	/* Get device offsets */
1125
 	/* Get device offsets */
1123
 	err = mtnic_query_offsets(priv);
1126
 	err = mtnic_query_offsets(priv);
1124
 	if (err) {
1127
 	if (err) {
1125
-		eprintf("Failed retrieving resource offests, aborting.\n");
1128
+		DBG("Failed retrieving resource offests, aborting.\n");
1126
 		free(priv->fw.extra_pages.buf);
1129
 		free(priv->fw.extra_pages.buf);
1127
 		goto map_extra_error;
1130
 		goto map_extra_error;
1128
 	}
1131
 	}
1131
         /* Alloc EQ */
1134
         /* Alloc EQ */
1132
 	err = mtnic_alloc_eq(priv);
1135
 	err = mtnic_alloc_eq(priv);
1133
 	if (err) {
1136
 	if (err) {
1134
-		eprintf("Failed init shared resources. error: %d\n", err);
1137
+		DBG("Failed init shared resources. error: %d\n", err);
1135
 		goto map_extra_error;
1138
 		goto map_extra_error;
1136
         }
1139
         }
1137
 
1140
 
1138
 	/* Configure HW */
1141
 	/* Configure HW */
1139
 	err = mtnic_CONFIG_EQ(priv);
1142
 	err = mtnic_CONFIG_EQ(priv);
1140
 	if (err) {
1143
 	if (err) {
1141
-		eprintf("Failed configuring EQ\n");
1144
+		DBG("Failed configuring EQ\n");
1142
 		goto eq_error;
1145
 		goto eq_error;
1143
 	}
1146
 	}
1144
 	err = mtnic_CONFIG_RX(priv);
1147
 	err = mtnic_CONFIG_RX(priv);
1145
 	if (err) {
1148
 	if (err) {
1146
-		eprintf("Failed Rx configuration\n");
1149
+		DBG("Failed Rx configuration\n");
1147
 		goto eq_error;
1150
 		goto eq_error;
1148
 	}
1151
 	}
1149
 	err = mtnic_CONFIG_TX(priv);
1152
 	err = mtnic_CONFIG_TX(priv);
1150
 	if (err) {
1153
 	if (err) {
1151
-		eprintf("Failed Tx configuration\n");
1154
+		DBG("Failed Tx configuration\n");
1152
 		goto eq_error;
1155
 		goto eq_error;
1153
 	}
1156
 	}
1154
 
1157
 
1270
 	if (ring->prod - ring->cons < (MAX_GAP_PROD_CONS)) {
1273
 	if (ring->prod - ring->cons < (MAX_GAP_PROD_CONS)) {
1271
 		err = mtnic_alloc_iobuf(priv, &priv->rx_ring, DEF_IOBUF_SIZE);
1274
 		err = mtnic_alloc_iobuf(priv, &priv->rx_ring, DEF_IOBUF_SIZE);
1272
 		if (err) {
1275
 		if (err) {
1273
-			eprintf("ERROR Allocating io buffer");
1276
+			DBG("ERROR Allocating io buffer");
1274
 			return MTNIC_ERROR;
1277
 			return MTNIC_ERROR;
1275
 		}
1278
 		}
1276
 	}
1279
 	}
1316
 	/* Alloc and configure CQs, TX, RX */
1319
 	/* Alloc and configure CQs, TX, RX */
1317
 	err = mtnic_alloc_resources(dev);
1320
 	err = mtnic_alloc_resources(dev);
1318
 	if (err) {
1321
 	if (err) {
1319
-		eprintf("Error allocating resources\n");
1322
+		DBG("Error allocating resources\n");
1320
 		return MTNIC_ERROR;
1323
 		return MTNIC_ERROR;
1321
 	}
1324
 	}
1322
 
1325
 
1325
 		cq = &priv->cq[cq_ind];
1328
 		cq = &priv->cq[cq_ind];
1326
 		err = mtnic_CONFIG_CQ(priv, priv->port, cq_ind, cq);
1329
 		err = mtnic_CONFIG_CQ(priv, priv->port, cq_ind, cq);
1327
 		if (err) {
1330
 		if (err) {
1328
-			eprintf("Failed configuring CQ:%d error %d\n",
1329
-				cq_ind, err);
1331
+			DBG("Failed configuring CQ:%d error %d\n",
1332
+			    cq_ind, err);
1330
 			if (cq_ind)
1333
 			if (cq_ind)
1331
 				goto cq_error;
1334
 				goto cq_error;
1332
 			else
1335
 			else
1341
 	ring = &priv->tx_ring;
1344
 	ring = &priv->tx_ring;
1342
         err = mtnic_CONFIG_TX_RING(priv, priv->port, 0, ring);
1345
         err = mtnic_CONFIG_TX_RING(priv, priv->port, 0, ring);
1343
 	if (err) {
1346
 	if (err) {
1344
-		eprintf("Failed configuring Tx ring:0\n");
1347
+		DBG("Failed configuring Tx ring:0\n");
1345
                 goto cq_error;
1348
                 goto cq_error;
1346
 	}
1349
 	}
1347
 
1350
 
1349
         ring = &priv->rx_ring;
1352
         ring = &priv->rx_ring;
1350
         err = mtnic_CONFIG_RX_RING(priv, priv->port, 0, ring);
1353
         err = mtnic_CONFIG_RX_RING(priv, priv->port, 0, ring);
1351
 	if (err) {
1354
 	if (err) {
1352
-		eprintf("Failed configuring Rx ring:0\n");
1355
+		DBG("Failed configuring Rx ring:0\n");
1353
 		goto tx_error;
1356
 		goto tx_error;
1354
 	}
1357
 	}
1355
 
1358
 
1358
 	if (!err)
1361
 	if (!err)
1359
 		err = mtnic_SET_PORT_RSS_INDIRECTION(priv, priv->port);
1362
 		err = mtnic_SET_PORT_RSS_INDIRECTION(priv, priv->port);
1360
 	if (err) {
1363
 	if (err) {
1361
-		eprintf("Failed configuring RSS steering\n");
1364
+		DBG("Failed configuring RSS steering\n");
1362
 		goto rx_error;
1365
 		goto rx_error;
1363
 	}
1366
 	}
1364
 
1367
 
1365
 	/* Set the port default ring to ring 0 */
1368
 	/* Set the port default ring to ring 0 */
1366
 	err = mtnic_SET_PORT_DEFAULT_RING(priv, priv->port, 0);
1369
 	err = mtnic_SET_PORT_DEFAULT_RING(priv, priv->port, 0);
1367
 	if (err) {
1370
 	if (err) {
1368
-		eprintf("Failed setting default ring\n");
1371
+		DBG("Failed setting default ring\n");
1369
 		goto rx_error;
1372
 		goto rx_error;
1370
 	}
1373
 	}
1371
 
1374
 
1372
 	/* Set Mac address */
1375
 	/* Set Mac address */
1373
 	err = mtnic_SET_RX_RING_ADDR(priv, priv->port, &priv->fw.mac[priv->port]);
1376
 	err = mtnic_SET_RX_RING_ADDR(priv, priv->port, &priv->fw.mac[priv->port]);
1374
 	if (err) {
1377
 	if (err) {
1375
-		eprintf("Failed setting default MAC address\n");
1378
+		DBG("Failed setting default MAC address\n");
1376
 		goto rx_error;
1379
 		goto rx_error;
1377
 	}
1380
 	}
1378
 
1381
 
1379
 	/* Set MTU  */
1382
 	/* Set MTU  */
1380
 	err = mtnic_SET_PORT_MTU(priv, priv->port, DEF_MTU);
1383
 	err = mtnic_SET_PORT_MTU(priv, priv->port, DEF_MTU);
1381
 	if (err) {
1384
 	if (err) {
1382
-		eprintf("Failed setting MTU\n");
1385
+		DBG("Failed setting MTU\n");
1383
 		goto rx_error;
1386
 		goto rx_error;
1384
 	}
1387
 	}
1385
 
1388
 
1386
 	/* Configure VLAN filter */
1389
 	/* Configure VLAN filter */
1387
 	err = mtnic_CONFIG_PORT_VLAN_FILTER(priv, priv->port);
1390
 	err = mtnic_CONFIG_PORT_VLAN_FILTER(priv, priv->port);
1388
         if (err) {
1391
         if (err) {
1389
-		eprintf("Failed configuring VLAN filter\n");
1392
+		DBG("Failed configuring VLAN filter\n");
1390
 		goto rx_error;
1393
 		goto rx_error;
1391
 	}
1394
 	}
1392
 
1395
 
1393
 	/* Bring up physical link */
1396
 	/* Bring up physical link */
1394
 	err = mtnic_SET_PORT_STATE(priv, priv->port, 1);
1397
 	err = mtnic_SET_PORT_STATE(priv, priv->port, 1);
1395
 	if (err) {
1398
 	if (err) {
1396
-		eprintf("Failed bringing up port\n");
1399
+		DBG("Failed bringing up port\n");
1397
 		goto rx_error;
1400
 		goto rx_error;
1398
 	}
1401
 	}
1399
 	mdelay(300); /* Let link state stabilize if cable was connected */
1402
 	mdelay(300); /* Let link state stabilize if cable was connected */
1402
 
1405
 
1403
 	err = mtnic_HEART_BEAT(priv, &dev_link_state);
1406
 	err = mtnic_HEART_BEAT(priv, &dev_link_state);
1404
 	if (err) {
1407
 	if (err) {
1405
-		eprintf("Failed getting device link state\n");
1408
+		DBG("Failed getting device link state\n");
1406
 		return MTNIC_ERROR;
1409
 		return MTNIC_ERROR;
1407
 	}
1410
 	}
1408
 	if (!(dev_link_state & 0x3)) {
1411
 	if (!(dev_link_state & 0x3)) {
1409
-		eprintf("Link down, check cables and restart\n");
1412
+		DBG("Link down, check cables and restart\n");
1410
 		return MTNIC_ERROR;
1413
 		return MTNIC_ERROR;
1411
 	}
1414
 	}
1412
 
1415
 
1453
 		/* Check device */
1456
 		/* Check device */
1454
 		err = mtnic_HEART_BEAT(priv, &dev_link_state);
1457
 		err = mtnic_HEART_BEAT(priv, &dev_link_state);
1455
 		if (err) {
1458
 		if (err) {
1456
-			eprintf("Device has internal error\n");
1459
+			DBG("Device has internal error\n");
1457
 			priv->state = CARD_DOWN;
1460
 			priv->state = CARD_DOWN;
1458
 			return;
1461
 			return;
1459
 		}
1462
 		}
1460
 		if (!(dev_link_state & 0x3)) {
1463
 		if (!(dev_link_state & 0x3)) {
1461
-			eprintf("Link down, check cables and restart\n");
1464
+			DBG("Link down, check cables and restart\n");
1462
 			priv->state = CARD_DOWN;
1465
 			priv->state = CARD_DOWN;
1463
 			return;
1466
 			return;
1464
 		}
1467
 		}
1472
                         err = mtnic_process_rx_cq(priv, cq->dev, cq);
1475
                         err = mtnic_process_rx_cq(priv, cq->dev, cq);
1473
 			if (err) {
1476
 			if (err) {
1474
 				priv->state = CARD_DOWN;
1477
 				priv->state = CARD_DOWN;
1475
-				eprintf(" Error allocating RX buffers\n");
1478
+				DBG(" Error allocating RX buffers\n");
1476
 				return;
1479
 				return;
1477
 			}
1480
 			}
1478
                 } else {
1481
                 } else {
1664
 	void *dev_id;
1667
 	void *dev_id;
1665
 	int i;
1668
 	int i;
1666
 
1669
 
1667
-	if (pci->vendor != MELLANOX_VENDOR_ID) {
1668
-		eprintf("");
1669
-		return 0;
1670
-	}
1671
-	printf("\nMellanox Technologies LTD - Boot over MTNIC implementaion\n");
1672
-
1673
         adjust_pci_device(pci);
1670
         adjust_pci_device(pci);
1674
 
1671
 
1675
         err = mtnic_init_pci(pci);
1672
         err = mtnic_init_pci(pci);
1676
 	if (err) {
1673
 	if (err) {
1677
-		eprintf("Error in pci_init\n");
1674
+		DBG("Error in pci_init\n");
1678
 		return MTNIC_ERROR;
1675
 		return MTNIC_ERROR;
1679
 	}
1676
 	}
1680
 
1677
 
1683
 
1680
 
1684
         err = restore_config();
1681
         err = restore_config();
1685
 	if (err) {
1682
 	if (err) {
1686
-		eprintf("");
1683
+		DBG("Error restoring config\n");
1687
 		return err;
1684
 		return err;
1688
 	}
1685
 	}
1689
 
1686
 
1693
 	result = ntohl(readl(dev_id));
1690
 	result = ntohl(readl(dev_id));
1694
 	iounmap(dev_id);
1691
 	iounmap(dev_id);
1695
         if (result != MTNIC_DEVICE_ID) {
1692
         if (result != MTNIC_DEVICE_ID) {
1696
-		eprintf("Wrong Devie ID (0x%lx) !!!", result);
1693
+		DBG("Wrong Devie ID (0x%lx) !!!", result);
1697
 		return MTNIC_ERROR;
1694
 		return MTNIC_ERROR;
1698
 	}
1695
 	}
1699
 
1696
 
1700
 	/* Initializing net device */
1697
 	/* Initializing net device */
1701
         dev = alloc_etherdev(sizeof(struct mtnic_priv));
1698
         dev = alloc_etherdev(sizeof(struct mtnic_priv));
1702
 	if (dev == NULL) {
1699
 	if (dev == NULL) {
1703
-		eprintf("Net device allocation failed\n");
1700
+		DBG("Net device allocation failed\n");
1704
 		return MTNIC_ERROR;
1701
 		return MTNIC_ERROR;
1705
 	}
1702
 	}
1706
 	/*
1703
 	/*
1719
 	/* Initialize hardware */
1716
 	/* Initialize hardware */
1720
 	err = mtnic_init_card(dev);
1717
 	err = mtnic_init_card(dev);
1721
 	if (err) {
1718
 	if (err) {
1722
-		eprintf("Error in init_card\n");
1719
+		DBG("Error in init_card\n");
1723
 		return MTNIC_ERROR;
1720
 		return MTNIC_ERROR;
1724
 	}
1721
 	}
1725
 
1722
 
1735
 	netdev_link_up ( dev );
1732
 	netdev_link_up ( dev );
1736
 
1733
 
1737
 	if (register_netdev(dev)) {
1734
 	if (register_netdev(dev)) {
1738
-		eprintf("Netdev registration failed\n");
1735
+		DBG("Netdev registration failed\n");
1739
 		return MTNIC_ERROR;
1736
 		return MTNIC_ERROR;
1740
 	}
1737
 	}
1741
 
1738
 

+ 0
- 8
src/drivers/net/mtnic.h View File

57
 #define ROUND_TO_CHECK		0x400
57
 #define ROUND_TO_CHECK		0x400
58
 
58
 
59
 
59
 
60
-/*
61
-* Helper macros
62
-*/
63
-/* Print in case of an error */
64
-#define eprintf(fmt, a...) \
65
-		 printf("%s:%d: " fmt "\n", __func__, __LINE__,  ##a)
66
-
67
 #define XNOR(x,y)		(!(x) == !(y))
60
 #define XNOR(x,y)		(!(x) == !(y))
68
 #define dma_addr_t 		unsigned long
61
 #define dma_addr_t 		unsigned long
69
 #define PAGE_SIZE		4096
62
 #define PAGE_SIZE		4096
70
 #define PAGE_MASK		(PAGE_SIZE - 1)
63
 #define PAGE_MASK		(PAGE_SIZE - 1)
71
 #define MTNIC_MAILBOX_SIZE	PAGE_SIZE
64
 #define MTNIC_MAILBOX_SIZE	PAGE_SIZE
72
-#define MTNIC_ERROR 1
73
 
65
 
74
 
66
 
75
 
67
 

+ 1
- 0
src/include/gpxe/errfile.h View File

104
 #define ERRFILE_ipoib		     ( ERRFILE_DRIVER | 0x00470000 )
104
 #define ERRFILE_ipoib		     ( ERRFILE_DRIVER | 0x00470000 )
105
 #define ERRFILE_e1000		     ( ERRFILE_DRIVER | 0x00480000 )
105
 #define ERRFILE_e1000		     ( ERRFILE_DRIVER | 0x00480000 )
106
 #define ERRFILE_e1000_hw	     ( ERRFILE_DRIVER | 0x00490000 )
106
 #define ERRFILE_e1000_hw	     ( ERRFILE_DRIVER | 0x00490000 )
107
+#define ERRFILE_mtnic		     ( ERRFILE_DRIVER | 0x004a0000 )
107
 
108
 
108
 #define ERRFILE_scsi		     ( ERRFILE_DRIVER | 0x00700000 )
109
 #define ERRFILE_scsi		     ( ERRFILE_DRIVER | 0x00700000 )
109
 #define ERRFILE_arbel		     ( ERRFILE_DRIVER | 0x00710000 )
110
 #define ERRFILE_arbel		     ( ERRFILE_DRIVER | 0x00710000 )

Loading…
Cancel
Save