Skip to content

Commit

Permalink
bnxt_en: Add bnxt_lookup_ntp_filter_from_idx() function
Browse files Browse the repository at this point in the history
Add the helper function to look up the ntuple filter from the
hash index and use it in bnxt_rx_flow_steer().  The helper function
will also be used by user defined ntuple filters in the next
patches.

Reviewed-by: Andy Gospodarek <andrew.gospodarek@broadcom.com>
Reviewed-by: Pavan Chebbi <pavan.chebbi@broadcom.com>
Signed-off-by: Michael Chan <michael.chan@broadcom.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Michael Chan authored and David S. Miller committed Jan 2, 2024
1 parent d3c9828 commit cb5bdd2
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions drivers/net/ethernet/broadcom/bnxt/bnxt.c
Original file line number Diff line number Diff line change
Expand Up @@ -13899,6 +13899,21 @@ static bool bnxt_fltr_match(struct bnxt_ntuple_filter *f1,
return false;
}

static struct bnxt_ntuple_filter *
bnxt_lookup_ntp_filter_from_idx(struct bnxt *bp,
struct bnxt_ntuple_filter *fltr, u32 idx)
{
struct bnxt_ntuple_filter *f;
struct hlist_head *head;

head = &bp->ntp_fltr_hash_tbl[idx];
hlist_for_each_entry_rcu(f, head, base.hash) {
if (bnxt_fltr_match(f, fltr))
return f;
}
return NULL;
}

static int bnxt_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb,
u16 rxq_index, u32 flow_id)
{
Expand Down Expand Up @@ -13963,12 +13978,11 @@ static int bnxt_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb,
idx = bnxt_get_ntp_filter_idx(bp, fkeys, skb);
head = &bp->ntp_fltr_hash_tbl[idx];
rcu_read_lock();
hlist_for_each_entry_rcu(fltr, head, base.hash) {
if (bnxt_fltr_match(fltr, new_fltr)) {
rc = fltr->base.sw_id;
rcu_read_unlock();
goto err_free;
}
fltr = bnxt_lookup_ntp_filter_from_idx(bp, new_fltr, idx);
if (fltr) {
rcu_read_unlock();
rc = fltr->base.sw_id;
goto err_free;
}
rcu_read_unlock();

Expand Down

0 comments on commit cb5bdd2

Please sign in to comment.