net/mlx5: fix tunnel flow priority
authorGregory Etelson <getelson@mellanox.com>
Thu, 16 Jul 2020 07:39:58 +0000 (10:39 +0300)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 21 Jul 2020 13:46:30 +0000 (15:46 +0200)
PMD flow priority is different from application flow priority.  Flow
rules with higher match granularity assigned higher PMD priority. Also
PMD splits internally RSS flows according to flow RSS layer.

Final PMD flow rule priority derived from the last match item network
level, after PMD adjusts flow rule, where L4 match gets the highest
priority and L2 the lowest.

The patch adjusts tunnels flow rule priority calculation for PMDs
running verb API.

Introduce MLX5_TUNNEL_PRIO_GET macro.

Fixes: 4a78c88e3bae ("net/mlx5: fix Verbs flow tunnel")
Cc: stable@dpdk.org
Signed-off-by: Gregory Etelson <getelson@mellanox.com>
Acked-by: Matan Azrad <matan@mellanox.com>
Acked-by: Ori Kam <orika@mellanox.com>
drivers/net/mlx5/mlx5_flow.h
drivers/net/mlx5/mlx5_flow_dv.c
drivers/net/mlx5/mlx5_flow_verbs.c

index 73cfa6e..66caefc 100644 (file)
@@ -510,6 +510,10 @@ struct mlx5_flow_rss_desc {
        uint16_t queue[]; /**< Destination queues to redirect traffic to. */
 };
 
