-1

I learned that harddisk data is transferred to main memory using DMA, but network stack data cannot use DMA and the data has to go through processor. Is it true? If yes, what are the ways to avoid this? Isn't it really inefficient to transfer data through processor?

Boolean
  • 14,266
  • 30
  • 88
  • 129

2 Answers2

2

Most modern network cards, or any hardware for that matter, also use DMA for data transfer, however the confusion stems from the fact that the CPU will have to process most of the data coming from user applications into data that the network card expects (for example, in the form of TCP packets and in ethernet frames). This processing has to be done by the CPU, since the CPU implements the various network protocols used to send data.

Incidentally, the same can be said of hard drives. Though DMA is used for transferring large blocks of data from RAM to the hard disk, almost inevitably the CPU must verify that these blocks of data will be placed at the correct location and formatted to the correct filesystem type.

Dougvj
  • 6,409
  • 2
  • 23
  • 18
2

Is it true?

No! Network devices DMA into memory buffers specifically allocated for this purpose. DMA for network IO has been the general rule in the x86 world since the early 1990's when the PCI bus emerged.

Isn't it really inefficient to transfer data through processor?

Yes, incredibly inefficient. After initialization, the only time a core interacts directly with a modern network card is to signal the "transmit doorbell". This doorbell is a lone write operation which tells the card to look into memory for new packets to transmit. All other interactions between core and network device take place indirectly via memory.

srking
  • 4,512
  • 1
  • 30
  • 46