1df006dd4SDave Ertman /* SPDX-License-Identifier: GPL-2.0 */ 2df006dd4SDave Ertman /* Copyright (C) 2018-2021, Intel Corporation. */ 3df006dd4SDave Ertman 4df006dd4SDave Ertman #ifndef _ICE_LAG_H_ 5df006dd4SDave Ertman #define _ICE_LAG_H_ 6df006dd4SDave Ertman 7df006dd4SDave Ertman #include <linux/netdevice.h> 8df006dd4SDave Ertman 9df006dd4SDave Ertman /* LAG roles for netdev */ 10df006dd4SDave Ertman enum ice_lag_role { 11df006dd4SDave Ertman ICE_LAG_NONE, 12df006dd4SDave Ertman ICE_LAG_PRIMARY, 13df006dd4SDave Ertman ICE_LAG_BACKUP, 14df006dd4SDave Ertman ICE_LAG_UNSET 15df006dd4SDave Ertman }; 16df006dd4SDave Ertman 1741ccedf5SDave Ertman #define ICE_LAG_INVALID_PORT 0xFF 1841ccedf5SDave Ertman 193579aa86SDave Ertman #define ICE_LAG_RESET_RETRIES 5 203579aa86SDave Ertman 21df006dd4SDave Ertman struct ice_pf; 2241ccedf5SDave Ertman struct ice_vf; 2341ccedf5SDave Ertman 2441ccedf5SDave Ertman struct ice_lag_netdev_list { 2541ccedf5SDave Ertman struct list_head node; 2641ccedf5SDave Ertman struct net_device *netdev; 2741ccedf5SDave Ertman }; 28df006dd4SDave Ertman 29df006dd4SDave Ertman /* LAG info struct */ 30df006dd4SDave Ertman struct ice_lag { 31df006dd4SDave Ertman struct ice_pf *pf; /* backlink to PF struct */ 32df006dd4SDave Ertman struct net_device *netdev; /* this PF's netdev */ 33df006dd4SDave Ertman struct net_device *upper_netdev; /* upper bonding netdev */ 3441ccedf5SDave Ertman struct list_head *netdev_head; 35df006dd4SDave Ertman struct notifier_block notif_block; 3641ccedf5SDave Ertman s32 bond_mode; 3741ccedf5SDave Ertman u16 bond_swid; /* swid for primary interface */ 3841ccedf5SDave Ertman u8 active_port; /* lport value for the current active port */ 39df006dd4SDave Ertman u8 bonded:1; /* currently bonded */ 405c603001SMikael Barsehyan u8 primary:1; /* this is primary */ 4141ccedf5SDave Ertman u16 pf_recipe; 4241ccedf5SDave Ertman u16 pf_rule_id; 4341ccedf5SDave Ertman u16 cp_rule_idx; 44df006dd4SDave Ertman u8 role; 45df006dd4SDave Ertman }; 46df006dd4SDave Ertman 4741ccedf5SDave Ertman /* LAG workqueue struct */ 4841ccedf5SDave Ertman struct ice_lag_work { 4941ccedf5SDave Ertman struct work_struct lag_task; 5041ccedf5SDave Ertman struct ice_lag_netdev_list netdev_list; 5141ccedf5SDave Ertman struct ice_lag *lag; 5241ccedf5SDave Ertman unsigned long event; 5341ccedf5SDave Ertman struct net_device *event_netdev; 5441ccedf5SDave Ertman union { 5541ccedf5SDave Ertman struct netdev_notifier_changeupper_info changeupper_info; 5641ccedf5SDave Ertman struct netdev_notifier_bonding_info bonding_info; 5741ccedf5SDave Ertman struct netdev_notifier_info notifier_info; 5841ccedf5SDave Ertman } info; 5941ccedf5SDave Ertman }; 6041ccedf5SDave Ertman 61ec5a6c5fSDave Ertman void ice_lag_move_new_vf_nodes(struct ice_vf *vf); 62df006dd4SDave Ertman int ice_init_lag(struct ice_pf *pf); 63df006dd4SDave Ertman void ice_deinit_lag(struct ice_pf *pf); 643579aa86SDave Ertman void ice_lag_rebuild(struct ice_pf *pf); 65776fe199SMichal Swiatkowski bool ice_lag_is_switchdev_running(struct ice_pf *pf); 66*fd7f7a8aSDave Ertman void ice_lag_move_vf_nodes_cfg(struct ice_lag *lag, u8 src_prt, u8 dst_prt); 67df006dd4SDave Ertman #endif /* _ICE_LAG_H_ */ 68