ice: Refactor ice_ena_vf_mappings to split MSIX and queue mappings
Subsystems (2)
Tony Nguyen
maintainerPATCH 1/15 ice: Refactor ice_ena_vf_mappings to split MSIX and queue mappings
From: Brett Creeley <[email protected]>
Currently ice_ena_vf_mappings() does all of the VF's MSIX and queue mapping in one function. This makes it hard to digest. Fix this by creating a new function for enabling MSIX mappings and one for enabling queue mappings.
Also, rename some variables in the functions for clarity.
--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 91 ++++++++++++------- 1 file changed, 59 insertions(+), 32 deletions(-)
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +59 -32
@@ -651,55 +651,70 @@ static int ice_alloc_vf_res(struct ice_vf *vf) }/** -* ice_ena_vf_mappings -* @vf: pointer to the VF structure +* ice_ena_vf_msix_mappings - enable VF MSIX mappings in hardware +* @vf: VF to enable MSIX mappings for * -* Enable VF vectors and queues allocation by writing the details into -* respective registers. +* Some of the registers need to be indexed/configured using hardware global +* device values and other registers need 0-based values, which represent PF +* based values. */ -static void ice_ena_vf_mappings (struct ice_vf *vf) +static void ice_ena_vf_msix_mappings (struct ice_vf *vf) { -int abs_vf_id, abs_first, abs_last; +int device_based_first_msix, device_based_last_msix; +int pf_based_first_msix, pf_based_last_msix, v;struct ice_pf *pf = vf->pf; -struct ice_vsi *vsi; -struct device *dev; -int first, last, v; +int device_based_vf_id;struct ice_hw *hw;u32 reg; - dev =ice_pf_to_dev (pf); hw = &pf->hw; - vsi = pf->vsi[vf->lan_vsi_idx]; - first = vf->first_vector_idx; - last = (first + pf->num_msix_per_vf) -1 ; - abs_first = first + pf->hw.func_caps.common_cap.msix_vector_first_id; - abs_last = (abs_first + pf->num_msix_per_vf) -1 ; - abs_vf_id = vf->vf_id + hw->func_caps.vf_base_id; - -/* VF Vector allocation */ - reg = (((abs_first <<VPINT_ALLOC_FIRST_S ) &VPINT_ALLOC_FIRST_M ) | - ((abs_last <<VPINT_ALLOC_LAST_S ) &VPINT_ALLOC_LAST_M ) | -VPINT_ALLOC_VALID_M ); + pf_based_first_msix = vf->first_vector_idx; + pf_based_last_msix = (pf_based_first_msix + pf->num_msix_per_vf) -1 ; + + device_based_first_msix = pf_based_first_msix + + pf->hw.func_caps.common_cap.msix_vector_first_id; + device_based_last_msix = + (device_based_first_msix + pf->num_msix_per_vf) -1 ; + device_based_vf_id = vf->vf_id + hw->func_caps.vf_base_id; + + reg = (((device_based_first_msix <<VPINT_ALLOC_FIRST_S ) & +VPINT_ALLOC_FIRST_M ) | + ((device_based_last_msix <<VPINT_ALLOC_LAST_S ) & +VPINT_ALLOC_LAST_M ) |VPINT_ALLOC_VALID_M );wr32 (hw,VPINT_ALLOC (vf->vf_id), reg); - reg = (((abs_first <<VPINT_ALLOC_PCI_FIRST_S ) + reg = (((device_based_first_msix <<VPINT_ALLOC_PCI_FIRST_S ) &VPINT_ALLOC_PCI_FIRST_M ) | - ((abs_last <<VPINT_ALLOC_PCI_LAST_S ) &VPINT_ALLOC_PCI_LAST_M ) | -VPINT_ALLOC_PCI_VALID_M ); + ((device_based_last_msix <<VPINT_ALLOC_PCI_LAST_S ) & +VPINT_ALLOC_PCI_LAST_M ) |VPINT_ALLOC_PCI_VALID_M );wr32 (hw,VPINT_ALLOC_PCI (vf->vf_id), reg); +/* map the interrupts to its functions */ -for (v = first; v <= last; v++) { - reg = (((abs_vf_id <<GLINT_VECT2FUNC_VF_NUM_S ) & +for (v = pf_based_first_msix; v <= pf_based_last_msix; v++) { + reg = (((device_based_vf_id <<GLINT_VECT2FUNC_VF_NUM_S ) &GLINT_VECT2FUNC_VF_NUM_M ) | ((hw->pf_id <<GLINT_VECT2FUNC_PF_NUM_S ) &GLINT_VECT2FUNC_PF_NUM_M ));wr32 (hw,GLINT_VECT2FUNC (v), reg); } -/* Map mailbox interrupt. We put an explicit 0 here to remind us that -* VF admin queue interrupts will go to VF MSI-X vector 0. -*/ -wr32 (hw,VPINT_MBX_CTL (abs_vf_id),VPINT_MBX_CTL_CAUSE_ENA_M |0 ); +/* Map mailbox interrupt to VF MSI-X vector 0 */ +wr32 (hw,VPINT_MBX_CTL (device_based_vf_id),VPINT_MBX_CTL_CAUSE_ENA_M ); +} + +/** +* ice_ena_vf_q_mappings - enable Rx/Tx queue mappings for a VF +* @vf: VF to enable the mappings for +* @max_txq: max Tx queues allowed on the VF's VSI +* @max_rxq: max Rx queues allowed on the VF's VSI +*/ +static void ice_ena_vf_q_mappings (struct ice_vf *vf,u16 max_txq,u16 max_rxq) +{ +struct ice_vsi *vsi = vf->pf->vsi[vf->lan_vsi_idx]; +struct device *dev =ice_pf_to_dev (vf->pf); +struct ice_hw *hw = &vf->pf->hw; +u32 reg; +/* set regardless of mapping mode */ wr32 (hw,VPLAN_TXQ_MAPENA (vf->vf_id),VPLAN_TXQ_MAPENA_TX_ENA_M );
@@ -711,7 +726,7 @@ static void ice_ena_vf_mappings(struct ice_vf *vf)*/ reg = (((vsi->txq_map[0 ] <<VPLAN_TX_QBASE_VFFIRSTQ_S ) &VPLAN_TX_QBASE_VFFIRSTQ_M ) | - (((vsi->alloc_txq -1 ) <<VPLAN_TX_QBASE_VFNUMQ_S ) & + (((max_txq -1 ) <<VPLAN_TX_QBASE_VFNUMQ_S ) &VPLAN_TX_QBASE_VFNUMQ_M ));wr32 (hw,VPLAN_TX_QBASE (vf->vf_id), reg); }else {
@@ -729,7 +744,7 @@ static void ice_ena_vf_mappings(struct ice_vf *vf)*/ reg = (((vsi->rxq_map[0 ] <<VPLAN_RX_QBASE_VFFIRSTQ_S ) &VPLAN_RX_QBASE_VFFIRSTQ_M ) | - (((vsi->alloc_txq -1 ) <<VPLAN_RX_QBASE_VFNUMQ_S ) & + (((max_rxq -1 ) <<VPLAN_RX_QBASE_VFNUMQ_S ) &VPLAN_RX_QBASE_VFNUMQ_M ));wr32 (hw,VPLAN_RX_QBASE (vf->vf_id), reg); }else {
@@ -737,6 +752,18 @@ static void ice_ena_vf_mappings(struct ice_vf *vf) } } +/** +* ice_ena_vf_mappings - enable VF MSIX and queue mapping +* @vf: pointer to the VF structure +*/ +static void ice_ena_vf_mappings (struct ice_vf *vf) +{ +struct ice_vsi *vsi = vf->pf->vsi[vf->lan_vsi_idx]; + +ice_ena_vf_msix_mappings (vf); +ice_ena_vf_q_mappings (vf, vsi->alloc_txq, vsi->alloc_rxq); +} +/** * ice_determine_res * @pf: pointer to the PF structure
Signature · 1 line
2.20.1
Tony Nguyen
maintainerPATCH 2/15 ice: Simplify ice_sriov_configure
From: Brett Creeley <[email protected]>
Add a new function for checking if SR-IOV can be configured based on the PF and/or device's state/capabilities. Also, simplify the flow in ice_sriov_configure().
--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 72 ++++++++++++------- 1 file changed, 48 insertions(+), 24 deletions(-)
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +48 -24
@@ -1435,6 +1435,8 @@ static int ice_alloc_vfs(struct ice_pf *pf, u16 num_alloc_vfs)* ice_pci_sriov_ena - Enable or change number of VFs * @pf: pointer to the PF structure * @num_vfs: number of VFs to allocate +* +* Returns 0 on success and negative on failure */ static int ice_pci_sriov_ena (struct ice_pf *pf,int num_vfs) {
@@ -1442,20 +1444,10 @@ static int ice_pci_sriov_ena(struct ice_pf *pf, int num_vfs)struct device *dev =ice_pf_to_dev (pf);int err; -if (!ice_pf_state_is_nominal (pf)) { -dev_err (dev,"Cannot enable SR-IOV, device not ready\n" ); -return -EBUSY ; - } - -if (!test_bit (ICE_FLAG_SRIOV_CAPABLE , pf->flags)) { -dev_err (dev,"This device is not capable of SR-IOV\n" ); -return -EOPNOTSUPP ; - } -if (pre_existing_vfs && pre_existing_vfs != num_vfs)ice_free_vfs (pf);else if (pre_existing_vfs && pre_existing_vfs == num_vfs) -return num_vfs; +return 0 ;if (num_vfs > pf->num_vfs_supported) { dev_err(dev, "Can't enable %d VFs, max VFs supported is %d\n",
@@ -1471,37 +1463,69 @@ static int ice_pci_sriov_ena(struct ice_pf *pf, int num_vfs) }set_bit (ICE_FLAG_SRIOV_ENA , pf->flags); -return num_vfs; +return 0 ; +} + +/** +* ice_check_sriov_allowed - check if SR-IOV is allowed based on various checks +* @pf: PF to enabled SR-IOV on +*/ +static int ice_check_sriov_allowed (struct ice_pf *pf) +{ +struct device *dev =ice_pf_to_dev (pf); + +if (!test_bit (ICE_FLAG_SRIOV_CAPABLE , pf->flags)) { +dev_err (dev,"This device is not capable of SR-IOV\n" ); +return -EOPNOTSUPP ; + } + +if (ice_is_safe_mode (pf)) { +dev_err (dev,"SR-IOV cannot be configured - Device is in Safe Mode\n" ); +return -EOPNOTSUPP ; + } + +if (!ice_pf_state_is_nominal (pf)) { +dev_err (dev,"Cannot enable SR-IOV, device not ready\n" ); +return -EBUSY ; + } + +return 0 ; }/** * ice_sriov_configure - Enable or change number of VFs via sysfs * @pdev: pointer to a pci_dev structure -* @num_vfs: number of VFs to allocate +* @num_vfs: number of VFs to allocate or 0 to free VFs * -* This function is called when the user updates the number of VFs in sysfs. +* This function is called when the user updates the number of VFs in sysfs. On +* success return whatever num_vfs was set to by the caller. Return negative on +* failure. */ int ice_sriov_configure (struct pci_dev *pdev,int num_vfs) {struct ice_pf *pf =pci_get_drvdata (pdev);struct device *dev =ice_pf_to_dev (pf); +int err; -if (ice_is_safe_mode (pf)) { -dev_err (dev,"SR-IOV cannot be configured - Device is in Safe Mode\n" ); -return -EOPNOTSUPP ; - } + err =ice_check_sriov_allowed (pf); +if (err) +return err; -if (num_vfs) -return ice_pci_sriov_ena (pf, num_vfs); +if (!num_vfs) { +if (!pci_vfs_assigned (pdev)) { +ice_free_vfs (pf); +return 0 ; + } -if (!pci_vfs_assigned (pdev)) { -ice_free_vfs (pf); - }else {dev_err (dev,"can't free VFs because some are assigned to VMs.\n" );return -EBUSY ; } -return 0 ; + err =ice_pci_sriov_ena (pf, num_vfs); +if (err) +return err; + +return num_vfs; }/**
Signature · 1 line
2.20.1
Bowers
PATCH 2/15 ice: Simplify ice_sriov_configure
Quoted 13 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Tony Nguyen
Sent: Friday, May 15, 2020 5:51 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S45 02/15] ice: Simplifyice_sriov_configureFrom: Brett Creeley <[email protected]>
Add a new function for checking if SR-IOV can be configured based on the PF and/or device's state/capabilities. Also, simplify the flow in
ice_sriov_configure().
Quoted 5 lines
Signed-off-by Brett Creeley <[email protected]>Signed-off-by Tony Nguyen <[email protected]>--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 72 ++++++++++++------- 1 file changed, 48 insertions(+), 24 deletions(-)
Tony Nguyen
maintainerPATCH 3/15 ice: Add helper function for clearing VPGEN_VFRTRIG
In reply to Tony NguyenFrom: Brett Creeley <[email protected]>
Create a helper function for clearing VPGEN_VFRTRIG as this needs to be done on reset to notify the VF that we are done resetting it. Also, it needs to be done on SR-IOV initialization/creation in case it was left in a bad state after SR-IOV teardown.
--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-)
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +20 -11
@@ -961,6 +961,21 @@ static int ice_set_per_vf_res(struct ice_pf *pf)return 0 ; } +/** +* ice_clear_vf_reset_trigger - enable VF to access hardware +* @vf: VF to enabled hardware access for +*/ +static void ice_clear_vf_reset_trigger (struct ice_vf *vf) +{ +struct ice_hw *hw = &vf->pf->hw; +u32 reg; + + reg =rd32 (hw,VPGEN_VFRTRIG (vf->vf_id)); + reg &= ~VPGEN_VFRTRIG_VFSWR_M ; +wr32 (hw,VPGEN_VFRTRIG (vf->vf_id), reg); +ice_flush (hw); +} +/** * ice_cleanup_and_realloc_vf - Clean up VF and reallocate resources after reset * @vf: pointer to the VF structure
@@ -974,26 +989,20 @@ static void ice_cleanup_and_realloc_vf(struct ice_vf *vf) {struct ice_pf *pf = vf->pf;struct ice_hw *hw; -u32 reg; hw = &pf->hw; -/* PF software completes the flow by notifying VF that reset flow is -* completed. This is done by enabling hardware by clearing the reset -* bit in the VPGEN_VFRTRIG reg and setting VFR_STATE in the VFGEN_RSTAT -* register to VFR completed (done at the end of this function) -* By doing this we allow HW to access VF memory at any point. If we -* did it any sooner, HW could access memory while it was being freed -* in ice_free_vf_res(), causing an IOMMU fault. +/* Allow HW to access VF memory after calling +* ice_clear_vf_reset_trigger(). If we did it any sooner, HW could +* access memory while it was being freed in ice_free_vf_res(), causing +* an IOMMU fault. * * On the other hand, this needs to be done ASAP, because the VF driver * is waiting for this to happen and may report a timeout. It's * harmless, but it gets logged into Guest OS kernel log, so best avoid * it. */ - reg =rd32 (hw,VPGEN_VFRTRIG (vf->vf_id)); - reg &= ~VPGEN_VFRTRIG_VFSWR_M ; -wr32 (hw,VPGEN_VFRTRIG (vf->vf_id), reg); +ice_clear_vf_reset_trigger (vf);/* reallocate VF resources to finish resetting the VSI state */ if (!ice_alloc_vf_res (vf)) {
Signature · 1 line
2.20.1
Bowers
PATCH 3/15 ice: Add helper function for clearing VPGEN_VFRTRIG
Quoted 15 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Tony Nguyen
Sent: Friday, May 15, 2020 5:51 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S45 03/15] ice: Add helper function for clearingVPGEN_VFRTRIGFrom: Brett Creeley <[email protected]>
Create a helper function for clearing
VPGEN_VFRTRIGas this needs to be done on reset to notify the VF that we are done resetting it. Also, it needs to be done on SR-IOV initialization/creation in case it was left in a bad state after SR-IOV teardown.
Quoted 4 lines
Signed-off-by Brett Creeley <[email protected]>--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 31 ++++++++++++------- 1 file changed, 20 insertions(+), 11 deletions(-)
Tony Nguyen
maintainerPATCH 4/15 ice: Separate VF VSI initialization/creation from reset flow
In reply to Tony NguyenFrom: Brett Creeley <[email protected]>
Currently the same flow is used for VF VSI initialization/creation and VF VSI reset. This makes the initialization/creation flow unnecessarily complicated. Fix this by separating the initialization/creation of the VF VSI from the reset flow.
--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 110 +++++++++++++++++- 1 file changed, 106 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +106 -4
@@ -1375,6 +1375,99 @@ static void ice_vc_notify_vf_reset(struct ice_vf *vf) NULL); } +/** +* ice_init_vf_vsi_res - initialize/setup VF VSI resources +* @vf: VF to initialize/setup the VSI for +* +* This function creates a VSI for the VF, adds a VLAN 0 filter, and sets up the +* VF VSI's broadcast filter and is only used during initial VF creation. +*/ +static int ice_init_vf_vsi_res (struct ice_vf *vf) +{ +struct ice_pf *pf = vf->pf; +u8 broadcast[ETH_ALEN ]; +enum ice_status status; +struct ice_vsi *vsi; +struct device *dev; +int err; + + vf->first_vector_idx =ice_calc_vf_first_vector_idx (pf, vf); + + dev =ice_pf_to_dev (pf); + vsi =ice_vf_vsi_setup (pf, pf->hw.port_info, vf->vf_id); +if (!vsi) { +dev_err (dev,"Failed to create VF VSI\n" ); +return -ENOMEM ; + } + + vf->lan_vsi_idx = vsi->idx; + vf->lan_vsi_num = vsi->vsi_num; + + err =ice_vsi_add_vlan (vsi,0 ,ICE_FWD_TO_VSI ); +if (err) { +dev_warn (dev,"Failed to add VLAN 0 filter for VF %d\n" , + vf->vf_id); + goto release_vsi; + } + +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 %d, status %s\n" , + vf->vf_id,ice_stat_str (status)); + err =ice_status_to_errno (status); + goto release_vsi; + } + + vf->num_mac =1 ; + +return 0 ; + +release_vsi: +ice_vsi_release (vsi); +return err; +} + +/** +* ice_start_vfs - start VFs so they are ready to be used by SR-IOV +* @pf: PF the VFs are associated with +*/ +static int ice_start_vfs (struct ice_pf *pf) +{ +struct ice_hw *hw = &pf->hw; +int retval, i; + +ice_for_each_vf (pf, i) { +struct ice_vf *vf = &pf->vf[i]; + +ice_clear_vf_reset_trigger (vf); + + retval =ice_init_vf_vsi_res (vf); +if (retval) { +dev_err (ice_pf_to_dev (pf),"Failed to initialize VSI resources for VF %d, error %d\n" , + vf->vf_id, retval); + goto teardown; + } + +set_bit (ICE_VF_STATE_INIT , vf->vf_states); +ice_ena_vf_mappings (vf); +wr32 (hw,VFGEN_RSTAT (vf->vf_id),VIRTCHNL_VFR_VFACTIVE ); + } + +ice_flush (hw); +return 0 ; + +teardown: +for (i = i -1 ; i >=0 ; i--) { +struct ice_vf *vf = &pf->vf[i]; + +ice_dis_vf_mappings (vf); +ice_vsi_release (pf->vsi[vf->lan_vsi_idx]); + } + +return retval; +} +/** * ice_alloc_vfs - Allocate and set up VFs resources * @pf: pointer to the PF structure
@@ -1407,6 +1500,13 @@ static int ice_alloc_vfs(struct ice_pf *pf, u16 num_alloc_vfs) pf->vf = vfs; pf->num_alloc_vfs = num_alloc_vfs; +if (ice_set_per_vf_res (pf)) { +dev_err (dev,"Not enough resources for %d VFs, try with fewer number of VFs\n" , + num_alloc_vfs); + ret = -ENOSPC ; + goto err_unroll_sriov; + } +/* apply default profile */ ice_for_each_vf (pf, i) { vfs[i].pf = pf;
@@ -1416,15 +1516,17 @@ static int ice_alloc_vfs(struct ice_pf *pf, u16 num_alloc_vfs)/* assign default capabilities */ set_bit (ICE_VIRTCHNL_VF_CAP_L2 , &vfs[i].vf_caps); vfs[i].spoofchk = true; + vfs[i].num_vf_qs = pf->num_qps_per_vf; } -/* VF resources get allocated with initialization */ -if (!ice_config_res_vfs (pf)) { - ret = -EIO ; +if (ice_start_vfs (pf)) { +dev_err (dev,"Failed to start VF(s)\n" ); + ret = -EAGAIN ; goto err_unroll_sriov; } -return ret; +clear_bit (__ICE_VF_DIS, pf->state); +return 0 ; err_unroll_sriov: pf->vf =NULL ;
Signature · 1 line
2.20.1
Bowers
PATCH 4/15 ice: Separate VF VSI initialization/creation from reset flow
Quoted 15 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Tony Nguyen
Sent: Friday, May 15, 2020 5:51 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S45 04/15] ice: Separate VF VSI initialization/creation from reset flowFrom: Brett Creeley <[email protected]>
Currently the same flow is used for VF VSI initialization/creation and VF VSI reset. This makes the initialization/creation flow unnecessarily complicated. Fix this by separating the initialization/creation of the VF VSI from the reset flow.
Quoted 4 lines
Signed-off-by Brett Creeley <[email protected]>--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 110 +++++++++++++++++- 1 file changed, 106 insertions(+), 4 deletions(-)
Tony Nguyen
maintainerPATCH 5/15 ice: Renaming and simplification in VF init path
In reply to Tony NguyenFrom: Brett Creeley <[email protected]>
Some function names weren't very clear and some portions of VF creation could be moved into functions for clarity. Fix this by renaming some functions and move pieces of code into clearly name functions.
--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 83 ++++++++++++------- 1 file changed, 54 insertions(+), 29 deletions(-)
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +54 -29
@@ -1469,16 +1469,56 @@ static int ice_start_vfs(struct ice_pf *pf) }/** -* ice_alloc_vfs - Allocate and set up VFs resources +* ice_set_dflt_settings - set VF defaults during initialization/creation +* @pf: PF holding reference to all VFs for default configuration +*/ +static void ice_set_dflt_settings_vfs (struct ice_pf *pf) +{ +int i; + +ice_for_each_vf (pf, i) { +struct ice_vf *vf = &pf->vf[i]; + + vf->pf = pf; + vf->vf_id = i; + vf->vf_sw_id = pf->first_sw; +/* assign default capabilities */ +set_bit (ICE_VIRTCHNL_VF_CAP_L2 , &vf->vf_caps); + vf->spoofchk = true; + vf->num_vf_qs = pf->num_qps_per_vf; + } +} + +/** +* ice_alloc_vfs - allocate num_vfs in the PF structure +* @pf: PF to store the allocated VFs in +* @num_vfs: number of VFs to allocate +*/ +static int ice_alloc_vfs (struct ice_pf *pf,int num_vfs) +{ +struct ice_vf *vfs; + + vfs =devm_kcalloc (ice_pf_to_dev (pf), num_vfs,sizeof (*vfs), +GFP_KERNEL ); +if (!vfs) +return -ENOMEM ; + + pf->vf = vfs; + pf->num_alloc_vfs = num_vfs; + +return 0 ; +} + +/** +* ice_ena_vfs - enable VFs so they are ready to be used * @pf: pointer to the PF structure -* @num_alloc_vfs: number of VFs to allocate +* @num_vfs: number of VFs to enable */ -static int ice_alloc_vfs (struct ice_pf *pf,u16 num_alloc_vfs) +static int ice_ena_vfs (struct ice_pf *pf,u16 num_vfs) {struct device *dev =ice_pf_to_dev (pf);struct ice_hw *hw = &pf->hw; -struct ice_vf *vfs; -int i, ret; +int ret;/* Disable global interrupt 0 so we don't try to handle the VFLR. */ wr32(hw, GLINT_DYN_CTL(pf->oicr_idx),
@@ -1486,38 +1526,24 @@ static int ice_alloc_vfs(struct ice_pf *pf, u16 num_alloc_vfs)set_bit (__ICE_OICR_INTR_DIS, pf->state);ice_flush (hw); - ret =pci_enable_sriov (pf->pdev, num_alloc_vfs); + ret =pci_enable_sriov (pf->pdev, num_vfs);if (ret) { pf->num_alloc_vfs =0 ; goto err_unroll_intr; } -/* allocate memory */ - vfs =devm_kcalloc (dev, num_alloc_vfs,sizeof (*vfs),GFP_KERNEL ); -if (!vfs) { - ret = -ENOMEM ; + + ret =ice_alloc_vfs (pf, num_vfs); +if (ret) goto err_pci_disable_sriov; - } - pf->vf = vfs; - pf->num_alloc_vfs = num_alloc_vfs;if (ice_set_per_vf_res (pf)) {dev_err (dev,"Not enough resources for %d VFs, try with fewer number of VFs\n" , - num_alloc_vfs); + num_vfs); ret = -ENOSPC ; goto err_unroll_sriov; } -/* apply default profile */ -ice_for_each_vf (pf, i) { - vfs[i].pf = pf; - vfs[i].vf_sw_id = pf->first_sw; - vfs[i].vf_id = i; - -/* assign default capabilities */ -set_bit (ICE_VIRTCHNL_VF_CAP_L2 , &vfs[i].vf_caps); - vfs[i].spoofchk = true; - vfs[i].num_vf_qs = pf->num_qps_per_vf; - } +ice_set_dflt_settings_vfs (pf);if (ice_start_vfs (pf)) {dev_err (dev,"Failed to start VF(s)\n" );
@@ -1529,9 +1555,8 @@ static int ice_alloc_vfs(struct ice_pf *pf, u16 num_alloc_vfs)return 0 ; err_unroll_sriov: +devm_kfree (dev, pf->vf); pf->vf =NULL ; -devm_kfree (dev, vfs); - vfs =NULL ; pf->num_alloc_vfs =0 ; err_pci_disable_sriov:pci_disable_sriov (pf->pdev);
@@ -1566,8 +1591,8 @@ static int ice_pci_sriov_ena(struct ice_pf *pf, int num_vfs)return -EOPNOTSUPP ; } -dev_info (dev,"Allocating %d VFs\n" , num_vfs); - err =ice_alloc_vfs (pf, num_vfs); +dev_info (dev,"Enabling %d VFs\n" , num_vfs); + err =ice_ena_vfs (pf, num_vfs);if (err) {dev_err (dev,"Failed to enable SR-IOV: %d\n" , err);return err;
Signature · 1 line
2.20.1
Bowers
PATCH 5/15 ice: Renaming and simplification in VF init path
Quoted 10 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Tony Nguyen
Sent: Friday, May 15, 2020 5:51 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S45 05/15] ice: Renaming and simplification in VF init pathFrom: Brett Creeley <[email protected]>
Quoted 8 lines
Some function names weren't very clear and some portions of VF creation could be moved into functions for clarity. Fix this by renaming some functions and move pieces of code into clearly name functions.
Signed-off-by Brett Creeley <[email protected]>--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 83 ++++++++++++------- 1 file changed, 54 insertions(+), 29 deletions(-)
Tony Nguyen
maintainerPATCH 6/15 ice: Add function to set trust mode bit on reset
In reply to Tony NguyenFrom: Brett Creeley <[email protected]>
As the title says, use a function to set trust mode bit on reset.
--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +13 -4
@@ -610,6 +610,18 @@ static int ice_alloc_vsi_res(struct ice_vf *vf)return status; } +/** +* ice_vf_set_host_trust_cfg - set trust setting based on pre-reset value +* @vf: VF to configure trust setting for +*/ +static void ice_vf_set_host_trust_cfg (struct ice_vf *vf) +{ +if (vf->trusted) +set_bit (ICE_VIRTCHNL_VF_CAP_PRIVILEGE , &vf->vf_caps); +else +clear_bit (ICE_VIRTCHNL_VF_CAP_PRIVILEGE , &vf->vf_caps); +} +/** * ice_alloc_vf_res - Allocate VF resources * @vf: pointer to the VF structure
@@ -635,10 +647,7 @@ static int ice_alloc_vf_res(struct ice_vf *vf)if (status) goto ice_alloc_vf_res_exit; -if (vf->trusted) -set_bit (ICE_VIRTCHNL_VF_CAP_PRIVILEGE , &vf->vf_caps); -else -clear_bit (ICE_VIRTCHNL_VF_CAP_PRIVILEGE , &vf->vf_caps); +ice_vf_set_host_trust_cfg (vf);/* VF is now completely initialized */ set_bit (ICE_VF_STATE_INIT , vf->vf_states);
Signature · 1 line
2.20.1
Bowers
PATCH 6/15 ice: Add function to set trust mode bit on reset
Quoted 8 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Tony Nguyen
Sent: Friday, May 15, 2020 5:51 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S45 06/15] ice: Add function to set trust mode bit on reset
Quoted 8 lines
From: Brett Creeley <[email protected]>
As the title says, use a function to set trust mode bit on reset.
Signed-off-by Brett Creeley <[email protected]>--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-)
Tony Nguyen
maintainerPATCH 7/15 ice: Add functions to rebuild host VLAN/MAC config for a VF
In reply to Tony NguyenFrom: Brett Creeley <[email protected]>
When resetting a VF the VLAN and MAC filter configurations need to be replayed. Add helper functions for this purpose.
--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 121 +++++++++++++----- 1 file changed, 89 insertions(+), 32 deletions(-)
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +89 -32
@@ -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; } +/** +* 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 * @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) {struct ice_pf *pf = vf->pf; -u8 broadcast[ETH_ALEN ];struct ice_vsi *vsi;struct device *dev; -int status =0 ; +int ret; dev =ice_pf_to_dev (pf);/* 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_num = vsi->vsi_num; -/* Check if port VLAN exist before, and restore it accordingly */ -if (vf->port_vlan_info) { -ice_vsi_manage_pvid (vsi, vf->port_vlan_info, true); -if (ice_vsi_add_vlan (vsi, vf->port_vlan_info &VLAN_VID_MASK , -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); + ret =ice_vf_rebuild_host_vlan_cfg (vf); +if (ret) { +dev_err (dev,"failed to rebuild default MAC configuration for VF %d, error %d\n" , + vf->vf_id, ret); + goto ice_alloc_vsi_res_exit; } -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; - } -eth_broadcast_addr (broadcast); - status =ice_fltr_add_mac (vsi, broadcast,ICE_FWD_TO_VSI ); -if (status) -dev_err (dev,"could not add mac filters error %d\n" , - status); -else - vf->num_mac =1 ; + ret =ice_vf_rebuild_host_mac_cfg (vf); +if (ret) { +dev_err (dev,"failed to rebuild default MAC configuration for VF %d, error %d\n" , + vf->vf_id, ret); + goto ice_alloc_vsi_res_exit; + }/* Clear this bit after VF initialization since we shouldn't reclaim * 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. */ ice_alloc_vsi_res_exit: -return status; +return ret; }/**
Signature · 1 line
2.20.1
Bowers
PATCH 7/15 ice: Add functions to rebuild host VLAN/MAC config for a VF
Quoted 10 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Tony Nguyen
Sent: Friday, May 15, 2020 5:51 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S45 07/15] ice: Add functions to rebuild host VLAN/MAC config for a VFFrom: Brett Creeley <[email protected]>
Quoted 8 lines
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 <[email protected]>Signed-off-by Tony Nguyen <[email protected]>--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 121 +++++++++++++----- 1 file changed, 89 insertions(+), 32 deletions(-)
Tony Nguyen
maintainerPATCH 8/15 ice: remove VM/VF disable command on CORER/GLOBR reset
In reply to Tony NguyenFrom: Paul Greenwalt <[email protected]>
Remove VM/VF disable AQC (opcode 0x0C31) when resetting all VFs. This is not required for CORER/GLOBR reset.
--- drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c | 11 ----------- 1 file changed, 11 deletions(-)
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +0 -11
@@ -1196,17 +1196,6 @@ bool ice_reset_all_vfs(struct ice_pf *pf, bool is_vflr)ice_for_each_vf (pf, v)ice_trigger_vf_reset (&pf->vf[v], is_vflr, true); -ice_for_each_vf (pf, v) { -struct ice_vsi *vsi; - - vf = &pf->vf[v]; - vsi = pf->vsi[vf->lan_vsi_idx]; -if (test_bit (ICE_VF_STATE_QS_ENA , vf->vf_states)) -ice_dis_vf_qs (vf); -ice_dis_vsi_txq (vsi->port_info, vsi->idx,0 ,0 ,NULL ,NULL , -NULL ,ICE_VF_RESET , vf->vf_id,NULL ); - } -/* HW requires some time to make sure it can flush the FIFO for a VF * when it resets it. Poll the VPGEN_VFRSTAT register for each VF in * sequence to make sure that it has completed. We'll keep track of
Signature · 1 line
2.20.1
Bowers
PATCH 8/15 ice: remove VM/VF disable command on CORER/GLOBR reset
Quoted 10 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Tony Nguyen
Sent: Friday, May 15, 2020 5:51 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S45 08/15] ice: remove VM/VF disable command on CORER/GLOBR resetFrom: Paul Greenwalt <[email protected]>
Quoted 7 lines
Remove VM/VF disable AQC (opcode
0x0C31) when resetting all VFs. This is not required for CORER/GLOBR reset.Signed-off-by Paul Greenwalt <[email protected]>--- drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c | 11 ----------- 1 file changed, 11 deletions(-)
Tony Nguyen
maintainerPATCH 9/15 ice: Refactor VF reset
In reply to Tony NguyenFrom: Brett Creeley <[email protected]>
Currently VF VSI are being reset twice during a PFR or greater. This is causing reset, specifically resetting all VFs, to take too long. This is causing various issues with VF drivers not being able to gracefully handle the VF reset timeout. Fix this by refactoring how VF reset is handled for the case mentioned previously and for the VFR/VFLR case.
The refactor was done by doing the following:
1. Removing the call to ice_vsi_rebuild_by_type for ICE_VSI_VF VSI, which was causing the initial VSI rebuild.
2. Adding functions for pre/post VSI rebuild functions that can be called in both the reset all VFs case and reset individual VF case.
3. Adding VSI rebuild functions that are specific for the reset all VFs case and adding functions that are specific for the reset individual VF case.
4. Calling the pre-rebuild function, then the specific VSI rebuild function based on the reset type, and then calling the post-rebuild function to handle VF resets.
This patch series makes some assumptions about how VSI are handling by FW during reset:
1. During a PFR or greater all VSI in FW will be cleared.
2. During a VFR/VFLR the VSI rebuild responsibility is in the hands of the PF software.
3. There is code in the ice_reset_all_vfs() case to amortize operations if possible. This was left intact.
4. PF software should not be replaying VSI based filters that were added other than host configured, PF software configured, or the VF's default/LAA MAC. This is the VF drivers job after it has been reset.
--- drivers/net/ethernet/intel/ice/ice_main.c | 12 +- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 304 +++++++----------- 2 files changed, 130 insertions(+), 186 deletions(-)
drivers/net/ethernet/intel/ice/ice_main.c +5 -7
@@ -4959,6 +4959,11 @@ static void ice_update_pf_netdev_link(struct ice_pf *pf)* ice_rebuild - rebuild after reset * @pf: PF to rebuild * @reset_type: type of reset +* +* Do not rebuild VF VSI in this flow because that is already handled via +* ice_reset_all_vfs(). This is because requirements for resetting a VF after a +* PFR/CORER/GLOBER/etc. are different than the normal flow. Also, we don't want +* to reset/rebuild all the VF VSI twice. */ static void ice_rebuild (struct ice_pf *pf,enum ice_reset_req reset_type) {
@@ -5064,13 +5069,6 @@ static void ice_rebuild(struct ice_pf *pf, enum ice_reset_req reset_type) }ice_for_each_peer (pf, vsi, ice_peer_update_vsi); } -if (test_bit (ICE_FLAG_SRIOV_ENA , pf->flags)) { - err =ice_vsi_rebuild_by_type (pf,ICE_VSI_VF ); -if (err) { -dev_err (dev,"VF VSI rebuild failed: %d\n" , err); - goto err_vsi_rebuild; - } - }/* If Flow Director is active */ if (test_bit (ICE_FLAG_FD_ENA , pf->flags)) {
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +125 -179
360 lines not on this page · raw message
Signature · 1 line
2.20.1
Bowers
PATCH 9/15 ice: Refactor VF reset
Quoted 43 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Tony Nguyen
Sent: Friday, May 15, 2020 5:51 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S45 09/15] ice: Refactor VF resetFrom: Brett Creeley <[email protected]>
Currently VF VSI are being reset twice during a PFR or greater. This is causing reset, specifically resetting all VFs, to take too long. This is causing various issues with VF drivers not being able to gracefully handle the VF reset timeout. Fix this by refactoring how VF reset is handled for the case mentioned previously and for the VFR/VFLR case.
The refactor was done by doing the following:
1. Removing the call to
ice_vsi_rebuild_by_typeforICE_VSI_VFVSI, which was causing the initial VSI rebuild.2. Adding functions for pre/post VSI rebuild functions that can be called in both the reset all VFs case and reset individual VF case.
3. Adding VSI rebuild functions that are specific for the reset all VFs case and adding functions that are specific for the reset individual VF case.
4. Calling the pre-rebuild function, then the specific VSI rebuild function based on the reset type, and then calling the post-rebuild function to handle VF resets.
This patch series makes some assumptions about how VSI are handling by FW during reset:
1. During a PFR or greater all VSI in FW will be cleared.
2. During a VFR/VFLR the VSI rebuild responsibility is in the hands of the PF software.
3. There is code in theice_reset_all_vfs()case to amortize operations if possible. This was left intact.
4. PF software should not be replaying VSI based filters that were added other than host configured, PF software configured, or the VF's default/LAA MAC. This is the VF drivers job after it has been reset.
Quoted 5 lines
Signed-off-by Brett Creeley <[email protected]>--- drivers/net/ethernet/intel/ice/ice_main.c | 12 +- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 304 +++++++----------- 2 files changed, 130 insertions(+), 186 deletions(-)
Tony Nguyen
maintainerPATCH 10/15 ice: Refactor VF VSI release and setup functions
In reply to Tony NguyenFrom: Brett Creeley <[email protected]>
Currently when a VF VSI calls ice_vsi_release() and ice_vsi_setup() it subsequently clears/sets the VF cached variables for lan_vsi_idx and lan_vsi_num. This works fine, but can be improved by handling this in the VF specific VSI release and setup functions.
Also, when a VF VSI is setup too many parameters are passed that can be derived from the VF. Fix this by only calling VF VSI setup with the bare minimum parameters.
Also, add functionality to invalidate a VF's VSI when it's released and/or setup fails. This will make it so a VF VSI cannot be accessed via its cached vsi_idx/vsi_num in these cases.
Finally when a VF's VSI is invalidated set the lan_vsi_idx and lan_vsi_num to ICE_NO_VSI to clearly show that there is no valid VSI associated with this VF.
--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 86 ++++++++++++------- 1 file changed, 55 insertions(+), 31 deletions(-)
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +55 -31
@@ -181,6 +181,26 @@ static void ice_vc_notify_vf_link_state(struct ice_vf *vf) sizeof(pfe), NULL); } +/** +* ice_vf_invalidate_vsi - invalidate vsi_idx/vsi_num to remove VSI access +* @vf: VF to remove access to VSI for +*/ +static void ice_vf_invalidate_vsi (struct ice_vf *vf) +{ + vf->lan_vsi_idx =ICE_NO_VSI ; + vf->lan_vsi_num =ICE_NO_VSI ; +} + +/** +* ice_vf_vsi_release - invalidate the VF's VSI after freeing it +* @vf: invalidate this VF's VSI after freeing it +*/ +static void ice_vf_vsi_release (struct ice_vf *vf) +{ +ice_vsi_release (vf->pf->vsi[vf->lan_vsi_idx]); +ice_vf_invalidate_vsi (vf); +} +/** * ice_free_vf_res - Free a VF's resources * @vf: pointer to the VF info
@@ -196,10 +216,8 @@ static void ice_free_vf_res(struct ice_vf *vf)clear_bit (ICE_VF_STATE_INIT , vf->vf_states);/* free VSI and disconnect it from the parent uplink */ -if (vf->lan_vsi_idx) { -ice_vsi_release (pf->vsi[vf->lan_vsi_idx]); - vf->lan_vsi_idx =0 ; - vf->lan_vsi_num =0 ; +if (vf->lan_vsi_idx !=ICE_NO_VSI ) { +ice_vf_vsi_release (vf); vf->num_mac =0 ; }
@@ -505,19 +523,40 @@ static int ice_vsi_manage_pvid(struct ice_vsi *vsi, u16 pvid_info, bool enable)return ret; } +/** +* ice_vf_get_port_info - Get the VF's port info structure +* @vf: VF used to get the port info structure for +*/ +static struct ice_port_info *ice_vf_get_port_info (struct ice_vf *vf) +{ +return vf->pf->hw.port_info; +} +/** * ice_vf_vsi_setup - Set up a VF VSI -* @pf: board private structure -* @pi: pointer to the port_info instance -* @vf_id: defines VF ID to which this VSI connects. +* @vf: VF to setup VSI for * * Returns pointer to the successfully allocated VSI struct on success, * otherwise returns NULL on failure. */ -static struct ice_vsi * -ice_vf_vsi_setup (struct ice_pf *pf,struct ice_port_info *pi,u16 vf_id) +static struct ice_vsi *ice_vf_vsi_setup (struct ice_vf *vf) { -return ice_vsi_setup (pf, pi,ICE_VSI_VF , vf_id); +struct ice_port_info *pi =ice_vf_get_port_info (vf); +struct ice_pf *pf = vf->pf; +struct ice_vsi *vsi; + + vsi =ice_vsi_setup (pf, pi,ICE_VSI_VF , vf->vf_id); + +if (!vsi) { +dev_err (ice_pf_to_dev (pf),"Failed to create VF VSI\n" ); +ice_vf_invalidate_vsi (vf); +return NULL ; + } + + vf->lan_vsi_idx = vsi->idx; + vf->lan_vsi_num = vsi->vsi_num; + +return vsi; }/**
@@ -1043,19 +1082,9 @@ static void ice_vf_rebuild_host_cfg(struct ice_vf *vf)*/ static int ice_vf_rebuild_vsi_with_release (struct ice_vf *vf) { -struct ice_pf *pf = vf->pf; -struct ice_vsi *vsi; - - vsi = pf->vsi[vf->lan_vsi_idx]; -ice_vsi_release (vsi); - vsi =ice_vf_vsi_setup (pf, pf->hw.port_info, vf->vf_id); -if (!vsi) { -dev_err (ice_pf_to_dev (pf),"Failed to create VF VSI\n" ); +ice_vf_vsi_release (vf); +if (!ice_vf_vsi_setup (vf))return -ENOMEM ; - } - - vf->lan_vsi_idx = vsi->idx; - vf->lan_vsi_num = vsi->vsi_num;return 0 ; }
@@ -1395,14 +1424,9 @@ static int ice_init_vf_vsi_res(struct ice_vf *vf) vf->first_vector_idx =ice_calc_vf_first_vector_idx (pf, vf); dev =ice_pf_to_dev (pf); - vsi =ice_vf_vsi_setup (pf, pf->hw.port_info, vf->vf_id); -if (!vsi) { -dev_err (dev,"Failed to create VF VSI\n" ); + vsi =ice_vf_vsi_setup (vf); +if (!vsi)return -ENOMEM ; - } - - vf->lan_vsi_idx = vsi->idx; - vf->lan_vsi_num = vsi->vsi_num; err =ice_vsi_add_vlan (vsi,0 ,ICE_FWD_TO_VSI );if (err) {
@@ -1425,7 +1449,7 @@ static int ice_init_vf_vsi_res(struct ice_vf *vf)return 0 ; release_vsi: -ice_vsi_release (vsi); +ice_vf_vsi_release (vf);return err; }
@@ -1463,7 +1487,7 @@ static int ice_start_vfs(struct ice_pf *pf)struct ice_vf *vf = &pf->vf[i];ice_dis_vf_mappings (vf); -ice_vsi_release (pf->vsi[vf->lan_vsi_idx]); +ice_vf_vsi_release (vf); }return retval;
Signature · 1 line
2.20.1
Bowers
PATCH 10/15 ice: Refactor VF VSI release and setup functions
Quoted 23 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Tony Nguyen
Sent: Friday, May 15, 2020 5:51 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S45 10/15] ice: Refactor VF VSI release and setup functionsFrom: Brett Creeley <[email protected]>
Currently when a VF VSI calls
ice_vsi_release()andice_vsi_setup()it subsequently clears/sets the VF cached variables forlan_vsi_idxandlan_vsi_num. This works fine, but can be improved by handling this in the VF specific VSI release and setup functions.Also, when a VF VSI is setup too many parameters are passed that can be derived from the VF. Fix this by only calling VF VSI setup with the bare minimum parameters.
Also, add functionality to invalidate a VF's VSI when it's released and/or setup fails. This will make it so a VF VSI cannot be accessed via its cached vsi_idx/vsi_num in these cases.
Quoted 7 lines
Finally when a VF's VSI is invalidated set the
lan_vsi_idxandlan_vsi_numtoICE_NO_VSIto clearly show that there is no valid VSI associated with this VF.Signed-off-by Brett Creeley <[email protected]>--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 86 ++++++++++++------- 1 file changed, 55 insertions(+), 31 deletions(-)
Tony Nguyen
maintainerPATCH 11/15 ice: allow host to clear administratively set VF MAC
In reply to Tony NguyenFrom: Brett Creeley <[email protected]>
Currently a user is not allowed to clear a VF's administratively set MAC on the PF. Fix this by allowing an all zero MAC address via "ip link set ${pf_eth} vf ${vf_id} mac 00:00:00:00:00:00".
An example use case for this would be issuing a "virsh shutdown" command on a VM. The call to iproute mentioned above is part of this flow. Without this change the driver incorrectly rejects clearing the VF's administratively set MAC and prints unhelpful log messages.
Also, improve the comments surrounding this change.
--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-)
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c +14 -8
@@ -3912,7 +3912,7 @@ int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac)if (ice_validate_vf_id (pf, vf_id))return -EINVAL ; -if (is_zero_ether_addr (mac) ||is_multicast_ether_addr (mac)) { +if (is_multicast_ether_addr (mac)) {netdev_err (netdev,"%pM not a valid unicast address\n" , mac);return -EINVAL ; }
@@ -3932,15 +3932,21 @@ int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac)return -EINVAL ; } -/* copy MAC into dflt_lan_addr and trigger a VF reset. The reset -* flow will use the updated dflt_lan_addr and add a MAC filter -* using ice_add_mac. Also set pf_set_mac to indicate that the PF has -* set the MAC address for this VF. +/* VF is notified of its new MAC via the PF's response to the +* VIRTCHNL_OP_GET_VF_RESOURCES message after the VF has been reset */ ether_addr_copy (vf->dflt_lan_addr.addr, mac); - vf->pf_set_mac = true; -netdev_info (netdev,"MAC on VF %d set to %pM. VF driver will be reinitialized\n" , - vf_id, mac); +if (is_zero_ether_addr (mac)) { +/* VF will send VIRTCHNL_OP_ADD_ETH_ADDR message with its MAC */ + vf->pf_set_mac = false; +netdev_info (netdev,"Removing MAC on VF %d. VF driver will be reinitialized\n" , + vf->vf_id); + }else { +/* PF will add MAC rule for the VF */ + vf->pf_set_mac = true; +netdev_info (netdev,"Setting MAC %pM on VF %d. VF driver will be reinitialized\n" , + mac, vf_id); + }ice_vc_reset_vf (vf);return 0 ;
Signature · 1 line
2.20.1
Bowers
PATCH 11/15 ice: allow host to clear administratively set VF MAC
Quoted 19 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Tony Nguyen
Sent: Friday, May 15, 2020 5:51 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S45 11/15] ice: allow host to clear administratively set VF MACFrom: Brett Creeley <[email protected]>
Currently a user is not allowed to clear a VF's administratively set MAC on the PF. Fix this by allowing an all zero MAC address via "ip link set ${pf_eth} vf ${vf_id} mac 00:00:00:00:00:00".
An example use case for this would be issuing a "virsh shutdown" command on a VM. The call to iproute mentioned above is part of this flow. Without this change the driver incorrectly rejects clearing the VF's administratively set MAC and prints unhelpful log messages.
Quoted 6 lines
Also, improve the comments surrounding this change.
Signed-off-by Brett Creeley <[email protected]>--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-)
Tony Nguyen
maintainerPATCH 12/15 ice: support adding 16 unicast/multicast filter on untrusted VF
In reply to Tony NguyenFrom: Paul Greenwalt <[email protected]>
Allow untrusted VF to add 16 unicast/multicast filters. VF uses 1 filter for the default/perm_addr/LAA MAC, 1 for broadcast, and 16 additional unicast/multicast filters.
--- drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h +4 -1
@@ -7,7 +7,10 @@/* Restrict number of MAC Addr and VLAN that non-trusted VF can programmed */ #define ICE_MAX_VLAN_PER_VF 8 -#define ICE_MAX_MACADDR_PER_VF 12 +/* MAC filters: 1 is reserved for the VF's default/perm_addr/LAA MAC, 1 for +* broadcast, and 16 for additional unicast/multicast filters +*/ +#define ICE_MAX_MACADDR_PER_VF 18/* Malicious Driver Detection */ #define ICE_DFLT_NUM_INVAL_MSGS_ALLOWED 10
Signature · 1 line
2.20.1
Bowers
PATCH 12/15 ice: support adding 16 unicast/multicast filter on untrusted VF
Quoted 10 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Tony Nguyen
Sent: Friday, May 15, 2020 5:51 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S45 12/15] ice: support adding 16 unicast/multicast filter on untrusted VFFrom: Paul Greenwalt <[email protected]>
Quoted 8 lines
Allow untrusted VF to add 16 unicast/multicast filters. VF uses 1 filter for the default/perm_addr/LAA MAC, 1 for broadcast, and 16 additional unicast/multicast filters.
Signed-off-by Paul Greenwalt <[email protected]>--- drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
Tony Nguyen
maintainerPATCH 13/15 ice: Fix transmit for all software offloaded VLANs
In reply to Tony NguyenFrom: Brett Creeley <[email protected]>
Currently the driver does not recognize when there is an 802.1AD VLAN tag right after the dmac/smac (outermost VLAN tag). If any DCB map is applied and/or DCB is enabled this is causing the hardware to insert a VLAN 0 tag after the 802.1AD VLAN tag that is already in the packet. Fix this by preventing VLAN tag 0 from being added when any VLAN is already present after dmac/smac (software offloaded) or skb (hardware offloaded).
--- drivers/net/ethernet/intel/ice/ice_dcb_lib.c | 28 +++++------- drivers/net/ethernet/intel/ice/ice_dcb_lib.h | 2 +- drivers/net/ethernet/intel/ice/ice_txrx.c | 45 +++++--------------- 3 files changed, 21 insertions(+), 54 deletions(-)
drivers/net/ethernet/intel/ice/ice_dcb_lib.c +10 -18
@@ -828,39 +828,31 @@ void ice_update_dcb_stats(struct ice_pf *pf)* ice_tx_prepare_vlan_flags_dcb - prepare VLAN tagging for DCB * @tx_ring: ring to send buffer on * @first: pointer to struct ice_tx_buf +* +* This should not be called if the outer VLAN is software offloaded as the VLAN +* tag will already be configured with the correct ID and priority bits */ -int +void ice_tx_prepare_vlan_flags_dcb (struct ice_ring *tx_ring,struct ice_tx_buf *first) {struct sk_buff *skb = first->skb;if (!test_bit (ICE_FLAG_DCB_ENA , tx_ring->vsi->back->flags)) -return 0 ; +return ;/* Insert 802.1p priority into VLAN header */ -if ((first->tx_flags & (ICE_TX_FLAGS_HW_VLAN |ICE_TX_FLAGS_SW_VLAN )) || +if ((first->tx_flags &ICE_TX_FLAGS_HW_VLAN ) || skb->priority !=TC_PRIO_CONTROL ) { first->tx_flags &= ~ICE_TX_FLAGS_VLAN_PR_M ;/* Mask the lower 3 bits to set the 802.1p priority */ first->tx_flags |= (skb->priority &0x7 ) <<ICE_TX_FLAGS_VLAN_PR_S ; -if (first->tx_flags &ICE_TX_FLAGS_SW_VLAN ) { -struct vlan_ethhdr *vhdr; -int rc; - - rc =skb_cow_head (skb,0 ); -if (rc <0 ) -return rc; - vhdr = (struct vlan_ethhdr *)skb->data; - vhdr->h_vlan_TCI =htons (first->tx_flags >> -ICE_TX_FLAGS_VLAN_S ); - }else { - first->tx_flags |=ICE_TX_FLAGS_HW_VLAN ; - } +/* if this is not already set it means a VLAN 0 + priority needs +* to be offloaded +*/ + first->tx_flags |=ICE_TX_FLAGS_HW_VLAN ; } - -return 0 ; }/**
drivers/net/ethernet/intel/ice/ice_dcb_lib.h +1 -1
@@ -27,7 +27,7 @@ void ice_pf_dcb_recfg(struct ice_pf *pf);void ice_vsi_cfg_dcb_rings (struct ice_vsi *vsi);int ice_init_pf_dcb (struct ice_pf *pf,bool locked);void ice_update_dcb_stats (struct ice_pf *pf); -int +void ice_tx_prepare_vlan_flags_dcb (struct ice_ring *tx_ring,struct ice_tx_buf *first);void
drivers/net/ethernet/intel/ice/ice_txrx.c +10 -35
67 lines not on this page · raw message
Signature · 1 line
2.20.1
Bowers
PATCH 13/15 ice: Fix transmit for all software offloaded VLANs
Quoted 18 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Tony Nguyen
Sent: Friday, May 15, 2020 5:51 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S45 13/15] ice: Fix transmit for all software offloaded VLANsFrom: Brett Creeley <[email protected]>
Currently the driver does not recognize when there is an 802.1AD VLAN tag right after the dmac/smac (outermost VLAN tag). If any DCB map is applied and/or DCB is enabled this is causing the hardware to insert a VLAN 0 tag after the 802.1AD VLAN tag that is already in the packet.
Fix this by preventing VLAN tag 0 from being added when any VLAN is already present after dmac/smac (software offloaded) or skb (hardware offloaded).
Quoted 6 lines
Signed-off-by Brett Creeley <[email protected]>--- drivers/net/ethernet/intel/ice/ice_dcb_lib.c | 28 +++++------- drivers/net/ethernet/intel/ice/ice_dcb_lib.h | 2 +- drivers/net/ethernet/intel/ice/ice_txrx.c | 45 +++++--------------- 3 files changed, 21 insertions(+), 54 deletions(-)
Tony Nguyen
maintainerPATCH 14/15 ice: Increase timeout after PFR
In reply to Tony NguyenFrom: Dan Nowlin <[email protected]>
To allow for resets during package download, increase the timeout period after performing a PFR. The time waited is the global config lock timeout plus the normal PFSWR timeout.
--- drivers/net/ethernet/intel/ice/ice_common.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_common.c +6 -1
@@ -965,7 +965,12 @@ static enum ice_status ice_pf_reset(struct ice_hw *hw)wr32 (hw,PFGEN_CTRL , (reg |PFGEN_CTRL_PFSWR_M )); -for (cnt =0 ; cnt <ICE_PF_RESET_WAIT_COUNT ; cnt++) { +/* Wait for the PFR to complete. The wait time is the global config lock +* timeout plus the PFR timeout which will account for a possible reset +* that is occurring during a download package operation. +*/ +for (cnt =0 ; cnt <ICE_GLOBAL_CFG_LOCK_TIMEOUT + +ICE_PF_RESET_WAIT_COUNT ; cnt++) { reg =rd32 (hw,PFGEN_CTRL );if (!(reg &PFGEN_CTRL_PFSWR_M ))break ;
Signature · 1 line
2.20.1
Bowers
PATCH 14/15 ice: Increase timeout after PFR
Quoted 9 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Tony Nguyen
Sent: Friday, May 15, 2020 5:51 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S45 14/15] ice: Increase timeout after PFRFrom: Dan Nowlin <[email protected]>
Quoted 8 lines
To allow for resets during package download, increase the timeout period after performing a PFR. The time waited is the global config lock timeout plus the normal PFSWR timeout.
Signed-off-by Dan Nowlin <[email protected]>--- drivers/net/ethernet/intel/ice/ice_common.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-)
Tony Nguyen
maintainerPATCH 15/15 ice: Update ICE_PHY_TYPE_HIGH_MAX_INDEX value
In reply to Tony NguyenFrom: Chinh T Cao <[email protected]>
As currently, we are supporting only 5 PHY_SPEEDs for phy_type_high. Thus, we should adjust the value of ICE_PHY_TYPE_HIGH_MAX_INDEX to 5.
--- drivers/net/ethernet/intel/ice/ice_adminq_cmd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h +1 -1
@@ -975,7 +975,7 @@ struct ice_aqc_get_phy_caps {#define ICE_PHY_TYPE_HIGH_100G_CAUI2 BIT_ULL(2)#define ICE_PHY_TYPE_HIGH_100G_AUI2_AOC_ACC BIT_ULL(3)#define ICE_PHY_TYPE_HIGH_100G_AUI2 BIT_ULL(4) -#define ICE_PHY_TYPE_HIGH_MAX_INDEX 19 +#define ICE_PHY_TYPE_HIGH_MAX_INDEX 5struct ice_aqc_get_phy_caps_data {__le64 phy_type_low;/* Use values from ICE_PHY_TYPE_LOW_* */
Signature · 1 line
2.20.1
Bowers
PATCH 15/15 ice: Update ICE_PHY_TYPE_HIGH_MAX_INDEX value
Quoted 10 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Tony Nguyen
Sent: Friday, May 15, 2020 5:51 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S45 15/15] ice: UpdateICE_PHY_TYPE_HIGH_MAX_INDEXvalueFrom: Chinh T Cao <[email protected]>
Quoted 7 lines
As currently, we are supporting only 5
PHY_SPEEDsforphy_type_high. Thus, we should adjust the value ofICE_PHY_TYPE_HIGH_MAX_INDEXto 5.Signed-off-by Chinh T Cao <[email protected]>--- drivers/net/ethernet/intel/ice/ice_adminq_cmd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Bowers
PATCH 1/15 ice: Refactor ice_ena_vf_mappings to split MSIX and queue mappings
In reply to Tony NguyenQuoted 15 lines
-----Original Message-----
From: Intel-wired-lan <[email protected]> On Behalf Of Tony Nguyen
Sent: Friday, May 15, 2020 5:51 PM
To: intel-wired-lan at lists.osuosl.org
Subject: [Intel-wired-lan] [PATCH S45 01/15] ice: Refactorice_ena_vf_mappingsto split MSIX and queue mappingsFrom: Brett Creeley <[email protected]>
Currently
ice_ena_vf_mappings()does all of the VF's MSIX and queue mapping in one function. This makes it hard to digest. Fix this by creating a new function for enabling MSIX mappings and one for enabling queue mappings.
Quoted 6 lines
Also, rename some variables in the functions for clarity.
Signed-off-by Brett Creeley <[email protected]>--- .../net/ethernet/intel/ice/ice_virtchnl_pf.c | 91 ++++++++++++------- 1 file changed, 59 insertions(+), 32 deletions(-)