Controlling and displaying the online state in Linux

Use the smc_rnics command, the lspci command, or the sysfs power attribute of a PCI function to display online or offline information in Linux®.

Using smc_rnics

The smc_rnics command can list your PCI functions if you want to assure that the PCI function of interest is available to your partition. In the command, specify the -a option to include offline PCI functions in the command output.

The command displays a table of all PCI functions that are eligible for your partition. A 0 in the Power column of the output table indicates that the PCI function is offline, while 1 indicates that the PCI function is online.

Example
On your system, assume that you want to configure two PCI functions. The first PCI function (FID=108d) will be set from online to offline while the second PCI function (FID=1881) will be set from offline to online. Start by installing the smcr_nics tool:
# dnf install smc-tools.s390x
To display online PCI functions, issue the smcr_nics command:
# smc_rnics
FID   Power  PCI_ID        PCHID  Type             PFT   VF   PPrt  PNET_ID   Net-Dev
----------------------------------------------------------------------------------------
108d  1      108d:00:00.0  03e0   Network_Express  NETH  y    n/a   n/a       eno4237
108e  1      108e:00:00.0  03e0   Network_Express  NETH  y    n/a   n/a       eno4238
1880  1      1880:00:00.0  01ac   Network_Express  NETD  n    n/a   n/a       eno6272np0


 
To set the first PCI function with the FID 108d offline, issue smc_rnics -d <fid>, where <fid> specifies the FID in hexadecimal format. You can omit leading zeros:
# smc_rnics -d 108d
# smc_rnics
FID   Power  PCI_ID        PCHID  Type             PFT   VF   PPrt  PNET_ID   Net-Dev
--------------------------------------------------------------------------------------
108e  1      108e:00:00.0  03e0   Network_Express  NETH  y    n/a   n/a       eno4238
1880  1      1880:00:00.0  01ac   Network_Express  NETD  n    n/a   n/a       eno6272np0


 
To set the second PCI function with the FID 1881 online, issue smc_rnics -e <fid>:
# smc_rnics -e 1881
# smc_rnics
FID   Power  PCI_ID        PCHID  Type             PFT   VF   PPrt  PNET_ID   Net-Dev
--------------------------------------------------------------------------------------
108e  1      108e:00:00.0  03e0   Network_Express  NETH  y    n/a   n/a       eno4238
1880  1      1880:00:00.0  01ac   Network_Express  NETD  n    n/a   n/a       eno6272np0
1881  1      1880:00:00.2  01ac   Network_Express  NETD  y    n/a   n/a       eno6273v0


 
The PCI function is now online to your Linux instance.
Hint: If a PCI function is already configured in another partition, the function is in a reserved state for other partitions. Linux treats reserved PCI functions as non existing. As a result, the smc_rnics -a command does not display the reserved PCI function, and attempts to set the function online fail.
To verify your changes, display all PCI functions:
# smc_rnics -a
FID   Power  PCI_ID        PCHID  Type             PFT   VF   PPrt  PNET_ID  Net-Dev
--------------------------------------------------------------------------------------
108d  0     -              -      -                -     -    -    -            -
108e  1      108e:00:00.0  03e0   Network_Express  NETH  y    n/a   n/a       eno4238
1880  1      1880:00:00.0  01ac   Network_Express  NETD  n    n/a   n/a       eno6272np0
1881  1      1880:00:00.2  01ac   Network_Express  NETD  y    n/a   n/a       eno6273v0


 

Using sysfs

Alternatively, use the sysfs attribute of the PCI function. In this path, <fid> is the function's FID as an 8-digit hexadecimal number. For more information about your PCI functions, you can use the following commands:
  • ls /sys/bus/pci/slots/:

    Displays FIDs of online and offline functions, unless the FID is online to another LPAR in PR/SM mode.
    Note: ls /sys/bus/pci/slots/ does not display NETD VFs that are not yet created through sriov_numvfs.
  • ls /sys/bus/pci/slots/<fid>/uid:

    Displays the UID of the PCI function.
    Note: You cannot determine the PCHID for an offline function through sysfs.
  • ls /sys/bus/pci/devices/:

    Displays online PCI devices and the corresponding PC ID of the device.
Example
In this example, assume that you want to configure two PCI functions. You want to set the first PCI function (FID=108d) from online to offline and the second PCI function (FID=1881) from offline to online. To display the available PCI functions, issue:
# ls /sys/bus/pci/slots/
108d
108e
1880
1881
Optional: To check if your PCI functions are offline or online, issue cat /sys/bus/pci/slots/<fid>/power. A 0 indicates that the PCI function is offline, while a 1 indicates that the PCI function is online.
# cat /sys/bus/pci/slots/108d/power
1
# cat /sys/bus/pci/slots/1881/power
0
To change the online states of your PCI functions, issue:
# echo 0 > /sys/bus/pci/slots/108d/power
# echo 1 > /sys/bus/pci/slots/1881/power
You can verify your changes using the cat /sys/bus/pci/slots/<fid>/power command as above:
# cat /sys/bus/pci/slots/108d/power
0
# cat /sys/bus/pci/slots/1881/power
1

Using lspci

The lspci command provides detailed PCI configuration information.

Example
To use lspci, install the pciutils tool:
# dnf install pciutils
To display PCI devices with online functions, issue lspci. In this example, your PCI function has the PCI ID 1409:00:00.0:
# lspci
1409:00:00.0 Ethernet controller: Mellanox Technologies ConnectX Family mlx5Gen Virtual
For more detailed information about your PCI function, issue lspci -v -s <pci_id>:
# lspci -v -s 1409:00:00.0
1409:00:00.0 Ethernet controller: Mellanox Technologies ConnectX Family mlx5Gen Virtual Function      
    Subsystem: Mellanox Technologies Device 0002
    Physical Slot: 00001409
    Flags: bus master, fast devsel, latency 0, IOMMU group 6
    Memory at 8f06c00000000000 (64-bit, prefetchable) [disabled] [size=32M]
    Capabilities: [60] Express Endpoint, IntMsgNum 0
    Capabilities: [9c] MSI-X: Enable+ Count=6 Masked-
    Capabilities: [100] Vendor Specific Information: ID=0000 Rev=0 Len=00c <?>
    Capabilities: [150] Alternative Routing-ID Interpretation (ARI)
    Kernel driver in use: mlx5_core
    Kernel modules: mlx5_core
The output display a NETH PCI function. In this example, the corresponding network adapter uses the standard mlx5 Linux kernel driver.