linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pcnet32 cable status check
@ 2002-09-30 19:31 Kent Yoder
  2002-09-30 20:21 ` Jeff Garzik
  0 siblings, 1 reply; 15+ messages in thread
From: Kent Yoder @ 2002-09-30 19:31 UTC (permalink / raw)
  To: linux-kernel; +Cc: tsbogend, jgarzik


  Hi,

Name: PCnet32 cable status patch
Author: Kent Yoder
Status: Tested on 2.4.20-pre8

D: A patch for the pcnet32 driver to check the status of the 
D: cable via a watchdog timer as the e100/e1000 drivers do.

Comments and criticism are welcome, as I've gotten no response from the 
maintainer. 

Thanks,
Kent


--- linux-2.4.19.vanilla/drivers/net/pcnet32.c	Fri Aug  2 19:39:44 2002
+++ linux-2.4.19/drivers/net/pcnet32.c	Mon Sep 30 10:59:27 2002
@@ -22,8 +22,8 @@
  *************************************************************************/
 
 #define DRV_NAME	"pcnet32"
-#define DRV_VERSION	"1.27a"
-#define DRV_RELDATE	"10.02.2002"
+#define DRV_VERSION	"1.27b"
+#define DRV_RELDATE	"30.09.2002"
 #define PFX		DRV_NAME ": "
 
 static const char *version =
@@ -212,6 +212,8 @@
  *	   fix pci probe not increment cards_found
  *	   FD auto negotiate error workaround for xSeries250
  *	   clean up and using new mii module
+ * v1.27b  Sep 30 2002 Kent Yoder <yoder1@us.ibm.com>
+ * 	   Added timer for cable connection state changes.
  */
 
 
@@ -316,9 +318,11 @@
     int	shared_irq:1,			/* shared irq possible */
 	ltint:1,			/* enable TxDone-intr inhibitor */
 	dxsuflo:1,			/* disable transmit stop on uflo */
-	mii:1;				/* mii port available */
+	mii:1,				/* mii port available */
+	link:1;				/* cable link up/down */
     struct net_device	*next;
     struct mii_if_info mii_if;
+    struct timer_list	watchdog_timer;
 };
 
 static void pcnet32_probe_vlbus(void);
@@ -334,6 +338,7 @@
 static struct net_device_stats *pcnet32_get_stats(struct net_device *);
 static void pcnet32_set_multicast_list(struct net_device *);
 static int  pcnet32_ioctl(struct net_device *, struct ifreq *, int);
+static void pcnet32_watchdog(struct net_device *);
 static int mdio_read(struct net_device *dev, int phy_id, int reg_num);
 static void mdio_write(struct net_device *dev, int phy_id, int reg_num, int val);
 
@@ -778,6 +783,13 @@
 	}
     }
 
+    /* Set the mii phy_id so that we can query the link state */
+    if (lp->mii)
+	lp->mii_if.phy_id = ((lp->a.read_bcr (ioaddr, 33)) >> 5) & 0x1f;
+
+    init_timer(&lp->watchdog_timer);
+    lp->watchdog_timer.data = (unsigned long) dev;
+    lp->watchdog_timer.function = (void *) &pcnet32_watchdog;
     
     /* The PCNET32-specific entries in the device structure. */
     dev->open = &pcnet32_open;
@@ -902,6 +914,19 @@
 
     netif_start_queue(dev);
 
+    /* If we have mii, print the link status and start the watchdog */
+    if (lp->mii) {
+	if(mii_link_ok (&lp->mii_if)) {
+	    printk (KERN_INFO PFX "%s: Cable link is up.\n", dev->name);
+	    lp->link = 1;
+	} else {
+	    printk (KERN_INFO PFX "%s: Cable not connected.\n", dev->name);
+	    lp->link = 0;
+	}
+
+        mod_timer(&(lp->watchdog_timer), jiffies + (2 * HZ));
+    }
+    
     i = 0;
     while (i++ < 100)
 	if (lp->a.read_csr (ioaddr, 0) & 0x0100)
@@ -1372,6 +1397,8 @@
     struct pcnet32_private *lp = dev->priv;
     int i;
 
+    del_timer_sync(&lp->watchdog_timer);
+
     netif_stop_queue(dev);
 
     lp->stats.rx_missed_errors = lp->a.read_csr (ioaddr, 112);
@@ -1650,6 +1677,22 @@
 	}
     }
     return -EOPNOTSUPP;
+}
+
+static void pcnet32_watchdog(struct net_device *dev)
+{
+    struct pcnet32_private *lp = dev->priv;
+
+    if(!netif_running(dev))
+	return;
+
+    if(mii_link_ok(&lp->mii_if) != (lp->link & 1)) {
+	printk(KERN_INFO PFX "%s: Cable link is %s.\n", 
+		dev->name, (lp->link ? "down" : "up"));
+	lp->link ^= 1;
+    }
+    
+    mod_timer(&(lp->watchdog_timer), jiffies + (2 * HZ));
 }
 
 static struct pci_driver pcnet32_driver = {



^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2002-10-22  1:27 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-09-30 19:31 [PATCH] pcnet32 cable status check Kent Yoder
2002-09-30 20:21 ` Jeff Garzik
2002-09-30 21:48   ` Oops on 2.5.39 was " Kent Yoder
2002-09-30 21:55     ` Jeff Garzik
2002-10-01 16:34   ` Kent Yoder
2002-10-01 16:50     ` Felipe W Damasio
2002-10-01 17:07       ` Jeff Garzik
2002-10-01 17:19         ` Kent Yoder
2002-10-01 17:19     ` Jeff Garzik
2002-10-01 17:30       ` Kent Yoder
2002-10-01 17:36         ` Jeff Garzik
2002-10-01 19:35           ` Kent Yoder
2002-10-01 17:40       ` Felipe W Damasio
2002-10-07 15:31       ` Kent Yoder
2002-10-22  1:33     ` Jeff Garzik

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).