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