Skip to content

Commit

Permalink
Recipes/ENRT/UseVfsMixin.py: add vf_trust parameter
Browse files Browse the repository at this point in the history
Allows user to set trust mode on created VFs.

Signed-off-by: Jan Tluka <[email protected]>
  • Loading branch information
jtluka committed Sep 24, 2024
1 parent 2b4dfb9 commit e780d08
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lnst/Recipes/ENRT/UseVfsMixin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from lnst.Common.Parameters import BoolParam
from lnst.Common.Parameters import BoolParam, ChoiceParam
from lnst.Controller.Requirements import DeviceReq
from lnst.Recipes.ENRT.SRIOVDevices import SRIOVDevices

Expand All @@ -12,11 +12,16 @@ class UseVfsMixin:
with VF Device instances. This allows user to interact with the network
interfaces without additional changes to the code of recipe.
Mixin provides two boolean parameters:
* use_vfs - main parameter to enable or disable (default) use of VFs
* vf_trust - set the trust parameter of the used VFs, 'on' or 'off' (default)
There are some limitations, for example pause frames cannot be configured
since the VF do not support these.
"""

use_vfs = BoolParam(default=False)
vf_trust = ChoiceParam(choices={'on', 'off'}, default='off')

def test_wide_configuration(self):
config = super().test_wide_configuration()
Expand All @@ -33,6 +38,8 @@ def test_wide_configuration(self):
for dev_name in dev_names:
dev = getattr(host, dev_name)
sriov_devices = SRIOVDevices(dev, 1)
dev.vf_trust(0, self.params.vf_trust)

vf_dev = sriov_devices.vfs[0]
host.map_device(dev_name, {"ifname": vf_dev.name})

Expand All @@ -56,7 +63,7 @@ def generate_test_wide_description(self, config):

if self.params.use_vfs:
description += [
f"Using vf device {vf_dev.name} of pf {sriov_devices.phys_dev.name} for DeviceReq {host.hostid}.{vf_dev._id}"
f"Using vf device {vf_dev.name} of pf {sriov_devices.phys_dev.name} for DeviceReq {host.hostid}.{vf_dev._id} trusted={self.params.vf_trust}"
for host, sriov_devices_list in config.vf_config.items()
for sriov_devices in sriov_devices_list
for vf_dev in sriov_devices.vfs
Expand Down

0 comments on commit e780d08

Please sign in to comment.