Pārlūkot izejas kodu

[forcedeth] Add support for newer forcedeth NICs

Also adds the MAC_ADDR_CORRECT flag, to indicate whether or not the
MAC address needs to be fixed up by the driver.

Signed-off-by: Michael Brown <mcb30@etherboot.org>
tags/v0.9.8
Thomas Miletich 15 gadus atpakaļ
vecāks
revīzija
03ff8cd3e2
1 mainītis faili ar 34 papildinājumiem un 7 dzēšanām
  1. 34
    7
      src/drivers/net/forcedeth.c

+ 34
- 7
src/drivers/net/forcedeth.c Parādīt failu

@@ -379,6 +379,9 @@ enum {
379 379
 #define LPA_1000FULL	0x0800
380 380
 #define LPA_1000HALF	0x0400
381 381
 
382
+/* Bit to know if MAC addr is stored in correct order */
383
+#define MAC_ADDR_CORRECT	0x01
384
+
382 385
 /* Big endian: should work, but is untested */
383 386
 struct ring_desc {
384 387
 	u32 PacketBuffer;
@@ -1241,6 +1244,9 @@ static int forcedeth_probe ( struct nic *nic, struct pci_device *pci ) {
1241 1244
 	int sz;
1242 1245
 	u8 *base;
1243 1246
 	int i;
1247
+	struct pci_device_id *ids = pci->driver->ids;
1248
+	int id_count = pci->driver->id_count;
1249
+	unsigned int flags = 0;
1244 1250
 
1245 1251
 	if (pci->ioaddr == 0)
1246 1252
 		return 0;
@@ -1280,12 +1286,31 @@ static int forcedeth_probe ( struct nic *nic, struct pci_device *pci ) {
1280 1286
 	np->orig_mac[0] = readl(base + NvRegMacAddrA);
1281 1287
 	np->orig_mac[1] = readl(base + NvRegMacAddrB);
1282 1288
 
1283
-	nic->node_addr[0] = (np->orig_mac[1] >> 8) & 0xff;
1284
-	nic->node_addr[1] = (np->orig_mac[1] >> 0) & 0xff;
1285
-	nic->node_addr[2] = (np->orig_mac[0] >> 24) & 0xff;
1286
-	nic->node_addr[3] = (np->orig_mac[0] >> 16) & 0xff;
1287
-	nic->node_addr[4] = (np->orig_mac[0] >> 8) & 0xff;
1288
-	nic->node_addr[5] = (np->orig_mac[0] >> 0) & 0xff;
1289
+	/* lookup the flags from pci_device_id */
1290
+	for(i = 0; i < id_count; i++) {
1291
+		if(pci->vendor == ids[i].vendor &&
1292
+		   pci->device == ids[i].device) {
1293
+			flags = ids[i].driver_data;
1294
+			break;
1295
+		   }
1296
+	}
1297
+
1298
+	/* read MAC address */
1299
+	if(flags & MAC_ADDR_CORRECT) {
1300
+		nic->node_addr[0] = (np->orig_mac[0] >>  0) & 0xff;
1301
+		nic->node_addr[1] = (np->orig_mac[0] >>  8) & 0xff;
1302
+		nic->node_addr[2] = (np->orig_mac[0] >> 16) & 0xff;
1303
+		nic->node_addr[3] = (np->orig_mac[0] >> 24) & 0xff;
1304
+		nic->node_addr[4] = (np->orig_mac[1] >>  0) & 0xff;
1305
+		nic->node_addr[5] = (np->orig_mac[1] >>  8) & 0xff;
1306
+	} else {
1307
+		nic->node_addr[0] = (np->orig_mac[1] >>  8) & 0xff;
1308
+		nic->node_addr[1] = (np->orig_mac[1] >>  0) & 0xff;
1309
+		nic->node_addr[2] = (np->orig_mac[0] >> 24) & 0xff;
1310
+		nic->node_addr[3] = (np->orig_mac[0] >> 16) & 0xff;
1311
+		nic->node_addr[4] = (np->orig_mac[0] >>  8) & 0xff;
1312
+		nic->node_addr[5] = (np->orig_mac[0] >>  0) & 0xff;
1313
+	}
1289 1314
 #ifdef LINUX
1290 1315
 	if (!is_valid_ether_addr(dev->dev_addr)) {
1291 1316
 		/*
@@ -1423,7 +1448,9 @@ PCI_ROM(0x10de, 0x0056, "nforce8", "nForce NVENET_8 Ethernet Controller", 0),
1423 1448
 PCI_ROM(0x10de, 0x0057, "nforce9", "nForce NVENET_9 Ethernet Controller", 0),
1424 1449
 PCI_ROM(0x10de, 0x0037, "nforce10", "nForce NVENET_10 Ethernet Controller", 0),
1425 1450
 PCI_ROM(0x10de, 0x0038, "nforce11", "nForce NVENET_11 Ethernet Controller", 0),
1426
-PCI_ROM(0x10de, 0x0373, "nforce15", "nForce NVENET_15 Ethernet Controller", 0)
1451
+PCI_ROM(0x10de, 0x0373, "nforce15", "nForce NVENET_15 Ethernet Controller", 0),
1452
+PCI_ROM(0x10de, 0x0269, "nforce16", "nForce NVENET_16 Ethernet Controller", 0),
1453
+PCI_ROM(0x10de, 0x0760, "nforce17", "nForce NVENET_17 Ethernet Controller", MAC_ADDR_CORRECT),
1427 1454
 };
1428 1455
 
1429 1456
 PCI_DRIVER ( forcedeth_driver, forcedeth_nics, PCI_NO_CLASS );

Notiek ielāde…
Atcelt
Saglabāt