← Documents Documentation/networking/device_drivers/ethernet/freescale/dpaa2/switch-driver.rst GitHub 원문 ↗

Linux 6.18.37 · Networking

DPAA2 Switch driver

DPSW 포트의 switchdev 모델, 생성 제약과 필수 객체, VLAN-aware bridge·FDB·flooding 제어, ACL action 및 VLAN mirroring 제약을 설명합니다.

Source pathDocumentation/networking/device_drivers/ethernet/freescale/dpaa2/switch-driver.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

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

1. 요약·해설

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

요약·해설

switch-driver.rst:1-217

DPAA2 Switch 드라이버는 DPSW의 각 port를 Linux netdevice로 노출하고 bridge와 tc 설정을 하드웨어 규칙으로 옮깁니다. 하드웨어 특성상 VLAN-aware bridge만 허용하며 FDB·flooding domain과 control interface가 올바르게 준비되어야 probe할 수 있습니다. ACL은 강력하지만 action 하나, VLAN mirroring key와 destination 같은 제약을 갖습니다.

DPSW 포트 토폴로지
ethA·ethBdpaa2-ethDPNIDPSW
ethC...ethFdpaa2-switchDPSWDPMACPHY

원문의 ASCII 도식을 DPNI 내부 연결과 DPMAC 외부 연결로 나눴습니다.

DPSW 생성 방법
시점방법
bootDataPath Layout(DPL)로 정적 생성
runtimerestool의 DPAA2 object API

fsl-mc bus에 DPSW를 제공하는 두 경로입니다.

probe 필수 조건
조건이유
FDB 수 ≥ port 수독립 port마다 자체 FDB
broadcast per FDBbridge별 broadcast domain 제한
flooding per FDBbridge별 flooding domain 제한
control interface 활성port netdevice Rx·Tx 지원

조건 하나라도 어기면 드라이버가 DPSW를 probe하지 않습니다.

추가 DPAA2 객체
객체수량용도
DPMCP1MC firmware 명령
DPBP1control interface Rx buffer
DPIO최소 1개 접근공유 enqueue·dequeue portal

DPSW 외에 control path와 packet I/O에 필요한 객체입니다.

Bridge 요구 사항
기능지원
VLAN-aware bridge필수
VLAN-unaware bridge거부
STP topology·loop detection`stp_state 1`
L2 FDB add/delete/dump지원

DPAA2 switch port의 bridge 구성 범위입니다.

FDB learning 제어
port별 HW learning`learning off`fast agelearned address 제거`learning on`

learning을 끌 때 기존 동적 주소도 함께 정리합니다.

Flooding 제어
종류제어제약
unknown unicast`flood`multicast와 함께 설정
unknown multicast`mcast_flood`독립 설정 불가
broadcastbrport sysfsport별 on/off

unknown traffic와 broadcast의 제어 표면이 다릅니다.

ACL offload 구조
tc flower·matchallshared filter blockACL tableDPSW hardwaredrop·redirect·trap

여러 port가 shared block의 ACL table 하나를 공유할 수 있습니다.

지원 flow key
계층
Ethernetdst_mac·src_mac
IPv4dst_ip·src_ip·ip_proto·tos
VLANid·priority·TPID·DEI
L4dst_port·src_port

ACL flower rule에서 사용할 수 있는 packet field입니다.

ACL action 규칙
action결과
droppacket 폐기
mirred egress redirect다른 port로 전송
trapCPU로 전달

filter 한 개는 action 하나만 가질 수 있습니다.

Offload 예제
예제기능
source MAC → CPUflower + trap
VID 100·PCP 3flower + drop
eth4 전체 → eth1matchall + redirect
eth5·eth6shared ingress block

문서의 네 예제가 검증하는 기능입니다.

Mirroring 범위
항목지원
port별 mirroring지원
VLAN별 mirroring지원
shared block filter지원
802.1q match key`vlan_id`만 허용

지원되는 단위와 shared block 사용 여부입니다.

VLAN mirror 준비
bridge VLAN add 또는 VLAN upper devicesource port에 VLAN 설치tc mirror filtermirror destination

