+ :param nodes: VPP nodes.
+ :type nodes: dict
+ """
+ for node in nodes.values():
+ if node[u"type"] == NodeType.DUT:
+ VhostUser.vhost_user_dump(node)
+
+ @staticmethod
+ def vhost_user_dump(node):
+ """Get vhost-user data for the given node.
+
+ :param node: VPP node to get interface data from.
+ :type node: dict
+ :returns: List of dictionaries with all vhost-user interfaces.
+ :rtype: list
+ """
+ cmd = u"sw_interface_vhost_user_dump"
+ err_msg = f"Failed to get vhost-user dump on host {node['host']}"
+
+ with PapiSocketExecutor(node) as papi_exec:
+ details = papi_exec.add(cmd).get_details(err_msg)
+
+ 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"""
+
+ @staticmethod
+ def create_virtio_feature_mask(**kwargs):
+ """Create virtio feature mask with feature bits set according to kwargs.
+ :param kwargs: Key-value pairs of feature names and it's state
+ :type kwargs: dict
+ """
+ virtio_feature_mask = 0
+
+ if u"all" in kwargs and kwargs[u"all"] is True:
+ for virtio_feature_flag in VirtioFeaturesFlags:
+ virtio_feature_mask |= 1 << virtio_feature_flag.value
+ else:
+ for feature_name, enabled in kwargs.items():
+ virtio_feature_name = \
+ u"VIRTIO_NET_F_API_" + feature_name.upper()
+ if virtio_feature_name not in VirtioFeaturesFlags.__members__:
+ raise ValueError(u"Unsupported virtio feature flag name")
+ if enabled:
+ virtio_feature_mask |= \
+ 1 << VirtioFeaturesFlags[virtio_feature_name].value
+
+ return virtio_feature_mask
+
+ @staticmethod
+ def is_feature_enabled(virtio_feature_mask, virtio_feature_flag):
+ """Checks if concrete virtio feature is enabled within
+ virtio_feature_mask
+ :param virtio_feature_mask: Mask of enabled virtio features
+ :param virtio_feature_flag: Checked virtio feature
+ :type virtio_feature_mask: int
+ :type virtio_feature_flag: VirtioFeaturesFlags
+ """
+ feature_flag_bit = 1 << virtio_feature_flag.value
+ return (virtio_feature_mask & feature_flag_bit) > 0