Search code examples
linuxkernellinux-device-driverkernel-moduleethernet

Disabling interrupt in NIC card from driver does it stop packet reception


in rtl driver I am trying to study in which inside init function (pci_driver probe function same) its disabling irq.

So my question is: if I disable interrupt then does NAPI (New API) works or it also stops so basiccally that same I have noticed in Ethernet device driver from intel.

So question is why disabling interrupt is useful.

Is Interrut different from New API. if it is different then how in NAPI (New API) packet reception be enabled.

is there any kernel function or I just call netif_napi_add function from kernel and write to device something like enable napi mask. What exactly I have to write to device with writeb or family to device.

I am talking about r8169 device driver for realtek Ethernet device


Solution

  • To begin with, NIC interrupts are not just for packet reception. In example, think of link status change interrupts, error interrupts (when the network adapter needs to notify the host of a HW error) and other "housekeeping" ones. A complete list of mechanisms served by interrupts might be largely vendor-specific. My point is that one may not necessarily want to disable all interrupts; doing so may cause unwanted consequences.

    With respect to Rx interrupts, it's interrupt mitigation which is commonly used. The idea is to let the NIC generate an Rx interrupt for a batch of packets rather than for a single received one (or, for larger batches compared to smaller ones). This way, the number of interrupts generated in a given time interval is reduced, which leads to lesser CPU time spent by the kernel in interrupt service routines (ISR).

    On the other hand, disabling Rx interrupts is a completely different approach which implies that the kernel itself periodically polls the driver to check for new packets. In this scheme, it's not the network adapter which "awakens" the kernel by means of interrupts asking to process new packets; it's the kernel which on its own decides to check for new packets when it deems that necessary. This way, packet reception becomes even more efficient, and this is the main idea behind NAPI (New API).

    What's for the specific driver which you're studying, one may not necessarily be well-versed in all the intricacies of it. It's better to file separate questions for specific device drivers.