mirror rule보다 먼저 source switch port에 VLAN을 설치해야 합니다.

Mirror egress 제약
조건결과
destination port에 packet VLAN 있음egress 허용
destination port에 packet VLAN 없음drop
여러 rule의 destination 동일허용
서로 다른 mirror destination거부

복제 packet도 일반 packet과 같은 egress 규칙을 따릅니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 .. SPDX-License-Identifier: GPL-2.0
2 .. include:: <isonum.txt>
3
4 ===================
5 DPAA2 Switch driver
6 ===================
7
8 :Copyright: |copy| 2021 NXP
9
10 The DPAA2 Switch driver probes on the Datapath Switch (DPSW) object which can
11 be instantiated on the following DPAA2 SoCs and their variants: LS2088A and
12 LX2160A.
13
14 The driver uses the switch device driver model and exposes each switch port as
15 a network interface, which can be included in a bridge or used as a standalone
16 interface. Traffic switched between ports is offloaded into the hardware.
17
18 The DPSW can have ports connected to DPNIs or to DPMACs for external access.
19 ::
20
21 [ethA] [ethB] [ethC] [ethD] [ethE] [ethF]
22 : : : : : :
23 : : : : : :
24 [dpaa2-eth] [dpaa2-eth] [ dpaa2-switch ]
25 : : : : : : kernel
26 =============================================================================
27 : : : : : : hardware
28 [DPNI] [DPNI] [============= DPSW =================]
29 | | | | | |
30 | ---------- | [DPMAC] [DPMAC]
31 ------------------------------- | |
32 | |
33 [PHY] [PHY]
34
35 Creating an Ethernet Switch
36 ===========================
37
38 The dpaa2-switch driver probes on DPSW devices found on the fsl-mc bus. These
39 devices can be either created statically through the boot time configuration
40 file - DataPath Layout (DPL) - or at runtime using the DPAA2 object APIs
41 (incorporated already into the restool userspace tool).
42
43 At the moment, the dpaa2-switch driver imposes the following restrictions on
44 the DPSW object that it will probe:
45
46 * The minimum number of FDBs should be at least equal to the number of switch
47 interfaces. This is necessary so that separation of switch ports can be
48 done, ie when not under a bridge, each switch port will have its own FDB.
49 ::
50
51 fsl_dpaa2_switch dpsw.0: The number of FDBs is lower than the number of ports, cannot probe
52
53 * Both the broadcast and flooding configuration should be per FDB. This
54 enables the driver to restrict the broadcast and flooding domains of each
55 FDB depending on the switch ports that are sharing it (aka are under the
56 same bridge).
57 ::
58
59 fsl_dpaa2_switch dpsw.0: Flooding domain is not per FDB, cannot probe
60 fsl_dpaa2_switch dpsw.0: Broadcast domain is not per FDB, cannot probe
61
62 * The control interface of the switch should not be disabled
63 (DPSW_OPT_CTRL_IF_DIS not passed as a create time option). Without the
64 control interface, the driver is not capable to provide proper Rx/Tx traffic
65 support on the switch port netdevices.
66 ::
67
68 fsl_dpaa2_switch dpsw.0: Control Interface is disabled, cannot probe
69
70 Besides the configuration of the actual DPSW object, the dpaa2-switch driver
71 will need the following DPAA2 objects:
72
73 * 1 DPMCP - A Management Command Portal object is needed for any interaction
74 with the MC firmware.
75
76 * 1 DPBP - A Buffer Pool is used for seeding buffers intended for the Rx path
77 on the control interface.
78
79 * Access to at least one DPIO object (Software Portal) is needed for any
80 enqueue/dequeue operation to be performed on the control interface queues.
81 The DPIO object will be shared, no need for a private one.
82
83 Switching features
84 ==================
85
86 The driver supports the configuration of L2 forwarding rules in hardware for
87 port bridging as well as standalone usage of the independent switch interfaces.
88
89 The hardware is not configurable with respect to VLAN awareness, thus any DPAA2
90 switch port should be used only in usecases with a VLAN aware bridge::
91
92 $ ip link add dev br0 type bridge vlan_filtering 1
93
94 $ ip link add dev br1 type bridge
95 $ ip link set dev ethX master br1
96 Error: fsl_dpaa2_switch: Cannot join a VLAN-unaware bridge
97
98 Topology and loop detection through STP is supported when ``stp_state 1`` is
99 used at bridge create ::
100
101 $ ip link add dev br0 type bridge vlan_filtering 1 stp_state 1
102
103 L2 FDB manipulation (add/delete/dump) is supported.
104
105 HW FDB learning can be configured on each switch port independently through
106 bridge commands. When the HW learning is disabled, a fast age procedure will be
107 run and any previously learnt addresses will be removed.
108 ::
109
110 $ bridge link set dev ethX learning off
111 $ bridge link set dev ethX learning on
112
113 Restricting the unknown unicast and multicast flooding domain is supported, but
114 not independently of each other::
115
116 $ ip link set dev ethX type bridge_slave flood off mcast_flood off
117 $ ip link set dev ethX type bridge_slave flood off mcast_flood on
118 Error: fsl_dpaa2_switch: Cannot configure multicast flooding independently of unicast.
119
120 Broadcast flooding on a switch port can be disabled/enabled through the brport sysfs::
121
122 $ echo 0 > /sys/bus/fsl-mc/devices/dpsw.Y/net/ethX/brport/broadcast_flood
123
124 Offloads
125 ========
126
127 Routing actions (redirect, trap, drop)
128 --------------------------------------
129
130 The DPAA2 switch is able to offload flow-based redirection of packets making
131 use of ACL tables. Shared filter blocks are supported by sharing a single ACL
132 table between multiple ports.
133
134 The following flow keys are supported:
135
136 * Ethernet: dst_mac/src_mac
137 * IPv4: dst_ip/src_ip/ip_proto/tos
138 * VLAN: vlan_id/vlan_prio/vlan_tpid/vlan_dei
139 * L4: dst_port/src_port
140
141 Also, the matchall filter can be used to redirect the entire traffic received
142 on a port.
143
144 As per flow actions, the following are supported:
145
146 * drop
147 * mirred egress redirect
148 * trap
149
150 Each ACL entry (filter) can be setup with only one of the listed
151 actions.
152
153 Example 1: send frames received on eth4 with a SA of 00:01:02:03:04:05 to the
154 CPU::
155
156 $ tc qdisc add dev eth4 clsact
157 $ tc filter add dev eth4 ingress flower src_mac 00:01:02:03:04:05 skip_sw action trap
158
159 Example 2: drop frames received on eth4 with VID 100 and PCP of 3::
160
161 $ tc filter add dev eth4 ingress protocol 802.1q flower skip_sw vlan_id 100 vlan_prio 3 action drop
162
163 Example 3: redirect all frames received on eth4 to eth1::
164
165 $ tc filter add dev eth4 ingress matchall action mirred egress redirect dev eth1
166
167 Example 4: Use a single shared filter block on both eth5 and eth6::
168
169 $ tc qdisc add dev eth5 ingress_block 1 clsact
170 $ tc qdisc add dev eth6 ingress_block 1 clsact
171 $ tc filter add block 1 ingress flower dst_mac 00:01:02:03:04:04 skip_sw \
172 action trap
173 $ tc filter add block 1 ingress protocol ipv4 flower src_ip 192.168.1.1 skip_sw \
174 action mirred egress redirect dev eth3
175
176 Mirroring
177 ~~~~~~~~~
178
179 The DPAA2 switch supports only per port mirroring and per VLAN mirroring.
180 Adding mirroring filters in shared blocks is also supported.
181
182 When using the tc-flower classifier with the 802.1q protocol, only the
183 ''vlan_id'' key will be accepted. Mirroring based on any other fields from the
184 802.1q protocol will be rejected::
185
186 $ tc qdisc add dev eth8 ingress_block 1 clsact
187 $ tc filter add block 1 ingress protocol 802.1q flower skip_sw vlan_prio 3 action mirred egress mirror dev eth6
188 Error: fsl_dpaa2_switch: Only matching on VLAN ID supported.
189 We have an error talking to the kernel
190
191 If a mirroring VLAN filter is requested on a port, the VLAN must to be
192 installed on the switch port in question either using ''bridge'' or by creating
193 a VLAN upper device if the switch port is used as a standalone interface::
194
195 $ tc qdisc add dev eth8 ingress_block 1 clsact
196 $ tc filter add block 1 ingress protocol 802.1q flower skip_sw vlan_id 200 action mirred egress mirror dev eth6
197 Error: VLAN must be installed on the switch port.
198 We have an error talking to the kernel
199
200 $ bridge vlan add vid 200 dev eth8
201 $ tc filter add block 1 ingress protocol 802.1q flower skip_sw vlan_id 200 action mirred egress mirror dev eth6
202
203 $ ip link add link eth8 name eth8.200 type vlan id 200
204 $ tc filter add block 1 ingress protocol 802.1q flower skip_sw vlan_id 200 action mirred egress mirror dev eth6
205
206 Also, it should be noted that the mirrored traffic will be subject to the same
207 egress restrictions as any other traffic. This means that when a mirrored
208 packet will reach the mirror port, if the VLAN found in the packet is not
209 installed on the port it will get dropped.
210
211 The DPAA2 switch supports only a single mirroring destination, thus multiple
212 mirror rules can be installed but their ''to'' port has to be the same::
213
214 $ tc filter add block 1 ingress protocol 802.1q flower skip_sw vlan_id 200 action mirred egress mirror dev eth6
215 $ tc filter add block 1 ingress protocol 802.1q flower skip_sw vlan_id 100 action mirred egress mirror dev eth7
216 Error: fsl_dpaa2_switch: Multiple mirror ports not supported.
217 We have an error talking to the kernel
218

