Commit 1ccc723b authored by Felix Fietkau's avatar Felix Fietkau Committed by David S. Miller

net: ethernet: mtk_eth_soc: allocate struct mtk_ppe separately

Preparation for adding more data to it, which will increase its size.
Signed-off-by: default avatarFelix Fietkau <nbd@nbd.name>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent bb14c191
...@@ -2269,7 +2269,7 @@ static int mtk_open(struct net_device *dev) ...@@ -2269,7 +2269,7 @@ static int mtk_open(struct net_device *dev)
if (err) if (err)
return err; return err;
if (eth->soc->offload_version && mtk_ppe_start(&eth->ppe) == 0) if (eth->soc->offload_version && mtk_ppe_start(eth->ppe) == 0)
gdm_config = MTK_GDMA_TO_PPE; gdm_config = MTK_GDMA_TO_PPE;
mtk_gdm_config(eth, gdm_config); mtk_gdm_config(eth, gdm_config);
...@@ -2343,7 +2343,7 @@ static int mtk_stop(struct net_device *dev) ...@@ -2343,7 +2343,7 @@ static int mtk_stop(struct net_device *dev)
mtk_dma_free(eth); mtk_dma_free(eth);
if (eth->soc->offload_version) if (eth->soc->offload_version)
mtk_ppe_stop(&eth->ppe); mtk_ppe_stop(eth->ppe);
return 0; return 0;
} }
...@@ -3262,10 +3262,11 @@ static int mtk_probe(struct platform_device *pdev) ...@@ -3262,10 +3262,11 @@ static int mtk_probe(struct platform_device *pdev)
} }
if (eth->soc->offload_version) { if (eth->soc->offload_version) {
err = mtk_ppe_init(&eth->ppe, eth->dev, eth->ppe = mtk_ppe_init(eth->dev, eth->base + MTK_ETH_PPE_BASE, 2);
eth->base + MTK_ETH_PPE_BASE, 2); if (!eth->ppe) {
if (err) err = -ENOMEM;
goto err_free_dev; goto err_free_dev;
}
err = mtk_eth_offload_init(eth); err = mtk_eth_offload_init(eth);
if (err) if (err)
......
...@@ -985,7 +985,7 @@ struct mtk_eth { ...@@ -985,7 +985,7 @@ struct mtk_eth {
u32 rx_dma_l4_valid; u32 rx_dma_l4_valid;
int ip_align; int ip_align;
struct mtk_ppe ppe; struct mtk_ppe *ppe;
struct rhashtable flow_table; struct rhashtable flow_table;
}; };
......
...@@ -384,10 +384,15 @@ int mtk_foe_entry_commit(struct mtk_ppe *ppe, struct mtk_foe_entry *entry, ...@@ -384,10 +384,15 @@ int mtk_foe_entry_commit(struct mtk_ppe *ppe, struct mtk_foe_entry *entry,
return hash; return hash;
} }
int mtk_ppe_init(struct mtk_ppe *ppe, struct device *dev, void __iomem *base, struct mtk_ppe *mtk_ppe_init(struct device *dev, void __iomem *base,
int version) int version)
{ {
struct mtk_foe_entry *foe; struct mtk_foe_entry *foe;
struct mtk_ppe *ppe;
ppe = devm_kzalloc(dev, sizeof(*ppe), GFP_KERNEL);
if (!ppe)
return NULL;
/* need to allocate a separate device, since it PPE DMA access is /* need to allocate a separate device, since it PPE DMA access is
* not coherent. * not coherent.
...@@ -399,13 +404,13 @@ int mtk_ppe_init(struct mtk_ppe *ppe, struct device *dev, void __iomem *base, ...@@ -399,13 +404,13 @@ int mtk_ppe_init(struct mtk_ppe *ppe, struct device *dev, void __iomem *base,
foe = dmam_alloc_coherent(ppe->dev, MTK_PPE_ENTRIES * sizeof(*foe), foe = dmam_alloc_coherent(ppe->dev, MTK_PPE_ENTRIES * sizeof(*foe),
&ppe->foe_phys, GFP_KERNEL); &ppe->foe_phys, GFP_KERNEL);
if (!foe) if (!foe)
return -ENOMEM; return NULL;
ppe->foe_table = foe; ppe->foe_table = foe;
mtk_ppe_debugfs_init(ppe); mtk_ppe_debugfs_init(ppe);
return 0; return ppe;
} }
static void mtk_ppe_init_foe_table(struct mtk_ppe *ppe) static void mtk_ppe_init_foe_table(struct mtk_ppe *ppe)
......
...@@ -246,8 +246,7 @@ struct mtk_ppe { ...@@ -246,8 +246,7 @@ struct mtk_ppe {
void *acct_table; void *acct_table;
}; };
int mtk_ppe_init(struct mtk_ppe *ppe, struct device *dev, void __iomem *base, struct mtk_ppe *mtk_ppe_init(struct device *dev, void __iomem *base, int version);
int version);
int mtk_ppe_start(struct mtk_ppe *ppe); int mtk_ppe_start(struct mtk_ppe *ppe);
int mtk_ppe_stop(struct mtk_ppe *ppe); int mtk_ppe_stop(struct mtk_ppe *ppe);
......
...@@ -411,7 +411,7 @@ mtk_flow_offload_replace(struct mtk_eth *eth, struct flow_cls_offload *f) ...@@ -411,7 +411,7 @@ mtk_flow_offload_replace(struct mtk_eth *eth, struct flow_cls_offload *f)
entry->cookie = f->cookie; entry->cookie = f->cookie;
timestamp = mtk_eth_timestamp(eth); timestamp = mtk_eth_timestamp(eth);
hash = mtk_foe_entry_commit(&eth->ppe, &foe, timestamp); hash = mtk_foe_entry_commit(eth->ppe, &foe, timestamp);
if (hash < 0) { if (hash < 0) {
err = hash; err = hash;
goto free; goto free;
...@@ -426,7 +426,7 @@ mtk_flow_offload_replace(struct mtk_eth *eth, struct flow_cls_offload *f) ...@@ -426,7 +426,7 @@ mtk_flow_offload_replace(struct mtk_eth *eth, struct flow_cls_offload *f)
return 0; return 0;
clear_flow: clear_flow:
mtk_foe_entry_clear(&eth->ppe, hash); mtk_foe_entry_clear(eth->ppe, hash);
free: free:
kfree(entry); kfree(entry);
if (wed_index >= 0) if (wed_index >= 0)
...@@ -444,7 +444,7 @@ mtk_flow_offload_destroy(struct mtk_eth *eth, struct flow_cls_offload *f) ...@@ -444,7 +444,7 @@ mtk_flow_offload_destroy(struct mtk_eth *eth, struct flow_cls_offload *f)
if (!entry) if (!entry)
return -ENOENT; return -ENOENT;
mtk_foe_entry_clear(&eth->ppe, entry->hash); mtk_foe_entry_clear(eth->ppe, entry->hash);
rhashtable_remove_fast(&eth->flow_table, &entry->node, rhashtable_remove_fast(&eth->flow_table, &entry->node,
mtk_flow_ht_params); mtk_flow_ht_params);
if (entry->wed_index >= 0) if (entry->wed_index >= 0)
...@@ -466,7 +466,7 @@ mtk_flow_offload_stats(struct mtk_eth *eth, struct flow_cls_offload *f) ...@@ -466,7 +466,7 @@ mtk_flow_offload_stats(struct mtk_eth *eth, struct flow_cls_offload *f)
if (!entry) if (!entry)
return -ENOENT; return -ENOENT;
timestamp = mtk_foe_entry_timestamp(&eth->ppe, entry->hash); timestamp = mtk_foe_entry_timestamp(eth->ppe, entry->hash);
if (timestamp < 0) if (timestamp < 0)
return -ETIMEDOUT; return -ETIMEDOUT;
...@@ -522,7 +522,7 @@ mtk_eth_setup_tc_block(struct net_device *dev, struct flow_block_offload *f) ...@@ -522,7 +522,7 @@ mtk_eth_setup_tc_block(struct net_device *dev, struct flow_block_offload *f)
struct flow_block_cb *block_cb; struct flow_block_cb *block_cb;
flow_setup_cb_t *cb; flow_setup_cb_t *cb;
if (!eth->ppe.foe_table) if (!eth->ppe || !eth->ppe->foe_table)
return -EOPNOTSUPP; return -EOPNOTSUPP;
if (f->binder_type != FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS) if (f->binder_type != FLOW_BLOCK_BINDER_TYPE_CLSACT_INGRESS)
...@@ -574,7 +574,7 @@ int mtk_eth_setup_tc(struct net_device *dev, enum tc_setup_type type, ...@@ -574,7 +574,7 @@ int mtk_eth_setup_tc(struct net_device *dev, enum tc_setup_type type,
int mtk_eth_offload_init(struct mtk_eth *eth) int mtk_eth_offload_init(struct mtk_eth *eth)
{ {
if (!eth->ppe.foe_table) if (!eth->ppe || !eth->ppe->foe_table)
return 0; return 0;
return rhashtable_init(&eth->flow_table, &mtk_flow_ht_params); return rhashtable_init(&eth->flow_table, &mtk_flow_ht_params);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment