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 
21 struct ice_pf;
22 struct ice_vf;
23 
24 struct ice_lag_netdev_list {
25 	struct list_head node;
26 	struct net_device *netdev;
27 };
28 
29 /* LAG info struct */
30 struct ice_lag {
31 	struct ice_pf *pf; /* backlink to PF struct */
32 	struct net_device *netdev; /* this PF's netdev */
33 	struct net_device *upper_netdev; /* upper bonding netdev */
34 	struct list_head *netdev_head;
35 	struct notifier_block notif_block;
36 	s32 bond_mode;
37 	u16 bond_swid; /* swid for primary interface */
38 	u8 active_port; /* lport value for the current active port */
39 	u8 bonded:1; /* currently bonded */
40 	u8 primary:1; /* this is primary */
41 	u16 pf_recipe;
42 	u16 pf_rule_id;
43 	u16 cp_rule_idx;
44 	u8 role;
45 };
46 
47 /* LAG workqueue struct */
48 struct ice_lag_work {
49 	struct work_struct lag_task;
50 	struct ice_lag_netdev_list netdev_list;
51 	struct ice_lag *lag;
52 	unsigned long event;
53 	struct net_device *event_netdev;
54 	union {
55 		struct netdev_notifier_changeupper_info changeupper_info;
56 		struct netdev_notifier_bonding_info bonding_info;
57 		struct netdev_notifier_info notifier_info;
58 	} info;
59 };
60 
61 void ice_lag_move_new_vf_nodes(struct ice_vf *vf);
62 int ice_init_lag(struct ice_pf *pf);
63 void ice_deinit_lag(struct ice_pf *pf);
64 void ice_lag_rebuild(struct ice_pf *pf);
65 #endif /* _ICE_LAG_H_ */
66