3. 한국어 전문 번역

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

DPAA2 Switch 드라이버와 포트 토폴로지

1-34

이 문서는 `GPL-2.0` 라이선스를 따르며 저작권은 © 2021 NXP에 있습니다.

DPAA2 Switch 드라이버

DPAA2 Switch 드라이버는 Datapath Switch(`DPSW`) 객체를 probe합니다. DPSW는 `LS2088A`, `LX2160A`와 그 변형 DPAA2 SoC에서 만들 수 있습니다.

드라이버는 switch device driver model을 사용하고 각 switch port를 네트워크 인터페이스로 노출합니다. 포트는 bridge에 포함하거나 독립 인터페이스로 사용할 수 있습니다.

포트 사이에서 switching되는 트래픽은 하드웨어로 offload됩니다.

DPSW 포트는 DPNI에 연결할 수도 있고 외부 접근을 위해 DPMAC에 연결할 수도 있습니다.

DPSW 포트 토폴로지
`ethA`·`ethB``dpaa2-eth`DPNIDPSW internal ports
`ethC` ... `ethF``dpaa2-switch`DPSW portsDPMACPHY

원문의 ASCII 도식을 Linux 인터페이스, 드라이버, DPSW, DPNI·DPMAC·PHY 연결로 다시 구성했습니다.

