Skip to content

Commit 7b46bda

Browse files
LorenzoBianconikuba-moo
authored andcommitted
net: airoha: Differentiate hwfd buffer size for QDMA0 and QDMA1
EN7581 SoC allows configuring the size and the number of buffers in hwfd payload queue for both QDMA0 and QDMA1. In order to reduce the required DRAM used for hwfd buffers queues and decrease the memory footprint, differentiate hwfd buffer size for QDMA0 and QDMA1 and reduce hwfd buffer size to 1KB for QDMA1 (WAN) while maintaining 2KB for QDMA0 (LAN). Signed-off-by: Lorenzo Bianconi <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent edf8afe commit 7b46bda

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

drivers/net/ethernet/airoha/airoha_eth.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,14 +1068,15 @@ static int airoha_qdma_init_hfwd_queues(struct airoha_qdma *qdma)
10681068
int size, index, num_desc = HW_DSCP_NUM;
10691069
struct airoha_eth *eth = qdma->eth;
10701070
int id = qdma - &eth->qdma[0];
1071+
u32 status, buf_size;
10711072
dma_addr_t dma_addr;
10721073
const char *name;
1073-
u32 status;
10741074

10751075
name = devm_kasprintf(eth->dev, GFP_KERNEL, "qdma%d-buf", id);
10761076
if (!name)
10771077
return -ENOMEM;
10781078

1079+
buf_size = id ? AIROHA_MAX_PACKET_SIZE / 2 : AIROHA_MAX_PACKET_SIZE;
10791080
index = of_property_match_string(eth->dev->of_node,
10801081
"memory-region-names", name);
10811082
if (index >= 0) {
@@ -1096,9 +1097,9 @@ static int airoha_qdma_init_hfwd_queues(struct airoha_qdma *qdma)
10961097
/* Compute the number of hw descriptors according to the
10971098
* reserved memory size and the payload buffer size
10981099
*/
1099-
num_desc = rmem->size / AIROHA_MAX_PACKET_SIZE;
1100+
num_desc = div_u64(rmem->size, buf_size);
11001101
} else {
1101-
size = AIROHA_MAX_PACKET_SIZE * num_desc;
1102+
size = buf_size * num_desc;
11021103
if (!dmam_alloc_coherent(eth->dev, size, &dma_addr,
11031104
GFP_KERNEL))
11041105
return -ENOMEM;
@@ -1111,9 +1112,10 @@ static int airoha_qdma_init_hfwd_queues(struct airoha_qdma *qdma)
11111112
return -ENOMEM;
11121113

11131114
airoha_qdma_wr(qdma, REG_FWD_DSCP_BASE, dma_addr);
1115+
/* QDMA0: 2KB. QDMA1: 1KB */
11141116
airoha_qdma_rmw(qdma, REG_HW_FWD_DSCP_CFG,
11151117
HW_FWD_DSCP_PAYLOAD_SIZE_MASK,
1116-
FIELD_PREP(HW_FWD_DSCP_PAYLOAD_SIZE_MASK, 0));
1118+
FIELD_PREP(HW_FWD_DSCP_PAYLOAD_SIZE_MASK, !!id));
11171119
airoha_qdma_rmw(qdma, REG_FWD_DSCP_LOW_THR, FWD_DSCP_LOW_THR_MASK,
11181120
FIELD_PREP(FWD_DSCP_LOW_THR_MASK, 128));
11191121
airoha_qdma_rmw(qdma, REG_LMGR_INIT_CFG,

0 commit comments

Comments
 (0)