// SPDX-License-Identifier: GPL-2.0 /* Copyright (C) 2019-2021, Intel Corporation. */ #include "ice_vsi_vlan_lib.h" #include "ice_lib.h" #include "ice_fltr.h" #include "ice.h" static void print_invalid_tpid(struct ice_vsi *vsi, u16 tpid) { … } /** * validate_vlan - check if the ice_vlan passed in is valid * @vsi: VSI used for printing error message * @vlan: ice_vlan structure to validate * * Return true if the VLAN TPID is valid or if the VLAN TPID is 0 and the VLAN * VID is 0, which allows for non-zero VLAN filters with the specified VLAN TPID * and untagged VLAN 0 filters to be added to the prune list respectively. */ static bool validate_vlan(struct ice_vsi *vsi, struct ice_vlan *vlan) { … } /** * ice_vsi_add_vlan - default add VLAN implementation for all VSI types * @vsi: VSI being configured * @vlan: VLAN filter to add */ int ice_vsi_add_vlan(struct ice_vsi *vsi, struct ice_vlan *vlan) { … } /** * ice_vsi_del_vlan - default del VLAN implementation for all VSI types * @vsi: VSI being configured * @vlan: VLAN filter to delete */ int ice_vsi_del_vlan(struct ice_vsi *vsi, struct ice_vlan *vlan) { … } /** * ice_vsi_manage_vlan_insertion - Manage VLAN insertion for the VSI for Tx * @vsi: the VSI being changed */ static int ice_vsi_manage_vlan_insertion(struct ice_vsi *vsi) { … } /** * ice_vsi_manage_vlan_stripping - Manage VLAN stripping for the VSI for Rx * @vsi: the VSI being changed * @ena: boolean value indicating if this is a enable or disable request */ static int ice_vsi_manage_vlan_stripping(struct ice_vsi *vsi, bool ena) { … } int ice_vsi_ena_inner_stripping(struct ice_vsi *vsi, const u16 tpid) { … } int ice_vsi_dis_inner_stripping(struct ice_vsi *vsi) { … } int ice_vsi_ena_inner_insertion(struct ice_vsi *vsi, const u16 tpid) { … } int ice_vsi_dis_inner_insertion(struct ice_vsi *vsi) { … } static void ice_save_vlan_info(struct ice_aqc_vsi_props *info, struct ice_vsi_vlan_info *vlan) { … } static void ice_restore_vlan_info(struct ice_aqc_vsi_props *info, struct ice_vsi_vlan_info *vlan) { … } /** * __ice_vsi_set_inner_port_vlan - set port VLAN VSI context settings to enable a port VLAN * @vsi: the VSI to update * @pvid_info: VLAN ID and QoS used to set the PVID VSI context field */ static int __ice_vsi_set_inner_port_vlan(struct ice_vsi *vsi, u16 pvid_info) { … } int ice_vsi_set_inner_port_vlan(struct ice_vsi *vsi, struct ice_vlan *vlan) { … } int ice_vsi_clear_inner_port_vlan(struct ice_vsi *vsi) { … } /** * ice_cfg_vlan_pruning - enable or disable VLAN pruning on the VSI * @vsi: VSI to enable or disable VLAN pruning on * @ena: set to true to enable VLAN pruning and false to disable it * * returns 0 if VSI is updated, negative otherwise */ static int ice_cfg_vlan_pruning(struct ice_vsi *vsi, bool ena) { … } int ice_vsi_ena_rx_vlan_filtering(struct ice_vsi *vsi) { … } int ice_vsi_dis_rx_vlan_filtering(struct ice_vsi *vsi) { … } static int ice_cfg_vlan_antispoof(struct ice_vsi *vsi, bool enable) { … } int ice_vsi_ena_tx_vlan_filtering(struct ice_vsi *vsi) { … } int ice_vsi_dis_tx_vlan_filtering(struct ice_vsi *vsi) { … } /** * tpid_to_vsi_outer_vlan_type - convert from TPID to VSI context based tag_type * @tpid: tpid used to translate into VSI context based tag_type * @tag_type: output variable to hold the VSI context based tag type */ static int tpid_to_vsi_outer_vlan_type(u16 tpid, u8 *tag_type) { … } /** * ice_vsi_ena_outer_stripping - enable outer VLAN stripping * @vsi: VSI to configure * @tpid: TPID to enable outer VLAN stripping for * * Enable outer VLAN stripping via VSI context. This function should only be * used if DVM is supported. Also, this function should never be called directly * as it should be part of ice_vsi_vlan_ops if it's needed. * * Since the VSI context only supports a single TPID for insertion and * stripping, setting the TPID for stripping will affect the TPID for insertion. * Callers need to be aware of this limitation. * * Only modify outer VLAN stripping settings and the VLAN TPID. Outer VLAN * insertion settings are unmodified. * * This enables hardware to strip a VLAN tag with the specified TPID to be * stripped from the packet and placed in the receive descriptor. */ int ice_vsi_ena_outer_stripping(struct ice_vsi *vsi, u16 tpid) { … } /** * ice_vsi_dis_outer_stripping - disable outer VLAN stripping * @vsi: VSI to configure * * Disable outer VLAN stripping via VSI context. This function should only be * used if DVM is supported. Also, this function should never be called directly * as it should be part of ice_vsi_vlan_ops if it's needed. * * Only modify the outer VLAN stripping settings. The VLAN TPID and outer VLAN * insertion settings are unmodified. * * This tells the hardware to not strip any VLAN tagged packets, thus leaving * them in the packet. This enables software offloaded VLAN stripping and * disables hardware offloaded VLAN stripping. */ int ice_vsi_dis_outer_stripping(struct ice_vsi *vsi) { … } /** * ice_vsi_ena_outer_insertion - enable outer VLAN insertion * @vsi: VSI to configure * @tpid: TPID to enable outer VLAN insertion for * * Enable outer VLAN insertion via VSI context. This function should only be * used if DVM is supported. Also, this function should never be called directly * as it should be part of ice_vsi_vlan_ops if it's needed. * * Since the VSI context only supports a single TPID for insertion and * stripping, setting the TPID for insertion will affect the TPID for stripping. * Callers need to be aware of this limitation. * * Only modify outer VLAN insertion settings and the VLAN TPID. Outer VLAN * stripping settings are unmodified. * * This allows a VLAN tag with the specified TPID to be inserted in the transmit * descriptor. */ int ice_vsi_ena_outer_insertion(struct ice_vsi *vsi, u16 tpid) { … } /** * ice_vsi_dis_outer_insertion - disable outer VLAN insertion * @vsi: VSI to configure * * Disable outer VLAN insertion via VSI context. This function should only be * used if DVM is supported. Also, this function should never be called directly * as it should be part of ice_vsi_vlan_ops if it's needed. * * Only modify the outer VLAN insertion settings. The VLAN TPID and outer VLAN * settings are unmodified. * * This tells the hardware to not allow any VLAN tagged packets in the transmit * descriptor. This enables software offloaded VLAN insertion and disables * hardware offloaded VLAN insertion. */ int ice_vsi_dis_outer_insertion(struct ice_vsi *vsi) { … } /** * __ice_vsi_set_outer_port_vlan - set the outer port VLAN and related settings * @vsi: VSI to configure * @vlan_info: packed u16 that contains the VLAN prio and ID * @tpid: TPID of the port VLAN * * Set the port VLAN prio, ID, and TPID. * * Enable VLAN pruning so the VSI doesn't receive any traffic that doesn't match * a VLAN prune rule. The caller should take care to add a VLAN prune rule that * matches the port VLAN ID and TPID. * * Tell hardware to strip outer VLAN tagged packets on receive and don't put * them in the receive descriptor. VSI(s) in port VLANs should not be aware of * the port VLAN ID or TPID they are assigned to. * * Tell hardware to prevent outer VLAN tag insertion on transmit and only allow * untagged outer packets from the transmit descriptor. * * Also, tell the hardware to insert the port VLAN on transmit. */ static int __ice_vsi_set_outer_port_vlan(struct ice_vsi *vsi, u16 vlan_info, u16 tpid) { … } /** * ice_vsi_set_outer_port_vlan - public version of __ice_vsi_set_outer_port_vlan * @vsi: VSI to configure * @vlan: ice_vlan structure used to set the port VLAN * * Set the outer port VLAN via VSI context. This function should only be * used if DVM is supported. Also, this function should never be called directly * as it should be part of ice_vsi_vlan_ops if it's needed. * * Use the ice_vlan structure passed in to set this VSI in a port VLAN. */ int ice_vsi_set_outer_port_vlan(struct ice_vsi *vsi, struct ice_vlan *vlan) { … } /** * ice_vsi_clear_outer_port_vlan - clear outer port vlan * @vsi: VSI to configure * * The function is restoring previously set vlan config (saved in * vsi->vlan_info). Setting happens in port vlan configuration. */ int ice_vsi_clear_outer_port_vlan(struct ice_vsi *vsi) { … } int ice_vsi_clear_port_vlan(struct ice_vsi *vsi) { … }