From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
To: davem@davemloft.net
Cc: Brett Creeley <brett.creeley@intel.com>,
netdev@vger.kernel.org, nhorman@redhat.com, sassmann@redhat.com,
Andrew Bowers <andrewx.bowers@intel.com>,
Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Subject: [net-next 03/15] ice: Disallow VF VLAN opcodes if VLAN offloads disabled
Date: Wed, 20 Nov 2019 23:46:00 -0800 [thread overview]
Message-ID: <20191121074612.3055661-4-jeffrey.t.kirsher@intel.com> (raw)
In-Reply-To: <20191121074612.3055661-1-jeffrey.t.kirsher@intel.com>
From: Brett Creeley <brett.creeley@intel.com>
Currently if the host disables VLAN offloads on the VF by
not setting the VIRTCHNL_VF_OFFLOAD_VLAN capability bit
we will still honor VF VLAN configuration messages over
VIRTCHNL. These messages (i.e. enable/disable VLAN stripping
and VLAN filtering) should be blocked when the feature
is not supported. Fix that by adding a helper function to
determine if the VF is allowed to do VLAN operations based
on the host's VF configuration.
Also, mirror the VF communicated capabilities in the host's
VF configuration.
Signed-off-by: Brett Creeley <brett.creeley@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
.../net/ethernet/intel/ice/ice_virtchnl_pf.c | 29 +++++++++++++++++++
1 file changed, 29 insertions(+)
diff --git a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
index 2ac83ad3d1a6..3cb394bdfe51 100644
--- a/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
+++ b/drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
@@ -1686,6 +1686,9 @@ static int ice_vc_get_vf_res_msg(struct ice_vf *vf, u8 *msg)
ether_addr_copy(vfres->vsi_res[0].default_mac_addr,
vf->dflt_lan_addr.addr);
+ /* match guest capabilities */
+ vf->driver_caps = vfres->vf_cap_flags;
+
set_bit(ICE_VF_STATE_ACTIVE, vf->vf_states);
err:
@@ -2653,6 +2656,17 @@ ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos,
return ret;
}
+/**
+ * ice_vf_vlan_offload_ena - determine if capabilities support VLAN offloads
+ * @caps: VF driver negotiated capabilities
+ *
+ * Return true if VIRTCHNL_VF_OFFLOAD_VLAN capability is set, else return false
+ */
+static bool ice_vf_vlan_offload_ena(u32 caps)
+{
+ return !!(caps & VIRTCHNL_VF_OFFLOAD_VLAN);
+}
+
/**
* ice_vc_process_vlan_msg
* @vf: pointer to the VF info
@@ -2679,6 +2693,11 @@ static int ice_vc_process_vlan_msg(struct ice_vf *vf, u8 *msg, bool add_v)
goto error_param;
}
+ if (!ice_vf_vlan_offload_ena(vf->driver_caps)) {
+ v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+ goto error_param;
+ }
+
if (!ice_vc_isvalid_vsi_id(vf, vfl->vsi_id)) {
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
goto error_param;
@@ -2864,6 +2883,11 @@ static int ice_vc_ena_vlan_stripping(struct ice_vf *vf)
goto error_param;
}
+ if (!ice_vf_vlan_offload_ena(vf->driver_caps)) {
+ v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+ goto error_param;
+ }
+
vsi = pf->vsi[vf->lan_vsi_idx];
if (ice_vsi_manage_vlan_stripping(vsi, true))
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
@@ -2890,6 +2914,11 @@ static int ice_vc_dis_vlan_stripping(struct ice_vf *vf)
goto error_param;
}
+ if (!ice_vf_vlan_offload_ena(vf->driver_caps)) {
+ v_ret = VIRTCHNL_STATUS_ERR_PARAM;
+ goto error_param;
+ }
+
vsi = pf->vsi[vf->lan_vsi_idx];
if (!vsi) {
v_ret = VIRTCHNL_STATUS_ERR_PARAM;
--
2.23.0
next prev parent reply other threads:[~2019-11-21 7:46 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-21 7:45 [net-next 00/15][pull request] 100GbE Intel Wired LAN Driver Updates 2019-11-20 Jeff Kirsher
2019-11-21 7:45 ` [net-next 01/15] ice: Store number of functions for the device Jeff Kirsher
2019-11-21 7:45 ` [net-next 02/15] ice: Correct capabilities reporting of max TCs Jeff Kirsher
2019-11-21 7:46 ` Jeff Kirsher [this message]
2019-11-21 7:46 ` [net-next 04/15] ice: Don't modify stripping for add/del VLANs on VF Jeff Kirsher
2019-11-21 7:46 ` [net-next 05/15] ice: fix stack leakage Jeff Kirsher
2019-11-21 22:25 ` Jakub Kicinski
2019-11-21 22:37 ` David Miller
2019-11-21 23:07 ` Jeff Kirsher
2019-11-21 7:46 ` [net-next 06/15] ice: Only disable VF state when freeing each VF resources Jeff Kirsher
2019-11-21 7:46 ` [net-next 07/15] ice: Fix setting coalesce to handle DCB configuration Jeff Kirsher
2019-11-21 7:46 ` [net-next 08/15] ice: Refactor removal of VLAN promiscuous rules Jeff Kirsher
2019-11-21 7:46 ` [net-next 09/15] ice: Do not use devm* functions for local uses Jeff Kirsher
2019-11-21 7:46 ` [net-next 10/15] ice: Add ice_pf_to_dev(pf) macro Jeff Kirsher
2019-11-21 7:46 ` [net-next 11/15] ice: add helpers for virtchnl Jeff Kirsher
2019-11-21 7:46 ` [net-next 12/15] ice: implement VF stats NDO Jeff Kirsher
2019-11-21 7:46 ` [net-next 13/15] ice: Implement ethtool ops for channels Jeff Kirsher
2019-11-21 22:42 ` Jakub Kicinski
2019-11-22 7:09 ` Jeff Kirsher
2019-11-22 17:44 ` Jakub Kicinski
2019-11-21 7:46 ` [net-next 14/15] ice: remove pointless NULL check of port_info Jeff Kirsher
2019-11-21 7:46 ` [net-next 15/15] ice: Update FW API minor version Jeff Kirsher
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191121074612.3055661-4-jeffrey.t.kirsher@intel.com \
--to=jeffrey.t.kirsher@intel.com \
--cc=andrewx.bowers@intel.com \
--cc=brett.creeley@intel.com \
--cc=davem@davemloft.net \
--cc=netdev@vger.kernel.org \
--cc=nhorman@redhat.com \
--cc=sassmann@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox