Skip to content

Commit d0fda04

Browse files
hramamu1Jeff Kirsher
authored andcommitted
i40e/i40evf: take into account queue map from vf when handling queues
The expectation of the ops VIRTCHNL_OP_ENABLE_QUEUES and VIRTCHNL_OP_DISABLE_QUEUES is that the queue map sent by the VF is taken into account when enabling/disabling queues in the VF VSI. This patch makes sure that happens. By breaking out the individual queue set up functions so that they can be called directly from the i40e_virtchnl_pf.c file, only the queues as specified by the queue bit map that accompanies the enable/disable queues ops will be handled. Signed-off-by: Harshitha Ramamurthy <[email protected]> Tested-by: Andrew Bowers <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 830e0dd commit d0fda04

File tree

3 files changed

+99
-13
lines changed

3 files changed

+99
-13
lines changed

drivers/net/ethernet/intel/i40e/i40e.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,9 @@ void i40e_service_event_schedule(struct i40e_pf *pf);
987987
void i40e_notify_client_of_vf_msg(struct i40e_vsi *vsi, u32 vf_id,
988988
u8 *msg, u16 len);
989989

990+
int i40e_control_wait_tx_q(int seid, struct i40e_pf *pf, int pf_q, bool is_xdp,
991+
bool enable);
992+
int i40e_control_wait_rx_q(struct i40e_pf *pf, int pf_q, bool enable);
990993
int i40e_vsi_start_rings(struct i40e_vsi *vsi);
991994
void i40e_vsi_stop_rings(struct i40e_vsi *vsi);
992995
void i40e_vsi_stop_rings_no_wait(struct i40e_vsi *vsi);

drivers/net/ethernet/intel/i40e/i40e_main.c

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4235,8 +4235,8 @@ static void i40e_control_tx_q(struct i40e_pf *pf, int pf_q, bool enable)
42354235
* @is_xdp: true if the queue is used for XDP
42364236
* @enable: start or stop the queue
42374237
**/
4238-
static int i40e_control_wait_tx_q(int seid, struct i40e_pf *pf, int pf_q,
4239-
bool is_xdp, bool enable)
4238+
int i40e_control_wait_tx_q(int seid, struct i40e_pf *pf, int pf_q,
4239+
bool is_xdp, bool enable)
42404240
{
42414241
int ret;
42424242

@@ -4281,7 +4281,6 @@ static int i40e_vsi_control_tx(struct i40e_vsi *vsi, bool enable)
42814281
if (ret)
42824282
break;
42834283
}
4284-
42854284
return ret;
42864285
}
42874286

@@ -4320,9 +4319,9 @@ static int i40e_pf_rxq_wait(struct i40e_pf *pf, int pf_q, bool enable)
43204319
* @pf_q: the PF queue to configure
43214320
* @enable: start or stop the queue
43224321
*
4323-
* This function enables or disables a single queue. Note that any delay
4324-
* required after the operation is expected to be handled by the caller of
4325-
* this function.
4322+
* This function enables or disables a single queue. Note that
4323+
* any delay required after the operation is expected to be
4324+
* handled by the caller of this function.
43264325
**/
43274326
static void i40e_control_rx_q(struct i40e_pf *pf, int pf_q, bool enable)
43284327
{
@@ -4351,6 +4350,30 @@ static void i40e_control_rx_q(struct i40e_pf *pf, int pf_q, bool enable)
43514350
wr32(hw, I40E_QRX_ENA(pf_q), rx_reg);
43524351
}
43534352

4353+
/**
4354+
* i40e_control_wait_rx_q
4355+
* @pf: the PF structure
4356+
* @pf_q: queue being configured
4357+
* @enable: start or stop the rings
4358+
*
4359+
* This function enables or disables a single queue along with waiting
4360+
* for the change to finish. The caller of this function should handle
4361+
* the delays needed in the case of disabling queues.
4362+
**/
4363+
int i40e_control_wait_rx_q(struct i40e_pf *pf, int pf_q, bool enable)
4364+
{
4365+
int ret = 0;
4366+
4367+
i40e_control_rx_q(pf, pf_q, enable);
4368+
4369+
/* wait for the change to finish */
4370+
ret = i40e_pf_rxq_wait(pf, pf_q, enable);
4371+
if (ret)
4372+
return ret;
4373+
4374+
return ret;
4375+
}
4376+
43544377
/**
43554378
* i40e_vsi_control_rx - Start or stop a VSI's rings
43564379
* @vsi: the VSI being configured
@@ -4363,10 +4386,7 @@ static int i40e_vsi_control_rx(struct i40e_vsi *vsi, bool enable)
43634386

43644387
pf_q = vsi->base_queue;
43654388
for (i = 0; i < vsi->num_queue_pairs; i++, pf_q++) {
4366-
i40e_control_rx_q(pf, pf_q, enable);
4367-
4368-
/* wait for the change to finish */
4369-
ret = i40e_pf_rxq_wait(pf, pf_q, enable);
4389+
ret = i40e_control_wait_rx_q(pf, pf_q, enable);
43704390
if (ret) {
43714391
dev_info(&pf->pdev->dev,
43724392
"VSI seid %d Rx ring %d %sable timeout\n",

drivers/net/ethernet/intel/i40e/i40e_virtchnl_pf.c

Lines changed: 66 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2153,6 +2153,51 @@ static int i40e_vc_config_irq_map_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)
21532153
aq_ret);
21542154
}
21552155

