diff mbox series

[net-next,v2,07/13] bnxt_en: Add new BNXT_FLTR_INSERTED flag to bnxt_filter_base struct.

Message ID 20231223042210.102485-8-michael.chan@broadcom.com (mailing list archive)
State Accepted
Commit ee908d05dd2acd89f5c0625535ef415fd89eb6aa
Delegated to: Netdev Maintainers
Headers show
Series bnxt_en: Add basic ntuple filter support | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
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: 1113 this patch: 1113
netdev/cc_maintainers success CCed 4 of 4 maintainers
netdev/build_clang success Errors and warnings before: 1140 this patch: 1140
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: 1144 this patch: 1144
netdev/checkpatch warning WARNING: 'retreived' may be misspelled - perhaps 'retrieved'? WARNING: line length of 97 exceeds 80 columns
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Michael Chan Dec. 23, 2023, 4:22 a.m. UTC
Change the unused flag to BNXT_FLTR_INSERTED.  To prepare for multiple
pathways that an ntuple filter can be deleted, we add this flag.  These
filter structures can be retreived from the RCU hash table but only
the caller that sees that the BNXT_FLTR_INSERTED flag is set can delete
the filter structure and clear the flag under spinlock.

Reviewed-by: Vasundhara Volam <vasundhara-v.volam@broadcom.com>
Reviewed-by: Andy Gospodarek <andrew.gospodarek@broadcom.com>
Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 10 ++++++++++
 drivers/net/ethernet/broadcom/bnxt/bnxt.h |  2 +-
 2 files changed, 11 insertions(+), 1 deletion(-)

Comments

Simon Horman Dec. 25, 2023, 5:02 p.m. UTC | #1
On Fri, Dec 22, 2023 at 08:22:04PM -0800, Michael Chan wrote:
> Change the unused flag to BNXT_FLTR_INSERTED.  To prepare for multiple
> pathways that an ntuple filter can be deleted, we add this flag.  These
> filter structures can be retreived from the RCU hash table but only
> the caller that sees that the BNXT_FLTR_INSERTED flag is set can delete
> the filter structure and clear the flag under spinlock.
> 
> Reviewed-by: Vasundhara Volam <vasundhara-v.volam@broadcom.com>
> Reviewed-by: Andy Gospodarek <andrew.gospodarek@broadcom.com>
> Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
> Signed-off-by: Michael Chan <michael.chan@broadcom.com>

...

> diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
> index 3f4e4708f7d8..867cab036e13 100644
> --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
> +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
> @@ -1348,7 +1348,7 @@ struct bnxt_filter_base {
>  	u16			vf_idx;
>  	unsigned long		state;
>  #define BNXT_FLTR_VALID		0
> -#define BNXT_FLTR_UPDATE	1
> +#define BNXT_FLTR_INSERTED	1

Hi Michael,

a minor nit from my side, which I don't think you need to bother with
unless you need to create v3 for some other reason.

I think that either the hunk above should be squashed into patch 1 of this
series. Or, better IMHO, BNXT_FLTR_UPDATE should simply be dropped from
patch 1.

>  
>  	struct rcu_head         rcu;
>  };
diff mbox series

Patch

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 7027391316e5..0aecf89b4fb9 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -5343,6 +5343,10 @@  void bnxt_del_l2_filter(struct bnxt *bp, struct bnxt_l2_filter *fltr)
 	if (!atomic_dec_and_test(&fltr->refcnt))
 		return;
 	spin_lock_bh(&bp->ntp_fltr_lock);
+	if (!test_and_clear_bit(BNXT_FLTR_INSERTED, &fltr->base.state)) {
+		spin_unlock_bh(&bp->ntp_fltr_lock);
+		return;
+	}
 	hlist_del_rcu(&fltr->base.hash);
 	if (fltr->base.flags) {
 		clear_bit(fltr->base.sw_id, bp->ntp_fltr_bmap);
@@ -5489,6 +5493,7 @@  static int bnxt_init_l2_filter(struct bnxt *bp, struct bnxt_l2_filter *fltr,
 	}
 	head = &bp->l2_fltr_hash_tbl[idx];
 	hlist_add_head_rcu(&fltr->base.hash, head);
+	set_bit(BNXT_FLTR_INSERTED, &fltr->base.state);
 	atomic_set(&fltr->refcnt, 1);
 	return 0;
 }
@@ -14000,6 +14005,7 @@  static int bnxt_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb,
 	new_fltr->base.type = BNXT_FLTR_TYPE_NTUPLE;
 	new_fltr->base.flags = BNXT_ACT_RING_DST;
 	hlist_add_head_rcu(&new_fltr->base.hash, head);
+	set_bit(BNXT_FLTR_INSERTED, &new_fltr->base.state);
 	bp->ntp_fltr_count++;
 	spin_unlock_bh(&bp->ntp_fltr_lock);
 
@@ -14046,6 +14052,10 @@  static void bnxt_cfg_ntp_filters(struct bnxt *bp)
 
 			if (del) {
 				spin_lock_bh(&bp->ntp_fltr_lock);
+				if (!test_and_clear_bit(BNXT_FLTR_INSERTED, &fltr->base.state)) {
+					spin_unlock_bh(&bp->ntp_fltr_lock);
+					continue;
+				}
 				hlist_del_rcu(&fltr->base.hash);
 				bp->ntp_fltr_count--;
 				spin_unlock_bh(&bp->ntp_fltr_lock);
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
index 3f4e4708f7d8..867cab036e13 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
@@ -1348,7 +1348,7 @@  struct bnxt_filter_base {
 	u16			vf_idx;
 	unsigned long		state;
 #define BNXT_FLTR_VALID		0
-#define BNXT_FLTR_UPDATE	1
+#define BNXT_FLTR_INSERTED	1
 
 	struct rcu_head         rcu;
 };