From patchwork Wed Mar 8 11:31:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tadhg Kearney X-Patchwork-Id: 124853 Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id D92E441E1F; Wed, 8 Mar 2023 12:31:20 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B2D6D40FAE; Wed, 8 Mar 2023 12:31:20 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id 22ABB40ED6 for ; Wed, 8 Mar 2023 12:31:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1678275079; x=1709811079; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=zgupdfo67RAlgKVvIMCUWQsP5CxwtnMQXgv761mi8+U=; b=SMgnbL8Jc7+B3+yZGe3lAid2G8FeCdIIYa2ItxP3mU3FtF9yepQcbGEz KN+GQIPJt1XBoBCzspqjWcYLgzL5fcEvCOOaDfnk2t7L3QCNOXgkgQaU9 ZFKO/PK/rTixH8qJQa0rKA3AXkgKtyaxvdOdlaLjk569Z40DiKjrK3tyK VoQqyEON31IREyKMK3UvklX+rrzgBKaT7eg++Q0KJSTBebPJSgExL0vUn +K+O+aoNViTkst6DLRpUp0r8fKsZZVN+S/8LDtNWwMqozdew11iIwTFA0 BNEi2ibAlRngzNnzpE6W4jLuvcFOZHqF+JoyzGOXcD3Vv2twhshiKQJQJ g==; X-IronPort-AV: E=McAfee;i="6500,9779,10642"; a="363765824" X-IronPort-AV: E=Sophos;i="5.98,243,1673942400"; d="scan'208";a="363765824" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Mar 2023 03:31:17 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10642"; a="626884915" X-IronPort-AV: E=Sophos;i="5.98,243,1673942400"; d="scan'208";a="626884915" Received: from silpixa00401183.ir.intel.com ([10.55.128.41]) by orsmga003.jf.intel.com with ESMTP; 08 Mar 2023 03:31:15 -0800 From: Tadhg Kearney To: dts@dpdk.org Cc: reshma.pattan@intel.com, Tadhg Kearney Subject: [dts][PATCH V1] tests/power_empty_poll: remove power_empty_poll test Date: Wed, 8 Mar 2023 11:31:04 +0000 Message-Id: <20230308113104.10562-1-tadhg.kearney@intel.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-BeenThere: dts@dpdk.org X-Mailman-Version: 2.1.29 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 The experimental empty poll API has been removed from the power management library in DPDK 22.03. Removing test that tested it's functionality. Signed-off-by: Tadhg Kearney --- tests/TestSuite_power_empty_poll.py | 437 ---------------------------- 1 file changed, 437 deletions(-) delete mode 100644 tests/TestSuite_power_empty_poll.py diff --git a/tests/TestSuite_power_empty_poll.py b/tests/TestSuite_power_empty_poll.py deleted file mode 100644 index 6db9d054..00000000 --- a/tests/TestSuite_power_empty_poll.py +++ /dev/null @@ -1,437 +0,0 @@ -# SPDX-License-Identifier: BSD-3-Clause -# Copyright(c) 2010-2020 Intel Corporation -# - -""" -DPDK Test suite. -power empty poll test suite. -""" -import os -import time -import traceback -from copy import deepcopy -from pprint import pformat - -from framework.exception import VerifyFailure -from framework.packet import Packet -from framework.pktgen import TRANSMIT_CONT -from framework.settings import HEADER_SIZE, PKTGEN_TREX -from framework.test_case import TestCase -from framework.utils import create_mask as dts_create_mask - - -class TestPowerEmptyPoll(TestCase): - TRAIN = "train" - NOTRAIN = "no-train" - MED = "med_threshold" - HIGH = "high_threshold" - - @property - def target_dir(self): - # get absolute directory of target source code - target_dir = ( - "/root" + self.dut.base_dir[1:] - if self.dut.base_dir.startswith("~") - else self.dut.base_dir - ) - return target_dir - - @property - def is_use_trex(self): - return ( - hasattr(self.tester, "is_pktgen") - and self.tester.is_pktgen - and self.tester.pktgen.pktgen_type == PKTGEN_TREX - ) - - def d_con(self, cmd): - _cmd = [cmd, "# ", 10] if isinstance(cmd, str) else cmd - return self.dut.send_expect(*_cmd) - - def d_a_con(self, cmd): - _cmd = [cmd, "# ", 10] if isinstance(cmd, str) else cmd - return self.dut.alt_session.send_expect(*_cmd) - - def prepare_binary(self, name): - example_dir = "examples/" + name - out = self.dut.build_dpdk_apps("./" + example_dir) - return os.path.join(self.target_dir, self.dut.apps_name[os.path.basename(name)]) - - def get_cores_mask(self, cores_list): - return dts_create_mask(cores_list) - - def add_stream_to_pktgen(self, txport, rxport, send_pkts, option): - stream_ids = [] - cnt = 0 - for pkt in send_pkts: - _option = deepcopy(option) - _option["pcap"] = pkt - stream_id = self.tester.pktgen.add_stream(txport, rxport, pkt) - self.tester.pktgen.config_stream(stream_id, _option) - stream_ids.append(stream_id) - # rxport -> txport - stream_id = self.tester.pktgen.add_stream(rxport, txport, pkt) - self.tester.pktgen.config_stream(stream_id, _option) - stream_ids.append(stream_id) - cnt += 1 - return stream_ids - - def run_traffic(self, option): - txport = self.tester.get_local_port(self.dut_ports[0]) - rxport = self.tester.get_local_port(self.dut_ports[1]) - stm_type = option.get("stm_types") - rate_percent = option.get("rate", float(100)) - duration = option.get("duration", 10) - send_pkts = self.set_stream(stm_type) - # clear streams before add new streams - self.tester.pktgen.clear_streams() - # set stream into pktgen - s_option = { - "stream_config": { - "txmode": {}, - "transmit_mode": TRANSMIT_CONT, - "rate": rate_percent, - } - } - stream_ids = self.add_stream_to_pktgen(txport, rxport, send_pkts, s_option) - # run traffic options - traffic_opt = option.get("traffic_opt") - # run pktgen(ixia/trex) traffic - result = self.tester.pktgen.measure(stream_ids, traffic_opt) - - return result - - def get_pkt_len(self, pkt_type, frame_size): - headers_size = sum([HEADER_SIZE[x] for x in ["eth", "ip", pkt_type]]) - pktlen = frame_size - headers_size - return pktlen - - def set_stream(self, stm_names=None): - # set streams for traffic - pkt_configs = { - "UDP_1": { - "type": "UDP", - "pkt_layers": { - "ipv4": {"dst": "1.1.1.1"}, - "raw": { - "payload": ["58"] - * self.get_pkt_len("udp", frame_size=self.frame_size) - }, - }, - }, - } - # create packet instance for send - streams = [] - for stm_name in stm_names: - if stm_name not in list(pkt_configs.keys()): - continue - values = pkt_configs[stm_name] - pkt_type = values.get("type") - pkt_layers = values.get("pkt_layers") - pkt = Packet(pkt_type=pkt_type) - for layer in list(pkt_layers.keys()): - pkt.config_layer(layer, pkt_layers[layer]) - streams.append(pkt.pktgen.pkt) - - return streams - - @property - def empty_poll_options(self): - table = { - "train": "1,0,0", - "no-train": "0,350000,500000", - } - return table - - def init_l3fwd_power(self): - self.l3fwd_power = self.prepare_binary("l3fwd-power") - - def start_l3fwd_power(self, core): - train_mode = self.empty_poll_options.get(self.train_mode) - option = ( - "-v " - "-c {core_mask} " - "-n {mem_channel} " - "-- " - "-p 0x3 " - "-P " - '--config="(0,0,{core}),(1,0,{core})" ' - "-l 10 -m 6 -h 1 " - '--empty-poll="{empty-poll}" ' - ).format( - **{ - "core": core[-1], - "core_mask": self.get_cores_mask(core), - "mem_channel": self.dut.get_memory_channels(), - "empty-poll": train_mode, - } - ) - prompts = { - self.NOTRAIN: "POWER: Bring up the Timer", - self.TRAIN: "POWER: Training is Complete", - } - prompt = prompts.get(self.train_mode) - cmd = [" ".join([self.l3fwd_power, option]), prompt, 120] - self.d_con(cmd) - self.is_l3fwd_on = True - - def close_l3fwd_power(self): - if not self.is_l3fwd_on: - return - cmd = "^C" - self.d_con(cmd) - - def is_hyper_threading(self): - cpu_index = list(self.cpu_info.keys())[-1] - core_num = self.cpu_info[cpu_index].get("core") - return (cpu_index + 1) / 2 == (core_num + 1) - - def is_support_pbf(self): - # check if cpu support bpf feature - cpu_attr = r"/sys/devices/system/cpu/cpu0/cpufreq/base_frequency" - cmd = "ls {0}".format(cpu_attr) - self.d_a_con(cmd) - cmd = "echo $?" - output = self.d_a_con(cmd) - ret = True if output == "0" else False - return ret - - def query_cpu_freq(self): - cmd = ( - "cat /sys/devices/system/cpu/cpu{0}/cpufreq/scaling_min_freq;" - "cat /sys/devices/system/cpu/cpu{0}/cpufreq/scaling_max_freq;" - ).format(self.check_core[1]) - output = self.d_a_con(cmd) - if not output: - self.scaling_min_freq, self.scaling_max_freq = 0, 0 - else: - values = [int(item) for item in output.splitlines()] - self.scaling_min_freq, self.scaling_max_freq = values - - def get_sys_power_driver(self): - drv_file = "/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver" - output = self.d_a_con("cat " + drv_file) - if not output: - msg = "unknown power driver" - self.verify(False, msg) - drv_name = output.splitlines()[0].strip() - return drv_name - - def get_all_cpu_attrs(self): - """get all cpus' base_frequency value""" - key_values = ["base_frequency", "cpuinfo_max_freq", "cpuinfo_min_freq"] - freq = "/sys/devices/system/cpu/cpu{0}/cpufreq/{1}".format - # use dut alt session to get dut platform cpu base frequency attribute - cpu_topos = self.dut.get_all_cores() - cpu_info = {} - for cpu_topo in cpu_topos: - cpu_id = int(cpu_topo["thread"]) - cpu_info[cpu_id] = {} - cpu_info[cpu_id]["socket"] = cpu_topo["socket"] - cpu_info[cpu_id]["core"] = cpu_topo["core"] - - for key_value in key_values: - cmds = [] - for cpu_id in sorted(cpu_info.keys()): - cmds.append("cat {0}".format(freq(cpu_id, key_value))) - output = self.d_a_con(";".join(cmds)) - freqs = ( - [int(item) for item in output.splitlines()] - if key_value != "scaling_available_frequencies" - else [item for item in output.splitlines()] - ) - for index, cpu_id in enumerate(sorted(cpu_info.keys())): - if key_value == "scaling_available_frequencies": - cpu_info[cpu_id][key_value] = [ - int(item) for item in sorted(freqs[index].split()) - ] - else: - cpu_info[cpu_id][key_value] = freqs[index] - - # get high priority core and normal core - base_freqs_info = {} - for core_index, value in list(cpu_info.items()): - base_frequency = value.get("base_frequency") - base_freqs_info.setdefault(base_frequency, []).append(core_index) - base_freqs = list(base_freqs_info.keys()) - # cpu should have high priority core and normal core - # high priority core frequency is higher than normal core frequency - if len(base_freqs) <= 1 or not all( - [len(value) for value in list(base_freqs_info.values())] - ): - msg = "current cpu has no high priority core" - raise VerifyFailure(msg) - self.logger.debug(pformat(base_freqs_info)) - - return cpu_info, base_freqs_info - - def get_normal_cores_index(self, number): - normal_freq = min(self.base_freqs_info.keys()) - cores_index = ( - self.base_freqs_info[normal_freq][1:number] - if self.base_freqs_info[normal_freq][0] == 0 - else self.base_freqs_info[normal_freq][:number] - ) - return cores_index - - def get_no_turbo_max(self, core): - cmd = "rdmsr -p {} 0x0CE -f 15:8 -d".format(core) - output = self.d_a_con(cmd) - freq = output.strip() + "00000" - return int(freq) - - def check_core_freq_in_traffic(self, core_index, mode): - """ - check the cores frequency when running traffic - highest frequency[no_turbo_max]: cur_min=cur_max=no_turbo_max - """ - freq = self.get_no_turbo_max(core_index) - expected_freq = freq if mode == self.HIGH else (freq - 500000) - msg = "max freq is failed to get." - self.verify(self.scaling_max_freq, msg) - msg = "max freq is not the same as highest frequency <{0}>" - self.verify(expected_freq == self.scaling_max_freq, msg.format(expected_freq)) - msg = "min freq is failed to get." - self.verify(self.scaling_min_freq, msg) - msg = "min freq is not the same as highest frequency <{0}>" - self.verify(expected_freq == self.scaling_min_freq, msg.format(expected_freq)) - msg = "core <{0}>: max freq/min_freq/expected freq<{1}> are the same" - self.logger.info(msg.format(core_index, expected_freq)) - - def check_no_train(self): - output = self.dut.get_session_output(timeout=2) - msg = "training steps should not be executed" - self.verify("POWER: Training is Complete" not in output, msg) - - @property - def train_mode_check_item(self): - # Injected Rate: - # 10G -> 0.1G -> 10G -> 0.1G -> 10G -> 0.1G - check_item = [ - [100, self.HIGH], - [1, self.MED], - [100, self.HIGH], - [1, self.MED], - [100, self.HIGH], - [1, self.MED], - ] - return check_item - - def verify_train_mode(self): - except_content = None - # begin run vm power policy testing - try: - self.start_l3fwd_power(self.check_core) - if self.train_mode == self.NOTRAIN: - self.check_no_train() - else: - time.sleep(10) # wait some time for stable training - msg = "{0} begin test mode <{1}> with traffic rate percent {2}%" - for rate, mode in self.train_mode_check_item: - self.logger.info(msg.format(self.train_mode, mode, rate)) - duration = 20 if self.is_use_trex else 10 - info = { - "traffic_opt": { - "method": "throughput", - "interval": duration - 2, - "duration": duration, - "callback": self.query_cpu_freq, - }, - "stm_types": ["UDP_1"], - "rate": rate, - } - # run traffic - self.run_traffic(info) - time.sleep(15 if self.is_use_trex else 2) - # check test result - self.check_core_freq_in_traffic(self.check_core[1], mode) - except Exception as e: - self.logger.error(traceback.format_exc()) - except_content = e - finally: - self.close_l3fwd_power() - - # check verify result - if except_content: - raise VerifyFailure(except_content) - else: - msg = "test <{0}> successful !!!".format(self.train_mode) - self.logger.info(msg) - - def verify_power_driver(self): - expected_drv = "intel_pstate" - power_drv = self.get_sys_power_driver() - msg = "{0} should work with {1} driver on DUT".format( - self.suite_name, expected_drv - ) - self.verify(power_drv == expected_drv, msg) - - def verify_hyper_threading(self): - msg = "{} should work under hyper threading close status" - self.verify(not self.is_hyper_threading(), msg.format(self.suite_name)) - - def verify_pbf_supported(self): - if self.is_support_pbf(): - return - msg = "dut cpu doesn't support priority base frequency feature" - raise VerifyFailure(msg) - - def preset_test_environment(self): - self.is_l3fwd_on = None - self.cpu_info, self.base_freqs_info = self.get_all_cpu_attrs() - test_content = self.get_suite_cfg() - self.frame_size = test_content.get("frame_size") or 1024 - self.check_core = self.get_normal_cores_index(2) - self.verify_hyper_threading() - # modprobe msr module to let the application can get the CPU HW info - self.d_a_con("modprobe msr") - # init binary - self.init_l3fwd_power() - - # - # Test cases. - # - - def set_up_all(self): - """ - Run at the start of each test suite. - """ - self.verify_power_driver() - # check if cpu support bpf feature - self.verify_pbf_supported() - self.dut_ports = self.dut.get_ports(self.nic) - self.verify(len(self.dut_ports) >= 2, "Not enough ports") - # prepare testing environment - self.preset_test_environment() - - def tear_down_all(self): - """ - Run after each test suite. - """ - pass - - def set_up(self): - """ - Run before each test case. - """ - pass - - def tear_down(self): - """ - Run after each test case. - """ - self.dut.kill_all() - - def test_perf_basic_train_mode(self): - """ - Set Branch-Ratio Rate by User - """ - self.train_mode = self.TRAIN - self.verify_train_mode() - - def test_perf_no_training_mode(self): - """ - Set Branch-Ratio Rate by User - """ - self.train_mode = self.NOTRAIN - self.verify_train_mode()