Skip to content

Commit 1ccc723

Browse files
nbd168davem330
authored andcommitted
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: Felix Fietkau <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent bb14c19 commit 1ccc723

File tree

5 files changed

+22
-17
lines changed

5 files changed

+22
-17
lines changed

drivers/net/ethernet/mediatek/mtk_eth_soc.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2269,7 +2269,7 @@ static int mtk_open(struct net_device *dev)
22692269
if (err)
22702270
return err;
22712271

2272-
if (eth->soc->offload_version && mtk_ppe_start(&eth->ppe) == 0)
2272+
if (eth->soc->offload_version && mtk_ppe_start(eth->ppe) == 0)
22732273
gdm_config = MTK_GDMA_TO_PPE;
22742274

22752275
mtk_gdm_config(eth, gdm_config);
@@ -2343,7 +2343,7 @@ static int mtk_stop(struct net_device *dev)
23432343
mtk_dma_free(eth);
23442344

23452345
if (eth->soc->offload_version)
2346-
mtk_ppe_stop(&eth->ppe);
2346+
mtk_ppe_stop(eth->ppe);
23472347

23482348
return 0;
23492349
}
@@ -3262,10 +3262,11 @@ static int mtk_probe(struct platform_device *pdev)
32623262
}
32633263

32643264
if (eth->soc->offload_version) {
3265-
err = mtk_ppe_init(&eth->ppe, eth->dev,
3266-
eth->base + MTK_ETH_PPE_BASE, 2);
3267-
if (err)
3265+
eth->ppe = mtk_ppe_init(eth->dev, eth->base + MTK_ETH_PPE_BASE, 2);
3266+
if (!eth->ppe) {
3267+
err = -ENOMEM;
32683268
goto err_free_dev;
3269+
}
32693270

32703271
err = mtk_eth_offload_init(eth);
32713272
if (err)

drivers/net/ethernet/mediatek/mtk_eth_soc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -985,7 +985,7 @@ struct mtk_eth {
985985
u32 rx_dma_l4_valid;
986986
int ip_align;
987987

988-
struct mtk_ppe ppe;
988+
struct mtk_ppe *ppe;
989989
struct rhashtable flow_table;
990990
};
991991

drivers/net/ethernet/mediatek/mtk_ppe.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -384,10 +384,15 @@ int mtk_foe_entry_commit(struct mtk_ppe *ppe, struct mtk_foe_entry *entry,
384384
return hash;
385385
}
386386

387-
int mtk_ppe_init(struct mtk_ppe *ppe, struct device *dev, void __iomem *base,
387+
struct mtk_ppe *mtk_ppe_init(struct device *dev, void __iomem *base,
388388
int version)
389389
{
390390
struct mtk_foe_entry *foe;
391+
struct mtk_ppe *ppe;
392+
393+
ppe = devm_kzalloc(dev, sizeof(*ppe), GFP_KERNEL);
394+
if (!ppe)
395+
return NULL;
391396

392397
/* need to allocate a separate device, since it PPE DMA access is
393398
* not coherent.
@@ -399,13 +404,13 @@ int mtk_ppe_init(struct mtk_ppe *ppe, struct device *dev, void __iomem *base,
399404
foe = dmam_alloc_coherent(ppe->dev, MTK_PPE_ENTRIES * sizeof(*foe),
400405
&ppe->foe_phys, GFP_KERNEL);
401406
if (!foe)
402-
return -ENOMEM;
407+
return NULL;
403408

404409
ppe->foe_table = foe;
405410

406411
mtk_ppe_debugfs_init(ppe);
407412

408-
return 0;
413+
return ppe;
409414
}
410415

411416
static void mtk_ppe_init_foe_table(struct mtk_ppe *ppe)

drivers/net/ethernet/mediatek/mtk_ppe.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,8 +246,7 @@ struct mtk_ppe {
246246
void *acct_table;
247247
};
248248

249-
int mtk_ppe_init(struct mtk_ppe *ppe, struct device *dev, void __iomem *base,
250-
int version);
249+
struct mtk_ppe *mtk_ppe_init(struct device *dev, void __iomem *base, int version);
251250
int mtk_ppe_start(struct mtk_ppe *ppe);
252251
int mtk_ppe_stop(struct mtk_ppe *ppe);
253252

drivers/net/ethernet/mediatek/mtk_ppe_offload.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ mtk_flow_offload_replace(struct mtk_eth *eth, struct flow_cls_offload *f)
411411

412412
entry->cookie = f->cookie;
413413
timestamp = mtk_eth_timestamp(eth);
414-
hash = mtk_foe_entry_commit(&eth->ppe, &foe, timestamp);
414+
hash = mtk_foe_entry_commit(eth->ppe, &foe, timestamp);
415415
if (hash < 0) {
416416
err = hash;
417417
goto free;
@@ -426,7 +426,7 @@ mtk_flow_offload_replace(struct mtk_eth *eth, struct flow_cls_offload *f)
426426

427427
return 0;
428428
clear_flow:
429-
mtk_foe_entry_clear(&eth->ppe, hash);
429+
mtk_foe_entry_clear(eth->ppe, hash);
430430
free:
431431
kfree(entry);
432432
if (wed_index >= 0)
@@ -444,7 +444,7 @@ mtk_flow_offload_destroy(struct mtk_eth *eth, struct flow_cls_offload *f)
444444
if (!entry)
445445
return -ENOENT;
446446

447-
mtk_foe_entry_clear(&eth->ppe, entry->hash);
447+
mtk_foe_entry_clear(eth->ppe, entry->hash);
448448
rhashtable_remove_fast(&eth->flow_table, &entry->node,
449449
mtk_flow_ht_params);
450450
if (entry->wed_index >= 0)
@@ -466,7 +466,7 @@ mtk_flow_offload_stats(struct mtk_eth *eth, struct flow_cls_offload *f)
466466
if (!entry)
467467
return -ENOENT;
468468

469-
timestamp = mtk_foe_entry_timestamp(&eth->ppe, entry->hash);
469+
timestamp = mtk_foe_entry_timestamp(eth->ppe, entry->hash);
470470
if (timestamp < 0)
471471
return -ETIMEDOUT;
472472

@@ -522,7 +522,7 @@ mtk_eth_setup_tc_block(struct net_device *dev, struct flow_block_offload *f)
522522
struct flow_block_cb *block_cb;
523523
flow_setup_cb_t *cb;
524524

525-
if (!eth->ppe.foe_table)
525+
if (!eth->ppe || !eth->ppe->foe_table)
526526
return -EOPNOTSUPP;
527527

528528
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,
574574

575575
int mtk_eth_offload_init(struct mtk_eth *eth)
576576
{
577-
if (!eth->ppe.foe_table)
577+
if (!eth->ppe || !eth->ppe->foe_table)
578578
return 0;
579579

580580
return rhashtable_init(&eth->flow_table, &mtk_flow_ht_params);

0 commit comments

Comments
 (0)