|
5 | 5 | */
|
6 | 6 | #include <linux/of.h>
|
7 | 7 | #include <linux/of_net.h>
|
| 8 | +#include <linux/of_reserved_mem.h> |
8 | 9 | #include <linux/platform_device.h>
|
9 | 10 | #include <linux/tcp.h>
|
10 | 11 | #include <linux/u64_stats_sync.h>
|
@@ -1072,20 +1073,46 @@ static void airoha_qdma_cleanup_tx_queue(struct airoha_queue *q)
|
1072 | 1073 | static int airoha_qdma_init_hfwd_queues(struct airoha_qdma *qdma)
|
1073 | 1074 | {
|
1074 | 1075 | struct airoha_eth *eth = qdma->eth;
|
| 1076 | + int id = qdma - ð->qdma[0]; |
1075 | 1077 | dma_addr_t dma_addr;
|
| 1078 | + const char *name; |
| 1079 | + int size, index; |
1076 | 1080 | u32 status;
|
1077 |
| - int size; |
1078 | 1081 |
|
1079 | 1082 | size = HW_DSCP_NUM * sizeof(struct airoha_qdma_fwd_desc);
|
1080 | 1083 | if (!dmam_alloc_coherent(eth->dev, size, &dma_addr, GFP_KERNEL))
|
1081 | 1084 | return -ENOMEM;
|
1082 | 1085 |
|
1083 | 1086 | airoha_qdma_wr(qdma, REG_FWD_DSCP_BASE, dma_addr);
|
1084 | 1087 |
|
1085 |
| - size = AIROHA_MAX_PACKET_SIZE * HW_DSCP_NUM; |
1086 |
| - if (!dmam_alloc_coherent(eth->dev, size, &dma_addr, GFP_KERNEL)) |
| 1088 | + name = devm_kasprintf(eth->dev, GFP_KERNEL, "qdma%d-buf", id); |
| 1089 | + if (!name) |
1087 | 1090 | return -ENOMEM;
|
1088 | 1091 |
|
| 1092 | + index = of_property_match_string(eth->dev->of_node, |
| 1093 | + "memory-region-names", name); |
| 1094 | + if (index >= 0) { |
| 1095 | + struct reserved_mem *rmem; |
| 1096 | + struct device_node *np; |
| 1097 | + |
| 1098 | + /* Consume reserved memory for hw forwarding buffers queue if |
| 1099 | + * available in the DTS |
| 1100 | + */ |
| 1101 | + np = of_parse_phandle(eth->dev->of_node, "memory-region", |
| 1102 | + index); |
| 1103 | + if (!np) |
| 1104 | + return -ENODEV; |
| 1105 | + |
| 1106 | + rmem = of_reserved_mem_lookup(np); |
| 1107 | + of_node_put(np); |
| 1108 | + dma_addr = rmem->base; |
| 1109 | + } else { |
| 1110 | + size = AIROHA_MAX_PACKET_SIZE * HW_DSCP_NUM; |
| 1111 | + if (!dmam_alloc_coherent(eth->dev, size, &dma_addr, |
| 1112 | + GFP_KERNEL)) |
| 1113 | + return -ENOMEM; |
| 1114 | + } |
| 1115 | + |
1089 | 1116 | airoha_qdma_wr(qdma, REG_FWD_BUF_BASE, dma_addr);
|
1090 | 1117 |
|
1091 | 1118 | airoha_qdma_rmw(qdma, REG_HW_FWD_DSCP_CFG,
|
|
0 commit comments