net: ethernet: mtk_eth_soc: fix flow block refcounting logic
Subsystems (4)
Felix Fietkau
maintainerPATCH 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.
---
v2: fix description, simplify refcounting change
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
@@ -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
Felix Fietkau
maintainerPATCH 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.
--- 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
@@ -2059,9 +2059,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 ) {
@@ -2089,6 +2086,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
@@ -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
Re: [PATCH v2 2/3] net: ethernet: mtk_eth_soc: fix L2 offloading with DSA untag offload
Quoted 5 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")Signed-off-by Felix Fietkau <[email protected]>
Felix Fietkau
maintainerPATCH v2 3/3 net: ethernet: mtk_eth_soc: add missing ppe cache flush when deleting a flow
In reply to Felix FietkauThe cache needs to be flushed to ensure that the hardware stops offloading the flow immediately.
--- drivers/net/ethernet/mediatek/mtk_ppe.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/mediatek/mtk_ppe.c +1 -0
@@ -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
Re: [PATCH v2 3/3] net: ethernet: mtk_eth_soc: add missing ppe cache flush when deleting a flow
Quoted 2 lines · Felix Fietkau
The cache needs to be flushed to ensure that the hardware stops offloading the flow immediately.
I wonder if a fixes tag is appropriate, and if so perhaps it should be:
Quoted 1 line
Signed-off-by Felix Fietkau <[email protected]>
In any case,
Quoted 6 lines · Felix Fietkau
Since we call
flow_block_cb_decrefonFLOW_BLOCK_UNBIND, we also need to callflow_block_cb_increffor a newly allocated cb.
Also fix the accidentally inverted refcount check on unbind.Fixes 502e84e2382d ("net: ethernet: mtk_eth_soc: add flow offloading support")Signed-off-by Felix Fietkau <[email protected]>
I'm guessing that this series is for 'net'.
But it seems that patchwork had a tough time figuring that out and gave up. So CI type things haven't run there.
https://patchwork.kernel.org/project/netdevbpf/patch/[email protected]/
Also, there is a merge conflict when merging net-next into net with this series applied.
momiji ~/projects/linux/linux git diff drivers/net/ethernet/mediatek/mtk_ppe.c
drivers/net/ethernet/mediatek/mtk_ppe.c +0 -0
@@@ -459,7 -500,13 +501,17 @@@ __mtk_foe_entry_clear(struct mtk_ppe *p hwe->ib1 &= ~MTK_FOE_IB1_STATE ; hwe->ib1 |=FIELD_PREP (MTK_FOE_IB1_STATE ,MTK_FOE_STATE_INVALID );dma_wmb (); ++<<<<<<< HEAD +mtk_ppe_cache_clear (ppe); ++======= +if (ppe->accounting) { +struct mtk_foe_accounting *acct; + + acct = ppe->acct_table + entry->hash *sizeof (*acct); + acct->packets =0 ; + acct->bytes =0 ; + } ++>>>>>>> net-next/main } entry->hash =0xffff ;
Jakub Kicinski
maintainerQuoted 3 lines · On Fri, 24 Mar 2023 13:21:02 +0100 Simon Horman wrote:
I'm guessing that this series is for 'net'.
But it seems that patchwork had a tough time figuring that out and gave up. So CI type things haven't run there.
Indeed, a resend with [PATCH net] in the subject would be appreciated. patchwork does a lot more build testing than we can handle manually.