ice: change vfs.num_msix_per to vf->num_msix
authorMichal Swiatkowski <michal.swiatkowski@linux.intel.com>
Tue, 24 Oct 2023 14:20:10 +0000 (16:20 +0200)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Tue, 5 Dec 2023 18:51:22 +0000 (10:51 -0800)
vfs::num_msix_per should be only used as default value for
vf->num_msix. For other use cases vf->num_msix should be used, as VF can
have different MSI-X amount values.

Fix incorrect register index calculation. vfs::num_msix_per and
pf->sriov_base_vector shouldn't be used after implementation of changing
MSI-X amount on VFs. Instead vf->first_vector_idx should be used, as it
is storing value for first irq index.

Fixes: fe1c5ca2fe76 ("ice: implement num_msix field per VF")
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Signed-off-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Tested-by: Rafal Romanowski <rafal.romanowski@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/ice/ice_sriov.c
drivers/net/ethernet/intel/ice/ice_virtchnl.c

index 2a5e6616cc0a794afd8d46dd63fb5d98a85f52b7..e1494f24f661d3c2c791846b5bdc2a1f2af8ff03 100644 (file)
@@ -374,16 +374,11 @@ static void ice_ena_vf_mappings(struct ice_vf *vf)
  */
 int ice_calc_vf_reg_idx(struct ice_vf *vf, struct ice_q_vector *q_vector)
 {
-       struct ice_pf *pf;
-
        if (!vf || !q_vector)
                return -EINVAL;
 
-       pf = vf->pf;
-
        /* always add one to account for the OICR being the first MSIX */
-       return pf->sriov_base_vector + pf->vfs.num_msix_per * vf->vf_id +
-               q_vector->v_idx + 1;
+       return vf->first_vector_idx + q_vector->v_idx + 1;
 }
 
 /**
index de11b3186bd7ea5731c3b63850841ffa39279ac8..1c7b4ded948b63205a72217cda869218e3cf10bf 100644 (file)
@@ -1523,7 +1523,6 @@ static int ice_vc_cfg_irq_map_msg(struct ice_vf *vf, u8 *msg)
        u16 num_q_vectors_mapped, vsi_id, vector_id;
        struct virtchnl_irq_map_info *irqmap_info;
        struct virtchnl_vector_map *map;
-       struct ice_pf *pf = vf->pf;
        struct ice_vsi *vsi;
        int i;
 
@@ -1535,7 +1534,7 @@ static int ice_vc_cfg_irq_map_msg(struct ice_vf *vf, u8 *msg)
         * there is actually at least a single VF queue vector mapped
         */
        if (!test_bit(ICE_VF_STATE_ACTIVE, vf->vf_states) ||
-           pf->vfs.num_msix_per < num_q_vectors_mapped ||
+           vf->num_msix < num_q_vectors_mapped ||
            !num_q_vectors_mapped) {
                v_ret = VIRTCHNL_STATUS_ERR_PARAM;
                goto error_param;
@@ -1557,7 +1556,7 @@ static int ice_vc_cfg_irq_map_msg(struct ice_vf *vf, u8 *msg)
                /* vector_id is always 0-based for each VF, and can never be
                 * larger than or equal to the max allowed interrupts per VF
                 */
-               if (!(vector_id < pf->vfs.num_msix_per) ||
+               if (!(vector_id < vf->num_msix) ||
                    !ice_vc_isvalid_vsi_id(vf, vsi_id) ||
                    (!vector_id && (map->rxq_map || map->txq_map))) {
                        v_ret = VIRTCHNL_STATUS_ERR_PARAM;