Added device module for kernel 2.6.17. Still slow?

This commit is contained in:
Florian Pose 2006-11-02 19:08:06 +00:00
parent 7e45d613cb
commit af20e0a5d2
6 changed files with 5891 additions and 300 deletions

View File

@ -705,7 +705,7 @@ 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);
int rtl8139_poll(struct net_device *dev, int *budget);
static int rtl8139_poll(struct net_device *dev, int *budget);
#ifdef CONFIG_NET_POLL_CONTROLLER
static void rtl8139_poll_controller(struct net_device *dev);
#endif
@ -820,7 +820,7 @@ static void rtl8139_chip_reset (void __iomem *ioaddr)
for (i = 1000; i > 0; i--) {
barrier();
if ((RTL_R8 (ChipCmd) & CmdReset) == 0)
break;
break;
udelay (10);
}
}
@ -955,7 +955,7 @@ static int __devinit rtl8139_init_board (struct pci_dev *pdev,
/* if unknown chip, assume array element #0, original RTL-8139 in this case */
printk (KERN_DEBUG PFX "%s: unknown chip version, assuming RTL-8139\n",
pci_name(pdev));
printk (KERN_DEBUG PFX "%s: TxConfig = 0x%lx\n", pci_name(pdev), RTL_R32 (TxConfig));
printk (KERN_DEBUG PFX "%s: TxConfig = 0x%lx\n", pci_name(pdev), RTL_R32 (TxConfig));
tp->chipset = 0;
match:
@ -1047,8 +1047,8 @@ static int __devinit rtl8139_init_one (struct pci_dev *pdev,
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
if (board_idx == ec_device_index) {
rtl_ec_net_dev = dev;
strcpy(dev->name, "ec0");
rtl_ec_net_dev = dev;
strcpy(dev->name, "ec0");
}
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
@ -1107,10 +1107,10 @@ static int __devinit rtl8139_init_one (struct pci_dev *pdev,
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
if (dev != rtl_ec_net_dev) {
DPRINTK("about to register device named %s (%p)...\n", dev->name, dev);
i = register_netdev (dev);
if (i) goto err_out;
if (dev != rtl_ec_net_dev) {
DPRINTK("about to register device named %s (%p)...\n", dev->name, dev);
i = register_netdev (dev);
if (i) goto err_out;
}
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
@ -1202,10 +1202,10 @@ static void __devexit rtl8139_remove_one (struct pci_dev *pdev)
assert (dev != NULL);
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
if (dev != rtl_ec_net_dev) {
unregister_netdev (dev);
if (dev != rtl_ec_net_dev) {
unregister_netdev (dev);
}
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
@ -1412,12 +1412,12 @@ static int rtl8139_open (struct net_device *dev)
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
if (dev != rtl_ec_net_dev) {
retval = request_irq(dev->irq, rtl8139_interrupt,
SA_SHIRQ, dev->name, dev);
if (retval)
return retval;
}
if (dev != rtl_ec_net_dev) {
retval = request_irq(dev->irq, rtl8139_interrupt,
SA_SHIRQ, dev->name, dev);
if (retval)
return retval;
}
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
@ -1426,22 +1426,22 @@ static int rtl8139_open (struct net_device *dev)
tp->rx_ring = pci_alloc_consistent(tp->pci_dev, RX_BUF_TOT_LEN,
&tp->rx_ring_dma);
if (tp->tx_bufs == NULL || tp->rx_ring == NULL) {
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
if (dev != rtl_ec_net_dev) {
free_irq(dev->irq, dev);
}
if (dev != rtl_ec_net_dev) {
free_irq(dev->irq, dev);
}
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
if (tp->tx_bufs)
pci_free_consistent(tp->pci_dev, TX_BUF_TOT_LEN,
tp->tx_bufs, tp->tx_bufs_dma);
if (tp->rx_ring)
pci_free_consistent(tp->pci_dev, RX_BUF_TOT_LEN,
tp->rx_ring, tp->rx_ring_dma);
if (tp->tx_bufs)
pci_free_consistent(tp->pci_dev, TX_BUF_TOT_LEN,
tp->tx_bufs, tp->tx_bufs_dma);
if (tp->rx_ring)
pci_free_consistent(tp->pci_dev, RX_BUF_TOT_LEN,
tp->rx_ring, tp->rx_ring_dma);
return -ENOMEM;
return -ENOMEM;
}
@ -1451,20 +1451,20 @@ static int rtl8139_open (struct net_device *dev)
rtl8139_init_ring (dev);
rtl8139_hw_start (dev);
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
if (dev != rtl_ec_net_dev) {
netif_start_queue (dev);
if (dev != rtl_ec_net_dev) {
netif_start_queue (dev);
if (netif_msg_ifup(tp))
printk(KERN_DEBUG "%s: rtl8139_open() ioaddr %#lx IRQ %d"
" GP Pins %2.2x %s-duplex.\n",
dev->name, pci_resource_start (tp->pci_dev, 1),
dev->irq, RTL_R8 (MediaStatus),
tp->mii.full_duplex ? "full" : "half");
if (netif_msg_ifup(tp))
printk(KERN_DEBUG "%s: rtl8139_open() ioaddr %#lx IRQ %d"
" GP Pins %2.2x %s-duplex.\n",
dev->name, pci_resource_start (tp->pci_dev, 1),
dev->irq, RTL_R8 (MediaStatus),
tp->mii.full_duplex ? "full" : "half");
rtl8139_start_thread(dev);
}
rtl8139_start_thread(dev);
}
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
@ -1478,18 +1478,17 @@ static void rtl_check_media (struct net_device *dev, unsigned int init_media)
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
if (dev != rtl_ec_net_dev) {
if (tp->phys[0] >= 0) {
mii_check_media(&tp->mii, netif_msg_link(tp), init_media);
}
} else {
void __iomem *ioaddr = tp->mmio_addr;
uint16_t state = RTL_R16(BasicModeStatus) & BMSR_LSTATUS;
ecdev_link_state(rtl_ec_dev, state ? 1 : 0);
}
if (dev != rtl_ec_net_dev) {
if (tp->phys[0] >= 0) {
mii_check_media(&tp->mii, netif_msg_link(tp), init_media);
}
} else {
void __iomem *ioaddr = tp->mmio_addr;
uint16_t state = RTL_R16(BasicModeStatus) & BMSR_LSTATUS;
ecdev_link_state(rtl_ec_dev, state ? 1 : 0);
}
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
}
/* Start the hardware at open or resume. */
@ -1556,9 +1555,9 @@ static void rtl8139_hw_start (struct net_device *dev)
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
if (dev != rtl_ec_net_dev) {
/* Enable all known interrupts by setting the interrupt mask. */
RTL_W16 (IntrMask, rtl8139_intr_mask);
if (dev != rtl_ec_net_dev) {
/* Enable all known interrupts by setting the interrupt mask. */
RTL_W16 (IntrMask, rtl8139_intr_mask);
}
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
@ -1818,30 +1817,30 @@ static void rtl8139_tx_timeout (struct net_device *dev)
/* disable Tx ASAP, if not already */
tmp8 = RTL_R8 (ChipCmd);
if (tmp8 & CmdTxEnb)
RTL_W8 (ChipCmd, CmdRxEnb);
RTL_W8 (ChipCmd, CmdRxEnb);
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
if (dev != rtl_ec_net_dev) {
spin_lock(&tp->rx_lock);
/* Disable interrupts by clearing the interrupt mask. */
RTL_W16 (IntrMask, 0x0000);
if (dev != rtl_ec_net_dev) {
spin_lock(&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_irqsave (&tp->lock, flags);
rtl8139_tx_clear (tp);
spin_unlock_irqrestore (&tp->lock, flags);
/* Stop a shared interrupt from scavenging while we are. */
spin_lock_irqsave (&tp->lock, flags);
rtl8139_tx_clear (tp);
spin_unlock_irqrestore (&tp->lock, flags);
/* ...and finally, reset everything */
if (netif_running(dev)) {
rtl8139_hw_start (dev);
netif_wake_queue (dev);
}
spin_unlock(&tp->rx_lock);
} else {
rtl8139_tx_clear (tp);
rtl8139_hw_start(dev);
}
/* ...and finally, reset everything */
if (netif_running(dev)) {
rtl8139_hw_start (dev);
netif_wake_queue (dev);
}
spin_unlock(&tp->rx_lock);
} else {
rtl8139_tx_clear (tp);
rtl8139_hw_start (dev);
}
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
}
@ -1857,27 +1856,27 @@ static int rtl8139_start_xmit (struct sk_buff *skb, struct net_device *dev)
/* Calculate the next Tx descriptor entry. */
entry = tp->cur_tx % NUM_TX_DESC;
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
/* Note: the chip doesn't have auto-pad! */
/* Note: the chip doesn't have auto-pad! */
if (likely(len < TX_BUF_SIZE)) {
if (len < ETH_ZLEN)
memset(tp->tx_buf[entry], 0, ETH_ZLEN);
skb_copy_and_csum_dev(skb, tp->tx_buf[entry]);
if (dev != rtl_ec_net_dev) {
dev_kfree_skb(skb);
}
if (len < ETH_ZLEN)
memset(tp->tx_buf[entry], 0, ETH_ZLEN);
skb_copy_and_csum_dev(skb, tp->tx_buf[entry]);
if (dev != rtl_ec_net_dev) {
dev_kfree_skb(skb);
}
} else {
if (dev != rtl_ec_net_dev) {
dev_kfree_skb(skb);
}
tp->stats.tx_dropped++;
return 0;
if (dev != rtl_ec_net_dev) {
dev_kfree_skb(skb);
}
tp->stats.tx_dropped++;
return 0;
}
if (dev != rtl_ec_net_dev) {
spin_lock_irq(&tp->lock);
}
spin_lock_irq(&tp->lock);
}
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
@ -1892,14 +1891,14 @@ static int rtl8139_start_xmit (struct sk_buff *skb, struct net_device *dev)
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
if (dev != rtl_ec_net_dev) {
if ((tp->cur_tx - NUM_TX_DESC) == tp->dirty_tx)
netif_stop_queue (dev);
spin_unlock_irq(&tp->lock);
if ((tp->cur_tx - NUM_TX_DESC) == tp->dirty_tx)
netif_stop_queue (dev);
spin_unlock_irq(&tp->lock);
if (netif_msg_tx_queued(tp))
printk (KERN_DEBUG "%s: Queued Tx packet size %u to slot %d.\n",
dev->name, len, entry);
}
if (netif_msg_tx_queued(tp))
printk (KERN_DEBUG "%s: Queued Tx packet size %u to slot %d.\n",
dev->name, len, entry);
}
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
@ -1960,7 +1959,7 @@ static void rtl8139_tx_interrupt (struct net_device *dev,
tx_left--;
}
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
#ifndef RTL8139_NDEBUG
if (dev != rtl_ec_net_dev && tp->cur_tx - dirty_tx > NUM_TX_DESC) {
@ -1970,21 +1969,16 @@ static void rtl8139_tx_interrupt (struct net_device *dev,
}
#endif /* RTL8139_NDEBUG */
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
/* only wake the queue if we did work, and the queue is stopped */
if (tp->dirty_tx != dirty_tx) {
tp->dirty_tx = dirty_tx;
mb();
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
if (dev != rtl_ec_net_dev) {
netif_wake_queue (dev);
}
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
if (dev != rtl_ec_net_dev) {
/* only wake the queue if we did work, and the queue is stopped */
if (tp->dirty_tx != dirty_tx) {
tp->dirty_tx = dirty_tx;
mb();
netif_wake_queue (dev);
}
}
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
}
@ -2118,13 +2112,13 @@ static int rtl8139_rx(struct net_device *dev, struct rtl8139_private *tp,
RTL_R16 (RxBufPtr), RTL_R8 (ChipCmd));
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
while ((dev == rtl_ec_net_dev || netif_running(dev))
&& received < budget
&& (RTL_R8 (ChipCmd) & RxBufEmpty) == 0) {
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
u32 ring_offset = cur_rx % RX_BUF_LEN;
u32 rx_status;
@ -2138,25 +2132,25 @@ static int rtl8139_rx(struct net_device *dev, struct rtl8139_private *tp,
rx_size = rx_status >> 16;
pkt_size = rx_size - 4;
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
if (dev != rtl_ec_net_dev) {
if (netif_msg_rx_status(tp))
printk(KERN_DEBUG "%s: rtl8139_rx() status %4.4x, size %4.4x,"
" cur %4.4x.\n", dev->name, rx_status,
rx_size, cur_rx);
}
if (dev != rtl_ec_net_dev) {
if (netif_msg_rx_status(tp))
printk(KERN_DEBUG "%s: rtl8139_rx() status %4.4x, size %4.4x,"
" cur %4.4x.\n", dev->name, rx_status,
rx_size, cur_rx);
}
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
#if RTL8139_DEBUG > 2
{
int i;
DPRINTK ("%s: Frame contents ", dev->name);
for (i = 0; i < 70; i++)
printk (" %2.2x",
rx_ring[ring_offset + i]);
printk (".\n");
int i;
DPRINTK ("%s: Frame contents ", dev->name);
for (i = 0; i < 70; i++)
printk (" %2.2x",
rx_ring[ring_offset + i]);
printk (".\n");
}
#endif
@ -2196,46 +2190,46 @@ no_early_rx:
goto out;
}
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
if (dev != rtl_ec_net_dev) {
/* Malloc up new buffer, compatible with net-2e. */
/* Omit the four octet CRC from the length. */
if (dev != rtl_ec_net_dev) {
/* Malloc up new buffer, compatible with net-2e. */
/* Omit the four octet CRC from the length. */
skb = dev_alloc_skb (pkt_size + 2);
if (likely(skb)) {
skb->dev = dev;
skb_reserve (skb, 2); /* 16 byte align the IP fields. */
skb = dev_alloc_skb (pkt_size + 2);
if (likely(skb)) {
skb->dev = dev;
skb_reserve (skb, 2); /* 16 byte align the IP fields. */
#if RX_BUF_IDX == 3
wrap_copy(skb, rx_ring, ring_offset+4, pkt_size);
wrap_copy(skb, rx_ring, ring_offset+4, pkt_size);
#else
eth_copy_and_sum (skb, &rx_ring[ring_offset + 4], pkt_size, 0);
eth_copy_and_sum (skb, &rx_ring[ring_offset + 4], pkt_size, 0);
#endif
skb_put (skb, pkt_size);
skb_put (skb, pkt_size);
skb->protocol = eth_type_trans (skb, dev);
skb->protocol = eth_type_trans (skb, dev);
dev->last_rx = jiffies;
tp->stats.rx_bytes += pkt_size;
tp->stats.rx_packets++;
dev->last_rx = jiffies;
tp->stats.rx_bytes += pkt_size;
tp->stats.rx_packets++;
netif_receive_skb (skb);
} else {
if (net_ratelimit())
printk (KERN_WARNING
"%s: Memory squeeze, dropping packet.\n",
dev->name);
tp->stats.rx_dropped++;
}
} else {
ecdev_receive(rtl_ec_dev,
&rx_ring[ring_offset + 4], pkt_size);
dev->last_rx = jiffies;
tp->stats.rx_bytes += pkt_size;
tp->stats.rx_packets++;
}
netif_receive_skb (skb);
} else {
if (net_ratelimit())
printk(KERN_WARNING
"%s: Memory squeeze, dropping packet.\n",
dev->name);
tp->stats.rx_dropped++;
}
} else {
ecdev_receive(rtl_ec_dev,
&rx_ring[ring_offset + 4], pkt_size);
dev->last_rx = jiffies;
tp->stats.rx_bytes += pkt_size;
tp->stats.rx_packets++;
}
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
received++;
@ -2308,7 +2302,7 @@ static void rtl8139_weird_interrupt (struct net_device *dev,
}
}
int rtl8139_poll(struct net_device *dev, int *budget)
static int rtl8139_poll(struct net_device *dev, int *budget)
{
struct rtl8139_private *tp = netdev_priv(dev);
void __iomem *ioaddr = tp->mmio_addr;
@ -2332,10 +2326,10 @@ int rtl8139_poll(struct net_device *dev, int *budget)
* Order is important since data can get interrupted
* again when we think we are done.
*/
local_irq_disable();
RTL_W16_F(IntrMask, rtl8139_intr_mask);
__netif_rx_complete(dev);
local_irq_enable();
local_irq_disable();
RTL_W16_F(IntrMask, rtl8139_intr_mask);
__netif_rx_complete(dev);
local_irq_enable();
}
spin_unlock(&tp->rx_lock);
@ -2354,38 +2348,38 @@ irqreturn_t rtl8139_interrupt (int irq, void *dev_instance,
int link_changed = 0; /* avoid bogus "uninit" warning */
int handled = 0;
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
if (dev != rtl_ec_net_dev) {
spin_lock (&tp->lock);
status = RTL_R16 (IntrStatus);
spin_lock (&tp->lock);
status = RTL_R16 (IntrStatus);
/* shared irq? */
if (unlikely((status & rtl8139_intr_mask) == 0))
goto out;
} else {
status = RTL_R16 (IntrStatus);
}
/* shared irq? */
if (unlikely((status & rtl8139_intr_mask) == 0))
goto out;
} else {
status = RTL_R16 (IntrStatus);
}
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
handled = 1;
/* h/w no longer present (hotplug?) or major error, bail */
if (unlikely(status == 0xFFFF))
if (unlikely(status == 0xFFFF))
goto out;
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
if (dev != rtl_ec_net_dev) {
/* close possible race's with dev_close */
if (unlikely(!netif_running(dev))) {
RTL_W16 (IntrMask, 0);
goto out;
}
/* close possible race's with dev_close */
if (unlikely(!netif_running(dev))) {
RTL_W16 (IntrMask, 0);
goto out;
}
}
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
/* Acknowledge all of the current interrupt sources ASAP, but
an first get an additional status bit from CSCR. */
@ -2399,22 +2393,22 @@ irqreturn_t rtl8139_interrupt (int irq, void *dev_instance,
/* Receive packets are processed by poll routine.
If not running start it now. */
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
if (status & RxAckBits){
if (dev != rtl_ec_net_dev) {
/* Mark for polling */
if (netif_rx_schedule_prep(dev)) {
RTL_W16_F (IntrMask, rtl8139_norx_intr_mask);
__netif_rx_schedule (dev);
}
} else {
/* EtherCAT device: Just receive all frames */
rtl8139_rx(dev, tp, 100); // FIXME
}
if (dev != rtl_ec_net_dev) {
/* Mark for polling */
if (netif_rx_schedule_prep(dev)) {
RTL_W16_F (IntrMask, rtl8139_norx_intr_mask);
__netif_rx_schedule (dev);
}
} else {
/* EtherCAT device: Just receive all frames */
rtl8139_rx(dev, tp, 100); // FIXME
}
}
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
/* Check uncommon events with one test. */
if (unlikely(status & (PCIErr | PCSTimeout | RxUnderrun | RxErr)))
@ -2428,13 +2422,13 @@ irqreturn_t rtl8139_interrupt (int irq, void *dev_instance,
}
out:
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
if (dev != rtl_ec_net_dev) {
spin_unlock (&tp->lock);
}
spin_unlock (&tp->lock);
}
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
DPRINTK ("%s: exiting interrupt, intr_status=%#4.4x.\n",
dev->name, RTL_R16 (IntrStatus));
@ -2461,55 +2455,55 @@ static int rtl8139_close (struct net_device *dev)
int ret = 0;
unsigned long flags;
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
if (dev != rtl_ec_net_dev) {
netif_stop_queue (dev);
if (dev != rtl_ec_net_dev) {
netif_stop_queue (dev);
if (tp->thr_pid >= 0) {
tp->time_to_die = 1;
wmb();
ret = kill_proc (tp->thr_pid, SIGTERM, 1);
if (ret) {
printk (KERN_ERR "%s: unable to signal thread\n", dev->name);
return ret;
}
wait_for_completion (&tp->thr_exited);
}
if (tp->thr_pid >= 0) {
tp->time_to_die = 1;
wmb();
ret = kill_proc (tp->thr_pid, SIGTERM, 1);
if (ret) {
printk (KERN_ERR "%s: unable to signal thread\n", dev->name);
return ret;
}
wait_for_completion (&tp->thr_exited);
}
if (netif_msg_ifdown(tp))
printk(KERN_DEBUG "%s: Shutting down ethercard, status was 0x%4.4x.\n",
dev->name, RTL_R16 (IntrStatus));
if (netif_msg_ifdown(tp))
printk(KERN_DEBUG "%s: Shutting down ethercard, status was 0x%4.4x.\n",
dev->name, RTL_R16 (IntrStatus));
spin_lock_irqsave (&tp->lock, flags);
spin_lock_irqsave (&tp->lock, flags);
/* Stop the chip's Tx and Rx DMA processes. */
RTL_W8 (ChipCmd, 0);
/* Stop the chip's Tx and Rx DMA processes. */
RTL_W8 (ChipCmd, 0);
/* Disable interrupts by clearing the interrupt mask. */
RTL_W16 (IntrMask, 0);
/* Disable interrupts by clearing the interrupt mask. */
RTL_W16 (IntrMask, 0);
/* Update the error counts. */
tp->stats.rx_missed_errors += RTL_R32 (RxMissed);
RTL_W32 (RxMissed, 0);
/* Update the error counts. */
tp->stats.rx_missed_errors += RTL_R32 (RxMissed);
RTL_W32 (RxMissed, 0);
spin_unlock_irqrestore (&tp->lock, flags);
spin_unlock_irqrestore (&tp->lock, flags);
synchronize_irq (dev->irq); /* racy, but that's ok here */
free_irq (dev->irq, dev);
} else {
/* Stop the chip's Tx and Rx DMA processes. */
RTL_W8 (ChipCmd, 0);
synchronize_irq (dev->irq); /* racy, but that's ok here */
free_irq (dev->irq, dev);
} else {
/* Stop the chip's Tx and Rx DMA processes. */
RTL_W8 (ChipCmd, 0);
/* Disable interrupts by clearing the interrupt mask. */
RTL_W16 (IntrMask, 0);
/* Disable interrupts by clearing the interrupt mask. */
RTL_W16 (IntrMask, 0);
/* Update the error counts. */
tp->stats.rx_missed_errors += RTL_R32 (RxMissed);
RTL_W32 (RxMissed, 0);
}
/* Update the error counts. */
tp->stats.rx_missed_errors += RTL_R32 (RxMissed);
RTL_W32 (RxMissed, 0);
}
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
rtl8139_tx_clear (tp);
@ -2724,12 +2718,12 @@ static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
struct rtl8139_private *np = netdev_priv(dev);
int rc;
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
if (dev == rtl_ec_net_dev || !netif_running(dev))
return -EINVAL;
if (dev == rtl_ec_net_dev || !netif_running(dev))
return -EINVAL;
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
spin_lock_irq(&np->lock);
rc = generic_mii_ioctl(&np->mii, if_mii(rq), cmd, NULL);
@ -2745,16 +2739,16 @@ static struct net_device_stats *rtl8139_get_stats (struct net_device *dev)
void __iomem *ioaddr = tp->mmio_addr;
unsigned long flags;
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
if (dev == rtl_ec_net_dev || netif_running(dev)) {
spin_lock_irqsave (&tp->lock, flags);
tp->stats.rx_missed_errors += RTL_R32 (RxMissed);
RTL_W32 (RxMissed, 0);
spin_unlock_irqrestore (&tp->lock, flags);
spin_lock_irqsave (&tp->lock, flags);
tp->stats.rx_missed_errors += RTL_R32 (RxMissed);
RTL_W32 (RxMissed, 0);
spin_unlock_irqrestore (&tp->lock, flags);
}
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
return &tp->stats;
}
@ -2815,9 +2809,9 @@ static void rtl8139_set_rx_mode (struct net_device *dev)
unsigned long flags;
struct rtl8139_private *tp = netdev_priv(dev);
spin_lock_irqsave (&tp->lock, flags);
__set_rx_mode(dev);
spin_unlock_irqrestore (&tp->lock, flags);
spin_lock_irqsave (&tp->lock, flags);
__set_rx_mode(dev);
spin_unlock_irqrestore (&tp->lock, flags);
}
#ifdef CONFIG_PM
@ -2831,12 +2825,12 @@ static int rtl8139_suspend (struct pci_dev *pdev, pm_message_t state)
pci_save_state (pdev);
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
if (dev == rtl_ec_net_dev || !netif_running (dev))
return 0;
return 0;
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
netif_device_detach (dev);
@ -2864,12 +2858,12 @@ static int rtl8139_resume (struct pci_dev *pdev)
pci_restore_state (pdev);
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
if (dev == rtl_ec_net_dev || !netif_running (dev))
return 0;
return 0;
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
pci_set_power_state (pdev, PCI_D0);
rtl8139_init_ring (dev);
@ -2895,66 +2889,65 @@ static struct pci_driver rtl8139_pci_driver = {
static int __init rtl8139_init_module (void)
{
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
printk(KERN_INFO RTL8139_DRIVER_NAME "\n");
printk(KERN_INFO "ec_device_index is %i\n", ec_device_index);
printk(KERN_INFO RTL8139_DRIVER_NAME "\n");
printk(KERN_INFO "ec_device_index is %i\n", ec_device_index);
if (pci_module_init(&rtl8139_pci_driver) < 0) {
printk(KERN_ERR "Failed to init PCI module.\n");
goto out_return;
}
if (pci_module_init(&rtl8139_pci_driver) < 0) {
printk(KERN_ERR "Failed to init PCI module.\n");
goto out_return;
}
if (rtl_ec_net_dev) {
printk(KERN_INFO "Registering EtherCAT device...\n");
if (!(rtl_ec_dev = ecdev_register(ec_device_master_index,
rtl_ec_net_dev, rtl8139_interrupt,
THIS_MODULE))) {
printk(KERN_ERR "Failed to register EtherCAT device!\n");
goto out_pci;
}
if (rtl_ec_net_dev) {
printk(KERN_INFO "Registering EtherCAT device...\n");
if (!(rtl_ec_dev = ecdev_register(ec_device_master_index,
rtl_ec_net_dev, rtl8139_interrupt, THIS_MODULE))) {
printk(KERN_ERR "Failed to register EtherCAT device!\n");
goto out_pci;
}
printk(KERN_INFO "Starting EtherCAT device...\n");
if (ecdev_start(ec_device_master_index)) {
printk(KERN_ERR "Failed to start EtherCAT device!\n");
goto out_unregister;
}
} else {
printk(KERN_WARNING "No EtherCAT device registered!\n");
}
printk(KERN_INFO "Starting EtherCAT device...\n");
if (ecdev_start(ec_device_master_index)) {
printk(KERN_ERR "Failed to start EtherCAT device!\n");
goto out_unregister;
}
} else {
printk(KERN_WARNING "No EtherCAT device registered!\n");
}
return 0;
return 0;
out_unregister:
ecdev_unregister(ec_device_master_index, rtl_ec_dev);
out_pci:
pci_unregister_driver(&rtl8139_pci_driver);
out_return:
return -1;
out_unregister:
ecdev_unregister(ec_device_master_index, rtl_ec_dev);
out_pci:
pci_unregister_driver(&rtl8139_pci_driver);
out_return:
return -1;
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
}
static void __exit rtl8139_cleanup_module (void)
{
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
/* EtherCAT >>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
printk(KERN_INFO "Cleaning up RTL8139-EtherCAT module...\n");
printk(KERN_INFO "Cleaning up RTL8139-EtherCAT module...\n");
if (rtl_ec_net_dev) {
printk(KERN_INFO "Stopping device...\n");
ecdev_stop(ec_device_master_index);
printk(KERN_INFO "Unregistering device...\n");
ecdev_unregister(ec_device_master_index, rtl_ec_dev);
rtl_ec_dev = NULL;
}
if (rtl_ec_net_dev) {
printk(KERN_INFO "Stopping device...\n");
ecdev_stop(ec_device_master_index);
printk(KERN_INFO "Unregistering device...\n");
ecdev_unregister(ec_device_master_index, rtl_ec_dev);
rtl_ec_dev = NULL;
}
pci_unregister_driver(&rtl8139_pci_driver);
pci_unregister_driver(&rtl8139_pci_driver);
printk(KERN_INFO "RTL8139-EtherCAT module cleaned up.\n");
printk(KERN_INFO "RTL8139-EtherCAT module cleaned up.\n");
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
/* EtherCAT <<<<<<<<<<<<<<<<<<<<<<<<<<<<*/
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -31,9 +31,11 @@
#
#------------------------------------------------------------------------------
EC_MOD_KERNEL := $(VERSION).$(PATCHLEVEL).$(SUBLEVEL)
obj-m := ec_8139too.o
ec_8139too-objs := 8139too.o
ec_8139too-objs := 8139too-$(EC_MOD_KERNEL)-ethercat.o
REV := $(shell if test -s $(src)/../svnrevision; then \
cat $(src)/../svnrevision; \
@ -41,6 +43,6 @@ REV := $(shell if test -s $(src)/../svnrevision; then \
svnversion $(src)/.. 2>/dev/null || echo "unknown"; \
fi)
CFLAGS_8139too.o = -DSVNREV=$(REV)
CFLAGS_8139too-$(EC_MOD_KERNEL)-ethercat.o = -DSVNREV=$(REV)
#------------------------------------------------------------------------------

View File

@ -34,8 +34,10 @@
EXTRA_DIST = \
Kbuild \
ecdev.h \
8139too.c \
original_8139too.c
8139too-2.6.13-ethercat.c \
8139too-2.6.13-orig.c \
8139too-2.6.17-ethercat.c \
8139too-2.6.17-orig.c
all-local:
$(MAKE) -C "$(LINUX_SOURCE_DIR)" M="@abs_srcdir@" modules