Commit graph

728 commits

Author SHA1 Message Date
Heiner Kallweit
93882c6f21 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>
2020-05-01 12:53:06 -07:00
Heiner Kallweit
3bf6ff3cec r8169: remove "out of memory" error message from rtl_request_firmware
When preparing an unrelated change, checkpatch complained about this
redundant out-of-memory message. Therefore remove it.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-05-01 12:53:06 -07:00
Heiner Kallweit
d56f58cec9 r8169: simplify counter handling
The counter handling functions can only fail if rtl8169_do_counters()
times out. In the poll function we emit an error message in case of
timeout, therefore we don't have to propagate the timeout all the
way up just to print another message basically saying the same.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-05-01 12:53:06 -07:00
Heiner Kallweit
f773d5118b r8169: remove redundant driver message when entering promiscuous mode
Net core -  __dev_set_promiscuity - prints a message already when
promiscuous mode in entered/left, therefore we don't have to do this
in the driver too. Also the driver message would be misleading
(would be because "link" message level is disabled per default)
because it would print "promisc mode enabled" even if it's being
left. Reason is that __dev_change_flags() calls dev_set_rx_mode()
before touching the promisc flag.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-05-01 12:53:06 -07:00
Heiner Kallweit
ef891284b1 r8169: remove not needed parameter in rtl8169_set_magic_reg
Remove a not needed parameter in rtl8169_set_magic_reg.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-05-01 12:12:06 -07:00
Heiner Kallweit
838974e1e0 r8169: configure PME_SIGNAL for RTL8125 too
RTL8125 supports the same PME_SIGNAL handling as all later RTL8168
chip variants.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-30 20:51:30 -07:00
Heiner Kallweit
b410439ca3 r8169: improve max jumbo packet size definition
Sync definition of max jumbo packet size with vendor driver and reserve
22 bytes for VLAN ethernet header plus checksum.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-30 20:51:13 -07:00
Heiner Kallweit
81496b72e9 r8169: add check for invalid parameter combination in rtl_set_coalesce
Realtek provided information about a HW constraint that time limit must
not be set to 0 if the frame limit is >0. Add a check for this and
reject invalid parameter combinations.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-30 17:39:15 -07:00
Heiner Kallweit
2b3e48b665 r8169: improve rtl_set_coalesce
Use FIELD_PREP() to make the code better readable, and avoid the loop.
No functional change intended.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-30 17:39:15 -07:00
Heiner Kallweit
bdd2be3adb r8169: improve interrupt coalescing parameter handling
The chip supports only frame limits 0, 4, 8, .. 60 internally.
Returning EINVAL for all val % 4 != 0 seems to be a little bit too
unfriendly to the user. Therefore round up the frame limit to the next
supported value. In addition round up the time limit, else a very low
limit could be rounded down to 0, and interpreted as "ignore value"
by the chip.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-30 17:39:15 -07:00
Heiner Kallweit
cb9d97de05 r8169: improve rtl_coalesce_choose_scale
The time limit provided by userspace is multiplied with 1000,
what could result in an overflow. Therefore change the time limit
parameter unit from ns to us, and avoid the problematic operation.
If there's no matching scale because provided time limit is too big,
return ERANGE instead of EINVAL to provide a hint to the user what's
wrong.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-30 17:39:15 -07:00
Heiner Kallweit
6cf96dd427 r8169: improve rtl_get_coalesce
Use FIELD_GET() macro to make the code better readable. In addition
change the logic to round the time limit up, not down. Reason is that
a time limit <1us would be rounded to 0 currently, what would be
interpreted as "no time limit set".

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-30 17:39:15 -07:00
Heiner Kallweit
2815b30535 r8169: merge scale for tx and rx irq coalescing
Rx and tx scale are the same always. Simplify the code by using one
scale for rx and tx only.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-30 17:39:15 -07:00
Heiner Kallweit
ef2c0a78ae r8169: don't pass net_device to irq coalescing sub-functions
The net_device argument is just used to get a struct rtl8169_private
pointer via netdev_priv(). Therefore pass the struct rtl8169_private
pointer directly.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-30 17:39:15 -07:00
Heiner Kallweit
0c2006b29e r8169: improve error message if no dedicated PHY driver is found
There's a number of consumer mainboards where the BIOS leaves the PHY
in a state that it's reporting an invalid PHY ID. To detect such cases
add the PHY ID to the error message if no dedicated PHY driver is found.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-27 13:25:13 -07:00
Heiner Kallweit
10478283f2 r8169: improve configuring RxConfig register
Two bits in RxConfig are controlled by the following dev->feature's:
- NETIF_F_RXALL
- NETIF_F_HW_VLAN_CTAG_RX (since RTL8125)

