@@ -6,6 +6,7 @@ import os
import re
import threading
import time
+import copy
from typing import Dict, List, Optional, Union
from uuid import uuid4
@@ -15,11 +16,13 @@ from nics.net_device import GetNicObj
from .config import AppNameConf, PortConf
from .crb import Crb
from .exception import ParameterInvalidException
-from .settings import LOG_NAME_SEP, NICS
+from .settings import LOG_NAME_SEP, NICS,DPDK_TEST_MEV_SETTING,\
+ DPDK_QUEUE_MODEL_SETTING,DPDK_VPORT_SETTING,DPDK_RX_VPORT_SETTING
from .ssh_connection import SSHConnection
from .test_result import ResultTable
from .utils import RED, remove_old_rsa_key
from .virt_resource import VirtResource
+from .logger import getLogger
class Dut(Crb):
@@ -62,7 +65,10 @@ class Dut(Crb):
self.apps_name = {}
self.dpdk_version = ""
self.nic = None
-
+ self.test_mev = settings.load_global_setting(DPDK_TEST_MEV_SETTING).lower()
+ # self.test_acc = settings.load_global_setting(DPDK_TEST_ACC_SETTING).lower()
+ if self.test_mev=="true":
+ self.set_up_mev_test_env()
def filter_cores_from_crb_cfg(self):
# get core list from crbs.cfg
core_list = []
@@ -327,11 +333,13 @@ class Dut(Crb):
self.load_portconf()
self.mount_procfs()
# auto detect network topology
- self.map_available_ports()
+ # self.map_available_ports()
# disable tester port ipv6
self.disable_tester_ipv6()
self.get_nic_configurations()
-
+ self.get_mev_nic_configurations()
+ # auto detect network topology
+ self.map_available_ports()
# print latest ports_info
for port_info in self.ports_info:
self.logger.info(port_info)
@@ -354,6 +362,24 @@ class Dut(Crb):
if self.nic.default_driver == "ice":
self.get_nic_pkg(retry_times)
+ def get_mev_nic_configurations(self):
+ if self.test_mev=="true":
+ self.vport=settings.load_global_setting(DPDK_VPORT_SETTING).lower()
+ try:
+ vport = self.vport.split("-")
+ vport = list(range(int(vport[0]),int(vport[1])+1))
+ except:
+ vport = [int(self.vport),]
+
+ if len(vport) > 1 :
+ for i in range(len(vport)-1):
+ dut_port_info = copy.copy(self.ports_info[0])
+ tester_port_info = copy.copy(self.tester.ports_info[0])
+ dut_port_info["mac"] = self.ports_info[0]["mac"].replace("0",str(i+1),2)
+ self.ports_info.append(dut_port_info)
+ self.tester.ports_info.append(tester_port_info)
+ # self.port_info[i+1]["pci"] = ""
+
def get_nic_pkg(self, retry_times=3):
self.nic.pkg = self.nic.get_nic_pkg()
while not self.nic.pkg.get("type") and retry_times > 0:
@@ -1379,9 +1405,65 @@ class Dut(Crb):
Recover all resource before crb exit
"""
self.enable_tester_ipv6()
+ try:
+ self.bak_session.send_expect("pkill minicom","#")
+ except:
+ pass
+ self.close()
self.close()
self.logger.logger_exit()
-
+
+ def create_imc_test_session(self):
+ self.imc_test_session = SSHConnection(host=self.crb["section"],session_name="imc",username="root",password="tester")
+ self.imc_test_session.init_log(getLogger("dut_imc_session"))
+ self.imc_test_session.send_expect("export TERM=linux-c-nc","#")
+ out = self.imc_test_session.send_command(f"sudo minicom -D {self.crb['IMC PORT']} -b {self.crb['IMC BAUDRATE']} -w")
+ while "root@mev-imc" not in out:
+ if "locked" in out:
+ self.bak_session.send_command("ps -ef | grep 'minicom -D %s' | grep -v grep | awk '{print $2}' | xargs kill -9"%(self.crb['IMC PORT']))
+ out = self.imc_test_session.send_command(f"sudo minicom -D {self.crb['IMC PORT']} -b {self.crb['IMC BAUDRATE']}")
+ elif "login" in out:
+ out = self.imc_test_session.send_command("root")
+ else:
+ out = self.imc_test_session.send_command("\n")
+ self.logger.info("create imc test session successfully")
+
+ def create_acc_test_session(self):
+ self.acc_test_session = SSHConnection(host=self.crb["section"],session_name="acc",username="root",password="tester")
+ self.acc_test_session.init_log(getLogger("dut_acc_session"))
+ self.acc_test_session.send_expect("export TERM=linux-c-nc","#")
+ out = self.acc_test_session.send_command(f"sudo minicom -D {self.crb['ACC PORT']} -b {self.crb['ACC BAUDRATE']}")
+ # out = self.send_command(f"ssh 192.168.0.2")
+ while "root@mev-acc" not in out:
+ if "locked" in out:
+ self.bak_session.send_command("ps -ef | grep 'minicom -D %s' | grep -v grep | awk '{print $2}' | xargs kill -9"%(self.crb['ACC PORT']))
+ out = self.acc_test_session.send_command(f"sudo minicom -D {self.crb['ACC PORT']} -b {self.crb['ACC BAUDRATE']}")
+ elif "login" in out:
+ out = self.acc_test_session.send_command("root")
+ else:
+ out = self.acc_test_session.send_command("\n")
+ self.acc_test_session.logger.info("login acc successfully")
+ def mev_config_rx_port(self, out):
+ rx_vport = settings.load_global_setting(DPDK_RX_VPORT_SETTING).lower()
+ try:
+ # self.ports_info[int(rx_vport)]['mac'] = re.findall(f'Port {rx_vport}: (.{17})\\r',out)[0]
+ mac = re.findall("Port %s: (.{17})\\r"%(rx_vport),out)[0]
+ except:
+ # self.ports_info[int(rx_vport)]['mac'] = re.findall('Address:(.{17})',out)[0]
+ mac = re.findall('Address:(.{17})',out)[0]
+ output = self.imc_test_session.send_command("cli_client --query --config --verbose")
+ vsi_id = re.findall("vsi_id: 0x(\w+).*is_created: yes.*mac addr: %s"%(mac.lower()),output)
+ self.imc_test_session.send_command("devmem 0x202920C100 64 0x80%s"%(vsi_id[0]))
+
+ def set_up_mev_test_env(self):
+ if self.test_mev == "true":
+ self.bak_session = SSHConnection(host=self.crb["section"],session_name="bak",username="root",password="tester")
+ self.bak_session.init_log(getLogger("dut_bak"))
+ self.create_imc_test_session()
+ if self.crb["ACC PORT"] != "" and self.crb["ACC BAUDRATE"] != "" and self.crb["IP"] == self.crb["section"]:
+ self.create_acc_test_session()
+ self.session = self.acc_test_session
+ self.alt_session = self.acc_test_session
class _EalParameter(object):
def __init__(
@@ -1428,6 +1510,7 @@ class _EalParameter(object):
param other_eal_param: user defined DPDK eal parameters, eg:
other_eal_param='--single-file-segments';
"""
+ self.test_mev=settings.load_global_setting(DPDK_TEST_MEV_SETTING).lower()
self.os_type = dut.get_os_type()
self.fixed_prefix = fixed_prefix
self.socket = socket
@@ -1561,7 +1644,12 @@ class _EalParameter(object):
for port_info in self.dut.ports_info:
pci_list.append("%s %s" % (allow_option, port_info["pci"]))
self.dut.logger.info(pci_list)
- return " ".join(pci_list)
+ # return " ".join(pci_list)
+ if self.test_mev =="true":
+ mev_port_options = self._get_mev_port_options()
+ return f"'' '.join(pci_list),{mev_port_options}"
+ else:
+ return " ".join(pci_list)
def _make_b_ports_param(self) -> str:
b_pci_list = []
@@ -1638,8 +1726,11 @@ class _EalParameter(object):
port_mac_addr = self.dut.ports_info[port]["pci"] if type(port) == int else port
port_param = f"{allow_option} {port_mac_addr}"
port_option = self._get_port_options_from_config(port)
- if port_option:
- port_param = f"{port_param},{port_option}"
+ # if port_option:
+ # port_param = f"{port_param},{port_option}"
+ mev_port_options = self._get_mev_port_options()
+ if port_option or mev_port_options:
+ port_param = f"{port_param},{mev_port_options},{port_option}"
return port_param
def _get_port_options_from_config(self, port: Union[str, int]) -> str:
@@ -1680,3 +1771,17 @@ class _EalParameter(object):
]
)
return _eal_str
+
+
+ def _get_mev_port_options(self):
+ if self.test_mev == "true":
+ self.queue_model = settings.load_global_setting(DPDK_QUEUE_MODEL_SETTING)
+ self.vport = settings.load_global_setting(DPDK_VPORT_SETTING)
+ port_options_dict = {
+ "splitq":f"vport={self.vport}",
+ "singleq":f"vport={self.vport},rx_single=1,tx_single=1",
+ }
+ out = port_options_dict[self.queue_model]
+ return out
+ else:
+ return ""