forked from samzapo/SOEM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart_rtnet.sh
executable file
·57 lines (49 loc) · 1.59 KB
/
start_rtnet.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/bash
# To start rtnet, type start_rtnet.sh start.
# To stop rtnet, type start_rtnet.sh stop.
# -------------------------------
# ------- Configuration --------
# Pci address of NIC (ex: 0000:03:00.0)
# Pci address can be checked with lspci
devices="0000:41:00.0"
# default loaded driver on the NIC.
# List of drivers that can be used on the NIC, can be checked with 'lspci -v' command on terminal. (ex: kernel modules : igb, rt_igb)
driver="e1000e"
# RT driver to use with the NIC (usually comes with 'rt_' letters are in front of driver name)
rtdriver="rt_e1000e"
# ------ Configuration End ------
case "$1" in
start)
modprobe rtpacket
dev_num=0
for dev in $devices; do
if [ -d /sys/bus/pci/devices/$dev/driver ]; then
echo $dev unbind $driver
echo -n $dev > /sys/bus/pci/drivers/$driver/unbind
fi
echo $dev bind $rtdriver
echo -n $dev > /sys/bus/pci/drivers/$rtdriver/bind
echo rtifconfig rteth$dev_num up promisc
/usr/xenomai/sbin/rtifconfig rteth$dev_num up promisc
dev_num=$(($dev_num + 1))
done
;;
stop)
rmmod rtpacket
dev_num=0
for dev in $devices; do
/usr/xenomai/sbin/rtifconfig rteth$dev_num down
echo 1 > /sys/bus/pci/devices/$dev/remove
echo removing $dev to $rtdriver
dev_num=$(($dev_num + 1))
done
echo rescan pci devices
echo 1 > /sys/bus/pci/rescan
;;
*)
cat << EOF
Usage:
start stop
EOF
;;
esac