We have to take care that RxConfig gets fully configured in
rtl_hw_start() after e.g. resume from hibernation. Therefore:

- Factor out setting the feature-controlled RxConfig bits to a new
  function rtl_set_rx_config_features() that is called from
  rtl8169_set_features() and rtl_hw_start().
- Don't deal with RX_VLAN_8125 in rtl_init_rxcfg(), it will be set
  by rtl_set_rx_config_features().
- Don't handle NETIF_F_RXALL in rtl_set_rx_mode().

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-27 11:48:47 -07:00
Heiner Kallweit
975e8505e6 r8169: improve handling CPCMD_MASK
It's sufficient to do the masking once in probe() for clearing
unwanted bits that may have been set by the BIOS.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-27 11:48:47 -07:00
Heiner Kallweit
0785dad480 r8169: use devm_mdiobus_register
Use new function devm_mdiobus_register() to simplify the driver.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-22 12:19:55 -07:00
Heiner Kallweit
794867ee67 r8169: change wmb to smb_wmb in rtl8169_start_xmit
A barrier is needed here to ensure that rtl_tx sees the descriptor
changes (DescOwn set) before the updated tp->cur_tx value. Else it may
wrongly assume that the transfer has been finished already. For this
purpose smp_wmb() is sufficient.

No separate barrier is needed for ordering the descriptor changes
with the MMIO doorbell write. The needed barrier is included in
the non-relaxed writel() used by rtl8169_doorbell().

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-20 16:03:48 -07:00
Heiner Kallweit
9d3679fe0f r8169: inline rtl8169_make_unusable_by_asic
Inline rtl8169_make_unusable_by_asic() and simplify it:
- Address field doesn't need to be poisoned because descriptor is
  owned by CPU now
- desc->opts1 is set by rtl8169_mark_to_asic() and rtl8169_rx_fill(),
  therefore we don't have to preserve any field parts.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-20 12:27:14 -07:00
Heiner Kallweit
2ac1fa439e r8169: inline rtl8169_mark_as_last_descriptor
rtl8169_mark_as_last_descriptor() has just one user, so inline it.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-20 12:27:14 -07:00
Heiner Kallweit
109f0cf23b r8169: remove PHY resume delay that is handled in the PHY driver now
The Realtek PHY driver takes care of adding the needed delay now,
therefore we can remove the delay here.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-20 11:12:29 -07:00
Heiner Kallweit
773235f4e1 r8169: add workaround for RTL8168evl TSO hw issues
Add workaround for hw issues with TSO on RTL8168evl. This workaround is
based on information I got from Realtek, and *should* allow to safely
enable TSO on this chip version.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-18 20:20:11 -07:00
Heiner Kallweit
0623b98b41 r8169: improve rtl8169_tso_csum_v2
Simplify the code and avoid the overhead of calling vlan_get_protocol().

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-18 20:20:11 -07:00
Heiner Kallweit
145192f83a r8169: use rtl8169_set_features in rtl8169_init_one
At that place in rtl_init_one() we can safely use rtl8169_set_features()
to configure the chip according to the default features.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-18 20:20:11 -07:00
Heiner Kallweit
85ab8b245e r8169: preserve VLAN setting on RTL8125 in rtl_init_rxcfg
So far we set RX_VLAN_8125 unconditionally, even if
NETIF_F_HW_VLAN_CTAG_RX may not be set. Don't touch these bits,
and let only rtl8169_set_features() control them.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-18 20:20:10 -07:00
Heiner Kallweit
a9b3d56830 r8169: remove NETIF_F_HIGHDMA from vlan_features
NETIF_F_HIGHDMA is added to vlan_features by register_netdev(),
therefore we can omit this here.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-18 20:20:10 -07:00
Heiner Kallweit
0360c046ca r8169: move setting OCP base to generic init code
Move setting the ocp_base to rtl_init_one(). Where supported the value
is always the same, and if not supported it doesn't hurt.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-18 20:20:10 -07:00
Heiner Kallweit
95099c569a r8169: change back SG and TSO to be disabled by default
There has been a number of reports that using SG/TSO on different chip
versions results in tx timeouts. However for a lot of people SG/TSO
works fine. Therefore disable both features by default, but allow users
to enable them. Use at own risk!

