All of lore.kernel.org
 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, xiaoliang.yang_1@nxp.com,
	hongbo.wang@nxp.com, netdev@vger.kernel.org, kuba@kernel.org,
	UNGLinuxDriver@microchip.com
Subject: [PATCH net-next 12/13] net: mscc: ocelot: add a new ocelot_vcap_block_find_filter_by_id function
Date: Wed, 30 Sep 2020 01:27:32 +0300	[thread overview]
Message-ID: <20200929222733.770926-13-vladimir.oltean@nxp.com> (raw)
In-Reply-To: <20200929222733.770926-1-vladimir.oltean@nxp.com>

And rename the existing find to ocelot_vcap_block_find_filter_by_index.
The index is the position in the TCAM, and the id is the flow cookie
given by tc.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
Changes since RFC v2:
None.

Changes since RFC v1:
None.

 drivers/net/ethernet/mscc/ocelot_vcap.c | 26 ++++++++++++++++++-------
 drivers/net/ethernet/mscc/ocelot_vcap.h |  2 ++
 2 files changed, 21 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/mscc/ocelot_vcap.c b/drivers/net/ethernet/mscc/ocelot_vcap.c
index 9e1b023f2d00..aa6f6a770199 100644
--- a/drivers/net/ethernet/mscc/ocelot_vcap.c
+++ b/drivers/net/ethernet/mscc/ocelot_vcap.c
@@ -769,8 +769,8 @@ static int ocelot_vcap_block_get_filter_index(struct ocelot_vcap_block *block,
 }
 
 static struct ocelot_vcap_filter*