+/* PMD flow priority for tunnel */
+#define MLX5_TUNNEL_PRIO_GET(rss_desc) \
+       ((rss_desc)->level >= 2 ? MLX5_PRIORITY_MAP_L2 : MLX5_PRIORITY_MAP_L4)
+
 
 /** Device flow handle structure for DV mode only. */
 struct mlx5_flow_handle_dv {
index 12c7db7..f0cc7ad 100644 (file)
@@ -8604,8 +8604,7 @@ __flow_dv_translate(struct rte_eth_dev *dev,
                case RTE_FLOW_ITEM_TYPE_GRE:
                        flow_dv_translate_item_gre(match_mask, match_value,
                                                   items, tunnel);
-                       matcher.priority = rss_desc->level >= 2 ?
-                                   MLX5_PRIORITY_MAP_L2 : MLX5_PRIORITY_MAP_L4;
+                       matcher.priority = MLX5_TUNNEL_PRIO_GET(rss_desc);
                        last_item = MLX5_FLOW_LAYER_GRE;
                        break;
                case RTE_FLOW_ITEM_TYPE_GRE_KEY:
@@ -8616,37 +8615,32 @@ __flow_dv_translate(struct rte_eth_dev *dev,
                case RTE_FLOW_ITEM_TYPE_NVGRE:
                        flow_dv_translate_item_nvgre(match_mask, match_value,
                                                     items, tunnel);
-                       matcher.priority = rss_desc->level >= 2 ?
-                                   MLX5_PRIORITY_MAP_L2 : MLX5_PRIORITY_MAP_L4;
+                       matcher.priority = MLX5_TUNNEL_PRIO_GET(rss_desc);
                        last_item = MLX5_FLOW_LAYER_GRE;
                        break;
                case RTE_FLOW_ITEM_TYPE_VXLAN:
                        flow_dv_translate_item_vxlan(match_mask, match_value,
                                                     items, tunnel);
-                       matcher.priority = rss_desc->level >= 2 ?
-                                   MLX5_PRIORITY_MAP_L2 : MLX5_PRIORITY_MAP_L4;
+                       matcher.priority = MLX5_TUNNEL_PRIO_GET(rss_desc);
                        last_item = MLX5_FLOW_LAYER_VXLAN;
                        break;
                case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
                        flow_dv_translate_item_vxlan_gpe(match_mask,
                                                         match_value, items,
                                                         tunnel);
-                       matcher.priority = rss_desc->level >= 2 ?
-                                   MLX5_PRIORITY_MAP_L2 : MLX5_PRIORITY_MAP_L4;
+                       matcher.priority = MLX5_TUNNEL_PRIO_GET(rss_desc);
                        last_item = MLX5_FLOW_LAYER_VXLAN_GPE;
                        break;
                case RTE_FLOW_ITEM_TYPE_GENEVE:
                        flow_dv_translate_item_geneve(match_mask, match_value,
                                                      items, tunnel);
-                       matcher.priority = rss_desc->level >= 2 ?
-                                   MLX5_PRIORITY_MAP_L2 : MLX5_PRIORITY_MAP_L4;
+                       matcher.priority = MLX5_TUNNEL_PRIO_GET(rss_desc);
                        last_item = MLX5_FLOW_LAYER_GENEVE;
                        break;
                case RTE_FLOW_ITEM_TYPE_MPLS:
                        flow_dv_translate_item_mpls(match_mask, match_value,
                                                    items, last_item, tunnel);
-                       matcher.priority = rss_desc->level >= 2 ?
-                                   MLX5_PRIORITY_MAP_L2 : MLX5_PRIORITY_MAP_L4;
+                       matcher.priority = MLX5_TUNNEL_PRIO_GET(rss_desc);
                        last_item = MLX5_FLOW_LAYER_MPLS;
                        break;
                case RTE_FLOW_ITEM_TYPE_MARK:
@@ -8688,8 +8682,7 @@ __flow_dv_translate(struct rte_eth_dev *dev,
                case RTE_FLOW_ITEM_TYPE_GTP:
                        flow_dv_translate_item_gtp(match_mask, match_value,
                                                   items, tunnel);
-                       matcher.priority = rss_desc->level >= 2 ?
-                                   MLX5_PRIORITY_MAP_L2 : MLX5_PRIORITY_MAP_L4;
+                       matcher.priority = MLX5_TUNNEL_PRIO_GET(rss_desc);
                        last_item = MLX5_FLOW_LAYER_GTP;
                        break;
                case RTE_FLOW_ITEM_TYPE_ECPRI:
index 905a122..334e19b 100644 (file)
@@ -1827,25 +1827,25 @@ flow_verbs_translate(struct rte_eth_dev *dev,
                case RTE_FLOW_ITEM_TYPE_VXLAN:
                        flow_verbs_translate_item_vxlan(dev_flow, items,
                                                        item_flags);
-                       subpriority = MLX5_PRIORITY_MAP_L2;
+                       subpriority = MLX5_TUNNEL_PRIO_GET(rss_desc);
                        item_flags |= MLX5_FLOW_LAYER_VXLAN;
                        break;
                case RTE_FLOW_ITEM_TYPE_VXLAN_GPE:
                        flow_verbs_translate_item_vxlan_gpe(dev_flow, items,
                                                            item_flags);
-                       subpriority = MLX5_PRIORITY_MAP_L2;
+                       subpriority = MLX5_TUNNEL_PRIO_GET(rss_desc);
                        item_flags |= MLX5_FLOW_LAYER_VXLAN_GPE;
                        break;
                case RTE_FLOW_ITEM_TYPE_GRE:
                        flow_verbs_translate_item_gre(dev_flow, items,
                                                      item_flags);
-                       subpriority = MLX5_PRIORITY_MAP_L2;
+                       subpriority = MLX5_TUNNEL_PRIO_GET(rss_desc);
                        item_flags |= MLX5_FLOW_LAYER_GRE;
                        break;
                case RTE_FLOW_ITEM_TYPE_MPLS:
                        flow_verbs_translate_item_mpls(dev_flow, items,
                                                       item_flags);
-                       subpriority = MLX5_PRIORITY_MAP_L2;
+                       subpriority = MLX5_TUNNEL_PRIO_GET(rss_desc);
                        item_flags |= MLX5_FLOW_LAYER_MPLS;
                        break;
                default: