[etherlab-users] 8139too-2.6.35 patch and "datagram UNMATCHED" warning question

Jacques GANGLOFF jacques.gangloff at unistra.fr
Sat Oct 9 17:42:33 CEST 2010


Hi,

First of all many thanks to etherlab and Florian Pose for this fantastic piece of open-source software. A programmer who cares about the strict accuracy of grammatical rules in kernel messages deserves the most deepest respect :

EC_MASTER_WARN(master, "%u datagram%s UNMATCHED!\n",
                   master->stats.unmatched,
                   master->stats.unmatched == 1 ? "" : "s");

I have precisely a little question about this warning. When I run the user/main.c example on Beckhoff slaves (EK1100, EL2008, EL4134, EL3102), the first time after a "/etc/init.d/ethercat start" everything runs smoothly and there are no warning in dmesg. But every subsequent calls to ec_user_example generate a "WARNING 0: 1 datagram UNMATCHED!" warning.

If I go through a "/etc/init.d/ethercat stop" "/etc/init.d/ethercat start" cycle, the first call, and only the first call just after is warning-less. I just found that strange so I would like to report it. Here you can find some debug 1 level messages surrounding this warning :

EtherCAT 0: Domain0: Logical address 0x00000000, 23 byte, expected working counter 7.
EtherCAT 0:   Datagram domain0-0: Logical offset 0x00000000, 23 byte, type LRW.
EtherCAT DEBUG 0: Stopping master thread.
EtherCAT DEBUG 0: Master IDLE thread exiting...
EtherCAT 0: Master thread exited.
EtherCAT DEBUG 0: FSM datagram is d16d9be0.
EtherCAT 0: Starting EtherCAT-OP thread.
EtherCAT DEBUG 0: Operation thread running with fsm interval = 1000 us, max data size=11250
EtherCAT WARNING 0: 1 datagram UNMATCHED!
EtherCAT DEBUG 0: mmap()
EtherCAT DEBUG 0: Vma fault, virtual_address = b7854000, offset = 0, page = c33fbf80
EtherCAT DEBUG 0-1: Changing state from PREOP to OP.
EtherCAT DEBUG 0-1: Configuring...
EtherCAT DEBUG 0-1: Now in INIT.
EtherCAT DEBUG 0-1: Clearing FMMU configurations...
EtherCAT DEBUG 0-1: Clearing sync manager configurations...
EtherCAT DEBUG 0-1: Clearing DC assignment...

It happens with the generic or the 8139too driver. I'm running linux 2.6.35.7 with xenomai patch on a slackware 13.1. The machine is a HP Z400. I installed the latest 1.5 etherlab master.

I modified the 8139too driver of the 2.6.35.7 to obtain 8139too-2.6.35-ethercat.c. You can find the patch below. I did not tested it extensively. But so far no bug.

Best,
Jacques Gangloff

*** 8139too-2.6.35-orig.c	2010-10-07 18:16:39.000000000 +0200
--- 8139too-2.6.35-ethercat.c	2010-10-08 10:00:22.000000000 +0200
***************
*** 1,4 ****
--- 1,41 ----
+ /******************************************************************************
+  *
+  *  $Id$
+  *
+  *  Copyright (C) 2006-2009  Florian Pose, Ingenieurgemeinschaft IgH
+  *
+  *  This file is part of the IgH EtherCAT Master.
+  *
+  *  The IgH EtherCAT Master is free software; you can redistribute it and/or
+  *  modify it under the terms of the GNU General Public License version 2, as
+  *  published by the Free Software Foundation.
+  *
+  *  The IgH EtherCAT Master is distributed in the hope that it will be useful,
+  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
+  *  Public License for more details.
+  *
+  *  You should have received a copy of the GNU General Public License along
+  *  with the IgH EtherCAT Master; if not, write to the Free Software
+  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+  *
+  *  ---
+  *
+  *  The license mentioned above concerns the source code only. Using the
+  *  EtherCAT technology and brand is only permitted in compliance with the
+  *  industrial property and similar rights of Beckhoff Automation GmbH.
+  *
+  *****************************************************************************/
+
+ /**
+    \file
+    EtherCAT driver for RTL8139-compatible NICs.
+ */
+
+ /**********************************RTL_W16_F(IntrMask, rtl8139_intr_mask);*******************************************/
+
 /*
+   Former documentation:

 	8139too.c: A RealTek RTL-8139 Fast Ethernet driver for Linux.

***************
*** 89,97 ****

 */

! #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
!
! #define DRV_NAME	"8139too"
 #define DRV_VERSION	"0.9.28"


--- 126,132 ----

 */

! #define DRV_NAME	"ec_8139too"
 #define DRV_VERSION	"0.9.28"


***************
*** 113,119 ****
 #include <linux/gfp.h>
 #include <asm/irq.h>

! #define RTL8139_DRIVER_NAME   DRV_NAME " Fast Ethernet driver " DRV_VERSION

 /* Default Message level */
 #define RTL8139_DEF_MSG_ENABLE   (NETIF_MSG_DRV   | \
--- 148,161 ----
 #include <linux/gfp.h>
 #include <asm/irq.h>

! #include "../globals.h"
! #include "ecdev.h"
!
! #define RTL8139_DRIVER_NAME DRV_NAME \
!                             " EtherCAT-capable Fast Ethernet driver " \
!                             DRV_VERSION ", master " EC_MASTER_VERSION
!
! #define PFX DRV_NAME ": "

 /* Default Message level */
 #define RTL8139_DEF_MSG_ENABLE   (NETIF_MSG_DRV   | \
***************
*** 132,140 ****
 #  define assert(expr) do {} while (0)
 #else
 #  define assert(expr) \
!         if (unlikely(!(expr))) {				\
! 		pr_err("Assertion failed! %s,%s,%s,line=%d\n",	\
! 		       #expr, __FILE__, __func__, __LINE__);	\
         }
 #endif

--- 174,182 ----
 #  define assert(expr) do {} while (0)
 #else
 #  define assert(expr) \
!         if(unlikely(!(expr))) {				        \
!         pr_err("Assertion failed! %s,%s,%s,line=%d\n",	\
! 	#expr, __FILE__, __func__, __LINE__);			\
         }
 #endif

***************
*** 272,278 ****

 	{0,}
 };
! MODULE_DEVICE_TABLE (pci, rtl8139_pci_tbl);

 static struct {
 	const char str[ETH_GSTRING_LEN];
--- 314,322 ----

 	{0,}
 };
!
! /* prevent driver from being loaded automatically */
! //MODULE_DEVICE_TABLE (pci, rtl8139_pci_tbl);

 static struct {
 	const char str[ETH_GSTRING_LEN];
***************
*** 604,615 ****
 	struct mii_if_info	mii;
 	unsigned int		regs_len;
 	unsigned long		fifo_copy_timeout;
 };

! MODULE_AUTHOR ("Jeff Garzik <jgarzik at pobox.com>");
! MODULE_DESCRIPTION ("RealTek RTL-8139 Fast Ethernet driver");
 MODULE_LICENSE("GPL");
! MODULE_VERSION(DRV_VERSION);

 module_param(use_io, int, 0);
 MODULE_PARM_DESC(use_io, "Force use of I/O access mode. 0=MMIO 1=PIO");
--- 648,661 ----
 	struct mii_if_info	mii;
 	unsigned int		regs_len;
 	unsigned long		fifo_copy_timeout;
+
+ 	ec_device_t *ecdev;
 };

