diff mbox series

[net-next,2/2] net: ethernet: mediatek: mtk_ppe: prefer newly added l2 flows over existing ones

Message ID 20230321133609.49591-2-nbd@nbd.name (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net-next,1/2] net: ethernet: mtk_eth_soc: add code for offloading flows from wlan devices | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next, async
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 18 this patch: 18
netdev/cc_maintainers warning 12 maintainers not CCed: angelogioacchino.delregno@collabora.com lorenzo@kernel.org pabeni@redhat.com sean.wang@mediatek.com kuba@kernel.org edumazet@google.com linux-mediatek@lists.infradead.org Mark-MC.Lee@mediatek.com john@phrozen.org linux-arm-kernel@lists.infradead.org matthias.bgg@gmail.com davem@davemloft.net
netdev/build_clang success Errors and warnings before: 18 this patch: 18
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 18 this patch: 18
netdev/checkpatch warning WARNING: line length of 81 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Felix Fietkau March 21, 2023, 1:36 p.m. UTC
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>
---
 drivers/net/ethernet/mediatek/mtk_ppe.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

Comments

Simon Horman March 22, 2023, 2 p.m. UTC | #1
On Tue, Mar 21, 2023 at 02:36:09PM +0100, Felix Fietkau wrote:
> 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.

As per patch 1/2. checkpatch complains that the patch description
has lines more than 75 characters long.

That aside, this change looks good to me.
But I'm wondering if it is fixing a bug.
Or just improving something suboptimal (form a user experience POV).

> 
> Signed-off-by: Felix Fietkau <nbd@nbd.name>

> ---
>  drivers/net/ethernet/mediatek/mtk_ppe.c | 14 ++++++++++++--
>  1 file changed, 12 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/mediatek/mtk_ppe.c b/drivers/net/ethernet/mediatek/mtk_ppe.c
> index 6883eb34cd8b..5e150007bb7d 100644
> --- a/drivers/net/ethernet/mediatek/mtk_ppe.c
> +++ b/drivers/net/ethernet/mediatek/mtk_ppe.c
> @@ -580,10 +580,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)
> -- 
> 2.39.0
>
Felix Fietkau March 22, 2023, 3:09 p.m. UTC | #2
On 22.03.23 15:00, Simon Horman wrote:
> On Tue, Mar 21, 2023 at 02:36:09PM +0100, Felix Fietkau wrote:
>> 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.
> 
> As per patch 1/2. checkpatch complains that the patch description
> has lines more than 75 characters long.
Will do.

> That aside, this change looks good to me.
> But I'm wondering if it is fixing a bug.
> Or just improving something suboptimal (form a user experience POV).
In my opinion, this is just an improvement, not a bugfix.

Thanks,

- Felix
Simon Horman March 22, 2023, 8 p.m. UTC | #3
On Wed, Mar 22, 2023 at 04:09:25PM +0100, Felix Fietkau wrote:
> On 22.03.23 15:00, Simon Horman wrote:
> > On Tue, Mar 21, 2023 at 02:36:09PM +0100, Felix Fietkau wrote:
> > > 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.
> > 
> > As per patch 1/2. checkpatch complains that the patch description
> > has lines more than 75 characters long.
> Will do.
> 
> > That aside, this change looks good to me.
> > But I'm wondering if it is fixing a bug.
> > Or just improving something suboptimal (form a user experience POV).
> In my opinion, this is just an improvement, not a bugfix.

Sure, thanks for the clarification.
diff mbox series

Patch

diff --git a/drivers/net/ethernet/mediatek/mtk_ppe.c b/drivers/net/ethernet/mediatek/mtk_ppe.c
index 6883eb34cd8b..5e150007bb7d 100644
--- a/drivers/net/ethernet/mediatek/mtk_ppe.c
+++ b/drivers/net/ethernet/mediatek/mtk_ppe.c
@@ -580,10 +580,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)