• L
    util: new function virNetDevGetPhysPortID() · 48f33bb5
    Laine Stump 提交于
    On Linux each network device *can* (but not necessarily *does*) have
    an attribute called phys_port_id which can be read from the file of
    that name in the netdev's sysfs directory. The examples I've seen have
    been a many-digit hexadecimal number (as an ASCII string).
    
    This value can be useful when a single PCI device is associated with
    multiple netdevs (e.g a dual port Mellanox SR-IOV NIC - this card has
    a single PCI Physical Function (PF), and that PF has two netdevs
    associated with it (the "net" subdirectory of the PF in sysfs has two
    links rather than the usual single link to a netdev directory). Each
    of the PF netdevs has a different phys_port_id. The Virtual Functions
    (VF) are similar - the PF (a PCI device) has "n" VFs (also each of
    these is a PCI device), each VF has two netdevs, and each of the VF
    netdevs points back to the VF PCI device (with the "device" entry in
    its sysfs directory) as well as having a phys_port_id matching the PF
    netdev it is associated with.
    
    virNetDevGetPhysPortID() simply attempts to read the phys_port_id for
    the given netdev and return it to the caller. If this particular
    netdev driver doesn't support phys_port_id, it returns NULL (*not* a
    NULL-terminated string, but a NULL pointer) but still counts it as a
    success.
    48f33bb5
libvirt_private.syms 67.1 KB