Skip to content

Commit 31eaaa5

Browse files
author
Paolo Abeni
committed
Merge branch 'add-the-capability-to-consume-sram-for-hwfd-descriptor-queue-in-airoha_eth-driver'
Lorenzo Bianconi says: ==================== Add the capability to consume SRAM for hwfd descriptor queue in airoha_eth driver In order to improve packet processing and packet forwarding performances, EN7581 SoC supports consuming SRAM instead of DRAM for hw forwarding descriptors queue. For downlink hw accelerated traffic request to consume SRAM memory for hw forwarding descriptors queue. Moreover, in some configurations QDMA blocks require a contiguous block of system memory for hwfd buffers queue. Introduce the capability to allocate hw buffers forwarding queue via the reserved-memory DTS property instead of running dmam_alloc_coherent(). v2: https://lore.kernel.org/r/[email protected] v1: https://lore.kernel.org/r/[email protected] ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents e272bbc + c683e37 commit 31eaaa5

File tree

4 files changed

+60
-24
lines changed

4 files changed

+60
-24
lines changed

Documentation/devicetree/bindings/net/airoha,en7581-eth.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,16 @@ properties:
5757
- const: hsi-mac
5858
- const: xfp-mac
5959

60+
memory-region:
61+
items:
62+
- description: QDMA0 buffer memory
63+
- description: QDMA1 buffer memory
64+
65+
memory-region-names:
66+
items:
67+
- const: qdma0-buf
68+
- const: qdma1-buf
69+
6070
"#address-cells":
6171
const: 1
6272

@@ -140,6 +150,9 @@ examples:
140150
<GIC_SPI 49 IRQ_TYPE_LEVEL_HIGH>,
141151
<GIC_SPI 64 IRQ_TYPE_LEVEL_HIGH>;
142152
153+
memory-region = <&qdma0_buf>, <&qdma1_buf>;
154+
memory-region-names = "qdma0-buf", "qdma1-buf";
155+
143156
airoha,npu = <&npu>;
144157
145158
#address-cells = <1>;

drivers/net/ethernet/airoha/airoha_eth.c

Lines changed: 32 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
#include <linux/of.h>
77
#include <linux/of_net.h>
8+
#include <linux/of_reserved_mem.h>
89
#include <linux/platform_device.h>
910
#include <linux/tcp.h>
1011
#include <linux/u64_stats_sync.h>
@@ -70,15 +71,6 @@ static void airoha_qdma_irq_disable(struct airoha_irq_bank *irq_bank,
7071
airoha_qdma_set_irqmask(irq_bank, index, mask, 0);
7172
}
7273

