Commit 1cdc14e9 authored by Erez Alfasi's avatar Erez Alfasi Committed by Saeed Mahameed

net/mlx5: LAG, Use affinity type enumerators

Instead of using explicit indexes, simply use affinity
type enumerators to make the code more readable.

Fixes: 544fe7c2 ("net/mlx5e: Activate HW multipath and handle port affinity based on FIB events")
Signed-off-by: default avatarErez Alfasi <ereza@mellanox.com>
Signed-off-by: default avatarSaeed Mahameed <saeedm@mellanox.com>
parent 84d2dbb0
...@@ -44,7 +44,8 @@ bool mlx5_lag_is_multipath(struct mlx5_core_dev *dev) ...@@ -44,7 +44,8 @@ bool mlx5_lag_is_multipath(struct mlx5_core_dev *dev)
* 2 - set affinity to port 2. * 2 - set affinity to port 2.
* *
**/ **/
static void mlx5_lag_set_port_affinity(struct mlx5_lag *ldev, int port) static void mlx5_lag_set_port_affinity(struct mlx5_lag *ldev,
enum mlx5_lag_port_affinity port)
{ {
struct lag_tracker tracker; struct lag_tracker tracker;
...@@ -52,19 +53,19 @@ static void mlx5_lag_set_port_affinity(struct mlx5_lag *ldev, int port) ...@@ -52,19 +53,19 @@ static void mlx5_lag_set_port_affinity(struct mlx5_lag *ldev, int port)
return; return;
switch (port) { switch (port) {
case 0: case MLX5_LAG_NORMAL_AFFINITY:
tracker.netdev_state[MLX5_LAG_P1].tx_enabled = true; tracker.netdev_state[MLX5_LAG_P1].tx_enabled = true;
tracker.netdev_state[MLX5_LAG_P2].tx_enabled = true; tracker.netdev_state[MLX5_LAG_P2].tx_enabled = true;
tracker.netdev_state[MLX5_LAG_P1].link_up = true; tracker.netdev_state[MLX5_LAG_P1].link_up = true;
tracker.netdev_state[MLX5_LAG_P2].link_up = true; tracker.netdev_state[MLX5_LAG_P2].link_up = true;
break; break;
case 1: case MLX5_LAG_P1_AFFINITY:
tracker.netdev_state[MLX5_LAG_P1].tx_enabled = true; tracker.netdev_state[MLX5_LAG_P1].tx_enabled = true;
tracker.netdev_state[MLX5_LAG_P1].link_up = true; tracker.netdev_state[MLX5_LAG_P1].link_up = true;
tracker.netdev_state[MLX5_LAG_P2].tx_enabled = false; tracker.netdev_state[MLX5_LAG_P2].tx_enabled = false;
tracker.netdev_state[MLX5_LAG_P2].link_up = false; tracker.netdev_state[MLX5_LAG_P2].link_up = false;
break; break;
case 2: case MLX5_LAG_P2_AFFINITY:
tracker.netdev_state[MLX5_LAG_P1].tx_enabled = false; tracker.netdev_state[MLX5_LAG_P1].tx_enabled = false;
tracker.netdev_state[MLX5_LAG_P1].link_up = false; tracker.netdev_state[MLX5_LAG_P1].link_up = false;
tracker.netdev_state[MLX5_LAG_P2].tx_enabled = true; tracker.netdev_state[MLX5_LAG_P2].tx_enabled = true;
...@@ -159,7 +160,7 @@ static void mlx5_lag_fib_route_event(struct mlx5_lag *ldev, ...@@ -159,7 +160,7 @@ static void mlx5_lag_fib_route_event(struct mlx5_lag *ldev,
mlx5_activate_lag(ldev, &tracker, MLX5_LAG_FLAG_MULTIPATH); mlx5_activate_lag(ldev, &tracker, MLX5_LAG_FLAG_MULTIPATH);
} }
mlx5_lag_set_port_affinity(ldev, 0); mlx5_lag_set_port_affinity(ldev, MLX5_LAG_NORMAL_AFFINITY);
mp->mfi = fi; mp->mfi = fi;
} }
...@@ -184,7 +185,7 @@ static void mlx5_lag_fib_nexthop_event(struct mlx5_lag *ldev, ...@@ -184,7 +185,7 @@ static void mlx5_lag_fib_nexthop_event(struct mlx5_lag *ldev,
} }
} else if (event == FIB_EVENT_NH_ADD && } else if (event == FIB_EVENT_NH_ADD &&
fib_info_num_path(fi) == 2) { fib_info_num_path(fi) == 2) {
mlx5_lag_set_port_affinity(ldev, 0); mlx5_lag_set_port_affinity(ldev, MLX5_LAG_NORMAL_AFFINITY);
} }
} }
......
...@@ -7,6 +7,12 @@ ...@@ -7,6 +7,12 @@
#include "lag.h" #include "lag.h"
#include "mlx5_core.h" #include "mlx5_core.h"
enum mlx5_lag_port_affinity {
MLX5_LAG_NORMAL_AFFINITY,
MLX5_LAG_P1_AFFINITY,
MLX5_LAG_P2_AFFINITY,
};
struct lag_mp { struct lag_mp {
struct notifier_block fib_nb; struct notifier_block fib_nb;
struct fib_info *mfi; /* used in tracking fib events */ struct fib_info *mfi; /* used in tracking fib events */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment