Commit 61c9ce86 authored by Brett Creeley's avatar Brett Creeley Committed by Jeff Kirsher

ice: Fix Port VLAN priority bits

Currently when configuring a port VLAN for a VF we are only shifting the
QoS bits by 12. This is incorrect. Fix this by getting rid of the ICE
specific VLAN defines and use the kernel VLAN defines instead.

Also, don't assign a value to vlanprio until the VLAN ID and QoS
parameters have been validated.

Also, there are many places we do (le16_to_cpu(vsi->info.pvid) &
VLAN_VID_MASK). Instead do (vf->port_vlan_info & VLAN_VID_MASK) because
we always save what's stored in vsi->info.pvid to vf->port_vlan_info in
the CPU's endianness.
Signed-off-by: default avatarBrett Creeley <brett.creeley@intel.com>
Tested-by: default avatarAndrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
parent 0b6c6a8b
...@@ -528,7 +528,7 @@ static int ice_alloc_vsi_res(struct ice_vf *vf) ...@@ -528,7 +528,7 @@ static int ice_alloc_vsi_res(struct ice_vf *vf)
/* Check if port VLAN exist before, and restore it accordingly */ /* Check if port VLAN exist before, and restore it accordingly */
if (vf->port_vlan_info) { if (vf->port_vlan_info) {
ice_vsi_manage_pvid(vsi, vf->port_vlan_info, true); ice_vsi_manage_pvid(vsi, vf->port_vlan_info, true);
ice_vsi_add_vlan(vsi, vf->port_vlan_info & ICE_VLAN_M); ice_vsi_add_vlan(vsi, vf->port_vlan_info & VLAN_VID_MASK);
} }
eth_broadcast_addr(broadcast); eth_broadcast_addr(broadcast);
...@@ -2684,19 +2684,20 @@ int ...@@ -2684,19 +2684,20 @@ int
ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos, ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos,
__be16 vlan_proto) __be16 vlan_proto)
{ {
u16 vlanprio = vlan_id | (qos << ICE_VLAN_PRIORITY_S);
struct ice_pf *pf = ice_netdev_to_pf(netdev); struct ice_pf *pf = ice_netdev_to_pf(netdev);
struct ice_vsi *vsi; struct ice_vsi *vsi;
struct device *dev; struct device *dev;
struct ice_vf *vf; struct ice_vf *vf;
u16 vlanprio;
int ret = 0; int ret = 0;
dev = ice_pf_to_dev(pf); dev = ice_pf_to_dev(pf);
if (ice_validate_vf_id(pf, vf_id)) if (ice_validate_vf_id(pf, vf_id))
return -EINVAL; return -EINVAL;
if (vlan_id > ICE_MAX_VLANID || qos > 7) { if (vlan_id >= VLAN_N_VID || qos > 7) {
dev_err(dev, "Invalid VF Parameters\n"); dev_err(dev, "Invalid Port VLAN parameters for VF %d, ID %d, QoS %d\n",
vf_id, vlan_id, qos);
return -EINVAL; return -EINVAL;
} }
...@@ -2710,16 +2711,17 @@ ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos, ...@@ -2710,16 +2711,17 @@ ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos,
if (ice_check_vf_init(pf, vf)) if (ice_check_vf_init(pf, vf))
return -EBUSY; return -EBUSY;
if (le16_to_cpu(vsi->info.pvid) == vlanprio) { vlanprio = vlan_id | (qos << VLAN_PRIO_SHIFT);
if (vf->port_vlan_info == vlanprio) {
/* duplicate request, so just return success */ /* duplicate request, so just return success */
dev_dbg(dev, "Duplicate pvid %d request\n", vlanprio); dev_dbg(dev, "Duplicate pvid %d request\n", vlanprio);
return ret; return ret;
} }
/* If PVID, then remove all filters on the old VLAN */ /* If PVID, then remove all filters on the old VLAN */
if (vsi->info.pvid) if (vf->port_vlan_info)
ice_vsi_kill_vlan(vsi, (le16_to_cpu(vsi->info.pvid) & ice_vsi_kill_vlan(vsi, vf->port_vlan_info & VLAN_VID_MASK);
VLAN_VID_MASK));
if (vlan_id || qos) { if (vlan_id || qos) {
ret = ice_vsi_manage_pvid(vsi, vlanprio, true); ret = ice_vsi_manage_pvid(vsi, vlanprio, true);
...@@ -2800,7 +2802,7 @@ static int ice_vc_process_vlan_msg(struct ice_vf *vf, u8 *msg, bool add_v) ...@@ -2800,7 +2802,7 @@ static int ice_vc_process_vlan_msg(struct ice_vf *vf, u8 *msg, bool add_v)
} }
for (i = 0; i < vfl->num_elements; i++) { for (i = 0; i < vfl->num_elements; i++) {
if (vfl->vlan_id[i] > ICE_MAX_VLANID) { if (vfl->vlan_id[i] >= VLAN_N_VID) {
v_ret = VIRTCHNL_STATUS_ERR_PARAM; v_ret = VIRTCHNL_STATUS_ERR_PARAM;
dev_err(dev, "invalid VF VLAN id %d\n", dev_err(dev, "invalid VF VLAN id %d\n",
vfl->vlan_id[i]); vfl->vlan_id[i]);
...@@ -3197,14 +3199,12 @@ int ...@@ -3197,14 +3199,12 @@ int
ice_get_vf_cfg(struct net_device *netdev, int vf_id, struct ifla_vf_info *ivi) ice_get_vf_cfg(struct net_device *netdev, int vf_id, struct ifla_vf_info *ivi)
{ {
struct ice_pf *pf = ice_netdev_to_pf(netdev); struct ice_pf *pf = ice_netdev_to_pf(netdev);
struct ice_vsi *vsi;
struct ice_vf *vf; struct ice_vf *vf;
if (ice_validate_vf_id(pf, vf_id)) if (ice_validate_vf_id(pf, vf_id))
return -EINVAL; return -EINVAL;
vf = &pf->vf[vf_id]; vf = &pf->vf[vf_id];
vsi = pf->vsi[vf->lan_vsi_idx];
if (ice_check_vf_init(pf, vf)) if (ice_check_vf_init(pf, vf))
return -EBUSY; return -EBUSY;
...@@ -3213,9 +3213,8 @@ ice_get_vf_cfg(struct net_device *netdev, int vf_id, struct ifla_vf_info *ivi) ...@@ -3213,9 +3213,8 @@ ice_get_vf_cfg(struct net_device *netdev, int vf_id, struct ifla_vf_info *ivi)
ether_addr_copy(ivi->mac, vf->dflt_lan_addr.addr); ether_addr_copy(ivi->mac, vf->dflt_lan_addr.addr);
/* VF configuration for VLAN and applicable QoS */ /* VF configuration for VLAN and applicable QoS */
ivi->vlan = le16_to_cpu(vsi->info.pvid) & ICE_VLAN_M; ivi->vlan = vf->port_vlan_info & VLAN_VID_MASK;
ivi->qos = (le16_to_cpu(vsi->info.pvid) & ICE_PRIORITY_M) >> ivi->qos = (vf->port_vlan_info & VLAN_PRIO_MASK) >> VLAN_PRIO_SHIFT;
ICE_VLAN_PRIORITY_S;
ivi->trusted = vf->trusted; ivi->trusted = vf->trusted;
ivi->spoofchk = vf->spoofchk; ivi->spoofchk = vf->spoofchk;
......
...@@ -5,11 +5,6 @@ ...@@ -5,11 +5,6 @@
#define _ICE_VIRTCHNL_PF_H_ #define _ICE_VIRTCHNL_PF_H_
#include "ice.h" #include "ice.h"
#define ICE_MAX_VLANID 4095
#define ICE_VLAN_PRIORITY_S 12
#define ICE_VLAN_M 0xFFF
#define ICE_PRIORITY_M 0x7000
/* Restrict number of MAC Addr and VLAN that non-trusted VF can programmed */ /* Restrict number of MAC Addr and VLAN that non-trusted VF can programmed */
#define ICE_MAX_VLAN_PER_VF 8 #define ICE_MAX_VLAN_PER_VF 8
#define ICE_MAX_MACADDR_PER_VF 12 #define ICE_MAX_MACADDR_PER_VF 12
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment