net/ice/base: add interface to support configuring VLAN mode
[dpdk.git] / drivers / net / ice / base / ice_vlan_mode.c
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2001-2020 Intel Corporation
3  */
4
5 #include "ice_vlan_mode.h"
6 #include "ice_common.h"
7
8 /**
9  * ice_set_svm - set single VLAN mode
10  * @hw: pointer to the HW structure
11  */
12 static enum ice_status ice_set_svm_dflt(struct ice_hw *hw)
13 {
14         ice_debug(hw, ICE_DBG_TRACE, "%s\n", __func__);
15
16         return ice_aq_set_port_params(hw->port_info, 0, false, false, false, NULL);
17 }
18
19 /**
20  * ice_init_vlan_mode_ops - initialize VLAN mode configuration ops
21  * @hw: pointer to the HW structure
22  */
23 void ice_init_vlan_mode_ops(struct ice_hw *hw)
24 {
25         hw->vlan_mode_ops.set_dvm = NULL;
26         hw->vlan_mode_ops.set_svm = ice_set_svm_dflt;
27 }
28
29 /**
30  * ice_set_vlan_mode
31  * @hw: pointer to the HW structure
32  */
33 enum ice_status ice_set_vlan_mode(struct ice_hw *hw)
34 {
35         enum ice_status status = ICE_ERR_NOT_IMPL;
36
37         if (hw->vlan_mode_ops.set_dvm)
38                 status = hw->vlan_mode_ops.set_dvm(hw);
39
40         if (status)
41                 return hw->vlan_mode_ops.set_svm(hw);
42
43         return ICE_SUCCESS;
44 }