Merge tag 'powerpc-6.7-1' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc...
[linux-2.6-block.git] / Documentation / networking / multiqueue.rst
CommitLineData
e98aa682 1.. SPDX-License-Identifier: GPL-2.0
a093bf00 2
e98aa682
MCC
3===========================================
4HOWTO for multiqueue network device support
5===========================================
a093bf00
PWJ
6
7Section 1: Base driver requirements for implementing multiqueue support
e98aa682 8=======================================================================
a093bf00
PWJ
9
10Intro: Kernel support for multiqueue devices
11---------------------------------------------------------
12
b19fa1fa 13Kernel support for multiqueue devices is always present.
a093bf00 14
a093bf00
PWJ
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
92651940
AD
27
28Section 2: Qdisc support for multiqueue devices
e98aa682 29===============================================
92651940 30
f07d1501
AD
31Currently two qdiscs are optimized for multiqueue devices. The first is the
32default pfifo_fast qdisc. This qdisc supports one qdisc per hardware queue.
33A new round-robin qdisc, sch_multiq also supports multiple hardware queues. The
92651940
AD
34qdisc is responsible for classifying the skb's and then directing the skb's to
35bands and queues based on the value in skb->queue_mapping. Use this field in
36the base driver to determine which queue to send the skb to.
37
f07d1501
AD
38sch_multiq has been added for hardware that wishes to avoid head-of-line
39blocking. It will cycle though the bands and verify that the hardware queue
92651940
AD
40associated with the band is not stopped prior to dequeuing a packet.
41
42On qdisc load, the number of bands is based on the number of queues on the
43hardware. Once the association is made, any skb with skb->queue_mapping set,
44will be queued to the band associated with the hardware queue.
45
46
47Section 3: Brief howto using MULTIQ for multiqueue devices
e98aa682 48==========================================================
92651940
AD
49
50The userspace command 'tc,' part of the iproute2 package, is used to configure
51qdiscs. To add the MULTIQ qdisc to your network device, assuming the device
e98aa682 52is called eth0, run the following command::
92651940 53
e98aa682 54 # tc qdisc add dev eth0 root handle 1: multiq
92651940
AD
55
56The qdisc will allocate the number of bands to equal the number of queues that
57the device reports, and bring the qdisc online. Assuming eth0 has 4 Tx
e98aa682 58queues, the band mapping would look like::
92651940 59
e98aa682
MCC
60 band 0 => queue 0
61 band 1 => queue 1
62 band 2 => queue 2
63 band 3 => queue 3
92651940 64
f07d1501
AD
65Traffic will begin flowing through each queue based on either the simple_tx_hash
66function or based on netdev->select_queue() if you have it defined.
92651940 67
ca9b0e27
AD
68The behavior of tc filters remains the same. However a new tc action,
69skbedit, has been added. Assuming you wanted to route all traffic to a
67333bb5 70specific host, for example 192.168.0.3, through a specific queue you could use
e98aa682 71this action and establish a filter such as::
ca9b0e27 72
e98aa682
MCC
73 tc filter add dev eth0 parent 1: protocol ip prio 1 u32 \
74 match ip dst 192.168.0.3 \
75 action skbedit queue_mapping 3
92651940 76
e98aa682
MCC
77:Author: Alexander Duyck <alexander.h.duyck@intel.com>
78:Original Author: Peter P. Waskiewicz Jr. <peter.p.waskiewicz.jr@intel.com>