浏览代码

[tulip] Use iPXE debugging infrastructure

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 14 年前
父节点
当前提交
ae34edbd3b
共有 1 个文件被更改,包括 79 次插入209 次删除
  1. 79
    209
      src/drivers/net/tulip.c

+ 79
- 209
src/drivers/net/tulip.c 查看文件

@@ -116,12 +116,6 @@ FILE_LICENCE ( GPL_ANY );
116 116
 
117 117
 /* User settable parameters */
118 118
 
119
-#undef	TULIP_DEBUG
120
-#undef	TULIP_DEBUG_WHERE
121
-#ifdef	TULIP_DEBUG
122
-static int tulip_debug = 2;             /* 1 normal messages, 0 quiet .. 7 verbose. */
123
-#endif
124
-
125 119
 #define TX_TIME_OUT       2*TICKS_PER_SEC
126 120
 
127 121
 /* helpful macros if on a big_endian machine for changing byte order.
@@ -510,37 +504,16 @@ static int tulip_check_duplex(struct nic *nic);
510 504
 
511 505
 static void tulip_wait(unsigned int nticks);
512 506
 
513
-#ifdef TULIP_DEBUG_WHERE
514
-static void whereami(const char *str);
515
-#endif
516
-
517
-#ifdef TULIP_DEBUG
518
-static void tulip_more(void);
519
-#endif
520
-
521 507
 
522 508
 /*********************************************************************/
523 509
 /* Utility Routines                                                  */
524 510
 /*********************************************************************/
525 511
 
526
-#ifdef TULIP_DEBUG_WHERE
527
-static void whereami (const char *str, struct pci_device *pci)
512
+static void whereami (const char *str)
528 513
 {
529
-    printf("%s: %s\n", tp->nic_name, str);
514
+    DBGP("%s\n", str);
530 515
     /* sleep(2); */
531 516
 }
532
-#endif
533
-
534
-#ifdef  TULIP_DEBUG
535
-static void tulip_more(void)
536
-{
537
-    printf("\n\n-- more --");
538
-    while (!iskey())
539
-        /* wait */;
540
-    getchar();
541
-    printf("\n\n");
542
-}
543
-#endif /* TULIP_DEBUG */
544 517
 
545 518
 static void tulip_wait(unsigned int nticks)
