netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch net-next 0/6] introduce trap control action to tc and offload it
@ 2017-06-05 14:38 Jiri Pirko
  2017-06-05 14:38 ` [patch net-next 1/6] net: sched: introduce a TRAP control action Jiri Pirko
                   ` (7 more replies)
  0 siblings, 8 replies; 17+ messages in thread
From: Jiri Pirko @ 2017-06-05 14:38 UTC (permalink / raw)
  To: netdev
  Cc: davem, jhs, xiyou.wangcong, edumazet, alexander.h.duyck, stephen,
	daniel, mlxsw

From: Jiri Pirko <jiri@mellanox.com>

This patchset introduces a control action dedicated to indicate
to trap the matched packet to CPU. This is specific action for
HW offloads. Also, the patchset offloads the action to mlxsw driver.

Example usage:
$ tc filter add dev enp3s0np19 parent ffff: protocol ip prio 20 flower skip_sw dst_ip 192.168.10.1 action trap

Jiri Pirko (6):
  net: sched: introduce a TRAP control action
  net: sched: introduce helper to identify gact trap action
  mlxsw: pci: Fix size of trap_id field in CQE
  mlxsw: spectrum: Introduce ACL trap
  acl: Introduce ACL trap action
  spectrum_flower: Implement gact trap TC action offload

 .../mellanox/mlxsw/core_acl_flex_actions.c         | 40 ++++++++++++++++++++--
 .../mellanox/mlxsw/core_acl_flex_actions.h         |  1 +
 drivers/net/ethernet/mellanox/mlxsw/pci_hw.h       |  2 +-
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c     |  4 ++-
 drivers/net/ethernet/mellanox/mlxsw/spectrum.h     |  1 +
 drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c |  5 +++
 .../net/ethernet/mellanox/mlxsw/spectrum_flower.c  |  4 +++
 drivers/net/ethernet/mellanox/mlxsw/trap.h         |  1 +
 include/net/tc_act/tc_gact.h                       | 15 ++++++--
 include/uapi/linux/pkt_cls.h                       |  5 +++
 net/core/dev.c                                     |  2 ++
 net/sched/cls_bpf.c                                |  1 +
 net/sched/sch_atm.c                                |  1 +
 net/sched/sch_cbq.c                                |  1 +
 net/sched/sch_drr.c                                |  1 +
 net/sched/sch_dsmark.c                             |  1 +
 net/sched/sch_fq_codel.c                           |  1 +
 net/sched/sch_hfsc.c                               |  1 +
 net/sched/sch_htb.c                                |  1 +
 net/sched/sch_multiq.c                             |  1 +
 net/sched/sch_prio.c                               |  1 +
 net/sched/sch_qfq.c                                |  1 +
 net/sched/sch_sfb.c                                |  1 +
 net/sched/sch_sfq.c                                |  1 +
 24 files changed, 87 insertions(+), 6 deletions(-)

-- 
2.9.3

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [patch net-next 1/6] net: sched: introduce a TRAP control action
  2017-06-05 14:38 [patch net-next 0/6] introduce trap control action to tc and offload it Jiri Pirko
