Hairpin Mesh Configuration and Testing
The new dpdk-testpmd parameter allows explicit selection of Rx and Tx ports and Rx and Tx queues in hairpin configuration.
The new hairpin-map parameter is provided with 5 parameters, separated by:
--hairpin-map=Rx port id:Rx queue:Tx port id:Tx queue:queues number
Configuration can provide several hairpin-map parameters. For example:
dpdk-testpmd <EAL params> -- <testpmd params> \
--rxq=2
--txq=2
--hairpinq=2
--hairpin-mode=0x12
\
--hairpin-map=0
:2
:1
:2
:1
\ # [1
]
--hairpin-map=0
:3
:2
:2
:3
# [2
]
Hairpin map [1] binds Rx port 0, queue 2 with Tx port 1, queue 2.
Hairpin map [2] binds
Rx port 0, queue 3 with Tx port 2, queue 2,
Rx port 0, queue 4 with Tx port 2, queue 3,
Rx port 0, queue 5 with Tx port 2, queue 4,
The new hairpin-map parameter is optional.
If omitted, testpmd will create "default" hairpin maps.
Starting testpmd application:
dpdk-testpmd -a 08
:00.0
-a 08
:00.1
-a 08
:00.2
-a 08
:00.3
-- \
-i --rxq=2
--txq=2
--hairpinq=16
--hairpin-mode=0x12
\
--hairpin-map=0
:2
:0
:2
:1
--hairpin-map=0
:3
:1
:3
:1
--hairpin-map=0
:4
:2
:4
:1
--hairpin-map=0
:5
:3
:5
:1
\
--hairpin-map=1
:6
:0
:6
:1
--hairpin-map=1
:7
:1
:7
:1
--hairpin-map=1
:8
:2
:8
:1
--hairpin-map=1
:9
:3
:9
:1
\
--hairpin-map=2
:10
:0
:10
:1
--hairpin-map=2
:11
:1
:11
:1
--hairpin-map=2
:12
:2
:12
:1
--hairpin-map=2
:13
:3
:13
:1
\
--hairpin-map=3
:14
:0
:14
:1
--hairpin-map=3
:15
:1
:15
:1
--hairpin-map=3
:16
:2
:16
:1
--hairpin-map=3
:17
:3
:17
:1
Insert flow rules (non-template API in this example):
set fwd rxonly
start
flow create 0
ingress pattern eth / ipv4 / udp / end actions jump group 1
/ end
flow create 0
ingress group 1
pattern eth / end actions modify_field op set dst_type udp_port_dst src_type value src_value 0100
width 16
/ jump group 2
/ end
flow create 0
ingress group 2
pattern eth / ipv4 / udp src is 1111
/ end actions queue index 2
/ end
flow create 0
ingress group 2
pattern eth / ipv4 / udp src is 2222
/ end actions queue index 3
/ end
flow create 0
ingress group 2
pattern eth / ipv4 / udp src is 3333
/ end actions queue index 4
/ end
flow create 0
ingress group 2
pattern eth / ipv4 / udp src is 4444
/ end actions queue index 5
/ end
flow create 1
ingress pattern eth / ipv4 / udp / end actions jump group 1
/ end
flow create 1
ingress group 1
pattern eth / end actions modify_field op set dst_type udp_port_dst src_type value src_value 0100
width 16
/ jump group 2
/ end
flow create 1
ingress group 2
pattern eth / ipv4 / udp src is 1111
/ end actions queue index 6
/ end
flow create 1
ingress group 2
pattern eth / ipv4 / udp src is 2222
/ end actions queue index 7
/ end
flow create 1
ingress group 2
pattern eth / ipv4 / udp src is 3333
/ end actions queue index 8
/ end
flow create 1
ingress group 2
pattern eth / ipv4 / udp src is 4444
/ end actions queue index 9
/ end
flow create 2
ingress pattern eth / ipv4 / udp / end actions jump group 1
/ end
flow create 2
ingress group 1
pattern eth / end actions modify_field op set dst_type udp_port_dst src_type value src_value 0100
width 16
/ jump group 2
/ end
flow create 2
ingress group 2
pattern eth / ipv4 / udp src is 1111
/ end actions queue index 10
/ end
flow create 2
ingress group 2
pattern eth / ipv4 / udp src is 2222
/ end actions queue index 11
/ end
flow create 2
ingress group 2
pattern eth / ipv4 / udp src is 3333
/ end actions queue index 12
/ end
flow create 2
ingress group 2
pattern eth / ipv4 / udp src is 4444
/ end actions queue index 13
/ end
flow create 3
ingress pattern eth / ipv4 / udp / end actions jump group 1
/ end
flow create 3
ingress group 1
pattern eth / end actions modify_field op set dst_type udp_port_dst src_type value src_value 0100
width 16
/ jump group 2
/ end
flow create 3
ingress group 2
pattern eth / ipv4 / udp src is 1111
/ end actions queue index 14
/ end
flow create 3
ingress group 2
pattern eth / ipv4 / udp src is 2222
/ end actions queue index 15
/ end
flow create 3
ingress group 2
pattern eth / ipv4 / udp src is 3333
/ end actions queue index 16
/ end
flow create 3
ingress group 2
pattern eth / ipv4 / udp src is 4444
/ end actions queue index 17
/ end
Sending and sniffing the packets from the TG:
p1=Ether(src='11:22:33:44:55:66'
, dst='aa:bb:cc:dd:ee:aa'
)/IP(src='1.1.1.1'
, dst='2.2.2.2'
)/UDP(sport=1111
, dport=5678
)/Raw('== hairpin test 1 =='
)
p2=Ether(src='11:22:33:44:55:66'
, dst='aa:bb:cc:dd:ee:aa'
)/IP(src='1.1.1.1'
, dst='2.2.2.2'
)/UDP(sport=2222
, dport=5678
)/Raw('== hairpin test 2 =='
)
p3=Ether(src='11:22:33:44:55:66'
, dst='aa:bb:cc:dd:ee:aa'
)/IP(src='1.1.1.1'
, dst='2.2.2.2'
)/UDP(sport=3333
, dport=5678
)/Raw('== hairpin test 3 =='
)
p4=Ether(src='11:22:33:44:55:66'
, dst='aa:bb:cc:dd:ee:aa'
)/IP(src='1.1.1.1'
, dst='2.2.2.2'
)/UDP(sport=4444
, dport=5678
)/Raw('== hairpin test 4 =='
)
sniff2=AsyncSniffer(iface='eth2'
, filter='udp'
, prn=lambda x:print('ETH2 CAPTURE:'
+ x.command()))
sniff2.start()
sniff3=AsyncSniffer(iface='eth3'
, filter='udp'
, prn=lambda x:print('ETH3 CAPTURE:'
+ x.command()))
sniff3.start()
sniff4=AsyncSniffer(iface='eth4'
, filter='udp'
, prn=lambda x:print('ETH4 CAPTURE:'
+ x.command()))
sniff4.start()
sniff5=AsyncSniffer(iface='eth5'
, filter='udp'
, prn=lambda x:print('ETH5 CAPTURE:'
+ x.command()))
sniff5.start()