2021-04-20 23:40:08 +00:00
|
|
|
/*
|
2008-03-19 16:14:51 +00:00
|
|
|
* Driver for the IDT RC32434 (Korina) on-chip ethernet controller.
|
|
|
|
*
|
|
|
|
* Copyright 2004 IDT Inc. (rischelp@idt.com)
|
|
|
|
* Copyright 2006 Felix Fietkau <nbd@openwrt.org>
|
|
|
|
* Copyright 2008 Florian Fainelli <florian@openwrt.org>
|
2017-09-17 17:25:11 +00:00
|
|
|
* Copyright 2017 Roman Yeryomin <roman@advem.lv>
|
2008-03-19 16:14:51 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
|
|
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
|
|
|
* NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
|
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
|
|
|
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
|
|
|
|
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
|
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
|
|
|
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*
|
|
|
|
* Writing to a DMA status register:
|
|
|
|
*
|
|
|
|
* When writing to the status register, you should mask the bit you have
|
|
|
|
* been testing the status register with. Both Tx and Rx DMA registers
|
|
|
|
* should stick to this procedure.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/moduleparam.h>
|
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/ctype.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/ioport.h>
|
2021-04-18 22:19:39 +00:00
|
|
|
#include <linux/iopoll.h>
|
2008-03-19 16:14:51 +00:00
|
|
|
#include <linux/in.h>
|
2021-04-18 22:19:45 +00:00
|
|
|
#include <linux/of_device.h>
|
|
|
|
#include <linux/of_net.h>
|
2008-03-19 16:14:51 +00:00
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/string.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/etherdevice.h>
|
|
|
|
#include <linux/skbuff.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/platform_device.h>
|
|
|
|
#include <linux/mii.h>
|
|
|
|
#include <linux/ethtool.h>
|
|
|
|
#include <linux/crc32.h>
|
2020-06-09 04:32:42 +00:00
|
|
|
#include <linux/pgtable.h>
|
2021-04-18 22:19:46 +00:00
|
|
|
#include <linux/clk.h>
|
2008-03-19 16:14:51 +00:00
|
|
|
|
2017-09-17 17:25:02 +00:00
|
|
|
#define DRV_NAME "korina"
|
2017-09-17 17:25:21 +00:00
|
|
|
#define DRV_VERSION "0.20"
|
|
|
|
#define DRV_RELDATE "15Sep2017"
|
2008-03-19 16:14:51 +00:00
|
|
|
|
2021-04-18 22:19:47 +00:00
|
|
|
struct eth_regs {
|
|
|
|
u32 ethintfc;
|
|
|
|
u32 ethfifott;
|
|
|
|
u32 etharc;
|
|
|
|
u32 ethhash0;
|
|
|
|
u32 ethhash1;
|
|
|
|
u32 ethu0[4]; /* Reserved. */
|
|
|
|
u32 ethpfs;
|
|
|
|
u32 ethmcp;
|
|
|
|
u32 eth_u1[10]; /* Reserved. */
|
|
|
|
u32 ethspare;
|
|
|
|
u32 eth_u2[42]; /* Reserved. */
|
|
|
|
u32 ethsal0;
|
|
|
|
u32 ethsah0;
|
|
|
|
u32 ethsal1;
|
|
|
|
u32 ethsah1;
|
|
|
|
u32 ethsal2;
|
|
|
|
u32 ethsah2;
|
|
|
|
u32 ethsal3;
|
|
|
|
u32 ethsah3;
|
|
|
|
u32 ethrbc;
|
|
|
|
u32 ethrpc;
|
|
|
|
u32 ethrupc;
|
|
|
|
u32 ethrfc;
|
|
|
|
u32 ethtbc;
|
|
|
|
u32 ethgpf;
|
|
|
|
u32 eth_u9[50]; /* Reserved. */
|
|
|
|
u32 ethmac1;
|
|
|
|
u32 ethmac2;
|
|
|
|
u32 ethipgt;
|
|
|
|
u32 ethipgr;
|
|
|
|
u32 ethclrt;
|
|
|
|
u32 ethmaxf;
|
|
|
|
u32 eth_u10; /* Reserved. */
|
|
|
|
u32 ethmtest;
|
|
|
|
u32 miimcfg;
|
|
|
|
u32 miimcmd;
|
|
|
|
u32 miimaddr;
|
|
|
|
u32 miimwtd;
|
|
|
|
u32 miimrdd;
|
|
|
|
u32 miimind;
|
|
|
|
u32 eth_u11; /* Reserved. */
|
|
|
|
u32 eth_u12; /* Reserved. */
|
|
|
|
u32 ethcfsa0;
|
|
|
|
u32 ethcfsa1;
|
|
|
|
u32 ethcfsa2;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Ethernet interrupt registers */
|
|
|
|
#define ETH_INT_FC_EN BIT(0)
|
|
|
|
#define ETH_INT_FC_ITS BIT(1)
|
|
|
|
#define ETH_INT_FC_RIP BIT(2)
|
|
|
|
#define ETH_INT_FC_JAM BIT(3)
|
|
|
|
#define ETH_INT_FC_OVR BIT(4)
|
|
|
|
#define ETH_INT_FC_UND BIT(5)
|
|
|
|
#define ETH_INT_FC_IOC 0x000000c0
|
|
|
|
|
|
|
|
/* Ethernet FIFO registers */
|
|
|
|
#define ETH_FIFI_TT_TTH_BIT 0
|
|
|
|
#define ETH_FIFO_TT_TTH 0x0000007f
|
|
|
|
|
|
|
|
/* Ethernet ARC/multicast registers */
|
|
|
|
#define ETH_ARC_PRO BIT(0)
|
|
|
|
#define ETH_ARC_AM BIT(1)
|
|
|
|
#define ETH_ARC_AFM BIT(2)
|
|
|
|
#define ETH_ARC_AB BIT(3)
|
|
|
|
|
|
|
|
/* Ethernet SAL registers */
|
|
|
|
#define ETH_SAL_BYTE_5 0x000000ff
|
|
|
|
#define ETH_SAL_BYTE_4 0x0000ff00
|
|
|
|
#define ETH_SAL_BYTE_3 0x00ff0000
|
|
|
|
#define ETH_SAL_BYTE_2 0xff000000
|
|
|
|
|
|
|
|
/* Ethernet SAH registers */
|
|
|
|
#define ETH_SAH_BYTE1 0x000000ff
|
|
|
|
#define ETH_SAH_BYTE0 0x0000ff00
|
|
|
|
|
|
|
|
/* Ethernet GPF register */
|
|
|
|
#define ETH_GPF_PTV 0x0000ffff
|
|
|
|
|
|
|
|
/* Ethernet PFG register */
|
|
|
|
#define ETH_PFS_PFD BIT(0)
|
|
|
|
|
|
|
|
/* Ethernet CFSA[0-3] registers */
|
|
|
|
#define ETH_CFSA0_CFSA4 0x000000ff
|
|
|
|
#define ETH_CFSA0_CFSA5 0x0000ff00
|
|
|
|
#define ETH_CFSA1_CFSA2 0x000000ff
|
|
|
|
#define ETH_CFSA1_CFSA3 0x0000ff00
|
|
|
|
#define ETH_CFSA1_CFSA0 0x000000ff
|
|
|
|
#define ETH_CFSA1_CFSA1 0x0000ff00
|
|
|
|
|
|
|
|
/* Ethernet MAC1 registers */
|
|
|
|
#define ETH_MAC1_RE BIT(0)
|
|
|
|
#define ETH_MAC1_PAF BIT(1)
|
|
|
|
#define ETH_MAC1_RFC BIT(2)
|
|
|
|
#define ETH_MAC1_TFC BIT(3)
|
|
|
|
#define ETH_MAC1_LB BIT(4)
|
|
|
|
#define ETH_MAC1_MR BIT(31)
|
|
|
|
|
|
|
|
/* Ethernet MAC2 registers */
|
|
|
|
#define ETH_MAC2_FD BIT(0)
|
|
|
|
#define ETH_MAC2_FLC BIT(1)
|
|
|
|
#define ETH_MAC2_HFE BIT(2)
|
|
|
|
#define ETH_MAC2_DC BIT(3)
|
|
|
|
#define ETH_MAC2_CEN BIT(4)
|
|
|
|
#define ETH_MAC2_PE BIT(5)
|
|
|
|
#define ETH_MAC2_VPE BIT(6)
|
|
|
|
#define ETH_MAC2_APE BIT(7)
|
|
|
|
#define ETH_MAC2_PPE BIT(8)
|
|
|
|
#define ETH_MAC2_LPE BIT(9)
|
|
|
|
#define ETH_MAC2_NB BIT(12)
|
|
|
|
#define ETH_MAC2_BP BIT(13)
|
|
|
|
#define ETH_MAC2_ED BIT(14)
|
|
|
|
|
|
|
|
/* Ethernet IPGT register */
|
|
|
|
#define ETH_IPGT 0x0000007f
|
|
|
|
|
|
|
|
/* Ethernet IPGR registers */
|
|
|
|
#define ETH_IPGR_IPGR2 0x0000007f
|
|
|
|
#define ETH_IPGR_IPGR1 0x00007f00
|
|
|
|
|
|
|
|
/* Ethernet CLRT registers */
|
|
|
|
#define ETH_CLRT_MAX_RET 0x0000000f
|
|
|
|
#define ETH_CLRT_COL_WIN 0x00003f00
|
|
|
|
|
|
|
|
/* Ethernet MAXF register */
|
|
|
|
#define ETH_MAXF 0x0000ffff
|
|
|
|
|
|
|
|
/* Ethernet test registers */
|
|
|
|
#define ETH_TEST_REG BIT(2)
|
|
|
|
#define ETH_MCP_DIV 0x000000ff
|
|
|
|
|
|
|
|
/* MII registers */
|
|
|
|
#define ETH_MII_CFG_RSVD 0x0000000c
|
|
|
|
#define ETH_MII_CMD_RD BIT(0)
|
|
|
|
#define ETH_MII_CMD_SCN BIT(1)
|
|
|
|
#define ETH_MII_REG_ADDR 0x0000001f
|
|
|
|
#define ETH_MII_PHY_ADDR 0x00001f00
|
|
|
|
#define ETH_MII_WTD_DATA 0x0000ffff
|
|
|
|
#define ETH_MII_RDD_DATA 0x0000ffff
|
|
|
|
#define ETH_MII_IND_BSY BIT(0)
|
|
|
|
#define ETH_MII_IND_SCN BIT(1)
|
|
|
|
#define ETH_MII_IND_NV BIT(2)
|
|
|
|
|
|
|
|
/* Values for the DEVCS field of the Ethernet DMA Rx and Tx descriptors. */
|
|
|
|
#define ETH_RX_FD BIT(0)
|
|
|
|
#define ETH_RX_LD BIT(1)
|
|
|
|
#define ETH_RX_ROK BIT(2)
|
|
|
|
#define ETH_RX_FM BIT(3)
|
|
|
|
#define ETH_RX_MP BIT(4)
|
|
|
|
#define ETH_RX_BP BIT(5)
|
|
|
|
#define ETH_RX_VLT BIT(6)
|
|
|
|
#define ETH_RX_CF BIT(7)
|
|
|
|
#define ETH_RX_OVR BIT(8)
|
|
|
|
#define ETH_RX_CRC BIT(9)
|
|
|
|
#define ETH_RX_CV BIT(10)
|
|
|
|
#define ETH_RX_DB BIT(11)
|
|
|
|
#define ETH_RX_LE BIT(12)
|
|
|
|
#define ETH_RX_LOR BIT(13)
|
|
|
|
#define ETH_RX_CES BIT(14)
|
|
|
|
#define ETH_RX_LEN_BIT 16
|
|
|
|
#define ETH_RX_LEN 0xffff0000
|
|
|
|
|
|
|
|
#define ETH_TX_FD BIT(0)
|
|
|
|
#define ETH_TX_LD BIT(1)
|
|
|
|
#define ETH_TX_OEN BIT(2)
|
|
|
|
#define ETH_TX_PEN BIT(3)
|
|
|
|
#define ETH_TX_CEN BIT(4)
|
|
|
|
#define ETH_TX_HEN BIT(5)
|
|
|
|
#define ETH_TX_TOK BIT(6)
|
|
|
|
#define ETH_TX_MP BIT(7)
|
|
|
|
#define ETH_TX_BP BIT(8)
|
|
|
|
#define ETH_TX_UND BIT(9)
|
|
|
|
#define ETH_TX_OF BIT(10)
|
|
|
|
#define ETH_TX_ED BIT(11)
|
|
|
|
#define ETH_TX_EC BIT(12)
|
|
|
|
#define ETH_TX_LC BIT(13)
|
|
|
|
#define ETH_TX_TD BIT(14)
|
|
|
|
#define ETH_TX_CRC BIT(15)
|
|
|
|
#define ETH_TX_LE BIT(16)
|
|
|
|
#define ETH_TX_CC 0x001E0000
|
|
|
|
|
|
|
|
/* DMA descriptor (in physical memory). */
|
|
|
|
struct dma_desc {
|
|
|
|
u32 control; /* Control. use DMAD_* */
|
|
|
|
u32 ca; /* Current Address. */
|
|
|
|
u32 devcs; /* Device control and status. */
|
|
|
|
u32 link; /* Next descriptor in chain. */
|
|
|
|
};
|
|
|
|
|
|
|
|
#define DMA_DESC_COUNT_BIT 0
|
|
|
|
#define DMA_DESC_COUNT_MSK 0x0003ffff
|
|
|
|
#define DMA_DESC_DS_BIT 20
|
|
|
|
#define DMA_DESC_DS_MSK 0x00300000
|
|
|
|
|
|
|
|
#define DMA_DESC_DEV_CMD_BIT 22
|
|
|
|
#define DMA_DESC_DEV_CMD_MSK 0x01c00000
|
|
|
|
|
|
|
|
/* DMA descriptors interrupts */
|
|
|
|
#define DMA_DESC_COF BIT(25) /* Chain on finished */
|
|
|
|
#define DMA_DESC_COD BIT(26) /* Chain on done */
|
|
|
|
#define DMA_DESC_IOF BIT(27) /* Interrupt on finished */
|
|
|
|
#define DMA_DESC_IOD BIT(28) /* Interrupt on done */
|
|
|
|
#define DMA_DESC_TERM BIT(29) /* Terminated */
|
|
|
|
#define DMA_DESC_DONE BIT(30) /* Done */
|
|
|
|
#define DMA_DESC_FINI BIT(31) /* Finished */
|
|
|
|
|
|
|
|
/* DMA register (within Internal Register Map). */
|
|
|
|
struct dma_reg {
|
|
|
|
u32 dmac; /* Control. */
|
|
|
|
u32 dmas; /* Status. */
|
|
|
|
u32 dmasm; /* Mask. */
|
|
|
|
u32 dmadptr; /* Descriptor pointer. */
|
|
|
|
u32 dmandptr; /* Next descriptor pointer. */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* DMA channels specific registers */
|
|
|
|
#define DMA_CHAN_RUN_BIT BIT(0)
|
|
|
|
#define DMA_CHAN_DONE_BIT BIT(1)
|
|
|
|
#define DMA_CHAN_MODE_BIT BIT(2)
|
|
|
|
#define DMA_CHAN_MODE_MSK 0x0000000c
|
|
|
|
#define DMA_CHAN_MODE_AUTO 0
|
|
|
|
#define DMA_CHAN_MODE_BURST 1
|
|
|
|
#define DMA_CHAN_MODE_XFRT 2
|
|
|
|
#define DMA_CHAN_MODE_RSVD 3
|
|
|
|
#define DMA_CHAN_ACT_BIT BIT(4)
|
|
|
|
|
|
|
|
/* DMA status registers */
|
|
|
|
#define DMA_STAT_FINI BIT(0)
|
|
|
|
#define DMA_STAT_DONE BIT(1)
|
|
|
|
#define DMA_STAT_CHAIN BIT(2)
|
|
|
|
#define DMA_STAT_ERR BIT(3)
|
|
|
|
#define DMA_STAT_HALT BIT(4)
|
|
|
|
|
2008-03-19 16:14:51 +00:00
|
|
|
#define STATION_ADDRESS_HIGH(dev) (((dev)->dev_addr[0] << 8) | \
|
|
|
|
((dev)->dev_addr[1]))
|
|
|
|
#define STATION_ADDRESS_LOW(dev) (((dev)->dev_addr[2] << 24) | \
|
|
|
|
((dev)->dev_addr[3] << 16) | \
|
|
|
|
((dev)->dev_addr[4] << 8) | \
|
|
|
|
((dev)->dev_addr[5]))
|
|
|
|
|
2017-09-17 17:25:02 +00:00
|
|
|
#define MII_CLOCK 1250000 /* no more than 2.5MHz */
|
2008-03-19 16:14:51 +00:00
|
|
|
|
|
|
|
/* the following must be powers of two */
|
|
|
|
#define KORINA_NUM_RDS 64 /* number of receive descriptors */
|
|
|
|
#define KORINA_NUM_TDS 64 /* number of transmit descriptors */
|
|
|
|
|
2009-01-15 05:47:50 +00:00
|
|
|
/* KORINA_RBSIZE is the hardware's default maximum receive
|
|
|
|
* frame size in bytes. Having this hardcoded means that there
|
|
|
|
* is no support for MTU sizes greater than 1500. */
|
|
|
|
#define KORINA_RBSIZE 1536 /* size of one resource buffer = Ether MTU */
|
2008-03-19 16:14:51 +00:00
|
|
|
#define KORINA_RDS_MASK (KORINA_NUM_RDS - 1)
|
|
|
|
#define KORINA_TDS_MASK (KORINA_NUM_TDS - 1)
|
2017-09-17 17:25:02 +00:00
|
|
|
#define RD_RING_SIZE (KORINA_NUM_RDS * sizeof(struct dma_desc))
|
2008-03-19 16:14:51 +00:00
|
|
|
#define TD_RING_SIZE (KORINA_NUM_TDS * sizeof(struct dma_desc))
|
|
|
|
|
2017-09-17 17:25:02 +00:00
|
|
|
#define TX_TIMEOUT (6000 * HZ / 1000)
|
2008-03-19 16:14:51 +00:00
|
|
|
|
2017-09-17 17:25:02 +00:00
|
|
|
enum chain_status {
|
|
|
|
desc_filled,
|
2021-04-20 23:24:26 +00:00
|
|
|
desc_is_empty
|
2017-09-17 17:25:02 +00:00
|
|
|
};
|
|
|
|
|
2021-04-18 22:19:47 +00:00
|
|
|
#define DMA_COUNT(count) ((count) & DMA_DESC_COUNT_MSK)
|
2017-09-17 17:25:02 +00:00
|
|
|
#define IS_DMA_FINISHED(X) (((X) & (DMA_DESC_FINI)) != 0)
|
|
|
|
#define IS_DMA_DONE(X) (((X) & (DMA_DESC_DONE)) != 0)
|
|
|
|
#define RCVPKT_LENGTH(X) (((X) & ETH_RX_LEN) >> ETH_RX_LEN_BIT)
|
2008-03-19 16:14:51 +00:00
|
|
|
|
|
|
|
/* Information that need to be kept for each board. */
|
|
|
|
struct korina_private {
|
2021-04-18 22:19:40 +00:00
|
|
|
struct eth_regs __iomem *eth_regs;
|
|
|
|
struct dma_reg __iomem *rx_dma_regs;
|
|
|
|
struct dma_reg __iomem *tx_dma_regs;
|
2008-03-19 16:14:51 +00:00
|
|
|
struct dma_desc *td_ring; /* transmit descriptor ring */
|
|
|
|
struct dma_desc *rd_ring; /* receive descriptor ring */
|
2021-04-18 22:19:43 +00:00
|
|
|
dma_addr_t td_dma;
|
|
|
|
dma_addr_t rd_dma;
|
2008-03-19 16:14:51 +00:00
|
|
|
|
|
|
|
struct sk_buff *tx_skb[KORINA_NUM_TDS];
|
|
|
|
struct sk_buff *rx_skb[KORINA_NUM_RDS];
|
|
|
|
|
2021-04-18 22:19:43 +00:00
|
|
|
dma_addr_t rx_skb_dma[KORINA_NUM_RDS];
|
|
|
|
dma_addr_t tx_skb_dma[KORINA_NUM_TDS];
|
|
|
|
|
2008-03-19 16:14:51 +00:00
|
|
|
int rx_next_done;
|
|
|
|
int rx_chain_head;
|
|
|
|
int rx_chain_tail;
|
|
|
|
enum chain_status rx_chain_status;
|
|
|
|
|
|
|
|
int tx_next_done;
|
|
|
|
int tx_chain_head;
|
|
|
|
int tx_chain_tail;
|
|
|
|
enum chain_status tx_chain_status;
|
|
|
|
int tx_count;
|
|
|
|
int tx_full;
|
|
|
|
|
|
|
|
int rx_irq;
|
|
|
|
int tx_irq;
|
|
|
|
|
2017-09-17 17:25:02 +00:00
|
|
|
spinlock_t lock; /* NIC xmit lock */
|
2008-03-19 16:14:51 +00:00
|
|
|
|
|
|
|
int dma_halt_cnt;
|
|
|
|
int dma_run_cnt;
|
|
|
|
struct napi_struct napi;
|
2009-05-28 00:58:41 +00:00
|
|
|
struct timer_list media_check_timer;
|
2008-03-19 16:14:51 +00:00
|
|
|
struct mii_if_info mii_if;
|
2010-05-29 13:23:34 +00:00
|
|
|
struct work_struct restart_task;
|
2008-03-19 16:14:51 +00:00
|
|
|
struct net_device *dev;
|
2021-04-18 22:19:43 +00:00
|
|
|
struct device *dmadev;
|
2021-04-18 22:19:46 +00:00
|
|
|
int mii_clock_freq;
|
2008-03-19 16:14:51 +00:00
|
|
|
};
|
|
|
|
|
2021-04-18 22:19:43 +00:00
|
|
|
static dma_addr_t korina_tx_dma(struct korina_private *lp, int idx)
|
|
|
|
{
|
|
|
|
return lp->td_dma + (idx * sizeof(struct dma_desc));
|
|
|
|
}
|
|
|
|
|
|
|
|
static dma_addr_t korina_rx_dma(struct korina_private *lp, int idx)
|
|
|
|
{
|
|
|
|
return lp->rd_dma + (idx * sizeof(struct dma_desc));
|
|
|
|
}
|
|
|
|
|
2008-03-19 16:14:51 +00:00
|
|
|
static inline void korina_abort_dma(struct net_device *dev,
|
|
|
|
struct dma_reg *ch)
|
|
|
|
{
|
2017-09-17 17:25:02 +00:00
|
|
|
if (readl(&ch->dmac) & DMA_CHAN_RUN_BIT) {
|
|
|
|
writel(0x10, &ch->dmac);
|
2008-03-19 16:14:51 +00:00
|
|
|
|
2017-09-17 17:25:02 +00:00
|
|
|
while (!(readl(&ch->dmas) & DMA_STAT_HALT))
|
|
|
|
netif_trans_update(dev);
|
2008-03-19 16:14:51 +00:00
|
|
|
|
2017-09-17 17:25:02 +00:00
|
|
|
writel(0, &ch->dmas);
|
|
|
|
}
|
2008-03-19 16:14:51 +00:00
|
|
|
|
2017-09-17 17:25:02 +00:00
|
|
|
writel(0, &ch->dmadptr);
|
|
|
|
writel(0, &ch->dmandptr);
|
2008-03-19 16:14:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void korina_abort_tx(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct korina_private *lp = netdev_priv(dev);
|
|
|
|
|
|
|
|
korina_abort_dma(dev, lp->tx_dma_regs);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void korina_abort_rx(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct korina_private *lp = netdev_priv(dev);
|
|
|
|
|
|
|
|
korina_abort_dma(dev, lp->rx_dma_regs);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* transmit packet */
|
|
|
|
static int korina_send_packet(struct sk_buff *skb, struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct korina_private *lp = netdev_priv(dev);
|
2009-01-15 05:50:41 +00:00
|
|
|
u32 chain_prev, chain_next;
|
2021-04-18 22:19:43 +00:00
|
|
|
unsigned long flags;
|
2008-03-19 16:14:51 +00:00
|
|
|
struct dma_desc *td;
|
2021-04-18 22:19:43 +00:00
|
|
|
dma_addr_t ca;
|
|
|
|
u32 length;
|
|
|
|
int idx;
|
2008-03-19 16:14:51 +00:00
|
|
|
|
|
|
|
spin_lock_irqsave(&lp->lock, flags);
|
|
|
|
|
2021-04-18 22:19:43 +00:00
|
|
|
idx = lp->tx_chain_tail;
|
|
|
|
td = &lp->td_ring[idx];
|
2008-03-19 16:14:51 +00:00
|
|
|
|
|
|
|
/* stop queue when full, drop pkts if queue already full */
|
|
|
|
if (lp->tx_count >= (KORINA_NUM_TDS - 2)) {
|
|
|
|
lp->tx_full = 1;
|
|
|
|
|
|
|
|
if (lp->tx_count == (KORINA_NUM_TDS - 2))
|
|
|
|
netif_stop_queue(dev);
|
2021-04-18 22:19:43 +00:00
|
|
|
else
|
|
|
|
goto drop_packet;
|
2008-03-19 16:14:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
lp->tx_count++;
|
|
|
|
|
2021-04-18 22:19:43 +00:00
|
|
|
lp->tx_skb[idx] = skb;
|
2008-03-19 16:14:51 +00:00
|
|
|
|
|
|
|
length = skb->len;
|
|
|
|
|
|
|
|
/* Setup the transmit descriptor. */
|
2021-04-18 22:19:43 +00:00
|
|
|
ca = dma_map_single(lp->dmadev, skb->data, length, DMA_TO_DEVICE);
|
|
|
|
if (dma_mapping_error(lp->dmadev, ca))
|
|
|
|
goto drop_packet;
|
|
|
|
|
|
|
|
lp->tx_skb_dma[idx] = ca;
|
|
|
|
td->ca = ca;
|
|
|
|
|
|
|
|
chain_prev = (idx - 1) & KORINA_TDS_MASK;
|
|
|
|
chain_next = (idx + 1) & KORINA_TDS_MASK;
|
2008-03-19 16:14:51 +00:00
|
|
|
|
|
|
|
if (readl(&(lp->tx_dma_regs->dmandptr)) == 0) {
|
2021-04-20 23:24:26 +00:00
|
|
|
if (lp->tx_chain_status == desc_is_empty) {
|
2008-03-19 16:14:51 +00:00
|
|
|
/* Update tail */
|
|
|
|
td->control = DMA_COUNT(length) |
|
|
|
|
DMA_DESC_COF | DMA_DESC_IOF;
|
|
|
|
/* Move tail */
|
2009-01-15 05:50:41 +00:00
|
|
|
lp->tx_chain_tail = chain_next;
|
2008-03-19 16:14:51 +00:00
|
|
|
/* Write to NDPTR */
|
2021-04-18 22:19:43 +00:00
|
|
|
writel(korina_tx_dma(lp, lp->tx_chain_head),
|
|
|
|
&lp->tx_dma_regs->dmandptr);
|
2008-03-19 16:14:51 +00:00
|
|
|
/* Move head to tail */
|
|
|
|
lp->tx_chain_head = lp->tx_chain_tail;
|
|
|
|
} else {
|
|
|
|
/* Update tail */
|
|
|
|
td->control = DMA_COUNT(length) |
|
|
|
|
DMA_DESC_COF | DMA_DESC_IOF;
|
|
|
|
/* Link to prev */
|
2009-01-15 05:50:41 +00:00
|
|
|
lp->td_ring[chain_prev].control &=
|
2008-03-19 16:14:51 +00:00
|
|
|
~DMA_DESC_COF;
|
|
|
|
/* Link to prev */
|
2021-04-18 22:19:43 +00:00
|
|
|
lp->td_ring[chain_prev].link = korina_tx_dma(lp, idx);
|
2008-03-19 16:14:51 +00:00
|
|
|
/* Move tail */
|
2009-01-15 05:50:41 +00:00
|
|
|
lp->tx_chain_tail = chain_next;
|
2008-03-19 16:14:51 +00:00
|
|
|
/* Write to NDPTR */
|
2021-04-18 22:19:43 +00:00
|
|
|
writel(korina_tx_dma(lp, lp->tx_chain_head),
|
|
|
|
&lp->tx_dma_regs->dmandptr);
|
2008-03-19 16:14:51 +00:00
|
|
|
/* Move head to tail */
|
|
|
|
lp->tx_chain_head = lp->tx_chain_tail;
|
2021-04-20 23:24:26 +00:00
|
|
|
lp->tx_chain_status = desc_is_empty;
|
2008-03-19 16:14:51 +00:00
|
|
|
}
|
|
|
|
} else {
|
2021-04-20 23:24:26 +00:00
|
|
|
if (lp->tx_chain_status == desc_is_empty) {
|
2008-03-19 16:14:51 +00:00
|
|
|
/* Update tail */
|
|
|
|
td->control = DMA_COUNT(length) |
|
|
|
|
DMA_DESC_COF | DMA_DESC_IOF;
|
|
|
|
/* Move tail */
|
2009-01-15 05:50:41 +00:00
|
|
|
lp->tx_chain_tail = chain_next;
|
2008-03-19 16:14:51 +00:00
|
|
|
lp->tx_chain_status = desc_filled;
|
|
|
|
} else {
|
|
|
|
/* Update tail */
|
|
|
|
td->control = DMA_COUNT(length) |
|
|
|
|
DMA_DESC_COF | DMA_DESC_IOF;
|
2009-01-15 05:50:41 +00:00
|
|
|
lp->td_ring[chain_prev].control &=
|
2008-03-19 16:14:51 +00:00
|
|
|
~DMA_DESC_COF;
|
2021-04-18 22:19:43 +00:00
|
|
|
lp->td_ring[chain_prev].link = korina_tx_dma(lp, idx);
|
2009-01-15 05:50:41 +00:00
|
|
|
lp->tx_chain_tail = chain_next;
|
2008-03-19 16:14:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-03 14:33:13 +00:00
|
|
|
netif_trans_update(dev);
|
2008-03-19 16:14:51 +00:00
|
|
|
spin_unlock_irqrestore(&lp->lock, flags);
|
|
|
|
|
2021-04-18 22:19:43 +00:00
|
|
|
return NETDEV_TX_OK;
|
|
|
|
|
|
|
|
drop_packet:
|
|
|
|
dev->stats.tx_dropped++;
|
|
|
|
dev_kfree_skb_any(skb);
|
|
|
|
spin_unlock_irqrestore(&lp->lock, flags);
|
|
|
|
|
2008-03-19 16:14:51 +00:00
|
|
|
return NETDEV_TX_OK;
|
|
|
|
}
|
|
|
|
|
2021-04-18 22:19:39 +00:00
|
|
|
static int korina_mdio_wait(struct korina_private *lp)
|
|
|
|
{
|
|
|
|
u32 value;
|
|
|
|
|
|
|
|
return readl_poll_timeout_atomic(&lp->eth_regs->miimind,
|
|
|
|
value, value & ETH_MII_IND_BSY,
|
|
|
|
1, 1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int korina_mdio_read(struct net_device *dev, int phy, int reg)
|
2008-03-19 16:14:51 +00:00
|
|
|
{
|
|
|
|
struct korina_private *lp = netdev_priv(dev);
|
|
|
|
int ret;
|
|
|
|
|
2021-04-18 22:19:39 +00:00
|
|
|
ret = korina_mdio_wait(lp);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
2008-03-19 16:14:51 +00:00
|
|
|
|
2021-04-18 22:19:39 +00:00
|
|
|
writel(phy << 8 | reg, &lp->eth_regs->miimaddr);
|
|
|
|
writel(1, &lp->eth_regs->miimcmd);
|
2008-03-19 16:14:51 +00:00
|
|
|
|
2021-04-18 22:19:39 +00:00
|
|
|
ret = korina_mdio_wait(lp);
|
|
|
|
if (ret < 0)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
if (readl(&lp->eth_regs->miimind) & ETH_MII_IND_NV)
|
|
|
|
return -EINVAL;
|
|
|
|
|
|
|
|
ret = readl(&lp->eth_regs->miimrdd);
|
|
|
|
writel(0, &lp->eth_regs->miimcmd);
|
2008-03-19 16:14:51 +00:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2021-04-18 22:19:39 +00:00
|
|
|
static void korina_mdio_write(struct net_device *dev, int phy, int reg, int val)
|
2008-03-19 16:14:51 +00:00
|
|
|
{
|
|
|
|
struct korina_private *lp = netdev_priv(dev);
|
|
|
|
|
2021-04-18 22:19:39 +00:00
|
|
|
if (korina_mdio_wait(lp))
|
|
|
|
return;
|
2008-03-19 16:14:51 +00:00
|
|
|
|
2021-04-18 22:19:39 +00:00
|
|
|
writel(0, &lp->eth_regs->miimcmd);
|
|
|
|
writel(phy << 8 | reg, &lp->eth_regs->miimaddr);
|
2008-03-19 16:14:51 +00:00
|
|
|
writel(val, &lp->eth_regs->miimwtd);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Ethernet Rx DMA interrupt */
|
|
|
|
static irqreturn_t korina_rx_dma_interrupt(int irq, void *dev_id)
|
|
|
|
{
|
|
|
|
struct net_device *dev = dev_id;
|
|
|
|
struct korina_private *lp = netdev_priv(dev);
|
|
|
|
u32 dmas, dmasm;
|
|
|
|
irqreturn_t retval;
|
|
|
|
|
|
|
|
dmas = readl(&lp->rx_dma_regs->dmas);
|
|
|
|
if (dmas & (DMA_STAT_DONE | DMA_STAT_HALT | DMA_STAT_ERR)) {
|
|
|
|
dmasm = readl(&lp->rx_dma_regs->dmasm);
|
|
|
|
writel(dmasm | (DMA_STAT_DONE |
|
|
|
|
DMA_STAT_HALT | DMA_STAT_ERR),
|
|
|
|
&lp->rx_dma_regs->dmasm);
|
|
|
|
|
2009-01-20 00:43:59 +00:00
|
|
|
napi_schedule(&lp->napi);
|
2009-01-15 05:50:12 +00:00
|
|
|
|
2008-03-19 16:14:51 +00:00
|
|
|
if (dmas & DMA_STAT_ERR)
|
2009-08-12 12:22:46 +00:00
|
|
|
printk(KERN_ERR "%s: DMA error\n", dev->name);
|
2008-03-19 16:14:51 +00:00
|
|
|
|
|
|
|
retval = IRQ_HANDLED;
|
|
|
|
} else
|
|
|
|
retval = IRQ_NONE;
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int korina_rx(struct net_device *dev, int limit)
|
|
|
|
{
|
|
|
|
struct korina_private *lp = netdev_priv(dev);
|
|
|
|
struct dma_desc *rd = &lp->rd_ring[lp->rx_next_done];
|
|
|
|
struct sk_buff *skb, *skb_new;
|
2009-01-15 05:48:59 +00:00
|
|
|
u32 devcs, pkt_len, dmas;
|
2021-04-18 22:19:43 +00:00
|
|
|
dma_addr_t ca;
|
2008-03-19 16:14:51 +00:00
|
|
|
int count;
|
|
|
|
|
|
|
|
for (count = 0; count < limit; count++) {
|
2009-01-15 05:48:59 +00:00
|
|
|
skb = lp->rx_skb[lp->rx_next_done];
|
|
|
|
skb_new = NULL;
|
2008-03-19 16:14:51 +00:00
|
|
|
|
|
|
|
devcs = rd->devcs;
|
|
|
|
|
2009-01-15 05:48:59 +00:00
|
|
|
if ((KORINA_RBSIZE - (u32)DMA_COUNT(rd->control)) == 0)
|
|
|
|
break;
|
|
|
|
|
2017-09-17 17:24:26 +00:00
|
|
|
/* check that this is a whole packet
|
|
|
|
* WARNING: DMA_FD bit incorrectly set
|
|
|
|
* in Rc32434 (errata ref #077) */
|
|
|
|
if (!(devcs & ETH_RX_LD))
|
|
|
|
goto next;
|
|
|
|
|
|
|
|
if (!(devcs & ETH_RX_ROK)) {
|
|
|
|
/* Update statistics counters */
|
2008-03-19 16:14:51 +00:00
|
|
|
dev->stats.rx_errors++;
|
|
|
|
dev->stats.rx_dropped++;
|
2017-09-17 17:24:26 +00:00
|
|
|
if (devcs & ETH_RX_CRC)
|
|
|
|
dev->stats.rx_crc_errors++;
|
|
|
|
if (devcs & ETH_RX_LE)
|
|
|
|
dev->stats.rx_length_errors++;
|
|
|
|
if (devcs & ETH_RX_OVR)
|
|
|
|
dev->stats.rx_fifo_errors++;
|
|
|
|
if (devcs & ETH_RX_CV)
|
|
|
|
dev->stats.rx_frame_errors++;
|
|
|
|
if (devcs & ETH_RX_CES)
|
|
|
|
dev->stats.rx_frame_errors++;
|
|
|
|
|
|
|
|
goto next;
|
|
|
|
}
|
2009-01-15 05:48:59 +00:00
|
|
|
|
2017-09-17 17:24:26 +00:00
|
|
|
/* Malloc up new buffer. */
|
|
|
|
skb_new = netdev_alloc_skb_ip_align(dev, KORINA_RBSIZE);
|
|
|
|
if (!skb_new)
|
|
|
|
break;
|
2021-04-18 22:19:43 +00:00
|
|
|
|
|
|
|
ca = dma_map_single(lp->dmadev, skb_new->data, KORINA_RBSIZE,
|
|
|
|
DMA_FROM_DEVICE);
|
|
|
|
if (dma_mapping_error(lp->dmadev, ca)) {
|
|
|
|
dev_kfree_skb_any(skb_new);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
pkt_len = RCVPKT_LENGTH(devcs);
|
|
|
|
dma_unmap_single(lp->dmadev, lp->rx_skb_dma[lp->rx_next_done],
|
|
|
|
pkt_len, DMA_FROM_DEVICE);
|
|
|
|
|
2017-09-17 17:24:26 +00:00
|
|
|
/* Do not count the CRC */
|
|
|
|
skb_put(skb, pkt_len - 4);
|
|
|
|
skb->protocol = eth_type_trans(skb, dev);
|
2009-01-15 05:48:59 +00:00
|
|
|
|
2017-09-17 17:24:26 +00:00
|
|
|
/* Pass the packet to upper layers */
|
2017-09-17 17:24:50 +00:00
|
|
|
napi_gro_receive(&lp->napi, skb);
|
2017-09-17 17:24:26 +00:00
|
|
|
dev->stats.rx_packets++;
|
|
|
|
dev->stats.rx_bytes += pkt_len;
|
2009-01-15 05:48:59 +00:00
|
|
|
|
2017-09-17 17:24:26 +00:00
|
|
|
/* Update the mcast stats */
|
|
|
|
if (devcs & ETH_RX_MP)
|
|
|
|
dev->stats.multicast++;
|
|
|
|
|
|
|
|
lp->rx_skb[lp->rx_next_done] = skb_new;
|
2021-04-18 22:19:43 +00:00
|
|
|
lp->rx_skb_dma[lp->rx_next_done] = ca;
|
2009-01-15 05:48:59 +00:00
|
|
|
|
2017-09-17 17:24:26 +00:00
|
|
|
next:
|
2009-01-15 05:48:59 +00:00
|
|
|
rd->devcs = 0;
|
|
|
|
|
|
|
|
/* Restore descriptor's curr_addr */
|
2021-04-18 22:19:43 +00:00
|
|
|
rd->ca = lp->rx_skb_dma[lp->rx_next_done];
|
2009-01-15 05:48:59 +00:00
|
|
|
|
|
|
|
rd->control = DMA_COUNT(KORINA_RBSIZE) |
|
|
|
|
DMA_DESC_COD | DMA_DESC_IOD;
|
|
|
|
lp->rd_ring[(lp->rx_next_done - 1) &
|
|
|
|
KORINA_RDS_MASK].control &=
|
|
|
|
~DMA_DESC_COD;
|
|
|
|
|
|
|
|
lp->rx_next_done = (lp->rx_next_done + 1) & KORINA_RDS_MASK;
|
|
|
|
rd = &lp->rd_ring[lp->rx_next_done];
|
2021-04-18 22:19:47 +00:00
|
|
|
writel((u32)~DMA_STAT_DONE, &lp->rx_dma_regs->dmas);
|
2008-03-19 16:14:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
dmas = readl(&lp->rx_dma_regs->dmas);
|
|
|
|
|
|
|
|
if (dmas & DMA_STAT_HALT) {
|
2021-04-18 22:19:47 +00:00
|
|
|
writel((u32)~(DMA_STAT_HALT | DMA_STAT_ERR),
|
|
|
|
&lp->rx_dma_regs->dmas);
|
2008-03-19 16:14:51 +00:00
|
|
|
|
|
|
|
lp->dma_halt_cnt++;
|
|
|
|
rd->devcs = 0;
|
2021-04-18 22:19:43 +00:00
|
|
|
rd->ca = lp->rx_skb_dma[lp->rx_next_done];
|
|
|
|
writel(korina_rx_dma(lp, rd - lp->rd_ring),
|
|
|
|
&lp->rx_dma_regs->dmandptr);
|
2008-03-19 16:14:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int korina_poll(struct napi_struct *napi, int budget)
|
|
|
|
{
|
|
|
|
struct korina_private *lp =
|
|
|
|
container_of(napi, struct korina_private, napi);
|
|
|
|
struct net_device *dev = lp->dev;
|
|
|
|
int work_done;
|
|
|
|
|
|
|
|
work_done = korina_rx(dev, budget);
|
|
|
|
if (work_done < budget) {
|
2017-01-30 16:22:01 +00:00
|
|
|
napi_complete_done(napi, work_done);
|
2008-03-19 16:14:51 +00:00
|
|
|
|
|
|
|
writel(readl(&lp->rx_dma_regs->dmasm) &
|
|
|
|
~(DMA_STAT_DONE | DMA_STAT_HALT | DMA_STAT_ERR),
|
|
|
|
&lp->rx_dma_regs->dmasm);
|
|
|
|
}
|
|
|
|
return work_done;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set or clear the multicast filter for this adaptor.
|
|
|
|
*/
|
|
|
|
static void korina_multicast_list(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct korina_private *lp = netdev_priv(dev);
|
|
|
|
unsigned long flags;
|
2010-04-01 21:22:57 +00:00
|
|
|
struct netdev_hw_addr *ha;
|
2008-03-19 16:14:51 +00:00
|
|
|
u32 recognise = ETH_ARC_AB; /* always accept broadcasts */
|
|
|
|
|
|
|
|
/* Set promiscuous mode */
|
|
|
|
if (dev->flags & IFF_PROMISC)
|
|
|
|
recognise |= ETH_ARC_PRO;
|
|
|
|
|
2010-02-08 04:30:35 +00:00
|
|
|
else if ((dev->flags & IFF_ALLMULTI) || (netdev_mc_count(dev) > 4))
|
2008-03-19 16:14:51 +00:00
|
|
|
/* All multicast and broadcast */
|
|
|
|
recognise |= ETH_ARC_AM;
|
|
|
|
|
|
|
|
/* Build the hash table */
|
2010-02-08 04:30:35 +00:00
|
|
|
if (netdev_mc_count(dev) > 4) {
|
2013-05-17 10:42:56 +00:00
|
|
|
u16 hash_table[4] = { 0 };
|
2008-03-19 16:14:51 +00:00
|
|
|
u32 crc;
|
|
|
|
|
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);
|
2008-03-19 16:14:51 +00:00
|
|
|
crc >>= 26;
|
|
|
|
hash_table[crc >> 4] |= 1 << (15 - (crc & 0xf));
|
|
|
|
}
|
|
|
|
/* Accept filtered multicast */
|
|
|
|
recognise |= ETH_ARC_AFM;
|
|
|
|
|
|
|
|
/* Fill the MAC hash tables with their values */
|
|
|
|
writel((u32)(hash_table[1] << 16 | hash_table[0]),
|
|
|
|
&lp->eth_regs->ethhash0);
|
|
|
|
writel((u32)(hash_table[3] << 16 | hash_table[2]),
|
|
|
|
&lp->eth_regs->ethhash1);
|
|
|
|
}
|
|
|
|
|
|
|
|
spin_lock_irqsave(&lp->lock, flags);
|
|
|
|
writel(recognise, &lp->eth_regs->etharc);
|
|
|
|
spin_unlock_irqrestore(&lp->lock, flags);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void korina_tx(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct korina_private *lp = netdev_priv(dev);
|
|
|
|
struct dma_desc *td = &lp->td_ring[lp->tx_next_done];
|
|
|
|
u32 devcs;
|
|
|
|
u32 dmas;
|
|
|
|
|
|
|
|
spin_lock(&lp->lock);
|
|
|
|
|
|
|
|
/* Process all desc that are done */
|
|
|
|
while (IS_DMA_FINISHED(td->control)) {
|
|
|
|
if (lp->tx_full == 1) {
|
|
|
|
netif_wake_queue(dev);
|
|
|
|
lp->tx_full = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
devcs = lp->td_ring[lp->tx_next_done].devcs;
|
|
|
|
if ((devcs & (ETH_TX_FD | ETH_TX_LD)) !=
|
|
|
|
(ETH_TX_FD | ETH_TX_LD)) {
|
|
|
|
dev->stats.tx_errors++;
|
|
|
|
dev->stats.tx_dropped++;
|
|
|
|
|
|
|
|
/* Should never happen */
|
2009-08-12 12:22:46 +00:00
|
|
|
printk(KERN_ERR "%s: split tx ignored\n",
|
2008-03-19 16:14:51 +00:00
|
|
|
dev->name);
|
|
|
|
} else if (devcs & ETH_TX_TOK) {
|
|
|
|
dev->stats.tx_packets++;
|
|
|
|
dev->stats.tx_bytes +=
|
|
|
|
lp->tx_skb[lp->tx_next_done]->len;
|
|
|
|
} else {
|
|
|
|
dev->stats.tx_errors++;
|
|
|
|
dev->stats.tx_dropped++;
|
|
|
|
|
|
|
|
/* Underflow */
|
|
|
|
if (devcs & ETH_TX_UND)
|
|
|
|
dev->stats.tx_fifo_errors++;
|
|
|
|
|
|
|
|
/* Oversized frame */
|
|
|
|
if (devcs & ETH_TX_OF)
|
|
|
|
dev->stats.tx_aborted_errors++;
|
|
|
|
|
|
|
|
/* Excessive deferrals */
|
|
|
|
if (devcs & ETH_TX_ED)
|
|
|
|
dev->stats.tx_carrier_errors++;
|
|
|
|
|
|
|
|
/* Collisions: medium busy */
|
|
|
|
if (devcs & ETH_TX_EC)
|
|
|
|
dev->stats.collisions++;
|
|
|
|
|
|
|
|
/* Late collision */
|
|
|
|
if (devcs & ETH_TX_LC)
|
|
|
|
dev->stats.tx_window_errors++;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We must always free the original skb */
|
|
|
|
if (lp->tx_skb[lp->tx_next_done]) {
|
2021-04-18 22:19:43 +00:00
|
|
|
dma_unmap_single(lp->dmadev,
|
|
|
|
lp->tx_skb_dma[lp->tx_next_done],
|
|
|
|
lp->tx_skb[lp->tx_next_done]->len,
|
|
|
|
DMA_TO_DEVICE);
|
2008-03-19 16:14:51 +00:00
|
|
|
dev_kfree_skb_any(lp->tx_skb[lp->tx_next_done]);
|
|
|
|
lp->tx_skb[lp->tx_next_done] = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
lp->td_ring[lp->tx_next_done].control = DMA_DESC_IOF;
|
|
|
|
lp->td_ring[lp->tx_next_done].devcs = ETH_TX_FD | ETH_TX_LD;
|
|
|
|
lp->td_ring[lp->tx_next_done].link = 0;
|
|
|
|
lp->td_ring[lp->tx_next_done].ca = 0;
|
|
|
|
lp->tx_count--;
|
|
|
|
|
|
|
|
/* Go on to next transmission */
|
|
|
|
lp->tx_next_done = (lp->tx_next_done + 1) & KORINA_TDS_MASK;
|
|
|
|
td = &lp->td_ring[lp->tx_next_done];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Clear the DMA status register */
|
|
|
|
dmas = readl(&lp->tx_dma_regs->dmas);
|
|
|
|
writel(~dmas, &lp->tx_dma_regs->dmas);
|
|
|
|
|
|
|
|
writel(readl(&lp->tx_dma_regs->dmasm) &
|
|
|
|
~(DMA_STAT_FINI | DMA_STAT_ERR),
|
|
|
|
&lp->tx_dma_regs->dmasm);
|
|
|
|
|
|
|
|
spin_unlock(&lp->lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
static irqreturn_t
|
|
|
|
korina_tx_dma_interrupt(int irq, void *dev_id)
|
|
|
|
{
|
|
|
|
struct net_device *dev = dev_id;
|
|
|
|
struct korina_private *lp = netdev_priv(dev);
|
|
|
|
u32 dmas, dmasm;
|
|
|
|
irqreturn_t retval;
|
|
|
|
|
|
|
|
dmas = readl(&lp->tx_dma_regs->dmas);
|
|
|
|
|
|
|
|
if (dmas & (DMA_STAT_FINI | DMA_STAT_ERR)) {
|
|
|
|
dmasm = readl(&lp->tx_dma_regs->dmasm);
|
|
|
|
writel(dmasm | (DMA_STAT_FINI | DMA_STAT_ERR),
|
|
|
|
&lp->tx_dma_regs->dmasm);
|
|
|
|
|
2009-01-15 05:50:12 +00:00
|
|
|
korina_tx(dev);
|
|
|
|
|
2008-03-19 16:14:51 +00:00
|
|
|
if (lp->tx_chain_status == desc_filled &&
|
|
|
|
(readl(&(lp->tx_dma_regs->dmandptr)) == 0)) {
|
2021-04-18 22:19:43 +00:00
|
|
|
writel(korina_tx_dma(lp, lp->tx_chain_head),
|
|
|
|
&lp->tx_dma_regs->dmandptr);
|
2021-04-20 23:24:26 +00:00
|
|
|
lp->tx_chain_status = desc_is_empty;
|
2008-03-19 16:14:51 +00:00
|
|
|
lp->tx_chain_head = lp->tx_chain_tail;
|
2016-05-03 14:33:13 +00:00
|
|
|
netif_trans_update(dev);
|
2008-03-19 16:14:51 +00:00
|
|
|
}
|
|
|
|
if (dmas & DMA_STAT_ERR)
|
2009-08-12 12:22:46 +00:00
|
|
|
printk(KERN_ERR "%s: DMA error\n", dev->name);
|
2008-03-19 16:14:51 +00:00
|
|
|
|
|
|
|
retval = IRQ_HANDLED;
|
|
|
|
} else
|
|
|
|
retval = IRQ_NONE;
|
|
|
|
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void korina_check_media(struct net_device *dev, unsigned int init_media)
|
|
|
|
{
|
|
|
|
struct korina_private *lp = netdev_priv(dev);
|
|
|
|
|
2021-04-18 22:19:39 +00:00
|
|
|
mii_check_media(&lp->mii_if, 1, init_media);
|
2008-03-19 16:14:51 +00:00
|
|
|
|
|
|
|
if (lp->mii_if.full_duplex)
|
|
|
|
writel(readl(&lp->eth_regs->ethmac2) | ETH_MAC2_FD,
|
|
|
|
&lp->eth_regs->ethmac2);
|
|
|
|
else
|
|
|
|
writel(readl(&lp->eth_regs->ethmac2) & ~ETH_MAC2_FD,
|
|
|
|
&lp->eth_regs->ethmac2);
|
|
|
|
}
|
|
|
|
|
2017-10-27 05:55:13 +00:00
|
|
|
static void korina_poll_media(struct timer_list *t)
|
2009-05-28 00:58:41 +00:00
|
|
|
{
|
2017-10-27 05:55:13 +00:00
|
|
|
struct korina_private *lp = from_timer(lp, t, media_check_timer);
|
|
|
|
struct net_device *dev = lp->dev;
|
2009-05-28 00:58:41 +00:00
|
|
|
|
|
|
|
korina_check_media(dev, 0);
|
|
|
|
mod_timer(&lp->media_check_timer, jiffies + HZ);
|
|
|
|
}
|
|
|
|
|
2008-03-19 16:14:51 +00:00
|
|
|
static void korina_set_carrier(struct mii_if_info *mii)
|
|
|
|
{
|
|
|
|
if (mii->force_media) {
|
|
|
|
/* autoneg is off: Link is always assumed to be up */
|
|
|
|
if (!netif_carrier_ok(mii->dev))
|
|
|
|
netif_carrier_on(mii->dev);
|
|
|
|
} else /* Let MMI library update carrier status */
|
|
|
|
korina_check_media(mii->dev, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int korina_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
|
|
|
|
{
|
|
|
|
struct korina_private *lp = netdev_priv(dev);
|
|
|
|
struct mii_ioctl_data *data = if_mii(rq);
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
if (!netif_running(dev))
|
|
|
|
return -EINVAL;
|
|
|
|
spin_lock_irq(&lp->lock);
|
|
|
|
rc = generic_mii_ioctl(&lp->mii_if, data, cmd, NULL);
|
|
|
|
spin_unlock_irq(&lp->lock);
|
|
|
|
korina_set_carrier(&lp->mii_if);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ethtool helpers */
|
|
|
|
static void netdev_get_drvinfo(struct net_device *dev,
|
2017-09-17 17:25:02 +00:00
|
|
|
struct ethtool_drvinfo *info)
|
2008-03-19 16:14:51 +00:00
|
|
|
{
|
|
|
|
struct korina_private *lp = netdev_priv(dev);
|
|
|
|
|
2013-01-06 00:44:26 +00:00
|
|
|
strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
|
|
|
|
strlcpy(info->version, DRV_VERSION, sizeof(info->version));
|
|
|
|
strlcpy(info->bus_info, lp->dev->name, sizeof(info->bus_info));
|
2008-03-19 16:14:51 +00:00
|
|
|
}
|
|
|
|
|
2017-01-14 11:33:19 +00:00
|
|
|
static int netdev_get_link_ksettings(struct net_device *dev,
|
|
|
|
struct ethtool_link_ksettings *cmd)
|
2008-03-19 16:14:51 +00:00
|
|
|
{
|
|
|
|
struct korina_private *lp = netdev_priv(dev);
|
|
|
|
|
|
|
|
spin_lock_irq(&lp->lock);
|
2017-06-04 17:22:00 +00:00
|
|
|
mii_ethtool_get_link_ksettings(&lp->mii_if, cmd);
|
2008-03-19 16:14:51 +00:00
|
|
|
spin_unlock_irq(&lp->lock);
|
|
|
|
|
2017-06-04 17:22:00 +00:00
|
|
|
return 0;
|
2008-03-19 16:14:51 +00:00
|
|
|
}
|
|
|
|
|
2017-01-14 11:33:19 +00:00
|
|
|
static int netdev_set_link_ksettings(struct net_device *dev,
|
|
|
|
const struct ethtool_link_ksettings *cmd)
|
2008-03-19 16:14:51 +00:00
|
|
|
{
|
|
|
|
struct korina_private *lp = netdev_priv(dev);
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
spin_lock_irq(&lp->lock);
|
2017-01-14 11:33:19 +00:00
|
|
|
rc = mii_ethtool_set_link_ksettings(&lp->mii_if, cmd);
|
2008-03-19 16:14:51 +00:00
|
|
|
spin_unlock_irq(&lp->lock);
|
|
|
|
korina_set_carrier(&lp->mii_if);
|
|
|
|
|
|
|
|
return rc;
|
|
|
|
}
|
|
|
|
|
|
|
|
static u32 netdev_get_link(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct korina_private *lp = netdev_priv(dev);
|
|
|
|
|
|
|
|
return mii_link_ok(&lp->mii_if);
|
|
|
|
}
|
|
|
|
|
2009-09-02 08:03:33 +00:00
|
|
|
static const struct ethtool_ops netdev_ethtool_ops = {
|
2017-09-17 17:25:02 +00:00
|
|
|
.get_drvinfo = netdev_get_drvinfo,
|
|
|
|
.get_link = netdev_get_link,
|
|
|
|
.get_link_ksettings = netdev_get_link_ksettings,
|
|
|
|
.set_link_ksettings = netdev_set_link_ksettings,
|
2008-03-19 16:14:51 +00:00
|
|
|
};
|
|
|
|
|
2009-08-12 12:52:32 +00:00
|
|
|
static int korina_alloc_ring(struct net_device *dev)
|
2008-03-19 16:14:51 +00:00
|
|
|
{
|
|
|
|
struct korina_private *lp = netdev_priv(dev);
|
2009-01-15 12:29:57 +00:00
|
|
|
struct sk_buff *skb;
|
2021-04-18 22:19:43 +00:00
|
|
|
dma_addr_t ca;
|
2008-03-19 16:14:51 +00:00
|
|
|
int i;
|
|
|
|
|
|
|
|
/* Initialize the transmit descriptors */
|
|
|
|
for (i = 0; i < KORINA_NUM_TDS; i++) {
|
|
|
|
lp->td_ring[i].control = DMA_DESC_IOF;
|
|
|
|
lp->td_ring[i].devcs = ETH_TX_FD | ETH_TX_LD;
|
|
|
|
lp->td_ring[i].ca = 0;
|
|
|
|
lp->td_ring[i].link = 0;
|
|
|
|
}
|
|
|
|
lp->tx_next_done = lp->tx_chain_head = lp->tx_chain_tail =
|
|
|
|
lp->tx_full = lp->tx_count = 0;
|
2021-04-20 23:24:26 +00:00
|
|
|
lp->tx_chain_status = desc_is_empty;
|
2008-03-19 16:14:51 +00:00
|
|
|
|
|
|
|
/* Initialize the receive descriptors */
|
|
|
|
for (i = 0; i < KORINA_NUM_RDS; i++) {
|
2010-05-29 13:23:35 +00:00
|
|
|
skb = netdev_alloc_skb_ip_align(dev, KORINA_RBSIZE);
|
2008-03-19 16:14:51 +00:00
|
|
|
if (!skb)
|
2009-08-12 12:52:32 +00:00
|
|
|
return -ENOMEM;
|
2008-03-19 16:14:51 +00:00
|
|
|
lp->rx_skb[i] = skb;
|
|
|
|
lp->rd_ring[i].control = DMA_DESC_IOD |
|
|
|
|
DMA_COUNT(KORINA_RBSIZE);
|
|
|
|
lp->rd_ring[i].devcs = 0;
|
2021-04-18 22:19:43 +00:00
|
|
|
ca = dma_map_single(lp->dmadev, skb->data, KORINA_RBSIZE,
|
|
|
|
DMA_FROM_DEVICE);
|
|
|
|
if (dma_mapping_error(lp->dmadev, ca))
|
|
|
|
return -ENOMEM;
|
|
|
|
lp->rd_ring[i].ca = ca;
|
|
|
|
lp->rx_skb_dma[i] = ca;
|
|
|
|
lp->rd_ring[i].link = korina_rx_dma(lp, i + 1);
|
2008-03-19 16:14:51 +00:00
|
|
|
}
|
|
|
|
|
2009-01-15 12:29:55 +00:00
|
|
|
/* loop back receive descriptors, so the last
|
|
|
|
* descriptor points to the first one */
|
2021-04-18 22:19:43 +00:00
|
|
|
lp->rd_ring[i - 1].link = lp->rd_dma;
|
2009-01-15 12:29:55 +00:00
|
|
|
lp->rd_ring[i - 1].control |= DMA_DESC_COD;
|
2008-03-19 16:14:51 +00:00
|
|
|
|
2009-01-15 12:29:55 +00:00
|
|
|
lp->rx_next_done = 0;
|
2008-03-19 16:14:51 +00:00
|
|
|
lp->rx_chain_head = 0;
|
|
|
|
lp->rx_chain_tail = 0;
|
2021-04-20 23:24:26 +00:00
|
|
|
lp->rx_chain_status = desc_is_empty;
|
2009-08-12 12:52:32 +00:00
|
|
|
|
|
|
|
return 0;
|
2008-03-19 16:14:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void korina_free_ring(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct korina_private *lp = netdev_priv(dev);
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < KORINA_NUM_RDS; i++) {
|
|
|
|
lp->rd_ring[i].control = 0;
|
2021-04-18 22:19:43 +00:00
|
|
|
if (lp->rx_skb[i]) {
|
|
|
|
dma_unmap_single(lp->dmadev, lp->rx_skb_dma[i],
|
|
|
|
KORINA_RBSIZE, DMA_FROM_DEVICE);
|
2008-03-19 16:14:51 +00:00
|
|
|
dev_kfree_skb_any(lp->rx_skb[i]);
|
2021-04-18 22:19:43 +00:00
|
|
|
lp->rx_skb[i] = NULL;
|
|
|
|
}
|
2008-03-19 16:14:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < KORINA_NUM_TDS; i++) {
|
|
|
|
lp->td_ring[i].control = 0;
|
2021-04-18 22:19:43 +00:00
|
|
|
if (lp->tx_skb[i]) {
|
|
|
|
dma_unmap_single(lp->dmadev, lp->tx_skb_dma[i],
|
|
|
|
lp->tx_skb[i]->len, DMA_TO_DEVICE);
|
2008-03-19 16:14:51 +00:00
|
|
|
dev_kfree_skb_any(lp->tx_skb[i]);
|
2021-04-18 22:19:43 +00:00
|
|
|
lp->tx_skb[i] = NULL;
|
|
|
|
}
|
2008-03-19 16:14:51 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize the RC32434 ethernet controller.
|
|
|
|
*/
|
|
|
|
static int korina_init(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct korina_private *lp = netdev_priv(dev);
|
|
|
|
|
|
|
|
/* Disable DMA */
|
|
|
|
korina_abort_tx(dev);
|
|
|
|
korina_abort_rx(dev);
|
|
|
|
|
|
|
|
/* reset ethernet logic */
|
|
|
|
writel(0, &lp->eth_regs->ethintfc);
|
|
|
|
while ((readl(&lp->eth_regs->ethintfc) & ETH_INT_FC_RIP))
|
2016-05-03 14:33:13 +00:00
|
|
|
netif_trans_update(dev);
|
2008-03-19 16:14:51 +00:00
|
|
|
|
|
|
|
/* Enable Ethernet Interface */
|
|
|
|
writel(ETH_INT_FC_EN, &lp->eth_regs->ethintfc);
|
|
|
|
|
|
|
|
/* Allocate rings */
|
2009-08-12 12:52:32 +00:00
|
|
|
if (korina_alloc_ring(dev)) {
|
|
|
|
printk(KERN_ERR "%s: descriptor allocation failed\n", dev->name);
|
|
|
|
korina_free_ring(dev);
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
2008-03-19 16:14:51 +00:00
|
|
|
|
|
|
|
writel(0, &lp->rx_dma_regs->dmas);
|
|
|
|
/* Start Rx DMA */
|
2021-04-18 22:19:42 +00:00
|
|
|
writel(0, &lp->rx_dma_regs->dmandptr);
|
2021-04-18 22:19:43 +00:00
|
|
|
writel(korina_rx_dma(lp, 0), &lp->rx_dma_regs->dmadptr);
|
2008-03-19 16:14:51 +00:00
|
|
|
|
|
|
|
writel(readl(&lp->tx_dma_regs->dmasm) &
|
|
|
|
~(DMA_STAT_FINI | DMA_STAT_ERR),
|
|
|
|
&lp->tx_dma_regs->dmasm);
|
|
|
|
writel(readl(&lp->rx_dma_regs->dmasm) &
|
|
|
|
~(DMA_STAT_DONE | DMA_STAT_HALT | DMA_STAT_ERR),
|
|
|
|
&lp->rx_dma_regs->dmasm);
|
|
|
|
|
|
|
|
/* Accept only packets destined for this Ethernet device address */
|
|
|
|
writel(ETH_ARC_AB, &lp->eth_regs->etharc);
|
|
|
|
|
|
|
|
/* Set all Ether station address registers to their initial values */
|
|
|
|
writel(STATION_ADDRESS_LOW(dev), &lp->eth_regs->ethsal0);
|
|
|
|
writel(STATION_ADDRESS_HIGH(dev), &lp->eth_regs->ethsah0);
|
|
|
|
|
|
|
|
writel(STATION_ADDRESS_LOW(dev), &lp->eth_regs->ethsal1);
|
|
|
|
writel(STATION_ADDRESS_HIGH(dev), &lp->eth_regs->ethsah1);
|
|
|
|
|
|
|
|
writel(STATION_ADDRESS_LOW(dev), &lp->eth_regs->ethsal2);
|
|
|
|
writel(STATION_ADDRESS_HIGH(dev), &lp->eth_regs->ethsah2);
|
|
|
|
|
|
|
|
writel(STATION_ADDRESS_LOW(dev), &lp->eth_regs->ethsal3);
|
|
|
|
writel(STATION_ADDRESS_HIGH(dev), &lp->eth_regs->ethsah3);
|
|
|
|
|
|
|
|
|
|
|
|
/* Frame Length Checking, Pad Enable, CRC Enable, Full Duplex set */
|
|
|
|
writel(ETH_MAC2_PE | ETH_MAC2_CEN | ETH_MAC2_FD,
|
|
|
|
&lp->eth_regs->ethmac2);
|
|
|
|
|
|
|
|
/* Back to back inter-packet-gap */
|
|
|
|
writel(0x15, &lp->eth_regs->ethipgt);
|
|
|
|
/* Non - Back to back inter-packet-gap */
|
|
|
|
writel(0x12, &lp->eth_regs->ethipgr);
|
|
|
|
|
|
|
|
/* Management Clock Prescaler Divisor
|
|
|
|
* Clock independent setting */
|
2021-04-18 22:19:46 +00:00
|
|
|
writel(((lp->mii_clock_freq) / MII_CLOCK + 1) & ~1,
|
|
|
|
&lp->eth_regs->ethmcp);
|
2021-04-18 22:19:39 +00:00
|
|
|
writel(0, &lp->eth_regs->miimcfg);
|
2008-03-19 16:14:51 +00:00
|
|
|
|
|
|
|
/* don't transmit until fifo contains 48b */
|
|
|
|
writel(48, &lp->eth_regs->ethfifott);
|
|
|
|
|
|
|
|
writel(ETH_MAC1_RE, &lp->eth_regs->ethmac1);
|
|
|
|
|
2021-04-18 22:19:39 +00:00
|
|
|
korina_check_media(dev, 1);
|
|
|
|
|
2008-03-19 16:14:51 +00:00
|
|
|
napi_enable(&lp->napi);
|
|
|
|
netif_start_queue(dev);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Restart the RC32434 ethernet controller.
|
|
|
|
*/
|
2010-05-29 13:23:34 +00:00
|
|
|
static void korina_restart_task(struct work_struct *work)
|
2008-03-19 16:14:51 +00:00
|
|
|
{
|
2010-05-29 13:23:34 +00:00
|
|
|
struct korina_private *lp = container_of(work,
|
|
|
|
struct korina_private, restart_task);
|
|
|
|
struct net_device *dev = lp->dev;
|
2008-03-19 16:14:51 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Disable interrupts
|
|
|
|
*/
|
|
|
|
disable_irq(lp->rx_irq);
|
|
|
|
disable_irq(lp->tx_irq);
|
|
|
|
|
|
|
|
writel(readl(&lp->tx_dma_regs->dmasm) |
|
|
|
|
DMA_STAT_FINI | DMA_STAT_ERR,
|
|
|
|
&lp->tx_dma_regs->dmasm);
|
|
|
|
writel(readl(&lp->rx_dma_regs->dmasm) |
|
|
|
|
DMA_STAT_DONE | DMA_STAT_HALT | DMA_STAT_ERR,
|
|
|
|
&lp->rx_dma_regs->dmasm);
|
|
|
|
|
2009-01-15 05:48:24 +00:00
|
|
|
napi_disable(&lp->napi);
|
|
|
|
|
2016-12-24 03:56:56 +00:00
|
|
|
korina_free_ring(dev);
|
|
|
|
|
2010-05-29 13:23:34 +00:00
|
|
|
if (korina_init(dev) < 0) {
|
2009-08-12 12:22:46 +00:00
|
|
|
printk(KERN_ERR "%s: cannot restart device\n", dev->name);
|
2010-05-29 13:23:34 +00:00
|
|
|
return;
|
2008-03-19 16:14:51 +00:00
|
|
|
}
|
|
|
|
korina_multicast_list(dev);
|
|
|
|
|
|
|
|
enable_irq(lp->tx_irq);
|
|
|
|
enable_irq(lp->rx_irq);
|
|
|
|
}
|
|
|
|
|
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 korina_tx_timeout(struct net_device *dev, unsigned int txqueue)
|
2008-03-19 16:14:51 +00:00
|
|
|
{
|
|
|
|
struct korina_private *lp = netdev_priv(dev);
|
|
|
|
|
2010-05-29 13:23:34 +00:00
|
|
|
schedule_work(&lp->restart_task);
|
2008-03-19 16:14:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_NET_POLL_CONTROLLER
|
|
|
|
static void korina_poll_controller(struct net_device *dev)
|
|
|
|
{
|
|
|
|
disable_irq(dev->irq);
|
|
|
|
korina_tx_dma_interrupt(dev->irq, dev);
|
|
|
|
enable_irq(dev->irq);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static int korina_open(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct korina_private *lp = netdev_priv(dev);
|
2008-04-20 16:06:13 +00:00
|
|
|
int ret;
|
2008-03-19 16:14:51 +00:00
|
|
|
|
|
|
|
/* Initialize */
|
|
|
|
ret = korina_init(dev);
|
|
|
|
if (ret < 0) {
|
2009-08-12 12:22:46 +00:00
|
|
|
printk(KERN_ERR "%s: cannot open device\n", dev->name);
|
2008-03-19 16:14:51 +00:00
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Install the interrupt handler
|
2017-09-17 17:24:15 +00:00
|
|
|
* that handles the Done Finished */
|
2009-11-19 07:29:17 +00:00
|
|
|
ret = request_irq(lp->rx_irq, korina_rx_dma_interrupt,
|
2013-09-07 05:20:57 +00:00
|
|
|
0, "Korina ethernet Rx", dev);
|
2008-03-19 16:14:51 +00:00
|
|
|
if (ret < 0) {
|
2009-08-12 12:22:46 +00:00
|
|
|
printk(KERN_ERR "%s: unable to get Rx DMA IRQ %d\n",
|
2017-09-17 17:25:02 +00:00
|
|
|
dev->name, lp->rx_irq);
|
2008-03-19 16:14:51 +00:00
|
|
|
goto err_release;
|
|
|
|
}
|
2009-11-19 07:29:17 +00:00
|
|
|
ret = request_irq(lp->tx_irq, korina_tx_dma_interrupt,
|
2013-09-07 05:20:57 +00:00
|
|
|
0, "Korina ethernet Tx", dev);
|
2008-03-19 16:14:51 +00:00
|
|
|
if (ret < 0) {
|
2009-08-12 12:22:46 +00:00
|
|
|
printk(KERN_ERR "%s: unable to get Tx DMA IRQ %d\n",
|
2017-09-17 17:25:02 +00:00
|
|
|
dev->name, lp->tx_irq);
|
2008-03-19 16:14:51 +00:00
|
|
|
goto err_free_rx_irq;
|
|
|
|
}
|
|
|
|
|
2009-05-28 00:58:41 +00:00
|
|
|
mod_timer(&lp->media_check_timer, jiffies + 1);
|
2008-04-20 16:05:31 +00:00
|
|
|
out:
|
|
|
|
return ret;
|
2008-03-19 16:14:51 +00:00
|
|
|
|
|
|
|
err_free_rx_irq:
|
|
|
|
free_irq(lp->rx_irq, dev);
|
|
|
|
err_release:
|
|
|
|
korina_free_ring(dev);
|
|
|
|
goto out;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int korina_close(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct korina_private *lp = netdev_priv(dev);
|
|
|
|
u32 tmp;
|
|
|
|
|
2009-05-28 00:58:41 +00:00
|
|
|
del_timer(&lp->media_check_timer);
|
|
|
|
|
2008-03-19 16:14:51 +00:00
|
|
|
/* Disable interrupts */
|
|
|
|
disable_irq(lp->rx_irq);
|
|
|
|
disable_irq(lp->tx_irq);
|
|
|
|
|
|
|
|
korina_abort_tx(dev);
|
|
|
|
tmp = readl(&lp->tx_dma_regs->dmasm);
|
|
|
|
tmp = tmp | DMA_STAT_FINI | DMA_STAT_ERR;
|
|
|
|
writel(tmp, &lp->tx_dma_regs->dmasm);
|
|
|
|
|
|
|
|
korina_abort_rx(dev);
|
|
|
|
tmp = readl(&lp->rx_dma_regs->dmasm);
|
|
|
|
tmp = tmp | DMA_STAT_DONE | DMA_STAT_HALT | DMA_STAT_ERR;
|
|
|
|
writel(tmp, &lp->rx_dma_regs->dmasm);
|
|
|
|
|
2009-01-15 05:48:24 +00:00
|
|
|
napi_disable(&lp->napi);
|
|
|
|
|
2010-05-29 13:23:34 +00:00
|
|
|
cancel_work_sync(&lp->restart_task);
|
|
|
|
|
2016-12-24 03:56:56 +00:00
|
|
|
korina_free_ring(dev);
|
|
|
|
|
2008-03-19 16:14:51 +00:00
|
|
|
free_irq(lp->rx_irq, dev);
|
|
|
|
free_irq(lp->tx_irq, dev);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-04-15 12:52:46 +00:00
|
|
|
static const struct net_device_ops korina_netdev_ops = {
|
|
|
|
.ndo_open = korina_open,
|
|
|
|
.ndo_stop = korina_close,
|
|
|
|
.ndo_start_xmit = korina_send_packet,
|
2011-08-16 06:29:01 +00:00
|
|
|
.ndo_set_rx_mode = korina_multicast_list,
|
2009-04-15 12:52:46 +00:00
|
|
|
.ndo_tx_timeout = korina_tx_timeout,
|
|
|
|
.ndo_do_ioctl = korina_ioctl,
|
|
|
|
.ndo_validate_addr = eth_validate_addr,
|
|
|
|
.ndo_set_mac_address = eth_mac_addr,
|
|
|
|
#ifdef CONFIG_NET_POLL_CONTROLLER
|
|
|
|
.ndo_poll_controller = korina_poll_controller,
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
2008-03-19 16:14:51 +00:00
|
|
|
static int korina_probe(struct platform_device *pdev)
|
|
|
|
{
|
2021-04-18 22:19:44 +00:00
|
|
|
u8 *mac_addr = dev_get_platdata(&pdev->dev);
|
2008-03-19 16:14:51 +00:00
|
|
|
struct korina_private *lp;
|
|
|
|
struct net_device *dev;
|
2021-04-18 22:19:46 +00:00
|
|
|
struct clk *clk;
|
2021-04-18 22:19:40 +00:00
|
|
|
void __iomem *p;
|
2008-04-20 16:06:13 +00:00
|
|
|
int rc;
|
2008-03-19 16:14:51 +00:00
|
|
|
|
2021-04-18 22:19:40 +00:00
|
|
|
dev = devm_alloc_etherdev(&pdev->dev, sizeof(struct korina_private));
|
2012-01-29 13:47:52 +00:00
|
|
|
if (!dev)
|
2008-03-19 16:14:51 +00:00
|
|
|
return -ENOMEM;
|
2012-01-29 13:47:52 +00:00
|
|
|
|
2008-03-19 16:14:51 +00:00
|
|
|
SET_NETDEV_DEV(dev, &pdev->dev);
|
|
|
|
lp = netdev_priv(dev);
|
|
|
|
|
2021-04-18 22:19:45 +00:00
|
|
|
if (mac_addr)
|
|
|
|
ether_addr_copy(dev->dev_addr, mac_addr);
|
|
|
|
else if (of_get_mac_address(pdev->dev.of_node, dev->dev_addr) < 0)
|
|
|
|
eth_hw_addr_random(dev);
|
2008-03-19 16:14:51 +00:00
|
|
|
|
2021-04-18 22:19:46 +00:00
|
|
|
clk = devm_clk_get_optional(&pdev->dev, "mdioclk");
|
|
|
|
if (IS_ERR(clk))
|
|
|
|
return PTR_ERR(clk);
|
|
|
|
if (clk) {
|
|
|
|
clk_prepare_enable(clk);
|
|
|
|
lp->mii_clock_freq = clk_get_rate(clk);
|
|
|
|
} else {
|
|
|
|
lp->mii_clock_freq = 200000000; /* max possible input clk */
|
|
|
|
}
|
|
|
|
|
2021-04-18 22:19:45 +00:00
|
|
|
lp->rx_irq = platform_get_irq_byname(pdev, "rx");
|
|
|
|
lp->tx_irq = platform_get_irq_byname(pdev, "tx");
|
2008-03-19 16:14:51 +00:00
|
|
|
|
2021-04-18 22:19:45 +00:00
|
|
|
p = devm_platform_ioremap_resource_byname(pdev, "emac");
|
2021-05-13 12:46:21 +00:00
|
|
|
if (IS_ERR(p)) {
|
2009-08-12 12:22:46 +00:00
|
|
|
printk(KERN_ERR DRV_NAME ": cannot remap registers\n");
|
2021-05-13 12:46:21 +00:00
|
|
|
return PTR_ERR(p);
|
2008-03-19 16:14:51 +00:00
|
|
|
}
|
2021-04-18 22:19:40 +00:00
|
|
|
lp->eth_regs = p;
|
2008-03-19 16:14:51 +00:00
|
|
|
|
2021-04-18 22:19:45 +00:00
|
|
|
p = devm_platform_ioremap_resource_byname(pdev, "dma_rx");
|
2021-05-13 12:46:21 +00:00
|
|
|
if (IS_ERR(p)) {
|
2009-08-12 12:22:46 +00:00
|
|
|
printk(KERN_ERR DRV_NAME ": cannot remap Rx DMA registers\n");
|
2021-05-13 12:46:21 +00:00
|
|
|
return PTR_ERR(p);
|
2008-03-19 16:14:51 +00:00
|
|
|
}
|
2021-04-18 22:19:40 +00:00
|
|
|
lp->rx_dma_regs = p;
|
2008-03-19 16:14:51 +00:00
|
|
|
|
2021-04-18 22:19:45 +00:00
|
|
|
p = devm_platform_ioremap_resource_byname(pdev, "dma_tx");
|
2021-05-13 12:46:21 +00:00
|
|
|
if (IS_ERR(p)) {
|
2009-08-12 12:22:46 +00:00
|
|
|
printk(KERN_ERR DRV_NAME ": cannot remap Tx DMA registers\n");
|
2021-05-13 12:46:21 +00:00
|
|
|
return PTR_ERR(p);
|
2008-03-19 16:14:51 +00:00
|
|
|
}
|
2021-04-18 22:19:40 +00:00
|
|
|
lp->tx_dma_regs = p;
|
2008-03-19 16:14:51 +00:00
|
|
|
|
2021-04-18 22:19:43 +00:00
|
|
|
lp->td_ring = dmam_alloc_coherent(&pdev->dev, TD_RING_SIZE,
|
|
|
|
&lp->td_dma, GFP_KERNEL);
|
2021-04-18 22:19:40 +00:00
|
|
|
if (!lp->td_ring)
|
|
|
|
return -ENOMEM;
|
2008-03-19 16:14:51 +00:00
|
|
|
|
2021-04-18 22:19:43 +00:00
|
|
|
lp->rd_ring = dmam_alloc_coherent(&pdev->dev, RD_RING_SIZE,
|
|
|
|
&lp->rd_dma, GFP_KERNEL);
|
|
|
|
if (!lp->rd_ring)
|
|
|
|
return -ENOMEM;
|
2008-03-19 16:14:51 +00:00
|
|
|
|
|
|
|
spin_lock_init(&lp->lock);
|
|
|
|
/* just use the rx dma irq */
|
|
|
|
dev->irq = lp->rx_irq;
|
|
|
|
lp->dev = dev;
|
2021-04-18 22:19:43 +00:00
|
|
|
lp->dmadev = &pdev->dev;
|
2008-03-19 16:14:51 +00:00
|
|
|
|
2009-04-15 12:52:46 +00:00
|
|
|
dev->netdev_ops = &korina_netdev_ops;
|
2008-03-19 16:14:51 +00:00
|
|
|
dev->ethtool_ops = &netdev_ethtool_ops;
|
|
|
|
dev->watchdog_timeo = TX_TIMEOUT;
|
2017-09-17 17:24:38 +00:00
|
|
|
netif_napi_add(dev, &lp->napi, korina_poll, NAPI_POLL_WEIGHT);
|
2008-03-19 16:14:51 +00:00
|
|
|
|
|
|
|
lp->mii_if.dev = dev;
|
2021-04-18 22:19:39 +00:00
|
|
|
lp->mii_if.mdio_read = korina_mdio_read;
|
|
|
|
lp->mii_if.mdio_write = korina_mdio_write;
|
|
|
|
lp->mii_if.phy_id = 1;
|
2008-03-19 16:14:51 +00:00
|
|
|
lp->mii_if.phy_id_mask = 0x1f;
|
|
|
|
lp->mii_if.reg_num_mask = 0x1f;
|
|
|
|
|
2021-04-18 22:19:44 +00:00
|
|
|
platform_set_drvdata(pdev, dev);
|
|
|
|
|
2008-04-20 16:06:13 +00:00
|
|
|
rc = register_netdev(dev);
|
|
|
|
if (rc < 0) {
|
2008-03-19 16:14:51 +00:00
|
|
|
printk(KERN_ERR DRV_NAME
|
2009-08-12 12:22:46 +00:00
|
|
|
": cannot register net device: %d\n", rc);
|
2021-04-18 22:19:40 +00:00
|
|
|
return rc;
|
2008-03-19 16:14:51 +00:00
|
|
|
}
|
2017-10-27 05:55:13 +00:00
|
|
|
timer_setup(&lp->media_check_timer, korina_poll_media, 0);
|
2009-08-12 12:22:46 +00:00
|
|
|
|
2010-05-29 13:23:34 +00:00
|
|
|
INIT_WORK(&lp->restart_task, korina_restart_task);
|
|
|
|
|
2009-08-12 12:22:46 +00:00
|
|
|
printk(KERN_INFO "%s: " DRV_NAME "-" DRV_VERSION " " DRV_RELDATE "\n",
|
|
|
|
dev->name);
|
2008-04-20 16:06:13 +00:00
|
|
|
return rc;
|
2008-03-19 16:14:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static int korina_remove(struct platform_device *pdev)
|
|
|
|
{
|
2021-04-18 22:19:44 +00:00
|
|
|
struct net_device *dev = platform_get_drvdata(pdev);
|
2008-03-19 16:14:51 +00:00
|
|
|
|
2021-04-18 22:19:44 +00:00
|
|
|
unregister_netdev(dev);
|
2008-03-19 16:14:51 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2021-04-18 22:19:45 +00:00
|
|
|
#ifdef CONFIG_OF
|
|
|
|
static const struct of_device_id korina_match[] = {
|
|
|
|
{
|
|
|
|
.compatible = "idt,3243x-emac",
|
|
|
|
},
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(of, korina_match);
|
|
|
|
#endif
|
|
|
|
|
2008-03-19 16:14:51 +00:00
|
|
|
static struct platform_driver korina_driver = {
|
2021-04-18 22:19:45 +00:00
|
|
|
.driver = {
|
|
|
|
.name = "korina",
|
|
|
|
.of_match_table = of_match_ptr(korina_match),
|
|
|
|
},
|
2008-03-19 16:14:51 +00:00
|
|
|
.probe = korina_probe,
|
|
|
|
.remove = korina_remove,
|
|
|
|
};
|
|
|
|
|
2011-11-27 16:44:17 +00:00
|
|
|
module_platform_driver(korina_driver);
|
2008-03-19 16:14:51 +00:00
|
|
|
|
|
|
|
MODULE_AUTHOR("Philip Rischel <rischelp@idt.com>");
|
|
|
|
MODULE_AUTHOR("Felix Fietkau <nbd@openwrt.org>");
|
|
|
|
MODULE_AUTHOR("Florian Fainelli <florian@openwrt.org>");
|
2017-09-17 17:25:11 +00:00
|
|
|
MODULE_AUTHOR("Roman Yeryomin <roman@advem.lv>");
|
2008-03-19 16:14:51 +00:00
|
|
|
MODULE_DESCRIPTION("IDT RC32434 (Korina) Ethernet driver");
|
|
|
|
MODULE_LICENSE("GPL");
|