3. Ethernet Device Assignment

In this quickstart guide an Ethernet device will be assigned in polling mode to the RTOS.

Hint

For more specific options like interrupt mode please check the chapter RTOS Devices (Partitioning) of the Hypervisor Manual.

3.1. Device Identification

In a first step, it is required to determine the Ethernet device that shall be used by the Real-time guest. There are several ways how to detect the desired adapter.

3.1.1. Identify by hardware information

An easy way to identify an adapter is its hardware information:

lshw -class network

returns

*-network:1
    description: Ethernet interface
    product: 82545EM Gigabit Ethernet Controller (Copper)
    vendor: Intel Corporation
    physical id: 6
    bus info: pci@0000:02:06.0
    logical name: enp2s0
    version: 01
    serial: 00:0c:29:94:bb:c3
    size: 1Gbit/s
    capacity: 1Gbit/s
    width: 64 bits
    clock: 66MHz
    capabilities: bus_master cap_list rom ethernet physical logical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
    configuration: autonegotiation=on broadcast=yes driver=e1000 driverversion=5.15.0-88-acontis duplex=full ip=172.17.10.26 latency=0 link=yes mingnt=255 multicast=yes port=twisted pair speed=1Gbit/s
    resources: irq:16 memory:fd580000-fd59ffff memory:fdfe0000-fdfeffff ioport:2080(size=64) memory:fd520000-fd52ffff

We can see many information helping on identification: The network adapter enp2s0 is an Intel type 82545EM with MAC-ID 00:0c:29:94:bb:c3 and current link state link=yes.

3.2. Device Assignment

Run the following command to assign the above device.

sudo hv_addeth enp2s0 rtos_eth1 1

3.3. RTOS Assignment

To assign a specific device to Real-time guests in general, the partitioning script /hv/config/usr_hvpart.sh must be adjusted.

The device assignment scripts <RTOS device name>.sh usually shall be executed automatically on system startup. To accomplish this, you need to add the respective <RTOS device name>.sh calls into the file /hv/config/usr_hvpart.sh. In our tutorial we use rtos_eth1 as the unique <RTOS device name>, as mentioned earlier.

gedit /hv/config/usr_hvpart.sh

The usr_hvpart.sh file should contain at least the following string after editing: source $HV_CONFIG/rtos_eth1.sh $cmd

The example below shows how the device with the unique name rtos_eth1 is assigned.

#!/bin/bash

cmd="add"
[ $1 == "delete" ] && cmd="delete"

# unbind devices (assign to RTOS)
source $HV_CONFIG/rtos_eth1.sh $cmd

Please run the hv_hvpart command with the parameter add or reboot the system to make the change effective.

hv_hvpart add

You may use the delete parameter to assign all RTOS devices back to the Hypervisor Host.

hv_hvpart delete

Hint

The $HV_BIN/hvpart.sh script will be automatically started via the systemd service controlled via /etc/systemd/system/hv_part.service. This script will call the usr_hvpart.sh script which includes user specific partitioning commands. This service can be enabled or disabled as shown below (by default, it is enabled)

sudo systemctl enable /hv/services/hv_part.service
sudo systemctl disable hv_part

3.4. Device Verification

You can verify if the assignment is active by checking if the Hypervisor Host’s original driver is not used in conjunction with the devices assigned to the Real-time guest.

lspci -k

The output will look similar like the following excerpt:

    :         :        :         :        :         :        :         :        :         :
    :         :        :         :        :         :        :         :        :         :
01:00.0 Ethernet controller: Intel Corporation I210 Gigabit Network Connection (rev 03)
        Subsystem: Intel Corporation I210 Gigabit Network Connection
        Kernel driver in use: igb
        Kernel modules: igb
02:00.0 Ethernet controller: Intel Corporation I210 Gigabit Backplane Connection (rev 03)
        Subsystem: Intel Corporation I210 Gigabit Backplane Connection
        Kernel driver in use: pci-stub
        Kernel modules: igb
    :         :        :         :        :         :        :         :        :         :
    :         :        :         :        :         :        :         :        :         :

In the above example, the instance 01:00.0 is used by Ubuntu (driver: igb, e1000e etc.) and the instance 02:00.0 is assigned to a Real-time guest (driver: pci-stub).

3.5. Adjust the configuration

After creating the device configuration file <RTOS device name>.config, it needs to be included into the guest configuration file to become effective for the respective guest. In this tutorial we use rtos_eth1 as the unique <RTOS device name>.

  • RTOS-32 guest:

    gedit /hv/guests/examples/rtos-32/usr.config
    
  • Real-time Linux guest:

    gedit /hv/guests/examples/rt-linux/usr.config
    

Add or uncomment #include "/hv/config/rtos_eth1.config".

The following example shows the ‘modified’ usr.config file:

RtosConfig
;-----------------------------------------------------------------------
; acontis technologies GmbH
;
; Guest user configuration
;-----------------------------------------------------------------------

#include "/hv/config/rtos_eth1.config"

;-----------------------------------------------------------------------
; End of file
;-----------------------------------------------------------------------

3.6. Reboot Hypervisor Host

sudo reboot now