Commit graph

94 commits

Author SHA1 Message Date
Mitchell Horne fae39d8da9 dwc: fix DEBUG macro name
It conflicts with the general "DEBUG" macro defined as an option in LINT
builds. Since this is actually unused, just rename it to GMAC_DEBUG.

Reviewed by:	manu
MFC after:	3 days
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D44102
2024-02-27 18:10:14 -04:00
Gordon Bergling e125371fb6 dwc: Fix two typos in a source code comment
- s/recevied/received/
- s/descriptr/descriptor/

MFC after:	3 days
2024-01-22 22:03:29 +01:00
Emmanuel Vadot 62e8ccc3a4 syscon: Move syscon code in dev/syscon
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/D43196
2024-01-10 19:20:37 +01:00
Emmanuel Vadot b2f0caf160 regulator: Move regulator code in dev/regulator
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:	emaste, imp
Sponsored by:   Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D43194
2024-01-10 19:20:32 +01:00
Emmanuel Vadot 1f469a9fc4 hwreset: Move reset code in dev/hwreset
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:	imp
Sponsored by:   Beckhoff Automation GmbH & Co. KG
Differential Revision:	https://reviews.freebsd.org/D43192
2024-01-10 19:20:28 +01:00
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
Emmanuel Vadot 0cb63dcac4 Revert "dwc: re-rewrite barrier part"
Turns out we need all the barrier.
The one before writing the OWN bit is needed so the DMA engine
have coherent data, the second one (after the OWN bit is set) is
also needed because the DMA buffers are allocated with VM_MEMATTR_DEFAULT
whic equals to being cached.

This reverts commit 2b4f615e7d4720b16007cfa8aaedf720f572067a.
This reverts commit 4870346488051b9c4a1dc8b11cab55d4e5b7c230.

Reported by:	mmel
2023-10-16 21:48:19 +02:00
Emmanuel Vadot 43cd6bbba0 dwc: re-rewrite barrier part
We need the DMA engine to have everything coherent *before* we
set the OWN bit (the bit that tells the DMA engine that it owns
the descriptor).

Fixes:	487034648805 ("dwc: Rewrite barrier part")

Reported by:	jhb
2023-10-12 20:56:16 +02:00
Emmanuel Vadot 38cbdae33b dwc: Rewrite barrier part
We only need a barrier after writing the OWN bit so everything is
coherent for the DMA engine.
2023-10-06 19:05:45 +02:00
Emmanuel Vadot cf037a17c7 dwc: rockchip: Properly calculate mii clock based on pclk_mac 2023-10-06 19:05:43 +02:00
Emmanuel Vadot 7854d0f658 dwc: Get the mii clock after calling IF_DWC_INIT
We need to calculate it based on the clocks and they aren't started
before IF_DWC_INIT.
2023-10-06 19:05:40 +02:00
Emmanuel Vadot 7786911ffd dwc: Rewrite part of the descriptors setup functions
- Add a txdesc_clear which clears the tx desc instead of doing that in
   dwc_setup_txdesc based on arguments.
 - Remove dwc_set_owner, in the end we always set the owner of the desc
   as we do it for id > 0 and then for the first one.
 - Remove dwc_ prefix

No functional changes intended.
2023-10-06 19:05:37 +02:00
Emmanuel Vadot b911f50400 dwc: if_dwc_aw: Include net/if_media.h
Needed my miivar.h

Fixes:	6b73554e3e9b ("dwc: Do not re-invent phy mode type")
2023-10-05 19:00:55 +02:00
Emmanuel Vadot 4b7975ecdc dwc: Remove if_dwc_mac_type
This doesn't represent the mac_type but if the DMA engine support
extended descriptors.
Read the HW_FEATURE register to learn if the DMA engine supports it.

No functional changes intended.
2023-10-05 17:34:40 +02:00
Emmanuel Vadot cef444d068 dwc: Move BUS_MODE_DEFAULT_PBL; in if_dwcvar.h
And rename it to DMA_DEFAULT_PBL, this is the default for all (most ?)
dma engine that dwc should support.
While here stop including dwc1000_reg.h in if_dwc.c, we don't need it anymore.

No functional changes intended.
2023-10-05 17:34:40 +02:00
Emmanuel Vadot 801fb66a7e dwc: Do not re-invent phy mode type
Directly uses the MII_CONTYPE_*