! MODULE_AUTHOR("Florian Pose <fp at igh-essen.com>");
! MODULE_DESCRIPTION("RealTek RTL-8139 EtherCAT driver");
 MODULE_LICENSE("GPL");
! MODULE_VERSION(EC_MASTER_VERSION);

 module_param(use_io, int, 0);
 MODULE_PARM_DESC(use_io, "Force use of I/O access mode. 0=MMIO 1=PIO");
***************
*** 622,627 ****
--- 668,675 ----
 MODULE_PARM_DESC (media, "8139too: Bits 4+9: force full duplex, bit 5: 100Mbps");
 MODULE_PARM_DESC (full_duplex, "8139too: Force full duplex for board(s) (1)");

+ void ec_poll(struct net_device *);
+
 static int read_eeprom (void __iomem *ioaddr, int location, int addr_len);
 static int rtl8139_open (struct net_device *dev);
 static int mdio_read (struct net_device *dev, int phy_id, int location);
***************
*** 630,637 ****
 static void rtl8139_start_thread(struct rtl8139_private *tp);
 static void rtl8139_tx_timeout (struct net_device *dev);
 static void rtl8139_init_ring (struct net_device *dev);
! static netdev_tx_t rtl8139_start_xmit (struct sk_buff *skb,
! 				       struct net_device *dev);
 #ifdef CONFIG_NET_POLL_CONTROLLER
 static void rtl8139_poll_controller(struct net_device *dev);
 #endif
--- 678,685 ----
 static void rtl8139_start_thread(struct rtl8139_private *tp);
 static void rtl8139_tx_timeout (struct net_device *dev);
 static void rtl8139_init_ring (struct net_device *dev);
! static int rtl8139_start_xmit (struct sk_buff *skb,
! 			       struct net_device *dev);
 #ifdef CONFIG_NET_POLL_CONTROLLER
 static void rtl8139_poll_controller(struct net_device *dev);
 #endif
***************
*** 960,966 ****
 	    pdev->device == PCI_DEVICE_ID_REALTEK_8139 &&
 	    pdev->subsystem_vendor == PCI_VENDOR_ID_ATHEROS &&
 	    pdev->subsystem_device == PCI_DEVICE_ID_REALTEK_8139) {
! 		pr_info("OQO Model 2 detected. Forcing PIO\n");
 		use_io = 1;
 	}

--- 1008,1014 ----
 	    pdev->device == PCI_DEVICE_ID_REALTEK_8139 &&
 	    pdev->subsystem_vendor == PCI_VENDOR_ID_ATHEROS &&
 	    pdev->subsystem_device == PCI_DEVICE_ID_REALTEK_8139) {
! 		pr_info("8139too: OQO Model 2 detected. Forcing PIO\n");
 		use_io = 1;
 	}

***************
*** 1013,1031 ****
 	tp->mii.reg_num_mask = 0x1f;

 	/* dev is fully set up and ready to use now */
! 	pr_debug("about to register device named %s (%p)...\n",
! 		 dev->name, dev);
! 	i = register_netdev (dev);
! 	if (i) goto err_out;

 	pci_set_drvdata (pdev, dev);

! 	netdev_info(dev, "%s at 0x%lx, %pM, IRQ %d\n",
! 		    board_info[ent->driver_data].name,
! 		    dev->base_addr, dev->dev_addr, dev->irq);

! 	netdev_dbg(dev, "Identified 8139 chip type '%s'\n",
! 		   rtl_chip_info[tp->chipset].name);

 	/* Find the connected MII xcvrs.
 	   Doing this in open() would allow detecting external xcvrs later, but
--- 1061,1086 ----
 	tp->mii.reg_num_mask = 0x1f;

 	/* dev is fully set up and ready to use now */
! 	// offer device to EtherCAT master module
! 	tp->ecdev = ecdev_offer(dev, ec_poll, THIS_MODULE);
!
! 	if (!tp->ecdev) {
! 		pr_debug("about to register device named %s (%p)...\n", dev->name, dev);
! 		i = register_netdev (dev);
! 		if (i) goto err_out;
! 	}

 	pci_set_drvdata (pdev, dev);

! 	pr_info("%s: %s at 0x%lx, %pM, IRQ %d\n",
! 		dev->name,
! 		board_info[ent->driver_data].name,
! 		dev->base_addr,
! 		dev->dev_addr,
! 		dev->irq);