@ 2017-06-05 14:38 ` Jiri Pirko
  2017-06-05 19:56   ` Andrew Lunn
  2017-06-05 14:38 ` [patch net-next 2/6] net: sched: introduce helper to identify gact trap action Jiri Pirko
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 17+ messages in thread
From: Jiri Pirko @ 2017-06-05 14:38 UTC (permalink / raw)
  To: netdev
  Cc: davem, jhs, xiyou.wangcong, edumazet, alexander.h.duyck, stephen,
	daniel, mlxsw

From: Jiri Pirko <jiri@mellanox.com>

There is need to instruct the HW offloaded path to push certain matched
packets to cpu/kernel for further analysis. So this patch introduces a
new TRAP control action to TC.

For kernel datapath, this action does not make much sense. So with the
same logic as in HW, new TRAP behaves similar to STOLEN. The skb is just
dropped in the datapath (and virtually ejected to an upper level, which
does not exist in case of kernel).

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Reviewed-by: Yotam Gigi <yotamg@mellanox.com>
---
 include/uapi/linux/pkt_cls.h | 5 +++++
 net/core/dev.c               | 2 ++
 net/sched/cls_bpf.c          | 1 +
 net/sched/sch_atm.c          | 1 +
 net/sched/sch_cbq.c          | 1 +
 net/sched/sch_drr.c          | 1 +
 net/sched/sch_dsmark.c       | 1 +
 net/sched/sch_fq_codel.c     | 1 +
 net/sched/sch_hfsc.c         | 1 +
 net/sched/sch_htb.c          | 1 +
 net/sched/sch_multiq.c       | 1 +
 net/sched/sch_prio.c         | 1 +
 net/sched/sch_qfq.c          | 1 +
 net/sched/sch_sfb.c          | 1 +
 net/sched/sch_sfq.c          | 1 +
 15 files changed, 20 insertions(+)

diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h
index edf43dd..5d6f711 100644
--- a/include/uapi/linux/pkt_cls.h
+++ b/include/uapi/linux/pkt_cls.h
@@ -37,6 +37,11 @@ enum {
 #define TC_ACT_QUEUED		5
 #define TC_ACT_REPEAT		6
 #define TC_ACT_REDIRECT		7
+#define TC_ACT_TRAP		8 /* For hw path, this means "trap to cpu",
+				   * for sw path, this is equivalent of
+				   * TC_ACT_STOLEN - drop the skb and act
+				   * like everything is allright.
+				   */
 
 /* There is a special kind of actions called "extended actions",
  * which need a value parameter. These have a local opcode located in
diff --git a/net/core/dev.c b/net/core/dev.c
index 06e0a74..8f72f4a 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3269,6 +3269,7 @@ sch_handle_egress(struct sk_buff *skb, int *ret, struct net_device *dev)
 		return NULL;
 	case TC_ACT_STOLEN:
 	case TC_ACT_QUEUED:
+	case TC_ACT_TRAP:
 		*ret = NET_XMIT_SUCCESS;
 		consume_skb(skb);
 		return NULL;
@@ -4038,6 +4039,7 @@ sch_handle_ingress(struct sk_buff *skb, struct packet_type **pt_prev, int *ret,
 		return NULL;
 	case TC_ACT_STOLEN:
 	case TC_ACT_QUEUED:
+	case TC_ACT_TRAP:
 		consume_skb(skb);
 		return NULL;
 	case TC_ACT_REDIRECT:
diff --git a/net/sched/cls_bpf.c b/net/sched/cls_bpf.c
index 5ebeae9..a9c56ad 100644
--- a/net/sched/cls_bpf.c
+++ b/net/sched/cls_bpf.c
@@ -70,6 +70,7 @@ static int cls_bpf_exec_opcode(int code)
 	case TC_ACT_OK:
 	case TC_ACT_SHOT:
 	case TC_ACT_STOLEN:
+	case TC_ACT_TRAP:
 	case TC_ACT_REDIRECT:
 	case TC_ACT_UNSPEC:
 		return code;
diff --git a/net/sched/sch_atm.c b/net/sched/sch_atm.c
index f435546..de16259 100644
--- a/net/sched/sch_atm.c
+++ b/net/sched/sch_atm.c
@@ -406,6 +406,7 @@ static int atm_tc_enqueue(struct sk_buff *skb, struct Qdisc *sch,
 		switch (result) {
 		case TC_ACT_QUEUED:
 		case TC_ACT_STOLEN:
+		case TC_ACT_TRAP:
 			__qdisc_drop(skb, to_free);
 			return NET_XMIT_SUCCESS | __NET_XMIT_STOLEN;
 		case TC_ACT_SHOT:
diff --git a/net/sched/sch_cbq.c b/net/sched/sch_cbq.c
index 8dd6d0a..481036f 100644
--- a/net/sched/sch_cbq.c
+++ b/net/sched/sch_cbq.c
@@ -254,6 +254,7 @@ cbq_classify(struct sk_buff *skb, struct Qdisc *sch, int *qerr)
 		switch (result) {
 		case TC_ACT_QUEUED:
 		case TC_ACT_STOLEN:
+		case TC_ACT_TRAP:
 			*qerr = NET_XMIT_SUCCESS | __NET_XMIT_STOLEN;
 		case TC_ACT_SHOT:
 			return NULL;
diff --git a/net/sched/sch_drr.c b/net/sched/sch_drr.c
index 5db2a28..a413dc1 100644
--- a/net/sched/sch_drr.c
+++ b/net/sched/sch_drr.c
@@ -339,6 +339,7 @@ static struct drr_class *drr_classify(struct sk_buff *skb, struct Qdisc *sch,
 		switch (result) {
 		case TC_ACT_QUEUED:
 		case TC_ACT_STOLEN:
+		case TC_ACT_TRAP:
 			*qerr = NET_XMIT_SUCCESS | __NET_XMIT_STOLEN;
 		case TC_ACT_SHOT:
 			return NULL;
diff --git a/net/sched/sch_dsmark.c b/net/sched/sch_dsmark.c
index 7ccdd82..6d94fcc 100644
--- a/net/sched/sch_dsmark.c
+++ b/net/sched/sch_dsmark.c
@@ -243,6 +243,7 @@ static int dsmark_enqueue(struct sk_buff *skb, struct Qdisc *sch,
 #ifdef CONFIG_NET_CLS_ACT
 		case TC_ACT_QUEUED:
 		case TC_ACT_STOLEN:
+		case TC_ACT_TRAP:
 			__qdisc_drop(skb, to_free);
 			return NET_XMIT_SUCCESS | __NET_XMIT_STOLEN;
 
diff --git a/net/sched/sch_fq_codel.c b/net/sched/sch_fq_codel.c
index f201e73..337f2d6 100644
--- a/net/sched/sch_fq_codel.c
+++ b/net/sched/sch_fq_codel.c
@@ -103,6 +103,7 @@ static unsigned int fq_codel_classify(struct sk_buff *skb, struct Qdisc *sch,
 		switch (result) {
 		case TC_ACT_STOLEN:
 		case TC_ACT_QUEUED:
+		case TC_ACT_TRAP:
 			*qerr = NET_XMIT_SUCCESS | __NET_XMIT_STOLEN;
 		case TC_ACT_SHOT:
 			return 0;
diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c
index a324f84..b52f746 100644
--- a/net/sched/sch_hfsc.c
+++ b/net/sched/sch_hfsc.c
@@ -1155,6 +1155,7 @@ hfsc_classify(struct sk_buff *skb, struct Qdisc *sch, int *qerr)
 		switch (result) {
 		case TC_ACT_QUEUED:
 		case TC_ACT_STOLEN:
+		case TC_ACT_TRAP:
 			*qerr = NET_XMIT_SUCCESS | __NET_XMIT_STOLEN;
 		case TC_ACT_SHOT:
 			return NULL;
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index 195bbca9..203286a 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -238,6 +238,7 @@ static struct htb_class *htb_classify(struct sk_buff *skb, struct Qdisc *sch,
 		switch (result) {
 		case TC_ACT_QUEUED:
 		case TC_ACT_STOLEN:
+		case TC_ACT_TRAP:
 			*qerr = NET_XMIT_SUCCESS | __NET_XMIT_STOLEN;
 		case TC_ACT_SHOT:
 			return NULL;
diff --git a/net/sched/sch_multiq.c b/net/sched/sch_multiq.c
index 6047674..f143b7b 100644
--- a/net/sched/sch_multiq.c
+++ b/net/sched/sch_multiq.c
@@ -52,6 +52,7 @@ multiq_classify(struct sk_buff *skb, struct Qdisc *sch, int *qerr)
 	switch (err) {
 	case TC_ACT_STOLEN:
 	case TC_ACT_QUEUED:
+	case TC_ACT_TRAP:
 		*qerr = NET_XMIT_SUCCESS | __NET_XMIT_STOLEN;
 	case TC_ACT_SHOT:
 		return NULL;
diff --git a/net/sched/sch_prio.c b/net/sched/sch_prio.c
index a240468..e3e364c 100644
--- a/net/sched/sch_prio.c
+++ b/net/sched/sch_prio.c
@@ -48,6 +48,7 @@ prio_classify(struct sk_buff *skb, struct Qdisc *sch, int *qerr)
 		switch (err) {
 		case TC_ACT_STOLEN:
 		case TC_ACT_QUEUED:
+		case TC_ACT_TRAP:
 			*qerr = NET_XMIT_SUCCESS | __NET_XMIT_STOLEN;
 		case TC_ACT_SHOT:
 			return NULL;
diff --git a/net/sched/sch_qfq.c b/net/sched/sch_qfq.c
index 076ad03..0e16dfd 100644
--- a/net/sched/sch_qfq.c
+++ b/net/sched/sch_qfq.c
@@ -726,6 +726,7 @@ static struct qfq_class *qfq_classify(struct sk_buff *skb, struct Qdisc *sch,
 		switch (result) {
 		case TC_ACT_QUEUED:
 		case TC_ACT_STOLEN:
+		case TC_ACT_TRAP:
 			*qerr = NET_XMIT_SUCCESS | __NET_XMIT_STOLEN;
 		case TC_ACT_SHOT:
 			return NULL;
diff --git a/net/sched/sch_sfb.c b/net/sched/sch_sfb.c
index 9756b1c..11fb6ec 100644
--- a/net/sched/sch_sfb.c
+++ b/net/sched/sch_sfb.c
@@ -266,6 +266,7 @@ static bool sfb_classify(struct sk_buff *skb, struct tcf_proto *fl,
 		switch (result) {
 		case TC_ACT_STOLEN:
 		case TC_ACT_QUEUED:
+		case TC_ACT_TRAP:
 			*qerr = NET_XMIT_SUCCESS | __NET_XMIT_STOLEN;
 		case TC_ACT_SHOT:
 			return false;
diff --git a/net/sched/sch_sfq.c b/net/sched/sch_sfq.c
index 66dfd15..f80ea2c 100644
--- a/net/sched/sch_sfq.c
+++ b/net/sched/sch_sfq.c
@@ -187,6 +187,7 @@ static unsigned int sfq_classify(struct sk_buff *skb, struct Qdisc *sch,
 		switch (result) {
 		case TC_ACT_STOLEN:
 		case TC_ACT_QUEUED:
+		case TC_ACT_TRAP:
 			*qerr = NET_XMIT_SUCCESS | __NET_XMIT_STOLEN;
 		case TC_ACT_SHOT:
 			return 0;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [patch net-next 2/6] net: sched: introduce helper to identify gact trap action
  2017-06-05 14:38 [patch net-next 0/6] introduce trap control action to tc and offload it Jiri Pirko
  2017-06-05 14:38 ` [patch net-next 1/6] net: sched: introduce a TRAP control action Jiri Pirko
