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