From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 4D78DA0679 for ; Sun, 28 Apr 2019 04:45:39 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C119B1B525; Sun, 28 Apr 2019 04:45:37 +0200 (CEST) Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id A9A7F1B49B for ; Sun, 28 Apr 2019 04:45:35 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Apr 2019 19:45:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,403,1549958400"; d="scan'208";a="146438588" Received: from itecstvdts01.sh.intel.com ([10.67.111.114]) by fmsmga007.fm.intel.com with ESMTP; 27 Apr 2019 19:45:34 -0700 From: yufengmx To: dts@dpdk.org Cc: yufengmx Date: Sun, 28 Apr 2019 10:49:03 +0800 Message-Id: <1556419751-41723-7-git-send-email-yufengx.mo@intel.com> X-Mailer: git-send-email 1.9.3 In-Reply-To: <1556419751-41723-1-git-send-email-yufengx.mo@intel.com> References: <1556419751-41723-1-git-send-email-yufengx.mo@intel.com> Subject: [dts] [next][PATCH V1 6/14] framework/pktgen: packet generator configure file parse X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: test suite reviews and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dts-bounces@dpdk.org Sender: "dts" class packet generator configure file parse class Class PktgenConf is used to parse config file pktgen.cfg. Ixia and trex configuration content can be set in different section. Section name is case insensitive. Signed-off-by: yufengmx --- framework/config.py | 107 +++++++++++++++++++++++++++++++++++----------------- 1 file changed, 72 insertions(+), 35 deletions(-) diff --git a/framework/config.py b/framework/config.py index fb23c6e..abb1469 100644 --- a/framework/config.py +++ b/framework/config.py @@ -1,6 +1,6 @@ # BSD LICENSE # -# Copyright(c) 2010-2014 Intel Corporation. All rights reserved. +# Copyright(c) 2010-2019 Intel Corporation. All rights reserved. # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -35,8 +35,9 @@ Generic port and crbs configuration file load function import os import re import ConfigParser # config parse module -import argparse # prase arguments module -from settings import IXIA, CONFIG_ROOT_PATH, SUITE_SECTION_NAME +import argparse # parse arguments module +from settings import (IXIA, PKTGEN, PKTGEN_DPDK, PKTGEN_TREX, PKTGEN_IXIA, + CONFIG_ROOT_PATH, SUITE_SECTION_NAME) from settings import load_global_setting, DTS_CFG_FOLDER from exception import ConfigParseException, VirtConfigParseException, PortConfigParseException @@ -89,6 +90,7 @@ class UserConf(): paramDict[key] = value return paramDict + class GlobalConf(UserConf): def __init__(self): self.global_cfg = {} @@ -115,6 +117,7 @@ class GlobalConf(UserConf): return global_cfg + class SuiteConf(UserConf): def __init__(self, suite_name=""): self.suite_cfg = GlobalConf().load_global_config() @@ -262,6 +265,7 @@ class CrbsConf(UserConf): DEF_CRB = {'IP': '', 'board': 'default', 'user': '', 'pass': '', 'tester IP': '', 'tester pass': '', IXIA: None, 'memory channels': 4, + PKTGEN: None, 'bypass core0': True} def __init__(self, crbs_conf=CRBCONF): @@ -305,6 +309,8 @@ class CrbsConf(UserConf): if value.lower() == 'none': value = None crb[IXIA] = value + elif key == 'pktgen_group': + crb[PKTGEN] = value.lower() elif key == 'channels': crb['memory channels'] = int(value) elif key == 'bypass_core0': @@ -381,9 +387,9 @@ class IxiaConf(UserConf): class PktgenConf(UserConf): - def __init__(self, pktgen_type='dpdk', pktgen_conf=PKTGENCONF): + def __init__(self, pktgen_type='ixia', pktgen_conf=PKTGENCONF): self.config_file = pktgen_conf - self.pktgen_type = pktgen_type + self.pktgen_type = pktgen_type.lower() self.pktgen_cfg = {} try: self.pktgen_conf = UserConf(self.config_file) @@ -391,45 +397,76 @@ class PktgenConf(UserConf): self.pktgen_conf = None raise ConfigParseException + def load_pktgen_ixia_config(self, section): + port_reg = r'card=(\d+),port=(\d+)' + pktgen_confs = self.pktgen_conf.load_section(section) + if not pktgen_confs: + return + # convert file configuration to dts ixiacfg + ixia_group = {} + for conf in pktgen_confs: + key, value = conf + if key == 'ixia_version': + ixia_group['Version'] = value + elif key == 'ixia_ip': + ixia_group['IP'] = value + elif key == 'ixia_ports': + ports = self.pktgen_conf.load_config(value) + ixia_ports = [] + for port in ports: + m = re.match(port_reg, port) + if m: + ixia_port = {} + ixia_port["card"] = int(m.group(1)) + ixia_port["port"] = int(m.group(2)) + ixia_ports.append(ixia_port) + ixia_group['Ports'] = ixia_ports + elif key == 'ixia_enable_rsfec': + ixia_group['enable_rsfec'] = value + + if 'Version' not in ixia_group: + print 'ixia configuration file request ixia_version option!!!' + return + if 'IP' not in ixia_group: + print 'ixia configuration file request ixia_ip option!!!' + return + if 'Ports' not in ixia_group: + print 'ixia configuration file request ixia_ports option!!!' + return + + self.pktgen_cfg[section.lower()] = ixia_group + def load_pktgen_config(self): sections = self.pktgen_conf.get_sections() if not sections: return self.pktgen_cfg for section in sections: - if self.pktgen_type=='dpdk': - if section == 'PKTGEN DPDK': - pktgen_confs = self.pktgen_conf.load_section(section) - if not pktgen_confs: - continue - - # covert file configuration to dts pktgen cfg - for conf in pktgen_confs: - key, value = conf - self.pktgen_cfg[key] = value - elif self.pktgen_type=='trex': - if section == 'TREX': - pktgen_confs = self.pktgen_conf.load_section(section) - if not pktgen_confs: - continue - - # covert file configuration to dts pktgen cfg - for conf in pktgen_confs: - key, value = conf - self.pktgen_cfg[key] = value - elif self.pktgen_type=='ixia': - if section == 'IXIA': - pktgen_confs = self.pktgen_conf.load_section(section) - if not pktgen_confs: - continue - - # covert file configuration to dts pktgen cfg - for conf in pktgen_confs: - key, value = conf - self.pktgen_cfg[key] = value + if self.pktgen_type == PKTGEN_DPDK and section.lower() == PKTGEN_DPDK: + pktgen_confs = self.pktgen_conf.load_section(section) + if not pktgen_confs: + continue + + # covert file configuration to dts pktgen cfg + for conf in pktgen_confs: + key, value = conf + self.pktgen_cfg[key] = value + elif self.pktgen_type == PKTGEN_TREX and section.lower() == PKTGEN_TREX: + pktgen_confs = self.pktgen_conf.load_section(section) + if not pktgen_confs: + continue + + # covert file configuration to dts pktgen cfg + for conf in pktgen_confs: + key, value = conf + self.pktgen_cfg[key] = value + elif self.pktgen_type == PKTGEN_IXIA and section.lower() == PKTGEN_IXIA: + # covert file configuration to dts pktgen cfg + self.load_pktgen_ixia_config(section) return self.pktgen_cfg + if __name__ == '__main__': parser = argparse.ArgumentParser( description="Load DTS configuration files") -- 1.9.3