4 tdc_batch.py - a script to generate TC batch file
6 Copyright (C) 2017 Chris Mi <chrism@mellanox.com>
11 parser
= argparse
.ArgumentParser(description
='TC batch file generator')
12 parser
.add_argument("device", help="device name")
13 parser
.add_argument("file", help="batch file name")
14 parser
.add_argument("-n", "--number", type=int,
15 help="how many lines in batch file")
16 parser
.add_argument("-o", "--skip_sw",
17 help="skip_sw (offload), by default skip_hw",
19 parser
.add_argument("-s", "--share_action",
20 help="all filters share the same action",
22 parser
.add_argument("-p", "--prio",
23 help="all filters have different prio",
25 args
= parser
.parse_args()
28 file = open(args
.file, 'w')
40 share_action
= "index 1"
49 for i
in range(0x100):
50 for j
in range(0x100):
51 for k
in range(0x100):
52 mac
= ("%02x:%02x:%02x" % (i
, j
, k
))
53 src_mac
= "e4:11:00:" + mac
54 dst_mac
= "e4:12:00:" + mac
55 cmd
= ("filter add dev %s %s protocol ip parent ffff: flower %s "
56 "src_mac %s dst_mac %s action drop %s" %
57 (device
, prio
, skip
, src_mac
, dst_mac
, share_action
))
58 file.write("%s\n" % cmd
)