@@ -820,6 +820,7 @@ int otx2_get_all_flows(struct otx2_nic *pfvf,
int otx2_add_flow(struct otx2_nic *pfvf,
struct ethtool_rxnfc *nfc);
int otx2_remove_flow(struct otx2_nic *pfvf, u32 location);
+int otx2_set_flow_rule_count(struct otx2_nic *pfvf, int count);
int otx2_prepare_flow_request(struct ethtool_rx_flow_spec *fsp,
struct npc_install_flow_req *req);
void otx2_rss_ctx_flow_del(struct otx2_nic *pfvf, int ctx_id);
@@ -690,6 +690,9 @@ static int otx2_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *nfc)
if (netif_running(dev) && ntuple)
ret = otx2_remove_flow(pfvf, nfc->fs.location);
break;
+ case ETHTOOL_SRXCLSRLCNT:
+ ret = otx2_set_flow_rule_count(pfvf, nfc->rule_cnt);
+ break;
default:
break;
}
@@ -117,12 +117,29 @@ static int otx2_alloc_ntuple_mcam_entries(struct otx2_nic *pfvf, u16 count)
if (allocated != count)
netdev_info(pfvf->netdev,
- "Unable to allocate %d MCAM entries for ntuple, got %d\n",
- count, allocated);
+ "Unable to allocate %d MCAM entries above default rules "
+ "start index %d, got only %d\n",
+ count, flow_cfg->def_ent[0], allocated);
return allocated;
}
+int otx2_set_flow_rule_count(struct otx2_nic *pfvf, int count)
+{
+ struct otx2_flow_config *flow_cfg = pfvf->flow_cfg;
+
+ if (!flow_cfg)
+ return 0;
+
+ if (flow_cfg->nr_flows) {
+ netdev_err(pfvf->netdev,
+ "Cannot change count when there are active rules\n");
+ return 0;
+ }
+
+ return otx2_alloc_ntuple_mcam_entries(pfvf, count);
+}
+
int otx2_alloc_mcam_entries(struct otx2_nic *pfvf)
{
struct otx2_flow_config *flow_cfg = pfvf->flow_cfg;
@@ -827,6 +844,12 @@ int otx2_add_flow(struct otx2_nic *pfvf, struct ethtool_rxnfc *nfc)
u32 ring;
int err;
+ if (!flow_cfg->ntuple_max_flows) {
+ netdev_err(pfvf->netdev,
+ "Ntuple rule count is 0, allocate and retry\n");
+ return -EINVAL;
+ }
+
ring = ethtool_get_flow_spec_ring(fsp->ring_cookie);
if (!(pfvf->flags & OTX2_FLAG_NTUPLE_SUPPORT))
return -ENOMEM;