<div dir="ltr"><div>Hi Daniel,<br><br>Thanks a lot for the quick reply - it's much appreciated.<br><br>> IIUC, the high level scenario is as follows<br><br>Yes, the high-level description matches the use-case.<br><br>The SmartNIC DPU cores may even rely on something else other than PCIe in a<br>general case: i.e. they could use a platform device or a different I/O<br>specification to access the network controller while the hypervisor host would<br>rely on PCIe. The end result is the same though - hypervisor host PCI addresses<br>cannot be relied upon to identify the so called "port representors"<br>(<a href="https://lwn.net/Articles/692942/">https://lwn.net/Articles/692942/</a>) at the SmartNIC DPU operating system side.<br><br>Moreover, there can be multiple SmartNIC DPUs per hypervisor in a general case<br>each with its own set of PFs and VFs. In order to determine which DPU is going<br>to handle representor port programming at the control plane level, there needs<br>to be a way to identify a DPU based on a VF selected by the hypervisor (at<br>least in Nova, VF selection is driven from the hypervisor side). A board serial<br>number can be determined both from the hypervisor and the DPU independently<br>and so the hypervisor services can provide the board serial to the network<br>control plane for the discovery of a relevant DPU. That's where Libvirt comes<br>in for helping with serial number retrieval.<br><br>> This seems like a reasonable feature request to me, since there is<br>a piece of info that apps using libvirt need, and libvirt does not<br>expose this. Requiring the mgmt app like Nova to dig into the host<br>PCI config space indicates a clear gap in libvirt functionality.<br><br>Ack, thanks for confirming.<br><br>> Is scenario (2) going to be at all common ? What would be a reason why the<br>info is not exposed via the standardized VPD - is it just a legacy hardware<br>issue ?<br><br>VPD is an optional capability in the PCI and PCIe specs. While there is hope<br>that every SmartNIC DPU vendor will implement it seeing the need for it,<br>there might be some fragmentation because the specs do not mandate its<br>presence. Scenario (2) is an attempt to have an alternative source for the<br>same piece of information: if a serial is available via the driver (which may<br>query NIC firmware instead of reading VPD) it can still be used with the same<br>end result. The devlink-info API does not mandate that a board serial is<br>exposed either so there is no guarantee this will be available via devlink.<br><br>It will surely be simpler to just implement scenario (1) and add (2)<br>later if there is a significant need for it. The generally available hardware<br>I have seen has VPD exposed so I can just focus on (1) while we can decide<br>on whether to do (2) or not.<br><br>Best Regards,<br>Dmitrii Shcherbakov<br>LP: ~dmitriis</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Tue, Jun 1, 2021 at 2:32 PM Daniel P. Berrangé <<a href="mailto:berrange@redhat.com" target="_blank">berrange@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">On Fri, May 28, 2021 at 10:58:05PM +0300, Dmitrii Shcherbakov wrote:<br>
> Hello Libvirt Developers,<br>
> <br>
> I am looking for some feedback on a planned enhancement to Libvirt: the aim<br>
> is<br>
> to store a portion of PCI(e) Vital Product Data (VPD) for each device along<br>
> with other PCI/PCIe device information already collected. Specifically, the<br>
> SN<br>
> (Serial Number) read-only field of a VPD data structure of a device is of<br>
> interest which is described in PCI/PCIe specs (PCI local bus 2.1+ and PCIe<br>
> 4.0+).<br>
> <br>
> The context for this is the cross-project work in OpenStack (Nova, Neutron),<br>
> OVS and OVN to support for off-path SmartNIC DPUs ([1], [2], [3], [4]). The<br>
> Nova specification [1] provides an overview of the relevant hardware and the<br>
> use-case for board serial numbers, however, VPD is the standard capability<br>
> in<br>
> the PCI/PCIe specifications not tied to the use-case in particular so the<br>
> suggestion from the Nova core team was to aim at introducing means of<br>
> collecting this information via Libvirt. It can then be retrieved by the<br>
> respective virt driver in Nova via Libvirt without having to introduce this<br>
> code into Nova itself.<br>
<br>
I've talked with Sean Mooney at little about the use case this morning.<br>
<br>
IIUC, the high level scenario is as follows<br>
<br>
 - The main host machine has a PCI controller topology to which the<br>
   NICs are attached. This is how the host OS and by extension libvirt,<br>
   nova, etc, see the PCI devices.<br>
