Skip to content

Commit 2f4f9fe

Browse files
Pavan Chebbikuba-moo
authored andcommitted
bnxt_en: Support adding ntuple rules on RSS contexts
When the user wants to add an ntuple filter to an RSS context, select the appropriate VNIC belonging to the selected RSS context and add the VNIC destination rule. Make the necessary changes to bnxt_add_ntuple_cls_rule(). Reviewed-by: Kalesh AP <[email protected]> Signed-off-by: Pavan Chebbi <[email protected]> Signed-off-by: Michael Chan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 61c814b commit 2f4f9fe

File tree

3 files changed

+51
-9
lines changed

3 files changed

+51
-9
lines changed

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5791,8 +5791,20 @@ bnxt_cfg_rfs_ring_tbl_idx(struct bnxt *bp,
57915791
struct hwrm_cfa_ntuple_filter_alloc_input *req,
57925792
struct bnxt_ntuple_filter *fltr)
57935793
{
5794+
struct bnxt_rss_ctx *rss_ctx, *tmp;
57945795
u16 rxq = fltr->base.rxq;
57955796

5797+
if (fltr->base.flags & BNXT_ACT_RSS_CTX) {
5798+
list_for_each_entry_safe(rss_ctx, tmp, &bp->rss_ctx_list, list) {
5799+
if (rss_ctx->index == fltr->base.fw_vnic_id) {
5800+
struct bnxt_vnic_info *vnic = &rss_ctx->vnic;
5801+
5802+
req->dst_id = cpu_to_le16(vnic->fw_vnic_id);
5803+
break;
5804+
}
5805+
}
5806+
return;
5807+
}
57965808
if (BNXT_SUPPORTS_NTUPLE_VNIC(bp)) {
57975809
struct bnxt_vnic_info *vnic;
57985810
u32 enables;
@@ -9944,6 +9956,8 @@ void bnxt_del_one_rss_ctx(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx,
99449956
bool all)
99459957
{
99469958
struct bnxt_vnic_info *vnic = &rss_ctx->vnic;
9959+
struct bnxt_filter_base *usr_fltr, *tmp;
9960+
struct bnxt_ntuple_filter *ntp_fltr;
99479961
int i;
99489962

99499963
bnxt_hwrm_vnic_free_one(bp, &rss_ctx->vnic);
@@ -9954,6 +9968,18 @@ void bnxt_del_one_rss_ctx(struct bnxt *bp, struct bnxt_rss_ctx *rss_ctx,
99549968
if (!all)
99559969
return;
99569970

9971+
list_for_each_entry_safe(usr_fltr, tmp, &bp->usr_fltr_list, list) {
9972+
if ((usr_fltr->flags & BNXT_ACT_RSS_CTX) &&
9973+
usr_fltr->fw_vnic_id == rss_ctx->index) {
9974+
ntp_fltr = container_of(usr_fltr,
9975+
struct bnxt_ntuple_filter,
9976+
base);
9977+
bnxt_hwrm_cfa_ntuple_filter_free(bp, ntp_fltr);
9978+
bnxt_del_ntp_filter(bp, ntp_fltr);
9979+
bnxt_del_one_usr_fltr(bp, usr_fltr);
9980+
}
9981+
}
9982+
99579983
if (vnic->rss_table)
99589984
dma_free_coherent(&bp->pdev->dev, vnic->rss_table_size,
99599985
vnic->rss_table,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,6 +1374,7 @@ struct bnxt_filter_base {
13741374
#define BNXT_ACT_RING_DST 2
13751375
#define BNXT_ACT_FUNC_DST 4
13761376
#define BNXT_ACT_NO_AGING 8
1377+
#define BNXT_ACT_RSS_CTX 0x10
13771378
u16 sw_id;
13781379
u16 rxq;
13791380
u16 fw_vnic_id;

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

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1312,22 +1312,24 @@ static bool bnxt_verify_ntuple_ip6_flow(struct ethtool_usrip6_spec *ip_spec,
13121312
}
13131313

13141314
static int bnxt_add_ntuple_cls_rule(struct bnxt *bp,
1315-
struct ethtool_rx_flow_spec *fs)
1315+
struct ethtool_rxnfc *cmd)
13161316
{
1317-
u8 vf = ethtool_get_flow_spec_ring_vf(fs->ring_cookie);
1318-
u32 ring = ethtool_get_flow_spec_ring(fs->ring_cookie);
1317+
struct ethtool_rx_flow_spec *fs = &cmd->fs;
13191318
struct bnxt_ntuple_filter *new_fltr, *fltr;
1319+
u32 flow_type = fs->flow_type & 0xff;
13201320
struct bnxt_l2_filter *l2_fltr;
13211321
struct bnxt_flow_masks *fmasks;
1322-
u32 flow_type = fs->flow_type;
13231322
struct flow_keys *fkeys;
1324-
u32 idx;
1323+
u32 idx, ring;
13251324
int rc;
1325+
u8 vf;
13261326

13271327
if (!bp->vnic_info)
13281328
return -EAGAIN;
13291329

1330-
if ((flow_type & (FLOW_MAC_EXT | FLOW_EXT)) || vf)
1330+
vf = ethtool_get_flow_spec_ring_vf(fs->ring_cookie);
1331+
ring = ethtool_get_flow_spec_ring(fs->ring_cookie);
1332+
if ((fs->flow_type & (FLOW_MAC_EXT | FLOW_EXT)) || vf)
13311333
return -EOPNOTSUPP;
13321334

13331335
if (flow_type == IP_USER_FLOW) {
@@ -1435,6 +1437,19 @@ static int bnxt_add_ntuple_cls_rule(struct bnxt *bp,
14351437
rcu_read_unlock();
14361438

14371439
new_fltr->base.flags = BNXT_ACT_NO_AGING;
1440+
if (fs->flow_type & FLOW_RSS) {
1441+
struct bnxt_rss_ctx *rss_ctx;
1442+
1443+
new_fltr->base.fw_vnic_id = 0;
1444+
new_fltr->base.flags |= BNXT_ACT_RSS_CTX;
1445+
rss_ctx = bnxt_get_rss_ctx_from_index(bp, cmd->rss_context);
1446+
if (rss_ctx) {
1447+
new_fltr->base.fw_vnic_id = rss_ctx->index;
1448+
} else {
1449+
rc = -EINVAL;
1450+
goto ntuple_err;
1451+
}
1452+
}
14381453
if (fs->ring_cookie == RX_CLS_FLOW_DISC)
14391454
new_fltr->base.flags |= BNXT_ACT_DROP;
14401455
else
@@ -1476,12 +1491,12 @@ static int bnxt_srxclsrlins(struct bnxt *bp, struct ethtool_rxnfc *cmd)
14761491
flow_type == IPV6_USER_FLOW) &&
14771492
!(bp->fw_cap & BNXT_FW_CAP_CFA_NTUPLE_RX_EXT_IP_PROTO))
14781493
return -EOPNOTSUPP;
1479-
if (flow_type & (FLOW_MAC_EXT | FLOW_RSS))
1494+
if (flow_type & FLOW_MAC_EXT)
14801495
return -EINVAL;
14811496
flow_type &= ~FLOW_EXT;
14821497

14831498
if (fs->ring_cookie == RX_CLS_FLOW_DISC && flow_type != ETHER_FLOW)
1484-
return bnxt_add_ntuple_cls_rule(bp, fs);
1499+
return bnxt_add_ntuple_cls_rule(bp, cmd);
14851500

14861501
ring = ethtool_get_flow_spec_ring(fs->ring_cookie);
14871502
vf = ethtool_get_flow_spec_ring_vf(fs->ring_cookie);
@@ -1495,7 +1510,7 @@ static int bnxt_srxclsrlins(struct bnxt *bp, struct ethtool_rxnfc *cmd)
14951510
if (flow_type == ETHER_FLOW)
14961511
rc = bnxt_add_l2_cls_rule(bp, fs);
14971512
else
1498-
rc = bnxt_add_ntuple_cls_rule(bp, fs);
1513+
rc = bnxt_add_ntuple_cls_rule(bp, cmd);
14991514
return rc;
15001515
}
15011516

0 commit comments

Comments
 (0)