Commit graph

46 commits

Author SHA1 Message Date
Emmanuel Vadot be82b3a0bf clk: Move clock code in dev/clk
We've removed kernel option EXT_RESOURCES almost two years ago.
While it was ok to have some code under a common 'extres' subdirectory
at first, we now have a lot of consumer of it and we made it mandatory
so no need to have it under a cryptic name.

Reviewed by:	mhorne
Sponsored by:	Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D43191
2024-01-10 19:20:26 +01:00
Warner Losh fdafd315ad sys: Automated cleanup of cdefs and other formatting
Apply the following automated changes to try to eliminate
no-longer-needed sys/cdefs.h includes as well as now-empty
blank lines in a row.

Remove /^#if.*\n#endif.*\n#include\s+<sys/cdefs.h>.*\n/
Remove /\n+#include\s+<sys/cdefs.h>.*\n+#if.*\n#endif.*\n+/
Remove /\n+#if.*\n#endif.*\n+/
Remove /^#if.*\n#endif.*\n/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/types.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/param.h>/
Remove /\n+#include\s+<sys/cdefs.h>\n#include\s+<sys/capsicum.h>/

Sponsored by:		Netflix
2023-11-26 22:24:00 -07:00
Warner Losh 685dc743dc sys: Remove $FreeBSD$: one-line .c pattern
Remove /^[\s*]*__FBSDID\("\$FreeBSD\$"\);?\s*\n/
2023-08-16 11:54:36 -06:00
Warner Losh 95ee2897e9 sys: Remove $FreeBSD$: two-line .h pattern
Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
2023-08-16 11:54:11 -06:00
Mateusz Guzik bef67a0f15 mvneta: add the missing include opt_mvneta.h
Sponsored by:	Rubicon Communications, LLC ("Netgate")
2023-02-07 19:20:05 +00:00
Justin Hibbits 992fa62b23 Mechanically convert neta(4) to IfAPI
Reviewed by:	mw
Sponsored by:	Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D37825
2023-01-24 14:36:28 -05:00
Albert Jakieła 06c30b2c76 mvneta: Use clkgen API on armv7
With addition of clkgen devices to the Armada38x we no longer
need to rely on get_tclk() to get the device frequency.
Leave it as a fallback, just in case.

Reviewed by:	manu
Obtained from:	Semihalf
Differential Revision: https://reviews.freebsd.org/D36465
2022-09-07 09:44:59 +02:00
Kornel Dulęba 97ecdc00ac neta: Fix MTU change sequence
The IFF_DRV_RUNNING flag is used to see if the interface needs
to be temporarily brought down during MTU change sequence.
The problem here is that this flag is cleared in mvneta_stop_locked,
resulting in the reinitialization logic never being executed after
MTU has been changed.
Fix that by saving the flag value before the interface is brought down.

Reported by:	Jérôme Tomczyk <jerome.tomczyk@stormshield.eu>
Approved by:	mw(mentor)
Obtained from:	Semihalf
Sponsored by:	Stormshield
MFC after:	2 weeks
2022-08-18 18:53:14 +02:00
John Baldwin 9104bbeb8d mvneta: Remove unused devclass argument to DRIVER_MODULE. 2022-05-09 14:26:46 -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 fcd0ea3a38 if_mvneta: Use __diagused for a variable only used in KASSERT(). 2022-04-13 16:08:22 -07:00
Gordon Bergling 19ae05aad3 neta: Fix a typo in a source code comment
- s/maintance/maintenance/

MFC after:	3 days
2022-04-09 09:25:07 +02:00
John Baldwin 27f889cf41 if_mvneta: Remove unused variables. 2022-04-08 17:30:14 -07:00
Warner Losh 28ea3785d9 neta: remove write only variable
Sponsored by:		Netflix
2022-04-05 21:42:06 -06:00
Gordon Bergling 592fcf6c45 neta: Fix a typo in a source code comment
- s/immediatly/immediately/

MFC after:	3 days
2022-04-02 10:46:13 +02:00
Gordon Bergling 6efd2e3e51 neta: Fix a few common typos in a source code comment
- s/hander/handler/

MFC after:	3 days
2022-04-02 10:29:23 +02:00
Sebastien Bini 231237bbb0 neta: split fixed and in-band link status configuration
Fixed-link mode requires different handling than the in-band
managed connection. Update interrupt, link-up/down and
autonegotiation settings for the former.

Reviewed by: mw
MFC after: 1 week
Obtained from: Stormshield
Differential Revision: https://reviews.freebsd.org/D34394
2022-03-22 16:52:31 +01:00
Warner Losh b4dda138e8 neta: clk code ifdef'd aarch64
So #ifdef the clk.h include aarch64. Otherwise the right kernel options
aren't always present.

