Netdev Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Sunil Goutham <sgoutham@marvell.com>
To: <netdev@vger.kernel.org>, <davem@davemloft.net>, <kuba@kernel.org>
Cc: Sunil Goutham <sgoutham@marvell.com>
Subject: [PATCH v2 2/2] octeontx2-pf: Support setting ntuple rule count
Date: Fri, 23 Jul 2021 23:46:46 +0530 [thread overview]
Message-ID: <1627064206-16032-3-git-send-email-sgoutham@marvell.com> (raw)
In-Reply-To: <1627064206-16032-1-git-send-email-sgoutham@marvell.com>
Added support for changing ethtool ntuple filter count.
Rule count change is supported only when there are no
ntuple filters installed.
Signed-off-by: Sunil Goutham <sgoutham@marvell.com>
---
.../ethernet/marvell/octeontx2/nic/otx2_common.h | 1 +
.../ethernet/marvell/octeontx2/nic/otx2_ethtool.c | 3 +++
.../ethernet/marvell/octeontx2/nic/otx2_flows.c | 27 ++++++++++++++++++++--
3 files changed, 29 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h
index 8fd58cd..6fe2bf7 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.h
@@ -825,6 +825,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);
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
index 8df748e..753a8cf 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
@@ -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;
}
diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c
index 4d9de52..ea2626c 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_flows.c
@@ -123,12 +123,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;
@@ -923,6 +940,12 @@ int otx2_add_flow(struct otx2_nic *pfvf, struct ethtool_rxnfc *nfc)
int err = 0;
u32 ring;
+ 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;
--
2.7.4
prev parent reply other threads:[~2021-07-23 18:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-23 18:16 [PATCH v2 0/2] Support ethtool ntuple rule count change Sunil Goutham
2021-07-23 18:16 ` [PATCH v2 1/2] net: ethtool: Support setting ntuple rule count Sunil Goutham
2021-07-24 17:23 ` Andrew Lunn
2021-07-26 22:29 ` Saeed Mahameed
2021-07-23 18:16 ` Sunil Goutham [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1627064206-16032-3-git-send-email-sgoutham@marvell.com \
--to=sgoutham@marvell.com \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--subject='Re: [PATCH v2 2/2] octeontx2-pf: Support setting ntuple rule count' \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).