2 # SPDX-License-Identifier: GPL-2.0
4 tdc_multibatch.py - a thin wrapper over tdc_batch.py to generate multiple batch
7 Copyright (C) 2019 Vlad Buslov <vladbu@mellanox.com>
13 parser
= argparse
.ArgumentParser(
14 description
='TC multiple batch file generator')
15 parser
.add_argument("device", help="device name")
16 parser
.add_argument("dir", help="where to put batch files")
18 "num_filters", type=int, help="how many lines per batch file")
19 parser
.add_argument("num_files", type=int, help="how many batch files")
22 choices
=['add', 'del', 'replace'],
23 help="operation to perform on filters")
28 help="prefix for generated batch file names")
31 "--duplicate_handles",
33 help="duplicate filter handle range in all files")
39 help="start handle range from (default: 1)")
45 choices
=range(0, 256),
46 help="add this value to third byte of source MAC address of flower filter"
48 args
= parser
.parse_args()
52 file_prefix
= args
.file_prefix
+ args
.operation
+ "_"
53 num_filters
= args
.num_filters
54 num_files
= args
.num_files
55 operation
= args
.operation
56 duplicate_handles
= args
.duplicate_handles
57 handle
= args
.handle_start
58 mac_prefix
= args
.mac_prefix
60 for i
in range(num_files
):
61 file = dir + '/' + file_prefix
+ str(i
)
62 os
.system("./tdc_batch.py -n {} -a {} -e {} -m {} {} {}".format(
63 num_filters
, handle
, operation
, i
+ mac_prefix
, device
, file))
64 if not duplicate_handles
: