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 <xuemi...@mellanox.com>
---
 drivers/net/mlx5/mlx5_flow.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 27183d5..5e5184b 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
@@ -1215,6 +1224,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;
 
@@ -1234,13 +1244,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;
 
@@ -1253,8 +1270,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;
 
@@ -1298,7 +1314,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)
-- 
1.8.3.1

Reply via email to