1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* Copyright (C) 2019-2021, Intel Corporation. */ 3 4 #ifndef _ICE_ESWITCH_H_ 5 #define _ICE_ESWITCH_H_ 6 7 #include <net/devlink.h> 8 9 #ifdef CONFIG_ICE_SWITCHDEV 10 void ice_eswitch_release(struct ice_pf *pf); 11 int ice_eswitch_configure(struct ice_pf *pf); 12 int ice_eswitch_rebuild(struct ice_pf *pf); 13 14 int ice_eswitch_mode_get(struct devlink *devlink, u16 *mode); 15 int 16 ice_eswitch_mode_set(struct devlink *devlink, u16 mode, 17 struct netlink_ext_ack *extack); 18 bool ice_is_eswitch_mode_switchdev(struct ice_pf *pf); 19 20 void ice_eswitch_update_repr(struct ice_vsi *vsi); 21 22 void ice_eswitch_stop_all_tx_queues(struct ice_pf *pf); 23 24 struct net_device * 25 ice_eswitch_get_target_netdev(struct ice_rx_ring *rx_ring, 26 union ice_32b_rx_flex_desc *rx_desc); 27 28 void ice_eswitch_set_target_vsi(struct sk_buff *skb, 29 struct ice_tx_offload_params *off); 30 netdev_tx_t 31 ice_eswitch_port_start_xmit(struct sk_buff *skb, struct net_device *netdev); 32 #else /* CONFIG_ICE_SWITCHDEV */ 33 static inline void ice_eswitch_release(struct ice_pf *pf) { } 34 35 static inline void ice_eswitch_stop_all_tx_queues(struct ice_pf *pf) { } 36 37 static inline void 38 ice_eswitch_set_target_vsi(struct sk_buff *skb, 39 struct ice_tx_offload_params *off) { } 40 41 static inline void ice_eswitch_update_repr(struct ice_vsi *vsi) { } 42 43 static inline int ice_eswitch_configure(struct ice_pf *pf) 44 { 45 return -EOPNOTSUPP; 46 } 47 48 static inline int ice_eswitch_rebuild(struct ice_pf *pf) 49 { 50 return -EOPNOTSUPP; 51 } 52 53 static inline int ice_eswitch_mode_get(struct devlink *devlink, u16 *mode) 54 { 55 return DEVLINK_ESWITCH_MODE_LEGACY; 56 } 57 58 static inline int 59 ice_eswitch_mode_set(struct devlink *devlink, u16 mode, 60 struct netlink_ext_ack *extack) 61 { 62 return -EOPNOTSUPP; 63 } 64 65 static inline bool ice_is_eswitch_mode_switchdev(struct ice_pf *pf) 66 { 67 return false; 68 } 69 70 static inline struct net_device * 71 ice_eswitch_get_target_netdev(struct ice_rx_ring *rx_ring, 72 union ice_32b_rx_flex_desc *rx_desc) 73 { 74 return rx_ring->netdev; 75 } 76 77 static inline netdev_tx_t 78 ice_eswitch_port_start_xmit(struct sk_buff *skb, struct net_device *netdev) 79 { 80 return NETDEV_TX_BUSY; 81 } 82 #endif /* CONFIG_ICE_SWITCHDEV */ 83 #endif /* _ICE_ESWITCH_H_ */ 84