Skip to content

Commit ec87f05

Browse files
sumang-mrvlPaolo Abeni
authored andcommitted
octeontx2-af: Install TC filter rules in hardware based on priority
As of today, hardware does not support installing tc filter rules based on priority. This patch adds support to install the hardware rules based on priority. The final hardware rules will not be dependent on rule installation order, it will be strictly priority based, same as software. Signed-off-by: Suman Ghosh <[email protected]> Reviewed-by: Simon Horman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
1 parent b8dc6d6 commit ec87f05

File tree

8 files changed

+255
-104
lines changed

8 files changed

+255
-104
lines changed

drivers/net/ethernet/marvell/octeontx2/af/mbox.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ M(NPC_GET_KEX_CFG, 0x600c, npc_get_kex_cfg, \
235235
M(NPC_INSTALL_FLOW, 0x600d, npc_install_flow, \
236236
npc_install_flow_req, npc_install_flow_rsp) \
237237
M(NPC_DELETE_FLOW, 0x600e, npc_delete_flow, \
238-
npc_delete_flow_req, msg_rsp) \
238+
npc_delete_flow_req, npc_delete_flow_rsp) \
239239
M(NPC_MCAM_READ_ENTRY, 0x600f, npc_mcam_read_entry, \
240240
npc_mcam_read_entry_req, \
241241
npc_mcam_read_entry_rsp) \
@@ -1491,6 +1491,8 @@ struct npc_install_flow_req {
14911491
u8 vtag0_op;
14921492
u16 vtag1_def;
14931493
u8 vtag1_op;
1494+
/* old counter value */
1495+
u16 cntr_val;
14941496
};
14951497

