xref: /linux/drivers/net/ethernet/intel/ice/ice_lag.h (revision 8e07e0e3964ca4e23ce7b68e2096fe660a888942)
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 lport_recipe;
43 	u16 pf_rule_id;
44 	u16 cp_rule_idx;
45 	u16 lport_rule_idx;
46 	u8 role;
47 };
48 
49 /* LAG workqueue struct */
50 struct ice_lag_work {
51 	struct work_struct lag_task;
52 	struct ice_lag_netdev_list netdev_list;
53 	struct ice_lag *lag;
54 	unsigned long event;
55 	struct net_device *event_netdev;
56 	union {
57 		struct netdev_notifier_changeupper_info changeupper_info;
58 		struct netdev_notifier_bonding_info bonding_info;
59 		struct netdev_notifier_info notifier_info;
60 	} info;
61 };
62 
63 void ice_lag_move_new_vf_nodes(struct ice_vf *vf);
64 int ice_init_lag(struct ice_pf *pf);
65 void ice_deinit_lag(struct ice_pf *pf);
66 void ice_lag_rebuild(struct ice_pf *pf);
67 bool ice_lag_is_switchdev_running(struct ice_pf *pf);
68 void ice_lag_move_vf_nodes_cfg(struct ice_lag *lag, u8 src_prt, u8 dst_prt);
69 #endif /* _ICE_LAG_H_ */
70