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

selftests: tdc_batch.py: add options needed for concurrency tests

Extend tdc_batch.py with several optional CLI arguments that are used for
implementation of concurrency tests in following patches in this set:

- Add optional argument to specify range of filter handles used in batch
file [fitler_handle, filter_handle+number). This is needed for testing
filter deletion where it is necessary to know exact handles of configured
filters.

- Add optional argument to specify filter operation type (possible values
are ['add', 'del', 'replace']) instead of hardcoded "add" value. This
allows generation of batches for filter addition, deletion and
replacement.

- Add optional argument to allow user to change mac address prefix that is
used for all filters in batch. This is necessary to allow generating
multiple batches with unique flower classifier keys.

Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Vlad Buslov and committed by
David S. Miller
3b07270d a0dce875

+54 -4
+54 -4
tools/testing/selftests/tc-testing/tdc_batch.py
··· 13 13 parser.add_argument("file", help="batch file name") 14 14 parser.add_argument("-n", "--number", type=int, 15 15 help="how many lines in batch file") 16 + parser.add_argument( 17 + "-a", 18 + "--handle_start", 19 + type=int, 20 + default=1, 21 + help="start handle range from (default: 1)") 16 22 parser.add_argument("-o", "--skip_sw", 17 23 help="skip_sw (offload), by default skip_hw", 18 24 action="store_true") ··· 28 22 parser.add_argument("-p", "--prio", 29 23 help="all filters have different prio", 30 24 action="store_true") 25 + parser.add_argument( 26 + "-e", 27 + "--operation", 28 + choices=['add', 'del', 'replace'], 29 + default='add', 30 + help="operation to perform on filters" 31 + "(default: add filter)") 32 + parser.add_argument( 33 + "-m", 34 + "--mac_prefix", 35 + type=int, 36 + default=0, 37 + choices=range(0, 256), 38 + help="third byte of source MAC address of flower filter" 39 + "(default: 0)") 31 40 args = parser.parse_args() 32 41 33 42 device = args.device ··· 51 30 number = 1 52 31 if args.number: 53 32 number = args.number 33 + 34 + handle_start = args.handle_start 54 35 55 36 skip = "skip_hw" 56 37 if args.skip_sw: ··· 68 45 if number > 0x4000: 69 46 number = 0x4000 70 47 48 + mac_prefix = args.mac_prefix 49 + 50 + def format_add_filter(device, prio, handle, skip, src_mac, dst_mac, 51 + share_action): 52 + return ("filter add dev {} {} protocol ip parent ffff: handle {} " 53 + " flower {} src_mac {} dst_mac {} action drop {}".format( 54 + device, prio, handle, skip, src_mac, dst_mac, share_action)) 55 + 56 + 57 + def format_rep_filter(device, prio, handle, skip, src_mac, dst_mac, 58 + share_action): 59 + return ("filter replace dev {} {} protocol ip parent ffff: handle {} " 60 + " flower {} src_mac {} dst_mac {} action drop {}".format( 61 + device, prio, handle, skip, src_mac, dst_mac, share_action)) 62 + 63 + 64 + def format_del_filter(device, prio, handle, skip, src_mac, dst_mac, 65 + share_action): 66 + return ("filter del dev {} {} protocol ip parent ffff: handle {} " 67 + "flower".format(device, prio, handle)) 68 + 69 + 70 + formatter = format_add_filter 71 + if args.operation == "del": 72 + formatter = format_del_filter 73 + elif args.operation == "replace": 74 + formatter = format_rep_filter 75 + 71 76 index = 0 72 77 for i in range(0x100): 73 78 for j in range(0x100): 74 79 for k in range(0x100): 75 80 mac = ("{:02x}:{:02x}:{:02x}".format(i, j, k)) 76 - src_mac = "e4:11:00:" + mac 81 + src_mac = "e4:11:{:02x}:{}".format(mac_prefix, mac) 77 82 dst_mac = "e4:12:00:" + mac 78 - cmd = ("filter add dev {} {} protocol ip parent ffff: flower {} " 79 - "src_mac {} dst_mac {} action drop {}".format 80 - (device, prio, skip, src_mac, dst_mac, share_action)) 83 + cmd = formatter(device, prio, handle_start + index, skip, src_mac, 84 + dst_mac, share_action) 81 85 file.write("{}\n".format(cmd)) 82 86 index += 1 83 87 if index >= number: