2018-02-06 19:34:23 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2006-06-24 04:23:01 +00:00
|
|
|
/* sunqe.c: Sparc QuadEthernet 10baseT SBUS card driver.
|
2005-04-16 22:20:36 +00:00
|
|
|
* Once again I am out to prove that every ethernet
|
|
|
|
* controller out there can be most efficiently programmed
|
|
|
|
* if you make it look like a LANCE.
|
|
|
|
*
|
2008-08-27 07:12:27 +00:00
|
|
|
* Copyright (C) 1996, 1999, 2003, 2006, 2008 David S. Miller (davem@davemloft.net)
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/fcntl.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/ioport.h>
|
|
|
|
#include <linux/in.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/string.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/crc32.h>
|
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/etherdevice.h>
|
|
|
|
#include <linux/skbuff.h>
|
|
|
|
#include <linux/ethtool.h>
|
|
|
|
#include <linux/bitops.h>
|
2008-08-28 01:09:11 +00:00
|
|
|
#include <linux/dma-mapping.h>
|
2008-08-27 07:12:27 +00:00
|
|
|
#include <linux/of.h>
|
|
|
|
#include <linux/of_device.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/dma.h>
|
|
|
|
#include <asm/byteorder.h>
|
|
|
|
#include <asm/idprom.h>
|
|
|
|
#include <asm/openprom.h>
|
|
|
|
#include <asm/oplib.h>
|
|
|
|
#include <asm/auxio.h>
|
2020-06-09 04:32:38 +00:00
|
|
|
#include <linux/pgtable.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <asm/irq.h>
|
|
|
|
|
|
|
|
#include "sunqe.h"
|
|
|
|
|
2005-04-25 03:35:20 +00:00
|
|
|
#define DRV_NAME "sunqe"
|
2008-08-27 07:12:27 +00:00
|
|
|
#define DRV_VERSION "4.1"
|
|
|
|
#define DRV_RELDATE "August 27, 2008"
|
2006-06-24 04:23:01 +00:00
|
|
|
#define DRV_AUTHOR "David S. Miller (davem@davemloft.net)"
|
2005-04-25 03:35:20 +00:00
|
|
|
|
|
|
|
static char version[] =
|
|
|
|
DRV_NAME ".c:v" DRV_VERSION " " DRV_RELDATE " " DRV_AUTHOR "\n";
|
|
|
|
|
|
|
|
MODULE_VERSION(DRV_VERSION);
|
|
|
|
MODULE_AUTHOR(DRV_AUTHOR);
|
|
|
|
MODULE_DESCRIPTION("Sun QuadEthernet 10baseT SBUS card driver");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
static struct sunqec *root_qec_dev;
|
|
|
|
|
|
|
|
static void qe_set_multicast(struct net_device *dev);
|
|
|
|
|
|
|
|
#define QEC_RESET_TRIES 200
|
|
|
|
|
|
|
|
static inline int qec_global_reset(void __iomem *gregs)
|
|
|
|
{
|
|
|
|
int tries = QEC_RESET_TRIES;
|
|
|
|
|
|
|
|
sbus_writel(GLOB_CTRL_RESET, gregs + GLOB_CTRL);
|
|
|
|
while (--tries) {
|
|
|
|
u32 tmp = sbus_readl(gregs + GLOB_CTRL);
|
|
|
|
if (tmp & GLOB_CTRL_RESET) {
|
|
|
|
udelay(20);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (tries)
|
|
|
|
return 0;
|
|
|
|
printk(KERN_ERR "QuadEther: AIEEE cannot reset the QEC!\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define MACE_RESET_RETRIES 200
|
|
|
|
#define QE_RESET_RETRIES 200
|
|
|
|
|
|
|
|
static inline int qe_stop(struct sunqe *qep)
|
|
|
|
{
|
|
|
|
void __iomem *cregs = qep->qcregs;
|
|
|
|
void __iomem *mregs = qep->mregs;
|
|
|
|
int tries;
|
|
|
|
|
|
|
|
/* Reset the MACE, then the QEC channel. */
|
|
|
|
sbus_writeb(MREGS_BCONFIG_RESET, mregs + MREGS_BCONFIG);
|
|
|
|
tries = MACE_RESET_RETRIES;
|
|
|
|
while (--tries) {
|
|
|
|
u8 tmp = sbus_readb(mregs + MREGS_BCONFIG);
|
|
|
|
if (tmp & MREGS_BCONFIG_RESET) {
|
|
|
|
udelay(20);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!tries) {
|
|
|
|
printk(KERN_ERR "QuadEther: AIEEE cannot reset the MACE!\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
sbus_writel(CREG_CTRL_RESET, cregs + CREG_CTRL);
|
|
|
|
tries = QE_RESET_RETRIES;
|
|
|
|
while (--tries) {
|
|
|
|
u32 tmp = sbus_readl(cregs + CREG_CTRL);
|
|
|
|
if (tmp & CREG_CTRL_RESET) {
|
|
|
|
udelay(20);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (!tries) {
|
|
|
|
printk(KERN_ERR "QuadEther: Cannot reset QE channel!\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void qe_init_rings(struct sunqe *qep)
|
|
|
|
{
|
|
|
|
struct qe_init_block *qb = qep->qe_block;
|
|
|
|
struct sunqe_buffers *qbufs = qep->buffers;
|
2016-10-17 20:56:59 +00:00
|
|
|
__u32 qbufs_dvma = (__u32)qep->buffers_dvma;
|
2005-04-16 22:20:36 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
qep->rx_new = qep->rx_old = qep->tx_new = qep->tx_old = 0;
|
|
|
|
memset(qb, 0, sizeof(struct qe_init_block));
|
|
|
|
memset(qbufs, 0, sizeof(struct sunqe_buffers));
|
|
|
|
for (i = 0; i < RX_RING_SIZE; i++) {
|
|
|
|
qb->qe_rxd[i].rx_addr = qbufs_dvma + qebuf_offset(rx_buf, i);
|
|
|
|
qb->qe_rxd[i].rx_flags =
|
|
|
|
(RXD_OWN | ((RXD_PKT_SZ) & RXD_LENGTH));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int qe_init(struct sunqe *qep, int from_irq)
|
|
|
|
{
|
|
|
|
struct sunqec *qecp = qep->parent;
|
|
|
|
void __iomem *cregs = qep->qcregs;
|
|
|
|
void __iomem *mregs = qep->mregs;
|
|
|
|
void __iomem *gregs = qecp->gregs;
|
|
|
|
unsigned char *e = &qep->dev->dev_addr[0];
|
2016-10-17 20:56:59 +00:00
|
|
|
__u32 qblk_dvma = (__u32)qep->qblock_dvma;
|
2005-04-16 22:20:36 +00:00
|
|
|
u32 tmp;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Shut it up. */
|
|
|
|
if (qe_stop(qep))
|
|
|
|
return -EAGAIN;
|
|
|
|
|
|
|
|
/* Setup initial rx/tx init block pointers. */
|
2016-10-17 20:56:59 +00:00
|
|
|
sbus_writel(qblk_dvma + qib_offset(qe_rxd, 0), cregs + CREG_RXDS);
|
|
|
|
sbus_writel(qblk_dvma + qib_offset(qe_txd, 0), cregs + CREG_TXDS);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Enable/mask the various irq's. */
|
|
|
|
sbus_writel(0, cregs + CREG_RIMASK);
|
|
|
|
sbus_writel(1, cregs + CREG_TIMASK);
|
|
|
|
|
|
|
|
sbus_writel(0, cregs + CREG_QMASK);
|
|
|
|
sbus_writel(CREG_MMASK_RXCOLL, cregs + CREG_MMASK);
|
|
|
|
|
|
|
|
/* Setup the FIFO pointers into QEC local memory. */
|
|
|
|
tmp = qep->channel * sbus_readl(gregs + GLOB_MSIZE);
|
|
|
|
sbus_writel(tmp, cregs + CREG_RXRBUFPTR);
|
|
|
|
sbus_writel(tmp, cregs + CREG_RXWBUFPTR);
|
|
|
|
|
|
|
|
tmp = sbus_readl(cregs + CREG_RXRBUFPTR) +
|
|
|
|
sbus_readl(gregs + GLOB_RSIZE);
|
|
|
|
sbus_writel(tmp, cregs + CREG_TXRBUFPTR);
|
|
|
|
sbus_writel(tmp, cregs + CREG_TXWBUFPTR);
|
|
|
|
|
|
|
|
/* Clear the channel collision counter. */
|
|
|
|
sbus_writel(0, cregs + CREG_CCNT);
|
|
|
|
|
|
|
|
/* For 10baseT, inter frame space nor throttle seems to be necessary. */
|
|
|
|
sbus_writel(0, cregs + CREG_PIPG);
|
|
|
|
|
|
|
|
/* Now dork with the AMD MACE. */
|
|
|
|
sbus_writeb(MREGS_PHYCONFIG_AUTO, mregs + MREGS_PHYCONFIG);
|
|
|
|
sbus_writeb(MREGS_TXFCNTL_AUTOPAD, mregs + MREGS_TXFCNTL);
|
|
|
|
sbus_writeb(0, mregs + MREGS_RXFCNTL);
|
|
|
|
|
|
|
|
/* The QEC dma's the rx'd packets from local memory out to main memory,
|
|
|
|
* and therefore it interrupts when the packet reception is "complete".
|
|
|
|
* So don't listen for the MACE talking about it.
|
|
|
|
*/
|
|
|
|
sbus_writeb(MREGS_IMASK_COLL | MREGS_IMASK_RXIRQ, mregs + MREGS_IMASK);
|
|
|
|
sbus_writeb(MREGS_BCONFIG_BSWAP | MREGS_BCONFIG_64TS, mregs + MREGS_BCONFIG);
|
|
|
|
sbus_writeb((MREGS_FCONFIG_TXF16 | MREGS_FCONFIG_RXF32 |
|
|
|
|
MREGS_FCONFIG_RFWU | MREGS_FCONFIG_TFWU),
|
|
|
|
mregs + MREGS_FCONFIG);
|
|
|
|
|
|
|
|
/* Only usable interface on QuadEther is twisted pair. */
|
|
|
|
sbus_writeb(MREGS_PLSCONFIG_TP, mregs + MREGS_PLSCONFIG);
|
|
|
|
|
|
|
|
/* Tell MACE we are changing the ether address. */
|
|
|
|
sbus_writeb(MREGS_IACONFIG_ACHNGE | MREGS_IACONFIG_PARESET,
|
|
|
|
mregs + MREGS_IACONFIG);
|
|
|
|
while ((sbus_readb(mregs + MREGS_IACONFIG) & MREGS_IACONFIG_ACHNGE) != 0)
|
|
|
|
barrier();
|
|
|
|
sbus_writeb(e[0], mregs + MREGS_ETHADDR);
|
|
|
|
sbus_writeb(e[1], mregs + MREGS_ETHADDR);
|
|
|
|
sbus_writeb(e[2], mregs + MREGS_ETHADDR);
|
|
|
|
sbus_writeb(e[3], mregs + MREGS_ETHADDR);
|
|
|
|
sbus_writeb(e[4], mregs + MREGS_ETHADDR);
|
|
|
|
sbus_writeb(e[5], mregs + MREGS_ETHADDR);
|
|
|
|
|
|
|
|
/* Clear out the address filter. */
|
|
|
|
sbus_writeb(MREGS_IACONFIG_ACHNGE | MREGS_IACONFIG_LARESET,
|
|
|
|
mregs + MREGS_IACONFIG);
|
|
|
|
while ((sbus_readb(mregs + MREGS_IACONFIG) & MREGS_IACONFIG_ACHNGE) != 0)
|
|
|
|
barrier();
|
|
|
|
for (i = 0; i < 8; i++)
|
|
|
|
sbus_writeb(0, mregs + MREGS_FILTER);
|
|
|
|
|
|
|
|
/* Address changes are now complete. */
|
|
|
|
sbus_writeb(0, mregs + MREGS_IACONFIG);
|
|
|
|
|
|
|
|
qe_init_rings(qep);
|
|
|
|
|
|
|
|
/* Wait a little bit for the link to come up... */
|
|
|
|
mdelay(5);
|
|
|
|
if (!(sbus_readb(mregs + MREGS_PHYCONFIG) & MREGS_PHYCONFIG_LTESTDIS)) {
|
|
|
|
int tries = 50;
|
|
|
|
|
2009-02-03 05:39:02 +00:00
|
|
|
while (--tries) {
|
2005-04-16 22:20:36 +00:00
|
|
|
u8 tmp;
|
|
|
|
|
|
|
|
mdelay(5);
|
|
|
|
barrier();
|
|
|
|
tmp = sbus_readb(mregs + MREGS_PHYCONFIG);
|
|
|
|
if ((tmp & MREGS_PHYCONFIG_LSTAT) != 0)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (tries == 0)
|
|
|
|
printk(KERN_NOTICE "%s: Warning, link state is down.\n", qep->dev->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Missed packet counter is cleared on a read. */
|
|
|
|
sbus_readb(mregs + MREGS_MPCNT);
|
|
|
|
|
|
|
|
/* Reload multicast information, this will enable the receiver
|
|
|
|
* and transmitter.
|
|
|
|
*/
|
|
|
|
qe_set_multicast(qep->dev);
|
|
|
|
|
|
|
|
/* QEC should now start to show interrupts. */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Grrr, certain error conditions completely lock up the AMD MACE,
|
|
|
|
* so when we get these we _must_ reset the chip.
|
|
|
|
*/
|
|
|
|
static int qe_is_bolixed(struct sunqe *qep, u32 qe_status)
|
|
|
|
{
|
|
|
|
struct net_device *dev = qep->dev;
|
|
|
|
int mace_hwbug_workaround = 0;
|
|
|
|
|
|
|
|
if (qe_status & CREG_STAT_EDEFER) {
|
|
|
|
printk(KERN_ERR "%s: Excessive transmit defers.\n", dev->name);
|
2007-10-04 00:41:50 +00:00
|
|
|
dev->stats.tx_errors++;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (qe_status & CREG_STAT_CLOSS) {
|
|
|
|
printk(KERN_ERR "%s: Carrier lost, link down?\n", dev->name);
|
2007-10-04 00:41:50 +00:00
|
|
|
dev->stats.tx_errors++;
|
|
|
|
dev->stats.tx_carrier_errors++;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (qe_status & CREG_STAT_ERETRIES) {
|
|
|
|
printk(KERN_ERR "%s: Excessive transmit retries (more than 16).\n", dev->name);
|
2007-10-04 00:41:50 +00:00
|
|
|
dev->stats.tx_errors++;
|
2005-04-16 22:20:36 +00:00
|
|
|
mace_hwbug_workaround = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (qe_status & CREG_STAT_LCOLL) {
|
|
|
|
printk(KERN_ERR "%s: Late transmit collision.\n", dev->name);
|
2007-10-04 00:41:50 +00:00
|
|
|
dev->stats.tx_errors++;
|
|
|
|
dev->stats.collisions++;
|
2005-04-16 22:20:36 +00:00
|
|
|
mace_hwbug_workaround = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (qe_status & CREG_STAT_FUFLOW) {
|
|
|
|
printk(KERN_ERR "%s: Transmit fifo underflow, driver bug.\n", dev->name);
|
2007-10-04 00:41:50 +00:00
|
|
|
dev->stats.tx_errors++;
|
2005-04-16 22:20:36 +00:00
|
|
|
mace_hwbug_workaround = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (qe_status & CREG_STAT_JERROR) {
|
|
|
|
printk(KERN_ERR "%s: Jabber error.\n", dev->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (qe_status & CREG_STAT_BERROR) {
|
|
|
|
printk(KERN_ERR "%s: Babble error.\n", dev->name);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (qe_status & CREG_STAT_CCOFLOW) {
|
2007-10-04 00:41:50 +00:00
|
|
|
dev->stats.tx_errors += 256;
|
|
|
|
dev->stats.collisions += 256;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (qe_status & CREG_STAT_TXDERROR) {
|
|
|
|
printk(KERN_ERR "%s: Transmit descriptor is bogus, driver bug.\n", dev->name);
|
2007-10-04 00:41:50 +00:00
|
|
|
dev->stats.tx_errors++;
|
|
|
|
dev->stats.tx_aborted_errors++;
|
2005-04-16 22:20:36 +00:00
|
|
|
mace_hwbug_workaround = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (qe_status & CREG_STAT_TXLERR) {
|
|
|
|
printk(KERN_ERR "%s: Transmit late error.\n", dev->name);
|
2007-10-04 00:41:50 +00:00
|
|
|
dev->stats.tx_errors++;
|
2005-04-16 22:20:36 +00:00
|
|
|
mace_hwbug_workaround = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (qe_status & CREG_STAT_TXPERR) {
|
|
|
|
printk(KERN_ERR "%s: Transmit DMA parity error.\n", dev->name);
|
2007-10-04 00:41:50 +00:00
|
|
|
dev->stats.tx_errors++;
|
|
|
|
dev->stats.tx_aborted_errors++;
|
2005-04-16 22:20:36 +00:00
|
|
|
mace_hwbug_workaround = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (qe_status & CREG_STAT_TXSERR) {
|
|
|
|
printk(KERN_ERR "%s: Transmit DMA sbus error ack.\n", dev->name);
|
2007-10-04 00:41:50 +00:00
|
|
|
dev->stats.tx_errors++;
|
|
|
|
dev->stats.tx_aborted_errors++;
|
2005-04-16 22:20:36 +00:00
|
|
|
mace_hwbug_workaround = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (qe_status & CREG_STAT_RCCOFLOW) {
|
2007-10-04 00:41:50 +00:00
|
|
|
dev->stats.rx_errors += 256;
|
|
|
|
dev->stats.collisions += 256;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (qe_status & CREG_STAT_RUOFLOW) {
|
2007-10-04 00:41:50 +00:00
|
|
|
dev->stats.rx_errors += 256;
|
|
|
|
dev->stats.rx_over_errors += 256;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (qe_status & CREG_STAT_MCOFLOW) {
|
2007-10-04 00:41:50 +00:00
|
|
|
dev->stats.rx_errors += 256;
|
|
|
|
dev->stats.rx_missed_errors += 256;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (qe_status & CREG_STAT_RXFOFLOW) {
|
|
|
|
printk(KERN_ERR "%s: Receive fifo overflow.\n", dev->name);
|
2007-10-04 00:41:50 +00:00
|
|
|
dev->stats.rx_errors++;
|
|
|
|
dev->stats.rx_over_errors++;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (qe_status & CREG_STAT_RLCOLL) {
|
|
|
|
printk(KERN_ERR "%s: Late receive collision.\n", dev->name);
|
2007-10-04 00:41:50 +00:00
|
|
|
dev->stats.rx_errors++;
|
|
|
|
dev->stats.collisions++;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (qe_status & CREG_STAT_FCOFLOW) {
|
2007-10-04 00:41:50 +00:00
|
|
|
dev->stats.rx_errors += 256;
|
|
|
|
dev->stats.rx_frame_errors += 256;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (qe_status & CREG_STAT_CECOFLOW) {
|
2007-10-04 00:41:50 +00:00
|
|
|
dev->stats.rx_errors += 256;
|
|
|
|
dev->stats.rx_crc_errors += 256;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (qe_status & CREG_STAT_RXDROP) {
|
|
|
|
printk(KERN_ERR "%s: Receive packet dropped.\n", dev->name);
|
2007-10-04 00:41:50 +00:00
|
|
|
dev->stats.rx_errors++;
|
|
|
|
dev->stats.rx_dropped++;
|
|
|
|
dev->stats.rx_missed_errors++;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (qe_status & CREG_STAT_RXSMALL) {
|
|
|
|
printk(KERN_ERR "%s: Receive buffer too small, driver bug.\n", dev->name);
|
2007-10-04 00:41:50 +00:00
|
|
|
dev->stats.rx_errors++;
|
|
|
|
dev->stats.rx_length_errors++;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (qe_status & CREG_STAT_RXLERR) {
|
|
|
|
printk(KERN_ERR "%s: Receive late error.\n", dev->name);
|
2007-10-04 00:41:50 +00:00
|
|
|
dev->stats.rx_errors++;
|
2005-04-16 22:20:36 +00:00
|
|
|
mace_hwbug_workaround = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (qe_status & CREG_STAT_RXPERR) {
|
|
|
|
printk(KERN_ERR "%s: Receive DMA parity error.\n", dev->name);
|
2007-10-04 00:41:50 +00:00
|
|
|
dev->stats.rx_errors++;
|
|
|
|
dev->stats.rx_missed_errors++;
|
2005-04-16 22:20:36 +00:00
|
|
|
mace_hwbug_workaround = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (qe_status & CREG_STAT_RXSERR) {
|
|
|
|
printk(KERN_ERR "%s: Receive DMA sbus error ack.\n", dev->name);
|
2007-10-04 00:41:50 +00:00
|
|
|
dev->stats.rx_errors++;
|
|
|
|
dev->stats.rx_missed_errors++;
|
2005-04-16 22:20:36 +00:00
|
|
|
mace_hwbug_workaround = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (mace_hwbug_workaround)
|
|
|
|
qe_init(qep, 1);
|
|
|
|
return mace_hwbug_workaround;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Per-QE receive interrupt service routine. Just like on the happy meal
|
|
|
|
* we receive directly into skb's with a small packet copy water mark.
|
|
|
|
*/
|
|
|
|
static void qe_rx(struct sunqe *qep)
|
|
|
|
{
|
|
|
|
struct qe_rxd *rxbase = &qep->qe_block->qe_rxd[0];
|
2007-10-04 00:41:50 +00:00
|
|
|
struct net_device *dev = qep->dev;
|
2005-04-16 22:20:36 +00:00
|
|
|
struct qe_rxd *this;
|
|
|
|
struct sunqe_buffers *qbufs = qep->buffers;
|
2016-10-17 20:56:59 +00:00
|
|
|
__u32 qbufs_dvma = (__u32)qep->buffers_dvma;
|
2013-03-08 15:03:25 +00:00
|
|
|
int elem = qep->rx_new;
|
2005-04-16 22:20:36 +00:00
|
|
|
u32 flags;
|
|
|
|
|
|
|
|
this = &rxbase[elem];
|
|
|
|
while (!((flags = this->rx_flags) & RXD_OWN)) {
|
|
|
|
struct sk_buff *skb;
|
|
|
|
unsigned char *this_qbuf =
|
|
|
|
&qbufs->rx_buf[elem & (RX_RING_SIZE - 1)][0];
|
|
|
|
__u32 this_qbuf_dvma = qbufs_dvma +
|
|
|
|
qebuf_offset(rx_buf, (elem & (RX_RING_SIZE - 1)));
|
|
|
|
struct qe_rxd *end_rxd =
|
|
|
|
&rxbase[(elem+RX_RING_SIZE)&(RX_RING_MAXSIZE-1)];
|
|
|
|
int len = (flags & RXD_LENGTH) - 4; /* QE adds ether FCS size to len */
|
|
|
|
|
|
|
|
/* Check for errors. */
|
|
|
|
if (len < ETH_ZLEN) {
|
2007-10-04 00:41:50 +00:00
|
|
|
dev->stats.rx_errors++;
|
|
|
|
dev->stats.rx_length_errors++;
|
|
|
|
dev->stats.rx_dropped++;
|
2005-04-16 22:20:36 +00:00
|
|
|
} else {
|
2012-02-06 11:16:13 +00:00
|
|
|
skb = netdev_alloc_skb(dev, len + 2);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (skb == NULL) {
|
2007-10-04 00:41:50 +00:00
|
|
|
dev->stats.rx_dropped++;
|
2005-04-16 22:20:36 +00:00
|
|
|
} else {
|
|
|
|
skb_reserve(skb, 2);
|
|
|
|
skb_put(skb, len);
|
2012-06-04 12:44:16 +00:00
|
|
|
skb_copy_to_linear_data(skb, this_qbuf,
|
2007-07-11 05:08:12 +00:00
|
|
|
len);
|
2005-04-16 22:20:36 +00:00
|
|
|
skb->protocol = eth_type_trans(skb, qep->dev);
|
|
|
|
netif_rx(skb);
|
2007-10-04 00:41:50 +00:00
|
|
|
dev->stats.rx_packets++;
|
|
|
|
dev->stats.rx_bytes += len;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
end_rxd->rx_addr = this_qbuf_dvma;
|
|
|
|
end_rxd->rx_flags = (RXD_OWN | ((RXD_PKT_SZ) & RXD_LENGTH));
|
2006-09-13 17:24:59 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
elem = NEXT_RX(elem);
|
|
|
|
this = &rxbase[elem];
|
|
|
|
}
|
|
|
|
qep->rx_new = elem;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void qe_tx_reclaim(struct sunqe *qep);
|
|
|
|
|
|
|
|
/* Interrupts for all QE's get filtered out via the QEC master controller,
|
|
|
|
* so we just run through each qe and check to see who is signaling
|
|
|
|
* and thus needs to be serviced.
|
|
|
|
*/
|
IRQ: Maintain regs pointer globally rather than passing to IRQ handlers
Maintain a per-CPU global "struct pt_regs *" variable which can be used instead
of passing regs around manually through all ~1800 interrupt handlers in the
Linux kernel.
The regs pointer is used in few places, but it potentially costs both stack
space and code to pass it around. On the FRV arch, removing the regs parameter
from all the genirq function results in a 20% speed up of the IRQ exit path
(ie: from leaving timer_interrupt() to leaving do_IRQ()).
Where appropriate, an arch may override the generic storage facility and do
something different with the variable. On FRV, for instance, the address is
maintained in GR28 at all times inside the kernel as part of general exception
handling.
Having looked over the code, it appears that the parameter may be handed down
through up to twenty or so layers of functions. Consider a USB character
device attached to a USB hub, attached to a USB controller that posts its
interrupts through a cascaded auxiliary interrupt controller. A character
device driver may want to pass regs to the sysrq handler through the input
layer which adds another few layers of parameter passing.
I've build this code with allyesconfig for x86_64 and i386. I've runtested the
main part of the code on FRV and i386, though I can't test most of the drivers.
I've also done partial conversion for powerpc and MIPS - these at least compile
with minimal configurations.
This will affect all archs. Mostly the changes should be relatively easy.
Take do_IRQ(), store the regs pointer at the beginning, saving the old one:
struct pt_regs *old_regs = set_irq_regs(regs);
And put the old one back at the end:
set_irq_regs(old_regs);
Don't pass regs through to generic_handle_irq() or __do_IRQ().
In timer_interrupt(), this sort of change will be necessary:
- update_process_times(user_mode(regs));
- profile_tick(CPU_PROFILING, regs);
+ update_process_times(user_mode(get_irq_regs()));
+ profile_tick(CPU_PROFILING);
I'd like to move update_process_times()'s use of get_irq_regs() into itself,
except that i386, alone of the archs, uses something other than user_mode().
Some notes on the interrupt handling in the drivers:
(*) input_dev() is now gone entirely. The regs pointer is no longer stored in
the input_dev struct.
(*) finish_unlinks() in drivers/usb/host/ohci-q.c needs checking. It does
something different depending on whether it's been supplied with a regs
pointer or not.
(*) Various IRQ handler function pointers have been moved to type
irq_handler_t.
Signed-Off-By: David Howells <dhowells@redhat.com>
(cherry picked from 1b16e7ac850969f38b375e511e3fa2f474a33867 commit)
2006-10-05 13:55:46 +00:00
|
|
|
static irqreturn_t qec_interrupt(int irq, void *dev_id)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2006-10-06 18:56:04 +00:00
|
|
|
struct sunqec *qecp = dev_id;
|
2005-04-16 22:20:36 +00:00
|
|
|
u32 qec_status;
|
|
|
|
int channel = 0;
|
|
|
|
|
|
|
|
/* Latch the status now. */
|
|
|
|
qec_status = sbus_readl(qecp->gregs + GLOB_STAT);
|
|
|
|
while (channel < 4) {
|
|
|
|
if (qec_status & 0xf) {
|
|
|
|
struct sunqe *qep = qecp->qes[channel];
|
|
|
|
u32 qe_status;
|
|
|
|
|
|
|
|
qe_status = sbus_readl(qep->qcregs + CREG_STAT);
|
|
|
|
if (qe_status & CREG_STAT_ERRORS) {
|
|
|
|
if (qe_is_bolixed(qep, qe_status))
|
|
|
|
goto next;
|
|
|
|
}
|
|
|
|
if (qe_status & CREG_STAT_RXIRQ)
|
|
|
|
qe_rx(qep);
|
|
|
|
if (netif_queue_stopped(qep->dev) &&
|
|
|
|
(qe_status & CREG_STAT_TXIRQ)) {
|
|
|
|
spin_lock(&qep->lock);
|
|
|
|
qe_tx_reclaim(qep);
|
|
|
|
if (TX_BUFFS_AVAIL(qep) > 0) {
|
|
|
|
/* Wake net queue and return to
|
|
|
|
* lazy tx reclaim.
|
|
|
|
*/
|
|
|
|
netif_wake_queue(qep->dev);
|
|
|
|
sbus_writel(1, qep->qcregs + CREG_TIMASK);
|
|
|
|
}
|
|
|
|
spin_unlock(&qep->lock);
|
|
|
|
}
|
|
|
|
next:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
qec_status >>= 4;
|
|
|
|
channel++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int qe_open(struct net_device *dev)
|
|
|
|
{
|
2008-11-13 07:38:36 +00:00
|
|
|
struct sunqe *qep = netdev_priv(dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
qep->mconfig = (MREGS_MCONFIG_TXENAB |
|
|
|
|
MREGS_MCONFIG_RXENAB |
|
|
|
|
MREGS_MCONFIG_MBAENAB);
|
|
|
|
return qe_init(qep, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int qe_close(struct net_device *dev)
|
|
|
|
{
|
2008-11-13 07:38:36 +00:00
|
|
|
struct sunqe *qep = netdev_priv(dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
qe_stop(qep);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Reclaim TX'd frames from the ring. This must always run under
|
|
|
|
* the IRQ protected qep->lock.
|
|
|
|
*/
|
|
|
|
static void qe_tx_reclaim(struct sunqe *qep)
|
|
|
|
{
|
|
|
|
struct qe_txd *txbase = &qep->qe_block->qe_txd[0];
|
|
|
|
int elem = qep->tx_old;
|
|
|
|
|
|
|
|
while (elem != qep->tx_new) {
|
|
|
|
u32 flags = txbase[elem].tx_flags;
|
|
|
|
|
|
|
|
if (flags & TXD_OWN)
|
|
|
|
break;
|
|
|
|
elem = NEXT_TX(elem);
|
|
|
|
}
|
|
|
|
qep->tx_old = elem;
|
|
|
|
}
|
|
|
|
|
netdev: pass the stuck queue to the timeout handler
This allows incrementing the correct timeout statistic without any mess.
Down the road, devices can learn to reset just the specific queue.
The patch was generated with the following script:
use strict;
use warnings;
our $^I = '.bak';
my @work = (
["arch/m68k/emu/nfeth.c", "nfeth_tx_timeout"],
["arch/um/drivers/net_kern.c", "uml_net_tx_timeout"],
["arch/um/drivers/vector_kern.c", "vector_net_tx_timeout"],
["arch/xtensa/platforms/iss/network.c", "iss_net_tx_timeout"],
["drivers/char/pcmcia/synclink_cs.c", "hdlcdev_tx_timeout"],
["drivers/infiniband/ulp/ipoib/ipoib_main.c", "ipoib_timeout"],
["drivers/infiniband/ulp/ipoib/ipoib_main.c", "ipoib_timeout"],
["drivers/message/fusion/mptlan.c", "mpt_lan_tx_timeout"],
["drivers/misc/sgi-xp/xpnet.c", "xpnet_dev_tx_timeout"],
["drivers/net/appletalk/cops.c", "cops_timeout"],
["drivers/net/arcnet/arcdevice.h", "arcnet_timeout"],
["drivers/net/arcnet/arcnet.c", "arcnet_timeout"],
["drivers/net/arcnet/com20020.c", "arcnet_timeout"],
["drivers/net/ethernet/3com/3c509.c", "el3_tx_timeout"],
["drivers/net/ethernet/3com/3c515.c", "corkscrew_timeout"],
["drivers/net/ethernet/3com/3c574_cs.c", "el3_tx_timeout"],
["drivers/net/ethernet/3com/3c589_cs.c", "el3_tx_timeout"],
["drivers/net/ethernet/3com/3c59x.c", "vortex_tx_timeout"],
["drivers/net/ethernet/3com/3c59x.c", "vortex_tx_timeout"],
["drivers/net/ethernet/3com/typhoon.c", "typhoon_tx_timeout"],
["drivers/net/ethernet/8390/8390.h", "ei_tx_timeout"],
["drivers/net/ethernet/8390/8390.h", "eip_tx_timeout"],
["drivers/net/ethernet/8390/8390.c", "ei_tx_timeout"],
["drivers/net/ethernet/8390/8390p.c", "eip_tx_timeout"],
["drivers/net/ethernet/8390/ax88796.c", "ax_ei_tx_timeout"],
["drivers/net/ethernet/8390/axnet_cs.c", "axnet_tx_timeout"],
["drivers/net/ethernet/8390/etherh.c", "__ei_tx_timeout"],
["drivers/net/ethernet/8390/hydra.c", "__ei_tx_timeout"],
["drivers/net/ethernet/8390/mac8390.c", "__ei_tx_timeout"],
["drivers/net/ethernet/8390/mcf8390.c", "__ei_tx_timeout"],
["drivers/net/ethernet/8390/lib8390.c", "__ei_tx_timeout"],
["drivers/net/ethernet/8390/ne2k-pci.c", "ei_tx_timeout"],
["drivers/net/ethernet/8390/pcnet_cs.c", "ei_tx_timeout"],
["drivers/net/ethernet/8390/smc-ultra.c", "ei_tx_timeout"],
["drivers/net/ethernet/8390/wd.c", "ei_tx_timeout"],
["drivers/net/ethernet/8390/zorro8390.c", "__ei_tx_timeout"],
["drivers/net/ethernet/adaptec/starfire.c", "tx_timeout"],
["drivers/net/ethernet/agere/et131x.c", "et131x_tx_timeout"],
["drivers/net/ethernet/allwinner/sun4i-emac.c", "emac_timeout"],
["drivers/net/ethernet/alteon/acenic.c", "ace_watchdog"],
["drivers/net/ethernet/amazon/ena/ena_netdev.c", "ena_tx_timeout"],
["drivers/net/ethernet/amd/7990.h", "lance_tx_timeout"],
["drivers/net/ethernet/amd/7990.c", "lance_tx_timeout"],
["drivers/net/ethernet/amd/a2065.c", "lance_tx_timeout"],
["drivers/net/ethernet/amd/am79c961a.c", "am79c961_timeout"],
["drivers/net/ethernet/amd/amd8111e.c", "amd8111e_tx_timeout"],
["drivers/net/ethernet/amd/ariadne.c", "ariadne_tx_timeout"],
["drivers/net/ethernet/amd/atarilance.c", "lance_tx_timeout"],
["drivers/net/ethernet/amd/au1000_eth.c", "au1000_tx_timeout"],
["drivers/net/ethernet/amd/declance.c", "lance_tx_timeout"],
["drivers/net/ethernet/amd/lance.c", "lance_tx_timeout"],
["drivers/net/ethernet/amd/mvme147.c", "lance_tx_timeout"],
["drivers/net/ethernet/amd/ni65.c", "ni65_timeout"],
["drivers/net/ethernet/amd/nmclan_cs.c", "mace_tx_timeout"],
["drivers/net/ethernet/amd/pcnet32.c", "pcnet32_tx_timeout"],
["drivers/net/ethernet/amd/sunlance.c", "lance_tx_timeout"],
["drivers/net/ethernet/amd/xgbe/xgbe-drv.c", "xgbe_tx_timeout"],
["drivers/net/ethernet/apm/xgene-v2/main.c", "xge_timeout"],
["drivers/net/ethernet/apm/xgene/xgene_enet_main.c", "xgene_enet_timeout"],
["drivers/net/ethernet/apple/macmace.c", "mace_tx_timeout"],
["drivers/net/ethernet/atheros/ag71xx.c", "ag71xx_tx_timeout"],
["drivers/net/ethernet/atheros/alx/main.c", "alx_tx_timeout"],
["drivers/net/ethernet/atheros/atl1c/atl1c_main.c", "atl1c_tx_timeout"],
["drivers/net/ethernet/atheros/atl1e/atl1e_main.c", "atl1e_tx_timeout"],
["drivers/net/ethernet/atheros/atlx/atl.c", "atlx_tx_timeout"],
["drivers/net/ethernet/atheros/atlx/atl1.c", "atlx_tx_timeout"],
["drivers/net/ethernet/atheros/atlx/atl2.c", "atl2_tx_timeout"],
["drivers/net/ethernet/broadcom/b44.c", "b44_tx_timeout"],
["drivers/net/ethernet/broadcom/bcmsysport.c", "bcm_sysport_tx_timeout"],
["drivers/net/ethernet/broadcom/bnx2.c", "bnx2_tx_timeout"],
["drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h", "bnx2x_tx_timeout"],
["drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c", "bnx2x_tx_timeout"],
["drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c", "bnx2x_tx_timeout"],
["drivers/net/ethernet/broadcom/bnxt/bnxt.c", "bnxt_tx_timeout"],
["drivers/net/ethernet/broadcom/genet/bcmgenet.c", "bcmgenet_timeout"],
["drivers/net/ethernet/broadcom/sb1250-mac.c", "sbmac_tx_timeout"],
["drivers/net/ethernet/broadcom/tg3.c", "tg3_tx_timeout"],
["drivers/net/ethernet/calxeda/xgmac.c", "xgmac_tx_timeout"],
["drivers/net/ethernet/cavium/liquidio/lio_main.c", "liquidio_tx_timeout"],
["drivers/net/ethernet/cavium/liquidio/lio_vf_main.c", "liquidio_tx_timeout"],
["drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c", "lio_vf_rep_tx_timeout"],
["drivers/net/ethernet/cavium/thunder/nicvf_main.c", "nicvf_tx_timeout"],
["drivers/net/ethernet/cirrus/cs89x0.c", "net_timeout"],
["drivers/net/ethernet/cisco/enic/enic_main.c", "enic_tx_timeout"],
["drivers/net/ethernet/cisco/enic/enic_main.c", "enic_tx_timeout"],
["drivers/net/ethernet/cortina/gemini.c", "gmac_tx_timeout"],
["drivers/net/ethernet/davicom/dm9000.c", "dm9000_timeout"],
["drivers/net/ethernet/dec/tulip/de2104x.c", "de_tx_timeout"],
["drivers/net/ethernet/dec/tulip/tulip_core.c", "tulip_tx_timeout"],
["drivers/net/ethernet/dec/tulip/winbond-840.c", "tx_timeout"],
["drivers/net/ethernet/dlink/dl2k.c", "rio_tx_timeout"],
["drivers/net/ethernet/dlink/sundance.c", "tx_timeout"],
["drivers/net/ethernet/emulex/benet/be_main.c", "be_tx_timeout"],
["drivers/net/ethernet/ethoc.c", "ethoc_tx_timeout"],
["drivers/net/ethernet/faraday/ftgmac100.c", "ftgmac100_tx_timeout"],
["drivers/net/ethernet/fealnx.c", "fealnx_tx_timeout"],
["drivers/net/ethernet/freescale/dpaa/dpaa_eth.c", "dpaa_tx_timeout"],
["drivers/net/ethernet/freescale/fec_main.c", "fec_timeout"],
["drivers/net/ethernet/freescale/fec_mpc52xx.c", "mpc52xx_fec_tx_timeout"],
["drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c", "fs_timeout"],
["drivers/net/ethernet/freescale/gianfar.c", "gfar_timeout"],
["drivers/net/ethernet/freescale/ucc_geth.c", "ucc_geth_timeout"],
["drivers/net/ethernet/fujitsu/fmvj18x_cs.c", "fjn_tx_timeout"],
["drivers/net/ethernet/google/gve/gve_main.c", "gve_tx_timeout"],
["drivers/net/ethernet/hisilicon/hip04_eth.c", "hip04_timeout"],
["drivers/net/ethernet/hisilicon/hix5hd2_gmac.c", "hix5hd2_net_timeout"],
["drivers/net/ethernet/hisilicon/hns/hns_enet.c", "hns_nic_net_timeout"],
["drivers/net/ethernet/hisilicon/hns3/hns3_enet.c", "hns3_nic_net_timeout"],
["drivers/net/ethernet/huawei/hinic/hinic_main.c", "hinic_tx_timeout"],
["drivers/net/ethernet/i825xx/82596.c", "i596_tx_timeout"],
["drivers/net/ethernet/i825xx/ether1.c", "ether1_timeout"],
["drivers/net/ethernet/i825xx/lib82596.c", "i596_tx_timeout"],
["drivers/net/ethernet/i825xx/sun3_82586.c", "sun3_82586_timeout"],
["drivers/net/ethernet/ibm/ehea/ehea_main.c", "ehea_tx_watchdog"],
["drivers/net/ethernet/ibm/emac/core.c", "emac_tx_timeout"],
["drivers/net/ethernet/ibm/emac/core.c", "emac_tx_timeout"],
["drivers/net/ethernet/ibm/ibmvnic.c", "ibmvnic_tx_timeout"],
["drivers/net/ethernet/intel/e100.c", "e100_tx_timeout"],
["drivers/net/ethernet/intel/e1000/e1000_main.c", "e1000_tx_timeout"],
["drivers/net/ethernet/intel/e1000e/netdev.c", "e1000_tx_timeout"],
["drivers/net/ethernet/intel/fm10k/fm10k_netdev.c", "fm10k_tx_timeout"],
["drivers/net/ethernet/intel/i40e/i40e_main.c", "i40e_tx_timeout"],
["drivers/net/ethernet/intel/iavf/iavf_main.c", "iavf_tx_timeout"],
["drivers/net/ethernet/intel/ice/ice_main.c", "ice_tx_timeout"],
["drivers/net/ethernet/intel/ice/ice_main.c", "ice_tx_timeout"],
["drivers/net/ethernet/intel/igb/igb_main.c", "igb_tx_timeout"],
["drivers/net/ethernet/intel/igbvf/netdev.c", "igbvf_tx_timeout"],
["drivers/net/ethernet/intel/ixgb/ixgb_main.c", "ixgb_tx_timeout"],
["drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c", "adapter->netdev->netdev_ops->ndo_tx_timeout(adapter->netdev);"],
["drivers/net/ethernet/intel/ixgbe/ixgbe_main.c", "ixgbe_tx_timeout"],
["drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c", "ixgbevf_tx_timeout"],
["drivers/net/ethernet/jme.c", "jme_tx_timeout"],
["drivers/net/ethernet/korina.c", "korina_tx_timeout"],
["drivers/net/ethernet/lantiq_etop.c", "ltq_etop_tx_timeout"],
["drivers/net/ethernet/marvell/mv643xx_eth.c", "mv643xx_eth_tx_timeout"],
["drivers/net/ethernet/marvell/pxa168_eth.c", "pxa168_eth_tx_timeout"],
["drivers/net/ethernet/marvell/skge.c", "skge_tx_timeout"],
["drivers/net/ethernet/marvell/sky2.c", "sky2_tx_timeout"],
["drivers/net/ethernet/marvell/sky2.c", "sky2_tx_timeout"],
["drivers/net/ethernet/mediatek/mtk_eth_soc.c", "mtk_tx_timeout"],
["drivers/net/ethernet/mellanox/mlx4/en_netdev.c", "mlx4_en_tx_timeout"],
["drivers/net/ethernet/mellanox/mlx4/en_netdev.c", "mlx4_en_tx_timeout"],
["drivers/net/ethernet/mellanox/mlx5/core/en_main.c", "mlx5e_tx_timeout"],
["drivers/net/ethernet/micrel/ks8842.c", "ks8842_tx_timeout"],
["drivers/net/ethernet/micrel/ksz884x.c", "netdev_tx_timeout"],
["drivers/net/ethernet/microchip/enc28j60.c", "enc28j60_tx_timeout"],
["drivers/net/ethernet/microchip/encx24j600.c", "encx24j600_tx_timeout"],
["drivers/net/ethernet/natsemi/sonic.h", "sonic_tx_timeout"],
["drivers/net/ethernet/natsemi/sonic.c", "sonic_tx_timeout"],
["drivers/net/ethernet/natsemi/jazzsonic.c", "sonic_tx_timeout"],
["drivers/net/ethernet/natsemi/macsonic.c", "sonic_tx_timeout"],
["drivers/net/ethernet/natsemi/natsemi.c", "ns_tx_timeout"],
["drivers/net/ethernet/natsemi/ns83820.c", "ns83820_tx_timeout"],
["drivers/net/ethernet/natsemi/xtsonic.c", "sonic_tx_timeout"],
["drivers/net/ethernet/neterion/s2io.h", "s2io_tx_watchdog"],
["drivers/net/ethernet/neterion/s2io.c", "s2io_tx_watchdog"],
["drivers/net/ethernet/neterion/vxge/vxge-main.c", "vxge_tx_watchdog"],
["drivers/net/ethernet/netronome/nfp/nfp_net_common.c", "nfp_net_tx_timeout"],
["drivers/net/ethernet/nvidia/forcedeth.c", "nv_tx_timeout"],
["drivers/net/ethernet/nvidia/forcedeth.c", "nv_tx_timeout"],
["drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c", "pch_gbe_tx_timeout"],
["drivers/net/ethernet/packetengines/hamachi.c", "hamachi_tx_timeout"],
["drivers/net/ethernet/packetengines/yellowfin.c", "yellowfin_tx_timeout"],
["drivers/net/ethernet/pensando/ionic/ionic_lif.c", "ionic_tx_timeout"],
["drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c", "netxen_tx_timeout"],
["drivers/net/ethernet/qlogic/qla3xxx.c", "ql3xxx_tx_timeout"],
["drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c", "qlcnic_tx_timeout"],
["drivers/net/ethernet/qualcomm/emac/emac.c", "emac_tx_timeout"],
["drivers/net/ethernet/qualcomm/qca_spi.c", "qcaspi_netdev_tx_timeout"],
["drivers/net/ethernet/qualcomm/qca_uart.c", "qcauart_netdev_tx_timeout"],
["drivers/net/ethernet/rdc/r6040.c", "r6040_tx_timeout"],
["drivers/net/ethernet/realtek/8139cp.c", "cp_tx_timeout"],
["drivers/net/ethernet/realtek/8139too.c", "rtl8139_tx_timeout"],
["drivers/net/ethernet/realtek/atp.c", "tx_timeout"],
["drivers/net/ethernet/realtek/r8169_main.c", "rtl8169_tx_timeout"],
["drivers/net/ethernet/renesas/ravb_main.c", "ravb_tx_timeout"],
["drivers/net/ethernet/renesas/sh_eth.c", "sh_eth_tx_timeout"],
["drivers/net/ethernet/renesas/sh_eth.c", "sh_eth_tx_timeout"],
["drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c", "sxgbe_tx_timeout"],
["drivers/net/ethernet/seeq/ether3.c", "ether3_timeout"],
["drivers/net/ethernet/seeq/sgiseeq.c", "timeout"],
["drivers/net/ethernet/sfc/efx.c", "efx_watchdog"],
["drivers/net/ethernet/sfc/falcon/efx.c", "ef4_watchdog"],
["drivers/net/ethernet/sgi/ioc3-eth.c", "ioc3_timeout"],
["drivers/net/ethernet/sgi/meth.c", "meth_tx_timeout"],
["drivers/net/ethernet/silan/sc92031.c", "sc92031_tx_timeout"],
["drivers/net/ethernet/sis/sis190.c", "sis190_tx_timeout"],
["drivers/net/ethernet/sis/sis900.c", "sis900_tx_timeout"],
["drivers/net/ethernet/smsc/epic100.c", "epic_tx_timeout"],
["drivers/net/ethernet/smsc/smc911x.c", "smc911x_timeout"],
["drivers/net/ethernet/smsc/smc9194.c", "smc_timeout"],
["drivers/net/ethernet/smsc/smc91c92_cs.c", "smc_tx_timeout"],
["drivers/net/ethernet/smsc/smc91x.c", "smc_timeout"],
["drivers/net/ethernet/stmicro/stmmac/stmmac_main.c", "stmmac_tx_timeout"],
["drivers/net/ethernet/sun/cassini.c", "cas_tx_timeout"],
["drivers/net/ethernet/sun/ldmvsw.c", "sunvnet_tx_timeout_common"],
["drivers/net/ethernet/sun/niu.c", "niu_tx_timeout"],
["drivers/net/ethernet/sun/sunbmac.c", "bigmac_tx_timeout"],
["drivers/net/ethernet/sun/sungem.c", "gem_tx_timeout"],
["drivers/net/ethernet/sun/sunhme.c", "happy_meal_tx_timeout"],
["drivers/net/ethernet/sun/sunqe.c", "qe_tx_timeout"],
["drivers/net/ethernet/sun/sunvnet.c", "sunvnet_tx_timeout_common"],
["drivers/net/ethernet/sun/sunvnet_common.c", "sunvnet_tx_timeout_common"],
["drivers/net/ethernet/sun/sunvnet_common.h", "sunvnet_tx_timeout_common"],
["drivers/net/ethernet/synopsys/dwc-xlgmac-net.c", "xlgmac_tx_timeout"],
["drivers/net/ethernet/ti/cpmac.c", "cpmac_tx_timeout"],
["drivers/net/ethernet/ti/cpsw.c", "cpsw_ndo_tx_timeout"],
["drivers/net/ethernet/ti/cpsw_priv.c", "cpsw_ndo_tx_timeout"],
["drivers/net/ethernet/ti/cpsw_priv.h", "cpsw_ndo_tx_timeout"],
["drivers/net/ethernet/ti/davinci_emac.c", "emac_dev_tx_timeout"],
["drivers/net/ethernet/ti/netcp_core.c", "netcp_ndo_tx_timeout"],
["drivers/net/ethernet/ti/tlan.c", "tlan_tx_timeout"],
["drivers/net/ethernet/toshiba/ps3_gelic_net.h", "gelic_net_tx_timeout"],
["drivers/net/ethernet/toshiba/ps3_gelic_net.c", "gelic_net_tx_timeout"],
["drivers/net/ethernet/toshiba/ps3_gelic_wireless.c", "gelic_net_tx_timeout"],
["drivers/net/ethernet/toshiba/spider_net.c", "spider_net_tx_timeout"],
["drivers/net/ethernet/toshiba/tc35815.c", "tc35815_tx_timeout"],
["drivers/net/ethernet/via/via-rhine.c", "rhine_tx_timeout"],
["drivers/net/ethernet/wiznet/w5100.c", "w5100_tx_timeout"],
["drivers/net/ethernet/wiznet/w5300.c", "w5300_tx_timeout"],
["drivers/net/ethernet/xilinx/xilinx_emaclite.c", "xemaclite_tx_timeout"],
["drivers/net/ethernet/xircom/xirc2ps_cs.c", "xirc_tx_timeout"],
["drivers/net/fjes/fjes_main.c", "fjes_tx_retry"],
["drivers/net/slip/slip.c", "sl_tx_timeout"],
["include/linux/usb/usbnet.h", "usbnet_tx_timeout"],
["drivers/net/usb/aqc111.c", "usbnet_tx_timeout"],
["drivers/net/usb/asix_devices.c", "usbnet_tx_timeout"],
["drivers/net/usb/asix_devices.c", "usbnet_tx_timeout"],
["drivers/net/usb/asix_devices.c", "usbnet_tx_timeout"],
["drivers/net/usb/ax88172a.c", "usbnet_tx_timeout"],
["drivers/net/usb/ax88179_178a.c", "usbnet_tx_timeout"],
["drivers/net/usb/catc.c", "catc_tx_timeout"],
["drivers/net/usb/cdc_mbim.c", "usbnet_tx_timeout"],
["drivers/net/usb/cdc_ncm.c", "usbnet_tx_timeout"],
["drivers/net/usb/dm9601.c", "usbnet_tx_timeout"],
["drivers/net/usb/hso.c", "hso_net_tx_timeout"],
["drivers/net/usb/int51x1.c", "usbnet_tx_timeout"],
["drivers/net/usb/ipheth.c", "ipheth_tx_timeout"],
["drivers/net/usb/kaweth.c", "kaweth_tx_timeout"],
["drivers/net/usb/lan78xx.c", "lan78xx_tx_timeout"],
["drivers/net/usb/mcs7830.c", "usbnet_tx_timeout"],
["drivers/net/usb/pegasus.c", "pegasus_tx_timeout"],
["drivers/net/usb/qmi_wwan.c", "usbnet_tx_timeout"],
["drivers/net/usb/r8152.c", "rtl8152_tx_timeout"],
["drivers/net/usb/rndis_host.c", "usbnet_tx_timeout"],
["drivers/net/usb/rtl8150.c", "rtl8150_tx_timeout"],
["drivers/net/usb/sierra_net.c", "usbnet_tx_timeout"],
["drivers/net/usb/smsc75xx.c", "usbnet_tx_timeout"],
["drivers/net/usb/smsc95xx.c", "usbnet_tx_timeout"],
["drivers/net/usb/sr9700.c", "usbnet_tx_timeout"],
["drivers/net/usb/sr9800.c", "usbnet_tx_timeout"],
["drivers/net/usb/usbnet.c", "usbnet_tx_timeout"],
["drivers/net/vmxnet3/vmxnet3_drv.c", "vmxnet3_tx_timeout"],
["drivers/net/wan/cosa.c", "cosa_net_timeout"],
["drivers/net/wan/farsync.c", "fst_tx_timeout"],
["drivers/net/wan/fsl_ucc_hdlc.c", "uhdlc_tx_timeout"],
["drivers/net/wan/lmc/lmc_main.c", "lmc_driver_timeout"],
["drivers/net/wan/x25_asy.c", "x25_asy_timeout"],
["drivers/net/wimax/i2400m/netdev.c", "i2400m_tx_timeout"],
["drivers/net/wireless/intel/ipw2x00/ipw2100.c", "ipw2100_tx_timeout"],
["drivers/net/wireless/intersil/hostap/hostap_main.c", "prism2_tx_timeout"],
["drivers/net/wireless/intersil/hostap/hostap_main.c", "prism2_tx_timeout"],
["drivers/net/wireless/intersil/hostap/hostap_main.c", "prism2_tx_timeout"],
["drivers/net/wireless/intersil/orinoco/main.c", "orinoco_tx_timeout"],
["drivers/net/wireless/intersil/orinoco/orinoco_usb.c", "orinoco_tx_timeout"],
["drivers/net/wireless/intersil/orinoco/orinoco.h", "orinoco_tx_timeout"],
["drivers/net/wireless/intersil/prism54/islpci_dev.c", "islpci_eth_tx_timeout"],
["drivers/net/wireless/intersil/prism54/islpci_eth.c", "islpci_eth_tx_timeout"],
["drivers/net/wireless/intersil/prism54/islpci_eth.h", "islpci_eth_tx_timeout"],
["drivers/net/wireless/marvell/mwifiex/main.c", "mwifiex_tx_timeout"],
["drivers/net/wireless/quantenna/qtnfmac/core.c", "qtnf_netdev_tx_timeout"],
["drivers/net/wireless/quantenna/qtnfmac/core.h", "qtnf_netdev_tx_timeout"],
["drivers/net/wireless/rndis_wlan.c", "usbnet_tx_timeout"],
["drivers/net/wireless/wl3501_cs.c", "wl3501_tx_timeout"],
["drivers/net/wireless/zydas/zd1201.c", "zd1201_tx_timeout"],
["drivers/s390/net/qeth_core.h", "qeth_tx_timeout"],
["drivers/s390/net/qeth_core_main.c", "qeth_tx_timeout"],
["drivers/s390/net/qeth_l2_main.c", "qeth_tx_timeout"],
["drivers/s390/net/qeth_l2_main.c", "qeth_tx_timeout"],
["drivers/s390/net/qeth_l3_main.c", "qeth_tx_timeout"],
["drivers/s390/net/qeth_l3_main.c", "qeth_tx_timeout"],
["drivers/staging/ks7010/ks_wlan_net.c", "ks_wlan_tx_timeout"],
["drivers/staging/qlge/qlge_main.c", "qlge_tx_timeout"],
["drivers/staging/rtl8192e/rtl8192e/rtl_core.c", "_rtl92e_tx_timeout"],
["drivers/staging/rtl8192u/r8192U_core.c", "tx_timeout"],
["drivers/staging/unisys/visornic/visornic_main.c", "visornic_xmit_timeout"],
["drivers/staging/wlan-ng/p80211netdev.c", "p80211knetdev_tx_timeout"],
["drivers/tty/n_gsm.c", "gsm_mux_net_tx_timeout"],
["drivers/tty/synclink.c", "hdlcdev_tx_timeout"],
["drivers/tty/synclink_gt.c", "hdlcdev_tx_timeout"],
["drivers/tty/synclinkmp.c", "hdlcdev_tx_timeout"],
["net/atm/lec.c", "lec_tx_timeout"],
["net/bluetooth/bnep/netdev.c", "bnep_net_timeout"]
);
for my $p (@work) {
my @pair = @$p;
my $file = $pair[0];
my $func = $pair[1];
print STDERR $file , ": ", $func,"\n";
our @ARGV = ($file);
while (<ARGV>) {
if (m/($func\s*\(struct\s+net_device\s+\*[A-Za-z_]?[A-Za-z-0-9_]*)(\))/) {
print STDERR "found $1+$2 in $file\n";
}
if (s/($func\s*\(struct\s+net_device\s+\*[A-Za-z_]?[A-Za-z-0-9_]*)(\))/$1, unsigned int txqueue$2/) {
print STDERR "$func found in $file\n";
}
print;
}
}
where the list of files and functions is simply from:
git grep ndo_tx_timeout, with manual addition of headers
in the rare cases where the function is from a header,
then manually changing the few places which actually
call ndo_tx_timeout.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Heiner Kallweit <hkallweit1@gmail.com>
Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Acked-by: Shannon Nelson <snelson@pensando.io>
Reviewed-by: Martin Habets <mhabets@solarflare.com>
changes from v9:
fixup a forward declaration
changes from v9:
more leftovers from v3 change
changes from v8:
fix up a missing direct call to timeout
rebased on net-next
changes from v7:
fixup leftovers from v3 change
changes from v6:
fix typo in rtl driver
changes from v5:
add missing files (allow any net device argument name)
changes from v4:
add a missing driver header
changes from v3:
change queue # to unsigned
Changes from v2:
added headers
Changes from v1:
Fix errors found by kbuild:
generalize the pattern a bit, to pick up
a couple of instances missed by the previous
version.
Signed-off-by: David S. Miller <davem@davemloft.net>
2019-12-10 14:23:51 +00:00
|
|
|
static void qe_tx_timeout(struct net_device *dev, unsigned int txqueue)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2008-11-13 07:38:36 +00:00
|
|
|
struct sunqe *qep = netdev_priv(dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
int tx_full;
|
|
|
|
|
|
|
|
spin_lock_irq(&qep->lock);
|
|
|
|
|
|
|
|
/* Try to reclaim, if that frees up some tx
|
|
|
|
* entries, we're fine.
|
|
|
|
*/
|
|
|
|
qe_tx_reclaim(qep);
|
|
|
|
tx_full = TX_BUFFS_AVAIL(qep) <= 0;
|
|
|
|
|
|
|
|
spin_unlock_irq(&qep->lock);
|
|
|
|
|
|
|
|
if (! tx_full)
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
printk(KERN_ERR "%s: transmit timed out, resetting\n", dev->name);
|
|
|
|
qe_init(qep, 1);
|
|
|
|
|
|
|
|
out:
|
|
|
|
netif_wake_queue(dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get a packet queued to go onto the wire. */
|
2018-09-19 11:21:32 +00:00
|
|
|
static netdev_tx_t qe_start_xmit(struct sk_buff *skb, struct net_device *dev)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2008-11-13 07:38:36 +00:00
|
|
|
struct sunqe *qep = netdev_priv(dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
struct sunqe_buffers *qbufs = qep->buffers;
|
2016-10-17 20:56:59 +00:00
|
|
|
__u32 txbuf_dvma, qbufs_dvma = (__u32)qep->buffers_dvma;
|
2005-04-16 22:20:36 +00:00
|
|
|
unsigned char *txbuf;
|
|
|
|
int len, entry;
|
|
|
|
|
|
|
|
spin_lock_irq(&qep->lock);
|
|
|
|
|
|
|
|
qe_tx_reclaim(qep);
|
|
|
|
|
|
|
|
len = skb->len;
|
|
|
|
entry = qep->tx_new;
|
|
|
|
|
|
|
|
txbuf = &qbufs->tx_buf[entry & (TX_RING_SIZE - 1)][0];
|
|
|
|
txbuf_dvma = qbufs_dvma +
|
|
|
|
qebuf_offset(tx_buf, (entry & (TX_RING_SIZE - 1)));
|
|
|
|
|
|
|
|
/* Avoid a race... */
|
|
|
|
qep->qe_block->qe_txd[entry].tx_flags = TXD_UPDATE;
|
|
|
|
|
2007-03-27 21:55:52 +00:00
|
|
|
skb_copy_from_linear_data(skb, txbuf, len);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
qep->qe_block->qe_txd[entry].tx_addr = txbuf_dvma;
|
|
|
|
qep->qe_block->qe_txd[entry].tx_flags =
|
|
|
|
(TXD_OWN | TXD_SOP | TXD_EOP | (len & TXD_LENGTH));
|
|
|
|
qep->tx_new = NEXT_TX(entry);
|
|
|
|
|
|
|
|
/* Get it going. */
|
|
|
|
sbus_writel(CREG_CTRL_TWAKEUP, qep->qcregs + CREG_CTRL);
|
|
|
|
|
2007-10-04 00:41:50 +00:00
|
|
|
dev->stats.tx_packets++;
|
|
|
|
dev->stats.tx_bytes += len;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
if (TX_BUFFS_AVAIL(qep) <= 0) {
|
|
|
|
/* Halt the net queue and enable tx interrupts.
|
|
|
|
* When the tx queue empties the tx irq handler
|
|
|
|
* will wake up the queue and return us back to
|
|
|
|
* the lazy tx reclaim scheme.
|
|
|
|
*/
|
|
|
|
netif_stop_queue(dev);
|
|
|
|
sbus_writel(0, qep->qcregs + CREG_TIMASK);
|
|
|
|
}
|
|
|
|
spin_unlock_irq(&qep->lock);
|
|
|
|
|
|
|
|
dev_kfree_skb(skb);
|
|
|
|
|
2009-06-23 06:03:08 +00:00
|
|
|
return NETDEV_TX_OK;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void qe_set_multicast(struct net_device *dev)
|
|
|
|
{
|
2008-11-13 07:38:36 +00:00
|
|
|
struct sunqe *qep = netdev_priv(dev);
|
2010-04-01 21:22:57 +00:00
|
|
|
struct netdev_hw_addr *ha;
|
2005-04-16 22:20:36 +00:00
|
|
|
u8 new_mconfig = qep->mconfig;
|
|
|
|
int i;
|
|
|
|
u32 crc;
|
|
|
|
|
|
|
|
/* Lock out others. */
|
|
|
|
netif_stop_queue(dev);
|
|
|
|
|
2010-02-08 04:30:35 +00:00
|
|
|
if ((dev->flags & IFF_ALLMULTI) || (netdev_mc_count(dev) > 64)) {
|
2005-04-16 22:20:36 +00:00
|
|
|
sbus_writeb(MREGS_IACONFIG_ACHNGE | MREGS_IACONFIG_LARESET,
|
|
|
|
qep->mregs + MREGS_IACONFIG);
|
|
|
|
while ((sbus_readb(qep->mregs + MREGS_IACONFIG) & MREGS_IACONFIG_ACHNGE) != 0)
|
|
|
|
barrier();
|
|
|
|
for (i = 0; i < 8; i++)
|
|
|
|
sbus_writeb(0xff, qep->mregs + MREGS_FILTER);
|
|
|
|
sbus_writeb(0, qep->mregs + MREGS_IACONFIG);
|
|
|
|
} else if (dev->flags & IFF_PROMISC) {
|
|
|
|
new_mconfig |= MREGS_MCONFIG_PROMISC;
|
|
|
|
} else {
|
|
|
|
u16 hash_table[4];
|
|
|
|
u8 *hbytes = (unsigned char *) &hash_table[0];
|
|
|
|
|
2010-02-18 00:42:54 +00:00
|
|
|
memset(hash_table, 0, sizeof(hash_table));
|
2010-04-01 21:22:57 +00:00
|
|
|
netdev_for_each_mc_addr(ha, dev) {
|
2011-07-07 22:06:26 +00:00
|
|
|
crc = ether_crc_le(6, ha->addr);
|
2005-04-16 22:20:36 +00:00
|
|
|
crc >>= 26;
|
|
|
|
hash_table[crc >> 4] |= 1 << (crc & 0xf);
|
|
|
|
}
|
|
|
|
/* Program the qe with the new filter value. */
|
|
|
|
sbus_writeb(MREGS_IACONFIG_ACHNGE | MREGS_IACONFIG_LARESET,
|
|
|
|
qep->mregs + MREGS_IACONFIG);
|
|
|
|
while ((sbus_readb(qep->mregs + MREGS_IACONFIG) & MREGS_IACONFIG_ACHNGE) != 0)
|
|
|
|
barrier();
|
|
|
|
for (i = 0; i < 8; i++) {
|
|
|
|
u8 tmp = *hbytes++;
|
|
|
|
sbus_writeb(tmp, qep->mregs + MREGS_FILTER);
|
|
|
|
}
|
|
|
|
sbus_writeb(0, qep->mregs + MREGS_IACONFIG);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Any change of the logical address filter, the physical address,
|
|
|
|
* or enabling/disabling promiscuous mode causes the MACE to disable
|
|
|
|
* the receiver. So we must re-enable them here or else the MACE
|
|
|
|
* refuses to listen to anything on the network. Sheesh, took
|
|
|
|
* me a day or two to find this bug.
|
|
|
|
*/
|
|
|
|
qep->mconfig = new_mconfig;
|
|
|
|
sbus_writeb(qep->mconfig, qep->mregs + MREGS_MCONFIG);
|
|
|
|
|
|
|
|
/* Let us get going again. */
|
|
|
|
netif_wake_queue(dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Ethtool support... */
|
|
|
|
static void qe_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
|
|
|
|
{
|
2008-08-27 07:12:27 +00:00
|
|
|
const struct linux_prom_registers *regs;
|
2008-11-13 07:38:36 +00:00
|
|
|
struct sunqe *qep = netdev_priv(dev);
|
2010-08-06 15:25:50 +00:00
|
|
|
struct platform_device *op;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2013-01-06 00:44:26 +00:00
|
|
|
strlcpy(info->driver, "sunqe", sizeof(info->driver));
|
|
|
|
strlcpy(info->version, "3.0", sizeof(info->version));
|
2008-08-27 07:12:27 +00:00
|
|
|
|
|
|
|
op = qep->op;
|
2010-04-13 23:12:29 +00:00
|
|
|
regs = of_get_property(op->dev.of_node, "reg", NULL);
|
2008-08-27 07:12:27 +00:00
|
|
|
if (regs)
|
2013-01-06 00:44:26 +00:00
|
|
|
snprintf(info->bus_info, sizeof(info->bus_info), "SBUS:%d",
|
|
|
|
regs->which_io);
|
2008-08-27 07:12:27 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static u32 qe_get_link(struct net_device *dev)
|
|
|
|
{
|
2008-11-13 07:38:36 +00:00
|
|
|
struct sunqe *qep = netdev_priv(dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
void __iomem *mregs = qep->mregs;
|
|
|
|
u8 phyconfig;
|
|
|
|
|
|
|
|
spin_lock_irq(&qep->lock);
|
|
|
|
phyconfig = sbus_readb(mregs + MREGS_PHYCONFIG);
|
|
|
|
spin_unlock_irq(&qep->lock);
|
|
|
|
|
2010-09-23 05:40:09 +00:00
|
|
|
return phyconfig & MREGS_PHYCONFIG_LSTAT;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2006-09-13 18:30:00 +00:00
|
|
|
static const struct ethtool_ops qe_ethtool_ops = {
|
2005-04-16 22:20:36 +00:00
|
|
|
.get_drvinfo = qe_get_drvinfo,
|
|
|
|
.get_link = qe_get_link,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* This is only called once at boot time for each card probed. */
|
2010-08-06 15:25:50 +00:00
|
|
|
static void qec_init_once(struct sunqec *qecp, struct platform_device *op)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
u8 bsizes = qecp->qec_bursts;
|
|
|
|
|
2008-08-27 06:33:42 +00:00
|
|
|
if (sbus_can_burst64() && (bsizes & DMA_BURST64)) {
|
2005-04-16 22:20:36 +00:00
|
|
|
sbus_writel(GLOB_CTRL_B64, qecp->gregs + GLOB_CTRL);
|
|
|
|
} else if (bsizes & DMA_BURST32) {
|
|
|
|
sbus_writel(GLOB_CTRL_B32, qecp->gregs + GLOB_CTRL);
|
|
|
|
} else {
|
|
|
|
sbus_writel(GLOB_CTRL_B16, qecp->gregs + GLOB_CTRL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Packetsize only used in 100baseT BigMAC configurations,
|
|
|
|
* set it to zero just to be on the safe side.
|
|
|
|
*/
|
|
|
|
sbus_writel(GLOB_PSIZE_2048, qecp->gregs + GLOB_PSIZE);
|
|
|
|
|
|
|
|
/* Set the local memsize register, divided up to one piece per QE channel. */
|
2008-08-27 07:12:27 +00:00
|
|
|
sbus_writel((resource_size(&op->resource[1]) >> 2),
|
2005-04-16 22:20:36 +00:00
|
|
|
qecp->gregs + GLOB_MSIZE);
|
|
|
|
|
|
|
|
/* Divide up the local QEC memory amongst the 4 QE receiver and
|
|
|
|
* transmitter FIFOs. Basically it is (total / 2 / num_channels).
|
|
|
|
*/
|
2008-08-27 07:12:27 +00:00
|
|
|
sbus_writel((resource_size(&op->resource[1]) >> 2) >> 1,
|
2005-04-16 22:20:36 +00:00
|
|
|
qecp->gregs + GLOB_TSIZE);
|
2008-08-27 07:12:27 +00:00
|
|
|
sbus_writel((resource_size(&op->resource[1]) >> 2) >> 1,
|
2005-04-16 22:20:36 +00:00
|
|
|
qecp->gregs + GLOB_RSIZE);
|
|
|
|
}
|
|
|
|
|
2012-12-03 14:24:02 +00:00
|
|
|
static u8 qec_get_burst(struct device_node *dp)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
u8 bsizes, bsizes_more;
|
|
|
|
|
2006-06-24 04:23:01 +00:00
|
|
|
/* Find and set the burst sizes for the QEC, since it
|
|
|
|
* does the actual dma for all 4 channels.
|
|
|
|
*/
|
|
|
|
bsizes = of_getintprop_default(dp, "burst-sizes", 0xff);
|
|
|
|
bsizes &= 0xff;
|
|
|
|
bsizes_more = of_getintprop_default(dp->parent, "burst-sizes", 0xff);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-06-24 04:23:01 +00:00
|
|
|
if (bsizes_more != 0xff)
|
|
|
|
bsizes &= bsizes_more;
|
|
|
|
if (bsizes == 0xff || (bsizes & DMA_BURST16) == 0 ||
|
|
|
|
(bsizes & DMA_BURST32)==0)
|
|
|
|
bsizes = (DMA_BURST32 - 1);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-06-24 04:23:01 +00:00
|
|
|
return bsizes;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2012-12-03 14:24:02 +00:00
|
|
|
static struct sunqec *get_qec(struct platform_device *child)
|
2006-06-24 04:23:01 +00:00
|
|
|
{
|
2010-08-06 15:25:50 +00:00
|
|
|
struct platform_device *op = to_platform_device(child->dev.parent);
|
2006-06-24 04:23:01 +00:00
|
|
|
struct sunqec *qecp;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2013-05-23 00:52:31 +00:00
|
|
|
qecp = platform_get_drvdata(op);
|
2006-06-24 04:23:01 +00:00
|
|
|
if (!qecp) {
|
|
|
|
qecp = kzalloc(sizeof(struct sunqec), GFP_KERNEL);
|
|
|
|
if (qecp) {
|
|
|
|
u32 ctrl;
|
|
|
|
|
2008-08-27 07:12:27 +00:00
|
|
|
qecp->op = op;
|
|
|
|
qecp->gregs = of_ioremap(&op->resource[0], 0,
|
|
|
|
GLOB_REG_SIZE,
|
|
|
|
"QEC Global Registers");
|
2006-06-24 04:23:01 +00:00
|
|
|
if (!qecp->gregs)
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
/* Make sure the QEC is in MACE mode. */
|
|
|
|
ctrl = sbus_readl(qecp->gregs + GLOB_CTRL);
|
|
|
|
ctrl &= 0xf0000000;
|
|
|
|
if (ctrl != GLOB_CTRL_MMODE) {
|
|
|
|
printk(KERN_ERR "qec: Not in MACE mode!\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-06-24 04:23:01 +00:00
|
|
|
if (qec_global_reset(qecp->gregs))
|
|
|
|
goto fail;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2010-04-13 23:12:29 +00:00
|
|
|
qecp->qec_bursts = qec_get_burst(op->dev.of_node);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-08-27 07:12:27 +00:00
|
|
|
qec_init_once(qecp, op);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2010-06-18 17:09:58 +00:00
|
|
|
if (request_irq(op->archdata.irqs[0], qec_interrupt,
|
2006-07-02 02:29:39 +00:00
|
|
|
IRQF_SHARED, "qec", (void *) qecp)) {
|
2006-06-24 04:23:01 +00:00
|
|
|
printk(KERN_ERR "qec: Can't register irq.\n");
|
|
|
|
goto fail;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2013-05-23 00:52:31 +00:00
|
|
|
platform_set_drvdata(op, qecp);
|
2008-08-27 07:12:27 +00:00
|
|
|
|
2006-06-24 04:23:01 +00:00
|
|
|
qecp->next_module = root_qec_dev;
|
|
|
|
root_qec_dev = qecp;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2006-06-24 04:23:01 +00:00
|
|
|
return qecp;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-06-24 04:23:01 +00:00
|
|
|
fail:
|
|
|
|
if (qecp->gregs)
|
2008-08-27 07:12:27 +00:00
|
|
|
of_iounmap(&op->resource[0], qecp->gregs, GLOB_REG_SIZE);
|
2006-06-24 04:23:01 +00:00
|
|
|
kfree(qecp);
|
|
|
|
return NULL;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2009-03-23 20:33:37 +00:00
|
|
|
static const struct net_device_ops qec_ops = {
|
|
|
|
.ndo_open = qe_open,
|
|
|
|
.ndo_stop = qe_close,
|
|
|
|
.ndo_start_xmit = qe_start_xmit,
|
2011-08-16 06:29:01 +00:00
|
|
|
.ndo_set_rx_mode = qe_set_multicast,
|
2009-03-23 20:33:37 +00:00
|
|
|
.ndo_tx_timeout = qe_tx_timeout,
|
2009-03-23 21:29:24 +00:00
|
|
|
.ndo_set_mac_address = eth_mac_addr,
|
|
|
|
.ndo_validate_addr = eth_validate_addr,
|
2009-03-23 20:33:37 +00:00
|
|
|
};
|
|
|
|
|
2012-12-03 14:24:02 +00:00
|
|
|
static int qec_ether_init(struct platform_device *op)
|
2006-06-24 04:23:01 +00:00
|
|
|
{
|
|
|
|
static unsigned version_printed;
|
|
|
|
struct net_device *dev;
|
|
|
|
struct sunqec *qecp;
|
2008-08-27 07:12:27 +00:00
|
|
|
struct sunqe *qe;
|
2006-06-24 04:23:01 +00:00
|
|
|
int i, res;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-06-24 04:23:01 +00:00
|
|
|
if (version_printed++ == 0)
|
|
|
|
printk(KERN_INFO "%s", version);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-06-24 04:23:01 +00:00
|
|
|
dev = alloc_etherdev(sizeof(struct sunqe));
|
|
|
|
if (!dev)
|
|
|
|
return -ENOMEM;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2013-10-02 02:04:40 +00:00
|
|
|
memcpy(dev->dev_addr, idprom->id_ethaddr, ETH_ALEN);
|
2007-04-21 22:31:58 +00:00
|
|
|
|
2006-06-24 04:23:01 +00:00
|
|
|
qe = netdev_priv(dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-08-27 07:12:27 +00:00
|
|
|
res = -ENODEV;
|
|
|
|
|
2010-04-13 23:12:29 +00:00
|
|
|
i = of_getintprop_default(op->dev.of_node, "channel#", -1);
|
2008-08-27 07:12:27 +00:00
|
|
|
if (i == -1)
|
|
|
|
goto fail;
|
2006-06-24 04:23:01 +00:00
|
|
|
qe->channel = i;
|
|
|
|
spin_lock_init(&qe->lock);
|
2006-09-13 17:24:59 +00:00
|
|
|
|
2008-08-27 07:12:27 +00:00
|
|
|
qecp = get_qec(op);
|
2006-06-24 04:23:01 +00:00
|
|
|
if (!qecp)
|
|
|
|
goto fail;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-06-24 04:23:01 +00:00
|
|
|
qecp->qes[qe->channel] = qe;
|
|
|
|
qe->dev = dev;
|
|
|
|
qe->parent = qecp;
|
2008-08-27 07:12:27 +00:00
|
|
|
qe->op = op;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-06-24 04:23:01 +00:00
|
|
|
res = -ENOMEM;
|
2008-08-27 07:12:27 +00:00
|
|
|
qe->qcregs = of_ioremap(&op->resource[0], 0,
|
|
|
|
CREG_REG_SIZE, "QEC Channel Registers");
|
2006-06-24 04:23:01 +00:00
|
|
|
if (!qe->qcregs) {
|
|
|
|
printk(KERN_ERR "qe: Cannot map channel registers.\n");
|
|
|
|
goto fail;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2008-08-27 07:12:27 +00:00
|
|
|
qe->mregs = of_ioremap(&op->resource[1], 0,
|
|
|
|
MREGS_REG_SIZE, "QE MACE Registers");
|
2006-06-24 04:23:01 +00:00
|
|
|
if (!qe->mregs) {
|
|
|
|
printk(KERN_ERR "qe: Cannot map MACE registers.\n");
|
|
|
|
goto fail;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2008-08-27 07:12:27 +00:00
|
|
|
qe->qe_block = dma_alloc_coherent(&op->dev, PAGE_SIZE,
|
2008-08-28 01:09:11 +00:00
|
|
|
&qe->qblock_dvma, GFP_ATOMIC);
|
2008-08-27 07:12:27 +00:00
|
|
|
qe->buffers = dma_alloc_coherent(&op->dev, sizeof(struct sunqe_buffers),
|
2008-08-28 01:09:11 +00:00
|
|
|
&qe->buffers_dvma, GFP_ATOMIC);
|
2006-06-24 04:23:01 +00:00
|
|
|
if (qe->qe_block == NULL || qe->qblock_dvma == 0 ||
|
|
|
|
qe->buffers == NULL || qe->buffers_dvma == 0)
|
|
|
|
goto fail;
|
|
|
|
|
|
|
|
/* Stop this QE. */
|
|
|
|
qe_stop(qe);
|
|
|
|
|
2008-08-27 07:12:27 +00:00
|
|
|
SET_NETDEV_DEV(dev, &op->dev);
|
2006-06-24 04:23:01 +00:00
|
|
|
|
|
|
|
dev->watchdog_timeo = 5*HZ;
|
2010-06-18 17:09:58 +00:00
|
|
|
dev->irq = op->archdata.irqs[0];
|
2006-06-24 04:23:01 +00:00
|
|
|
dev->dma = 0;
|
|
|
|
dev->ethtool_ops = &qe_ethtool_ops;
|
2009-03-23 20:33:37 +00:00
|
|
|
dev->netdev_ops = &qec_ops;
|
2006-06-24 04:23:01 +00:00
|
|
|
|
|
|
|
res = register_netdev(dev);
|
|
|
|
if (res)
|
|
|
|
goto fail;
|
|
|
|
|
2013-05-23 00:52:31 +00:00
|
|
|
platform_set_drvdata(op, qe);
|
2006-06-24 04:23:01 +00:00
|
|
|
|
2012-02-24 03:45:57 +00:00
|
|
|
printk(KERN_INFO "%s: qe channel[%d] %pM\n", dev->name, qe->channel,
|
|
|
|
dev->dev_addr);
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
|
2006-06-24 04:23:01 +00:00
|
|
|
fail:
|
|
|
|
if (qe->qcregs)
|
2008-08-27 07:12:27 +00:00
|
|
|
of_iounmap(&op->resource[0], qe->qcregs, CREG_REG_SIZE);
|
2006-06-24 04:23:01 +00:00
|
|
|
if (qe->mregs)
|
2008-08-27 07:12:27 +00:00
|
|
|
of_iounmap(&op->resource[1], qe->mregs, MREGS_REG_SIZE);
|
2006-06-24 04:23:01 +00:00
|
|
|
if (qe->qe_block)
|
2008-08-27 07:12:27 +00:00
|
|
|
dma_free_coherent(&op->dev, PAGE_SIZE,
|
|
|
|
qe->qe_block, qe->qblock_dvma);
|
2006-06-24 04:23:01 +00:00
|
|
|
if (qe->buffers)
|
2008-08-27 07:12:27 +00:00
|
|
|
dma_free_coherent(&op->dev,
|
2008-08-28 01:09:11 +00:00
|
|
|
sizeof(struct sunqe_buffers),
|
|
|
|
qe->buffers,
|
|
|
|
qe->buffers_dvma);
|
2006-06-24 04:23:01 +00:00
|
|
|
|
|
|
|
free_netdev(dev);
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2012-12-03 14:24:02 +00:00
|
|
|
static int qec_sbus_probe(struct platform_device *op)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2008-08-27 07:12:27 +00:00
|
|
|
return qec_ether_init(op);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2012-12-03 14:24:02 +00:00
|
|
|
static int qec_sbus_remove(struct platform_device *op)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2013-05-23 00:52:31 +00:00
|
|
|
struct sunqe *qp = platform_get_drvdata(op);
|
2006-06-24 04:23:01 +00:00
|
|
|
struct net_device *net_dev = qp->dev;
|
|
|
|
|
2007-04-21 22:31:58 +00:00
|
|
|
unregister_netdev(net_dev);
|
2006-06-24 04:23:01 +00:00
|
|
|
|
2008-08-27 07:12:27 +00:00
|
|
|
of_iounmap(&op->resource[0], qp->qcregs, CREG_REG_SIZE);
|
|
|
|
of_iounmap(&op->resource[1], qp->mregs, MREGS_REG_SIZE);
|
|
|
|
dma_free_coherent(&op->dev, PAGE_SIZE,
|
|
|
|
qp->qe_block, qp->qblock_dvma);
|
|
|
|
dma_free_coherent(&op->dev, sizeof(struct sunqe_buffers),
|
|
|
|
qp->buffers, qp->buffers_dvma);
|
2006-06-24 04:23:01 +00:00
|
|
|
|
|
|
|
free_netdev(net_dev);
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-08-31 08:23:17 +00:00
|
|
|
static const struct of_device_id qec_sbus_match[] = {
|
2006-06-24 04:23:01 +00:00
|
|
|
{
|
|
|
|
.name = "qe",
|
|
|
|
},
|
|
|
|
{},
|
|
|
|
};
|
|
|
|
|
|
|
|
MODULE_DEVICE_TABLE(of, qec_sbus_match);
|
|
|
|
|
2011-02-23 04:05:51 +00:00
|
|
|
static struct platform_driver qec_sbus_driver = {
|
2010-04-13 23:13:02 +00:00
|
|
|
.driver = {
|
|
|
|
.name = "qec",
|
|
|
|
.of_match_table = qec_sbus_match,
|
|
|
|
},
|
2006-06-24 04:23:01 +00:00
|
|
|
.probe = qec_sbus_probe,
|
2012-12-03 14:24:02 +00:00
|
|
|
.remove = qec_sbus_remove,
|
2006-06-24 04:23:01 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int __init qec_init(void)
|
|
|
|
{
|
2011-02-23 04:05:51 +00:00
|
|
|
return platform_driver_register(&qec_sbus_driver);
|
2006-06-24 04:23:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit qec_exit(void)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2011-02-23 04:05:51 +00:00
|
|
|
platform_driver_unregister(&qec_sbus_driver);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
while (root_qec_dev) {
|
2006-06-24 04:23:01 +00:00
|
|
|
struct sunqec *next = root_qec_dev->next_module;
|
2010-08-06 15:25:50 +00:00
|
|
|
struct platform_device *op = root_qec_dev->op;
|
2006-06-24 04:23:01 +00:00
|
|
|
|
2010-06-18 17:09:58 +00:00
|
|
|
free_irq(op->archdata.irqs[0], (void *) root_qec_dev);
|
2008-08-27 07:12:27 +00:00
|
|
|
of_iounmap(&op->resource[0], root_qec_dev->gregs,
|
|
|
|
GLOB_REG_SIZE);
|
2005-04-16 22:20:36 +00:00
|
|
|
kfree(root_qec_dev);
|
2006-06-24 04:23:01 +00:00
|
|
|
|
|
|
|
root_qec_dev = next;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-06-24 04:23:01 +00:00
|
|
|
module_init(qec_init);
|
|
|
|
module_exit(qec_exit);
|