c0720152d65ddfa9da7b005658e8f9f694fb3007
[openwrt/staging/thess.git] /
1 From: Lorenzo Bianconi <lorenzo@kernel.org>
2 Date: Fri, 22 Jul 2022 09:06:19 +0200
3 Subject: [PATCH] net: ethernet: mtk-ppe: fix traffic offload with bridged wlan
4
5 A typical flow offload scenario for OpenWrt users is routed traffic
6 received by the wan interface that is redirected to a wlan device
7 belonging to the lan bridge. Current implementation fails to
8 fill wdma offload info in mtk_flow_get_wdma_info() since odev device is
9 the local bridge. Fix the issue running dev_fill_forward_path routine in
10 mtk_flow_get_wdma_info in order to identify the wlan device.
11
12 Tested-by: Paolo Valerio <pvalerio@redhat.com>
13 Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
14 Signed-off-by: David S. Miller <davem@davemloft.net>
15 ---
16
17 --- a/drivers/net/ethernet/mediatek/mtk_ppe_offload.c
18 +++ b/drivers/net/ethernet/mediatek/mtk_ppe_offload.c
19 @@ -88,32 +88,28 @@ mtk_flow_offload_mangle_eth(const struct
20 static int
21 mtk_flow_get_wdma_info(struct net_device *dev, const u8 *addr, struct mtk_wdma_info *info)
22 {
23 - struct net_device_path_ctx ctx = {
24 - .dev = dev,
25 - };
26 - struct net_device_path path = {};
27 + struct net_device_path_stack stack;
28 + struct net_device_path *path;
29 + int err;
30
31 - if (!ctx.dev)
32 + if (!dev)
33 return -ENODEV;
34
35 - memcpy(ctx.daddr, addr, sizeof(ctx.daddr));
36 -
37 if (!IS_ENABLED(CONFIG_NET_MEDIATEK_SOC_WED))
38 return -1;
39
40 - if (!dev->netdev_ops->ndo_fill_forward_path)
41 - return -1;
42 -
43 - if (dev->netdev_ops->ndo_fill_forward_path(&ctx, &path))
44 - return -1;
45 + err = dev_fill_forward_path(dev, addr, &stack);
46 + if (err)
47 + return err;
48
49 - if (path.type != DEV_PATH_MTK_WDMA)
50 + path = &stack.path[stack.num_paths - 1];
51 + if (path->type != DEV_PATH_MTK_WDMA)
52 return -1;
53
54 - info->wdma_idx = path.mtk_wdma.wdma_idx;
55 - info->queue = path.mtk_wdma.queue;
56 - info->bss = path.mtk_wdma.bss;
57 - info->wcid = path.mtk_wdma.wcid;
58 + info->wdma_idx = path->mtk_wdma.wdma_idx;
59 + info->queue = path->mtk_wdma.queue;
60 + info->bss = path->mtk_wdma.bss;
61 + info->wcid = path->mtk_wdma.wcid;
62
63 return 0;
64 }