@ 2017-06-05 14:38 ` Jiri Pirko
  2017-06-05 14:38 ` [patch net-next 3/6] mlxsw: pci: Fix size of trap_id field in CQE Jiri Pirko
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 17+ messages in thread
From: Jiri Pirko @ 2017-06-05 14:38 UTC (permalink / raw)
  To: netdev
  Cc: davem, jhs, xiyou.wangcong, edumazet, alexander.h.duyck, stephen,
	daniel, mlxsw

From: Jiri Pirko <jiri@mellanox.com>

Introduce a helper called is_tcf_gact_trap which could be used to
tell if the action is gact trap or not.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Reviewed-by: Yotam Gigi <yotamg@mellanox.com>
---
 include/net/tc_act/tc_gact.h | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/include/net/tc_act/tc_gact.h b/include/net/tc_act/tc_gact.h
index b6f1739..d576374 100644
--- a/include/net/tc_act/tc_gact.h
+++ b/include/net/tc_act/tc_gact.h
@@ -15,7 +15,7 @@ struct tcf_gact {
 };
 #define to_gact(a) ((struct tcf_gact *)a)
 
-static inline bool is_tcf_gact_shot(const struct tc_action *a)
+static inline bool __is_tcf_gact_act(const struct tc_action *a, int act)
 {
 #ifdef CONFIG_NET_CLS_ACT
 	struct tcf_gact *gact;
@@ -24,10 +24,21 @@ static inline bool is_tcf_gact_shot(const struct tc_action *a)
 		return false;
 
 	gact = to_gact(a);
-	if (gact->tcf_action == TC_ACT_SHOT)
+	if (gact->tcf_action == act)
 		return true;
 
 #endif
 	return false;
 }
+
+static inline bool is_tcf_gact_shot(const struct tc_action *a)
+{
+	return __is_tcf_gact_act(a, TC_ACT_SHOT);
+}
+
+static inline bool is_tcf_gact_trap(const struct tc_action *a)
+{
+	return __is_tcf_gact_act(a, TC_ACT_TRAP);
+}
+
 #endif /* __NET_TC_GACT_H */
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [patch net-next 3/6] mlxsw: pci: Fix size of trap_id field in CQE
  2017-06-05 14:38 [patch net-next 0/6] introduce trap control action to tc and offload it Jiri Pirko
  2017-06-05 14:38 ` [patch net-next 1/6] net: sched: introduce a TRAP control action Jiri Pirko
  2017-06-05 14:38 ` [patch net-next 2/6] net: sched: introduce helper to identify gact trap action Jiri Pirko
@ 2017-06-05 14:38 ` Jiri Pirko
  2017-06-05 14:38 ` [patch net-next 4/6] mlxsw: spectrum: Introduce ACL trap Jiri Pirko
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 17+ messages in thread
From: Jiri Pirko @ 2017-06-05 14:38 UTC (permalink / raw)
  To: netdev
  Cc: davem, jhs, xiyou.wangcong, edumazet, alexander.h.duyck, stephen,
	daniel, mlxsw

From: Jiri Pirko <jiri@mellanox.com>

The "trap_id" is 9bits long. So far, this was not a problem since we
used only traps with ids that fit into 8bits. But the ACL traps that are
going to be introduced use the 9th bit.

Fixes: eda6500a987a ("mlxsw: Add PCI bus implementation")
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Reviewed-by: Yotam Gigi <yotamg@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlxsw/pci_hw.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/pci_hw.h b/drivers/net/ethernet/mellanox/mlxsw/pci_hw.h
index 0af3338..a644120 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/pci_hw.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/pci_hw.h
@@ -155,7 +155,7 @@ MLXSW_ITEM32(pci, cqe, byte_count, 0x04, 0, 14);
 /* pci_cqe_trap_id
  * Trap ID that captured the packet.
  */
