Skip to content

Commit 992d38d

Browse files
Michael Chandavem330
authored andcommitted
bnxt_en: Refactor bnxt_ntuple_filter structure.
This is in preparation to support user defined L2 (ether) filters, which will have many similarities with ntuple filters. Refactor bnxt_ntuple_filter structure to have a bnxt_filter_base structure that can be re-used by the L2 filters. 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 8a48a2d commit 992d38d

File tree

3 files changed

+44
-30
lines changed

3 files changed

+44
-30
lines changed

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

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4803,8 +4803,8 @@ static void bnxt_free_ntp_fltrs(struct bnxt *bp, bool irq_reinit)
48034803
struct bnxt_ntuple_filter *fltr;
48044804

48054805
head = &bp->ntp_fltr_hash_tbl[i];
4806-
hlist_for_each_entry_safe(fltr, tmp, head, hash) {
4807-
hlist_del(&fltr->hash);
4806+
hlist_for_each_entry_safe(fltr, tmp, head, base.hash) {
4807+
hlist_del(&fltr->base.hash);
48084808
kfree(fltr);
48094809
}
48104810
}
@@ -5301,7 +5301,7 @@ static int bnxt_hwrm_cfa_ntuple_filter_free(struct bnxt *bp,
53015301
if (rc)
53025302
return rc;
53035303

5304-
req->ntuple_filter_id = fltr->filter_id;
5304+
req->ntuple_filter_id = fltr->base.filter_id;
53055305
return hwrm_req_send(bp, req);
53065306
}
53075307

