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