linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Xiaoliang Yang <xiaoliang.yang_1@nxp.com>
To: xiaoliang.yang_1@nxp.com, po.liu@nxp.com, claudiu.manoil@nxp.com,
	alexandru.marginean@nxp.com, vladimir.oltean@nxp.com,
	leoyang.li@nxp.com, mingkai.hu@nxp.com, andrew@lunn.ch,
	f.fainelli@gmail.com, vivien.didelot@gmail.com,
	davem@davemloft.net, jiri@resnulli.us, idosch@idosch.org,
	kuba@kernel.org, vinicius.gomes@intel.com,
	nikolay@cumulusnetworks.com, roopa@cumulusnetworks.com,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	horatiu.vultur@microchip.com, alexandre.belloni@bootlin.com,
	allan.nielsen@microchip.com, joergen.andreasen@microchip.com,
	UNGLinuxDriver@microchip.com, linux-devel@linux.nxdi.nxp.com
Subject: [PATCH v2 net-next 07/10] net: mscc: ocelot: multiple actions support
Date: Tue,  2 Jun 2020 13:18:25 +0800	[thread overview]
Message-ID: <20200602051828.5734-8-xiaoliang.yang_1@nxp.com> (raw)
In-Reply-To: <20200602051828.5734-1-xiaoliang.yang_1@nxp.com>

Support multiple actions for each flower rule, multiple actions can only
set on the same VCAP, and all actions can mix with action goto chain.
Action drop, trap, and police on VCAP IS2 could not be mixed.

Signed-off-by: Xiaoliang Yang <xiaoliang.yang_1@nxp.com>
---
 drivers/net/ethernet/mscc/ocelot_ace.c    | 15 +++++++++------
 drivers/net/ethernet/mscc/ocelot_ace.h    |  8 +++++++-
 drivers/net/ethernet/mscc/ocelot_flower.c | 14 +++++++++-----
 3 files changed, 25 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/mscc/ocelot_ace.c b/drivers/net/ethernet/mscc/ocelot_ace.c
