3. Ethernet Device Assigment
Hint
All commands to be executed in the following guide have to be input via the shell. To open the shell right click on the desktop and select ‘Open Terminal here’ or press CRTL + ALT + T.
3.1. Device Identification
In a first step, it is required to determine the Ethernet device that shall be used by the Real-time geust. 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-41-generic 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.1.2. Identify by link-status change
Having identical devices the link status change can be used for identification. First unplug the cable of the desired Ethernet port and then list the current states:
ifconfig -a
enp2s0: flags=4099<UP,BROADCAST,MULTICAST> mtu 1500
ether 00:0c:29:94:bb:c3 txqueuelen 1000 (Ethernet)
RX packets 6063 bytes 705772 (705.7 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 292 bytes 62080 (62.0 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Now you (re-)connect the port (to a live network) and list the states again.
enp2s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.17.10.26 netmask 255.255.0.0 broadcast 172.17.255.255
inet6 fe80::28d1:40ed:dd73:b97a prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:94:bb:c3 txqueuelen 1000 (Ethernet)
RX packets 6125 bytes 717920 (717.9 KB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 350 bytes 71344 (71.3 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Both outputs are similar except the wanted adapter’s <link>
state has changed.
In this example the name of the network adapter is enp2s0
.
The can also be used to identify an adapter by its MAC-ID - in this case 00:0c:29:94:bb:c3
.
3.2. PCIe Device Assignment
In case a PCI Express (PCIe) device is assigned, the method described in this section has to be applied.
The device name identified above must be used as the first parameter of the script ./addeth.sh
.
The second (mandatory) parameter is a unique device name used on the Real-time side.
The third (mandatory) parameter is a unique number (to be increased sequentially) for each assigned device, starting with 1.
cd /hv/config
sudo ./addeth.sh enp2s0 rtos_eth1 1
This creates two files: /hv/config/rtos_eth1.sh
and /hv/config/rtos_eth1.config
.
In case additional network devices shall be assigned:
sudo ./addeth.sh [DETECTED_NAME] rtos_eth2 2
Hint
The RTOS device name is mandatory. This parameter must be a unique name that is used to identify the device.
This name will also be used in filenames
that are created by the addeth.sh
script. In this tutorial the default name used is rtos_eth1
.
Caution
If devices with same name are assigned to the same Rtos the names of the keys in rtos_eth1.sh
, rtos_eth1.config
, etc. must be altered!
3.3. Legacy PCI Device Assignment
In case a Legacy PCI device is assigned, the method described in this section has to be applied (all other information described for PCIe devices are valid, though).
Compared with PCIe devices, a fourth parameter of the addeth.sh
script is required.
sudo ./addeth.sh [DETECTED_NAME] rtos_eth 1 <interrupt type>
Possible values of <interrupt type>
are legacy or no_interrupt. If this parameter is not provided, the default MSI interrupt
is used which is not feasible for Legacy PCI devices.
3.4. Adjust the main Real-time guest configuration files
After creating the device configuration file <RTOS device name>.config
, it needs to be included in the main configuration file.
In this tutorial we use rtos_eth1
as the unique <RTOS device name>
.
Please adjust the RTOS-32 configuration file as well because we will use the RTOS-32 guest for device assignment verification later.
RTOS-32 guest:
cd /hv/rtos-32 gedit ./rtos-32demo.config
Real-time Linux guest:
cd /hv/lx gedit ./hv.config
Add the corresponding rtos_eth1.config
entry to the includes
section of the file.
The following example shows the ‘modified’ hv
.config
file:
;-----------------------------------------------------------------------
; includes
;-----------------------------------------------------------------------
#include "../config/membase.config"
#include "../config/memory.config"
#include "../config/cpu.config"
#include "../config/hwbase.config"
#include "../config/hwdevbase.config"
;#include "../config/hwdevbase_rtos2.config"
#include "../config/vmf.config"
;#include "../config/debug.config"
#include "../config/windowsvm.config"
#include "../config/rtos_eth1.config"
;#include "../config/pcidev1.config"
;#include "../config/pcidev2.config"
#include "linux.config"
3.5. Adjust the hypervisor partitioning script /hv/config/hvpart.sh
The device assignment scripts <RTOS device name>.sh
usually shall be executed automatically on system startup.
To accomplish this, add the respective <RTOS device name>.sh
calls into the file /hv/config/hvpart.sh
.
In our tutorial we use rtos_eth1
as the unique <RTOS device name>
, as mentioned earlier.
gedit /hv/config/hvpart.sh
The hvpart.sh
file should contain at least the following string after editing: source $scriptDir/rtos_eth1.sh add
The example below shows, how the device with the unique name rtos_eth1
is assigned.
#!/bin/bash
source /hv/config/rtos_eth1.sh add
Please reboot the system to make the change effective.
sudo reboot
Hint
The hvpart.sh
script will be automatically started via the systemd service controlled via /etc/systemd/system/hv_part.service
.
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.6. Device verification
3.6.1. Xubuntu de-assignment check
In a first step, check if the Xubuntu 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
03: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 instances 02:00.0
and 03:00.0
are assigned to a Real-time guest (driver: pci-stub).
3.6.2. Real-time guest assignment check
With the RTOS-32Demo
it’s possible to verify, if the assigned netwok adapter is visible to the rtos part:
cd /hv/rtos-32
sudo ./rtos-32demo.sh
The output will looks like this for the used network adapter (8086:1533) in this tutorial:
PCI BIOS Information
Vendor Device Bus Dev Func Class Int IRQ TLat MSI Type
-------------------------------------------------------
FFFE FFFE 0 0 0 000000 - 0 0 - Invalid class code
FFFE FFFE 0 2 0 000000 - 0 0 - Invalid class code
FFFE FFFE 0 20 0 000000 - 0 0 - Invalid class code
FFFE FFFE 0 22 0 000000 - 0 0 - Invalid class code
FFFE FFFE 0 26 0 000000 - 0 0 - Invalid class code
FFFE FFFE 0 27 0 000000 - 0 0 - Invalid class code
FFFE FFFE 0 28 0 000000 - 0 0 - Invalid class code
FFFE FFFE 0 29 0 000000 - 0 0 - Invalid class code
FFFE FFFE 0 30 0 000000 - 0 0 - Invalid class code
FFFE FFFE 0 31 0 000000 - 0 0 - Invalid class code
8086 1533 1 0 0 020000 A 5 0 X Network controller
FFFE FFFE 2 0 0 000000 - 0 0 - Invalid class code
10EC 8169 3 5 0 020000 A 4 64 - Network controller
Current Date/time: 01/01/2018 00:00:00
Current Date/time: 01/01/2018 00:00:01
Current Date/time: 01/01/2018 00:00:02
Current Date/time: 01/01/2018 00:00:03
Current Date/time: 01/01/2018 00:00:04
List of threads:
Name Prio State R.Del FStck MStck Scheds CTime CT%
---------------------------------------------------------------------
Main Task 5 Current 63060 61276 11 - -
Idle Task 0 Ready 2164 2164 526 - -
Comm 5 Delaying 1 32832 31724 527 - -
IPTASK 6 BlckdWait 4128 3940 2 - -
IPTIMER 6 Delaying 11 4120 3940 44 - -
Interrupts:
IRQ Calls FreeStack Doubles Time
-------------------------------------------
0 526 744 0 -
Network:
Ping will respond at IP address 192.168.157.2
In the above example, one 8086:1533 device at BDF 1,0,0 is assigned to the Real-time guest.
Finally, terminate the console connection to the real-time guest and stop the Real-time guest OS:
CTRL + C
cd /hv/rtos-32
sudo ./stopall.sh