From: "Juraj Linkeš" <juraj.linkes@pantheon.tech>
To: jspewock@iol.unh.edu, npratte@iol.unh.edu,
yoan.picchi@foss.arm.com, thomas@monjalon.net,
Honnappa.Nagarahalli@arm.com, probb@iol.unh.edu,
wathsala.vithanage@arm.com, paul.szczepanek@arm.com,
Luca.Vizzarro@arm.com, alex.chapman@arm.com
Cc: dev@dpdk.org
Subject: Re: [PATCH v4 4/5] dts: add OS abstractions for creating virtual functions
Date: Wed, 25 Sep 2024 14:05:06 +0200 [thread overview]
Message-ID: <5b229d0b-768b-4cdf-b18e-c37300d93ab3@pantheon.tech> (raw)
In-Reply-To: <20240923184235.22582-5-jspewock@iol.unh.edu>
> diff --git a/dts/framework/testbed_model/linux_session.py b/dts/framework/testbed_model/linux_session.py
> @@ -210,3 +214,37 @@ def configure_ipv4_forwarding(self, enable: bool) -> None:
> """Overrides :meth:`~.os_session.OSSession.configure_ipv4_forwarding`."""
> state = 1 if enable else 0
> self.send_command(f"sysctl -w net.ipv4.ip_forward={state}", privileged=True)
> +
> + def set_num_virtual_functions(self, num: int, pf_port: Port) -> bool:
> + """Overrides :meth:`~.os_session.OSSession.set_num_virtual_functions`."""
> + sys_bus_path = f"/sys/bus/pci/devices/{pf_port.pci}/sriov_numvfs".replace(":", "\\:")
> + curr_num_vfs = int(self.send_command(f"cat {sys_bus_path}").stdout)
> + if num > 0 and curr_num_vfs >= num:
> + self._logger.info(
> + f"{curr_num_vfs} VFs already configured on port {pf_port.identifier.pci} on node "
> + f"{pf_port.identifier.node}."
> + )
> + return False
> + elif num > 0 and curr_num_vfs > 0:
These two conditions could be written as:
if num > 0:
if curr_num_vfs >= num:
return False
elif curr_num_vfs > 0:
raise InternalError()
Maybe it's not worth the extra indent, but it's easier to understand, so
I lean towards doing it this way.
> + def get_pci_addr_of_vfs(self, pf_port: Port) -> list[str]:
> + """Overrides :meth:`~.os_session.OSSession.get_pci_addr_of_vfs`."""
> + sys_bus_path = f"/sys/bus/pci/devices/{pf_port.pci}".replace(":", "\\:")
> + curr_num_vfs = int(self.send_command(f"cat {sys_bus_path}/sriov_numvfs").stdout)
> + if curr_num_vfs > 0:
> + pci_addrs = self.send_command(
> + 'awk -F "PCI_SLOT_NAME=" "/PCI_SLOT_NAME=/ {print \\$2}" '
> + + f"{sys_bus_path}/virtfn*/uevent",
We could use a TextParser here. Not sure if it's a good fit though.
> diff --git a/dts/framework/testbed_model/os_session.py b/dts/framework/testbed_model/os_session.py
> @@ -395,3 +395,43 @@ def configure_ipv4_forwarding(self, enable: bool) -> None:
> + @abstractmethod
> + def set_num_virtual_functions(self, num: int, pf_port: Port) -> bool:
> + """Update the number of virtual functions (VFs) on a port.
> +
> + It should be noted that, due to the nature of VFs, if there are already VFs that exist on
> + the physical function (PF) prior to calling this function, additional ones cannot be added.
> + The only way to add more VFs is to remove the existing and then set the desired amount. For
> + this reason, this method will handle creation in the following order:
> +
> + 1. Use existing VFs on the PF if the number of existing VFs is greater than or equal to
> + `num`
> + 2. Throw an exception noting that VFs cannot be created if the PF has some VFs already set
> + on it, but the total VFs that it has are less then `num`.
> + 3. Create `num` VFs on the PF if there are none on it already
> +
> + Args:
> + num: The number of VFs to set on the port.
> + pf_port: The port to add the VFs to.
> +
> + Raises:
> + InternalError: If `pf_port` has less than `num` VFs configured on it
> + already.
> +
> + Returns:
> + :data:`True` if this method successfully created VFs, :data:`False` if existing VFs
> + were used instead.
> + """
The whole docstring talks only about the creation of VFs, but we can
also remove VFs with this.
next prev parent reply other threads:[~2024-09-25 12:05 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-21 19:15 [RFC PATCH v1 0/5] dts: add VFs to the framework jspewock
2024-08-21 19:15 ` [RFC PATCH v1 1/5] dts: allow binding only a single port to a different driver jspewock
2024-08-21 19:15 ` [RFC PATCH v1 2/5] dts: parameterize what ports the TG sends packets to jspewock
2024-08-21 19:15 ` [RFC PATCH v1 3/5] dts: add class for virtual functions jspewock
2024-08-21 19:15 ` [RFC PATCH v1 4/5] dts: add OS abstractions for creating " jspewock
2024-08-21 19:15 ` [RFC PATCH v1 5/5] dts: add functions for managing VFs to Node jspewock
2024-08-21 19:21 ` [RFC PATCH v2 0/5] dts: add VFs to the framework jspewock
2024-08-21 19:21 ` [RFC PATCH v2 1/5] dts: allow binding only a single port to a different driver jspewock
2024-08-21 19:21 ` [RFC PATCH v2 2/5] dts: parameterize what ports the TG sends packets to jspewock
2024-08-21 19:21 ` [RFC PATCH v2 3/5] dts: add class for virtual functions jspewock
2024-08-21 19:21 ` [RFC PATCH v2 4/5] dts: add OS abstractions for creating " jspewock
2024-08-21 19:21 ` [RFC PATCH v2 5/5] dts: add functions for managing VFs to Node jspewock
2024-08-21 19:38 ` [RFC PATCH v2 0/5] dts: add VFs to the framework jspewock
2024-08-21 19:38 ` [RFC PATCH v2 1/5] dts: allow binding only a single port to a different driver jspewock
2024-08-21 19:38 ` [RFC PATCH v2 2/5] dts: parameterize what ports the TG sends packets to jspewock
2024-08-21 19:38 ` [RFC PATCH v2 3/5] dts: add class for virtual functions jspewock
2024-08-21 19:38 ` [RFC PATCH v2 4/5] dts: add OS abstractions for creating " jspewock
2024-08-21 19:38 ` [RFC PATCH v2 5/5] dts: add functions for managing VFs to Node jspewock
2024-08-21 19:44 ` [RFC PATCH v2 0/5] dts: add VFs to the framework Jeremy Spewock
2024-08-21 21:30 ` [RFC PATCH v3 " jspewock
2024-08-21 21:30 ` [RFC PATCH v3 1/5] dts: allow binding only a single port to a different driver jspewock
2024-08-21 21:30 ` [RFC PATCH v3 2/5] dts: parameterize what ports the TG sends packets to jspewock
2024-08-21 21:30 ` [RFC PATCH v3 3/5] dts: add class for virtual functions jspewock
2024-08-21 21:30 ` [RFC PATCH v3 4/5] dts: add OS abstractions for creating " jspewock
2024-08-21 21:30 ` [RFC PATCH v3 5/5] dts: add functions for managing VFs to Node jspewock
2024-09-23 18:42 ` [PATCH v4 0/5] dts: add VFs to the framework jspewock
2024-09-23 18:42 ` [PATCH v4 1/5] dts: allow binding only a single port to a different driver jspewock
2024-09-25 8:45 ` Juraj Linkeš
2024-09-23 18:42 ` [PATCH v4 2/5] dts: parameterize what ports the TG sends packets to jspewock
2024-09-25 10:58 ` Juraj Linkeš
2024-09-23 18:42 ` [PATCH v4 3/5] dts: add class for virtual functions jspewock
2024-09-25 11:28 ` Juraj Linkeš
2024-09-23 18:42 ` [PATCH v4 4/5] dts: add OS abstractions for creating " jspewock
2024-09-25 12:05 ` Juraj Linkeš [this message]
2024-09-23 18:42 ` [PATCH v4 5/5] dts: add functions for managing VFs to Node jspewock
2024-09-25 13:29 ` Juraj Linkeš
2024-09-25 8:24 ` [PATCH v4 0/5] dts: add VFs to the framework Juraj Linkeš
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5b229d0b-768b-4cdf-b18e-c37300d93ab3@pantheon.tech \
--to=juraj.linkes@pantheon.tech \
--cc=Honnappa.Nagarahalli@arm.com \
--cc=Luca.Vizzarro@arm.com \
--cc=alex.chapman@arm.com \
--cc=dev@dpdk.org \
--cc=jspewock@iol.unh.edu \
--cc=npratte@iol.unh.edu \
--cc=paul.szczepanek@arm.com \
--cc=probb@iol.unh.edu \
--cc=thomas@monjalon.net \
--cc=wathsala.vithanage@arm.com \
--cc=yoan.picchi@foss.arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).