<br>
 - There is a second PCI controller topology to which the NICs are<br>
   attached. This is only visible to the arm cores for the offload<br>
   engine<br>
<br>
 - Nova/Neutron can identify the NICs based on the PCI topology<br>
   seen by the host OS, but need to tell the NIC mgmt software<br>
   which NIC to use in a way that can be undersood by the offload<br>
   cores.<br>
<br>
IOW, the PCI address is not usable as a unique identifier because<br>
there are two completely independant PCI topologies with no mapping<br>
between them.<br>
<br>
The VPD data provides a replacement way to identify a NIC based on<br>
a unique serial number that is indendant of PCI topology. Nova needs<br>
this serial number in order to configure the device offload featues.<br>
<br>
This seems like a reasonable feature request to me, since there is<br>
a piece of info that apps using libvirt need, and libvirt does not<br>
expose this. Requiring the mgmt app like Nova to dig into the host<br>
PCI config space indicates a clear gap in libvirt functionality.<br>
<br>
> I would like to suggest the following to be done in Libvirt:<br>
> <br>
> 1) adding the code for extracting a serial number from VPD for PCI/PCIe<br>
> devices<br>
>    in general and storing it for exposure via the Libvirt API;<br>
> More specifically, I propose adding a nested capability called "vpd" under<br>
> VIR_NODE_DEV_CAP_PCI_DEV:<br>
>   <capability type='pci'><br>
>     <capability type='vpd'><br>
>     <serial>UNIQUESERIAL</serial><br>
> <!-- ... other VPD attributes if present --><br>
> </capability><br>
> <!-- ... --><br>
> </capability><br>
<br>
This looks like a reasonable proposal<br>
<br>
> 2) (optional) implementing functionality to obtain a board serial number via<br>
>    devlink-info for PCIe devices if they do not expose a VPD capability<br>
> but the device driver can retrieve it via firmware. The board serial number<br>
> can be stored in the same element as suggested above.<br>
<br>
Is scenario (2) going to be at all common ? What would be a reason why the<br>
info is not exposed via the standardized VPD - is it just a legacy hardware<br>
issue ?<br>
<br>
> Not all devices expose the devlink API and even fewer do expose board serial<br>
> via devlink-info:<br>
> <br>
> * devlink was added in 4.10 [11];<br>
> * devlink-info was introduced in 5.1 [12];<br>
> * querying for board.serial_number was added in kernel 5.9 [13] and iproute2<br>
>   5.9.0 [14];<br>
> * Besides the generic devlink infrastructure support above, device drivers<br>
>   also need to support exposing this field.<br>
> <br>
> Therefore, implementing two approaches (sysfs VPD, devlink) is preferable<br>
> for better compatibility.<br>
> <br>
> I would appreciate any feedback on whether this potential addition makes<br>
> sense.<br>
> If so, I can look into implementing this.<br>
<br>
It makes sense to me.<br>
<br>
Regards,<br>
Daniel<br>
-- <br>
|: <a href="https://berrange.com" rel="noreferrer" target="_blank">https://berrange.com</a>      -o-    <a href="https://www.flickr.com/photos/dberrange" rel="noreferrer" target="_blank">https://www.flickr.com/photos/dberrange</a> :|<br>
|: <a href="https://libvirt.org" rel="noreferrer" target="_blank">https://libvirt.org</a>         -o-            <a href="https://fstop138.berrange.com" rel="noreferrer" target="_blank">https://fstop138.berrange.com</a> :|<br>
|: <a href="https://entangle-photo.org" rel="noreferrer" target="_blank">https://entangle-photo.org</a>    -o-    <a href="https://www.instagram.com/dberrange" rel="noreferrer" target="_blank">https://www.instagram.com/dberrange</a> :|<br>
<br>
</blockquote></div></div>