Skip to content

Commit cc71de8

Browse files
bcreeley13anguy11
authored andcommitted
ice: Add support for VIRTCHNL_VF_OFFLOAD_VLAN_V2
Add support for the VF driver to be able to request VIRTCHNL_VF_OFFLOAD_VLAN_V2, negotiate its VLAN capabilities via VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS, add/delete VLAN filters, and enable/disable VLAN offloads. VFs supporting VIRTCHNL_OFFLOAD_VLAN_V2 will be able to use the following virtchnl opcodes: VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS VIRTCHNL_OP_ADD_VLAN_V2 VIRTCHNL_OP_DEL_VLAN_V2 VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2 VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2 VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2 VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2 Legacy VF drivers may expect the initial VLAN stripping settings to be configured by the PF, so the PF initializes VLAN stripping based on the VIRTCHNL_OP_GET_VF_RESOURCES opcode. However, with VLAN support via VIRTCHNL_VF_OFFLOAD_VLAN_V2, this function is only expected to be used for VFs that only support VIRTCHNL_VF_OFFLOAD_VLAN, which will only be supported when a port VLAN is configured. Update the function based on the new expectations. Also, change the message when the PF can't enable/disable VLAN stripping to a dev_dbg() as this isn't fatal. When a VF isn't in a port VLAN and it only supports VIRTCHNL_VF_OFFLOAD_VLAN when Double VLAN Mode (DVM) is enabled, then the PF needs to reject the VIRTCHNL_VF_OFFLOAD_VLAN capability and configure the VF in software only VLAN mode. To do this add the new function ice_vf_vsi_cfg_legacy_vlan_mode(), which updates the VF's inner and outer ice_vsi_vlan_ops functions and sets up software only VLAN mode. Signed-off-by: Brett Creeley <[email protected]> Tested-by: Konrad Jankowski <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 0d54d8f commit cc71de8

File tree

6 files changed

+1226
-43
lines changed

6 files changed

+1226
-43
lines changed

drivers/net/ethernet/intel/ice/ice_base.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
#include "ice_base.h"
66
#include "ice_lib.h"
77
#include "ice_dcb_lib.h"
8+
#include "ice_virtchnl_pf.h"
89

