Browse Source

eth_ntoa and warnings cleanup

tags/v0.9.3
Marty Connor 18 years ago
parent
commit
0d1087a5de
1 changed files with 44 additions and 54 deletions
  1. 44
    54
      src/drivers/net/tlan.c

+ 44
- 54
src/drivers/net/tlan.c View File

38
 *    Indent Options: indent -kr -i8
38
 *    Indent Options: indent -kr -i8
39
 ***************************************************************************/
39
 ***************************************************************************/
40
 
40
 
41
-/* to get some global routines like printf */
42
 #include "etherboot.h"
41
 #include "etherboot.h"
43
-/* to get the interface to the body of the program */
44
 #include "nic.h"
42
 #include "nic.h"
45
-/* to get the PCI support functions, if this is a PCI NIC */
46
 #include <gpxe/pci.h>
43
 #include <gpxe/pci.h>
44
+#include <gpxe/ethernet.h>
47
 #include "timer.h"
45
 #include "timer.h"
48
 #include "tlan.h"
46
 #include "tlan.h"
49
 
47
 
58
 #define virt_to_le32desc(addr)  cpu_to_le32(virt_to_bus(addr))
56
 #define virt_to_le32desc(addr)  cpu_to_le32(virt_to_bus(addr))
59
 #define le32desc_to_virt(addr)  bus_to_virt(le32_to_cpu(addr))
57
 #define le32desc_to_virt(addr)  bus_to_virt(le32_to_cpu(addr))
60
 
58
 
61
-//#define EDEBUG
62
-#ifdef EDEBUG
63
-#define dprintf(x) printf x
64
-#else
65
-#define dprintf(x)
66
-#endif
67
-
68
 static void TLan_ResetLists(struct nic *nic __unused);
59
 static void TLan_ResetLists(struct nic *nic __unused);
69
 static void TLan_ResetAdapter(struct nic *nic __unused);
60
 static void TLan_ResetAdapter(struct nic *nic __unused);
70
 static void TLan_FinishReset(struct nic *nic __unused);
61
 static void TLan_FinishReset(struct nic *nic __unused);
414
 	if ((tlan_pci_tbl[chip_idx].flags & TLAN_ADAPTER_UNMANAGED_PHY)
405
 	if ((tlan_pci_tbl[chip_idx].flags & TLAN_ADAPTER_UNMANAGED_PHY)
415
 	    || (priv->aui)) {
406
 	    || (priv->aui)) {
416
 		status = MII_GS_LINK;
407
 		status = MII_GS_LINK;
417
-		dprintf(("TLAN:  %s: Link forced.\n", priv->nic_name));
408
+		DBG ( "TLAN:  %s: Link forced.\n", priv->nic_name );
418
 	} else {
409
 	} else {
419
 		TLan_MiiReadReg(nic, phy, MII_GEN_STS, &status);
410
 		TLan_MiiReadReg(nic, phy, MII_GEN_STS, &status);
420
 		udelay(1000);
411
 		udelay(1000);
426
 			TLan_MiiReadReg(nic, phy, TLAN_TLPHY_PAR,
417
 			TLan_MiiReadReg(nic, phy, TLAN_TLPHY_PAR,
427
 					&tlphy_par);
418
 					&tlphy_par);
428
 
419
 
429
-			dprintf(("TLAN: %s: Link active with ",
430
-			       priv->nic_name));
420
+			DBG ( "TLAN: %s: Link active with ",
421
+			       priv->nic_name );
431
 			if (!(tlphy_par & TLAN_PHY_AN_EN_STAT)) {
422
 			if (!(tlphy_par & TLAN_PHY_AN_EN_STAT)) {
432
-				dprintf(("forced 10%sMbps %s-Duplex\n",
423
+				DBG ( "forced 10%sMbps %s-Duplex\n",
433
 				       tlphy_par & TLAN_PHY_SPEED_100 ? ""
424
 				       tlphy_par & TLAN_PHY_SPEED_100 ? ""
434
 				       : "0",
425
 				       : "0",
435
 				       tlphy_par & TLAN_PHY_DUPLEX_FULL ?
426
 				       tlphy_par & TLAN_PHY_DUPLEX_FULL ?
436
-				       "Full" : "Half"));
427
+				       "Full" : "Half" );
437
 			} else {
428
 			} else {
438
-				dprintf
439
-				    (("AutoNegotiation enabled, at 10%sMbps %s-Duplex\n",
429
+				DBG 
430
+				    ( "AutoNegotiation enabled, at 10%sMbps %s-Duplex\n",
440
 				     tlphy_par & TLAN_PHY_SPEED_100 ? "" :
431
 				     tlphy_par & TLAN_PHY_SPEED_100 ? "" :
441
 				     "0",
432
 				     "0",
442
 				     tlphy_par & TLAN_PHY_DUPLEX_FULL ?
433
 				     tlphy_par & TLAN_PHY_DUPLEX_FULL ?
443
-				     "Full" : "Half"));
444
-				dprintf(("TLAN: Partner capability: "));
434
+				     "Full" : "Half" );
435
+				DBG ( "TLAN: Partner capability: " );
445
 				for (i = 5; i <= 10; i++)
436
 				for (i = 5; i <= 10; i++)
446
 					if (partner & (1 << i)) {
437
 					if (partner & (1 << i)) {
447
-						dprintf(("%s", media[i - 5]));
438
+						DBG ( "%s", media[i - 5] );
448
 					}
439
 					}
449
-				dprintf(("\n"));
440
+				DBG ( "\n" );
450
 			}
441
 			}
451
 
442
 
452
 			TLan_DioWrite8(BASE, TLAN_LED_REG, TLAN_LED_LINK);
443
 			TLan_DioWrite8(BASE, TLAN_LED_REG, TLAN_LED_LINK);
459
 			TLan_PhyMonitor(nic);
450
 			TLan_PhyMonitor(nic);
460
 #endif
451
 #endif
461
 		} else if (status & MII_GS_LINK) {
452
 		} else if (status & MII_GS_LINK) {
462
-			dprintf(("TLAN: %s: Link active\n", priv->nic_name));
453
+			DBG ( "TLAN: %s: Link active\n", priv->nic_name );
463
 			TLan_DioWrite8(BASE, TLAN_LED_REG, TLAN_LED_LINK);
454
 			TLan_DioWrite8(BASE, TLAN_LED_REG, TLAN_LED_LINK);
464
 		}
455
 		}