No functional changes intended.
2023-10-05 17:34:40 +02:00
Emmanuel Vadot 5d88a52be4 dwc: Move dma engine configuration to dwc1000_dma.c
No functional changes intended.
2023-10-05 17:34:40 +02:00
Emmanuel Vadot 363b7c39fb dwc: Move the dma reset code in dwc1000_dma.c
No functional changes intended
2023-10-05 17:34:40 +02:00
Emmanuel Vadot f0a7dd7703 dwc: Setup desc addresses in the dma init function. 2023-10-05 17:34:40 +02:00
Emmanuel Vadot 29776aa436 dwc: Move interrupt related code to core and dma file
No functional changes intended.
2023-10-05 17:34:40 +02:00
Emmanuel Vadot fe82f82dcc dwc: Put all DMA related defines in dma1000_dma.c
No need to polute dwm1000_dma.h now.

No functional changes intended.
2023-10-05 17:34:39 +02:00
Emmanuel Vadot 627726b5b6 dwc: Move struct dwc_hash_maddr_ctx declaration in dwc1000_core
it's only used there.

No functional change intended.
2023-10-05 17:34:39 +02:00
Emmanuel Vadot afa0f66e81 dwc: Move the txstart dma part to dwc1000_dma
This is dma related to move it to the dma file.

No functional changes intended.
2023-10-05 17:34:39 +02:00
Emmanuel Vadot 62519d5a4f dwc: Split core functions
Synopsis/Designware controller have multiple version. The version currently
supported by dwc(4) is the version 3 and it's usually called 1000 for gigabit.
In the goal to support all of those in the same base driver start splitting the
core function to a new file.

No functional changes intended.
2023-10-05 17:34:39 +02:00
Emmanuel Vadot 972adf0f97 dwc: Split dma functions
Synopsis/Designware controller have multiple dma version, the one included
in the driver is the base one. if_awg is one example of a dwc variant that
have another DMA controller. eqos is a newer variant of dwc that have a newer
dma controller.
In the goal to support all of those in the same base driver start splitting the
dma function to a new file.

No functional changes intended.
2023-10-05 17:34:39 +02:00
Emmanuel Vadot c36125f6cc dwc: Rename if_dwc.h to dwc1000_reg.h
Synopsis/Designware controller have multiple version. The version currently
supported by dwc(4) is the version 3 and it's usually called 1000 for gigabit.
This file only have definition for the registers of this version so rename it.

No functional changes intended.
2023-10-05 17:34:39 +02:00
Emmanuel Vadot 9e3879fcc1 dwc: Drop 'All rights reserved'
Discussed with:	br
2023-10-05 17:34:39 +02:00
Emmanuel Vadot 50059a60ed dwc: Rewrite clock and reset functions
snps,dwmac have one required clock named stmmaceth and one optional pclk,
correctly handle both in if_dwc, no need to get/enable stmmacseth again
in if_dwc_rk.
It also have one required reset also named stmmaceth and one optional ahb,
correctly handle both.
Rockchip have another optional clock named clk_mac_speed, get it and enable it
if present. Also fix the optional RMII clocks, they were previously wrongly
enabled in RGMII case.
2023-10-05 17:34:38 +02:00
Emmanuel Vadot b69c49d106 dwc: Add support for aal
snps,aal is used to indicate that the DMA engine should
use Address-Aligned Beats.
2023-10-05 17:34:38 +02:00
Emmanuel Vadot f4bb6ea521 dwc: Add support for mixed-burst
snps,mixed-burst is used to indicate that the DMA engine should
use mixed-burst mode.
2023-10-05 17:34:38 +02:00
Emmanuel Vadot 27f03f1608 dwc: Remove unused GPIO_ACTIVE_LOW define
While here move comment block above the appropriate functions.
2023-10-05 17:34:38 +02:00
Emmanuel Vadot f114aadd3e dwc: Rename dwc_reset to dwc_reset_phy
It only deals with reseting the phy.
While here avoid calling ofw_bus_get_node again and save the node in softc.
2023-10-05 17:34:38 +02:00
Emmanuel Vadot 432ae724e6 dwc: Move every sub drivers to dev/dwc
It makes it easier to find all the sub drivers and change them if needed.
While here do not gate dwc_rk with soc options, dwc_rk is made for all rockchip
SoCs. Same thing for dwc_socfpga
2023-10-05 17:34:38 +02:00
Justin Hibbits 2a3716432d IfAPI: Retire if_etherbpfmtap() and if_bpfmtap()
Summary:
These came in the original DrvAPI commits in 2014, and are obsoleted by
bpf_mtap_if() and ether_bpf_mtap_if().  The `_if` suffix, rather than
prefix, conveys that it's operating on the bpf of the interface, instead
than the interface itself.

