ice: store VF relative MSI-X index in q_vector->vf_reg_idx
authorJacob Keller <jacob.e.keller@intel.com>
Fri, 22 Mar 2024 21:44:45 +0000 (14:44 -0700)
committerTony Nguyen <anthony.l.nguyen@intel.com>
Fri, 12 Apr 2024 17:34:29 +0000 (10:34 -0700)
The ice physical function driver needs to configure the association of
queues and interrupts on behalf of its virtual functions. This is done over
virtchnl by the VF sending messages during its initialization phase. These
messages contain a vector_id which the VF wants to associate with a given
queue. This ID is relative to the VF space, where 0 indicates the control
IRQ for non-queue interrupts.

When programming the mapping, the PF driver currently passes this vector_id
directly to the low level functions for programming. This works for SR-IOV,
because the hardware uses the VF-based indexing for interrupts.

This won't work for Scalable IOV, which uses PF-based indexing for
programming its VSIs. To handle this, the driver needs to be able to look
up the proper index to use for programming. For typical IRQs, this would be
the q_vector->reg_idx field.

The q_vector->reg_idx can't be set to a VF relative value, because it is
used when the PF needs to control the interrupt, such as when triggering a
software interrupt on stopping the Tx queue. Thus, introduce a new
q_vector->vf_reg_idx which can store the VF relative index for registers
which expect this.

Use this in ice_cfg_interrupt to look up the VF index from the q_vector.
This allows removing the vector ID parameter of ice_cfg_interrupt. Also
notice that this function returns an int, but then is cast to the virtchnl
error enumeration, virtchnl_status_code. Update the return type to indicate
it does not return an integer error code. We can't use normal error codes
here because the return values are passed across the virtchnl interface.

This will allow the future Scalable IOV VFs to correctly look up the index
needed for programming the VF queues without breaking SR-IOV.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Rafal Romanowski <rafal.romanowski@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
drivers/net/ethernet/intel/ice/ice.h
drivers/net/ethernet/intel/ice/ice_base.c
drivers/net/ethernet/intel/ice/ice_sriov.c
drivers/net/ethernet/intel/ice/ice_sriov.h
drivers/net/ethernet/intel/ice/ice_virtchnl.c