910
static bool ice_alloc_rx_buf_zc(struct ice_rx_ring *rx_ring)
1011
{

drivers/net/ethernet/intel/ice/ice_vf_vsi_vlan_ops.c

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,20 @@ noop_vlan_arg(struct ice_vsi __always_unused *vsi,
1414
return 0;
1515
}
1616

17+
static int
18+
noop_vlan(struct ice_vsi __always_unused *vsi)
19+
{
20+
return 0;
21+
}
22+
1723
/**
1824
* ice_vf_vsi_init_vlan_ops - Initialize default VSI VLAN ops for VF VSI
1925
* @vsi: VF's VSI being configured
26+
*
27+
* If Double VLAN Mode (DVM) is enabled, assume that the VF supports the new
28+
* VIRTCHNL_VF_VLAN_OFFLOAD_V2 capability and set up the VLAN ops accordingly.
29+
* If SVM is enabled maintain the same level of VLAN support previous to
30+
* VIRTCHNL_VF_VLAN_OFFLOAD_V2.
2031
*/
2132
void ice_vf_vsi_init_vlan_ops(struct ice_vsi *vsi)
2233
{
@@ -44,6 +55,20 @@ void ice_vf_vsi_init_vlan_ops(struct ice_vsi *vsi)
4455
vlan_ops = &vsi->inner_vlan_ops;
4556
vlan_ops->add_vlan = noop_vlan_arg;
4657
vlan_ops->del_vlan = noop_vlan_arg;
58+
vlan_ops->ena_stripping = ice_vsi_ena_inner_stripping;
59+
vlan_ops->dis_stripping = ice_vsi_dis_inner_stripping;
60+
vlan_ops->ena_insertion = ice_vsi_ena_inner_insertion;
61+
vlan_ops->dis_insertion = ice_vsi_dis_inner_insertion;
62+
} else {
63+
vlan_ops->del_vlan = ice_vsi_del_vlan;
64+
vlan_ops->ena_stripping = ice_vsi_ena_outer_stripping;
65+
vlan_ops->dis_stripping = ice_vsi_dis_outer_stripping;
66+
vlan_ops->ena_insertion = ice_vsi_ena_outer_insertion;
67+
vlan_ops->dis_insertion = ice_vsi_dis_outer_insertion;
68+
69+
/* setup inner VLAN ops */
70+
vlan_ops = &vsi->inner_vlan_ops;
71+
4772
vlan_ops->ena_stripping = ice_vsi_ena_inner_stripping;
4873
vlan_ops->dis_stripping = ice_vsi_dis_inner_stripping;
4974
vlan_ops->ena_insertion = ice_vsi_ena_inner_insertion;
@@ -70,3 +95,93 @@ void ice_vf_vsi_init_vlan_ops(struct ice_vsi *vsi)
7095
}
7196
}
7297
}
98+
99+
/**
100+
* ice_vf_vsi_cfg_dvm_legacy_vlan_mode - Config VLAN mode for old VFs in DVM
101+
* @vsi: VF's VSI being configured
102+
*
103+
* This should only be called when Double VLAN Mode (DVM) is enabled, there
104+
* is not a port VLAN enabled on this VF, and the VF negotiates
105+
* VIRTCHNL_VF_OFFLOAD_VLAN.
106+
*
107+
* This function sets up the VF VSI's inner and outer ice_vsi_vlan_ops and also
108+
* initializes software only VLAN mode (i.e. allow all VLANs). Also, use no-op
109+
* implementations for any functions that may be called during the lifetime of
110+
* the VF so these methods do nothing and succeed.
111+
*/
112+
void ice_vf_vsi_cfg_dvm_legacy_vlan_mode(struct ice_vsi *vsi)
113+
{
114+
struct ice_vf *vf = &vsi->back->vf[vsi->vf_id];
115+
struct device *dev = ice_pf_to_dev(vf->pf);
116+
struct ice_vsi_vlan_ops *vlan_ops;
117+
118+
if (!ice_is_dvm_ena(&vsi->back->hw) || ice_vf_is_port_vlan_ena(vf))
119+
return;
120+
121+
vlan_ops = &vsi->outer_vlan_ops;
122+
123+
/* Rx VLAN filtering always disabled to allow software offloaded VLANs
124+
* for VFs that only support VIRTCHNL_VF_OFFLOAD_VLAN and don't have a
125+
* port VLAN configured
126+
*/
127+
vlan_ops->dis_rx_filtering = ice_vsi_dis_rx_vlan_filtering;
128+
/* Don't fail when attempting to enable Rx VLAN filtering */
129+
vlan_ops->ena_rx_filtering = noop_vlan;
130+
131+
/* Tx VLAN filtering always disabled to allow software offloaded VLANs
132+
* for VFs that only support VIRTCHNL_VF_OFFLOAD_VLAN and don't have a
133+
* port VLAN configured
134+
*/
135+
vlan_ops->dis_tx_filtering = ice_vsi_dis_tx_vlan_filtering;
136+
/* Don't fail when attempting to enable Tx VLAN filtering */
137+
vlan_ops->ena_tx_filtering = noop_vlan;
138+
139+
if (vlan_ops->dis_rx_filtering(vsi))
140+
dev_dbg(dev, "Failed to disable Rx VLAN filtering for old VF without VIRTCHNL_VF_OFFLOAD_VLAN_V2 support\n");
141+
if (vlan_ops->dis_tx_filtering(vsi))
142+
dev_dbg(dev, "Failed to disable Tx VLAN filtering for old VF without VIRTHCNL_VF_OFFLOAD_VLAN_V2 support\n");
143+
144+
/* All outer VLAN offloads must be disabled */
145+
vlan_ops->dis_stripping = ice_vsi_dis_outer_stripping;
146+
vlan_ops->dis_insertion = ice_vsi_dis_outer_insertion;
147+
148+
if (vlan_ops->dis_stripping(vsi))
149+
dev_dbg(dev, "Failed to disable outer VLAN stripping for old VF without VIRTCHNL_VF_OFFLOAD_VLAN_V2 support\n");
150+
151+
if (vlan_ops->dis_insertion(vsi))
152+
dev_dbg(dev, "Failed to disable outer VLAN insertion for old VF without VIRTCHNL_VF_OFFLOAD_VLAN_V2 support\n");
153+
154+
/* All inner VLAN offloads must be disabled */
155+
vlan_ops = &vsi->inner_vlan_ops;
156+
157+
vlan_ops->dis_stripping = ice_vsi_dis_outer_stripping;
158+
vlan_ops->dis_insertion = ice_vsi_dis_outer_insertion;
159+
160+
if (vlan_ops->dis_stripping(vsi))
161+
dev_dbg(dev, "Failed to disable inner VLAN stripping for old VF without VIRTCHNL_VF_OFFLOAD_VLAN_V2 support\n");
162+
163+
if (vlan_ops->dis_insertion(vsi))
164+
dev_dbg(dev, "Failed to disable inner VLAN insertion for old VF without VIRTCHNL_VF_OFFLOAD_VLAN_V2 support\n");
165+
}
166+
167+
/**
168+
* ice_vf_vsi_cfg_svm_legacy_vlan_mode - Config VLAN mode for old VFs in SVM
169+
* @vsi: VF's VSI being configured
170+
*
171+
* This should only be called when Single VLAN Mode (SVM) is enabled, there is
172+
* not a port VLAN enabled on this VF, and the VF negotiates
173+
* VIRTCHNL_VF_OFFLOAD_VLAN.
174+
*
175+
* All of the normal SVM VLAN ops are identical for this case. However, by
176+
* default Rx VLAN filtering should be turned off by default in this case.
177+
*/
178+
void ice_vf_vsi_cfg_svm_legacy_vlan_mode(struct ice_vsi *vsi)
179+
{
180+
struct ice_vf *vf = &vsi->back->vf[vsi->vf_id];
181+
182+
if (ice_is_dvm_ena(&vsi->back->hw) || ice_vf_is_port_vlan_ena(vf))
183+
return;
184+
185+
if (vsi->inner_vlan_ops.dis_rx_filtering(vsi))
186+
dev_dbg(ice_pf_to_dev(vf->pf), "Failed to disable Rx VLAN filtering for old VF with VIRTCHNL_VF_OFFLOAD_VLAN support\n");
187+
}

