Re: [net-next v3 2/2] tg3: Link queues to NAPIs

From: Joe Damato
Date: Mon Oct 07 2024 - 09:38:54 EST


On Mon, Oct 07, 2024 at 12:30:09AM -0700, Michael Chan wrote:
> On Sat, Oct 5, 2024 at 7:57 AM Joe Damato <jdamato@xxxxxxxxxx> wrote:
> >
> > Link queues to NAPIs using the netdev-genl API so this information is
> > queryable.
> >
> > $ ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/netdev.yaml \
> > --dump queue-get --json='{"ifindex": 2}'
> >
> > [{'id': 0, 'ifindex': 2, 'napi-id': 8194, 'type': 'rx'},
> > {'id': 1, 'ifindex': 2, 'napi-id': 8195, 'type': 'rx'},
> > {'id': 2, 'ifindex': 2, 'napi-id': 8196, 'type': 'rx'},
> > {'id': 3, 'ifindex': 2, 'napi-id': 8197, 'type': 'rx'},
> > {'id': 0, 'ifindex': 2, 'napi-id': 8193, 'type': 'tx'}]
> >
> > Signed-off-by: Joe Damato <jdamato@xxxxxxxxxx>
>
> > static void tg3_napi_enable(struct tg3 *tp)
> > {
> > + int txq_idx = 0, rxq_idx = 0;
> > + struct tg3_napi *tnapi;
> > int i;
> >
> > - for (i = 0; i < tp->irq_cnt; i++)
> > - napi_enable(&tp->napi[i].napi);
> > + for (i = 0; i < tp->irq_cnt; i++) {
> > + tnapi = &tp->napi[i];
> > + napi_enable(&tnapi->napi);
> > + if (tnapi->tx_buffers) {
> > + netif_queue_set_napi(tp->dev, txq_idx,
> > + NETDEV_QUEUE_TYPE_TX,
> > + &tnapi->napi);
> > + txq_idx++;
> > + } else if (tnapi->rx_rcb) {
>
> Shouldn't this be "if" instead of "else if" ? A napi can be for both
> a TX ring and an RX ring in some cases.
> Thanks.

OK, but is this approach (with the running counters) acceptable for
rxq and txq numbering? If not, can you suggest an alternative?