diff mbox series

[net-next,01/16] net/mlx5: CT: Add support for matching on ct_state inv and rel flags

Message ID 20210404041954.146958-2-saeed@kernel.org (mailing list archive)
State Accepted
Commit 116c76c51035ec49af0894e8e8ad71334f9ad7aa
Delegated to: Netdev Maintainers
Headers show
Series [net-next,01/16] net/mlx5: CT: Add support for matching on ct_state inv and rel flags | expand

Checks

Context Check Description
netdev/cover_letter success Pull request
netdev/fixes_present success Link
netdev/patch_count warning Series longer than 15 patches
netdev/tree_selection success Clearly marked for net-next
netdev/subject_prefix success Link
netdev/cc_maintainers warning 6 maintainers not CCed: ozsh@nvidia.com elibr@mellanox.com roid@nvidia.com paulb@mellanox.com linux-rdma@vger.kernel.org leon@kernel.org
netdev/source_inline success Was 0 now: 0
netdev/verify_signedoff success Link
netdev/module_param success Was 0 now: 0
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/verify_fixes success Link
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 60 lines checked
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/header_inline success Link

Commit Message

Saeed Mahameed April 4, 2021, 4:19 a.m. UTC
From: Ariel Levkovich <lariel@nvidia.com>

Add support for matching on ct_state inv and rel flags.

Currently the support is only for match on -inv and -rel.
Matching on +inv and +rel will be rejected.

Example:
$ tc filter add dev ens1f0_0 ingress prio 1 chain 1 proto ip flower \
  ct_state -est-rel+trk \
  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-inv \
  action mirred egress redirect dev ens1f0_0

Signed-off-by: Ariel Levkovich <lariel@nvidia.com>
Signed-off-by: Saeed Mahameed <saeedm@nvidia.com>
---
 .../ethernet/mellanox/mlx5/core/en/tc_ct.c    | 26 +++++++++++++++++--
 1 file changed, 24 insertions(+), 2 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org April 4, 2021, 8:50 a.m. UTC | #1
Hello:

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

On Sat,  3 Apr 2021 21:19:39 -0700 you wrote:
> From: Ariel Levkovich <lariel@nvidia.com>
> 
> Add support for matching on ct_state inv and rel flags.
> 
> Currently the support is only for match on -inv and -rel.
> Matching on +inv and +rel will be rejected.
> 
> [...]

Here is the summary with links:
  - [net-next,01/16] net/mlx5: CT: Add support for matching on ct_state inv and rel flags
    https://git.kernel.org/netdev/net-next/c/116c76c51035
  - [net-next,02/16] net/mlx5: E-Switch, cut down mlx5_vport_info structure size by 8 bytes
    https://git.kernel.org/netdev/net-next/c/cadb129ffdfe
  - [net-next,03/16] net/mlx5: E-Switch, move QoS specific fields to existing qos struct
    https://git.kernel.org/netdev/net-next/c/e591605f801e
  - [net-next,04/16] net/mlx5: Use unsigned int for free_count
    https://git.kernel.org/netdev/net-next/c/c6baac47d9e6
  - [net-next,05/16] net/mlx5: Pack mlx5_rl_entry structure
    https://git.kernel.org/netdev/net-next/c/4c4c0a89abd5
  - [net-next,06/16] net/mlx5: Do not hold mutex while reading table constants
    https://git.kernel.org/netdev/net-next/c/16e74672a21b
  - [net-next,07/16] net/mlx5: Use helpers to allocate and free rl table entries
    https://git.kernel.org/netdev/net-next/c/51ccc9f5f106
  - [net-next,08/16] net/mlx5: Use helper to increment, decrement rate entry refcount
    https://git.kernel.org/netdev/net-next/c/97d85aba2543
  - [net-next,09/16] net/mlx5: Allocate rate limit table when rate is configured
    https://git.kernel.org/netdev/net-next/c/6b30b6d4d36c
  - [net-next,10/16] net/mlx5: Pair mutex_destory with mutex_init for rate limit table
    https://git.kernel.org/netdev/net-next/c/19779f28c96d
  - [net-next,11/16] net/mlx5: E-Switch, cut down mlx5_vport_info structure size by 8 bytes
    https://git.kernel.org/netdev/net-next/c/b47e1056257c
  - [net-next,12/16] net/mlx5: E-Switch, move QoS specific fields to existing qos struct
    https://git.kernel.org/netdev/net-next/c/233dd7d6565e
  - [net-next,13/16] net/mlx5: Use ida_alloc_range() instead of ida_simple_alloc()
    https://git.kernel.org/netdev/net-next/c/8802b8a44ef8
  - [net-next,14/16] net/mlx5e: Reject tc rules which redirect from a VF to itself
    https://git.kernel.org/netdev/net-next/c/bb5696570b0b
  - [net-next,15/16] net/mlx5e: Dynamic alloc arfs table for netdev when needed
    https://git.kernel.org/netdev/net-next/c/f6755b80d693
  - [net-next,16/16] net/mlx5e: Dynamic alloc vlan table for netdev when needed
    https://git.kernel.org/netdev/net-next/c/6783f0a21a3c

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

