All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] net/sched: cls_flower: Add support for matching on ct_state reply flag
@ 2021-01-27 14:32 Paul Blakey
  2021-01-27 14:32 ` [PATCH net-next 1/3] net/sched: cls_flower: Add match on the " Paul Blakey
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Paul Blakey @ 2021-01-27 14:32 UTC (permalink / raw)
  To: Paul Blakey, netdev, Jamal Hadi Salim, David S. Miller,
	Jakub Kicinski, Cong Wang
  Cc: Vlad Buslov, Oz Shlomo, Roi Dayan, Jiri Pirko, Saeed Mahameed

This patchset adds software match support and offload of flower
match ct_state reply flag (+/-rpl).

The first patch adds the definition for the flag and match to flower.

Second patch gives the direction of the connection to the offloading drivers via
ct_metadata flow offload action.

The last patch does offload of this new ct_state by using the supplied
connection's direction.

Paul Blakey (3):
  net/sched: cls_flower: Add match on the ct_state reply flag
  net: flow_offload: Add original direction flag to ct_metadata
  net/mlx5: CT: Add support for matching on ct_state reply flag

 drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c | 13 ++++++++++---
 include/net/flow_offload.h                         |  1 +
 include/uapi/linux/pkt_cls.h                       |  1 +
 net/sched/act_ct.c                                 |  1 +
 net/sched/cls_flower.c                             |  6 ++++--
 5 files changed, 17 insertions(+), 5 deletions(-)

-- 
1.8.3.1


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

* [PATCH net-next 1/3] net/sched: cls_flower: Add match on the ct_state reply flag
  2021-01-27 14:32 [PATCH net-next 0/3] net/sched: cls_flower: Add support for matching on ct_state reply flag Paul Blakey
@ 2021-01-27 14:32 ` Paul Blakey
  2021-01-27 14:32 ` [PATCH net-next 2/3] net: flow_offload: Add original direction flag to ct_metadata Paul Blakey
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: Paul Blakey @ 2021-01-27 14:32 UTC (permalink / raw)
  To: Paul Blakey, netdev, Jamal Hadi Salim, David S. Miller,
	Jakub Kicinski, Cong Wang
  Cc: Vlad Buslov, Oz Shlomo, Roi Dayan, Jiri Pirko, Saeed Mahameed

Add match on the ct_state reply flag.

Example:
$ tc filter add dev ens1f0_0 ingress prio 1 chain 1 proto ip flower \
  ct_state +trk+est+rpl \
  action mirred egress redirect dev ens1f0_1
$ tc filter add dev ens1f0_1 ingress prio 1 chain 1 proto ip flower \
  ct_state +trk+est-rpl \
  action mirred egress redirect dev ens1f0_0

Signed-off-by: Paul Blakey <paulb@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
---
 include/uapi/linux/pkt_cls.h | 1 +
 net/sched/cls_flower.c       | 6 ++++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/include/uapi/linux/pkt_cls.h b/include/uapi/linux/pkt_cls.h
index 709668e..afe6836 100644
--- a/include/uapi/linux/pkt_cls.h
+++ b/include/uapi/linux/pkt_cls.h
@@ -592,6 +592,7 @@ enum {
 	TCA_FLOWER_KEY_CT_FLAGS_RELATED = 1 << 2, /* Related to an established connection. */
 	TCA_FLOWER_KEY_CT_FLAGS_TRACKED = 1 << 3, /* Conntrack has occurred. */
 	TCA_FLOWER_KEY_CT_FLAGS_INVALID = 1 << 4, /* Conntrack is invalid. */
+	TCA_FLOWER_KEY_CT_FLAGS_REPLY = 1 << 5, /* Packet is in the reply direction. */
 };
 
 enum {
diff --git a/net/sched/cls_flower.c b/net/sched/cls_flower.c
index 4a9297a..caf7643 100644
--- a/net/sched/cls_flower.c
+++ b/net/sched/cls_flower.c
@@ -291,9 +291,11 @@ struct cls_fl_filter *fl_mask_lookup(struct fl_flow_mask *mask, struct fl_flow_k
 	[IP_CT_RELATED] =		TCA_FLOWER_KEY_CT_FLAGS_TRACKED |
 					TCA_FLOWER_KEY_CT_FLAGS_RELATED,
 	[IP_CT_ESTABLISHED_REPLY] =	TCA_FLOWER_KEY_CT_FLAGS_TRACKED |
-					TCA_FLOWER_KEY_CT_FLAGS_ESTABLISHED,
+					TCA_FLOWER_KEY_CT_FLAGS_ESTABLISHED |
+					TCA_FLOWER_KEY_CT_FLAGS_REPLY,
 	[IP_CT_RELATED_REPLY] =		TCA_FLOWER_KEY_CT_FLAGS_TRACKED |
-					TCA_FLOWER_KEY_CT_FLAGS_RELATED,
+					TCA_FLOWER_KEY_CT_FLAGS_RELATED |
+					TCA_FLOWER_KEY_CT_FLAGS_REPLY,
 	[IP_CT_NEW] =			TCA_FLOWER_KEY_CT_FLAGS_TRACKED |
 					TCA_FLOWER_KEY_CT_FLAGS_NEW,
 };
-- 
1.8.3.1


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

* [PATCH net-next 2/3] net: flow_offload: Add original direction flag to ct_metadata
  2021-01-27 14:32 [PATCH net-next 0/3] net/sched: cls_flower: Add support for matching on ct_state reply flag Paul Blakey
  2021-01-27 14:32 ` [PATCH net-next 1/3] net/sched: cls_flower: Add match on the " Paul Blakey
