a380adf3b73a8728fd8b89b8c11ddfa190bcb875
[openwrt/staging/thess.git] /
1 From c683e378c0907e66cee939145edf936c254ff1e3 Mon Sep 17 00:00:00 2001
2 From: Lorenzo Bianconi <lorenzo@kernel.org>
3 Date: Wed, 21 May 2025 09:16:39 +0200
4 Subject: [PATCH 3/3] net: airoha: Add the capability to allocate hfwd
5 descriptors in SRAM
6
7 In order to improve packet processing and packet forwarding
8 performances, EN7581 SoC supports consuming SRAM instead of DRAM for
9 hw forwarding descriptors queue.
10 For downlink hw accelerated traffic request to consume SRAM memory
11 for hw forwarding descriptors queue.
12
13 Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
14 Reviewed-by: Simon Horman <horms@kernel.org>
15 Link: https://patch.msgid.link/20250521-airopha-desc-sram-v3-4-a6e9b085b4f0@kernel.org
16 Signed-off-by: Paolo Abeni <pabeni@redhat.com>
17 ---
18 drivers/net/ethernet/airoha/airoha_eth.c | 11 +----------
19 drivers/net/ethernet/airoha/airoha_eth.h | 9 +++++++++
20 drivers/net/ethernet/airoha/airoha_ppe.c | 6 ++++++
21 3 files changed, 16 insertions(+), 10 deletions(-)
22
23 --- a/drivers/net/ethernet/airoha/airoha_eth.c
24 +++ b/drivers/net/ethernet/airoha/airoha_eth.c
25 @@ -71,15 +71,6 @@ static void airoha_qdma_irq_disable(stru
26 airoha_qdma_set_irqmask(irq_bank, index, mask, 0);
27 }
28
29 -static bool airhoa_is_lan_gdm_port(struct airoha_gdm_port *port)
30 -{
31 - /* GDM1 port on EN7581 SoC is connected to the lan dsa switch.
32 - * GDM{2,3,4} can be used as wan port connected to an external
33 - * phy module.
34 - */
35 - return port->id == 1;
36 -}
37 -
38 static void airoha_set_macaddr(struct airoha_gdm_port *port, const u8 *addr)
39 {
40 struct airoha_eth *eth = port->qdma->eth;
41 @@ -1125,7 +1116,7 @@ static int airoha_qdma_init_hfwd_queues(
42 LMGR_INIT_START | LMGR_SRAM_MODE_MASK |
43 HW_FWD_DESC_NUM_MASK,
44 FIELD_PREP(HW_FWD_DESC_NUM_MASK, HW_DSCP_NUM) |
45 - LMGR_INIT_START);
46 + LMGR_INIT_START | LMGR_SRAM_MODE_MASK);
47
48 return read_poll_timeout(airoha_qdma_rr, status,
49 !(status & LMGR_INIT_START), USEC_PER_MSEC,
50 --- a/drivers/net/ethernet/airoha/airoha_eth.h
51 +++ b/drivers/net/ethernet/airoha/airoha_eth.h
52 @@ -597,6 +597,15 @@ u32 airoha_rmw(void __iomem *base, u32 o
53 #define airoha_qdma_clear(qdma, offset, val) \
54 airoha_rmw((qdma)->regs, (offset), (val), 0)
55
56 +static inline bool airhoa_is_lan_gdm_port(struct airoha_gdm_port *port)
57 +{
58 + /* GDM1 port on EN7581 SoC is connected to the lan dsa switch.
59 + * GDM{2,3,4} can be used as wan port connected to an external
60 + * phy module.
61 + */
62 + return port->id == 1;
63 +}
64 +
65 bool airoha_is_valid_gdm_port(struct airoha_eth *eth,
66 struct airoha_gdm_port *port);
67
68 --- a/drivers/net/ethernet/airoha/airoha_ppe.c
69 +++ b/drivers/net/ethernet/airoha/airoha_ppe.c
70 @@ -251,6 +251,12 @@ static int airoha_ppe_foe_entry_prepare(
71 else
72 pse_port = 2; /* uplink relies on GDM2 loopback */
73 val |= FIELD_PREP(AIROHA_FOE_IB2_PSE_PORT, pse_port);
74 +
75 + /* For downlink traffic consume SRAM memory for hw forwarding
76 + * descriptors queue.
77 + */
78 + if (airhoa_is_lan_gdm_port(port))
79 + val |= AIROHA_FOE_IB2_FAST_PATH;
80 }
81
82 if (is_multicast_ether_addr(data->eth.h_dest))