netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vladimir Oltean <olteanv@gmail.com>
To: davem@davemloft.net, netdev@vger.kernel.org
Cc: UNGLinuxDriver@microchip.com, andrew@lunn.ch,
	f.fainelli@gmail.com, vivien.didelot@gmail.com,
	claudiu.manoil@nxp.com, alexandru.marginean@nxp.com,
	xiaoliang.yang_1@nxp.com
Subject: [PATCH net-next 12/12] net: mscc: ocelot: unexpose ocelot_vcap_policer_{add,del}
Date: Sat, 20 Jun 2020 18:43:47 +0300	[thread overview]
Message-ID: <20200620154347.3587114-13-olteanv@gmail.com> (raw)
In-Reply-To: <20200620154347.3587114-1-olteanv@gmail.com>

From: Vladimir Oltean <vladimir.oltean@nxp.com>

Remove the function prototypes from ocelot_police.h and make these
functions static. We need to move them above their callers. Note that
moving the implementations to ocelot_police.c is not trivially possible
due to dependency on is2_entry_set() which is static to ocelot_vcap.c.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 drivers/net/ethernet/mscc/ocelot_police.h |  5 --
 drivers/net/ethernet/mscc/ocelot_vcap.c   | 96 +++++++++++------------
 2 files changed, 45 insertions(+), 56 deletions(-)