.. SPDX-License-Identifier: GPL-2.0
.. include:: <isonum.txt>

===================
DPAA2 Switch driver
===================

:Copyright: |copy| 2021 NXP

The DPAA2 Switch driver probes on the Datapath Switch (DPSW) object which can
be instantiated on the following DPAA2 SoCs and their variants: LS2088A and
LX2160A.

The driver uses the switch device driver model and exposes each switch port as
a network interface, which can be included in a bridge or used as a standalone
interface. Traffic switched between ports is offloaded into the hardware.

The DPSW can have ports connected to DPNIs or to DPMACs for external access.
::

         [ethA]     [ethB]      [ethC]     [ethD]     [ethE]     [ethF]
            :          :          :          :          :          :
            :          :          :          :          :          :
       [dpaa2-eth]  [dpaa2-eth]  [              dpaa2-switch              ]
            :          :          :          :          :          :        kernel
       =============================================================================
            :          :          :          :          :          :        hardware
         [DPNI]      [DPNI]     [============= DPSW =================]
            |          |          |          |          |          |
            |           ----------           |       [DPMAC]    [DPMAC]
             -------------------------------            |          |
                                                        |          |
                                                      [PHY]      [PHY]

Ethernet switch 생성 조건과 필요한 객체

35-82

Ethernet switch 생성