Fixes: 93681cd7d9 ("r8169: enable HW csum and TSO")
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-04-06 10:09:58 -07:00
Heiner Kallweit
b8447abc4c r8169: factor out rtl8169_tx_map
Factor out mapping the tx skb to a new function rtl8169_tx_map(). This
allows to remove redundancies, and rtl8169_get_txd_opts1() has only
one user left, so it can be inlined.
As a result rtl8169_xmit_frags() is significantly simplified, and in
rtl8169_start_xmit() the code is simplified and better readable.
No functional change intended.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-03-30 11:50:20 -07:00
Heiner Kallweit
4abc3c0481 r8169: improve handling of TD_MSS_MAX
If the mtu is greater than TD_MSS_MAX, then TSO is disabled, see
rtl8169_fix_features(). Because mss is less than mtu, we can't have
the case mss > TD_MSS_MAX in the TSO path.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-03-30 11:44:53 -07:00
David S. Miller
f0b5989745 Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
Minor comment conflict in mac80211.

Signed-off-by: David S. Miller <davem@davemloft.net>
2020-03-29 21:25:29 -07:00
Heiner Kallweit
2e8c339b49 r8169: fix PHY driver check on platforms w/o module softdeps
On Android/x86 the module loading infrastructure can't deal with
softdeps. Therefore the check for presence of the Realtek PHY driver
module fails. mdiobus_register() will try to load the PHY driver
module, therefore move the check to after this call and explicitly
check that a dedicated PHY driver is bound to the PHY device.

Fixes: f325937735 ("r8169: check that Realtek PHY driver module is loaded")
Reported-by: Chih-Wei Huang <cwhuang@android-x86.org>
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-03-27 15:56:34 -07:00
David S. Miller
9fb16955fb Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net
Overlapping header include additions in macsec.c

A bug fix in 'net' overlapping with the removal of 'version'
string in ena_netdev.c

Overlapping test additions in selftests Makefile

Overlapping PCI ID table adjustments in iwlwifi driver.

Signed-off-by: David S. Miller <davem@davemloft.net>
2020-03-25 18:58:11 -07:00
Heiner Kallweit
f13bc68131 r8169: re-enable MSI on RTL8168c
The original change fixed an issue on RTL8168b by mimicking the vendor
driver behavior to disable MSI on chip versions before RTL8168d.
This however now caused an issue on a system with RTL8168c, see [0].
Therefore leave MSI disabled on RTL8168b, but re-enable it on RTL8168c.

[0] https://bugzilla.redhat.com/show_bug.cgi?id=1792839