Reviewed by:	glebius
Sponsored by:	Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D41146
2023-08-25 12:50:14 -04:00
Warner Losh 031beb4e23 sys: Remove $FreeBSD$: one-line sh pattern
Remove /^\s*#[#!]?\s*\$FreeBSD\$.*$\n/
2023-08-16 11:54:58 -06: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
John Baldwin 2fd903276d dwc(4): Use bool rather than boolean_t.
This was already using true/false rather than TRUE/FALSE.

Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D39925
2023-05-04 12:33:20 -07:00
Justin Hibbits 068f2c0e10 Mechanically convert dwc(4) to IfAPI
Reviewed by:	manu (older)
Sponsored by:	Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D37846
2023-03-07 09:49:11 -05:00
Jiahao LI 6501fcdc0a if_dwc: fix reinitialization with changed MAC
It was observed that on RockPro64 hardware, the dwc interface is unable
to receive packets after being assigned a new MAC address. The fix is
simply to call mii_mediachg() before touching any device registers in
dwc_init_locked(). This is consistent with what the OpenBSD driver does.

PR:		263820
MFC after:	1 week
2022-09-09 12:31:26 -03:00
Mitchell Horne 9718759043 if_dwc: avoid duplicate packet counts
We already increment the unicast IPACKETS and OPACKETS counters in the
rx/tx paths, respectively. Multicast packets are counted in the generic
ethernet code. Therefore, we shouldn't increment these counters in
dwc_harvest_stats().

Drop the early return from dwc_rxfinish_one() so that we still count
received packets with e.g. a checksum error.

PR:		263817
Reported by:	Jiahao LI <jiahali@blackberry.com>
Reviewed by:	manu
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D35499
2022-06-23 15:15:10 -03:00
Jiahao Li 35c9edab41 if_dwc: enable RX checksum offload feature
We claim support in ifcaps, but don't actually enable it.

PR:		263886
Reviewed by:	manu
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D35498
2022-06-23 15:15:10 -03:00
Mitchell Horne 27b39e58b3 if_dwc: add detach method
It can be useful for testing.

Reviewed by:	manu
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D35496
2022-06-23 15:15:10 -03:00
Mitchell Horne ca01879004 if_dwc: consistently use if.c helper methods
And if_t rather than struct ifnet *. No functional change intended.

Reviewed by:	manu
MFC after:	1 week
Sponsored by:	The FreeBSD Foundation
Differential Revision:	https://reviews.freebsd.org/D35497
2022-06-23 15:15:09 -03:00
John Baldwin e55d0536b4 dwc: Remove unused devclass argument to DRIVER_MODULE. 2022-05-09 14:26:45 -07:00
John Baldwin 3e38757d4c Remove unused miibus_devclass and miibus_fdt_devclass. 2022-05-06 15:39:28 -07:00
Emmanuel Vadot da6252a6a0 dwc: Support phy mode MII
Some board use dwc phy in MII mode, so do not fail to attach if this is
the case.
Only rockchip code uses the phy mode to program some custom syscon register.

PR:	260848
MFC after:	1 week
Sponsored by:	Beckhoff Automation GmbH & Co. KG
2022-02-22 10:01:56 +01:00
Emmanuel Vadot 30f16ad460 dwc: Release resources when attach fails
PR:	259282
MFC after:	1 week
Sponsored by:	Beckhoff Automation GmbH & Co. KG
2022-02-22 10:01:54 +01:00
Emmanuel Vadot a5339ba3ff dwc: Make ext_resources non-optional
EXT_RESOURCES have been introduced in 12-CURRENT and all supported
releases have it enabled in their kernel config.

MFC after:	1 month
Differential Revision:	https://reviews.freebsd.org/D33820
2022-02-21 17:28:37 +01:00