Skip to content

Commit 668e423

Browse files
emuslnkuba-moo
authored andcommitted
ionic: always use rxq_info
Instead of setting up and tearing down the rxq_info only when the XDP program is loaded or unloaded, we will build the rxq_info whether or not XDP is in use. This is the more common use pattern and better supports future conversion to page_pool. Since the rxq_info wants the napi_id we re-order things slightly to tie this into the queue init and deinit functions where we do the add and delete of napi. Signed-off-by: Shannon Nelson <[email protected]> Signed-off-by: Brett Creeley <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 7b4ec51 commit 668e423

File tree

1 file changed

+15
-36
lines changed

1 file changed

+15
-36
lines changed

drivers/net/ethernet/pensando/ionic/ionic_lif.c

Lines changed: 15 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ static int ionic_start_queues(struct ionic_lif *lif);
4646
static void ionic_stop_queues(struct ionic_lif *lif);
4747
static void ionic_lif_queue_identify(struct ionic_lif *lif);
4848

49-
static int ionic_xdp_rxqs_update(struct ionic_lif *lif);
50-
static void ionic_xdp_unregister_rxq_info(struct ionic_queue *q);
49+
static void ionic_xdp_rxqs_prog_update(struct ionic_lif *lif);
50+
static void ionic_unregister_rxq_info(struct ionic_queue *q);
51+
static int ionic_register_rxq_info(struct ionic_queue *q, unsigned int napi_id);
5152

5253
static void ionic_dim_work(struct work_struct *work)
5354
{
@@ -380,6 +381,7 @@ static void ionic_lif_qcq_deinit(struct ionic_lif *lif, struct ionic_qcq *qcq)
380381
if (!(qcq->flags & IONIC_QCQ_F_INITED))
381382
return;
382383

384+
ionic_unregister_rxq_info(&qcq->q);
383385
if (qcq->flags & IONIC_QCQ_F_INTR) {
384386
ionic_intr_mask(idev->intr_ctrl, qcq->intr.index,
385387
IONIC_INTR_MASK_SET);
@@ -437,9 +439,7 @@ static void ionic_qcq_free(struct ionic_lif *lif, struct ionic_qcq *qcq)
437439
qcq->sg_base_pa = 0;
438440
}
439441

440-
ionic_xdp_unregister_rxq_info(&qcq->q);
441442
ionic_qcq_intr_free(lif, qcq);
442-
443443
vfree(qcq->q.info);
444444
qcq->q.info = NULL;
445445
}
@@ -925,6 +925,11 @@ static int ionic_lif_rxq_init(struct ionic_lif *lif, struct ionic_qcq *qcq)
925925
netif_napi_add(lif->netdev, &qcq->napi, ionic_rx_napi);
926926
else
927927
netif_napi_add(lif->netdev, &qcq->napi, ionic_txrx_napi);
928+
err = ionic_register_rxq_info(q, qcq->napi.napi_id);
929+
if (err) {
930+
netif_napi_del(&qcq->napi);
931+
return err;
932+
}
928933

929934
qcq->flags |= IONIC_QCQ_F_INITED;
930935

@@ -2143,9 +2148,7 @@ static int ionic_txrx_enable(struct ionic_lif *lif)
21432148
int derr = 0;
21442149
int i, err;
21452150

2146-
err = ionic_xdp_rxqs_update(lif);
2147-
if (err)
2148-
return err;
2151+
ionic_xdp_rxqs_prog_update(lif);
21492152

21502153
for (i = 0; i < lif->nxqs; i++) {
21512154
if (!(lif->rxqcqs[i] && lif->txqcqs[i])) {
@@ -2192,7 +2195,7 @@ static int ionic_txrx_enable(struct ionic_lif *lif)
21922195
derr = ionic_qcq_disable(lif, lif->rxqcqs[i], derr);
21932196
}
21942197

2195-
ionic_xdp_rxqs_update(lif);
2198+
ionic_xdp_rxqs_prog_update(lif);
21962199

21972200
return err;
21982201
}
@@ -2651,7 +2654,7 @@ static void ionic_vf_attr_replay(struct ionic_lif *lif)
26512654
ionic_vf_start(ionic);
26522655
}
26532656

2654-
static void ionic_xdp_unregister_rxq_info(struct ionic_queue *q)
2657+
static void ionic_unregister_rxq_info(struct ionic_queue *q)
26552658
{
26562659
struct xdp_rxq_info *xi;
26572660

@@ -2665,7 +2668,7 @@ static void ionic_xdp_unregister_rxq_info(struct ionic_queue *q)
26652668
kfree(xi);
26662669
}
26672670

2668-
static int ionic_xdp_register_rxq_info(struct ionic_queue *q, unsigned int napi_id)
2671+
static int ionic_register_rxq_info(struct ionic_queue *q, unsigned int napi_id)
26692672
{
26702673
struct xdp_rxq_info *rxq_info;
26712674
int err;
@@ -2698,44 +2701,20 @@ static int ionic_xdp_register_rxq_info(struct ionic_queue *q, unsigned int napi_
26982701
return err;
26992702
}
27002703

2701-
static int ionic_xdp_rxqs_update(struct ionic_lif *lif)
2704+
static void ionic_xdp_rxqs_prog_update(struct ionic_lif *lif)
27022705
{
27032706
struct bpf_prog *xdp_prog;
27042707
unsigned int i;
2705-
int err;
27062708

27072709
if (!lif->rxqcqs)
2708-
return 0;
2710+
return;
27092711

27102712
xdp_prog = READ_ONCE(lif->xdp_prog);
27112713
for (i = 0; i < lif->ionic->nrxqs_per_lif && lif->rxqcqs[i]; i++) {
27122714
struct ionic_queue *q = &lif->rxqcqs[i]->q;
27132715

2714-
if (q->xdp_prog) {
2715-
ionic_xdp_unregister_rxq_info(q);
2716-
q->xdp_prog = NULL;
2717-
}
2718-
2719-
if (xdp_prog) {
2720-
unsigned int napi_id = lif->rxqcqs[i]->napi.napi_id;
2721-
2722-
err = ionic_xdp_register_rxq_info(q, napi_id);
2723-
if (err) {
2724-
dev_err(lif->ionic->dev, "failed to register RX queue %d info for XDP, err %d\n",
2725-
i, err);
2726-
goto err_out;
2727-
}
2728-
}
27292716
q->xdp_prog = xdp_prog;
27302717
}
2731-
2732-
return 0;
2733-
2734-
err_out:
2735-
for (i = 0; i < lif->ionic->nrxqs_per_lif && lif->rxqcqs[i]; i++)
2736-
ionic_xdp_unregister_rxq_info(&lif->rxqcqs[i]->q);
2737-
2738-
return err;
27392718
}
27402719

27412720
static int ionic_xdp_config(struct net_device *netdev, struct netdev_bpf *bpf)

0 commit comments

Comments
 (0)