Sponsored by:		Netflix
2022-01-04 16:01:14 -07:00
Mark Johnston ed166a0173 mvneta: Unconditionally print an error message if mii_attach() fails
The error message is useful for diagnosing mvneta_attach() failures.

MFC after:	1 week
2022-01-04 09:46:23 -05:00
Hubert Mazur 4885d6f3ec if_mvneta: Use clock frequency
Make neta use frequency obtained from clock, instead of
hardcoded one. Use default frequency in case of clock
device failure. Remove unnecessary function calls
to obtain frequency and use cached one instead.

Reviewed by:		manu
Obtained from:		Semihalf
Differential revision:	https://reviews.freebsd.org/D32336
2022-01-04 13:26:35 +01:00
Arnaud Ysmal ea68079ffd Suport Q-in-Q for mvneta. 2021-12-03 11:06:58 +01:00
Wojciech Macek f5639a06b8 mvneta: fix encap property
Fix MVNETA encap property.
2021-10-29 10:56:57 +02:00
Bjoern A. Zeeb 25adbd0b8c neta: cleanup warning
mvneta_find_ethernet_prop_switch() is file-local static to
if_mvneta_fdt.c.  Normally we would not need a function declararion
but in case MVNETA_DEBUG is set it becomes public.  Move the
function declaration from if_mvneta.c to if_mvneta_fdt.c to avoid
a warning during each compile.
2021-09-29 12:37:16 +00:00
Wojciech Macek 5572fda3a2 mvneta: split to FDT and generic part
Split some missing routines.

Obtained from:	Semihalf
2021-09-21 09:38:38 +02:00
Hubert Mazur b831f9ce70 if_mvneta: Build the driver as a kernel module
Fix device detach and attach routine. Add required Makefile
to build as a module. Remove entry from GENERIC, since now
it can be loaded automatically.

Tested on EspressoBin.

Obtained from:		Semihalf
Reviewed by:		manu
Differential revision:	https://reviews.freebsd.org/D31581
2021-09-20 10:58:58 +02:00
Wojciech Macek ba4d9d9d5b Revert "if_mvneta: Build the driver as a kernel module"
This reverts commit bcf5c7a8b1.
2021-09-14 11:49:59 +02:00
Hubert Mazur bcf5c7a8b1 if_mvneta: Build the driver as a kernel module
Fix device detach and attach routine. Add required Makefile
to build as a module. Remove entry from GENERIC, since now
it can be loaded automatically.

Tested on EspressoBin.

Obtained from:		Semihalf
Reviewed by:		manu
Differential revision:	https://reviews.freebsd.org/D31581
2021-09-14 08:29:53 +02:00
Wojciech Macek 6e93bdfff3 Revert "if_mvneta: Build the driver as a kernel module"
This reverts commit 41b0190cc4.
2021-09-13 12:55:15 +02:00
Hubert Mazur 41b0190cc4 if_mvneta: Build the driver as a kernel module
Fix device detach and attach routine. Add required Makefile
to build as a module. Remove entry from GENERIC, since now
it can be loaded automatically.

Tested on EspressoBin.

Obtained from:		Semihalf
Reviewed by:		manu
Differential revision:	https://reviews.freebsd.org/D31581
2021-09-13 11:44:31 +02:00
Kornel Duleba 5438ef47e3 mvneta: Fix MTU update sequence
After MTU is updated we might start using allocating RX buffers from different pool. (MJUM9BYTES vs MCLBYTES)
Because of that we need to update the RX buffer size in hardware.
Previously it was done only when the interface was up, which is incorrect since MTU can be changed at any time.

Differential revision:	https://reviews.freebsd.org/D31724
Sponsored by:		Stormshield
Obtained from:		Semihalf
MFC after:		2 weeks
Reviewed by:		wma
2021-08-31 08:22:29 +02:00
Mark Johnston 109260d202 mvneta: Acquire the softc lock before clearing the MIB
Reported by:	Andrei Martin <andrei.cos.martin@gmail.com>
MFC with:	caf552a607
2021-01-09 10:04:17 -05:00
Mark Johnston caf552a607 mvneta: Fix 64-bit MIB reads
It appears we must read MIB values as 2 4-byte words, lower address
first.  A single 8-byte MIB read returns the value with the lower 4
bytes copied into the upper 4 bytes, resulting in bogus byte counter
values.

Reviewed by:	mw
MFC after:	2 weeks
Sponsored by:	Rubicon Communications, LLC (Netgate)
Differential Revision:	https://reviews.freebsd.org/D27870
2021-01-04 08:32:54 -05:00
Marcin Wojtas acdc915461 Fix TX csum handling in if_mvneta
The mvneta device requires MVNETA_TX_CMD_L4_CHECKSUM_NONE bit to be set in the tx descriptor is checksum not required. However, mvneta_tx_set_csumflag() is not setting this flag currently, causing the hardware to randomly corrupt IP header during transmission.