index a7e88d797d4c0d3ce6b637abdb30ad78a45dc60d..67a3236ab1fcb4ac959e35fd18e807b652e7d240 100644 (file)
@@ -459,7 +459,7 @@ struct ice_q_vector {
        struct ice_vsi *vsi;
 
        u16 v_idx;                      /* index in the vsi->q_vector array. */
-       u16 reg_idx;
+       u16 reg_idx;                    /* PF relative register index */
        u8 num_ring_rx;                 /* total number of Rx rings in vector */
        u8 num_ring_tx;                 /* total number of Tx rings in vector */
        u8 wb_on_itr:1;                 /* if true, WB on ITR is enabled */
@@ -481,6 +481,7 @@ struct ice_q_vector {
        char name[ICE_INT_NAME_STR_LEN];
 
        u16 total_events;       /* net_dim(): number of interrupts processed */
+       u16 vf_reg_idx;         /* VF relative register index */
        struct msi_map irq;
 } ____cacheline_internodealigned_in_smp;
 
index af0384b3711926ba3d1b25d34d22cf2026039621..687f6cb2b917afc55de7020c401c5095c6163825 100644 (file)
@@ -121,7 +121,7 @@ static int ice_vsi_alloc_q_vector(struct ice_vsi *vsi, u16 v_idx)
        q_vector->irq.index = -ENOENT;
 
        if (vsi->type == ICE_VSI_VF) {
-               q_vector->reg_idx = ice_calc_vf_reg_idx(vsi->vf, q_vector);
+               ice_calc_vf_reg_idx(vsi->vf, q_vector);
                goto out;
        } else if (vsi->type == ICE_VSI_CTRL && vsi->vf) {
                struct ice_vsi *ctrl_vsi = ice_get_vf_ctrl_vsi(pf, vsi);
@@ -145,6 +145,7 @@ static int ice_vsi_alloc_q_vector(struct ice_vsi *vsi, u16 v_idx)
 
 skip_alloc:
        q_vector->reg_idx = q_vector->irq.index;
+       q_vector->vf_reg_idx = q_vector->irq.index;
 
        /* only set affinity_mask if the CPU is online */
        if (cpu_online(v_idx))
index 5e9521876617780c6dd0f6503f74d9c566256eb8..fb2e96db647ef2bb9486aad8f079e4071a0a87af 100644 (file)
@@ -360,13 +360,14 @@ static void ice_ena_vf_mappings(struct ice_vf *vf)
  * @vf: VF to calculate the register index for
  * @q_vector: a q_vector associated to the VF
  */
-int ice_calc_vf_reg_idx(struct ice_vf *vf, struct ice_q_vector *q_vector)
+void ice_calc_vf_reg_idx(struct ice_vf *vf, struct ice_q_vector *q_vector)
 {
        if (!vf || !q_vector)
-               return -EINVAL;
+               return;
 
        /* always add one to account for the OICR being the first MSIX */
-       return vf->first_vector_idx + q_vector->v_idx + 1;
+       q_vector->vf_reg_idx = q_vector->v_idx + ICE_NONQ_VECS_VF;
+       q_vector->reg_idx = vf->first_vector_idx + q_vector->vf_reg_idx;
 }
 
 /**
index 8488df38b5863dea2a593c0f78b5aa71e90ce66e..4ba8fb53aea1dfae094f39e44f1bf17ac63b86ef 100644 (file)
@@ -49,7 +49,7 @@ int ice_set_vf_link_state(struct net_device *netdev, int vf_id, int link_state);
 
 int ice_set_vf_spoofchk(struct net_device *netdev, int vf_id, bool ena);
 
-int ice_calc_vf_reg_idx(struct ice_vf *vf, struct ice_q_vector *q_vector);
+void ice_calc_vf_reg_idx(struct ice_vf *vf, struct ice_q_vector *q_vector);
 
 int
 ice_get_vf_stats(struct net_device *netdev, int vf_id,
@@ -130,11 +130,10 @@ ice_set_vf_bw(struct net_device __always_unused *netdev,
        return -EOPNOTSUPP;
 }
 
-static inline int
+static inline void
 ice_calc_vf_reg_idx(struct ice_vf __always_unused *vf,
                    struct ice_q_vector __always_unused *q_vector)
 {
-       return 0;
 }
 
 static inline int
index 1ff9818b4c84f4d8a0661f7baa3c4989d621ab93..1c6ce0c4ed4ee9370b93518bf8d3096d488abdd3 100644 (file)
@@ -1505,13 +1505,12 @@ error_param:
  * ice_cfg_interrupt
  * @vf: pointer to the VF info
  * @vsi: the VSI being configured
- * @vector_id: vector ID
  * @map: vector map for mapping vectors to queues
  * @q_vector: structure for interrupt vector
  * configure the IRQ to queue map
  */
-static int
-ice_cfg_interrupt(struct ice_vf *vf, struct ice_vsi *vsi, u16 vector_id,
+static enum virtchnl_status_code
+ice_cfg_interrupt(struct ice_vf *vf, struct ice_vsi *vsi,
                  struct virtchnl_vector_map *map,
                  struct ice_q_vector *q_vector)
 {
@@ -1531,7 +1530,8 @@ ice_cfg_interrupt(struct ice_vf *vf, struct ice_vsi *vsi, u16 vector_id,
                q_vector->num_ring_rx++;
                q_vector->rx.itr_idx = map->rxitr_idx;
                vsi->rx_rings[vsi_q_id]->q_vector = q_vector;
-               ice_cfg_rxq_interrupt(vsi, vsi_q_id, vector_id,
+               ice_cfg_rxq_interrupt(vsi, vsi_q_id,
+                                     q_vector->vf_reg_idx,
                                      q_vector->rx.itr_idx);
        }
 
@@ -1545,7 +1545,8 @@ ice_cfg_interrupt(struct ice_vf *vf, struct ice_vsi *vsi, u16 vector_id,
                q_vector->num_ring_tx++;
                q_vector->tx.itr_idx = map->txitr_idx;
                vsi->tx_rings[vsi_q_id]->q_vector = q_vector;
-               ice_cfg_txq_interrupt(vsi, vsi_q_id, vector_id,
+               ice_cfg_txq_interrupt(vsi, vsi_q_id,
+                                     q_vector->vf_reg_idx,
                                      q_vector->tx.itr_idx);
        }
 
@@ -1619,8 +1620,7 @@ static int ice_vc_cfg_irq_map_msg(struct ice_vf *vf, u8 *msg)
                }
 
                /* lookout for the invalid queue index */
-               v_ret = (enum virtchnl_status_code)
-                       ice_cfg_interrupt(vf, vsi, vector_id, map, q_vector);
+               v_ret = ice_cfg_interrupt(vf, vsi, map, q_vector);
                if (v_ret)
                        goto error_param;
        }