14961498
struct npc_install_flow_rsp {
@@ -1506,6 +1508,11 @@ struct npc_delete_flow_req {
15061508
u8 all; /* PF + VFs */
15071509
};
15081510

1511+
struct npc_delete_flow_rsp {
1512+
struct mbox_msghdr hdr;
1513+
u16 cntr_val;
1514+
};
1515+
15091516
struct npc_mcam_read_entry_req {
15101517
struct mbox_msghdr hdr;
15111518
u16 entry; /* MCAM entry to read */

drivers/net/ethernet/marvell/octeontx2/af/rvu_npc_fs.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1192,7 +1192,7 @@ static int npc_install_flow(struct rvu *rvu, int blkaddr, u16 target,
11921192
write_req.enable_entry = (u8)enable;
11931193
/* if counter is available then clear and use it */
11941194
if (req->set_cntr && rule->has_cntr) {
1195-
rvu_write64(rvu, blkaddr, NPC_AF_MATCH_STATX(rule->cntr), 0x00);
1195+
rvu_write64(rvu, blkaddr, NPC_AF_MATCH_STATX(rule->cntr), req->cntr_val);
11961196
write_req.set_cntr = 1;
11971197
write_req.cntr = rule->cntr;
11981198
}
@@ -1407,12 +1407,13 @@ static int npc_delete_flow(struct rvu *rvu, struct rvu_npc_mcam_rule *rule,
14071407

14081408
int rvu_mbox_handler_npc_delete_flow(struct rvu *rvu,
14091409
struct npc_delete_flow_req *req,
1410-
struct msg_rsp *rsp)
1410+
struct npc_delete_flow_rsp *rsp)
14111411
{
14121412
struct npc_mcam *mcam = &rvu->hw->mcam;
14131413
struct rvu_npc_mcam_rule *iter, *tmp;
14141414
u16 pcifunc = req->hdr.pcifunc;
14151415
struct list_head del_list;
1416+
int blkaddr;
14161417

14171418
INIT_LIST_HEAD(&del_list);
14181419

@@ -1428,6 +1429,10 @@ int rvu_mbox_handler_npc_delete_flow(struct rvu *rvu,
14281429
list_move_tail(&iter->list, &del_list);
14291430
/* single rule */
14301431
} else if (req->entry == iter->entry) {
1432+
blkaddr = rvu_get_blkaddr(rvu, BLKTYPE_NPC, 0);
1433+
if (blkaddr)
1434+
rsp->cntr_val = rvu_read64(rvu, blkaddr,
1435+
NPC_AF_MATCH_STATX(iter->cntr));
14311436
list_move_tail(&iter->list, &del_list);
14321437
break;
14331438
}

drivers/net/ethernet/marvell/octeontx2/af/rvu_switch.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,7 @@ void rvu_switch_enable(struct rvu *rvu)
158158
struct npc_mcam_alloc_entry_req alloc_req = { 0 };
159159
struct npc_mcam_alloc_entry_rsp alloc_rsp = { 0 };
160160
struct npc_delete_flow_req uninstall_req = { 0 };
161+
struct npc_delete_flow_rsp uninstall_rsp = { 0 };
161162
struct npc_mcam_free_entry_req free_req = { 0 };
162163
struct rvu_switch *rswitch = &rvu->rswitch;
163164
struct msg_rsp rsp;
@@ -197,7 +198,7 @@ void rvu_switch_enable(struct rvu *rvu)
197198
uninstall_rules:
198199
uninstall_req.start = rswitch->start_entry;
199200
uninstall_req.end = rswitch->start_entry + rswitch->used_entries - 1;
200-
rvu_mbox_handler_npc_delete_flow(rvu, &uninstall_req, &rsp);
201+
rvu_mbox_handler_npc_delete_flow(rvu, &uninstall_req, &uninstall_rsp);
201202
kfree(rswitch->entry2pcifunc);
202203
free_entries:
203204
free_req.all = 1;
@@ -209,6 +210,7 @@ void rvu_switch_enable(struct rvu *rvu)
209210
void rvu_switch_disable(struct rvu *rvu)
210211
{
211212
struct npc_delete_flow_req uninstall_req = { 0 };
213+
struct npc_delete_flow_rsp uninstall_rsp = { 0 };
212214
struct npc_mcam_free_entry_req free_req = { 0 };
213215
struct rvu_switch *rswitch = &rvu->rswitch;
214216
struct rvu_hwinfo *hw = rvu->hw;
@@ -250,7 +252,7 @@ void rvu_switch_disable(struct rvu *rvu)
250252
uninstall_req.start = rswitch->start_entry;
251253
uninstall_req.end = rswitch->start_entry + rswitch->used_entries - 1;
252254
free_req.all = 1;
253-
rvu_mbox_handler_npc_delete_flow(rvu, &uninstall_req, &rsp);
255+
rvu_mbox_handler_npc_delete_flow(rvu, &uninstall_req, &uninstall_rsp);
254256
rvu_mbox_handler_npc_mcam_free_entry(rvu, &free_req, &rsp);
255257
rswitch->used_entries = 0;
256258
kfree(rswitch->entry2pcifunc);

drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -361,13 +361,8 @@ struct otx2_flow_config {
361361
struct list_head flow_list;
362362
u32 dmacflt_max_flows;
363363
u16 max_flows;
364-
};
365-
366-
struct otx2_tc_info {
367-
/* hash table to store TC offloaded flows */
368-
struct rhashtable flow_table;
369-
struct rhashtable_params flow_ht_params;
370-
unsigned long *tc_entries_bitmap;
364+
struct list_head flow_list_tc;
365+
bool ntuple;
371366
};
372367

373368
struct dev_hw_ops {
@@ -492,7 +487,6 @@ struct otx2_nic {
492487
/* NPC MCAM */
493488
struct otx2_flow_config *flow_cfg;
494489
struct otx2_mac_table *mac_table;
495-
struct otx2_tc_info tc_info;
496490

497491
u64 reset_count;
498492
struct work_struct reset_task;
@@ -1064,7 +1058,6 @@ int otx2_init_tc(struct otx2_nic *nic);
10641058
void otx2_shutdown_tc(struct otx2_nic *nic);
10651059
int otx2_setup_tc(struct net_device *netdev, enum tc_setup_type type,
10661060
void *type_data);
1067-
int otx2_tc_alloc_ent_bitmap(struct otx2_nic *nic);
10681061
/* CGX/RPM DMAC filters support */
10691062
int otx2_dmacflt_get_max_cnt(struct otx2_nic *pf);
10701063
int otx2_dmacflt_add(struct otx2_nic *pf, const u8 *mac, u32 bit_pos);

drivers/net/ethernet/marvell/octeontx2/nic/otx2_devlink.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ static int otx2_dl_mcam_count_set(struct devlink *devlink, u32 id,
4141
return 0;
4242

4343
otx2_alloc_mcam_entries(pfvf, ctx->val.vu16);
44-
otx2_tc_alloc_ent_bitmap(pfvf);
4544

4645
return 0;
4746
}

drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -764,6 +764,7 @@ static int otx2_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *nfc)
764764
struct otx2_nic *pfvf = netdev_priv(dev);
765765
int ret = -EOPNOTSUPP;
766766

767+
pfvf->flow_cfg->ntuple = ntuple;
767768
switch (nfc->cmd) {
768769
case ETHTOOL_SRXFH:
769770
ret = otx2_set_rss_hash_opts(pfvf, nfc);

drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ int otx2vf_mcam_flow_init(struct otx2_nic *pfvf)
276276

277277
flow_cfg = pfvf->flow_cfg;
278278
INIT_LIST_HEAD(&flow_cfg->flow_list);
279+
INIT_LIST_HEAD(&flow_cfg->flow_list_tc);
279280
flow_cfg->max_flows = 0;
280281

281282
return 0;
@@ -298,6 +299,7 @@ int otx2_mcam_flow_init(struct otx2_nic *pf)
298299
return -ENOMEM;
299300

300301
INIT_LIST_HEAD(&pf->flow_cfg->flow_list);
302+
INIT_LIST_HEAD(&pf->flow_cfg->flow_list_tc);
301303

302304
/* Allocate bare minimum number of MCAM entries needed for
303305
* unicast and ntuple filters.

0 commit comments

Comments
 (0)