-MLXSW_ITEM32(pci, cqe, trap_id, 0x08, 0, 8);
+MLXSW_ITEM32(pci, cqe, trap_id, 0x08, 0, 9);
 
 /* pci_cqe_crc
  * Length include CRC. Indicates the length field includes
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [patch net-next 4/6] mlxsw: spectrum: Introduce ACL trap
  2017-06-05 14:38 [patch net-next 0/6] introduce trap control action to tc and offload it Jiri Pirko
                   ` (2 preceding siblings ...)
  2017-06-05 14:38 ` [patch net-next 3/6] mlxsw: pci: Fix size of trap_id field in CQE Jiri Pirko
@ 2017-06-05 14:38 ` Jiri Pirko
  2017-06-05 14:38 ` [patch net-next 5/6] acl: Introduce ACL trap action Jiri Pirko
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 17+ messages in thread
From: Jiri Pirko @ 2017-06-05 14:38 UTC (permalink / raw)
  To: netdev
  Cc: davem, jhs, xiyou.wangcong, edumazet, alexander.h.duyck, stephen,
	daniel, mlxsw

From: Jiri Pirko <jiri@mellanox.com>

Introduce an ACL trap and put it into ip2me trap group.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Reviewed-by: Yotam Gigi <yotamg@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 4 +++-
 drivers/net/ethernet/mellanox/mlxsw/trap.h     | 1 +
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index 84b6f36..f60e2ba 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -3261,7 +3261,9 @@ static const struct mlxsw_listener mlxsw_sp_listener[] = {
 	MLXSW_SP_RXL_NO_MARK(BGP_IPV4, TRAP_TO_CPU, BGP_IPV4, false),
 	/* PKT Sample trap */
 	MLXSW_RXL(mlxsw_sp_rx_listener_sample_func, PKT_SAMPLE, MIRROR_TO_CPU,
-		  false, SP_IP2ME, DISCARD)
+		  false, SP_IP2ME, DISCARD),
+	/* ACL trap */
+	MLXSW_SP_RXL_NO_MARK(ACL0, TRAP_TO_CPU, IP2ME, false),
 };
 
 static int mlxsw_sp_cpu_policers_set(struct mlxsw_core *mlxsw_core)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/trap.h b/drivers/net/ethernet/mellanox/mlxsw/trap.h
index e008fdb..12b5ed5 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/trap.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/trap.h
@@ -66,6 +66,7 @@ enum {
 	MLXSW_TRAP_ID_RTR_INGRESS0 = 0x70,
 	MLXSW_TRAP_ID_BGP_IPV4 = 0x88,
 	MLXSW_TRAP_ID_HOST_MISS_IPV4 = 0x90,
+	MLXSW_TRAP_ID_ACL0 = 0x1C0,
 
 	MLXSW_TRAP_ID_MAX = 0x1FF
 };
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [patch net-next 5/6] acl: Introduce ACL trap action
  2017-06-05 14:38 [patch net-next 0/6] introduce trap control action to tc and offload it Jiri Pirko
                   ` (3 preceding siblings ...)
  2017-06-05 14:38 ` [patch net-next 4/6] mlxsw: spectrum: Introduce ACL trap Jiri Pirko
@ 2017-06-05 14:38 ` Jiri Pirko
  2017-06-05 14:38 ` [patch net-next 6/6] spectrum_flower: Implement gact trap TC action offload Jiri Pirko
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 17+ messages in thread
From: Jiri Pirko @ 2017-06-05 14:38 UTC (permalink / raw)
  To: netdev
  Cc: davem, jhs, xiyou.wangcong, edumazet, alexander.h.duyck, stephen,
	daniel, mlxsw

From: Jiri Pirko <jiri@mellanox.com>

Use trap/discard flex action to implement trap.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Reviewed-by: Yotam Gigi <yotamg@mellanox.com>
---
 .../mellanox/mlxsw/core_acl_flex_actions.c         | 40 ++++++++++++++++++++--
 .../mellanox/mlxsw/core_acl_flex_actions.h         |  1 +
 drivers/net/ethernet/mellanox/mlxsw/spectrum.h     |  1 +
 drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c |  5 +++
 4 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c
index 46304ff..5ae1101 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.c
@@ -40,6 +40,7 @@
 #include <linux/list.h>
 
 #include "item.h"
+#include "trap.h"
 #include "core_acl_flex_actions.h"
 
 enum mlxsw_afa_set_type {
@@ -662,6 +663,16 @@ EXPORT_SYMBOL(mlxsw_afa_block_append_vlan_modify);
 #define MLXSW_AFA_TRAPDISC_CODE 0x03
 #define MLXSW_AFA_TRAPDISC_SIZE 1
 
+enum mlxsw_afa_trapdisc_trap_action {
+	MLXSW_AFA_TRAPDISC_TRAP_ACTION_NOP = 0,
+	MLXSW_AFA_TRAPDISC_TRAP_ACTION_TRAP = 2,
+};
+
+/* afa_trapdisc_trap_action
+ * Trap Action.
+ */
+MLXSW_ITEM32(afa, trapdisc, trap_action, 0x00, 24, 4);
+
 enum mlxsw_afa_trapdisc_forward_action {
 	MLXSW_AFA_TRAPDISC_FORWARD_ACTION_DISCARD = 3,
 };
@@ -671,11 +682,20 @@ enum mlxsw_afa_trapdisc_forward_action {
  */
 MLXSW_ITEM32(afa, trapdisc, forward_action, 0x00, 0, 4);
 
+/* afa_trapdisc_trap_id
+ * Trap ID to configure.
+ */
+MLXSW_ITEM32(afa, trapdisc, trap_id, 0x04, 0, 9);
+
 static inline void
 mlxsw_afa_trapdisc_pack(char *payload,
-			enum mlxsw_afa_trapdisc_forward_action forward_action)
+			enum mlxsw_afa_trapdisc_trap_action trap_action,
+			enum mlxsw_afa_trapdisc_forward_action forward_action,
+			u16 trap_id)
 {
+	mlxsw_afa_trapdisc_trap_action_set(payload, trap_action);
 	mlxsw_afa_trapdisc_forward_action_set(payload, forward_action);
+	mlxsw_afa_trapdisc_trap_id_set(payload, trap_id);
 }
 
 int mlxsw_afa_block_append_drop(struct mlxsw_afa_block *block)
@@ -686,11 +706,27 @@ int mlxsw_afa_block_append_drop(struct mlxsw_afa_block *block)
 
 	if (!act)
 		return -ENOBUFS;
-	mlxsw_afa_trapdisc_pack(act, MLXSW_AFA_TRAPDISC_FORWARD_ACTION_DISCARD);
+	mlxsw_afa_trapdisc_pack(act, MLXSW_AFA_TRAPDISC_TRAP_ACTION_NOP,
+				MLXSW_AFA_TRAPDISC_FORWARD_ACTION_DISCARD, 0);
 	return 0;
 }
 EXPORT_SYMBOL(mlxsw_afa_block_append_drop);
 