! 	pr_debug("%s:  Identified 8139 chip type '%s'\n",
! 		dev->name, rtl_chip_info[tp->chipset].name);

 	/* Find the connected MII xcvrs.
 	   Doing this in open() would allow detecting external xcvrs later, but
***************
*** 1038,1049 ****
 			if (mii_status != 0xffff  &&  mii_status != 0x0000) {
 				u16 advertising = mdio_read(dev, phy, 4);
 				tp->phys[phy_idx++] = phy;
! 				netdev_info(dev, "MII transceiver %d status 0x%04x advertising %04x\n",
! 					    phy, mii_status, advertising);
 			}
 		}
 		if (phy_idx == 0) {
! 			netdev_info(dev, "No MII transceivers found! Assuming SYM transceiver\n");
 			tp->phys[0] = 32;
 		}
 	} else
--- 1093,1105 ----
 			if (mii_status != 0xffff  &&  mii_status != 0x0000) {
 				u16 advertising = mdio_read(dev, phy, 4);
 				tp->phys[phy_idx++] = phy;
! 				pr_info("%s: MII transceiver %d status 0x%4.4x advertising %4.4x.\n",
! 					   dev->name, phy, mii_status, advertising);
 			}
 		}
 		if (phy_idx == 0) {
! 			pr_info("%s: No MII transceivers found! Assuming SYM transceiver.\n",
! 				   dev->name);
 			tp->phys[0] = 32;
 		}
 	} else
***************
*** 1062,1076 ****
 	if (board_idx < MAX_UNITS  &&  full_duplex[board_idx] > 0)
 		tp->mii.full_duplex = full_duplex[board_idx];
 	if (tp->mii.full_duplex) {
! 		netdev_info(dev, "Media type forced to Full Duplex\n");
 		/* Changing the MII-advertised media because might prevent
 		   re-connection. */
 		tp->mii.force_media = 1;
 	}
 	if (tp->default_port) {
! 		netdev_info(dev, "  Forcing %dMbps %s-duplex operation\n",
! 			    (option & 0x20 ? 100 : 10),
! 			    (option & 0x10 ? "full" : "half"));
 		mdio_write(dev, tp->phys[0], 0,
 				   ((option & 0x20) ? 0x2000 : 0) | 	/* 100Mbps? */
 				   ((option & 0x10) ? 0x0100 : 0)); /* Full duplex? */
--- 1118,1132 ----
 	if (board_idx < MAX_UNITS  &&  full_duplex[board_idx] > 0)
 		tp->mii.full_duplex = full_duplex[board_idx];
 	if (tp->mii.full_duplex) {
! 		pr_info("%s: Media type forced to Full Duplex.\n", dev->name);
 		/* Changing the MII-advertised media because might prevent
 		   re-connection. */
 		tp->mii.force_media = 1;
 	}
 	if (tp->default_port) {
! 		pr_info("  Forcing %dMbps %s-duplex operation.\n",
! 			   (option & 0x20 ? 100 : 10),
! 			   (option & 0x10 ? "full" : "half"));
 		mdio_write(dev, tp->phys[0], 0,
 				   ((option & 0x20) ? 0x2000 : 0) | 	/* 100Mbps? */
 				   ((option & 0x10) ? 0x0100 : 0)); /* Full duplex? */
***************
*** 1080,1085 ****
--- 1136,1146 ----
 	if (rtl_chip_info[tp->chipset].flags & HasHltClk)
 		RTL_W8 (HltClk, 'H');	/* 'R' would leave the clock running. */

+ 	if (tp->ecdev && ecdev_open(tp->ecdev)) {
+ 		ecdev_withdraw(tp->ecdev);
+ 		goto err_out;
+ 	}
+
 	return 0;

 err_out:
***************
*** 1092,1103 ****
 static void __devexit rtl8139_remove_one (struct pci_dev *pdev)
 {
 	struct net_device *dev = pci_get_drvdata (pdev);

 	assert (dev != NULL);

 	flush_scheduled_work();

! 	unregister_netdev (dev);

 	__rtl8139_cleanup_dev (dev);
 	pci_disable_device (pdev);
--- 1153,1171 ----
 static void __devexit rtl8139_remove_one (struct pci_dev *pdev)
 {
 	struct net_device *dev = pci_get_drvdata (pdev);
+ 	struct rtl8139_private *tp = netdev_priv(dev);

 	assert (dev != NULL);

 	flush_scheduled_work();

! 	if (tp->ecdev) {
! 		ecdev_close(tp->ecdev);
! 		ecdev_withdraw(tp->ecdev);
! 	}
! 	else {
! 		unregister_netdev (dev);
! 	}

 	__rtl8139_cleanup_dev (dev);
 	pci_disable_device (pdev);
***************
*** 1299,1314 ****
 	int retval;
 	void __iomem *ioaddr = tp->mmio_addr;

! 	retval = request_irq (dev->irq, rtl8139_interrupt, IRQF_SHARED, dev->name, dev);
! 	if (retval)
! 		return retval;

 	tp->tx_bufs = dma_alloc_coherent(&tp->pci_dev->dev, TX_BUF_TOT_LEN,
 					   &tp->tx_bufs_dma, GFP_KERNEL);
 	tp->rx_ring = dma_alloc_coherent(&tp->pci_dev->dev, RX_BUF_TOT_LEN,
 					   &tp->rx_ring_dma, GFP_KERNEL);
 	if (tp->tx_bufs == NULL || tp->rx_ring == NULL) {
! 		free_irq(dev->irq, dev);

 		if (tp->tx_bufs)
 			dma_free_coherent(&tp->pci_dev->dev, TX_BUF_TOT_LEN,
--- 1367,1385 ----
 	int retval;
 	void __iomem *ioaddr = tp->mmio_addr;

! 	if (!tp->ecdev) {
! 		retval = request_irq(dev->irq, rtl8139_interrupt,
! 			IRQF_SHARED, dev->name, dev);
! 		if (retval)
! 			return retval;
! 	}

 	tp->tx_bufs = dma_alloc_coherent(&tp->pci_dev->dev, TX_BUF_TOT_LEN,
 					   &tp->tx_bufs_dma, GFP_KERNEL);
 	tp->rx_ring = dma_alloc_coherent(&tp->pci_dev->dev, RX_BUF_TOT_LEN,
 					   &tp->rx_ring_dma, GFP_KERNEL);
 	if (tp->tx_bufs == NULL || tp->rx_ring == NULL) {
! 		if (!tp->ecdev) free_irq(dev->irq, dev);

 		if (tp->tx_bufs)
 			dma_free_coherent(&tp->pci_dev->dev, TX_BUF_TOT_LEN,
***************
*** 1330,1343 ****
 	rtl8139_hw_start (dev);
 	netif_start_queue (dev);

! 	netif_dbg(tp, ifup, dev,
! 		  "%s() ioaddr %#llx IRQ %d GP Pins %02x %s-duplex\n",
! 		  __func__,
! 		  (unsigned long long)pci_resource_start (tp->pci_dev, 1),
! 		  dev->irq, RTL_R8 (MediaStatus),
! 		  tp->mii.full_duplex ? "full" : "half");

! 	rtl8139_start_thread(tp);

 	return 0;
 }
--- 1401,1416 ----
 	rtl8139_hw_start (dev);
 	netif_start_queue (dev);

! 	if (!tp->ecdev) {
! 		if (netif_msg_ifup(tp))
! 			pr_debug("%s: rtl8139_open() ioaddr %#llx IRQ %d"
! 				" GP Pins %2.2x %s-duplex.\n", dev->name,
! 				(unsigned long long)pci_resource_start (tp->pci_dev, 1),
! 				dev->irq, RTL_R8 (MediaStatus),
! 				tp->mii.full_duplex ? "full" : "half");

! 		rtl8139_start_thread(tp);
! 	}

 	return 0;
 }
***************
*** 1347,1354 ****
 {
 	struct rtl8139_private *tp = netdev_priv(dev);

! 	if (tp->phys[0] >= 0) {
! 		mii_check_media(&tp->mii, netif_msg_link(tp), init_media);
 	}
 }

--- 1420,1434 ----
 {
 	struct rtl8139_private *tp = netdev_priv(dev);

! 	if (tp->ecdev) {
! 		void __iomem *ioaddr = tp->mmio_addr;
! 		u16 state = RTL_R16(BasicModeStatus) & BMSR_LSTATUS;
! 		ecdev_set_link(tp->ecdev, state ? 1 : 0);
! 	}
! 	else {
! 		if (tp->phys[0] >= 0) {
! 			mii_check_media(&tp->mii, netif_msg_link(tp), init_media);
! 		}
 	}
 }

***************
*** 1393,1399 ****
 		RTL_W8 (Config3, RTL_R8 (Config3) & ~Cfg3_Magic);
 	}

! 	netdev_dbg(dev, "init buffer addresses\n");

 	/* Lock Config[01234] and BMCR register writes */
 	RTL_W8 (Cfg9346, Cfg9346_Lock);
--- 1473,1479 ----
 		RTL_W8 (Config3, RTL_R8 (Config3) & ~Cfg3_Magic);
 	}

! 	pr_debug("init buffer addresses\n");

 	/* Lock Config[01234] and BMCR register writes */
 	RTL_W8 (Cfg9346, Cfg9346_Lock);
***************
*** 1414,1421 ****
 	if ((!(tmp & CmdRxEnb)) || (!(tmp & CmdTxEnb)))
 		RTL_W8 (ChipCmd, CmdRxEnb | CmdTxEnb);

! 	/* Enable all known interrupts by setting the interrupt mask. */
! 	RTL_W16 (IntrMask, rtl8139_intr_mask);
 }


--- 1494,1502 ----
 	if ((!(tmp & CmdRxEnb)) || (!(tmp & CmdTxEnb)))
 		RTL_W8 (ChipCmd, CmdRxEnb | CmdTxEnb);

! 	if (!tp->ecdev)
! 		/* Enable all known interrupts by setting the interrupt mask. */
! 		RTL_W16 (IntrMask, rtl8139_intr_mask);
 }


***************
*** 1549,1565 ****
 	mii_lpa = mdio_read (dev, tp->phys[0], MII_LPA);

 	if (!tp->mii.force_media && mii_lpa != 0xffff) {
! 		int duplex = ((mii_lpa & LPA_100FULL) ||
! 			      (mii_lpa & 0x01C0) == 0x0040);
 		if (tp->mii.full_duplex != duplex) {
 			tp->mii.full_duplex = duplex;

 			if (mii_lpa) {
! 				netdev_info(dev, "Setting %s-duplex based on MII #%d link partner ability of %04x\n",
! 					    tp->mii.full_duplex ? "full" : "half",
! 					    tp->phys[0], mii_lpa);
 			} else {
! 				netdev_info(dev, "media is unconnected, link down, or incompatible connection\n");
 			}
 #if 0
 			RTL_W8 (Cfg9346, Cfg9346_Unlock);
--- 1630,1649 ----
 	mii_lpa = mdio_read (dev, tp->phys[0], MII_LPA);

 	if (!tp->mii.force_media && mii_lpa != 0xffff) {
! 		int duplex = (mii_lpa & LPA_100FULL)
! 		    || (mii_lpa & 0x01C0) == 0x0040;
 		if (tp->mii.full_duplex != duplex) {
 			tp->mii.full_duplex = duplex;

 			if (mii_lpa) {
! 				pr_info("%s: Setting %s-duplex based on MII #%d link"
! 					" partner ability of %4.4x.\n",
! 					dev->name,
! 					tp->mii.full_duplex ? "full" : "half",
! 					tp->phys[0], mii_lpa);
 			} else {
! 				pr_info("%s: media is unconnected, link down, or incompatible connection\n",
! 				       dev->name);
 			}
 #if 0
 			RTL_W8 (Cfg9346, Cfg9346_Unlock);
***************
*** 1573,1584 ****

 	rtl8139_tune_twister (dev, tp);

! 	netdev_dbg(dev, "Media selection tick, Link partner %04x\n",
! 		   RTL_R16(NWayLPAR));
! 	netdev_dbg(dev, "Other registers are IntMask %04x IntStatus %04x\n",
! 		   RTL_R16(IntrMask), RTL_R16(IntrStatus));
! 	netdev_dbg(dev, "Chip config %02x %02x\n",
! 		   RTL_R8(Config0), RTL_R8(Config1));
 }

 static void rtl8139_thread (struct work_struct *work)
--- 1657,1669 ----

 	rtl8139_tune_twister (dev, tp);

! 	pr_debug("%s: Media selection tick, Link partner %4.4x.\n",
! 		 dev->name, RTL_R16 (NWayLPAR));
! 	pr_debug("%s:  Other registers are IntMask %4.4x IntStatus %4.4x\n",
! 		 dev->name, RTL_R16 (IntrMask), RTL_R16 (IntrStatus));
! 	pr_debug("%s:  Chip config %2.2x %2.2x.\n",
! 		 dev->name, RTL_R8 (Config0),
! 		 RTL_R8 (Config1));
 }

 static void rtl8139_thread (struct work_struct *work)
***************
*** 1636,1652 ****
 	int i;
 	u8 tmp8;

! 	netdev_dbg(dev, "Transmit timeout, status %02x %04x %04x media %02x\n",
! 		   RTL_R8(ChipCmd), RTL_R16(IntrStatus),
! 		   RTL_R16(IntrMask), RTL_R8(MediaStatus));
 	/* Emit info to figure out what went wrong. */
! 	netdev_dbg(dev, "Tx queue start entry %ld  dirty entry %ld\n",
! 		   tp->cur_tx, tp->dirty_tx);
 	for (i = 0; i < NUM_TX_DESC; i++)
! 		netdev_dbg(dev, "Tx descriptor %d is %08lx%s\n",
! 			   i, RTL_R32(TxStatus0 + (i * 4)),
! 			   i == tp->dirty_tx % NUM_TX_DESC ?
! 			   " (queue head)" : "");

 	tp->xstats.tx_timeouts++;

--- 1721,1737 ----
 	int i;
 	u8 tmp8;

! 	pr_debug("%s: Transmit timeout, status %2.2x %4.4x %4.4x media %2.2x.\n",
! 		dev->name, RTL_R8 (ChipCmd),
! 		RTL_R16(IntrStatus), RTL_R16(IntrMask), RTL_R8(MediaStatus));
 	/* Emit info to figure out what went wrong. */
! 	pr_debug("%s: Tx queue start entry %ld  dirty entry %ld.\n",
! 		dev->name, tp->cur_tx, tp->dirty_tx);
 	for (i = 0; i < NUM_TX_DESC; i++)
! 		pr_debug("%s:  Tx descriptor %d is %8.8lx.%s\n",
! 			dev->name, i, RTL_R32 (TxStatus0 + (i * 4)),
! 			i == tp->dirty_tx % NUM_TX_DESC ?
! 				" (queue head)" : "");

 	tp->xstats.tx_timeouts++;

***************
*** 1655,1675 ****
 	if (tmp8 & CmdTxEnb)
 		RTL_W8 (ChipCmd, CmdRxEnb);

! 	spin_lock_bh(&tp->rx_lock);
! 	/* Disable interrupts by clearing the interrupt mask. */
! 	RTL_W16 (IntrMask, 0x0000);
!
! 	/* Stop a shared interrupt from scavenging while we are. */
! 	spin_lock_irq(&tp->lock);
! 	rtl8139_tx_clear (tp);
! 	spin_unlock_irq(&tp->lock);
!
! 	/* ...and finally, reset everything */
! 	if (netif_running(dev)) {
 		rtl8139_hw_start (dev);
- 		netif_wake_queue (dev);
 	}
! 	spin_unlock_bh(&tp->rx_lock);
 }

 static void rtl8139_tx_timeout (struct net_device *dev)
--- 1740,1766 ----
 	if (tmp8 & CmdTxEnb)
 		RTL_W8 (ChipCmd, CmdRxEnb);

! 	if (tp->ecdev) {
! 		rtl8139_tx_clear (tp);
 		rtl8139_hw_start (dev);
 	}
! 	else {
! 	  spin_lock_bh(&tp->rx_lock);
! 	  /* Disable interrupts by clearing the interrupt mask. */
! 	  RTL_W16 (IntrMask, 0x0000);
!
! 	  /* Stop a shared interrupt from scavenging while we are. */
! 	  spin_lock_irq(&tp->lock);
! 	  rtl8139_tx_clear (tp);
! 	  spin_unlock_irq(&tp->lock);
!
! 	  /* ...and finally, reset everything */
! 	  if (netif_running(dev)) {
! 	    rtl8139_hw_start (dev);
! 	    netif_wake_queue (dev);
! 	  }
! 	  spin_unlock_bh(&tp->rx_lock);
! 	}
 }

 static void rtl8139_tx_timeout (struct net_device *dev)
***************
*** 1677,1690 ****
 	struct rtl8139_private *tp = netdev_priv(dev);

 	tp->watchdog_fired = 1;
! 	if (!tp->have_thread) {
 		INIT_DELAYED_WORK(&tp->thread, rtl8139_thread);
 		schedule_delayed_work(&tp->thread, next_tick);
 	}
 }

! static netdev_tx_t rtl8139_start_xmit (struct sk_buff *skb,
! 					     struct net_device *dev)
 {
 	struct rtl8139_private *tp = netdev_priv(dev);
 	void __iomem *ioaddr = tp->mmio_addr;
--- 1768,1780 ----
 	struct rtl8139_private *tp = netdev_priv(dev);

 	tp->watchdog_fired = 1;
! 	if (!tp->ecdev && !tp->have_thread) {
 		INIT_DELAYED_WORK(&tp->thread, rtl8139_thread);
 		schedule_delayed_work(&tp->thread, next_tick);
 	}
 }

! static int rtl8139_start_xmit (struct sk_buff *skb, struct net_device *dev)
 {
 	struct rtl8139_private *tp = netdev_priv(dev);
 	void __iomem *ioaddr = tp->mmio_addr;
***************
*** 1700,1732 ****
 		if (len < ETH_ZLEN)
 			memset(tp->tx_buf[entry], 0, ETH_ZLEN);
 		skb_copy_and_csum_dev(skb, tp->tx_buf[entry]);
! 		dev_kfree_skb(skb);
 	} else {
! 		dev_kfree_skb(skb);
 		dev->stats.tx_dropped++;
! 		return NETDEV_TX_OK;
 	}

! 	spin_lock_irqsave(&tp->lock, flags);
! 	/*
! 	 * Writing to TxStatus triggers a DMA transfer of the data
! 	 * copied to tp->tx_buf[entry] above. Use a memory barrier
! 	 * to make sure that the device sees the updated data.
! 	 */
! 	wmb();
! 	RTL_W32_F (TxStatus0 + (entry * sizeof (u32)),
! 		   tp->tx_flag | max(len, (unsigned int)ETH_ZLEN));

! 	tp->cur_tx++;

! 	if ((tp->cur_tx - NUM_TX_DESC) == tp->dirty_tx)
! 		netif_stop_queue (dev);
! 	spin_unlock_irqrestore(&tp->lock, flags);

! 	netif_dbg(tp, tx_queued, dev, "Queued Tx packet size %u to slot %d\n",
! 		  len, entry);

! 	return NETDEV_TX_OK;
 }


