From patchwork Mon Feb 5 22:31:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Chan X-Patchwork-Id: 13546349 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qt1-f175.google.com (mail-qt1-f175.google.com [209.85.160.175]) (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 91D2748CCF for ; Mon, 5 Feb 2024 22:32:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707172349; cv=none; b=X/SQqN+ZbsuYzH/1uV5QcXhn0j7IYzfGcaz1Ls57/yboSPfUARVWpy8oYSKkQzcEET/LUAx9A1JUK6vViXyWBnMq/xAkNiT5YMhQPcjkmFPD6IgOQ6N6kG+c3PnUn4pPIE3IYezHoTUPPnsxTQI3L2tgIJ911g065VNGw/137hE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707172349; c=relaxed/simple; bh=AB1bCTPf3UZDfPkZCqaa0Pp9gCGzt538ekc7sJ41Vzc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Type; b=MsT/MSAN5VtXRv2F/ekpXXY5vPu9f/+9f4htgYw2Y/8kzUjeupclw2cuuFjm6fL9QbE8fJlt1GUx7b1xgFK54+QbU67OiYZipZsBo3XwvlFm1aev/4DZIqLkhDi13f1k8N7P8nxGnEKVcbdI3MqDJVVBxaIGp9fBwGxaO39MqbM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com; spf=fail smtp.mailfrom=broadcom.com; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b=f8W6d6IB; arc=none smtp.client-ip=209.85.160.175 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="f8W6d6IB" Received: by mail-qt1-f175.google.com with SMTP id d75a77b69052e-42c2591e7aaso11101001cf.0 for ; Mon, 05 Feb 2024 14:32:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1707172346; x=1707777146; 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=dN3r1Dcnc91l419zFgMLk79fNtTm5YA98Xwn1Qudldw=; b=f8W6d6IBcPz6OKvdm6hdBp3Wxo7zNp4u5WwG3oMfquuKoquWj2V0xeypA4W8P+ER8M Ovj1BbM7xo4cW25KP6Eld5XaSbKBGOTk5q0SfrwTYv5aXryigd34VVwZRkAssLmrd9tA 3fIVpwaoRXOww1QnVso8sY+Sd50t/k91bMKZ0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707172346; x=1707777146; 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=dN3r1Dcnc91l419zFgMLk79fNtTm5YA98Xwn1Qudldw=; b=OBMYbcwLbcd+peBgtylsFkyY+cjh3FviucThTV7dbvp6grtQfkC75WWXOzmE6zfZE4 le8BiwRle53YBfb7tiN2lvp8/avgF9v7CVQPW6gI0PC6eWxF/ygY0quxaHgz8kHYZpiw Teq+JW+1ESoUQeZUvQZim2nJvz6TnElmC20fW58a9mIygiAEs8pczG6JUPz4OYWu0z9H E1XprFwUSAala7gQmR3HzePjd41DVti8tJBYWllVgN3GZkeyYOJaCK6pUHF1gPk3k38u nfkWiTYyKGzw2jsAnJSdiSTd6GzoYRTFwpgWQSfuWTzyyXeNNyLn5VyHTeX2p91zG9V3 q35Q== X-Gm-Message-State: AOJu0YxL9m3/1vha90GbHXz5rqAPcoz90Evg79QOMQIYpme3fvzdG98P ODaqqnHk6tUfI9sH1UV5I2K+U23EeN5UYXuw7yM0PryowBvb6FEgOW3GRarCjQ== X-Google-Smtp-Source: AGHT+IHR+VAY4O4r4YkZS8QGQGOhmCsebrUYxDEWtqSMw8tWFD/p9LLrV0cIo5x8cA7b9CRHu//mJg== X-Received: by 2002:ac8:4e86:0:b0:42a:995d:13d1 with SMTP id 6-20020ac84e86000000b0042a995d13d1mr777645qtp.43.1707172346320; Mon, 05 Feb 2024 14:32:26 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWXyYgxSd0vL0sPDyxFZQp+xTunIXq0lLfz1JzVARLbg6DCIiue7lL6xwro6pbwdE8eJdcJplZ/WldURkWvNS4e0svuGBbzO4gNjHx3eE615D7hetFJhSjkUoRUBTYaqBTfEIZcKIiojJUEeMIwMvRhBgB8zPURwqUMN4vljpxlImNVcN87g2JH3Y7ZnaQHNGhzc4J43VRv0wGbRx/KxTmkVe0= Received: from lvnvda5233.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id x11-20020ac8120b000000b0042c2d47d7fbsm340864qti.60.2024.02.05.14.32.24 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2024 14:32:25 -0800 (PST) From: Michael Chan To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, andrew.gospodarek@broadcom.com, pavan.chebbi@broadcom.com Subject: [PATCH net-next 07/13] bnxt_en: Add separate function to delete the filter structure Date: Mon, 5 Feb 2024 14:31:56 -0800 Message-Id: <20240205223202.25341-8-michael.chan@broadcom.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20240205223202.25341-1-michael.chan@broadcom.com> References: <20240205223202.25341-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 From: Pavan Chebbi Since we are going to do filter deletion at multiple places in the upcoming patches, add a function that does the deletion. Future patches add more code into this function. Since we are passing the address of the filter base to free the entire filter structure, add a comment to make sure that the base is always at the beginning of the structure. Reviewed-by: Andy Gospodarek Signed-off-by: Pavan Chebbi Signed-off-by: Michael Chan --- drivers/net/ethernet/broadcom/bnxt/bnxt.c | 22 ++++++++++++---------- drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 ++ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c index 382b4a559c9c..d39de72bffea 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c @@ -4841,6 +4841,16 @@ static void bnxt_clear_ring_indices(struct bnxt *bp) } } +static void bnxt_del_fltr(struct bnxt *bp, struct bnxt_filter_base *fltr) +{ + hlist_del(&fltr->hash); + if (fltr->flags) { + clear_bit(fltr->sw_id, bp->ntp_fltr_bmap); + bp->ntp_fltr_count--; + } + kfree(fltr); +} + static void bnxt_free_ntp_fltrs(struct bnxt *bp, bool all) { int i; @@ -4858,10 +4868,7 @@ static void bnxt_free_ntp_fltrs(struct bnxt *bp, bool all) bnxt_del_l2_filter(bp, fltr->l2_fltr); if (!all && (fltr->base.flags & BNXT_ACT_FUNC_DST)) continue; - hlist_del(&fltr->base.hash); - clear_bit(fltr->base.sw_id, bp->ntp_fltr_bmap); - bp->ntp_fltr_count--; - kfree(fltr); + bnxt_del_fltr(bp, &fltr->base); } } if (!all) @@ -4904,12 +4911,7 @@ static void bnxt_free_l2_filters(struct bnxt *bp, bool all) hlist_for_each_entry_safe(fltr, tmp, head, base.hash) { if (!all && (fltr->base.flags & BNXT_ACT_FUNC_DST)) continue; - hlist_del(&fltr->base.hash); - if (fltr->base.flags) { - clear_bit(fltr->base.sw_id, bp->ntp_fltr_bmap); - bp->ntp_fltr_count--; - } - kfree(fltr); + bnxt_del_fltr(bp, &fltr->base); } } } diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h b/drivers/net/ethernet/broadcom/bnxt/bnxt.h index 16f18c70c7bb..d070e3ac9739 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h @@ -1365,6 +1365,7 @@ extern const struct bnxt_flow_masks BNXT_FLOW_IPV6_MASK_ALL; extern const struct bnxt_flow_masks BNXT_FLOW_IPV4_MASK_ALL; struct bnxt_ntuple_filter { + /* base filter must be the first member */ struct bnxt_filter_base base; struct flow_keys fkeys; struct bnxt_flow_masks fmasks; @@ -1395,6 +1396,7 @@ struct bnxt_ipv6_tuple { #define BNXT_L2_KEY_SIZE (sizeof(struct bnxt_l2_key) / 4) struct bnxt_l2_filter { + /* base filter must be the first member */ struct bnxt_filter_base base; struct bnxt_l2_key l2_key; atomic_t refcnt;