Commit Graph

177 Commits

Author SHA1 Message Date
Justin Hibbits
b29549c7f9 etherswitch: Fix leftovers from IfAPI conversion
Sponsored by:	Juniper Networks, Inc.
2023-02-14 10:21:18 -05:00
Justin Hibbits
74c592c047 etherswitch: Clean up whitespace after IfAPI conversion
Sponsored by:	Juniper Networks, Inc.
Fixes:		2e6a8c1ae
2023-01-31 16:26:33 -05:00
Justin Hibbits
2e6a8c1ae3 Mechanically convert etherswitch drivers to IfAPI
Reviewed by:	kd
Sponsored by:	Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D37813
2023-01-24 14:36:29 -05:00
Elliott Mitchell
21cc0918c7 sys: Nuke double-semicolons
A distinct number of double-semicolons have ended up in FreeBSD.  Take a
pass at getting rid of many of these harmless typos.

Reviewed by: emaste, rrs
Pull Request: https://github.com/freebsd/freebsd-src/pull/609
Differential Revision: https://reviews.freebsd.org/D31716
2022-11-02 09:34:20 -06:00
Gordon Bergling
8cf905e5fa etherswitch(4): Remove a double word in a source code comment
- s/the the/the/

MFC after:	3 days
2022-09-04 13:41:44 +02:00
Kristof Provost
7647626d33 e6000sw: fix incorrect locking
During attach we release the lock to call e6000sw_attach_miibus(), which
calls mii_attach(). The mii_attach() function calls miibus_readreg() /
miibus_writereg(). However, these are set to be
e6000sw_readphy_locked().

That is, the read/write phy functions do not acquire the lock, but
expect to be called while locked.  Simply do not unlock and relock while
calling mii_attach().

Reviewed by:	Hubert Mazur <hum@semihalf.com>
Sponsored by:	Rubicon Communications, LLC ("Netgate")
Differential Revision:	https://reviews.freebsd.org/D36117
2022-08-19 23:09:11 +02:00
Albert Jakiela
4692906480 e6000sw: add readphy and writephy wrappers
New functions take lock and give lock after operation.
Removed locking and unlocking within other methods,
to prevent from recursive locking on non recursive lock.

Tested on EspressoBin.

Reviewed by: mw
Obtained from: Semihalf
Differential Revision: https://reviews.freebsd.org/D35656
2022-07-07 18:25:00 +02:00
Kornel Dulęba
6654825907 e6000sw: Fix direct register write logic
When accessing a register directly from etherswitchcfg one must specify
a register group(e.g. registers of portN) and the register offset within
the group. The latter is passed as the 5 least significant bits.
Extract the former by dividing the register address by 32, not by 5.

Approved by:	mw(mentor)
Obtained from:	Semihalf
Sponsored by:	Stormshield
MFC after:	2 weeks
Differential Revision:	https://reviews.freebsd.org/D35672
2022-07-04 16:22:22 +02:00
John Baldwin
42726c2fc2 etherswitch drivers: Remove unused devclass arguments to DRIVER_MODULE. 2022-05-09 14:26:44 -07:00
John Baldwin
beccd04c88 Remove unused miiproxy_devclass. 2022-05-09 14:26:43 -07:00
John Baldwin
829a13fa7f Remove unused etherswitch_devclass. 2022-05-09 14:26:43 -07:00
John Baldwin
8933f7d600 Remove unused mdio_devclass. 2022-05-06 15:39:28 -07:00
John Baldwin
3e38757d4c Remove unused miibus_devclass and miibus_fdt_devclass. 2022-05-06 15:39:28 -07:00
John Baldwin
3ef2d49e7d arswitch: Remove unused variable. 2022-04-12 14:58:59 -07:00
John Baldwin
683ca8034d etherswitch: Remove unused variable. 2022-04-08 17:25:14 -07:00
Warner Losh
9a2e6ca6ef e6000sw_set_atustat: eliminate write only ret variable
Sponsored by:		Netflix
2022-04-04 22:29:26 -06:00
Gordon Bergling
9097d2f5d1 etherswitch(4): Fix a few common typos in source code comments
- s/accomodate/accommodate/

MFC after:	3 days
2022-04-02 14:51:57 +02:00
Adrian Chadd
e388de98bd ar40xx_switch: add initial switch for the IPQ4018/IPQ4019.
Summary:

This switch is based off of the AR8327/AR8337 external switch/PHY.
However unlike the AR8327/AR8337 it itself doesn't have any PHYs;
instead an external PHY connects to it using the PSGMII port.

Differential Revision: https://reviews.freebsd.org/D34112
Reviewed by: manu

This code is inspired by the ar40xx code in openwrt, which itself
is based on the Qualcomm QCA-SSDK.  Both of these sources are, amusingly,
BSD licenced - and thus I have included some of the comments in the
hardware workaround paths to document some of the magic numbers.
2022-02-03 21:27:13 -08:00
Kornel Duleba
0f84feb9fb felix: Add support for PHY interrupts
- Replace miibus with newly created miibus_fdt.
- Use generic passthrough resource allocation devmethods.

Obtained from: Semihalf
Sponsored by: Alstom Group
2021-11-24 07:40:37 +01:00
Bjoern A. Zeeb
782cd815e1 etherswitch/felix: remove unused function
Remove unused file-local static function felix_phyforport()
which was missed in 29cf6a79ac to avoid compile time warning.

Reviewed by:	Kornel Duleba (mindal semihalf.com)
Differential Revision: https://reviews.freebsd.org/D32906
2021-11-09 15:08:53 +00:00
Kornel Duleba
d88aecce69 felix: Add a sysctl to control timer routine frequency
Driver polls status of all PHYs connected to the switch in a
fixed interval.
Add a sysctl that allows to control frequency of that.
The value is expressed in ticks and defaults to "hz", or 1 second.

Obtained from: Semihalf
Sponsored by: Alstom Group
2021-10-29 10:08:26 +02:00
Kornel Duleba
29cf6a79ac felix: Use internal MDIO regs for PHY communication
Previously we would use an external MDIO device found on the PCI bus.
Switch to using MDIO mapped in a separate BAR of the switch device.
It is much easier this way since we don't have to depend on another
driver anymore.

Obtained from: Semihalf
Sponsored by: Alstom Group
2021-10-29 10:08:26 +02:00
Hubert Mazur
ee1b7811a3 e6000sw: Build the driver as a kernel module
Fix detach routine.
Driver was tested on EspressoBin.
Remove it from GENERIC, since now it can be loaded automatically.

Obtained from:		Semihalf
Reviewed by:		manu
Differential revision:	https://reviews.freebsd.org/D31580
2021-09-13 11:42:16 +02:00
Hubert Mazur
1e1253510a e6000sw: Use taskqueue subsytem for MDIO polling
Previosuly the link status was pooled in an infinite loop in a separate
kproc. Use taskqueue subsytem instead. This is a prequisite for making
this driver work as a loadable module.

Obtained from:		Semihalf
Differential revision:	https://reviews.freebsd.org/D31579
2021-09-13 11:37:11 +02:00
Kornel Duleba
dfcaa2c18b enetc_mdio: Support building the driver as a loadable module.
After recent arm64 GENERIC config cleanup the ENETC MDIO
in NXP LS1028A SoC should support being loaded as a module.

Obtained from: Semihalf
Sponsored by: Alstom Group
2021-08-03 12:07:49 +02:00
Marcin Wojtas
451bcf1b36 Introduce driver for Freescale Felix switch
It is found on boards equipped with LS1028A SoC.
802.1q VLAN grouping is supported.
An external MDIO device is used for communicating with PHYs.
The driver is built as a module by default, it is not included
in GENERIC kernel config.

Submitted by: Lukasz Hajec <lha@semihalf.com>
              Kornel Duleba <mindal@semihalf.com>
Obtained from: Semihalf
Sponsored by: Alstom Group
Differential Revision: https://reviews.freebsd.org/D30923
2021-08-03 12:07:49 +02:00
Kornel Duleba
f5b29d0f35 etherswitch: Add a new striptagingress port flag
Felix switch found in LS1028A supports stripping VLAN tag on
ingress, instead of egress. The striptag flag excepts the latter
behaviour.
Add a new flag to support the feature.

Obtained from: Semihalf
Sponsored by: Alstom Group
Differential Revision: https://reviews.freebsd.org/D30922
2021-08-03 12:07:48 +02:00
Adrian Chadd
c864575148 [etherswitch] bump register width to 32 bits.
Some ethernet switches have very large register windows; for example
the AR8316 switch MIB starts at 0x20000.

Submitted by:	Mori Hiroki <yamori813@yahoo.co.jp>
2020-05-08 22:22:12 +00:00
Ed Maste
aeb665b538 remove extraneous double ;s in sys/ 2020-03-30 16:04:25 +00:00
Pawel Biernacki
7029da5c36 Mark more nodes as CTLFLAG_MPSAFE or CTLFLAG_NEEDGIANT (17 of many)
r357614 added CTLFLAG_NEEDGIANT to make it easier to find nodes that are
still not MPSAFE (or already are but aren’t properly marked).
Use it in preparation for a general review of all nodes.

This is non-functional change that adds annotations to SYSCTL_NODE and
SYSCTL_PROC nodes using one of the soon-to-be-required flags.

Mark all obvious cases as MPSAFE.  All entries that haven't been marked
as MPSAFE before are by default marked as NEEDGIANT

