Commit 8336a974 authored by Pavan Chebbi's avatar Pavan Chebbi Committed by Jakub Kicinski
Browse files

bnxt_en: Save user configured filters in a lookup list



Driver needs to maintain a lookup list of all the user configured
filters. This is required in order to reconfigure these filters upon
interface toggle. We can look up this list to follow the order with
which they should be re-applied.

Reviewed-by: default avatarAndy Gospodarek <andrew.gospodarek@broadcom.com>
Signed-off-by: default avatarPavan Chebbi <pavan.chebbi@broadcom.com>
Signed-off-by: default avatarMichael Chan <michael.chan@broadcom.com>
Link: https://lore.kernel.org/r/20240205223202.25341-9-michael.chan@broadcom.com


Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent be40b4e9
Loading
Loading
Loading
Loading
+23 −0
Original line number Diff line number Diff line
@@ -4841,9 +4841,26 @@ static void bnxt_clear_ring_indices(struct bnxt *bp)
	}
}

void bnxt_insert_usr_fltr(struct bnxt *bp, struct bnxt_filter_base *fltr)
{
	u8 type = fltr->type, flags = fltr->flags;

	INIT_LIST_HEAD(&fltr->list);
	if ((type == BNXT_FLTR_TYPE_L2 && flags & BNXT_ACT_RING_DST) ||
	    (type == BNXT_FLTR_TYPE_NTUPLE && flags & BNXT_ACT_NO_AGING))
		list_add_tail(&fltr->list, &bp->usr_fltr_list);
}

void bnxt_del_one_usr_fltr(struct bnxt *bp, struct bnxt_filter_base *fltr)
{
	if (!list_empty(&fltr->list))
		list_del_init(&fltr->list);
}

static void bnxt_del_fltr(struct bnxt *bp, struct bnxt_filter_base *fltr)
{
	hlist_del(&fltr->hash);
	bnxt_del_one_usr_fltr(bp, fltr);
	if (fltr->flags) {
		clear_bit(fltr->sw_id, bp->ntp_fltr_bmap);
		bp->ntp_fltr_count--;
@@ -5387,6 +5404,7 @@ void bnxt_del_l2_filter(struct bnxt *bp, struct bnxt_l2_filter *fltr)
		return;
	}
	hlist_del_rcu(&fltr->base.hash);
	bnxt_del_one_usr_fltr(bp, &fltr->base);
	if (fltr->base.flags) {
		clear_bit(fltr->base.sw_id, bp->ntp_fltr_bmap);
		bp->ntp_fltr_count--;
@@ -5533,6 +5551,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);
	bnxt_insert_usr_fltr(bp, &fltr->base);
	set_bit(BNXT_FLTR_INSERTED, &fltr->base.state);
	atomic_set(&fltr->refcnt, 1);
	return 0;
@@ -13985,6 +14004,7 @@ int bnxt_insert_ntp_filter(struct bnxt *bp, struct bnxt_ntuple_filter *fltr,
	head = &bp->ntp_fltr_hash_tbl[idx];
	hlist_add_head_rcu(&fltr->base.hash, head);
	set_bit(BNXT_FLTR_INSERTED, &fltr->base.state);
	bnxt_insert_usr_fltr(bp, &fltr->base);
	bp->ntp_fltr_count++;
	spin_unlock_bh(&bp->ntp_fltr_lock);
	return 0;
@@ -14139,6 +14159,7 @@ void bnxt_del_ntp_filter(struct bnxt *bp, struct bnxt_ntuple_filter *fltr)
		return;
	}
	hlist_del_rcu(&fltr->base.hash);
	bnxt_del_one_usr_fltr(bp, &fltr->base);
	bp->ntp_fltr_count--;
	spin_unlock_bh(&bp->ntp_fltr_lock);
	bnxt_del_l2_filter(bp, fltr->l2_fltr);
@@ -14955,6 +14976,8 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
	if (rc)
		goto init_err_dl;

	INIT_LIST_HEAD(&bp->usr_fltr_list);

	rc = register_netdev(dev);
	if (rc)
		goto init_err_cleanup;
+5 −0
Original line number Diff line number Diff line
@@ -1334,6 +1334,7 @@ struct bnxt_pf_info {

struct bnxt_filter_base {
	struct hlist_node	hash;
	struct list_head	list;
	__le64			filter_id;
	u8			type;
#define BNXT_FLTR_TYPE_NTUPLE	1
@@ -2442,6 +2443,8 @@ struct bnxt {
	u32			hash_seed;
	u64			toeplitz_prefix;

	struct list_head	usr_fltr_list;

	/* To protect link related settings during link changes and
	 * ethtool settings changes.
	 */
@@ -2646,6 +2649,8 @@ u32 bnxt_fw_health_readl(struct bnxt *bp, int reg_idx);
void bnxt_set_tpa_flags(struct bnxt *bp);
void bnxt_set_ring_params(struct bnxt *);
int bnxt_set_rx_skb_mode(struct bnxt *bp, bool page_mode);
void bnxt_insert_usr_fltr(struct bnxt *bp, struct bnxt_filter_base *fltr);
void bnxt_del_one_usr_fltr(struct bnxt *bp, struct bnxt_filter_base *fltr);
int bnxt_hwrm_func_drv_rgtr(struct bnxt *bp, unsigned long *bmap,
			    int bmap_size, bool async_only);
int bnxt_hwrm_func_drv_unrgtr(struct bnxt *bp);