A brief understanding of alloc_netdev_mqs

In the previous articles, we used alloc_netdev to allocate and initialize a netdevice structure. The usage of alloc_netdev creates a network device with a single transmit and receive queue. This can be seen by its MACRO definition in netdevice.h.

FIG: alloc_netdev MACRO

If the network device supports multiple hardware transmit and receive queues, It is better to map those hardware queues to separate network device queues. This allows the Linux QoS sub-system to better manage QoS for the network device. This operation is achieved by utilizing the alloc_netdev_mqs API. It can be seen from the above image that alloc_netdev macro maps to alloc_netdev_mqs API internally.

alloc_netdev_mqs API declaration is shown below for reference. It allows the creation of txq/rxq count number of transmit and receive queues.

The creation of multiple transmit and receive queues for the network device helps improve performance. This, happens for few of the reasons stated below:

  • The Linux QoS subsystem can now prioritize packets for the network device and can effectively map different priority priority packets to different queues leading to better qdisc management (short for queuing discipline management – will discuss in a later article) for the device.
  • The different networking queues can be mapped to different CPUs using smp_affinity to map IRQs or mapped via software transmit and receive packet steering. This allows better utilization of the networking drivers resources as well as manage CPU load.
  • The different transmit or receive queues within the driver are now no longer under a single lock and key, hence, packet management within the networking device driver and also in the Linux networking sub-system for the network device.

Do kindly note that the networking transmit and receive queues are not directly manipulable by the networking device driver. The networking device driver has its internal Transmit and Receive ring buffers that it generally creates to manage its hardware queues. The network device queues are mapped to the device driver rings either one-to-one or via specific priority mapping. This allows for better queue management within the driver as well.

Now that we have a brief understanding of alloc_netdev_mqs , we will utilize this in our networking loopback interface example to create multiple transmit and receive queues as we progress in providing more functionality to our example networking driver.

Use alloc_netdev_mqs to incorporate multiple TX/RX networking queues

Leave a Reply

Your email address will not be published. Required fields are marked *