Skip to contentSkip to conversation

net: ethernet: mtk_eth_soc: fix flow block refcounting logic

PATCH Applied Felix Fietkau 3 participants 9 messages Mar 30, 2023

Subsystems (4)
lore
Share & tools
lore

Felix Fietkau

author maintainer
#0 lore raw

PATCH v2 1/3 net: ethernet: mtk_eth_soc: fix flow block refcounting logic

Since we call flow_block_cb_decref on FLOW_BLOCK_UNBIND, we also need to call flow_block_cb_incref for a newly allocated cb.
Also fix the accidentally inverted refcount check on unbind.

Fixes 502e84e2382d ("net: ethernet: mtk_eth_soc: add flow offloading support")
---
 drivers/net/ethernet/mediatek/mtk_ppe_offload.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/ethernet/mediatek/mtk_ppe_offload.c +2 -1
index 81afd5ee3fbf..161751bb36c9 100644
@@ -576,6 +576,7 @@ mtk_eth_setup_tc_block(struct net_device *dev, struct flow_block_offload *f)
 		if (IS_ERR(block_cb))
 			return PTR_ERR(block_cb);
 
+		flow_block_cb_incref(block_cb);
 		flow_block_cb_add(block_cb, f);
 		list_add_tail(&block_cb->driver_list, &block_cb_list);
 		return 0;
@@ -584,7 +585,7 @@ mtk_eth_setup_tc_block(struct net_device *dev, struct flow_block_offload *f)
 		if (!block_cb)
 			return -ENOENT;
 