73-
static bool airhoa_is_lan_gdm_port(struct airoha_gdm_port *port)
74-
{
75-
/* GDM1 port on EN7581 SoC is connected to the lan dsa switch.
76-
* GDM{2,3,4} can be used as wan port connected to an external
77-
* phy module.
78-
*/
79-
return port->id == 1;
80-
}
81-
8274
static void airoha_set_macaddr(struct airoha_gdm_port *port, const u8 *addr)
8375
{
8476
struct airoha_eth *eth = port->qdma->eth;
@@ -1072,24 +1064,46 @@ static void airoha_qdma_cleanup_tx_queue(struct airoha_queue *q)
10721064
static int airoha_qdma_init_hfwd_queues(struct airoha_qdma *qdma)
10731065
{
10741066
struct airoha_eth *eth = qdma->eth;
1067+
int id = qdma - &eth->qdma[0];
10751068
dma_addr_t dma_addr;
1069+
const char *name;
1070+
int size, index;
10761071
u32 status;
1077-
int size;
10781072

10791073
size = HW_DSCP_NUM * sizeof(struct airoha_qdma_fwd_desc);
1080-
qdma->hfwd.desc = dmam_alloc_coherent(eth->dev, size, &dma_addr,
1081-
GFP_KERNEL);
1082-
if (!qdma->hfwd.desc)
1074+
if (!dmam_alloc_coherent(eth->dev, size, &dma_addr, GFP_KERNEL))
10831075
return -ENOMEM;
10841076

10851077
airoha_qdma_wr(qdma, REG_FWD_DSCP_BASE, dma_addr);
10861078

1087-
size = AIROHA_MAX_PACKET_SIZE * HW_DSCP_NUM;
1088-
qdma->hfwd.q = dmam_alloc_coherent(eth->dev, size, &dma_addr,
1089-
GFP_KERNEL);
1090-
if (!qdma->hfwd.q)
1079+
name = devm_kasprintf(eth->dev, GFP_KERNEL, "qdma%d-buf", id);
1080+
if (!name)
10911081
return -ENOMEM;
10921082

1083+
index = of_property_match_string(eth->dev->of_node,
1084+
"memory-region-names", name);
1085+
if (index >= 0) {
1086+
struct reserved_mem *rmem;
1087+
struct device_node *np;
1088+
1089+
/* Consume reserved memory for hw forwarding buffers queue if
1090+
* available in the DTS
1091+
*/
1092+
np = of_parse_phandle(eth->dev->of_node, "memory-region",
1093+
index);
1094+
if (!np)
1095+
return -ENODEV;
1096+
1097+
rmem = of_reserved_mem_lookup(np);
1098+
of_node_put(np);
1099+
dma_addr = rmem->base;
1100+
} else {
1101+
size = AIROHA_MAX_PACKET_SIZE * HW_DSCP_NUM;
1102+
if (!dmam_alloc_coherent(eth->dev, size, &dma_addr,
1103+
GFP_KERNEL))
1104+
return -ENOMEM;
1105+
}
1106+
10931107
airoha_qdma_wr(qdma, REG_FWD_BUF_BASE, dma_addr);
10941108

10951109
airoha_qdma_rmw(qdma, REG_HW_FWD_DSCP_CFG,
@@ -1101,7 +1115,7 @@ static int airoha_qdma_init_hfwd_queues(struct airoha_qdma *qdma)
11011115
LMGR_INIT_START | LMGR_SRAM_MODE_MASK |
11021116
HW_FWD_DESC_NUM_MASK,
11031117
FIELD_PREP(HW_FWD_DESC_NUM_MASK, HW_DSCP_NUM) |
1104-
LMGR_INIT_START);
1118+
LMGR_INIT_START | LMGR_SRAM_MODE_MASK);
11051119

11061120
return read_poll_timeout(airoha_qdma_rr, status,
11071121
!(status & LMGR_INIT_START), USEC_PER_MSEC,

drivers/net/ethernet/airoha/airoha_eth.h

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -513,12 +513,6 @@ struct airoha_qdma {
513513

514514
struct airoha_queue q_tx[AIROHA_NUM_TX_RING];
515515
struct airoha_queue q_rx[AIROHA_NUM_RX_RING];
516-
517-
/* descriptor and packet buffers for qdma hw forward */
518-
struct {
519-
void *desc;
520-
void *q;
521-
} hfwd;
522516
};
523517

524518
struct airoha_gdm_port {
@@ -603,6 +597,15 @@ u32 airoha_rmw(void __iomem *base, u32 offset, u32 mask, u32 val);
603597
#define airoha_qdma_clear(qdma, offset, val) \
604598
airoha_rmw((qdma)->regs, (offset), (val), 0)
605599

600+
static inline bool airhoa_is_lan_gdm_port(struct airoha_gdm_port *port)
601+
{
602+
/* GDM1 port on EN7581 SoC is connected to the lan dsa switch.
603+
* GDM{2,3,4} can be used as wan port connected to an external
604+
* phy module.
605+
*/
606+
return port->id == 1;
607+
}
608+
606609
bool airoha_is_valid_gdm_port(struct airoha_eth *eth,
607610
struct airoha_gdm_port *port);
608611

drivers/net/ethernet/airoha/airoha_ppe.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,12 @@ static int airoha_ppe_foe_entry_prepare(struct airoha_eth *eth,
251251
else
252252
pse_port = 2; /* uplink relies on GDM2 loopback */
253253
val |= FIELD_PREP(AIROHA_FOE_IB2_PSE_PORT, pse_port);
254+
255+
/* For downlink traffic consume SRAM memory for hw forwarding
256+
* descriptors queue.
257+
*/
258+
if (airhoa_is_lan_gdm_port(port))
259+
val |= AIROHA_FOE_IB2_FAST_PATH;
254260
}
255261

256262
if (is_multicast_ether_addr(data->eth.h_dest))

0 commit comments

Comments
 (0)