summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py5
-rw-r--r--yardstick/network_services/vnf_generic/vnf/vpe_vnf.py39
2 files changed, 34 insertions, 10 deletions
diff --git a/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py b/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py
index 1abc53688..6dc6df0d8 100644
--- a/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py
+++ b/tests/unit/network_services/vnf_generic/vnf/test_vpe_vnf.py
@@ -163,6 +163,11 @@ class TestConfigCreate(unittest.TestCase):
self.assertEqual(config_create.downlink_ports, ['xe1'])
self.assertEqual(config_create.socket, 2)
+ def test_dpdk_port_to_link_id(self):
+ vnfd_helper = VnfdHelper(self.VNFD_0)
+ config_create = ConfigCreate(vnfd_helper, 2)
+ self.assertEqual(config_create.dpdk_port_to_link_id_map, {'xe0': 0, 'xe1': 1})
+
def test_vpe_initialize(self):
vnfd_helper = VnfdHelper(self.VNFD_0)
config_create = ConfigCreate(vnfd_helper, 2)
diff --git a/yardstick/network_services/vnf_generic/vnf/vpe_vnf.py b/yardstick/network_services/vnf_generic/vnf/vpe_vnf.py
index c02c0eb27..077ce2385 100644
--- a/yardstick/network_services/vnf_generic/vnf/vpe_vnf.py
+++ b/yardstick/network_services/vnf_generic/vnf/vpe_vnf.py
@@ -34,9 +34,9 @@ LOG = logging.getLogger(__name__)
VPE_PIPELINE_COMMAND = """sudo {tool_path} -p {port_mask_hex} -f {cfg_file} -s {script}"""
VPE_COLLECT_KPI = """\
-Pkts in:\s(\d+)\r\n\
-\tPkts dropped by AH:\s(\d+)\r\n\
-\tPkts dropped by other:\s(\d+)\
+Pkts in:\\s(\\d+)\r\n\
+\tPkts dropped by AH:\\s(\\d+)\r\n\
+\tPkts dropped by other:\\s(\\d+)\
"""
@@ -61,6 +61,25 @@ class ConfigCreate(object):
self.downlink_ports = self.vnfd_helper.port_pairs.downlink_ports
self.pipeline_per_port = 9
self.socket = socket
+ self._dpdk_port_to_link_id_map = None
+
+ @property
+ def dpdk_port_to_link_id_map(self):
+ # we need interface name -> DPDK port num (PMD ID) -> LINK ID
+ # LINK ID -> PMD ID is governed by the port mask
+ # LINK instances are created implicitly based on the PORT_MASK application startup
+ # argument. LINK0 is the first port enabled in the PORT_MASK, port 1 is the next one,
+ # etc. The LINK ID is different than the DPDK PMD-level NIC port ID, which is the actual
+ # position in the bitmask mentioned above. For example, if bit 5 is the first bit set
+ # in the bitmask, then LINK0 is having the PMD ID of 5. This mechanism creates a
+ # contiguous LINK ID space and isolates the configuration file against changes in the
+ # board PCIe slots where NICs are plugged in.
+ if self._dpdk_port_to_link_id_map is None:
+ self._dpdk_port_to_link_id_map = {}
+ for link_id, port_name in enumerate(sorted(self.vnfd_helper.port_pairs.all_ports,
+ key=self.vnfd_helper.port_num)):
+ self._dpdk_port_to_link_id_map[port_name] = link_id
+ return self._dpdk_port_to_link_id_map
def vpe_initialize(self, config):
config.add_section('EAL')
@@ -79,7 +98,7 @@ class ConfigCreate(object):
def vpe_rxq(self, config):
for port in self.downlink_ports:
- new_section = 'RXQ{0}.0'.format(self.vnfd_helper.port_num(port))
+ new_section = 'RXQ{0}.0'.format(self.dpdk_port_to_link_id_map[port])
config.add_section(new_section)
config.set(new_section, 'mempool', 'MEMPOOL1')
@@ -104,7 +123,7 @@ class ConfigCreate(object):
for k, v in parser.items(pipeline):
if k == "pktq_in":
if "RXQ" in v:
- port = self.vnfd_helper.port_num(self.uplink_ports[index])
+ port = self.dpdk_port_to_link_id_map[self.uplink_ports[index]]
value = "RXQ{0}.0".format(port)
else:
value = self.get_sink_swq(parser, pipeline, k, index)
@@ -113,7 +132,7 @@ class ConfigCreate(object):
elif k == "pktq_out":
if "TXQ" in v:
- port = self.vnfd_helper.port_num(self.downlink_ports[index])
+ port = self.dpdk_port_to_link_id_map[self.downlink_ports[index]]
value = "TXQ{0}.0".format(port)
else:
self.sw_q += 1
@@ -135,7 +154,7 @@ class ConfigCreate(object):
for k, v in parser.items(pipeline):
if k == "pktq_in":
- port = self.vnfd_helper.port_num(self.downlink_ports[index])
+ port = self.dpdk_port_to_link_id_map[self.downlink_ports[index]]
if "RXQ" not in v:
value = self.get_sink_swq(parser, pipeline, k, index)
elif "TM" in v:
@@ -146,7 +165,7 @@ class ConfigCreate(object):
parser.set(pipeline, k, value)
if k == "pktq_out":
- port = self.vnfd_helper.port_num(self.uplink_ports[index])
+ port = self.dpdk_port_to_link_id_map[self.uplink_ports[index]]
if "TXQ" not in v:
self.sw_q += 1
value = self.get_sink_swq(parser, pipeline, k, index)
@@ -171,7 +190,7 @@ class ConfigCreate(object):
config = self.vpe_initialize(config)
config = self.vpe_rxq(config)
config.write(cfg_file)
- for index in range(0, len(self.uplink_ports)):
+ for index, _ in enumerate(self.uplink_ports):
config = self.vpe_upstream(vnf_cfg, index)
config.write(cfg_file)
config = self.vpe_downstream(vnf_cfg, index)
@@ -209,7 +228,7 @@ class ConfigCreate(object):
return rules.get_string()
- def generate_tm_cfg(self, vnf_cfg, index=0):
+ def generate_tm_cfg(self, vnf_cfg):
vnf_cfg = os.path.join(vnf_cfg, "full_tm_profile_10G.cfg")
if os.path.exists(vnf_cfg):
return open(vnf_cfg).read()