@ 2021-01-27 14:32 ` Paul Blakey
  2021-01-27 14:32 ` [PATCH net-next 3/3] net/mlx5: CT: Add support for matching on ct_state reply flag Paul Blakey
  2021-01-30  2:30 ` [PATCH net-next 0/3] net/sched: cls_flower: " patchwork-bot+netdevbpf
  3 siblings, 0 replies; 7+ messages in thread
From: Paul Blakey @ 2021-01-27 14:32 UTC (permalink / raw)
  To: Paul Blakey, netdev, Jamal Hadi Salim, David S. Miller,
	Jakub Kicinski, Cong Wang
  Cc: Vlad Buslov, Oz Shlomo, Roi Dayan, Jiri Pirko, Saeed Mahameed

Give offloading drivers the direction of the offloaded ct flow,
this will be used for matches on direction (ct_state +/-rpl).

Signed-off-by: Paul Blakey <paulb@nvidia.com>
Reviewed-by: Jiri Pirko <jiri@nvidia.com>
---
 include/net/flow_offload.h | 1 +
 net/sched/act_ct.c         | 1 +
 2 files changed, 2 insertions(+)

diff --git a/include/net/flow_offload.h b/include/net/flow_offload.h
index 123b1e9..e6bd8eb 100644
--- a/include/net/flow_offload.h
+++ b/include/net/flow_offload.h
@@ -245,6 +245,7 @@ struct flow_action_entry {
 			unsigned long cookie;
 			u32 mark;
 			u32 labels[4];
+			bool orig_dir;
 		} ct_metadata;
 		struct {				/* FLOW_ACTION_MPLS_PUSH */
 			u32		label;
diff --git a/net/sched/act_ct.c b/net/sched/act_ct.c
index b344207..f0a0aa1 100644
--- a/net/sched/act_ct.c
+++ b/net/sched/act_ct.c
@@ -183,6 +183,7 @@ static void tcf_ct_flow_table_add_action_meta(struct nf_conn *ct,
 					     IP_CT_ESTABLISHED_REPLY;
 	/* aligns with the CT reference on the SKB nf_ct_set */
 	entry->ct_metadata.cookie = (unsigned long)ct | ctinfo;
+	entry->ct_metadata.orig_dir = dir == IP_CT_DIR_ORIGINAL;
 
 	act_ct_labels = entry->ct_metadata.labels;
 	ct_labels = nf_ct_labels_find(ct);
-- 
1.8.3.1


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

* [PATCH net-next 3/3] net/mlx5: CT: Add support for matching on ct_state reply flag
  2021-01-27 14:32 [PATCH net-next 0/3] net/sched: cls_flower: Add support for matching on ct_state reply flag Paul Blakey
  2021-01-27 14:32 ` [PATCH net-next 1/3] net/sched: cls_flower: Add match on the " Paul Blakey
  2021-01-27 14:32 ` [PATCH net-next 2/3] net: flow_offload: Add original direction flag to ct_metadata Paul Blakey
@ 2021-01-27 14:32 ` Paul Blakey
  2021-02-02 12:36   ` Marcelo Ricardo Leitner
  2021-01-30  2:30 ` [PATCH net-next 0/3] net/sched: cls_flower: " patchwork-bot+netdevbpf
  3 siblings, 1 reply; 7+ messages in thread
From: Paul Blakey @ 2021-01-27 14:32 UTC (permalink / raw)
  To: Paul Blakey, netdev, Jamal Hadi Salim, David S. Miller,
	Jakub Kicinski, Cong Wang
  Cc: Vlad Buslov, Oz Shlomo, Roi Dayan, Jiri Pirko, Saeed Mahameed

Add support for matching on ct_state reply flag.

Example:
$ tc filter add dev ens1f0_0 ingress prio 1 chain 1 proto ip flower \
  ct_state +trk+est+rpl \
  action mirred egress redirect dev ens1f0_1
$ tc filter add dev ens1f0_1 ingress prio 1 chain 1 proto ip flower \
  ct_state +trk+est-rpl \
  action mirred egress redirect dev ens1f0_0

