]> Git Repo - J-linux.git/blob - drivers/net/ethernet/mellanox/mlx5/core/lag.h
Merge remote-tracking branch 'spi/for-5.14' into spi-linus
[J-linux.git] / drivers / net / ethernet / mellanox / mlx5 / core / lag.h
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 kref               ref;
44         struct lag_func           pf[MLX5_MAX_PORTS];
45         struct lag_tracker        tracker;
46         struct workqueue_struct   *wq;
47         struct delayed_work       bond_work;
48         struct notifier_block     nb;
49         struct lag_mp             lag_mp;
50 };
51
52 static inline struct mlx5_lag *
53 mlx5_lag_dev(struct mlx5_core_dev *dev)
54 {
55         return dev->priv.lag;
56 }
57
58 static inline bool
59 __mlx5_lag_is_active(struct mlx5_lag *ldev)
60 {
61         return !!(ldev->flags & MLX5_LAG_MODE_FLAGS);
62 }
63
64 static inline bool
65 mlx5_lag_is_ready(struct mlx5_lag *ldev)
66 {
67         return ldev->flags & MLX5_LAG_FLAG_READY;
68 }
69
70 void mlx5_modify_lag(struct mlx5_lag *ldev,
71                      struct lag_tracker *tracker);
72 int mlx5_activate_lag(struct mlx5_lag *ldev,
73                       struct lag_tracker *tracker,
74                       u8 flags);
75 int mlx5_lag_dev_get_netdev_idx(struct mlx5_lag *ldev,
76                                 struct net_device *ndev);
77
78 #endif /* __MLX5_LAG_H__ */
This page took 0.048518 seconds and 4 git commands to generate.