-		if (flow_block_cb_decref(block_cb)) {
+		if (!flow_block_cb_decref(block_cb)) {
 			flow_block_cb_remove(block_cb, f);
 			list_del(&block_cb->driver_list);
 		}
Signature · 1 line
2.39.0
author maintainer
#1 lore raw

PATCH v2 2/3 net: ethernet: mtk_eth_soc: fix L2 offloading with DSA untag offload

Check for skb metadata in order to detect the case where the DSA header is not present.

Fixes 2d7605a72906 ("net: ethernet: mtk_eth_soc: enable hardware DSA untagging")
---
 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 6 +++---
 drivers/net/ethernet/mediatek/mtk_ppe.c     | 5 ++++-
 2 files changed, 7 insertions(+), 4 deletions(-)
drivers/net/ethernet/mediatek/mtk_eth_soc.c +3 -3
index 20d3e5ab1b2a..e14050e17862 100644
@@ -2058,9 +2058,6 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget,
 			skb_checksum_none_assert(skb);
 		skb->protocol = eth_type_trans(skb, netdev);
 
-		if (reason == MTK_PPE_CPU_REASON_HIT_UNBIND_RATE_REACHED)
-			mtk_ppe_check_skb(eth->ppe[0], skb, hash);
-
 		if (netdev->features & NETIF_F_HW_VLAN_CTAG_RX) {
 			if (MTK_HAS_CAPS(eth->soc->caps, MTK_NETSYS_V2)) {
 				if (trxd.rxd3 & RX_DMA_VTAG_V2) {
@@ -2088,6 +2085,9 @@ static int mtk_poll_rx(struct napi_struct *napi, int budget,
 			__vlan_hwaccel_put_tag(skb, htons(vlan_proto), vlan_tci);
 		}
 
+		if (reason == MTK_PPE_CPU_REASON_HIT_UNBIND_RATE_REACHED)
+			mtk_ppe_check_skb(eth->ppe[0], skb, hash);
+
 		skb_record_rx_queue(skb, 0);
 		napi_gro_receive(napi, skb);
 
drivers/net/ethernet/mediatek/mtk_ppe.c +4 -1
index 6883eb34cd8b..a038b99ecbda 100644
@@ -8,6 +8,7 @@
 #include <linux/platform_device.h>
 #include <linux/if_ether.h>
 #include <linux/if_vlan.h>
+#include <net/dst_metadata.h>
 #include <net/dsa.h>
 #include "mtk_eth_soc.h"
 #include "mtk_ppe.h"
@@ -699,7 +700,9 @@ void __mtk_ppe_check_skb(struct mtk_ppe *ppe, struct sk_buff *skb, u16 hash)
 		    skb->dev->dsa_ptr->tag_ops->proto != DSA_TAG_PROTO_MTK)
 			goto out;
 
-		tag += 4;
+		if (!skb_metadata_dst(skb))
+			tag += 4;
+
 		if (get_unaligned_be16(tag) != ETH_P_8021Q)
 			break;
 
Signature · 1 line
2.39.0
Reviewed-by on v2 2/3
#2 lore raw

Re: [PATCH net v2 2/3] net: ethernet: mtk_eth_soc: fix L2 offloading with DSA untag offload

Quoted 11 lines · Felix Fietkau

Check for skb metadata in order to detect the case where the DSA header is not present.

Fixes 2d7605a72906 ("net: ethernet: mtk_eth_soc: enable hardware DSA untagging")
---
 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 6 +++---
 drivers/net/ethernet/mediatek/mtk_ppe.c     | 5 ++++-
 2 files changed, 7 insertions(+), 4 deletions(-)

Thanks,

author maintainer
#3 lore raw

PATCH v2 3/3 net: ethernet: mtk_eth_soc: add missing ppe cache flush when deleting a flow

In reply to Felix Fietkau

The cache needs to be flushed to ensure that the hardware stops offloading the flow immediately.

Fixes 33fc42de3327 ("net: ethernet: mtk_eth_soc: support creating mac address based offload entries")
---
 drivers/net/ethernet/mediatek/mtk_ppe.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/mediatek/mtk_ppe.c +1 -0
index a038b99ecbda..fd07d6e14273 100644
@@ -459,6 +459,7 @@ __mtk_foe_entry_clear(struct mtk_ppe *ppe, struct mtk_flow_entry *entry)
 		hwe->ib1 &= ~MTK_FOE_IB1_STATE;
 		hwe->ib1 |= FIELD_PREP(MTK_FOE_IB1_STATE, MTK_FOE_STATE_INVALID);
 		dma_wmb();
+		mtk_ppe_cache_clear(ppe);
 	}
 	entry->hash = 0xffff;
 
Signature · 1 line
2.39.0
Reviewed-by on v2 3/3
#4 lore raw

Re: [PATCH net v2 3/3] net: ethernet: mtk_eth_soc: add missing ppe cache flush when deleting a flow

Quoted 9 lines · Felix Fietkau

The cache needs to be flushed to ensure that the hardware stops offloading the flow immediately.

Fixes 33fc42de3327 ("net: ethernet: mtk_eth_soc: support creating mac address based offload entries")
---
 drivers/net/ethernet/mediatek/mtk_ppe.c | 1 +
 1 file changed, 1 insertion(+)

Thanks,

#5 lore raw
In reply to Felix Fietkau
Quoted 10 lines · Felix Fietkau

Since we call flow_block_cb_decref on FLOW_BLOCK_UNBIND, we also need to call flow_block_cb_incref for a newly allocated cb.
Also fix the accidentally inverted refcount check on unbind.

Fixes 502e84e2382d ("net: ethernet: mtk_eth_soc: add flow offloading support")
---
 drivers/net/ethernet/mediatek/mtk_ppe_offload.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

So what was changed between version 1 and 2?
It is expected to send cover letter too for series with more than 2 patches.

Thanks

author maintainer
#6 lore raw
Quoted 12 lines · Leon Romanovsky
Quoted 10 lines · Felix Fietkau

Since we call flow_block_cb_decref on FLOW_BLOCK_UNBIND, we also need to call flow_block_cb_incref for a newly allocated cb.
Also fix the accidentally inverted refcount check on unbind.

Fixes 502e84e2382d ("net: ethernet: mtk_eth_soc: add flow offloading support")
---
 drivers/net/ethernet/mediatek/mtk_ppe_offload.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
Quoted 2 lines

So what was changed between version 1 and 2?
It is expected to send cover letter too for series with more than 2 patches.

I had already sent v2 without the net prefix, this was just a resend without any further code changes. Unfortunately I forgot to copy the changelog as well. Here it is:
v2: fix description, simplify refcounting change

Sorry about that.

- Felix

Reviewed-by on v2 1/3
#7 lore raw
In reply to Felix Fietkau
Quoted 11 lines · Felix Fietkau

Since we call flow_block_cb_decref on FLOW_BLOCK_UNBIND, we also need to call flow_block_cb_incref for a newly allocated cb.
Also fix the accidentally inverted refcount check on unbind.

Fixes 502e84e2382d ("net: ethernet: mtk_eth_soc: add flow offloading support")
---
 drivers/net/ethernet/mediatek/mtk_ppe_offload.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Thanks,

#8 lore raw
In reply to Felix Fietkau
This series was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Thu, 30 Mar 2023 14:08:38 +0200 you wrote:

Since we call flow_block_cb_decref on FLOW_BLOCK_UNBIND, we also need to call flow_block_cb_incref for a newly allocated cb.
Also fix the accidentally inverted refcount check on unbind.

Fixes 502e84e2382d ("net: ethernet: mtk_eth_soc: add flow offloading support")

[...]

Here is the summary with links:
- [net,v2,1/3] net: ethernet: mtk_eth_soc: fix flow block refcounting logic

    https://git.kernel.org/netdev/net/c/8c1cb87c2a5c
  - [net,v2,2/3] net: ethernet: mtk_eth_soc: fix L2 offloading with DSA untag offload
    https://git.kernel.org/netdev/net/c/5f36ca1b841f
  - [net,v2,3/3] net: ethernet: mtk_eth_soc: add missing ppe cache flush when deleting a flow
    https://git.kernel.org/netdev/net/c/924531326e2d

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html