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 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 #else /* CONFIG_ICE_SWITCHDEV */
29 static inline void ice_eswitch_release(struct ice_pf *pf) { }
30 
31 static inline void ice_eswitch_stop_all_tx_queues(struct ice_pf *pf) { }
32 
33 static inline void
34 ice_eswitch_set_target_vsi(struct sk_buff *skb,
35 			   struct ice_tx_offload_params *off) { }
36 
37 static inline void ice_eswitch_update_repr(struct ice_vsi *vsi) { }
38 
39 static inline int ice_eswitch_configure(struct ice_pf *pf)
40 {
41 	return 0;
42 }
43 
44 static inline int ice_eswitch_rebuild(struct ice_pf *pf)
45 {
46 	return -EOPNOTSUPP;
47 }
48 
49 static inline int ice_eswitch_mode_get(struct devlink *devlink, u16 *mode)
50 {
51 	return DEVLINK_ESWITCH_MODE_LEGACY;
52 }
53 
54 static inline int
55 ice_eswitch_mode_set(struct devlink *devlink, u16 mode,
56 		     struct netlink_ext_ack *extack)
57 {
58 	return -EOPNOTSUPP;
59 }
60 
61 static inline bool ice_is_eswitch_mode_switchdev(struct ice_pf *pf)
62 {
63 	return false;
64 }
65 
66 static inline netdev_tx_t
67 ice_eswitch_port_start_xmit(struct sk_buff *skb, struct net_device *netdev)
68 {
69 	return NETDEV_TX_BUSY;
70 }
71 #endif /* CONFIG_ICE_SWITCHDEV */
72 #endif /* _ICE_ESWITCH_H_ */
73