index 76d679b8d15e..bf2b7a03c832 100644
--- a/drivers/net/ethernet/mscc/ocelot_ace.c
+++ b/drivers/net/ethernet/mscc/ocelot_ace.c
@@ -651,20 +651,23 @@ static void is1_action_set(struct ocelot *ocelot, struct vcap_data *data,
 	const struct vcap_props *vcap = &ocelot->vcap[VCAP_IS1];
 
 	switch (ace->action) {
+	case OCELOT_ACL_ACTION_PRIORITY:
 	case OCELOT_ACL_ACTION_VLAN_MODIFY:
-		vcap_action_set(vcap, data, VCAP_IS1_ACT_VID_REPLACE_ENA, 1);
+		vcap_action_set(vcap, data, VCAP_IS1_ACT_VID_REPLACE_ENA,
+				ace->vlan_modify.ena);
 		vcap_action_set(vcap, data, VCAP_IS1_ACT_VID_ADD_VAL,
 				ace->vlan_modify.vid);
-		vcap_action_set(vcap, data, VCAP_IS1_ACT_PCP_DEI_ENA, 1);
+		vcap_action_set(vcap, data, VCAP_IS1_ACT_PCP_DEI_ENA,
+				ace->vlan_modify.ena);
 		vcap_action_set(vcap, data, VCAP_IS1_ACT_PCP_VAL,
 				ace->vlan_modify.pcp);
 		vcap_action_set(vcap, data, VCAP_IS1_ACT_DEI_VAL,
 				ace->vlan_modify.dei);
-		break;
-	case OCELOT_ACL_ACTION_PRIORITY:
-		vcap_action_set(vcap, data, VCAP_IS1_ACT_QOS_ENA, 1);
+
+		vcap_action_set(vcap, data, VCAP_IS1_ACT_QOS_ENA,
+				ace->qos_modify.ena);
 		vcap_action_set(vcap, data, VCAP_IS1_ACT_QOS_VAL,
-				ace->qos_val);
+				ace->qos_modify.qos_val);
 		break;
 	default:
 		break;
diff --git a/drivers/net/ethernet/mscc/ocelot_ace.h b/drivers/net/ethernet/mscc/ocelot_ace.h
index 70fe45d747fb..02fa81b3fe92 100644
--- a/drivers/net/ethernet/mscc/ocelot_ace.h
+++ b/drivers/net/ethernet/mscc/ocelot_ace.h
@@ -97,6 +97,12 @@ struct ocelot_ace_action_vlan {
 	u16 vid;
 	u8 pcp;
 	u8 dei;
+	u8 ena;
+};
+
+struct ocelot_ace_action_qos {
+	u8 qos_val;
+	u8 ena;
 };
 
 struct ocelot_ace_frame_etype {
@@ -212,6 +218,7 @@ struct ocelot_ace_rule {
 	enum ocelot_vcap_bit dmac_bc;
 	struct ocelot_ace_vlan vlan;
 	struct ocelot_ace_action_vlan vlan_modify;
+	struct ocelot_ace_action_qos qos_modify;
 
 	enum ocelot_ace_type type;
 	union {
@@ -225,7 +232,6 @@ struct ocelot_ace_rule {
 	} frame;
 	struct ocelot_policer pol;
 	u32 pol_ix;
-	u8 qos_val;
 };
 
 int ocelot_ace_rule_offload_add(struct ocelot *ocelot, int block_id,
diff --git a/drivers/net/ethernet/mscc/ocelot_flower.c b/drivers/net/ethernet/mscc/ocelot_flower.c
index d598e103c796..6ce37f152f12 100644
--- a/drivers/net/ethernet/mscc/ocelot_flower.c
+++ b/drivers/net/ethernet/mscc/ocelot_flower.c
@@ -32,9 +32,6 @@ static int ocelot_flower_parse_action(struct flow_cls_offload *f,
 	s64 burst;
 	u64 rate;
 
-	if (!flow_offload_has_one_action(&f->rule->action))
-		return -EOPNOTSUPP;
-
 	if (!flow_action_basic_hw_stats_check(&f->rule->action,
 					      f->common.extack))
 		return -EOPNOTSUPP;
@@ -42,14 +39,20 @@ static int ocelot_flower_parse_action(struct flow_cls_offload *f,
 	flow_action_for_each(i, a, &f->rule->action) {
 		switch (a->id) {
 		case FLOW_ACTION_DROP:
+			if (i)
+				return -EOPNOTSUPP;
 			ace->action = OCELOT_ACL_ACTION_DROP;
 			allowed_chain = 1;
 			break;
 		case FLOW_ACTION_TRAP:
+			if (i)
+				return -EOPNOTSUPP;
 			ace->action = OCELOT_ACL_ACTION_TRAP;
 			allowed_chain = 1;
 			break;
 		case FLOW_ACTION_POLICE:
+			if (i)
+				return -EOPNOTSUPP;
 			ace->action = OCELOT_ACL_ACTION_POLICE;
 			rate = a->police.rate_bytes_ps;
 			ace->pol.rate = div_u64(rate, 1000) * 8;
@@ -62,18 +65,19 @@ static int ocelot_flower_parse_action(struct flow_cls_offload *f,
 				NL_SET_ERR_MSG_MOD(extack, "HW only support goto next chain\n");
 				return -EOPNOTSUPP;
 			}
-			ace->action = OCELOT_ACL_ACTION_NULL;
 			allowed_chain = f->common.chain_index;
 			break;
 		case FLOW_ACTION_VLAN_MANGLE:
 			ace->action = OCELOT_ACL_ACTION_VLAN_MODIFY;
+			ace->vlan_modify.ena = 1;
 			ace->vlan_modify.vid = a->vlan.vid;
 			ace->vlan_modify.pcp = a->vlan.prio;
 			allowed_chain = 0;
 			break;
 		case FLOW_ACTION_PRIORITY:
 			ace->action = OCELOT_ACL_ACTION_PRIORITY;
-			ace->qos_val = a->priority;
+			ace->qos_modify.ena = 1;
+			ace->qos_modify.qos_val = a->priority;
 			allowed_chain = 0;
 			break;
 		case FLOW_ACTION_VLAN_PUSH:
-- 
2.17.1


  parent reply	other threads:[~2020-06-02  5:24 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-02  5:18 [PATCH v2 net-next 00/10] net: ocelot: VCAP IS1 and ES0 support Xiaoliang Yang
2020-06-02  5:18 ` [PATCH v2 net-next 01/10] net: mscc: ocelot: introduce a new ocelot_target_{read,write} API Xiaoliang Yang
2020-06-02  5:18 ` [PATCH v2 net-next 02/10] net: mscc: ocelot: generalize existing code for VCAP Xiaoliang Yang
2020-06-02  5:18 ` [PATCH v2 net-next 03/10] net: mscc: ocelot: allocated rules to different hardware VCAP TCAMs by chain index Xiaoliang Yang
2020-06-02  8:36   ` Allan W. Nielsen
2020-06-03 10:04     ` Vladimir Oltean
2020-06-08 13:56       ` Allan W. Nielsen
2020-06-09 12:55         ` Vladimir Oltean
2020-06-10 18:18           ` Allan W. Nielsen
2020-07-16  6:49             ` [EXT] " Xiaoliang Yang
2020-07-16  8:50               ` Joergen Andreasen
2020-07-16 10:37                 ` Xiaoliang Yang
2020-07-16 14:45                   ` Vladimir Oltean
2020-07-17  7:34                     ` Joergen Andreasen
2020-07-17  9:08                       ` Vladimir Oltean
2020-07-17 19:10                         ` Allan W. Nielsen
2020-07-20 11:04                           ` Xiaoliang Yang
2020-06-02  5:18 ` [PATCH v2 net-next 04/10] net: mscc: ocelot: change vcap to be compatible with full and quad entry Xiaoliang Yang
2020-06-02  5:18 ` [PATCH v2 net-next 05/10] net: mscc: ocelot: VCAP IS1 support Xiaoliang Yang
2020-06-02 16:16   ` Jakub Kicinski
2020-06-02  5:18 ` [PATCH v2 net-next 06/10] net: mscc: ocelot: VCAP ES0 support Xiaoliang Yang
2020-06-02 16:17   ` Jakub Kicinski
2020-06-02  5:18 ` Xiaoliang Yang [this message]
2020-06-02  5:18 ` [PATCH v2 net-next 08/10] net: ocelot: return error if rule is not found Xiaoliang Yang
2020-06-02  5:18 ` [PATCH v2 net-next 09/10] net: dsa: felix: correct VCAP IS2 keys offset Xiaoliang Yang
2020-06-02  5:18 ` [PATCH v2 net-next 10/10] net: dsa: tag_ocelot: use VLAN information from tagging header when available Xiaoliang Yang
2020-06-02  8:03 ` [PATCH v2 net-next 00/10] net: ocelot: VCAP IS1 and ES0 support Vladimir Oltean
2020-06-02  8:49   ` [EXT] " Xiaoliang Yang
2020-06-09 11:35     ` 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=20200602051828.5734-8-xiaoliang.yang_1@nxp.com \
    --to=xiaoliang.yang_1@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=idosch@idosch.org \
    --cc=jiri@resnulli.us \
    --cc=joergen.andreasen@microchip.com \
    --cc=kuba@kernel.org \
    --cc=leoyang.li@nxp.com \
    --cc=linux-devel@linux.nxdi.nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingkai.hu@nxp.com \
    --cc=netdev@vger.kernel.org \
    --cc=nikolay@cumulusnetworks.com \
    --cc=po.liu@nxp.com \
    --cc=roopa@cumulusnetworks.com \
    --cc=vinicius.gomes@intel.com \
    --cc=vivien.didelot@gmail.com \
    --cc=vladimir.oltean@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).