aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/sis190.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/sis190.c')
-rw-r--r--drivers/net/sis190.c152
1 files changed, 75 insertions, 77 deletions
diff --git a/drivers/net/sis190.c b/drivers/net/sis190.c
index ead1d31308f8..4487b065ef72 100644
--- a/drivers/net/sis190.c
+++ b/drivers/net/sis190.c
@@ -17,7 +17,9 @@
17 17
18 See the file COPYING in this distribution for more information. 18 See the file COPYING in this distribution for more information.
19 19
20 */ 20*/
21
22#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
21 23
22#include <linux/module.h> 24#include <linux/module.h>
23#include <linux/moduleparam.h> 25#include <linux/moduleparam.h>
@@ -32,17 +34,6 @@
32#include <linux/dma-mapping.h> 34#include <linux/dma-mapping.h>
33#include <asm/irq.h> 35#include <asm/irq.h>
34 36
35#define net_drv(p, arg...) if (netif_msg_drv(p)) \
36 printk(arg)
37#define net_probe(p, arg...) if (netif_msg_probe(p)) \
38 printk(arg)
39#define net_link(p, arg...) if (netif_msg_link(p)) \
40 printk(arg)
41#define net_intr(p, arg...) if (netif_msg_intr(p)) \
42 printk(arg)
43#define net_tx_err(p, arg...) if (netif_msg_tx_err(p)) \
44 printk(arg)
45
46#define PHY_MAX_ADDR 32 37#define PHY_MAX_ADDR 32
47#define PHY_ID_ANY 0x1f 38#define PHY_ID_ANY 0x1f
48#define MII_REG_ANY 0x1f 39#define MII_REG_ANY 0x1f
@@ -50,7 +41,6 @@
50#define DRV_VERSION "1.4" 41#define DRV_VERSION "1.4"
51#define DRV_NAME "sis190" 42#define DRV_NAME "sis190"
52#define SIS190_DRIVER_NAME DRV_NAME " Gigabit Ethernet driver " DRV_VERSION 43#define SIS190_DRIVER_NAME DRV_NAME " Gigabit Ethernet driver " DRV_VERSION
53#define PFX DRV_NAME ": "
54 44
55#define sis190_rx_skb netif_rx 45#define sis190_rx_skb netif_rx
56#define sis190_rx_quota(count, quota) count 46#define sis190_rx_quota(count, quota) count
@@ -382,7 +372,7 @@ static void __mdio_cmd(void __iomem *ioaddr, u32 ctl)
382 } 372 }
383 373
384 if (i > 99) 374 if (i > 99)
385 printk(KERN_ERR PFX "PHY command failed !\n"); 375 pr_err("PHY command failed !\n");
386} 376}
387 377
388static void mdio_write(void __iomem *ioaddr, int phy_id, int reg, int val) 378static void mdio_write(void __iomem *ioaddr, int phy_id, int reg, int val)
@@ -590,8 +580,7 @@ static int sis190_rx_interrupt(struct net_device *dev,
590 580
591 status = le32_to_cpu(desc->PSize); 581 status = le32_to_cpu(desc->PSize);
592 582
593 // net_intr(tp, KERN_INFO "%s: Rx PSize = %08x.\n", dev->name, 583 //netif_info(tp, intr, dev, "Rx PSize = %08x\n", status);
594 // status);
595 584
596 if (sis190_rx_pkt_err(status, stats) < 0) 585 if (sis190_rx_pkt_err(status, stats) < 0)
597 sis190_give_to_asic(desc, tp->rx_buf_sz); 586 sis190_give_to_asic(desc, tp->rx_buf_sz);
@@ -602,9 +591,8 @@ static int sis190_rx_interrupt(struct net_device *dev,
602 struct pci_dev *pdev = tp->pci_dev; 591 struct pci_dev *pdev = tp->pci_dev;
603 592
604 if (unlikely(pkt_size > tp->rx_buf_sz)) { 593 if (unlikely(pkt_size > tp->rx_buf_sz)) {
605 net_intr(tp, KERN_INFO 594 netif_info(tp, intr, dev,
606 "%s: (frag) status = %08x.\n", 595 "(frag) status = %08x\n", status);
607 dev->name, status);
608 stats->rx_dropped++; 596 stats->rx_dropped++;
609 stats->rx_length_errors++; 597 stats->rx_length_errors++;
610 sis190_give_to_asic(desc, tp->rx_buf_sz); 598 sis190_give_to_asic(desc, tp->rx_buf_sz);
@@ -638,12 +626,12 @@ static int sis190_rx_interrupt(struct net_device *dev,
638 tp->cur_rx = cur_rx; 626 tp->cur_rx = cur_rx;
639 627
640 delta = sis190_rx_fill(tp, dev, tp->dirty_rx, tp->cur_rx); 628 delta = sis190_rx_fill(tp, dev, tp->dirty_rx, tp->cur_rx);
641 if (!delta && count && netif_msg_intr(tp)) 629 if (!delta && count)
642 printk(KERN_INFO "%s: no Rx buffer allocated.\n", dev->name); 630 netif_info(tp, intr, dev, "no Rx buffer allocated\n");
643 tp->dirty_rx += delta; 631 tp->dirty_rx += delta;
644 632
645 if (((tp->dirty_rx + NUM_RX_DESC) == tp->cur_rx) && netif_msg_intr(tp)) 633 if ((tp->dirty_rx + NUM_RX_DESC) == tp->cur_rx)
646 printk(KERN_EMERG "%s: Rx buffers exhausted.\n", dev->name); 634 netif_emerg(tp, intr, dev, "Rx buffers exhausted\n");
647 635
648 return count; 636 return count;
649} 637}
@@ -752,10 +740,10 @@ static irqreturn_t sis190_interrupt(int irq, void *__dev)
752 740
753 SIS_W32(IntrStatus, status); 741 SIS_W32(IntrStatus, status);
754 742
755 // net_intr(tp, KERN_INFO "%s: status = %08x.\n", dev->name, status); 743// netif_info(tp, intr, dev, "status = %08x\n", status);
756 744
757 if (status & LinkChange) { 745 if (status & LinkChange) {
758 net_intr(tp, KERN_INFO "%s: link change.\n", dev->name); 746 netif_info(tp, intr, dev, "link change\n");
759 schedule_work(&tp->phy_task); 747 schedule_work(&tp->phy_task);
760 } 748 }
761 749
@@ -931,8 +919,7 @@ static void sis190_phy_task(struct work_struct *work)
931 } else if (!(mdio_read_latched(ioaddr, phy_id, MII_BMSR) & 919 } else if (!(mdio_read_latched(ioaddr, phy_id, MII_BMSR) &
932 BMSR_ANEGCOMPLETE)) { 920 BMSR_ANEGCOMPLETE)) {
933 netif_carrier_off(dev); 921 netif_carrier_off(dev);
934 net_link(tp, KERN_WARNING "%s: auto-negotiating...\n", 922 netif_warn(tp, link, dev, "auto-negotiating...\n");
935 dev->name);
936 mod_timer(&tp->timer, jiffies + SIS190_PHY_TIMEOUT); 923 mod_timer(&tp->timer, jiffies + SIS190_PHY_TIMEOUT);
937 } else { 924 } else {
938 /* Rejoice ! */ 925 /* Rejoice ! */
@@ -958,13 +945,13 @@ static void sis190_phy_task(struct work_struct *work)
958 u16 adv, autoexp, gigadv, gigrec; 945 u16 adv, autoexp, gigadv, gigrec;
959 946
960 val = mdio_read(ioaddr, phy_id, 0x1f); 947 val = mdio_read(ioaddr, phy_id, 0x1f);
961 net_link(tp, KERN_INFO "%s: mii ext = %04x.\n", dev->name, val); 948 netif_info(tp, link, dev, "mii ext = %04x\n", val);
962 949
963 val = mdio_read(ioaddr, phy_id, MII_LPA); 950 val = mdio_read(ioaddr, phy_id, MII_LPA);
964 adv = mdio_read(ioaddr, phy_id, MII_ADVERTISE); 951 adv = mdio_read(ioaddr, phy_id, MII_ADVERTISE);
965 autoexp = mdio_read(ioaddr, phy_id, MII_EXPANSION); 952 autoexp = mdio_read(ioaddr, phy_id, MII_EXPANSION);
966 net_link(tp, KERN_INFO "%s: mii lpa=%04x adv=%04x exp=%04x.\n", 953 netif_info(tp, link, dev, "mii lpa=%04x adv=%04x exp=%04x\n",
967 dev->name, val, adv, autoexp); 954 val, adv, autoexp);
968 955
969 if (val & LPA_NPAGE && autoexp & EXPANSION_NWAY) { 956 if (val & LPA_NPAGE && autoexp & EXPANSION_NWAY) {
970 /* check for gigabit speed */ 957 /* check for gigabit speed */
@@ -1005,8 +992,7 @@ static void sis190_phy_task(struct work_struct *work)
1005 992
1006 tp->negotiated_lpa = p->val; 993 tp->negotiated_lpa = p->val;
1007 994
1008 net_link(tp, KERN_INFO "%s: link on %s mode.\n", dev->name, 995 netif_info(tp, link, dev, "link on %s mode\n", p->msg);
1009 p->msg);
1010 netif_carrier_on(dev); 996 netif_carrier_on(dev);
1011 } 997 }
1012 998
@@ -1192,9 +1178,8 @@ static netdev_tx_t sis190_start_xmit(struct sk_buff *skb,
1192 1178
1193 if (unlikely(le32_to_cpu(desc->status) & OWNbit)) { 1179 if (unlikely(le32_to_cpu(desc->status) & OWNbit)) {
1194 netif_stop_queue(dev); 1180 netif_stop_queue(dev);
1195 net_tx_err(tp, KERN_ERR PFX 1181 netif_err(tp, tx_err, dev,
1196 "%s: BUG! Tx Ring full when queue awake!\n", 1182 "BUG! Tx Ring full when queue awake!\n");
1197 dev->name);
1198 return NETDEV_TX_BUSY; 1183 return NETDEV_TX_BUSY;
1199 } 1184 }
1200 1185
@@ -1294,9 +1279,9 @@ static u16 sis190_default_phy(struct net_device *dev)
1294 1279
1295 if (mii_if->phy_id != phy_default->phy_id) { 1280 if (mii_if->phy_id != phy_default->phy_id) {
1296 mii_if->phy_id = phy_default->phy_id; 1281 mii_if->phy_id = phy_default->phy_id;
1297 net_probe(tp, KERN_INFO 1282 if (netif_msg_probe(tp))
1298 "%s: Using transceiver at address %d as default.\n", 1283 pr_info("%s: Using transceiver at address %d as default\n",
1299 pci_name(tp->pci_dev), mii_if->phy_id); 1284 pci_name(tp->pci_dev), mii_if->phy_id);
1300 } 1285 }
1301 1286
1302 status = mdio_read(ioaddr, mii_if->phy_id, MII_BMCR); 1287 status = mdio_read(ioaddr, mii_if->phy_id, MII_BMCR);
@@ -1334,14 +1319,15 @@ static void sis190_init_phy(struct net_device *dev, struct sis190_private *tp,
1334 ((mii_status & (BMSR_100FULL | BMSR_100HALF)) ? 1319 ((mii_status & (BMSR_100FULL | BMSR_100HALF)) ?
1335 LAN : HOME) : p->type; 1320 LAN : HOME) : p->type;
1336 tp->features |= p->feature; 1321 tp->features |= p->feature;
1337 net_probe(tp, KERN_INFO "%s: %s transceiver at address %d.\n", 1322 if (netif_msg_probe(tp))
1338 pci_name(tp->pci_dev), p->name, phy_id); 1323 pr_info("%s: %s transceiver at address %d\n",
1324 pci_name(tp->pci_dev), p->name, phy_id);
1339 } else { 1325 } else {
1340 phy->type = UNKNOWN; 1326 phy->type = UNKNOWN;
1341 net_probe(tp, KERN_INFO 1327 if (netif_msg_probe(tp))
1342 "%s: unknown PHY 0x%x:0x%x transceiver at address %d\n", 1328 pr_info("%s: unknown PHY 0x%x:0x%x transceiver at address %d\n",
1343 pci_name(tp->pci_dev), 1329 pci_name(tp->pci_dev),
1344 phy->id[0], (phy->id[1] & 0xfff0), phy_id); 1330 phy->id[0], (phy->id[1] & 0xfff0), phy_id);
1345 } 1331 }
1346} 1332}
1347 1333
@@ -1405,8 +1391,9 @@ static int __devinit sis190_mii_probe(struct net_device *dev)
1405 } 1391 }
1406 1392
1407 if (list_empty(&tp->first_phy)) { 1393 if (list_empty(&tp->first_phy)) {
1408 net_probe(tp, KERN_INFO "%s: No MII transceivers found!\n", 1394 if (netif_msg_probe(tp))
1409 pci_name(tp->pci_dev)); 1395 pr_info("%s: No MII transceivers found!\n",
1396 pci_name(tp->pci_dev));
1410 rc = -EIO; 1397 rc = -EIO;
1411 goto out; 1398 goto out;
1412 } 1399 }
@@ -1452,7 +1439,8 @@ static struct net_device * __devinit sis190_init_board(struct pci_dev *pdev)
1452 1439
1453 dev = alloc_etherdev(sizeof(*tp)); 1440 dev = alloc_etherdev(sizeof(*tp));
1454 if (!dev) { 1441 if (!dev) {
1455 net_drv(&debug, KERN_ERR PFX "unable to alloc new ethernet\n"); 1442 if (netif_msg_drv(&debug))
1443 pr_err("unable to alloc new ethernet\n");
1456 rc = -ENOMEM; 1444 rc = -ENOMEM;
1457 goto err_out_0; 1445 goto err_out_0;
1458 } 1446 }
@@ -1465,34 +1453,39 @@ static struct net_device * __devinit sis190_init_board(struct pci_dev *pdev)
1465 1453
1466 rc = pci_enable_device(pdev); 1454 rc = pci_enable_device(pdev);
1467 if (rc < 0) { 1455 if (rc < 0) {
1468 net_probe(tp, KERN_ERR "%s: enable failure\n", pci_name(pdev)); 1456 if (netif_msg_probe(tp))
1457 pr_err("%s: enable failure\n", pci_name(pdev));
1469 goto err_free_dev_1; 1458 goto err_free_dev_1;
1470 } 1459 }
1471 1460
1472 rc = -ENODEV; 1461 rc = -ENODEV;
1473 1462
1474 if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { 1463 if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) {
1475 net_probe(tp, KERN_ERR "%s: region #0 is no MMIO resource.\n", 1464 if (netif_msg_probe(tp))
1476 pci_name(pdev)); 1465 pr_err("%s: region #0 is no MMIO resource\n",
1466 pci_name(pdev));
1477 goto err_pci_disable_2; 1467 goto err_pci_disable_2;
1478 } 1468 }
1479 if (pci_resource_len(pdev, 0) < SIS190_REGS_SIZE) { 1469 if (pci_resource_len(pdev, 0) < SIS190_REGS_SIZE) {
1480 net_probe(tp, KERN_ERR "%s: invalid PCI region size(s).\n", 1470 if (netif_msg_probe(tp))
1481 pci_name(pdev)); 1471 pr_err("%s: invalid PCI region size(s)\n",
1472 pci_name(pdev));
1482 goto err_pci_disable_2; 1473 goto err_pci_disable_2;
1483 } 1474 }
1484 1475
1485 rc = pci_request_regions(pdev, DRV_NAME); 1476 rc = pci_request_regions(pdev, DRV_NAME);
1486 if (rc < 0) { 1477 if (rc < 0) {
1487 net_probe(tp, KERN_ERR PFX "%s: could not request regions.\n", 1478 if (netif_msg_probe(tp))
1488 pci_name(pdev)); 1479 pr_err("%s: could not request regions\n",
1480 pci_name(pdev));
1489 goto err_pci_disable_2; 1481 goto err_pci_disable_2;
1490 } 1482 }
1491 1483
1492 rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); 1484 rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32));
1493 if (rc < 0) { 1485 if (rc < 0) {
1494 net_probe(tp, KERN_ERR "%s: DMA configuration failed.\n", 1486 if (netif_msg_probe(tp))
1495 pci_name(pdev)); 1487 pr_err("%s: DMA configuration failed\n",
1488 pci_name(pdev));
1496 goto err_free_res_3; 1489 goto err_free_res_3;
1497 } 1490 }
1498 1491
@@ -1500,8 +1493,9 @@ static struct net_device * __devinit sis190_init_board(struct pci_dev *pdev)
1500 1493
1501 ioaddr = ioremap(pci_resource_start(pdev, 0), SIS190_REGS_SIZE); 1494 ioaddr = ioremap(pci_resource_start(pdev, 0), SIS190_REGS_SIZE);
1502 if (!ioaddr) { 1495 if (!ioaddr) {
1503 net_probe(tp, KERN_ERR "%s: cannot remap MMIO, aborting\n", 1496 if (netif_msg_probe(tp))
1504 pci_name(pdev)); 1497 pr_err("%s: cannot remap MMIO, aborting\n",
1498 pci_name(pdev));
1505 rc = -EIO; 1499 rc = -EIO;
1506 goto err_free_res_3; 1500 goto err_free_res_3;
1507 } 1501 }
@@ -1537,9 +1531,8 @@ static void sis190_tx_timeout(struct net_device *dev)
1537 if (tmp8 & CmdTxEnb) 1531 if (tmp8 & CmdTxEnb)
1538 SIS_W8(TxControl, tmp8 & ~CmdTxEnb); 1532 SIS_W8(TxControl, tmp8 & ~CmdTxEnb);
1539 1533
1540 1534 netif_info(tp, tx_err, dev, "Transmit timeout, status %08x %08x\n",
1541 net_tx_err(tp, KERN_INFO "%s: Transmit timeout, status %08x %08x.\n", 1535 SIS_R32(TxControl), SIS_R32(TxSts));
1542 dev->name, SIS_R32(TxControl), SIS_R32(TxSts));
1543 1536
1544 /* Disable interrupts by clearing the interrupt mask. */ 1537 /* Disable interrupts by clearing the interrupt mask. */
1545 SIS_W32(IntrMask, 0x0000); 1538 SIS_W32(IntrMask, 0x0000);
@@ -1568,15 +1561,16 @@ static int __devinit sis190_get_mac_addr_from_eeprom(struct pci_dev *pdev,
1568 u16 sig; 1561 u16 sig;
1569 int i; 1562 int i;
1570 1563
1571 net_probe(tp, KERN_INFO "%s: Read MAC address from EEPROM\n", 1564 if (netif_msg_probe(tp))
1572 pci_name(pdev)); 1565 pr_info("%s: Read MAC address from EEPROM\n", pci_name(pdev));
1573 1566
1574 /* Check to see if there is a sane EEPROM */ 1567 /* Check to see if there is a sane EEPROM */
1575 sig = (u16) sis190_read_eeprom(ioaddr, EEPROMSignature); 1568 sig = (u16) sis190_read_eeprom(ioaddr, EEPROMSignature);
1576 1569
1577 if ((sig == 0xffff) || (sig == 0x0000)) { 1570 if ((sig == 0xffff) || (sig == 0x0000)) {
1578 net_probe(tp, KERN_INFO "%s: Error EEPROM read %x.\n", 1571 if (netif_msg_probe(tp))
1579 pci_name(pdev), sig); 1572 pr_info("%s: Error EEPROM read %x\n",
1573 pci_name(pdev), sig);
1580 return -EIO; 1574 return -EIO;
1581 } 1575 }
1582 1576
@@ -1610,8 +1604,8 @@ static int __devinit sis190_get_mac_addr_from_apc(struct pci_dev *pdev,
1610 u8 reg, tmp8; 1604 u8 reg, tmp8;
1611 unsigned int i; 1605 unsigned int i;
1612 1606
1613 net_probe(tp, KERN_INFO "%s: Read MAC address from APC.\n", 1607 if (netif_msg_probe(tp))
1614 pci_name(pdev)); 1608 pr_info("%s: Read MAC address from APC\n", pci_name(pdev));
1615 1609
1616 for (i = 0; i < ARRAY_SIZE(ids); i++) { 1610 for (i = 0; i < ARRAY_SIZE(ids); i++) {
1617 isa_bridge = pci_get_device(PCI_VENDOR_ID_SI, ids[i], NULL); 1611 isa_bridge = pci_get_device(PCI_VENDOR_ID_SI, ids[i], NULL);
@@ -1620,8 +1614,9 @@ static int __devinit sis190_get_mac_addr_from_apc(struct pci_dev *pdev,
1620 } 1614 }
1621 1615
1622 if (!isa_bridge) { 1616 if (!isa_bridge) {
1623 net_probe(tp, KERN_INFO "%s: Can not find ISA bridge.\n", 1617 if (netif_msg_probe(tp))
1624 pci_name(pdev)); 1618 pr_info("%s: Can not find ISA bridge\n",
1619 pci_name(pdev));
1625 return -EIO; 1620 return -EIO;
1626 } 1621 }
1627 1622
@@ -1702,7 +1697,7 @@ static void sis190_set_speed_auto(struct net_device *dev)
1702 int phy_id = tp->mii_if.phy_id; 1697 int phy_id = tp->mii_if.phy_id;
1703 int val; 1698 int val;
1704 1699
1705 net_link(tp, KERN_INFO "%s: Enabling Auto-negotiation.\n", dev->name); 1700 netif_info(tp, link, dev, "Enabling Auto-negotiation\n");
1706 1701
1707 val = mdio_read(ioaddr, phy_id, MII_ADVERTISE); 1702 val = mdio_read(ioaddr, phy_id, MII_ADVERTISE);
1708 1703
@@ -1829,7 +1824,8 @@ static int __devinit sis190_init_one(struct pci_dev *pdev,
1829 int rc; 1824 int rc;
1830 1825
1831 if (!printed_version) { 1826 if (!printed_version) {
1832 net_drv(&debug, KERN_INFO SIS190_DRIVER_NAME " loaded.\n"); 1827 if (netif_msg_drv(&debug))
1828 pr_info(SIS190_DRIVER_NAME " loaded\n");
1833 printed_version = 1; 1829 printed_version = 1;
1834 } 1830 }
1835 1831
@@ -1869,12 +1865,14 @@ static int __devinit sis190_init_one(struct pci_dev *pdev,
1869 if (rc < 0) 1865 if (rc < 0)
1870 goto err_remove_mii; 1866 goto err_remove_mii;
1871 1867
1872 net_probe(tp, KERN_INFO "%s: %s at %p (IRQ: %d), %pM\n", 1868 if (netif_msg_probe(tp)) {
1873 pci_name(pdev), sis_chip_info[ent->driver_data].name, 1869 netdev_info(dev, "%s: %s at %p (IRQ: %d), %pM\n",
1874 ioaddr, dev->irq, dev->dev_addr); 1870 pci_name(pdev),
1875 1871 sis_chip_info[ent->driver_data].name,
1876 net_probe(tp, KERN_INFO "%s: %s mode.\n", dev->name, 1872 ioaddr, dev->irq, dev->dev_addr);
1877 (tp->features & F_HAS_RGMII) ? "RGMII" : "GMII"); 1873 netdev_info(dev, "%s mode.\n",
1874 (tp->features & F_HAS_RGMII) ? "RGMII" : "GMII");
1875 }
1878 1876
1879 netif_carrier_off(dev); 1877 netif_carrier_off(dev);
1880 1878