Commit Graph

60 Commits

Author SHA1 Message Date
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
Emmanuel Vadot
79778f8692 if_dwc: Plug set but not used variable
Sponsored by:	Beckhoff Automation GmbH & Co. KG
2022-02-21 11:08:18 +01:00
Emmanuel Vadot
f77d8d1011 dwc: Use mii_fdt function
Use the helper function to get phy mode and configure dwc accordingly.

Reviewed by:	ian
2021-04-27 19:07:33 +02:00
Oleksandr Tymoshenko
e523262107 [if_dwc] add support for multi-descriptor packets in TX path
Original if_dwc driver used m_defrag as an implementation shortcut but on
1000Mb networks it affects performance. Implement multi-descriptor support for
TX path.

Tested on RK3399-Firefly, patch adds ~15% of network throughput.

Reviewed By:	manu
Differential Revision:	https://reviews.freebsd.org/D27520
2020-12-23 12:29:29 -08:00
Emmanuel Vadot
3e5cd548af if_dwc: Honor snps,pbl property
DTS node can have this property which configure the burst length
for both TX and RX if it's the same.
This unbreak if_dwc on Allwinner A20 and possibly other boards that
uses this prop.

Reported by:	qroxana <qroxana@mail.ru>
2020-12-03 11:15:49 +00:00
Emmanuel Vadot
5e38d9e483 if_dwc: Correctly configure the DMA engine based on the fdt properties
Do not hardcode what we setup for the DMA engine configuration but
lookup the fdt properties and configuring accordingly.
Use a default value of 8 for the burst dma length for both TX and
RX, this is what we used for TX before.
2020-11-22 20:16:46 +00:00
Emmanuel Vadot
98ea5a7b9a if_dwc: Add checksum offloading support 2020-11-20 11:31:25 +00:00
Emmanuel Vadot
2b4a66ed17 if_dwc: Add flow control support 2020-11-20 11:31:04 +00:00
Emmanuel Vadot
3bbd11ee51 if_dwc: Use if_ function where appropriate
No functional changes intended
2020-11-20 11:30:23 +00:00
Emmanuel Vadot
2a35d39179 if_dwc: Reorder functions and sort them by usage
No functional changes intended
2020-11-20 11:30:01 +00:00
Emmanuel Vadot
f88e0af64a if_dwc: dwc_get_hwaddr cannot fail, change return to void
No functional changes intended
2020-11-20 11:29:20 +00:00
Emmanuel Vadot
afd0c3c268 if_dwc: Add dwc_stop_dma and use it in dwc_stop_locked
No functional changes intended
2020-11-20 11:29:00 +00:00
Emmanuel Vadot
86c7bc68ed if_dwc: Use dwc_enable_mac in dwc_stop_locked
No functional changes intended
2020-11-20 11:28:06 +00:00
Emmanuel Vadot
f368f4b109 if_dwc: Add a function to enable/disable the mac tx/rx
No functional changes intended
2020-11-20 11:27:43 +00:00
Emmanuel Vadot
b0cc649b95 if_dwc: Use if_setdrvflagbits to notify that we are running
No functional changes intended
2020-11-20 11:27:08 +00:00
Emmanuel Vadot
158ce7ba0e if_dwc: Split init code into sub function
Be clear of what we enable or init.

No functional changes intended
2020-11-20 11:26:46 +00:00
Li-Wen Hsu
fc254a2e4a Fix armv{6,7} build after r364088
Sponsored by:	The FreeBSD Foundation
2020-08-11 05:17:10 +00:00
Oleksandr Tymoshenko
824cfb4729 Improve Rockchip's integration of if_dwc
- Do not rely on U-Boot for clocks configuration, enable and set frequencies
    in the driver's attach method.
- Adjust MAC settings according to detected linespeed on RK3399 and RK3328.
- Add support for RMII PHY mode on RK3328.

Reviewed by:	manu
Differential Revision:	https://reviews.freebsd.org/D26006
2020-08-10 19:37:06 +00:00
Michal Meloun
b72e2878ab Improve if_dwc:
- refactorize packet receive path. Make sure that we don't leak mbufs
   and/or that we don't create holes in RX descriptor ring
 - slightly simplify handling with TX descriptors

MFC after:	4 weeks
2020-06-19 19:26:55 +00:00
Michal Meloun
188aee740f Finish renaming in if_dwc.
By using DWC TRM terminology, normal descriptor format should be named
extended and alternate descriptor format should be named normal.

Should not been functional change.

MFC after:	4 weeks
2020-06-19 18:34:27 +00:00
Michal Meloun
8d43a8685c Use naming nomenclature used in DesignWare TRM.
Use naming nomenclature used in DesignWare TRM.
This driver was written by using Altera (now Intel) documentation for Arria
FPGA manual. Unfortunately this manual used very different (and in some cases
opposite naming) for registers and descriptor fields. Unfortunately,
this makes future expansion extremely hard.

Should not been functional change.

MFC after:	4 weeks
2020-06-19 18:04:41 +00:00
Michal Meloun
7ed7d9798b Fix style(9). Strip write only variables.
Not a functional change.

MFC after:	1 week
2020-04-29 14:36:50 +00:00
Gleb Smirnoff
3e346c0a6c Convert to if_foreach_llmaddr() KPI. 2019-10-21 18:11:19 +00:00
Emmanuel Vadot
c069412ec3 dwc: Add more delay for chip reset
On rockchip board it seems that the value in the DTS
are not enough for reseting the chip, I don't know if
the value are really incorrect or if DELAY is not precise
enough or if the rockchip gpio driver have some "lag" of some
kind or not.
For now just add more delay.
2019-09-28 22:23:21 +00:00
Matt Macy
d7c5a620e2 ifnet: Replace if_addr_lock rwlock with epoch + mutex
Run on LLNW canaries and tested by pho@

