d6ef40cd5b31571a5a92bbb4a075b098a96056c9
[openwrt/staging/ldir.git] /
1 From: Lorenzo Bianconi <lorenzo@kernel.org>
2 Date: Wed, 13 Sep 2023 20:42:47 +0200
3 Subject: [PATCH] net: ethernet: mtk_wed: do not assume offload callbacks are
4 always set
5
6 Check if wlan.offload_enable and wlan.offload_disable callbacks are set
7 in mtk_wed_flow_add/mtk_wed_flow_remove since mt7996 will not rely
8 on them.
9
10 Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
11 Reviewed-by: Simon Horman <horms@kernel.org>
12 Signed-off-by: David S. Miller <davem@davemloft.net>
13 ---
14
15 --- a/drivers/net/ethernet/mediatek/mtk_wed.c
16 +++ b/drivers/net/ethernet/mediatek/mtk_wed.c
17 @@ -1713,19 +1713,20 @@ mtk_wed_irq_set_mask(struct mtk_wed_devi
18 int mtk_wed_flow_add(int index)
19 {
20 struct mtk_wed_hw *hw = hw_list[index];
21 - int ret;
22 + int ret = 0;
23
24 - if (!hw || !hw->wed_dev)
25 - return -ENODEV;
26 + mutex_lock(&hw_lock);
27
28 - if (hw->num_flows) {
29 - hw->num_flows++;
30 - return 0;
31 + if (!hw || !hw->wed_dev) {
32 + ret = -ENODEV;
33 + goto out;
34 }
35
36 - mutex_lock(&hw_lock);
37 - if (!hw->wed_dev) {
38 - ret = -ENODEV;
39 + if (!hw->wed_dev->wlan.offload_enable)
40 + goto out;
41 +
42 + if (hw->num_flows) {
43 + hw->num_flows++;
44 goto out;
45 }
46
47 @@ -1744,14 +1745,15 @@ void mtk_wed_flow_remove(int index)
48 {
49 struct mtk_wed_hw *hw = hw_list[index];
50
51 - if (!hw)
52 - return;
53 + mutex_lock(&hw_lock);
54
55 - if (--hw->num_flows)
56 - return;
57 + if (!hw || !hw->wed_dev)
58 + goto out;
59
60 - mutex_lock(&hw_lock);
61 - if (!hw->wed_dev)
62 + if (!hw->wed_dev->wlan.offload_disable)
63 + goto out;
64 +
65 + if (--hw->num_flows)
66 goto out;
67
68 hw->wed_dev->wlan.offload_disable(hw->wed_dev);