--- 1790,1833 ----
 		if (len < ETH_ZLEN)
 			memset(tp->tx_buf[entry], 0, ETH_ZLEN);
 		skb_copy_and_csum_dev(skb, tp->tx_buf[entry]);
! 		if (!tp->ecdev) dev_kfree_skb(skb);
 	} else {
! 		if (!tp->ecdev) dev_kfree_skb(skb);
 		dev->stats.tx_dropped++;
! 		return 0;
 	}

! 	if (tp->ecdev) {
! 		wmb();
! 		RTL_W32_F (TxStatus0 + (entry * sizeof (u32)),
! 			tp->tx_flag | max(len, (unsigned int)ETH_ZLEN));
!
! 		dev->trans_start = jiffies;
!
! 		tp->cur_tx++;
! 	} else {
! 		spin_lock_irqsave(&tp->lock, flags);
! 		/*
! 		 * Writing to TxStatus triggers a DMA transfer of the data
! 		 * copied to tp->tx_buf[entry] above. Use a memory barrier
! 		 * to make sure that the device sees the updated data.
! 		 */
! 		wmb();
! 		RTL_W32_F (TxStatus0 + (entry * sizeof (u32)),
! 			   tp->tx_flag | max(len, (unsigned int)ETH_ZLEN));

! 		tp->cur_tx++;

! 		if ((tp->cur_tx - NUM_TX_DESC) == tp->dirty_tx)
! 			netif_stop_queue (dev);
! 		spin_unlock_irqrestore(&tp->lock, flags);

! 		if (netif_msg_tx_queued(tp))
! 			pr_debug("%s: Queued Tx packet size %u to slot %d.\n",
! 				dev->name, len, entry);
! 	}