Patch

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 df13e5094034..1c44000ad675 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c
@@ -29,6 +29,8 @@ 
 #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_CT_STATE_RELATED_BIT BIT(5)
+#define MLX5_CT_STATE_INVALID_BIT BIT(6)
 
 #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)
@@ -1207,8 +1209,8 @@  mlx5_tc_ct_match_add(struct mlx5_tc_ct_priv *priv,
 		     struct mlx5_ct_attr *ct_attr,
 		     struct netlink_ext_ack *extack)
 {
+	bool trk, est, untrk, unest, new, rpl, unrpl, rel, unrel, inv, uninv;
 	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;
 	u32 ctstate = 0, ctstate_mask = 0;
 	u16 ct_state_on, ct_state_off;
@@ -1236,7 +1238,9 @@  mlx5_tc_ct_match_add(struct mlx5_tc_ct_priv *priv,
 	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_REPLY)) {
+			      TCA_FLOWER_KEY_CT_FLAGS_REPLY |
+			      TCA_FLOWER_KEY_CT_FLAGS_RELATED |
+			      TCA_FLOWER_KEY_CT_FLAGS_INVALID)) {
 		NL_SET_ERR_MSG_MOD(extack,
 				   "only ct_state trk, est, new and rpl are supported for offload");
 		return -EOPNOTSUPP;
@@ -1248,9 +1252,13 @@  mlx5_tc_ct_match_add(struct mlx5_tc_ct_priv *priv,
 	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;
+	rel = ct_state_on & TCA_FLOWER_KEY_CT_FLAGS_RELATED;
+	inv = ct_state_on & TCA_FLOWER_KEY_CT_FLAGS_INVALID;
 	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;
+	unrel = ct_state_off & TCA_FLOWER_KEY_CT_FLAGS_RELATED;
+	uninv = ct_state_off & TCA_FLOWER_KEY_CT_FLAGS_INVALID;
 
 	ctstate |= trk ? MLX5_CT_STATE_TRK_BIT : 0;
 	ctstate |= est ? MLX5_CT_STATE_ESTABLISHED_BIT : 0;
@@ -1258,6 +1266,20 @@  mlx5_tc_ct_match_add(struct mlx5_tc_ct_priv *priv,
 	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;
+	ctstate_mask |= unrel ? MLX5_CT_STATE_RELATED_BIT : 0;
+	ctstate_mask |= uninv ? MLX5_CT_STATE_INVALID_BIT : 0;
+
+	if (rel) {
+		NL_SET_ERR_MSG_MOD(extack,
+				   "matching on ct_state +rel isn't supported");
+		return -EOPNOTSUPP;
+	}
+
+	if (inv) {
+		NL_SET_ERR_MSG_MOD(extack,
+				   "matching on ct_state +inv isn't supported");
+		return -EOPNOTSUPP;
+	}
 
 	if (new) {
 		NL_SET_ERR_MSG_MOD(extack,