This affects injected IPv4 packets that skips kernel IP stack processing (e.g. DHCP), as well as all IPv6 packets, since the driver currently does not offload csum for IPv6.

The fix is to remove all the early return paths from mvneta_tx_set_csumflag() which do not set the MVNETA_TX_CMD_L4_CHECKSUM_NONE flag.

PR: 248306
Submitted by: Mike Cui <cuicui@gmail.com>
Reported by: Mike Cui <cuicui@gmail.com>
2020-08-01 09:40:19 +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
Marcin Wojtas 73f20bb3a9 Implement jumbo frame support in mvneta driver
This patch introduces processing of the frames
up to 9kB by the mvneta driver. Some versions of
this NIC limit TX checksum offloading, depending
on the frame size, so add appropriate handling
of this feature.

Submitted by: Kornel Duleba
Obtained from: Semihalf
Sponsored by: Stormshield
Differential Revision: https://reviews.freebsd.org/D23225
2020-02-08 13:33:47 +00:00
Marcin Wojtas 3599e81c97 Destroy RX DMA tag on detach in mvneta driver
This patch fixes deinitialization sequence of the mvneta
driver by adding missing bus_dma_tag_destroy call.

Submitted by: Kornel Duleba <mindal@semihalf.com>
Obtained from: Semihalf
MFC after: 1 week
Sponsored by: Stormshield
2020-02-08 13:25:39 +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
Luiz Otavio O Souza e13a20dad7 Disable the auto negotiation if the port is set to fixed-link.
Tested on SG-3100 (ARMADA38X) and Espresso.bin (A37x0).  Fixes the network
on espresso.bin.

Sponsored by:	Rubicon Communications, LLC (Netgate)
2018-08-14 18:58:16 +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
Nick Hibma 3bc4bd5edd Make this compile if NO_SYSCTL_DESCR is defined.
Defining a variable with the description and then only use it in the
SYSCTL declaration led to an unused variable warning. In the SYSCTL the
passed value is discarded using __DESCR.
2017-09-28 19:57:46 +00:00
Marcin Wojtas 40c2a6da0d Fix gcc compilation issues in the mvneta driver
Compiling mvneta driver with gcc unveiled two issues, that
required fixing.

Reported by: andrew
Obtained from: Semihalf
2017-09-25 02:06:51 +00:00
Marcin Wojtas e314ac07f4 Add support for Armada 3700 in the NETA driver
This patch enables using NETA driver on Marvell Armada 3700 SoC
by introducing new compatible string, modifying clock source
obtaining and also excluding unnecessary parts.
The driver is added as a build option for arm64 platforms as well.

Submitted by: Patryk Duda <pdk@semihalf.com>
Obtained from: Semihalf
Sponsored by: Semihalf
Differential Revision: https://reviews.freebsd.org/D12258
2017-09-09 11:54:04 +00:00
Marcin Wojtas e7843f1dd6 Store virtual address of buffer in mvneta_rx_ring
Now the virtual address of received buffer is taken from a software ring.
Thanks to this, we can use the NETA driver on 64 bits architecture and
avoid 32-bit buf_cookie descriptor field limitation.

Submitted by: Patryk Duda <pdk@semihalf.com>
Obtained from: Semihalf
Sponsored by: Semihalf
Differential Revision: https://reviews.freebsd.org/D12257
2017-09-09 11:49:36 +00:00
Luiz Otavio O Souza db79a5f9f6 Allow the use of extended media types with if_mvneta, so it can report 2.5G
speeds properly.

While here remove a couple of stray white spaces.

Sponsored by:	Rubicon Communications, LLC (Netgate)
2017-06-20 18:14:56 +00:00
Zbigniew Bodek a8d7fc4ac1 Introduce Armada 38x/XP network controller support
This patch contains a new driver for the network unit of Marvell
Armada 38x/XP SoCs, called NETA. This support was thoroughly tested
and optimised in terms of stability and performance. Additional
hardware features, like Buffer Management (BM) or Parser and Classifier
(PnC) will be progressively supported as needed.

Submitted by: Fabien Thomas <fabien.thomas@stormshield.eu>
	      Arnaud Ysmal <arnaud.ysmal@stormshield.eu>
	      Zbigniew Bodek <zbb@semihalf.com>
	      Michal Mazur <mkm@semihalf.com>
	      Bartosz Szczepanek <bsz@semihalf.com>
	      Marcin Wojtas <mw@semihalf.com>

Obtained from:	Semihalf
Sponsored by:	Stormshield (main development)
		Netgate (cleanup and upstreaming)
Differential revision: https://reviews.freebsd.org/D10706
2017-06-13 18:46:29 +00:00