Alex
Alex

Reputation: 13116

What does the interrupt code for packet processing in the TCP/IP?

I use TCP/IP over Ethernet 10 Gbit/s on Linux x86_64.

But what happen when interrupt occured in one of CPU-Core?

Is it true, that happens:

Upvotes: 1

Views: 3192

Answers (2)

Dražen Grašovec
Dražen Grašovec

Reputation: 802

I think this it the way of working of DMA (bus mastering) capable network interfaces with NAPI driver:

When packet(s) arrive, Socket Buffers are already allocated and mapped to DMA memory buffer, and DMA is armed.

  1. Packet is transferred from NIC to Socket Buffer through DMA
  2. NIC raises hardware interrupt when DMA transfer is done.
  3. Hardware interrupt handler schedules packet receiving software interrupt (SOFTIRQ)
  4. SOFTIRQ calls NAPI poll() for further processing.
  5. NAPI poll() process packets in DMA buffer queue and and passes them to upper layers as sk_buff and initializes new DMA buffers. if all packets (quota) are processed, IRQ is enabled and NAPI is told to stop polling.

Upvotes: 2

Maquefel
Maquefel

Reputation: 509

Your question is a mix of hardware, protocol stack and user-space.

code of interrupt calculates checksum of IP-packet

this part is protocols - i think somewhere here net/ipv4/ip_input.c

code of interrupt copies data from kernel-space buffer to the required socket-buffer

mix of proto and user space for example here net/ipv4/tcp_input.c

code of interrupt copies data from the buffer on Ethernet-card to the buffer in kernel-space (or it occurs before an interrupt is generated, by using DMA-controller on Ethernet and is this initiated by Ethernet-card?)

this is hardware for example drivers/net/8139cp.c

Next - i think you are misunderstanding the "interrupt" term - there are hardware interrupts and software interrupts. The only hardware interrupt here are rx/tx interrupts from Ethernet controller.

Not a full answer to your question:

First of all it is possible to divide networking into two parts the actual protocols (net/ipv4 directory) and part which implements various network hardware (drivers/net).

Not all hardware drivers implement interrupt driven technique some drivers for high-bandwidth adapter use poll technique (NAPI interface - which i shortly describe).

  1. Packets are first received by the card. When interface receives "data arrived interrupt", it disables interrupt and tells kernel to start polling the interface.
  2. Then when packet is available the interrupt handler leaves it in the interface and a method netif_rx_schedule is called. Which causes interface driver poll method to be called in some future.
  3. then it goes to network layer and finally (but not so short as i described) goes to user space, and user is notified about data available for read event, which i can't call an interrupt.

I recommend you reading the following article:

Linux Networking Kernel (http://www.ecsl.cs.sunysb.edu/elibrary/linux/network/LinuxKernel.pdf)

Upvotes: 3

Related Questions