From patchwork Thu Dec 21 22:02:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13502686 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qv1-f43.google.com (mail-qv1-f43.google.com [209.85.219.43]) (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 2CAF97946F for ; Thu, 21 Dec 2023 22:03:10 +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="VsCbPqpU" Received: by mail-qv1-f43.google.com with SMTP id 6a1803df08f44-67ad277a06bso6797486d6.1 for ; Thu, 21 Dec 2023 14:03:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1703196189; x=1703800989; 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=P4gSX1SZyeut/T2PdVLNXG93+Z7gXvfdfLf+sytFx1U=; b=VsCbPqpURxXSobfwFvWotj7Y/+kiv5LHt/SvnmAnXrO1drBp2WHtMAvUpqYkah02+P BVsOgRvY+xq+xEwJ6XrzMmrhW7jcTz3+kx5w57Suad6yYYF+TszsqNRI3Fg1p/tIpv8n prfkoA/l3suNJLwtDFH6w88IQk//ewXdfYOzI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703196189; x=1703800989; 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=P4gSX1SZyeut/T2PdVLNXG93+Z7gXvfdfLf+sytFx1U=; b=trIzgtRnAWgp00lQvR6FQFZGthWCux5hbCNEzchWbJAp95TJxAJdcdgtKMd94q8Qto fJHk+K79gpkUgDJymxebEDWGygiseYhNkvz2aQH9Tg13lfPkXxucYPNqkLRNzQ3dB65b GkfeoND0Qszh7DHvjBjLVTOj3HMT3I3fOdHPEE4zoniaTr1PFuX+PNzOKA/AmhU4Y1FK oV5lh8iZzQHWJy0L65E3Wh5dTY3v7EQm+kidbPQeYG3QEEAXcb4Jk0nMY9CkIgPDuuqG OJwdcyFnr3w+/pxo+KDQQV3JX7iy44Bjp8v2Ny8CGbIhX6OU4/NvfW358c0yhaitVUSo tzDQ== X-Gm-Message-State: AOJu0YxHPirhjXPpHJUuabnE+euE+y6T3ifLb7KkvzR6+m7b01MIRcxu YIafyECfPxTu58zQTHruzvxn0F43hMk7 X-Google-Smtp-Source: AGHT+IE75nVJ4Rn1CUf9GKjzPybSxTdWu+cYPDoTjLkn/Z/lNSVx85/Vay8zHcWm+J8eyO5b1RVs0w== X-Received: by 2002:a05:6214:2403:b0:67f:356:5731 with SMTP id fv3-20020a056214240300b0067f03565731mr590662qvb.44.1703196189016; Thu, 21 Dec 2023 14:03:09 -0800 (PST) Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id ee14-20020a0562140a4e00b0067f712874fbsm905198qvb.129.2023.12.21.14.03.07 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Dec 2023 14:03:08 -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 07/13] bnxt_en: Add new BNXT_FLTR_INSERTED flag to bnxt_filter_base struct. Date: Thu, 21 Dec 2023 14:02:12 -0800 Message-Id: <20231221220218.197386-8-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20231221220218.197386-1-michael.chan@broadcom.com> References: <20231221220218.197386-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 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 267ffcffa2b4..16eae3bd90e5 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; } @@ -13996,6 +14001,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); @@ -14042,6 +14048,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; };