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

Pavan Chebbi
2024-10-03T04:26:52Z

[-- Attachment #1: Type: text/plain, Size: 2263 bytes --]

On Thu, Oct 3, 2024 at 4:51 AM Joe Damato <jdamato@fastly.com> wrote:
>

> This is happening because the code in the driver does this:
>
> 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, i, NETDEV_QUEUE_TYPE_TX,
> &tnapi->napi);
>
> The code I added assumed that i is the txq or rxq index, but it's
> not - it's the index into the array of struct tg3_napi.

Yes, you are right..
>
> Corrected, the code looks like something like this:
>
> int txq_idx = 0, rxq_idx = 0;
> [...]
>
> 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) {
> netif_queue_set_napi(tp->dev, rxq_idx, NETDEV_QUEUE_TYPE_RX,
> &tnapi->napi);
> rxq_idx++;
> [...]
>
> I tested that and the output looks correct to me. However, what to
> do about tg3_napi_disable ?
>
> Probably something like this (txq only for brevity):
>
> int txq_idx = tp->txq_cnt - 1;
> [...]
>
> for (i = tp->irq_cnt - 1; i >= 0; i--) {
> [...]
> if (tnapi->tx_buffers) {
> netif_queue_set_napi(tp->dev, txq_idx, NETDEV_QUEUE_TYPE_TX,
> NULL);
> txq_idx--;
> }
> [...]
>
> Does that seem correct to you? I wanted to ask before sending
> another revision, since I am not a tg3 expert.
>

The local counter variable for the ring ids might work because irqs
are requested sequentially.
Thinking out loud, a better way would be to save the tx/rx id inside
their struct tg3_napi in the tg3_request_irq() function.
And have a separate new function (I know you did something similar for
v1 of irq-napi linking) to link queues and napi.
I think it should work, and should help during de-linking also. Let me
know what you think.

[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4209 bytes --]