ice: Add functions to rebuild host VLAN/MAC config for a VF
When resetting a VF the VLAN and MAC filter configurations need to be replayed. Add helper functions for this purpose. Signed-off-by: Brett Creeley <brett.creeley@intel.com> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com> Tested-by: Andrew Bowers <andrewx.bowers@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
This commit is contained in:
committed by
Jeff Kirsher
parent
eb2af3ee94
commit
350e822cd5
@@ -540,6 +540,82 @@ static int ice_calc_vf_first_vector_idx(struct ice_pf *pf, struct ice_vf *vf)
|
|||||||
return pf->sriov_base_vector + vf->vf_id * pf->num_msix_per_vf;
|
return pf->sriov_base_vector + vf->vf_id * pf->num_msix_per_vf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ice_vf_rebuild_host_vlan_cfg - add VLAN 0 filter or rebuild the Port VLAN
|
||||||
|
* @vf: VF to add MAC filters for
|
||||||
|
*
|
||||||
|
* Called after a VF VSI has been re-added/rebuilt during reset. The PF driver
|
||||||
|
* always re-adds either a VLAN 0 or port VLAN based filter after reset.
|
||||||
|
*/
|
||||||
|
static int ice_vf_rebuild_host_vlan_cfg(struct ice_vf *vf)
|
||||||
|
{
|
||||||
|
struct ice_vsi *vsi = vf->pf->vsi[vf->lan_vsi_idx];
|
||||||
|
struct device *dev = ice_pf_to_dev(vf->pf);
|
||||||
|
u16 vlan_id = 0;
|
||||||
|
int err;
|
||||||
|
|
||||||
|
if (vf->port_vlan_info) {
|
||||||
|
err = ice_vsi_manage_pvid(vsi, vf->port_vlan_info, true);
|
||||||
|
if (err) {
|
||||||
|
dev_err(dev, "failed to configure port VLAN via VSI parameters for VF %u, error %d\n",
|
||||||
|
vf->vf_id, err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
vlan_id = vf->port_vlan_info & VLAN_VID_MASK;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* vlan_id will either be 0 or the port VLAN number */
|
||||||
|
err = ice_vsi_add_vlan(vsi, vlan_id, ICE_FWD_TO_VSI);
|
||||||
|
if (err) {
|
||||||
|
dev_err(dev, "failed to add %s VLAN %u filter for VF %u, error %d\n",
|
||||||
|
vf->port_vlan_info ? "port" : "", vlan_id, vf->vf_id,
|
||||||
|
err);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ice_vf_rebuild_host_mac_cfg - add broadcast and the VF's perm_addr/LAA
|
||||||
|
* @vf: VF to add MAC filters for
|
||||||
|
*
|
||||||
|
* Called after a VF VSI has been re-added/rebuilt during reset. The PF driver
|
||||||
|
* always re-adds a broadcast filter and the VF's perm_addr/LAA after reset.
|
||||||
|
*/
|
||||||
|
static int ice_vf_rebuild_host_mac_cfg(struct ice_vf *vf)
|
||||||
|
{
|
||||||
|
struct ice_vsi *vsi = vf->pf->vsi[vf->lan_vsi_idx];
|
||||||
|
struct device *dev = ice_pf_to_dev(vf->pf);
|
||||||
|
enum ice_status status;
|
||||||
|
u8 broadcast[ETH_ALEN];
|
||||||
|
|
||||||
|
eth_broadcast_addr(broadcast);
|
||||||
|
status = ice_fltr_add_mac(vsi, broadcast, ICE_FWD_TO_VSI);
|
||||||
|
if (status) {
|
||||||
|
dev_err(dev, "failed to add broadcast MAC filter for VF %u, error %s\n",
|
||||||
|
vf->vf_id, ice_stat_str(status));
|
||||||
|
return ice_status_to_errno(status);
|
||||||
|
}
|
||||||
|
|
||||||
|
vf->num_mac++;
|
||||||
|
|
||||||
|
if (is_valid_ether_addr(vf->dflt_lan_addr.addr)) {
|
||||||
|
status = ice_fltr_add_mac(vsi, vf->dflt_lan_addr.addr,
|
||||||
|
ICE_FWD_TO_VSI);
|
||||||
|
if (status) {
|
||||||
|
dev_err(dev, "failed to add default unicast MAC filter %pM for VF %u, error %s\n",
|
||||||
|
&vf->dflt_lan_addr.addr[0], vf->vf_id,
|
||||||
|
ice_stat_str(status));
|
||||||
|
return ice_status_to_errno(status);
|
||||||
|
}
|
||||||
|
vf->num_mac++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ice_alloc_vsi_res - Setup VF VSI and its resources
|
* ice_alloc_vsi_res - Setup VF VSI and its resources
|
||||||
* @vf: pointer to the VF structure
|
* @vf: pointer to the VF structure
|
||||||
@@ -549,10 +625,9 @@ static int ice_calc_vf_first_vector_idx(struct ice_pf *pf, struct ice_vf *vf)
|
|||||||
static int ice_alloc_vsi_res(struct ice_vf *vf)
|
static int ice_alloc_vsi_res(struct ice_vf *vf)
|
||||||
{
|
{
|
||||||
struct ice_pf *pf = vf->pf;
|
struct ice_pf *pf = vf->pf;
|
||||||
u8 broadcast[ETH_ALEN];
|
|
||||||
struct ice_vsi *vsi;
|
struct ice_vsi *vsi;
|
||||||
struct device *dev;
|
struct device *dev;
|
||||||
int status = 0;
|
int ret;
|
||||||
|
|
||||||
dev = ice_pf_to_dev(pf);
|
dev = ice_pf_to_dev(pf);
|
||||||
/* first vector index is the VFs OICR index */
|
/* first vector index is the VFs OICR index */
|
||||||
@@ -567,38 +642,20 @@ static int ice_alloc_vsi_res(struct ice_vf *vf)
|
|||||||
vf->lan_vsi_idx = vsi->idx;
|
vf->lan_vsi_idx = vsi->idx;
|
||||||
vf->lan_vsi_num = vsi->vsi_num;
|
vf->lan_vsi_num = vsi->vsi_num;
|
||||||
|
|
||||||
/* Check if port VLAN exist before, and restore it accordingly */
|
ret = ice_vf_rebuild_host_vlan_cfg(vf);
|
||||||
if (vf->port_vlan_info) {
|
if (ret) {
|
||||||
ice_vsi_manage_pvid(vsi, vf->port_vlan_info, true);
|
dev_err(dev, "failed to rebuild default MAC configuration for VF %d, error %d\n",
|
||||||
if (ice_vsi_add_vlan(vsi, vf->port_vlan_info & VLAN_VID_MASK,
|
vf->vf_id, ret);
|
||||||
ICE_FWD_TO_VSI))
|
|
||||||
dev_warn(ice_pf_to_dev(pf), "Failed to add Port VLAN %d filter for VF %d\n",
|
|
||||||
vf->port_vlan_info & VLAN_VID_MASK, vf->vf_id);
|
|
||||||
} else {
|
|
||||||
/* set VLAN 0 filter by default when no port VLAN is
|
|
||||||
* enabled. If a port VLAN is enabled we don't want
|
|
||||||
* untagged broadcast/multicast traffic seen on the VF
|
|
||||||
* interface.
|
|
||||||
*/
|
|
||||||
if (ice_vsi_add_vlan(vsi, 0, ICE_FWD_TO_VSI))
|
|
||||||
dev_warn(ice_pf_to_dev(pf), "Failed to add VLAN 0 filter for VF %d, MDD events will trigger. Reset the VF, disable spoofchk, or enable 8021q module on the guest\n",
|
|
||||||
vf->vf_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (is_valid_ether_addr(vf->dflt_lan_addr.addr)) {
|
|
||||||
status = ice_fltr_add_mac(vsi, vf->dflt_lan_addr.addr,
|
|
||||||
ICE_FWD_TO_VSI);
|
|
||||||
if (status)
|
|
||||||
goto ice_alloc_vsi_res_exit;
|
goto ice_alloc_vsi_res_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
eth_broadcast_addr(broadcast);
|
|
||||||
status = ice_fltr_add_mac(vsi, broadcast, ICE_FWD_TO_VSI);
|
ret = ice_vf_rebuild_host_mac_cfg(vf);
|
||||||
if (status)
|
if (ret) {
|
||||||
dev_err(dev, "could not add mac filters error %d\n",
|
dev_err(dev, "failed to rebuild default MAC configuration for VF %d, error %d\n",
|
||||||
status);
|
vf->vf_id, ret);
|
||||||
else
|
goto ice_alloc_vsi_res_exit;
|
||||||
vf->num_mac = 1;
|
}
|
||||||
|
|
||||||
/* Clear this bit after VF initialization since we shouldn't reclaim
|
/* Clear this bit after VF initialization since we shouldn't reclaim
|
||||||
* and reassign interrupts for synchronous or asynchronous VFR events.
|
* and reassign interrupts for synchronous or asynchronous VFR events.
|
||||||
@@ -607,7 +664,7 @@ static int ice_alloc_vsi_res(struct ice_vf *vf)
|
|||||||
* more vectors.
|
* more vectors.
|
||||||
*/
|
*/
|
||||||
ice_alloc_vsi_res_exit:
|
ice_alloc_vsi_res_exit:
|
||||||
return status;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user