1 From 7b46bdaec00a675f6fac9d0b01a2105b5746ebe9 Mon Sep 17 00:00:00 2001
2 From: Lorenzo Bianconi <lorenzo@kernel.org>
3 Date: Thu, 19 Jun 2025 09:07:25 +0200
4 Subject: [PATCH 2/2] net: airoha: Differentiate hwfd buffer size for QDMA0 and
7 EN7581 SoC allows configuring the size and the number of buffers in
8 hwfd payload queue for both QDMA0 and QDMA1.
9 In order to reduce the required DRAM used for hwfd buffers queues and
10 decrease the memory footprint, differentiate hwfd buffer size for QDMA0
11 and QDMA1 and reduce hwfd buffer size to 1KB for QDMA1 (WAN) while
12 maintaining 2KB for QDMA0 (LAN).
14 Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
15 Reviewed-by: Simon Horman <horms@kernel.org>
16 Link: https://patch.msgid.link/20250619-airoha-hw-num-desc-v4-2-49600a9b319a@kernel.org
17 Signed-off-by: Jakub Kicinski <kuba@kernel.org>
19 drivers/net/ethernet/airoha/airoha_eth.c | 10 ++++++----
20 1 file changed, 6 insertions(+), 4 deletions(-)
22 --- a/drivers/net/ethernet/airoha/airoha_eth.c
23 +++ b/drivers/net/ethernet/airoha/airoha_eth.c
24 @@ -1069,14 +1069,15 @@ static int airoha_qdma_init_hfwd_queues(
25 int size, index, num_desc = HW_DSCP_NUM;
26 struct airoha_eth *eth = qdma->eth;
27 int id = qdma - ð->qdma[0];
28 + u32 status, buf_size;
33 name = devm_kasprintf(eth->dev, GFP_KERNEL, "qdma%d-buf", id);
37 + buf_size = id ? AIROHA_MAX_PACKET_SIZE / 2 : AIROHA_MAX_PACKET_SIZE;
38 index = of_property_match_string(eth->dev->of_node,
39 "memory-region-names", name);
41 @@ -1097,9 +1098,9 @@ static int airoha_qdma_init_hfwd_queues(
42 /* Compute the number of hw descriptors according to the
43 * reserved memory size and the payload buffer size
45 - num_desc = rmem->size / AIROHA_MAX_PACKET_SIZE;
46 + num_desc = div_u64(rmem->size, buf_size);
48 - size = AIROHA_MAX_PACKET_SIZE * num_desc;
49 + size = buf_size * num_desc;
50 if (!dmam_alloc_coherent(eth->dev, size, &dma_addr,
53 @@ -1112,9 +1113,10 @@ static int airoha_qdma_init_hfwd_queues(
56 airoha_qdma_wr(qdma, REG_FWD_DSCP_BASE, dma_addr);
57 + /* QDMA0: 2KB. QDMA1: 1KB */
58 airoha_qdma_rmw(qdma, REG_HW_FWD_DSCP_CFG,
59 HW_FWD_DSCP_PAYLOAD_SIZE_MASK,
60 - FIELD_PREP(HW_FWD_DSCP_PAYLOAD_SIZE_MASK, 0));
61 + FIELD_PREP(HW_FWD_DSCP_PAYLOAD_SIZE_MASK, !!id));
62 airoha_qdma_rmw(qdma, REG_FWD_DSCP_LOW_THR, FWD_DSCP_LOW_THR_MASK,
63 FIELD_PREP(FWD_DSCP_LOW_THR_MASK, 128));
64 airoha_qdma_rmw(qdma, REG_LMGR_INIT_CFG,