2019-05-27 13:55:01 +07:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2015-10-07 03:37:46 +07:00
|
|
|
/**
|
|
|
|
* Microchip ENCX24J600 ethernet driver
|
|
|
|
*
|
|
|
|
* Copyright (C) 2015 Gridpoint
|
|
|
|
* Author: Jon Ringle <jringle@gridpoint.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/device.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/etherdevice.h>
|
|
|
|
#include <linux/ethtool.h>
|
|
|
|
#include <linux/interrupt.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/netdevice.h>
|
|
|
|
#include <linux/regmap.h>
|
|
|
|
#include <linux/skbuff.h>
|
|
|
|
#include <linux/spi/spi.h>
|
|
|
|
|
|
|
|
#include "encx24j600_hw.h"
|
|
|
|
|
|
|
|
#define DRV_NAME "encx24j600"
|
|
|
|
#define DRV_VERSION "1.0"
|
|
|
|
|
|
|
|
#define DEFAULT_MSG_ENABLE (NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_LINK)
|
|
|
|
static int debug = -1;
|
2016-12-12 20:29:09 +07:00
|
|
|
module_param(debug, int, 0000);
|
2015-10-07 03:37:46 +07:00
|
|
|
MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
|
|
|
|
|
|
|
|
/* SRAM memory layout:
|
|
|
|
*
|
|
|
|
* 0x0000-0x05ff TX buffers 1.5KB (1*1536) reside in the GP area in SRAM
|
|
|
|
* 0x0600-0x5fff RX buffers 22.5KB (15*1536) reside in the RX area in SRAM
|
|
|
|
*/
|
|
|
|
#define ENC_TX_BUF_START 0x0000U
|
|
|
|
#define ENC_RX_BUF_START 0x0600U
|
|
|
|
#define ENC_RX_BUF_END 0x5fffU
|
|
|
|
#define ENC_SRAM_SIZE 0x6000U
|
|
|
|
|
|
|
|
enum {
|
|
|
|
RXFILTER_NORMAL,
|
|
|
|
RXFILTER_MULTI,
|
|
|
|
RXFILTER_PROMISC
|
|
|
|
};
|
|
|
|
|
|
|
|
struct encx24j600_priv {
|
|
|
|
struct net_device *ndev;
|
|
|
|
struct mutex lock; /* device access lock */
|
|
|
|
struct encx24j600_context ctx;
|
|
|
|
struct sk_buff *tx_skb;
|
|
|
|
struct task_struct *kworker_task;
|
|
|
|
struct kthread_worker kworker;
|
|
|
|
struct kthread_work tx_work;
|
|
|
|
struct kthread_work setrx_work;
|
|
|
|
u16 next_packet;
|
|
|
|
bool hw_enabled;
|
|
|
|
bool full_duplex;
|
|
|
|
bool autoneg;
|
|
|
|
u16 speed;
|
|
|
|
int rxfilter;
|
|
|
|
u32 msg_enable;
|
|
|
|
};
|
|
|
|
|
|
|
|
static void dump_packet(const char *msg, int len, const char *data)
|
|
|
|
{
|
|
|
|
pr_debug(DRV_NAME ": %s - packet len:%d\n", msg, len);
|
|
|
|
print_hex_dump_bytes("pk data: ", DUMP_PREFIX_OFFSET, data, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void encx24j600_dump_rsv(struct encx24j600_priv *priv, const char *msg,
|
|
|
|
struct rsv *rsv)
|
|
|
|
{
|
|
|
|
struct net_device *dev = priv->ndev;
|
|
|
|
|
|
|
|
netdev_info(dev, "RX packet Len:%d\n", rsv->len);
|
|
|
|
netdev_dbg(dev, "%s - NextPk: 0x%04x\n", msg,
|
|
|
|
rsv->next_packet);
|
|
|
|
netdev_dbg(dev, "RxOK: %d, DribbleNibble: %d\n",
|
|
|
|
RSV_GETBIT(rsv->rxstat, RSV_RXOK),
|
|
|
|
RSV_GETBIT(rsv->rxstat, RSV_DRIBBLENIBBLE));
|
|
|
|
netdev_dbg(dev, "CRCErr:%d, LenChkErr: %d, LenOutOfRange: %d\n",
|
|
|
|
RSV_GETBIT(rsv->rxstat, RSV_CRCERROR),
|
|
|
|
RSV_GETBIT(rsv->rxstat, RSV_LENCHECKERR),
|
|
|
|
RSV_GETBIT(rsv->rxstat, RSV_LENOUTOFRANGE));
|
|
|
|
netdev_dbg(dev, "Multicast: %d, Broadcast: %d, LongDropEvent: %d, CarrierEvent: %d\n",
|
|
|
|
RSV_GETBIT(rsv->rxstat, RSV_RXMULTICAST),
|
|
|
|
RSV_GETBIT(rsv->rxstat, RSV_RXBROADCAST),
|
|
|
|
RSV_GETBIT(rsv->rxstat, RSV_RXLONGEVDROPEV),
|
|
|
|
RSV_GETBIT(rsv->rxstat, RSV_CARRIEREV));
|
|
|
|
netdev_dbg(dev, "ControlFrame: %d, PauseFrame: %d, UnknownOp: %d, VLanTagFrame: %d\n",
|
|
|
|
RSV_GETBIT(rsv->rxstat, RSV_RXCONTROLFRAME),
|
|
|
|
RSV_GETBIT(rsv->rxstat, RSV_RXPAUSEFRAME),
|
|
|
|
RSV_GETBIT(rsv->rxstat, RSV_RXUNKNOWNOPCODE),
|
|
|
|
RSV_GETBIT(rsv->rxstat, RSV_RXTYPEVLAN));
|
|
|
|
}
|
|
|
|
|
|
|
|
static u16 encx24j600_read_reg(struct encx24j600_priv *priv, u8 reg)
|
|
|
|
{
|
|
|
|
struct net_device *dev = priv->ndev;
|
|
|
|
unsigned int val = 0;
|
|
|
|
int ret = regmap_read(priv->ctx.regmap, reg, &val);
|
2016-12-12 20:29:09 +07:00
|
|
|
|
2015-10-07 03:37:46 +07:00
|
|
|
if (unlikely(ret))
|
|
|
|
netif_err(priv, drv, dev, "%s: error %d reading reg %02x\n",
|
|
|
|
__func__, ret, reg);
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void encx24j600_write_reg(struct encx24j600_priv *priv, u8 reg, u16 val)
|
|
|
|
{
|
|
|
|
struct net_device *dev = priv->ndev;
|
|
|
|
int ret = regmap_write(priv->ctx.regmap, reg, val);
|
2016-12-12 20:29:09 +07:00
|
|
|
|
2015-10-07 03:37:46 +07:00
|
|
|
if (unlikely(ret))
|
|
|
|
netif_err(priv, drv, dev, "%s: error %d writing reg %02x=%04x\n",
|
|
|
|
__func__, ret, reg, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void encx24j600_update_reg(struct encx24j600_priv *priv, u8 reg,
|
|
|
|
u16 mask, u16 val)
|
|
|
|
{
|
|
|
|
struct net_device *dev = priv->ndev;
|
|
|
|
int ret = regmap_update_bits(priv->ctx.regmap, reg, mask, val);
|
2016-12-12 20:29:09 +07:00
|
|
|
|
2015-10-07 03:37:46 +07:00
|
|
|
if (unlikely(ret))
|
|
|
|
netif_err(priv, drv, dev, "%s: error %d updating reg %02x=%04x~%04x\n",
|
|
|
|
__func__, ret, reg, val, mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
static u16 encx24j600_read_phy(struct encx24j600_priv *priv, u8 reg)
|
|
|
|
{
|
|
|
|
struct net_device *dev = priv->ndev;
|
|
|
|
unsigned int val = 0;
|
|
|
|
int ret = regmap_read(priv->ctx.phymap, reg, &val);
|
2016-12-12 20:29:09 +07:00
|
|
|
|
2015-10-07 03:37:46 +07:00
|
|
|
if (unlikely(ret))
|
|
|
|
netif_err(priv, drv, dev, "%s: error %d reading %02x\n",
|
|
|
|
__func__, ret, reg);
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void encx24j600_write_phy(struct encx24j600_priv *priv, u8 reg, u16 val)
|
|
|
|
{
|
|
|
|
struct net_device *dev = priv->ndev;
|
|
|
|
int ret = regmap_write(priv->ctx.phymap, reg, val);
|
2016-12-12 20:29:09 +07:00
|
|
|
|
2015-10-07 03:37:46 +07:00
|
|
|
if (unlikely(ret))
|
|
|
|
netif_err(priv, drv, dev, "%s: error %d writing reg %02x=%04x\n",
|
|
|
|
__func__, ret, reg, val);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void encx24j600_clr_bits(struct encx24j600_priv *priv, u8 reg, u16 mask)
|
|
|
|
{
|
|
|
|
encx24j600_update_reg(priv, reg, mask, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void encx24j600_set_bits(struct encx24j600_priv *priv, u8 reg, u16 mask)
|
|
|
|
{
|
|
|
|
encx24j600_update_reg(priv, reg, mask, mask);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void encx24j600_cmd(struct encx24j600_priv *priv, u8 cmd)
|
|
|
|
{
|
|
|
|
struct net_device *dev = priv->ndev;
|
|
|
|
int ret = regmap_write(priv->ctx.regmap, cmd, 0);
|
2016-12-12 20:29:09 +07:00
|
|
|
|
2015-10-07 03:37:46 +07:00
|
|
|
if (unlikely(ret))
|
|
|
|
netif_err(priv, drv, dev, "%s: error %d with cmd %02x\n",
|
|
|
|
__func__, ret, cmd);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int encx24j600_raw_read(struct encx24j600_priv *priv, u8 reg, u8 *data,
|
|
|
|
size_t count)
|
|
|
|
{
|
|
|
|
int ret;
|
2016-12-12 20:29:09 +07:00
|
|
|
|
2015-10-07 03:37:46 +07:00
|
|
|
mutex_lock(&priv->ctx.mutex);
|
|
|
|
ret = regmap_encx24j600_spi_read(&priv->ctx, reg, data, count);
|
|
|
|
mutex_unlock(&priv->ctx.mutex);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int encx24j600_raw_write(struct encx24j600_priv *priv, u8 reg,
|
|
|
|
const u8 *data, size_t count)
|
|
|
|
{
|
|
|
|
int ret;
|
2016-12-12 20:29:09 +07:00
|
|
|
|
2015-10-07 03:37:46 +07:00
|
|
|
mutex_lock(&priv->ctx.mutex);
|
|
|
|
ret = regmap_encx24j600_spi_write(&priv->ctx, reg, data, count);
|
|
|
|
mutex_unlock(&priv->ctx.mutex);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void encx24j600_update_phcon1(struct encx24j600_priv *priv)
|
|
|
|
{
|
|
|
|
u16 phcon1 = encx24j600_read_phy(priv, PHCON1);
|
2016-12-12 20:29:09 +07:00
|
|
|
|
2015-10-07 03:37:46 +07:00
|
|
|
if (priv->autoneg == AUTONEG_ENABLE) {
|
|
|
|
phcon1 |= ANEN | RENEG;
|
|
|
|
} else {
|
|
|
|
phcon1 &= ~ANEN;
|
|
|
|
if (priv->speed == SPEED_100)
|
|
|
|
phcon1 |= SPD100;
|
|
|
|
else
|
|
|
|
phcon1 &= ~SPD100;
|
|
|
|
|
|
|
|
if (priv->full_duplex)
|
|
|
|
phcon1 |= PFULDPX;
|
|
|
|
else
|
|
|
|
phcon1 &= ~PFULDPX;
|
|
|
|
}
|
|
|
|
encx24j600_write_phy(priv, PHCON1, phcon1);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Waits for autonegotiation to complete. */
|
|
|
|
static int encx24j600_wait_for_autoneg(struct encx24j600_priv *priv)
|
|
|
|
{
|
|
|
|
struct net_device *dev = priv->ndev;
|
|
|
|
unsigned long timeout = jiffies + msecs_to_jiffies(2000);
|
|
|
|
u16 phstat1;
|
|
|
|
u16 estat;
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
phstat1 = encx24j600_read_phy(priv, PHSTAT1);
|
|
|
|
while ((phstat1 & ANDONE) == 0) {
|
|
|
|
if (time_after(jiffies, timeout)) {
|
|
|
|
u16 phstat3;
|
|
|
|
|
|
|
|
netif_notice(priv, drv, dev, "timeout waiting for autoneg done\n");
|
|
|
|
|
|
|
|
priv->autoneg = AUTONEG_DISABLE;
|
|
|
|
phstat3 = encx24j600_read_phy(priv, PHSTAT3);
|
|
|
|
priv->speed = (phstat3 & PHY3SPD100)
|
|
|
|
? SPEED_100 : SPEED_10;
|
|
|
|
priv->full_duplex = (phstat3 & PHY3DPX) ? 1 : 0;
|
|
|
|
encx24j600_update_phcon1(priv);
|
|
|
|
netif_notice(priv, drv, dev, "Using parallel detection: %s/%s",
|
|
|
|
priv->speed == SPEED_100 ? "100" : "10",
|
|
|
|
priv->full_duplex ? "Full" : "Half");
|
|
|
|
|
|
|
|
return -ETIMEDOUT;
|
|
|
|
}
|
|
|
|
cpu_relax();
|
|
|
|
phstat1 = encx24j600_read_phy(priv, PHSTAT1);
|
|
|
|
}
|
|
|
|
|
|
|
|
estat = encx24j600_read_reg(priv, ESTAT);
|
|
|
|
if (estat & PHYDPX) {
|
|
|
|
encx24j600_set_bits(priv, MACON2, FULDPX);
|
|
|
|
encx24j600_write_reg(priv, MABBIPG, 0x15);
|
|
|
|
} else {
|
|
|
|
encx24j600_clr_bits(priv, MACON2, FULDPX);
|
|
|
|
encx24j600_write_reg(priv, MABBIPG, 0x12);
|
|
|
|
/* Max retransmittions attempt */
|
|
|
|
encx24j600_write_reg(priv, MACLCON, 0x370f);
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Access the PHY to determine link status */
|
|
|
|
static void encx24j600_check_link_status(struct encx24j600_priv *priv)
|
|
|
|
{
|
|
|
|
struct net_device *dev = priv->ndev;
|
|
|
|
u16 estat;
|
|
|
|
|
|
|
|
estat = encx24j600_read_reg(priv, ESTAT);
|
|
|
|
|
|
|
|
if (estat & PHYLNK) {
|
|
|
|
if (priv->autoneg == AUTONEG_ENABLE)
|
|
|
|
encx24j600_wait_for_autoneg(priv);
|
|
|
|
|
|
|
|
netif_carrier_on(dev);
|
|
|
|
netif_info(priv, ifup, dev, "link up\n");
|
|
|
|
} else {
|
|
|
|
netif_info(priv, ifdown, dev, "link down\n");
|
|
|
|
|
|
|
|
/* Re-enable autoneg since we won't know what we might be
|
|
|
|
* connected to when the link is brought back up again.
|
|
|
|
*/
|
|
|
|
priv->autoneg = AUTONEG_ENABLE;
|
|
|
|
priv->full_duplex = true;
|
|
|
|
priv->speed = SPEED_100;
|
|
|
|
netif_carrier_off(dev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void encx24j600_int_link_handler(struct encx24j600_priv *priv)
|
|
|
|
{
|
|
|
|
struct net_device *dev = priv->ndev;
|
|
|
|
|
|
|
|
netif_dbg(priv, intr, dev, "%s", __func__);
|
|
|
|
encx24j600_check_link_status(priv);
|
|
|
|
encx24j600_clr_bits(priv, EIR, LINKIF);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void encx24j600_tx_complete(struct encx24j600_priv *priv, bool err)
|
|
|
|
{
|
|
|
|
struct net_device *dev = priv->ndev;
|
|
|
|
|
|
|
|
if (!priv->tx_skb) {
|
|
|
|
BUG();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mutex_lock(&priv->lock);
|
|
|
|
|
|
|
|
if (err)
|
|
|
|
dev->stats.tx_errors++;
|
|
|
|
else
|
|
|
|
dev->stats.tx_packets++;
|
|
|
|
|
|
|
|
dev->stats.tx_bytes += priv->tx_skb->len;
|
|
|
|
|
|
|
|
encx24j600_clr_bits(priv, EIR, TXIF | TXABTIF);
|
|
|
|
|
|
|
|
netif_dbg(priv, tx_done, dev, "TX Done%s\n", err ? ": Err" : "");
|
|
|
|
|
|
|
|
dev_kfree_skb(priv->tx_skb);
|
|
|
|
priv->tx_skb = NULL;
|
|
|
|
|
|
|
|
netif_wake_queue(dev);
|
|
|
|
|
|
|
|
mutex_unlock(&priv->lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int encx24j600_receive_packet(struct encx24j600_priv *priv,
|
|
|
|
struct rsv *rsv)
|
|
|
|
{
|
|
|
|
struct net_device *dev = priv->ndev;
|
|
|
|
struct sk_buff *skb = netdev_alloc_skb(dev, rsv->len + NET_IP_ALIGN);
|
2016-12-12 20:29:09 +07:00
|
|
|
|
2015-10-07 03:37:46 +07:00
|
|
|
if (!skb) {
|
|
|
|
pr_err_ratelimited("RX: OOM: packet dropped\n");
|
|
|
|
dev->stats.rx_dropped++;
|
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
skb_reserve(skb, NET_IP_ALIGN);
|
|
|
|
encx24j600_raw_read(priv, RRXDATA, skb_put(skb, rsv->len), rsv->len);
|
|
|
|
|
|
|
|
if (netif_msg_pktdata(priv))
|
|
|
|
dump_packet("RX", skb->len, skb->data);
|
|
|
|
|
|
|
|
skb->dev = dev;
|
|
|
|
skb->protocol = eth_type_trans(skb, dev);
|
|
|
|
skb->ip_summed = CHECKSUM_COMPLETE;
|
|
|
|
|
|
|
|
/* Maintain stats */
|
|
|
|
dev->stats.rx_packets++;
|
|
|
|
dev->stats.rx_bytes += rsv->len;
|
|
|
|
|
|
|
|
netif_rx(skb);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void encx24j600_rx_packets(struct encx24j600_priv *priv, u8 packet_count)
|
|
|
|
{
|
|
|
|
struct net_device *dev = priv->ndev;
|
|
|
|
|
|
|
|
while (packet_count--) {
|
|
|
|
struct rsv rsv;
|
|
|
|
u16 newrxtail;
|
|
|
|
|
|
|
|
encx24j600_write_reg(priv, ERXRDPT, priv->next_packet);
|
|
|
|
encx24j600_raw_read(priv, RRXDATA, (u8 *)&rsv, sizeof(rsv));
|
|
|
|
|
|
|
|
if (netif_msg_rx_status(priv))
|
|
|
|
encx24j600_dump_rsv(priv, __func__, &rsv);
|
|
|
|
|
|
|
|
if (!RSV_GETBIT(rsv.rxstat, RSV_RXOK) ||
|
|
|
|
(rsv.len > MAX_FRAMELEN)) {
|
|
|
|
netif_err(priv, rx_err, dev, "RX Error %04x\n",
|
|
|
|
rsv.rxstat);
|
|
|
|
dev->stats.rx_errors++;
|
|
|
|
|
|
|
|
if (RSV_GETBIT(rsv.rxstat, RSV_CRCERROR))
|
|
|
|
dev->stats.rx_crc_errors++;
|
|
|
|
if (RSV_GETBIT(rsv.rxstat, RSV_LENCHECKERR))
|
|
|
|
dev->stats.rx_frame_errors++;
|
|
|
|
if (rsv.len > MAX_FRAMELEN)
|
|
|
|
dev->stats.rx_over_errors++;
|
|
|
|
} else {
|
|
|
|
encx24j600_receive_packet(priv, &rsv);
|
|
|
|
}
|
|
|
|
|
encx24j600: bugfix - always move ERXTAIL to next packet in encx24j600_rx_packets
Before, encx24j600_rx_packets did not update encx24j600_priv's next_packet
member when an error occurred during packet handling (either because the
packet's RSV header indicates an error or because the encx24j600_receive_packet
method can't allocate an sk_buff).
If the next_packet member is not updated, the ERXTAIL register will be set to
the same value it had before, which means the bad packet remains in the
component's memory and its RSV header will be read again when a new packet
arrives. If the RSV header indicates a bad packet or if sk_buff allocation
continues to fail, new packets will be stored in the component's memory until
that memory is full, after which packets will be dropped.
The SETPKTDEC command is always executed though, so the encx24j600 hardware has
an incorrect count of the packets in its memory.
To prevent this, the next_packet member should always be updated, allowing the
packet to be skipped (either because it's bad, as indicated in its RSV header,
or because allocating an sk_buff failed). In the allocation failure case, this
does mean dropping a valid packet, but dropping the oldest packet to keep as
much memory as possible available for new packets seems preferable to keeping
old (but valid) packets around while dropping new ones.
Signed-off-by: Jeroen De Wachter <jeroen.de_wachter.ext@nokia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2016-12-12 20:29:08 +07:00
|
|
|
priv->next_packet = rsv.next_packet;
|
|
|
|
|
2015-10-07 03:37:46 +07:00
|
|
|
newrxtail = priv->next_packet - 2;
|
|
|
|
if (newrxtail == ENC_RX_BUF_START)
|
|
|
|
newrxtail = SRAM_SIZE - 2;
|
|
|
|
|
|
|
|
encx24j600_cmd(priv, SETPKTDEC);
|
|
|
|
encx24j600_write_reg(priv, ERXTAIL, newrxtail);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static irqreturn_t encx24j600_isr(int irq, void *dev_id)
|
|
|
|
{
|
|
|
|
struct encx24j600_priv *priv = dev_id;
|
|
|
|
struct net_device *dev = priv->ndev;
|
|
|
|
int eir;
|
|
|
|
|
|
|
|
/* Clear interrupts */
|
|
|
|
encx24j600_cmd(priv, CLREIE);
|
|
|
|
|
|
|
|
eir = encx24j600_read_reg(priv, EIR);
|
|
|
|
|
|
|
|
if (eir & LINKIF)
|
|
|
|
encx24j600_int_link_handler(priv);
|
|
|
|
|
|
|
|
if (eir & TXIF)
|
|
|
|
encx24j600_tx_complete(priv, false);
|
|
|
|
|
|
|
|
if (eir & TXABTIF)
|
|
|
|
encx24j600_tx_complete(priv, true);
|
|
|
|
|
|
|
|
if (eir & RXABTIF) {
|
|
|
|
if (eir & PCFULIF) {
|
|
|
|
/* Packet counter is full */
|
|
|
|
netif_err(priv, rx_err, dev, "Packet counter full\n");
|
|
|
|
}
|
|
|
|
dev->stats.rx_dropped++;
|
|
|
|
encx24j600_clr_bits(priv, EIR, RXABTIF);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (eir & PKTIF) {
|
|
|
|
u8 packet_count;
|
|
|
|
|
|
|
|
mutex_lock(&priv->lock);
|
|
|
|
|
|
|
|
packet_count = encx24j600_read_reg(priv, ESTAT) & 0xff;
|
|
|
|
while (packet_count) {
|
|
|
|
encx24j600_rx_packets(priv, packet_count);
|
|
|
|
packet_count = encx24j600_read_reg(priv, ESTAT) & 0xff;
|
|
|
|
}
|
|
|
|
|
|
|
|
mutex_unlock(&priv->lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Enable interrupts */
|
|
|
|
encx24j600_cmd(priv, SETEIE);
|
|
|
|
|
|
|
|
return IRQ_HANDLED;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int encx24j600_soft_reset(struct encx24j600_priv *priv)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
int timeout;
|
|
|
|
u16 eudast;
|
|
|
|
|
|
|
|
/* Write and verify a test value to EUDAST */
|
|
|
|
regcache_cache_bypass(priv->ctx.regmap, true);
|
|
|
|
timeout = 10;
|
|
|
|
do {
|
|
|
|
encx24j600_write_reg(priv, EUDAST, EUDAST_TEST_VAL);
|
|
|
|
eudast = encx24j600_read_reg(priv, EUDAST);
|
|
|
|
usleep_range(25, 100);
|
|
|
|
} while ((eudast != EUDAST_TEST_VAL) && --timeout);
|
|
|
|
regcache_cache_bypass(priv->ctx.regmap, false);
|
|
|
|
|
|
|
|
if (timeout == 0) {
|
|
|
|
ret = -ETIMEDOUT;
|
|
|
|
goto err_out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Wait for CLKRDY to become set */
|
|
|
|
timeout = 10;
|
|
|
|
while (!(encx24j600_read_reg(priv, ESTAT) & CLKRDY) && --timeout)
|
|
|
|
usleep_range(25, 100);
|
|
|
|
|
|
|
|
if (timeout == 0) {
|
|
|
|
ret = -ETIMEDOUT;
|
|
|
|
goto err_out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Issue a System Reset command */
|
|
|
|
encx24j600_cmd(priv, SETETHRST);
|
|
|
|
usleep_range(25, 100);
|
|
|
|
|
|
|
|
/* Confirm that EUDAST has 0000h after system reset */
|
|
|
|
if (encx24j600_read_reg(priv, EUDAST) != 0) {
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto err_out;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Wait for PHY register and status bits to become available */
|
|
|
|
usleep_range(256, 1000);
|
|
|
|
|
|
|
|
err_out:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int encx24j600_hw_reset(struct encx24j600_priv *priv)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
mutex_lock(&priv->lock);
|
|
|
|
ret = encx24j600_soft_reset(priv);
|
|
|
|
mutex_unlock(&priv->lock);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void encx24j600_reset_hw_tx(struct encx24j600_priv *priv)
|
|
|
|
{
|
|
|
|
encx24j600_set_bits(priv, ECON2, TXRST);
|
|
|
|
encx24j600_clr_bits(priv, ECON2, TXRST);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void encx24j600_hw_init_tx(struct encx24j600_priv *priv)
|
|
|
|
{
|
|
|
|
/* Reset TX */
|
|
|
|
encx24j600_reset_hw_tx(priv);
|
|
|
|
|
|
|
|
/* Clear the TXIF flag if were previously set */
|
|
|
|
encx24j600_clr_bits(priv, EIR, TXIF | TXABTIF);
|
|
|
|
|
|
|
|
/* Write the Tx Buffer pointer */
|
|
|
|
encx24j600_write_reg(priv, EGPWRPT, ENC_TX_BUF_START);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void encx24j600_hw_init_rx(struct encx24j600_priv *priv)
|
|
|
|
{
|
|
|
|
encx24j600_cmd(priv, DISABLERX);
|
|
|
|
|
|
|
|
/* Set up RX packet start address in the SRAM */
|
|
|
|
encx24j600_write_reg(priv, ERXST, ENC_RX_BUF_START);
|
|
|
|
|
|
|
|
/* Preload the RX Data pointer to the beginning of the RX area */
|
|
|
|
encx24j600_write_reg(priv, ERXRDPT, ENC_RX_BUF_START);
|
|
|
|
|
|
|
|
priv->next_packet = ENC_RX_BUF_START;
|
|
|
|
|
|
|
|
/* Set up RX end address in the SRAM */
|
|
|
|
encx24j600_write_reg(priv, ERXTAIL, ENC_SRAM_SIZE - 2);
|
|
|
|
|
|
|
|
/* Reset the user data pointers */
|
|
|
|
encx24j600_write_reg(priv, EUDAST, ENC_SRAM_SIZE);
|
|
|
|
encx24j600_write_reg(priv, EUDAND, ENC_SRAM_SIZE + 1);
|
|
|
|
|
|
|
|
/* Set Max Frame length */
|
|
|
|
encx24j600_write_reg(priv, MAMXFL, MAX_FRAMELEN);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void encx24j600_dump_config(struct encx24j600_priv *priv,
|
|
|
|
const char *msg)
|
|
|
|
{
|
|
|
|
pr_info(DRV_NAME ": %s\n", msg);
|
|
|
|
|
|
|
|
/* CHIP configuration */
|
|
|
|
pr_info(DRV_NAME " ECON1: %04X\n", encx24j600_read_reg(priv, ECON1));
|
|
|
|
pr_info(DRV_NAME " ECON2: %04X\n", encx24j600_read_reg(priv, ECON2));
|
|
|
|
pr_info(DRV_NAME " ERXFCON: %04X\n", encx24j600_read_reg(priv,
|
|
|
|
ERXFCON));
|
|
|
|
pr_info(DRV_NAME " ESTAT: %04X\n", encx24j600_read_reg(priv, ESTAT));
|
|
|
|
pr_info(DRV_NAME " EIR: %04X\n", encx24j600_read_reg(priv, EIR));
|
|
|
|
pr_info(DRV_NAME " EIDLED: %04X\n", encx24j600_read_reg(priv, EIDLED));
|
|
|
|
|
|
|
|
/* MAC layer configuration */
|
|
|
|
pr_info(DRV_NAME " MACON1: %04X\n", encx24j600_read_reg(priv, MACON1));
|
|
|
|
pr_info(DRV_NAME " MACON2: %04X\n", encx24j600_read_reg(priv, MACON2));
|
|
|
|
pr_info(DRV_NAME " MAIPG: %04X\n", encx24j600_read_reg(priv, MAIPG));
|
|
|
|
pr_info(DRV_NAME " MACLCON: %04X\n", encx24j600_read_reg(priv,
|
|
|
|
MACLCON));
|
|
|
|
pr_info(DRV_NAME " MABBIPG: %04X\n", encx24j600_read_reg(priv,
|
|
|
|
MABBIPG));
|
|
|
|
|
|
|
|
/* PHY configuation */
|
|
|
|
pr_info(DRV_NAME " PHCON1: %04X\n", encx24j600_read_phy(priv, PHCON1));
|
|
|
|
pr_info(DRV_NAME " PHCON2: %04X\n", encx24j600_read_phy(priv, PHCON2));
|
|
|
|
pr_info(DRV_NAME " PHANA: %04X\n", encx24j600_read_phy(priv, PHANA));
|
|
|
|
pr_info(DRV_NAME " PHANLPA: %04X\n", encx24j600_read_phy(priv,
|
|
|
|
PHANLPA));
|
|
|
|
pr_info(DRV_NAME " PHANE: %04X\n", encx24j600_read_phy(priv, PHANE));
|
|
|
|
pr_info(DRV_NAME " PHSTAT1: %04X\n", encx24j600_read_phy(priv,
|
|
|
|
PHSTAT1));
|
|
|
|
pr_info(DRV_NAME " PHSTAT2: %04X\n", encx24j600_read_phy(priv,
|
|
|
|
PHSTAT2));
|
|
|
|
pr_info(DRV_NAME " PHSTAT3: %04X\n", encx24j600_read_phy(priv,
|
|
|
|
PHSTAT3));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void encx24j600_set_rxfilter_mode(struct encx24j600_priv *priv)
|
|
|
|
{
|
|
|
|
switch (priv->rxfilter) {
|
|
|
|
case RXFILTER_PROMISC:
|
|
|
|
encx24j600_set_bits(priv, MACON1, PASSALL);
|
|
|
|
encx24j600_write_reg(priv, ERXFCON, UCEN | MCEN | NOTMEEN);
|
|
|
|
break;
|
|
|
|
case RXFILTER_MULTI:
|
|
|
|
encx24j600_clr_bits(priv, MACON1, PASSALL);
|
|
|
|
encx24j600_write_reg(priv, ERXFCON, UCEN | CRCEN | BCEN | MCEN);
|
|
|
|
break;
|
|
|
|
case RXFILTER_NORMAL:
|
|
|
|
default:
|
|
|
|
encx24j600_clr_bits(priv, MACON1, PASSALL);
|
|
|
|
encx24j600_write_reg(priv, ERXFCON, UCEN | CRCEN | BCEN);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-07 18:09:05 +07:00
|
|
|
static void encx24j600_hw_init(struct encx24j600_priv *priv)
|
2015-10-07 03:37:46 +07:00
|
|
|
{
|
|
|
|
u16 macon2;
|
|
|
|
|
|
|
|
priv->hw_enabled = false;
|
|
|
|
|
|
|
|
/* PHY Leds: link status,
|
2015-10-23 02:09:04 +07:00
|
|
|
* LEDA: Link State + collision events
|
|
|
|
* LEDB: Link State + transmit/receive events
|
2015-10-07 03:37:46 +07:00
|
|
|
*/
|
2015-10-23 02:09:04 +07:00
|
|
|
encx24j600_update_reg(priv, EIDLED, 0xff00, 0xcb00);
|
2015-10-07 03:37:46 +07:00
|
|
|
|
|
|
|
/* Loopback disabled */
|
|
|
|
encx24j600_write_reg(priv, MACON1, 0x9);
|
|
|
|
|
|
|
|
/* interpacket gap value */
|
|
|
|
encx24j600_write_reg(priv, MAIPG, 0x0c12);
|
|
|
|
|
|
|
|
/* Write the auto negotiation pattern */
|
|
|
|
encx24j600_write_phy(priv, PHANA, PHANA_DEFAULT);
|
|
|
|
|
|
|
|
encx24j600_update_phcon1(priv);
|
|
|
|
encx24j600_check_link_status(priv);
|
|
|
|
|
|
|
|
macon2 = MACON2_RSV1 | TXCRCEN | PADCFG0 | PADCFG2 | MACON2_DEFER;
|
|
|
|
if ((priv->autoneg == AUTONEG_DISABLE) && priv->full_duplex)
|
|
|
|
macon2 |= FULDPX;
|
|
|
|
|
|
|
|
encx24j600_set_bits(priv, MACON2, macon2);
|
|
|
|
|
|
|
|
priv->rxfilter = RXFILTER_NORMAL;
|
|
|
|
encx24j600_set_rxfilter_mode(priv);
|
|
|
|
|
|
|
|
/* Program the Maximum frame length */
|
|
|
|
encx24j600_write_reg(priv, MAMXFL, MAX_FRAMELEN);
|
|
|
|
|
|
|
|
/* Init Tx pointers */
|
|
|
|
encx24j600_hw_init_tx(priv);
|
|
|
|
|
|
|
|
/* Init Rx pointers */
|
|
|
|
encx24j600_hw_init_rx(priv);
|
|
|
|
|
|
|
|
if (netif_msg_hw(priv))
|
|
|
|
encx24j600_dump_config(priv, "Hw is initialized");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void encx24j600_hw_enable(struct encx24j600_priv *priv)
|
|
|
|
{
|
|
|
|
/* Clear the interrupt flags in case was set */
|
|
|
|
encx24j600_clr_bits(priv, EIR, (PCFULIF | RXABTIF | TXABTIF | TXIF |
|
|
|
|
PKTIF | LINKIF));
|
|
|
|
|
|
|
|
/* Enable the interrupts */
|
|
|
|
encx24j600_write_reg(priv, EIE, (PCFULIE | RXABTIE | TXABTIE | TXIE |
|
|
|
|
PKTIE | LINKIE | INTIE));
|
|
|
|
|
|
|
|
/* Enable RX */
|
|
|
|
encx24j600_cmd(priv, ENABLERX);
|
|
|
|
|
|
|
|
priv->hw_enabled = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void encx24j600_hw_disable(struct encx24j600_priv *priv)
|
|
|
|
{
|
|
|
|
/* Disable all interrupts */
|
|
|
|
encx24j600_write_reg(priv, EIE, 0);
|
|
|
|
|
|
|
|
/* Disable RX */
|
|
|
|
encx24j600_cmd(priv, DISABLERX);
|
|
|
|
|
|
|
|
priv->hw_enabled = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int encx24j600_setlink(struct net_device *dev, u8 autoneg, u16 speed,
|
|
|
|
u8 duplex)
|
|
|
|
{
|
|
|
|
struct encx24j600_priv *priv = netdev_priv(dev);
|
|
|
|
int ret = 0;
|
|
|
|
|
|
|
|
if (!priv->hw_enabled) {
|
|
|
|
/* link is in low power mode now; duplex setting
|
|
|
|
* will take effect on next encx24j600_hw_init()
|
|
|
|
*/
|
|
|
|
if (speed == SPEED_10 || speed == SPEED_100) {
|
|
|
|
priv->autoneg = (autoneg == AUTONEG_ENABLE);
|
|
|
|
priv->full_duplex = (duplex == DUPLEX_FULL);
|
|
|
|
priv->speed = (speed == SPEED_100);
|
|
|
|
} else {
|
|
|
|
netif_warn(priv, link, dev, "unsupported link speed setting\n");
|
|
|
|
/*speeds other than SPEED_10 and SPEED_100 */
|
|
|
|
/*are not supported by chip */
|
|
|
|
ret = -EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
netif_warn(priv, link, dev, "Warning: hw must be disabled to set link mode\n");
|
|
|
|
ret = -EBUSY;
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void encx24j600_hw_get_macaddr(struct encx24j600_priv *priv,
|
|
|
|
unsigned char *ethaddr)
|
|
|
|
{
|
|
|
|
unsigned short val;
|
|
|
|
|
|
|
|
val = encx24j600_read_reg(priv, MAADR1);
|
|
|
|
|
|
|
|
ethaddr[0] = val & 0x00ff;
|
|
|
|
ethaddr[1] = (val & 0xff00) >> 8;
|
|
|
|
|
|
|
|
val = encx24j600_read_reg(priv, MAADR2);
|
|
|
|
|
|
|
|
ethaddr[2] = val & 0x00ffU;
|
|
|
|
ethaddr[3] = (val & 0xff00U) >> 8;
|
|
|
|
|
|
|
|
val = encx24j600_read_reg(priv, MAADR3);
|
|
|
|
|
|
|
|
ethaddr[4] = val & 0x00ffU;
|
|
|
|
ethaddr[5] = (val & 0xff00U) >> 8;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Program the hardware MAC address from dev->dev_addr.*/
|
|
|
|
static int encx24j600_set_hw_macaddr(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct encx24j600_priv *priv = netdev_priv(dev);
|
|
|
|
|
|
|
|
if (priv->hw_enabled) {
|
|
|
|
netif_info(priv, drv, dev, "Hardware must be disabled to set Mac address\n");
|
|
|
|
return -EBUSY;
|
|
|
|
}
|
|
|
|
|
|
|
|
mutex_lock(&priv->lock);
|
|
|
|
|
|
|
|
netif_info(priv, drv, dev, "%s: Setting MAC address to %pM\n",
|
|
|
|
dev->name, dev->dev_addr);
|
|
|
|
|
|
|
|
encx24j600_write_reg(priv, MAADR3, (dev->dev_addr[4] |
|
|
|
|
dev->dev_addr[5] << 8));
|
|
|
|
encx24j600_write_reg(priv, MAADR2, (dev->dev_addr[2] |
|
|
|
|
dev->dev_addr[3] << 8));
|
|
|
|
encx24j600_write_reg(priv, MAADR1, (dev->dev_addr[0] |
|
|
|
|
dev->dev_addr[1] << 8));
|
|
|
|
|
|
|
|
mutex_unlock(&priv->lock);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Store the new hardware address in dev->dev_addr, and update the MAC.*/
|
|
|
|
static int encx24j600_set_mac_address(struct net_device *dev, void *addr)
|
|
|
|
{
|
|
|
|
struct sockaddr *address = addr;
|
|
|
|
|
|
|
|
if (netif_running(dev))
|
|
|
|
return -EBUSY;
|
|
|
|
if (!is_valid_ether_addr(address->sa_data))
|
|
|
|
return -EADDRNOTAVAIL;
|
|
|
|
|
|
|
|
memcpy(dev->dev_addr, address->sa_data, dev->addr_len);
|
|
|
|
return encx24j600_set_hw_macaddr(dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int encx24j600_open(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct encx24j600_priv *priv = netdev_priv(dev);
|
|
|
|
|
|
|
|
int ret = request_threaded_irq(priv->ctx.spi->irq, NULL, encx24j600_isr,
|
|
|
|
IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
|
|
|
|
DRV_NAME, priv);
|
|
|
|
if (unlikely(ret < 0)) {
|
|
|
|
netdev_err(dev, "request irq %d failed (ret = %d)\n",
|
|
|
|
priv->ctx.spi->irq, ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
encx24j600_hw_disable(priv);
|
|
|
|
encx24j600_hw_init(priv);
|
|
|
|
encx24j600_hw_enable(priv);
|
|
|
|
netif_start_queue(dev);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int encx24j600_stop(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct encx24j600_priv *priv = netdev_priv(dev);
|
|
|
|
|
|
|
|
netif_stop_queue(dev);
|
|
|
|
free_irq(priv->ctx.spi->irq, priv);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void encx24j600_setrx_proc(struct kthread_work *ws)
|
|
|
|
{
|
|
|
|
struct encx24j600_priv *priv =
|
|
|
|
container_of(ws, struct encx24j600_priv, setrx_work);
|
|
|
|
|
|
|
|
mutex_lock(&priv->lock);
|
|
|
|
encx24j600_set_rxfilter_mode(priv);
|
|
|
|
mutex_unlock(&priv->lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void encx24j600_set_multicast_list(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct encx24j600_priv *priv = netdev_priv(dev);
|
|
|
|
int oldfilter = priv->rxfilter;
|
|
|
|
|
|
|
|
if (dev->flags & IFF_PROMISC) {
|
|
|
|
netif_dbg(priv, link, dev, "promiscuous mode\n");
|
|
|
|
priv->rxfilter = RXFILTER_PROMISC;
|
|
|
|
} else if ((dev->flags & IFF_ALLMULTI) || !netdev_mc_empty(dev)) {
|
|
|
|
netif_dbg(priv, link, dev, "%smulticast mode\n",
|
|
|
|
(dev->flags & IFF_ALLMULTI) ? "all-" : "");
|
|
|
|
priv->rxfilter = RXFILTER_MULTI;
|
|
|
|
} else {
|
|
|
|
netif_dbg(priv, link, dev, "normal mode\n");
|
|
|
|
priv->rxfilter = RXFILTER_NORMAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (oldfilter != priv->rxfilter)
|
2016-10-12 03:55:20 +07:00
|
|
|
kthread_queue_work(&priv->kworker, &priv->setrx_work);
|
2015-10-07 03:37:46 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void encx24j600_hw_tx(struct encx24j600_priv *priv)
|
|
|
|
{
|
|
|
|
struct net_device *dev = priv->ndev;
|
2016-12-12 20:29:09 +07:00
|
|
|
|
2015-10-07 03:37:46 +07:00
|
|
|
netif_info(priv, tx_queued, dev, "TX Packet Len:%d\n",
|
|
|
|
priv->tx_skb->len);
|
|
|
|
|
|
|
|
if (netif_msg_pktdata(priv))
|
|
|
|
dump_packet("TX", priv->tx_skb->len, priv->tx_skb->data);
|
|
|
|
|
|
|
|
if (encx24j600_read_reg(priv, EIR) & TXABTIF)
|
|
|
|
/* Last transmition aborted due to error. Reset TX interface */
|
|
|
|
encx24j600_reset_hw_tx(priv);
|
|
|
|
|
|
|
|
/* Clear the TXIF flag if were previously set */
|
|
|
|
encx24j600_clr_bits(priv, EIR, TXIF);
|
|
|
|
|
|
|
|
/* Set the data pointer to the TX buffer address in the SRAM */
|
|
|
|
encx24j600_write_reg(priv, EGPWRPT, ENC_TX_BUF_START);
|
|
|
|
|
|
|
|
/* Copy the packet into the SRAM */
|
|
|
|
encx24j600_raw_write(priv, WGPDATA, (u8 *)priv->tx_skb->data,
|
|
|
|
priv->tx_skb->len);
|
|
|
|
|
|
|
|
/* Program the Tx buffer start pointer */
|
|
|
|
encx24j600_write_reg(priv, ETXST, ENC_TX_BUF_START);
|
|
|
|
|
|
|
|
/* Program the packet length */
|
|
|
|
encx24j600_write_reg(priv, ETXLEN, priv->tx_skb->len);
|
|
|
|
|
|
|
|
/* Start the transmission */
|
|
|
|
encx24j600_cmd(priv, SETTXRTS);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void encx24j600_tx_proc(struct kthread_work *ws)
|
|
|
|
{
|
|
|
|
struct encx24j600_priv *priv =
|
|
|
|
container_of(ws, struct encx24j600_priv, tx_work);
|
|
|
|
|
|
|
|
mutex_lock(&priv->lock);
|
|
|
|
encx24j600_hw_tx(priv);
|
|
|
|
mutex_unlock(&priv->lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
static netdev_tx_t encx24j600_tx(struct sk_buff *skb, struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct encx24j600_priv *priv = netdev_priv(dev);
|
|
|
|
|
|
|
|
netif_stop_queue(dev);
|
|
|
|
|
|
|
|
/* save the timestamp */
|
2016-05-03 21:33:13 +07:00
|
|
|
netif_trans_update(dev);
|
2015-10-07 03:37:46 +07:00
|
|
|
|
|
|
|
/* Remember the skb for deferred processing */
|
|
|
|
priv->tx_skb = skb;
|
|
|
|
|
2016-10-12 03:55:20 +07:00
|
|
|
kthread_queue_work(&priv->kworker, &priv->tx_work);
|
2015-10-07 03:37:46 +07:00
|
|
|
|
|
|
|
return NETDEV_TX_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Deal with a transmit timeout */
|
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 21:23:51 +07:00
|
|
|
static void encx24j600_tx_timeout(struct net_device *dev, unsigned int txqueue)
|
2015-10-07 03:37:46 +07:00
|
|
|
{
|
|
|
|
struct encx24j600_priv *priv = netdev_priv(dev);
|
|
|
|
|
|
|
|
netif_err(priv, tx_err, dev, "TX timeout at %ld, latency %ld\n",
|
2016-05-03 21:30:59 +07:00
|
|
|
jiffies, jiffies - dev_trans_start(dev));
|
2015-10-07 03:37:46 +07:00
|
|
|
|
|
|
|
dev->stats.tx_errors++;
|
|
|
|
netif_wake_queue(dev);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int encx24j600_get_regs_len(struct net_device *dev)
|
|
|
|
{
|
|
|
|
return SFR_REG_COUNT;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void encx24j600_get_regs(struct net_device *dev,
|
|
|
|
struct ethtool_regs *regs, void *p)
|
|
|
|
{
|
|
|
|
struct encx24j600_priv *priv = netdev_priv(dev);
|
|
|
|
u16 *buff = p;
|
|
|
|
u8 reg;
|
|
|
|
|
|
|
|
regs->version = 1;
|
|
|
|
mutex_lock(&priv->lock);
|
|
|
|
for (reg = 0; reg < SFR_REG_COUNT; reg += 2) {
|
|
|
|
unsigned int val = 0;
|
|
|
|
/* ignore errors for unreadable registers */
|
|
|
|
regmap_read(priv->ctx.regmap, reg, &val);
|
|
|
|
buff[reg] = val & 0xffff;
|
|
|
|
}
|
|
|
|
mutex_unlock(&priv->lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void encx24j600_get_drvinfo(struct net_device *dev,
|
|
|
|
struct ethtool_drvinfo *info)
|
|
|
|
{
|
|
|
|
strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
|
|
|
|
strlcpy(info->version, DRV_VERSION, sizeof(info->version));
|
|
|
|
strlcpy(info->bus_info, dev_name(dev->dev.parent),
|
|
|
|
sizeof(info->bus_info));
|
|
|
|
}
|
|
|
|
|
2017-02-10 04:42:18 +07:00
|
|
|
static int encx24j600_get_link_ksettings(struct net_device *dev,
|
|
|
|
struct ethtool_link_ksettings *cmd)
|
2015-10-07 03:37:46 +07:00
|
|
|
{
|
|
|
|
struct encx24j600_priv *priv = netdev_priv(dev);
|
2017-02-10 04:42:18 +07:00
|
|
|
u32 supported;
|
2015-10-07 03:37:46 +07:00
|
|
|
|
2017-02-10 04:42:18 +07:00
|
|
|
supported = SUPPORTED_10baseT_Half | SUPPORTED_10baseT_Full |
|
2015-10-07 03:37:46 +07:00
|
|
|
SUPPORTED_100baseT_Half | SUPPORTED_100baseT_Full |
|
|
|
|
SUPPORTED_Autoneg | SUPPORTED_TP;
|
|
|
|
|
2017-02-10 04:42:18 +07:00
|
|
|
ethtool_convert_legacy_u32_to_link_mode(cmd->link_modes.supported,
|
|
|
|
supported);
|
|
|
|
|
|
|
|
cmd->base.speed = priv->speed;
|
|
|
|
cmd->base.duplex = priv->full_duplex ? DUPLEX_FULL : DUPLEX_HALF;
|
|
|
|
cmd->base.port = PORT_TP;
|
|
|
|
cmd->base.autoneg = priv->autoneg ? AUTONEG_ENABLE : AUTONEG_DISABLE;
|
2015-10-07 03:37:46 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-02-10 04:42:18 +07:00
|
|
|
static int
|
|
|
|
encx24j600_set_link_ksettings(struct net_device *dev,
|
|
|
|
const struct ethtool_link_ksettings *cmd)
|
2015-10-07 03:37:46 +07:00
|
|
|
{
|
2017-02-10 04:42:18 +07:00
|
|
|
return encx24j600_setlink(dev, cmd->base.autoneg,
|
|
|
|
cmd->base.speed, cmd->base.duplex);
|
2015-10-07 03:37:46 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
static u32 encx24j600_get_msglevel(struct net_device *dev)
|
|
|
|
{
|
|
|
|
struct encx24j600_priv *priv = netdev_priv(dev);
|
2016-12-12 20:29:09 +07:00
|
|
|
|
2015-10-07 03:37:46 +07:00
|
|
|
return priv->msg_enable;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void encx24j600_set_msglevel(struct net_device *dev, u32 val)
|
|
|
|
{
|
|
|
|
struct encx24j600_priv *priv = netdev_priv(dev);
|
2016-12-12 20:29:09 +07:00
|
|
|
|
2015-10-07 03:37:46 +07:00
|
|
|
priv->msg_enable = val;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const struct ethtool_ops encx24j600_ethtool_ops = {
|
|
|
|
.get_drvinfo = encx24j600_get_drvinfo,
|
|
|
|
.get_msglevel = encx24j600_get_msglevel,
|
|
|
|
.set_msglevel = encx24j600_set_msglevel,
|
|
|
|
.get_regs_len = encx24j600_get_regs_len,
|
|
|
|
.get_regs = encx24j600_get_regs,
|
2017-02-10 04:42:18 +07:00
|
|
|
.get_link_ksettings = encx24j600_get_link_ksettings,
|
|
|
|
.set_link_ksettings = encx24j600_set_link_ksettings,
|
2015-10-07 03:37:46 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct net_device_ops encx24j600_netdev_ops = {
|
|
|
|
.ndo_open = encx24j600_open,
|
|
|
|
.ndo_stop = encx24j600_stop,
|
|
|
|
.ndo_start_xmit = encx24j600_tx,
|
|
|
|
.ndo_set_rx_mode = encx24j600_set_multicast_list,
|
|
|
|
.ndo_set_mac_address = encx24j600_set_mac_address,
|
|
|
|
.ndo_tx_timeout = encx24j600_tx_timeout,
|
|
|
|
.ndo_validate_addr = eth_validate_addr,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int encx24j600_spi_probe(struct spi_device *spi)
|
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
struct net_device *ndev;
|
|
|
|
struct encx24j600_priv *priv;
|
2015-11-19 04:22:21 +07:00
|
|
|
u16 eidled;
|
2015-10-07 03:37:46 +07:00
|
|
|
|
|
|
|
ndev = alloc_etherdev(sizeof(struct encx24j600_priv));
|
|
|
|
|
|
|
|
if (!ndev) {
|
|
|
|
ret = -ENOMEM;
|
|
|
|
goto error_out;
|
|
|
|
}
|
|
|
|
|
|
|
|
priv = netdev_priv(ndev);
|
|
|
|
spi_set_drvdata(spi, priv);
|
|
|
|
dev_set_drvdata(&spi->dev, priv);
|
|
|
|
SET_NETDEV_DEV(ndev, &spi->dev);
|
|
|
|
|
|
|
|
priv->msg_enable = netif_msg_init(debug, DEFAULT_MSG_ENABLE);
|
|
|
|
priv->ndev = ndev;
|
|
|
|
|
|
|
|
/* Default configuration PHY configuration */
|
|
|
|
priv->full_duplex = true;
|
|
|
|
priv->autoneg = AUTONEG_ENABLE;
|
|
|
|
priv->speed = SPEED_100;
|
|
|
|
|
|
|
|
priv->ctx.spi = spi;
|
|
|
|
devm_regmap_init_encx24j600(&spi->dev, &priv->ctx);
|
|
|
|
ndev->irq = spi->irq;
|
|
|
|
ndev->netdev_ops = &encx24j600_netdev_ops;
|
|
|
|
|
|
|
|
mutex_init(&priv->lock);
|
|
|
|
|
|
|
|
/* Reset device and check if it is connected */
|
|
|
|
if (encx24j600_hw_reset(priv)) {
|
|
|
|
netif_err(priv, probe, ndev,
|
|
|
|
DRV_NAME ": Chip is not detected\n");
|
|
|
|
ret = -EIO;
|
|
|
|
goto out_free;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize the device HW to the consistent state */
|
2020-05-07 18:09:05 +07:00
|
|
|
encx24j600_hw_init(priv);
|
2015-10-07 03:37:46 +07:00
|
|
|
|
2016-10-12 03:55:20 +07:00
|
|
|
kthread_init_worker(&priv->kworker);
|
|
|
|
kthread_init_work(&priv->tx_work, encx24j600_tx_proc);
|
|
|
|
kthread_init_work(&priv->setrx_work, encx24j600_setrx_proc);
|
2015-10-07 03:37:46 +07:00
|
|
|
|
|
|
|
priv->kworker_task = kthread_run(kthread_worker_fn, &priv->kworker,
|
|
|
|
"encx24j600");
|
|
|
|
|
|
|
|
if (IS_ERR(priv->kworker_task)) {
|
|
|
|
ret = PTR_ERR(priv->kworker_task);
|
|
|
|
goto out_free;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the MAC address from the chip */
|
|
|
|
encx24j600_hw_get_macaddr(priv, ndev->dev_addr);
|
|
|
|
|
|
|
|
ndev->ethtool_ops = &encx24j600_ethtool_ops;
|
|
|
|
|
|
|
|
ret = register_netdev(ndev);
|
|
|
|
if (unlikely(ret)) {
|
|
|
|
netif_err(priv, probe, ndev, "Error %d initializing card encx24j600 card\n",
|
|
|
|
ret);
|
2020-05-07 22:13:20 +07:00
|
|
|
goto out_stop;
|
2015-10-07 03:37:46 +07:00
|
|
|
}
|
|
|
|
|
2015-11-19 04:22:21 +07:00
|
|
|
eidled = encx24j600_read_reg(priv, EIDLED);
|
|
|
|
if (((eidled & DEVID_MASK) >> DEVID_SHIFT) != ENCX24J600_DEV_ID) {
|
|
|
|
ret = -EINVAL;
|
|
|
|
goto out_unregister;
|
|
|
|
}
|
|
|
|
|
|
|
|
netif_info(priv, probe, ndev, "Silicon rev ID: 0x%02x\n",
|
|
|
|
(eidled & REVID_MASK) >> REVID_SHIFT);
|
|
|
|
|
2015-10-07 03:37:46 +07:00
|
|
|
netif_info(priv, drv, priv->ndev, "MAC address %pM\n", ndev->dev_addr);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
|
2015-11-19 04:22:21 +07:00
|
|
|
out_unregister:
|
|
|
|
unregister_netdev(priv->ndev);
|
2020-05-07 22:13:20 +07:00
|
|
|
out_stop:
|
|
|
|
kthread_stop(priv->kworker_task);
|
2015-10-07 03:37:46 +07:00
|
|
|
out_free:
|
|
|
|
free_netdev(ndev);
|
|
|
|
|
|
|
|
error_out:
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int encx24j600_spi_remove(struct spi_device *spi)
|
|
|
|
{
|
|
|
|
struct encx24j600_priv *priv = dev_get_drvdata(&spi->dev);
|
|
|
|
|
|
|
|
unregister_netdev(priv->ndev);
|
2020-05-07 22:13:20 +07:00
|
|
|
kthread_stop(priv->kworker_task);
|
2015-10-07 03:37:46 +07:00
|
|
|
|
|
|
|
free_netdev(priv->ndev);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2015-10-30 19:49:17 +07:00
|
|
|
static const struct spi_device_id encx24j600_spi_id_table[] = {
|
|
|
|
{ .name = "encx24j600" },
|
|
|
|
{ /* sentinel */ }
|
2015-10-07 03:37:46 +07:00
|
|
|
};
|
2015-10-30 19:49:18 +07:00
|
|
|
MODULE_DEVICE_TABLE(spi, encx24j600_spi_id_table);
|
2015-10-07 03:37:46 +07:00
|
|
|
|
|
|
|
static struct spi_driver encx24j600_spi_net_driver = {
|
|
|
|
.driver = {
|
|
|
|
.name = DRV_NAME,
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.bus = &spi_bus_type,
|
|
|
|
},
|
|
|
|
.probe = encx24j600_spi_probe,
|
|
|
|
.remove = encx24j600_spi_remove,
|
2015-10-30 19:49:17 +07:00
|
|
|
.id_table = encx24j600_spi_id_table,
|
2015-10-07 03:37:46 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
static int __init encx24j600_init(void)
|
|
|
|
{
|
|
|
|
return spi_register_driver(&encx24j600_spi_net_driver);
|
|
|
|
}
|
|
|
|
module_init(encx24j600_init);
|
|
|
|
|
|
|
|
static void encx24j600_exit(void)
|
|
|
|
{
|
|
|
|
spi_unregister_driver(&encx24j600_spi_net_driver);
|
|
|
|
}
|
|
|
|
module_exit(encx24j600_exit);
|
|
|
|
|
|
|
|
MODULE_DESCRIPTION(DRV_NAME " ethernet driver");
|
|
|
|
MODULE_AUTHOR("Jon Ringle <jringle@gridpoint.com>");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_ALIAS("spi:" DRV_NAME);
|