aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python/VhostUser.py
diff options
context:
space:
mode:
authorpmikus <pmikus@cisco.com>2020-10-02 05:48:34 +0000
committerPeter Mikus <pmikus@cisco.com>2021-01-04 10:30:50 +0000
commit44dcb3113c8ade2e44543746abca861a89362c9b (patch)
tree4800a2f9dcf106c5f5222f4be256c9a488f1b85b /resources/libraries/python/VhostUser.py
parente813695b481b745d5136f8cbd0152e62a4ec990c (diff)
GSO: TAP/VHOST use case
Signed-off-by: pmikus <pmikus@cisco.com> Change-Id: Ibafaaca4438587284d1e255c764f0701002941e8
Diffstat (limited to 'resources/libraries/python/VhostUser.py')
-rw-r--r--resources/libraries/python/VhostUser.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/resources/libraries/python/VhostUser.py b/resources/libraries/python/VhostUser.py
index 22528b2b7f..c6b9185e14 100644
--- a/resources/libraries/python/VhostUser.py
+++ b/resources/libraries/python/VhostUser.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2020 Cisco and/or its affiliates.
+# Copyright (c) 2021 Cisco and/or its affiliates.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
@@ -17,9 +17,11 @@ from enum import IntEnum
from robot.api import logger
+from resources.libraries.python.CpuUtils import CpuUtils
from resources.libraries.python.PapiExecutor import PapiSocketExecutor
from resources.libraries.python.topology import NodeType, Topology
from resources.libraries.python.InterfaceUtil import InterfaceUtil
+from resources.libraries.python.ssh import exec_cmd_no_error
class VirtioFeaturesFlags(IntEnum):
@@ -151,6 +153,26 @@ class VhostUser:
logger.debug(f"Vhost-user details:\n{details}")
return details
+ @staticmethod
+ def vhost_user_affinity(node, pf_key, skip_cnt=0):
+ """Set vhost-user affinity for the given node.
+
+ :param node: Topology node.
+ :param pf_key: Interface key to compute numa location.
+ :param skip_cnt: Skip first "skip_cnt" CPUs.
+ :type node: dict
+ :type pf_key: str
+ :type skip_cnt: int
+ """
+ pids, _ = exec_cmd_no_error(
+ node, f"grep -h vhost /proc/*/comm | uniq | xargs pidof")
+
+ affinity = CpuUtils.get_affinity_vhost(
+ node, pf_key, skip_cnt=skip_cnt, cpu_cnt=len(pids.split(" ")))
+
+ for cpu, pid in zip(affinity, pids.split(" ")):
+ exec_cmd_no_error(node, f"taskset -pc {cpu} {pid}", sudo=True)
+
class VirtioFeatureMask:
"""Virtio features utilities"""