// SPDX-License-Identifier: GPL-2.0 /* Copyright (C) 2019-2021, Intel Corporation. */ #include "ice.h" #include "ice_lib.h" #include "ice_eswitch.h" #include "ice_eswitch_br.h" #include "ice_fltr.h" #include "ice_repr.h" #include "devlink/devlink.h" #include "ice_tc_lib.h" /** * ice_eswitch_setup_env - configure eswitch HW filters * @pf: pointer to PF struct * * This function adds HW filters configuration specific for switchdev * mode. */ static int ice_eswitch_setup_env(struct ice_pf *pf) { … } /** * ice_eswitch_release_repr - clear PR VSI configuration * @pf: poiner to PF struct * @repr: pointer to PR */ static void ice_eswitch_release_repr(struct ice_pf *pf, struct ice_repr *repr) { … } /** * ice_eswitch_setup_repr - configure PR to run in switchdev mode * @pf: pointer to PF struct * @repr: pointer to PR struct */ static int ice_eswitch_setup_repr(struct ice_pf *pf, struct ice_repr *repr) { … } /** * ice_eswitch_cfg_vsi - configure VSI to work in slow-path * @vsi: VSI structure of representee * @mac: representee MAC * * Return: 0 on success, non-zero on error. */ int ice_eswitch_cfg_vsi(struct ice_vsi *vsi, const u8 *mac) { … } /** * ice_eswitch_decfg_vsi - unroll changes done to VSI for switchdev * @vsi: VSI structure of representee * @mac: representee MAC */ void ice_eswitch_decfg_vsi(struct ice_vsi *vsi, const u8 *mac) { … } /** * ice_eswitch_update_repr - reconfigure port representor * @repr_id: representor ID * @vsi: VSI for which port representor is configured */ void ice_eswitch_update_repr(unsigned long *repr_id, struct ice_vsi *vsi) { … } /** * ice_eswitch_port_start_xmit - callback for packets transmit * @skb: send buffer * @netdev: network interface device structure * * Returns NETDEV_TX_OK if sent, else an error code */ netdev_tx_t ice_eswitch_port_start_xmit(struct sk_buff *skb, struct net_device *netdev) { … } /** * ice_eswitch_set_target_vsi - set eswitch context in Tx context descriptor * @skb: pointer to send buffer * @off: pointer to offload struct */ void ice_eswitch_set_target_vsi(struct sk_buff *skb, struct ice_tx_offload_params *off) { … } /** * ice_eswitch_release_env - clear eswitch HW filters * @pf: pointer to PF struct * * This function removes HW filters configuration specific for switchdev * mode and restores default legacy mode settings. */ static void ice_eswitch_release_env(struct ice_pf *pf) { … } /** * ice_eswitch_enable_switchdev - configure eswitch in switchdev mode * @pf: pointer to PF structure */ static int ice_eswitch_enable_switchdev(struct ice_pf *pf) { … } /** * ice_eswitch_disable_switchdev - disable eswitch resources * @pf: pointer to PF structure */ static void ice_eswitch_disable_switchdev(struct ice_pf *pf) { … } /** * ice_eswitch_mode_set - set new eswitch mode * @devlink: pointer to devlink structure * @mode: eswitch mode to switch to * @extack: pointer to extack structure */ int ice_eswitch_mode_set(struct devlink *devlink, u16 mode, struct netlink_ext_ack *extack) { … } /** * ice_eswitch_mode_get - get current eswitch mode * @devlink: pointer to devlink structure * @mode: output parameter for current eswitch mode */ int ice_eswitch_mode_get(struct devlink *devlink, u16 *mode) { … } /** * ice_is_eswitch_mode_switchdev - check if eswitch mode is set to switchdev * @pf: pointer to PF structure * * Returns true if eswitch mode is set to DEVLINK_ESWITCH_MODE_SWITCHDEV, * false otherwise. */ bool ice_is_eswitch_mode_switchdev(struct ice_pf *pf) { … } /** * ice_eswitch_start_all_tx_queues - start Tx queues of all port representors * @pf: pointer to PF structure */ static void ice_eswitch_start_all_tx_queues(struct ice_pf *pf) { … } /** * ice_eswitch_stop_all_tx_queues - stop Tx queues of all port representors * @pf: pointer to PF structure */ void ice_eswitch_stop_all_tx_queues(struct ice_pf *pf) { … } static void ice_eswitch_stop_reprs(struct ice_pf *pf) { … } static void ice_eswitch_start_reprs(struct ice_pf *pf) { … } static int ice_eswitch_attach(struct ice_pf *pf, struct ice_repr *repr, unsigned long *id) { … } /** * ice_eswitch_attach_vf - attach VF to a eswitch * @pf: pointer to PF structure * @vf: pointer to VF structure to be attached * * During attaching port representor for VF is created. * * Return: zero on success or an error code on failure. */ int ice_eswitch_attach_vf(struct ice_pf *pf, struct ice_vf *vf) { … } /** * ice_eswitch_attach_sf - attach SF to a eswitch * @pf: pointer to PF structure * @sf: pointer to SF structure to be attached * * During attaching port representor for SF is created. * * Return: zero on success or an error code on failure. */ int ice_eswitch_attach_sf(struct ice_pf *pf, struct ice_dynamic_port *sf) { … } static void ice_eswitch_detach(struct ice_pf *pf, struct ice_repr *repr) { … } /** * ice_eswitch_detach_vf - detach VF from a eswitch * @pf: pointer to PF structure * @vf: pointer to VF structure to be detached */ void ice_eswitch_detach_vf(struct ice_pf *pf, struct ice_vf *vf) { … } /** * ice_eswitch_detach_sf - detach SF from a eswitch * @pf: pointer to PF structure * @sf: pointer to SF structure to be detached */ void ice_eswitch_detach_sf(struct ice_pf *pf, struct ice_dynamic_port *sf) { … } /** * ice_eswitch_get_target - get netdev based on src_vsi from descriptor * @rx_ring: ring used to receive the packet * @rx_desc: descriptor used to get src_vsi value * * Get src_vsi value from descriptor and load correct representor. If it isn't * found return rx_ring->netdev. */ struct net_device *ice_eswitch_get_target(struct ice_rx_ring *rx_ring, union ice_32b_rx_flex_desc *rx_desc) { … }