! 	return 0;
 }


***************
*** 1753,1760 ****
 		/* Note: TxCarrierLost is always asserted at 100mbps. */
 		if (txstatus & (TxOutOfWindow | TxAborted)) {
 			/* There was an major error, log it. */
! 			netif_dbg(tp, tx_err, dev, "Transmit error, Tx status %08x\n",
! 				  txstatus);
 			dev->stats.tx_errors++;
 			if (txstatus & TxAborted) {
 				dev->stats.tx_aborted_errors++;
--- 1854,1862 ----
 		/* Note: TxCarrierLost is always asserted at 100mbps. */
 		if (txstatus & (TxOutOfWindow | TxAborted)) {
 			/* There was an major error, log it. */
! 			if (netif_msg_tx_err(tp))
! 				pr_debug("%s: Transmit error, Tx status %8.8x.\n",
! 					dev->name, txstatus);
 			dev->stats.tx_errors++;
 			if (txstatus & TxAborted) {
 				dev->stats.tx_aborted_errors++;
***************
*** 1783,1791 ****
 	}

 #ifndef RTL8139_NDEBUG
! 	if (tp->cur_tx - dirty_tx > NUM_TX_DESC) {
! 		netdev_err(dev, "Out-of-sync dirty pointer, %ld vs. %ld\n",
! 			   dirty_tx, tp->cur_tx);
 		dirty_tx += NUM_TX_DESC;
 	}
 #endif /* RTL8139_NDEBUG */
--- 1885,1893 ----
 	}

 #ifndef RTL8139_NDEBUG
! 	if (!tp->ecdev && tp->cur_tx - dirty_tx > NUM_TX_DESC) {
! 		pr_err("%s: Out-of-sync dirty pointer, %ld vs. %ld.\n",
! 		        dev->name, dirty_tx, tp->cur_tx);
 		dirty_tx += NUM_TX_DESC;
 	}
 #endif /* RTL8139_NDEBUG */
***************
*** 1794,1800 ****
 	if (tp->dirty_tx != dirty_tx) {
 		tp->dirty_tx = dirty_tx;
 		mb();
! 		netif_wake_queue (dev);
 	}
 }

--- 1896,1902 ----
 	if (tp->dirty_tx != dirty_tx) {
 		tp->dirty_tx = dirty_tx;
 		mb();
! 		if (!tp->ecdev) netif_wake_queue (dev);
 	}
 }

***************
*** 1808,1820 ****
 	int tmp_work;
 #endif