2156+
/**
2157+
* i40e_ctrl_vf_tx_rings
2158+
* @vsi: the SRIOV VSI being configured
2159+
* @q_map: bit map of the queues to be enabled
2160+
* @enable: start or stop the queue
2161+
**/
2162+
static int i40e_ctrl_vf_tx_rings(struct i40e_vsi *vsi, unsigned long q_map,
2163+
bool enable)
2164+
{
2165+
struct i40e_pf *pf = vsi->back;
2166+
int ret = 0;
2167+
u16 q_id;
2168+
2169+
for_each_set_bit(q_id, &q_map, I40E_MAX_VF_QUEUES) {
2170+
ret = i40e_control_wait_tx_q(vsi->seid, pf,
2171+
vsi->base_queue + q_id,
2172+
false /*is xdp*/, enable);
2173+
if (ret)
2174+
break;
2175+
}
2176+
return ret;
2177+
}
2178+
2179+
/**
2180+
* i40e_ctrl_vf_rx_rings
2181+
* @vsi: the SRIOV VSI being configured
2182+
* @q_map: bit map of the queues to be enabled
2183+
* @enable: start or stop the queue
2184+
**/
2185+
static int i40e_ctrl_vf_rx_rings(struct i40e_vsi *vsi, unsigned long q_map,
2186+
bool enable)
2187+
{
2188+
struct i40e_pf *pf = vsi->back;
2189+
int ret = 0;
2190+
u16 q_id;
2191+
2192+
for_each_set_bit(q_id, &q_map, I40E_MAX_VF_QUEUES) {
2193+
ret = i40e_control_wait_rx_q(pf, vsi->base_queue + q_id,
2194+
enable);
2195+
if (ret)
2196+
break;
2197+
}
2198+
return ret;
2199+
}
2200+
21562201
/**
21572202
* i40e_vc_enable_queues_msg
21582203
* @vf: pointer to the VF info
@@ -2185,8 +2230,17 @@ static int i40e_vc_enable_queues_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)
21852230
goto error_param;
21862231
}
21872232

2188-
if (i40e_vsi_start_rings(pf->vsi[vf->lan_vsi_idx]))
2233+
/* Use the queue bit map sent by the VF */
2234+
if (i40e_ctrl_vf_rx_rings(pf->vsi[vf->lan_vsi_idx], vqs->rx_queues,
2235+
true)) {
2236+
aq_ret = I40E_ERR_TIMEOUT;
2237+
goto error_param;
2238+
}
2239+
if (i40e_ctrl_vf_tx_rings(pf->vsi[vf->lan_vsi_idx], vqs->tx_queues,
2240+
true)) {
21892241
aq_ret = I40E_ERR_TIMEOUT;
2242+
goto error_param;
2243+
}
21902244

21912245
/* need to start the rings for additional ADq VSI's as well */
21922246
if (vf->adq_enabled) {
@@ -2234,8 +2288,17 @@ static int i40e_vc_disable_queues_msg(struct i40e_vf *vf, u8 *msg, u16 msglen)
22342288
goto error_param;
22352289
}
22362290

2237-
i40e_vsi_stop_rings(pf->vsi[vf->lan_vsi_idx]);
2238-
2291+
/* Use the queue bit map sent by the VF */
2292+
if (i40e_ctrl_vf_tx_rings(pf->vsi[vf->lan_vsi_idx], vqs->tx_queues,
2293+
false)) {
2294+
aq_ret = I40E_ERR_TIMEOUT;
2295+
goto error_param;
2296+
}
2297+
if (i40e_ctrl_vf_rx_rings(pf->vsi[vf->lan_vsi_idx], vqs->rx_queues,
2298+
false)) {
2299+
aq_ret = I40E_ERR_TIMEOUT;
2300+
goto error_param;
2301+
}
22392302
error_param:
22402303
/* send the response to the VF */
22412304
return i40e_vc_send_resp_to_vf(vf, VIRTCHNL_OP_DISABLE_QUEUES,

0 commit comments

Comments
 (0)