]> www.infradead.org Git - users/hch/misc.git/commitdiff
bnxt_en: Add separate function to delete the filter structure
authorPavan Chebbi <pavan.chebbi@broadcom.com>
Mon, 5 Feb 2024 22:31:56 +0000 (14:31 -0800)
committerJakub Kicinski <kuba@kernel.org>
Fri, 9 Feb 2024 20:37:41 +0000 (12:37 -0800)
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 <andrew.gospodarek@broadcom.com>
Signed-off-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Link: https://lore.kernel.org/r/20240205223202.25341-8-michael.chan@broadcom.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/broadcom/bnxt/bnxt.c
drivers/net/ethernet/broadcom/bnxt/bnxt.h

index 0ebe6a27a31e472430b5df6bb0eeb99cd8fea854..9fb9c5f4ecbd55c92da1b509350c28d0103e7f41 100644 (file)
@@ -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);
                }
        }
 }
index 16f18c70c7bbe4ac0ea98fddfc5a10b4d8f3ffcb..d070e3ac9739481f11dda93d048e0151d5c1fe00 100644 (file)
@@ -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;