Commit Graph

62 Commits (22f9afa118a4536a331a4a2b4d40f9d454249378)

Author SHA1 Message Date
Petr Štetiar 22f9afa118 ar71xx: ag71xx: Replace duplicate debugging code with simple function call
ag71xx_dump_regs is used in code several times, and is providing same
output.

Signed-off-by: Petr Štetiar <ynezz@true.cz>
6 years ago
David Bauer f4f99ec973 ar71xx: fix QCA955X SGMII link loss
The QCA955X is affected by a hardware bug which causes link-loss of the
SGMII link between SoC and PHY. This happens on change of link-state or
speed.

It is not really known what causes this bug. It definitely occurs when
using a AR8033 Gigabit Ethernet PHY.

Qualcomm solves this Bug in a similar fashion. We need to apply the fix
on a per-device base via platform-data as performing the fixup work will
break connectivity in case the SGMII interface is connected to a Switch.

This bug was first proposed to be fixed by Sven Eckelmann in 2016.
 https://patchwork.ozlabs.org/patch/604782/

Based-on-patch-by: Sven Eckelmann <sven.eckelmann@open-mesh.com>
Signed-off-by: David Bauer <mail@david-bauer.net>
6 years ago
Felix Fietkau f62d2b9549 ar71xx: remove pdata->fifo_cfg*
The values are the same for all chipsets that use it

Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
Rosen Penev 810659a22c ag71xx: Move timestamp struct member outside of struct.
With this change, the timestamp variable is only used in ag71xx_check_dma_stuck. Small tx speedup.

Based on a Qualcomm commit. ag->timestamp = jiffies was not replaced with netif_trans_update(dev) because of this quote:

It should be noted that after this series several instances
of netif_trans_update() are useless (if they occur in
.ndo_start_xmit and driver doesn't set LLTX flag -- stack already
did an update).

From: http://lists.openwall.net/netdev/2016/05/03/87

Signed-off-by: Rosen Penev <rosenp@gmail.com>
6 years ago
Felix Fietkau 798497c66e ar71xx: use global timestamp for hang check
Shrink the size of struct ag71xx_buf to 8 bytes, which improves cache
footprint

Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
Felix Fietkau 31e6016d2e ar71xx: only access device stats in tx handler if packets were processed
Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
Felix Fietkau 890e7458b0 ar71xx: allocate rx/tx descriptor/buffers in one chunk
Reduces false sharing due to cache aliases

Signed-off-by: Felix Fietkau <nbd@nbd.name>
6 years ago
Gabor Juhos 8f44c8086b ar71xx: remove obsolete '< KERNEL_VERSION(4, 2, 0)' check
Because the oldest supported kernel version on the ar71xx target is 4.4,
the condition that the kernel version is smaller than 4.2.0 is always
false. Remove the obsolete check from ag71xx_main.c to clean up the code
a bit.

Signed-off-by: Gabor Juhos <juhosg@freemail.hu>
6 years ago
Vittorio Gambaletta d40a358136
ag71xx: Fix rx ring buffer stall on small packets flood on qca956x and qca953x.
Backported from Code Aurora QSDK

Signed-off-by: Vittorio Gambaletta <openwrt@vittgam.net>
7 years ago
Rosen Penev 524d103e7e Revert "ag71xx: Switch from driver to kernel macro for NAPI_WEIGHT."
The motivation for this was misguided. It turns out tuning the NAPI weight could be useful for testing purposes. Therefore reverting.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
7 years ago
Rosen Penev e555153807 ag71xx: Switch from driver to kernel macro for NAPI_WEIGHT.
NAPI_POLL_WEIGHT was introduced in the kernel for exactly this purpose 5 years ago.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
7 years ago
Felix Fietkau 3db529d5cc Revert "ar71xx: Add GRO support to ag71xx"
This reverts commit 13e5e47369.
This commit causes a severe regression in LAN->WAN routing performance
for several devices. This appears to be caused by the extra requirement
to validate the SKB checksum early in the rx path, which the ethernet
hardware does not do

Signed-off-by: Felix Fietkau <nbd@nbd.name>
7 years ago
Rosen Penev 13e5e47369 ar71xx: Add GRO support to ag71xx
On a TL-WN710N, this patch increases iperf performance from ~92.5 to ~93.5 mbps. Keep in mind the WN710N is a 100mbps device. I expect greater numbers from gigabit devices.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
7 years ago
Felix Fietkau 02a9a74d17 ar71xx: fix ethernet driver fast reset issue causing tx timeouts
Signed-off-by: Felix Fietkau <nbd@nbd.name>
8 years ago
Stephen Walker 900da27c91 ar71xx: add software transmit timestamp support
Add software transmit timestamp and ethtool (-T) timestamp support

