summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYaroslav Brustinov <ybrustin@cisco.com>2016-03-17 01:18:15 +0200
committerYaroslav Brustinov <ybrustin@cisco.com>2016-03-17 01:18:15 +0200
commit110e3c7abb79e8ab22c4044cbdf01c262e597056 (patch)
tree334ff1bbd0899199f17d0aa72bb48c8663c64364
parent21ce94c228a58857bbb0a725ec80cb5250ae8833 (diff)
add HLT args table generation
-rw-r--r--draft_trex_stateless.asciidoc143
-rw-r--r--ws_main.py111
2 files changed, 81 insertions, 173 deletions
diff --git a/draft_trex_stateless.asciidoc b/draft_trex_stateless.asciidoc
index 35cf639d..6418f55f 100644
--- a/draft_trex_stateless.asciidoc
+++ b/draft_trex_stateless.asciidoc
@@ -3205,148 +3205,7 @@ Ether()/IP()/TCP()/"GET / HTTP/1.1\r\nHost: www.google.com\r\n\r\n"
==== HLT supported Arguments anchor:altapi-support[]
-
-[source,python]
-----
-
-traffic_config_kwargs = {
- 'mode': None, # ( create | modify | remove | reset )
- 'split_by_cores': 'split', # ( split | duplicate | single ) TRex extention: split = split traffic by cores, duplicate = duplicate traffic for all cores, single = run only with sinle core (not implemented yet)
- 'consistent_random': False, # TRex extention: False (default): random sequence will be different every run, True: random sequence will be same every run
- 'port_handle': None,
- 'port_handle2': None,
- # stream builder parameters
- 'transmit_mode': 'continuous', # ( continuous | multi_burst | single_burst )
- 'rate_pps': None,
- 'rate_bps': None,
- 'rate_percent': 10,
- 'stream_id': None,
- 'name': None,
- 'bidirectional': 0,
- 'direction': 0, # ( 0 | 1 ) TRex extention: 1 = exchange sources and destinations
- 'pkts_per_burst': 1,
- 'burst_loop_count': 1,
- 'inter_burst_gap': 12,
- 'length_mode': 'fixed', # ( auto | fixed | increment | decrement | random | imix )
- 'l3_imix1_size': 60,
- 'l3_imix1_ratio': 28,
- 'l3_imix2_size': 590,
- 'l3_imix2_ratio': 20,
- 'l3_imix3_size': 1514,
- 'l3_imix3_ratio': 4,
- 'l3_imix4_size': 9226,
- 'l3_imix4_ratio': 0,
- #L2
- 'frame_size': 64,
- 'frame_size_min': 64,
- 'frame_size_max': 64,
- 'frame_size_step': 1,
- 'l2_encap': 'ethernet_ii', # ( ethernet_ii | ethernet_ii_vlan )
- 'mac_src': '00:00:01:00:00:01',
- 'mac_dst': '00:00:00:00:00:00',
- 'mac_src2': '00:00:01:00:00:01',
- 'mac_dst2': '00:00:00:00:00:00',
- 'mac_src_mode': 'fixed', # ( fixed | increment | decrement | random )
- 'mac_src_step': 1,
- 'mac_src_count': 1,
- 'mac_dst_mode': 'fixed', # ( fixed | increment | decrement | random )
- 'mac_dst_step': 1,
- 'mac_dst_count': 1,
- 'mac_src2_mode': 'fixed', # ( fixed | increment | decrement | random )
- 'mac_src2_step': 1,
- 'mac_src2_count': 1,
- 'mac_dst2_mode': 'fixed', # ( fixed | increment | decrement | random )
- 'mac_dst2_step': 1,
- 'mac_dst2_count': 1,
- # vlan options below can have multiple values for nested Dot1Q headers
- 'vlan_user_priority': 1,
- 'vlan_priority_mode': 'fixed', # ( fixed | increment | decrement | random )
- 'vlan_priority_count': 1,
- 'vlan_priority_step': 1,
- 'vlan_id': 0,
- 'vlan_id_mode': 'fixed', # ( fixed | increment | decrement | random )
- 'vlan_id_count': 1,
- 'vlan_id_step': 1,
- 'vlan_cfi': 1,
- 'vlan_protocol_tag_id': None,
- #L3, general
- 'l3_protocol': None, # ( ipv4 | ipv6 )
- 'l3_length_min': 110,
- 'l3_length_max': 238,
- 'l3_length_step': 1,
- #L3, IPv4
- 'ip_precedence': 0,
- 'ip_tos_field': 0,
- 'ip_mbz': 0,
- 'ip_delay': 0,
- 'ip_throughput': 0,
- 'ip_reliability': 0,
- 'ip_cost': 0,
- 'ip_reserved': 0,
- 'ip_dscp': 0,
- 'ip_cu': 0,
- 'l3_length': None,
- 'ip_id': 0,
- 'ip_fragment_offset': 0,
- 'ip_ttl': 64,
- 'ip_checksum': None,
- 'ip_src_addr': '0.0.0.0',
- 'ip_dst_addr': '192.0.0.1',
- 'ip_src_mode': 'fixed', # ( fixed | increment | decrement | random )
- 'ip_src_step': 1, # ip or number
- 'ip_src_count': 1,
- 'ip_dst_mode': 'fixed', # ( fixed | increment | decrement | random )
- 'ip_dst_step': 1, # ip or number
- 'ip_dst_count': 1,
- #L3, IPv6
- 'ipv6_traffic_class': 0,
- 'ipv6_flow_label': 0,
- 'ipv6_length': None,
- 'ipv6_next_header': None,
- 'ipv6_hop_limit': 64,
- 'ipv6_src_addr': 'fe80:0:0:0:0:0:0:12',
- 'ipv6_dst_addr': 'fe80:0:0:0:0:0:0:22',
- 'ipv6_src_mode': 'fixed', # ( fixed | increment | decrement | random )
- 'ipv6_src_step': 1, # we are changing only 32 lowest bits; can be ipv6 or number
- 'ipv6_src_count': 1,
- 'ipv6_dst_mode': 'fixed', # ( fixed | increment | decrement | random )
- 'ipv6_dst_step': 1, # we are changing only 32 lowest bits; can be ipv6 or number
- 'ipv6_dst_count': 1,
- #L4, TCP
- 'l4_protocol': None, # ( tcp | udp )
- 'tcp_src_port': 1024,
- 'tcp_dst_port': 80,
- 'tcp_seq_num': 1,
- 'tcp_ack_num': 1,
- 'tcp_data_offset': 5,
- 'tcp_fin_flag': 0,
- 'tcp_syn_flag': 0,
- 'tcp_rst_flag': 0,
- 'tcp_psh_flag': 0,
- 'tcp_ack_flag': 0,
- 'tcp_urg_flag': 0,
- 'tcp_window': 4069,
- 'tcp_checksum': None,
- 'tcp_urgent_ptr': 0,
- 'tcp_src_port_mode': 'increment', # ( increment | decrement | random )
- 'tcp_src_port_step': 1,
- 'tcp_src_port_count': 1,
- 'tcp_dst_port_mode': 'increment', # ( increment | decrement | random )
- 'tcp_dst_port_step': 1,
- 'tcp_dst_port_count': 1,
- # L4, UDP
- 'udp_src_port': 1024,
- 'udp_dst_port': 80,
- 'udp_length': None,
- 'udp_dst_port_mode': 'increment', # ( increment | decrement | random )
- 'udp_src_port_step': 1,
- 'udp_src_port_count': 1,
- 'udp_src_port_mode': 'increment', # ( increment | decrement | random )
- 'udp_dst_port_step': 1,
- 'udp_dst_port_count': 1,
-}
-----
-
+include::build/hlt_args.asciidoc[]
==== FD.IO open source project using TRex
diff --git a/ws_main.py b/ws_main.py
index 90716b4a..8287316f 100644
--- a/ws_main.py
+++ b/ws_main.py
@@ -120,50 +120,92 @@ def do_visio(bld):
for x in bld.path.ant_glob('visio\\*.vsd'):
tg = bld(rule='${VIS} -i ${SRC} -o ${TGT} ', source=x, target=x.change_ext('.png'))
-def build_cp_docs (task):
- out_dir = task.outputs[0].abspath()
- export_path = os.path.join(os.getcwd(), 'build', 'cp_docs')
+def get_trex_core_git():
trex_core_git_path = os.path.join(os.getcwd(), os.pardir, "trex-core")
if not os.path.isdir(trex_core_git_path):
trex_core_git_path = os.getenv('TREX_CORE_GIT', None)
- if trex_core_git_path: # there exists a default directory or the desired ENV variable.
- trex_core_docs_path = os.path.abspath(os.path.join(trex_core_git_path, 'scripts', 'automation', 'trex_control_plane', 'doc'))
- build_doc_cmd = shlex.split("/usr/local/bin/sphinx-build -W -b {bld} {src} {dst}".format(
- bld= "html",
- src= ".",
- dst= out_dir)
- )
- return subprocess.call(build_doc_cmd, cwd = trex_core_docs_path)
- return (1)
+ return trex_core_git_path
+
+def parse_hlt_args(task):
+ trex_core_git_path = get_trex_core_git()
+ if not trex_core_git_path:
+ return 1
+ hltapi_path = os.path.abspath(os.path.join(trex_core_git_path, 'scripts', 'automation', 'trex_control_plane', 'stl', 'trex_stl_lib', 'trex_stl_hltapi.py'))
+ header = ['[options="header",cols="<.^1,^.^1,9<.^e"]', '|=================', '^| Argument | Default ^| Comment']
+ footer = ['|=================\n']
+ hlt_asciidoc = []
+ category_regexp = '^(\S+)_kwargs = {$'
+ comment_line_regexp = '^\s*#\s*(.+)$'
+ arg_line_regexp = "^\s*'([^']+)':\s*'?([^,']+)'?,\s*#?\s*(.+)?$"
+ if not os.path.exists(hltapi_path):
+ raise Exception('Could not find hltapi file: %s' % hltapi_path)
+ with open(hltapi_path) as f:
+ in_args = False
+ for line in f.read().splitlines():
+ if not in_args:
+ if line.startswith('import'):
+ break
+ category_line = re.match(category_regexp, line)
+ if category_line:
+ hlt_asciidoc.append('\n===== %s\n' % category_line.group(1))
+ hlt_asciidoc += header
+ in_args = True
+ continue
+ comment_line = re.match(comment_line_regexp, line)
+ if comment_line:
+ hlt_asciidoc.append('3+^.^s| %s' % comment_line.group(1).replace('|', '\|'))
+ continue
+ arg_line = re.match(arg_line_regexp, line)
+ if arg_line:
+ arg, default, comment = arg_line.groups()
+ hlt_asciidoc.append('| %s | %s | %s' % (arg, default, comment.replace('|', '\|') if comment else ''))
+ continue
+ if line == '}':
+ hlt_asciidoc += footer
+ in_args = False
+ if not len(hlt_asciidoc):
+ raise Exception('Parsing of hltapi args failed')
+ with open('build/hlt_args.asciidoc', 'w') as f:
+ f.write('\n'.join(hlt_asciidoc))
+ return 0
+
+def build_cp_docs (task):
+ out_dir = task.outputs[0].abspath()
+ export_path = os.path.join(os.getcwd(), 'build', 'cp_docs')
+ trex_core_git_path = get_trex_core_git()
+ if not trex_core_git_path: # there exists a default directory or the desired ENV variable.
+ return 1
+ trex_core_docs_path = os.path.abspath(os.path.join(trex_core_git_path, 'scripts', 'automation', 'trex_control_plane', 'doc'))
+ build_doc_cmd = shlex.split("/usr/local/bin/sphinx-build -W -b {bld} {src} {dst}".format(
+ bld= "html",
+ src= ".",
+ dst= out_dir)
+ )
+ return subprocess.call(build_doc_cmd, cwd = trex_core_docs_path)
def build_stl_cp_docs (task):
out_dir = task.outputs[0].abspath()
export_path = os.path.join(os.getcwd(), 'build', 'cp_stl_docs')
- trex_core_git_path = os.path.join(os.getcwd(), os.pardir, "trex-core")
- if not os.path.isdir(trex_core_git_path):
- trex_core_git_path = os.getenv('TREX_CORE_GIT', None)
- if trex_core_git_path: # there exists a default directory or the desired ENV variable.
- trex_core_docs_path = os.path.abspath(os.path.join(trex_core_git_path, 'scripts', 'automation', 'trex_control_plane', 'doc_stl'))
- build_doc_cmd = shlex.split("/usr/local/bin/sphinx-build -W -b {bld} {src} {dst}".format(
- bld= "html",
- src= ".",
- dst= out_dir)
- )
- return subprocess.call(build_doc_cmd, cwd = trex_core_docs_path)
- return (1)
+ trex_core_git_path = get_trex_core_git()
+ if not trex_core_git_path: # there exists a default directory or the desired ENV variable.
+ return 1
+ trex_core_docs_path = os.path.abspath(os.path.join(trex_core_git_path, 'scripts', 'automation', 'trex_control_plane', 'doc_stl'))
+ build_doc_cmd = shlex.split("/usr/local/bin/sphinx-build -W -b {bld} {src} {dst}".format(
+ bld= "html",
+ src= ".",
+ dst= out_dir)
+ )
+ return subprocess.call(build_doc_cmd, cwd = trex_core_docs_path)
def build_cp(bld,dir,root,callback):
export_path = os.path.join(os.getcwd(), 'build', dir)
- trex_core_git_path = os.path.join(os.getcwd(), os.pardir, "trex-core")
- if not os.path.isdir(trex_core_git_path):
- trex_core_git_path = os.getenv('TREX_CORE_GIT', None)
- if trex_core_git_path: # there exists a default directory or the desired ENV variable.
- trex_core_docs_path = os.path.join(trex_core_git_path, 'scripts', 'automation', 'trex_control_plane', root, 'index.rst')
- bld(rule=callback,target = dir)
- else:
+ trex_core_git_path = get_trex_core_git()
+ if not trex_core_git_path: # there exists a default directory or the desired ENV variable.
raise NameError("Environment variable 'TREX_CORE_GIT' is not defined.")
+ trex_core_docs_path = os.path.join(trex_core_git_path, 'scripts', 'automation', 'trex_control_plane', root, 'index.rst')
+ bld(rule=callback,target = dir)
@@ -191,8 +233,15 @@ def build(bld):
bld(rule=my_copy, target='my_chart.js')
+ build_cp(bld,'hlt_args.asciidoc','stl/trex_stl_lib', parse_hlt_args)
+
bld.add_group() # separator, the documents may require any of the pictures from above
+ if os.path.exists('build/hlt_args.asciidoc'):
+ bld.add_manual_dependency(
+ bld.path.find_node('draft_trex_stateless.asciidoc'),
+ 'build/hlt_args.asciidoc')
+
bld(rule='${ASCIIDOC} -b deckjs -o ${TGT} ${SRC[0].abspath()}',
source='trex_config.asciidoc ', target='trex_config_guide.html', scan=ascii_doc_scan)