! 	netif_dbg(tp, rx_err, dev, "Ethernet frame had errors, status %08x\n",
! 		  rx_status);
 	dev->stats.rx_errors++;
 	if (!(rx_status & RxStatusOK)) {
 		if (rx_status & RxTooLong) {
! 			netdev_dbg(dev, "Oversized Ethernet frame, status %04x!\n",
! 				   rx_status);
 			/* A.C.: The chip hangs here. */
 		}
 		if (rx_status & (RxBadSymbol | RxBadAlign))
--- 1910,1923 ----
 	int tmp_work;
 #endif

! 	if (netif_msg_rx_err (tp))
! 		pr_debug("%s: Ethernet frame had errors, status %8.8x.\n",
! 			dev->name, rx_status);
 	dev->stats.rx_errors++;
 	if (!(rx_status & RxStatusOK)) {
 		if (rx_status & RxTooLong) {
! 			pr_debug("%s: Oversized Ethernet frame, status %4.4x!\n",
! 			 	dev->name, rx_status);
 			/* A.C.: The chip hangs here. */
 		}
 		if (rx_status & (RxBadSymbol | RxBadAlign))
***************
*** 1846,1852 ****
 			break;
 	}
 	if (tmp_work <= 0)
! 		netdev_warn(dev, "rx stop wait too long\n");
 	/* restart receive */
 	tmp_work = 200;
 	while (--tmp_work > 0) {
--- 1949,1955 ----
 			break;
 	}
 	if (tmp_work <= 0)
! 		pr_warning(PFX "rx stop wait too long\n");
 	/* restart receive */
 	tmp_work = 200;
 	while (--tmp_work > 0) {
***************
*** 1857,1863 ****
 			break;
 	}
 	if (tmp_work <= 0)
! 		netdev_warn(dev, "tx/rx enable wait too long\n");

 	/* and reinitialize all rx related registers */
 	RTL_W8_F (Cfg9346, Cfg9346_Unlock);
--- 1960,1966 ----
 			break;
 	}
 	if (tmp_work <= 0)
! 		pr_warning(PFX "tx/rx enable wait too long\n");

 	/* and reinitialize all rx related registers */
 	RTL_W8_F (Cfg9346, Cfg9346_Unlock);
***************
*** 1868,1874 ****
 	RTL_W32 (RxConfig, tp->rx_config);
 	tp->cur_rx = 0;

! 	netdev_dbg(dev, "init buffer addresses\n");

 	/* Lock Config[01234] and BMCR register writes */
 	RTL_W8 (Cfg9346, Cfg9346_Lock);
--- 1971,1977 ----
 	RTL_W32 (RxConfig, tp->rx_config);
 	tp->cur_rx = 0;

! 	pr_debug("init buffer addresses\n");

 	/* Lock Config[01234] and BMCR register writes */
 	RTL_W8 (Cfg9346, Cfg9346_Lock);
***************
*** 1922,1933 ****
 	unsigned int cur_rx = tp->cur_rx;
 	unsigned int rx_size = 0;

! 	netdev_dbg(dev, "In %s(), current %04x BufAddr %04x, free to %04x, Cmd %02x\n",
! 		   __func__, (u16)cur_rx,
! 		   RTL_R16(RxBufAddr), RTL_R16(RxBufPtr), RTL_R8(ChipCmd));
!
! 	while (netif_running(dev) && received < budget &&
! 	       (RTL_R8 (ChipCmd) & RxBufEmpty) == 0) {
 		u32 ring_offset = cur_rx % RX_BUF_LEN;
 		u32 rx_status;
 		unsigned int pkt_size;
--- 2025,2038 ----
 	unsigned int cur_rx = tp->cur_rx;
 	unsigned int rx_size = 0;

! 	pr_debug("%s: In rtl8139_rx(), current %4.4x BufAddr %4.4x,"
! 		 " free to %4.4x, Cmd %2.2x.\n", dev->name, (u16)cur_rx,
! 		 RTL_R16 (RxBufAddr),
! 		 RTL_R16 (RxBufPtr), RTL_R8 (ChipCmd));
!
! 	while ((tp->ecdev || netif_running(dev))
! 			&& received < budget
! 			&& (RTL_R8 (ChipCmd) & RxBufEmpty) == 0) {
 		u32 ring_offset = cur_rx % RX_BUF_LEN;
 		u32 rx_status;
 		unsigned int pkt_size;
***************
*** 1940,1951 ****
 		rx_size = rx_status >> 16;
 		pkt_size = rx_size - 4;

! 		netif_dbg(tp, rx_status, dev, "%s() status %04x, size %04x, cur %04x\n",
! 			  __func__, rx_status, rx_size, cur_rx);
 #if RTL8139_DEBUG > 2
! 		print_hex_dump(KERN_DEBUG, "Frame contents: ",
! 			       DUMP_PREFIX_OFFSET, 16, 1,
! 			       &rx_ring[ring_offset], 70, true);
 #endif

 		/* Packet copy from FIFO still in progress.
--- 2045,2065 ----
 		rx_size = rx_status >> 16;
 		pkt_size = rx_size - 4;

! 		if (!tp->ecdev) {
! 			if (netif_msg_rx_status(tp))
! 				pr_debug("%s:  rtl8139_rx() status %4.4x, size %4.4x,"
! 					" cur %4.4x.\n", dev->name, rx_status,
! 				 rx_size, cur_rx);
! 		}
 #if RTL8139_DEBUG > 2
! 		{
! 			int i;
! 			pr_debug("%s: Frame contents ", dev->name);
! 			for (i = 0; i < 70; i++)
! 				pr_cont(" %2.2x",
! 					rx_ring[ring_offset + i]);
! 			pr_cont(".\n");
! 		}
 #endif

 		/* Packet copy from FIFO still in progress.
***************
*** 1956,1966 ****
 			if (!tp->fifo_copy_timeout)
 				tp->fifo_copy_timeout = jiffies + 2;
 			else if (time_after(jiffies, tp->fifo_copy_timeout)) {
! 				netdev_dbg(dev, "hung FIFO. Reset\n");
 				rx_size = 0;
 				goto no_early_rx;
 			}
! 			netif_dbg(tp, intr, dev, "fifo copy in progress\n");
 			tp->xstats.early_rx++;
 			break;
 		}
--- 2070,2083 ----
 			if (!tp->fifo_copy_timeout)
 				tp->fifo_copy_timeout = jiffies + 2;
 			else if (time_after(jiffies, tp->fifo_copy_timeout)) {
! 				pr_debug("%s: hung FIFO. Reset.", dev->name);
 				rx_size = 0;
 				goto no_early_rx;
 			}
! 			if (netif_msg_intr(tp)) {
! 				pr_debug("%s: fifo copy in progress.",
! 				       dev->name);
! 			}
 			tp->xstats.early_rx++;
 			break;
 		}
***************
*** 1981,2008 ****
 			goto out;
 		}

! 		/* Malloc up new buffer, compatible with net-2e. */
! 		/* Omit the four octet CRC from the length. */

! 		skb = netdev_alloc_skb_ip_align(dev, pkt_size);
! 		if (likely(skb)) {
 #if RX_BUF_IDX == 3
! 			wrap_copy(skb, rx_ring, ring_offset+4, pkt_size);
 #else
! 			skb_copy_to_linear_data (skb, &rx_ring[ring_offset + 4], pkt_size);
 #endif
! 			skb_put (skb, pkt_size);

! 			skb->protocol = eth_type_trans (skb, dev);

! 			dev->stats.rx_bytes += pkt_size;
! 			dev->stats.rx_packets++;

! 			netif_receive_skb (skb);
! 		} else {
! 			if (net_ratelimit())
! 				netdev_warn(dev, "Memory squeeze, dropping packet\n");
! 			dev->stats.rx_dropped++;
 		}
 		received++;

--- 2098,2135 ----
 			goto out;
 		}

! 		if (tp->ecdev) {
! 			ecdev_receive(tp->ecdev,
! 					&rx_ring[ring_offset + 4], pkt_size);
! 					dev->last_rx = jiffies;
! 					dev->stats.rx_bytes += pkt_size;
! 					dev->stats.rx_packets++;
! 		} else {
! 			/* Malloc up new buffer, compatible with net-2e. */
! 			/* Omit the four octet CRC from the length. */

! 			skb = netdev_alloc_skb(dev, pkt_size + NET_IP_ALIGN);
! 			if (likely(skb)) {
! 				skb_reserve (skb, NET_IP_ALIGN);	/* 16 byte align the IP fields. */
 #if RX_BUF_IDX == 3
! 				wrap_copy(skb, rx_ring, ring_offset+4, pkt_size);
 #else
! 				skb_copy_to_linear_data (skb, &rx_ring[ring_offset + 4], pkt_size);
 #endif
! 				skb_put (skb, pkt_size);

! 				skb->protocol = eth_type_trans (skb, dev);

! 				dev->stats.rx_bytes += pkt_size;
! 				dev->stats.rx_packets++;

! 				netif_receive_skb (skb);
! 			} else {
! 				if (net_ratelimit())
! 					pr_warning("%s: Memory squeeze, dropping packet.\n",
! 						dev->name);
! 				dev->stats.rx_dropped++;
! 			}
 		}
 		received++;

***************
*** 2015,2023 ****
 	if (unlikely(!received || rx_size == 0xfff0))
 		rtl8139_isr_ack(tp);

! 	netdev_dbg(dev, "Done %s(), current %04x BufAddr %04x, free to %04x, Cmd %02x\n",
! 		   __func__, cur_rx,
! 		   RTL_R16(RxBufAddr), RTL_R16(RxBufPtr), RTL_R8(ChipCmd));

 	tp->cur_rx = cur_rx;

--- 2142,2151 ----
 	if (unlikely(!received || rx_size == 0xfff0))
 		rtl8139_isr_ack(tp);

! 	pr_debug("%s: Done rtl8139_rx(), current %4.4x BufAddr %4.4x,"
! 		 " free to %4.4x, Cmd %2.2x.\n", dev->name, cur_rx,
! 		 RTL_R16 (RxBufAddr),
! 		 RTL_R16 (RxBufPtr), RTL_R8 (ChipCmd));

 	tp->cur_rx = cur_rx;

***************
*** 2038,2044 ****
 				     void __iomem *ioaddr,
 				     int status, int link_changed)
 {
! 	netdev_dbg(dev, "Abnormal interrupt, status %08x\n", status);

 	assert (dev != NULL);
 	assert (tp != NULL);
--- 2166,2173 ----
 				     void __iomem *ioaddr,
 				     int status, int link_changed)
 {
! 	pr_debug("%s: Abnormal interrupt, status %8.8x.\n",
! 		 dev->name, status);

 	assert (dev != NULL);
 	assert (tp != NULL);
***************
*** 2066,2072 ****
 		pci_read_config_word (tp->pci_dev, PCI_STATUS, &pci_cmd_status);
 		pci_write_config_word (tp->pci_dev, PCI_STATUS, pci_cmd_status);

! 		netdev_err(dev, "PCI Bus error %04x\n", pci_cmd_status);
 	}
 }

