net/mlx5: fix port action assert timing
authorBing Zhao <bingz@mellanox.com>
Fri, 15 May 2020 11:44:43 +0000 (19:44 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 18 May 2020 18:35:57 +0000 (20:35 +0200)
After memory optimization, some action object handles are changed to
index to save the overhead. Assertion in debug mode will be helpful
for trouble shooting.
In the current implementation, only one port action is supported in
switchdev mode for one device flow. In debug mode, an assertion will
be used to check the if the port action is none, and it should
locate before the port action resource registration but not after
it. The action index in the handle should be 0 before registration.
Or else it will always cause a failure because the port action is
registered and the index is not 0.

Fixes: f3faf9ea1185 ("net/mlx5: convert port id action to indexed")

Signed-off-by: Bing Zhao <bingz@mellanox.com>
Reviewed-by: Matan Azrad <matan@mellanox.com>
Reviewed-by: Suanming Mou <suanmingm@mellanox.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
drivers/net/mlx5/mlx5_flow_dv.c

index deb4469..6f58032 100644 (file)
@@ -7834,10 +7834,10 @@ __flow_dv_translate(struct rte_eth_dev *dev,
                                return -rte_errno;
                        memset(&port_id_resource, 0, sizeof(port_id_resource));
                        port_id_resource.port_id = port_id;
+                       MLX5_ASSERT(!handle->rix_port_id_action);
                        if (flow_dv_port_id_action_resource_register
                            (dev, &port_id_resource, dev_flow, error))
                                return -rte_errno;
-                       MLX5_ASSERT(!handle->rix_port_id_action);
                        dev_flow->dv.actions[actions_n++] =
                                        dev_flow->dv.port_id_action->action;
                        action_flags |= MLX5_FLOW_ACTION_PORT_ID;