← Documents Documentation/networking/multiqueue.rst GitHub 원문 ↗

Linux 6.18.37 · Networking

HOWTO for multiqueue network device support

Driver subqueue API, multiqueue qdisc와 tc queue mapping 설정법입니다.

Source pathDocumentation/networking/multiqueue.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

요약·해설

multiqueue.rst:1-78

Driver는 queue별 start·stop·wake를 관리하고 qdisc는 `skb->queue_mapping`을 hardware queue와 연결합니다. `tc multiq`와 `skbedit`으로 band 구성과 traffic별 queue를 지정할 수 있습니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

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

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

Base driver 요구 사항

1-27

Multiqueue device에 대한 kernel 지원은 항상 존재합니다. Base driver는 `alloc_etherdev_mq()` 또는 `alloc_netdev_mq()`로 device subqueue를 할당해야 합니다. Kernel API가 subqueue memory 할당과 해제, queue가 memory 어디에 있는지에 대한 netdev configuration을 처리합니다.

Driver는 기존 global `netdev->queue_lock`처럼 각 queue도 관리해야 합니다. Device가 동작 중일 때는 `netif_start_subqueue()`, `netif_stop_subqueue()`, `netif_wake_subqueue()`를 사용합니다. `netdev->queue_lock`은 device가 online이 되거나 `unregister_netdev()`처럼 완전히 shutdown할 때 계속 사용합니다.

.. SPDX-License-Identifier: GPL-2.0

===========================================
HOWTO for multiqueue network device support
===========================================

Section 1: Base driver requirements for implementing multiqueue support
=======================================================================

Intro: Kernel support for multiqueue devices
---------------------------------------------------------

Kernel support for multiqueue devices is always present.

Base drivers are required to use the new alloc_etherdev_mq() or
alloc_netdev_mq() functions to allocate the subqueues for the device.  The
underlying kernel API will take care of the allocation and deallocation of
the subqueue memory, as well as netdev configuration of where the queues
exist in memory.

The base driver will also need to manage the queues as it does the global
netdev->queue_lock today.  Therefore base drivers should use the
netif_{start|stop|wake}_subqueue() functions to manage each queue while the
device is still operational.  netdev->queue_lock is still used when the device
comes online or when it's completely shut down (unregister_netdev(), etc.).

Multiqueue용 qdisc

28-46

Multiqueue에 최적화된 qdisc는 기본 `pfifo_fast`와 round-robin `sch_multiq` 두 가지입니다. `pfifo_fast`는 hardware queue마다 qdisc 하나를 지원합니다. Qdisc는 skb를 분류하고 `skb->queue_mapping` 값으로 band와 queue에 보내며 base driver도 이 field로 실제 송신 queue를 결정합니다.

`sch_multiq`는 head-of-line blocking을 피하려는 hardware를 위한 것으로 band를 순회하면서 연결된 hardware queue가 stop 상태가 아닌지 확인한 후 packet을 dequeue합니다. Load 때 hardware queue 수에 맞춰 band 수를 정하고 `skb->queue_mapping`이 설정된 skb를 해당 hardware queue와 연결된 band에 넣습니다.

Section 2: Qdisc support for multiqueue devices
===============================================

Currently two qdiscs are optimized for multiqueue devices.  The first is the
default pfifo_fast qdisc.  This qdisc supports one qdisc per hardware queue.
A new round-robin qdisc, sch_multiq also supports multiple hardware queues. The
qdisc is responsible for classifying the skb's and then directing the skb's to
bands and queues based on the value in skb->queue_mapping.  Use this field in
the base driver to determine which queue to send the skb to.

sch_multiq has been added for hardware that wishes to avoid head-of-line
blocking.  It will cycle though the bands and verify that the hardware queue
associated with the band is not stopped prior to dequeuing a packet.

On qdisc load, the number of bands is based on the number of queues on the
hardware.  Once the association is made, any skb with skb->queue_mapping set,
will be queued to the band associated with the hardware queue.

tc multiq 설정과 queue 지정

47-78

iproute2의 `tc`로 qdisc를 설정합니다. `tc qdisc add dev eth0 root handle 1: multiq`는 device가 보고한 queue 수만큼 band를 만들고 qdisc를 online으로 올립니다. 4개 Tx queue라면 band 0~3이 queue 0~3에 일대일로 대응합니다.

Traffic은 `simple_tx_hash` 또는 driver가 정의한 `netdev->select_queue()` 결과에 따라 queue로 흐릅니다. 기존 tc filter 동작은 같고 새 `skbedit` action으로 특정 traffic의 `queue_mapping`을 직접 정할 수 있습니다. 예제는 destination `192.168.0.3` traffic을 queue 3으로 보냅니다.

MULTIQ band mapping
BandHardware queue
00
11
22
33

4 Tx queue device의 원문 mapping입니다.

Section 3: Brief howto using MULTIQ for multiqueue devices
==========================================================

The userspace command 'tc,' part of the iproute2 package, is used to configure
qdiscs.  To add the MULTIQ qdisc to your network device, assuming the device
is called eth0, run the following command::

    # tc qdisc add dev eth0 root handle 1: multiq

The qdisc will allocate the number of bands to equal the number of queues that
the device reports, and bring the qdisc online.  Assuming eth0 has 4 Tx
queues, the band mapping would look like::

    band 0 => queue 0
    band 1 => queue 1
    band 2 => queue 2
    band 3 => queue 3

Traffic will begin flowing through each queue based on either the simple_tx_hash
function or based on netdev->select_queue() if you have it defined.

The behavior of tc filters remains the same.  However a new tc action,
skbedit, has been added.  Assuming you wanted to route all traffic to a
specific host, for example 192.168.0.3, through a specific queue you could use
this action and establish a filter such as::

    tc filter add dev eth0 parent 1: protocol ip prio 1 u32 \
            match ip dst 192.168.0.3 \
            action skbedit queue_mapping 3

:Author: Alexander Duyck <alexander.h.duyck@intel.com>
:Original Author: Peter P. Waskiewicz Jr. <peter.p.waskiewicz.jr@intel.com>