Signed-off-by: Stephen Walker <stephendwalker+github@gmail.com>
8 years ago
Felix Fietkau f9e7ffe73b ar71xx: prevent spurious ethernet resets from dma hang check false positives
Signed-off-by: Felix Fietkau <nbd@nbd.name>
8 years ago
Felix Fietkau 75b2105cd3 ar71xx: rename ethernet pdata->builtin_switch to use_flow_control
Signed-off-by: Felix Fietkau <nbd@nbd.name>
8 years ago
Felix Fietkau 3bf3512673 Revert "ar71xx: prevent spurious ethernet resets from dma hang check false positives"
This reverts commit 3d58d7f053.
8 years ago
Felix Fietkau 3d58d7f053 ar71xx: prevent spurious ethernet resets from dma hang check false positives
Signed-off-by: Felix Fietkau <nbd@nbd.name>
8 years ago
Felix Fietkau 26b8db2537 ar71xx: enable flow control for ethernet MACs with built-in switch
Should fix LAN speed issues on some devices. This is an updated version
of the previously reverted commit with the same name.
It improves the check for MACs connected to a built-in switch

Signed-off-by: Felix Fietkau <nbd@nbd.name>
8 years ago
Felix Fietkau 7c02ecdd35 Revert "ar71xx: enable flow control for ethernet MACs with built-in switch"
This reverts commit 1beb5bec64.

It was found to cause the WAN port to fail on some AR934x devices

Signed-off-by: Felix Fietkau <nbd@nbd.name>
8 years ago
Felix Fietkau 1beb5bec64 ar71xx: enable flow control for ethernet MACs with built-in switch
Should fix LAN speed issues on some devices

Signed-off-by: Felix Fietkau <nbd@nbd.name>
8 years ago
Felix Fietkau 29bbc6e6be ar71xx: reset ethernet tx ring on fast reset to prevent packet loss / irq issues
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 48753
8 years ago
Felix Fietkau 11ca71cfdb ag71xx: store ring size order instead of ring size to avoid div/mod
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 48693
8 years ago
Felix Fietkau b7a2c533da ag71xx: optimize icache footprint of the receive poll function
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 48691
8 years ago
Felix Fietkau 2067f7f1de ar71xx: use page fragment API in the ethernet driver
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 48578
8 years ago
Felix Fietkau 5c5c60fec4 ar71xx: fix ethernet MAC reset on DMA hang
Fully reset the chip like on a full up/down, but without the PHY
statemachine restart.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 48228
9 years ago
Felix Fietkau cf2cf43717 ar71xx: extend ethernet DMA stuck check to all ar724x (and newer) chips
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 48227
9 years ago
Felix Fietkau 6505dc3367 ar71xx: clean up ethernet tx queue after reset, wake queues when done - fixes hangs reported in #18922
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 47892
9 years ago
John Crispin 3b14473968 ar71xx: ag71xx remove IRQF_DISABLED
no-op since 2.6.35
removed in Kernel 4.1
see https://lwn.net/Articles/380931/

Signed-off-by: Dirk Neukirchen <dirkneukirchen@web.de>

SVN-Revision: 46280
9 years ago
Felix Fietkau a1b8ee0307 ar71xx: return limit as number of processed frames when re-scheduling NAPI poll
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 45971
9 years ago
Felix Fietkau 8c6f1412b1 ar71xx: improve ethernet driver cache footprint by removing an unnecessary pointer
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 43588
10 years ago
John Crispin 59e7999a44 ag71xx: replace delay with sleep calls
I don't see that we're in an atomic context so there's no need to
busy-wait. Therefore replace the delay with sleep calls.
See also Documentation/timers/timers-howto.txt. It states:
"In general, use of mdelay is discouraged and code should
be refactored to allow for the use of msleep."

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>