@@ -5342,9 +5342,9 @@ static int bnxt_hwrm_cfa_ntuple_filter_alloc(struct bnxt *bp,
53425342

53435343
if (bp->fw_cap & BNXT_FW_CAP_CFA_RFS_RING_TBL_IDX_V2) {
53445344
flags = CFA_NTUPLE_FILTER_ALLOC_REQ_FLAGS_DEST_RFS_RING_IDX;
5345-
req->dst_id = cpu_to_le16(fltr->rxq);
5345+
req->dst_id = cpu_to_le16(fltr->base.rxq);
53465346
} else {
5347-
vnic = &bp->vnic_info[fltr->rxq + 1];
5347+
vnic = &bp->vnic_info[fltr->base.rxq + 1];
53485348
req->dst_id = cpu_to_le16(vnic->fw_vnic_id);
53495349
}
53505350
req->flags = cpu_to_le32(flags);
@@ -5389,7 +5389,7 @@ static int bnxt_hwrm_cfa_ntuple_filter_alloc(struct bnxt *bp,
53895389
resp = hwrm_req_hold(bp, req);
53905390
rc = hwrm_req_send(bp, req);
53915391
if (!rc)
5392-
fltr->filter_id = resp->ntuple_filter_id;
5392+
fltr->base.filter_id = resp->ntuple_filter_id;
53935393
hwrm_req_drop(bp, req);
53945394
return rc;
53955395
}
@@ -13653,9 +13653,9 @@ static int bnxt_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb,
1365313653
idx = skb_get_hash_raw(skb) & BNXT_NTP_FLTR_HASH_MASK;
1365413654
head = &bp->ntp_fltr_hash_tbl[idx];
1365513655
rcu_read_lock();
13656-
hlist_for_each_entry_rcu(fltr, head, hash) {
13656+
hlist_for_each_entry_rcu(fltr, head, base.hash) {
1365713657
if (bnxt_fltr_match(fltr, new_fltr)) {
13658-
rc = fltr->sw_id;
13658+
rc = fltr->base.sw_id;
1365913659
rcu_read_unlock();
1366013660
goto err_free;
1366113661
}
@@ -13671,17 +13671,18 @@ static int bnxt_rx_flow_steer(struct net_device *dev, const struct sk_buff *skb,
1367113671
goto err_free;
1367213672
}
1367313673

13674-
new_fltr->sw_id = (u16)bit_id;
13674+
new_fltr->base.sw_id = (u16)bit_id;
1367513675
new_fltr->flow_id = flow_id;
1367613676
new_fltr->l2_fltr_idx = l2_idx;
13677-
new_fltr->rxq = rxq_index;
13678-
hlist_add_head_rcu(&new_fltr->hash, head);
13677+
new_fltr->base.rxq = rxq_index;
13678+
new_fltr->base.type = BNXT_FLTR_TYPE_NTUPLE;
13679+
hlist_add_head_rcu(&new_fltr->base.hash, head);
1367913680
bp->ntp_fltr_count++;
1368013681
spin_unlock_bh(&bp->ntp_fltr_lock);
1368113682

1368213683
bnxt_queue_sp_work(bp, BNXT_RX_NTP_FLTR_SP_EVENT);
1368313684

13684-
return new_fltr->sw_id;
13685+
return new_fltr->base.sw_id;
1368513686

1368613687
err_free:
1368713688
kfree(new_fltr);
@@ -13699,13 +13700,13 @@ static void bnxt_cfg_ntp_filters(struct bnxt *bp)
1369913700
int rc;
1370013701

1370113702
head = &bp->ntp_fltr_hash_tbl[i];
13702-
hlist_for_each_entry_safe(fltr, tmp, head, hash) {
13703+
hlist_for_each_entry_safe(fltr, tmp, head, base.hash) {
1370313704
bool del = false;
1370413705

13705-
if (test_bit(BNXT_FLTR_VALID, &fltr->state)) {
13706-
if (rps_may_expire_flow(bp->dev, fltr->rxq,
13706+
if (test_bit(BNXT_FLTR_VALID, &fltr->base.state)) {
13707+
if (rps_may_expire_flow(bp->dev, fltr->base.rxq,
1370713708
fltr->flow_id,
13708-
fltr->sw_id)) {
13709+
fltr->base.sw_id)) {
1370913710
bnxt_hwrm_cfa_ntuple_filter_free(bp,
1371013711
fltr);
1371113712
del = true;
@@ -13716,16 +13717,16 @@ static void bnxt_cfg_ntp_filters(struct bnxt *bp)
1371613717
if (rc)
1371713718
del = true;
1371813719
else
13719-
set_bit(BNXT_FLTR_VALID, &fltr->state);
13720+
set_bit(BNXT_FLTR_VALID, &fltr->base.state);
1372013721
}
1372113722

1372213723
if (del) {
1372313724
spin_lock_bh(&bp->ntp_fltr_lock);
13724-
hlist_del_rcu(&fltr->hash);
13725+
hlist_del_rcu(&fltr->base.hash);
1372513726
bp->ntp_fltr_count--;
1372613727
spin_unlock_bh(&bp->ntp_fltr_lock);
1372713728
synchronize_rcu();
13728-
clear_bit(fltr->sw_id, bp->ntp_fltr_bmap);
13729+
clear_bit(fltr->base.sw_id, bp->ntp_fltr_bmap);
1372913730
kfree(fltr);
1373013731
}
1373113732
}

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

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1332,21 +1332,34 @@ struct bnxt_pf_info {
13321332
struct bnxt_vf_info *vf;
13331333
};
13341334

1335-
struct bnxt_ntuple_filter {
1335+
struct bnxt_filter_base {
13361336
struct hlist_node hash;
1337-
u8 dst_mac_addr[ETH_ALEN];
1338-
u8 src_mac_addr[ETH_ALEN];
1339-
struct flow_keys fkeys;
13401337
__le64 filter_id;
1338+
u8 type;
1339+
#define BNXT_FLTR_TYPE_NTUPLE 1
1340+
#define BNXT_FLTR_TYPE_L2 2
1341+
u8 flags;
1342+
#define BNXT_ACT_DROP 1
1343+
#define BNXT_ACT_RING_DST 2
1344+
#define BNXT_ACT_FUNC_DST 4
13411345
u16 sw_id;
1342-
u8 l2_fltr_idx;
13431346
u16 rxq;
1344-
u32 flow_id;
1347+
u16 fw_vnic_id;
1348+
u16 vf_idx;
13451349
unsigned long state;
13461350
#define BNXT_FLTR_VALID 0
13471351
#define BNXT_FLTR_UPDATE 1
13481352
};
13491353

1354+
struct bnxt_ntuple_filter {
1355+
struct bnxt_filter_base base;
1356+
u8 dst_mac_addr[ETH_ALEN];
1357+
u8 src_mac_addr[ETH_ALEN];
1358+
struct flow_keys fkeys;
1359+
u8 l2_fltr_idx;
1360+
u32 flow_id;
1361+
};
1362+
13501363
struct bnxt_link_info {
13511364
u8 phy_type;
13521365
u8 media_type;

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,10 +1024,10 @@ static int bnxt_grxclsrlall(struct bnxt *bp, struct ethtool_rxnfc *cmd,
10241024

10251025
head = &bp->ntp_fltr_hash_tbl[i];
10261026
rcu_read_lock();
1027-
hlist_for_each_entry_rcu(fltr, head, hash) {
1027+
hlist_for_each_entry_rcu(fltr, head, base.hash) {
10281028
if (j == cmd->rule_cnt)
10291029
break;
1030-
rule_locs[j++] = fltr->sw_id;
1030+
rule_locs[j++] = fltr->base.sw_id;
10311031
}
10321032
rcu_read_unlock();
10331033
if (j == cmd->rule_cnt)
@@ -1053,8 +1053,8 @@ static int bnxt_grxclsrule(struct bnxt *bp, struct ethtool_rxnfc *cmd)
10531053

10541054
head = &bp->ntp_fltr_hash_tbl[i];
10551055
rcu_read_lock();
1056-
hlist_for_each_entry_rcu(fltr, head, hash) {
1057-
if (fltr->sw_id == fs->location)
1056+
hlist_for_each_entry_rcu(fltr, head, base.hash) {
1057+
if (fltr->base.sw_id == fs->location)
10581058
goto fltr_found;
10591059
}
10601060
rcu_read_unlock();
@@ -1107,7 +1107,7 @@ static int bnxt_grxclsrule(struct bnxt *bp, struct ethtool_rxnfc *cmd)
11071107
fs->m_u.tcp_ip6_spec.pdst = cpu_to_be16(~0);
11081108
}
11091109

1110-
fs->ring_cookie = fltr->rxq;
1110+
fs->ring_cookie = fltr->base.rxq;
11111111
rc = 0;
11121112

11131113
fltr_err:

0 commit comments

Comments
 (0)