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