`dpaa2-switch` 드라이버는 `fsl-mc` bus에서 발견한 DPSW 장치를 probe합니다.

DPSW 장치는 boot-time 구성 파일인 DataPath Layout(`DPL`)로 정적으로 만들거나, 이미 `restool` userspace 도구에 포함된 DPAA2 object API로 실행 중 동적으로 만들 수 있습니다.

현재 `dpaa2-switch` 드라이버는 probe할 DPSW 객체에 다음 제약을 둡니다.

FDB 수

최소 FDB 수는 switch interface 수 이상이어야 합니다. bridge 아래에 있지 않을 때 각 switch port가 자체 FDB를 가져야 포트를 서로 분리할 수 있기 때문입니다.

fsl_dpaa2_switch dpsw.0: The number of FDBs is lower than the number of ports, cannot probe

broadcast와 flooding domain

broadcast와 flooding 구성이 모두 FDB별로 이루어져야 합니다. 그래야 같은 bridge 아래에 있어 FDB를 공유하는 switch port에 맞춰 각 FDB의 broadcast와 flooding domain을 제한할 수 있습니다.

fsl_dpaa2_switch dpsw.0: Flooding domain is not per FDB, cannot probe
fsl_dpaa2_switch dpsw.0: Broadcast domain is not per FDB, cannot probe

control interface

switch control interface가 비활성화되어서는 안 됩니다. 즉 생성 옵션으로 `DPSW_OPT_CTRL_IF_DIS`를 전달하면 안 됩니다.

control interface가 없으면 드라이버는 switch port netdevice에 올바른 Rx/Tx 트래픽 지원을 제공할 수 없습니다.

fsl_dpaa2_switch dpsw.0: Control Interface is disabled, cannot probe

실제 DPSW 객체 구성 외에도 `dpaa2-switch` 드라이버에는 다음 DPAA2 객체가 필요합니다.

  • DPMCP 1개: MC firmware와 상호 작용하기 위한 Management Command Portal
  • DPBP 1개: control interface의 Rx 경로용 버퍼를 채우는 Buffer Pool
  • DPIO 최소 1개에 대한 접근: control interface 큐에서 enqueue/dequeue 작업을 수행하는 Software Portal. 전용 객체가 아니라 공유 객체를 사용합니다.
Creating an Ethernet Switch
===========================

The dpaa2-switch driver probes on DPSW devices found on the fsl-mc bus. These
devices can be either created statically through the boot time configuration
file - DataPath Layout (DPL) - or at runtime using the DPAA2 object APIs
(incorporated already into the restool userspace tool).

At the moment, the dpaa2-switch driver imposes the following restrictions on
the DPSW object that it will probe:

 * The minimum number of FDBs should be at least equal to the number of switch
   interfaces. This is necessary so that separation of switch ports can be
   done, ie when not under a bridge, each switch port will have its own FDB.
   ::

        fsl_dpaa2_switch dpsw.0: The number of FDBs is lower than the number of ports, cannot probe

 * Both the broadcast and flooding configuration should be per FDB. This
   enables the driver to restrict the broadcast and flooding domains of each
   FDB depending on the switch ports that are sharing it (aka are under the
   same bridge).
   ::

        fsl_dpaa2_switch dpsw.0: Flooding domain is not per FDB, cannot probe
        fsl_dpaa2_switch dpsw.0: Broadcast domain is not per FDB, cannot probe

 * The control interface of the switch should not be disabled
   (DPSW_OPT_CTRL_IF_DIS not passed as a create time option). Without the
   control interface, the driver is not capable to provide proper Rx/Tx traffic
   support on the switch port netdevices.
   ::

        fsl_dpaa2_switch dpsw.0: Control Interface is disabled, cannot probe