gallatin:
Using a 14-core, 28-HTT single socket E5-2697 v3 with a 40GbE MLX5
based ConnectX 4-LX NIC, I see an almost 12% improvement in received
packet rate, and a larger improvement in bytes delivered all the way
to userspace.

When the host receiving 64 streams of netperf -H $DUT -t UDP_STREAM -- -m 1,
I see, using nstat -I mce0 1 before the patch:

InMpps OMpps  InGbs  OGbs err TCP Est %CPU syscalls csw     irq GBfree
4.98   0.00   4.42   0.00 4235592     33   83.80 4720653 2149771   1235 247.32
4.73   0.00   4.20   0.00 4025260     33   82.99 4724900 2139833   1204 247.32
4.72   0.00   4.20   0.00 4035252     33   82.14 4719162 2132023   1264 247.32
4.71   0.00   4.21   0.00 4073206     33   83.68 4744973 2123317   1347 247.32
4.72   0.00   4.21   0.00 4061118     33   80.82 4713615 2188091   1490 247.32
4.72   0.00   4.21   0.00 4051675     33   85.29 4727399 2109011   1205 247.32
4.73   0.00   4.21   0.00 4039056     33   84.65 4724735 2102603   1053 247.32

After the patch

InMpps OMpps  InGbs  OGbs err TCP Est %CPU syscalls csw     irq GBfree
5.43   0.00   4.20   0.00 3313143     33   84.96 5434214 1900162   2656 245.51
5.43   0.00   4.20   0.00 3308527     33   85.24 5439695 1809382   2521 245.51
5.42   0.00   4.19   0.00 3316778     33   87.54 5416028 1805835   2256 245.51
5.42   0.00   4.19   0.00 3317673     33   90.44 5426044 1763056   2332 245.51
5.42   0.00   4.19   0.00 3314839     33   88.11 5435732 1792218   2499 245.52
5.44   0.00   4.19   0.00 3293228     33   91.84 5426301 1668597   2121 245.52

Similarly, netperf reports 230Mb/s before the patch, and 270Mb/s after the patch

Reviewed by:	gallatin
Sponsored by:	Limelight Networks
Differential Revision:	https://reviews.freebsd.org/D15366
2018-05-18 20:13:34 +00:00
Michal Meloun
dac935533b EXTRES: Add OF node as argument to all <foo>_get_by_ofw_<bar>() functions.
In some cases, the driver must handle given properties located in
specific OF subnode. Instead of creating duplicate set of function, add
'node' as argument to existing functions, defaulting it to device OF node.

MFC after: 3 weeks
2016-07-10 18:28:15 +00:00
Jared McNeill
eeec1f9fbf Fix an issue with multicast hash filters on Amlogic and Allwinner boards.
For DWC_GMAC_ALT_DESC implementations, the multicast hash table has only
64 entries. Instead of 8 registers starting at 0x500, a pair of registers
at 0x08 and 0x0c are used instead.

Approved by:	re (hrs)
Submitted by:	Guy Yur <guyyur@gmail.com>
2016-06-12 22:55:50 +00:00
Jared McNeill
483ebfe09b Multicast filters on DWC_GMAC_ALT_DESC type implementations use a different
hash register setup. In addition, strip trailing FCS in receive path.

Reviewed by:		loos
Differential Revision:	https://reviews.freebsd.org/D6653
2016-06-08 20:22:25 +00:00
Jared McNeill
e7502187c2 Set txbuf_map array size to TX_DESC_COUNT instead of RX_DESC_COUNT. 2016-04-29 21:46:43 +00:00
Pedro F. Giffuni
73a1170a8c sys/dev: use our nitems() macro when it is avaliable through param.h.
No functional change, only trivial cases are done in this sweep,
Drivers that can get further enhancements will be done independently.

Discussed in:	freebsd-current
2016-04-19 23:37:24 +00:00
Jared McNeill
6a05f063ed Convert Allwinner port to extres clk/hwreset/regulator APIs.
Reviewed by:		andrew, gonzo, Emmanuel Vadot <manu@bidouilliste.com>
Approved by:		gonzo (mentor)
Differential Revision:	https://reviews.freebsd.org/D5752
2016-04-06 23:11:03 +00:00
Jared McNeill
d7acb49aee Add support for resetting the PHY via GPIO.
Submitted by:		Emmanuel Vadot <manu@bidouilliste.com>
Reviewed by:		andrew, jmcneill
Approved by:		adrian (mentor)
Differential Revision:	https://reviews.freebsd.org/D5505
2016-03-03 22:26:36 +00:00
Luiz Otavio O Souza
715a136ddf Fix the build by adding the alternate descriptors and MII clock defines.
This obviously should be in the last commit.
2015-09-20 14:28:06 +00:00
Luiz Otavio O Souza
5df539274f Add alternate descriptors support for if_dwc.
This also adds a newbus interface that allows a SoC to override the
following settings:

 - if_dwc specific SoC initialization;
 - if_dwc descriptor type;
 - if_dwc MII clock.

This seems to be an old version of the hardware descriptors but it is
still in use in a few SoCs (namely Allwinner A20 and Amlogic at least).

Tested on Cubieboard2 and Banana pi.

Tested for regressions on Altera Cyclone by br@ (old version).

Obtained from:	NetBSD
2015-09-20 14:13:29 +00:00
Luiz Otavio O Souza
da9a326be3 Remove unnecessary includes and, while here, sort them. 2015-09-20 13:15:09 +00:00