1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (C) 2019-2021, Intel Corporation. */
4 #include "ice_pf_vsi_vlan_ops.h"
5 #include "ice_vf_vsi_vlan_ops.h"
6 #include "ice_sf_vsi_vlan_ops.h"
11 op_unsupported_vlan_arg(struct ice_vsi * __always_unused vsi,
12 struct ice_vlan * __always_unused vlan)
18 op_unsupported_tpid_arg(struct ice_vsi *__always_unused vsi,
19 u16 __always_unused tpid)
24 static int op_unsupported(struct ice_vsi *__always_unused vsi)
29 /* If any new ops are added to the VSI VLAN ops interface then an unsupported
30 * implementation should be set here.
32 static struct ice_vsi_vlan_ops ops_unsupported = {
33 .add_vlan = op_unsupported_vlan_arg,
34 .del_vlan = op_unsupported_vlan_arg,
35 .ena_stripping = op_unsupported_tpid_arg,
36 .dis_stripping = op_unsupported,
37 .ena_insertion = op_unsupported_tpid_arg,
38 .dis_insertion = op_unsupported,
39 .ena_rx_filtering = op_unsupported,
40 .dis_rx_filtering = op_unsupported,
41 .ena_tx_filtering = op_unsupported,
42 .dis_tx_filtering = op_unsupported,
43 .set_port_vlan = op_unsupported_vlan_arg,
47 * ice_vsi_init_unsupported_vlan_ops - init all VSI VLAN ops to unsupported
48 * @vsi: VSI to initialize VSI VLAN ops to unsupported for
50 * By default all inner and outer VSI VLAN ops return -EOPNOTSUPP. This was done
51 * as oppsed to leaving the ops null to prevent unexpected crashes. Instead if
52 * an unsupported VSI VLAN op is called it will just return -EOPNOTSUPP.
55 static void ice_vsi_init_unsupported_vlan_ops(struct ice_vsi *vsi)
57 vsi->outer_vlan_ops = ops_unsupported;
58 vsi->inner_vlan_ops = ops_unsupported;
62 * ice_vsi_init_vlan_ops - initialize type specific VSI VLAN ops
63 * @vsi: VSI to initialize ops for
65 * If any VSI types are added and/or require different ops than the PF or VF VSI
66 * then they will have to add a case here to handle that. Also, VSI type
67 * specific files should be added in the same manner that was done for PF VSI.
69 void ice_vsi_init_vlan_ops(struct ice_vsi *vsi)
71 /* Initialize all VSI types to have unsupported VSI VLAN ops */
72 ice_vsi_init_unsupported_vlan_ops(vsi);
76 ice_pf_vsi_init_vlan_ops(vsi);
79 ice_vf_vsi_init_vlan_ops(vsi);
82 ice_sf_vsi_init_vlan_ops(vsi);
85 dev_dbg(ice_pf_to_dev(vsi->back), "%s does not support VLAN operations\n",
86 ice_vsi_type_str(vsi->type));
92 * ice_get_compat_vsi_vlan_ops - Get VSI VLAN ops based on VLAN mode
93 * @vsi: VSI used to get the VSI VLAN ops
95 * This function is meant to be used when the caller doesn't know which VLAN ops
96 * to use (i.e. inner or outer). This allows backward compatibility for VLANs
97 * since most of the Outer VSI VLAN functins are not supported when
98 * the device is configured in Single VLAN Mode (SVM).
100 struct ice_vsi_vlan_ops *ice_get_compat_vsi_vlan_ops(struct ice_vsi *vsi)
102 if (ice_is_dvm_ena(&vsi->back->hw))
103 return &vsi->outer_vlan_ops;
105 return &vsi->inner_vlan_ops;