546 519
 {
@@ -586,9 +559,7 @@ int mdio_read(struct nic *nic __unused, int phy_id, int location)
586 559
     int retval = 0;
587 560
     long mdio_addr = ioaddr + CSR9;
588 561
 
589
-#ifdef TULIP_DEBUG_WHERE
590 562
     whereami("mdio_read\n");
591
-#endif
592 563
 
593 564
     if (tp->chip_id == LC82C168) {
594 565
 	int i = 1000;
@@ -646,9 +617,7 @@ void mdio_write(struct nic *nic __unused, int phy_id, int location, int value)
646 617
     int cmd = (0x5002 << 16) | (phy_id << 23) | (location<<18) | value;
647 618
     long mdio_addr = ioaddr + CSR9;
648 619
 
649
-#ifdef TULIP_DEBUG_WHERE
650 620
     whereami("mdio_write\n");
651
-#endif
652 621
 
653 622
     if (tp->chip_id == LC82C168) {
654 623
 	int i = 1000;
@@ -711,9 +680,7 @@ static int read_eeprom(unsigned long ioaddr, int location, int addr_len)
711 680
     long ee_addr = ioaddr + CSR9;
712 681
     int read_cmd = location | EE_READ_CMD;
713 682
 
714
-#ifdef TULIP_DEBUG_WHERE
715 683
     whereami("read_eeprom\n");
716
-#endif
717 684
 
718 685
     outl(EE_ENB & ~EE_CS, ee_addr);
719 686
     outl(EE_ENB, ee_addr);
@@ -751,9 +718,7 @@ static void parse_eeprom(struct nic *nic)
751 718
     int new_advertise = 0;
752 719
     int i;
753 720
 
754
-#ifdef TULIP_DEBUG_WHERE
755 721
     whereami("parse_eeprom\n");
756
-#endif
757 722
 
758 723
     tp->mtable = 0;
759 724
     /* Detect an old-style (SA only) EEPROM layout:
@@ -771,44 +736,34 @@ static void parse_eeprom(struct nic *nic)
771 736
                     i++;                /* An Accton EN1207, not an outlaw Maxtech. */
772 737
                 memcpy(ee_data + 26, eeprom_fixups[i].newtable,
773 738
                        sizeof(eeprom_fixups[i].newtable));
774
-#ifdef TULIP_DEBUG
775
-                printf("%s: Old format EEPROM on '%s' board.\n%s: Using substitute media control info.\n",
739
+                DBG("%s: Old format EEPROM on '%s' board.\n%s: Using substitute media control info.\n",
776 740
                        tp->nic_name, eeprom_fixups[i].name, tp->nic_name);
777
-#endif
778 741
                 break;
779 742
             }
780 743
         }
781 744
         if (eeprom_fixups[i].name == NULL) { /* No fixup found. */
782
-#ifdef TULIP_DEBUG
783
-            printf("%s: Old style EEPROM with no media selection information.\n",
745
+            DBG("%s: Old style EEPROM with no media selection information.\n",
784 746
                    tp->nic_name);
785
-#endif
786 747
             return;
787 748
         }
788 749
     }
789 750
 
790 751
     if (ee_data[19] > 1) {
791
-#ifdef TULIP_DEBUG
792
-        printf("%s:  Multiport cards (%d ports) may not work correctly.\n", 
752
+        DBG("%s:  Multiport cards (%d ports) may not work correctly.\n",
793 753
                tp->nic_name, ee_data[19]);
794
-#endif
795 754
     }
796 755
 
797 756
     p = (void *)ee_data + ee_data[27];
798 757
 
799 758
     if (ee_data[27] == 0) {             /* No valid media table. */
800
-#ifdef TULIP_DEBUG
801
-        if (tulip_debug > 1) {
802
-            printf("%s:  No Valid Media Table. ee_data[27] = %hhX\n", 
803
-                   tp->nic_name, ee_data[27]);
804
-        }
805
-#endif
759
+            DBG2("%s:  No Valid Media Table. ee_data[27] = %hhX\n",
760
+		 tp->nic_name, ee_data[27]);
806 761
     } else if (tp->chip_id == DC21041) {
807 762
         int media = get_u16(p);
808 763
         int count = p[2];
809 764
         p += 3;
810 765
 
811
-        printf("%s: 21041 Media table, default media %hX (%s).\n",
766
+        DBG("%s: 21041 Media table, default media %hX (%s).\n",
812 767
                tp->nic_name, media,
813 768
                media & 0x0800 ? "Autosense" : medianame[media & 15]);
814 769
         for (i = 0; i < count; i++) {
@@ -820,7 +775,7 @@ static void parse_eeprom(struct nic *nic)
820 775
             case 0: new_advertise |= 0x0020; break;
821 776
             case 4: new_advertise |= 0x0040; break;
822 777
             }
823
-            printf("%s:  21041 media #%d, %s.\n",
778
+            DBG("%s:  21041 media #%d, %s.\n",
824 779
                    tp->nic_name, media_code, medianame[media_code]);
825 780
         }
826 781
     } else {
@@ -842,7 +797,7 @@ static void parse_eeprom(struct nic *nic)
842 797
         mtable->has_nonmii = mtable->has_mii = mtable->has_reset = 0;
843 798
         mtable->csr15dir = mtable->csr15val = 0;
844 799
 
845
-        printf("%s:  EEPROM default media type %s.\n", tp->nic_name,
800
+        DBG("%s:  EEPROM default media type %s.\n", tp->nic_name,
846 801
                media & 0x0800 ? "Autosense" : medianame[media & MEDIA_MASK]);
847 802
 
848 803
         for (i = 0; i < count; i++) {
@@ -890,15 +845,13 @@ static void parse_eeprom(struct nic *nic)
890 845
                 leaf->leafdata = p + 2;
891 846
                 p += (p[0] & 0x3f) + 1;
892 847
             }
893
-#ifdef TULIP_DEBUG
894
-            if (tulip_debug > 1  &&  leaf->media == 11) {
848
+            if (leaf->media == 11) {
895 849
                 unsigned char *bp = leaf->leafdata;
896
-                printf("%s:  MII interface PHY %d, setup/reset sequences %d/%d long, capabilities %hhX %hhX.\n",
897
-                       tp->nic_name, bp[0], bp[1], bp[2 + bp[1]*2],
898
-                       bp[5 + bp[2 + bp[1]*2]*2], bp[4 + bp[2 + bp[1]*2]*2]);
850
+                DBG2("%s:  MII interface PHY %d, setup/reset sequences %d/%d long, capabilities %hhX %hhX.\n",
851
+		     tp->nic_name, bp[0], bp[1], bp[2 + bp[1]*2],
852
+		     bp[5 + bp[2 + bp[1]*2]*2], bp[4 + bp[2 + bp[1]*2]*2]);
899 853
             }
900
-#endif
901
-            printf("%s:  Index #%d - Media %s (#%d) described "
854
+            DBG("%s:  Index #%d - Media %s (#%d) described "
902 855
                    "by a %s (%d) block.\n",
903 856
                    tp->nic_name, i, medianame[leaf->media], leaf->media,
904 857
                    leaf->type < 6 ? block_name[leaf->type] : "UNKNOWN",
@@ -917,9 +870,7 @@ static void tulip_init_ring(struct nic *nic __unused)
917 870
 {
918 871
     int i;
919 872
 
920
-#ifdef TULIP_DEBUG_WHERE
921 873
     whereami("tulip_init_ring\n");
922
-#endif
923 874
 
924 875
     tp->cur_rx = 0;
925 876
 
@@ -974,9 +925,7 @@ static void tulip_reset(struct nic *nic)
974 925
     int i;
975 926
     unsigned long to;
976 927
 
977
-#ifdef TULIP_DEBUG_WHERE
978 928
     whereami("tulip_reset\n");
979
-#endif
980 929
 
981 930
     /* Stop Tx and RX */
982 931
     outl(inl(ioaddr + CSR6) & ~0x00002002, ioaddr + CSR6);
@@ -1071,7 +1020,7 @@ static void tulip_reset(struct nic *nic)
1071 1020
 	    /* wait */ ;
1072 1021
 
1073 1022
 	if (currticks() >= to) {
1074
-	    printf ("%s: TX Setup Timeout.\n", tp->nic_name);
1023
+	    DBG ("%s: TX Setup Timeout.\n", tp->nic_name);
1075 1024
 	}
1076 1025
     }
1077 1026
 
@@ -1095,9 +1044,7 @@ static void tulip_transmit(struct nic *nic, const char *d, unsigned int t,
1095 1044
     u32 to;
1096 1045
     u32 csr6 = inl(ioaddr + CSR6);
1097 1046
 
1098
-#ifdef TULIP_DEBUG_WHERE    
1099 1047
     whereami("tulip_transmit\n");
1100
-#endif
1101 1048
 
1102 1049
     /* Disable Tx */
1103 1050
     outl(csr6 & ~0x00002000, ioaddr + CSR6);
@@ -1115,10 +1062,7 @@ static void tulip_transmit(struct nic *nic, const char *d, unsigned int t,
1115 1062
     while (s < ETH_ZLEN)  
1116 1063
         txb[s++] = '\0';
1117 1064
 
1118
-#ifdef TULIP_DEBUG
1119
-    if (tulip_debug > 1)
1120
-	printf("%s: sending %d bytes ethtype %hX\n", tp->nic_name, s, t);
1121
-#endif
1065
+    DBG2("%s: sending %d bytes ethtype %hX\n", tp->nic_name, s, t);
1122 1066
         
1123 1067
     /* setup the transmit descriptor */
1124 1068
     /* 0x60000000 = no interrupt on completion */
@@ -1138,7 +1082,7 @@ static void tulip_transmit(struct nic *nic, const char *d, unsigned int t,
1138 1082
         /* wait */ ;
1139 1083
 
1140 1084
     if (currticks() >= to) {
1141
-        printf ("TX Timeout!\n");
1085
+        DBG ("TX Timeout!\n");
1142 1086
     }
1143 1087
 
1144 1088
     /* Disable Tx */
@@ -1151,9 +1095,7 @@ static void tulip_transmit(struct nic *nic, const char *d, unsigned int t,
1151 1095
 static int tulip_poll(struct nic *nic, int retrieve)
1152 1096
 {
1153 1097
 
1154
-#ifdef TULIP_DEBUG_WHERE
1155 1098
     whereami("tulip_poll\n");
1156
-#endif
1157 1099
 
1158 1100
     /* no packet waiting. packet still owned by NIC */
1159 1101
     if (rx_ring[tp->cur_rx].status & 0x80000000)
@@ -1161,9 +1103,7 @@ static int tulip_poll(struct nic *nic, int retrieve)
1161 1103
 
1162 1104
     if ( ! retrieve ) return 1;
1163 1105
 
1164
-#ifdef TULIP_DEBUG_WHERE
1165 1106
     whereami("tulip_poll got one\n");
1166
-#endif
1167 1107
 
1168 1108
     nic->packetlen = (rx_ring[tp->cur_rx].status & 0x3FFF0000) >> 16;
1169 1109
 
@@ -1190,9 +1130,7 @@ static int tulip_poll(struct nic *nic, int retrieve)
1190 1130
 /*********************************************************************/
1191 1131
 static void tulip_disable ( struct nic *nic ) {
1192 1132
 
1193
-#ifdef TULIP_DEBUG_WHERE
1194 1133
     whereami("tulip_disable\n");
1195
-#endif
1196 1134
 
1197 1135
     tulip_reset(nic);
1198 1136
 
@@ -1269,16 +1207,11 @@ static int tulip_probe ( struct nic *nic, struct pci_device *pci ) {
1269 1207
     /* Clear the missed-packet counter. */
1270 1208
     inl(ioaddr + CSR8);
1271 1209
 
1272
-    printf("\n");                /* so we start on a fresh line */
1273
-#ifdef TULIP_DEBUG_WHERE
1210
+    DBG("\n");                /* so we start on a fresh line */
1274 1211
     whereami("tulip_probe\n");
1275
-#endif
1276 1212
 
1277
-#ifdef TULIP_DEBUG
1278
-    if (tulip_debug > 1)
1279
-	printf ("%s: Looking for Tulip Chip: Vendor=%hX  Device=%hX\n", tp->nic_name,
1280
-		tp->vendor, tp->dev_id);
1281
-#endif
1213
+    DBG2 ("%s: Looking for Tulip Chip: Vendor=%hX  Device=%hX\n", tp->nic_name,
1214
+	  tp->vendor_id, tp->dev_id);
1282 1215
 
1283 1216
     /* Figure out which chip we're dealing with */
1284 1217
     i = 0;
@@ -1294,7 +1227,7 @@ static int tulip_probe ( struct nic *nic, struct pci_device *pci ) {
1294 1227
     }
1295 1228
 
1296 1229
     if (chip_idx == -1) {
1297
-        printf ("%s: Unknown Tulip Chip: Vendor=%hX  Device=%hX\n", tp->nic_name,
1230
+        DBG ("%s: Unknown Tulip Chip: Vendor=%hX  Device=%hX\n", tp->nic_name,
1298 1231
                 tp->vendor_id, tp->dev_id);
1299 1232
         return 0;
1300 1233
     }
@@ -1302,14 +1235,10 @@ static int tulip_probe ( struct nic *nic, struct pci_device *pci ) {
1302 1235
     tp->pci_id_idx = i;
1303 1236
     tp->flags = tulip_tbl[chip_idx].flags;
1304 1237
 
1305
-#ifdef TULIP_DEBUG
1306
-    if (tulip_debug > 1) {
1307
-	printf ("%s: tp->pci_id_idx == %d,  name == %s\n", tp->nic_name, 
1308
-		tp->pci_id_idx, pci_id_tbl[tp->pci_id_idx].name);
1309
-	printf ("%s: chip_idx == %d, name == %s\n", tp->nic_name, chip_idx, 
1310
-		tulip_tbl[chip_idx].chip_name);
1311
-    }
1312
-#endif
1238
+    DBG2 ("%s: tp->pci_id_idx == %d,  name == %s\n", tp->nic_name,
1239
+	  tp->pci_id_idx, pci_id_tbl[tp->pci_id_idx].name);
1240
+    DBG2 ("%s: chip_idx == %d, name == %s\n", tp->nic_name, chip_idx,
1241
+	  tulip_tbl[chip_idx].chip_name);
1313 1242
   
1314 1243
     /* Bring the 21041/21143 out of sleep mode.
1315 1244
        Caution: Snooze mode does not work with some boards! */
@@ -1317,23 +1246,23 @@ static int tulip_probe ( struct nic *nic, struct pci_device *pci ) {
1317 1246
         pci_write_config_dword(pci, 0x40, 0x00000000);
1318 1247
 
1319 1248
     if (inl(ioaddr + CSR5) == 0xFFFFFFFF) {
1320
-        printf("%s: The Tulip chip at %X is not functioning.\n",
1249
+        DBG("%s: The Tulip chip at %X is not functioning.\n",
1321 1250
                tp->nic_name, (unsigned int) ioaddr);
1322 1251
         return 0;
1323 1252
     }
1324 1253
    
1325 1254
     pci_read_config_byte(pci, PCI_REVISION, &chip_rev);
1326 1255
 
1327
-    printf("%s: [chip: %s] rev %d at %hX\n", tp->nic_name,
1256
+    DBG("%s: [chip: %s] rev %d at %hX\n", tp->nic_name,
1328 1257
            tulip_tbl[chip_idx].chip_name, chip_rev, (unsigned int) ioaddr);
1329
-    printf("%s: Vendor=%hX  Device=%hX", tp->nic_name, tp->vendor_id, tp->dev_id);
1258
+    DBG("%s: Vendor=%hX  Device=%hX", tp->nic_name, tp->vendor_id, tp->dev_id);
1330 1259
 
1331 1260
     if (chip_idx == DC21041  &&  inl(ioaddr + CSR9) & 0x8000) {
1332
-        printf(" 21040 compatible mode.");
1261
+        DBG(" 21040 compatible mode.");
1333 1262
         chip_idx = DC21040;
1334 1263
     }
1335 1264
 
1336
-    printf("\n");
1265
+    DBG("\n");
1337 1266
 
1338 1267
     /* The SROM/EEPROM interface varies dramatically. */
1339 1268
     sum = 0;
@@ -1396,7 +1325,7 @@ static int tulip_probe ( struct nic *nic, struct pci_device *pci ) {
1396 1325
         }
1397 1326
 
1398 1327
     if (sum == 0  || sum == ETH_ALEN*0xff) {
1399
-        printf("%s: EEPROM not present!\n", tp->nic_name);
1328
+        DBG("%s: EEPROM not present!\n", tp->nic_name);
1400 1329
         for (i = 0; i < ETH_ALEN-1; i++)
1401 1330
             nic->node_addr[i] = last_phys_addr[i];
1402 1331
         nic->node_addr[i] = last_phys_addr[i] + 1;
@@ -1449,9 +1378,7 @@ static void start_link(struct nic *nic)
1449 1378
 {
1450 1379
     int i;
1451 1380
 
1452
-#ifdef TULIP_DEBUG_WHERE
1453 1381
     whereami("start_link\n");
1454
-#endif
1455 1382
 
1456 1383
     if ((tp->flags & ALWAYS_CHECK_MII) ||
1457 1384
         (tp->mtable  &&  tp->mtable->has_mii) ||
@@ -1486,11 +1413,11 @@ static void start_link(struct nic *nic)
1486 1413
                     tp->mii_advertise = to_advert = mii_advert;
1487 1414
 
1488 1415
                 tp->phys[phy_idx++] = phy;
1489
-                printf("%s:  MII transceiver %d config %hX status %hX advertising %hX.\n",
1416
+                DBG("%s:  MII transceiver %d config %hX status %hX advertising %hX.\n",
1490 1417
                        tp->nic_name, phy, mii_reg0, mii_status, mii_advert);
1491 1418
                                 /* Fixup for DLink with miswired PHY. */
1492 1419
                 if (mii_advert != to_advert) {
1493
-                    printf("%s:  Advertising %hX on PHY %d previously advertising %hX.\n",
1420
+                    DBG("%s:  Advertising %hX on PHY %d previously advertising %hX.\n",
1494 1421
                            tp->nic_name, to_advert, phy, mii_advert);
1495 1422
                     mdio_write(nic, phy, 4, to_advert);
1496 1423
                 }
@@ -1502,7 +1429,7 @@ static void start_link(struct nic *nic)
1502 1429
         }
1503 1430
         tp->mii_cnt = phy_idx;
1504 1431
         if (tp->mtable  &&  tp->mtable->has_mii  &&  phy_idx == 0) {
1505
-            printf("%s: ***WARNING***: No MII transceiver found!\n",
1432
+            DBG("%s: ***WARNING***: No MII transceiver found!\n",
1506 1433
                    tp->nic_name);
1507 1434
             tp->phys[0] = 1;
1508 1435
         }
@@ -1569,9 +1496,7 @@ static void nway_start(struct nic *nic __unused)
1569 1496
     int csr14 = ((tp->sym_advertise & 0x0780) << 9)  |
1570 1497
         ((tp->sym_advertise&0x0020)<<1) | 0xffbf;
1571 1498
 
1572
-#ifdef TULIP_DEBUG_WHERE
1573 1499
     whereami("nway_start\n");
1574
-#endif
1575 1500
 
1576 1501
     tp->if_port = 0;
1577 1502
     tp->nway = tp->mediasense = 1;
@@ -1580,11 +1505,8 @@ static void nway_start(struct nic *nic __unused)
1580 1505
         tp->csr6 = 0x01000000 | (tp->sym_advertise & 0x0040 ? 0x0200 : 0);
1581 1506
         return;
1582 1507
     }
1583
-#ifdef TULIP_DEBUG
1584
-    if (tulip_debug > 1)
1585
-        printf("%s: Restarting internal NWay autonegotiation, %X.\n",
1586
-               tp->nic_name, csr14);
1587
-#endif
1508
+    DBG2("%s: Restarting internal NWay autonegotiation, %X.\n",
1509
+	 tp->nic_name, csr14);
1588 1510
     outl(0x0001, ioaddr + CSR13);
1589 1511
     outl(csr14, ioaddr + CSR14);
1590 1512
     tp->csr6 = 0x82420000 | (tp->sym_advertise & 0x0040 ? 0x0200 : 0);
@@ -1604,9 +1526,7 @@ static void init_media(struct nic *nic)
1604 1526
 {
1605 1527
     int i;
1606 1528
 
1607
-#ifdef TULIP_DEBUG_WHERE
1608 1529
     whereami("init_media\n");
1609
-#endif
1610 1530
 
1611 1531
     tp->saved_if_port = tp->if_port;
1612 1532
     if (tp->if_port == 0)
@@ -1621,7 +1541,7 @@ static void init_media(struct nic *nic)
1621 1541
             (tp->if_port == 12 ? 0 : tp->if_port);
1622 1542
         for (i = 0; i < tp->mtable->leafcount; i++)
1623 1543
             if (tp->mtable->mleaf[i].media == looking_for) {
1624
-                printf("%s: Using user-specified media %s.\n",
1544
+                DBG("%s: Using user-specified media %s.\n",
1625 1545
                        tp->nic_name, medianame[tp->if_port]);
1626 1546
                 goto media_picked;
1627 1547
             }
@@ -1630,7 +1550,7 @@ static void init_media(struct nic *nic)
1630 1550
         int looking_for = tp->mtable->defaultmedia & 15;
1631 1551
         for (i = 0; i < tp->mtable->leafcount; i++)
1632 1552
             if (tp->mtable->mleaf[i].media == looking_for) {
1633
-                printf("%s: Using EEPROM-set media %s.\n",
1553
+                DBG("%s: Using EEPROM-set media %s.\n",
1634 1554
                        tp->nic_name, medianame[looking_for]);
1635 1555
                 goto media_picked;
1636 1556
             }
@@ -1663,11 +1583,8 @@ static void init_media(struct nic *nic)
1663 1583
     case DC21142:
1664 1584
         if (tp->mii_cnt) {
1665 1585
             select_media(nic, 1);
1666
-#ifdef TULIP_DEBUG
1667
-            if (tulip_debug > 1)
1668
-                printf("%s: Using MII transceiver %d, status %hX.\n",
1669
-                       tp->nic_name, tp->phys[0], mdio_read(nic, tp->phys[0], 1));
1670
-#endif
1586
+	    DBG2("%s: Using MII transceiver %d, status %hX.\n",
1587
+		 tp->nic_name, tp->phys[0], mdio_read(nic, tp->phys[0], 1));
1671 1588
             outl(0x82020000, ioaddr + CSR6);
1672 1589
             tp->csr6 = 0x820E0000;
1673 1590
             tp->if_port = 11;
@@ -1725,9 +1642,7 @@ static void pnic_do_nway(struct nic *nic __unused)
1725 1642
     u32 phy_reg = inl(ioaddr + 0xB8);
1726 1643
     u32 new_csr6 = tp->csr6 & ~0x40C40200;
1727 1644
 
1728
-#ifdef TULIP_DEBUG_WHERE
1729 1645
     whereami("pnic_do_nway\n");
1730
-#endif
1731 1646
 
1732 1647
     if (phy_reg & 0x78000000) { /* Ignore baseT4 */
1733 1648
         if (phy_reg & 0x20000000)               tp->if_port = 5;
@@ -1743,11 +1658,8 @@ static void pnic_do_nway(struct nic *nic __unused)
1743 1658
             tp->full_duplex = 1;
1744 1659
             new_csr6 |= 0x00000200;
1745 1660
         }
1746
-#ifdef TULIP_DEBUG
1747
-        if (tulip_debug > 1)
1748
-            printf("%s: PNIC autonegotiated status %X, %s.\n",
1749
-                   tp->nic_name, phy_reg, medianame[tp->if_port]);
1750
-#endif
1661
+	DBG2("%s: PNIC autonegotiated status %X, %s.\n",
1662
+	     tp->nic_name, phy_reg, medianame[tp->if_port]);
1751 1663
         if (tp->csr6 != new_csr6) {
1752 1664
             tp->csr6 = new_csr6;
1753 1665
             outl(tp->csr6 | 0x0002, ioaddr + CSR6);     /* Restart Tx */
@@ -1763,21 +1675,16 @@ static void select_media(struct nic *nic, int startup)
1763 1675
     u32 new_csr6;
1764 1676
     int i;
1765 1677
 
1766
-#ifdef TULIP_DEBUG_WHERE
1767 1678
     whereami("select_media\n");
1768
-#endif
1769 1679
 
1770 1680
     if (mtable) {
1771 1681
         struct medialeaf *mleaf = &mtable->mleaf[tp->cur_index];
1772 1682
         unsigned char *p = mleaf->leafdata;
1773 1683
         switch (mleaf->type) {
1774 1684
         case 0:                                 /* 21140 non-MII xcvr. */
1775
-#ifdef TULIP_DEBUG
1776
-            if (tulip_debug > 1)
1777
-                printf("%s: Using a 21140 non-MII transceiver"
1778
-                       " with control setting %hhX.\n",
1779
-                       tp->nic_name, p[1]);
1780
-#endif
1685
+            DBG2("%s: Using a 21140 non-MII transceiver"
1686
+		 " with control setting %hhX.\n",
1687
+		 tp->nic_name, p[1]);
1781 1688
             tp->if_port = p[0];
1782 1689
             if (startup)
1783 1690
                 outl(mtable->csr12dir | 0x100, ioaddr + CSR12);
@@ -1797,20 +1704,13 @@ static void select_media(struct nic *nic, int startup)
1797 1704
             if (startup && mtable->has_reset) {
1798 1705
                 struct medialeaf *rleaf = &mtable->mleaf[mtable->has_reset];
1799 1706
                 unsigned char *rst = rleaf->leafdata;
1800
-#ifdef TULIP_DEBUG
1801
-                if (tulip_debug > 1)
1802
-                    printf("%s: Resetting the transceiver.\n",
1803
-                           tp->nic_name);
1804
-#endif
1707
+		DBG2("%s: Resetting the transceiver.\n",
1708
+		     tp->nic_name);
1805 1709
                 for (i = 0; i < rst[0]; i++)
1806 1710
                     outl(get_u16(rst + 1 + (i<<1)) << 16, ioaddr + CSR15);
1807 1711
             }
1808
-#ifdef TULIP_DEBUG
1809
-            if (tulip_debug > 1)
1810
-                printf("%s: 21143 non-MII %s transceiver control "
1811
-                       "%hX/%hX.\n",
1812
-                       tp->nic_name, medianame[tp->if_port], setup[0], setup[1]);
1813
-#endif
1712
+	    DBG2("%s: 21143 non-MII %s transceiver control %hX/%hX.\n",
1713
+		 tp->nic_name, medianame[tp->if_port], setup[0], setup[1]);
1814 1714
             if (p[0] & 0x40) {  /* SIA (CSR13-15) setup values are provided. */
1815 1715
                 csr13val = setup[0];
1816 1716
                 csr14val = setup[1];
@@ -1836,11 +1736,8 @@ static void select_media(struct nic *nic, int startup)
1836 1736
                 outl(csr15val, ioaddr + CSR15); /* Data */
1837 1737
                 if (startup) outl(csr13val, ioaddr + CSR13);
1838 1738
             }
1839
-#ifdef TULIP_DEBUG
1840
-            if (tulip_debug > 1)
1841
-                printf("%s:  Setting CSR15 to %X/%X.\n",
1842
-                       tp->nic_name, csr15dir, csr15val);
1843
-#endif
1739
+	    DBG2("%s:  Setting CSR15 to %X/%X.\n",
1740
+		 tp->nic_name, csr15dir, csr15val);
1844 1741
             if (mleaf->type == 4)
1845 1742
                 new_csr6 = 0x82020000 | ((setup[2] & 0x71) << 18);
1846 1743
             else
@@ -1881,34 +1778,25 @@ static void select_media(struct nic *nic, int startup)
1881 1778
             if (startup < 2) {
1882 1779
                 if (tp->mii_advertise == 0)
1883 1780
                     tp->mii_advertise = tp->advertising[phy_num];
1884
-#ifdef TULIP_DEBUG
1885
-                if (tulip_debug > 1)
1886
-                    printf("%s:  Advertising %hX on MII %d.\n",
1887
-                           tp->nic_name, tp->mii_advertise, tp->phys[phy_num]);
1888
-#endif
1781
+		DBG2("%s:  Advertising %hX on MII %d.\n",
1782
+		     tp->nic_name, tp->mii_advertise, tp->phys[phy_num]);
1889 1783
                 mdio_write(nic, tp->phys[phy_num], 4, tp->mii_advertise);
1890 1784
             }
1891 1785
             break;
1892 1786
         }
1893 1787
         default:
1894
-            printf("%s:  Invalid media table selection %d.\n",
1788
+            DBG("%s:  Invalid media table selection %d.\n",
1895 1789
                    tp->nic_name, mleaf->type);
1896 1790
             new_csr6 = 0x020E0000;
1897 1791
         }
1898
-#ifdef TULIP_DEBUG
1899
-        if (tulip_debug > 1)
1900
-            printf("%s: Using media type %s, CSR12 is %hhX.\n",
1901
-                   tp->nic_name, medianame[tp->if_port],
1902
-                   inl(ioaddr + CSR12) & 0xff);
1903
-#endif
1792
+	DBG2("%s: Using media type %s, CSR12 is %hhX.\n",
1793
+	     tp->nic_name, medianame[tp->if_port],
1794
+	     inl(ioaddr + CSR12) & 0xff);
1904 1795
     } else if (tp->chip_id == DC21041) {
1905 1796
         int port = tp->if_port <= 4 ? tp->if_port : 0;
1906
-#ifdef TULIP_DEBUG
1907
-        if (tulip_debug > 1)
1908
-            printf("%s: 21041 using media %s, CSR12 is %hX.\n",
1909
-                   tp->nic_name, medianame[port == 3 ? 12: port],
1910
-                   inl(ioaddr + CSR12));
1911
-#endif
1797
+	DBG2("%s: 21041 using media %s, CSR12 is %hX.\n",
1798
+	     tp->nic_name, medianame[port == 3 ? 12: port],
1799
+	     inl(ioaddr + CSR12));
1912 1800
         outl(0x00000000, ioaddr + CSR13); /* Reset the serial interface */
1913 1801
         outl(t21041_csr14[port], ioaddr + CSR14);
1914 1802
         outl(t21041_csr15[port], ioaddr + CSR15);
@@ -1917,11 +1805,8 @@ static void select_media(struct nic *nic, int startup)
1917 1805
     } else if (tp->chip_id == LC82C168) {
1918 1806
         if (startup && ! tp->medialock)
1919 1807
             tp->if_port = tp->mii_cnt ? 11 : 0;
1920
-#ifdef TULIP_DEBUG
1921
-        if (tulip_debug > 1)
1922
-	    printf("%s: PNIC PHY status is %hX, media %s.\n",
1923
-                   tp->nic_name, inl(ioaddr + 0xB8), medianame[tp->if_port]);
1924
-#endif
1808
+	DBG2("%s: PNIC PHY status is %hX, media %s.\n",
1809
+	     tp->nic_name, inl(ioaddr + 0xB8), medianame[tp->if_port]);
1925 1810
         if (tp->mii_cnt) {
1926 1811
             new_csr6 = 0x810C0000;
1927 1812
             outl(0x0001, ioaddr + CSR15);
@@ -1944,12 +1829,9 @@ static void select_media(struct nic *nic, int startup)
1944 1829
         }
1945 1830
     } else if (tp->chip_id == DC21040) {                                        /* 21040 */
1946 1831
         /* Turn on the xcvr interface. */
1947
-#ifdef TULIP_DEBUG
1948 1832
         int csr12 = inl(ioaddr + CSR12);
1949
-        if (tulip_debug > 1)
1950
-            printf("%s: 21040 media type is %s, CSR12 is %hhX.\n",
1951
-                   tp->nic_name, medianame[tp->if_port], csr12);
1952
-#endif
1833
+	DBG2("%s: 21040 media type is %s, CSR12 is %hhX.\n",
1834
+	     tp->nic_name, medianame[tp->if_port], csr12);
1953 1835
         if (media_cap[tp->if_port] & MediaAlwaysFD)
1954 1836
             tp->full_duplex = 1;
1955 1837
         new_csr6 = 0x20000;
@@ -1973,13 +1855,10 @@ static void select_media(struct nic *nic, int startup)
1973 1855
             new_csr6 = 0x028600000;
1974 1856
         } else
1975 1857
             new_csr6 = 0x038600000;
1976
-#ifdef TULIP_DEBUG
1977
-        if (tulip_debug > 1)
1978
-            printf("%s: No media description table, assuming "
1979
-                   "%s transceiver, CSR12 %hhX.\n",
1980
-                   tp->nic_name, medianame[tp->if_port],
1981
-                   inl(ioaddr + CSR12));
1982
-#endif
1858
+	DBG2("%s: No media description table, assuming "
1859
+	     "%s transceiver, CSR12 %hhX.\n",
1860
+	     tp->nic_name, medianame[tp->if_port],
1861
+	     inl(ioaddr + CSR12));
1983 1862
     }
1984 1863
 
1985 1864
     tp->csr6 = new_csr6 | (tp->csr6 & 0xfdff) | (tp->full_duplex ? 0x0200 : 0);
@@ -1999,23 +1878,17 @@ static int tulip_check_duplex(struct nic *nic)
1999 1878
         bmsr = mdio_read(nic, tp->phys[0], 1);
2000 1879
         lpa = mdio_read(nic, tp->phys[0], 5);
2001 1880
 
2002
-#ifdef TULIP_DEBUG
2003
-        if (tulip_debug > 1)
2004
-                printf("%s: MII status %#x, Link partner report "
2005
-                           "%#x.\n", tp->nic_name, bmsr, lpa);
2006
-#endif
1881
+	DBG2("%s: MII status %#x, Link partner report %#x.\n",
1882
+	     tp->nic_name, bmsr, lpa);
2007 1883
 
2008 1884
         if (bmsr == 0xffff)
2009 1885
                 return -2;
2010 1886
         if ((bmsr & 4) == 0) { 
2011 1887
                 int new_bmsr = mdio_read(nic, tp->phys[0], 1); 
2012 1888
                 if ((new_bmsr & 4) == 0) { 
2013
-#ifdef TULIP_DEBUG
2014
-                        if (tulip_debug  > 1)
2015
-                                printf("%s: No link beat on the MII interface,"
2016
-                                           " status %#x.\n", tp->nic_name, 
2017
-                                           new_bmsr);
2018
-#endif
1889
+			DBG2("%s: No link beat on the MII interface,"
1890
+			     " status %#x.\n", tp->nic_name,
1891
+			     new_bmsr);
2019 1892
                         return -1;
2020 1893
                 }
2021 1894
         }
@@ -2032,14 +1905,11 @@ static int tulip_check_duplex(struct nic *nic)
2032 1905
         if (new_csr6 != tp->csr6) {
2033 1906
                 tp->csr6 = new_csr6;
2034 1907
 
2035
-#ifdef TULIP_DEBUG
2036
-                if (tulip_debug > 0)
2037
-                        printf("%s: Setting %s-duplex based on MII"
2038
-                                   "#%d link partner capability of %#x.\n",
2039
-                                   tp->nic_name, 
2040
-                                   tp->full_duplex ? "full" : "half",
2041
-                                   tp->phys[0], lpa);
2042
-#endif
1908
+		DBG("%s: Setting %s-duplex based on MII"
1909
+		    "#%d link partner capability of %#x.\n",
1910
+		    tp->nic_name,
1911
+		    tp->full_duplex ? "full" : "half",
1912
+		    tp->phys[0], lpa);
2043 1913
                 return 1;
2044 1914
         }
2045 1915
 

正在加载...
取消
保存