blob: 4caa0e314cc2929f1991b05bc8b91cb634b86635 [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
Peter P Waskiewicz Jra093bf02007-06-28 20:45:47 -07006
7Intro: Kernel support for multiqueue devices
8---------------------------------------------------------
9
David S. Millerb19fa1f2008-07-08 23:14:24 -070010Kernel support for multiqueue devices is always present.
Peter P Waskiewicz Jra093bf02007-06-28 20:45:47 -070011
12Section 1: Base driver requirements for implementing multiqueue support
13-----------------------------------------------------------------------
14
15Base drivers are required to use the new alloc_etherdev_mq() or
16alloc_netdev_mq() functions to allocate the subqueues for the device. The
17underlying kernel API will take care of the allocation and deallocation of
18the subqueue memory, as well as netdev configuration of where the queues
19exist in memory.
20
21The base driver will also need to manage the queues as it does the global
22netdev->queue_lock today. Therefore base drivers should use the
23netif_{start|stop|wake}_subqueue() functions to manage each queue while the
24device is still operational. netdev->queue_lock is still used when the device
25comes online or when it's completely shut down (unregister_netdev(), etc.).
26
Alexander Duyck92651942008-09-12 16:29:34 -070027
28Section 2: Qdisc support for multiqueue devices
29
30-----------------------------------------------
31
Alexander Duyckf07d1502008-09-12 17:57:23 -070032Currently two qdiscs are optimized for multiqueue devices. The first is the
33default pfifo_fast qdisc. This qdisc supports one qdisc per hardware queue.
34A new round-robin qdisc, sch_multiq also supports multiple hardware queues. The
Alexander Duyck92651942008-09-12 16:29:34 -070035qdisc is responsible for classifying the skb's and then directing the skb's to
36bands and queues based on the value in skb->queue_mapping. Use this field in
37the base driver to determine which queue to send the skb to.
38
Alexander Duyckf07d1502008-09-12 17:57:23 -070039sch_multiq has been added for hardware that wishes to avoid head-of-line
40blocking. It will cycle though the bands and verify that the hardware queue
Alexander Duyck92651942008-09-12 16:29:34 -070041associated with the band is not stopped prior to dequeuing a packet.
42
43On qdisc load, the number of bands is based on the number of queues on the
44hardware. Once the association is made, any skb with skb->queue_mapping set,
45will be queued to the band associated with the hardware queue.
46
47
48Section 3: Brief howto using MULTIQ for multiqueue devices
49---------------------------------------------------------------
50
51The userspace command 'tc,' part of the iproute2 package, is used to configure
52qdiscs. To add the MULTIQ qdisc to your network device, assuming the device
53is called eth0, run the following command:
54
55# tc qdisc add dev eth0 root handle 1: multiq
56
57The qdisc will allocate the number of bands to equal the number of queues that
58the device reports, and bring the qdisc online. Assuming eth0 has 4 Tx
59queues, the band mapping would look like:
60
61band 0 => queue 0
62band 1 => queue 1
63band 2 => queue 2
64band 3 => queue 3
65
Alexander Duyckf07d1502008-09-12 17:57:23 -070066Traffic will begin flowing through each queue based on either the simple_tx_hash
67function or based on netdev->select_queue() if you have it defined.
Alexander Duyck92651942008-09-12 16:29:34 -070068
Alexander Duyckca9b0e22008-09-12 16:30:20 -070069The behavior of tc filters remains the same. However a new tc action,
70skbedit, has been added. Assuming you wanted to route all traffic to a
Alexander Duyck67333bb2008-09-12 17:56:50 -070071specific host, for example 192.168.0.3, through a specific queue you could use
Alexander Duyckca9b0e22008-09-12 16:30:20 -070072this action and establish a filter such as:
73
74tc filter add dev eth0 parent 1: protocol ip prio 1 u32 \
75 match ip dst 192.168.0.3 \
76 action skbedit queue_mapping 3
Alexander Duyck92651942008-09-12 16:29:34 -070077
78Author: Alexander Duyck <alexander.h.duyck@intel.com>
79Original Author: Peter P. Waskiewicz Jr. <peter.p.waskiewicz.jr@intel.com>