xref: /linux/drivers/net/ethernet/intel/ice/ice_eswitch.h (revision 9410645520e9b820069761f3450ef6661418e279)
13ea9bd5dSMichal Swiatkowski /* SPDX-License-Identifier: GPL-2.0 */
23ea9bd5dSMichal Swiatkowski /* Copyright (C) 2019-2021, Intel Corporation. */
33ea9bd5dSMichal Swiatkowski 
43ea9bd5dSMichal Swiatkowski #ifndef _ICE_ESWITCH_H_
53ea9bd5dSMichal Swiatkowski #define _ICE_ESWITCH_H_
63ea9bd5dSMichal Swiatkowski 
73ea9bd5dSMichal Swiatkowski #include <net/devlink.h>
8415db839SMichal Swiatkowski #include "devlink/devlink_port.h"
93ea9bd5dSMichal Swiatkowski 
103ea9bd5dSMichal Swiatkowski #ifdef CONFIG_ICE_SWITCHDEV
11415db839SMichal Swiatkowski void ice_eswitch_detach_vf(struct ice_pf *pf, struct ice_vf *vf);
12*977514fbSMichal Swiatkowski void ice_eswitch_detach_sf(struct ice_pf *pf, struct ice_dynamic_port *sf);
13415db839SMichal Swiatkowski int ice_eswitch_attach_vf(struct ice_pf *pf, struct ice_vf *vf);
14*977514fbSMichal Swiatkowski int ice_eswitch_attach_sf(struct ice_pf *pf, struct ice_dynamic_port *sf);
151a1c40dfSGrzegorz Nitka 
163ea9bd5dSMichal Swiatkowski int ice_eswitch_mode_get(struct devlink *devlink, u16 *mode);
173ea9bd5dSMichal Swiatkowski int
183ea9bd5dSMichal Swiatkowski ice_eswitch_mode_set(struct devlink *devlink, u16 mode,
193ea9bd5dSMichal Swiatkowski 		     struct netlink_ext_ack *extack);
203ea9bd5dSMichal Swiatkowski bool ice_is_eswitch_mode_switchdev(struct ice_pf *pf);
211c54c839SGrzegorz Nitka 
22fff5cca3SMichal Swiatkowski void ice_eswitch_update_repr(unsigned long *repr_id, struct ice_vsi *vsi);
23b3be918dSGrzegorz Nitka 
24b3be918dSGrzegorz Nitka void ice_eswitch_stop_all_tx_queues(struct ice_pf *pf);
25f5396b8aSGrzegorz Nitka 
26f5396b8aSGrzegorz Nitka void ice_eswitch_set_target_vsi(struct sk_buff *skb,
27f5396b8aSGrzegorz Nitka 				struct ice_tx_offload_params *off);
28f5396b8aSGrzegorz Nitka netdev_tx_t
29f5396b8aSGrzegorz Nitka ice_eswitch_port_start_xmit(struct sk_buff *skb, struct net_device *netdev);
3044ba608dSMichal Swiatkowski struct net_device *ice_eswitch_get_target(struct ice_rx_ring *rx_ring,
3144ba608dSMichal Swiatkowski 					  union ice_32b_rx_flex_desc *rx_desc);
324d364df2SMichal Swiatkowski 
334d364df2SMichal Swiatkowski int ice_eswitch_cfg_vsi(struct ice_vsi *vsi, const u8 *mac);
344d364df2SMichal Swiatkowski void ice_eswitch_decfg_vsi(struct ice_vsi *vsi, const u8 *mac);
353ea9bd5dSMichal Swiatkowski #else /* CONFIG_ICE_SWITCHDEV */
36415db839SMichal Swiatkowski static inline void
ice_eswitch_detach_vf(struct ice_pf * pf,struct ice_vf * vf)37415db839SMichal Swiatkowski ice_eswitch_detach_vf(struct ice_pf *pf, struct ice_vf *vf) { }
38fff292b4SMichal Swiatkowski 
39*977514fbSMichal Swiatkowski static inline void
ice_eswitch_detach_sf(struct ice_pf * pf,struct ice_dynamic_port * sf)40*977514fbSMichal Swiatkowski ice_eswitch_detach_sf(struct ice_pf *pf, struct ice_dynamic_port *sf) { }
41*977514fbSMichal Swiatkowski 
42fff292b4SMichal Swiatkowski static inline int
ice_eswitch_attach_vf(struct ice_pf * pf,struct ice_vf * vf)43415db839SMichal Swiatkowski ice_eswitch_attach_vf(struct ice_pf *pf, struct ice_vf *vf)
44fff292b4SMichal Swiatkowski {
45fff292b4SMichal Swiatkowski 	return -EOPNOTSUPP;
46fff292b4SMichal Swiatkowski }
471a1c40dfSGrzegorz Nitka 
48*977514fbSMichal Swiatkowski static inline int
ice_eswitch_attach_sf(struct ice_pf * pf,struct ice_dynamic_port * sf)49*977514fbSMichal Swiatkowski ice_eswitch_attach_sf(struct ice_pf *pf, struct ice_dynamic_port *sf)
50*977514fbSMichal Swiatkowski {
51*977514fbSMichal Swiatkowski 	return -EOPNOTSUPP;
52*977514fbSMichal Swiatkowski }
53*977514fbSMichal Swiatkowski 
ice_eswitch_stop_all_tx_queues(struct ice_pf * pf)54b3be918dSGrzegorz Nitka static inline void ice_eswitch_stop_all_tx_queues(struct ice_pf *pf) { }
55b3be918dSGrzegorz Nitka 
56f5396b8aSGrzegorz Nitka static inline void
ice_eswitch_set_target_vsi(struct sk_buff * skb,struct ice_tx_offload_params * off)57f5396b8aSGrzegorz Nitka ice_eswitch_set_target_vsi(struct sk_buff *skb,
58f5396b8aSGrzegorz Nitka 			   struct ice_tx_offload_params *off) { }
59f5396b8aSGrzegorz Nitka 
60e4c46abcSMichal Swiatkowski static inline void
ice_eswitch_update_repr(unsigned long * repr_id,struct ice_vsi * vsi)61fff5cca3SMichal Swiatkowski ice_eswitch_update_repr(unsigned long *repr_id, struct ice_vsi *vsi) { }
621c54c839SGrzegorz Nitka 
ice_eswitch_configure(struct ice_pf * pf)631a1c40dfSGrzegorz Nitka static inline int ice_eswitch_configure(struct ice_pf *pf)
641a1c40dfSGrzegorz Nitka {
65aacca7a8SMaciej Fijalkowski 	return 0;
661a1c40dfSGrzegorz Nitka }
671a1c40dfSGrzegorz Nitka 
ice_eswitch_mode_get(struct devlink * devlink,u16 * mode)681a1c40dfSGrzegorz Nitka static inline int ice_eswitch_mode_get(struct devlink *devlink, u16 *mode)
693ea9bd5dSMichal Swiatkowski {
703ea9bd5dSMichal Swiatkowski 	return DEVLINK_ESWITCH_MODE_LEGACY;
713ea9bd5dSMichal Swiatkowski }
723ea9bd5dSMichal Swiatkowski 
733ea9bd5dSMichal Swiatkowski static inline int
ice_eswitch_mode_set(struct devlink * devlink,u16 mode,struct netlink_ext_ack * extack)743ea9bd5dSMichal Swiatkowski ice_eswitch_mode_set(struct devlink *devlink, u16 mode,
753ea9bd5dSMichal Swiatkowski 		     struct netlink_ext_ack *extack)
763ea9bd5dSMichal Swiatkowski {
773ea9bd5dSMichal Swiatkowski 	return -EOPNOTSUPP;
783ea9bd5dSMichal Swiatkowski }
793ea9bd5dSMichal Swiatkowski 
ice_is_eswitch_mode_switchdev(struct ice_pf * pf)801a1c40dfSGrzegorz Nitka static inline bool ice_is_eswitch_mode_switchdev(struct ice_pf *pf)
813ea9bd5dSMichal Swiatkowski {
823ea9bd5dSMichal Swiatkowski 	return false;
833ea9bd5dSMichal Swiatkowski }
84f5396b8aSGrzegorz Nitka 
85f5396b8aSGrzegorz Nitka static inline netdev_tx_t
ice_eswitch_port_start_xmit(struct sk_buff * skb,struct net_device * netdev)86f5396b8aSGrzegorz Nitka ice_eswitch_port_start_xmit(struct sk_buff *skb, struct net_device *netdev)
87f5396b8aSGrzegorz Nitka {
88f5396b8aSGrzegorz Nitka 	return NETDEV_TX_BUSY;
89f5396b8aSGrzegorz Nitka }
9044ba608dSMichal Swiatkowski 
9144ba608dSMichal Swiatkowski static inline struct net_device *
ice_eswitch_get_target(struct ice_rx_ring * rx_ring,union ice_32b_rx_flex_desc * rx_desc)9244ba608dSMichal Swiatkowski ice_eswitch_get_target(struct ice_rx_ring *rx_ring,
9344ba608dSMichal Swiatkowski 		       union ice_32b_rx_flex_desc *rx_desc)
9444ba608dSMichal Swiatkowski {
9544ba608dSMichal Swiatkowski 	return rx_ring->netdev;
9644ba608dSMichal Swiatkowski }
974d364df2SMichal Swiatkowski 
ice_eswitch_cfg_vsi(struct ice_vsi * vsi,const u8 * mac)984d364df2SMichal Swiatkowski static inline int ice_eswitch_cfg_vsi(struct ice_vsi *vsi, const u8 *mac)
994d364df2SMichal Swiatkowski {
1004d364df2SMichal Swiatkowski 	return -EOPNOTSUPP;
1014d364df2SMichal Swiatkowski }
1024d364df2SMichal Swiatkowski 
ice_eswitch_decfg_vsi(struct ice_vsi * vsi,const u8 * mac)1034d364df2SMichal Swiatkowski static inline void ice_eswitch_decfg_vsi(struct ice_vsi *vsi, const u8 *mac) { }
1043ea9bd5dSMichal Swiatkowski #endif /* CONFIG_ICE_SWITCHDEV */
1053ea9bd5dSMichal Swiatkowski #endif /* _ICE_ESWITCH_H_ */
106