Skip to content

Commit 91fdbce

Browse files
anambiarinkuba-moo
authored andcommitted
ice: Add support in the driver for associating queue with napi
After the napi context is initialized, map the napi instance with the queue/queue-set on the corresponding irq line. Signed-off-by: Amritha Nambiar <[email protected]> Reviewed-by: Sridhar Samudrala <[email protected]> Link: https://lore.kernel.org/r/170147332060.5260.13310934657151560599.stgit@anambiarhost.jf.intel.com Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 2a502ff commit 91fdbce

File tree

4 files changed

+84
-3
lines changed

4 files changed

+84
-3
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,10 +189,18 @@ static void ice_free_q_vector(struct ice_vsi *vsi, int v_idx)
189189
}
190190
q_vector = vsi->q_vectors[v_idx];
191191

192-
ice_for_each_tx_ring(tx_ring, q_vector->tx)
192+
ice_for_each_tx_ring(tx_ring, q_vector->tx) {
193+
if (vsi->netdev)
194+
netif_queue_set_napi(vsi->netdev, tx_ring->q_index,
195+
NETDEV_QUEUE_TYPE_TX, NULL);
193196
tx_ring->q_vector = NULL;
194-
ice_for_each_rx_ring(rx_ring, q_vector->rx)
197+
}
198+
ice_for_each_rx_ring(rx_ring, q_vector->rx) {
199+
if (vsi->netdev)
200+
netif_queue_set_napi(vsi->netdev, rx_ring->q_index,
201+
NETDEV_QUEUE_TYPE_RX, NULL);
195202
rx_ring->q_vector = NULL;
203+
}
196204

197205
/* only VSI with an associated netdev is set up with NAPI */
198206
if (vsi->netdev)

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

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2452,6 +2452,10 @@ ice_vsi_cfg_def(struct ice_vsi *vsi, struct ice_vsi_cfg_params *params)
24522452
goto unroll_vector_base;
24532453

24542454
ice_vsi_map_rings_to_vectors(vsi);
2455+
2456+
/* Associate q_vector rings to napi */
2457+
ice_vsi_set_napi_queues(vsi, true);
2458+
24552459
vsi->stat_offsets_loaded = false;
24562460

24572461
if (ice_is_xdp_ena_vsi(vsi)) {
@@ -2931,6 +2935,69 @@ void ice_vsi_dis_irq(struct ice_vsi *vsi)
29312935
synchronize_irq(vsi->q_vectors[i]->irq.virq);
29322936
}
29332937

2938+
/**
2939+
* ice_queue_set_napi - Set the napi instance for the queue
2940+
* @dev: device to which NAPI and queue belong
2941+
* @queue_index: Index of queue
2942+
* @type: queue type as RX or TX
2943+
* @napi: NAPI context
2944+
* @locked: is the rtnl_lock already held
2945+
*
2946+
* Set the napi instance for the queue
2947+
*/
2948+
static void
2949+
ice_queue_set_napi(struct net_device *dev, unsigned int queue_index,
2950+
enum netdev_queue_type type, struct napi_struct *napi,
2951+
bool locked)
2952+
{
2953+
if (!locked)
2954+
rtnl_lock();
2955+
netif_queue_set_napi(dev, queue_index, type, napi);
2956+
if (!locked)
2957+
rtnl_unlock();
2958+
}
2959+
2960+
/**
2961+
* ice_q_vector_set_napi_queues - Map queue[s] associated with the napi
2962+
* @q_vector: q_vector pointer
2963+
* @locked: is the rtnl_lock already held
2964+
*
2965+
* Associate the q_vector napi with all the queue[s] on the vector
2966+
*/
2967+
void ice_q_vector_set_napi_queues(struct ice_q_vector *q_vector, bool locked)
2968+
{
2969+
struct ice_rx_ring *rx_ring;
2970+
struct ice_tx_ring *tx_ring;
2971+
2972+
ice_for_each_rx_ring(rx_ring, q_vector->rx)
2973+
ice_queue_set_napi(q_vector->vsi->netdev, rx_ring->q_index,
2974+
NETDEV_QUEUE_TYPE_RX, &q_vector->napi,
2975+
locked);
2976+
2977+
ice_for_each_tx_ring(tx_ring, q_vector->tx)
2978+
ice_queue_set_napi(q_vector->vsi->netdev, tx_ring->q_index,
2979+
NETDEV_QUEUE_TYPE_TX, &q_vector->napi,
2980+
locked);
2981+
}
2982+
2983+
/**
2984+
* ice_vsi_set_napi_queues
2985+
* @vsi: VSI pointer
2986+
* @locked: is the rtnl_lock already held
2987+
*
2988+
* Associate queue[s] with napi for all vectors
2989+
*/
2990+
void ice_vsi_set_napi_queues(struct ice_vsi *vsi, bool locked)
2991+
{
2992+
int i;
2993+
2994+
if (!vsi->netdev)
2995+
return;
2996+
2997+
ice_for_each_q_vector(vsi, i)
2998+
ice_q_vector_set_napi_queues(vsi->q_vectors[i], locked);
2999+
}
3000+
29343001
/**
29353002
* ice_vsi_release - Delete a VSI and free its resources
29363003
* @vsi: the VSI being removed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@ void ice_vsi_cfg_netdev_tc(struct ice_vsi *vsi, u8 ena_tc);
9191
struct ice_vsi *
9292
ice_vsi_setup(struct ice_pf *pf, struct ice_vsi_cfg_params *params);
9393

94+
void ice_q_vector_set_napi_queues(struct ice_q_vector *q_vector, bool locked);
95+
96+
void ice_vsi_set_napi_queues(struct ice_vsi *vsi, bool locked);
97+
9498
int ice_vsi_release(struct ice_vsi *vsi);
9599

96100
void ice_vsi_close(struct ice_vsi *vsi);

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3375,9 +3375,11 @@ static void ice_napi_add(struct ice_vsi *vsi)
33753375
if (!vsi->netdev)
33763376
return;
33773377

3378-
ice_for_each_q_vector(vsi, v_idx)
3378+
ice_for_each_q_vector(vsi, v_idx) {
33793379
netif_napi_add(vsi->netdev, &vsi->q_vectors[v_idx]->napi,
33803380
ice_napi_poll);
3381+
ice_q_vector_set_napi_queues(vsi->q_vectors[v_idx], false);
3382+
}
33813383
}
33823384

33833385
/**

0 commit comments

Comments
 (0)