netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Oltean <vladimir.oltean@nxp.com>
To: davem@davemloft.net
Cc: alexandre.belloni@bootlin.com, andrew@lunn.ch,
	f.fainelli@gmail.com, vivien.didelot@gmail.com,
	horatiu.vultur@microchip.com, joergen.andreasen@microchip.com,
	allan.nielsen@microchip.com, alexandru.marginean@nxp.com,
	claudiu.manoil@nxp.com, netdev@vger.kernel.org,
	UNGLinuxDriver@microchip.com
Subject: [RFC PATCH net-next 06/14] net: mscc: ocelot: look up the filters in flower_stats() and flower_destroy()
Date: Fri, 25 Sep 2020 15:18:47 +0300	[thread overview]
Message-ID: <20200925121855.370863-7-vladimir.oltean@nxp.com> (raw)
In-Reply-To: <20200925121855.370863-1-vladimir.oltean@nxp.com>

Currently a new filter is created, containing just enough correct
information to be able to call ocelot_vcap_block_find_filter_by_index()
on it.

This will be limiting us in the future, when we'll have more metadata
associated with a filter, which will matter in the stats() and destroy()
callbacks, and which we can't make up on the spot. For example, we'll
start "offloading" some dummy tc filter entries for the TCAM skeleton,
but we won't actually be adding them to the hardware, or to block->rules.
So, it makes sense to avoid deleting those rules too. That's the kind of
thing which is difficult to determine unless we look up the real filter.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 drivers/net/ethernet/mscc/ocelot_flower.c | 23 ++++++++++++++---------
 drivers/net/ethernet/mscc/ocelot_vcap.c   |  8 ++++----
 2 files changed, 18 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/mscc/ocelot_flower.c b/drivers/net/ethernet/mscc/ocelot_flower.c
