xref: /linux/drivers/net/ethernet/intel/ice/ice_lag.h (revision 4adfc94d4aeca1177e1188ba83c20ed581523fe1)
1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (C) 2018-2021, Intel Corporation. */
3 
4 #ifndef _ICE_LAG_H_
5 #define _ICE_LAG_H_
6 
7 #include <linux/netdevice.h>
8 
9 /* LAG roles for netdev */
10 enum ice_lag_role {
11 	ICE_LAG_NONE,
12 	ICE_LAG_PRIMARY,
13 	ICE_LAG_BACKUP,
14 	ICE_LAG_UNSET
15 };
16 
17 #define ICE_LAG_INVALID_PORT 0xFF
18 
19 #define ICE_LAG_RESET_RETRIES		5
20 #define ICE_SW_DEFAULT_PROFILE		0
21 #define ICE_FV_PROT_MDID		255
22 #define ICE_LP_EXT_BUF_OFFSET		32
23 
24 struct ice_pf;
25 struct ice_vf;
26 
27 struct ice_lag_netdev_list {
28 	struct list_head node;
29 	struct net_device *netdev;
30 };
31 
32 /* LAG info struct */
33 struct ice_lag {
34 	struct ice_pf *pf; /* backlink to PF struct */
35 	struct net_device *netdev; /* this PF's netdev */
36 	struct net_device *upper_netdev; /* upper bonding netdev */
37 	struct list_head *netdev_head;
38 	struct notifier_block notif_block;
39 	s32 bond_mode;
40 	u16 bond_swid; /* swid for primary interface */
41 	u8 active_port; /* lport value for the current active port */
42 	u8 bonded:1; /* currently bonded */
43 	u8 primary:1; /* this is primary */
44 	u16 pf_recipe;
45 	u16 lport_recipe;
46 	u16 pf_rule_id;
47 	u16 cp_rule_idx;
48 	u16 lport_rule_idx;
49 	u8 role;
50 };
51 
52 /* LAG workqueue struct */
53 struct ice_lag_work {
54 	struct work_struct lag_task;
55 	struct ice_lag_netdev_list netdev_list;
56 	struct ice_lag *lag;
57 	unsigned long event;
58 	struct net_device *event_netdev;
59 	union {
60 		struct netdev_notifier_changeupper_info changeupper_info;
61 		struct netdev_notifier_bonding_info bonding_info;
62 		struct netdev_notifier_info notifier_info;
63 	} info;
64 };
65 
66 void ice_lag_move_new_vf_nodes(struct ice_vf *vf);
67 int ice_init_lag(struct ice_pf *pf);
68 void ice_deinit_lag(struct ice_pf *pf);
69 void ice_lag_rebuild(struct ice_pf *pf);
70 bool ice_lag_is_switchdev_running(struct ice_pf *pf);
71 void ice_lag_move_vf_nodes_cfg(struct ice_lag *lag, u8 src_prt, u8 dst_prt);
72 #endif /* _ICE_LAG_H_ */
73