Commit Graph

43 Commits

Author SHA1 Message Date
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
Luiz Otavio O Souza
8fbc5d1840 Do not call mii_mediachg() from NIC interrupt handler.
This fixes the link instability on banana pi (A20).

Suggested by:	yongari
2015-09-12 16:46:41 +00:00
Luiz Otavio O Souza
1d7a730974 When initializing the (unused) TX descriptors it is not necessary set the
chain bit.

Obtained from:	NetBSD
2015-07-06 17:13:17 +00:00
Luiz Otavio O Souza
ff0752c870 Use uint32_t consistently to store registers values.
Always use unsigned numbers to avoid undefined behavior on (1 << 31).

Remove unused variables and some stray semicolons.

No functional changes.
2015-07-06 16:45:48 +00:00
Luiz Otavio O Souza
a5221d68dc Fix the sent packets statistics for if_dwc. 2015-07-06 03:06:13 +00:00
Luiz Otavio O Souza
ecb3497f56 Fix wrong variable name in the previous commit.
Pointy hat to:	loos
Reported by:	araujo
2015-06-03 15:18:32 +00:00
Luiz Otavio O Souza
9500101c2f Fix the OACTIVE handling on if_dwc.
Previously the OACTIVE flag was being set when the tx descriptors are fully
allocated but it wasn't unset anywhere.

As soon as a packet is transmitted, unset the OACTIVE flag and call start
routine to push any pending packets from the tx queue.

This closes another race where a full tx queue would jam the tx path (tx
queue is full, new packets cannot be added to queue and dwc_txstart never
gets called).
2015-06-03 14:48:03 +00:00
Ruslan Bukin
db8a143a94 o Remove superfluous includes
o Avoid NULL pointer access
o Fix 'set but not used' warning

Submitted by:	Sebastian Huber <sebastian.huber@embedded-brains.de>
2015-04-03 11:37:23 +00:00
Ruslan Bukin
d8e5258da2 o Correct the condition in reset procedure
o Setup interrupt hander after reset, not before

This fixes operation on ODROID-C1 (Amlogic S805)

Submitted by:	John Wehle <john@feith.com>
2015-02-13 11:00:13 +00:00
Gleb Smirnoff
08c95c53d7 Mechanically convert to if_inc_counter(). 2014-09-27 20:43:01 +00:00
Ruslan Bukin
5d43fd685b Add driver for Synopsys DesignWare 3504-0 Universal 10/100/1000
Ethernet MAC.

Sponsored by:	DARPA, AFRL
2014-09-25 18:03:14 +00:00