# if empty defaults to the one specified in generator_profile.cores
cores:
+# Add cache size in packet generation for TRex field engine (FE).
+# More information for TRex performance:
+# https://trex-tgn.cisco.com/trex/doc/trex_stateless.html#_tutorial_field_engine_significantly_improve_performance
+# If cache_size = 0 (or empty): no cache will be used by TRex (default)
+# If cache_size < 0: cache_size will be set to flow count value
+cache_size:
+# The cache size is actually limited by the number of 64B mbufs configured in the trex platform configuration (see Trex manual 6.2.2. Memory section configuration)
+# Trex will use 1 x 64B mbuf per pre-built cached packet, assuming 1 pre-built cached packet per flow, it means for very large number of flows, the number of configured mbuf_64 will need to be set accordingly.
+mbuf_64:
+
# mbuffer ratio to use for TRex (see TRex documentation for more details)
mbuf_factor: 0.2
try:
# recalc the running config based on the base config and options for this run
self._update_config(opts)
-
+ if self.config.cache_size < 0:
+ self.config.cache_size = self.config.flow_count
# check that an empty openrc file (no OpenStack) is only allowed
# with EXT chain
if not self.config.openrc_file and self.config.service_chain != ChainType.EXT:
metavar='<vlan>',
help='Port to port or port to switch to port L2 loopback with VLAN id')
+ parser.add_argument('--cache-size', dest='cache_size',
+ action='store',
+ default='0',
+ help='Specify the FE cache size (default: 0, flow-count if < 0)')
+
opts, unknown_opts = parser.parse_known_args()
return opts, unknown_opts
else:
self.cores = gen_config.get('cores', 1)
self.mbuf_factor = config.mbuf_factor
+ self.mbuf_64 = config.mbuf_64
self.hdrh = not config.disable_hdrh
if gen_config.intf_speed:
# interface speed is overriden from config
self.interfaces = gen_config.interfaces
if self.interfaces[0].port != 0 or self.interfaces[1].port != 1:
raise TrafficClientException('Invalid port order/id in generator_profile.interfaces')
- if hasattr(gen_config, 'platform'):
- self.platform = gen_config.platform
self.service_chain = config.service_chain
self.service_chain_count = config.service_chain_count
self.flow_count = config.flow_count
l4_type=CTRexVmInsFixHwCs.L4_TYPE_UDP))
pad = max(0, frame_size - len(pkt_base)) * 'x'
- return STLPktBuilder(pkt=pkt_base / pad, vm=STLScVmRaw(vm_param))
+ return STLPktBuilder(pkt=pkt_base / pad,
+ vm=STLScVmRaw(vm_param, cache_size=int(self.config.cache_size)))
def generate_streams(self, port, chain_id, stream_cfg, l2frame, latency=True,
e2e=False):
prefix=generator_config.name,
limit_memory=generator_config.limit_memory,
ifs=ifs)
+ if hasattr(generator_config, 'mbuf_64') and generator_config.mbuf_64:
+ result += """
+ memory :
+ mbuf_64 : {mbuf_64}""".format(mbuf_64=generator_config.mbuf_64)
+
if self.__check_platform_config(generator_config):
try:
platform = """
platform :
master_thread_id : {master_thread_id}
latency_thread_id : {latency_thread_id}
- dual_if:""".format(master_thread_id=generator_config.platform.master_thread_id,
- latency_thread_id=generator_config.platform.latency_thread_id)
+ dual_if:""".format(master_thread_id=generator_config.gen_config.platform.
+ master_thread_id,
+ latency_thread_id=generator_config.gen_config.platform.
+ latency_thread_id)
result += platform
- for core in generator_config.platform.dual_if:
+ for core in generator_config.gen_config.platform.dual_if:
threads = ""
try:
threads = ",".join([repr(thread) for thread in core.threads])
return result
def __check_platform_config(self, generator_config):
- return hasattr(generator_config, 'platform') \
- and hasattr(generator_config.platform, "master_thread_id") \
- and generator_config.platform.master_thread_id is not None \
- and hasattr(generator_config.platform, "latency_thread_id") \
- and generator_config.platform.latency_thread_id is not None
+ return hasattr(generator_config.gen_config, 'platform') \
+ and hasattr(generator_config.gen_config.platform, "master_thread_id") \
+ and generator_config.gen_config.platform.master_thread_id is not None \
+ and hasattr(generator_config.gen_config.platform, "latency_thread_id") \
+ and generator_config.gen_config.platform.latency_thread_id is not None
def check_config_updated(self, generator_config):
existing_config = self.__load_config(filename='/etc/trex_cfg.yaml')
'l2_loopback': False,
'cores': None,
'mbuf_factor': None,
- 'disable_hdrh': None
+ 'disable_hdrh': None,
+ 'mbuf_64': None
})