aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/etherswitch
Commit message (Collapse)AuthorAgeFilesLines
* Improve detection of addressing mode in e6000swMarcin Wojtas2018-04-101-1/+3
| | | | | | | | | | | | | | Some devices cannot rely on the switch MDIO address passed in the DTB for specifying single/multi-chip addressing mode. Introduce new property "single-chip-addressing" which added to DTS will force single-chip mode. Submitted by: Michal Mazur <mkm@semihalf.com> Obtained from: Semihalf Sponsored by: Stormshield Differential Revision: https://reviews.freebsd.org/D14800 Notes: svn path=/head/; revision=332354
* Clean up OF_getprop_alloc APIOleksandr Tymoshenko2018-04-081-2/+2
| | | | | | | | | | | | | | | | | | | | OF_getprop_alloc takes element size argument and returns number of elements in the property. There are valid use cases for such behavior but mostly API consumers pass 1 as element size to get string properties. What API users would expect from OF_getprop_alloc is to be a combination of malloc + OF_getprop with the same semantic of return value. This patch modifies API signature to match these expectations. For the valid use cases with element size != 1 and to reduce modification scope new OF_getprop_alloc_multi function has been introduced that behaves the same way OF_getprop_alloc behaved prior to this patch. Reviewed by: ian, manu Differential Revision: https://reviews.freebsd.org/D14850 Notes: svn path=/head/; revision=332310
* [arswitch] Implement the switch MAC address fetch API.Adrian Chadd2018-02-063-0/+65
| | | | | | | | | | | | The placeholders are here for some future "set" MAC address API. Tested: * AR9340 switch * AR8327 switch Notes: svn path=/head/; revision=328924
* [etherswitch] add initial support for potentially configuring and fetching ↵Adrian Chadd2018-02-061-0/+2
| | | | | | | | | | | | the switch MAC address. Switches that originate their own frames (eg obvious ones like Pause frames) need a MAC address to use to send those frames from. This API will hopefully begin to allow that to be configurable. Notes: svn path=/head/; revision=328922
* [arswitch] disable ARP copy-to-CPU port for AR9340 for now.Adrian Chadd2018-02-051-0/+2
| | | | | | | | | | | I'll have to go double check to see if it does indeed pass ARP frames between switch ports with this disabled, but it seems required for the CPU port to see ARP traffic. I'll dig into this some more. Notes: svn path=/head/; revision=328901
* [arswitch] fix build breakage.Adrian Chadd2018-02-051-1/+1
| | | | | | | | Apparently the last time I checked building this it didn't pick up that the header had changed. Notes: svn path=/head/; revision=328900
* [arswitch] Enable ATU dump support for the AR9340.Adrian Chadd2018-02-051-11/+11
| | | | | | | | | | | | | | | | This indeed uses the same registers as the AR8216 and later chips. There seems to be an issue with ARP requests being sent out from the CPU through this switch here, so figuring that out is next. Learning works fine on the AR8327 ethernet switch on the /other/ gigabit ethernet port, so I don't think it's the network stack or ethernet driver. Tested: * DB120 - AR9340 SOC + ethernet switch (and other bits.) Notes: svn path=/head/; revision=328873
* [arswitch] fix mac address field definition.Adrian Chadd2018-02-051-4/+18
| | | | | | | | | | | | | Whilst here, add some further fields for future experimenting. Tested: * AR9340 switch * AR9330 switch * AR7240 switch Notes: svn path=/head/; revision=328872
* [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] fix up issues on the AR8327.Adrian Chadd2018-02-042-7/+7
| | | | | | | | | | | | | | | | | | | | This correctly dumps the ethernet bridge contents on an AR8327 switch. Tested: * AP135 - QCA9550 + AR8327 ethernet switch: # etherswitchcfg atu dump [0] c0:3f:d5:7e:6f:45: portmask 0x00000004 [1] f6:b6:03:96:1e:ba: portmask 0x00000004 [2] 00:03:7f:11:38:4f: portmask 0x00000040 # arp -na ? (192.168.3.170) at 00:03:7f:11:38:4f on arge0 permanent [ethernet] ? (192.168.3.12) at c0:3f:d5:7e:6f:45 on arge0 expires in 1188 seconds [ethernet] ? (192.168.3.1) at f6:b6:03:96:1e:ba on arge0 expires in 1186 seconds [ethernet] Notes: svn path=/head/; revision=328838
* [arswitch] add initial functionality for AR8327 ATU management.Adrian Chadd2018-02-032-5/+108
| | | | | | | | | | | | | * Add the bulk of the ATU table read function * Correct how the ATU function and WAIT bits work TODO: * more testing, figure out how the multi-vlan table stuff works and push that up to userspace Notes: svn path=/head/; revision=328823
* [arswitch] Stub out the ATU table dump in AR9340 switches until I implementAdrian Chadd2018-02-021-0/+11
| | | | | | | this. Notes: svn path=/head/; revision=328814
* [arswitch] begin tidying up the learning and ATU management, introduce ATU APIs.Adrian Chadd2018-02-027-29/+406
| | | | | | | | | | | | | | | | | | | | | | | | | * 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
* [etherswitch] add the first pass of a simple API to flush and fetch the L2 ↵Adrian Chadd2018-02-023-0/+124
| | | | | | | | | | | | | | | | | | | | | | | | | | address table from the ethernet switch. This stuff may be a bit fluid during this -HEAD cycle as various other switch features are added, but the current stuff is enough to drive initial development and features on the atheros range of integrated and external switches. * add a method to flush the whole address table; * add a method to flush all addresses on a given port; * add a method to download the address table; * .. and then a method to fetch entries from the address table. The table fetch/read methods pass through to the drivers for now since the drivers may implement different ways of fetching/caching the address table data. The atheros devices for example fetch the table by iterating over the table through a set of registers and so you need to keep that locked whilst you iterate otherwise you may have the table flushed half way by a port status change. This is a no-op until the userland and arswitch code shows up. Notes: svn path=/head/; revision=328766
* [arswitch] Fix ATU programming on the AR8327 switch.Adrian Chadd2018-01-311-1/+1
| | | | | | | Doing a flush actually requires setting this bit. Notes: svn path=/head/; revision=328619
* [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
* [arswitch] add a new debug section for upcoming address table management.Adrian Chadd2018-01-311-0/+3
| | | | Notes: svn path=/head/; revision=328617
* [etherswitch] fix LINT build for rtl8366rbMichael Zhilin2018-01-251-1/+1
| | | | | | | | | | | Build with rtl8366rb has been broken due to incorrect retrieval of pointer to device_t. Reported by: lwhsu Differential Revision: https://reviews.freebsd.org/D14044 Notes: svn path=/head/; revision=328389
* [etherswitch] check if_alloc returns NULLMichael Zhilin2018-01-248-0/+48
| | | | | | | | | | | 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-2738-0/+76
| | | | | | | | | | | | | | | 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
* Fix the port vlan support in e6000 based switches.Luiz Otavio O Souza2017-07-272-92/+85
| | | | | | | | | | | | Reduce the use of local copies of switch register data. The switch now works with the upstream dsa node (i.e. the upstream DTS). Tested on: ClearFog Pro (88E6176), SG-3100 (88E6141) Sponsored by: Rubicon Communications, LLC (Netgate) Notes: svn path=/head/; revision=321602
* Add support to 2.5G uplink for the MV88E6141 and MV88E6341 switches.Luiz Otavio O Souza2017-06-202-43/+111
| | | | | | | | | | Force the switch port settings for fixed media types. Tested with: 88E6176, 88E6141 Sponsored by: Rubicon Communications, LLC (Netgate) Notes: svn path=/head/; revision=320157
* Prevent multiple lock initialization in e6000sw probeZbigniew Bodek2017-06-131-3/+8
| | | | | | | | | | | | | | | | r319886 ("Add the initial support for the Marvell 88E6141 and 88E6341 switches.") unveiled a problem with possible multiple lock creation. Move its initialization to the driver attach and for obtaining the switch ID create a temprorary one, which is immediately destroyed after the check. Submitted by: Zbigniew Bodek <zbb@semihalf.com> Marcin Wojtas <mw@semihalf.com> Obtained from: Semihalf Notes: svn path=/head/; revision=319906
* Add the initial support for the Marvell 88E6141 and 88E6341 switches.Luiz Otavio O Souza2017-06-131-18/+66
| | | | | | | | | | | | | Right now the driver only supports port VLANs, so make sure etherswitch_getinfo() return the proper switch capabilities. Handle the cases where not all ports are in use (that will also require etherswitch cooperation). Sponsored by: Rubicon Communications, LLC (Netgate) Notes: svn path=/head/; revision=319886
* Remove an unnecessary variable from the switch softc structure and make theLuiz Otavio O Souza2017-06-091-19/+22
| | | | | | | | | functions that are used as booleans return real boolean values. Sponsored by: Rubicon Communications, LLC (Netgate) Notes: svn path=/head/; revision=319760
* style(9) fixes, remove unnecessary headers, remove duplicate #defines andLuiz Otavio O Souza2017-06-022-136/+88
| | | | | | | | | | | in some cases, shuffle the code around to simplify locking. No functional changes. Sponsored by: Rubicon Communications, LLC (Netgate) Notes: svn path=/head/; revision=319498
* [etherswitch] [rtl8366] add phy4cpu setting and support mdioproxyMichael Zhilin2017-05-282-33/+80
| | | | | | | | | | Tested on WZR-HP-G301NH(RTL8366RB) and WZR-HP-G300NH(RTL8366SR). Submitted by: Hiroki Mori <yamori813@yahoo.co.jp> Differential Revision: https://reviews.freebsd.org/D10740 Notes: svn path=/head/; revision=319070
* [arswitch] add phy debugging to the internal PHY read/write functions.Adrian Chadd2017-05-231-0/+15
| | | | Notes: svn path=/head/; revision=318690
* Poll PHY status using internal e6000sw registersWojciech Macek2017-05-192-6/+53
| | | | | | | | | | | | | | | | | | | | | | | | e6000sw family automatically reflects PHY status in each port's registers. Therefore it is not necessary to do a full PHY polling squence, which results in much quicker operation and much less significant usage of the SMI bus. Care must be taken that the resulting ifmedia_active is identical to what the PHY will compute, or gratuitous link status changes will occur whenever the PHYs update function is called. This patch implements above improvement. On the occasion set a pointer to the proc structure to be part of software context instead of being a global variable. Submitted by: Marcin Wojtas <mw@semihalf.com> Obtained from: Semihalf Sponsored by: Stormshield Reviewed by: loos Differential revision: https://reviews.freebsd.org/D10714 Notes: svn path=/head/; revision=318524
* Improve busy-wait loop during switch phy access in e6000swWojciech Macek2017-05-191-8/+39
| | | | | | | | | | | | | | | | Hitherto implementation of PHY polling resulted in a risk of an endless loop and very high occupation of the SMI bus. Improve the operation by limiting the polling tries and adding sleepable pause. Submitted by: Marcin Wojtas <mw@semihalf.com> Obtained from: Semihalf Sponsored by: Stormshield Reviewed by: loos Differential revision: https://reviews.freebsd.org/D10713 Notes: svn path=/head/; revision=318521
* Add missing unlock in e6000sw driverZbigniew Bodek2017-05-171-0/+1
| | | | | | | | | | | | | This patch adds missing unlock on attach failure. Submitted by: Zbigniew Bodek <zbb@semihalf.com> Obtained from: Semihalf Sponsored by: Stormshield Reviewed by: loos Differential revision: https://reviews.freebsd.org/D10712 Notes: svn path=/head/; revision=318411
* Fix broken malloc in e6000swZbigniew Bodek2017-05-171-2/+4
| | | | | | | | | | | | | | | | Malloc should always return something when M_WAITOK flag is used, but keep this code and change flag to M_NOWAIT as it is under a lock (allows for possible future change). Free ifnet structure to avoid memory leak on failure. Submitted by: Zbigniew Bodek <zbb@semihalf.com> Obtained from: Semihalf Sponsored by: Stormshield Reviewed by: loos Differential revision: https://reviews.freebsd.org/D10711 Notes: svn path=/head/; revision=318410
* [etherswitch] [e6000sw] fix compile issue under clang/armAdrian Chadd2017-05-061-2/+4
| | | | | | | | | Submitted by: Hiroki Mori <yamori813@yahoo.co.jp> Approved by: mizhka Differential Revision: https://reviews.freebsd.org/D10563 Notes: svn path=/head/; revision=317869
* [ip17x] [etherswitch] fdt away and mii hang workaround on ip17xAdrian Chadd2017-05-062-4/+48
| | | | | | | | | | | | | | | | Add workaround mii access because of rt1310 is hang up on etherswitch mii poll. And FDT away on arm platform. Tested: * wzr2-g300n Submitted by: Hiroki Mori <yamori813@yahoo.co.jp> Reviewed by: mizhka Differential Revision: https://reviews.freebsd.org/D10295 Notes: svn path=/head/; revision=317866
* [infineon] [etherswitch] no hardcode tagging port setting at amd6996fcAdrian Chadd2017-05-061-5/+5
| | | | | | | | | | | | | | Tagging port can set by etherswitchcfg command. Tested: * on Netgear_WGR614Cv7 Submitted by: Hiroki Mori <yamori813@yahoo.co.jp> Reviewed by: mizhka Notes: svn path=/head/; revision=317864
* When the switch is set to operate in the Multi Chip Addressing Mode weLuiz Otavio O Souza2017-04-301-13/+7
| | | | | | | | | | | | | | | | | | cannot access the GLOBAL2 register directly. Despite the comment in code (which was misleading), the indirect access is only used to read the switch CONFIG data from the scrap register and not for the GLOBAL2 access. Use the dsa data to define when the switch is in the Multi Chip Addressing Mode (a even address different than zero). While here fix a typo. Sponsored by: Rubicon Communications, LLC (Netgate) Notes: svn path=/head/; revision=317605
* [etherswitch] add support for Marvell 88E6065 ethernet switch incl. 802.1qMichael Zhilin2017-03-271-42/+364
| | | | | | | | | | | | | This patch brings 802.1q support for Marvell 88E606x ethernet switches. Test is done on 88E6065 chip (Aterm WR1200). Submitted by: Hiroki Mori <yamori813@yahoo.co.jp> Reviewed by: mizhka MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D10144 Notes: svn path=/head/; revision=316052
* etherswitch: Fix RT305x vlan group operationStanislav Galabov2017-02-201-3/+30
| | | | | | | | | | | | | | Fix an issue which prevents proper operation (addition/removal of members) of RT305x vlan groups. Tested by: yamori813@yahoo.co.jp Submitted by: yamori813@yahoo.co.jp (initial version) Reviewed by: adrian Differential Revision: https://reviews.freebsd.org/D9607 Notes: svn path=/head/; revision=313988
* arswitch: Ensure the lock is always held when calling arswitch_modifyreg()Kristof Provost2017-01-155-1/+21
| | | | | | | | | | | | | | | 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
* [etherswitch] Support Micrel KSZ8995MA switch chipMichael Zhilin2017-01-141-0/+960
| | | | | | | | | | | | | | | This is Micrel KSZ8995MA driver code. KSZ8995MA uses SPI bus to control. This code is written & tested on @SRCHACK's ksz8995ma board and FON2100 with gpiospi. etherswitchcfg support commands: addtag, ingress, striptag, dropuntagged. Submitted by: Hiroki Mori <yamori813@yahoo.co.jp> Reviewed by: mizhka, adrian Approved by: adrian (mentor) Differential Revision: https://reviews.freebsd.org/D8790 Notes: svn path=/head/; revision=312204
* Convert etherswitch to use the make_dev_s(9) KPI. This fix a possible raceLuiz Otavio O Souza2017-01-081-6/+13
| | | | | | | | | | | where si_drv1 can be accessed before it gets set. MFC after: 3 days Suggested by: kib Sponsored by: Rubicon Communications, LLC (Netgate) Notes: svn path=/head/; revision=311700
* Improve ports handling in e6000sw driverZbigniew Bodek2017-01-052-80/+286
| | | | | | | | | | | | | | | | | | | - recognize ports and vlangroups based on DTS file - support multi-chip addresing mode (required in upcoming Armada-388-Clearfog support) - refactor attachment function Each port in 'dsa' node should have 'vlangroup' property. Otherwise, e6000sw will fail to attach. Submitted by: Bartosz Szczepanek <bsz@semihalf.com> Konrad Adamczyk <ka@semihalf.com> Obtained from: Semihalf Sponsored by: Stormshield Differential revision: https://reviews.freebsd.org/D7328 Notes: svn path=/head/; revision=311448
* Allow simultaneous access to switch device, there is no reason to preventLuiz Otavio O Souza2016-12-031-70/+1
| | | | | | | | | | | | | | | it. Remove bogus wrappers and use the kernel defaults. While here, use DEVMETHOD_END. Obtained from: pfSense MFC after: 2 weeks Sponsored by: Rubicon Communications, LLC (Netgate) Notes: svn path=/head/; revision=309461
* [etherswitch] add ukswitch hint that is phy offset at mdio registerMichael Zhilin2016-11-211-1/+5
| | | | | | | | | | | | | | | | This patch allows to specify PHY register offset for ukswitch. For instance, switch MAICREL KS8995XA connected via MDIO to SoC, but PHY register starts at 1. So hint for this case is: hint.ukswitch.0.phyoffset=1 No change/effect if hint is not set. Submitted by: Hiroki Mori <yamori813@yahoo.co.jp> Reviewed by: adrian, mizhka Approved by: adrian(mentor) Differential Revision: https://reviews.freebsd.org/D8584 Notes: svn path=/head/; revision=308937
* [etherswitch] add infineon adm6996fc support on etherswitchMichael Zhilin2016-11-171-0/+858
| | | | | | | | | | | | | | | | This is Infineon ADM6996FC/M/MX driver code on etherswitch framework. Support PORT and DOT1Q VLAN. This code suppose ADM6996FC SDC/SDIO connect to SOC network interface MDC/MDIO. This code tested on Netgear WGR614Cv7. Submitted by: Hiroki Mori <yamori813@yahoo.co.jp> Reviewed by: adrian, mizhka Approved by: adrian(mentor) Differential Revision: https://reviews.freebsd.org/D8495 Notes: svn path=/head/; revision=308744
* [etherswitch] enable phy4/mac4 of ip175cMichael Zhilin2016-11-152-0/+10
| | | | | | | | | | | | If MII1 interface is disabled, then enable phy4/mac4. Submitted by: Hiroki Mori <yamori813@yahoo.co.jp> Reviewed by: mizhka, adrian Approved by: adrian (mentor) Differential Revision: https://reviews.freebsd.org/D6832 Notes: svn path=/head/; revision=308702
* [etherswitch] add RTL8366SR supportMichael Zhilin2016-11-152-222/+335
| | | | | | | | | | | | | Add RTL8366SR support at etherswitch driver. Tested on RTL8366RB and RTL8366SR. Submitted by: Hiroki Mori <yamori813@yahoo.co.jp> Reviewed by: adrian, mizhka Approved by: adrian(mentor) Differential Revision: https://reviews.freebsd.org/D6796 Notes: svn path=/head/; revision=308700
* [etherswitch] add Marvell 88e6060 switch supportMichael Zhilin2016-11-151-0/+703
| | | | | | | | | | | | | Add 88e6060 basic support: only port-based VLAN is supported. No vlan(4) support. Submitted by: Hiroki Mori <yamori813@yahoo.co.jp> Reviewed by: mizhka, adrian Approved by: adrian(mentor) Differential Revision: https://reviews.freebsd.org/D8344 Notes: svn path=/head/; revision=308699
* sys/dev: replace comma with semicolon when pertinent.Pedro F. Giffuni2016-08-091-1/+1
| | | | | | | | | | | | | Uses of commas instead of a semicolons can easily go undetected. The comma can serve as a statement separator but this shouldn't be abused when statements are meant to be standalone. Detected with devel/coccinelle following a hint from DragonFlyBSD. MFC after: 1 month Notes: svn path=/head/; revision=303891
* etherswitch: Unbreak LINT buildSepherosa Ziehau2016-08-081-1/+2
| | | | | | | Sponsored by: Microsoft Notes: svn path=/head/; revision=303821