Skip to content

Commit 93882c6

Browse files
hkallweitdavem330
authored andcommitted
r8169: switch from netif_xxx message functions to netdev_xxx
Considering the few messages we have in the driver, there's not really a benefit in being able to control them on a message type level. Therefore simplify the code and switch to the netdev_xxx message functions. In addition add net_ratelimit() to messages that can be printed from a hot path. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 3bf6ff3 commit 93882c6

1 file changed

Lines changed: 22 additions & 46 deletions

File tree

‎drivers/net/ethernet/realtek/r8169_main.c‎

Lines changed: 22 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,6 @@
5959
#define FIRMWARE_8107E_2 "rtl_nic/rtl8107e-2.fw"
6060
#define FIRMWARE_8125A_3 "rtl_nic/rtl8125a-3.fw"
6161

62-
#define R8169_MSG_DEFAULT \
63-
(NETIF_MSG_DRV | NETIF_MSG_PROBE | NETIF_MSG_IFUP | NETIF_MSG_IFDOWN)
64-
6562
/* Maximum number of multicast addresses to filter (vs. Rx-all-multicast).
6663
The RTL chips use a 64 element hash table based on the Ethernet CRC. */
6764
#define MC_FILTER_LIMIT 32
@@ -179,10 +176,6 @@ static const struct pci_device_id rtl8169_pci_tbl[] = {
179176

180177
MODULE_DEVICE_TABLE(pci, rtl8169_pci_tbl);
181178

182-
static struct {
183-
u32 msg_enable;
184-
} debug = { -1 };
185-
186179
enum rtl_registers {
187180
MAC0 = 0, /* Ethernet hardware address. */
188181
MAC4 = 4,
@@ -604,7 +597,6 @@ struct rtl8169_private {
604597
struct net_device *dev;
605598
struct phy_device *phydev;
606599
struct napi_struct napi;
607-
u32 msg_enable;
608600
enum mac_version mac_version;
609601
u32 cur_rx; /* Index into the Rx descriptor buffer of next Rx pkt. */
610602
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);
646638

647639
MODULE_AUTHOR("Realtek and the Linux r8169 crew <netdev@vger.kernel.org>");
648640
MODULE_DESCRIPTION("RealTek RTL-8169 Gigabit Ethernet driver");
649-
module_param_named(debug, debug.msg_enable, int, 0);
650-
MODULE_PARM_DESC(debug, "Debug verbosity level (0=none, ..., 16=all)");
651641
MODULE_SOFTDEP("pre: realtek");
652642
MODULE_LICENSE("GPL");
653643
MODULE_FIRMWARE(FIRMWARE_8168D_1);
@@ -751,8 +741,10 @@ static bool rtl_loop_wait(struct rtl8169_private *tp, const struct rtl_cond *c,
751741
return true;
752742
delay(d);
753743
}
754-
netif_err(tp, drv, tp->dev, "%s == %d (loop: %d, delay: %d).\n",
755-
c->msg, !high, n, d);
744+
745+
if (net_ratelimit())
746+
netdev_err(tp->dev, "%s == %d (loop: %d, delay: %d).\n",
747+
c->msg, !high, n, d);
756748
return false;
757749
}
758750

@@ -797,7 +789,8 @@ static bool name ## _check(struct rtl8169_private *tp)
797789
static bool rtl_ocp_reg_failure(struct rtl8169_private *tp, u32 reg)
798790
{
799791
if (reg & 0xffff0001) {
800-
netif_err(tp, drv, tp->dev, "Invalid ocp reg %x!\n", reg);
792+
if (net_ratelimit())
793+
netdev_err(tp->dev, "Invalid ocp reg %x!\n", reg);
801794
return true;
802795
}
803796
return false;
@@ -1580,20 +1573,6 @@ static void rtl8169_get_regs(struct net_device *dev, struct ethtool_regs *regs,
15801573
rtl_unlock_work(tp);
15811574
}
15821575

1583-
static u32 rtl8169_get_msglevel(struct net_device *dev)
1584-
{
1585-
struct rtl8169_private *tp = netdev_priv(dev);
1586-
1587-
return tp->msg_enable;
1588-
}
1589-
1590-
static void rtl8169_set_msglevel(struct net_device *dev, u32 value)
1591-
{
1592-
struct rtl8169_private *tp = netdev_priv(dev);
1593-
1594-
tp->msg_enable = value;
1595-
}
1596-
15971576
static const char rtl8169_gstrings[][ETH_GSTRING_LEN] = {
15981577
"tx_packets",
15991578
"rx_packets",
@@ -1985,8 +1964,6 @@ static const struct ethtool_ops rtl8169_ethtool_ops = {
19851964
.get_link = ethtool_op_get_link,
19861965
.get_coalesce = rtl_get_coalesce,
19871966
.set_coalesce = rtl_set_coalesce,
1988-
.get_msglevel = rtl8169_get_msglevel,
1989-
.set_msglevel = rtl8169_set_msglevel,
19901967
.get_regs = rtl8169_get_regs,
19911968
.get_wol = rtl8169_get_wol,
19921969
.set_wol = rtl8169_set_wol,
@@ -3868,8 +3845,7 @@ static struct page *rtl8169_alloc_rx_data(struct rtl8169_private *tp,
38683845

38693846
mapping = dma_map_page(d, data, 0, R8169_RX_BUF_SIZE, DMA_FROM_DEVICE);
38703847
if (unlikely(dma_mapping_error(d, mapping))) {
3871-
if (net_ratelimit())
3872-
netif_err(tp, drv, tp->dev, "Failed to map RX DMA!\n");
3848+
netdev_err(tp->dev, "Failed to map RX DMA!\n");
38733849
__free_pages(data, get_order(R8169_RX_BUF_SIZE));
38743850
return NULL;
38753851
}
@@ -4006,7 +3982,7 @@ static int rtl8169_tx_map(struct rtl8169_private *tp, const u32 *opts, u32 len,
40063982
ret = dma_mapping_error(d, mapping);
40073983
if (unlikely(ret)) {
40083984
if (net_ratelimit())
4009-
netif_err(tp, drv, tp->dev, "Failed to map TX data!\n");
3985+
netdev_err(tp->dev, "Failed to map TX data!\n");
40103986
return ret;
40113987
}
40123988

@@ -4172,7 +4148,8 @@ static netdev_tx_t rtl8169_start_xmit(struct sk_buff *skb,
41724148
txd_first = tp->TxDescArray + entry;
41734149

41744150
if (unlikely(!rtl_tx_slots_avail(tp, frags))) {
4175-
netif_err(tp, drv, dev, "BUG! Tx Ring full when queue awake!\n");
4151+
if (net_ratelimit())
4152+
netdev_err(dev, "BUG! Tx Ring full when queue awake!\n");
41764153
goto err_stop_0;
41774154
}
41784155

@@ -4334,9 +4311,9 @@ static void rtl8169_pcierr_interrupt(struct net_device *dev)
43344311

43354312
pci_status_errs = pci_status_get_and_clear_errors(pdev);
43364313

4337-
netif_err(tp, intr, dev, "PCI error (cmd = 0x%04x, status_errs = 0x%04x)\n",
4338-
pci_cmd, pci_status_errs);
4339-
4314+
if (net_ratelimit())
4315+
netdev_err(dev, "PCI error (cmd = 0x%04x, status_errs = 0x%04x)\n",
4316+
pci_cmd, pci_status_errs);
43404317
/*
43414318
* The recovery sequence below admits a very elaborated explanation:
43424319
* - it seems to work;
@@ -4454,8 +4431,9 @@ static int rtl_rx(struct net_device *dev, struct rtl8169_private *tp, u32 budget
44544431
dma_rmb();
44554432

44564433
if (unlikely(status & RxRES)) {
4457-
netif_info(tp, rx_err, dev, "Rx ERROR. status = %08x\n",
4458-
status);
4434+
if (net_ratelimit())
4435+
netdev_warn(dev, "Rx ERROR. status = %08x\n",
4436+
status);
44594437
dev->stats.rx_errors++;
44604438
if (status & (RxRWT | RxRUNT))
44614439
dev->stats.rx_length_errors++;
@@ -5326,7 +5304,6 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
53265304
tp = netdev_priv(dev);
53275305
tp->dev = dev;
53285306
tp->pci_dev = pdev;
5329-
tp->msg_enable = netif_msg_init(debug.msg_enable, R8169_MSG_DEFAULT);
53305307
tp->supports_gmii = ent->driver_data == RTL_CFG_NO_GBIT ? 0 : 1;
53315308
tp->eee_adv = -1;
53325309
tp->ocp_base = OCP_STD_PHY_BASE;
@@ -5484,15 +5461,14 @@ static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
54845461
if (rc)
54855462
return rc;
54865463

5487-
netif_info(tp, probe, dev, "%s, %pM, XID %03x, IRQ %d\n",
5488-
rtl_chip_infos[chipset].name, dev->dev_addr, xid,
5489-
pci_irq_vector(pdev, 0));
5464+
netdev_info(dev, "%s, %pM, XID %03x, IRQ %d\n",
5465+
rtl_chip_infos[chipset].name, dev->dev_addr, xid,
5466+
pci_irq_vector(pdev, 0));
54905467

54915468
if (jumbo_max)
5492-
netif_info(tp, probe, dev,
5493-
"jumbo features [frames: %d bytes, tx checksumming: %s]\n",
5494-
jumbo_max, tp->mac_version <= RTL_GIGA_MAC_VER_06 ?
5495-
"ok" : "ko");
5469+
netdev_info(dev, "jumbo features [frames: %d bytes, tx checksumming: %s]\n",
5470+
jumbo_max, tp->mac_version <= RTL_GIGA_MAC_VER_06 ?
5471+
"ok" : "ko");
54965472

54975473
if (r8168_check_dash(tp))
54985474
rtl8168_driver_start(tp);

0 commit comments

Comments
 (0)