Kaynağa Gözat

[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 yıl önce
ebeveyn
işleme
3430226d40
3 değiştirilmiş dosya ile 78 ekleme ve 88 silme
  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 Dosyayı Görüntüle

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

+ 0
- 8
src/drivers/net/mtnic.h Dosyayı Görüntüle

@@ -57,19 +57,11 @@
57 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 60
 #define XNOR(x,y)		(!(x) == !(y))
68 61
 #define dma_addr_t 		unsigned long
69 62
 #define PAGE_SIZE		4096
70 63
 #define PAGE_MASK		(PAGE_SIZE - 1)
71 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 Dosyayı Görüntüle

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

Loading…
İptal
Kaydet