Skip to content

Commit 4faeadf

Browse files
Michael Chandavem330
authored andcommitted
bnxt_en: Refactor ntuple filter removal logic in bnxt_cfg_ntp_filters().
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 <[email protected]> Reviewed-by: Andy Gospodarek <[email protected]> Reviewed-by: Pavan Chebbi <[email protected]> Signed-off-by: Michael Chan <[email protected]> Reviewed-by: Simon Horman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 80cfde2 commit 4faeadf

File tree

2 files changed

+22
-16
lines changed

2 files changed

+22
-16
lines changed

drivers/net/ethernet/broadcom/bnxt/bnxt.c

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5609,8 +5609,8 @@ int bnxt_hwrm_l2_filter_alloc(struct bnxt *bp, struct bnxt_l2_filter *fltr)
56095609
return rc;
56105610
}
56115611

5612-
static int bnxt_hwrm_cfa_ntuple_filter_free(struct bnxt *bp,
5613-
struct bnxt_ntuple_filter *fltr)
5612+
int bnxt_hwrm_cfa_ntuple_filter_free(struct bnxt *bp,
5613+
struct bnxt_ntuple_filter *fltr)
56145614
{
56155615
struct hwrm_cfa_ntuple_filter_free_input *req;
56165616
int rc;
@@ -14011,6 +14011,21 @@ static int bnxt_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb,
1401114011
}
1401214012
#endif
1401314013

14014+
void bnxt_del_ntp_filter(struct bnxt *bp, struct bnxt_ntuple_filter *fltr)
14015+
{
14016+
spin_lock_bh(&bp->ntp_fltr_lock);
14017+
if (!test_and_clear_bit(BNXT_FLTR_INSERTED, &fltr->base.state)) {
14018+
spin_unlock_bh(&bp->ntp_fltr_lock);
14019+
return;
14020+
}
14021+
hlist_del_rcu(&fltr->base.hash);
14022+
bp->ntp_fltr_count--;
14023+
spin_unlock_bh(&bp->ntp_fltr_lock);
14024+
bnxt_del_l2_filter(bp, fltr->l2_fltr);
14025+
clear_bit(fltr->base.sw_id, bp->ntp_fltr_bmap);
14026+
kfree_rcu(fltr, base.rcu);
14027+
}
14028+
1401414029
static void bnxt_cfg_ntp_filters(struct bnxt *bp)
1401514030
{
1401614031
int i;
@@ -14042,20 +14057,8 @@ static void bnxt_cfg_ntp_filters(struct bnxt *bp)
1404214057
set_bit(BNXT_FLTR_VALID, &fltr->base.state);
1404314058
}
1404414059

14045-
if (del) {
14046-
spin_lock_bh(&bp->ntp_fltr_lock);
14047-
if (!test_and_clear_bit(BNXT_FLTR_INSERTED, &fltr->base.state)) {
14048-
spin_unlock_bh(&bp->ntp_fltr_lock);
14049-
continue;
14050-
}
14051-
hlist_del_rcu(&fltr->base.hash);
14052-
bp->ntp_fltr_count--;
14053-
spin_unlock_bh(&bp->ntp_fltr_lock);
14054-
bnxt_del_l2_filter(bp, fltr->l2_fltr);
14055-
synchronize_rcu();
14056-
clear_bit(fltr->base.sw_id, bp->ntp_fltr_bmap);
14057-
kfree(fltr);
14058-
}
14060+
if (del)
14061+
bnxt_del_ntp_filter(bp, fltr);
1405914062
}
1406014063
}
1406114064
if (test_and_clear_bit(BNXT_HWRM_PF_UNLOAD_SP_EVENT, &bp->sp_event))

drivers/net/ethernet/broadcom/bnxt/bnxt.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2636,6 +2636,8 @@ int bnxt_hwrm_func_drv_unrgtr(struct bnxt *bp);
26362636
void bnxt_del_l2_filter(struct bnxt *bp, struct bnxt_l2_filter *fltr);
26372637
int bnxt_hwrm_l2_filter_free(struct bnxt *bp, struct bnxt_l2_filter *fltr);
26382638
int bnxt_hwrm_l2_filter_alloc(struct bnxt *bp, struct bnxt_l2_filter *fltr);
2639+
int bnxt_hwrm_cfa_ntuple_filter_free(struct bnxt *bp,
2640+
struct bnxt_ntuple_filter *fltr);
26392641
int bnxt_get_nr_rss_ctxs(struct bnxt *bp, int rx_rings);
26402642
int bnxt_hwrm_vnic_cfg(struct bnxt *bp, u16 vnic_id);
26412643
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,
26852687
const struct sk_buff *skb);
26862688
int bnxt_insert_ntp_filter(struct bnxt *bp, struct bnxt_ntuple_filter *fltr,
26872689
u32 idx);
2690+
void bnxt_del_ntp_filter(struct bnxt *bp, struct bnxt_ntuple_filter *fltr);
26882691
int bnxt_get_max_rings(struct bnxt *, int *, int *, bool);
26892692
int bnxt_restore_pf_fw_resources(struct bnxt *bp);
26902693
int bnxt_get_port_parent_id(struct net_device *dev,

0 commit comments

Comments
 (0)