History log of /freebsd-current/sys/dev/etherswitch/arswitch/arswitch.c
Revision Date Author Comments
# 54482989 04-Feb-2024 Mark Johnston <markj@FreeBSD.org>

etherswitch: Use device_set_desc(f)()

No functional change intended.

MFC after: 1 week


# 95ee2897 16-Aug-2023 Warner Losh <imp@FreeBSD.org>

sys: Remove $FreeBSD$: two-line .h pattern

Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/


# 8f5dbc22 08-Aug-2023 Marius Strobl <marius@FreeBSD.org>

arswitch(4): Remove support for AR{7240,9340} found in MIPS SoCs only

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


# e0bc8f8d 08-Aug-2023 Michael Zhilin <mizhka@FreeBSD.org>

etherswitch/arswitch: correct version detection

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


# 4d846d26 10-May-2023 Warner Losh <imp@FreeBSD.org>

spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSD

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


# 74c592c0 31-Jan-2023 Justin Hibbits <jhibbits@FreeBSD.org>

etherswitch: Clean up whitespace after IfAPI conversion

Sponsored by: Juniper Networks, Inc.
Fixes: 2e6a8c1ae


# 2e6a8c1a 30-May-2022 Justin Hibbits <jhibbits@FreeBSD.org>

Mechanically convert etherswitch drivers to IfAPI

Reviewed by: kd
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D37813


# 42726c2f 09-May-2022 John Baldwin <jhb@FreeBSD.org>

etherswitch drivers: Remove unused devclass arguments to DRIVER_MODULE.


# 829a13fa 09-May-2022 John Baldwin <jhb@FreeBSD.org>

Remove unused etherswitch_devclass.


# 8933f7d6 19-Apr-2022 John Baldwin <jhb@FreeBSD.org>

Remove unused mdio_devclass.


# 3e38757d 19-Apr-2022 John Baldwin <jhb@FreeBSD.org>

Remove unused miibus_devclass and miibus_fdt_devclass.


# 2ba4bf8f 06-Feb-2018 Adrian Chadd <adrian@FreeBSD.org>

[arswitch] Implement the switch MAC address fetch API.

The placeholders are here for some future "set" MAC address API.

Tested:

* AR9340 switch
* AR8327 switch


# 7ed08319 04-Feb-2018 Adrian Chadd <adrian@FreeBSD.org>

[arswitch] Break out of the loop upon any error, not just -1.

This fixes the AR9340 "unimplemented" thingy for now.


# 62042c97 02-Feb-2018 Adrian Chadd <adrian@FreeBSD.org>

[arswitch] begin tidying up the learning and ATU management, introduce ATU APIs.

* 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


# 2c6cecca 31-Jan-2018 Adrian Chadd <adrian@FreeBSD.org>

[arswitch] Fix ATU flushing on AR8216/AR8316 and most of the later chips.

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)


# 0774131e 24-Jan-2018 Michael Zhilin <mizhka@FreeBSD.org>

[etherswitch] check if_alloc returns NULL

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>


# 718cf2cc 27-Nov-2017 Pedro F. Giffuni <pfg@FreeBSD.org>

sys/dev: further adoption of SPDX licensing ID tags.

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.


# 6d011946 15-Jan-2017 Kristof Provost <kp@FreeBSD.org>

arswitch: Ensure the lock is always held when calling arswitch_modifyreg()

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


# 1b334c8b 06-Aug-2016 Adrian Chadd <adrian@FreeBSD.org>

[arswitch] extend the debug support to be configurable at runtime.

* 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.


# c94dc808 04-Aug-2016 Adrian Chadd <adrian@FreeBSD.org>

[etherswitch] add in an initial API for controlling per-port LED behaviour.

This is just implemented for the AR8327 for now.

Submitted by: Dan Nelson <dnelson_1901@yahoo.com>


# 74b8d63d 10-Apr-2016 Pedro F. Giffuni <pfg@FreeBSD.org>

Cleanup unnecessary semicolons from the kernel.

Found with devel/coccinelle.


# 71e8eac4 25-Dec-2015 Adrian Chadd <adrian@FreeBSD.org>

[mdio] migrate mdiobus out of etherswitch and into a top-level device of its 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


# f35f94f4 08-Mar-2015 Adrian Chadd <adrian@FreeBSD.org>

Methodise a couple more of the VLAN methods.


# 749cac13 08-Mar-2015 Adrian Chadd <adrian@FreeBSD.org>

Add per-port vlan support for the AR8327.

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


# 78549b94 07-Mar-2015 Adrian Chadd <adrian@FreeBSD.org>

Fix up support for the AR8327.

* 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


# 9682e347 26-Jul-2014 Adrian Chadd <adrian@FreeBSD.org>

Add another revision of the AR8327.


# efce3748 12-Jul-2014 Rui Paulo <rpaulo@FreeBSD.org>

Revert r268543.

We should probably fix sys/gpio.h instead.


# bd08cbb8 11-Jul-2014 Rui Paulo <rpaulo@FreeBSD.org>

Move iic.h to sys/ so that it's automatically installed in /usr/include/sys.

This lets us call iic(4) ioctls without needing the kernel source code
and follows the same model of GPIO.

MFC after: 3 weeks


# 4ff2f60d 01-Mar-2014 Adrian Chadd <adrian@FreeBSD.org>

Add ATU flush support.

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


# 482d268d 23-Feb-2014 Adrian Chadd <adrian@FreeBSD.org>

Link the AR8327 to the build.


# 6dcbabd7 23-Feb-2014 Adrian Chadd <adrian@FreeBSD.org>

Methodize the arswitch VLAN routines.

These differ per chipset family in subtle and evil ways.

It becomes very noticable on the AR8327 where the layout is just plain
wrong.


# a9ad4222 18-Feb-2014 Adrian Chadd <adrian@FreeBSD.org>

Extract out the port VLAN flags/setup code and throw it into two new
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.


# ddbc4420 18-Feb-2014 Adrian Chadd <adrian@FreeBSD.org>

Turn the port init function into a HAL method and initialise it to the
default port init code.

This needs to be overridden for the AR8327.


# df892897 18-Feb-2014 Adrian Chadd <adrian@FreeBSD.org>

Change arswitch_ports_init() to arswitch_port_init(), and teach it to take
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


# 0e67bf94 18-Feb-2014 Adrian Chadd <adrian@FreeBSD.org>

Add in the AR8327 probe/attach code and switch type.

It detects fine, but (as expected) it won't attach just yet, let alone
pass traffic.

Tested:

* DB120, AR8327 switch


# dd843f87 18-Feb-2014 Adrian Chadd <adrian@FreeBSD.org>

Store away the chip version and revision; some AR8327 code depends upon
the chip revision.


# 104dc214 28-Oct-2013 Gleb Smirnoff <glebius@FreeBSD.org>

- Provide necessary includes, that before came via if.h pollution.
- Remove unnecessary ones.

Sponsored by: Netflix
Sponsored by: Nginx, Inc.


# b2152161 15-Oct-2013 Adrian Chadd <adrian@FreeBSD.org>

Add support for the AR9340 switch to the switch framework.

* 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


# b9f07b86 23-Jul-2013 Luiz Otavio O Souza <loos@FreeBSD.org>

Add the support for 802.1q and port based vlans for arswitch.

Tested on: RB450G (standalone ar8316), RSPRO (standalone ar8316) and
TPLink MR-3220 (ar724x integrated switch).

Approved by: adrian (mentor)
Obtained from: zrouter


# f47857dc 08-May-2013 Adrian Chadd <adrian@FreeBSD.org>

Correctly mark the CPU port.

Submitted by: Luiz Otavio O Souza <loos.br@gmail.com>
Reviewed by: ray


# 03d48af2 22-Apr-2013 Adrian Chadd <adrian@FreeBSD.org>

Update arswitch to the new API.


# dc9c386c 07-Nov-2012 Aleksandr Rybalko <ray@FreeBSD.org>

Disable automatic attachment of arswitch. It can't be auto-detected (like PHYs
do) and cause a problems trying to attach another instance to child mdio.

Submitted by: Luiz Otavio O Souza
Approved by: adrian (menthor)


# 454d507a 14-Oct-2012 Aleksandr Rybalko <ray@FreeBSD.org>

Locking for etherswitch framework:
* 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)


# daa4deac 14-Oct-2012 Aleksandr Rybalko <ray@FreeBSD.org>

Defaulting to id "0" if ar7240_probe(dev) success, fix warning when building
with DEBUG.

Submitted by: Luiz Otavio O Souza
Approved by: adrian (mentor)


# 6130ff50 12-May-2012 Adrian Chadd <adrian@FreeBSD.org>

Setup the CPU port and broadcast map on the AR7240, rather than
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


# 27a2ecaa 11-May-2012 Adrian Chadd <adrian@FreeBSD.org>

Further arswitch work:

* Add in the AR724x support. It probes the same as an AR8216/AR8316, so
just add in a hint to force the probe success rather than auto-detecting
it.

* Add in the missing entries from conf/files, lacking in the previous
commit.

The register values and CPU port / mirror port initialisation value was
obtained from Linux OpenWRT ag71xx_ar7240.c.

The DELAY(1000) to let things settle is my local workaround. For some
reason, PHY4 doesn't seem to probe very reliably without it. It's quite
possible that we're missing some MDIO bus initialisation code in if_arge
for the AR724x case. As I dislike DELAY() workarounds in general, it's
definitely worth trying to figure out why this is the case.

Tested on: AP93 (AR7240) reference design

Obtained from: Linux OpenWRT


# a043e8c7 11-May-2012 Adrian Chadd <adrian@FreeBSD.org>

Commit the first pass of the etherswitch support.

This is designed to support the very basic ethernet switch chip behaviour,
specifically:

* accessing switch register space;
* accessing per-PHY registers (for switches that actually expose PHYs);
* basic vlan group support, which applies for the rtl8366 driver but not
for the atheros switches.

This also includes initial support for:

* rtl8366rb support - which is a 10/100/1000 switch which supports
vlan groups;
* Initial Atheros AR8316 switch support - which is a 10/100/1000 switch
which supports an alternate vlan configuration (so the vlan group
methods are stubbed.)

The general idea here is that the switch driver may speak to a variety of
backend busses (mdio, i2c, spi, whatever) and expose:

* If applicable, one or more MDIO busses which ethernet interfaces can
then attach PHYs to via miiproxy/mdioproxy;

* exposes miibusses, one for each port at the moment, so ..

* .. a PHY can be exposed on each miibus, for each switch port, with all
of the existing MII/ifnet framework.

However:

* The ifnet is manually created for now, and it isn't linked into the
interface list, nor can you (currently) send/receive frames on this ifnet.
At some point in the future there may be _some_ support for this, for
switches with a multi-port, isolated mode.

* I'm still in the process of sorting out correct(er) locking.

TODO:

* ray's switch code in zrouter (zrouter.org) includes a much more developed
newbus API that covers the various switch methods, as well as a
capability API so drivers, the switch layer and the userland utility
can properly control the subset of supported features.

The plan is to sort that out later, once the rest of ray's switch drivers
are brought over and extended to export MII busses and PHYs.

Submitted by: Stefan Bethke <stb@lassitu.de>
Reviewed by: ray