Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

docs: networking: convert pktgen.txt to ReST

- add SPDX header;
- adjust title markup;
- use bold markups on a few places;
- mark code blocks and literals as such;
- adjust identation, whitespaces and blank lines where needed;
- add to networking/index.rst.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Mauro Carvalho Chehab and committed by
David S. Miller
c1e4535f 6e94eaaa

+168 -155
+1
Documentation/networking/index.rst
··· 91 91 operstates 92 92 packet_mmap 93 93 phonet 94 + pktgen 94 95 95 96 .. only:: subproject and html 96 97
+164 -152
Documentation/networking/pktgen.txt Documentation/networking/pktgen.rst
··· 1 + .. SPDX-License-Identifier: GPL-2.0 1 2 2 - 3 - HOWTO for the linux packet generator 4 - ------------------------------------ 3 + ==================================== 4 + HOWTO for the linux packet generator 5 + ==================================== 5 6 6 7 Enable CONFIG_NET_PKTGEN to compile and build pktgen either in-kernel 7 8 or as a module. A module is preferred; modprobe pktgen if needed. Once ··· 10 9 Monitoring and controlling is done via /proc. It is easiest to select a 11 10 suitable sample script and configure that. 12 11 13 - On a dual CPU: 12 + On a dual CPU:: 14 13 15 - ps aux | grep pkt 16 - root 129 0.3 0.0 0 0 ? SW 2003 523:20 [kpktgend_0] 17 - root 130 0.3 0.0 0 0 ? SW 2003 509:50 [kpktgend_1] 14 + ps aux | grep pkt 15 + root 129 0.3 0.0 0 0 ? SW 2003 523:20 [kpktgend_0] 16 + root 130 0.3 0.0 0 0 ? SW 2003 509:50 [kpktgend_1] 18 17 19 18 20 - For monitoring and control pktgen creates: 19 + For monitoring and control pktgen creates:: 20 + 21 21 /proc/net/pktgen/pgctrl 22 22 /proc/net/pktgen/kpktgend_X 23 - /proc/net/pktgen/ethX 23 + /proc/net/pktgen/ethX 24 24 25 25 26 26 Tuning NIC for max performance ··· 30 28 The default NIC settings are (likely) not tuned for pktgen's artificial 31 29 overload type of benchmarking, as this could hurt the normal use-case. 32 30 33 - Specifically increasing the TX ring buffer in the NIC: 31 + Specifically increasing the TX ring buffer in the NIC:: 32 + 34 33 # ethtool -G ethX tx 1024 35 34 36 35 A larger TX ring can improve pktgen's performance, while it can hurt ··· 49 46 and the cleanup interval is affected by the ethtool --coalesce setting 50 47 of parameter "rx-usecs". 51 48 52 - For ixgbe use e.g. "30" resulting in approx 33K interrupts/sec (1/30*10^6): 49 + For ixgbe use e.g. "30" resulting in approx 33K interrupts/sec (1/30*10^6):: 50 + 53 51 # ethtool -C ethX rx-usecs 30 54 52 55 53 ··· 59 55 Pktgen creates a thread for each CPU with affinity to that CPU. 60 56 Which is controlled through procfile /proc/net/pktgen/kpktgend_X. 61 57 62 - Example: /proc/net/pktgen/kpktgend_0 58 + Example: /proc/net/pktgen/kpktgend_0:: 63 59 64 60 Running: 65 61 Stopped: eth4@0 ··· 68 64 Most important are the devices assigned to the thread. 69 65 70 66 The two basic thread commands are: 67 + 71 68 * add_device DEVICE@NAME -- adds a single device 72 69 * rem_device_all -- remove all associated devices 73 70 ··· 78 73 79 74 To support adding the same device to multiple threads, which is useful 80 75 with multi queue NICs, the device naming scheme is extended with "@": 81 - device@something 76 + device@something 82 77 83 78 The part after "@" can be anything, but it is custom to use the thread 84 79 number. ··· 88 83 89 84 The Params section holds configured information. The Current section 90 85 holds running statistics. The Result is printed after a run or after 91 - interruption. Example: 86 + interruption. Example:: 92 87 93 - /proc/net/pktgen/eth4@0 88 + /proc/net/pktgen/eth4@0 94 89 95 - Params: count 100000 min_pkt_size: 60 max_pkt_size: 60 96 - frags: 0 delay: 0 clone_skb: 64 ifname: eth4@0 97 - flows: 0 flowlen: 0 98 - queue_map_min: 0 queue_map_max: 0 99 - dst_min: 192.168.81.2 dst_max: 100 - src_min: src_max: 101 - src_mac: 90:e2:ba:0a:56:b4 dst_mac: 00:1b:21:3c:9d:f8 102 - udp_src_min: 9 udp_src_max: 109 udp_dst_min: 9 udp_dst_max: 9 103 - src_mac_count: 0 dst_mac_count: 0 104 - Flags: UDPSRC_RND NO_TIMESTAMP QUEUE_MAP_CPU 105 - Current: 106 - pkts-sofar: 100000 errors: 0 107 - started: 623913381008us stopped: 623913396439us idle: 25us 108 - seq_num: 100001 cur_dst_mac_offset: 0 cur_src_mac_offset: 0 109 - cur_saddr: 192.168.8.3 cur_daddr: 192.168.81.2 110 - cur_udp_dst: 9 cur_udp_src: 42 111 - cur_queue_map: 0 112 - flows: 0 113 - Result: OK: 15430(c15405+d25) usec, 100000 (60byte,0frags) 114 - 6480562pps 3110Mb/sec (3110669760bps) errors: 0 90 + Params: count 100000 min_pkt_size: 60 max_pkt_size: 60 91 + frags: 0 delay: 0 clone_skb: 64 ifname: eth4@0 92 + flows: 0 flowlen: 0 93 + queue_map_min: 0 queue_map_max: 0 94 + dst_min: 192.168.81.2 dst_max: 95 + src_min: src_max: 96 + src_mac: 90:e2:ba:0a:56:b4 dst_mac: 00:1b:21:3c:9d:f8 97 + udp_src_min: 9 udp_src_max: 109 udp_dst_min: 9 udp_dst_max: 9 98 + src_mac_count: 0 dst_mac_count: 0 99 + Flags: UDPSRC_RND NO_TIMESTAMP QUEUE_MAP_CPU 100 + Current: 101 + pkts-sofar: 100000 errors: 0 102 + started: 623913381008us stopped: 623913396439us idle: 25us 103 + seq_num: 100001 cur_dst_mac_offset: 0 cur_src_mac_offset: 0 104 + cur_saddr: 192.168.8.3 cur_daddr: 192.168.81.2 105 + cur_udp_dst: 9 cur_udp_src: 42 106 + cur_queue_map: 0 107 + flows: 0 108 + Result: OK: 15430(c15405+d25) usec, 100000 (60byte,0frags) 109 + 6480562pps 3110Mb/sec (3110669760bps) errors: 0 115 110 116 111 117 112 Configuring devices ··· 119 114 This is done via the /proc interface, and most easily done via pgset 120 115 as defined in the sample scripts. 121 116 You need to specify PGDEV environment variable to use functions from sample 122 - scripts, i.e.: 123 - export PGDEV=/proc/net/pktgen/eth4@0 124 - source samples/pktgen/functions.sh 117 + scripts, i.e.:: 125 118 126 - Examples: 119 + export PGDEV=/proc/net/pktgen/eth4@0 120 + source samples/pktgen/functions.sh 121 + 122 + Examples:: 127 123 128 124 pg_ctrl start starts injection. 129 125 pg_ctrl stop aborts injection. Also, ^C aborts generator. ··· 132 126 pgset "clone_skb 1" sets the number of copies of the same packet 133 127 pgset "clone_skb 0" use single SKB for all transmits 134 128 pgset "burst 8" uses xmit_more API to queue 8 copies of the same 135 - packet and update HW tx queue tail pointer once. 136 - "burst 1" is the default 129 + packet and update HW tx queue tail pointer once. 130 + "burst 1" is the default 137 131 pgset "pkt_size 9014" sets packet size to 9014 138 132 pgset "frags 5" packet will consist of 5 fragments 139 133 pgset "count 200000" sets number of packets to send, set to zero 140 - for continuous sends until explicitly stopped. 134 + for continuous sends until explicitly stopped. 141 135 142 136 pgset "delay 5000" adds delay to hard_start_xmit(). nanoseconds 143 137 144 138 pgset "dst 10.0.0.1" sets IP destination address 145 - (BEWARE! This generator is very aggressive!) 139 + (BEWARE! This generator is very aggressive!) 146 140 147 141 pgset "dst_min 10.0.0.1" Same as dst 148 142 pgset "dst_max 10.0.0.254" Set the maximum destination IP. ··· 155 149 156 150 pgset "queue_map_min 0" Sets the min value of tx queue interval 157 151 pgset "queue_map_max 7" Sets the max value of tx queue interval, for multiqueue devices 158 - To select queue 1 of a given device, 159 - use queue_map_min=1 and queue_map_max=1 152 + To select queue 1 of a given device, 153 + use queue_map_min=1 and queue_map_max=1 160 154 161 155 pgset "src_mac_count 1" Sets the number of MACs we'll range through. 162 - The 'minimum' MAC is what you set with srcmac. 156 + The 'minimum' MAC is what you set with srcmac. 163 157 164 158 pgset "dst_mac_count 1" Sets the number of MACs we'll range through. 165 - The 'minimum' MAC is what you set with dstmac. 159 + The 'minimum' MAC is what you set with dstmac. 166 160 167 161 pgset "flag [name]" Set a flag to determine behaviour. Current flags 168 - are: IPSRC_RND # IP source is random (between min/max) 169 - IPDST_RND # IP destination is random 170 - UDPSRC_RND, UDPDST_RND, 171 - MACSRC_RND, MACDST_RND 172 - TXSIZE_RND, IPV6, 173 - MPLS_RND, VID_RND, SVID_RND 174 - FLOW_SEQ, 175 - QUEUE_MAP_RND # queue map random 176 - QUEUE_MAP_CPU # queue map mirrors smp_processor_id() 177 - UDPCSUM, 178 - IPSEC # IPsec encapsulation (needs CONFIG_XFRM) 179 - NODE_ALLOC # node specific memory allocation 180 - NO_TIMESTAMP # disable timestamping 162 + are: IPSRC_RND # IP source is random (between min/max) 163 + IPDST_RND # IP destination is random 164 + UDPSRC_RND, UDPDST_RND, 165 + MACSRC_RND, MACDST_RND 166 + TXSIZE_RND, IPV6, 167 + MPLS_RND, VID_RND, SVID_RND 168 + FLOW_SEQ, 169 + QUEUE_MAP_RND # queue map random 170 + QUEUE_MAP_CPU # queue map mirrors smp_processor_id() 171 + UDPCSUM, 172 + IPSEC # IPsec encapsulation (needs CONFIG_XFRM) 173 + NODE_ALLOC # node specific memory allocation 174 + NO_TIMESTAMP # disable timestamping 181 175 pgset 'flag ![name]' Clear a flag to determine behaviour. 182 - Note that you might need to use single quote in 183 - interactive mode, so that your shell wouldn't expand 184 - the specified flag as a history command. 176 + Note that you might need to use single quote in 177 + interactive mode, so that your shell wouldn't expand 178 + the specified flag as a history command. 185 179 186 180 pgset "spi [SPI_VALUE]" Set specific SA used to transform packet. 187 181 188 182 pgset "udp_src_min 9" set UDP source port min, If < udp_src_max, then 189 - cycle through the port range. 183 + cycle through the port range. 190 184 191 185 pgset "udp_src_max 9" set UDP source port max. 192 186 pgset "udp_dst_min 9" set UDP destination port min, If < udp_dst_max, then 193 - cycle through the port range. 187 + cycle through the port range. 194 188 pgset "udp_dst_max 9" set UDP destination port max. 195 189 196 190 pgset "mpls 0001000a,0002000a,0000000a" set MPLS labels (in this example 197 - outer label=16,middle label=32, 191 + outer label=16,middle label=32, 198 192 inner label=0 (IPv4 NULL)) Note that 199 193 there must be no spaces between the 200 194 arguments. Leading zeros are required. ··· 238 232 samples/pktgen directory. The helper parameters.sh file support easy 239 233 and consistent parameter parsing across the sample scripts. 240 234 241 - Usage example and help: 235 + Usage example and help:: 236 + 242 237 ./pktgen_sample01_simple.sh -i eth4 -m 00:1B:21:3C:9D:F8 -d 192.168.8.2 243 238 244 - Usage: ./pktgen_sample01_simple.sh [-vx] -i ethX 239 + Usage::: 240 + 241 + ./pktgen_sample01_simple.sh [-vx] -i ethX 242 + 245 243 -i : ($DEV) output interface/device (required) 246 244 -s : ($PKT_SIZE) packet size 247 245 -d : ($DEST_IP) destination IP ··· 260 250 interface/device parameter "-i" sets variable $DEV. Copy the 261 251 pktgen_sampleXX scripts and modify them to fit your own needs. 262 252 263 - The old scripts: 253 + The old scripts:: 264 254 265 - pktgen.conf-1-2 # 1 CPU 2 dev 266 - pktgen.conf-1-1-rdos # 1 CPU 1 dev w. route DoS 267 - pktgen.conf-1-1-ip6 # 1 CPU 1 dev ipv6 268 - pktgen.conf-1-1-ip6-rdos # 1 CPU 1 dev ipv6 w. route DoS 269 - pktgen.conf-1-1-flows # 1 CPU 1 dev multiple flows. 255 + pktgen.conf-1-2 # 1 CPU 2 dev 256 + pktgen.conf-1-1-rdos # 1 CPU 1 dev w. route DoS 257 + pktgen.conf-1-1-ip6 # 1 CPU 1 dev ipv6 258 + pktgen.conf-1-1-ip6-rdos # 1 CPU 1 dev ipv6 w. route DoS 259 + pktgen.conf-1-1-flows # 1 CPU 1 dev multiple flows. 270 260 271 261 272 262 Interrupt affinity ··· 281 271 Enable IPsec 282 272 ============ 283 273 Default IPsec transformation with ESP encapsulation plus transport mode 284 - can be enabled by simply setting: 274 + can be enabled by simply setting:: 285 275 286 - pgset "flag IPSEC" 287 - pgset "flows 1" 276 + pgset "flag IPSEC" 277 + pgset "flows 1" 288 278 289 279 To avoid breaking existing testbed scripts for using AH type and tunnel mode, 290 280 you can use "pgset spi SPI_VALUE" to specify which transformation mode ··· 294 284 Current commands and configuration options 295 285 ========================================== 296 286 297 - ** Pgcontrol commands: 287 + **Pgcontrol commands**:: 298 288 299 - start 300 - stop 301 - reset 289 + start 290 + stop 291 + reset 302 292 303 - ** Thread commands: 293 + **Thread commands**:: 304 294 305 - add_device 306 - rem_device_all 295 + add_device 296 + rem_device_all 307 297 308 298 309 - ** Device commands: 299 + **Device commands**:: 310 300 311 - count 312 - clone_skb 313 - burst 314 - debug 301 + count 302 + clone_skb 303 + burst 304 + debug 315 305 316 - frags 317 - delay 306 + frags 307 + delay 318 308 319 - src_mac_count 320 - dst_mac_count 309 + src_mac_count 310 + dst_mac_count 321 311 322 - pkt_size 323 - min_pkt_size 324 - max_pkt_size 312 + pkt_size 313 + min_pkt_size 314 + max_pkt_size 325 315 326 - queue_map_min 327 - queue_map_max 328 - skb_priority 316 + queue_map_min 317 + queue_map_max 318 + skb_priority 329 319 330 - tos (ipv4) 331 - traffic_class (ipv6) 320 + tos (ipv4) 321 + traffic_class (ipv6) 332 322 333 - mpls 323 + mpls 334 324 335 - udp_src_min 336 - udp_src_max 325 + udp_src_min 326 + udp_src_max 337 327 338 - udp_dst_min 339 - udp_dst_max 328 + udp_dst_min 329 + udp_dst_max 340 330 341 - node 331 + node 342 332 343 - flag 344 - IPSRC_RND 345 - IPDST_RND 346 - UDPSRC_RND 347 - UDPDST_RND 348 - MACSRC_RND 349 - MACDST_RND 350 - TXSIZE_RND 351 - IPV6 352 - MPLS_RND 353 - VID_RND 354 - SVID_RND 355 - FLOW_SEQ 356 - QUEUE_MAP_RND 357 - QUEUE_MAP_CPU 358 - UDPCSUM 359 - IPSEC 360 - NODE_ALLOC 361 - NO_TIMESTAMP 333 + flag 334 + IPSRC_RND 335 + IPDST_RND 336 + UDPSRC_RND 337 + UDPDST_RND 338 + MACSRC_RND 339 + MACDST_RND 340 + TXSIZE_RND 341 + IPV6 342 + MPLS_RND 343 + VID_RND 344 + SVID_RND 345 + FLOW_SEQ 346 + QUEUE_MAP_RND 347 + QUEUE_MAP_CPU 348 + UDPCSUM 349 + IPSEC 350 + NODE_ALLOC 351 + NO_TIMESTAMP 362 352 363 - spi (ipsec) 353 + spi (ipsec) 364 354 365 - dst_min 366 - dst_max 355 + dst_min 356 + dst_max 367 357 368 - src_min 369 - src_max 358 + src_min 359 + src_max 370 360 371 - dst_mac 372 - src_mac 361 + dst_mac 362 + src_mac 373 363 374 - clear_counters 364 + clear_counters 375 365 376 - src6 377 - dst6 378 - dst6_max 379 - dst6_min 366 + src6 367 + dst6 368 + dst6_max 369 + dst6_min 380 370 381 - flows 382 - flowlen 371 + flows 372 + flowlen 383 373 384 - rate 385 - ratep 374 + rate 375 + ratep 386 376 387 - xmit_mode <start_xmit|netif_receive> 377 + xmit_mode <start_xmit|netif_receive> 388 378 389 - vlan_cfi 390 - vlan_id 391 - vlan_p 379 + vlan_cfi 380 + vlan_id 381 + vlan_p 392 382 393 - svlan_cfi 394 - svlan_id 395 - svlan_p 383 + svlan_cfi 384 + svlan_id 385 + svlan_p 396 386 397 387 398 388 References: 399 - ftp://robur.slu.se/pub/Linux/net-development/pktgen-testing/ 400 - ftp://robur.slu.se/pub/Linux/net-development/pktgen-testing/examples/ 389 + 390 + - ftp://robur.slu.se/pub/Linux/net-development/pktgen-testing/ 391 + - tp://robur.slu.se/pub/Linux/net-development/pktgen-testing/examples/ 401 392 402 393 Paper from Linux-Kongress in Erlangen 2004. 403 - ftp://robur.slu.se/pub/Linux/net-development/pktgen-testing/pktgen_paper.pdf 394 + - ftp://robur.slu.se/pub/Linux/net-development/pktgen-testing/pktgen_paper.pdf 404 395 405 396 Thanks to: 397 + 406 398 Grant Grundler for testing on IA-64 and parisc, Harald Welte, Lennert Buytenhek 407 399 Stephen Hemminger, Andi Kleen, Dave Miller and many others. 408 400
+1 -1
net/Kconfig
··· 344 344 what was just said, you don't need it: say N. 345 345 346 346 Documentation on how to use the packet generator can be found 347 - at <file:Documentation/networking/pktgen.txt>. 347 + at <file:Documentation/networking/pktgen.rst>. 348 348 349 349 To compile this code as a module, choose M here: the 350 350 module will be called pktgen.
+1 -1
net/core/pktgen.c
··· 56 56 * Integrated to 2.5.x 021029 --Lucio Maciel (luciomaciel@zipmail.com.br) 57 57 * 58 58 * 021124 Finished major redesign and rewrite for new functionality. 59 - * See Documentation/networking/pktgen.txt for how to use this. 59 + * See Documentation/networking/pktgen.rst for how to use this. 60 60 * 61 61 * The new operation: 62 62 * For each CPU one thread/process is created at start. This process checks
+1 -1
samples/pktgen/README.rst
··· 3 3 This directory contains some pktgen sample and benchmark scripts, that 4 4 can easily be copied and adjusted for your own use-case. 5 5 6 - General doc is located in kernel: Documentation/networking/pktgen.txt 6 + General doc is located in kernel: Documentation/networking/pktgen.rst 7 7 8 8 Helper include files 9 9 ====================