net/mlx5: fix RSS expansion traversal over next nodes
authorLior Margalit <lmargalit@nvidia.com>
Sun, 5 Sep 2021 09:35:58 +0000 (12:35 +0300)
committerRaslan Darawsheh <rasland@nvidia.com>
Mon, 13 Sep 2021 19:56:10 +0000 (21:56 +0200)
The RSS expansion is based on DFS algorithm to traverse over the possible
expansion paths.

The current implementation breaks out, if it reaches the terminator of
the "next nodes" array, instead of going backwards to try the next path.
For example:
testpmd> flow create 0 ingress pattern eth / ipv6 / udp / vxlan / end
actions rss level 2 types tcp end / end
The paths found are:
ETH IPV6 UDP VXLAN END
ETH IPV6 UDP VXLAN ETH IPV4 TCP END
ETH IPV6 UDP VXLAN ETH IPV6 TCP END
The traversal stopped after getting to the terminator of the next nodes
of the ETH node. It missed the rest of the nodes in the next nodes array
of the VXLAN node.

The fix is to go backwards when reaching the terminator of the current
level and find if there is a "next node" to start traversing a new path.
Using the above example, the flows will be:
ETH IPV6 UDP VXLAN END
ETH IPV6 UDP VXLAN ETH IPV4 TCP END
ETH IPV6 UDP VXLAN ETH IPV6 TCP END
ETH IPV6 UDP VXLAN IPV4 TCP END
ETH IPV6 UDP VXLAN IPV6 TCP END
The traversal will find additional paths, because it traverses through
all the next nodes array of the VXLAN node.

Fixes: 4ed05fcd441b ("ethdev: add flow API to expand RSS flows")
Cc: stable@dpdk.org
Signed-off-by: Lior Margalit <lmargalit@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
drivers/net/mlx5/mlx5_flow.c

index 6cf1bb8..c914a71 100644 (file)
@@ -460,12 +460,22 @@ mlx5_flow_expand_rss(struct mlx5_flow_expand_rss *buf, size_t size,
                        /* Follow up with the next possibility. */
                        next_node = mlx5_flow_expand_rss_skip_explicit(graph,
                                        ++next_node);
+               } else if (!stack_pos) {
+                       /*
+                        * Completing the traverse over the different paths.
+                        * The next_node is advanced to the terminator.
+                        */
+                       ++next_node;
                } else {
                        /* Move to the next path. */
-                       if (stack_pos)
+                       while (stack_pos) {
                                next_node = stack[--stack_pos];
+                               next_node++;
+                               if (*next_node)
+                                       break;
+                       }
                        next_node = mlx5_flow_expand_rss_skip_explicit(graph,
-                                       ++next_node);
+                                       next_node);
                        stack[stack_pos] = next_node;
                }
                node = next_node && *next_node ? &graph[*next_node] : NULL;