Approved by:	kib (mentor, blanket)
Commented by:	kib, gallatin, melifaro
Differential Revision:	https://reviews.freebsd.org/D23718
2020-02-26 14:26:36 +00:00
Ganbold Tsagaankhuu
75f5224ea8 Fix panic when running etherswitchcfg port command. 2019-12-25 11:26:38 +00:00
Luiz Otavio O Souza
9aba06377d Add support for the Marvell 88E6190 11 ports switch.
With more ports, some of the registers are shifted a bit to accommodate.

This switch also adds two high speed Serdes/SGMII interfaces (2.5 Gb/s).

Sponsored by:	Rubicon Communications, LLC (Netgate)
2019-07-01 13:41:37 +00:00
Luiz Otavio O Souza
d7cecbd179 Add the 802.1q support for the Marvell e6000 series of ethernet switches.
Tested on:	espressobin, Clearfog, SG-3100 and others
Sponsored by:	Rubicon Communications, LLC (Netgate)
2019-06-28 22:19:50 +00:00
Luiz Otavio O Souza
4e4cedb00b Add the 'drop tagged' flag support for ethernet switch ports.
This is intended to drop all 802.1q tagged packets on a port.

Sponsored by:	 Rubicon Communications, LLC (Netgate)
2019-06-28 22:12:43 +00:00
Luiz Otavio O Souza
5429f5f309 Do not overwrite the RGMII bits in the CPU port register of Switch.
Fixes the network on Espressobin.

The GENERIC kernel now boots over NFS.

Sponsored by:	Rubicon Communications, LLC (Netgate)
2019-06-06 21:25:46 +00:00
Marcin Wojtas
0fd68d7298 Update mvneta/e6000sw for new DSA Device Tree Bindings
In the latest Linux kernel revisions the DSA (Distributed
Switch Architecture) device tree binding was changed.
Instead of the top level dsa@ node, the switch and its
ports is represented as a child node of the mdio bus.
With that other modifications were added, such as
relation with the ethernet port of the SoC. Adjust
e6000sw etherswitch and mvneta drivers to that.

Tested on Armada 3720 EspressoBin and Armada 388 Clearfog Pro boards.

Submitted by: Bert JW Regeer <xistence@0x58.com>
Reviewed by: manu
Differential Revision: https://reviews.freebsd.org/D19036
2019-03-23 02:48:47 +00:00
Marcin Wojtas
fb4478a336 Improve detection of addressing mode in e6000sw
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
2018-04-10 08:35:43 +00:00
Oleksandr Tymoshenko
217d17bcd3 Clean up OF_getprop_alloc API
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
2018-04-08 22:59:34 +00:00
Adrian Chadd
2ba4bf8fa5 [arswitch] Implement the switch MAC address fetch API.
The placeholders are here for some future "set" MAC address API.

Tested:

* AR9340 switch
* AR8327 switch
2018-02-06 08:35:49 +00:00
Adrian Chadd
15bd1a867e [etherswitch] add initial support for potentially configuring and fetching 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.
2018-02-06 08:34:50 +00:00
Adrian Chadd
f6f7bec6f8 [arswitch] disable ARP copy-to-CPU port for AR9340 for now.
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.
2018-02-05 20:37:29 +00:00
Adrian Chadd
45a7272a5b [arswitch] fix build breakage.
Apparently the last time I checked building this it didn't pick up that the
header had changed.
2018-02-05 20:30:53 +00:00
Adrian Chadd
f76883d64c [arswitch] Enable ATU dump support for the AR9340.
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.)
2018-02-05 07:05:28 +00:00
Adrian Chadd
7f81a20479 [arswitch] fix mac address field definition.
Whilst here, add some further fields for future experimenting.

Tested:

* AR9340 switch
* AR9330 switch
* AR7240 switch
2018-02-05 07:03:45 +00:00
Adrian Chadd
7ed0831923 [arswitch] Break out of the loop upon any error, not just -1.
This fixes the AR9340 "unimplemented" thingy for now.
2018-02-05 05:51:37 +00:00
Adrian Chadd
c9f70b7b88 [arswitch] fix up issues on the AR8327.
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]
2018-02-04 08:22:11 +00:00
Adrian Chadd
65d59686e1 [arswitch] add initial functionality for AR8327 ATU management.
* 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
2018-02-03 00:59:08 +00:00
Adrian Chadd
84a5558c38 [arswitch] Stub out the ATU table dump in AR9340 switches until I implement
this.
2018-02-02 22:08:03 +00:00
Adrian Chadd
62042c979d [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
2018-02-02 22:05:36 +00:00
Adrian Chadd
877d73ecb4 [etherswitch] add the first pass of a simple API to flush and fetch the L2 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.
2018-02-02 02:05:14 +00:00