0001
0002
0003
0004 #ifndef _ICE_LAG_H_
0005 #define _ICE_LAG_H_
0006
0007 #include <linux/netdevice.h>
0008
0009
0010 enum ice_lag_role {
0011 ICE_LAG_NONE,
0012 ICE_LAG_PRIMARY,
0013 ICE_LAG_BACKUP,
0014 ICE_LAG_UNSET
0015 };
0016
0017 struct ice_pf;
0018
0019
0020 struct ice_lag {
0021 struct ice_pf *pf;
0022 struct net_device *netdev;
0023 struct net_device *peer_netdev;
0024 struct net_device *upper_netdev;
0025 struct notifier_block notif_block;
0026 u8 bonded:1;
0027 u8 master:1;
0028 u8 handler:1;
0029
0030
0031
0032 u16 dis_lag;
0033 u8 role;
0034 };
0035
0036 int ice_init_lag(struct ice_pf *pf);
0037 void ice_deinit_lag(struct ice_pf *pf);
0038 rx_handler_result_t ice_lag_nop_handler(struct sk_buff **pskb);
0039
0040
0041
0042
0043
0044 static inline void ice_disable_lag(struct ice_lag *lag)
0045 {
0046
0047 rtnl_lock();
0048 if (!netdev_is_rx_handler_busy(lag->netdev)) {
0049 if (!netdev_rx_handler_register(lag->netdev,
0050 ice_lag_nop_handler,
0051 NULL))
0052 lag->handler = true;
0053 }
0054 rtnl_unlock();
0055 lag->dis_lag++;
0056 }
0057
0058
0059
0060
0061
0062
0063
0064
0065 static inline void ice_enable_lag(struct ice_lag *lag)
0066 {
0067 if (lag->dis_lag)
0068 lag->dis_lag--;
0069 if (!lag->dis_lag && lag->handler) {
0070 rtnl_lock();
0071 netdev_rx_handler_unregister(lag->netdev);
0072 rtnl_unlock();
0073 lag->handler = false;
0074 }
0075 }
0076
0077
0078
0079
0080
0081
0082
0083 static inline bool ice_is_lag_dis(struct ice_lag *lag)
0084 {
0085 return !!(lag->dis_lag);
0086 }
0087 #endif