index ffd66966b0b7..9910fcafcabc 100644
--- a/drivers/net/ethernet/mscc/ocelot_flower.c
+++ b/drivers/net/ethernet/mscc/ocelot_flower.c
@@ -222,28 +222,33 @@ EXPORT_SYMBOL_GPL(ocelot_cls_flower_replace);
 int ocelot_cls_flower_destroy(struct ocelot *ocelot, int port,
 			      struct flow_cls_offload *f, bool ingress)
 {
-	struct ocelot_vcap_filter filter;
+	struct ocelot_vcap_block *block = &ocelot->block;
+	struct ocelot_vcap_filter *filter;
 
-	filter.prio = f->common.prio;
-	filter.id = f->cookie;
+	filter = ocelot_vcap_block_find_filter_by_id(block, f->cookie);
+	if (!filter)
+		return 0;
 
-	return ocelot_vcap_filter_del(ocelot, &filter);
+	return ocelot_vcap_filter_del(ocelot, filter);
 }
 EXPORT_SYMBOL_GPL(ocelot_cls_flower_destroy);
 
 int ocelot_cls_flower_stats(struct ocelot *ocelot, int port,
 			    struct flow_cls_offload *f, bool ingress)
 {
-	struct ocelot_vcap_filter filter;
+	struct ocelot_vcap_block *block = &ocelot->block;
+	struct ocelot_vcap_filter *filter;
 	int ret;
 
-	filter.prio = f->common.prio;
-	filter.id = f->cookie;
-	ret = ocelot_vcap_filter_stats_update(ocelot, &filter);
+	filter = ocelot_vcap_block_find_filter_by_id(block, f->cookie);
+	if (!filter)
+		return 0;
+
+	ret = ocelot_vcap_filter_stats_update(ocelot, filter);
 	if (ret)
 		return ret;
 
-	flow_stats_update(&f->stats, 0x0, filter.stats.pkts, 0, 0x0,
+	flow_stats_update(&f->stats, 0x0, filter->stats.pkts, 0, 0x0,
 			  FLOW_ACTION_HW_STATS_IMMEDIATE);
 	return 0;
 }
diff --git a/drivers/net/ethernet/mscc/ocelot_vcap.c b/drivers/net/ethernet/mscc/ocelot_vcap.c
index 6c43c1de1d54..8bb03aa57811 100644
--- a/drivers/net/ethernet/mscc/ocelot_vcap.c
+++ b/drivers/net/ethernet/mscc/ocelot_vcap.c
@@ -956,7 +956,7 @@ int ocelot_vcap_filter_stats_update(struct ocelot *ocelot,
 				    struct ocelot_vcap_filter *filter)
 {
 	struct ocelot_vcap_block *block = &ocelot->block;
-	struct ocelot_vcap_filter *tmp;
+	struct ocelot_vcap_filter tmp;
 	int index;
 
 	index = ocelot_vcap_block_get_filter_index(block, filter);
@@ -966,9 +966,9 @@ int ocelot_vcap_filter_stats_update(struct ocelot *ocelot,
 	vcap_entry_get(ocelot, filter, index);
 
 	/* After we get the result we need to clear the counters */
-	tmp = ocelot_vcap_block_find_filter_by_index(block, index);
-	tmp->stats.pkts = 0;
-	is2_entry_set(ocelot, index, tmp);
+	tmp = *filter;
+	tmp.stats.pkts = 0;
+	is2_entry_set(ocelot, index, &tmp);
 
 	return 0;
 }
-- 
2.25.1


  parent reply	other threads:[~2020-09-25 12:19 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-25 12:18 [RFC PATCH net-next 00/14] Offload tc-flower using VCAP chains Vladimir Oltean
2020-09-25 12:18 ` [RFC PATCH net-next 01/14] net: mscc: ocelot: introduce a new ocelot_target_{read,write} API Vladimir Oltean
2020-09-25 13:51   ` Alexandre Belloni
2020-09-25 12:18 ` [RFC PATCH net-next 02/14] net: mscc: ocelot: generalize existing code for VCAP Vladimir Oltean
2020-09-25 12:18 ` [RFC PATCH net-next 03/14] net: mscc: ocelot: offload multiple tc-flower actions in same rule Vladimir Oltean
2020-09-26 11:50   ` Horatiu Vultur
2020-09-25 12:18 ` [RFC PATCH net-next 04/14] net: mscc: ocelot: change vcap to be compatible with full and quad entry Vladimir Oltean
2020-09-25 12:18 ` [RFC PATCH net-next 05/14] net: mscc: ocelot: add a new ocelot_vcap_block_find_filter_by_id function Vladimir Oltean
2020-09-25 12:18 ` Vladimir Oltean [this message]
2020-09-25 12:18 ` [RFC PATCH net-next 07/14] net: mscc: ocelot: introduce conversion helpers between port and netdev Vladimir Oltean
2020-09-25 13:53   ` Alexandre Belloni
2020-09-25 12:18 ` [RFC PATCH net-next 08/14] net: mscc: ocelot: create TCAM skeleton from tc filter chains Vladimir Oltean
2020-09-25 12:18 ` [RFC PATCH net-next 09/14] net: mscc: ocelot: offload ingress skbedit and vlan actions to VCAP IS1 Vladimir Oltean
2020-09-25 12:18 ` [RFC PATCH net-next 10/14] net: mscc: ocelot: offload egress VLAN rewriting to VCAP ES0 Vladimir Oltean
2020-09-25 12:18 ` [RFC PATCH net-next 11/14] net: mscc: ocelot: only install TCAM entries into a specific lookup and PAG Vladimir Oltean
2020-09-25 12:18 ` [RFC PATCH net-next 12/14] net: mscc: ocelot: relax ocelot_exclusive_mac_etype_filter_rules() Vladimir Oltean
2020-09-25 12:18 ` [RFC PATCH net-next 13/14] net: mscc: ocelot: offload redirect action to VCAP IS2 Vladimir Oltean
2020-09-25 12:18 ` [RFC PATCH net-next 14/14] selftests: ocelot: add some example VCAP IS1, IS2 and ES0 tc offloads Vladimir Oltean

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=20200925121855.370863-7-vladimir.oltean@nxp.com \
    --to=vladimir.oltean@nxp.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=alexandre.belloni@bootlin.com \
    --cc=alexandru.marginean@nxp.com \
    --cc=allan.nielsen@microchip.com \
    --cc=andrew@lunn.ch \
    --cc=claudiu.manoil@nxp.com \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=horatiu.vultur@microchip.com \
    --cc=joergen.andreasen@microchip.com \
    --cc=netdev@vger.kernel.org \
    --cc=vivien.didelot@gmail.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).