+int mlxsw_afa_block_append_trap(struct mlxsw_afa_block *block)
+{
+	char *act = mlxsw_afa_block_append_action(block,
+						  MLXSW_AFA_TRAPDISC_CODE,
+						  MLXSW_AFA_TRAPDISC_SIZE);
+
+	if (!act)
+		return -ENOBUFS;
+	mlxsw_afa_trapdisc_pack(act, MLXSW_AFA_TRAPDISC_TRAP_ACTION_TRAP,
+				MLXSW_AFA_TRAPDISC_FORWARD_ACTION_DISCARD,
+				MLXSW_TRAP_ID_ACL0);
+	return 0;
+}
+EXPORT_SYMBOL(mlxsw_afa_block_append_trap);
+
 /* Forwarding Action
  * -----------------
  * Forwarding Action can be used to implement Policy Based Switching (PBS)
diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.h b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.h
index bd8b91d..f99c341 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/core_acl_flex_actions.h
@@ -60,6 +60,7 @@ u32 mlxsw_afa_block_first_set_kvdl_index(struct mlxsw_afa_block *block);
 void mlxsw_afa_block_continue(struct mlxsw_afa_block *block);
 void mlxsw_afa_block_jump(struct mlxsw_afa_block *block, u16 group_id);
 int mlxsw_afa_block_append_drop(struct mlxsw_afa_block *block);
+int mlxsw_afa_block_append_trap(struct mlxsw_afa_block *block);
 int mlxsw_afa_block_append_fwd(struct mlxsw_afa_block *block,
 			       u8 local_port, bool in_port);
 int mlxsw_afa_block_append_vlan_modify(struct mlxsw_afa_block *block,
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
index 99760fd..4a7a39a 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
@@ -460,6 +460,7 @@ void mlxsw_sp_acl_rulei_act_continue(struct mlxsw_sp_acl_rule_info *rulei);
 void mlxsw_sp_acl_rulei_act_jump(struct mlxsw_sp_acl_rule_info *rulei,
 				 u16 group_id);
 int mlxsw_sp_acl_rulei_act_drop(struct mlxsw_sp_acl_rule_info *rulei);
+int mlxsw_sp_acl_rulei_act_trap(struct mlxsw_sp_acl_rule_info *rulei);
 int mlxsw_sp_acl_rulei_act_fwd(struct mlxsw_sp *mlxsw_sp,
 			       struct mlxsw_sp_acl_rule_info *rulei,
 			       struct net_device *out_dev);
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c
index 1da889a..01a1501 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_acl.c
@@ -347,6 +347,11 @@ int mlxsw_sp_acl_rulei_act_drop(struct mlxsw_sp_acl_rule_info *rulei)
 	return mlxsw_afa_block_append_drop(rulei->act_block);
 }
 
+int mlxsw_sp_acl_rulei_act_trap(struct mlxsw_sp_acl_rule_info *rulei)
+{
+	return mlxsw_afa_block_append_trap(rulei->act_block);
+}
+
 int mlxsw_sp_acl_rulei_act_fwd(struct mlxsw_sp *mlxsw_sp,
 			       struct mlxsw_sp_acl_rule_info *rulei,
 			       struct net_device *out_dev)
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [patch net-next 6/6] spectrum_flower: Implement gact trap TC action offload
  2017-06-05 14:38 [patch net-next 0/6] introduce trap control action to tc and offload it Jiri Pirko
                   ` (4 preceding siblings ...)
  2017-06-05 14:38 ` [patch net-next 5/6] acl: Introduce ACL trap action Jiri Pirko
@ 2017-06-05 14:38 ` Jiri Pirko
  2017-06-05 14:39 ` [patch iproute2/net-next] tc: add support for TRAP action Jiri Pirko
  2017-06-05 15:46 ` [patch net-next 0/6] introduce trap control action to tc and offload it Andrew Lunn
  7 siblings, 0 replies; 17+ messages in thread
From: Jiri Pirko @ 2017-06-05 14:38 UTC (permalink / raw)
  To: netdev
  Cc: davem, jhs, xiyou.wangcong, edumazet, alexander.h.duyck, stephen,
	daniel, mlxsw

From: Jiri Pirko <jiri@mellanox.com>

Just use the previously prepared infrastructure and offload the gact
trap action to ACL.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Reviewed-by: Yotam Gigi <yotamg@mellanox.com>
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c
index 13af8e3..21bb2bf 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_flower.c
@@ -67,6 +67,10 @@ static int mlxsw_sp_flower_parse_actions(struct mlxsw_sp *mlxsw_sp,
 			err = mlxsw_sp_acl_rulei_act_drop(rulei);
 			if (err)
 				return err;
+		} else if (is_tcf_gact_trap(a)) {
+			err = mlxsw_sp_acl_rulei_act_trap(rulei);
+			if (err)
+				return err;
 		} else if (is_tcf_mirred_egress_redirect(a)) {
 			int ifindex = tcf_mirred_ifindex(a);
 			struct net_device *out_dev;
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [patch iproute2/net-next] tc: add support for TRAP action
  2017-06-05 14:38 [patch net-next 0/6] introduce trap control action to tc and offload it Jiri Pirko
                   ` (5 preceding siblings ...)
  2017-06-05 14:38 ` [patch net-next 6/6] spectrum_flower: Implement gact trap TC action offload Jiri Pirko
@ 2017-06-05 14:39 ` Jiri Pirko
  2017-06-08  6:57   ` Jiri Pirko
                     ` (2 more replies)
  2017-06-05 15:46 ` [patch net-next 0/6] introduce trap control action to tc and offload it Andrew Lunn
  7 siblings, 3 replies; 17+ messages in thread
From: Jiri Pirko @ 2017-06-05 14:39 UTC (permalink / raw)
  To: netdev
  Cc: davem, jhs, xiyou.wangcong, edumazet, alexander.h.duyck, stephen,
	daniel, mlxsw

From: Jiri Pirko <jiri@mellanox.com>

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
---
 include/linux/pkt_cls.h | 5 +++++
 tc/tc_util.c            | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/include/linux/pkt_cls.h b/include/linux/pkt_cls.h
index c6e8cf5..477ed05 100644
--- a/include/linux/pkt_cls.h
+++ b/include/linux/pkt_cls.h
@@ -37,6 +37,11 @@ enum {
 #define TC_ACT_QUEUED		5
 #define TC_ACT_REPEAT		6
 #define TC_ACT_REDIRECT		7
+#define TC_ACT_TRAP		8 /* For hw path, this means "trap to cpu",
+				   * for sw path, this is equivalent of
+				   * TC_ACT_STOLEN - drop the skb and act
+				   * like everything is allright.
+				   */
 
 /* There is a special kind of actions called "extended actions",
  * which need a value parameter. These have a local opcode located in
diff --git a/tc/tc_util.c b/tc/tc_util.c
index 4f7283d..5a0f96a 100644
--- a/tc/tc_util.c
+++ b/tc/tc_util.c
@@ -430,6 +430,8 @@ static const char *action_n2a(int action)
 		return "pipe";
 	case TC_ACT_STOLEN:
 		return "stolen";
+	case TC_ACT_TRAP:
+		return "trap";
 	default:
 		snprintf(buf, 64, "%d", action);
 		buf[63] = '\0';
@@ -462,6 +464,7 @@ static int action_a2n(char *arg, int *result, bool allow_num)
 		{"reclassify", TC_ACT_RECLASSIFY},
 		{"pipe", TC_ACT_PIPE},
 		{"goto", TC_ACT_GOTO_CHAIN},
+		{"trap", TC_ACT_TRAP},
 		{ NULL },
 	}, *iter;
 
-- 
2.9.3

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [patch net-next 0/6] introduce trap control action to tc and offload it
  2017-06-05 14:38 [patch net-next 0/6] introduce trap control action to tc and offload it Jiri Pirko
                   ` (6 preceding siblings ...)
  2017-06-05 14:39 ` [patch iproute2/net-next] tc: add support for TRAP action Jiri Pirko
@ 2017-06-05 15:46 ` Andrew Lunn
  2017-06-05 19:43   ` Jiri Pirko
  7 siblings, 1 reply; 17+ messages in thread
From: Andrew Lunn @ 2017-06-05 15:46 UTC (permalink / raw)
  To: Jiri Pirko
  Cc: netdev, davem, jhs, xiyou.wangcong, edumazet, alexander.h.duyck,
	stephen, daniel, mlxsw

On Mon, Jun 05, 2017 at 04:38:26PM +0200, Jiri Pirko wrote:
> From: Jiri Pirko <jiri@mellanox.com>
> 
> This patchset introduces a control action dedicated to indicate
> to trap the matched packet to CPU. This is specific action for
> HW offloads. Also, the patchset offloads the action to mlxsw driver.
> 
> Example usage:
> $ tc filter add dev enp3s0np19 parent ffff: protocol ip prio 20 flower skip_sw dst_ip 192.168.10.1 action trap

Hi Jiri

So i assume this means a frame ingressing on the switch port
enp3s0np19 matching the filter is now visible on the linux enp3s0np19
interface?  How do you avoid Linux processing it? If enp3s0np19 is a
member of a bridge, we don't want the software bridge processing it
and forwarding it out another port, since i assume the hardware has
already done this. Or does the trap stop further processing of the
frame by the hardware?

Thanks
      Andrew

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [patch net-next 0/6] introduce trap control action to tc and offload it
  2017-06-05 15:46 ` [patch net-next 0/6] introduce trap control action to tc and offload it Andrew Lunn
@ 2017-06-05 19:43   ` Jiri Pirko
  2017-06-05 19:56     ` Jiri Pirko
  0 siblings, 1 reply; 17+ messages in thread
From: Jiri Pirko @ 2017-06-05 19:43 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: netdev, davem, jhs, xiyou.wangcong, edumazet, alexander.h.duyck,
	stephen, daniel, mlxsw

Mon, Jun 05, 2017 at 05:46:51PM CEST, andrew@lunn.ch wrote:
>On Mon, Jun 05, 2017 at 04:38:26PM +0200, Jiri Pirko wrote:
>> From: Jiri Pirko <jiri@mellanox.com>
>> 
>> This patchset introduces a control action dedicated to indicate
>> to trap the matched packet to CPU. This is specific action for
>> HW offloads. Also, the patchset offloads the action to mlxsw driver.
>> 
>> Example usage:
>> $ tc filter add dev enp3s0np19 parent ffff: protocol ip prio 20 flower skip_sw dst_ip 192.168.10.1 action trap
>
>Hi Jiri
>
>So i assume this means a frame ingressing on the switch port
>enp3s0np19 matching the filter is now visible on the linux enp3s0np19

Yes.


>interface?  How do you avoid Linux processing it? If enp3s0np19 is a

On contrary. I want Linux to process it. The packet was stolen from the
offloaded fastpath to kernel.


>member of a bridge, we don't want the software bridge processing it
>and forwarding it out another port, since i assume the hardware has
>already done this. Or does the trap stop further processing of the
>frame by the hardware?

Exactly the latter :) Thanks!


>
>Thanks
>      Andrew

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [patch net-next 0/6] introduce trap control action to tc and offload it
  2017-06-05 19:43   ` Jiri Pirko
@ 2017-06-05 19:56     ` Jiri Pirko
  0 siblings, 0 replies; 17+ messages in thread
From: Jiri Pirko @ 2017-06-05 19:56 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: netdev, davem, jhs, xiyou.wangcong, edumazet, alexander.h.duyck,
	stephen, daniel, mlxsw

Mon, Jun 05, 2017 at 09:43:17PM CEST, jiri@resnulli.us wrote:
>Mon, Jun 05, 2017 at 05:46:51PM CEST, andrew@lunn.ch wrote:
>>On Mon, Jun 05, 2017 at 04:38:26PM +0200, Jiri Pirko wrote:
>>> From: Jiri Pirko <jiri@mellanox.com>
>>> 
>>> This patchset introduces a control action dedicated to indicate
>>> to trap the matched packet to CPU. This is specific action for
>>> HW offloads. Also, the patchset offloads the action to mlxsw driver.
>>> 
>>> Example usage:
>>> $ tc filter add dev enp3s0np19 parent ffff: protocol ip prio 20 flower skip_sw dst_ip 192.168.10.1 action trap
>>
>>Hi Jiri
>>
>>So i assume this means a frame ingressing on the switch port
>>enp3s0np19 matching the filter is now visible on the linux enp3s0np19
>
>Yes.
>
>
>>interface?  How do you avoid Linux processing it? If enp3s0np19 is a
>
>On contrary. I want Linux to process it. The packet was stolen from the
>offloaded fastpath to kernel.
>
>
>>member of a bridge, we don't want the software bridge processing it
>>and forwarding it out another port, since i assume the hardware has
>>already done this. Or does the trap stop further processing of the
>>frame by the hardware?
>
>Exactly the latter :) Thanks!

Btw, if you would like to just sample the traffic and not really
influence it in any way, there is a special action "sample" for that.
mlxsw offloads that.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [patch net-next 1/6] net: sched: introduce a TRAP control action
  2017-06-05 14:38 ` [patch net-next 1/6] net: sched: introduce a TRAP control action Jiri Pirko
@ 2017-06-05 19:56   ` Andrew Lunn
  2017-06-05 19:59     ` Jiri Pirko
  0 siblings, 1 reply; 17+ messages in thread
From: Andrew Lunn @ 2017-06-05 19:56 UTC (permalink / raw)
  To: Jiri Pirko
  Cc: netdev, davem, jhs, xiyou.wangcong, edumazet, alexander.h.duyck,
	stephen, daniel, mlxsw

> On Mon, Jun 05, 2017 at 04:38:27PM +0200, Jiri Pirko wrote:
> From: Jiri Pirko <jiri@mellanox.com>
> 
> There is need to instruct the HW offloaded path to push certain matched
> packets to cpu/kernel for further analysis. So this patch introduces a
> new TRAP control action to TC.
> 
> For kernel datapath, this action does not make much sense. So with the
> same logic as in HW, new TRAP behaves similar to STOLEN. The skb is just
> dropped in the datapath (and virtually ejected to an upper level, which
> does not exist in case of kernel).
> 
> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
> Reviewed-by: Yotam Gigi <yotamg@mellanox.com>
> ---
>  include/uapi/linux/pkt_cls.h | 5 +++++
>  net/core/dev.c               | 2 ++
>  net/sched/cls_bpf.c          | 1 +
>  net/sched/sch_atm.c          | 1 +
>  net/sched/sch_cbq.c          | 1 +
>  net/sched/sch_drr.c          | 1 +
>  net/sched/sch_dsmark.c       | 1 +
>  net/sched/sch_fq_codel.c     | 1 +
>  net/sched/sch_hfsc.c         | 1 +
>  net/sched/sch_htb.c          | 1 +
>  net/sched/sch_multiq.c       | 1 +
>  net/sched/sch_prio.c         | 1 +
>  net/sched/sch_qfq.c          | 1 +
>  net/sched/sch_sfb.c          | 1 +
>  net/sched/sch_sfq.c          | 1 +
>  15 files changed, 20 insertions(+)
> 
> diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h
> index edf43dd..5d6f711 100644
> --- a/include/uapi/linux/pkt_cls.h
> +++ b/include/uapi/linux/pkt_cls.h
> @@ -37,6 +37,11 @@ enum {
>  #define TC_ACT_QUEUED		5
>  #define TC_ACT_REPEAT		6
>  #define TC_ACT_REDIRECT		7
> +#define TC_ACT_TRAP		8 /* For hw path, this means "trap to cpu",
> +				   * for sw path, this is equivalent of
> +				   * TC_ACT_STOLEN - drop the skb and act
> +				   * like everything is allright.
> +				   */

