Commit 58eb4363 authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

nfp: wrap napi add/del logic

There will be more NAPI register logic once AF_XDP support is
added, wrap our already conditional napi add/del into helpers.
Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: default avatarNiklas Söderlund <niklas.soderlund@corigine.com>
Signed-off-by: default avatarSimon Horman <simon.horman@corigine.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3cdb35fb
...@@ -2638,6 +2638,25 @@ static void nfp_net_rx_rings_free(struct nfp_net_dp *dp) ...@@ -2638,6 +2638,25 @@ static void nfp_net_rx_rings_free(struct nfp_net_dp *dp)
kfree(dp->rx_rings); kfree(dp->rx_rings);
} }
static void
nfp_net_napi_add(struct nfp_net_dp *dp, struct nfp_net_r_vector *r_vec)
{
if (dp->netdev)
netif_napi_add(dp->netdev, &r_vec->napi,
nfp_net_poll, NAPI_POLL_WEIGHT);
else
tasklet_enable(&r_vec->tasklet);
}
static void
nfp_net_napi_del(struct nfp_net_dp *dp, struct nfp_net_r_vector *r_vec)
{
if (dp->netdev)
netif_napi_del(&r_vec->napi);
else
tasklet_disable(&r_vec->tasklet);
}
static void static void
nfp_net_vector_assign_rings(struct nfp_net_dp *dp, nfp_net_vector_assign_rings(struct nfp_net_dp *dp,
struct nfp_net_r_vector *r_vec, int idx) struct nfp_net_r_vector *r_vec, int idx)
...@@ -2656,23 +2675,14 @@ nfp_net_prepare_vector(struct nfp_net *nn, struct nfp_net_r_vector *r_vec, ...@@ -2656,23 +2675,14 @@ nfp_net_prepare_vector(struct nfp_net *nn, struct nfp_net_r_vector *r_vec,
{ {
int err; int err;
/* Setup NAPI */ nfp_net_napi_add(&nn->dp, r_vec);
if (nn->dp.netdev)
netif_napi_add(nn->dp.netdev, &r_vec->napi,
nfp_net_poll, NAPI_POLL_WEIGHT);
else
tasklet_enable(&r_vec->tasklet);
snprintf(r_vec->name, sizeof(r_vec->name), snprintf(r_vec->name, sizeof(r_vec->name),
"%s-rxtx-%d", nfp_net_name(nn), idx); "%s-rxtx-%d", nfp_net_name(nn), idx);
err = request_irq(r_vec->irq_vector, r_vec->handler, 0, r_vec->name, err = request_irq(r_vec->irq_vector, r_vec->handler, 0, r_vec->name,
r_vec); r_vec);
if (err) { if (err) {
if (nn->dp.netdev) nfp_net_napi_del(&nn->dp, r_vec);
netif_napi_del(&r_vec->napi);
else
tasklet_disable(&r_vec->tasklet);
nn_err(nn, "Error requesting IRQ %d\n", r_vec->irq_vector); nn_err(nn, "Error requesting IRQ %d\n", r_vec->irq_vector);
return err; return err;
} }
...@@ -2690,11 +2700,7 @@ static void ...@@ -2690,11 +2700,7 @@ static void
nfp_net_cleanup_vector(struct nfp_net *nn, struct nfp_net_r_vector *r_vec) nfp_net_cleanup_vector(struct nfp_net *nn, struct nfp_net_r_vector *r_vec)
{ {
irq_set_affinity_hint(r_vec->irq_vector, NULL); irq_set_affinity_hint(r_vec->irq_vector, NULL);
if (nn->dp.netdev) nfp_net_napi_del(&nn->dp, r_vec);
netif_napi_del(&r_vec->napi);
else
tasklet_disable(&r_vec->tasklet);
free_irq(r_vec->irq_vector, r_vec); free_irq(r_vec->irq_vector, r_vec);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment