1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Mon, 21 Feb 2022 15:38:20 +0100
3 Subject: [PATCH] net: ethernet: mtk_eth_soc: allocate struct mtk_ppe
6 Preparation for adding more data to it, which will increase its size.
8 Signed-off-by: Felix Fietkau <nbd@nbd.name>
11 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
12 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
13 @@ -2335,7 +2335,7 @@ static int mtk_open(struct net_device *d
17 - if (eth->soc->offload_version && mtk_ppe_start(ð->ppe) == 0)
18 + if (eth->soc->offload_version && mtk_ppe_start(eth->ppe) == 0)
19 gdm_config = MTK_GDMA_TO_PPE;
21 mtk_gdm_config(eth, gdm_config);
22 @@ -2409,7 +2409,7 @@ static int mtk_stop(struct net_device *d
25 if (eth->soc->offload_version)
26 - mtk_ppe_stop(ð->ppe);
27 + mtk_ppe_stop(eth->ppe);
31 @@ -3294,10 +3294,11 @@ static int mtk_probe(struct platform_dev
34 if (eth->soc->offload_version) {
35 - err = mtk_ppe_init(ð->ppe, eth->dev,
36 - eth->base + MTK_ETH_PPE_BASE, 2);
38 + eth->ppe = mtk_ppe_init(eth->dev, eth->base + MTK_ETH_PPE_BASE, 2);
44 err = mtk_eth_offload_init(eth);
46 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.h
47 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.h
48 @@ -983,7 +983,7 @@ struct mtk_eth {
53 + struct mtk_ppe *ppe;
54 struct rhashtable flow_table;
57 --- a/drivers/net/ethernet/mediatek/mtk_ppe.c
58 +++ b/drivers/net/ethernet/mediatek/mtk_ppe.c
59 @@ -384,10 +384,15 @@ int mtk_foe_entry_commit(struct mtk_ppe
63 -int mtk_ppe_init(struct mtk_ppe *ppe, struct device *dev, void __iomem *base,
64 +struct mtk_ppe *mtk_ppe_init(struct device *dev, void __iomem *base,
67 struct mtk_foe_entry *foe;
68 + struct mtk_ppe *ppe;
70 + ppe = devm_kzalloc(dev, sizeof(*ppe), GFP_KERNEL);
74 /* need to allocate a separate device, since it PPE DMA access is
76 @@ -399,13 +404,13 @@ int mtk_ppe_init(struct mtk_ppe *ppe, st
77 foe = dmam_alloc_coherent(ppe->dev, MTK_PPE_ENTRIES * sizeof(*foe),
78 &ppe->foe_phys, GFP_KERNEL);
85 mtk_ppe_debugfs_init(ppe);
91 static void mtk_ppe_init_foe_table(struct mtk_ppe *ppe)
92 --- a/drivers/net/ethernet/mediatek/mtk_ppe.h
93 +++ b/drivers/net/ethernet/mediatek/mtk_ppe.h
94 @@ -246,8 +246,7 @@ struct mtk_ppe {
98 -int mtk_ppe_init(struct mtk_ppe *ppe, struct device *dev, void __iomem *base,
100 +struct mtk_ppe *mtk_ppe_init(struct device *dev, void __iomem *base, int version);
101 int mtk_ppe_start(struct mtk_ppe *ppe);
102 int mtk_ppe_stop(struct mtk_ppe *ppe);
104 --- a/drivers/net/ethernet/mediatek/mtk_ppe_offload.c
105 +++ b/drivers/net/ethernet/mediatek/mtk_ppe_offload.c
106 @@ -411,7 +411,7 @@ mtk_flow_offload_replace(struct mtk_eth
108 entry->cookie = f->cookie;
109 timestamp = mtk_eth_timestamp(eth);
110 - hash = mtk_foe_entry_commit(ð->ppe, &foe, timestamp);
111 + hash = mtk_foe_entry_commit(eth->ppe, &foe, timestamp);
115 @@ -426,7 +426,7 @@ mtk_flow_offload_replace(struct mtk_eth
119 - mtk_foe_entry_clear(ð->ppe, hash);
120 + mtk_foe_entry_clear(eth->ppe, hash);
124 @@ -444,7 +444,7 @@ mtk_flow_offload_destroy(struct mtk_eth
128 - mtk_foe_entry_clear(ð->ppe, entry->hash);
129 + mtk_foe_entry_clear(eth->ppe, entry->hash);
130 rhashtable_remove_fast(ð->flow_table, &entry->node,
132 if (entry->wed_index >= 0)
133 @@ -466,7 +466,7 @@ mtk_flow_offload_stats(struct mtk_eth *e
137 - timestamp = mtk_foe_entry_timestamp(ð->ppe, entry->hash);
138 + timestamp = mtk_foe_entry_timestamp(eth->ppe, entry->hash);
142 @@ -522,7 +522,7 @@ mtk_eth_setup_tc_block(struct net_device
143 struct flow_block_cb *block_cb;
146 - if (!eth->ppe.foe_table)
147 + if (!eth->ppe || !eth->ppe->foe_table)
150 if (f->binder_type != FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS)
151 @@ -575,7 +575,7 @@ int mtk_eth_setup_tc(struct net_device *
153 int mtk_eth_offload_init(struct mtk_eth *eth)
155 - if (!eth->ppe.foe_table)
156 + if (!eth->ppe || !eth->ppe->foe_table)
159 return rhashtable_init(ð->flow_table, &mtk_flow_ht_params);