Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the relationship of DMA ring buffer and TX/RX ring for a network card?

I know that for a network card, OS must allocate tx/rx rings for it so that when OS wants to receive/transmit packets, the network card will know where the packets are and which packets are to be transmit.

And when I read about DMA, I see something named DMA ring buffer. Are the DMA ring and tx/rx ring the same thing?Or what is the relationship?

like image 612
4va1anch3 Avatar asked Nov 23 '17 07:11

4va1anch3


People also ask

What is DMA ring buffer?

DMA ring buffer and TX/RX rings are the same thing. DMA has two type of ring buffers. TX ring buffer - used for transmitting data from kernel to device. RX ring buffer - used for receiving data from device to kernel.

What is Rx ring buffer?

Ring buffers, also known as circular buffers, are shared buffers between the device driver and Network Interface Card (NIC). These buffers store incoming packets until the device driver can process them. Ring buffers exist on both the receive (rx) and transmit (tx) side of each interface on the firewall.

What are ring buffers used for?

Ring Buffer (or Circular Buffer) is a bounded circular data structure that is used for buffering data between two or more threads.

Can ring buffer size be increased?

Solution Answer: Yes. In general, when you change the ring buffer size, the ring closes then allocates more size, and then reopens.


2 Answers

  1. Ring Buffer Contains Start and End Address of Buffer in RAM. TX Ring will contain addresses of Buffer in RAM that contains data to be transmitted. RX Ring will contains address of Buffer in RAM where NIC will place data.

    These rings are present in RAM.

  2. TX buffer and RX buffer are are in RAM pointed by TX/RX rings.

  3. Now Network Card Register has Location of Rings Buffer in RAM .

Now 1 and 2 can be DMA able buffer , they are called DMA TX/RX ring and DMA TX/RX buffer. Now since RX/TX ring must remain throughout they are made as consistent/coherent DMA type of meory. While Buffers are made streaming/Single DMA type of memory

enter image description here enter image description here enter image description here enter image description here

like image 151
Alok Prasad Avatar answered Nov 15 '22 18:11

Alok Prasad


Short Answer: These are the same.

More details: First, see this post which is very related to your question.

In this article it says:

A variant of the asynchronous approach is often seen with network cards. These cards often expect to see a circular buffer (often called a DMA ring buffer) established in memory shared with the processor; each incoming packet is placed in the next available buffer in the ring, and an interrupt is signaled. The driver then passes the network packets to the rest of the kernel, and places a new DMA buffer in the ring.

The DMA ring allows the NIC to directly access the memory used by the software. The software (NIC's driver in the kernel case) is allocating memory for the rings and then mapping it as DMA memory, so the NIC would know it may access it. TX packets will be created in this memory by the software and will be read and transmitted by the NIC (usually after the software signals the NIC it should start transmitting). RX packets will be written to this memory by the NIC and will be read and processed by the software (usually after an interrupt is issued to signal there's work).

Hope this helps.

like image 23
Tgilgul Avatar answered Nov 15 '22 18:11

Tgilgul