Besides the configuration of the actual DPSW object, the dpaa2-switch driver
will need the following DPAA2 objects:

 * 1 DPMCP - A Management Command Portal object is needed for any interaction
   with the MC firmware.

 * 1 DPBP - A Buffer Pool is used for seeding buffers intended for the Rx path
   on the control interface.

 * Access to at least one DPIO object (Software Portal) is needed for any
   enqueue/dequeue operation to be performed on the control interface queues.
   The DPIO object will be shared, no need for a private one.

L2 switching, VLAN·STP·FDB와 flooding

83-123

Switching 기능

드라이버는 port bridging과 각 switch interface의 독립 사용을 위한 L2 forwarding rule을 하드웨어에 구성할 수 있습니다.

하드웨어의 VLAN awareness는 구성할 수 없습니다. 따라서 DPAA2 switch port는 VLAN-aware bridge를 사용하는 사례에서만 사용해야 합니다.

ip link add dev br0 type bridge vlan_filtering 1

VLAN-unaware bridge에 연결하려 하면 실패합니다.

ip link add dev br1 type bridge
ip link set dev ethX master br1
Error: fsl_dpaa2_switch: Cannot join a VLAN-unaware bridge

bridge 생성 시 `stp_state 1`을 사용하면 STP를 통한 topology와 loop detection을 지원합니다.

ip link add dev br0 type bridge vlan_filtering 1 stp_state 1

L2 FDB의 add, delete, dump를 지원합니다.

각 switch port의 하드웨어 FDB learning은 bridge 명령으로 독립 구성할 수 있습니다. hardware learning을 끄면 fast age 절차를 실행해 이전에 학습한 주소를 모두 제거합니다.

bridge link set dev ethX learning off
bridge link set dev ethX learning on

unknown unicast와 multicast flooding domain을 제한할 수 있지만 둘을 서로 독립적으로 구성할 수는 없습니다.

ip link set dev ethX type bridge_slave flood off mcast_flood off
ip link set dev ethX type bridge_slave flood off mcast_flood on
Error: fsl_dpaa2_switch: Cannot configure multicast flooding independently of unicast.

switch port의 broadcast flooding은 `brport` sysfs를 통해 끄고 켤 수 있습니다.

echo 0 > /sys/bus/fsl-mc/devices/dpsw.Y/net/ethX/brport/broadcast_flood
Switching features
==================

The driver supports the configuration of L2 forwarding rules in hardware for
port bridging as well as standalone usage of the independent switch interfaces.

The hardware is not configurable with respect to VLAN awareness, thus any DPAA2
switch port should be used only in usecases with a VLAN aware bridge::

        $ ip link add dev br0 type bridge vlan_filtering 1

        $ ip link add dev br1 type bridge
        $ ip link set dev ethX master br1
        Error: fsl_dpaa2_switch: Cannot join a VLAN-unaware bridge

Topology and loop detection through STP is supported when ``stp_state 1`` is
used at bridge create ::

        $ ip link add dev br0 type bridge vlan_filtering 1 stp_state 1

L2 FDB manipulation (add/delete/dump) is supported.

HW FDB learning can be configured on each switch port independently through
bridge commands. When the HW learning is disabled, a fast age procedure will be
run and any previously learnt addresses will be removed.
::

        $ bridge link set dev ethX learning off
        $ bridge link set dev ethX learning on

Restricting the unknown unicast and multicast flooding domain is supported, but
not independently of each other::

        $ ip link set dev ethX type bridge_slave flood off mcast_flood off
        $ ip link set dev ethX type bridge_slave flood off mcast_flood on
        Error: fsl_dpaa2_switch: Cannot configure multicast flooding independently of unicast.

Broadcast flooding on a switch port can be disabled/enabled through the brport sysfs::

        $ echo 0 > /sys/bus/fsl-mc/devices/dpsw.Y/net/ethX/brport/broadcast_flood

ACL 기반 redirect·trap·drop offload

124-175

Offload

Routing action: redirect, trap, drop

DPAA2 switch는 ACL table을 사용해 flow 기반 packet redirection을 offload할 수 있습니다. 여러 port가 ACL table 하나를 공유하는 shared filter block도 지원합니다.

지원 flow key

