📄 multiqueue.txt
字号:
HOWTO for multiqueue network device support ===========================================Section 1: Base driver requirements for implementing multiqueue supportSection 2: Qdisc support for multiqueue devicesSection 3: Brief howto using PRIO or RR for multiqueue devicesIntro: Kernel support for multiqueue devices---------------------------------------------------------Kernel support for multiqueue devices is only an API that is presented to thenetdevice layer for base drivers to implement. This feature is part of thecore networking stack, and all network devices will be running on themultiqueue-aware stack. If a base driver only has one queue, then thesechanges are transparent to that driver.Section 1: Base driver requirements for implementing multiqueue support-----------------------------------------------------------------------Base drivers are required to use the new alloc_etherdev_mq() oralloc_netdev_mq() functions to allocate the subqueues for the device. Theunderlying kernel API will take care of the allocation and deallocation ofthe subqueue memory, as well as netdev configuration of where the queuesexist in memory.The base driver will also need to manage the queues as it does the globalnetdev->queue_lock today. Therefore base drivers should use thenetif_{start|stop|wake}_subqueue() functions to manage each queue while thedevice is still operational. netdev->queue_lock is still used when the devicecomes online or when it's completely shut down (unregister_netdev(), etc.).Finally, the base driver should indicate that it is a multiqueue device. Thefeature flag NETIF_F_MULTI_QUEUE should be added to the netdev->featuresbitmap on device initialization. Below is an example from e1000:#ifdef CONFIG_E1000_MQ if ( (adapter->hw.mac.type == e1000_82571) || (adapter->hw.mac.type == e1000_82572) || (adapter->hw.mac.type == e1000_80003es2lan)) netdev->features |= NETIF_F_MULTI_QUEUE;#endifSection 2: Qdisc support for multiqueue devices-----------------------------------------------Currently two qdiscs support multiqueue devices. A new round-robin qdisc,sch_rr, and sch_prio. The qdisc is responsible for classifying the skb's tobands and queues, and will store the queue mapping into skb->queue_mapping.Use this field in the base driver to determine which queue to send the skbto.sch_rr has been added for hardware that doesn't want scheduling policies fromsoftware, so it's a straight round-robin qdisc. It uses the same syntax andclassification priomap that sch_prio uses, so it should be intuitive toconfigure for people who've used sch_prio.In order to utilitize the multiqueue features of the qdiscs, the networkdevice layer needs to enable multiple queue support. This can be done byselecting NETDEVICES_MULTIQUEUE under Drivers.The PRIO qdisc naturally plugs into a multiqueue device. IfNETDEVICES_MULTIQUEUE is selected, then on qdisc load, the number ofbands requested is compared to the number of queues on the hardware. If theyare equal, it sets a one-to-one mapping up between the queues and bands. Ifthey're not equal, it will not load the qdisc. This is the same behaviorfor RR. Once the association is made, any skb that is classified will haveskb->queue_mapping set, which will allow the driver to properly queue skb'sto multiple queues.Section 3: Brief howto using PRIO and RR for multiqueue devices---------------------------------------------------------------The userspace command 'tc,' part of the iproute2 package, is used to configureqdiscs. To add the PRIO qdisc to your network device, assuming the device iscalled eth0, run the following command:# tc qdisc add dev eth0 root handle 1: prio bands 4 multiqueueThis will create 4 bands, 0 being highest priority, and associate those bandsto the queues on your NIC. Assuming eth0 has 4 Tx queues, the band mappingwould look like:band 0 => queue 0band 1 => queue 1band 2 => queue 2band 3 => queue 3Traffic will begin flowing through each queue if your TOS values are assigningtraffic across the various bands. For example, ssh traffic will always try togo out band 0 based on TOS -> Linux priority conversion (realtime traffic),so it will be sent out queue 0. ICMP traffic (pings) fall into the "normal"traffic classification, which is band 1. Therefore pings will be send outqueue 1 on the NIC.Note the use of the multiqueue keyword. This is only in versions of iproute2that support multiqueue networking devices; if this is omitted when loadinga qdisc onto a multiqueue device, the qdisc will load and operate the sameif it were loaded onto a single-queue device (i.e. - sends all traffic toqueue 0).Another alternative to multiqueue band allocation can be done by using themultiqueue option and specify 0 bands. If this is the case, the qdisc willallocate the number of bands to equal the number of queues that the devicereports, and bring the qdisc online.The behavior of tc filters remains the same, where it will override TOS priorityclassification.Author: Peter P. Waskiewicz Jr. <peter.p.waskiewicz.jr@intel.com>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -