1MQPRIO(8) Linux MQPRIO(8)
2
3
4
6 MQPRIO - Multiqueue Priority Qdisc (Offloaded Hardware QOS)
7
9 tc qdisc ... dev dev ( parent classid | root) [ handle major: ] mqprio
10 [ num_tc tcs ] [ map P0 P1 P2... ] [ queues count1@offset1
11 count2@offset2 ... ]
12 [ hw 1|0 ] [ mode dcb|channel ] [ shaper dcb|bw_rlimit ]
13 [ min_rate min_rate1 min_rate2 ... ] [ max_rate max_rate1
14 max_rate2 ... ]
15 [ fp FP0 FP1 FP2 ... ]
16
17
19 The MQPRIO qdisc is a simple queuing discipline that allows mapping
20 traffic flows to hardware queue ranges using priorities and a config‐
21 urable priority to traffic class mapping. A traffic class in this con‐
22 text is a set of contiguous qdisc classes which map 1:1 to a set of
23 hardware exposed queues.
24
25 By default the qdisc allocates a pfifo qdisc (packet limited first in,
26 first out queue) per TX queue exposed by the lower layer device. Other
27 queuing disciplines may be added subsequently. Packets are enqueued us‐
28 ing the map parameter and hashed across the indicated queues in the
29 offset and count. By default these parameters are configured by the
30 hardware driver to match the hardware QOS structures.
31
32 Channel mode supports full offload of the mqprio options, the traffic
33 classes, the queue configurations and QOS attributes to the hardware.
34 Enabled hardware can provide hardware QOS with the ability to steer
35 traffic flows to designated traffic classes provided by this qdisc.
36 Hardware based QOS is configured using the shaper parameter. bw_rlimit
37 with minimum and maximum bandwidth rates can be used for setting trans‐
38 mission rates on each traffic class. Also further qdiscs may be added
39 to the classes of MQPRIO to create more complex configurations.
40
41
43 On creation with 'tc qdisc add', eight traffic classes are created map‐
44 ping priorities 0..7 to traffic classes 0..7 and priorities greater
45 than 7 to traffic class 0. This requires base driver support and the
46 creation will fail on devices that do not support hardware QOS schemes.
47
48 These defaults can be overridden using the qdisc parameters. Providing
49 the 'hw 0' flag allows software to run without hardware coordination.
50
51 If hardware coordination is being used and arguments are provided that
52 the hardware can not support then an error is returned. For many users
53 hardware defaults should work reasonably well.
54
55 As one specific example numerous Ethernet cards support the 802.1Q link
56 strict priority transmission selection algorithm (TSA). MQPRIO enabled
57 hardware in conjunction with the classification methods below can pro‐
58 vide hardware offloaded support for this TSA.
59
60
62 Multiple methods are available to set the SKB priority which MQPRIO
63 uses to select which traffic class to enqueue the packet.
64
65 From user space
66 A process with sufficient privileges can encode the destination
67 class directly with SO_PRIORITY, see socket(7).
68
69 with iptables/nftables
70 An iptables/nftables rule can be created to match traffic flows
71 and set the priority. iptables(8)
72
73 with net_prio cgroups
74 The net_prio cgroup can be used to set the priority of all sock‐
75 ets belong to an application. See kernel and cgroup documenta‐
76 tion for details.
77
78
80 num_tc Number of traffic classes to use. Up to 16 classes supported.
81 You cannot have more classes than queues
82
83
84 map The priority to traffic class map. Maps priorities 0..15 to a
85 specified traffic class.
86
87
88 queues Provide count and offset of queue range for each traffic class.
89 In the format, count@offset. Queue ranges for each traffic
90 classes cannot overlap and must be a contiguous range of queues.
91
92
93 hw Set to 1 to support hardware offload. Set to 0 to configure user
94 specified values in software only. The default value of this
95 parameter is 1
96
97
98 mode Set to channel for full use of the mqprio options. Use dcb to
99 offload only TC values and use hardware QOS defaults. Supported
100 with 'hw' set to 1 only.
101
102
103 shaper Use bw_rlimit to set bandwidth rate limits for a traffic class.
104 Use dcb for hardware QOS defaults. Supported with 'hw' set to 1
105 only.
106
107
108 min_rate
109 Minimum value of bandwidth rate limit for a traffic class. Sup‐
110 ported only when the 'shaper' argument is set to 'bw_rlimit'.
111
112
113 max_rate
114 Maximum value of bandwidth rate limit for a traffic class. Sup‐
115 ported only when the 'shaper' argument is set to 'bw_rlimit'.
116
117
118 fp Selects whether traffic classes are express (deliver packets via
119 the eMAC) or preemptible (deliver packets via the pMAC), accord‐
120 ing to IEEE 802.1Q-2018 clause 6.7.2 Frame preemption. Takes the
121 form of an array (one element per traffic class) with values be‐
122 ing 'E' (for express) or 'P' (for preemptible).
123
124 Multiple priorities which map to the same traffic class, as well
125 as multiple TXQs which map to the same traffic class, must have
126 the same FP attributes. To interpret the FP as an attribute per
127 priority, the 'map' argument can be used for translation. To in‐
128 terpret FP as an attribute per TXQ, the 'queues' argument can be
129 used for translation.
130
131 Traffic classes are express by default. The argument is sup‐
132 ported only with 'hw' set to 1. Preemptible traffic classes are
133 accepted only if the device has a MAC Merge layer configurable
134 through ethtool(8).
135
136
138 ethtool(8)
139
140
142 The following example shows how to attach priorities to 4 traffic
143 classes ("num_tc 4"), and then how to pair these traffic classes with 4
144 hardware queues with mqprio, with hardware coordination ("hw 1", or
145 does not specified, because 1 is the default value). Traffic class 0
146 (tc0) is mapped to hardware queue 0 (q0), tc1 is mapped to q1, tc2 is
147 mapped to q2, and tc3 is mapped q3.
148
149 # tc qdisc add dev eth0 root mqprio num_tc 4 map 0 0 0 0 1 1 1 1 2 2 2 2 3 3 3 3 queues 1@0 1@1 1@2 1@3 hw 1
150
151 The next example shows how to attach priorities to 3 traffic classes
152 ("num_tc 3"), and how to pair these traffic classes with 4 queues,
153 without hardware coordination ("hw 0"). Traffic class 0 (tc0) is
154 mapped to hardware queue 0 (q0), tc1 is mapped to q1, tc2 and is mapped
155 to q2 and q3, where the queue selection between these two queues is
156 somewhat randomly decided.
157
158 # tc qdisc add dev eth0 root mqprio num_tc 3 map 0 0 0 0 1 1 1 1 2 2 2 2 2 2 2 2 queues 1@0 1@1 2@2 hw 0
159
160
161 In both cases from above the priority values from 0 to 3 (prio0-3) are
162 mapped to tc0, prio4-7 are mapped to tc1, and the prio8-11 are mapped
163 to tc2 ("map" attribute). The last four priority values (prio12-15) are
164 mapped in different ways in the two examples. They are mapped to tc3
165 in the first example and mapped to tc2 in the second example. The val‐
166 ues of these two examples are the following:
167
168 ┌────┬────┬───────┐ ┌────┬────┬────────┐
169 │Prio│ tc │ queue │ │Prio│ tc │ queue │
170 ├────┼────┼───────┤ ├────┼────┼────────┤
171 │ 0 │ 0 │ 0 │ │ 0 │ 0 │ 0 │
172 │ 1 │ 0 │ 0 │ │ 1 │ 0 │ 0 │
173 │ 2 │ 0 │ 0 │ │ 2 │ 0 │ 0 │
174 │ 3 │ 0 │ 0 │ │ 3 │ 0 │ 0 │
175 │ 4 │ 1 │ 1 │ │ 4 │ 1 │ 1 │
176 │ 5 │ 1 │ 1 │ │ 5 │ 1 │ 1 │
177 │ 6 │ 1 │ 1 │ │ 6 │ 1 │ 1 │
178 │ 7 │ 1 │ 1 │ │ 7 │ 1 │ 1 │
179 │ 8 │ 2 │ 2 │ │ 8 │ 2 │ 2 or 3 │
180 │ 9 │ 2 │ 2 │ │ 9 │ 2 │ 2 or 3 │
181 │ 10 │ 2 │ 2 │ │ 10 │ 2 │ 2 or 3 │
182 │ 11 │ 2 │ 2 │ │ 11 │ 2 │ 2 or 3 │
183 │ 12 │ 3 │ 3 │ │ 12 │ 2 │ 2 or 3 │
184 │ 13 │ 3 │ 3 │ │ 13 │ 2 │ 2 or 3 │
185 │ 14 │ 3 │ 3 │ │ 14 │ 2 │ 2 or 3 │
186 │ 15 │ 3 │ 3 │ │ 15 │ 2 │ 2 or 3 │
187 └────┴────┴───────┘ └────┴────┴────────┘
188 example1 example2
189
190
191 Another example of queue mapping is the following. There are 5 traffic
192 classes, and there are 8 hardware queues.
193
194 # tc qdisc add dev eth0 root mqprio num_tc 5 map 0 0 0 1 1 1 1 2 2 3 3 4 4 4 4 4 queues 1@0 2@1 1@3 1@4 3@5
195
196 The value mapping is the following for this example:
197
198 ┌───────┐
199 tc0────┤Queue 0│◄────1@0
200 ├───────┤
201 ┌─┤Queue 1│◄────2@1
202 tc1──┤ ├───────┤
203 └─┤Queue 2│
204 ├───────┤
205 tc2────┤Queue 3│◄────1@3
206 ├───────┤
207 tc3────┤Queue 4│◄────1@4
208 ├───────┤
209 ┌─┤Queue 5│◄────3@5
210 │ ├───────┤
211 tc4──┼─┤Queue 6│
212 │ ├───────┤
213 └─┤Queue 7│
214 └───────┘
215
216
217
219 John Fastabend, <john.r.fastabend@intel.com>
220
221
222
223iproute2 24 Sept 2013 MQPRIO(8)