Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

documentation: networking: Add NAPI config

Document the existence of persistent per-NAPI configuration space and
the API that drivers can opt into.

Update stale documentation which suggested that NAPI IDs cannot be
queried from userspace.

Signed-off-by: Joe Damato <jdamato@fastly.com>
Acked-by: Jakub Kicinski <kuba@kernel.org>
Reviewed-by: Bagas Sanjaya <bagasdotme@gmail.com>
Link: https://patch.msgid.link/20250213191535.38792-1-jdamato@fastly.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Joe Damato and committed by
Jakub Kicinski
bf1b8e0a 6041d8bf

+32 -1
+32 -1
Documentation/networking/napi.rst
··· 171 171 a configuration of 1 ``rx``, 1 ``tx`` and 1 ``combined`` channel is expected 172 172 to utilize 3 interrupts, 2 Rx and 2 Tx queues. 173 173 174 + Persistent NAPI config 175 + ---------------------- 176 + 177 + Drivers often allocate and free NAPI instances dynamically. This leads to loss 178 + of NAPI-related user configuration each time NAPI instances are reallocated. 179 + The netif_napi_add_config() API prevents this loss of configuration by 180 + associating each NAPI instance with a persistent NAPI configuration based on 181 + a driver defined index value, like a queue number. 182 + 183 + Using this API allows for persistent NAPI IDs (among other settings), which can 184 + be beneficial to userspace programs using ``SO_INCOMING_NAPI_ID``. See the 185 + sections below for other NAPI configuration settings. 186 + 187 + Drivers should try to use netif_napi_add_config() whenever possible. 188 + 174 189 User API 175 190 ======== 176 191 177 192 User interactions with NAPI depend on NAPI instance ID. The instance IDs 178 193 are only visible to the user thru the ``SO_INCOMING_NAPI_ID`` socket option. 179 - It's not currently possible to query IDs used by a given device. 194 + 195 + Users can query NAPI IDs for a device or device queue using netlink. This can 196 + be done programmatically in a user application or by using a script included in 197 + the kernel source tree: ``tools/net/ynl/pyynl/cli.py``. 198 + 199 + For example, using the script to dump all of the queues for a device (which 200 + will reveal each queue's NAPI ID): 201 + 202 + .. code-block:: bash 203 + 204 + $ kernel-source/tools/net/ynl/pyynl/cli.py \ 205 + --spec Documentation/netlink/specs/netdev.yaml \ 206 + --dump queue-get \ 207 + --json='{"ifindex": 2}' 208 + 209 + See ``Documentation/netlink/specs/netdev.yaml`` for more details on 210 + available operations and attributes. 180 211 181 212 Software IRQ coalescing 182 213 -----------------------