Fixes: 003bd5b4a7 ("r8169: don't use MSI before RTL8168d")
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-03-24 17:20:10 -07:00
Heiner Kallweit
6b02e407cb r8169: improve RTL8168b FIFO overflow workaround
So far only the reset bit it set, but the handler executing the reset
is not scheduled. Therefore nothing will happen until some other action
schedules the handler. Improve this by ensuring that the handler is
scheduled.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-03-23 21:38:21 -07:00
Heiner Kallweit
3f6ca6c739 r8169: improve rtl_schedule_task
The current implementation makes the implicit assumption that if a bit
is set, then the work is scheduled already. Remove the need for this
implicit assumption and call schedule_work() always. It will check
internally whether the work is scheduled already.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-03-23 21:38:21 -07:00
Heiner Kallweit
e18958c6a2 r8169: simplify rtl_task
Currently rtl_task() is designed to handle a large number of tasks.
However we have just one, so we can remove some overhead.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-03-23 21:38:21 -07:00
Heiner Kallweit
aba53204ce r8169: add new helper rtl8168g_enable_gphy_10m
Factor out setting GPHY 10M to new helper rtl8168g_enable_gphy_10m.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-03-23 21:27:10 -07:00
Jakub Kicinski
b604eb31a4 net: r8169: reject unsupported coalescing params
Set ethtool_ops->supported_coalesce_params to let
the core reject unsupported coalescing parameters.

This driver did not previously reject unsupported parameters.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Acked-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-03-14 21:13:55 -07:00
Heiner Kallweit
314a9cbbfb r8169: simplify getting stats by using netdev_stats_to_stats64
Let netdev_stats_to_stats64() do the copy work for us.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-03-10 16:23:44 -07:00
Heiner Kallweit
047521d7b1 r8169: let rtl8169_mark_to_asic clear rx descriptor field opts2
Clearing opts2 belongs to preparing the descriptor for DMA engine use.
Therefore move it into rtl8169_mark_to_asic().

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-03-10 16:23:23 -07:00
Heiner Kallweit
101438729d r8169: remove now unneeded barrier in rtl_tx
Until ae84bc1873 ("r8169: don't use bit LastFrag in tx descriptor
after send") we used to access another bit in the descriptor, therefore
it seems the barrier was needed. Since this commit DescOwn is the
only bit we're interested in, so the barrier isn't needed any longer.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-03-09 19:07:42 -07:00
Heiner Kallweit
22d352c51e r8169: simplify usage of rtl8169_unmap_tx_skb
Simplify the parameters taken by rtl8169_unmap_tx_skb, this makes
usage of this function easier to read and understand.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-03-09 19:07:42 -07:00
Heiner Kallweit
6a41f2b2f1 r8169: ensure tx_skb is fully reset after calling rtl8169_unmap_tx_skb
So far tx_skb->skb is the only member of the two structs that is not
reset. Make understanding the code easier by resetting both structs
completely in rtl8169_unmap_tx_skb.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-03-09 19:07:42 -07:00
Heiner Kallweit
a0e6650bdd r8169: convert while to for loop in rtl_tx
Slightly improve the code by converting this while to a for loop.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-03-09 19:07:42 -07:00
Heiner Kallweit
2864a883f9 r8169: use pci_status_get_and_clear_errors
Use new helper pci_status_get_and_clear_errors() to simplify the code.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-03-04 14:21:00 -08:00
Heiner Kallweit
90760b21ae r8169: add PCI_STATUS_PARITY to PCI status error bits
In preparation of factoring out PCI_STATUS error bit handling let drivers
use the same collection of error bits. To facilitate bisecting we do this
in a separate patch per affected driver. For the r8169 driver we have to
add PCI_STATUS_PARITY to the error bits.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-03-04 14:21:00 -08:00
Heiner Kallweit
9020845fb5 r8169: improve rtl8169_start_xmit
Only call rtl8169_xmit_frags() if the skb is actually fragmented.
This avoid a small overhead for non-fragmented skb's, and it allows
to simplify rtl8169_xmit_frags() a little.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-02-23 17:17:57 -08:00
Heiner Kallweit
2045e158fc r8169: remove RTL_EVENT_NAPI constants
These constants are used in one place only, so we can remove them and
use the values directly.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
2020-02-22 21:56:07 -08:00