Skip to content

Commit b80d01e

Browse files
jacob-kelleranguy11
authored andcommitted
ice: store VF relative MSI-X index in q_vector->vf_reg_idx
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 <[email protected]> Tested-by: Rafal Romanowski <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent c22f7da commit b80d01e

File tree

5 files changed

+17
-15
lines changed

5 files changed

+17
-15
lines changed

drivers/net/ethernet/intel/ice/ice.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ struct ice_q_vector {
459459
struct ice_vsi *vsi;
460460

461461
u16 v_idx; /* index in the vsi->q_vector array. */
462-
u16 reg_idx;
462+
u16 reg_idx; /* PF relative register index */
463463
u8 num_ring_rx; /* total number of Rx rings in vector */
464464
u8 num_ring_tx; /* total number of Tx rings in vector */
465465
u8 wb_on_itr:1; /* if true, WB on ITR is enabled */
@@ -481,6 +481,7 @@ struct ice_q_vector {
481481
char name[ICE_INT_NAME_STR_LEN];
482482

483483
u16 total_events; /* net_dim(): number of interrupts processed */
484+
u16 vf_reg_idx; /* VF relative register index */
484485
struct msi_map irq;
485486
} ____cacheline_internodealigned_in_smp;
486487

drivers/net/ethernet/intel/ice/ice_base.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ static int ice_vsi_alloc_q_vector(struct ice_vsi *vsi, u16 v_idx)
121121
q_vector->irq.index = -ENOENT;
122122

123123
if (vsi->type == ICE_VSI_VF) {
124-
q_vector->reg_idx = ice_calc_vf_reg_idx(vsi->vf, q_vector);
124+
ice_calc_vf_reg_idx(vsi->vf, q_vector);
125125
goto out;
126126
} else if (vsi->type == ICE_VSI_CTRL && vsi->vf) {
127127
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)
145145

146146
skip_alloc:
147147
q_vector->reg_idx = q_vector->irq.index;
148+
q_vector->vf_reg_idx = q_vector->irq.index;
148149

149150
/* only set affinity_mask if the CPU is online */
150151
if (cpu_online(v_idx))

drivers/net/ethernet/intel/ice/ice_sriov.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,13 +360,14 @@ static void ice_ena_vf_mappings(struct ice_vf *vf)
360360
* @vf: VF to calculate the register index for
361361
* @q_vector: a q_vector associated to the VF
362362
*/
363-
int ice_calc_vf_reg_idx(struct ice_vf *vf, struct ice_q_vector *q_vector)
363+
void ice_calc_vf_reg_idx(struct ice_vf *vf, struct ice_q_vector *q_vector)
364364
{
365365
if (!vf || !q_vector)
366-
return -EINVAL;
366+
return;
367367

368368
/* always add one to account for the OICR being the first MSIX */
369-
return vf->first_vector_idx + q_vector->v_idx + 1;
369+
q_vector->vf_reg_idx = q_vector->v_idx + ICE_NONQ_VECS_VF;
370+
q_vector->reg_idx = vf->first_vector_idx + q_vector->vf_reg_idx;
370371
}
371372

372373
/**

drivers/net/ethernet/intel/ice/ice_sriov.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ int ice_set_vf_link_state(struct net_device *netdev, int vf_id, int link_state);
4949

5050
int ice_set_vf_spoofchk(struct net_device *netdev, int vf_id, bool ena);
5151

52-
int ice_calc_vf_reg_idx(struct ice_vf *vf, struct ice_q_vector *q_vector);
52+
void ice_calc_vf_reg_idx(struct ice_vf *vf, struct ice_q_vector *q_vector);
5353

5454
int
5555
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,
130130
return -EOPNOTSUPP;
131131
}
132132

133-
static inline int
133+
static inline void
134134
ice_calc_vf_reg_idx(struct ice_vf __always_unused *vf,
135135
struct ice_q_vector __always_unused *q_vector)
136136
{
137-
return 0;
138137
}
139138

140139
static inline int

drivers/net/ethernet/intel/ice/ice_virtchnl.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1505,13 +1505,12 @@ static int ice_vc_dis_qs_msg(struct ice_vf *vf, u8 *msg)
15051505
* ice_cfg_interrupt
15061506
* @vf: pointer to the VF info
15071507
* @vsi: the VSI being configured
1508-
* @vector_id: vector ID
15091508
* @map: vector map for mapping vectors to queues
15101509
* @q_vector: structure for interrupt vector
15111510
* configure the IRQ to queue map
15121511
*/
1513-
static int
1514-
ice_cfg_interrupt(struct ice_vf *vf, struct ice_vsi *vsi, u16 vector_id,
1512+
static enum virtchnl_status_code
1513+
ice_cfg_interrupt(struct ice_vf *vf, struct ice_vsi *vsi,
15151514
struct virtchnl_vector_map *map,
15161515
struct ice_q_vector *q_vector)
15171516
{
@@ -1531,7 +1530,8 @@ ice_cfg_interrupt(struct ice_vf *vf, struct ice_vsi *vsi, u16 vector_id,
15311530
q_vector->num_ring_rx++;
15321531
q_vector->rx.itr_idx = map->rxitr_idx;
15331532
vsi->rx_rings[vsi_q_id]->q_vector = q_vector;
1534-
ice_cfg_rxq_interrupt(vsi, vsi_q_id, vector_id,
1533+
ice_cfg_rxq_interrupt(vsi, vsi_q_id,
1534+
q_vector->vf_reg_idx,
15351535
q_vector->rx.itr_idx);
15361536
}
15371537

@@ -1545,7 +1545,8 @@ ice_cfg_interrupt(struct ice_vf *vf, struct ice_vsi *vsi, u16 vector_id,
15451545
q_vector->num_ring_tx++;
15461546
q_vector->tx.itr_idx = map->txitr_idx;
15471547
vsi->tx_rings[vsi_q_id]->q_vector = q_vector;
1548-
ice_cfg_txq_interrupt(vsi, vsi_q_id, vector_id,
1548+
ice_cfg_txq_interrupt(vsi, vsi_q_id,
1549+
q_vector->vf_reg_idx,
15491550
q_vector->tx.itr_idx);
15501551
}
15511552

@@ -1619,8 +1620,7 @@ static int ice_vc_cfg_irq_map_msg(struct ice_vf *vf, u8 *msg)
16191620
}
16201621

16211622
/* lookout for the invalid queue index */
1622-
v_ret = (enum virtchnl_status_code)
1623-
ice_cfg_interrupt(vf, vsi, vector_id, map, q_vector);
1623+
v_ret = ice_cfg_interrupt(vf, vsi, map, q_vector);
16241624
if (v_ret)
16251625
goto error_param;
16261626
}

0 commit comments

Comments
 (0)