Hi Jiri

Given my question and your answer, can we please extend this
description.

"For hw path, this means "trap to cpu" and don't further process the
frame in hardware."

Oh, and s/allright/alright.

    Andrew

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [patch net-next 1/6] net: sched: introduce a TRAP control action
  2017-06-05 19:56   ` Andrew Lunn
@ 2017-06-05 19:59     ` Jiri Pirko
  0 siblings, 0 replies; 17+ messages in thread
From: Jiri Pirko @ 2017-06-05 19:59 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: netdev, davem, jhs, xiyou.wangcong, edumazet, alexander.h.duyck,
	stephen, daniel, mlxsw

Mon, Jun 05, 2017 at 09:56:32PM CEST, andrew@lunn.ch wrote:
>> On Mon, Jun 05, 2017 at 04:38:27PM +0200, Jiri Pirko wrote:
>> From: Jiri Pirko <jiri@mellanox.com>
>> 
>> There is need to instruct the HW offloaded path to push certain matched
>> packets to cpu/kernel for further analysis. So this patch introduces a
>> new TRAP control action to TC.
>> 
>> For kernel datapath, this action does not make much sense. So with the
>> same logic as in HW, new TRAP behaves similar to STOLEN. The skb is just
>> dropped in the datapath (and virtually ejected to an upper level, which
>> does not exist in case of kernel).
>> 
>> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
>> Reviewed-by: Yotam Gigi <yotamg@mellanox.com>
>> ---
>>  include/uapi/linux/pkt_cls.h | 5 +++++
>>  net/core/dev.c               | 2 ++
>>  net/sched/cls_bpf.c          | 1 +
>>  net/sched/sch_atm.c          | 1 +
>>  net/sched/sch_cbq.c          | 1 +
>>  net/sched/sch_drr.c          | 1 +
>>  net/sched/sch_dsmark.c       | 1 +
>>  net/sched/sch_fq_codel.c     | 1 +
>>  net/sched/sch_hfsc.c         | 1 +
>>  net/sched/sch_htb.c          | 1 +
>>  net/sched/sch_multiq.c       | 1 +
>>  net/sched/sch_prio.c         | 1 +
>>  net/sched/sch_qfq.c          | 1 +
>>  net/sched/sch_sfb.c          | 1 +
>>  net/sched/sch_sfq.c          | 1 +
>>  15 files changed, 20 insertions(+)
>> 
>> diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h
>> index edf43dd..5d6f711 100644
>> --- a/include/uapi/linux/pkt_cls.h
>> +++ b/include/uapi/linux/pkt_cls.h
>> @@ -37,6 +37,11 @@ enum {
>>  #define TC_ACT_QUEUED		5
>>  #define TC_ACT_REPEAT		6
>>  #define TC_ACT_REDIRECT		7
>> +#define TC_ACT_TRAP		8 /* For hw path, this means "trap to cpu",
>> +				   * for sw path, this is equivalent of
>> +				   * TC_ACT_STOLEN - drop the skb and act
>> +				   * like everything is allright.
>> +				   */
>
>Hi Jiri
>
>Given my question and your answer, can we please extend this
>description.
>
>"For hw path, this means "trap to cpu" and don't further process the
>frame in hardware."

Okay :)


