[PATCH] Link change interrupt support to 8139cp ethernet driver

From: Felipe W Damasio (felipewd@terra.com.br)
Date: Sat Aug 24 2002 - 01:57:38 EST


        Hi,

        According to Clifford Chiang <wrchiang@msx.realtek.com.tw>, the LinkChg
is used just to inform the driver the link status has changed, the
changes are automatically set.

        Here's a patch against version 0.2.1.

        Please consider pulling it from:

        http://cscience.org/~felipewd/linux/patches-fwd/2.5/8139cp-LinkChg.patch

        Comments?

Felipe

--- ./drivers/net/8139cp.c.orig Mon Aug 19 22:06:01 2002
+++ ./drivers/net/8139cp.c Sat Aug 24 06:49:31 2002
@@ -26,7 +26,6 @@
         TODO, in rough priority order:
         * Test Tx checksumming thoroughly
         * dev->tx_timeout
- * LinkChg interrupt
         * Support forcing media type with a module parameter,
           like dl2k.c/sundance.c
         * Constants (module parms?) for Rx work limit
@@ -396,6 +395,8 @@
 
 static void __cp_set_rx_mode (struct net_device *dev);
 static void cp_tx (struct cp_private *cp);
+static int mdio_read(struct net_device *dev, int phy_id, int location);
+static void mdio_write(struct net_device *dev, int phy_id, int location, int value);
 static void cp_clean_rings (struct cp_private *cp);
 
 enum board_type {
@@ -677,6 +678,36 @@
                 cp_rx(cp);
         if (status & (TxOK | TxErr | TxEmpty | SWInt))
                 cp_tx(cp);
+ if (status & LinkChg) {
+ if (netif_msg_link(cp)) {
+ u16 bmcr = mdio_read (dev, cp->mii_if.phy_id, MII_BMCR);
+
+ printk (PFX "Link Changed: ");
+ if (bmcr & BMCR_ANENABLE) {
+ u16 lpa, advertise;
+
+ lpa = mdio_read (dev, cp->mii_if.phy_id, MII_ADVERTISE);
+ advertise = mdio_read (dev, cp->mii_if.phy_id, MII_LPA);
+
+ advertise &= lpa;
+
+ if (advertise & ADVERTISE_100FULL)
+ printk ("100Mbps, full duplex\n");
+ else if (advertise & ADVERTISE_100HALF)
+ printk ("100Mbps, half duplex\n");
+ else if (advertise & ADVERTISE_10FULL)
+ printk ("10Mbps, full duplex\n");
+ else if (advertise & ADVERTISE_10HALF)
+ printk ("10Mbps, half duplex\n");
+ }
+ else {
+ printk ("%dMbps, %s duplex\n",
+ bmcr & BMCR_SPEED100 ? 100 : 10,
+ bmcr & BMCR_FULLDPLX ? "full" : "half"
+ );
+ }
+ }
+ }
 
         cpw16_f(IntrStatus, status);
 
-
To unsubscribe from this list: send the line "unsubscribe linux-net" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html



This archive was generated by hypermail 2b29 : Sat Aug 31 2002 - 22:00:01 EST