• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
2 /* Copyright (c) 2019 Mellanox Technologies. */
3 
4 #ifndef __MLX5_LAG_H__
5 #define __MLX5_LAG_H__
6 
7 #include "mlx5_core.h"
8 #include "lag_mp.h"
9 
10 enum {
11 	MLX5_LAG_P1,
12 	MLX5_LAG_P2,
13 };
14 
15 enum {
16 	MLX5_LAG_FLAG_ROCE   = 1 << 0,
17 	MLX5_LAG_FLAG_SRIOV  = 1 << 1,
18 	MLX5_LAG_FLAG_MULTIPATH = 1 << 2,
19 	MLX5_LAG_FLAG_READY = 1 << 3,
20 };
21 
22 #define MLX5_LAG_MODE_FLAGS (MLX5_LAG_FLAG_ROCE | MLX5_LAG_FLAG_SRIOV |\
23 			     MLX5_LAG_FLAG_MULTIPATH)
24 
25 struct lag_func {
26 	struct mlx5_core_dev *dev;
27 	struct net_device    *netdev;
28 };
29 
30 /* Used for collection of netdev event info. */
31 struct lag_tracker {
32 	enum   netdev_lag_tx_type           tx_type;
33 	struct netdev_lag_lower_state_info  netdev_state[MLX5_MAX_PORTS];
34 	unsigned int is_bonded:1;
35 };
36 
37 /* LAG data of a ConnectX card.
38  * It serves both its phys functions.
39  */
40 struct mlx5_lag {
41 	u8                        flags;
42 	u8                        v2p_map[MLX5_MAX_PORTS];
43 	struct lag_func           pf[MLX5_MAX_PORTS];
44 	struct lag_tracker        tracker;
45 	struct workqueue_struct   *wq;
46 	struct delayed_work       bond_work;
47 	struct notifier_block     nb;
48 	struct lag_mp             lag_mp;
49 };
50 
51 static inline struct mlx5_lag *
mlx5_lag_dev_get(struct mlx5_core_dev * dev)52 mlx5_lag_dev_get(struct mlx5_core_dev *dev)
53 {
54 	return dev->priv.lag;
55 }
56 
57 static inline bool
__mlx5_lag_is_active(struct mlx5_lag * ldev)58 __mlx5_lag_is_active(struct mlx5_lag *ldev)
59 {
60 	return !!(ldev->flags & MLX5_LAG_MODE_FLAGS);
61 }
62 
63 static inline bool
mlx5_lag_is_ready(struct mlx5_lag * ldev)64 mlx5_lag_is_ready(struct mlx5_lag *ldev)
65 {
66 	return ldev->flags & MLX5_LAG_FLAG_READY;
67 }
68 
69 void mlx5_modify_lag(struct mlx5_lag *ldev,
70 		     struct lag_tracker *tracker);
71 int mlx5_activate_lag(struct mlx5_lag *ldev,
72 		      struct lag_tracker *tracker,
73 		      u8 flags);
74 int mlx5_lag_dev_get_netdev_idx(struct mlx5_lag *ldev,
75 				struct net_device *ndev);
76 
77 #endif /* __MLX5_LAG_H__ */
78