Skip to content

Commit b1b5cff

Browse files
Gerhard Englederkuba-moo
authored andcommitted
tsnep: Link queues to NAPIs
Use netif_queue_set_napi() to link queues to NAPI instances so that they can be queried with netlink. $ ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/netdev.yaml \ --dump queue-get --json='{"ifindex": 11}' [{'id': 0, 'ifindex': 11, 'napi-id': 9, 'type': 'rx'}, {'id': 1, 'ifindex': 11, 'napi-id': 10, 'type': 'rx'}, {'id': 0, 'ifindex': 11, 'napi-id': 9, 'type': 'tx'}, {'id': 1, 'ifindex': 11, 'napi-id': 10, 'type': 'tx'}] Additionally use netif_napi_set_irq() to also provide NAPI interrupt number to userspace. $ ./tools/net/ynl/cli.py --spec Documentation/netlink/specs/netdev.yaml \ --do napi-get --json='{"id": 9}' {'defer-hard-irqs': 0, 'gro-flush-timeout': 0, 'id': 9, 'ifindex': 11, 'irq': 42, 'irq-suspend-timeout': 0} Providing information about queues to userspace makes sense as APIs like XSK provide queue specific access. Also XSK busy polling relies on queues linked to NAPIs. Signed-off-by: Gerhard Engleder <[email protected]> Reviewed-by: Alexander Lobakin <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent af2bcb5 commit b1b5cff

File tree

1 file changed

+23
-5
lines changed

1 file changed

+23
-5
lines changed

drivers/net/ethernet/engleder/tsnep_main.c

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1966,23 +1966,41 @@ static int tsnep_queue_open(struct tsnep_adapter *adapter,
19661966

19671967
static void tsnep_queue_enable(struct tsnep_queue *queue)
19681968
{
1969+
struct tsnep_adapter *adapter = queue->adapter;
1970+
1971+
netif_napi_set_irq(&queue->napi, queue->irq);
19691972
napi_enable(&queue->napi);
1970-
tsnep_enable_irq(queue->adapter, queue->irq_mask);
1973+
tsnep_enable_irq(adapter, queue->irq_mask);
19711974

1972-
if (queue->tx)
1975+
if (queue->tx) {
1976+
netif_queue_set_napi(adapter->netdev, queue->tx->queue_index,
1977+
NETDEV_QUEUE_TYPE_TX, &queue->napi);
19731978
tsnep_tx_enable(queue->tx);
1979+
}
19741980

1975-
if (queue->rx)
1981+
if (queue->rx) {
1982+
netif_queue_set_napi(adapter->netdev, queue->rx->queue_index,
1983+
NETDEV_QUEUE_TYPE_RX, &queue->napi);
19761984
tsnep_rx_enable(queue->rx);
1985+
}
19771986
}
19781987

19791988
static void tsnep_queue_disable(struct tsnep_queue *queue)
19801989
{
1981-
if (queue->tx)
1990+
struct tsnep_adapter *adapter = queue->adapter;
1991+
1992+
if (queue->rx)
1993+
netif_queue_set_napi(adapter->netdev, queue->rx->queue_index,
1994+
NETDEV_QUEUE_TYPE_RX, NULL);
1995+
1996+
if (queue->tx) {
19821997
tsnep_tx_disable(queue->tx, &queue->napi);
1998+
netif_queue_set_napi(adapter->netdev, queue->tx->queue_index,
1999+
NETDEV_QUEUE_TYPE_TX, NULL);
2000+
}
19832001

19842002
napi_disable(&queue->napi);
1985-
tsnep_disable_irq(queue->adapter, queue->irq_mask);
2003+
tsnep_disable_irq(adapter, queue->irq_mask);
19862004

19872005
/* disable RX after NAPI polling has been disabled, because RX can be
19882006
* enabled during NAPI polling

0 commit comments

Comments
 (0)