Skip to content

Commit dc35a10

Browse files
wojtas-marcindavem330
authored andcommitted
net: mvneta: bm: add support for hardware buffer management
Buffer manager (BM) is a dedicated hardware unit that can be used by all ethernet ports of Armada XP and 38x SoC's. It allows to offload CPU on RX path by sparing DRAM access on refilling buffer pool, hardware-based filling of descriptor ring data and better memory utilization due to HW arbitration for using 'short' pools for small packets. Tests performed with A388 SoC working as a network bridge between two packet generators showed increase of maximum processed 64B packets by ~20k (~555k packets with BM enabled vs ~535 packets without BM). Also when pushing 1500B-packets with a line rate achieved, CPU load decreased from around 25% without BM to 20% with BM. BM comprise up to 4 buffer pointers' (BP) rings kept in DRAM, which are called external BP pools - BPPE. Allocating and releasing buffer pointers (BP) to/from BPPE is performed indirectly by write/read access to a dedicated internal SRAM, where internal BP pools (BPPI) are placed. BM hardware controls status of BPPE automatically, as well as assigning proper buffers to RX descriptors. For more details please refer to Functional Specification of Armada XP or 38x SoC. In order to enable support for a separate hardware block, common for all ports, a new driver has to be implemented ('mvneta_bm'). It provides initialization sequence of address space, clocks, registers, SRAM, empty pools' structures and also obtaining optional configuration from DT (please refer to device tree binding documentation). mvneta_bm exposes also a necessary API to mvneta driver, as well as a dedicated structure with BM information (bm_priv), whose presence is used as a flag notifying of BM usage by port. It has to be ensured that mvneta_bm probe is executed prior to the ones in ports' driver. In case BM is not used or its probe fails, mvneta falls back to use software buffer management. A sequence executed in mvneta_probe function is modified in order to have an access to needed resources before possible port's BM initialization is done. According to port-pools mapping provided by DT appropriate registers are configured and the buffer pools are filled. RX path is modified accordingly. Becaues the hardware allows a wide variety of configuration options, following assumptions are made: * using BM mechanisms can be selectively disabled/enabled basing on DT configuration among the ports * 'long' pool's single buffer size is tied to port's MTU * using 'long' pool by port is obligatory and it cannot be shared * using 'short' pool for smaller packets is optional * one 'short' pool can be shared among all ports This commit enables hardware buffer management operation cooperating with existing mvneta driver. New device tree binding documentation is added and the one of mvneta is updated accordingly. [[email protected]: removed the suspend/resume part] Signed-off-by: Marcin Wojtas <[email protected]> Signed-off-by: Gregory CLEMENT <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent f2900ac commit dc35a10

File tree

7 files changed

+1285
-39
lines changed

7 files changed

+1285
-39
lines changed

Documentation/devicetree/bindings/net/marvell-armada-370-neta.txt

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,30 @@ Optional properties:
1818
"core" for core clock and "bus" for the optional bus clock.
1919

2020

21+
Optional properties (valid only for Armada XP/38x):
22+
23+
- buffer-manager: a phandle to a buffer manager node. Please refer to
24+
Documentation/devicetree/bindings/net/marvell-neta-bm.txt
25+
- bm,pool-long: ID of a pool, that will accept all packets of a size
26+
higher than 'short' pool's threshold (if set) and up to MTU value.
27+
Obligatory, when the port is supposed to use hardware
28+
buffer management.
29+
- bm,pool-short: ID of a pool, that will be used for accepting
30+
packets of a size lower than given threshold. If not set, the port
31+
will use a single 'long' pool for all packets, as defined above.
32+
2133
Example:
2234

23-
ethernet@d0070000 {
35+
ethernet@70000 {
2436
compatible = "marvell,armada-370-neta";
25-
reg = <0xd0070000 0x2500>;
37+
reg = <0x70000 0x2500>;
2638
interrupts = <8>;
2739
clocks = <&gate_clk 4>;
2840
tx-csum-limit = <9800>
2941
status = "okay";
3042
phy = <&phy0>;
3143
phy-mode = "rgmii-id";
44+
buffer-manager = <&bm>;
45+
bm,pool-long = <0>;
46+
bm,pool-short = <1>;
3247
};
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
* Marvell Armada 380/XP Buffer Manager driver (BM)
2+
3+
Required properties:
4+
5+
- compatible: should be "marvell,armada-380-neta-bm".
6+
- reg: address and length of the register set for the device.
7+
- clocks: a pointer to the reference clock for this device.
8+
- internal-mem: a phandle to BM internal SRAM definition.
9+
10+
Optional properties (port):
11+
12+
- pool<0 : 3>,capacity: size of external buffer pointers' ring maintained
13+
in DRAM. Can be set for each pool (id 0 : 3) separately. The value has
14+
to be chosen between 128 and 16352 and it also has to be aligned to 32.
15+
Otherwise the driver would adjust a given number or choose default if
16+
not set.
17+
- pool<0 : 3>,pkt-size: maximum size of a packet accepted by a given buffer
18+
pointers' pool (id 0 : 3). It will be taken into consideration only when pool
19+
type is 'short'. For 'long' ones it would be overridden by port's MTU.
20+
If not set a driver will choose a default value.
21+
22+
In order to see how to hook the BM to a given ethernet port, please
23+
refer to Documentation/devicetree/bindings/net/marvell-armada-370-neta.txt.
24+
25+
Example:
26+
27+
- main node:
28+
29+
bm: bm@c8000 {
30+
compatible = "marvell,armada-380-neta-bm";
31+
reg = <0xc8000 0xac>;
32+
clocks = <&gateclk 13>;
33+
internal-mem = <&bm_bppi>;
34+
status = "okay";
35+
pool2,capacity = <4096>;
36+
pool1,pkt-size = <512>;
37+
};
38+
39+
- internal SRAM node:
40+
41+
bm_bppi: bm-bppi {
42+
compatible = "mmio-sram";
43+
reg = <MBUS_ID(0x0c, 0x04) 0 0x100000>;
44+
ranges = <0 MBUS_ID(0x0c, 0x04) 0 0x100000>;
45+
#address-cells = <1>;
46+
#size-cells = <1>;
47+
clocks = <&gateclk 13>;
48+
status = "okay";
49+
};

drivers/net/ethernet/marvell/Kconfig

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,19 @@ config MVMDIO
4040

4141
This driver is used by the MV643XX_ETH and MVNETA drivers.
4242

43+
config MVNETA_BM
44+
tristate "Marvell Armada 38x/XP network interface BM support"
45+
depends on MVNETA
46+
---help---
47+
This driver supports auxiliary block of the network
48+
interface units in the Marvell ARMADA XP and ARMADA 38x SoC
49+
family, which is called buffer manager.
50+
51+
This driver, when enabled, strictly cooperates with mvneta
52+
driver and is common for all network ports of the devices,
53+
even for Armada 370 SoC, which doesn't support hardware
54+
buffer management.
55+
4356
config MVNETA
4457
tristate "Marvell Armada 370/38x/XP network interface support"
4558
depends on PLAT_ORION

drivers/net/ethernet/marvell/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
obj-$(CONFIG_MVMDIO) += mvmdio.o
66
obj-$(CONFIG_MV643XX_ETH) += mv643xx_eth.o
7+
obj-$(CONFIG_MVNETA_BM) += mvneta_bm.o
78
obj-$(CONFIG_MVNETA) += mvneta.o
89
obj-$(CONFIG_MVPP2) += mvpp2.o
910
obj-$(CONFIG_PXA168_ETH) += pxa168_eth.o

0 commit comments

Comments
 (0)