>
>Oh, and s/allright/alright.

English is an odd language :) Thanks!

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [patch iproute2/net-next] tc: add support for TRAP action
  2017-06-05 14:39 ` [patch iproute2/net-next] tc: add support for TRAP action Jiri Pirko
@ 2017-06-08  6:57   ` Jiri Pirko
  2017-06-08 17:26   ` Jiri Benc
  2017-06-08 18:03   ` Stephen Hemminger
  2 siblings, 0 replies; 17+ messages in thread
From: Jiri Pirko @ 2017-06-08  6:57 UTC (permalink / raw)
  To: netdev
  Cc: davem, jhs, xiyou.wangcong, edumazet, alexander.h.duyck, stephen,
	daniel, mlxsw

Mon, Jun 05, 2017 at 04:39:45PM CEST, jiri@resnulli.us wrote:
>From: Jiri Pirko <jiri@mellanox.com>
>
>Signed-off-by: Jiri Pirko <jiri@mellanox.com>

Stephen, note that the kernel part was accepted in v2. Thanks.


>---
> include/linux/pkt_cls.h | 5 +++++
> tc/tc_util.c            | 3 +++
> 2 files changed, 8 insertions(+)
>
>diff --git a/include/linux/pkt_cls.h b/include/linux/pkt_cls.h
>index c6e8cf5..477ed05 100644
>--- a/include/linux/pkt_cls.h
>+++ b/include/linux/pkt_cls.h
>@@ -37,6 +37,11 @@ enum {
> #define TC_ACT_QUEUED		5
> #define TC_ACT_REPEAT		6
> #define TC_ACT_REDIRECT		7
>+#define TC_ACT_TRAP		8 /* For hw path, this means "trap to cpu",
>+				   * for sw path, this is equivalent of
>+				   * TC_ACT_STOLEN - drop the skb and act
>+				   * like everything is allright.
>+				   */
> 
> /* There is a special kind of actions called "extended actions",
>  * which need a value parameter. These have a local opcode located in
>diff --git a/tc/tc_util.c b/tc/tc_util.c
>index 4f7283d..5a0f96a 100644
>--- a/tc/tc_util.c
>+++ b/tc/tc_util.c
>@@ -430,6 +430,8 @@ static const char *action_n2a(int action)
> 		return "pipe";
> 	case TC_ACT_STOLEN:
> 		return "stolen";
>+	case TC_ACT_TRAP:
>+		return "trap";
> 	default:
> 		snprintf(buf, 64, "%d", action);
> 		buf[63] = '\0';
>@@ -462,6 +464,7 @@ static int action_a2n(char *arg, int *result, bool allow_num)
> 		{"reclassify", TC_ACT_RECLASSIFY},
> 		{"pipe", TC_ACT_PIPE},
> 		{"goto", TC_ACT_GOTO_CHAIN},
>+		{"trap", TC_ACT_TRAP},
> 		{ NULL },
> 	}, *iter;
> 
>-- 
>2.9.3
>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [patch iproute2/net-next] tc: add support for TRAP action
  2017-06-05 14:39 ` [patch iproute2/net-next] tc: add support for TRAP action Jiri Pirko
  2017-06-08  6:57   ` Jiri Pirko
@ 2017-06-08 17:26   ` Jiri Benc
  2017-06-08 18:41     ` Jiri Pirko
  2017-06-08 18:03   ` Stephen Hemminger
  2 siblings, 1 reply; 17+ messages in thread
From: Jiri Benc @ 2017-06-08 17:26 UTC (permalink / raw)
  To: Jiri Pirko
  Cc: netdev, davem, jhs, xiyou.wangcong, edumazet, alexander.h.duyck,
	stephen, daniel, mlxsw

On Mon,  5 Jun 2017 16:39:45 +0200, Jiri Pirko wrote:
> From: Jiri Pirko <jiri@mellanox.com>
> 
> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
> ---
>  include/linux/pkt_cls.h | 5 +++++
>  tc/tc_util.c            | 3 +++
>  2 files changed, 8 insertions(+)

No documentation again. Please add the description of the new action to
a man page.

 Jiri

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [patch iproute2/net-next] tc: add support for TRAP action
  2017-06-05 14:39 ` [patch iproute2/net-next] tc: add support for TRAP action Jiri Pirko
  2017-06-08  6:57   ` Jiri Pirko
  2017-06-08 17:26   ` Jiri Benc
@ 2017-06-08 18:03   ` Stephen Hemminger
  2 siblings, 0 replies; 17+ messages in thread
From: Stephen Hemminger @ 2017-06-08 18:03 UTC (permalink / raw)
  To: Jiri Pirko
  Cc: netdev, davem, jhs, xiyou.wangcong, edumazet, alexander.h.duyck,
	daniel, mlxsw

On Mon,  5 Jun 2017 16:39:45 +0200
Jiri Pirko <jiri@resnulli.us> wrote:

> From: Jiri Pirko <jiri@mellanox.com>
> 
> Signed-off-by: Jiri Pirko <jiri@mellanox.com>

Applied to net-next

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [patch iproute2/net-next] tc: add support for TRAP action
  2017-06-08 17:26   ` Jiri Benc
@ 2017-06-08 18:41     ` Jiri Pirko
  0 siblings, 0 replies; 17+ messages in thread
From: Jiri Pirko @ 2017-06-08 18:41 UTC (permalink / raw)
  To: Jiri Benc
  Cc: netdev, davem, jhs, xiyou.wangcong, edumazet, alexander.h.duyck,
	stephen, daniel, mlxsw

Thu, Jun 08, 2017 at 07:26:12PM CEST, jbenc@redhat.com wrote:
>On Mon,  5 Jun 2017 16:39:45 +0200, Jiri Pirko wrote:
>> From: Jiri Pirko <jiri@mellanox.com>
>> 
>> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
>> ---
>>  include/linux/pkt_cls.h | 5 +++++
>>  tc/tc_util.c            | 3 +++
>>  2 files changed, 8 insertions(+)
>
>No documentation again. Please add the description of the new action to
>a man page.

Will do. It's on my todo list.

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2017-06-08 18:41 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-05 14:38 [patch net-next 0/6] introduce trap control action to tc and offload it Jiri Pirko
2017-06-05 14:38 ` [patch net-next 1/6] net: sched: introduce a TRAP control action Jiri Pirko
2017-06-05 19:56   ` Andrew Lunn
2017-06-05 19:59     ` Jiri Pirko
2017-06-05 14:38 ` [patch net-next 2/6] net: sched: introduce helper to identify gact trap action Jiri Pirko
2017-06-05 14:38 ` [patch net-next 3/6] mlxsw: pci: Fix size of trap_id field in CQE Jiri Pirko
2017-06-05 14:38 ` [patch net-next 4/6] mlxsw: spectrum: Introduce ACL trap Jiri Pirko
2017-06-05 14:38 ` [patch net-next 5/6] acl: Introduce ACL trap action Jiri Pirko
2017-06-05 14:38 ` [patch net-next 6/6] spectrum_flower: Implement gact trap TC action offload Jiri Pirko
2017-06-05 14:39 ` [patch iproute2/net-next] tc: add support for TRAP action Jiri Pirko
2017-06-08  6:57   ` Jiri Pirko
2017-06-08 17:26   ` Jiri Benc
2017-06-08 18:41     ` Jiri Pirko
2017-06-08 18:03   ` Stephen Hemminger
2017-06-05 15:46 ` [patch net-next 0/6] introduce trap control action to tc and offload it Andrew Lunn
2017-06-05 19:43   ` Jiri Pirko
2017-06-05 19:56     ` Jiri Pirko

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).