계층
Ethernet`dst_mac`, `src_mac`
IPv4`dst_ip`, `src_ip`, `ip_proto`, `tos`
VLAN`vlan_id`, `vlan_prio`, `vlan_tpid`, `vlan_dei`
L4`dst_port`, `src_port`

`matchall` filter를 사용하면 port에서 받은 모든 트래픽을 redirect할 수 있습니다.

지원 flow action

  • `drop`
  • `mirred egress redirect`
  • `trap`

ACL entry, 즉 filter 하나에는 위 action 중 하나만 설정할 수 있습니다.

예제 1: `eth4`에서 받은 frame 중 source address가 `00:01:02:03:04:05`인 frame을 CPU로 보냅니다.

tc qdisc add dev eth4 clsact
tc filter add dev eth4 ingress flower src_mac 00:01:02:03:04:05 skip_sw action trap

예제 2: `eth4`에서 받은 frame 중 VID 100이고 PCP가 3인 frame을 drop합니다.

tc filter add dev eth4 ingress protocol 802.1q flower skip_sw vlan_id 100 vlan_prio 3 action drop

예제 3: `eth4`에서 받은 모든 frame을 `eth1`로 redirect합니다.

tc filter add dev eth4 ingress matchall action mirred egress redirect dev eth1

예제 4: `eth5`와 `eth6`에서 shared filter block 하나를 사용합니다.

tc qdisc add dev eth5 ingress_block 1 clsact
tc qdisc add dev eth6 ingress_block 1 clsact
tc filter add block 1 ingress flower dst_mac 00:01:02:03:04:04 skip_sw \
  action trap
tc filter add block 1 ingress protocol ipv4 flower src_ip 192.168.1.1 skip_sw \
  action mirred egress redirect dev eth3
Offloads
========

Routing actions (redirect, trap, drop)
--------------------------------------

The DPAA2 switch is able to offload flow-based redirection of packets making
use of ACL tables. Shared filter blocks are supported by sharing a single ACL
table between multiple ports.

The following flow keys are supported:

 * Ethernet: dst_mac/src_mac
 * IPv4: dst_ip/src_ip/ip_proto/tos
 * VLAN: vlan_id/vlan_prio/vlan_tpid/vlan_dei
 * L4: dst_port/src_port

Also, the matchall filter can be used to redirect the entire traffic received
on a port.

As per flow actions, the following are supported:

 * drop
 * mirred egress redirect
 * trap

Each ACL entry (filter) can be setup with only one of the listed
actions.

Example 1: send frames received on eth4 with a SA of 00:01:02:03:04:05 to the
CPU::

        $ tc qdisc add dev eth4 clsact
        $ tc filter add dev eth4 ingress flower src_mac 00:01:02:03:04:05 skip_sw action trap

Example 2: drop frames received on eth4 with VID 100 and PCP of 3::

        $ tc filter add dev eth4 ingress protocol 802.1q flower skip_sw vlan_id 100 vlan_prio 3 action drop

Example 3: redirect all frames received on eth4 to eth1::

        $ tc filter add dev eth4 ingress matchall action mirred egress redirect dev eth1

Example 4: Use a single shared filter block on both eth5 and eth6::

        $ tc qdisc add dev eth5 ingress_block 1 clsact
        $ tc qdisc add dev eth6 ingress_block 1 clsact
        $ tc filter add block 1 ingress flower dst_mac 00:01:02:03:04:04 skip_sw \
                action trap
        $ tc filter add block 1 ingress protocol ipv4 flower src_ip 192.168.1.1 skip_sw \
                action mirred egress redirect dev eth3

port·VLAN mirroring 제약

176-217

Mirroring

DPAA2 switch는 port별 mirroring과 VLAN별 mirroring만 지원합니다. shared block에 mirroring filter를 추가하는 것도 지원합니다.

`802.1q` protocol과 함께 `tc-flower` classifier를 사용할 때는 `vlan_id` key만 허용합니다. 다른 802.1q field를 기준으로 mirroring하려 하면 거부됩니다.

tc qdisc add dev eth8 ingress_block 1 clsact
tc filter add block 1 ingress protocol 802.1q flower skip_sw vlan_prio 3 action mirred egress mirror dev eth6
Error: fsl_dpaa2_switch: Only matching on VLAN ID supported.
We have an error talking to the kernel