SVN-Revision: 43539
10 years ago
Felix Fietkau 1961f8cdb7 ar71xx: ack completed tx descriptors only after the full frame has been completed
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 42457
10 years ago
Felix Fietkau 60eeadd0ba ar71xx: re-enable descriptor splitting on ar716x after the previous bugfixes (#13072)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 42429
10 years ago
Felix Fietkau 2da2317fed ar71xx: fix off-by-one error in packet descriptor splitting (patch from #13072)
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 42428
10 years ago
Felix Fietkau 926f000b99 ar71xx: disable ethernet descriptor splitting for now, as it seems to cause tx hangs in some setups
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 42333
10 years ago
Felix Fietkau 2c680151e4 ar71xx: split packets into multiple descriptors on ar716x
This improves performance when doing concurrent rx/tx on a single
ethernet MAC, e.g. when routing between VLANs.

Fixes #13072

Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 42328
10 years ago
Gabor Juhos 30ebad2dee ar71xx: ag71xx: increase calculated max frame length value
The r39147 commit introduces a regression: at lease on some routers
with ar8216 switch large packets get lost if 802.1q tagged port is
used on the interface connected to the aforementioned switch.

The r39147 changes code in the way so interface is set to accept
packets no longer than max ethernet frame length for a given mtu.

Unfortunately ar8216 has a feature: it sends two additional bytes
as a packet header and those this header needs to be added to the
max frame length. Otherwise long enough packets get lost.

The problem only manuifests itself if interface is used in vlan
tagged mode. If interface is untagged then ar8216's header fits
into space used by 802.1q tag and not packets are lost.

Include two additional bytes in the max frame length calculation
to fix the issue.

This patch is tested and works with Trendnet TEW-632BRP.

Signed-off-by Nikolay Martynov <mar.kolya@gmail.com>
Patchwork: http://patchwork.openwrt.org/patch/4656/
[juhosg:
  - simplify the patch to include the additional bytes of the
    switch header unconditionally,
  - change subject and update commit message]
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>

SVN-Revision: 39219
11 years ago
Gabor Juhos 35d601f974 ar71xx: ag71xx: calculate max frame len register value from the MTU
Set the MAX_FRAME_LEN register to zero in ag71xx_hw_init()
and write the correct value into that from the ag71xx_open()
and ag71xx_fast_reset() functions.

Also recalculate the RX buffer size based on the actual
maximum frame length value to optimize memory allocation.
Additionaly, disallow to change the MTU value while the
interface it running.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>

SVN-Revision: 39147
11 years ago
Gabor Juhos 9e7d77de2d ar71xx: ag71xx: add ag71xx_max_frame_len() helper
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>

SVN-Revision: 39146
11 years ago
Gabor Juhos 2c4e3cf33a ar71xx: ag71xx: get max_frame_len and desc_pktlen_mask from platform data
This will allow to use SoC specific values for both.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>

SVN-Revision: 39145
11 years ago
Gabor Juhos 9be1e508f9 ar71xx: ag71xx: store descriptor packet length mask in ag71xx struct
The currently used bitmask is not correct for all SoCs.
Introduce a new field in struct ag71xx and store the
bitmask in that. Use the current value for now, it will
be adjusted for each SoCs in further patches.

Aslo use the new field directly in the ag71xx_rx_packets
and ag71xx_hard_start_xmit() functions and remove the
ag71xx_desc_pktlen() helper.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>

SVN-Revision: 39144
11 years ago
Gabor Juhos 31de995025 ar71xx: ag71xx: compute the RX buffer size from the maximum frame size
Currently, the AG71XX_RX_PKT_SIZE value limits the received
frame size to 1514/1516 bytes with/without a VLAN header
respectively. However the hardware limit is controlled by
the value the AG71XX_REG_MAC_MFL register which contains
the value of the max_frame_len field.

Compute the RX buffer size from the max_frame_len field
to get rid of the 1514/1516 byte limitation. Also remove
the unused AG71XX_RX_PKT_SIZE definition.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>

SVN-Revision: 39121
11 years ago
Gabor Juhos b35e0da0f4 ar71xx: ag71xx: store RX buffer size in the ag71xx struct
This allows to change the value dynamically.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>

SVN-Revision: 39120
11 years ago
Gabor Juhos 6072e777e9 ar71xx: ag71xx: store maximum frame length in the ag71xx struct
This will allow to use different values for the
different SoCs.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>

SVN-Revision: 39117
11 years ago
Gabor Juhos ec09569b17 ar71xx: ag71xx: fix ag71xx_probe error path
Signed-off-by: Catalin Patulea <cat@vv.carleton.ca>
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>

SVN-Revision: 38716
11 years ago
Gabor Juhos 7bd3a7bc7b ar71xx: ag71xx: fix a race involving netdev registration
In particular, phy_connect before register_netdev. This is because
register_netdev runs the netdev notifiers, which can race with the rest of
the initialization in ag71xx_probe. In my case this manifested in two ways:

1) If ag71xx is compiled as a module and inserted after netifd has started,
   netifd is notified by register_netdev before the call to
   ag71xx_phy_connect. netifd tries to bring the interface up, which calls
   ag71xx_open, which in turn enters ag71xx_phy_start. This keys off
   ag->phy_dev (which is still NULL) and thinks this is a fixed-link board,
   and enters ag71xx_link_adjust. This looks at ag->speed which is not yet
   initialized and hits the BUG() in the switch (ag->speed) in
   ag71xx_link_adjust.

   This is the wrong code path for ag71xx_phy_start - my board has PHYs that
   need to be brought up with phy_start. Doing ag71xx_phy_connect before
   register_netdev ensures that ag->phy_dev is non-NULL before
   ag71xx_phy_start is ever called.

2) When ag71xx is built into the kernel, and netconsole is enabled, there
   is a gap in the initial burst of replayed printks right after the netdev
   comes up. My assumption is that netconsole is also triggered by a netdev
   notifier, and part of this printk burst happens before the call into
   ag71xx_phy_connect, so part of the burst is lost while the PHY comes up.
   This patch fixes the gap - all the printks before eth0 comes up are bursted
   in full when netconsole initializes.

ag71xx_phy_connect_xxx no longer runs with a registered netdev, so the
logging has been adjusted accordingly to avoid "unregistered net_device" or
"eth%d" messages in dmesg.

Signed-off-by: Catalin Patulea <cat@vv.carleton.ca>
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>

SVN-Revision: 38689
11 years ago
Felix Fietkau f43b4ea962 ar71xx: ethernet: cache skb->len in the tx function to avoid accessing it again in completion
Improves ethernet performance, especially during bridging

Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 37761
11 years ago
Felix Fietkau 53c3b2a193 ar71xx: fix typo
Signed-off-by: Felix Fietkau <nbd@openwrt.org>

SVN-Revision: 37759
11 years ago