--- 2195,2202 ----
 		pci_read_config_word (tp->pci_dev, PCI_STATUS, &pci_cmd_status);
 		pci_write_config_word (tp->pci_dev, PCI_STATUS, pci_cmd_status);

! 		pr_err("%s: PCI Bus error %4.4x.\n",
! 			dev->name, pci_cmd_status);
 	}
 }

***************
*** 2098,2103 ****
--- 2228,2238 ----
 	return work_done;
 }

+ void ec_poll(struct net_device *dev)
+ {
+     rtl8139_interrupt(0, dev);
+ }
+
 /* The interrupt handler does all of the Rx thread work and cleans up
    after the Tx thread. */
 static irqreturn_t rtl8139_interrupt (int irq, void *dev_instance)
***************
*** 2109,2120 ****
 	int link_changed = 0; /* avoid bogus "uninit" warning */
 	int handled = 0;

! 	spin_lock (&tp->lock);
! 	status = RTL_R16 (IntrStatus);

! 	/* shared irq? */
! 	if (unlikely((status & rtl8139_intr_mask) == 0))
! 		goto out;

 	handled = 1;

--- 2244,2260 ----
 	int link_changed = 0; /* avoid bogus "uninit" warning */
 	int handled = 0;

! 	if (tp->ecdev) {
! 		status = RTL_R16 (IntrStatus);
! 	}
! 	else {
! 		spin_lock (&tp->lock);
! 		status = RTL_R16 (IntrStatus);

! 		/* shared irq? */
! 		if (unlikely((status & rtl8139_intr_mask) == 0))
! 			goto out;
! 	}

 	handled = 1;

***************
*** 2122,2131 ****
 	if (unlikely(status == 0xFFFF))
 		goto out;

! 	/* close possible race's with dev_close */
! 	if (unlikely(!netif_running(dev))) {
! 		RTL_W16 (IntrMask, 0);
! 		goto out;
 	}

 	/* Acknowledge all of the current interrupt sources ASAP, but
--- 2262,2273 ----
 	if (unlikely(status == 0xFFFF))
 		goto out;

! 	if (!tp->ecdev) {
! 		/* close possible race's with dev_close */
! 		if (unlikely(!netif_running(dev))) {
! 			RTL_W16 (IntrMask, 0);
! 			goto out;
! 		}
 	}

 	/* Acknowledge all of the current interrupt sources ASAP, but
***************
*** 2140,2148 ****
 	/* Receive packets are processed by poll routine.
 	   If not running start it now. */
 	if (status & RxAckBits){
! 		if (napi_schedule_prep(&tp->napi)) {
! 			RTL_W16_F (IntrMask, rtl8139_norx_intr_mask);
! 			__napi_schedule(&tp->napi);
 		}
 	}

--- 2282,2296 ----
 	/* Receive packets are processed by poll routine.
 	   If not running start it now. */
 	if (status & RxAckBits){
! 		if (tp->ecdev) {
! 			/* EtherCAT device: Just receive all frames */
! 			rtl8139_rx(dev, tp, 100); // FIXME
! 		} else {
! 			/* Mark for polling */
! 			if (napi_schedule_prep(&tp->napi)) {
! 				RTL_W16_F (IntrMask, rtl8139_norx_intr_mask);
! 				__napi_schedule(&tp->napi);
! 			}
 		}
 	}

***************
*** 2157,2166 ****
 			RTL_W16 (IntrStatus, TxErr);
 	}
  out:
! 	spin_unlock (&tp->lock);

! 	netdev_dbg(dev, "exiting interrupt, intr_status=%#4.4x\n",
! 		   RTL_R16(IntrStatus));
 	return IRQ_RETVAL(handled);
 }

--- 2305,2314 ----
 			RTL_W16 (IntrStatus, TxErr);
 	}
  out:
! 	if (!tp->ecdev) spin_unlock (&tp->lock);

! 	pr_debug("%s: exiting interrupt, intr_status=%#4.4x.\n",
! 		 dev->name, RTL_R16 (IntrStatus));
 	return IRQ_RETVAL(handled);
 }

***************
*** 2206,2232 ****
 	void __iomem *ioaddr = tp->mmio_addr;
 	unsigned long flags;

