aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/etherswitch/arswitch/arswitch.c
Commit message (Collapse)AuthorAgeFilesLines
* IfAPI: Finish etherswitch driver conversionsJustin Hibbits2025-06-251-1/+1
| | | | | | | These drivers are not compiled by default, so were missed in the conversion. Sponsored by: Juniper Networks, Inc.
* etherswitch: Cleanup detach and delete of child devices during detachJohn Baldwin2025-01-021-4/+5
| | | | | | | Call bus_generic_detach first and return any error. Remove no longer needed individual device_delete_child calls. Differential Revision: https://reviews.freebsd.org/D47970
* Replace calls to bus_generic_attach with bus_attach_childrenJohn Baldwin2024-12-061-6/+1
| | | | | Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D47675
* Replace calls to bus_generic_probe with bus_identify_childrenJohn Baldwin2024-12-061-1/+1
| | | | | Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D47674
* net: Remove unneeded NULL check for the allocated ifnetZhenlei Huang2024-06-281-6/+0
| | | | | | | | | | | Change 4787572d0580 made if_alloc_domain() never fail, then also do the wrappers if_alloc(), if_alloc_dev(), and if_gethandle(). No functional change intended. Reviewed by: kp, imp, glebius, stevek MFC after: 2 weeks Differential Revision: https://reviews.freebsd.org/D45740
* etherswitch: Use device_set_desc(f)()Mark Johnston2024-06-021-6/+3
| | | | | | No functional change intended. MFC after: 1 week
* sys: Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-161-2/+0
| | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
* arswitch(4): Remove support for AR{7240,9340} found in MIPS SoCs onlyMarius Strobl2023-08-091-27/+1
| | | | | | | | With the general removal of MIPS support there's no longer a need to support these integrated switches. Approved by: adrian Differential Revision: https://reviews.freebsd.org/D41394
* etherswitch/arswitch: correct version detectionMichael Zhilin2023-08-081-1/+1
| | | | | | | | During porting of etherswitch to NetBSD mistypo was discovered in Atheros switch version detection. Reported by: Hiroki Mori yamori813@yahoo.co.jp MFC after: 1 week
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-05-121-1/+1
| | | | | | | | | The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause. Discussed with: pfg MFC After: 3 days Sponsored by: Netflix
* etherswitch: Clean up whitespace after IfAPI conversionJustin Hibbits2023-01-311-2/+2
| | | | | Sponsored by: Juniper Networks, Inc. Fixes: 2e6a8c1ae
* Mechanically convert etherswitch drivers to IfAPIJustin Hibbits2023-01-241-13/+13
| | | | | | Reviewed by: kd Sponsored by: Juniper Networks, Inc. Differential Revision: https://reviews.freebsd.org/D37813
* etherswitch drivers: Remove unused devclass arguments to DRIVER_MODULE.John Baldwin2022-05-091-2/+1
|
* Remove unused etherswitch_devclass.John Baldwin2022-05-091-1/+1
|
* Remove unused mdio_devclass.John Baldwin2022-05-061-1/+1
|
* Remove unused miibus_devclass and miibus_fdt_devclass.John Baldwin2022-05-061-1/+1
|
* [arswitch] Implement the switch MAC address fetch API.Adrian Chadd2018-02-061-0/+47
| | | | | | | | | | | | The placeholders are here for some future "set" MAC address API. Tested: * AR9340 switch * AR8327 switch Notes: svn path=/head/; revision=328924
* [arswitch] Break out of the loop upon any error, not just -1.Adrian Chadd2018-02-051-1/+1
| | | | | | | This fixes the AR9340 "unimplemented" thingy for now. Notes: svn path=/head/; revision=328871
* [arswitch] begin tidying up the learning and ATU management, introduce ATU APIs.Adrian Chadd2018-02-021-2/+290
| | | | | | | | | | | | | | | | | | | | | | | | | * Refactor the initial learning configuration (port learning, address expiry, handling address moving between ports, etc, etc) into a separate HAL routine * and ensure that it's consistent between switch chips - the AR8216,8316,724x,9331 SoCs all share the same switch code. * .. the AR8327 needs doing - the defaults seem OK for now * .. the AR9340 is different but it's also programmed now. * Add support for flushing a single port worth of ATU entries * Add support for fetching the ATU table from AR8216 and derived chips Tested: * AR9344, Carambola 2 TODO: * Further testing on other chips * Add AR9340 support * Add AR8327 support Notes: svn path=/head/; revision=328812
* [arswitch] Fix ATU flushing on AR8216/AR8316 and most of the later chips.Adrian Chadd2018-01-311-1/+1
| | | | | | | | | | | | | | The switch hardware requires this bit to be set in order to kick start the actual ATU update. This was being masked on some chips by the learning programming (what to do when a MAC address moves, hash table collision, etc) which is currently inconsistent between chips. Tested: * AR9344 SoC (AR7240 style switch internal) Notes: svn path=/head/; revision=328618
* [etherswitch] check if_alloc returns NULLMichael Zhilin2018-01-241-0/+6
| | | | | | | | | | | This patch is cosmetic. It checks if allocation of ifnet structure failed. It's better to have this check rather than assume positive scenario. Submitted by: Dmitry Luhtionov <dmitryluhtionov@gmail.com> Reported by: Dmitry Luhtionov <dmitryluhtionov@gmail.com> Notes: svn path=/head/; revision=328377
* sys/dev: further adoption of SPDX licensing ID tags.Pedro F. Giffuni2017-11-271-0/+2
| | | | | | | | | | | | | | | Mainly focus on files that use BSD 2-Clause license, however the tool I was using misidentified many licenses so this was mostly a manual - error prone - task. The Software Package Data Exchange (SPDX) group provides a specification to make it easier for automated tools to detect and summarize well known opensource licenses. We are gradually adopting the specification, noting that the tags are considered only advisory and do not, in any way, superceed or replace the license texts. Notes: svn path=/head/; revision=326255
* arswitch: Ensure the lock is always held when calling arswitch_modifyreg()Kristof Provost2017-01-151-1/+7
| | | | | | | | | | | | | | | arswitch_setled() and a number of _global_setup functions did not acquire the lock before calling arswitch_modifyreg(). With WITNESS enabled this would instantly panic. Discovered on a TPLink-3600: ("panic: mutex arswitch not owned at sys/dev/etherswitch/arswitch/arswitch_reg.c:236") Reviewed by: adrian, kan Differential Revision: https://reviews.freebsd.org/D9187 Notes: svn path=/head/; revision=312224
* [arswitch] extend the debug support to be configurable at runtime.Adrian Chadd2016-08-071-24/+41
| | | | | | | | | | | | | | | | | | * remove the DEBUG ifdef; defining it is too far reaching throughout the whole system; * add a bitmask in the softc for controlling debugging; * .. enable said debugging as a sysctl; * add bitmaps for register access, reset and vlans. TODO: * Now that the debug statements are configurable, we definitely could do with more debugging * Move the debugging into the top-level etherswitch driver and have sub-drivers obey. Notes: svn path=/head/; revision=303810
* [etherswitch] add in an initial API for controlling per-port LED behaviour.Adrian Chadd2016-08-041-3/+87
| | | | | | | | | This is just implemented for the AR8327 for now. Submitted by: Dan Nelson <dnelson_1901@yahoo.com> Notes: svn path=/head/; revision=303751
* Cleanup unnecessary semicolons from the kernel.Pedro F. Giffuni2016-04-101-1/+1
| | | | | | | Found with devel/coccinelle. Notes: svn path=/head/; revision=297793
* [mdio] migrate mdiobus out of etherswitch and into a top-level device of its ↵Adrian Chadd2015-12-261-1/+1
| | | | | | | | | | | | | | own. The mdio driver interface is generally useful for devices that require MDIO without the full MII bus interface. This lifts the driver/interface out of etherswitch(4), and adds a mdio(4) man page. Submitted by: Landon Fuller <landon@landonf.org> Differential Revision: https://reviews.freebsd.org/D4606 Notes: svn path=/head/; revision=292738
* Methodise a couple more of the VLAN methods.Adrian Chadd2015-03-081-0/+2
| | | | Notes: svn path=/head/; revision=279797
* Add per-port vlan support for the AR8327.Adrian Chadd2015-03-081-4/+24
| | | | | | | | | | | | | | | | | | | | | All the per-port support is really doing is applying a port visibility mask to each of the switchports. Everything still look like a single portgroup (vlan id 1), but the per-port visibility mask is modified. Whilst I'm here, also add some initial dot1q support - the pvid stuff is doing the right thing, but it's not useful without the rest of the VLAN table programming. It's enough for me to be able to use the LAN/WAN port distinction on the AP135, where there isn't (for now!) a dedicated PHY for the "WAN" port. Tested: * AP135, QCA9558 SoC + AR8327 switch Notes: svn path=/head/; revision=279790
* Fix up support for the AR8327.Adrian Chadd2015-03-081-4/+35
| | | | | | | | | | | | | | | | | | | | | | | * Even though I got the registers around "right", it seems I'm not tickling the MDIO access correctly for the internal PHY bus. Some of the switches are fine poking at the external PHY registers; others aren't. So, enable direct PHY bus access for the AR8327, and leave the existing code in place for the others. * Go and shuffle the register access around. Whilst here, restore the 2ms delay if changing page. * Comment out some of the stub printf()s; there's some upcoming work to add port VLAN support. Tested: * AP135 development board * Carambola2 - AR9331 SoC Notes: svn path=/head/; revision=279767
* Add another revision of the AR8327.Adrian Chadd2014-07-261-0/+1
| | | | Notes: svn path=/head/; revision=269147
* Revert r268543.Rui Paulo2014-07-121-1/+1
| | | | | | | We should probably fix sys/gpio.h instead. Notes: svn path=/head/; revision=268564
* Move iic.h to sys/ so that it's automatically installed in /usr/include/sys.Rui Paulo2014-07-121-1/+1
| | | | | | | | | | This lets us call iic(4) ioctls without needing the kernel source code and follows the same model of GPIO. MFC after: 3 weeks Notes: svn path=/head/; revision=268543
* Add ATU flush support.Adrian Chadd2014-03-021-1/+49
| | | | | | | | | | | | | | | | | | | | | | The OpenWRT AR8xxx switch support flushes the ATU (address translation unit) after each port link 'up' status change. I've modified this to just flush on any port transition. Whilst here, bump the number of ports on the AR8327 to 6, rather than the default of 5. It's DB120 specific; I'll go and make this configurable later. There's some debugging code in here still; I am still debugging whether this is or isn't working fully. Tested: * DB120, AR9344 + AR8327 switch Obtained from: OpenWRT Notes: svn path=/head/; revision=262681
* Link the AR8327 to the build.Adrian Chadd2014-02-241-0/+3
| | | | Notes: svn path=/head/; revision=262431
* Methodize the arswitch VLAN routines.Adrian Chadd2014-02-241-3/+24
| | | | | | | | | | These differ per chipset family in subtle and evil ways. It becomes very noticable on the AR8327 where the layout is just plain wrong. Notes: svn path=/head/; revision=262429
* Extract out the port VLAN flags/setup code and throw it into two newAdrian Chadd2014-02-191-43/+70
| | | | | | | | | | | | | | HAL methods. This allows the AR8327 code to override it as appropriate. Tested: * DB120 - AR8327 and AR9340 on-board switch; only running 'etherswitchcfg' to check configs. The actual VLAN programming wasn't tested. Notes: svn path=/head/; revision=262208
* Turn the port init function into a HAL method and initialise it to theAdrian Chadd2014-02-191-4/+14
| | | | | | | | | default port init code. This needs to be overridden for the AR8327. Notes: svn path=/head/; revision=262206
* Change arswitch_ports_init() to arswitch_port_init(), and teach it to takeAdrian Chadd2014-02-191-16/+18
| | | | | | | | | | | | | | | a single port to setup. This may end up later being used as part of some logic to program the PHY for a single port, rather than having to reinitialise them all at once. Tested: * DB120 Notes: svn path=/head/; revision=262203
* Add in the AR8327 probe/attach code and switch type.Adrian Chadd2014-02-191-0/+5
| | | | | | | | | | | | It detects fine, but (as expected) it won't attach just yet, let alone pass traffic. Tested: * DB120, AR8327 switch Notes: svn path=/head/; revision=262202
* Store away the chip version and revision; some AR8327 code depends uponAdrian Chadd2014-02-191-0/+2
| | | | | | | the chip revision. Notes: svn path=/head/; revision=262201
* - Provide necessary includes, that before came via if.h pollution.Gleb Smirnoff2013-10-281-0/+2
| | | | | | | | | | - Remove unnecessary ones. Sponsored by: Netflix Sponsored by: Nginx, Inc. Notes: svn path=/head/; revision=257284
* Add support for the AR9340 switch to the switch framework.Adrian Chadd2013-10-161-12/+29
| | | | | | | | | | | | | | | | | * Do the hardware setup in the right order! * Modify/improve the chip probe check so it can actually probe the 7240/9340 directly (although it's not yet used..) * Initialise and fetch the is_mii option * Fix some debugging whilst I'm here. This is enough to get things off the ground. Tested: * AR9344 SoC Notes: svn path=/head/; revision=256582
* Add the support for 802.1q and port based vlans for arswitch.Luiz Otavio O Souza2013-07-231-64/+185
| | | | | | | | | | | Tested on: RB450G (standalone ar8316), RSPRO (standalone ar8316) and TPLink MR-3220 (ar724x integrated switch). Approved by: adrian (mentor) Obtained from: zrouter Notes: svn path=/head/; revision=253572
* Correctly mark the CPU port.Adrian Chadd2013-05-081-0/+1
| | | | | | | | Submitted by: Luiz Otavio O Souza <loos.br@gmail.com> Reviewed by: ray Notes: svn path=/head/; revision=250383
* Update arswitch to the new API.Adrian Chadd2013-04-221-1/+1
| | | | Notes: svn path=/head/; revision=249775
* Disable automatic attachment of arswitch. It can't be auto-detected (like PHYsAleksandr Rybalko2012-11-071-11/+0
| | | | | | | | | | do) and cause a problems trying to attach another instance to child mdio. Submitted by: Luiz Otavio O Souza Approved by: adrian (menthor) Notes: svn path=/head/; revision=242716
* Locking for etherswitch framework:Aleksandr Rybalko2012-10-151-0/+25
| | | | | | | | | | | | | * add lock/unlock methods; * add lock/unlock default implementation; * surround switch IOCTLs with locking; * add lock/unlock implementation for arswitch; Submitted by: Luiz Otavio O Souza Approved by: adrian (mentor) Notes: svn path=/head/; revision=241578
* Defaulting to id "0" if ar7240_probe(dev) success, fix warning when buildingAleksandr Rybalko2012-10-151-0/+1
| | | | | | | | | | with DEBUG. Submitted by: Luiz Otavio O Souza Approved by: adrian (mentor) Notes: svn path=/head/; revision=241577
* Setup the CPU port and broadcast map on the AR7240, rather thanAdrian Chadd2012-05-121-3/+9
| | | | | | | | | | | | | | | | | | depending upon the bootloader initialising it. The aim is to eventually support a full switch set and reinitialisation rather than relying on a consistent bootloader setup. Remove the port flood config from arswitch.c, it's not yet used and it's totally incorrect. Whilst I'm here, also add in a comment describing why the full switch reset is disabled. Obtained from: Linux (OpenWRT) - Values Notes: svn path=/head/; revision=235377