-ocelot_vcap_block_find_filter(struct ocelot_vcap_block *block,
-			      int index)
+ocelot_vcap_block_find_filter_by_index(struct ocelot_vcap_block *block,
+				       int index)
 {
 	struct ocelot_vcap_filter *tmp;
 	int i = 0;
@@ -784,6 +784,18 @@ ocelot_vcap_block_find_filter(struct ocelot_vcap_block *block,
 	return NULL;
 }
 
+struct ocelot_vcap_filter *
+ocelot_vcap_block_find_filter_by_id(struct ocelot_vcap_block *block, int id)
+{
+	struct ocelot_vcap_filter *filter;
+
+	list_for_each_entry(filter, &block->rules, list)
+		if (filter->id == id)
+			return filter;
+
+	return NULL;
+}
+
 /* If @on=false, then SNAP, ARP, IP and OAM frames will not match on keys based
  * on destination and source MAC addresses, but only on higher-level protocol
  * information. The only frame types to match on keys containing MAC addresses
@@ -865,7 +877,7 @@ ocelot_exclusive_mac_etype_filter_rules(struct ocelot *ocelot,
 	if (ocelot_vcap_is_problematic_mac_etype(filter)) {
 		/* Search for any non-MAC_ETYPE rules on the port */
 		for (i = 0; i < block->count; i++) {
-			tmp = ocelot_vcap_block_find_filter(block, i);
+			tmp = ocelot_vcap_block_find_filter_by_index(block, i);
 			if (tmp->ingress_port_mask & filter->ingress_port_mask &&
 			    ocelot_vcap_is_problematic_non_mac_etype(tmp))
 				return false;
@@ -877,7 +889,7 @@ ocelot_exclusive_mac_etype_filter_rules(struct ocelot *ocelot,
 	} else if (ocelot_vcap_is_problematic_non_mac_etype(filter)) {
 		/* Search for any MAC_ETYPE rules on the port */
 		for (i = 0; i < block->count; i++) {
-			tmp = ocelot_vcap_block_find_filter(block, i);
+			tmp = ocelot_vcap_block_find_filter_by_index(block, i);
 			if (tmp->ingress_port_mask & filter->ingress_port_mask &&
 			    ocelot_vcap_is_problematic_mac_etype(tmp))
 				return false;
@@ -916,7 +928,7 @@ int ocelot_vcap_filter_add(struct ocelot *ocelot,
 	for (i = block->count - 1; i > index; i--) {
 		struct ocelot_vcap_filter *tmp;
 
-		tmp = ocelot_vcap_block_find_filter(block, i);
+		tmp = ocelot_vcap_block_find_filter_by_index(block, i);
 		is2_entry_set(ocelot, i, tmp);
 	}
 
@@ -968,7 +980,7 @@ int ocelot_vcap_filter_del(struct ocelot *ocelot,
 	for (i = index; i < block->count; i++) {
 		struct ocelot_vcap_filter *tmp;
 
-		tmp = ocelot_vcap_block_find_filter(block, i);
+		tmp = ocelot_vcap_block_find_filter_by_index(block, i);
 		is2_entry_set(ocelot, i, tmp);
 	}
 
@@ -992,7 +1004,7 @@ 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(block, index);
+	tmp = ocelot_vcap_block_find_filter_by_index(block, index);
 	tmp->stats.pkts = 0;
 	is2_entry_set(ocelot, index, tmp);
 
diff --git a/drivers/net/ethernet/mscc/ocelot_vcap.h b/drivers/net/ethernet/mscc/ocelot_vcap.h
index 50742d13c01a..7db6da6e35b9 100644
--- a/drivers/net/ethernet/mscc/ocelot_vcap.h
+++ b/drivers/net/ethernet/mscc/ocelot_vcap.h
@@ -221,6 +221,8 @@ int ocelot_vcap_filter_del(struct ocelot *ocelot,
 			   struct ocelot_vcap_filter *rule);
 int ocelot_vcap_filter_stats_update(struct ocelot *ocelot,
 				    struct ocelot_vcap_filter *rule);
+struct ocelot_vcap_filter *
+ocelot_vcap_block_find_filter_by_id(struct ocelot_vcap_block *block, int id);
 
 void ocelot_detect_vcap_constants(struct ocelot *ocelot);
 int ocelot_vcap_init(struct ocelot *ocelot);
-- 
2.25.1


  parent reply	other threads:[~2020-09-29 22:29 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-29 22:27 [PATCH net-next 00/13] HW support for VCAP IS1 and ES0 in mscc_ocelot Vladimir Oltean
2020-09-29 22:27 ` [PATCH net-next 01/13] net: mscc: ocelot: introduce a new ocelot_target_{read,write} API Vladimir Oltean
2020-09-29 22:27 ` [PATCH net-next 02/13] net: mscc: ocelot: return error if VCAP filter is not found Vladimir Oltean
2020-09-29 22:27 ` [PATCH net-next 03/13] net: mscc: ocelot: generalize existing code for VCAP Vladimir Oltean
2020-09-29 22:27 ` [PATCH net-next 04/13] net: mscc: ocelot: add definitions for VCAP IS1 keys, actions and target Vladimir Oltean
2020-09-29 22:27 ` [PATCH net-next 05/13] net: mscc: ocelot: add definitions for VCAP ES0 " Vladimir Oltean
2020-09-29 22:27 ` [PATCH net-next 06/13] net: mscc: ocelot: automatically detect VCAP constants Vladimir Oltean
2020-09-29 22:27 ` [PATCH net-next 07/13] net: mscc: ocelot: remove unneeded VCAP parameters for IS2 Vladimir Oltean
2020-09-29 22:27 ` [PATCH net-next 08/13] net: mscc: ocelot: parse flower action before key Vladimir Oltean
2020-09-29 22:27 ` [PATCH net-next 09/13] net: mscc: ocelot: calculate vcap offsets correctly for full and quarter entries Vladimir Oltean
2020-09-29 22:27 ` [PATCH net-next 10/13] net: mscc: ocelot: rename variable 'count' in vcap_data_offset_get() Vladimir Oltean
2020-09-29 22:27 ` [PATCH net-next 11/13] net: mscc: ocelot: rename variable 'cnt' " Vladimir Oltean
2020-09-29 22:27 ` Vladimir Oltean [this message]
2020-09-29 22:27 ` [PATCH net-next 13/13] net: mscc: ocelot: look up the filters in flower_stats() and flower_destroy() Vladimir Oltean
2020-09-30  1:26 ` [PATCH net-next 00/13] HW support for VCAP IS1 and ES0 in mscc_ocelot David Miller

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=20200929222733.770926-13-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=hongbo.wang@nxp.com \
    --cc=horatiu.vultur@microchip.com \
    --cc=joergen.andreasen@microchip.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=vivien.didelot@gmail.com \
    --cc=xiaoliang.yang_1@nxp.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.