port에 mirroring VLAN filter를 요청하려면 해당 switch port에 VLAN이 설치되어 있어야 합니다. `bridge`로 설치하거나, switch port를 독립 인터페이스로 사용할 때 VLAN upper device를 만들 수 있습니다.

tc qdisc add dev eth8 ingress_block 1 clsact
tc filter add block 1 ingress protocol 802.1q flower skip_sw vlan_id 200 action mirred egress mirror dev eth6
Error: VLAN must be installed on the switch port.
We have an error talking to the kernel

bridge로 VLAN 200을 설치한 뒤 filter를 추가하는 예입니다.

bridge vlan add vid 200 dev eth8
tc filter add block 1 ingress protocol 802.1q flower skip_sw vlan_id 200 action mirred egress mirror dev eth6

VLAN upper device를 만든 뒤 filter를 추가하는 예입니다.

ip link add link eth8 name eth8.200 type vlan id 200
tc filter add block 1 ingress protocol 802.1q flower skip_sw vlan_id 200 action mirred egress mirror dev eth6

mirrored 트래픽도 다른 트래픽과 같은 egress 제한을 받습니다. packet의 VLAN이 mirror port에 설치되어 있지 않으면 port에 도달했을 때 drop됩니다.

DPAA2 switch는 mirroring destination을 하나만 지원합니다. 여러 mirror rule을 설치할 수 있지만 모두 같은 `to` port를 사용해야 합니다.

tc filter add block 1 ingress protocol 802.1q flower skip_sw vlan_id 200 action mirred egress mirror dev eth6
tc filter add block 1 ingress protocol 802.1q flower skip_sw vlan_id 100 action mirred egress mirror dev eth7
Error: fsl_dpaa2_switch: Multiple mirror ports not supported.
We have an error talking to the kernel
Mirroring
~~~~~~~~~

The DPAA2 switch supports only per port mirroring and per VLAN mirroring.
Adding mirroring filters in shared blocks is also supported.

When using the tc-flower classifier with the 802.1q protocol, only the
''vlan_id'' key will be accepted. Mirroring based on any other fields from the
802.1q protocol will be rejected::

        $ tc qdisc add dev eth8 ingress_block 1 clsact
        $ tc filter add block 1 ingress protocol 802.1q flower skip_sw vlan_prio 3 action mirred egress mirror dev eth6
        Error: fsl_dpaa2_switch: Only matching on VLAN ID supported.
        We have an error talking to the kernel

If a mirroring VLAN filter is requested on a port, the VLAN must to be
installed on the switch port in question either using ''bridge'' or by creating
a VLAN upper device if the switch port is used as a standalone interface::

        $ tc qdisc add dev eth8 ingress_block 1 clsact
        $ tc filter add block 1 ingress protocol 802.1q flower skip_sw vlan_id 200 action mirred egress mirror dev eth6
        Error: VLAN must be installed on the switch port.
        We have an error talking to the kernel

        $ bridge vlan add vid 200 dev eth8
        $ tc filter add block 1 ingress protocol 802.1q flower skip_sw vlan_id 200 action mirred egress mirror dev eth6

        $ ip link add link eth8 name eth8.200 type vlan id 200
        $ tc filter add block 1 ingress protocol 802.1q flower skip_sw vlan_id 200 action mirred egress mirror dev eth6

Also, it should be noted that the mirrored traffic will be subject to the same
egress restrictions as any other traffic. This means that when a mirrored
packet will reach the mirror port, if the VLAN found in the packet is not
installed on the port it will get dropped.

The DPAA2 switch supports only a single mirroring destination, thus multiple
mirror rules can be installed but their ''to'' port has to be the same::

        $ tc filter add block 1 ingress protocol 802.1q flower skip_sw vlan_id 200 action mirred egress mirror dev eth6
        $ tc filter add block 1 ingress protocol 802.1q flower skip_sw vlan_id 100 action mirred egress mirror dev eth7
        Error: fsl_dpaa2_switch: Multiple mirror ports not supported.
        We have an error talking to the kernel