[dpdk-dev,13/18] net/mlx5: support 16 hardware priorities

Message ID 20180226150947.107179-14-xuemingl@mellanox.com (mailing list archive)
State Superseded, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Xueming Li Feb. 26, 2018, 3:09 p.m. UTC
  Since OFED 4.3-0.1.3.0, new driver support 16 Verbs priorities, adjust
RTE FLOW priority mapping to:
0-3: RTE FLOW tunnel rule
4-7: RTE FLOW non-tunnel rule
8-15: PMD default control flow

Signed-off-by: Xueming Li <xuemingl@mellanox.com>
---
 drivers/net/mlx5/mlx5_flow.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)
  

Patch

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 1e9e3d6..f01c90f 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -28,7 +28,16 @@ 
 #include "mlx5_glue.h"
 
 /* Define minimal priority for control plane flows. */
+#ifdef HAVE_IBV_DEVICE_TUNNEL_SUPPORT
+/* 16 verb priorities since OFED 4.3, control flow start from 8. */
+#define MLX5_CTRL_FLOW_PRIORITY 8
+#else
+/* 8 Verb priorities before OFED4.3, control flow start from 4. */
 #define MLX5_CTRL_FLOW_PRIORITY 4
+#endif
+
+/* Define verb priority span for each flow. */
+#define MLX5_FLOW_PRIORITY_SPAN 4
 
 /* Internet Protocol versions. */
 #define MLX5_IPV4 4
@@ -1216,6 +1225,7 @@  struct ibv_spec_header {
 		  struct mlx5_flow_parse *parser)
 {
 	const struct mlx5_flow_items *cur_item = mlx5_flow_items;
+	unsigned int priority_shift = attr->priority;
 	unsigned int i;
 	int ret;
 
@@ -1235,13 +1245,20 @@  struct ibv_spec_header {
 	if (ret)
 		return ret;
 	priv_flow_convert_finalise(priv, parser);
+#ifdef HAVE_IBV_DEVICE_TUNNEL_SUPPORT
+	/*
+	 * 16 priorities since OFED4.3, tunnel rules use highest priority 0-3,
+	 * other user-flows use 4-7, control flows use lowest start from 8.
+	 */
+	if (!parser->tunnel)
+		priority_shift += MLX5_FLOW_PRIORITY_SPAN;
+#endif
 	/*
 	 * Second step.
 	 * Allocate the memory space to store verbs specifications.
 	 */
 	if (parser->drop) {
-		unsigned int priority =
-			attr->priority +
+		unsigned int priority = priority_shift +
 			hash_rxq_init[HASH_RXQ_ETH].flow_priority;
 		unsigned int offset = parser->queue[HASH_RXQ_ETH].offset;
 
@@ -1254,8 +1271,7 @@  struct ibv_spec_header {
 			sizeof(struct ibv_flow_attr);
 	} else {
 		for (i = 0; i != hash_rxq_init_n; ++i) {
-			unsigned int priority =
-				attr->priority +
+			unsigned int priority = priority_shift +
 				hash_rxq_init[i].flow_priority;
 			unsigned int offset;
 
@@ -1299,7 +1315,7 @@  struct ibv_spec_header {
 		priv_flow_convert_finalise(priv, parser);
 	} else {
 		parser->queue[HASH_RXQ_ETH].ibv_attr->priority =
-			attr->priority +
+			priority_shift +
 			hash_rxq_init[parser->layer].flow_priority;
 	}
 	if (parser->mark)