From patchwork Sat Dec 23 04:22:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13503911 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com [209.85.219.47]) (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 E3DBA9441 for ; Sat, 23 Dec 2023 04:22:51 +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="RgvF2UR6" Received: by mail-qv1-f47.google.com with SMTP id 6a1803df08f44-67ac0ef6bb8so13596386d6.1 for ; Fri, 22 Dec 2023 20:22:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1703305371; x=1703910171; 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=2ZxVfS8QxfYacqg50BVloNEHrBAWAsZkRMI1I8mNgkE=; b=RgvF2UR6vvJkM8Q+E/rh9udg9Q4FdwfkEHt2EofTkTn9DHm+JXy/6guEpGMns+gKQ7 BPaLnVyNFMaVhL/0lgDVypP33C74QZ9D+7S75j3YwKaJIQPTT6IytT80lzts+gYMT9j2 WYwRWMwioXTStKGQ5nXTlWUuUeXsszRkpcOcA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703305371; x=1703910171; 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=2ZxVfS8QxfYacqg50BVloNEHrBAWAsZkRMI1I8mNgkE=; b=mIJOinsUKczP2Fmr0L0+56c0Cn9ViXwQB9aDh+ifTY8jvz2+Jqk0EnYRra6WVwdRLC E8LD8SWgwn6mLEaEzSpYcXYjFK4VzG4/JY0B2uzbHsA2z/F+gj/R1+3IZEssMeaDJ57b g2jfYsG/MXGk+Z7PfnMm8w2hqPvOfVh2/6fHWwA5oIh3D0+bQ2PmwtiRP22IXBEz9N5r +MLDeUSBZrAidSv/hSL/5AKEb3YRFTRidvH7kA4pSeewxwj3KZpUCA05UYfLue4wgj7d MgggI5vNTl7pies2koLGk1b/o1LlXUJlU1Rtu4IaAklEANSpZtKIcEVnTO4/ZwEUejBr DFKw== X-Gm-Message-State: AOJu0Yy5l0awFKyy9uOs2br2pAMmvQLyycPp2DABFEvmc0SaCyOVls/a or9EMlYTifv9ofyJ7OUNkXeJj+wnA0a8 X-Google-Smtp-Source: AGHT+IFWMkwfz51vAtgQ/TpLsAq3/RSW9mMNabymNa5YCkimh2osH6jUtZkCqbi3WHU7woUUksgyMg== X-Received: by 2002:a05:6214:b65:b0:67f:9128:8d0e with SMTP id ey5-20020a0562140b6500b0067f91288d0emr4379013qvb.46.1703305370716; Fri, 22 Dec 2023 20:22:50 -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.49 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Dec 2023 20:22:50 -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 10/13] bnxt_en: Refactor ntuple filter removal logic in bnxt_cfg_ntp_filters(). Date: Fri, 22 Dec 2023 20:22:07 -0800 Message-Id: <20231223042210.102485-11-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 Refactor the logic into a new function bnxt_del_ntp_filters(). The same call will be used when the user deletes an ntuple filter. The bnxt_hwrm_cfa_ntuple_filter_free() function to call fw to free the ntuple filter is exported so that the ethtool logic can call it. Reviewed-by: Vasundhara Volam Reviewed-by: Andy Gospodarek Reviewed-by: Pavan Chebbi Signed-off-by: Michael Chan Reviewed-by: Simon Horman --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 35 ++++++++++++----------- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 3 ++ 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 1e5bf8b7dd55..79a1081c25f5 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -5609,8 +5609,8 @@ int bnxt_hwrm_l2_filter_alloc(struct bnxt *bp, struct bnxt_l2_filter *fltr) return rc; } -static int bnxt_hwrm_cfa_ntuple_filter_free(struct bnxt *bp, - struct bnxt_ntuple_filter *fltr) +int bnxt_hwrm_cfa_ntuple_filter_free(struct bnxt *bp, + struct bnxt_ntuple_filter *fltr) { struct hwrm_cfa_ntuple_filter_free_input *req; int rc; @@ -14011,6 +14011,21 @@ static int bnxt_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb, } #endif +void bnxt_del_ntp_filter(struct bnxt *bp, struct bnxt_ntuple_filter *fltr) +{ + 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); + bp->ntp_fltr_count--; + spin_unlock_bh(&bp->ntp_fltr_lock); + bnxt_del_l2_filter(bp, fltr->l2_fltr); + clear_bit(fltr->base.sw_id, bp->ntp_fltr_bmap); + kfree_rcu(fltr, base.rcu); +} + static void bnxt_cfg_ntp_filters(struct bnxt *bp) { int i; @@ -14042,20 +14057,8 @@ static void bnxt_cfg_ntp_filters(struct bnxt *bp) set_bit(BNXT_FLTR_VALID, &fltr->base.state); } - 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); - bnxt_del_l2_filter(bp, fltr->l2_fltr); - synchronize_rcu(); - clear_bit(fltr->base.sw_id, bp->ntp_fltr_bmap); - kfree(fltr); - } + if (del) + bnxt_del_ntp_filter(bp, fltr); } } if (test_and_clear_bit(BNXT_HWRM_PF_UNLOAD_SP_EVENT, &bp->sp_event)) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index f37d98d7962a..60f62bc36d2c 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -2636,6 +2636,8 @@ int bnxt_hwrm_func_drv_unrgtr(struct bnxt *bp); void bnxt_del_l2_filter(struct bnxt *bp, struct bnxt_l2_filter *fltr); int bnxt_hwrm_l2_filter_free(struct bnxt *bp, struct bnxt_l2_filter *fltr); int bnxt_hwrm_l2_filter_alloc(struct bnxt *bp, struct bnxt_l2_filter *fltr); +int bnxt_hwrm_cfa_ntuple_filter_free(struct bnxt *bp, + struct bnxt_ntuple_filter *fltr); int bnxt_get_nr_rss_ctxs(struct bnxt *bp, int rx_rings); int bnxt_hwrm_vnic_cfg(struct bnxt *bp, u16 vnic_id); int __bnxt_hwrm_get_tx_rings(struct bnxt *bp, u16 fid, int *tx_rings); @@ -2685,6 +2687,7 @@ u32 bnxt_get_ntp_filter_idx(struct bnxt *bp, struct flow_keys *fkeys, const struct sk_buff *skb); int bnxt_insert_ntp_filter(struct bnxt *bp, struct bnxt_ntuple_filter *fltr, u32 idx); +void bnxt_del_ntp_filter(struct bnxt *bp, struct bnxt_ntuple_filter *fltr); int bnxt_get_max_rings(struct bnxt *, int *, int *, bool); int bnxt_restore_pf_fw_resources(struct bnxt *bp); int bnxt_get_port_parent_id(struct net_device *dev,