465
 	}
456
 	}
480
 		outl(virt_to_bus(&rx_ring), BASE + TLAN_CH_PARM);
471
 		outl(virt_to_bus(&rx_ring), BASE + TLAN_CH_PARM);
481
 		outl(TLAN_HC_GO | TLAN_HC_RT, BASE + TLAN_HOST_CMD);
472
 		outl(TLAN_HC_GO | TLAN_HC_RT, BASE + TLAN_HOST_CMD);
482
 	} else {
473
 	} else {
483
-		dprintf
484
-		    (("TLAN: %s: Link inactive, will retry in 10 secs...\n",
485
-		     priv->nic_name));
474
+		DBG 
475
+		    ( "TLAN: %s: Link inactive, will retry in 10 secs...\n",
476
+		     priv->nic_name );
486
 		/* TLan_SetTimer( nic, (10*HZ), TLAN_TIMER_FINISH_RESET ); */
477
 		/* TLan_SetTimer( nic, (10*HZ), TLAN_TIMER_FINISH_RESET ); */
487
 		mdelay(10000);
478
 		mdelay(10000);
488
 		TLan_FinishReset(nic);
479
 		TLan_FinishReset(nic);
524
 
515
 
525
 	nic->packetlen = framesize;
516
 	nic->packetlen = framesize;
526
 
517
 
527
-	dprintf((".%d.", framesize)); 
518
+	DBG ( ".%d.", framesize ); 
528
      
519
      
529
 	memcpy(nic->packet, rxb +
520
 	memcpy(nic->packet, rxb +
530
 	       (priv->cur_rx * TLAN_MAX_FRAME_SIZE), nic->packetlen);
521
 	       (priv->cur_rx * TLAN_MAX_FRAME_SIZE), nic->packetlen);
531
 
522
 
532
 	rx_ring[entry].cStat = 0;
523
 	rx_ring[entry].cStat = 0;
533
 
524
 
534
-	dprintf(("%d", entry));  
525
+	DBG ( "%d", entry );  
535
 
526
 
536
 	entry = (entry + 1) % TLAN_NUM_RX_LISTS;
527
 	entry = (entry + 1) % TLAN_NUM_RX_LISTS;
537
 	priv->cur_rx = entry;
528
 	priv->cur_rx = entry;
546
 		host_cmd = TLAN_HC_ACK | ack | (0x000C0000);
537
 		host_cmd = TLAN_HC_ACK | ack | (0x000C0000);
547
 		outl(host_cmd, BASE + TLAN_HOST_CMD);
538
 		outl(host_cmd, BASE + TLAN_HOST_CMD);
548
 		
539
 		
549
-		dprintf(("AC: 0x%hX\n", inw(BASE + TLAN_CH_PARM))); 
550
-		dprintf(("PI-2: 0x%hX\n", inw(BASE + TLAN_HOST_INT)));
540
+		DBG ( "AC: 0x%hX\n", inw(BASE + TLAN_CH_PARM) ); 
541
+		DBG ( "PI-2: 0x%hX\n", inw(BASE + TLAN_HOST_INT) );
551
 	}
