Commit a465fb1e authored by David S. Miller's avatar David S. Miller

Merge branch 'r8169-improve-user-message-handling'

Heiner Kallweit says:

====================
r8169: improve user message handling

Series improves few aspects of handling messages to users.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 4b4976a6 93882c6f
...@@ -59,9 +59,6 @@ ...@@ -59,9 +59,6 @@
#define FIRMWARE_8107E_2 "rtl_nic/rtl8107e-2.fw" #define FIRMWARE_8107E_2 "rtl_nic/rtl8107e-2.fw"
#define FIRMWARE_8125A_3 "rtl_nic/rtl8125a-3.fw" #define FIRMWARE_8125A_3 "rtl_nic/rtl8125a-3.fw"
#define R8169_MSG_DEFAULT \
(NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_IFUP | NETIF_MSG_IFDOWN)
/* Maximum number of multicast addresses to filter (vs. Rx-all-multicast). /* Maximum number of multicast addresses to filter (vs. Rx-all-multicast).
The RTL chips use a 64 element hash table based on the Ethernet CRC. */ The RTL chips use a 64 element hash table based on the Ethernet CRC. */
#define MC_FILTER_LIMIT 32 #define MC_FILTER_LIMIT 32
...@@ -179,10 +176,6 @@ static const struct pci_device_id rtl8169_pci_tbl[] = { ...@@ -179,10 +176,6 @@ static const struct pci_device_id rtl8169_pci_tbl[] = {
MODULE_DEVICE_TABLE(pci, rtl8169_pci_tbl); MODULE_DEVICE_TABLE(pci, rtl8169_pci_tbl);
static struct {
u32 msg_enable;
} debug = { -1 };
enum rtl_registers { enum rtl_registers {
MAC0 = 0, /* Ethernet hardware address. */ MAC0 = 0, /* Ethernet hardware address. */
MAC4 = 4, MAC4 = 4,
...@@ -604,7 +597,6 @@ struct rtl8169_private { ...@@ -604,7 +597,6 @@ struct rtl8169_private {
struct net_device *dev; struct net_device *dev;
struct phy_device *phydev; struct phy_device *phydev;
struct napi_struct napi; struct napi_struct napi;
u32 msg_enable;
enum mac_version mac_version; enum mac_version mac_version;
u32 cur_rx; /* Index into the Rx descriptor buffer of next Rx pkt. */ u32 cur_rx; /* Index into the Rx descriptor buffer of next Rx pkt. */
u32 cur_tx; /* Index into the Tx descriptor buffer of next Rx pkt. */ u32 cur_tx; /* Index into the Tx descriptor buffer of next Rx pkt. */
...@@ -646,8 +638,6 @@ typedef void (*rtl_generic_fct)(struct rtl8169_private *tp); ...@@ -646,8 +638,6 @@ typedef void (*rtl_generic_fct)(struct rtl8169_private *tp);
MODULE_AUTHOR("Realtek and the Linux r8169 crew <netdev@vger.kernel.org>"); MODULE_AUTHOR("Realtek and the Linux r8169 crew <netdev@vger.kernel.org>");
MODULE_DESCRIPTION("RealTek RTL-8169 Gigabit Ethernet driver"); MODULE_DESCRIPTION("RealTek RTL-8169 Gigabit Ethernet driver");
module_param_named(debug, debug.msg_enable, int, 0);
MODULE_PARM_DESC(debug, "Debug verbosity level (0=none, ..., 16=all)");
MODULE_SOFTDEP("pre: realtek"); MODULE_SOFTDEP("pre: realtek");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_FIRMWARE(FIRMWARE_8168D_1); MODULE_FIRMWARE(FIRMWARE_8168D_1);
...@@ -751,8 +741,10 @@ static bool rtl_loop_wait(struct rtl8169_private *tp, const struct rtl_cond *c, ...@@ -751,8 +741,10 @@ static bool rtl_loop_wait(struct rtl8169_private *tp, const struct rtl_cond *c,
return true; return true;
delay(d); delay(d);
} }
netif_err(tp, drv, tp->dev, "%s == %d (loop: %d, delay: %d).\n",
c->msg, !high, n, d); if (net_ratelimit())
netdev_err(tp->dev, "%s == %d (loop: %d, delay: %d).\n",
c->msg, !high, n, d);
return false; return false;
} }
...@@ -797,7 +789,8 @@ static bool name ## _check(struct rtl8169_private *tp) ...@@ -797,7 +789,8 @@ static bool name ## _check(struct rtl8169_private *tp)
static bool rtl_ocp_reg_failure(struct rtl8169_private *tp, u32 reg) static bool rtl_ocp_reg_failure(struct rtl8169_private *tp, u32 reg)
{ {
if (reg & 0xffff0001) { if (reg & 0xffff0001) {
netif_err(tp, drv, tp->dev, "Invalid ocp reg %x!\n", reg); if (net_ratelimit())
netdev_err(tp->dev, "Invalid ocp reg %x!\n", reg);
return true; return true;
} }
return false; return false;
...@@ -1580,20 +1573,6 @@ static void rtl8169_get_regs(struct net_device *dev, struct ethtool_regs *regs, ...@@ -1580,20 +1573,6 @@ static void rtl8169_get_regs(struct net_device *dev, struct ethtool_regs *regs,
rtl_unlock_work(tp); rtl_unlock_work(tp);
} }
static u32 rtl8169_get_msglevel(struct net_device *dev)
{
struct rtl8169_private *tp = netdev_priv(dev);
return tp->msg_enable;
}
static void rtl8169_set_msglevel(struct net_device *dev, u32 value)
{
struct rtl8169_private *tp = netdev_priv(dev);
tp->msg_enable = value;
}
static const char rtl8169_gstrings[][ETH_GSTRING_LEN] = { static const char rtl8169_gstrings[][ETH_GSTRING_LEN] = {
"tx_packets", "tx_packets",
"rx_packets", "rx_packets",
...@@ -1625,7 +1604,7 @@ DECLARE_RTL_COND(rtl_counters_cond) ...@@ -1625,7 +1604,7 @@ DECLARE_RTL_COND(rtl_counters_cond)
return RTL_R32(tp, CounterAddrLow) & (CounterReset | CounterDump); return RTL_R32(tp, CounterAddrLow) & (CounterReset | CounterDump);
} }
static bool rtl8169_do_counters(struct rtl8169_private *tp, u32 counter_cmd) static void rtl8169_do_counters(struct rtl8169_private *tp, u32 counter_cmd)
{ {
dma_addr_t paddr = tp->counters_phys_addr; dma_addr_t paddr = tp->counters_phys_addr;
u32 cmd; u32 cmd;
...@@ -1636,22 +1615,20 @@ static bool rtl8169_do_counters(struct rtl8169_private *tp, u32 counter_cmd) ...@@ -1636,22 +1615,20 @@ static bool rtl8169_do_counters(struct rtl8169_private *tp, u32 counter_cmd)
RTL_W32(tp, CounterAddrLow, cmd); RTL_W32(tp, CounterAddrLow, cmd);
RTL_W32(tp, CounterAddrLow, cmd | counter_cmd); RTL_W32(tp, CounterAddrLow, cmd | counter_cmd);
return rtl_udelay_loop_wait_low(tp, &rtl_counters_cond, 10, 1000); rtl_udelay_loop_wait_low(tp, &rtl_counters_cond, 10, 1000);
} }
static bool rtl8169_reset_counters(struct rtl8169_private *tp) static void rtl8169_reset_counters(struct rtl8169_private *tp)
{ {
/* /*
* Versions prior to RTL_GIGA_MAC_VER_19 don't support resetting the * Versions prior to RTL_GIGA_MAC_VER_19 don't support resetting the
* tally counters. * tally counters.
*/ */
if (tp->mac_version < RTL_GIGA_MAC_VER_19) if (tp->mac_version >= RTL_GIGA_MAC_VER_19)
return true; rtl8169_do_counters(tp, CounterReset);
return rtl8169_do_counters(tp, CounterReset);
} }
static bool rtl8169_update_counters(struct rtl8169_private *tp) static void rtl8169_update_counters(struct rtl8169_private *tp)
{ {
u8 val = RTL_R8(tp, ChipCmd); u8 val = RTL_R8(tp, ChipCmd);
...@@ -1659,16 +1636,13 @@ static bool rtl8169_update_counters(struct rtl8169_private *tp) ...@@ -1659,16 +1636,13 @@ static bool rtl8169_update_counters(struct rtl8169_private *tp)
* Some chips are unable to dump tally counters when the receiver * Some chips are unable to dump tally counters when the receiver
* is disabled. If 0xff chip may be in a PCI power-save state. * is disabled. If 0xff chip may be in a PCI power-save state.
*/ */
if (!(val & CmdRxEnb) || val == 0xff) if (val & CmdRxEnb && val != 0xff)
return true; rtl8169_do_counters(tp, CounterDump);
return rtl8169_do_counters(tp, CounterDump);
} }
static bool rtl8169_init_counter_offsets(struct rtl8169_private *tp) static void rtl8169_init_counter_offsets(struct rtl8169_private *tp)
{ {
struct rtl8169_counters *counters = tp->counters; struct rtl8169_counters *counters = tp->counters;
bool ret = false;
/* /*
* rtl8169_init_counter_offsets is called from rtl_open. On chip * rtl8169_init_counter_offsets is called from rtl_open. On chip
...@@ -1686,22 +1660,16 @@ static bool rtl8169_init_counter_offsets(struct rtl8169_private *tp) ...@@ -1686,22 +1660,16 @@ static bool rtl8169_init_counter_offsets(struct rtl8169_private *tp)
*/ */
if (tp->tc_offset.inited) if (tp->tc_offset.inited)
return true; return;
/* If both, reset and update fail, propagate to caller. */
if (rtl8169_reset_counters(tp))
ret = true;
if (rtl8169_update_counters(tp)) rtl8169_reset_counters(tp);
ret = true; rtl8169_update_counters(tp);
tp->tc_offset.tx_errors = counters->tx_errors; tp->tc_offset.tx_errors = counters->tx_errors;
tp->tc_offset.tx_multi_collision = counters->tx_multi_collision; tp->tc_offset.tx_multi_collision = counters->tx_multi_collision;
tp->tc_offset.tx_aborted = counters->tx_aborted; tp->tc_offset.tx_aborted = counters->tx_aborted;
tp->tc_offset.rx_missed = counters->rx_missed; tp->tc_offset.rx_missed = counters->rx_missed;
tp->tc_offset.inited = true; tp->tc_offset.inited = true;
return ret;
} }
static void rtl8169_get_ethtool_stats(struct net_device *dev, static void rtl8169_get_ethtool_stats(struct net_device *dev,
...@@ -1996,8 +1964,6 @@ static const struct ethtool_ops rtl8169_ethtool_ops = { ...@@ -1996,8 +1964,6 @@ static const struct ethtool_ops rtl8169_ethtool_ops = {
.get_link = ethtool_op_get_link, .get_link = ethtool_op_get_link,
.get_coalesce = rtl_get_coalesce, .get_coalesce = rtl_get_coalesce,
.set_coalesce = rtl_set_coalesce, .set_coalesce = rtl_set_coalesce,
.get_msglevel = rtl8169_get_msglevel,
.set_msglevel = rtl8169_set_msglevel,
.get_regs = rtl8169_get_regs, .get_regs = rtl8169_get_regs,
.get_wol = rtl8169_get_wol, .get_wol = rtl8169_get_wol,
.set_wol = rtl8169_set_wol, .set_wol = rtl8169_set_wol,
...@@ -2518,10 +2484,8 @@ static void rtl_request_firmware(struct rtl8169_private *tp) ...@@ -2518,10 +2484,8 @@ static void rtl_request_firmware(struct rtl8169_private *tp)
return; return;
rtl_fw = kzalloc(sizeof(*rtl_fw), GFP_KERNEL); rtl_fw = kzalloc(sizeof(*rtl_fw), GFP_KERNEL);
if (!rtl_fw) { if (!rtl_fw)
netif_warn(tp, ifup, tp->dev, "Unable to load firmware, out of memory\n");
return; return;
}
rtl_fw->phy_write = rtl_writephy; rtl_fw->phy_write = rtl_writephy;
rtl_fw->phy_read = rtl_readphy; rtl_fw->phy_read = rtl_readphy;
...@@ -2634,8 +2598,6 @@ static void rtl_set_rx_mode(struct net_device *dev) ...@@ -2634,8 +2598,6 @@ static void rtl_set_rx_mode(struct net_device *dev)
u32 tmp; u32 tmp;
if (dev->flags & IFF_PROMISC) { if (dev->flags & IFF_PROMISC) {
/* Unconditionally log net taps. */
netif_notice(tp, link, dev, "Promiscuous mode enabled\n");
rx_mode |= AcceptAllPhys; rx_mode |= AcceptAllPhys;
} else if (netdev_mc_count(dev) > MC_FILTER_LIMIT || } else if (netdev_mc_count(dev) > MC_FILTER_LIMIT ||
dev->flags & IFF_ALLMULTI || dev->flags & IFF_ALLMULTI ||
...@@ -3883,8 +3845,7 @@ static struct page *rtl8169_alloc_rx_data(struct rtl8169_private *tp, ...@@ -3883,8 +3845,7 @@ static struct page *rtl8169_alloc_rx_data(struct rtl8169_private *tp,
mapping = dma_map_page(d, data, 0, R8169_RX_BUF_SIZE, DMA_FROM_DEVICE); mapping = dma_map_page(d, data, 0, R8169_RX_BUF_SIZE, DMA_FROM_DEVICE);
if (unlikely(dma_mapping_error(d, mapping))) { if (unlikely(dma_mapping_error(d, mapping))) {
if (net_ratelimit()) netdev_err(tp->dev, "Failed to map RX DMA!\n");
netif_err(tp, drv, tp->dev, "Failed to map RX DMA!\n");
__free_pages(data, get_order(R8169_RX_BUF_SIZE)); __free_pages(data, get_order(R8169_RX_BUF_SIZE));
return NULL; return NULL;
} }
...@@ -4021,7 +3982,7 @@ static int rtl8169_tx_map(struct rtl8169_private *tp, const u32 *opts, u32 len, ...@@ -4021,7 +3982,7 @@ static int rtl8169_tx_map(struct rtl8169_private *tp, const u32 *opts, u32 len,
ret = dma_mapping_error(d, mapping); ret = dma_mapping_error(d, mapping);
if (unlikely(ret)) { if (unlikely(ret)) {
if (net_ratelimit()) if (net_ratelimit())
netif_err(tp, drv, tp->dev, "Failed to map TX data!\n"); netdev_err(tp->dev, "Failed to map TX data!\n");
return ret; return ret;
} }
...@@ -4187,7 +4148,8 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb, ...@@ -4187,7 +4148,8 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
txd_first = tp->TxDescArray + entry; txd_first = tp->TxDescArray + entry;
if (unlikely(!rtl_tx_slots_avail(tp, frags))) { if (unlikely(!rtl_tx_slots_avail(tp, frags))) {
netif_err(tp, drv, dev, "BUG! Tx Ring full when queue awake!\n"); if (net_ratelimit())
netdev_err(dev, "BUG! Tx Ring full when queue awake!\n");
goto err_stop_0; goto err_stop_0;
} }
...@@ -4349,9 +4311,9 @@ static void rtl8169_pcierr_interrupt(struct net_device *dev) ...@@ -4349,9 +4311,9 @@ static void rtl8169_pcierr_interrupt(struct net_device *dev)
pci_status_errs = pci_status_get_and_clear_errors(pdev); pci_status_errs = pci_status_get_and_clear_errors(pdev);
netif_err(tp, intr, dev, "PCI error (cmd = 0x%04x, status_errs = 0x%04x)\n", if (net_ratelimit())
pci_cmd, pci_status_errs); netdev_err(dev, "PCI error (cmd = 0x%04x, status_errs = 0x%04x)\n",
pci_cmd, pci_status_errs);
/* /*
* The recovery sequence below admits a very elaborated explanation: * The recovery sequence below admits a very elaborated explanation:
* - it seems to work; * - it seems to work;
...@@ -4469,8 +4431,9 @@ static int rtl_rx(struct net_device *dev, struct rtl8169_private *tp, u32 budget ...@@ -4469,8 +4431,9 @@ static int rtl_rx(struct net_device *dev, struct rtl8169_private *tp, u32 budget
dma_rmb(); dma_rmb();
if (unlikely(status & RxRES)) { if (unlikely(status & RxRES)) {
netif_info(tp, rx_err, dev, "Rx ERROR. status = %08x\n", if (net_ratelimit())
status); netdev_warn(dev, "Rx ERROR. status = %08x\n",
status);
dev->stats.rx_errors++; dev->stats.rx_errors++;
if (status & (RxRWT | RxRUNT)) if (status & (RxRWT | RxRUNT))
dev->stats.rx_length_errors++; dev->stats.rx_length_errors++;
...@@ -4761,8 +4724,7 @@ static int rtl_open(struct net_device *dev) ...@@ -4761,8 +4724,7 @@ static int rtl_open(struct net_device *dev)
rtl_hw_start(tp); rtl_hw_start(tp);
if (!rtl8169_init_counter_offsets(tp)) rtl8169_init_counter_offsets(tp);
netif_warn(tp, hw, dev, "counter reset/update failed\n");
phy_start(tp->phydev); phy_start(tp->phydev);
netif_start_queue(dev); netif_start_queue(dev);
...@@ -5342,7 +5304,6 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -5342,7 +5304,6 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
tp = netdev_priv(dev); tp = netdev_priv(dev);
tp->dev = dev; tp->dev = dev;
tp->pci_dev = pdev; tp->pci_dev = pdev;
tp->msg_enable = netif_msg_init(debug.msg_enable, R8169_MSG_DEFAULT);
tp->supports_gmii = ent->driver_data == RTL_CFG_NO_GBIT ? 0 : 1; tp->supports_gmii = ent->driver_data == RTL_CFG_NO_GBIT ? 0 : 1;
tp->eee_adv = -1; tp->eee_adv = -1;
tp->ocp_base = OCP_STD_PHY_BASE; tp->ocp_base = OCP_STD_PHY_BASE;
...@@ -5500,15 +5461,14 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -5500,15 +5461,14 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
if (rc) if (rc)
return rc; return rc;
netif_info(tp, probe, dev, "%s, %pM, XID %03x, IRQ %d\n", netdev_info(dev, "%s, %pM, XID %03x, IRQ %d\n",
rtl_chip_infos[chipset].name, dev->dev_addr, xid, rtl_chip_infos[chipset].name, dev->dev_addr, xid,
pci_irq_vector(pdev, 0)); pci_irq_vector(pdev, 0));
if (jumbo_max) if (jumbo_max)
netif_info(tp, probe, dev, netdev_info(dev, "jumbo features [frames: %d bytes, tx checksumming: %s]\n",
"jumbo features [frames: %d bytes, tx checksumming: %s]\n", jumbo_max, tp->mac_version <= RTL_GIGA_MAC_VER_06 ?
jumbo_max, tp->mac_version <= RTL_GIGA_MAC_VER_06 ? "ok" : "ko");
"ok" : "ko");
if (r8168_check_dash(tp)) if (r8168_check_dash(tp))
rtl8168_driver_start(tp); rtl8168_driver_start(tp);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment