aboutsummaryrefslogtreecommitdiffstats
path: root/target/linux/generic/files/drivers/net/phy/ar8327.c
Commit message (Collapse)AuthorAgeFilesLines
* treewide: rename POWER_ON_STRIP registerSungbo Eo2020-07-251-7/+7
| | | | | | | | | | AR8327 datasheet[1] calls the register at address 0x0010 "Power-on Strapping Register". As it has nothing to do with "strip", let's rename it to "POWER_ON_STRAP" to make it easier to grasp. [1] https://lafibre.info/images/doc/201106_spec_AR8327.pdf Signed-off-by: Sungbo Eo <mans0n@gorani.run>
* generic ar8xxx: increase VLAN table for AR83x7David Bauer2019-11-301-2/+2
| | | | | | | | | | | | The Atheros AR8327 and AR8337 have (according to their datasheet) a VLAN table with a maximum of 4096 entries. Currently, there's a hard limit of 128 VLANs, which is the same as for most other Atheros switches. Increase this limit only for the AR83x7 series and modify some shared functions to allow them to work with a variable max VLAN count. Signed-off-by: David Bauer <mail@david-bauer.net>
* generic: ar8216: group MIB counters and use two basic ones only by defaultChuanhong Guo2019-05-201-0/+7
| | | | | | | | | | | | | | | | | There are too many MIB counters that almost nobody needs since commit d6366ce3665f ("generic: ar8216: mib_work_func: read all port mibs everytime"). In the worker function to poll MIB data, it deals with all ports instead of only one port every time, which introduces too many mdio operations that it becomes a heavy CPU load even on not-emulated MDIO bus. This commit groups MIB counters and enable only TxBytes and RxGoodBytes by default (both of which are necessary to get swconfig led working.) and adds an swconfig attribute to allow enabling all counters if users need them. Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
* generic: ar8216: add mib_poll_interval switch attributeChuanhong Guo2019-05-201-0/+7
| | | | | | | | | | | | | | This allows specifying interval of polling MIB counters from userspace and allow completely turning off MIB counter support by setting mib_poll_interval to 0. Since MIB counter polling is a heavy CPU load for GPIO emulated MDIO bus, disable this behavior by default. Those who wants to use swconfig LEDs can enable them with qca,mib-poll-interval dts property or with swconfig command. Fixes: FS#2230 ("kworker spikes 100% cpu every 2 second.") Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
* generic: ar8216: add support for get_port_stats()Chuanhong Guo2019-03-241-11/+6
| | | | | | | | | | | | | | | | | | | | | | | Partially reverts commit eff3549c5883a9abc5dbff00c084cabbcfdf4437. AR7240 and AR9341 have buggy hardware switch LED trigger. The AR7240 one doesn't blink and the blinking of port0/port5 is reversed on AR9341 if we swap PHY0 and PHY4. (Only blinking is reversed, which means LED for PHY0 will lit when PHY0 is link up and will blink when PHY4 has active link and vice versa.) On these two chips a software swconfig LED trigger is required. This commit adds swconfig port stats back but: 1. move checking of mib_t/rxb_id into ar8xxx_chip since we can't distinguish ar7240sw and ar8216 using only chip id. 2. don't update mib counter in get_port_stat. This function is called every 0.01s and this capturing procedure will take up a lot of CPU. We already have a mib_work_func updating mib counters every 2s so return the saved counter instead of fetching new data. The blinking rate will be weird but it should solve the previously mentioned CPU time problem. Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
* generic: ar8216: add device struct into struct ar8xxx_privChuanhong Guo2019-03-241-2/+2
| | | | | | dev has been taken up by switch_dev so it's named pdev instead. Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
* generic: ar8216: ar8327: kill warningsChuanhong Guo2019-01-131-3/+3
| | | | | | This fixed warnings caused by returning value in a void function Signed-off-by: Chuanhong Guo <gch981213@gmail.com>
* kernel: ar83xx: Add support for three GMAC's connectionRam Chandra Jangir2018-12-061-0/+44
| | | | | | | | | | | | | We have IPQ8064 AP161 board which has three GMAC's * RGMII x2 * SGMII x1. The existing ar8327 driver does not have support for three GMAC's connection, hence this change adds support for the same. This has been verified on AP148 and AP161 board. Signed-off-by: xiaofeis <xiaofeis@codeaurora.org> Signed-off-by: Ram Chandra Jangir <rjangir@codeaurora.org>
* kernel: ar8xxx: get_arl_table now shows all ports of an entryGünther Kelleter2018-11-261-8/+2
| | | | | | | Multicast ARL entries can have multiple destination ports. Get and dump all destination ports of each entry, not just the lowest. Signed-off-by: Günther Kelleter <guenther.kelleter@devolo.de>
* generic: revert workarounds for AR8337 switchMathias Kresin2018-08-231-41/+1
| | | | | | | | | | | | | The intention of 967b6be118e3 ("ar8327: Add workarounds for AR8337 switch") was to remove the register fixups for AR8337. But instead they were removed for AR8327. The RGMII RX delay is forced even if the port is used as phy instead of mac, which results in no package flow at least for one board. Fixes: FS#1664 Signed-off-by: Mathias Kresin <dev@kresin.me>
* ar8216: reduce latency even further for ar8327 chipsFelix Fietkau2018-04-081-2/+4
| | | | Signed-off-by: Felix Fietkau <nbd@nbd.name>
* kernel: ar83xx: remove stray leading spaceJohn Crispin2018-02-201-3/+3
| | | | Signed-off-by: John Crispin <john@phrozen.org>
* kernel: ar83xx: add support to configure per port VLAN priorityTan Hong Hui2018-02-201-0/+48
| | | | | | | | | Add support to allow for per switch port VLAN priority (PCP) bits for the ar8327/8337 chip using the swconfig utility. Tested on Netgear R7800 Signed-off-by: Tan Hong Hui <hhtan72@yahoo.com>
* generic: drop support for get_port_stats() on ar8xxxThibaut VARENE2017-09-131-0/+9
| | | | | | | | | | | | | | | | The implementation is not efficient on ar8xxx switches. It triggers high CPU load and degrades device performance. The high CPU load has been traced down to the ar8xxx_reg_wait() call in ar8xxx_mib_op(), which has to usleep_range() till the MIB busy flag set by the request to update the MIB counter is cleared. This commit removes the get_port_stats() code introduced in 4d8a66d and leaves a note for future hacker's beware. Fixes: FS#1004 Signed-off-by: Thibaut VARENE <hacks@slashdirt.org>
* generic: provide get_port_stats() on ar8xxx switchesThibaut VARENE2017-09-011-0/+1
| | | | | | | | | | | | | This patch provides a generic switch_dev_ops 'get_port_stats()' callback by taping into the relevant port MIB counters. The implementation uses a generic callback that select the correct MIB counter index based on chip version. This callback is used by swconfig_leds led trigger to blink LEDs with port network traffic. Signed-off-by: Thibaut VARENE <hacks@slashdirt.org>
* ar8327: Add workarounds for AR8337 switch.Vittorio Gambaletta2017-03-301-1/+41
| | | | | | | | | | | | | | | | RGMII RX delay setting needs to be always specified for AR8337 to avoid port 5 RX hang on high traffic / flood conditions. Also, the HOL registers that set per-port and per-packet-priority buffer sizes are updated with the reduced values suggested by the QCA switch team. Finally, AR8327 reserved register fixups are disabled for the AR8337. This patch is adapted from the Code Aurora QSDK, but with magic values mapped to proper defines. Signed-off-by: Vittorio Gambaletta <openwrt@vittgam.net>
* Revert "kernel: ar8327/ar8337: disable ARL access code to avoid lockups ↵Stijn Tintel2017-02-221-6/+0
| | | | | | | | | | | (FS#384)" This reverts commit ec1a695daa7390a6c24e3b28d3956f194cba2cb5. Revert the workaround, the problem was properly fixed in 237454991618e0e8b7ceb8a8a2a43fca12c1a454. Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
* kernel: update phy drivers for 4.9Felix Fietkau2017-02-031-4/+4
| | | | | | add backport patches for older kernels Signed-off-by: Felix Fietkau <nbd@nbd.name>
* kernel: ar8327/ar8337: disable ARL access code to avoid lockups (FS#384)Jo-Philipp Wich2017-01-161-0/+6
| | | | | | | | | | Running ar8327_get_arl_entry() early after boot leads to MDIO related system lockups on several devices using this driver. Since dumping the ARL table contens is an optional, uncritical feature, simply disable the code for now. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
* net: ar8327: modify some configuration of switchPavel Kubelun2016-12-011-4/+12
| | | | | | | | | | | | | | | | Imported from https://source.codeaurora.org/quic/qsdk/system/openwrt/commit/?h=korg/linux-3.4.y/release/arugula_bb_cs&id=2be4f8a8b205ae1a37db44839864451ebe893e6e Signed-off-by: Pavel Kubelun <be.dissent@gmail.com> Enable flow control of LAN and WAN ports to get better performance. Setup pvid as 0 for all ports during initialisation to avoid confusion during system or switch INIT. Disable PORT MAC before config MAC to avoid it work abnormal. This change is for IR-054144, IR-057315. Change-Id: I345f3dffa59ad3f97150e09692723da12a7b1067 Signed-off-by: Zou Shunxiang <shunxian@codeaurora.org> Signed-off-by: xiaofeis <xiaofeis@codeaurora.org>
* net: ar8327: replace sprintf() by scnprintf()Pavel Kubelun2016-12-011-2/+1
| | | | | | | | | | | | | | | | | Import from https://chromium.googlesource.com/chromiumos/third_party/kernel/+/fd0c41c7b9327ce003f44df38ce42556fb177b17%5E%21/#F0 Signed-off-by: Pavel Kubelun <be.dissent@gmail.com> CHROMIUM: drivers: ar8216: replace sprintf() by scnprintf() BUG=chrome-os-partner:33096 TEST=none Change-Id: Ib82035c9f2769a86d3e90f9573a09e5700ff5676 Signed-off-by: Mathieu Olivari <mathieu@codeaurora.org> Reviewed-on: https://chromium-review.googlesource.com/232829 Reviewed-by: Matthias Kaehlcke <mka@chromium.org> Tested-by: Toshi Kikuchi <toshik@chromium.org> Reviewed-by: Toshi Kikuchi <toshik@chromium.org>
* net: ar8327: remove unnecessary spinlocksPavel Kubelun2016-12-011-4/+0
| | | | | | | | | | | | | | | | | Import from https://chromium.googlesource.com/chromiumos/third_party/kernel/+/541c15f8dd02ddce07e0a462a0c2572d8398bccc%5E%21/#F0 Signed-off-by: Pavel Kubelun <be.dissent@gmail.com> CHROMIUM: drivers: ar8216: remove unnecessary spinlocks BUG=chrome-os-partner:33096 TEST=none Change-Id: Ia1b51258504501863fd3298717cc923a1baf34ca Signed-off-by: Mathieu Olivari <mathieu@codeaurora.org> Reviewed-on: https://chromium-review.googlesource.com/232828 Reviewed-by: Matthias Kaehlcke <mka@chromium.org> Reviewed-by: Toshi Kikuchi <toshik@chromium.org> Tested-by: Toshi Kikuchi <toshik@chromium.org>
* treewide: replace nbd@openwrt.org with nbd@nbd.nameFelix Fietkau2016-06-071-1/+1
| | | | Signed-off-by: Felix Fietkau <nbd@nbd.name>
* AR8216: improve mmd register accessJohn Crispin2016-03-041-7/+3
| | | | | | | | | | | Combine all bus operations for one MMD access in one function. Protecting all these bus operations with one lock also helps to avoid potential issues due to bus operations intercepting the register and data write. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> SVN-Revision: 48914
* AR8216: make ARL age time configurableJohn Crispin2016-03-041-0/+9
| | | | | | | | | | | | | | | | | The default TTL for address resolution table entries is 5 minutes for all members of the AR8216 family. This can cause issues if e.g. Wifi clients roam to another AP and their MAC appears on another switch port suddenly. Then the client may not be reachable until the old ARL entry expires. I would have expected the switch to invalidate old entries if it detects the same MAC on another port. But that's not the case. Therefore make the TTL for ARL entries configurable. The effective TTL will always be a multiple of 7 seconds. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> SVN-Revision: 48913
* ar8327: add IGMP Snooping supportFelix Fietkau2016-01-171-0/+167
| | | | | | | | | | | | | | | This add support for IGMP Snooping on atheros switches (disabled by default), which avoids flooding the network with multicast data. Tested on TL-WDR4300: disabling IGMP Snooping results in multicast flooding on each specific port, enabling it back again prevents each port from receiving all multicast packets. Partially based on: http://patchwork.ozlabs.org/patch/418122/ Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com> SVN-Revision: 48268
* ar8216: rework/fix AR8337 MAC swap handlingFelix Fietkau2015-12-201-3/+3
| | | | | | | | | | | | | | In r45970 the MAC swap handling was made opt-in, however some boards have been forgotten during the conversion. Since the reference design uses this MAC swapping, and pretty much all known boards using this chip seem to do so too, enabling the swapping is a more reasonable default than leaving it disabled. Change the code to still allow boards to opt-out of this. Signed-off-by: Felix Fietkau <nbd@openwrt.org> SVN-Revision: 47956
* ar8216: add swconfig attributes for ARL table flushingFelix Fietkau2015-07-151-0/+12
| | | | | | | | Add swconfig attributes for flushing the ARL table globally or per port. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> SVN-Revision: 46382
* ar8216: add ARL table flushing per portFelix Fietkau2015-07-151-0/+20
| | | | | | | | | | | | | Adds functions for flushing ARL table entries per port. Successfully tested on AR8327. Implementation for AR8216/AR8236/AR8316 is based on the AR8236 datasheet and assumes that the three chips share a common ATU register layout. Compile-tested only for AR8216/AR8236/AR8316. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> SVN-Revision: 46380
* ar8216: Fix problem with AR8337 MAC swap handlingFelix Fietkau2015-06-141-3/+3
| | | | | | | | | | | | | | | | | | | | | AR8337 supports a configuration bit to swap MAC0 and MAC6. Currently this is set in general if an AR8337 is detected and causes issues with devices using an AR8334 (internally an AR8337, just less chip pins). And it might even cause issues with AR8337-based devices with different board designs. Swapping the MAC's however isn't needed for AR8337 in general. It's just needed in case of certain board designs (affected devices seem to be based on Atheros reference board AP135/136-010). Therefore this configuration bit should be moved to platform data. The patch includes the needed changes to the device initialization code of affected devices. Hopefully I didn't miss any .. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> SVN-Revision: 45970
* ar8216: prefix mii_xxx functions to avoid kernel namespace pollutionFelix Fietkau2015-01-241-10/+10
| | | | | | | | | Prefix the exported mii_xxx32 functions with ar8xxx_ to avoid kernel namespace pollution. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> SVN-Revision: 44105
* ar8216: add swconfig attribute to display ARL table on AR8327/AR8337Felix Fietkau2015-01-241-0/+81
| | | | | | | | | | | | | | Add global read-only swconfig attribute "arl_table" to display the address resolution table. So far the chip-specific part is implemented for AR8327/AR8337 only as I don't have the datasheets for the other AR8XXX chips. Successfully tested on TL-WDR4300 (AR8327rev2) and TL-WDR4900 (AR8327rev4). Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> SVN-Revision: 44104
* ar8216: fix ATU flushingFelix Fietkau2015-01-241-1/+2
| | | | | | | | | | | | | | | | | | The functionality to flush the address translation table contains two bugs which luckily compensate each other. 1. Just setting the operation is not sufficient to perform the flushing. The "active" bit needs to be set to actually trigger an action. For the vtu operations this is implemented correctly. 2. ar8xxx_phy_read_status is called every 2s by the phy state machine to check for link changes. This would have caused an ATU flush every 2s. Fix the chip-specific ATU flush functions and remove the ATU flush call from ar8xxx_phy_read_status. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> SVN-Revision: 44101
* ar8216: display flow control info in swconfig get_link in case of ↵Felix Fietkau2015-01-181-1/+17
| | | | | | | | | | | | | | | | | | autonegatiation too The swconfig get_link attribute (at least) on AR8327/AR8337 doesn't consider the autonegotiated flow control. AR8327/AR8337 provide the info about autonegotiated rx/tx flow control in bits 10 and 11 of the port status register. Use these values to display info about autonegotiated rx/tx flow control as part of the get_link attribute. Successfully tested on TL-WDR4900 (AR8327 rev.4) and TL-WDR4300 (AR8327 rev.2). Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> SVN-Revision: 44023
* ar8216: add 802.3az EEE info to swconfig get_link attributeFelix Fietkau2015-01-181-0/+24
| | | | | | | | | | | | | AR8327/AR8337 allow to read the result of EEE autonegotiation. If EEE is autonegotiated between the link partners, display this as part of the swconfig get_link attribute. eee100: 100MBit EEE supported by both link partners eee1000: 1GBit EEE supported by both link partners Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> SVN-Revision: 44022
* ar8216: introduce enable_eee swconfig attribute to control 802.3az EEE per portFelix Fietkau2015-01-181-12/+101
| | | | | | | | | | | | | | | | Users reported network issues with AR8327 which turned out to be caused by EEE not working correctly with certain link partners (ticket 14597). The workaround was to disable EEE on all ports (changeset 41577). The issue was with certain link partners only, therefore this patch allows to control usage of EEE per port via swconfig. Still the default is to initially disable EEE on all ports. Successfully tested on a TL-WDR4900 (AR8327 rev.4) Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> SVN-Revision: 44021
* ar8216: introduce ar8xxx_reg_clear complementing ar8xxx_reg_setJohn Crispin2015-01-171-6/+4
| | | | | | | | Introduce ar8xxx_reg_clear complementing ar8xxx_reg_set. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> SVN-Revision: 44004
* ar8216: replace ar8xxx_rmw with ar8xxx_reg_set where appropriateJohn Crispin2015-01-171-4/+2
| | | | | | | | Replace ar8xxx_rmw with ar8xxx_reg_set where appropriate. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> SVN-Revision: 44003
* ar8216: define all switch_addr structs as constJohn Crispin2015-01-171-3/+3
| | | | | | | | Define all switch_addr structs as const. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> SVN-Revision: 44002
* ar8216: factor out AR8327/AR8337-specific driver code into ar8327.cFelix Fietkau2015-01-051-0/+1029
Move all AR8327/AR8337-specific driver code into a separate source file ar8327.c and adjust patches so that ar8327.c is compiled if CONFIG_AR8216_PHY is set. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> SVN-Revision: 43845