git: 513a6d84e913 - stable/13 - mlx5: Implement offloads flowtable namespace.

From: Hans Petter Selasky <hselasky_at_FreeBSD.org>
Date: Tue, 08 Feb 2022 15:14:07 UTC
The branch stable/13 has been updated by hselasky:

URL: https://cgit.FreeBSD.org/src/commit/?id=513a6d84e913d99925a989e86ce1a0e0a30f4bdd

commit 513a6d84e913d99925a989e86ce1a0e0a30f4bdd
Author:     Hans Petter Selasky <hselasky@FreeBSD.org>
AuthorDate: 2022-02-08 15:08:53 +0000
Commit:     Hans Petter Selasky <hselasky@FreeBSD.org>
CommitDate: 2022-02-08 15:08:53 +0000

    mlx5: Implement offloads flowtable namespace.
    
    This namespace will be used for TCP offloads, like hardware decryption
    of TLS TCP data.
    
    Sponsored by:   NVIDIA Networking
    
    (cherry picked from commit 0ee1b09eaa99ed96885fd024a32baf182411a35a)
---
 sys/dev/mlx5/fs.h                     |  1 +
 sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c | 35 ++++++++++++++++++++++++-----------
 2 files changed, 25 insertions(+), 11 deletions(-)

diff --git a/sys/dev/mlx5/fs.h b/sys/dev/mlx5/fs.h
index fc7a6f429fd0..e5ec897fd9f1 100644
--- a/sys/dev/mlx5/fs.h
+++ b/sys/dev/mlx5/fs.h
@@ -54,6 +54,7 @@ enum {
 
 enum mlx5_flow_namespace_type {
 	MLX5_FLOW_NAMESPACE_BYPASS,
+	MLX5_FLOW_NAMESPACE_OFFLOADS,
 	MLX5_FLOW_NAMESPACE_KERNEL,
 	MLX5_FLOW_NAMESPACE_LEFTOVERS,
 	MLX5_FLOW_NAMESPACE_SNIFFER_RX,
diff --git a/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c b/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c
index 860c2331f03a..5305991689ca 100644
--- a/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c
+++ b/sys/dev/mlx5/mlx5_core/mlx5_fs_tree.c
@@ -1,5 +1,5 @@
 /*-
- * Copyright (c) 2013-2017, Mellanox Technologies, Ltd.  All rights reserved.
+ * Copyright (c) 2013-2021, Mellanox Technologies, Ltd.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -67,13 +67,19 @@
 #define FS_REQUIRED_CAPS(...) {.arr_sz = INIT_CAPS_ARRAY_SIZE(__VA_ARGS__), \
 			       .caps = (long[]) {__VA_ARGS__}}
 
-#define BYPASS_MAX_FT 5
-#define BYPASS_PRIO_MAX_FT 1
-#define KERNEL_MAX_FT 5
-#define LEFTOVER_MAX_FT 1
-#define KERNEL_MIN_LEVEL 3
-#define LEFTOVER_MIN_LEVEL KERNEL_MIN_LEVEL + 1
-#define BYPASS_MIN_LEVEL MLX5_NUM_BYPASS_FTS + LEFTOVER_MIN_LEVEL
+/* Flowtable sizes: */
+#define	BYPASS_MAX_FT 5
+#define	BYPASS_PRIO_MAX_FT 1
+#define	OFFLOADS_MAX_FT 2
+#define	KERNEL_MAX_FT 5
+#define	LEFTOVER_MAX_FT 1
+
+/* Flowtable levels: */
+#define	OFFLOADS_MIN_LEVEL 3
+#define	KERNEL_MIN_LEVEL (OFFLOADS_MIN_LEVEL + 1)
+#define	LEFTOVER_MIN_LEVEL (KERNEL_MIN_LEVEL + 1)
+#define	BYPASS_MIN_LEVEL (MLX5_NUM_BYPASS_FTS + LEFTOVER_MIN_LEVEL)
+
 struct node_caps {
 	size_t	arr_sz;
 	long	*caps;
@@ -92,7 +98,7 @@ struct init_tree_node {
 } root_fs = {
 	.type = FS_TYPE_NAMESPACE,
 	.name = "root",
-	.ar_size = 3,
+	.ar_size = 4,
 	.children = (struct init_tree_node[]) {
 		ADD_PRIO("by_pass_prio", 0, BYPASS_MIN_LEVEL, 0,
 			 FS_REQUIRED_CAPS(FS_CAP(flow_table_properties_nic_receive.flow_modify_en),
@@ -116,6 +122,10 @@ struct init_tree_node {
 					    BYPASS_PRIO_MAX_FT),
 				ADD_FT_PRIO("prio-mcast", 0,
 					    BYPASS_PRIO_MAX_FT))),
+		ADD_PRIO("offloads_prio", 0, OFFLOADS_MIN_LEVEL, 0, {},
+			 ADD_NS("offloads_ns",
+				ADD_FT_PRIO("prio_offloads-0", 0,
+					    OFFLOADS_MAX_FT))),
 		ADD_PRIO("kernel_prio", 0, KERNEL_MIN_LEVEL, 0, {},
 			 ADD_NS("kernel_ns",
 				ADD_FT_PRIO("prio_kernel-0", 0,
@@ -2375,12 +2385,15 @@ struct mlx5_flow_namespace *mlx5_get_flow_namespace(struct mlx5_core_dev *dev,
 	case MLX5_FLOW_NAMESPACE_BYPASS:
 		prio = 0;
 		break;
-	case MLX5_FLOW_NAMESPACE_KERNEL:
+	case MLX5_FLOW_NAMESPACE_OFFLOADS:
 		prio = 1;
 		break;
-	case MLX5_FLOW_NAMESPACE_LEFTOVERS:
+	case MLX5_FLOW_NAMESPACE_KERNEL:
 		prio = 2;
 		break;
+	case MLX5_FLOW_NAMESPACE_LEFTOVERS:
+		prio = 3;
+		break;
 	case MLX5_FLOW_NAMESPACE_FDB:
 		if (dev->fdb_root_ns)
 			return &dev->fdb_root_ns->ns;