drivers/net/ethernet/intel/ice/ice_vf_vsi_vlan_ops.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
struct ice_vsi;
1010

11+
void ice_vf_vsi_cfg_dvm_legacy_vlan_mode(struct ice_vsi *vsi);
12+
void ice_vf_vsi_cfg_svm_legacy_vlan_mode(struct ice_vsi *vsi);
13+
1114
#ifdef CONFIG_PCI_IOV
1215
void ice_vf_vsi_init_vlan_ops(struct ice_vsi *vsi);
1316
#else

drivers/net/ethernet/intel/ice/ice_virtchnl_allowlist.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ static const u32 vlan_allowlist_opcodes[] = {
5555
VIRTCHNL_OP_ENABLE_VLAN_STRIPPING, VIRTCHNL_OP_DISABLE_VLAN_STRIPPING,
5656
};
5757

58+
/* VIRTCHNL_VF_OFFLOAD_VLAN_V2 */
59+
static const u32 vlan_v2_allowlist_opcodes[] = {
60+
VIRTCHNL_OP_GET_OFFLOAD_VLAN_V2_CAPS, VIRTCHNL_OP_ADD_VLAN_V2,
61+
VIRTCHNL_OP_DEL_VLAN_V2, VIRTCHNL_OP_ENABLE_VLAN_STRIPPING_V2,
62+
VIRTCHNL_OP_DISABLE_VLAN_STRIPPING_V2,
63+
VIRTCHNL_OP_ENABLE_VLAN_INSERTION_V2,
64+
VIRTCHNL_OP_DISABLE_VLAN_INSERTION_V2,
65+
};
66+
5867
/* VIRTCHNL_VF_OFFLOAD_RSS_PF */
5968
static const u32 rss_pf_allowlist_opcodes[] = {
6069
VIRTCHNL_OP_CONFIG_RSS_KEY, VIRTCHNL_OP_CONFIG_RSS_LUT,
@@ -89,6 +98,7 @@ static const struct allowlist_opcode_info allowlist_opcodes[] = {
8998
ALLOW_ITEM(VIRTCHNL_VF_OFFLOAD_RSS_PF, rss_pf_allowlist_opcodes),
9099
ALLOW_ITEM(VIRTCHNL_VF_OFFLOAD_ADV_RSS_PF, adv_rss_pf_allowlist_opcodes),
91100
ALLOW_ITEM(VIRTCHNL_VF_OFFLOAD_FDIR_PF, fdir_pf_allowlist_opcodes),
101+
ALLOW_ITEM(VIRTCHNL_VF_OFFLOAD_VLAN_V2, vlan_v2_allowlist_opcodes),
92102
};
93103

94104
/**

0 commit comments

Comments
 (0)