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_detach(struct ice_pf *pf, struct ice_vf *vf); 11 int 12 ice_eswitch_attach(struct ice_pf *pf, struct ice_vf *vf); 13 void ice_eswitch_rebuild(struct ice_pf *pf); 14 15 int ice_eswitch_mode_get(struct devlink *devlink, u16 *mode); 16 int 17 ice_eswitch_mode_set(struct devlink *devlink, u16 mode, 18 struct netlink_ext_ack *extack); 19 bool ice_is_eswitch_mode_switchdev(struct ice_pf *pf); 20 21 void ice_eswitch_update_repr(unsigned long repr_id, struct ice_vsi *vsi); 22 23 void ice_eswitch_stop_all_tx_queues(struct ice_pf *pf); 24 25 void ice_eswitch_set_target_vsi(struct sk_buff *skb, 26 struct ice_tx_offload_params *off); 27 netdev_tx_t 28 ice_eswitch_port_start_xmit(struct sk_buff *skb, struct net_device *netdev); 29 struct net_device *ice_eswitch_get_target(struct ice_rx_ring *rx_ring, 30 union ice_32b_rx_flex_desc *rx_desc); 31 #else /* CONFIG_ICE_SWITCHDEV */ 32 static inline void ice_eswitch_detach(struct ice_pf *pf, struct ice_vf *vf) { } 33 34 static inline int 35 ice_eswitch_attach(struct ice_pf *pf, struct ice_vf *vf) 36 { 37 return -EOPNOTSUPP; 38 } 39 40 static inline void ice_eswitch_stop_all_tx_queues(struct ice_pf *pf) { } 41 42 static inline void 43 ice_eswitch_set_target_vsi(struct sk_buff *skb, 44 struct ice_tx_offload_params *off) { } 45 46 static inline void 47 ice_eswitch_update_repr(unsigned long repr_id, struct ice_vsi *vsi) { } 48 49 static inline int ice_eswitch_configure(struct ice_pf *pf) 50 { 51 return 0; 52 } 53 54 static inline int ice_eswitch_rebuild(struct ice_pf *pf) 55 { 56 return -EOPNOTSUPP; 57 } 58 59 static inline int ice_eswitch_mode_get(struct devlink *devlink, u16 *mode) 60 { 61 return DEVLINK_ESWITCH_MODE_LEGACY; 62 } 63 64 static inline int 65 ice_eswitch_mode_set(struct devlink *devlink, u16 mode, 66 struct netlink_ext_ack *extack) 67 { 68 return -EOPNOTSUPP; 69 } 70 71 static inline bool ice_is_eswitch_mode_switchdev(struct ice_pf *pf) 72 { 73 return false; 74 } 75 76 static inline netdev_tx_t 77 ice_eswitch_port_start_xmit(struct sk_buff *skb, struct net_device *netdev) 78 { 79 return NETDEV_TX_BUSY; 80 } 81 82 static inline struct net_device * 83 ice_eswitch_get_target(struct ice_rx_ring *rx_ring, 84 union ice_32b_rx_flex_desc *rx_desc) 85 { 86 return rx_ring->netdev; 87 } 88 #endif /* CONFIG_ICE_SWITCHDEV */ 89 #endif /* _ICE_ESWITCH_H_ */ 90