diff --git a/drivers/net/ethernet/mscc/ocelot_police.h b/drivers/net/ethernet/mscc/ocelot_police.h
index be6f2286a5cd..7adb05f71999 100644
--- a/drivers/net/ethernet/mscc/ocelot_police.h
+++ b/drivers/net/ethernet/mscc/ocelot_police.h
@@ -33,9 +33,4 @@ struct qos_policer_conf {
 int qos_policer_conf_set(struct ocelot *ocelot, int port, u32 pol_ix,
 			 struct qos_policer_conf *conf);
 
-int ocelot_vcap_policer_add(struct ocelot *ocelot, u32 pol_ix,
-			    struct ocelot_policer *pol);
-
-int ocelot_vcap_policer_del(struct ocelot *ocelot, u32 pol_ix);
-
 #endif /* _MSCC_OCELOT_POLICE_H_ */
diff --git a/drivers/net/ethernet/mscc/ocelot_vcap.c b/drivers/net/ethernet/mscc/ocelot_vcap.c
index 8597034fd3b7..3ef620faf995 100644
--- a/drivers/net/ethernet/mscc/ocelot_vcap.c
+++ b/drivers/net/ethernet/mscc/ocelot_vcap.c
@@ -651,6 +651,49 @@ static void is2_entry_get(struct ocelot *ocelot, struct ocelot_vcap_filter *filt
 	filter->stats.pkts = cnt;
 }
 
+static int ocelot_vcap_policer_add(struct ocelot *ocelot, u32 pol_ix,
+				   struct ocelot_policer *pol)
+{
+	struct qos_policer_conf pp = { 0 };
+
+	if (!pol)
+		return -EINVAL;
+
+	pp.mode = MSCC_QOS_RATE_MODE_DATA;
+	pp.pir = pol->rate;
+	pp.pbs = pol->burst;
+
+	return qos_policer_conf_set(ocelot, 0, pol_ix, &pp);
+}
+
+static void ocelot_vcap_policer_del(struct ocelot *ocelot,
+				    struct ocelot_vcap_block *block,
+				    u32 pol_ix)
+{
+	struct ocelot_vcap_filter *filter;
+	struct qos_policer_conf pp = {0};
+	int index = -1;
+
+	if (pol_ix < block->pol_lpr)
+		return;
+
+	list_for_each_entry(filter, &block->rules, list) {
+		index++;
+		if (filter->action == OCELOT_VCAP_ACTION_POLICE &&
+		    filter->pol_ix < pol_ix) {
+			filter->pol_ix += 1;
+			ocelot_vcap_policer_add(ocelot, filter->pol_ix,
+						&filter->pol);
+			is2_entry_set(ocelot, index, filter);
+		}
+	}
+
+	pp.mode = MSCC_QOS_RATE_MODE_DISABLED;
+	qos_policer_conf_set(ocelot, 0, pol_ix, &pp);
+
+	block->pol_lpr++;
+}
+
 static void ocelot_vcap_filter_add_to_block(struct ocelot *ocelot,
 					    struct ocelot_vcap_block *block,
 					    struct ocelot_vcap_filter *filter)
@@ -848,55 +891,6 @@ int ocelot_vcap_filter_add(struct ocelot *ocelot,
 	return 0;
 }
 
-int ocelot_vcap_policer_add(struct ocelot *ocelot, u32 pol_ix,
-			    struct ocelot_policer *pol)
-{
-	struct qos_policer_conf pp = { 0 };
-
-	if (!pol)
-		return -EINVAL;
-
-	pp.mode = MSCC_QOS_RATE_MODE_DATA;
-	pp.pir = pol->rate;
-	pp.pbs = pol->burst;
-
-	return qos_policer_conf_set(ocelot, 0, pol_ix, &pp);
-}
-
-int ocelot_vcap_policer_del(struct ocelot *ocelot, u32 pol_ix)
-{
-	struct qos_policer_conf pp = { 0 };
-
-	pp.mode = MSCC_QOS_RATE_MODE_DISABLED;
-
-	return qos_policer_conf_set(ocelot, 0, pol_ix, &pp);
-}
-
-static void ocelot_vcap_police_del(struct ocelot *ocelot,
-				   struct ocelot_vcap_block *block,
-				   u32 ix)
-{
-	struct ocelot_vcap_filter *filter;
-	int index = -1;
-
-	if (ix < block->pol_lpr)
-		return;
-
-	list_for_each_entry(filter, &block->rules, list) {
-		index++;
-		if (filter->action == OCELOT_VCAP_ACTION_POLICE &&
-		    filter->pol_ix < ix) {
-			filter->pol_ix += 1;
-			ocelot_vcap_policer_add(ocelot, filter->pol_ix,
-						&filter->pol);
-			is2_entry_set(ocelot, index, filter);
-		}
-	}
-
-	ocelot_vcap_policer_del(ocelot, block->pol_lpr);
-	block->pol_lpr++;
-}
-
 static void ocelot_vcap_block_remove_filter(struct ocelot *ocelot,
 					    struct ocelot_vcap_block *block,
 					    struct ocelot_vcap_filter *filter)
@@ -908,8 +902,8 @@ static void ocelot_vcap_block_remove_filter(struct ocelot *ocelot,
 		tmp = list_entry(pos, struct ocelot_vcap_filter, list);
 		if (tmp->id == filter->id) {
 			if (tmp->action == OCELOT_VCAP_ACTION_POLICE)
-				ocelot_vcap_police_del(ocelot, block,
-						       tmp->pol_ix);
+				ocelot_vcap_policer_del(ocelot, block,
+							tmp->pol_ix);
 
 			list_del(pos);
 			kfree(tmp);
-- 
2.25.1


  parent reply	other threads:[~2020-06-20 15:44 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-20 15:43 [PATCH net-next 00/12] Ocelot/Felix driver cleanup Vladimir Oltean
2020-06-20 15:43 ` [PATCH net-next 01/12] net: dsa: felix: make vcap is2 keys and actions static Vladimir Oltean
2020-06-20 15:43 ` [PATCH net-next 02/12] net: mscc: ocelot: use plain int when interacting with TCAM tables Vladimir Oltean
2020-06-20 15:43 ` [PATCH net-next 03/12] net: mscc: ocelot: access EtherType using __be16 Vladimir Oltean
2020-06-20 15:43 ` [PATCH net-next 04/12] net: mscc: ocelot: rename ocelot_board.c to ocelot_vsc7514.c Vladimir Oltean
2020-06-20 15:43 ` [PATCH net-next 05/12] net: mscc: ocelot: rename module to mscc_ocelot Vladimir Oltean
2020-06-20 15:43 ` [PATCH net-next 06/12] net: mscc: ocelot: convert MSCC_OCELOT_SWITCH into a library Vladimir Oltean
2020-06-20 15:43 ` [PATCH net-next 07/12] net: mscc: ocelot: rename MSCC_OCELOT_SWITCH_OCELOT to MSCC_OCELOT_SWITCH Vladimir Oltean
2020-06-20 15:43 ` [PATCH net-next 08/12] net: mscc: ocelot: move ocelot_regs.c into ocelot_vsc7514.c Vladimir Oltean
2020-06-20 15:43 ` [PATCH net-next 09/12] net: mscc: ocelot: move net_device related functions to ocelot_net.c Vladimir Oltean
2020-06-20 15:43 ` [PATCH net-next 10/12] net: mscc: ocelot: rename ocelot_ace.{c,h} to ocelot_vcap.{c,h} Vladimir Oltean
2020-06-20 15:43 ` [PATCH net-next 11/12] net: mscc: ocelot: generalize the "ACE/ACL" names Vladimir Oltean
2020-06-20 15:43 ` Vladimir Oltean [this message]
2020-06-21  0:25 ` [PATCH net-next 00/12] Ocelot/Felix driver cleanup 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=20200620154347.3587114-13-olteanv@gmail.com \
    --to=olteanv@gmail.com \
    --cc=UNGLinuxDriver@microchip.com \
    --cc=alexandru.marginean@nxp.com \
    --cc=andrew@lunn.ch \
    --cc=claudiu.manoil@nxp.com \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --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 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).