xref: /linux/drivers/net/ethernet/intel/ice/ice_lag.h (revision 7a7c52645ce62314cdd69815e9d8fcb33e0042d5)
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 #define ICE_LAGP_IDX			0
19 #define ICE_LAGS_IDX			1
20 #define ICE_LAGP_M			0x1
21 #define ICE_LAGS_M			0x2
22 
23 #define ICE_LAG_RESET_RETRIES		5
24 #define ICE_SW_DEFAULT_PROFILE		0
25 #define ICE_FV_PROT_MDID		255
26 #define ICE_LP_EXT_BUF_OFFSET		32
27 
28 struct ice_pf;
29 struct ice_vf;
30 
31 struct ice_lag_netdev_list {
32 	struct list_head node;
33 	struct net_device *netdev;
34 };
35 
36 /* LAG info struct */
37 struct ice_lag {
38 	struct ice_pf *pf; /* backlink to PF struct */
39 	struct net_device *netdev; /* this PF's netdev */
40 	struct net_device *upper_netdev; /* upper bonding netdev */
41 	struct list_head *netdev_head;
42 	struct notifier_block notif_block;
43 	s32 bond_mode;
44 	u16 bond_swid; /* swid for primary interface */
45 	u8 active_port; /* lport value for the current active port */
46 	u8 bonded:1; /* currently bonded */
47 	u8 primary:1; /* this is primary */
48 	u8 bond_aa:1; /* is this bond active-active */
49 	u8 need_fltr_cfg:1; /* fltrs for A/A bond still need to be make */
50 	u8 port_bitmap:2; /* bitmap of active ports */
51 	u8 bond_lport_pri; /* lport values for primary PF */
52 	u8 bond_lport_sec; /* lport values for secondary PF */
53 
54 	/* q_home keeps track of which interface the q is currently on */
55 	u8 q_home[ICE_MAX_SRIOV_VFS][ICE_MAX_RSS_QS_PER_VF];
56 
57 	/* placeholder VSI for hanging VF queues from on secondary interface */
58 	struct ice_vsi *sec_vf[ICE_MAX_SRIOV_VFS];
59 
60 	u16 pf_recipe;
61 	u16 lport_recipe;
62 	u16 act_act_recipe;
63 	u16 pf_rx_rule_id;
64 	u16 pf_tx_rule_id;
65 	u16 cp_rule_idx;
66 	u16 lport_rule_idx;
67 	u16 act_act_rule_idx;
68 	u8 role;
69 };
70 
71 /* LAG workqueue struct */
72 struct ice_lag_work {
73 	struct work_struct lag_task;
74 	struct ice_lag_netdev_list netdev_list;
75 	struct ice_lag *lag;
76 	unsigned long event;
77 	struct net_device *event_netdev;
78 	union {
79 		struct netdev_notifier_changeupper_info changeupper_info;
80 		struct netdev_notifier_bonding_info bonding_info;
81 		struct netdev_notifier_info notifier_info;
82 	} info;
83 };
84 
85 void ice_lag_move_new_vf_nodes(struct ice_vf *vf);
86 void ice_lag_aa_failover(struct ice_lag *lag, u8 dest, struct ice_pf *e_pf);
87 int ice_init_lag(struct ice_pf *pf);
88 void ice_deinit_lag(struct ice_pf *pf);
89 void ice_lag_rebuild(struct ice_pf *pf);
90 bool ice_lag_is_switchdev_running(struct ice_pf *pf);
91 void ice_lag_move_vf_nodes_cfg(struct ice_lag *lag, u8 src_prt, u8 dst_prt);
92 u8 ice_lag_prepare_vf_reset(struct ice_lag *lag);
93 void ice_lag_complete_vf_reset(struct ice_lag *lag, u8 act_prt);
94 #endif /* _ICE_LAG_H_ */
95