542
 	}
552
 	refill_rx(nic);
543
 	refill_rx(nic);
553
 	return (1);		/* initially as this is called to flush the input */
544
 	return (1);		/* initially as this is called to flush the input */
585
 	u32 host_cmd;
576
 	u32 host_cmd;
586
 	int eoc = 0;
577
 	int eoc = 0;
587
 	u16 tmpCStat;
578
 	u16 tmpCStat;
588
-#ifdef EBDEBUG
589
 	u16 host_int = inw(BASE + TLAN_HOST_INT);
579
 	u16 host_int = inw(BASE + TLAN_HOST_INT);
590
-#endif
580
+
591
 	int entry = 0;
581
 	int entry = 0;
592
 
582
 
593
-	dprintf(("INT0-0x%hX\n", host_int));
583
+	DBG ( "INT0-0x%hX\n", host_int );
594
 
584
 
595
 	if (!priv->phyOnline) {
585
 	if (!priv->phyOnline) {
596
 		printf("TRANSMIT:  %s PHY is not ready\n", priv->nic_name);
586
 		printf("TRANSMIT:  %s PHY is not ready\n", priv->nic_name);
600
 	tail_list = priv->txList + priv->txTail;
590
 	tail_list = priv->txList + priv->txTail;
601
 
591
 
602
 	if (tail_list->cStat != TLAN_CSTAT_UNUSED) {
592
 	if (tail_list->cStat != TLAN_CSTAT_UNUSED) {
603
-		printf("TRANSMIT: %s is busy (Head=%d Tail=%d)\n",
593
+		printf("TRANSMIT: %s is busy (Head=%p Tail=%x)\n",
604
 		       priv->nic_name, priv->txList, priv->txTail);
594
 		       priv->nic_name, priv->txList, priv->txTail);
605
 		tx_ring[entry].cStat = TLAN_CSTAT_UNUSED;
595
 		tx_ring[entry].cStat = TLAN_CSTAT_UNUSED;
606
 //		priv->txBusyCount++;
596
 //		priv->txBusyCount++;
649
 
639
 
650
 	tail_list->cStat = TLAN_CSTAT_READY;
640
 	tail_list->cStat = TLAN_CSTAT_READY;
651
 
641
 
652
-	dprintf(("INT1-0x%hX\n", inw(BASE + TLAN_HOST_INT)));
642
+	DBG ( "INT1-0x%hX\n", inw(BASE + TLAN_HOST_INT) );
653
 
643
 
654
 	if (!priv->txInProgress) {
644
 	if (!priv->txInProgress) {
655
 		priv->txInProgress = 1;
645
 		priv->txInProgress = 1;
657
 		outl(TLAN_HC_GO, BASE + TLAN_HOST_CMD);
647
 		outl(TLAN_HC_GO, BASE + TLAN_HOST_CMD);
658
 	} else {
648
 	} else {
659
 		if (priv->txTail == 0) {
649
 		if (priv->txTail == 0) {
660
-			dprintf(("Out buffer\n"));
650
+			DBG ( "Out buffer\n" );
661
 			(priv->txList + (TLAN_NUM_TX_LISTS - 1))->forward =
651
 			(priv->txList + (TLAN_NUM_TX_LISTS - 1))->forward =
662
 			    virt_to_le32desc(tail_list);
652
 			    virt_to_le32desc(tail_list);
663
 		} else {
653
 		} else {
664
-			dprintf(("Fix this \n"));
654
+			DBG ( "Fix this \n" );
665
 			(priv->txList + (priv->txTail - 1))->forward =
655
 			(priv->txList + (priv->txTail - 1))->forward =
666
 			    virt_to_le32desc(tail_list);
656
 			    virt_to_le32desc(tail_list);
667
 		}
657
 		}
669
 	
659
 	
670
 	CIRC_INC(priv->txTail, TLAN_NUM_TX_LISTS);
660
 	CIRC_INC(priv->txTail, TLAN_NUM_TX_LISTS);
671
 
661
 
672
-	dprintf(("INT2-0x%hX\n", inw(BASE + TLAN_HOST_INT)));
662
+	DBG ( "INT2-0x%hX\n", inw(BASE + TLAN_HOST_INT) );
673
 
663
 
674
 	to = currticks() + TX_TIME_OUT;
664
 	to = currticks() + TX_TIME_OUT;
675
 	while ((tail_list->cStat == TLAN_CSTAT_READY) && currticks() < to);
665
 	while ((tail_list->cStat == TLAN_CSTAT_READY) && currticks() < to);
829
 				       addrOfs + i,
819
 				       addrOfs + i,
830
 				       (u8 *) & nic->node_addr[i]);
820
 				       (u8 *) & nic->node_addr[i]);
831
 	if (err) {
821
 	if (err) {
832
-		printf("TLAN: %s: Error reading MAC from eeprom: %d\n",
833
-		       pci->name, err);
834
-	} else 
835
-		/* Print out some hardware info */
836
-		printf("%s: %! at ioaddr %hX, ", 
837
-			pci->name, nic->node_addr, pci->ioaddr);
822
+  	    printf ( "TLAN: %s: Error reading MAC from eeprom: %d\n",
823
+		    pci->name, err);
824
+	} else {
825
+	    DBG ( "%s: %s at ioaddr %#lX, ", 
826
+		  pci->name, eth_ntoa ( nic->node_addr ), pci->ioaddr );
827
+	}
838
 
828
 
839
 	priv->tlanRev = TLan_DioRead8(BASE, TLAN_DEF_REVISION);
829
 	priv->tlanRev = TLan_DioRead8(BASE, TLAN_DEF_REVISION);
840
 	printf("revision: 0x%hX\n", priv->tlanRev);
830
 	printf("revision: 0x%hX\n", priv->tlanRev);
1395
 {
1385
 {
1396
 
1386
 
1397
 	u16 value;
1387
 	u16 value;
1398
-	dprintf(("%s: Powering down PHY(s).\n", priv->nic_name));
1388
+	DBG ( "%s: Powering down PHY(s).\n", priv->nic_name );
1399
 	value = MII_GC_PDOWN | MII_GC_LOOPBK | MII_GC_ISOLATE;
1389
 	value = MII_GC_PDOWN | MII_GC_LOOPBK | MII_GC_ISOLATE;
1400
 	TLan_MiiSync(BASE);
1390
 	TLan_MiiSync(BASE);
1401
 	TLan_MiiWriteReg(nic, priv->phy[priv->phyNum], MII_GEN_CTL, value);
1391
 	TLan_MiiWriteReg(nic, priv->phy[priv->phyNum], MII_GEN_CTL, value);
1422
 {
1412
 {
1423
 	u16 value;
1413
 	u16 value;
1424
 
1414
 
1425
-	dprintf(("%s: Powering up PHY.\n", priv->nic_name));
1415
+	DBG ( "%s: Powering up PHY.\n", priv->nic_name );
1426
 	TLan_MiiSync(BASE);
1416
 	TLan_MiiSync(BASE);
1427
 	value = MII_GC_LOOPBK;
1417
 	value = MII_GC_LOOPBK;
1428
 	TLan_MiiWriteReg(nic, priv->phy[priv->phyNum], MII_GEN_CTL, value);
1418
 	TLan_MiiWriteReg(nic, priv->phy[priv->phyNum], MII_GEN_CTL, value);
1444
 
1434
 
1445
 	phy = priv->phy[priv->phyNum];
1435
 	phy = priv->phy[priv->phyNum];
1446
 
1436
 
1447
-	dprintf(("%s: Reseting PHY.\n", priv->nic_name));
1437
+	DBG ( "%s: Reseting PHY.\n", priv->nic_name );
1448
 	TLan_MiiSync(BASE);
1438
 	TLan_MiiSync(BASE);
1449
 	value = MII_GC_LOOPBK | MII_GC_RESET;
1439
 	value = MII_GC_LOOPBK | MII_GC_RESET;
1450
 	TLan_MiiWriteReg(nic, phy, MII_GEN_CTL, value);
1440
 	TLan_MiiWriteReg(nic, phy, MII_GEN_CTL, value);
1475
 	u16 tctl;
1465
 	u16 tctl;
1476
 
1466
 
1477
 	phy = priv->phy[priv->phyNum];
1467
 	phy = priv->phy[priv->phyNum];
1478
-	dprintf(("%s: Trying to activate link.\n", priv->nic_name));
1468
+	DBG ( "%s: Trying to activate link.\n", priv->nic_name );
1479
 	TLan_MiiReadReg(nic, phy, MII_GEN_STS, &status);
1469
 	TLan_MiiReadReg(nic, phy, MII_GEN_STS, &status);
1480
 	TLan_MiiReadReg(nic, phy, MII_GEN_STS, &ability);
1470
 	TLan_MiiReadReg(nic, phy, MII_GEN_STS, &ability);
1481
 
1471
 
1509
 			 * but the card need additional time to start AN.
1499
 			 * but the card need additional time to start AN.
1510
 			 * .5 sec should be plenty extra.
1500
 			 * .5 sec should be plenty extra.
1511
 			 */
1501
 			 */
1512
-			dprintf(("TLAN: %s: Starting autonegotiation.\n",
1513
-			       priv->nic_name));
1502
+			DBG ( "TLAN: %s: Starting autonegotiation.\n",
1503
+			       priv->nic_name );
1514
 			mdelay(4000);
1504
 			mdelay(4000);
1515
 			TLan_PhyFinishAutoNeg(nic);
1505
 			TLan_PhyFinishAutoNeg(nic);
1516
 			/* TLan_SetTimer( dev, (2*HZ), TLAN_TIMER_PHY_FINISH_AN ); */
1506
 			/* TLan_SetTimer( dev, (2*HZ), TLAN_TIMER_PHY_FINISH_AN ); */
1593
 		return;
1583
 		return;
1594
 	}
1584
 	}
1595
 
1585
 
1596
-	dprintf(("TLAN: %s: Autonegotiation complete.\n", priv->nic_name));
1586
+	DBG ( "TLAN: %s: Autonegotiation complete.\n", priv->nic_name );
1597
 	TLan_MiiReadReg(nic, phy, MII_AN_ADV, &an_adv);
1587
 	TLan_MiiReadReg(nic, phy, MII_AN_ADV, &an_adv);
1598
 	TLan_MiiReadReg(nic, phy, MII_AN_LPA, &an_lpa);
1588
 	TLan_MiiReadReg(nic, phy, MII_AN_LPA, &an_lpa);
1599
 	mode = an_adv & an_lpa & 0x03E0;
1589
 	mode = an_adv & an_lpa & 0x03E0;
1624
 		    || (an_adv & an_lpa & 0x0040)) {
1614
 		    || (an_adv & an_lpa & 0x0040)) {
1625
 			TLan_MiiWriteReg(nic, phy, MII_GEN_CTL,
1615
 			TLan_MiiWriteReg(nic, phy, MII_GEN_CTL,
1626
 					 MII_GC_AUTOENB | MII_GC_DUPLEX);
1616
 					 MII_GC_AUTOENB | MII_GC_DUPLEX);
1627
-			dprintf
1628
-			    (("TLAN:  Starting internal PHY with FULL-DUPLEX\n"));
1617
+			DBG 
1618
+			    ( "TLAN:  Starting internal PHY with FULL-DUPLEX\n" );
1629
 		} else {
1619
 		} else {
1630
 			TLan_MiiWriteReg(nic, phy, MII_GEN_CTL,
1620
 			TLan_MiiWriteReg(nic, phy, MII_GEN_CTL,
1631
 					 MII_GC_AUTOENB);
1621
 					 MII_GC_AUTOENB);
1632
-			dprintf
1633
-			    (("TLAN:  Starting internal PHY with HALF-DUPLEX\n"));
1622
+			DBG 
1623
+			    ( "TLAN:  Starting internal PHY with HALF-DUPLEX\n" );
1634
 		}
1624
 		}
1635
 	}
1625
 	}
1636
 
1626
 

Loading…
Cancel
Save