Signed-off-by: Paul Blakey <paulb@nvidia.com>
Acked-by: Saeed Mahameed <saeedm@nvidia.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c
index e20c1da..68bdf5c 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c
@@ -27,6 +27,7 @@
 #define MLX5_CT_STATE_ESTABLISHED_BIT BIT(1)
 #define MLX5_CT_STATE_TRK_BIT BIT(2)
 #define MLX5_CT_STATE_NAT_BIT BIT(3)
+#define MLX5_CT_STATE_REPLY_BIT BIT(4)
 
 #define MLX5_FTE_ID_BITS (mlx5e_tc_attr_to_reg_mappings[FTEID_TO_REG].mlen * 8)
 #define MLX5_FTE_ID_MAX GENMASK(MLX5_FTE_ID_BITS - 1, 0)
@@ -635,6 +636,7 @@ struct mlx5_ct_entry {
 	}
 
 	ct_state |= MLX5_CT_STATE_ESTABLISHED_BIT | MLX5_CT_STATE_TRK_BIT;
+	ct_state |= meta->ct_metadata.orig_dir ? 0 : MLX5_CT_STATE_REPLY_BIT;
 	err = mlx5_tc_ct_entry_set_registers(ct_priv, &mod_acts,
 					     ct_state,
 					     meta->ct_metadata.mark,
@@ -1080,8 +1082,8 @@ void mlx5_tc_ct_match_del(struct mlx5_tc_ct_priv *priv, struct mlx5_ct_attr *ct_
 		     struct netlink_ext_ack *extack)
 {
 	struct flow_rule *rule = flow_cls_offload_flow_rule(f);
+	bool trk, est, untrk, unest, new, rpl, unrpl;
 	struct flow_dissector_key_ct *mask, *key;
-	bool trk, est, untrk, unest, new;
 	u32 ctstate = 0, ctstate_mask = 0;
 	u16 ct_state_on, ct_state_off;
 	u16 ct_state, ct_state_mask;
@@ -1107,9 +1109,10 @@ void mlx5_tc_ct_match_del(struct mlx5_tc_ct_priv *priv, struct mlx5_ct_attr *ct_
 
 	if (ct_state_mask & ~(TCA_FLOWER_KEY_CT_FLAGS_TRACKED |
 			      TCA_FLOWER_KEY_CT_FLAGS_ESTABLISHED |
-			      TCA_FLOWER_KEY_CT_FLAGS_NEW)) {
+			      TCA_FLOWER_KEY_CT_FLAGS_NEW |
+			      TCA_FLOWER_KEY_CT_FLAGS_REPLY)) {
 		NL_SET_ERR_MSG_MOD(extack,
-				   "only ct_state trk, est and new are supported for offload");
+				   "only ct_state trk, est, new and rpl are supported for offload");
 		return -EOPNOTSUPP;
 	}
 
@@ -1118,13 +1121,17 @@ void mlx5_tc_ct_match_del(struct mlx5_tc_ct_priv *priv, struct mlx5_ct_attr *ct_
 	trk = ct_state_on & TCA_FLOWER_KEY_CT_FLAGS_TRACKED;
 	new = ct_state_on & TCA_FLOWER_KEY_CT_FLAGS_NEW;
 	est = ct_state_on & TCA_FLOWER_KEY_CT_FLAGS_ESTABLISHED;
+	rpl = ct_state_on & TCA_FLOWER_KEY_CT_FLAGS_REPLY;
 	untrk = ct_state_off & TCA_FLOWER_KEY_CT_FLAGS_TRACKED;
 	unest = ct_state_off & TCA_FLOWER_KEY_CT_FLAGS_ESTABLISHED;
+	unrpl = ct_state_off & TCA_FLOWER_KEY_CT_FLAGS_REPLY;
 
 	ctstate |= trk ? MLX5_CT_STATE_TRK_BIT : 0;
 	ctstate |= est ? MLX5_CT_STATE_ESTABLISHED_BIT : 0;
+	ctstate |= rpl ? MLX5_CT_STATE_REPLY_BIT : 0;
 	ctstate_mask |= (untrk || trk) ? MLX5_CT_STATE_TRK_BIT : 0;
 	ctstate_mask |= (unest || est) ? MLX5_CT_STATE_ESTABLISHED_BIT : 0;
+	ctstate_mask |= (unrpl || rpl) ? MLX5_CT_STATE_REPLY_BIT : 0;
 
 	if (new) {
 		NL_SET_ERR_MSG_MOD(extack,
-- 
1.8.3.1


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

* Re: [PATCH net-next 0/3] net/sched: cls_flower: Add support for matching on ct_state reply flag
  2021-01-27 14:32 [PATCH net-next 0/3] net/sched: cls_flower: Add support for matching on ct_state reply flag Paul Blakey
                   ` (2 preceding siblings ...)
  2021-01-27 14:32 ` [PATCH net-next 3/3] net/mlx5: CT: Add support for matching on ct_state reply flag Paul Blakey
@ 2021-01-30  2:30 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 7+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-01-30  2:30 UTC (permalink / raw)
  To: Paul Blakey
  Cc: netdev, jhs, davem, kuba, xiyou.wangcong, vladbu, ozsh, roid,
	jiri, saeedm

Hello:

This series was applied to netdev/net-next.git (refs/heads/master):

On Wed, 27 Jan 2021 16:32:44 +0200 you wrote:
> This patchset adds software match support and offload of flower
> match ct_state reply flag (+/-rpl).
> 
> The first patch adds the definition for the flag and match to flower.
> 
> Second patch gives the direction of the connection to the offloading drivers via
> ct_metadata flow offload action.
> 
> [...]

Here is the summary with links:
  - [net-next,1/3] net/sched: cls_flower: Add match on the ct_state reply flag
    https://git.kernel.org/netdev/net-next/c/8c85d18ce647
  - [net-next,2/3] net: flow_offload: Add original direction flag to ct_metadata
    https://git.kernel.org/netdev/net-next/c/941eff5aea5d
  - [net-next,3/3] net/mlx5: CT: Add support for matching on ct_state reply flag
    https://git.kernel.org/netdev/net-next/c/6895cb3a95c9

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

* Re: [PATCH net-next 3/3] net/mlx5: CT: Add support for matching on ct_state reply flag
  2021-01-27 14:32 ` [PATCH net-next 3/3] net/mlx5: CT: Add support for matching on ct_state reply flag Paul Blakey
@ 2021-02-02 12:36   ` Marcelo Ricardo Leitner
  2021-02-03  7:58     ` Paul Blakey
  0 siblings, 1 reply; 7+ messages in thread
From: Marcelo Ricardo Leitner @ 2021-02-02 12:36 UTC (permalink / raw)
  To: Paul Blakey
  Cc: netdev, Jamal Hadi Salim, David S. Miller, Jakub Kicinski,
	Cong Wang, Vlad Buslov, Oz Shlomo, Roi Dayan, Jiri Pirko,
	Saeed Mahameed

On Wed, Jan 27, 2021 at 04:32:47PM +0200, Paul Blakey wrote:
> Add support for matching on ct_state reply flag.

Sorry for the late reply, missed the patchset here. (just noticed
because of the iproute2 patch, thanks for the Cc in there)

Only one question though. Is it safe to assume that this will require
a firmware update as well?

Thanks,
Marcelo

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

* Re: [PATCH net-next 3/3] net/mlx5: CT: Add support for matching on ct_state reply flag
  2021-02-02 12:36   ` Marcelo Ricardo Leitner
@ 2021-02-03  7:58     ` Paul Blakey
  0 siblings, 0 replies; 7+ messages in thread
From: Paul Blakey @ 2021-02-03  7:58 UTC (permalink / raw)
  To: Marcelo Ricardo Leitner
  Cc: netdev, Jamal Hadi Salim, David S. Miller, Jakub Kicinski,
	Cong Wang, Vlad Buslov, Oz Shlomo, Roi Dayan, Jiri Pirko,
	Saeed Mahameed



On Tue, 2 Feb 2021, Marcelo Ricardo Leitner wrote:

> On Wed, Jan 27, 2021 at 04:32:47PM +0200, Paul Blakey wrote:
> > Add support for matching on ct_state reply flag.
> 
> Sorry for the late reply, missed the patchset here. (just noticed
> because of the iproute2 patch, thanks for the Cc in there)
> 
> Only one question though. Is it safe to assume that this will require
> a firmware update as well?

No, it will not, there was room for this flag in the register before (as 
long as you had a firmware recent enough that supported CT feature 
itself ofc).

Paul.

> 
> Thanks,
> Marcelo
> 

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

end of thread, other threads:[~2021-02-03  7:59 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-27 14:32 [PATCH net-next 0/3] net/sched: cls_flower: Add support for matching on ct_state reply flag Paul Blakey
2021-01-27 14:32 ` [PATCH net-next 1/3] net/sched: cls_flower: Add match on the " Paul Blakey
2021-01-27 14:32 ` [PATCH net-next 2/3] net: flow_offload: Add original direction flag to ct_metadata Paul Blakey
2021-01-27 14:32 ` [PATCH net-next 3/3] net/mlx5: CT: Add support for matching on ct_state reply flag Paul Blakey
2021-02-02 12:36   ` Marcelo Ricardo Leitner
2021-02-03  7:58     ` Paul Blakey
2021-01-30  2:30 ` [PATCH net-next 0/3] net/sched: cls_flower: " patchwork-bot+netdevbpf

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.