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
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
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>
15 --- a/drivers/net/ethernet/mediatek/mtk_wed.c
16 +++ b/drivers/net/ethernet/mediatek/mtk_wed.c
17 @@ -1709,19 +1709,20 @@ mtk_wed_irq_set_mask(struct mtk_wed_devi
18 int mtk_wed_flow_add(int index)
20 struct mtk_wed_hw *hw = hw_list[index];
24 - if (!hw || !hw->wed_dev)
26 + mutex_lock(&hw_lock);
28 - if (hw->num_flows) {
31 + if (!hw || !hw->wed_dev) {
36 - mutex_lock(&hw_lock);
39 + if (!hw->wed_dev->wlan.offload_enable)
42 + if (hw->num_flows) {
47 @@ -1740,14 +1741,15 @@ void mtk_wed_flow_remove(int index)
49 struct mtk_wed_hw *hw = hw_list[index];
53 + mutex_lock(&hw_lock);
55 - if (--hw->num_flows)
57 + if (!hw || !hw->wed_dev)
60 - mutex_lock(&hw_lock);
62 + if (!hw->wed_dev->wlan.offload_disable)
65 + if (--hw->num_flows)
68 hw->wed_dev->wlan.offload_disable(hw->wed_dev);