Skip to content

Commit ba37b7c

Browse files
nbd168davem330
authored andcommitted
net: ethernet: mtk_eth_soc: add support for initializing the PPE
The PPE (packet processing engine) is used to offload NAT/routed or even bridged flows. This patch brings up the PPE and uses it to get a packet hash. It also contains some functionality that will be used to bring up flow offloading. Signed-off-by: Felix Fietkau <[email protected]> Signed-off-by: Pablo Neira Ayuso <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d5c53da commit ba37b7c

File tree

7 files changed

+1190
-3
lines changed

7 files changed

+1190
-3
lines changed

drivers/net/ethernet/mediatek/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
#
55

66
obj-$(CONFIG_NET_MEDIATEK_SOC) += mtk_eth.o
7-
mtk_eth-y := mtk_eth_soc.o mtk_sgmii.o mtk_eth_path.o
7+
mtk_eth-y := mtk_eth_soc.o mtk_sgmii.o mtk_eth_path.o mtk_ppe.o mtk_ppe_debugfs.o
88
obj-$(CONFIG_NET_MEDIATEK_STAR_EMAC) += mtk_star_emac.o

drivers/net/ethernet/mediatek/mtk_eth_soc.c

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2258,12 +2258,17 @@ static int mtk_open(struct net_device *dev)
22582258

22592259
/* we run 2 netdevs on the same dma ring so we only bring it up once */
22602260
if (!refcount_read(&eth->dma_refcnt)) {
2261-
int err = mtk_start_dma(eth);
2261+
u32 gdm_config = MTK_GDMA_TO_PDMA;
2262+
int err;
22622263

2264+
err = mtk_start_dma(eth);
22632265
if (err)
22642266
return err;
22652267

2266-
mtk_gdm_config(eth, MTK_GDMA_TO_PDMA);
2268+
if (eth->soc->offload_version && mtk_ppe_start(&eth->ppe) == 0)
2269+
gdm_config = MTK_GDMA_TO_PPE;
2270+
2271+
mtk_gdm_config(eth, gdm_config);
22672272

22682273
napi_enable(&eth->tx_napi);
22692274
napi_enable(&eth->rx_napi);
@@ -2330,6 +2335,9 @@ static int mtk_stop(struct net_device *dev)
23302335

23312336
mtk_dma_free(eth);
23322337

2338+
if (eth->soc->offload_version)
2339+
mtk_ppe_stop(&eth->ppe);
2340+
23332341
return 0;
23342342
}
23352343

@@ -3091,6 +3099,13 @@ static int mtk_probe(struct platform_device *pdev)
30913099
goto err_free_dev;
30923100
}
30933101

3102+
if (eth->soc->offload_version) {
3103+
err = mtk_ppe_init(&eth->ppe, eth->dev,
3104+
eth->base + MTK_ETH_PPE_BASE, 2);
3105+
if (err)
3106+
goto err_free_dev;
3107+
}
3108+
30943109
for (i = 0; i < MTK_MAX_DEVS; i++) {
30953110
if (!eth->netdev[i])
30963111
continue;
@@ -3165,6 +3180,7 @@ static const struct mtk_soc_data mt7621_data = {
31653180
.hw_features = MTK_HW_FEATURES,
31663181
.required_clks = MT7621_CLKS_BITMAP,
31673182
.required_pctl = false,
3183+
.offload_version = 2,
31683184
};
31693185

31703186
static const struct mtk_soc_data mt7622_data = {
@@ -3173,6 +3189,7 @@ static const struct mtk_soc_data mt7622_data = {
31733189
.hw_features = MTK_HW_FEATURES,
31743190
.required_clks = MT7622_CLKS_BITMAP,
31753191
.required_pctl = false,
3192+
.offload_version = 2,
31763193
};
31773194

31783195
static const struct mtk_soc_data mt7623_data = {

drivers/net/ethernet/mediatek/mtk_eth_soc.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/u64_stats_sync.h>
1616
#include <linux/refcount.h>
1717
#include <linux/phylink.h>
18+
#include "mtk_ppe.h"
1819

1920
#define MTK_QDMA_PAGE_SIZE 2048
2021
#define MTK_MAX_RX_LENGTH 1536
@@ -87,6 +88,7 @@
8788
#define MTK_GDMA_TCS_EN BIT(21)
8889
#define MTK_GDMA_UCS_EN BIT(20)
8990
#define MTK_GDMA_TO_PDMA 0x0
91+
#define MTK_GDMA_TO_PPE 0x4444
9092
#define MTK_GDMA_DROP_ALL 0x7777
9193

9294
/* Unicast Filter MAC Address Register - Low */
@@ -301,6 +303,12 @@
301303
/* QDMA descriptor rxd3 */
302304
#define RX_DMA_VID(_x) ((_x) & 0xfff)
303305

306+
/* QDMA descriptor rxd4 */
307+
#define MTK_RXD4_FOE_ENTRY GENMASK(13, 0)
308+
#define MTK_RXD4_PPE_CPU_REASON GENMASK(18, 14)
309+
#define MTK_RXD4_SRC_PORT GENMASK(21, 19)
310+
#define MTK_RXD4_ALG GENMASK(31, 22)
311+
304312
/* QDMA descriptor rxd4 */
305313
#define RX_DMA_L4_VALID BIT(24)
306314
#define RX_DMA_L4_VALID_PDMA BIT(30) /* when PDMA is used */
@@ -804,6 +812,7 @@ struct mtk_soc_data {
804812
u32 caps;
805813
u32 required_clks;
806814
bool required_pctl;
815+
u8 offload_version;
807816
netdev_features_t hw_features;
808817
};
809818

@@ -903,6 +912,8 @@ struct mtk_eth {
903912
u32 tx_int_status_reg;
904913
u32 rx_dma_l4_valid;
905914
int ip_align;
915+
916+
struct mtk_ppe ppe;
906917
};
907918

908919
/* struct mtk_mac - the structure that holds the info about the MACs of the

0 commit comments

Comments
 (0)