From patchwork Sat Dec 23 04:22:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13503908 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qv1-f48.google.com (mail-qv1-f48.google.com [209.85.219.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 124841375 for ; Sat, 23 Dec 2023 04:22:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="Ow/6HvLs" Received: by mail-qv1-f48.google.com with SMTP id 6a1803df08f44-67f0d22e4faso15140866d6.3 for ; Fri, 22 Dec 2023 20:22:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1703305367; x=1703910167; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=/9Lpj6NR1Wc0IWXKM8jZHfh0aQ6rrgPLjIdaXPrKqYw=; b=Ow/6HvLsLF0G5onkmFIHqora6BJu2J07Dxnv/CjEy67Tm/UOT+v0+jqNiakMRr0xb6 CwMWJTUIU5i03EJRxy1KDQWFZ0wj2k2jyejr1Ch37X4pgEYQb0i4bUHUBb3DI8qz66W4 KAhOVCHIsSVig8apyI4Bh5Y82BEUXulM3WOk0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703305367; x=1703910167; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=/9Lpj6NR1Wc0IWXKM8jZHfh0aQ6rrgPLjIdaXPrKqYw=; b=G8hEXMrGldq8V5nA9QoiYwWnfOKCakWDzx4dQ/csqZmllXLvGapzMT5sC7XvFYWZw3 9cgrCTkDYFyFV7aUd2aqNaCfOHr3cppJ542EG++klWshInQPNg5OjNfnqWAz/HGsWgbV wsaygkPwVjMg1+TefyyF6E2LZmYkMujOQvBcMUniL7Z8OQqUwdTU45gx+qFWV7a4Mm9z QWAZ+AgvgA+88MZoImzQvMtqvmIqU9S7V7bTeSk2sUg2Oh9nVpUuc+VRl43ECbstC0Wq vX0i51lpYFOwQTVSBg5A9FCkUVPsJXyV/o4qTWIRXXhhsZpOU9U/djLlcTkazN2biuBN dfwg== X-Gm-Message-State: AOJu0YwamVIpXFONeIsMVNF5+L0bkDw+QhEchBw4ajAzY3en4VzL24Kc Cx4DEfB0A1OJky1pWwuuVgo/oXD83RtLrDDUK025dtZvQQ== X-Google-Smtp-Source: AGHT+IG2H9uOVUU8kXLsK5/1gW2IVMefBj0n09Txia6tTDz2gCtWV4RNxe2RYdz2gz172JfeMDtR/A== X-Received: by 2002:a05:6214:d64:b0:67f:8030:11b6 with SMTP id 4-20020a0562140d6400b0067f803011b6mr3479672qvs.1.1703305366773; Fri, 22 Dec 2023 20:22:46 -0800 (PST) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id ek5-20020ad45985000000b0067f8046a1acsm1299916qvb.144.2023.12.22.20.22.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Dec 2023 20:22:46 -0800 (PST) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, pavan.chebbi@broadcom.com, andrew.gospodarek@broadcom.com Subject: [PATCH net-next v2 07/13] bnxt_en: Add new BNXT_FLTR_INSERTED flag to bnxt_filter_base struct. Date: Fri, 22 Dec 2023 20:22:04 -0800 Message-Id: <20231223042210.102485-8-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20231223042210.102485-1-michael.chan@broadcom.com> References: <20231223042210.102485-1-michael.chan@broadcom.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: kuba@kernel.org 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 Reviewed-by: Andy Gospodarek Reviewed-by: Pavan Chebbi Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 10 ++++++++++ drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) 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; };