diff options
author | Felix Fietkau <nbd@nbd.name> | 2023-04-05 17:10:26 +0200 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2023-04-07 09:23:08 +0200 |
commit | e28531143b257a4cbfdc1c3358eff18cc3024783 (patch) | |
tree | ba0f94a4144eaced032754d35e1367e438d85e13 /drivers/net/ethernet/mediatek/mtk_ppe.c | |
parent | net: ethernet: mtk_eth_soc: add code for offloading flows from wlan devices (diff) | |
download | linux-e28531143b257a4cbfdc1c3358eff18cc3024783.tar.xz linux-e28531143b257a4cbfdc1c3358eff18cc3024783.zip |
net: ethernet: mtk_eth_soc: mtk_ppe: prefer newly added l2 flows
When a device is roaming between interfaces and a new flow entry is
created, we should assume that its output device is more up to date than
whatever entry existed already.
Signed-off-by: Felix Fietkau <nbd@nbd.name>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/mediatek/mtk_ppe.c')
-rw-r--r-- | drivers/net/ethernet/mediatek/mtk_ppe.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/drivers/net/ethernet/mediatek/mtk_ppe.c b/drivers/net/ethernet/mediatek/mtk_ppe.c index f9c9f2ea4206..dd9581334b05 100644 --- a/drivers/net/ethernet/mediatek/mtk_ppe.c +++ b/drivers/net/ethernet/mediatek/mtk_ppe.c @@ -635,10 +635,20 @@ void mtk_foe_entry_clear(struct mtk_ppe *ppe, struct mtk_flow_entry *entry) static int mtk_foe_entry_commit_l2(struct mtk_ppe *ppe, struct mtk_flow_entry *entry) { + struct mtk_flow_entry *prev; + entry->type = MTK_FLOW_TYPE_L2; - return rhashtable_insert_fast(&ppe->l2_flows, &entry->l2_node, - mtk_flow_l2_ht_params); + prev = rhashtable_lookup_get_insert_fast(&ppe->l2_flows, &entry->l2_node, + mtk_flow_l2_ht_params); + if (likely(!prev)) + return 0; + + if (IS_ERR(prev)) + return PTR_ERR(prev); + + return rhashtable_replace_fast(&ppe->l2_flows, &prev->l2_node, + &entry->l2_node, mtk_flow_l2_ht_params); } int mtk_foe_entry_commit(struct mtk_ppe *ppe, struct mtk_flow_entry *entry) |