blob: ea5a42e8f79f780ff14549b820423156f0fd5cd2 [file] [log] [blame]
Peter P Waskiewicz Jra093bf02007-06-28 20:45:47 -07001
2 HOWTO for multiqueue network device support
3 ===========================================
4
5Section 1: Base driver requirements for implementing multiqueue support
6Section 2: Qdisc support for multiqueue devices
7Section 3: Brief howto using PRIO or RR for multiqueue devices
8
9
10Intro: Kernel support for multiqueue devices
11---------------------------------------------------------
12
13Kernel support for multiqueue devices is only an API that is presented to the
14netdevice layer for base drivers to implement. This feature is part of the
15core networking stack, and all network devices will be running on the
16multiqueue-aware stack. If a base driver only has one queue, then these
17changes are transparent to that driver.
18
19
20Section 1: Base driver requirements for implementing multiqueue support
21-----------------------------------------------------------------------
22
23Base drivers are required to use the new alloc_etherdev_mq() or
24alloc_netdev_mq() functions to allocate the subqueues for the device. The
25underlying kernel API will take care of the allocation and deallocation of
26the subqueue memory, as well as netdev configuration of where the queues
27exist in memory.
28
29The base driver will also need to manage the queues as it does the global
30netdev->queue_lock today. Therefore base drivers should use the
31netif_{start|stop|wake}_subqueue() functions to manage each queue while the
32device is still operational. netdev->queue_lock is still used when the device
33comes online or when it's completely shut down (unregister_netdev(), etc.).
34
35Finally, the base driver should indicate that it is a multiqueue device. The
36feature flag NETIF_F_MULTI_QUEUE should be added to the netdev->features
37bitmap on device initialization. Below is an example from e1000:
38
39#ifdef CONFIG_E1000_MQ
40 if ( (adapter->hw.mac.type == e1000_82571) ||
41 (adapter->hw.mac.type == e1000_82572) ||
42 (adapter->hw.mac.type == e1000_80003es2lan))
43 netdev->features |= NETIF_F_MULTI_QUEUE;
44#endif
45
46
47Section 2: Qdisc support for multiqueue devices
48-----------------------------------------------
49
50Currently two qdiscs support multiqueue devices. A new round-robin qdisc,
51sch_rr, and sch_prio. The qdisc is responsible for classifying the skb's to
52bands and queues, and will store the queue mapping into skb->queue_mapping.
53Use this field in the base driver to determine which queue to send the skb
54to.
55
56sch_rr has been added for hardware that doesn't want scheduling policies from
57software, so it's a straight round-robin qdisc. It uses the same syntax and
58classification priomap that sch_prio uses, so it should be intuitive to
59configure for people who've used sch_prio.
60
Peter P Waskiewicz Jrfdd8a532007-09-11 11:12:06 +020061In order to utilitize the multiqueue features of the qdiscs, the network
62device layer needs to enable multiple queue support. This can be done by
63selecting NETDEVICES_MULTIQUEUE under Drivers.
64
65The PRIO qdisc naturally plugs into a multiqueue device. If
66NETDEVICES_MULTIQUEUE is selected, then on qdisc load, the number of
67bands requested is compared to the number of queues on the hardware. If they
Peter P Waskiewicz Jra093bf02007-06-28 20:45:47 -070068are equal, it sets a one-to-one mapping up between the queues and bands. If
69they're not equal, it will not load the qdisc. This is the same behavior
70for RR. Once the association is made, any skb that is classified will have
71skb->queue_mapping set, which will allow the driver to properly queue skb's
72to multiple queues.
73
74
75Section 3: Brief howto using PRIO and RR for multiqueue devices
76---------------------------------------------------------------
77
78The userspace command 'tc,' part of the iproute2 package, is used to configure
79qdiscs. To add the PRIO qdisc to your network device, assuming the device is
80called eth0, run the following command:
81
82# tc qdisc add dev eth0 root handle 1: prio bands 4 multiqueue
83
84This will create 4 bands, 0 being highest priority, and associate those bands
85to the queues on your NIC. Assuming eth0 has 4 Tx queues, the band mapping
86would look like:
87
88band 0 => queue 0
89band 1 => queue 1
90band 2 => queue 2
91band 3 => queue 3
92
93Traffic will begin flowing through each queue if your TOS values are assigning
94traffic across the various bands. For example, ssh traffic will always try to
95go out band 0 based on TOS -> Linux priority conversion (realtime traffic),
96so it will be sent out queue 0. ICMP traffic (pings) fall into the "normal"
97traffic classification, which is band 1. Therefore pings will be send out
98queue 1 on the NIC.
99
100Note the use of the multiqueue keyword. This is only in versions of iproute2
101that support multiqueue networking devices; if this is omitted when loading
102a qdisc onto a multiqueue device, the qdisc will load and operate the same
103if it were loaded onto a single-queue device (i.e. - sends all traffic to
104queue 0).
105
106Another alternative to multiqueue band allocation can be done by using the
107multiqueue option and specify 0 bands. If this is the case, the qdisc will
108allocate the number of bands to equal the number of queues that the device
109reports, and bring the qdisc online.
110
111The behavior of tc filters remains the same, where it will override TOS priority
112classification.
113
114
115Author: Peter P. Waskiewicz Jr. <peter.p.waskiewicz.jr@intel.com>