! 	netif_stop_queue(dev);
! 	napi_disable(&tp->napi);

! 	netif_dbg(tp, ifdown, dev, "Shutting down ethercard, status was 0x%04x\n",
! 		  RTL_R16(IntrStatus));

! 	spin_lock_irqsave (&tp->lock, flags);

! 	/* Stop the chip's Tx and Rx DMA processes. */
! 	RTL_W8 (ChipCmd, 0);

! 	/* Disable interrupts by clearing the interrupt mask. */
! 	RTL_W16 (IntrMask, 0);

! 	/* Update the error counts. */
! 	dev->stats.rx_missed_errors += RTL_R32 (RxMissed);
! 	RTL_W32 (RxMissed, 0);

! 	spin_unlock_irqrestore (&tp->lock, flags);

! 	free_irq (dev->irq, dev);

 	rtl8139_tx_clear (tp);

--- 2354,2393 ----
 	void __iomem *ioaddr = tp->mmio_addr;
 	unsigned long flags;

! 	if (tp->ecdev) {
! 		/* Stop the chip's Tx and Rx DMA processes. */
! 		RTL_W8 (ChipCmd, 0);

! 		/* Disable interrupts by clearing the interrupt mask. */
! 		RTL_W16 (IntrMask, 0);

! 		/* Update the error counts. */
! 		dev->stats.rx_missed_errors += RTL_R32 (RxMissed);
! 		RTL_W32 (RxMissed, 0);
! 	} else {
! 		netif_stop_queue(dev);
! 		napi_disable(&tp->napi);

! 		if (netif_msg_ifdown(tp))
! 			pr_debug("%s: Shutting down ethercard, status was 0x%4.4x.\n",
! 				dev->name, RTL_R16 (IntrStatus));

! 		spin_lock_irqsave (&tp->lock, flags);

! 		/* Stop the chip's Tx and Rx DMA processes. */
! 		RTL_W8 (ChipCmd, 0);

! 		/* Disable interrupts by clearing the interrupt mask. */
! 		RTL_W16 (IntrMask, 0);

! 		/* Update the error counts. */
! 		dev->stats.rx_missed_errors += RTL_R32 (RxMissed);
! 		RTL_W32 (RxMissed, 0);
!
! 		spin_unlock_irqrestore (&tp->lock, flags);
!
! 		free_irq (dev->irq, dev);
! 	}

 	rtl8139_tx_clear (tp);

***************
*** 2449,2455 ****
 	struct rtl8139_private *tp = netdev_priv(dev);
 	int rc;

! 	if (!netif_running(dev))
 		return -EINVAL;

 	spin_lock_irq(&tp->lock);
--- 2610,2616 ----
 	struct rtl8139_private *tp = netdev_priv(dev);
 	int rc;

! 	if (tp->ecdev || !netif_running(dev))
 		return -EINVAL;

 	spin_lock_irq(&tp->lock);
***************
*** 2466,2472 ****
 	void __iomem *ioaddr = tp->mmio_addr;
 	unsigned long flags;

! 	if (netif_running(dev)) {
 		spin_lock_irqsave (&tp->lock, flags);
 		dev->stats.rx_missed_errors += RTL_R32 (RxMissed);
 		RTL_W32 (RxMissed, 0);
--- 2627,2633 ----
 	void __iomem *ioaddr = tp->mmio_addr;
 	unsigned long flags;

! 	if (tp->ecdev || netif_running(dev)) {
 		spin_lock_irqsave (&tp->lock, flags);
 		dev->stats.rx_missed_errors += RTL_R32 (RxMissed);
 		RTL_W32 (RxMissed, 0);
***************
*** 2487,2494 ****
 	int rx_mode;
 	u32 tmp;

! 	netdev_dbg(dev, "rtl8139_set_rx_mode(%04x) done -- Rx config %08lx\n",
! 		   dev->flags, RTL_R32(RxConfig));

 	/* Note: do not reorder, GCC is clever about common statements. */
 	if (dev->flags & IFF_PROMISC) {
--- 2648,2655 ----
 	int rx_mode;
 	u32 tmp;

! 	pr_debug("%s:   rtl8139_set_rx_mode(%4.4x) done -- Rx config %8.8lx.\n",
! 			dev->name, dev->flags, RTL_R32 (RxConfig));

 	/* Note: do not reorder, GCC is clever about common statements. */
 	if (dev->flags & IFF_PROMISC) {
***************
*** 2496,2503 ****
 		    AcceptBroadcast | AcceptMulticast | AcceptMyPhys |
 		    AcceptAllPhys;
 		mc_filter[1] = mc_filter[0] = 0xffffffff;
! 	} else if ((netdev_mc_count(dev) > multicast_filter_limit) ||
! 		   (dev->flags & IFF_ALLMULTI)) {
 		/* Too many to filter perfectly -- accept all multicasts. */
 		rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys;
 		mc_filter[1] = mc_filter[0] = 0xffffffff;
--- 2657,2664 ----
 		    AcceptBroadcast | AcceptMulticast | AcceptMyPhys |
 		    AcceptAllPhys;
 		mc_filter[1] = mc_filter[0] = 0xffffffff;
! 	} else if ((netdev_mc_count(dev) > multicast_filter_limit)
! 		   || (dev->flags & IFF_ALLMULTI)) {
 		/* Too many to filter perfectly -- accept all multicasts. */
 		rx_mode = AcceptBroadcast | AcceptMulticast | AcceptMyPhys;
 		mc_filter[1] = mc_filter[0] = 0xffffffff;
***************
*** 2544,2550 ****

 	pci_save_state (pdev);

! 	if (!netif_running (dev))
 		return 0;

 	netif_device_detach (dev);
--- 2705,2711 ----

 	pci_save_state (pdev);

! 	if (tp->ecdev || !netif_running (dev))
 		return 0;

 	netif_device_detach (dev);
***************
*** 2570,2578 ****
 static int rtl8139_resume (struct pci_dev *pdev)
 {
 	struct net_device *dev = pci_get_drvdata (pdev);

 	pci_restore_state (pdev);
! 	if (!netif_running (dev))
 		return 0;
 	pci_set_power_state (pdev, PCI_D0);
 	rtl8139_init_ring (dev);
--- 2731,2740 ----
 static int rtl8139_resume (struct pci_dev *pdev)
 {
 	struct net_device *dev = pci_get_drvdata (pdev);
+ 	struct rtl8139_private *tp = netdev_priv(dev);

 	pci_restore_state (pdev);
! 	if (tp->ecdev || !netif_running (dev))
 		return 0;
 	pci_set_power_state (pdev, PCI_D0);
 	rtl8139_init_ring (dev);


_________________________

Prof. Jacques GANGLOFF
Phone : +33 (0)3 68 85 44 68
Mobile : +33 (0)6 43 49 74 29

Université de Strasbourg
LSIIT - AVR
Bd. Sébastien Brant
BP 10413
F - 67412 ILLKIRCH
http://eavr.u-strasbg.fr/~jacques/
_________________________





-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20101009/66dbcc3a/attachment-0003.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 6915 bytes
Desc: not available
URL: <http://lists.etherlab.org/pipermail/etherlab-users/attachments/20101009/66dbcc3a/attachment-0003.bin>


More information about the Etherlab-users mailing list