All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Allow RTNet to be builtin kernel
@ 2019-10-02 13:45 François Legal
  2019-10-02 15:30 ` Jan Kiszka
  0 siblings, 1 reply; 17+ messages in thread
From: François Legal @ 2019-10-02 13:45 UTC (permalink / raw)
  To: xenomai

From: François LEGAL <devel@thom.fr.eu.org>

Signed-off-by: François LEGAL <devel@thom.fr.eu.org>

Subject: [PATCH] Allow RTNet to be builtin kernel

Makefile is changed because when builtin, the modules
get loaded in the link order. In the previous version
protocols would get loaded before stackmgr which
obviously fails.

This has been tested on Zynq 7000 Hardware (microzed
board) with MACB/GEM RTNet driver, with linux 4.4.189
vanilla. Kernel boots up correctly, and the following
messages get printed on the console during the boot :

[   13.875451] sdhci-pltfm: SDHCI platform and OF driver helper
[   13.881627] sdhci-arasan e0100000.sdhci: No vmmc regulator found
[   13.887581] sdhci-arasan e0100000.sdhci: No vqmmc regulator found
[   13.927585] mmc0: SDHCI controller on e0100000.sdhci [e0100000.sdhci] using ADMA
[   13.945085] fpga_manager fpga0: Xilinx Zynq FPGA Manager registered
[   13.951896]
[   13.951896] *** RTnet for Xenomai v3.0.9 ***
[   13.951896]
[   13.959156] RTnet: initialising real-time networking
[   13.964928] RTmac/TDMA: init time division multiple access control mechanism
[   13.972074] RTmac: init realtime media access control
[   13.977064] RTcfg: init real-time configuration distribution protocol
[   13.983752] initializing loopback...
[   13.987295] RTnet: registered rtlo
[   13.993238] RTnet: registered rteth0
[   13.996832] libphy: MACB_mii_bus: probed
[   14.001140] rt_macb: rteth0: Cadence GEM at 0xe000b000 irq 26 (00:0a:35:00:01:22)
[   14.008630] rt_macb: rteth0: attached PHY driver [Marvell 88E1510] (mii_bus:phy_addr=e000b000.ethernet-ffffffff:00, irq=-1)
[   14.019845] RTcap: real-time capturing interface
[   14.026562] RTproxy attached to rteth0
[   14.031129] rtnetproxy installed as "rtproxy"
[   14.035693] NET: Registered protocol family 26
[   14.040309] NET: Registered protocol family 17
[   14.044686] can: controller area network core (rev 20120528 abi 9)
[   14.050957] NET: Registered protocol family 29
[   14.055329] can: raw protocol (rev 20120528)
[   14.059683] can: broadcast manager protocol (rev 20120528 t)

---
 kernel/drivers/net/Kconfig        |   1 -
 kernel/drivers/net/addons/Kconfig |   4 +-
 kernel/drivers/net/stack/Makefile |  16 ++---
 utils/net/rtnet.in                | 148 +++++++++++++++++++++++---------------
 4 files changed, 101 insertions(+), 68 deletions(-)

diff --git a/kernel/drivers/net/Kconfig b/kernel/drivers/net/Kconfig
index ac3bced..49d2402 100644
--- a/kernel/drivers/net/Kconfig
+++ b/kernel/drivers/net/Kconfig
@@ -1,7 +1,6 @@
 menu "RTnet"

 config XENO_DRIVERS_NET
-    depends on m
     select NET
     tristate "RTnet, TCP/IP socket interface"

diff --git a/kernel/drivers/net/addons/Kconfig b/kernel/drivers/net/addons/Kconfig
index baa6cbc..616ed40 100644
--- a/kernel/drivers/net/addons/Kconfig
+++ b/kernel/drivers/net/addons/Kconfig
@@ -2,7 +2,7 @@ menu "Add-Ons"
     depends on XENO_DRIVERS_NET

 config XENO_DRIVERS_NET_ADDON_RTCAP
-    depends on XENO_DRIVERS_NET && m
+    depends on XENO_DRIVERS_NET
     select ETHERNET
     tristate "Real-Time Capturing Support"
     default n
@@ -18,7 +18,7 @@ config XENO_DRIVERS_NET_ADDON_RTCAP
     For further information see Documentation/README.rtcap.

 config XENO_DRIVERS_NET_ADDON_PROXY
-    depends on XENO_DRIVERS_NET_RTIPV4 && m
+    depends on XENO_DRIVERS_NET_RTIPV4
     select ETHERNET
     tristate "IP protocol proxy for Linux"
     default n
diff --git a/kernel/drivers/net/stack/Makefile b/kernel/drivers/net/stack/Makefile
index d055dc2..f8db6fa 100644
--- a/kernel/drivers/net/stack/Makefile
+++ b/kernel/drivers/net/stack/Makefile
@@ -1,13 +1,5 @@
 ccflags-y += -Idrivers/xenomai/net/stack/include -Ikernel/

-obj-$(CONFIG_XENO_DRIVERS_NET_RTIPV4) += ipv4/
-
-obj-$(CONFIG_XENO_DRIVERS_NET_RTPACKET) += packet/
-
-obj-$(CONFIG_XENO_DRIVERS_NET_RTMAC) += rtmac/
-
-obj-$(CONFIG_XENO_DRIVERS_NET_RTCFG) += rtcfg/
-
 obj-$(CONFIG_XENO_DRIVERS_NET) += rtnet.o

 rtnet-y :=  \
@@ -23,4 +15,12 @@ rtnet-y :=  \
 	stack_mgr.o \
 	eth.o

+obj-$(CONFIG_XENO_DRIVERS_NET_RTIPV4) += ipv4/
+
+obj-$(CONFIG_XENO_DRIVERS_NET_RTPACKET) += packet/
+
+obj-$(CONFIG_XENO_DRIVERS_NET_RTMAC) += rtmac/
+
+obj-$(CONFIG_XENO_DRIVERS_NET_RTCFG) += rtcfg/
+
 rtnet-$(CONFIG_XENO_DRIVERS_NET_RTWLAN) += rtwlan.o
diff --git a/utils/net/rtnet.in b/utils/net/rtnet.in
index f81a7bb..3c3cab9 100644
--- a/utils/net/rtnet.in
+++ b/utils/net/rtnet.in
@@ -31,44 +31,62 @@ EOF
 }

 init_rtnet() {
-    modprobe rtnet >/dev/null || exit 1
-    modprobe rtipv4 >/dev/null || exit 1
-    modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
+    if [ ! -d /proc/rtnet ]; then
+        modprobe rtnet >/dev/null || exit 1
+    fi

-    for dev in $REBIND_RT_NICS; do
-	if [ -d /sys/bus/pci/devices/$dev/driver ]; then
-	    echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
-	fi
-	echo $dev > /sys/bus/pci/drivers/$RT_DRIVER/bind
-    done
+    if [ ! -d /proc/rtnet/ipv4 ]; then
+        modprobe rtipv4 >/dev/null || exit 1
+        for PROTOCOL in $RT_PROTOCOLS; do
+            modprobe rt$PROTOCOL >/dev/null || exit 1
+        done
+    fi

-    for PROTOCOL in $RT_PROTOCOLS; do
-	modprobe rt$PROTOCOL >/dev/null || exit 1
-    done
+    $(cat /proc/rtnet/devices | grep -q rteth0)
+    if [ $? -eq 1 ]; then
+        modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
+
+        for dev in $REBIND_RT_NICS; do
+            if [ -d /sys/bus/pci/devices/$dev/driver ]; then
+                echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
+            fi
+            echo $dev > /sys/bus/pci/drivers/$RT_DRIVER/bind
+        done
+    fi

     if [ $RT_LOOPBACK = "yes" ]; then
-	modprobe rt_loopback >/dev/null || exit 1
+        $(cat /proc/rtnet/devices | grep -q rtlo)
+        if [ $? -eq 1 ]; then
+
+            modprobe rt_loopback >/dev/null || exit 1
+        fi
     fi

-    if [ $RTCAP = "yes" ]; then
-	modprobe rtcap >/dev/null || exit 1
+    if [ $RTCAP = "yes" -a ! -d /sys/modules/rtcap ]; then
+        modprobe rtcap >/dev/null || exit 1
     fi

     if [ $RT_LOOPBACK = "yes" ]; then
-	$RTIFCONFIG rtlo up 127.0.0.1
+        $RTIFCONFIG rtlo up 127.0.0.1
     fi

     if [ $RTCAP = "yes" ]; then
-	ifconfig rteth0 up
-	ifconfig rteth0-mac up
-	if [ $RT_LOOPBACK = "yes" ]; then
-	    ifconfig rtlo up
-	fi
+        ifconfig rteth0 up
+        ifconfig rteth0-mac up
+        if [ $RT_LOOPBACK = "yes" ]; then
+            ifconfig rtlo up
+        fi
     fi

-    modprobe rtcfg >/dev/null
-    modprobe rtmac >/dev/null
-    modprobe tdma >/dev/null
+    if [ ! -d /proc/rtnet/rtcfg ]; then
+        modprobe rtcfg >/dev/null
+    fi
+    if [ ! -d /proc/rtnet/rtmac ]; then
+        modprobe rtmac >/dev/null
+    fi
+    if [ ! -f /proc/tdma ]; then
+        modprobe tdma >/dev/null
+    fi
 }

 submit_cfg() {
@@ -329,43 +347,59 @@ case "$1" in
 	;;

     master)
-	shift
-	init_rtnet
-	TDMA_SLAVES=$*
-	start_master
-	;;
+        shift
+        init_rtnet
+        TDMA_SLAVES=$*
+        start_master
+        ;;

     capture)
-	modprobe rtnet >/dev/null || exit 1
-	modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
-	modprobe rtcap >/dev/null || exit 1
-	$RTIFCONFIG rteth0 up promisc
-	ifconfig rteth0 up
-	ifconfig rteth0-mac up
-	;;
+        if [ ! -d /proc/rtnet ]; then
+            modprobe rtnet >/dev/null || exit 1
+        fi
+        $(cat /proc/rtnet/devices | grep -q rteth0)
+        if [ $? -eq 1 ]; then
+            modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
+        fi
+        if [ ! -d /sys/modules/rtcap ]; then
+            modprobe rtcap >/dev/null || exit 1
+        fi
+        $RTIFCONFIG rteth0 up promisc
+        ifconfig rteth0 up
+        ifconfig rteth0-mac up
+        ;;

     loopback)
-	modprobe rtnet >/dev/null || exit 1
-	modprobe rtipv4 >/dev/null || exit 1
-
-	for PROTOCOL in $RT_PROTOCOLS; do
-	    modprobe rt$PROTOCOL >/dev/null || exit 1
-	done
-
-	modprobe rt_loopback >/dev/null || exit 1
-
-	if [ $RTCAP = "yes" ]; then
-	    modprobe rtcap >/dev/null || exit 1
-	fi
-
-	$RTIFCONFIG rtlo up 127.0.0.1
-
-	if [ $RTCAP = "yes" ]; then
-	    ifconfig rtlo up
-	fi
-	;;
+        if [ ! -d /proc/rtnet ]; then
+            modprobe rtnet >/dev/null || exit 1
+        fi
+        if [ ! -d /proc/rtnet/ipv4 ]; then
+            modprobe rtipv4 >/dev/null || exit 1
+            for PROTOCOL in $RT_PROTOCOLS; do
+                modprobe rt$PROTOCOL >/dev/null || exit 1
+            done
+        fi
+
+        if [ $RT_LOOPBACK = "yes" ]; then
+            $(cat /proc/rtnet/devices | grep -q rtlo)
+            if [ $? -eq 1 ]; then
+
+                modprobe rt_loopback >/dev/null || exit 1
+            fi
+        fi
+
+        if [ $RTCAP = "yes" -a ! -d /sys/modules/rtcap ]; then
+            modprobe rtcap >/dev/null || exit 1
+        fi
+
+        $RTIFCONFIG rtlo up 127.0.0.1
+
+        if [ $RTCAP = "yes" ]; then
+            ifconfig rtlo up
+        fi
+        ;;

     *)
-	usage
-	exit 1
+        usage
+        exit 1
 esac
--
2.1.4



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH] Allow RTNet to be builtin kernel
  2019-10-02 13:45 [PATCH] Allow RTNet to be builtin kernel François Legal
@ 2019-10-02 15:30 ` Jan Kiszka
  0 siblings, 0 replies; 17+ messages in thread
From: Jan Kiszka @ 2019-10-02 15:30 UTC (permalink / raw)
  To: François Legal, xenomai

On 02.10.19 15:45, François Legal via Xenomai wrote:
> From: François LEGAL <devel@thom.fr.eu.org>
> 
> Signed-off-by: François LEGAL <devel@thom.fr.eu.org>
> 
> Subject: [PATCH] Allow RTNet to be builtin kernel
> 

Proper ordering is

- one subject (first line of your commit message)
- optionally a "From:", specifically when your provider rewrites the
   sender address
- commit message body
- signed-off
- separator ("---")
- optionally some message that should not be in git afterwards, e.g. a
   changelog of what you edited in this revision of the patch. I don't
   see all of my comments addressed in code. So you should at least tell
   us why you didn't change something.
- the diff

Jan

> Makefile is changed because when builtin, the modules
> get loaded in the link order. In the previous version
> protocols would get loaded before stackmgr which
> obviously fails.
> 
> This has been tested on Zynq 7000 Hardware (microzed
> board) with MACB/GEM RTNet driver, with linux 4.4.189
> vanilla. Kernel boots up correctly, and the following
> messages get printed on the console during the boot :
> 
> [   13.875451] sdhci-pltfm: SDHCI platform and OF driver helper
> [   13.881627] sdhci-arasan e0100000.sdhci: No vmmc regulator found
> [   13.887581] sdhci-arasan e0100000.sdhci: No vqmmc regulator found
> [   13.927585] mmc0: SDHCI controller on e0100000.sdhci [e0100000.sdhci] using ADMA
> [   13.945085] fpga_manager fpga0: Xilinx Zynq FPGA Manager registered
> [   13.951896]
> [   13.951896] *** RTnet for Xenomai v3.0.9 ***
> [   13.951896]
> [   13.959156] RTnet: initialising real-time networking
> [   13.964928] RTmac/TDMA: init time division multiple access control mechanism
> [   13.972074] RTmac: init realtime media access control
> [   13.977064] RTcfg: init real-time configuration distribution protocol
> [   13.983752] initializing loopback...
> [   13.987295] RTnet: registered rtlo
> [   13.993238] RTnet: registered rteth0
> [   13.996832] libphy: MACB_mii_bus: probed
> [   14.001140] rt_macb: rteth0: Cadence GEM at 0xe000b000 irq 26 (00:0a:35:00:01:22)
> [   14.008630] rt_macb: rteth0: attached PHY driver [Marvell 88E1510] (mii_bus:phy_addr=e000b000.ethernet-ffffffff:00, irq=-1)
> [   14.019845] RTcap: real-time capturing interface
> [   14.026562] RTproxy attached to rteth0
> [   14.031129] rtnetproxy installed as "rtproxy"
> [   14.035693] NET: Registered protocol family 26
> [   14.040309] NET: Registered protocol family 17
> [   14.044686] can: controller area network core (rev 20120528 abi 9)
> [   14.050957] NET: Registered protocol family 29
> [   14.055329] can: raw protocol (rev 20120528)
> [   14.059683] can: broadcast manager protocol (rev 20120528 t)
> 
> ---
>   kernel/drivers/net/Kconfig        |   1 -
>   kernel/drivers/net/addons/Kconfig |   4 +-
>   kernel/drivers/net/stack/Makefile |  16 ++---
>   utils/net/rtnet.in                | 148 +++++++++++++++++++++++---------------
>   4 files changed, 101 insertions(+), 68 deletions(-)
> 
> diff --git a/kernel/drivers/net/Kconfig b/kernel/drivers/net/Kconfig
> index ac3bced..49d2402 100644
> --- a/kernel/drivers/net/Kconfig
> +++ b/kernel/drivers/net/Kconfig
> @@ -1,7 +1,6 @@
>   menu "RTnet"
>   
>   config XENO_DRIVERS_NET
> -    depends on m
>       select NET
>       tristate "RTnet, TCP/IP socket interface"
>   
> diff --git a/kernel/drivers/net/addons/Kconfig b/kernel/drivers/net/addons/Kconfig
> index baa6cbc..616ed40 100644
> --- a/kernel/drivers/net/addons/Kconfig
> +++ b/kernel/drivers/net/addons/Kconfig
> @@ -2,7 +2,7 @@ menu "Add-Ons"
>       depends on XENO_DRIVERS_NET
>   
>   config XENO_DRIVERS_NET_ADDON_RTCAP
> -    depends on XENO_DRIVERS_NET && m
> +    depends on XENO_DRIVERS_NET
>       select ETHERNET
>       tristate "Real-Time Capturing Support"
>       default n
> @@ -18,7 +18,7 @@ config XENO_DRIVERS_NET_ADDON_RTCAP
>       For further information see Documentation/README.rtcap.
>   
>   config XENO_DRIVERS_NET_ADDON_PROXY
> -    depends on XENO_DRIVERS_NET_RTIPV4 && m
> +    depends on XENO_DRIVERS_NET_RTIPV4
>       select ETHERNET
>       tristate "IP protocol proxy for Linux"
>       default n
> diff --git a/kernel/drivers/net/stack/Makefile b/kernel/drivers/net/stack/Makefile
> index d055dc2..f8db6fa 100644
> --- a/kernel/drivers/net/stack/Makefile
> +++ b/kernel/drivers/net/stack/Makefile
> @@ -1,13 +1,5 @@
>   ccflags-y += -Idrivers/xenomai/net/stack/include -Ikernel/
>   
> -obj-$(CONFIG_XENO_DRIVERS_NET_RTIPV4) += ipv4/
> -
> -obj-$(CONFIG_XENO_DRIVERS_NET_RTPACKET) += packet/
> -
> -obj-$(CONFIG_XENO_DRIVERS_NET_RTMAC) += rtmac/
> -
> -obj-$(CONFIG_XENO_DRIVERS_NET_RTCFG) += rtcfg/
> -
>   obj-$(CONFIG_XENO_DRIVERS_NET) += rtnet.o
>   
>   rtnet-y :=  \
> @@ -23,4 +15,12 @@ rtnet-y :=  \
>   	stack_mgr.o \
>   	eth.o
>   
> +obj-$(CONFIG_XENO_DRIVERS_NET_RTIPV4) += ipv4/
> +
> +obj-$(CONFIG_XENO_DRIVERS_NET_RTPACKET) += packet/
> +
> +obj-$(CONFIG_XENO_DRIVERS_NET_RTMAC) += rtmac/
> +
> +obj-$(CONFIG_XENO_DRIVERS_NET_RTCFG) += rtcfg/
> +
>   rtnet-$(CONFIG_XENO_DRIVERS_NET_RTWLAN) += rtwlan.o
> diff --git a/utils/net/rtnet.in b/utils/net/rtnet.in
> index f81a7bb..3c3cab9 100644
> --- a/utils/net/rtnet.in
> +++ b/utils/net/rtnet.in
> @@ -31,44 +31,62 @@ EOF
>   }
>   
>   init_rtnet() {
> -    modprobe rtnet >/dev/null || exit 1
> -    modprobe rtipv4 >/dev/null || exit 1
> -    modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
> +    if [ ! -d /proc/rtnet ]; then
> +        modprobe rtnet >/dev/null || exit 1
> +    fi
>   
> -    for dev in $REBIND_RT_NICS; do
> -	if [ -d /sys/bus/pci/devices/$dev/driver ]; then
> -	    echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
> -	fi
> -	echo $dev > /sys/bus/pci/drivers/$RT_DRIVER/bind
> -    done
> +    if [ ! -d /proc/rtnet/ipv4 ]; then
> +        modprobe rtipv4 >/dev/null || exit 1
> +        for PROTOCOL in $RT_PROTOCOLS; do
> +            modprobe rt$PROTOCOL >/dev/null || exit 1
> +        done
> +    fi
>   
> -    for PROTOCOL in $RT_PROTOCOLS; do
> -	modprobe rt$PROTOCOL >/dev/null || exit 1
> -    done
> +    $(cat /proc/rtnet/devices | grep -q rteth0)
> +    if [ $? -eq 1 ]; then
> +        modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
> +
> +        for dev in $REBIND_RT_NICS; do
> +            if [ -d /sys/bus/pci/devices/$dev/driver ]; then
> +                echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
> +            fi
> +            echo $dev > /sys/bus/pci/drivers/$RT_DRIVER/bind
> +        done
> +    fi
>   
>       if [ $RT_LOOPBACK = "yes" ]; then
> -	modprobe rt_loopback >/dev/null || exit 1
> +        $(cat /proc/rtnet/devices | grep -q rtlo)
> +        if [ $? -eq 1 ]; then
> +
> +            modprobe rt_loopback >/dev/null || exit 1
> +        fi
>       fi
>   
> -    if [ $RTCAP = "yes" ]; then
> -	modprobe rtcap >/dev/null || exit 1
> +    if [ $RTCAP = "yes" -a ! -d /sys/modules/rtcap ]; then
> +        modprobe rtcap >/dev/null || exit 1
>       fi
>   
>       if [ $RT_LOOPBACK = "yes" ]; then
> -	$RTIFCONFIG rtlo up 127.0.0.1
> +        $RTIFCONFIG rtlo up 127.0.0.1
>       fi
>   
>       if [ $RTCAP = "yes" ]; then
> -	ifconfig rteth0 up
> -	ifconfig rteth0-mac up
> -	if [ $RT_LOOPBACK = "yes" ]; then
> -	    ifconfig rtlo up
> -	fi
> +        ifconfig rteth0 up
> +        ifconfig rteth0-mac up
> +        if [ $RT_LOOPBACK = "yes" ]; then
> +            ifconfig rtlo up
> +        fi
>       fi
>   
> -    modprobe rtcfg >/dev/null
> -    modprobe rtmac >/dev/null
> -    modprobe tdma >/dev/null
> +    if [ ! -d /proc/rtnet/rtcfg ]; then
> +        modprobe rtcfg >/dev/null
> +    fi
> +    if [ ! -d /proc/rtnet/rtmac ]; then
> +        modprobe rtmac >/dev/null
> +    fi
> +    if [ ! -f /proc/tdma ]; then
> +        modprobe tdma >/dev/null
> +    fi
>   }
>   
>   submit_cfg() {
> @@ -329,43 +347,59 @@ case "$1" in
>   	;;
>   
>       master)
> -	shift
> -	init_rtnet
> -	TDMA_SLAVES=$*
> -	start_master
> -	;;
> +        shift
> +        init_rtnet
> +        TDMA_SLAVES=$*
> +        start_master
> +        ;;
>   
>       capture)
> -	modprobe rtnet >/dev/null || exit 1
> -	modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
> -	modprobe rtcap >/dev/null || exit 1
> -	$RTIFCONFIG rteth0 up promisc
> -	ifconfig rteth0 up
> -	ifconfig rteth0-mac up
> -	;;
> +        if [ ! -d /proc/rtnet ]; then
> +            modprobe rtnet >/dev/null || exit 1
> +        fi
> +        $(cat /proc/rtnet/devices | grep -q rteth0)
> +        if [ $? -eq 1 ]; then
> +            modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
> +        fi
> +        if [ ! -d /sys/modules/rtcap ]; then
> +            modprobe rtcap >/dev/null || exit 1
> +        fi
> +        $RTIFCONFIG rteth0 up promisc
> +        ifconfig rteth0 up
> +        ifconfig rteth0-mac up
> +        ;;
>   
>       loopback)
> -	modprobe rtnet >/dev/null || exit 1
> -	modprobe rtipv4 >/dev/null || exit 1
> -
> -	for PROTOCOL in $RT_PROTOCOLS; do
> -	    modprobe rt$PROTOCOL >/dev/null || exit 1
> -	done
> -
> -	modprobe rt_loopback >/dev/null || exit 1
> -
> -	if [ $RTCAP = "yes" ]; then
> -	    modprobe rtcap >/dev/null || exit 1
> -	fi
> -
> -	$RTIFCONFIG rtlo up 127.0.0.1
> -
> -	if [ $RTCAP = "yes" ]; then
> -	    ifconfig rtlo up
> -	fi
> -	;;
> +        if [ ! -d /proc/rtnet ]; then
> +            modprobe rtnet >/dev/null || exit 1
> +        fi
> +        if [ ! -d /proc/rtnet/ipv4 ]; then
> +            modprobe rtipv4 >/dev/null || exit 1
> +            for PROTOCOL in $RT_PROTOCOLS; do
> +                modprobe rt$PROTOCOL >/dev/null || exit 1
> +            done
> +        fi
> +
> +        if [ $RT_LOOPBACK = "yes" ]; then
> +            $(cat /proc/rtnet/devices | grep -q rtlo)
> +            if [ $? -eq 1 ]; then
> +
> +                modprobe rt_loopback >/dev/null || exit 1
> +            fi
> +        fi
> +
> +        if [ $RTCAP = "yes" -a ! -d /sys/modules/rtcap ]; then
> +            modprobe rtcap >/dev/null || exit 1
> +        fi
> +
> +        $RTIFCONFIG rtlo up 127.0.0.1
> +
> +        if [ $RTCAP = "yes" ]; then
> +            ifconfig rtlo up
> +        fi
> +        ;;
>   
>       *)
> -	usage
> -	exit 1
> +        usage
> +        exit 1
>   esac
> 

-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux


^ permalink raw reply	[flat|nested] 17+ messages in thread

* RE: [PATCH] Allow RTNet to be builtin kernel
       [not found]           ` <c6b47e60-642a-7779-7639-2ff4a62c805d@siemens.com>
@ 2019-10-09 14:25             ` Lange Norbert
  0 siblings, 0 replies; 17+ messages in thread
From: Lange Norbert @ 2019-10-09 14:25 UTC (permalink / raw)
  To: Jan Kiszka, François Legal, Xenomai (xenomai@xenomai.org)

> -----Original Message-----
> From: Jan Kiszka <jan.kiszka@siemens.com>
> Sent: Mittwoch, 9. Oktober 2019 13:00
> To: Lange Norbert <norbert.lange@andritz.com>; François Legal
> <devel@thom.fr.eu.org>
> Subject: Re: [PATCH] Allow RTNet to be builtin kernel
>
> NON-ANDRITZ SOURCE: BE CAUTIOUS WITH CONTENT, LINKS OR
> ATTACHMENTS.
>
>
> On 09.10.19 12:49, Lange Norbert wrote:
> >
> >
> >> -----Original Message-----
> >> From: Xenomai <xenomai-bounces@xenomai.org> On Behalf Of Jan
> Kiszka
> >> via Xenomai
> >> Sent: Freitag, 4. Oktober 2019 16:31
> >> To: François Legal <devel@thom.fr.eu.org>
> >> Cc: Xenomai <xenomai@xenomai.org>
> >> Subject: Re: [PATCH] Allow RTNet to be builtin kernel
> >>
> >> NON-ANDRITZ SOURCE: BE CAUTIOUS WITH CONTENT, LINKS OR
> ATTACHMENTS.
> >>
> >>
> >> On 04.10.19 16:22, François Legal wrote:
> >>> Le Vendredi, Octobre 04, 2019 15:36 CEST, Jan Kiszka
> >> <jan.kiszka@siemens.com> a écrit:
> >>>
> >>>> On 04.10.19 13:10, Jan Kiszka wrote:
> >>>>> On 03.10.19 10:10, François Legal via Xenomai wrote:
> >>>>>> Subject: [PATCH] Allow RTNet to be builtin kernel
> >>>>>>
> >>>>>> Makefile is changed because when builtin, the modules get loaded
> in
> >>>>>> the link order. In the previous version protocols would get loaded
> >>>>>> before stackmgr which obviously fails.
> >>>>>>
> >>>>>> Signed-off-by: François LEGAL <devel@thom.fr.eu.org>
> >>>>>>
> >>>>>> ---
> >>>>>>
> >>>>>> This has been tested on Zynq 7000 Hardware (microzed
> >>>>>> board) with MACB/GEM RTNet driver, with linux 4.4.189 vanilla.
> >>>>>> Kernel boots up correctly, and the following messages get printed
> >>>>>> on the console during the boot :
> >>>>>>
> >>>>>> [   13.875451] sdhci-pltfm: SDHCI platform and OF driver helper
> >>>>>> [   13.881627] sdhci-arasan e0100000.sdhci: No vmmc regulator found
> >>>>>> [   13.887581] sdhci-arasan e0100000.sdhci: No vqmmc regulator
> found
> >>>>>> [   13.927585] mmc0: SDHCI controller on e0100000.sdhci
> >> [e0100000.sdhci] using ADMA
> >>>>>> [   13.945085] fpga_manager fpga0: Xilinx Zynq FPGA Manager
> >> registered
> >>>>>> [   13.951896]
> >>>>>> [   13.951896] *** RTnet for Xenomai v3.0.9 ***
> >>>>>> [   13.951896]
> >>>>>> [   13.959156] RTnet: initialising real-time networking
> >>>>>> [   13.964928] RTmac/TDMA: init time division multiple access control
> >> mechanism
> >>>>>> [   13.972074] RTmac: init realtime media access control
> >>>>>> [   13.977064] RTcfg: init real-time configuration distribution protocol
> >>>>>> [   13.983752] initializing loopback...
> >>>>>> [   13.987295] RTnet: registered rtlo
> >>>>>> [   13.993238] RTnet: registered rteth0
> >>>>>> [   13.996832] libphy: MACB_mii_bus: probed
> >>>>>> [   14.001140] rt_macb: rteth0: Cadence GEM at 0xe000b000 irq 26
> >> (00:0a:35:00:01:22)
> >>>>>> [   14.008630] rt_macb: rteth0: attached PHY driver [Marvell 88E1510]
> >> (mii_bus:phy_addr=e000b000.ethernet-ffffffff:00, irq=-1)
> >>>>>> [   14.019845] RTcap: real-time capturing interface
> >>>>>> [   14.026562] RTproxy attached to rteth0
> >>>>>> [   14.031129] rtnetproxy installed as "rtproxy"
> >>>>>> [   14.035693] NET: Registered protocol family 26
> >>>>>> [   14.040309] NET: Registered protocol family 17
> >>>>>> [   14.044686] can: controller area network core (rev 20120528 abi 9)
> >>>>>> [   14.050957] NET: Registered protocol family 29
> >>>>>> [   14.055329] can: raw protocol (rev 20120528)
> >>>>>> [   14.059683] can: broadcast manager protocol (rev 20120528 t)
> >>>>>>
> >>>>>>     kernel/drivers/net/Kconfig        |  1 -
> >>>>>>     kernel/drivers/net/addons/Kconfig |  4 ++--
> >>>>>>     kernel/drivers/net/stack/Makefile | 16 ++++++++--------
> >>>>>>     utils/net/rtnet.in | 144
> >> +++++++++++++++++++++++++++++++++++------------------
> >>>>>>     4 files changed, 105 insertions(+), 60 deletions(-)
> >>>>>>
> >>>>>> diff --git a/kernel/drivers/net/Kconfig
> >>>>>> b/kernel/drivers/net/Kconfig index ac3bced..49d2402 100644
> >>>>>> --- a/kernel/drivers/net/Kconfig
> >>>>>> +++ b/kernel/drivers/net/Kconfig
> >>>>>> @@ -1,7 +1,6 @@
> >>>>>>     menu "RTnet"
> >>>>>>
> >>>>>>     config XENO_DRIVERS_NET
> >>>>>> -    depends on m
> >>>>>>         select NET
> >>>>>>         tristate "RTnet, TCP/IP socket interface"
> >>>>>>
> >>>>>> diff --git a/kernel/drivers/net/addons/Kconfig
> >>>>>> b/kernel/drivers/net/addons/Kconfig
> >>>>>> index baa6cbc..616ed40 100644
> >>>>>> --- a/kernel/drivers/net/addons/Kconfig
> >>>>>> +++ b/kernel/drivers/net/addons/Kconfig
> >>>>>> @@ -2,7 +2,7 @@ menu "Add-Ons"
> >>>>>>         depends on XENO_DRIVERS_NET
> >>>>>>
> >>>>>>     config XENO_DRIVERS_NET_ADDON_RTCAP
> >>>>>> -    depends on XENO_DRIVERS_NET && m
> >>>>>> +    depends on XENO_DRIVERS_NET
> >>>>>>         select ETHERNET
> >>>>>>         tristate "Real-Time Capturing Support"
> >>>>>>         default n
> >>>>>> @@ -18,7 +18,7 @@ config XENO_DRIVERS_NET_ADDON_RTCAP
> >>>>>>         For further information see Documentation/README.rtcap.
> >>>>>>
> >>>>>>     config XENO_DRIVERS_NET_ADDON_PROXY
> >>>>>> -    depends on XENO_DRIVERS_NET_RTIPV4 && m
> >>>>>> +    depends on XENO_DRIVERS_NET_RTIPV4
> >>>>>>         select ETHERNET
> >>>>>>         tristate "IP protocol proxy for Linux"
> >>>>>>         default n
> >>>>>> diff --git a/kernel/drivers/net/stack/Makefile
> >>>>>> b/kernel/drivers/net/stack/Makefile
> >>>>>> index d055dc2..f8db6fa 100644
> >>>>>> --- a/kernel/drivers/net/stack/Makefile
> >>>>>> +++ b/kernel/drivers/net/stack/Makefile
> >>>>>> @@ -1,13 +1,5 @@
> >>>>>>     ccflags-y += -Idrivers/xenomai/net/stack/include -Ikernel/
> >>>>>>
> >>>>>> -obj-$(CONFIG_XENO_DRIVERS_NET_RTIPV4) += ipv4/
> >>>>>> -
> >>>>>> -obj-$(CONFIG_XENO_DRIVERS_NET_RTPACKET) += packet/
> >>>>>> -
> >>>>>> -obj-$(CONFIG_XENO_DRIVERS_NET_RTMAC) += rtmac/
> >>>>>> -
> >>>>>> -obj-$(CONFIG_XENO_DRIVERS_NET_RTCFG) += rtcfg/
> >>>>>> -
> >>>>>>     obj-$(CONFIG_XENO_DRIVERS_NET) += rtnet.o
> >>>>>>
> >>>>>>     rtnet-y :=  \
> >>>>>> @@ -23,4 +15,12 @@ rtnet-y :=  \
> >>>>>>            stack_mgr.o \
> >>>>>>            eth.o
> >>>>>>
> >>>>>> +obj-$(CONFIG_XENO_DRIVERS_NET_RTIPV4) += ipv4/
> >>>>>> +
> >>>>>> +obj-$(CONFIG_XENO_DRIVERS_NET_RTPACKET) += packet/
> >>>>>> +
> >>>>>> +obj-$(CONFIG_XENO_DRIVERS_NET_RTMAC) += rtmac/
> >>>>>> +
> >>>>>> +obj-$(CONFIG_XENO_DRIVERS_NET_RTCFG) += rtcfg/
> >>>>>> +
> >>>>>>     rtnet-$(CONFIG_XENO_DRIVERS_NET_RTWLAN) += rtwlan.o diff -
> -git
> >>>>>> a/utils/net/rtnet.in b/utils/net/rtnet.in index f81a7bb..fa12a03
> >>>>>> 100644
> >>>>>> --- a/utils/net/rtnet.in
> >>>>>> +++ b/utils/net/rtnet.in
> >>>>>> @@ -31,44 +31,68 @@ EOF
> >>>>>>     }
> >>>>>>
> >>>>>>     init_rtnet() {
> >>>>>> -    modprobe rtnet >/dev/null || exit 1
> >>>>>> -    modprobe rtipv4 >/dev/null || exit 1
> >>>>>> -    modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit
> 1
> >>>>>> -
> >>>>>> -    for dev in $REBIND_RT_NICS; do
> >>>>>> -  if [ -d /sys/bus/pci/devices/$dev/driver ]; then
> >>>>>> -      echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
> >>>>>> -  fi
> >>>>>> -  echo $dev > /sys/bus/pci/drivers/$RT_DRIVER/bind
> >>>>>> -    done
> >>>>>> +    if [ ! -d /proc/rtnet ]; then
> >>>>>> +        modprobe rtnet >/dev/null || exit 1
> >>>>>> +    fi
> >>>>>>
> >>>>>> +    if [ ! -d /proc/rtnet/ipv4 ]; then
> >>>>>> +        modprobe rtipv4 >/dev/null || exit 1
> >>>>>> +    fi
> >>>>>>         for PROTOCOL in $RT_PROTOCOLS; do
> >>>>>> -  modprobe rt$PROTOCOL >/dev/null || exit 1
> >>>>>> +        if [ ! -d /sys/modules/rt$PROTOCOL ]; then
> >>>>>> +            if [ "$PROTOCOL" = "packet" ]; then
> >>>>>> +                modprobe rt$PROTOCOL >/dev/null
> >>>>>> +            else
> >>>>>> +                modprobe rt$PROTOCOL >/dev/null || exit 1
> >>>>>> +            fi
> >>>>>> +        fi
> >>>>>>         done
> >>>>>>
> >>>>>> +    $(cat /proc/rtnet/devices | grep -q rteth0)
> >>>>>> +    if [ $? -eq 1 ]; then
> >>>>>> +        modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null ||
> exit
> >>>>>> + 1
> >>>>>> +
> >>>>>> +        for dev in $REBIND_RT_NICS; do
> >>>>>> +            if [ -d /sys/bus/pci/devices/$dev/driver ]; then
> >>>>>> +                echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
> >>>>>> +            fi
> >>>>>> +            echo $dev > /sys/bus/pci/drivers/$RT_DRIVER/bind
> >>>>>> +        done
> >>>>>> +    fi
> >>>>>> +
> >>>>>>         if [ $RT_LOOPBACK = "yes" ]; then
> >>>>>> -  modprobe rt_loopback >/dev/null || exit 1
> >>>>>> +        $(cat /proc/rtnet/devices | grep -q rtlo)
> >>>>>> +        if [ $? -eq 1 ]; then
> >>>>>> +
> >>>>>> +            modprobe rt_loopback >/dev/null || exit 1
> >>>>>> +        fi
> >>>>>>         fi
> >>>>>>
> >>>>>> -    if [ $RTCAP = "yes" ]; then
> >>>>>> -  modprobe rtcap >/dev/null || exit 1
> >>>>>> +    if [ $RTCAP = "yes" -a ! -d /sys/modules/rtcap ]; then
> >>>>>> +        modprobe rtcap >/dev/null || exit 1
> >>>>>>         fi
> >>>>>>
> >>>>>>         if [ $RT_LOOPBACK = "yes" ]; then
> >>>>>> -  $RTIFCONFIG rtlo up 127.0.0.1
> >>>>>> +        $RTIFCONFIG rtlo up 127.0.0.1
> >>>>>>         fi
> >>>>>>
> >>>>>>         if [ $RTCAP = "yes" ]; then
> >>>>>> -  ifconfig rteth0 up
> >>>>>> -  ifconfig rteth0-mac up
> >>>>>> -  if [ $RT_LOOPBACK = "yes" ]; then
> >>>>>> -      ifconfig rtlo up
> >>>>>> -  fi
> >>>>>> +        ifconfig rteth0 up
> >>>>>> +        ifconfig rteth0-mac up
> >>>>>> +        if [ $RT_LOOPBACK = "yes" ]; then
> >>>>>> +            ifconfig rtlo up
> >>>>>> +        fi
> >>>>>>         fi
> >>>>>>
> >>>>>> -    modprobe rtcfg >/dev/null
> >>>>>> -    modprobe rtmac >/dev/null
> >>>>>> -    modprobe tdma >/dev/null
> >>>>>> +    if [ ! -d /proc/rtnet/rtcfg ]; then
> >>>>>> +        modprobe rtcfg >/dev/null
> >>>>>> +    fi
> >>>>>> +    if [ ! -d /proc/rtnet/rtmac ]; then
> >>>>>> +        modprobe rtmac >/dev/null
> >>>>>> +    fi
> >>>>>> +    if [ ! -f /proc/tdma ]; then
> >>>>>> +        modprobe tdma >/dev/null
> >>>>>> +    fi
> >>>>>>     }
> >>>>>>
> >>>>>>     submit_cfg() {
> >>>>>> @@ -336,34 +360,56 @@ case "$1" in
> >>>>>>            ;;
> >>>>>>
> >>>>>>         capture)
> >>>>>> -  modprobe rtnet >/dev/null || exit 1
> >>>>>> -  modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
> >>>>>> -  modprobe rtcap >/dev/null || exit 1
> >>>>>> -  $RTIFCONFIG rteth0 up promisc
> >>>>>> -  ifconfig rteth0 up
> >>>>>> -  ifconfig rteth0-mac up
> >>>>>> -  ;;
> >>>>>> +        if [ ! -d /proc/rtnet ]; then
> >>>>>> +            modprobe rtnet >/dev/null || exit 1
> >>>>>> +        fi
> >>>>>> +        $(cat /proc/rtnet/devices | grep -q rteth0)
> >>>>>> +        if [ $? -eq 1 ]; then
> >>>>>> +            modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null ||
> >> exit 1
> >>>>>> +        fi
> >>>>>> +        if [ ! -d /sys/modules/rtcap ]; then
> >>>>>> +            modprobe rtcap >/dev/null || exit 1
> >>>>>> +        fi
> >>>>>> +        $RTIFCONFIG rteth0 up promisc
> >>>>>> +        ifconfig rteth0 up
> >>>>>> +        ifconfig rteth0-mac up
> >>>>>> +        ;;
> >>>>>>
> >>>>>>         loopback)
> >>>>>> -  modprobe rtnet >/dev/null || exit 1
> >>>>>> -  modprobe rtipv4 >/dev/null || exit 1
> >>>>>> -
> >>>>>> -  for PROTOCOL in $RT_PROTOCOLS; do
> >>>>>> -      modprobe rt$PROTOCOL >/dev/null || exit 1
> >>>>>> -  done
> >>>>>> -
> >>>>>> -  modprobe rt_loopback >/dev/null || exit 1
> >>>>>> -
> >>>>>> -  if [ $RTCAP = "yes" ]; then
> >>>>>> -      modprobe rtcap >/dev/null || exit 1
> >>>>>> -  fi
> >>>>>> -
> >>>>>> -  $RTIFCONFIG rtlo up 127.0.0.1
> >>>>>> -
> >>>>>> -  if [ $RTCAP = "yes" ]; then
> >>>>>> -      ifconfig rtlo up
> >>>>>> -  fi
> >>>>>> -  ;;
> >>>>>> +        if [ ! -d /proc/rtnet ]; then
> >>>>>> +            modprobe rtnet >/dev/null || exit 1
> >>>>>> +        fi
> >>>>>> +        if [ ! -d /proc/rtnet/ipv4 ]; then
> >>>>>> +            modprobe rtipv4 >/dev/null || exit 1
> >>>>>> +        fi
> >>>>>> +        for PROTOCOL in $RT_PROTOCOLS; do
> >>>>>> +            if [ ! -d /sys/modules/rt$PROTOCOL ]; then
> >>>>>> +                if [ "$PROTOCOL" = "packet" ]; then
> >>>>>> +                    modprobe rt$PROTOCOL >/dev/null
> >>>>>> +                else
> >>>>>> +                    modprobe rt$PROTOCOL >/dev/null || exit 1
> >>>>>> +                fi
> >>>>>> +            fi
> >>>>>> +        done
> >>>>>> +
> >>>>>> +        if [ $RT_LOOPBACK = "yes" ]; then
> >>>>>> +            $(cat /proc/rtnet/devices | grep -q rtlo)
> >>>>>> +            if [ $? -eq 1 ]; then
> >>>>>> +
> >>>>>> +                modprobe rt_loopback >/dev/null || exit 1
> >>>>>> +            fi
> >>>>>> +        fi
> >>>>>> +
> >>>>>> +        if [ $RTCAP = "yes" -a ! -d /sys/modules/rtcap ]; then
> >>>>>> +            modprobe rtcap >/dev/null || exit 1
> >>>>>> +        fi
> >>>>>> +
> >>>>>> +        $RTIFCONFIG rtlo up 127.0.0.1
> >>>>>> +
> >>>>>> +        if [ $RTCAP = "yes" ]; then
> >>>>>> +            ifconfig rtlo up
> >>>>>> +        fi
> >>>>>> +        ;;
> >>>>>>
> >>>>>>         *)
> >>>>>>            usage
> >>>>>>
> >>>>>
> >>>>> Could you check if this delta on top works as well?
> >>>>>
> >>>>> diff --git a/utils/net/rtnet.in b/utils/net/rtnet.in index
> >>>>> fa12a0378a..84f7eed00d 100644
> >>>>> --- a/utils/net/rtnet.in
> >>>>> +++ b/utils/net/rtnet.in
> >>>>> @@ -48,8 +48,7 @@ init_rtnet() {
> >>>>>            fi
> >>>>>        done
> >>>>>
> >>>>> -    $(cat /proc/rtnet/devices | grep -q rteth0)
> >>>>> -    if [ $? -eq 1 ]; then
> >>>>> +    if grep -vq rteth0 /proc/rtnet/devices; then
> >>>>>            modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null ||
> exit
> >>>>> 1
> >>>>>
> >>>>>            for dev in $REBIND_RT_NICS; do @@ -61,9 +60,7 @@
> >>>>> init_rtnet() {
> >>>>>        fi
> >>>>>
> >>>>>        if [ $RT_LOOPBACK = "yes" ]; then
> >>>>> -        $(cat /proc/rtnet/devices | grep -q rtlo)
> >>>>> -        if [ $? -eq 1 ]; then
> >>>>> -
> >>>>> +        if grep -vq rtlo /proc/rtnet/devices; then
> >>>>>                modprobe rt_loopback >/dev/null || exit 1
> >>>>>            fi
> >>>>>        fi
> >>>>> @@ -363,8 +360,7 @@ case "$1" in
> >>>>>            if [ ! -d /proc/rtnet ]; then
> >>>>>                modprobe rtnet >/dev/null || exit 1
> >>>>>            fi
> >>>>> -        $(cat /proc/rtnet/devices | grep -q rteth0)
> >>>>> -        if [ $? -eq 1 ]; then
> >>>>> +        if grep -vq rteth0 /proc/rtnet/devices; then
> >>>>>                modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null ||
> exit
> >> 1
> >>>>>            fi
> >>>>>            if [ ! -d /sys/modules/rtcap ]; then @@ -393,9 +389,7 @@
> >>>>> case "$1" in
> >>>>>            done
> >>>>>
> >>>>>            if [ $RT_LOOPBACK = "yes" ]; then
> >>>>> -            $(cat /proc/rtnet/devices | grep -q rtlo)
> >>>>> -            if [ $? -eq 1 ]; then
> >>>>> -
> >>>>> +            if grep -vq rtlo /proc/rtnet/devices; then
> >>>>>                    modprobe rt_loopback >/dev/null || exit 1
> >>>>>                fi
> >>>>>            fi
> >>>>>
> >>>>> Then I would prefer it and would merge the combination to next. It
> >>>>> looks safe and orthogonal enough for -rc2.
> >>>>
> >>>> Nah, not yet. We need to check the drivers first. At least the e1000
> >>>> have non-static symbols that collide with the in-tree version.
> >>>>
> >>>> Jan
> >>>>
> >>>
> >>> Anyway, what you proposed does not work as there is an header line in
> the
> >> file which will match anyway (plus there is likely another network
> interface
> >> there too, causing your rule to fail.
> >>>
> >>> We could replace that with :
> >>> grep -q rtlo /proc/rtnet/devices || modprobe rt_loopback >/dev/null ||
> >>> exit 1
> >>>
> >>> I can send the patch back that way if that fits your rules.
> >>
> >> Ah, yeah, not the same... But then do "if ! grep -q ...".
> >>
> >> Regarding the symbol conflicts: Maybe we start with marking all drivers
> >> "depends m", and then dropping those step-wise which do not conflict
> with
> >> their upstream siblings. But it is important to check that by building both
> into
> >> the kernel.
> >
> > I have fixed some of the intel drivers to remove conflicts, can post those
> patches when I got some time for cleaning up.
> >
>
> TIA!
>
> > How will the PCI-autobinding work, if two drivers support the same device?
> Link-order?
> >
>
> Would be my guess. But I also bet providing multiple drivers for the
> same bind match is a grey area in the kernel.
>
> > Ideally I would want that all devices are bound to the linux driver at start, so
> things like NFS root (over a secondary adapter) aren't affected.
>
> This is where I would say: modular RT drivers, again.

I'd prefer being able to tag the rt_* drivers to not bind automatically.

I tested the patch and static rtnet seem to work so far.
All devices are bound to the normal igb driver aswell.

I still have some trouble with my extended rt_igb driver not responding to AUXTS interrupts,
but I am not willing to investigate further for now. Static rtnet + rt_igb module works.


Norbert
________________________________

This message and any attachments are solely for the use of the intended recipients. They may contain privileged and/or confidential information or other information protected from disclosure. If you are not an intended recipient, you are hereby notified that you received this email in error and that any review, dissemination, distribution or copying of this email and any attachment is strictly prohibited. If you have received this email in error, please contact the sender and delete the message and any attachment from your system.

ANDRITZ HYDRO GmbH


Rechtsform/ Legal form: Gesellschaft mit beschränkter Haftung / Corporation

Firmensitz/ Registered seat: Wien

Firmenbuchgericht/ Court of registry: Handelsgericht Wien

Firmenbuchnummer/ Company registration: FN 61833 g

DVR: 0605077

UID-Nr.: ATU14756806


Thank You
________________________________

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] Allow RTNet to be builtin kernel
  2019-10-09  7:24     ` Jan Kiszka
@ 2019-10-09  7:27       ` François Legal
  0 siblings, 0 replies; 17+ messages in thread
From: François Legal @ 2019-10-09  7:27 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Xenomai

Le Mercredi, Octobre 09, 2019 09:24 CEST, Jan Kiszka <jan.kiszka@siemens.com> a écrit:

> On 09.10.19 09:21, François Legal via Xenomai wrote:
> > From: François LEGAL <devel@thom.fr.eu.org>
> >
> > Subject: [PATCH] Allow RTNet to be builtin kernel
> >
> > Makefile is changed because when builtin, the modules get loaded in the link order. In the previous version protocols would get loaded before stackmgr which obviously fails.
> >
> > Signed-off-by: François LEGAL <devel@thom.fr.eu.org>
> >
> > ---
> >
> > This has been tested on Zynq 7000 Hardware (microzed board) with MACB/GEM RTNet driver, with linux 4.4.189 vanilla. Kernel boots up correctly, and the following messages get printed on the console during the boot :
> >
> > [   13.875451] sdhci-pltfm: SDHCI platform and OF driver helper
> > [   13.881627] sdhci-arasan e0100000.sdhci: No vmmc regulator found
> > [   13.887581] sdhci-arasan e0100000.sdhci: No vqmmc regulator found
> > [   13.927585] mmc0: SDHCI controller on e0100000.sdhci [e0100000.sdhci] using ADMA
> > [   13.945085] fpga_manager fpga0: Xilinx Zynq FPGA Manager registered
> > [   13.951896]
> > [   13.951896] *** RTnet for Xenomai v3.0.9 ***
> > [   13.951896]
> > [   13.959156] RTnet: initialising real-time networking
> > [   13.964928] RTmac/TDMA: init time division multiple access control mechanism
> > [   13.972074] RTmac: init realtime media access control
> > [   13.977064] RTcfg: init real-time configuration distribution protocol
> > [   13.983752] initializing loopback...
> > [   13.987295] RTnet: registered rtlo
> > [   13.993238] RTnet: registered rteth0
> > [   13.996832] libphy: MACB_mii_bus: probed
> > [   14.001140] rt_macb: rteth0: Cadence GEM at 0xe000b000 irq 26 (00:0a:35:00:01:22)
> > [   14.008630] rt_macb: rteth0: attached PHY driver [Marvell 88E1510] (mii_bus:phy_addr=e000b000.ethernet-ffffffff:00, irq=-1)
> > [   14.019845] RTcap: real-time capturing interface
> > [   14.026562] RTproxy attached to rteth0
> > [   14.031129] rtnetproxy installed as "rtproxy"
> > [   14.035693] NET: Registered protocol family 26
> > [   14.040309] NET: Registered protocol family 17
> > [   14.044686] can: controller area network core (rev 20120528 abi 9)
> > [   14.050957] NET: Registered protocol family 29
> > [   14.055329] can: raw protocol (rev 20120528)
> > [   14.059683] can: broadcast manager protocol (rev 20120528 t)
> >
> >  kernel/drivers/net/Kconfig         |   1 -
> >  kernel/drivers/net/addons/Kconfig  |   4 +-
> >  kernel/drivers/net/drivers/Kconfig |  22 +++---
> >  kernel/drivers/net/stack/Makefile  |  16 ++---
> >  utils/net/rtnet.in                 | 138 ++++++++++++++++++++++++-------------
> >  5 files changed, 110 insertions(+), 71 deletions(-)
> >
> > diff --git a/kernel/drivers/net/Kconfig b/kernel/drivers/net/Kconfig
> > index ac3bced..49d2402 100644
> > --- a/kernel/drivers/net/Kconfig
> > +++ b/kernel/drivers/net/Kconfig
> > @@ -1,7 +1,6 @@
> >  menu "RTnet"
> >
> >  config XENO_DRIVERS_NET
> > -    depends on m
> >      select NET
> >      tristate "RTnet, TCP/IP socket interface"
> >
> > diff --git a/kernel/drivers/net/addons/Kconfig b/kernel/drivers/net/addons/Kconfig
> > index baa6cbc..616ed40 100644
> > --- a/kernel/drivers/net/addons/Kconfig
> > +++ b/kernel/drivers/net/addons/Kconfig
> > @@ -2,7 +2,7 @@ menu "Add-Ons"
> >      depends on XENO_DRIVERS_NET
> >
> >  config XENO_DRIVERS_NET_ADDON_RTCAP
> > -    depends on XENO_DRIVERS_NET && m
> > +    depends on XENO_DRIVERS_NET
> >      select ETHERNET
> >      tristate "Real-Time Capturing Support"
> >      default n
> > @@ -18,7 +18,7 @@ config XENO_DRIVERS_NET_ADDON_RTCAP
> >      For further information see Documentation/README.rtcap.
> >
> >  config XENO_DRIVERS_NET_ADDON_PROXY
> > -    depends on XENO_DRIVERS_NET_RTIPV4 && m
> > +    depends on XENO_DRIVERS_NET_RTIPV4
> >      select ETHERNET
> >      tristate "IP protocol proxy for Linux"
> >      default n
> > diff --git a/kernel/drivers/net/drivers/Kconfig b/kernel/drivers/net/drivers/Kconfig
> > index 65f0855..6140f94 100644
> > --- a/kernel/drivers/net/drivers/Kconfig
> > +++ b/kernel/drivers/net/drivers/Kconfig
> > @@ -10,7 +10,7 @@ config XENO_DRIVERS_NET_DRV_PCNET32
> >
> >
> >  config XENO_DRIVERS_NET_DRV_TULIP
> > -    depends on XENO_DRIVERS_NET && PCI
> > +    depends on XENO_DRIVERS_NET && PCI && m
> >      tristate "DEC Tulip"
> >
> >
> > @@ -40,12 +40,12 @@ config XENO_DRIVERS_NET_DRV_EEPRO100_DBG
> >
> >
> >  config XENO_DRIVERS_NET_DRV_E1000
> > -    depends on XENO_DRIVERS_NET && PCI
> > +    depends on XENO_DRIVERS_NET && PCI && m
> >      tristate "Intel(R) PRO/1000 (Gigabit)"
> >      default y
> >
> >  config XENO_DRIVERS_NET_DRV_E1000E
> > -    depends on XENO_DRIVERS_NET && PCI
> > +    depends on XENO_DRIVERS_NET && PCI && m
> >      tristate "New Intel(R) PRO/1000 PCIe (Gigabit)"
> >
> >
> > @@ -68,7 +68,7 @@ config XENO_DRIVERS_NET_DRV_VIA_RHINE
> >  config XENO_DRIVERS_NET_DRV_IGB
> >      select I2C
> >      select I2C_ALGOBIT
> > -    depends on XENO_DRIVERS_NET && PCI
> > +    depends on XENO_DRIVERS_NET && PCI && m
> >      tristate "Intel(R) 82575 (Gigabit)"
> >
> >
> > @@ -83,22 +83,22 @@ comment "Embedded MPC Drivers"
> >      depends on XENO_DRIVERS_NET
> >
> >  config XENO_DRIVERS_NET_DRV_FCC_ENET
> > -    depends on XENO_DRIVERS_NET
> > +    depends on XENO_DRIVERS_NET && m
> >      tristate "MPC8260 FCC Ethernet"
> >
> >
> >  config XENO_DRIVERS_NET_DRV_FEC_ENET
> > -    depends on XENO_DRIVERS_NET
> > +    depends on XENO_DRIVERS_NET && m
> >      tristate "MPC8xx FEC Ethernet"
> >
> >
> >  config XENO_DRIVERS_NET_DRV_SCC_ENET
> > -    depends on XENO_DRIVERS_NET
> > +    depends on XENO_DRIVERS_NET && m
> >      tristate "MPC8xx SCC Ethernet"
> >
> >
> >  config XENO_DRIVERS_NET_DRV_MPC52XX_FEC
> > -    depends on XENO_DRIVERS_NET
> > +    depends on XENO_DRIVERS_NET && m
> >      tristate "MPC52xx FEC Ethernet"
> >
> >  endif
> > @@ -124,9 +124,9 @@ config XENO_DRIVERS_NET_DRV_AT91_ETHER
> >      tristate "AT91RM9200 Board Ethernet Driver"
> >
> >  config XENO_DRIVERS_NET_DRV_MACB
> > -    depends on XENO_DRIVERS_NET && ARCH_AT91
> > -    select AT91_PROGRAMMABLE_CLOCKS
> > -    tristate "MACB AT91SAM926x devices"
> > +    depends on XENO_DRIVERS_NET
> > +    select AT91_PROGRAMMABLE_CLOCKS if ARCH_AT91
> > +    tristate "Cadence MACB/GEM devices"
> >      ---help---
> >      Driver for internal MAC-controller on AT91SAM926x microcontrollers.
> >      Porting by Cristiano Mantovani and Stefano Banzi (Marposs SpA).
> > diff --git a/kernel/drivers/net/stack/Makefile b/kernel/drivers/net/stack/Makefile
> > index d055dc2..f8db6fa 100644
> > --- a/kernel/drivers/net/stack/Makefile
> > +++ b/kernel/drivers/net/stack/Makefile
> > @@ -1,13 +1,5 @@
> >  ccflags-y += -Idrivers/xenomai/net/stack/include -Ikernel/
> >
> > -obj-$(CONFIG_XENO_DRIVERS_NET_RTIPV4) += ipv4/
> > -
> > -obj-$(CONFIG_XENO_DRIVERS_NET_RTPACKET) += packet/
> > -
> > -obj-$(CONFIG_XENO_DRIVERS_NET_RTMAC) += rtmac/
> > -
> > -obj-$(CONFIG_XENO_DRIVERS_NET_RTCFG) += rtcfg/
> > -
> >  obj-$(CONFIG_XENO_DRIVERS_NET) += rtnet.o
> >
> >  rtnet-y :=  \
> > @@ -23,4 +15,12 @@ rtnet-y :=  \
> >  	stack_mgr.o \
> >  	eth.o
> >
> > +obj-$(CONFIG_XENO_DRIVERS_NET_RTIPV4) += ipv4/
> > +
> > +obj-$(CONFIG_XENO_DRIVERS_NET_RTPACKET) += packet/
> > +
> > +obj-$(CONFIG_XENO_DRIVERS_NET_RTMAC) += rtmac/
> > +
> > +obj-$(CONFIG_XENO_DRIVERS_NET_RTCFG) += rtcfg/
> > +
> >  rtnet-$(CONFIG_XENO_DRIVERS_NET_RTWLAN) += rtwlan.o
> > diff --git a/utils/net/rtnet.in b/utils/net/rtnet.in
> > index f81a7bb..7e6264c 100644
> > --- a/utils/net/rtnet.in
> > +++ b/utils/net/rtnet.in
> > @@ -31,44 +31,65 @@ EOF
> >  }
> >
> >  init_rtnet() {
> > -    modprobe rtnet >/dev/null || exit 1
> > -    modprobe rtipv4 >/dev/null || exit 1
> > -    modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
> > -
> > -    for dev in $REBIND_RT_NICS; do
> > -	if [ -d /sys/bus/pci/devices/$dev/driver ]; then
> > -	    echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
> > -	fi
> > -	echo $dev > /sys/bus/pci/drivers/$RT_DRIVER/bind
> > -    done
> > +    if [ ! -d /proc/rtnet ]; then
> > +        modprobe rtnet >/dev/null || exit 1
> > +    fi
> >
> > +    if [ ! -d /proc/rtnet/ipv4 ]; then
> > +        modprobe rtipv4 >/dev/null || exit 1
> > +    fi
> >      for PROTOCOL in $RT_PROTOCOLS; do
> > -	modprobe rt$PROTOCOL >/dev/null || exit 1
> > +        if [ ! -d /sys/module/rt$PROTOCOL ]; then
> > +            if [ "$PROTOCOL" = "packet" ]; then
> > +                modprobe rt$PROTOCOL >/dev/null 2>&1
> > +            else
> > +                modprobe rt$PROTOCOL >/dev/null || exit 1
> > +            fi
> > +        fi
> >      done
> >
> > +    if ! grep q rteth0 /proc/rtnet/devices; then
> > +        modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
> > +
> > +        for dev in $REBIND_RT_NICS; do
> > +            if [ -d /sys/bus/pci/devices/$dev/driver ]; then
> > +                echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
> > +            fi
> > +            echo $dev > /sys/bus/pci/drivers/$RT_DRIVER/bind
> > +        done
> > +    fi
> > +
> >      if [ $RT_LOOPBACK = "yes" ]; then
> > -	modprobe rt_loopback >/dev/null || exit 1
> > +        if ! grep q rtlo /proc/rtnet/devices; then
> > +            modprobe rt_loopback >/dev/null || exit 1
> > +        fi
> >      fi
> >
> > -    if [ $RTCAP = "yes" ]; then
> > -	modprobe rtcap >/dev/null || exit 1
> > +    if [ $RTCAP = "yes" -a ! -d /sys/module/rtcap ]; then
> > +        modprobe rtcap >/dev/null || exit 1
> >      fi
> >
> >      if [ $RT_LOOPBACK = "yes" ]; then
> > -	$RTIFCONFIG rtlo up 127.0.0.1
> > +        $RTIFCONFIG rtlo up 127.0.0.1
> >      fi
> >
> >      if [ $RTCAP = "yes" ]; then
> > -	ifconfig rteth0 up
> > -	ifconfig rteth0-mac up
> > -	if [ $RT_LOOPBACK = "yes" ]; then
> > -	    ifconfig rtlo up
> > -	fi
> > +        ifconfig rteth0 up
> > +        ifconfig rteth0-mac up
> > +        if [ $RT_LOOPBACK = "yes" ]; then
> > +            ifconfig rtlo up
> > +        fi
> >      fi
> >
> > -    modprobe rtcfg >/dev/null
> > -    modprobe rtmac >/dev/null
> > -    modprobe tdma >/dev/null
> > +    if [ ! -d /proc/rtnet/rtcfg ]; then
> > +        modprobe rtcfg >/dev/null
> > +    fi
> > +    if [ ! -d /proc/rtnet/rtmac ]; then
> > +        modprobe rtmac >/dev/null
> > +    fi
> > +    if [ ! -f /proc/tdma ]; then
> > +        modprobe tdma >/dev/null
> > +    fi
> >  }
> >
> >  submit_cfg() {
> > @@ -336,34 +357,53 @@ case "$1" in
> >  	;;
> >
> >      capture)
> > -	modprobe rtnet >/dev/null || exit 1
> > -	modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
> > -	modprobe rtcap >/dev/null || exit 1
> > -	$RTIFCONFIG rteth0 up promisc
> > -	ifconfig rteth0 up
> > -	ifconfig rteth0-mac up
> > -	;;
> > +        if [ ! -d /proc/rtnet ]; then
> > +            modprobe rtnet >/dev/null || exit 1
> > +        fi
> > +        if ! grep q rteth0 /proc/rtnet/devices; then
> > +            modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
> > +        fi
> > +        if [ ! -d /sys/module/rtcap ]; then
> > +            modprobe rtcap >/dev/null || exit 1
> > +        fi
> > +        $RTIFCONFIG rteth0 up promisc
> > +        ifconfig rteth0 up
> > +        ifconfig rteth0-mac up
> > +        ;;
> >
> >      loopback)
> > -	modprobe rtnet >/dev/null || exit 1
> > -	modprobe rtipv4 >/dev/null || exit 1
> > -
> > -	for PROTOCOL in $RT_PROTOCOLS; do
> > -	    modprobe rt$PROTOCOL >/dev/null || exit 1
> > -	done
> > -
> > -	modprobe rt_loopback >/dev/null || exit 1
> > -
> > -	if [ $RTCAP = "yes" ]; then
> > -	    modprobe rtcap >/dev/null || exit 1
> > -	fi
> > -
> > -	$RTIFCONFIG rtlo up 127.0.0.1
> > -
> > -	if [ $RTCAP = "yes" ]; then
> > -	    ifconfig rtlo up
> > -	fi
> > -	;;
> > +        if [ ! -d /proc/rtnet ]; then
> > +            modprobe rtnet >/dev/null || exit 1
> > +        fi
> > +        if [ ! -d /proc/rtnet/ipv4 ]; then
> > +            modprobe rtipv4 >/dev/null || exit 1
> > +        fi
> > +        for PROTOCOL in $RT_PROTOCOLS; do
> > +            if [ ! -d /sys/module/rt$PROTOCOL ]; then
> > +                if [ "$PROTOCOL" = "packet" ]; then
> > +                    modprobe rt$PROTOCOL >/dev/null 2>&1
> > +                else
> > +                    modprobe rt$PROTOCOL >/dev/null || exit 1
> > +                fi
> > +            fi
> > +        done
> > +
> > +        if [ $RT_LOOPBACK = "yes" ]; then
> > +            if ! grep q rtlo /proc/rtnet/devices; then
> > +                modprobe rt_loopback >/dev/null || exit 1
> > +            fi
> > +        fi
> > +
> > +        if [ $RTCAP = "yes" -a ! -d /sys/module/rtcap ]; then
> > +            modprobe rtcap >/dev/null || exit 1
> > +        fi
> > +
> > +        $RTIFCONFIG rtlo up 127.0.0.1
> > +
> > +        if [ $RTCAP = "yes" ]; then
> > +            ifconfig rtlo up
> > +        fi
> > +        ;;
> >
> >      *)
> >  	usage
> >
>
> I got this three times - which one is valid?
>
> Also, for future clarity, please version your patches
> ("[PATCH v3] ...").
>
> Jan
>

Yes, sorry for that. I sent the first one too fast, not setting the right email address (as registered on the list), so it went through to you but not to the list. So I sent it back just to the list. They both are the same. Sorry again.

François
> --
> Siemens AG, Corporate Technology, CT RDA IOT SES-DE
> Corporate Competence Center Embedded Linux



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] Allow RTNet to be builtin kernel
  2019-10-09  7:21   ` François Legal
@ 2019-10-09  7:24     ` Jan Kiszka
  2019-10-09  7:27       ` François Legal
  0 siblings, 1 reply; 17+ messages in thread
From: Jan Kiszka @ 2019-10-09  7:24 UTC (permalink / raw)
  To: François Legal; +Cc: Xenomai

On 09.10.19 09:21, François Legal via Xenomai wrote:
> From: François LEGAL <devel@thom.fr.eu.org>
> 
> Subject: [PATCH] Allow RTNet to be builtin kernel
> 
> Makefile is changed because when builtin, the modules get loaded in the link order. In the previous version protocols would get loaded before stackmgr which obviously fails.
> 
> Signed-off-by: François LEGAL <devel@thom.fr.eu.org>
> 
> ---
> 
> This has been tested on Zynq 7000 Hardware (microzed board) with MACB/GEM RTNet driver, with linux 4.4.189 vanilla. Kernel boots up correctly, and the following messages get printed on the console during the boot :
> 
> [   13.875451] sdhci-pltfm: SDHCI platform and OF driver helper
> [   13.881627] sdhci-arasan e0100000.sdhci: No vmmc regulator found
> [   13.887581] sdhci-arasan e0100000.sdhci: No vqmmc regulator found
> [   13.927585] mmc0: SDHCI controller on e0100000.sdhci [e0100000.sdhci] using ADMA
> [   13.945085] fpga_manager fpga0: Xilinx Zynq FPGA Manager registered
> [   13.951896]
> [   13.951896] *** RTnet for Xenomai v3.0.9 ***
> [   13.951896]
> [   13.959156] RTnet: initialising real-time networking
> [   13.964928] RTmac/TDMA: init time division multiple access control mechanism
> [   13.972074] RTmac: init realtime media access control
> [   13.977064] RTcfg: init real-time configuration distribution protocol
> [   13.983752] initializing loopback...
> [   13.987295] RTnet: registered rtlo
> [   13.993238] RTnet: registered rteth0
> [   13.996832] libphy: MACB_mii_bus: probed
> [   14.001140] rt_macb: rteth0: Cadence GEM at 0xe000b000 irq 26 (00:0a:35:00:01:22)
> [   14.008630] rt_macb: rteth0: attached PHY driver [Marvell 88E1510] (mii_bus:phy_addr=e000b000.ethernet-ffffffff:00, irq=-1)
> [   14.019845] RTcap: real-time capturing interface
> [   14.026562] RTproxy attached to rteth0
> [   14.031129] rtnetproxy installed as "rtproxy"
> [   14.035693] NET: Registered protocol family 26
> [   14.040309] NET: Registered protocol family 17
> [   14.044686] can: controller area network core (rev 20120528 abi 9)
> [   14.050957] NET: Registered protocol family 29
> [   14.055329] can: raw protocol (rev 20120528)
> [   14.059683] can: broadcast manager protocol (rev 20120528 t)
> 
>  kernel/drivers/net/Kconfig         |   1 -
>  kernel/drivers/net/addons/Kconfig  |   4 +-
>  kernel/drivers/net/drivers/Kconfig |  22 +++---
>  kernel/drivers/net/stack/Makefile  |  16 ++---
>  utils/net/rtnet.in                 | 138 ++++++++++++++++++++++++-------------
>  5 files changed, 110 insertions(+), 71 deletions(-)
> 
> diff --git a/kernel/drivers/net/Kconfig b/kernel/drivers/net/Kconfig
> index ac3bced..49d2402 100644
> --- a/kernel/drivers/net/Kconfig
> +++ b/kernel/drivers/net/Kconfig
> @@ -1,7 +1,6 @@
>  menu "RTnet"
>  
>  config XENO_DRIVERS_NET
> -    depends on m
>      select NET
>      tristate "RTnet, TCP/IP socket interface"
>  
> diff --git a/kernel/drivers/net/addons/Kconfig b/kernel/drivers/net/addons/Kconfig
> index baa6cbc..616ed40 100644
> --- a/kernel/drivers/net/addons/Kconfig
> +++ b/kernel/drivers/net/addons/Kconfig
> @@ -2,7 +2,7 @@ menu "Add-Ons"
>      depends on XENO_DRIVERS_NET
>  
>  config XENO_DRIVERS_NET_ADDON_RTCAP
> -    depends on XENO_DRIVERS_NET && m
> +    depends on XENO_DRIVERS_NET
>      select ETHERNET
>      tristate "Real-Time Capturing Support"
>      default n
> @@ -18,7 +18,7 @@ config XENO_DRIVERS_NET_ADDON_RTCAP
>      For further information see Documentation/README.rtcap.
>  
>  config XENO_DRIVERS_NET_ADDON_PROXY
> -    depends on XENO_DRIVERS_NET_RTIPV4 && m
> +    depends on XENO_DRIVERS_NET_RTIPV4
>      select ETHERNET
>      tristate "IP protocol proxy for Linux"
>      default n
> diff --git a/kernel/drivers/net/drivers/Kconfig b/kernel/drivers/net/drivers/Kconfig
> index 65f0855..6140f94 100644
> --- a/kernel/drivers/net/drivers/Kconfig
> +++ b/kernel/drivers/net/drivers/Kconfig
> @@ -10,7 +10,7 @@ config XENO_DRIVERS_NET_DRV_PCNET32
>  
>  
>  config XENO_DRIVERS_NET_DRV_TULIP
> -    depends on XENO_DRIVERS_NET && PCI
> +    depends on XENO_DRIVERS_NET && PCI && m
>      tristate "DEC Tulip"
>  
>  
> @@ -40,12 +40,12 @@ config XENO_DRIVERS_NET_DRV_EEPRO100_DBG
>  
>  
>  config XENO_DRIVERS_NET_DRV_E1000
> -    depends on XENO_DRIVERS_NET && PCI
> +    depends on XENO_DRIVERS_NET && PCI && m
>      tristate "Intel(R) PRO/1000 (Gigabit)"
>      default y
>  
>  config XENO_DRIVERS_NET_DRV_E1000E
> -    depends on XENO_DRIVERS_NET && PCI
> +    depends on XENO_DRIVERS_NET && PCI && m
>      tristate "New Intel(R) PRO/1000 PCIe (Gigabit)"
>  
>  
> @@ -68,7 +68,7 @@ config XENO_DRIVERS_NET_DRV_VIA_RHINE
>  config XENO_DRIVERS_NET_DRV_IGB
>      select I2C
>      select I2C_ALGOBIT
> -    depends on XENO_DRIVERS_NET && PCI
> +    depends on XENO_DRIVERS_NET && PCI && m
>      tristate "Intel(R) 82575 (Gigabit)"
>  
>  
> @@ -83,22 +83,22 @@ comment "Embedded MPC Drivers"
>      depends on XENO_DRIVERS_NET
>  
>  config XENO_DRIVERS_NET_DRV_FCC_ENET
> -    depends on XENO_DRIVERS_NET
> +    depends on XENO_DRIVERS_NET && m
>      tristate "MPC8260 FCC Ethernet"
>  
>  
>  config XENO_DRIVERS_NET_DRV_FEC_ENET
> -    depends on XENO_DRIVERS_NET
> +    depends on XENO_DRIVERS_NET && m
>      tristate "MPC8xx FEC Ethernet"
>  
>  
>  config XENO_DRIVERS_NET_DRV_SCC_ENET
> -    depends on XENO_DRIVERS_NET
> +    depends on XENO_DRIVERS_NET && m
>      tristate "MPC8xx SCC Ethernet"
>  
>  
>  config XENO_DRIVERS_NET_DRV_MPC52XX_FEC
> -    depends on XENO_DRIVERS_NET
> +    depends on XENO_DRIVERS_NET && m
>      tristate "MPC52xx FEC Ethernet"
>  
>  endif
> @@ -124,9 +124,9 @@ config XENO_DRIVERS_NET_DRV_AT91_ETHER
>      tristate "AT91RM9200 Board Ethernet Driver"
>  
>  config XENO_DRIVERS_NET_DRV_MACB
> -    depends on XENO_DRIVERS_NET && ARCH_AT91
> -    select AT91_PROGRAMMABLE_CLOCKS
> -    tristate "MACB AT91SAM926x devices"
> +    depends on XENO_DRIVERS_NET
> +    select AT91_PROGRAMMABLE_CLOCKS if ARCH_AT91
> +    tristate "Cadence MACB/GEM devices"
>      ---help---
>      Driver for internal MAC-controller on AT91SAM926x microcontrollers.
>      Porting by Cristiano Mantovani and Stefano Banzi (Marposs SpA).
> diff --git a/kernel/drivers/net/stack/Makefile b/kernel/drivers/net/stack/Makefile
> index d055dc2..f8db6fa 100644
> --- a/kernel/drivers/net/stack/Makefile
> +++ b/kernel/drivers/net/stack/Makefile
> @@ -1,13 +1,5 @@
>  ccflags-y += -Idrivers/xenomai/net/stack/include -Ikernel/
>  
> -obj-$(CONFIG_XENO_DRIVERS_NET_RTIPV4) += ipv4/
> -
> -obj-$(CONFIG_XENO_DRIVERS_NET_RTPACKET) += packet/
> -
> -obj-$(CONFIG_XENO_DRIVERS_NET_RTMAC) += rtmac/
> -
> -obj-$(CONFIG_XENO_DRIVERS_NET_RTCFG) += rtcfg/
> -
>  obj-$(CONFIG_XENO_DRIVERS_NET) += rtnet.o
>  
>  rtnet-y :=  \
> @@ -23,4 +15,12 @@ rtnet-y :=  \
>  	stack_mgr.o \
>  	eth.o
>  
> +obj-$(CONFIG_XENO_DRIVERS_NET_RTIPV4) += ipv4/
> +
> +obj-$(CONFIG_XENO_DRIVERS_NET_RTPACKET) += packet/
> +
> +obj-$(CONFIG_XENO_DRIVERS_NET_RTMAC) += rtmac/
> +
> +obj-$(CONFIG_XENO_DRIVERS_NET_RTCFG) += rtcfg/
> +
>  rtnet-$(CONFIG_XENO_DRIVERS_NET_RTWLAN) += rtwlan.o
> diff --git a/utils/net/rtnet.in b/utils/net/rtnet.in
> index f81a7bb..7e6264c 100644
> --- a/utils/net/rtnet.in
> +++ b/utils/net/rtnet.in
> @@ -31,44 +31,65 @@ EOF
>  }
>  
>  init_rtnet() {
> -    modprobe rtnet >/dev/null || exit 1
> -    modprobe rtipv4 >/dev/null || exit 1
> -    modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
> -
> -    for dev in $REBIND_RT_NICS; do
> -	if [ -d /sys/bus/pci/devices/$dev/driver ]; then
> -	    echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
> -	fi
> -	echo $dev > /sys/bus/pci/drivers/$RT_DRIVER/bind
> -    done
> +    if [ ! -d /proc/rtnet ]; then
> +        modprobe rtnet >/dev/null || exit 1
> +    fi
>  
> +    if [ ! -d /proc/rtnet/ipv4 ]; then
> +        modprobe rtipv4 >/dev/null || exit 1
> +    fi
>      for PROTOCOL in $RT_PROTOCOLS; do
> -	modprobe rt$PROTOCOL >/dev/null || exit 1
> +        if [ ! -d /sys/module/rt$PROTOCOL ]; then
> +            if [ "$PROTOCOL" = "packet" ]; then
> +                modprobe rt$PROTOCOL >/dev/null 2>&1
> +            else
> +                modprobe rt$PROTOCOL >/dev/null || exit 1
> +            fi
> +        fi
>      done
>  
> +    if ! grep q rteth0 /proc/rtnet/devices; then
> +        modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
> +
> +        for dev in $REBIND_RT_NICS; do
> +            if [ -d /sys/bus/pci/devices/$dev/driver ]; then
> +                echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
> +            fi
> +            echo $dev > /sys/bus/pci/drivers/$RT_DRIVER/bind
> +        done
> +    fi
> +
>      if [ $RT_LOOPBACK = "yes" ]; then
> -	modprobe rt_loopback >/dev/null || exit 1
> +        if ! grep q rtlo /proc/rtnet/devices; then
> +            modprobe rt_loopback >/dev/null || exit 1
> +        fi
>      fi
>  
> -    if [ $RTCAP = "yes" ]; then
> -	modprobe rtcap >/dev/null || exit 1
> +    if [ $RTCAP = "yes" -a ! -d /sys/module/rtcap ]; then
> +        modprobe rtcap >/dev/null || exit 1
>      fi
>  
>      if [ $RT_LOOPBACK = "yes" ]; then
> -	$RTIFCONFIG rtlo up 127.0.0.1
> +        $RTIFCONFIG rtlo up 127.0.0.1
>      fi
>  
>      if [ $RTCAP = "yes" ]; then
> -	ifconfig rteth0 up
> -	ifconfig rteth0-mac up
> -	if [ $RT_LOOPBACK = "yes" ]; then
> -	    ifconfig rtlo up
> -	fi
> +        ifconfig rteth0 up
> +        ifconfig rteth0-mac up
> +        if [ $RT_LOOPBACK = "yes" ]; then
> +            ifconfig rtlo up
> +        fi
>      fi
>  
> -    modprobe rtcfg >/dev/null
> -    modprobe rtmac >/dev/null
> -    modprobe tdma >/dev/null
> +    if [ ! -d /proc/rtnet/rtcfg ]; then
> +        modprobe rtcfg >/dev/null
> +    fi
> +    if [ ! -d /proc/rtnet/rtmac ]; then
> +        modprobe rtmac >/dev/null
> +    fi
> +    if [ ! -f /proc/tdma ]; then
> +        modprobe tdma >/dev/null
> +    fi
>  }
>  
>  submit_cfg() {
> @@ -336,34 +357,53 @@ case "$1" in
>  	;;
>  
>      capture)
> -	modprobe rtnet >/dev/null || exit 1
> -	modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
> -	modprobe rtcap >/dev/null || exit 1
> -	$RTIFCONFIG rteth0 up promisc
> -	ifconfig rteth0 up
> -	ifconfig rteth0-mac up
> -	;;
> +        if [ ! -d /proc/rtnet ]; then
> +            modprobe rtnet >/dev/null || exit 1
> +        fi
> +        if ! grep q rteth0 /proc/rtnet/devices; then
> +            modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
> +        fi
> +        if [ ! -d /sys/module/rtcap ]; then
> +            modprobe rtcap >/dev/null || exit 1
> +        fi
> +        $RTIFCONFIG rteth0 up promisc
> +        ifconfig rteth0 up
> +        ifconfig rteth0-mac up
> +        ;;
>  
>      loopback)
> -	modprobe rtnet >/dev/null || exit 1
> -	modprobe rtipv4 >/dev/null || exit 1
> -
> -	for PROTOCOL in $RT_PROTOCOLS; do
> -	    modprobe rt$PROTOCOL >/dev/null || exit 1
> -	done
> -
> -	modprobe rt_loopback >/dev/null || exit 1
> -
> -	if [ $RTCAP = "yes" ]; then
> -	    modprobe rtcap >/dev/null || exit 1
> -	fi
> -
> -	$RTIFCONFIG rtlo up 127.0.0.1
> -
> -	if [ $RTCAP = "yes" ]; then
> -	    ifconfig rtlo up
> -	fi
> -	;;
> +        if [ ! -d /proc/rtnet ]; then
> +            modprobe rtnet >/dev/null || exit 1
> +        fi
> +        if [ ! -d /proc/rtnet/ipv4 ]; then
> +            modprobe rtipv4 >/dev/null || exit 1
> +        fi
> +        for PROTOCOL in $RT_PROTOCOLS; do
> +            if [ ! -d /sys/module/rt$PROTOCOL ]; then
> +                if [ "$PROTOCOL" = "packet" ]; then
> +                    modprobe rt$PROTOCOL >/dev/null 2>&1
> +                else
> +                    modprobe rt$PROTOCOL >/dev/null || exit 1
> +                fi
> +            fi
> +        done
> +
> +        if [ $RT_LOOPBACK = "yes" ]; then
> +            if ! grep q rtlo /proc/rtnet/devices; then
> +                modprobe rt_loopback >/dev/null || exit 1
> +            fi
> +        fi
> +
> +        if [ $RTCAP = "yes" -a ! -d /sys/module/rtcap ]; then
> +            modprobe rtcap >/dev/null || exit 1
> +        fi
> +
> +        $RTIFCONFIG rtlo up 127.0.0.1
> +
> +        if [ $RTCAP = "yes" ]; then
> +            ifconfig rtlo up
> +        fi
> +        ;;
>  
>      *)
>  	usage
> 

I got this three times - which one is valid?

Also, for future clarity, please version your patches
("[PATCH v3] ...").

Jan

-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] Allow RTNet to be builtin kernel
  2019-10-08 16:24 ` Jan Kiszka
@ 2019-10-09  7:21   ` François Legal
  2019-10-09  7:24     ` Jan Kiszka
  0 siblings, 1 reply; 17+ messages in thread
From: François Legal @ 2019-10-09  7:21 UTC (permalink / raw)
  Cc: Xenomai

From: François LEGAL <devel@thom.fr.eu.org>

Subject: [PATCH] Allow RTNet to be builtin kernel

Makefile is changed because when builtin, the modules get loaded in the link order. In the previous version protocols would get loaded before stackmgr which obviously fails.

Signed-off-by: François LEGAL <devel@thom.fr.eu.org>

---

This has been tested on Zynq 7000 Hardware (microzed board) with MACB/GEM RTNet driver, with linux 4.4.189 vanilla. Kernel boots up correctly, and the following messages get printed on the console during the boot :

[   13.875451] sdhci-pltfm: SDHCI platform and OF driver helper
[   13.881627] sdhci-arasan e0100000.sdhci: No vmmc regulator found
[   13.887581] sdhci-arasan e0100000.sdhci: No vqmmc regulator found
[   13.927585] mmc0: SDHCI controller on e0100000.sdhci [e0100000.sdhci] using ADMA
[   13.945085] fpga_manager fpga0: Xilinx Zynq FPGA Manager registered
[   13.951896]
[   13.951896] *** RTnet for Xenomai v3.0.9 ***
[   13.951896]
[   13.959156] RTnet: initialising real-time networking
[   13.964928] RTmac/TDMA: init time division multiple access control mechanism
[   13.972074] RTmac: init realtime media access control
[   13.977064] RTcfg: init real-time configuration distribution protocol
[   13.983752] initializing loopback...
[   13.987295] RTnet: registered rtlo
[   13.993238] RTnet: registered rteth0
[   13.996832] libphy: MACB_mii_bus: probed
[   14.001140] rt_macb: rteth0: Cadence GEM at 0xe000b000 irq 26 (00:0a:35:00:01:22)
[   14.008630] rt_macb: rteth0: attached PHY driver [Marvell 88E1510] (mii_bus:phy_addr=e000b000.ethernet-ffffffff:00, irq=-1)
[   14.019845] RTcap: real-time capturing interface
[   14.026562] RTproxy attached to rteth0
[   14.031129] rtnetproxy installed as "rtproxy"
[   14.035693] NET: Registered protocol family 26
[   14.040309] NET: Registered protocol family 17
[   14.044686] can: controller area network core (rev 20120528 abi 9)
[   14.050957] NET: Registered protocol family 29
[   14.055329] can: raw protocol (rev 20120528)
[   14.059683] can: broadcast manager protocol (rev 20120528 t)

 kernel/drivers/net/Kconfig         |   1 -
 kernel/drivers/net/addons/Kconfig  |   4 +-
 kernel/drivers/net/drivers/Kconfig |  22 +++---
 kernel/drivers/net/stack/Makefile  |  16 ++---
 utils/net/rtnet.in                 | 138 ++++++++++++++++++++++++-------------
 5 files changed, 110 insertions(+), 71 deletions(-)

diff --git a/kernel/drivers/net/Kconfig b/kernel/drivers/net/Kconfig
index ac3bced..49d2402 100644
--- a/kernel/drivers/net/Kconfig
+++ b/kernel/drivers/net/Kconfig
@@ -1,7 +1,6 @@
 menu "RTnet"

 config XENO_DRIVERS_NET
-    depends on m
     select NET
     tristate "RTnet, TCP/IP socket interface"

diff --git a/kernel/drivers/net/addons/Kconfig b/kernel/drivers/net/addons/Kconfig
index baa6cbc..616ed40 100644
--- a/kernel/drivers/net/addons/Kconfig
+++ b/kernel/drivers/net/addons/Kconfig
@@ -2,7 +2,7 @@ menu "Add-Ons"
     depends on XENO_DRIVERS_NET

 config XENO_DRIVERS_NET_ADDON_RTCAP
-    depends on XENO_DRIVERS_NET && m
+    depends on XENO_DRIVERS_NET
     select ETHERNET
     tristate "Real-Time Capturing Support"
     default n
@@ -18,7 +18,7 @@ config XENO_DRIVERS_NET_ADDON_RTCAP
     For further information see Documentation/README.rtcap.

 config XENO_DRIVERS_NET_ADDON_PROXY
-    depends on XENO_DRIVERS_NET_RTIPV4 && m
+    depends on XENO_DRIVERS_NET_RTIPV4
     select ETHERNET
     tristate "IP protocol proxy for Linux"
     default n
diff --git a/kernel/drivers/net/drivers/Kconfig b/kernel/drivers/net/drivers/Kconfig
index 65f0855..6140f94 100644
--- a/kernel/drivers/net/drivers/Kconfig
+++ b/kernel/drivers/net/drivers/Kconfig
@@ -10,7 +10,7 @@ config XENO_DRIVERS_NET_DRV_PCNET32


 config XENO_DRIVERS_NET_DRV_TULIP
-    depends on XENO_DRIVERS_NET && PCI
+    depends on XENO_DRIVERS_NET && PCI && m
     tristate "DEC Tulip"


@@ -40,12 +40,12 @@ config XENO_DRIVERS_NET_DRV_EEPRO100_DBG


 config XENO_DRIVERS_NET_DRV_E1000
-    depends on XENO_DRIVERS_NET && PCI
+    depends on XENO_DRIVERS_NET && PCI && m
     tristate "Intel(R) PRO/1000 (Gigabit)"
     default y

 config XENO_DRIVERS_NET_DRV_E1000E
-    depends on XENO_DRIVERS_NET && PCI
+    depends on XENO_DRIVERS_NET && PCI && m
     tristate "New Intel(R) PRO/1000 PCIe (Gigabit)"


@@ -68,7 +68,7 @@ config XENO_DRIVERS_NET_DRV_VIA_RHINE
 config XENO_DRIVERS_NET_DRV_IGB
     select I2C
     select I2C_ALGOBIT
-    depends on XENO_DRIVERS_NET && PCI
+    depends on XENO_DRIVERS_NET && PCI && m
     tristate "Intel(R) 82575 (Gigabit)"


@@ -83,22 +83,22 @@ comment "Embedded MPC Drivers"
     depends on XENO_DRIVERS_NET

 config XENO_DRIVERS_NET_DRV_FCC_ENET
-    depends on XENO_DRIVERS_NET
+    depends on XENO_DRIVERS_NET && m
     tristate "MPC8260 FCC Ethernet"


 config XENO_DRIVERS_NET_DRV_FEC_ENET
-    depends on XENO_DRIVERS_NET
+    depends on XENO_DRIVERS_NET && m
     tristate "MPC8xx FEC Ethernet"


 config XENO_DRIVERS_NET_DRV_SCC_ENET
-    depends on XENO_DRIVERS_NET
+    depends on XENO_DRIVERS_NET && m
     tristate "MPC8xx SCC Ethernet"


 config XENO_DRIVERS_NET_DRV_MPC52XX_FEC
-    depends on XENO_DRIVERS_NET
+    depends on XENO_DRIVERS_NET && m
     tristate "MPC52xx FEC Ethernet"

 endif
@@ -124,9 +124,9 @@ config XENO_DRIVERS_NET_DRV_AT91_ETHER
     tristate "AT91RM9200 Board Ethernet Driver"

 config XENO_DRIVERS_NET_DRV_MACB
-    depends on XENO_DRIVERS_NET && ARCH_AT91
-    select AT91_PROGRAMMABLE_CLOCKS
-    tristate "MACB AT91SAM926x devices"
+    depends on XENO_DRIVERS_NET
+    select AT91_PROGRAMMABLE_CLOCKS if ARCH_AT91
+    tristate "Cadence MACB/GEM devices"
     ---help---
     Driver for internal MAC-controller on AT91SAM926x microcontrollers.
     Porting by Cristiano Mantovani and Stefano Banzi (Marposs SpA).
diff --git a/kernel/drivers/net/stack/Makefile b/kernel/drivers/net/stack/Makefile
index d055dc2..f8db6fa 100644
--- a/kernel/drivers/net/stack/Makefile
+++ b/kernel/drivers/net/stack/Makefile
@@ -1,13 +1,5 @@
 ccflags-y += -Idrivers/xenomai/net/stack/include -Ikernel/

-obj-$(CONFIG_XENO_DRIVERS_NET_RTIPV4) += ipv4/
-
-obj-$(CONFIG_XENO_DRIVERS_NET_RTPACKET) += packet/
-
-obj-$(CONFIG_XENO_DRIVERS_NET_RTMAC) += rtmac/
-
-obj-$(CONFIG_XENO_DRIVERS_NET_RTCFG) += rtcfg/
-
 obj-$(CONFIG_XENO_DRIVERS_NET) += rtnet.o

 rtnet-y :=  \
@@ -23,4 +15,12 @@ rtnet-y :=  \
 	stack_mgr.o \
 	eth.o

+obj-$(CONFIG_XENO_DRIVERS_NET_RTIPV4) += ipv4/
+
+obj-$(CONFIG_XENO_DRIVERS_NET_RTPACKET) += packet/
+
+obj-$(CONFIG_XENO_DRIVERS_NET_RTMAC) += rtmac/
+
+obj-$(CONFIG_XENO_DRIVERS_NET_RTCFG) += rtcfg/
+
 rtnet-$(CONFIG_XENO_DRIVERS_NET_RTWLAN) += rtwlan.o
diff --git a/utils/net/rtnet.in b/utils/net/rtnet.in
index f81a7bb..7e6264c 100644
--- a/utils/net/rtnet.in
+++ b/utils/net/rtnet.in
@@ -31,44 +31,65 @@ EOF
 }

 init_rtnet() {
-    modprobe rtnet >/dev/null || exit 1
-    modprobe rtipv4 >/dev/null || exit 1
-    modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
-
-    for dev in $REBIND_RT_NICS; do
-	if [ -d /sys/bus/pci/devices/$dev/driver ]; then
-	    echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
-	fi
-	echo $dev > /sys/bus/pci/drivers/$RT_DRIVER/bind
-    done
+    if [ ! -d /proc/rtnet ]; then
+        modprobe rtnet >/dev/null || exit 1
+    fi

+    if [ ! -d /proc/rtnet/ipv4 ]; then
+        modprobe rtipv4 >/dev/null || exit 1
+    fi
     for PROTOCOL in $RT_PROTOCOLS; do
-	modprobe rt$PROTOCOL >/dev/null || exit 1
+        if [ ! -d /sys/module/rt$PROTOCOL ]; then
+            if [ "$PROTOCOL" = "packet" ]; then
+                modprobe rt$PROTOCOL >/dev/null 2>&1
+            else
+                modprobe rt$PROTOCOL >/dev/null || exit 1
+            fi
+        fi
     done

+    if ! grep q rteth0 /proc/rtnet/devices; then
+        modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
+
+        for dev in $REBIND_RT_NICS; do
+            if [ -d /sys/bus/pci/devices/$dev/driver ]; then
+                echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
+            fi
+            echo $dev > /sys/bus/pci/drivers/$RT_DRIVER/bind
+        done
+    fi
+
     if [ $RT_LOOPBACK = "yes" ]; then
-	modprobe rt_loopback >/dev/null || exit 1
+        if ! grep q rtlo /proc/rtnet/devices; then
+            modprobe rt_loopback >/dev/null || exit 1
+        fi
     fi

-    if [ $RTCAP = "yes" ]; then
-	modprobe rtcap >/dev/null || exit 1
+    if [ $RTCAP = "yes" -a ! -d /sys/module/rtcap ]; then
+        modprobe rtcap >/dev/null || exit 1
     fi

     if [ $RT_LOOPBACK = "yes" ]; then
-	$RTIFCONFIG rtlo up 127.0.0.1
+        $RTIFCONFIG rtlo up 127.0.0.1
     fi

     if [ $RTCAP = "yes" ]; then
-	ifconfig rteth0 up
-	ifconfig rteth0-mac up
-	if [ $RT_LOOPBACK = "yes" ]; then
-	    ifconfig rtlo up
-	fi
+        ifconfig rteth0 up
+        ifconfig rteth0-mac up
+        if [ $RT_LOOPBACK = "yes" ]; then
+            ifconfig rtlo up
+        fi
     fi

-    modprobe rtcfg >/dev/null
-    modprobe rtmac >/dev/null
-    modprobe tdma >/dev/null
+    if [ ! -d /proc/rtnet/rtcfg ]; then
+        modprobe rtcfg >/dev/null
+    fi
+    if [ ! -d /proc/rtnet/rtmac ]; then
+        modprobe rtmac >/dev/null
+    fi
+    if [ ! -f /proc/tdma ]; then
+        modprobe tdma >/dev/null
+    fi
 }

 submit_cfg() {
@@ -336,34 +357,53 @@ case "$1" in
 	;;

     capture)
-	modprobe rtnet >/dev/null || exit 1
-	modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
-	modprobe rtcap >/dev/null || exit 1
-	$RTIFCONFIG rteth0 up promisc
-	ifconfig rteth0 up
-	ifconfig rteth0-mac up
-	;;
+        if [ ! -d /proc/rtnet ]; then
+            modprobe rtnet >/dev/null || exit 1
+        fi
+        if ! grep q rteth0 /proc/rtnet/devices; then
+            modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
+        fi
+        if [ ! -d /sys/module/rtcap ]; then
+            modprobe rtcap >/dev/null || exit 1
+        fi
+        $RTIFCONFIG rteth0 up promisc
+        ifconfig rteth0 up
+        ifconfig rteth0-mac up
+        ;;

     loopback)
-	modprobe rtnet >/dev/null || exit 1
-	modprobe rtipv4 >/dev/null || exit 1
-
-	for PROTOCOL in $RT_PROTOCOLS; do
-	    modprobe rt$PROTOCOL >/dev/null || exit 1
-	done
-
-	modprobe rt_loopback >/dev/null || exit 1
-
-	if [ $RTCAP = "yes" ]; then
-	    modprobe rtcap >/dev/null || exit 1
-	fi
-
-	$RTIFCONFIG rtlo up 127.0.0.1
-
-	if [ $RTCAP = "yes" ]; then
-	    ifconfig rtlo up
-	fi
-	;;
+        if [ ! -d /proc/rtnet ]; then
+            modprobe rtnet >/dev/null || exit 1
+        fi
+        if [ ! -d /proc/rtnet/ipv4 ]; then
+            modprobe rtipv4 >/dev/null || exit 1
+        fi
+        for PROTOCOL in $RT_PROTOCOLS; do
+            if [ ! -d /sys/module/rt$PROTOCOL ]; then
+                if [ "$PROTOCOL" = "packet" ]; then
+                    modprobe rt$PROTOCOL >/dev/null 2>&1
+                else
+                    modprobe rt$PROTOCOL >/dev/null || exit 1
+                fi
+            fi
+        done
+
+        if [ $RT_LOOPBACK = "yes" ]; then
+            if ! grep q rtlo /proc/rtnet/devices; then
+                modprobe rt_loopback >/dev/null || exit 1
+            fi
+        fi
+
+        if [ $RTCAP = "yes" -a ! -d /sys/module/rtcap ]; then
+            modprobe rtcap >/dev/null || exit 1
+        fi
+
+        $RTIFCONFIG rtlo up 127.0.0.1
+
+        if [ $RTCAP = "yes" ]; then
+            ifconfig rtlo up
+        fi
+        ;;

     *)
 	usage
--
2.1.4



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH] Allow RTNet to be builtin kernel
       [not found] <b80-5d9cb700-133-62bca880@213435307>
@ 2019-10-08 16:24 ` Jan Kiszka
  2019-10-09  7:21   ` François Legal
  0 siblings, 1 reply; 17+ messages in thread
From: Jan Kiszka @ 2019-10-08 16:24 UTC (permalink / raw)
  To: François Legal; +Cc: Xenomai

On 08.10.19 18:19, François Legal wrote:
> Le Vendredi, Octobre 04, 2019 18:24 CEST, Jan Kiszka <jan.kiszka@siemens.com> a écrit: 
>  
>> On 04.10.19 17:29, François Legal wrote:
>>> Le Vendredi, Octobre 04, 2019 17:16 CEST, François Legal via Xenomai <xenomai@xenomai.org> a écrit:
>>>   
>>>> Le Vendredi, Octobre 04, 2019 16:31 CEST, Jan Kiszka <jan.kiszka@siemens.com> a écrit:
>>>>   
>>>>> On 04.10.19 16:22, François Legal wrote:
>>>>>> Le Vendredi, Octobre 04, 2019 15:36 CEST, Jan Kiszka <jan.kiszka@siemens.com> a écrit:
>>>>>>    
>>>>>>> On 04.10.19 13:10, Jan Kiszka wrote:
>>>>>>>> On 03.10.19 10:10, François Legal via Xenomai wrote:
>>>>>>>>> Subject: [PATCH] Allow RTNet to be builtin kernel
>>>>>>>>>
>>>>>>>>> Makefile is changed because when builtin, the modules
>>>>>>>>> get loaded in the link order. In the previous version
>>>>>>>>> protocols would get loaded before stackmgr which
>>>>>>>>> obviously fails.
>>>>>>>>>
>>>>>>>>> Signed-off-by: François LEGAL <devel@thom.fr.eu.org>
>>>>>>>>>
>>>>>>>>> ---
>>>>>>>>>
>>>>>>>>> This has been tested on Zynq 7000 Hardware (microzed
>>>>>>>>> board) with MACB/GEM RTNet driver, with linux 4.4.189
>>>>>>>>> vanilla. Kernel boots up correctly, and the following
>>>>>>>>> messages get printed on the console during the boot :
>>>>>>>>>
>>>>>>>>> [   13.875451] sdhci-pltfm: SDHCI platform and OF driver helper
>>>>>>>>> [   13.881627] sdhci-arasan e0100000.sdhci: No vmmc regulator found
>>>>>>>>> [   13.887581] sdhci-arasan e0100000.sdhci: No vqmmc regulator found
>>>>>>>>> [   13.927585] mmc0: SDHCI controller on e0100000.sdhci [e0100000.sdhci] using ADMA
>>>>>>>>> [   13.945085] fpga_manager fpga0: Xilinx Zynq FPGA Manager registered
>>>>>>>>> [   13.951896]
>>>>>>>>> [   13.951896] *** RTnet for Xenomai v3.0.9 ***
>>>>>>>>> [   13.951896]
>>>>>>>>> [   13.959156] RTnet: initialising real-time networking
>>>>>>>>> [   13.964928] RTmac/TDMA: init time division multiple access control mechanism
>>>>>>>>> [   13.972074] RTmac: init realtime media access control
>>>>>>>>> [   13.977064] RTcfg: init real-time configuration distribution protocol
>>>>>>>>> [   13.983752] initializing loopback...
>>>>>>>>> [   13.987295] RTnet: registered rtlo
>>>>>>>>> [   13.993238] RTnet: registered rteth0
>>>>>>>>> [   13.996832] libphy: MACB_mii_bus: probed
>>>>>>>>> [   14.001140] rt_macb: rteth0: Cadence GEM at 0xe000b000 irq 26 (00:0a:35:00:01:22)
>>>>>>>>> [   14.008630] rt_macb: rteth0: attached PHY driver [Marvell 88E1510] (mii_bus:phy_addr=e000b000.ethernet-ffffffff:00, irq=-1)
>>>>>>>>> [   14.019845] RTcap: real-time capturing interface
>>>>>>>>> [   14.026562] RTproxy attached to rteth0
>>>>>>>>> [   14.031129] rtnetproxy installed as "rtproxy"
>>>>>>>>> [   14.035693] NET: Registered protocol family 26
>>>>>>>>> [   14.040309] NET: Registered protocol family 17
>>>>>>>>> [   14.044686] can: controller area network core (rev 20120528 abi 9)
>>>>>>>>> [   14.050957] NET: Registered protocol family 29
>>>>>>>>> [   14.055329] can: raw protocol (rev 20120528)
>>>>>>>>> [   14.059683] can: broadcast manager protocol (rev 20120528 t)
>>>>>>>>>
>>>>>>>>>      kernel/drivers/net/Kconfig        |  1 -
>>>>>>>>>      kernel/drivers/net/addons/Kconfig |  4 ++--
>>>>>>>>>      kernel/drivers/net/stack/Makefile | 16 ++++++++--------
>>>>>>>>>      utils/net/rtnet.in | 144 +++++++++++++++++++++++++++++++++++------------------
>>>>>>>>>      4 files changed, 105 insertions(+), 60 deletions(-)
>>>>>>>>>
>>>>>>>>> diff --git a/kernel/drivers/net/Kconfig b/kernel/drivers/net/Kconfig
>>>>>>>>> index ac3bced..49d2402 100644
>>>>>>>>> --- a/kernel/drivers/net/Kconfig
>>>>>>>>> +++ b/kernel/drivers/net/Kconfig
>>>>>>>>> @@ -1,7 +1,6 @@
>>>>>>>>>      menu "RTnet"
>>>>>>>>>      
>>>>>>>>>      config XENO_DRIVERS_NET
>>>>>>>>> -    depends on m
>>>>>>>>>          select NET
>>>>>>>>>          tristate "RTnet, TCP/IP socket interface"
>>>>>>>>>      
>>>>>>>>> diff --git a/kernel/drivers/net/addons/Kconfig b/kernel/drivers/net/addons/Kconfig
>>>>>>>>> index baa6cbc..616ed40 100644
>>>>>>>>> --- a/kernel/drivers/net/addons/Kconfig
>>>>>>>>> +++ b/kernel/drivers/net/addons/Kconfig
>>>>>>>>> @@ -2,7 +2,7 @@ menu "Add-Ons"
>>>>>>>>>          depends on XENO_DRIVERS_NET
>>>>>>>>>      
>>>>>>>>>      config XENO_DRIVERS_NET_ADDON_RTCAP
>>>>>>>>> -    depends on XENO_DRIVERS_NET && m
>>>>>>>>> +    depends on XENO_DRIVERS_NET
>>>>>>>>>          select ETHERNET
>>>>>>>>>          tristate "Real-Time Capturing Support"
>>>>>>>>>          default n
>>>>>>>>> @@ -18,7 +18,7 @@ config XENO_DRIVERS_NET_ADDON_RTCAP
>>>>>>>>>          For further information see Documentation/README.rtcap.
>>>>>>>>>      
>>>>>>>>>      config XENO_DRIVERS_NET_ADDON_PROXY
>>>>>>>>> -    depends on XENO_DRIVERS_NET_RTIPV4 && m
>>>>>>>>> +    depends on XENO_DRIVERS_NET_RTIPV4
>>>>>>>>>          select ETHERNET
>>>>>>>>>          tristate "IP protocol proxy for Linux"
>>>>>>>>>          default n
>>>>>>>>> diff --git a/kernel/drivers/net/stack/Makefile b/kernel/drivers/net/stack/Makefile
>>>>>>>>> index d055dc2..f8db6fa 100644
>>>>>>>>> --- a/kernel/drivers/net/stack/Makefile
>>>>>>>>> +++ b/kernel/drivers/net/stack/Makefile
>>>>>>>>> @@ -1,13 +1,5 @@
>>>>>>>>>      ccflags-y += -Idrivers/xenomai/net/stack/include -Ikernel/> >>>>
>>>>>>>>> -obj-$(CONFIG_XENO_DRIVERS_NET_RTIPV4) += ipv4/
>>>>>>>>> -
>>>>>>>>> -obj-$(CONFIG_XENO_DRIVERS_NET_RTPACKET) += packet/
>>>>>>>>> -
>>>>>>>>> -obj-$(CONFIG_XENO_DRIVERS_NET_RTMAC) += rtmac/
>>>>>>>>> -
>>>>>>>>> -obj-$(CONFIG_XENO_DRIVERS_NET_RTCFG) += rtcfg/
>>>>>>>>> -
>>>>>>>>>      obj-$(CONFIG_XENO_DRIVERS_NET) += rtnet.o
>>>>>>>>>      
>>>>>>>>>      rtnet-y :=  \
>>>>>>>>> @@ -23,4 +15,12 @@ rtnet-y :=  \
>>>>>>>>>      	stack_mgr.o \
>>>>>>>>>      	eth.o
>>>>>>>>>      
>>>>>>>>> +obj-$(CONFIG_XENO_DRIVERS_NET_RTIPV4) += ipv4/
>>>>>>>>> +
>>>>>>>>> +obj-$(CONFIG_XENO_DRIVERS_NET_RTPACKET) += packet/
>>>>>>>>> +
>>>>>>>>> +obj-$(CONFIG_XENO_DRIVERS_NET_RTMAC) += rtmac/
>>>>>>>>> +
>>>>>>>>> +obj-$(CONFIG_XENO_DRIVERS_NET_RTCFG) += rtcfg/
>>>>>>>>> +
>>>>>>>>>      rtnet-$(CONFIG_XENO_DRIVERS_NET_RTWLAN) += rtwlan.o
>>>>>>>>> diff --git a/utils/net/rtnet.in b/utils/net/rtnet.in
>>>>>>>>> index f81a7bb..fa12a03 100644
>>>>>>>>> --- a/utils/net/rtnet.in
>>>>>>>>> +++ b/utils/net/rtnet.in
>>>>>>>>> @@ -31,44 +31,68 @@ EOF
>>>>>>>>>      }
>>>>>>>>>      
>>>>>>>>>      init_rtnet() {
>>>>>>>>> -    modprobe rtnet >/dev/null || exit 1
>>>>>>>>> -    modprobe rtipv4 >/dev/null || exit 1
>>>>>>>>> -    modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
>>>>>>>>> -
>>>>>>>>> -    for dev in $REBIND_RT_NICS; do
>>>>>>>>> -	if [ -d /sys/bus/pci/devices/$dev/driver ]; then
>>>>>>>>> -	    echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
>>>>>>>>> -	fi
>>>>>>>>> -	echo $dev > /sys/bus/pci/drivers/$RT_DRIVER/bind
>>>>>>>>> -    done
>>>>>>>>> +    if [ ! -d /proc/rtnet ]; then
>>>>>>>>> +        modprobe rtnet >/dev/null || exit 1
>>>>>>>>> +    fi
>>>>>>>>>      
>>>>>>>>> +    if [ ! -d /proc/rtnet/ipv4 ]; then
>>>>>>>>> +        modprobe rtipv4 >/dev/null || exit 1
>>>>>>>>> +    fi
>>>>>>>>>          for PROTOCOL in $RT_PROTOCOLS; do
>>>>>>>>> -	modprobe rt$PROTOCOL >/dev/null || exit 1
>>>>>>>>> +        if [ ! -d /sys/modules/rt$PROTOCOL ]; then
>>>>>>>>> +            if [ "$PROTOCOL" = "packet" ]; then
>>>>>>>>> +                modprobe rt$PROTOCOL >/dev/null
>>>>>>>>> +            else
>>>>>>>>> +                modprobe rt$PROTOCOL >/dev/null || exit 1
>>>>>>>>> +            fi
>>>>>>>>> +        fi
>>>>>>>>>          done
>>>>>>>>>      
>>>>>>>>> +    $(cat /proc/rtnet/devices | grep -q rteth0)
>>>>>>>>> +    if [ $? -eq 1 ]; then
>>>>>>>>> +        modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
>>>>>>>>> +
>>>>>>>>> +        for dev in $REBIND_RT_NICS; do
>>>>>>>>> +            if [ -d /sys/bus/pci/devices/$dev/driver ]; then
>>>>>>>>> +                echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
>>>>>>>>> +            fi
>>>>>>>>> +            echo $dev > /sys/bus/pci/drivers/$RT_DRIVER/bind
>>>>>>>>> +        done
>>>>>>>>> +    fi
>>>>>>>>> +
>>>>>>>>>          if [ $RT_LOOPBACK = "yes" ]; then
>>>>>>>>> -	modprobe rt_loopback >/dev/null || exit 1
>>>>>>>>> +        $(cat /proc/rtnet/devices | grep -q rtlo)
>>>>>>>>> +        if [ $? -eq 1 ]; then
>>>>>>>>> +
>>>>>>>>> +            modprobe rt_loopback >/dev/null || exit 1
>>>>>>>>> +        fi
>>>>>>>>>          fi
>>>>>>>>>      
>>>>>>>>> -    if [ $RTCAP = "yes" ]; then
>>>>>>>>> -	modprobe rtcap >/dev/null || exit 1
>>>>>>>>> +    if [ $RTCAP = "yes" -a ! -d /sys/modules/rtcap ]; then
>>>>>>>>> +        modprobe rtcap >/dev/null || exit 1
>>>>>>>>>          fi
>>>>>>>>>      
>>>>>>>>>          if [ $RT_LOOPBACK = "yes" ]; then
>>>>>>>>> -	$RTIFCONFIG rtlo up 127.0.0.1
>>>>>>>>> +        $RTIFCONFIG rtlo up 127.0.0.1
>>>>>>>>>          fi
>>>>>>>>>      
>>>>>>>>>          if [ $RTCAP = "yes" ]; then
>>>>>>>>> -	ifconfig rteth0 up
>>>>>>>>> -	ifconfig rteth0-mac up
>>>>>>>>> -	if [ $RT_LOOPBACK = "yes" ]; then
>>>>>>>>> -	    ifconfig rtlo up
>>>>>>>>> -	fi
>>>>>>>>> +        ifconfig rteth0 up
>>>>>>>>> +        ifconfig rteth0-mac up
>>>>>>>>> +        if [ $RT_LOOPBACK = "yes" ]; then
>>>>>>>>> +            ifconfig rtlo up
>>>>>>>>> +        fi
>>>>>>>>>          fi
>>>>>>>>>      
>>>>>>>>> -    modprobe rtcfg >/dev/null
>>>>>>>>> -    modprobe rtmac >/dev/null
>>>>>>>>> -    modprobe tdma >/dev/null
>>>>>>>>> +    if [ ! -d /proc/rtnet/rtcfg ]; then
>>>>>>>>> +        modprobe rtcfg >/dev/null
>>>>>>>>> +    fi
>>>>>>>>> +    if [ ! -d /proc/rtnet/rtmac ]; then
>>>>>>>>> +        modprobe rtmac >/dev/null
>>>>>>>>> +    fi
>>>>>>>>> +    if [ ! -f /proc/tdma ]; then
>>>>>>>>> +        modprobe tdma >/dev/null
>>>>>>>>> +    fi
>>>>>>>>>      }
>>>>>>>>>      
>>>>>>>>>      submit_cfg() {
>>>>>>>>> @@ -336,34 +360,56 @@ case "$1" in
>>>>>>>>>      	;;
>>>>>>>>>      
>>>>>>>>>          capture)
>>>>>>>>> -	modprobe rtnet >/dev/null || exit 1
>>>>>>>>> -	modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
>>>>>>>>> -	modprobe rtcap >/dev/null || exit 1
>>>>>>>>> -	$RTIFCONFIG rteth0 up promisc
>>>>>>>>> -	ifconfig rteth0 up
>>>>>>>>> -	ifconfig rteth0-mac up
>>>>>>>>> -	;;
>>>>>>>>> +        if [ ! -d /proc/rtnet ]; then
>>>>>>>>> +            modprobe rtnet >/dev/null || exit 1
>>>>>>>>> +        fi
>>>>>>>>> +        $(cat /proc/rtnet/devices | grep -q rteth0)
>>>>>>>>> +        if [ $? -eq 1 ]; then
>>>>>>>>> +            modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
>>>>>>>>> +        fi
>>>>>>>>> +        if [ ! -d /sys/modules/rtcap ]; then
>>>>>>>>> +            modprobe rtcap >/dev/null || exit 1
>>>>>>>>> +        fi
>>>>>>>>> +        $RTIFCONFIG rteth0 up promisc
>>>>>>>>> +        ifconfig rteth0 up
>>>>>>>>> +        ifconfig rteth0-mac up
>>>>>>>>> +        ;;
>>>>>>>>>      
>>>>>>>>>          loopback)
>>>>>>>>> -	modprobe rtnet >/dev/null || exit 1
>>>>>>>>> -	modprobe rtipv4 >/dev/null || exit 1
>>>>>>>>> -
>>>>>>>>> -	for PROTOCOL in $RT_PROTOCOLS; do
>>>>>>>>> -	    modprobe rt$PROTOCOL >/dev/null || exit 1
>>>>>>>>> -	done
>>>>>>>>> -
>>>>>>>>> -	modprobe rt_loopback >/dev/null || exit 1
>>>>>>>>> -
>>>>>>>>> -	if [ $RTCAP = "yes" ]; then
>>>>>>>>> -	    modprobe rtcap >/dev/null || exit 1
>>>>>>>>> -	fi
>>>>>>>>> -
>>>>>>>>> -	$RTIFCONFIG rtlo up 127.0.0.1
>>>>>>>>> -
>>>>>>>>> -	if [ $RTCAP = "yes" ]; then
>>>>>>>>> -	    ifconfig rtlo up
>>>>>>>>> -	fi
>>>>>>>>> -	;;
>>>>>>>>> +        if [ ! -d /proc/rtnet ]; then
>>>>>>>>> +            modprobe rtnet >/dev/null || exit 1
>>>>>>>>> +        fi
>>>>>>>>> +        if [ ! -d /proc/rtnet/ipv4 ]; then
>>>>>>>>> +            modprobe rtipv4 >/dev/null || exit 1
>>>>>>>>> +        fi
>>>>>>>>> +        for PROTOCOL in $RT_PROTOCOLS; do
>>>>>>>>> +            if [ ! -d /sys/modules/rt$PROTOCOL ]; then
>>>>>>>>> +                if [ "$PROTOCOL" = "packet" ]; then
>>>>>>>>> +                    modprobe rt$PROTOCOL >/dev/null
>>>>>>>>> +                else
>>>>>>>>> +                    modprobe rt$PROTOCOL >/dev/null || exit 1
>>>>>>>>> +                fi
>>>>>>>>> +            fi
>>>>>>>>> +        done
>>>>>>>>> +
>>>>>>>>> +        if [ $RT_LOOPBACK = "yes" ]; then
>>>>>>>>> +            $(cat /proc/rtnet/devices | grep -q rtlo)
>>>>>>>>> +            if [ $? -eq 1 ]; then
>>>>>>>>> +
>>>>>>>>> +                modprobe rt_loopback >/dev/null || exit 1
>>>>>>>>> +            fi
>>>>>>>>> +        fi
>>>>>>>>> +
>>>>>>>>> +        if [ $RTCAP = "yes" -a ! -d /sys/modules/rtcap ]; then
>>>>>>>>> +            modprobe rtcap >/dev/null || exit 1
>>>>>>>>> +        fi
>>>>>>>>> +
>>>>>>>>> +        $RTIFCONFIG rtlo up 127.0.0.1
>>>>>>>>> +
>>>>>>>>> +        if [ $RTCAP = "yes" ]; then
>>>>>>>>> +            ifconfig rtlo up
>>>>>>>>> +        fi
>>>>>>>>> +        ;;
>>>>>>>>>      
>>>>>>>>>          *)
>>>>>>>>>      	usage
>>>>>>>>>
>>>>>>>>
>>>>>>>> Could you check if this delta on top works as well?
>>>>>>>>
>>>>>>>> diff --git a/utils/net/rtnet.in b/utils/net/rtnet.in
>>>>>>>> index fa12a0378a..84f7eed00d 100644
>>>>>>>> --- a/utils/net/rtnet.in
>>>>>>>> +++ b/utils/net/rtnet.in
>>>>>>>> @@ -48,8 +48,7 @@ init_rtnet() {
>>>>>>>>             fi
>>>>>>>>         done
>>>>>>>>     
>>>>>>>> -    $(cat /proc/rtnet/devices | grep -q rteth0)
>>>>>>>> -    if [ $? -eq 1 ]; then
>>>>>>>> +    if grep -vq rteth0 /proc/rtnet/devices; then
>>>>>>>>             modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
>>>>>>>>     
>>>>>>>>             for dev in $REBIND_RT_NICS; do
>>>>>>>> @@ -61,9 +60,7 @@ init_rtnet() {
>>>>>>>>         fi
>>>>>>>>     
>>>>>>>>         if [ $RT_LOOPBACK = "yes" ]; then
>>>>>>>> -        $(cat /proc/rtnet/devices | grep -q rtlo)
>>>>>>>> -        if [ $? -eq 1 ]; then
>>>>>>>> -
>>>>>>>> +        if grep -vq rtlo /proc/rtnet/devices; then
>>>>>>>>                 modprobe rt_loopback >/dev/null || exit 1
>>>>>>>>             fi
>>>>>>>>         fi
>>>>>>>> @@ -363,8 +360,7 @@ case "$1" in
>>>>>>>>             if [ ! -d /proc/rtnet ]; then
>>>>>>>>                 modprobe rtnet >/dev/null || exit 1
>>>>>>>>             fi
>>>>>>>> -        $(cat /proc/rtnet/devices | grep -q rteth0)
>>>>>>>> -        if [ $? -eq 1 ]; then
>>>>>>>> +        if grep -vq rteth0 /proc/rtnet/devices; then
>>>>>>>>                 modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
>>>>>>>>             fi
>>>>>>>>             if [ ! -d /sys/modules/rtcap ]; then
>>>>>>>> @@ -393,9 +389,7 @@ case "$1" in
>>>>>>>>             done
>>>>>>>>     
>>>>>>>>             if [ $RT_LOOPBACK = "yes" ]; then
>>>>>>>> -            $(cat /proc/rtnet/devices | grep -q rtlo)
>>>>>>>> -            if [ $? -eq 1 ]; then
>>>>>>>> -
>>>>>>>> +            if grep -vq rtlo /proc/rtnet/devices; then
>>>>>>>>                     modprobe rt_loopback >/dev/null || exit 1
>>>>>>>>                 fi
>>>>>>>>             fi
>>>>>>>>
>>>>>>>> Then I would prefer it and would merge the combination to next. It looks
>>>>>>>> safe and orthogonal enough for -rc2.
>>>>>>>
>>>>>>> Nah, not yet. We need to check the drivers first. At least the e1000 have
>>>>>>> non-static symbols that collide with the in-tree version.
>>>>>>>
>>>>>>> Jan
>>>>>>>
>>>>>>
>>>>>> Anyway, what you proposed does not work as there is an header line in the file which will match anyway (plus there is likely another network interface there too, causing your rule to fail.
>>>>>>
>>>>>> We could replace that with :
>>>>>> grep -q rtlo /proc/rtnet/devices || modprobe rt_loopback >/dev/null || exit 1
>>>>>>
>>>>>> I can send the patch back that way if that fits your rules.
>>>>>
>>>>> Ah, yeah, not the same... But then do "if ! grep -q ...".
>>>>>
>>>>> Regarding the symbol conflicts: Maybe we start with marking all drivers "depends
>>>>> m", and then dropping those step-wise which do not conflict with their upstream
>>>>> siblings. But it is important to check that by building both into the kernel.
>>>>>
>>>>> Jan
>>>>
>>>> grep ! -q... does the trick !
>>>> About making both drivers builtin, I could try for the PCI ones, and the result is (AFAICT), the following ones conflict with linux :
>>>> - XENO_DRIVERS_NET_DRV_TULIP
>>>> - XENO_DRIVERS_NET_DRV_E1000
>>>> - XENO_DRIVERS_NET_DRV_E1000E
>>>> - XENO_DRIVERS_NET_DRV_IGB
>>>>
>>>> I can't check for the XENO_DRIVERS_NET_DRV_E1000_NEW that does not even build (at least on 3.0.9).
>>>> I'll try to hack into the Kconfig to try to build the PPC drivers, and come back to the list.
>>>>
>>>> Please note that I did not say the other drivers work builtin (which I tested only for MACB/GEM), I can tell they compile and link with linux. I attach the kernel config so that you may double check.
>>>>
>>>> François
>>>
>>>
>>> Well, it's going to be a mess to try to build the PPC driver with an ARM cross compiler (probably the same with an x86 one).
>>> If anybody on the list can try and tell me so that I could adjust the patch.
>>
>> You could try in CI, maybe just adjusting our .travis.yml. If you have a github 
>> account, fork https://github.com/xenomai-ci/xenomai and set up your own travis, 
>> like on https://travis-ci.com/xenomai-ci/xenomai. But the safe option remains to 
>> keep those on "depends on m" which can't be tested yet.
>>
> 
> I tried my best to build those PPC drivers, but I did not succeed. Seems that some files are missing for each and any one of them (<asm/mpc8xx.h>, <asm/immap_8260.h>, <asm/system.h>, <bestcomm_api.h>, ...)
> 
> I don't know if tht is related to the kernel version (4.4.189) I'm using, but I propose to let the dependency on module for these one and resubmit the patch this way.

Ack. And who knows, maybe they just bit-rotted.

Jan

-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] Allow RTNet to be builtin kernel
       [not found] <b7f-5d976580-6b-344a2840@235496640>
@ 2019-10-04 16:24 ` Jan Kiszka
  0 siblings, 0 replies; 17+ messages in thread
From: Jan Kiszka @ 2019-10-04 16:24 UTC (permalink / raw)
  To: François Legal, François Legal; +Cc: Xenomai

On 04.10.19 17:29, François Legal wrote:
> Le Vendredi, Octobre 04, 2019 17:16 CEST, François Legal via Xenomai <xenomai@xenomai.org> a écrit:
>   
>> Le Vendredi, Octobre 04, 2019 16:31 CEST, Jan Kiszka <jan.kiszka@siemens.com> a écrit:
>>   
>>> On 04.10.19 16:22, François Legal wrote:
>>>> Le Vendredi, Octobre 04, 2019 15:36 CEST, Jan Kiszka <jan.kiszka@siemens.com> a écrit:
>>>>    
>>>>> On 04.10.19 13:10, Jan Kiszka wrote:
>>>>>> On 03.10.19 10:10, François Legal via Xenomai wrote:
>>>>>>> Subject: [PATCH] Allow RTNet to be builtin kernel
>>>>>>>
>>>>>>> Makefile is changed because when builtin, the modules
>>>>>>> get loaded in the link order. In the previous version
>>>>>>> protocols would get loaded before stackmgr which
>>>>>>> obviously fails.
>>>>>>>
>>>>>>> Signed-off-by: François LEGAL <devel@thom.fr.eu.org>
>>>>>>>
>>>>>>> ---
>>>>>>>
>>>>>>> This has been tested on Zynq 7000 Hardware (microzed
>>>>>>> board) with MACB/GEM RTNet driver, with linux 4.4.189
>>>>>>> vanilla. Kernel boots up correctly, and the following
>>>>>>> messages get printed on the console during the boot :
>>>>>>>
>>>>>>> [   13.875451] sdhci-pltfm: SDHCI platform and OF driver helper
>>>>>>> [   13.881627] sdhci-arasan e0100000.sdhci: No vmmc regulator found
>>>>>>> [   13.887581] sdhci-arasan e0100000.sdhci: No vqmmc regulator found
>>>>>>> [   13.927585] mmc0: SDHCI controller on e0100000.sdhci [e0100000.sdhci] using ADMA
>>>>>>> [   13.945085] fpga_manager fpga0: Xilinx Zynq FPGA Manager registered
>>>>>>> [   13.951896]
>>>>>>> [   13.951896] *** RTnet for Xenomai v3.0.9 ***
>>>>>>> [   13.951896]
>>>>>>> [   13.959156] RTnet: initialising real-time networking
>>>>>>> [   13.964928] RTmac/TDMA: init time division multiple access control mechanism
>>>>>>> [   13.972074] RTmac: init realtime media access control
>>>>>>> [   13.977064] RTcfg: init real-time configuration distribution protocol
>>>>>>> [   13.983752] initializing loopback...
>>>>>>> [   13.987295] RTnet: registered rtlo
>>>>>>> [   13.993238] RTnet: registered rteth0
>>>>>>> [   13.996832] libphy: MACB_mii_bus: probed
>>>>>>> [   14.001140] rt_macb: rteth0: Cadence GEM at 0xe000b000 irq 26 (00:0a:35:00:01:22)
>>>>>>> [   14.008630] rt_macb: rteth0: attached PHY driver [Marvell 88E1510] (mii_bus:phy_addr=e000b000.ethernet-ffffffff:00, irq=-1)
>>>>>>> [   14.019845] RTcap: real-time capturing interface
>>>>>>> [   14.026562] RTproxy attached to rteth0
>>>>>>> [   14.031129] rtnetproxy installed as "rtproxy"
>>>>>>> [   14.035693] NET: Registered protocol family 26
>>>>>>> [   14.040309] NET: Registered protocol family 17
>>>>>>> [   14.044686] can: controller area network core (rev 20120528 abi 9)
>>>>>>> [   14.050957] NET: Registered protocol family 29
>>>>>>> [   14.055329] can: raw protocol (rev 20120528)
>>>>>>> [   14.059683] can: broadcast manager protocol (rev 20120528 t)
>>>>>>>
>>>>>>>      kernel/drivers/net/Kconfig        |  1 -
>>>>>>>      kernel/drivers/net/addons/Kconfig |  4 ++--
>>>>>>>      kernel/drivers/net/stack/Makefile | 16 ++++++++--------
>>>>>>>      utils/net/rtnet.in | 144 +++++++++++++++++++++++++++++++++++------------------
>>>>>>>      4 files changed, 105 insertions(+), 60 deletions(-)
>>>>>>>
>>>>>>> diff --git a/kernel/drivers/net/Kconfig b/kernel/drivers/net/Kconfig
>>>>>>> index ac3bced..49d2402 100644
>>>>>>> --- a/kernel/drivers/net/Kconfig
>>>>>>> +++ b/kernel/drivers/net/Kconfig
>>>>>>> @@ -1,7 +1,6 @@
>>>>>>>      menu "RTnet"
>>>>>>>      
>>>>>>>      config XENO_DRIVERS_NET
>>>>>>> -    depends on m
>>>>>>>          select NET
>>>>>>>          tristate "RTnet, TCP/IP socket interface"
>>>>>>>      
>>>>>>> diff --git a/kernel/drivers/net/addons/Kconfig b/kernel/drivers/net/addons/Kconfig
>>>>>>> index baa6cbc..616ed40 100644
>>>>>>> --- a/kernel/drivers/net/addons/Kconfig
>>>>>>> +++ b/kernel/drivers/net/addons/Kconfig
>>>>>>> @@ -2,7 +2,7 @@ menu "Add-Ons"
>>>>>>>          depends on XENO_DRIVERS_NET
>>>>>>>      
>>>>>>>      config XENO_DRIVERS_NET_ADDON_RTCAP
>>>>>>> -    depends on XENO_DRIVERS_NET && m
>>>>>>> +    depends on XENO_DRIVERS_NET
>>>>>>>          select ETHERNET
>>>>>>>          tristate "Real-Time Capturing Support"
>>>>>>>          default n
>>>>>>> @@ -18,7 +18,7 @@ config XENO_DRIVERS_NET_ADDON_RTCAP
>>>>>>>          For further information see Documentation/README.rtcap.
>>>>>>>      
>>>>>>>      config XENO_DRIVERS_NET_ADDON_PROXY
>>>>>>> -    depends on XENO_DRIVERS_NET_RTIPV4 && m
>>>>>>> +    depends on XENO_DRIVERS_NET_RTIPV4
>>>>>>>          select ETHERNET
>>>>>>>          tristate "IP protocol proxy for Linux"
>>>>>>>          default n
>>>>>>> diff --git a/kernel/drivers/net/stack/Makefile b/kernel/drivers/net/stack/Makefile
>>>>>>> index d055dc2..f8db6fa 100644
>>>>>>> --- a/kernel/drivers/net/stack/Makefile
>>>>>>> +++ b/kernel/drivers/net/stack/Makefile
>>>>>>> @@ -1,13 +1,5 @@
>>>>>>>      ccflags-y += -Idrivers/xenomai/net/stack/include -Ikernel/> >>>>
>>>>>>> -obj-$(CONFIG_XENO_DRIVERS_NET_RTIPV4) += ipv4/
>>>>>>> -
>>>>>>> -obj-$(CONFIG_XENO_DRIVERS_NET_RTPACKET) += packet/
>>>>>>> -
>>>>>>> -obj-$(CONFIG_XENO_DRIVERS_NET_RTMAC) += rtmac/
>>>>>>> -
>>>>>>> -obj-$(CONFIG_XENO_DRIVERS_NET_RTCFG) += rtcfg/
>>>>>>> -
>>>>>>>      obj-$(CONFIG_XENO_DRIVERS_NET) += rtnet.o
>>>>>>>      
>>>>>>>      rtnet-y :=  \
>>>>>>> @@ -23,4 +15,12 @@ rtnet-y :=  \
>>>>>>>      	stack_mgr.o \
>>>>>>>      	eth.o
>>>>>>>      
>>>>>>> +obj-$(CONFIG_XENO_DRIVERS_NET_RTIPV4) += ipv4/
>>>>>>> +
>>>>>>> +obj-$(CONFIG_XENO_DRIVERS_NET_RTPACKET) += packet/
>>>>>>> +
>>>>>>> +obj-$(CONFIG_XENO_DRIVERS_NET_RTMAC) += rtmac/
>>>>>>> +
>>>>>>> +obj-$(CONFIG_XENO_DRIVERS_NET_RTCFG) += rtcfg/
>>>>>>> +
>>>>>>>      rtnet-$(CONFIG_XENO_DRIVERS_NET_RTWLAN) += rtwlan.o
>>>>>>> diff --git a/utils/net/rtnet.in b/utils/net/rtnet.in
>>>>>>> index f81a7bb..fa12a03 100644
>>>>>>> --- a/utils/net/rtnet.in
>>>>>>> +++ b/utils/net/rtnet.in
>>>>>>> @@ -31,44 +31,68 @@ EOF
>>>>>>>      }
>>>>>>>      
>>>>>>>      init_rtnet() {
>>>>>>> -    modprobe rtnet >/dev/null || exit 1
>>>>>>> -    modprobe rtipv4 >/dev/null || exit 1
>>>>>>> -    modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
>>>>>>> -
>>>>>>> -    for dev in $REBIND_RT_NICS; do
>>>>>>> -	if [ -d /sys/bus/pci/devices/$dev/driver ]; then
>>>>>>> -	    echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
>>>>>>> -	fi
>>>>>>> -	echo $dev > /sys/bus/pci/drivers/$RT_DRIVER/bind
>>>>>>> -    done
>>>>>>> +    if [ ! -d /proc/rtnet ]; then
>>>>>>> +        modprobe rtnet >/dev/null || exit 1
>>>>>>> +    fi
>>>>>>>      
>>>>>>> +    if [ ! -d /proc/rtnet/ipv4 ]; then
>>>>>>> +        modprobe rtipv4 >/dev/null || exit 1
>>>>>>> +    fi
>>>>>>>          for PROTOCOL in $RT_PROTOCOLS; do
>>>>>>> -	modprobe rt$PROTOCOL >/dev/null || exit 1
>>>>>>> +        if [ ! -d /sys/modules/rt$PROTOCOL ]; then
>>>>>>> +            if [ "$PROTOCOL" = "packet" ]; then
>>>>>>> +                modprobe rt$PROTOCOL >/dev/null
>>>>>>> +            else
>>>>>>> +                modprobe rt$PROTOCOL >/dev/null || exit 1
>>>>>>> +            fi
>>>>>>> +        fi
>>>>>>>          done
>>>>>>>      
>>>>>>> +    $(cat /proc/rtnet/devices | grep -q rteth0)
>>>>>>> +    if [ $? -eq 1 ]; then
>>>>>>> +        modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
>>>>>>> +
>>>>>>> +        for dev in $REBIND_RT_NICS; do
>>>>>>> +            if [ -d /sys/bus/pci/devices/$dev/driver ]; then
>>>>>>> +                echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
>>>>>>> +            fi
>>>>>>> +            echo $dev > /sys/bus/pci/drivers/$RT_DRIVER/bind
>>>>>>> +        done
>>>>>>> +    fi
>>>>>>> +
>>>>>>>          if [ $RT_LOOPBACK = "yes" ]; then
>>>>>>> -	modprobe rt_loopback >/dev/null || exit 1
>>>>>>> +        $(cat /proc/rtnet/devices | grep -q rtlo)
>>>>>>> +        if [ $? -eq 1 ]; then
>>>>>>> +
>>>>>>> +            modprobe rt_loopback >/dev/null || exit 1
>>>>>>> +        fi
>>>>>>>          fi
>>>>>>>      
>>>>>>> -    if [ $RTCAP = "yes" ]; then
>>>>>>> -	modprobe rtcap >/dev/null || exit 1
>>>>>>> +    if [ $RTCAP = "yes" -a ! -d /sys/modules/rtcap ]; then
>>>>>>> +        modprobe rtcap >/dev/null || exit 1
>>>>>>>          fi
>>>>>>>      
>>>>>>>          if [ $RT_LOOPBACK = "yes" ]; then
>>>>>>> -	$RTIFCONFIG rtlo up 127.0.0.1
>>>>>>> +        $RTIFCONFIG rtlo up 127.0.0.1
>>>>>>>          fi
>>>>>>>      
>>>>>>>          if [ $RTCAP = "yes" ]; then
>>>>>>> -	ifconfig rteth0 up
>>>>>>> -	ifconfig rteth0-mac up
>>>>>>> -	if [ $RT_LOOPBACK = "yes" ]; then
>>>>>>> -	    ifconfig rtlo up
>>>>>>> -	fi
>>>>>>> +        ifconfig rteth0 up
>>>>>>> +        ifconfig rteth0-mac up
>>>>>>> +        if [ $RT_LOOPBACK = "yes" ]; then
>>>>>>> +            ifconfig rtlo up
>>>>>>> +        fi
>>>>>>>          fi
>>>>>>>      
>>>>>>> -    modprobe rtcfg >/dev/null
>>>>>>> -    modprobe rtmac >/dev/null
>>>>>>> -    modprobe tdma >/dev/null
>>>>>>> +    if [ ! -d /proc/rtnet/rtcfg ]; then
>>>>>>> +        modprobe rtcfg >/dev/null
>>>>>>> +    fi
>>>>>>> +    if [ ! -d /proc/rtnet/rtmac ]; then
>>>>>>> +        modprobe rtmac >/dev/null
>>>>>>> +    fi
>>>>>>> +    if [ ! -f /proc/tdma ]; then
>>>>>>> +        modprobe tdma >/dev/null
>>>>>>> +    fi
>>>>>>>      }
>>>>>>>      
>>>>>>>      submit_cfg() {
>>>>>>> @@ -336,34 +360,56 @@ case "$1" in
>>>>>>>      	;;
>>>>>>>      
>>>>>>>          capture)
>>>>>>> -	modprobe rtnet >/dev/null || exit 1
>>>>>>> -	modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
>>>>>>> -	modprobe rtcap >/dev/null || exit 1
>>>>>>> -	$RTIFCONFIG rteth0 up promisc
>>>>>>> -	ifconfig rteth0 up
>>>>>>> -	ifconfig rteth0-mac up
>>>>>>> -	;;
>>>>>>> +        if [ ! -d /proc/rtnet ]; then
>>>>>>> +            modprobe rtnet >/dev/null || exit 1
>>>>>>> +        fi
>>>>>>> +        $(cat /proc/rtnet/devices | grep -q rteth0)
>>>>>>> +        if [ $? -eq 1 ]; then
>>>>>>> +            modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
>>>>>>> +        fi
>>>>>>> +        if [ ! -d /sys/modules/rtcap ]; then
>>>>>>> +            modprobe rtcap >/dev/null || exit 1
>>>>>>> +        fi
>>>>>>> +        $RTIFCONFIG rteth0 up promisc
>>>>>>> +        ifconfig rteth0 up
>>>>>>> +        ifconfig rteth0-mac up
>>>>>>> +        ;;
>>>>>>>      
>>>>>>>          loopback)
>>>>>>> -	modprobe rtnet >/dev/null || exit 1
>>>>>>> -	modprobe rtipv4 >/dev/null || exit 1
>>>>>>> -
>>>>>>> -	for PROTOCOL in $RT_PROTOCOLS; do
>>>>>>> -	    modprobe rt$PROTOCOL >/dev/null || exit 1
>>>>>>> -	done
>>>>>>> -
>>>>>>> -	modprobe rt_loopback >/dev/null || exit 1
>>>>>>> -
>>>>>>> -	if [ $RTCAP = "yes" ]; then
>>>>>>> -	    modprobe rtcap >/dev/null || exit 1
>>>>>>> -	fi
>>>>>>> -
>>>>>>> -	$RTIFCONFIG rtlo up 127.0.0.1
>>>>>>> -
>>>>>>> -	if [ $RTCAP = "yes" ]; then
>>>>>>> -	    ifconfig rtlo up
>>>>>>> -	fi
>>>>>>> -	;;
>>>>>>> +        if [ ! -d /proc/rtnet ]; then
>>>>>>> +            modprobe rtnet >/dev/null || exit 1
>>>>>>> +        fi
>>>>>>> +        if [ ! -d /proc/rtnet/ipv4 ]; then
>>>>>>> +            modprobe rtipv4 >/dev/null || exit 1
>>>>>>> +        fi
>>>>>>> +        for PROTOCOL in $RT_PROTOCOLS; do
>>>>>>> +            if [ ! -d /sys/modules/rt$PROTOCOL ]; then
>>>>>>> +                if [ "$PROTOCOL" = "packet" ]; then
>>>>>>> +                    modprobe rt$PROTOCOL >/dev/null
>>>>>>> +                else
>>>>>>> +                    modprobe rt$PROTOCOL >/dev/null || exit 1
>>>>>>> +                fi
>>>>>>> +            fi
>>>>>>> +        done
>>>>>>> +
>>>>>>> +        if [ $RT_LOOPBACK = "yes" ]; then
>>>>>>> +            $(cat /proc/rtnet/devices | grep -q rtlo)
>>>>>>> +            if [ $? -eq 1 ]; then
>>>>>>> +
>>>>>>> +                modprobe rt_loopback >/dev/null || exit 1
>>>>>>> +            fi
>>>>>>> +        fi
>>>>>>> +
>>>>>>> +        if [ $RTCAP = "yes" -a ! -d /sys/modules/rtcap ]; then
>>>>>>> +            modprobe rtcap >/dev/null || exit 1
>>>>>>> +        fi
>>>>>>> +
>>>>>>> +        $RTIFCONFIG rtlo up 127.0.0.1
>>>>>>> +
>>>>>>> +        if [ $RTCAP = "yes" ]; then
>>>>>>> +            ifconfig rtlo up
>>>>>>> +        fi
>>>>>>> +        ;;
>>>>>>>      
>>>>>>>          *)
>>>>>>>      	usage
>>>>>>>
>>>>>>
>>>>>> Could you check if this delta on top works as well?
>>>>>>
>>>>>> diff --git a/utils/net/rtnet.in b/utils/net/rtnet.in
>>>>>> index fa12a0378a..84f7eed00d 100644
>>>>>> --- a/utils/net/rtnet.in
>>>>>> +++ b/utils/net/rtnet.in
>>>>>> @@ -48,8 +48,7 @@ init_rtnet() {
>>>>>>             fi
>>>>>>         done
>>>>>>     
>>>>>> -    $(cat /proc/rtnet/devices | grep -q rteth0)
>>>>>> -    if [ $? -eq 1 ]; then
>>>>>> +    if grep -vq rteth0 /proc/rtnet/devices; then
>>>>>>             modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
>>>>>>     
>>>>>>             for dev in $REBIND_RT_NICS; do
>>>>>> @@ -61,9 +60,7 @@ init_rtnet() {
>>>>>>         fi
>>>>>>     
>>>>>>         if [ $RT_LOOPBACK = "yes" ]; then
>>>>>> -        $(cat /proc/rtnet/devices | grep -q rtlo)
>>>>>> -        if [ $? -eq 1 ]; then
>>>>>> -
>>>>>> +        if grep -vq rtlo /proc/rtnet/devices; then
>>>>>>                 modprobe rt_loopback >/dev/null || exit 1
>>>>>>             fi
>>>>>>         fi
>>>>>> @@ -363,8 +360,7 @@ case "$1" in
>>>>>>             if [ ! -d /proc/rtnet ]; then
>>>>>>                 modprobe rtnet >/dev/null || exit 1
>>>>>>             fi
>>>>>> -        $(cat /proc/rtnet/devices | grep -q rteth0)
>>>>>> -        if [ $? -eq 1 ]; then
>>>>>> +        if grep -vq rteth0 /proc/rtnet/devices; then
>>>>>>                 modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
>>>>>>             fi
>>>>>>             if [ ! -d /sys/modules/rtcap ]; then
>>>>>> @@ -393,9 +389,7 @@ case "$1" in
>>>>>>             done
>>>>>>     
>>>>>>             if [ $RT_LOOPBACK = "yes" ]; then
>>>>>> -            $(cat /proc/rtnet/devices | grep -q rtlo)
>>>>>> -            if [ $? -eq 1 ]; then
>>>>>> -
>>>>>> +            if grep -vq rtlo /proc/rtnet/devices; then
>>>>>>                     modprobe rt_loopback >/dev/null || exit 1
>>>>>>                 fi
>>>>>>             fi
>>>>>>
>>>>>> Then I would prefer it and would merge the combination to next. It looks
>>>>>> safe and orthogonal enough for -rc2.
>>>>>
>>>>> Nah, not yet. We need to check the drivers first. At least the e1000 have
>>>>> non-static symbols that collide with the in-tree version.
>>>>>
>>>>> Jan
>>>>>
>>>>
>>>> Anyway, what you proposed does not work as there is an header line in the file which will match anyway (plus there is likely another network interface there too, causing your rule to fail.
>>>>
>>>> We could replace that with :
>>>> grep -q rtlo /proc/rtnet/devices || modprobe rt_loopback >/dev/null || exit 1
>>>>
>>>> I can send the patch back that way if that fits your rules.
>>>
>>> Ah, yeah, not the same... But then do "if ! grep -q ...".
>>>
>>> Regarding the symbol conflicts: Maybe we start with marking all drivers "depends
>>> m", and then dropping those step-wise which do not conflict with their upstream
>>> siblings. But it is important to check that by building both into the kernel.
>>>
>>> Jan
>>
>> grep ! -q... does the trick !
>> About making both drivers builtin, I could try for the PCI ones, and the result is (AFAICT), the following ones conflict with linux :
>> - XENO_DRIVERS_NET_DRV_TULIP
>> - XENO_DRIVERS_NET_DRV_E1000
>> - XENO_DRIVERS_NET_DRV_E1000E
>> - XENO_DRIVERS_NET_DRV_IGB
>>
>> I can't check for the XENO_DRIVERS_NET_DRV_E1000_NEW that does not even build (at least on 3.0.9).
>> I'll try to hack into the Kconfig to try to build the PPC drivers, and come back to the list.
>>
>> Please note that I did not say the other drivers work builtin (which I tested only for MACB/GEM), I can tell they compile and link with linux. I attach the kernel config so that you may double check.
>>
>> François
> 
> 
> Well, it's going to be a mess to try to build the PPC driver with an ARM cross compiler (probably the same with an x86 one).
> If anybody on the list can try and tell me so that I could adjust the patch.

You could try in CI, maybe just adjusting our .travis.yml. If you have a github 
account, fork https://github.com/xenomai-ci/xenomai and set up your own travis, 
like on https://travis-ci.com/xenomai-ci/xenomai. But the safe option remains to 
keep those on "depends on m" which can't be tested yet.

Jan

-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] Allow RTNet to be builtin kernel
@ 2019-10-04 15:16 François Legal
  0 siblings, 0 replies; 17+ messages in thread
From: François Legal @ 2019-10-04 15:16 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Xenomai

Le Vendredi, Octobre 04, 2019 16:31 CEST, Jan Kiszka <jan.kiszka@siemens.com> a écrit: 
 
> On 04.10.19 16:22, François Legal wrote:
> > Le Vendredi, Octobre 04, 2019 15:36 CEST, Jan Kiszka <jan.kiszka@siemens.com> a écrit:
> >   
> >> On 04.10.19 13:10, Jan Kiszka wrote:
> >>> On 03.10.19 10:10, François Legal via Xenomai wrote:
> >>>> Subject: [PATCH] Allow RTNet to be builtin kernel
> >>>>
> >>>> Makefile is changed because when builtin, the modules
> >>>> get loaded in the link order. In the previous version
> >>>> protocols would get loaded before stackmgr which
> >>>> obviously fails.
> >>>>
> >>>> Signed-off-by: François LEGAL <devel@thom.fr.eu.org>
> >>>>
> >>>> ---
> >>>>
> >>>> This has been tested on Zynq 7000 Hardware (microzed
> >>>> board) with MACB/GEM RTNet driver, with linux 4.4.189
> >>>> vanilla. Kernel boots up correctly, and the following
> >>>> messages get printed on the console during the boot :
> >>>>
> >>>> [   13.875451] sdhci-pltfm: SDHCI platform and OF driver helper
> >>>> [   13.881627] sdhci-arasan e0100000.sdhci: No vmmc regulator found
> >>>> [   13.887581] sdhci-arasan e0100000.sdhci: No vqmmc regulator found
> >>>> [   13.927585] mmc0: SDHCI controller on e0100000.sdhci [e0100000.sdhci] using ADMA
> >>>> [   13.945085] fpga_manager fpga0: Xilinx Zynq FPGA Manager registered
> >>>> [   13.951896]
> >>>> [   13.951896] *** RTnet for Xenomai v3.0.9 ***
> >>>> [   13.951896]
> >>>> [   13.959156] RTnet: initialising real-time networking
> >>>> [   13.964928] RTmac/TDMA: init time division multiple access control mechanism
> >>>> [   13.972074] RTmac: init realtime media access control
> >>>> [   13.977064] RTcfg: init real-time configuration distribution protocol
> >>>> [   13.983752] initializing loopback...
> >>>> [   13.987295] RTnet: registered rtlo
> >>>> [   13.993238] RTnet: registered rteth0
> >>>> [   13.996832] libphy: MACB_mii_bus: probed
> >>>> [   14.001140] rt_macb: rteth0: Cadence GEM at 0xe000b000 irq 26 (00:0a:35:00:01:22)
> >>>> [   14.008630] rt_macb: rteth0: attached PHY driver [Marvell 88E1510] (mii_bus:phy_addr=e000b000.ethernet-ffffffff:00, irq=-1)
> >>>> [   14.019845] RTcap: real-time capturing interface
> >>>> [   14.026562] RTproxy attached to rteth0
> >>>> [   14.031129] rtnetproxy installed as "rtproxy"
> >>>> [   14.035693] NET: Registered protocol family 26
> >>>> [   14.040309] NET: Registered protocol family 17
> >>>> [   14.044686] can: controller area network core (rev 20120528 abi 9)
> >>>> [   14.050957] NET: Registered protocol family 29
> >>>> [   14.055329] can: raw protocol (rev 20120528)
> >>>> [   14.059683] can: broadcast manager protocol (rev 20120528 t)
> >>>>
> >>>>     kernel/drivers/net/Kconfig        |  1 -
> >>>>     kernel/drivers/net/addons/Kconfig |  4 ++--
> >>>>     kernel/drivers/net/stack/Makefile | 16 ++++++++--------
> >>>>     utils/net/rtnet.in | 144 +++++++++++++++++++++++++++++++++++------------------
> >>>>     4 files changed, 105 insertions(+), 60 deletions(-)
> >>>>
> >>>> diff --git a/kernel/drivers/net/Kconfig b/kernel/drivers/net/Kconfig
> >>>> index ac3bced..49d2402 100644
> >>>> --- a/kernel/drivers/net/Kconfig
> >>>> +++ b/kernel/drivers/net/Kconfig
> >>>> @@ -1,7 +1,6 @@
> >>>>     menu "RTnet"
> >>>>     
> >>>>     config XENO_DRIVERS_NET
> >>>> -    depends on m
> >>>>         select NET
> >>>>         tristate "RTnet, TCP/IP socket interface"
> >>>>     
> >>>> diff --git a/kernel/drivers/net/addons/Kconfig b/kernel/drivers/net/addons/Kconfig
> >>>> index baa6cbc..616ed40 100644
> >>>> --- a/kernel/drivers/net/addons/Kconfig
> >>>> +++ b/kernel/drivers/net/addons/Kconfig
> >>>> @@ -2,7 +2,7 @@ menu "Add-Ons"
> >>>>         depends on XENO_DRIVERS_NET
> >>>>     
> >>>>     config XENO_DRIVERS_NET_ADDON_RTCAP
> >>>> -    depends on XENO_DRIVERS_NET && m
> >>>> +    depends on XENO_DRIVERS_NET
> >>>>         select ETHERNET
> >>>>         tristate "Real-Time Capturing Support"
> >>>>         default n
> >>>> @@ -18,7 +18,7 @@ config XENO_DRIVERS_NET_ADDON_RTCAP
> >>>>         For further information see Documentation/README.rtcap.
> >>>>     
> >>>>     config XENO_DRIVERS_NET_ADDON_PROXY
> >>>> -    depends on XENO_DRIVERS_NET_RTIPV4 && m
> >>>> +    depends on XENO_DRIVERS_NET_RTIPV4
> >>>>         select ETHERNET
> >>>>         tristate "IP protocol proxy for Linux"
> >>>>         default n
> >>>> diff --git a/kernel/drivers/net/stack/Makefile b/kernel/drivers/net/stack/Makefile
> >>>> index d055dc2..f8db6fa 100644
> >>>> --- a/kernel/drivers/net/stack/Makefile
> >>>> +++ b/kernel/drivers/net/stack/Makefile
> >>>> @@ -1,13 +1,5 @@
> >>>>     ccflags-y += -Idrivers/xenomai/net/stack/include -Ikernel/> >>>>     
> >>>> -obj-$(CONFIG_XENO_DRIVERS_NET_RTIPV4) += ipv4/
> >>>> -
> >>>> -obj-$(CONFIG_XENO_DRIVERS_NET_RTPACKET) += packet/
> >>>> -
> >>>> -obj-$(CONFIG_XENO_DRIVERS_NET_RTMAC) += rtmac/
> >>>> -
> >>>> -obj-$(CONFIG_XENO_DRIVERS_NET_RTCFG) += rtcfg/
> >>>> -
> >>>>     obj-$(CONFIG_XENO_DRIVERS_NET) += rtnet.o
> >>>>     
> >>>>     rtnet-y :=  \
> >>>> @@ -23,4 +15,12 @@ rtnet-y :=  \
> >>>>     	stack_mgr.o \
> >>>>     	eth.o
> >>>>     
> >>>> +obj-$(CONFIG_XENO_DRIVERS_NET_RTIPV4) += ipv4/
> >>>> +
> >>>> +obj-$(CONFIG_XENO_DRIVERS_NET_RTPACKET) += packet/
> >>>> +
> >>>> +obj-$(CONFIG_XENO_DRIVERS_NET_RTMAC) += rtmac/
> >>>> +
> >>>> +obj-$(CONFIG_XENO_DRIVERS_NET_RTCFG) += rtcfg/
> >>>> +
> >>>>     rtnet-$(CONFIG_XENO_DRIVERS_NET_RTWLAN) += rtwlan.o
> >>>> diff --git a/utils/net/rtnet.in b/utils/net/rtnet.in
> >>>> index f81a7bb..fa12a03 100644
> >>>> --- a/utils/net/rtnet.in
> >>>> +++ b/utils/net/rtnet.in
> >>>> @@ -31,44 +31,68 @@ EOF
> >>>>     }
> >>>>     
> >>>>     init_rtnet() {
> >>>> -    modprobe rtnet >/dev/null || exit 1
> >>>> -    modprobe rtipv4 >/dev/null || exit 1
> >>>> -    modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
> >>>> -
> >>>> -    for dev in $REBIND_RT_NICS; do
> >>>> -	if [ -d /sys/bus/pci/devices/$dev/driver ]; then
> >>>> -	    echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
> >>>> -	fi
> >>>> -	echo $dev > /sys/bus/pci/drivers/$RT_DRIVER/bind
> >>>> -    done
> >>>> +    if [ ! -d /proc/rtnet ]; then
> >>>> +        modprobe rtnet >/dev/null || exit 1
> >>>> +    fi
> >>>>     
> >>>> +    if [ ! -d /proc/rtnet/ipv4 ]; then
> >>>> +        modprobe rtipv4 >/dev/null || exit 1
> >>>> +    fi
> >>>>         for PROTOCOL in $RT_PROTOCOLS; do
> >>>> -	modprobe rt$PROTOCOL >/dev/null || exit 1
> >>>> +        if [ ! -d /sys/modules/rt$PROTOCOL ]; then
> >>>> +            if [ "$PROTOCOL" = "packet" ]; then
> >>>> +                modprobe rt$PROTOCOL >/dev/null
> >>>> +            else
> >>>> +                modprobe rt$PROTOCOL >/dev/null || exit 1
> >>>> +            fi
> >>>> +        fi
> >>>>         done
> >>>>     
> >>>> +    $(cat /proc/rtnet/devices | grep -q rteth0)
> >>>> +    if [ $? -eq 1 ]; then
> >>>> +        modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
> >>>> +
> >>>> +        for dev in $REBIND_RT_NICS; do
> >>>> +            if [ -d /sys/bus/pci/devices/$dev/driver ]; then
> >>>> +                echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
> >>>> +            fi
> >>>> +            echo $dev > /sys/bus/pci/drivers/$RT_DRIVER/bind
> >>>> +        done
> >>>> +    fi
> >>>> +
> >>>>         if [ $RT_LOOPBACK = "yes" ]; then
> >>>> -	modprobe rt_loopback >/dev/null || exit 1
> >>>> +        $(cat /proc/rtnet/devices | grep -q rtlo)
> >>>> +        if [ $? -eq 1 ]; then
> >>>> +
> >>>> +            modprobe rt_loopback >/dev/null || exit 1
> >>>> +        fi
> >>>>         fi
> >>>>     
> >>>> -    if [ $RTCAP = "yes" ]; then
> >>>> -	modprobe rtcap >/dev/null || exit 1
> >>>> +    if [ $RTCAP = "yes" -a ! -d /sys/modules/rtcap ]; then
> >>>> +        modprobe rtcap >/dev/null || exit 1
> >>>>         fi
> >>>>     
> >>>>         if [ $RT_LOOPBACK = "yes" ]; then
> >>>> -	$RTIFCONFIG rtlo up 127.0.0.1
> >>>> +        $RTIFCONFIG rtlo up 127.0.0.1
> >>>>         fi
> >>>>     
> >>>>         if [ $RTCAP = "yes" ]; then
> >>>> -	ifconfig rteth0 up
> >>>> -	ifconfig rteth0-mac up
> >>>> -	if [ $RT_LOOPBACK = "yes" ]; then
> >>>> -	    ifconfig rtlo up
> >>>> -	fi
> >>>> +        ifconfig rteth0 up
> >>>> +        ifconfig rteth0-mac up
> >>>> +        if [ $RT_LOOPBACK = "yes" ]; then
> >>>> +            ifconfig rtlo up
> >>>> +        fi
> >>>>         fi
> >>>>     
> >>>> -    modprobe rtcfg >/dev/null
> >>>> -    modprobe rtmac >/dev/null
> >>>> -    modprobe tdma >/dev/null
> >>>> +    if [ ! -d /proc/rtnet/rtcfg ]; then
> >>>> +        modprobe rtcfg >/dev/null
> >>>> +    fi
> >>>> +    if [ ! -d /proc/rtnet/rtmac ]; then
> >>>> +        modprobe rtmac >/dev/null
> >>>> +    fi
> >>>> +    if [ ! -f /proc/tdma ]; then
> >>>> +        modprobe tdma >/dev/null
> >>>> +    fi
> >>>>     }
> >>>>     
> >>>>     submit_cfg() {
> >>>> @@ -336,34 +360,56 @@ case "$1" in
> >>>>     	;;
> >>>>     
> >>>>         capture)
> >>>> -	modprobe rtnet >/dev/null || exit 1
> >>>> -	modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
> >>>> -	modprobe rtcap >/dev/null || exit 1
> >>>> -	$RTIFCONFIG rteth0 up promisc
> >>>> -	ifconfig rteth0 up
> >>>> -	ifconfig rteth0-mac up
> >>>> -	;;
> >>>> +        if [ ! -d /proc/rtnet ]; then
> >>>> +            modprobe rtnet >/dev/null || exit 1
> >>>> +        fi
> >>>> +        $(cat /proc/rtnet/devices | grep -q rteth0)
> >>>> +        if [ $? -eq 1 ]; then
> >>>> +            modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
> >>>> +        fi
> >>>> +        if [ ! -d /sys/modules/rtcap ]; then
> >>>> +            modprobe rtcap >/dev/null || exit 1
> >>>> +        fi
> >>>> +        $RTIFCONFIG rteth0 up promisc
> >>>> +        ifconfig rteth0 up
> >>>> +        ifconfig rteth0-mac up
> >>>> +        ;;
> >>>>     
> >>>>         loopback)
> >>>> -	modprobe rtnet >/dev/null || exit 1
> >>>> -	modprobe rtipv4 >/dev/null || exit 1
> >>>> -
> >>>> -	for PROTOCOL in $RT_PROTOCOLS; do
> >>>> -	    modprobe rt$PROTOCOL >/dev/null || exit 1
> >>>> -	done
> >>>> -
> >>>> -	modprobe rt_loopback >/dev/null || exit 1
> >>>> -
> >>>> -	if [ $RTCAP = "yes" ]; then
> >>>> -	    modprobe rtcap >/dev/null || exit 1
> >>>> -	fi
> >>>> -
> >>>> -	$RTIFCONFIG rtlo up 127.0.0.1
> >>>> -
> >>>> -	if [ $RTCAP = "yes" ]; then
> >>>> -	    ifconfig rtlo up
> >>>> -	fi
> >>>> -	;;
> >>>> +        if [ ! -d /proc/rtnet ]; then
> >>>> +            modprobe rtnet >/dev/null || exit 1
> >>>> +        fi
> >>>> +        if [ ! -d /proc/rtnet/ipv4 ]; then
> >>>> +            modprobe rtipv4 >/dev/null || exit 1
> >>>> +        fi
> >>>> +        for PROTOCOL in $RT_PROTOCOLS; do
> >>>> +            if [ ! -d /sys/modules/rt$PROTOCOL ]; then
> >>>> +                if [ "$PROTOCOL" = "packet" ]; then
> >>>> +                    modprobe rt$PROTOCOL >/dev/null
> >>>> +                else
> >>>> +                    modprobe rt$PROTOCOL >/dev/null || exit 1
> >>>> +                fi
> >>>> +            fi
> >>>> +        done
> >>>> +
> >>>> +        if [ $RT_LOOPBACK = "yes" ]; then
> >>>> +            $(cat /proc/rtnet/devices | grep -q rtlo)
> >>>> +            if [ $? -eq 1 ]; then
> >>>> +
> >>>> +                modprobe rt_loopback >/dev/null || exit 1
> >>>> +            fi
> >>>> +        fi
> >>>> +
> >>>> +        if [ $RTCAP = "yes" -a ! -d /sys/modules/rtcap ]; then
> >>>> +            modprobe rtcap >/dev/null || exit 1
> >>>> +        fi
> >>>> +
> >>>> +        $RTIFCONFIG rtlo up 127.0.0.1
> >>>> +
> >>>> +        if [ $RTCAP = "yes" ]; then
> >>>> +            ifconfig rtlo up
> >>>> +        fi
> >>>> +        ;;
> >>>>     
> >>>>         *)
> >>>>     	usage
> >>>>
> >>>
> >>> Could you check if this delta on top works as well?
> >>>
> >>> diff --git a/utils/net/rtnet.in b/utils/net/rtnet.in
> >>> index fa12a0378a..84f7eed00d 100644
> >>> --- a/utils/net/rtnet.in
> >>> +++ b/utils/net/rtnet.in
> >>> @@ -48,8 +48,7 @@ init_rtnet() {
> >>>            fi
> >>>        done
> >>>    
> >>> -    $(cat /proc/rtnet/devices | grep -q rteth0)
> >>> -    if [ $? -eq 1 ]; then
> >>> +    if grep -vq rteth0 /proc/rtnet/devices; then
> >>>            modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
> >>>    
> >>>            for dev in $REBIND_RT_NICS; do
> >>> @@ -61,9 +60,7 @@ init_rtnet() {
> >>>        fi
> >>>    
> >>>        if [ $RT_LOOPBACK = "yes" ]; then
> >>> -        $(cat /proc/rtnet/devices | grep -q rtlo)
> >>> -        if [ $? -eq 1 ]; then
> >>> -
> >>> +        if grep -vq rtlo /proc/rtnet/devices; then
> >>>                modprobe rt_loopback >/dev/null || exit 1
> >>>            fi
> >>>        fi
> >>> @@ -363,8 +360,7 @@ case "$1" in
> >>>            if [ ! -d /proc/rtnet ]; then
> >>>                modprobe rtnet >/dev/null || exit 1
> >>>            fi
> >>> -        $(cat /proc/rtnet/devices | grep -q rteth0)
> >>> -        if [ $? -eq 1 ]; then
> >>> +        if grep -vq rteth0 /proc/rtnet/devices; then
> >>>                modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
> >>>            fi
> >>>            if [ ! -d /sys/modules/rtcap ]; then
> >>> @@ -393,9 +389,7 @@ case "$1" in
> >>>            done
> >>>    
> >>>            if [ $RT_LOOPBACK = "yes" ]; then
> >>> -            $(cat /proc/rtnet/devices | grep -q rtlo)
> >>> -            if [ $? -eq 1 ]; then
> >>> -
> >>> +            if grep -vq rtlo /proc/rtnet/devices; then
> >>>                    modprobe rt_loopback >/dev/null || exit 1
> >>>                fi
> >>>            fi
> >>>
> >>> Then I would prefer it and would merge the combination to next. It looks
> >>> safe and orthogonal enough for -rc2.
> >>
> >> Nah, not yet. We need to check the drivers first. At least the e1000 have
> >> non-static symbols that collide with the in-tree version.
> >>
> >> Jan
> >>
> > 
> > Anyway, what you proposed does not work as there is an header line in the file which will match anyway (plus there is likely another network interface there too, causing your rule to fail.
> > 
> > We could replace that with :
> > grep -q rtlo /proc/rtnet/devices || modprobe rt_loopback >/dev/null || exit 1
> > 
> > I can send the patch back that way if that fits your rules.
> 
> Ah, yeah, not the same... But then do "if ! grep -q ...".
> 
> Regarding the symbol conflicts: Maybe we start with marking all drivers "depends 
> m", and then dropping those step-wise which do not conflict with their upstream 
> siblings. But it is important to check that by building both into the kernel.
> 
> Jan

grep ! -q... does the trick !
About making both drivers builtin, I could try for the PCI ones, and the result is (AFAICT), the following ones conflict with linux :
- XENO_DRIVERS_NET_DRV_TULIP
- XENO_DRIVERS_NET_DRV_E1000
- XENO_DRIVERS_NET_DRV_E1000E
- XENO_DRIVERS_NET_DRV_IGB

I can't check for the XENO_DRIVERS_NET_DRV_E1000_NEW that does not even build (at least on 3.0.9).
I'll try to hack into the Kconfig to try to build the PPC drivers, and come back to the list.

Please note that I did not say the other drivers work builtin (which I tested only for MACB/GEM), I can tell they compile and link with linux. I attach the kernel config so that you may double check.

François

- 


> 
> -- 
> Siemens AG, Corporate Technology, CT RDA IOT SES-DE
> Corporate Competence Center Embedded Linux

-------------- next part --------------
A non-text attachment was scrubbed...
Name: config
Type: application/octet-stream
Size: 74709 bytes
Desc: not available
URL: <http://xenomai.org/pipermail/xenomai/attachments/20191004/e79e649f/attachment.obj>

^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] Allow RTNet to be builtin kernel
  2019-10-04 14:22     ` François Legal
@ 2019-10-04 14:31       ` Jan Kiszka
       [not found]         ` <VI1PR05MB59174B531D2FFC88C2E05458F6950@VI1PR05MB5917.eurprd05.prod.outlook.com>
  0 siblings, 1 reply; 17+ messages in thread
From: Jan Kiszka @ 2019-10-04 14:31 UTC (permalink / raw)
  To: François Legal; +Cc: Xenomai

On 04.10.19 16:22, François Legal wrote:
> Le Vendredi, Octobre 04, 2019 15:36 CEST, Jan Kiszka <jan.kiszka@siemens.com> a écrit:
>   
>> On 04.10.19 13:10, Jan Kiszka wrote:
>>> On 03.10.19 10:10, François Legal via Xenomai wrote:
>>>> Subject: [PATCH] Allow RTNet to be builtin kernel
>>>>
>>>> Makefile is changed because when builtin, the modules
>>>> get loaded in the link order. In the previous version
>>>> protocols would get loaded before stackmgr which
>>>> obviously fails.
>>>>
>>>> Signed-off-by: François LEGAL <devel@thom.fr.eu.org>
>>>>
>>>> ---
>>>>
>>>> This has been tested on Zynq 7000 Hardware (microzed
>>>> board) with MACB/GEM RTNet driver, with linux 4.4.189
>>>> vanilla. Kernel boots up correctly, and the following
>>>> messages get printed on the console during the boot :
>>>>
>>>> [   13.875451] sdhci-pltfm: SDHCI platform and OF driver helper
>>>> [   13.881627] sdhci-arasan e0100000.sdhci: No vmmc regulator found
>>>> [   13.887581] sdhci-arasan e0100000.sdhci: No vqmmc regulator found
>>>> [   13.927585] mmc0: SDHCI controller on e0100000.sdhci [e0100000.sdhci] using ADMA
>>>> [   13.945085] fpga_manager fpga0: Xilinx Zynq FPGA Manager registered
>>>> [   13.951896]
>>>> [   13.951896] *** RTnet for Xenomai v3.0.9 ***
>>>> [   13.951896]
>>>> [   13.959156] RTnet: initialising real-time networking
>>>> [   13.964928] RTmac/TDMA: init time division multiple access control mechanism
>>>> [   13.972074] RTmac: init realtime media access control
>>>> [   13.977064] RTcfg: init real-time configuration distribution protocol
>>>> [   13.983752] initializing loopback...
>>>> [   13.987295] RTnet: registered rtlo
>>>> [   13.993238] RTnet: registered rteth0
>>>> [   13.996832] libphy: MACB_mii_bus: probed
>>>> [   14.001140] rt_macb: rteth0: Cadence GEM at 0xe000b000 irq 26 (00:0a:35:00:01:22)
>>>> [   14.008630] rt_macb: rteth0: attached PHY driver [Marvell 88E1510] (mii_bus:phy_addr=e000b000.ethernet-ffffffff:00, irq=-1)
>>>> [   14.019845] RTcap: real-time capturing interface
>>>> [   14.026562] RTproxy attached to rteth0
>>>> [   14.031129] rtnetproxy installed as "rtproxy"
>>>> [   14.035693] NET: Registered protocol family 26
>>>> [   14.040309] NET: Registered protocol family 17
>>>> [   14.044686] can: controller area network core (rev 20120528 abi 9)
>>>> [   14.050957] NET: Registered protocol family 29
>>>> [   14.055329] can: raw protocol (rev 20120528)
>>>> [   14.059683] can: broadcast manager protocol (rev 20120528 t)
>>>>
>>>>     kernel/drivers/net/Kconfig        |  1 -
>>>>     kernel/drivers/net/addons/Kconfig |  4 ++--
>>>>     kernel/drivers/net/stack/Makefile | 16 ++++++++--------
>>>>     utils/net/rtnet.in | 144 +++++++++++++++++++++++++++++++++++------------------
>>>>     4 files changed, 105 insertions(+), 60 deletions(-)
>>>>
>>>> diff --git a/kernel/drivers/net/Kconfig b/kernel/drivers/net/Kconfig
>>>> index ac3bced..49d2402 100644
>>>> --- a/kernel/drivers/net/Kconfig
>>>> +++ b/kernel/drivers/net/Kconfig
>>>> @@ -1,7 +1,6 @@
>>>>     menu "RTnet"
>>>>     
>>>>     config XENO_DRIVERS_NET
>>>> -    depends on m
>>>>         select NET
>>>>         tristate "RTnet, TCP/IP socket interface"
>>>>     
>>>> diff --git a/kernel/drivers/net/addons/Kconfig b/kernel/drivers/net/addons/Kconfig
>>>> index baa6cbc..616ed40 100644
>>>> --- a/kernel/drivers/net/addons/Kconfig
>>>> +++ b/kernel/drivers/net/addons/Kconfig
>>>> @@ -2,7 +2,7 @@ menu "Add-Ons"
>>>>         depends on XENO_DRIVERS_NET
>>>>     
>>>>     config XENO_DRIVERS_NET_ADDON_RTCAP
>>>> -    depends on XENO_DRIVERS_NET && m
>>>> +    depends on XENO_DRIVERS_NET
>>>>         select ETHERNET
>>>>         tristate "Real-Time Capturing Support"
>>>>         default n
>>>> @@ -18,7 +18,7 @@ config XENO_DRIVERS_NET_ADDON_RTCAP
>>>>         For further information see Documentation/README.rtcap.
>>>>     
>>>>     config XENO_DRIVERS_NET_ADDON_PROXY
>>>> -    depends on XENO_DRIVERS_NET_RTIPV4 && m
>>>> +    depends on XENO_DRIVERS_NET_RTIPV4
>>>>         select ETHERNET
>>>>         tristate "IP protocol proxy for Linux"
>>>>         default n
>>>> diff --git a/kernel/drivers/net/stack/Makefile b/kernel/drivers/net/stack/Makefile
>>>> index d055dc2..f8db6fa 100644
>>>> --- a/kernel/drivers/net/stack/Makefile
>>>> +++ b/kernel/drivers/net/stack/Makefile
>>>> @@ -1,13 +1,5 @@
>>>>     ccflags-y += -Idrivers/xenomai/net/stack/include -Ikernel/
>>>>     
>>>> -obj-$(CONFIG_XENO_DRIVERS_NET_RTIPV4) += ipv4/
>>>> -
>>>> -obj-$(CONFIG_XENO_DRIVERS_NET_RTPACKET) += packet/
>>>> -
>>>> -obj-$(CONFIG_XENO_DRIVERS_NET_RTMAC) += rtmac/
>>>> -
>>>> -obj-$(CONFIG_XENO_DRIVERS_NET_RTCFG) += rtcfg/
>>>> -
>>>>     obj-$(CONFIG_XENO_DRIVERS_NET) += rtnet.o
>>>>     
>>>>     rtnet-y :=  \
>>>> @@ -23,4 +15,12 @@ rtnet-y :=  \
>>>>     	stack_mgr.o \
>>>>     	eth.o
>>>>     
>>>> +obj-$(CONFIG_XENO_DRIVERS_NET_RTIPV4) += ipv4/
>>>> +
>>>> +obj-$(CONFIG_XENO_DRIVERS_NET_RTPACKET) += packet/
>>>> +
>>>> +obj-$(CONFIG_XENO_DRIVERS_NET_RTMAC) += rtmac/
>>>> +
>>>> +obj-$(CONFIG_XENO_DRIVERS_NET_RTCFG) += rtcfg/
>>>> +
>>>>     rtnet-$(CONFIG_XENO_DRIVERS_NET_RTWLAN) += rtwlan.o
>>>> diff --git a/utils/net/rtnet.in b/utils/net/rtnet.in
>>>> index f81a7bb..fa12a03 100644
>>>> --- a/utils/net/rtnet.in
>>>> +++ b/utils/net/rtnet.in
>>>> @@ -31,44 +31,68 @@ EOF
>>>>     }
>>>>     
>>>>     init_rtnet() {
>>>> -    modprobe rtnet >/dev/null || exit 1
>>>> -    modprobe rtipv4 >/dev/null || exit 1
>>>> -    modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
>>>> -
>>>> -    for dev in $REBIND_RT_NICS; do
>>>> -	if [ -d /sys/bus/pci/devices/$dev/driver ]; then
>>>> -	    echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
>>>> -	fi
>>>> -	echo $dev > /sys/bus/pci/drivers/$RT_DRIVER/bind
>>>> -    done
>>>> +    if [ ! -d /proc/rtnet ]; then
>>>> +        modprobe rtnet >/dev/null || exit 1
>>>> +    fi
>>>>     
>>>> +    if [ ! -d /proc/rtnet/ipv4 ]; then
>>>> +        modprobe rtipv4 >/dev/null || exit 1
>>>> +    fi
>>>>         for PROTOCOL in $RT_PROTOCOLS; do
>>>> -	modprobe rt$PROTOCOL >/dev/null || exit 1
>>>> +        if [ ! -d /sys/modules/rt$PROTOCOL ]; then
>>>> +            if [ "$PROTOCOL" = "packet" ]; then
>>>> +                modprobe rt$PROTOCOL >/dev/null
>>>> +            else
>>>> +                modprobe rt$PROTOCOL >/dev/null || exit 1
>>>> +            fi
>>>> +        fi
>>>>         done
>>>>     
>>>> +    $(cat /proc/rtnet/devices | grep -q rteth0)
>>>> +    if [ $? -eq 1 ]; then
>>>> +        modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
>>>> +
>>>> +        for dev in $REBIND_RT_NICS; do
>>>> +            if [ -d /sys/bus/pci/devices/$dev/driver ]; then
>>>> +                echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
>>>> +            fi
>>>> +            echo $dev > /sys/bus/pci/drivers/$RT_DRIVER/bind
>>>> +        done
>>>> +    fi
>>>> +
>>>>         if [ $RT_LOOPBACK = "yes" ]; then
>>>> -	modprobe rt_loopback >/dev/null || exit 1
>>>> +        $(cat /proc/rtnet/devices | grep -q rtlo)
>>>> +        if [ $? -eq 1 ]; then
>>>> +
>>>> +            modprobe rt_loopback >/dev/null || exit 1
>>>> +        fi
>>>>         fi
>>>>     
>>>> -    if [ $RTCAP = "yes" ]; then
>>>> -	modprobe rtcap >/dev/null || exit 1
>>>> +    if [ $RTCAP = "yes" -a ! -d /sys/modules/rtcap ]; then
>>>> +        modprobe rtcap >/dev/null || exit 1
>>>>         fi
>>>>     
>>>>         if [ $RT_LOOPBACK = "yes" ]; then
>>>> -	$RTIFCONFIG rtlo up 127.0.0.1
>>>> +        $RTIFCONFIG rtlo up 127.0.0.1
>>>>         fi
>>>>     
>>>>         if [ $RTCAP = "yes" ]; then
>>>> -	ifconfig rteth0 up
>>>> -	ifconfig rteth0-mac up
>>>> -	if [ $RT_LOOPBACK = "yes" ]; then
>>>> -	    ifconfig rtlo up
>>>> -	fi
>>>> +        ifconfig rteth0 up
>>>> +        ifconfig rteth0-mac up
>>>> +        if [ $RT_LOOPBACK = "yes" ]; then
>>>> +            ifconfig rtlo up
>>>> +        fi
>>>>         fi
>>>>     
>>>> -    modprobe rtcfg >/dev/null
>>>> -    modprobe rtmac >/dev/null
>>>> -    modprobe tdma >/dev/null
>>>> +    if [ ! -d /proc/rtnet/rtcfg ]; then
>>>> +        modprobe rtcfg >/dev/null
>>>> +    fi
>>>> +    if [ ! -d /proc/rtnet/rtmac ]; then
>>>> +        modprobe rtmac >/dev/null
>>>> +    fi
>>>> +    if [ ! -f /proc/tdma ]; then
>>>> +        modprobe tdma >/dev/null
>>>> +    fi
>>>>     }
>>>>     
>>>>     submit_cfg() {
>>>> @@ -336,34 +360,56 @@ case "$1" in
>>>>     	;;
>>>>     
>>>>         capture)
>>>> -	modprobe rtnet >/dev/null || exit 1
>>>> -	modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
>>>> -	modprobe rtcap >/dev/null || exit 1
>>>> -	$RTIFCONFIG rteth0 up promisc
>>>> -	ifconfig rteth0 up
>>>> -	ifconfig rteth0-mac up
>>>> -	;;
>>>> +        if [ ! -d /proc/rtnet ]; then
>>>> +            modprobe rtnet >/dev/null || exit 1
>>>> +        fi
>>>> +        $(cat /proc/rtnet/devices | grep -q rteth0)
>>>> +        if [ $? -eq 1 ]; then
>>>> +            modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
>>>> +        fi
>>>> +        if [ ! -d /sys/modules/rtcap ]; then
>>>> +            modprobe rtcap >/dev/null || exit 1
>>>> +        fi
>>>> +        $RTIFCONFIG rteth0 up promisc
>>>> +        ifconfig rteth0 up
>>>> +        ifconfig rteth0-mac up
>>>> +        ;;
>>>>     
>>>>         loopback)
>>>> -	modprobe rtnet >/dev/null || exit 1
>>>> -	modprobe rtipv4 >/dev/null || exit 1
>>>> -
>>>> -	for PROTOCOL in $RT_PROTOCOLS; do
>>>> -	    modprobe rt$PROTOCOL >/dev/null || exit 1
>>>> -	done
>>>> -
>>>> -	modprobe rt_loopback >/dev/null || exit 1
>>>> -
>>>> -	if [ $RTCAP = "yes" ]; then
>>>> -	    modprobe rtcap >/dev/null || exit 1
>>>> -	fi
>>>> -
>>>> -	$RTIFCONFIG rtlo up 127.0.0.1
>>>> -
>>>> -	if [ $RTCAP = "yes" ]; then
>>>> -	    ifconfig rtlo up
>>>> -	fi
>>>> -	;;
>>>> +        if [ ! -d /proc/rtnet ]; then
>>>> +            modprobe rtnet >/dev/null || exit 1
>>>> +        fi
>>>> +        if [ ! -d /proc/rtnet/ipv4 ]; then
>>>> +            modprobe rtipv4 >/dev/null || exit 1
>>>> +        fi
>>>> +        for PROTOCOL in $RT_PROTOCOLS; do
>>>> +            if [ ! -d /sys/modules/rt$PROTOCOL ]; then
>>>> +                if [ "$PROTOCOL" = "packet" ]; then
>>>> +                    modprobe rt$PROTOCOL >/dev/null
>>>> +                else
>>>> +                    modprobe rt$PROTOCOL >/dev/null || exit 1
>>>> +                fi
>>>> +            fi
>>>> +        done
>>>> +
>>>> +        if [ $RT_LOOPBACK = "yes" ]; then
>>>> +            $(cat /proc/rtnet/devices | grep -q rtlo)
>>>> +            if [ $? -eq 1 ]; then
>>>> +
>>>> +                modprobe rt_loopback >/dev/null || exit 1
>>>> +            fi
>>>> +        fi
>>>> +
>>>> +        if [ $RTCAP = "yes" -a ! -d /sys/modules/rtcap ]; then
>>>> +            modprobe rtcap >/dev/null || exit 1
>>>> +        fi
>>>> +
>>>> +        $RTIFCONFIG rtlo up 127.0.0.1
>>>> +
>>>> +        if [ $RTCAP = "yes" ]; then
>>>> +            ifconfig rtlo up
>>>> +        fi
>>>> +        ;;
>>>>     
>>>>         *)
>>>>     	usage
>>>>
>>>
>>> Could you check if this delta on top works as well?
>>>
>>> diff --git a/utils/net/rtnet.in b/utils/net/rtnet.in
>>> index fa12a0378a..84f7eed00d 100644
>>> --- a/utils/net/rtnet.in
>>> +++ b/utils/net/rtnet.in
>>> @@ -48,8 +48,7 @@ init_rtnet() {
>>>            fi
>>>        done
>>>    
>>> -    $(cat /proc/rtnet/devices | grep -q rteth0)
>>> -    if [ $? -eq 1 ]; then
>>> +    if grep -vq rteth0 /proc/rtnet/devices; then
>>>            modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
>>>    
>>>            for dev in $REBIND_RT_NICS; do
>>> @@ -61,9 +60,7 @@ init_rtnet() {
>>>        fi
>>>    
>>>        if [ $RT_LOOPBACK = "yes" ]; then
>>> -        $(cat /proc/rtnet/devices | grep -q rtlo)
>>> -        if [ $? -eq 1 ]; then
>>> -
>>> +        if grep -vq rtlo /proc/rtnet/devices; then
>>>                modprobe rt_loopback >/dev/null || exit 1
>>>            fi
>>>        fi
>>> @@ -363,8 +360,7 @@ case "$1" in
>>>            if [ ! -d /proc/rtnet ]; then
>>>                modprobe rtnet >/dev/null || exit 1
>>>            fi
>>> -        $(cat /proc/rtnet/devices | grep -q rteth0)
>>> -        if [ $? -eq 1 ]; then
>>> +        if grep -vq rteth0 /proc/rtnet/devices; then
>>>                modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
>>>            fi
>>>            if [ ! -d /sys/modules/rtcap ]; then
>>> @@ -393,9 +389,7 @@ case "$1" in
>>>            done
>>>    
>>>            if [ $RT_LOOPBACK = "yes" ]; then
>>> -            $(cat /proc/rtnet/devices | grep -q rtlo)
>>> -            if [ $? -eq 1 ]; then
>>> -
>>> +            if grep -vq rtlo /proc/rtnet/devices; then
>>>                    modprobe rt_loopback >/dev/null || exit 1
>>>                fi
>>>            fi
>>>
>>> Then I would prefer it and would merge the combination to next. It looks
>>> safe and orthogonal enough for -rc2.
>>
>> Nah, not yet. We need to check the drivers first. At least the e1000 have
>> non-static symbols that collide with the in-tree version.
>>
>> Jan
>>
> 
> Anyway, what you proposed does not work as there is an header line in the file which will match anyway (plus there is likely another network interface there too, causing your rule to fail.
> 
> We could replace that with :
> grep -q rtlo /proc/rtnet/devices || modprobe rt_loopback >/dev/null || exit 1
> 
> I can send the patch back that way if that fits your rules.

Ah, yeah, not the same... But then do "if ! grep -q ...".

Regarding the symbol conflicts: Maybe we start with marking all drivers "depends 
m", and then dropping those step-wise which do not conflict with their upstream 
siblings. But it is important to check that by building both into the kernel.

Jan

-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] Allow RTNet to be builtin kernel
  2019-10-04 13:36   ` Jan Kiszka
@ 2019-10-04 14:22     ` François Legal
  2019-10-04 14:31       ` Jan Kiszka
  0 siblings, 1 reply; 17+ messages in thread
From: François Legal @ 2019-10-04 14:22 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Xenomai

Le Vendredi, Octobre 04, 2019 15:36 CEST, Jan Kiszka <jan.kiszka@siemens.com> a écrit:

> On 04.10.19 13:10, Jan Kiszka wrote:
> > On 03.10.19 10:10, François Legal via Xenomai wrote:
> >> Subject: [PATCH] Allow RTNet to be builtin kernel
> >>
> >> Makefile is changed because when builtin, the modules
> >> get loaded in the link order. In the previous version
> >> protocols would get loaded before stackmgr which
> >> obviously fails.
> >>
> >> Signed-off-by: François LEGAL <devel@thom.fr.eu.org>
> >>
> >> ---
> >>
> >> This has been tested on Zynq 7000 Hardware (microzed
> >> board) with MACB/GEM RTNet driver, with linux 4.4.189
> >> vanilla. Kernel boots up correctly, and the following
> >> messages get printed on the console during the boot :
> >>
> >> [   13.875451] sdhci-pltfm: SDHCI platform and OF driver helper
> >> [   13.881627] sdhci-arasan e0100000.sdhci: No vmmc regulator found
> >> [   13.887581] sdhci-arasan e0100000.sdhci: No vqmmc regulator found
> >> [   13.927585] mmc0: SDHCI controller on e0100000.sdhci [e0100000.sdhci] using ADMA
> >> [   13.945085] fpga_manager fpga0: Xilinx Zynq FPGA Manager registered
> >> [   13.951896]
> >> [   13.951896] *** RTnet for Xenomai v3.0.9 ***
> >> [   13.951896]
> >> [   13.959156] RTnet: initialising real-time networking
> >> [   13.964928] RTmac/TDMA: init time division multiple access control mechanism
> >> [   13.972074] RTmac: init realtime media access control
> >> [   13.977064] RTcfg: init real-time configuration distribution protocol
> >> [   13.983752] initializing loopback...
> >> [   13.987295] RTnet: registered rtlo
> >> [   13.993238] RTnet: registered rteth0
> >> [   13.996832] libphy: MACB_mii_bus: probed
> >> [   14.001140] rt_macb: rteth0: Cadence GEM at 0xe000b000 irq 26 (00:0a:35:00:01:22)
> >> [   14.008630] rt_macb: rteth0: attached PHY driver [Marvell 88E1510] (mii_bus:phy_addr=e000b000.ethernet-ffffffff:00, irq=-1)
> >> [   14.019845] RTcap: real-time capturing interface
> >> [   14.026562] RTproxy attached to rteth0
> >> [   14.031129] rtnetproxy installed as "rtproxy"
> >> [   14.035693] NET: Registered protocol family 26
> >> [   14.040309] NET: Registered protocol family 17
> >> [   14.044686] can: controller area network core (rev 20120528 abi 9)
> >> [   14.050957] NET: Registered protocol family 29
> >> [   14.055329] can: raw protocol (rev 20120528)
> >> [   14.059683] can: broadcast manager protocol (rev 20120528 t)
> >>
> >>    kernel/drivers/net/Kconfig        |  1 -
> >>    kernel/drivers/net/addons/Kconfig |  4 ++--
> >>    kernel/drivers/net/stack/Makefile | 16 ++++++++--------
> >>    utils/net/rtnet.in | 144 +++++++++++++++++++++++++++++++++++------------------
> >>    4 files changed, 105 insertions(+), 60 deletions(-)
> >>
> >> diff --git a/kernel/drivers/net/Kconfig b/kernel/drivers/net/Kconfig
> >> index ac3bced..49d2402 100644
> >> --- a/kernel/drivers/net/Kconfig
> >> +++ b/kernel/drivers/net/Kconfig
> >> @@ -1,7 +1,6 @@
> >>    menu "RTnet"
> >>
> >>    config XENO_DRIVERS_NET
> >> -    depends on m
> >>        select NET
> >>        tristate "RTnet, TCP/IP socket interface"
> >>
> >> diff --git a/kernel/drivers/net/addons/Kconfig b/kernel/drivers/net/addons/Kconfig
> >> index baa6cbc..616ed40 100644
> >> --- a/kernel/drivers/net/addons/Kconfig
> >> +++ b/kernel/drivers/net/addons/Kconfig
> >> @@ -2,7 +2,7 @@ menu "Add-Ons"
> >>        depends on XENO_DRIVERS_NET
> >>
> >>    config XENO_DRIVERS_NET_ADDON_RTCAP
> >> -    depends on XENO_DRIVERS_NET && m
> >> +    depends on XENO_DRIVERS_NET
> >>        select ETHERNET
> >>        tristate "Real-Time Capturing Support"
> >>        default n
> >> @@ -18,7 +18,7 @@ config XENO_DRIVERS_NET_ADDON_RTCAP
> >>        For further information see Documentation/README.rtcap.
> >>
> >>    config XENO_DRIVERS_NET_ADDON_PROXY
> >> -    depends on XENO_DRIVERS_NET_RTIPV4 && m
> >> +    depends on XENO_DRIVERS_NET_RTIPV4
> >>        select ETHERNET
> >>        tristate "IP protocol proxy for Linux"
> >>        default n
> >> diff --git a/kernel/drivers/net/stack/Makefile b/kernel/drivers/net/stack/Makefile
> >> index d055dc2..f8db6fa 100644
> >> --- a/kernel/drivers/net/stack/Makefile
> >> +++ b/kernel/drivers/net/stack/Makefile
> >> @@ -1,13 +1,5 @@
> >>    ccflags-y += -Idrivers/xenomai/net/stack/include -Ikernel/
> >>
> >> -obj-$(CONFIG_XENO_DRIVERS_NET_RTIPV4) += ipv4/
> >> -
> >> -obj-$(CONFIG_XENO_DRIVERS_NET_RTPACKET) += packet/
> >> -
> >> -obj-$(CONFIG_XENO_DRIVERS_NET_RTMAC) += rtmac/
> >> -
> >> -obj-$(CONFIG_XENO_DRIVERS_NET_RTCFG) += rtcfg/
> >> -
> >>    obj-$(CONFIG_XENO_DRIVERS_NET) += rtnet.o
> >>
> >>    rtnet-y :=  \
> >> @@ -23,4 +15,12 @@ rtnet-y :=  \
> >>    	stack_mgr.o \
> >>    	eth.o
> >>
> >> +obj-$(CONFIG_XENO_DRIVERS_NET_RTIPV4) += ipv4/
> >> +
> >> +obj-$(CONFIG_XENO_DRIVERS_NET_RTPACKET) += packet/
> >> +
> >> +obj-$(CONFIG_XENO_DRIVERS_NET_RTMAC) += rtmac/
> >> +
> >> +obj-$(CONFIG_XENO_DRIVERS_NET_RTCFG) += rtcfg/
> >> +
> >>    rtnet-$(CONFIG_XENO_DRIVERS_NET_RTWLAN) += rtwlan.o
> >> diff --git a/utils/net/rtnet.in b/utils/net/rtnet.in
> >> index f81a7bb..fa12a03 100644
> >> --- a/utils/net/rtnet.in
> >> +++ b/utils/net/rtnet.in
> >> @@ -31,44 +31,68 @@ EOF
> >>    }
> >>
> >>    init_rtnet() {
> >> -    modprobe rtnet >/dev/null || exit 1
> >> -    modprobe rtipv4 >/dev/null || exit 1
> >> -    modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
> >> -
> >> -    for dev in $REBIND_RT_NICS; do
> >> -	if [ -d /sys/bus/pci/devices/$dev/driver ]; then
> >> -	    echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
> >> -	fi
> >> -	echo $dev > /sys/bus/pci/drivers/$RT_DRIVER/bind
> >> -    done
> >> +    if [ ! -d /proc/rtnet ]; then
> >> +        modprobe rtnet >/dev/null || exit 1
> >> +    fi
> >>
> >> +    if [ ! -d /proc/rtnet/ipv4 ]; then
> >> +        modprobe rtipv4 >/dev/null || exit 1
> >> +    fi
> >>        for PROTOCOL in $RT_PROTOCOLS; do
> >> -	modprobe rt$PROTOCOL >/dev/null || exit 1
> >> +        if [ ! -d /sys/modules/rt$PROTOCOL ]; then
> >> +            if [ "$PROTOCOL" = "packet" ]; then
> >> +                modprobe rt$PROTOCOL >/dev/null
> >> +            else
> >> +                modprobe rt$PROTOCOL >/dev/null || exit 1
> >> +            fi
> >> +        fi
> >>        done
> >>
> >> +    $(cat /proc/rtnet/devices | grep -q rteth0)
> >> +    if [ $? -eq 1 ]; then
> >> +        modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
> >> +
> >> +        for dev in $REBIND_RT_NICS; do
> >> +            if [ -d /sys/bus/pci/devices/$dev/driver ]; then
> >> +                echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
> >> +            fi
> >> +            echo $dev > /sys/bus/pci/drivers/$RT_DRIVER/bind
> >> +        done
> >> +    fi
> >> +
> >>        if [ $RT_LOOPBACK = "yes" ]; then
> >> -	modprobe rt_loopback >/dev/null || exit 1
> >> +        $(cat /proc/rtnet/devices | grep -q rtlo)
> >> +        if [ $? -eq 1 ]; then
> >> +
> >> +            modprobe rt_loopback >/dev/null || exit 1
> >> +        fi
> >>        fi
> >>
> >> -    if [ $RTCAP = "yes" ]; then
> >> -	modprobe rtcap >/dev/null || exit 1
> >> +    if [ $RTCAP = "yes" -a ! -d /sys/modules/rtcap ]; then
> >> +        modprobe rtcap >/dev/null || exit 1
> >>        fi
> >>
> >>        if [ $RT_LOOPBACK = "yes" ]; then
> >> -	$RTIFCONFIG rtlo up 127.0.0.1
> >> +        $RTIFCONFIG rtlo up 127.0.0.1
> >>        fi
> >>
> >>        if [ $RTCAP = "yes" ]; then
> >> -	ifconfig rteth0 up
> >> -	ifconfig rteth0-mac up
> >> -	if [ $RT_LOOPBACK = "yes" ]; then
> >> -	    ifconfig rtlo up
> >> -	fi
> >> +        ifconfig rteth0 up
> >> +        ifconfig rteth0-mac up
> >> +        if [ $RT_LOOPBACK = "yes" ]; then
> >> +            ifconfig rtlo up
> >> +        fi
> >>        fi
> >>
> >> -    modprobe rtcfg >/dev/null
> >> -    modprobe rtmac >/dev/null
> >> -    modprobe tdma >/dev/null
> >> +    if [ ! -d /proc/rtnet/rtcfg ]; then
> >> +        modprobe rtcfg >/dev/null
> >> +    fi
> >> +    if [ ! -d /proc/rtnet/rtmac ]; then
> >> +        modprobe rtmac >/dev/null
> >> +    fi
> >> +    if [ ! -f /proc/tdma ]; then
> >> +        modprobe tdma >/dev/null
> >> +    fi
> >>    }
> >>
> >>    submit_cfg() {
> >> @@ -336,34 +360,56 @@ case "$1" in
> >>    	;;
> >>
> >>        capture)
> >> -	modprobe rtnet >/dev/null || exit 1
> >> -	modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
> >> -	modprobe rtcap >/dev/null || exit 1
> >> -	$RTIFCONFIG rteth0 up promisc
> >> -	ifconfig rteth0 up
> >> -	ifconfig rteth0-mac up
> >> -	;;
> >> +        if [ ! -d /proc/rtnet ]; then
> >> +            modprobe rtnet >/dev/null || exit 1
> >> +        fi
> >> +        $(cat /proc/rtnet/devices | grep -q rteth0)
> >> +        if [ $? -eq 1 ]; then
> >> +            modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
> >> +        fi
> >> +        if [ ! -d /sys/modules/rtcap ]; then
> >> +            modprobe rtcap >/dev/null || exit 1
> >> +        fi
> >> +        $RTIFCONFIG rteth0 up promisc
> >> +        ifconfig rteth0 up
> >> +        ifconfig rteth0-mac up
> >> +        ;;
> >>
> >>        loopback)
> >> -	modprobe rtnet >/dev/null || exit 1
> >> -	modprobe rtipv4 >/dev/null || exit 1
> >> -
> >> -	for PROTOCOL in $RT_PROTOCOLS; do
> >> -	    modprobe rt$PROTOCOL >/dev/null || exit 1
> >> -	done
> >> -
> >> -	modprobe rt_loopback >/dev/null || exit 1
> >> -
> >> -	if [ $RTCAP = "yes" ]; then
> >> -	    modprobe rtcap >/dev/null || exit 1
> >> -	fi
> >> -
> >> -	$RTIFCONFIG rtlo up 127.0.0.1
> >> -
> >> -	if [ $RTCAP = "yes" ]; then
> >> -	    ifconfig rtlo up
> >> -	fi
> >> -	;;
> >> +        if [ ! -d /proc/rtnet ]; then
> >> +            modprobe rtnet >/dev/null || exit 1
> >> +        fi
> >> +        if [ ! -d /proc/rtnet/ipv4 ]; then
> >> +            modprobe rtipv4 >/dev/null || exit 1
> >> +        fi
> >> +        for PROTOCOL in $RT_PROTOCOLS; do
> >> +            if [ ! -d /sys/modules/rt$PROTOCOL ]; then
> >> +                if [ "$PROTOCOL" = "packet" ]; then
> >> +                    modprobe rt$PROTOCOL >/dev/null
> >> +                else
> >> +                    modprobe rt$PROTOCOL >/dev/null || exit 1
> >> +                fi
> >> +            fi
> >> +        done
> >> +
> >> +        if [ $RT_LOOPBACK = "yes" ]; then
> >> +            $(cat /proc/rtnet/devices | grep -q rtlo)
> >> +            if [ $? -eq 1 ]; then
> >> +
> >> +                modprobe rt_loopback >/dev/null || exit 1
> >> +            fi
> >> +        fi
> >> +
> >> +        if [ $RTCAP = "yes" -a ! -d /sys/modules/rtcap ]; then
> >> +            modprobe rtcap >/dev/null || exit 1
> >> +        fi
> >> +
> >> +        $RTIFCONFIG rtlo up 127.0.0.1
> >> +
> >> +        if [ $RTCAP = "yes" ]; then
> >> +            ifconfig rtlo up
> >> +        fi
> >> +        ;;
> >>
> >>        *)
> >>    	usage
> >>
> >
> > Could you check if this delta on top works as well?
> >
> > diff --git a/utils/net/rtnet.in b/utils/net/rtnet.in
> > index fa12a0378a..84f7eed00d 100644
> > --- a/utils/net/rtnet.in
> > +++ b/utils/net/rtnet.in
> > @@ -48,8 +48,7 @@ init_rtnet() {
> >           fi
> >       done
> >
> > -    $(cat /proc/rtnet/devices | grep -q rteth0)
> > -    if [ $? -eq 1 ]; then
> > +    if grep -vq rteth0 /proc/rtnet/devices; then
> >           modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
> >
> >           for dev in $REBIND_RT_NICS; do
> > @@ -61,9 +60,7 @@ init_rtnet() {
> >       fi
> >
> >       if [ $RT_LOOPBACK = "yes" ]; then
> > -        $(cat /proc/rtnet/devices | grep -q rtlo)
> > -        if [ $? -eq 1 ]; then
> > -
> > +        if grep -vq rtlo /proc/rtnet/devices; then
> >               modprobe rt_loopback >/dev/null || exit 1
> >           fi
> >       fi
> > @@ -363,8 +360,7 @@ case "$1" in
> >           if [ ! -d /proc/rtnet ]; then
> >               modprobe rtnet >/dev/null || exit 1
> >           fi
> > -        $(cat /proc/rtnet/devices | grep -q rteth0)
> > -        if [ $? -eq 1 ]; then
> > +        if grep -vq rteth0 /proc/rtnet/devices; then
> >               modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
> >           fi
> >           if [ ! -d /sys/modules/rtcap ]; then
> > @@ -393,9 +389,7 @@ case "$1" in
> >           done
> >
> >           if [ $RT_LOOPBACK = "yes" ]; then
> > -            $(cat /proc/rtnet/devices | grep -q rtlo)
> > -            if [ $? -eq 1 ]; then
> > -
> > +            if grep -vq rtlo /proc/rtnet/devices; then
> >                   modprobe rt_loopback >/dev/null || exit 1
> >               fi
> >           fi
> >
> > Then I would prefer it and would merge the combination to next. It looks
> > safe and orthogonal enough for -rc2.
>
> Nah, not yet. We need to check the drivers first. At least the e1000 have
> non-static symbols that collide with the in-tree version.
>
> Jan
>

Anyway, what you proposed does not work as there is an header line in the file which will match anyway (plus there is likely another network interface there too, causing your rule to fail.

We could replace that with :
grep -q rtlo /proc/rtnet/devices || modprobe rt_loopback >/dev/null || exit 1

I can send the patch back that way if that fits your rules.

François
> --
> Siemens AG, Corporate Technology, CT RDA IOT SES-DE
> Corporate Competence Center Embedded Linux



^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] Allow RTNet to be builtin kernel
  2019-10-04 11:10 ` Jan Kiszka
@ 2019-10-04 13:36   ` Jan Kiszka
  2019-10-04 14:22     ` François Legal
  0 siblings, 1 reply; 17+ messages in thread
From: Jan Kiszka @ 2019-10-04 13:36 UTC (permalink / raw)
  To: François Legal, Xenomai

On 04.10.19 13:10, Jan Kiszka wrote:
> On 03.10.19 10:10, François Legal via Xenomai wrote:
>> Subject: [PATCH] Allow RTNet to be builtin kernel
>>
>> Makefile is changed because when builtin, the modules
>> get loaded in the link order. In the previous version
>> protocols would get loaded before stackmgr which
>> obviously fails.
>>
>> Signed-off-by: François LEGAL <devel@thom.fr.eu.org>
>>
>> ---
>>
>> This has been tested on Zynq 7000 Hardware (microzed
>> board) with MACB/GEM RTNet driver, with linux 4.4.189
>> vanilla. Kernel boots up correctly, and the following
>> messages get printed on the console during the boot :
>>
>> [   13.875451] sdhci-pltfm: SDHCI platform and OF driver helper
>> [   13.881627] sdhci-arasan e0100000.sdhci: No vmmc regulator found
>> [   13.887581] sdhci-arasan e0100000.sdhci: No vqmmc regulator found
>> [   13.927585] mmc0: SDHCI controller on e0100000.sdhci [e0100000.sdhci] using ADMA
>> [   13.945085] fpga_manager fpga0: Xilinx Zynq FPGA Manager registered
>> [   13.951896]
>> [   13.951896] *** RTnet for Xenomai v3.0.9 ***
>> [   13.951896]
>> [   13.959156] RTnet: initialising real-time networking
>> [   13.964928] RTmac/TDMA: init time division multiple access control mechanism
>> [   13.972074] RTmac: init realtime media access control
>> [   13.977064] RTcfg: init real-time configuration distribution protocol
>> [   13.983752] initializing loopback...
>> [   13.987295] RTnet: registered rtlo
>> [   13.993238] RTnet: registered rteth0
>> [   13.996832] libphy: MACB_mii_bus: probed
>> [   14.001140] rt_macb: rteth0: Cadence GEM at 0xe000b000 irq 26 (00:0a:35:00:01:22)
>> [   14.008630] rt_macb: rteth0: attached PHY driver [Marvell 88E1510] (mii_bus:phy_addr=e000b000.ethernet-ffffffff:00, irq=-1)
>> [   14.019845] RTcap: real-time capturing interface
>> [   14.026562] RTproxy attached to rteth0
>> [   14.031129] rtnetproxy installed as "rtproxy"
>> [   14.035693] NET: Registered protocol family 26
>> [   14.040309] NET: Registered protocol family 17
>> [   14.044686] can: controller area network core (rev 20120528 abi 9)
>> [   14.050957] NET: Registered protocol family 29
>> [   14.055329] can: raw protocol (rev 20120528)
>> [   14.059683] can: broadcast manager protocol (rev 20120528 t)
>>
>>    kernel/drivers/net/Kconfig        |  1 -
>>    kernel/drivers/net/addons/Kconfig |  4 ++--
>>    kernel/drivers/net/stack/Makefile | 16 ++++++++--------
>>    utils/net/rtnet.in | 144 +++++++++++++++++++++++++++++++++++------------------
>>    4 files changed, 105 insertions(+), 60 deletions(-)
>>
>> diff --git a/kernel/drivers/net/Kconfig b/kernel/drivers/net/Kconfig
>> index ac3bced..49d2402 100644
>> --- a/kernel/drivers/net/Kconfig
>> +++ b/kernel/drivers/net/Kconfig
>> @@ -1,7 +1,6 @@
>>    menu "RTnet"
>>    
>>    config XENO_DRIVERS_NET
>> -    depends on m
>>        select NET
>>        tristate "RTnet, TCP/IP socket interface"
>>    
>> diff --git a/kernel/drivers/net/addons/Kconfig b/kernel/drivers/net/addons/Kconfig
>> index baa6cbc..616ed40 100644
>> --- a/kernel/drivers/net/addons/Kconfig
>> +++ b/kernel/drivers/net/addons/Kconfig
>> @@ -2,7 +2,7 @@ menu "Add-Ons"
>>        depends on XENO_DRIVERS_NET
>>    
>>    config XENO_DRIVERS_NET_ADDON_RTCAP
>> -    depends on XENO_DRIVERS_NET && m
>> +    depends on XENO_DRIVERS_NET
>>        select ETHERNET
>>        tristate "Real-Time Capturing Support"
>>        default n
>> @@ -18,7 +18,7 @@ config XENO_DRIVERS_NET_ADDON_RTCAP
>>        For further information see Documentation/README.rtcap.
>>    
>>    config XENO_DRIVERS_NET_ADDON_PROXY
>> -    depends on XENO_DRIVERS_NET_RTIPV4 && m
>> +    depends on XENO_DRIVERS_NET_RTIPV4
>>        select ETHERNET
>>        tristate "IP protocol proxy for Linux"
>>        default n
>> diff --git a/kernel/drivers/net/stack/Makefile b/kernel/drivers/net/stack/Makefile
>> index d055dc2..f8db6fa 100644
>> --- a/kernel/drivers/net/stack/Makefile
>> +++ b/kernel/drivers/net/stack/Makefile
>> @@ -1,13 +1,5 @@
>>    ccflags-y += -Idrivers/xenomai/net/stack/include -Ikernel/
>>    
>> -obj-$(CONFIG_XENO_DRIVERS_NET_RTIPV4) += ipv4/
>> -
>> -obj-$(CONFIG_XENO_DRIVERS_NET_RTPACKET) += packet/
>> -
>> -obj-$(CONFIG_XENO_DRIVERS_NET_RTMAC) += rtmac/
>> -
>> -obj-$(CONFIG_XENO_DRIVERS_NET_RTCFG) += rtcfg/
>> -
>>    obj-$(CONFIG_XENO_DRIVERS_NET) += rtnet.o
>>    
>>    rtnet-y :=  \
>> @@ -23,4 +15,12 @@ rtnet-y :=  \
>>    	stack_mgr.o \
>>    	eth.o
>>    
>> +obj-$(CONFIG_XENO_DRIVERS_NET_RTIPV4) += ipv4/
>> +
>> +obj-$(CONFIG_XENO_DRIVERS_NET_RTPACKET) += packet/
>> +
>> +obj-$(CONFIG_XENO_DRIVERS_NET_RTMAC) += rtmac/
>> +
>> +obj-$(CONFIG_XENO_DRIVERS_NET_RTCFG) += rtcfg/
>> +
>>    rtnet-$(CONFIG_XENO_DRIVERS_NET_RTWLAN) += rtwlan.o
>> diff --git a/utils/net/rtnet.in b/utils/net/rtnet.in
>> index f81a7bb..fa12a03 100644
>> --- a/utils/net/rtnet.in
>> +++ b/utils/net/rtnet.in
>> @@ -31,44 +31,68 @@ EOF
>>    }
>>    
>>    init_rtnet() {
>> -    modprobe rtnet >/dev/null || exit 1
>> -    modprobe rtipv4 >/dev/null || exit 1
>> -    modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
>> -
>> -    for dev in $REBIND_RT_NICS; do
>> -	if [ -d /sys/bus/pci/devices/$dev/driver ]; then
>> -	    echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
>> -	fi
>> -	echo $dev > /sys/bus/pci/drivers/$RT_DRIVER/bind
>> -    done
>> +    if [ ! -d /proc/rtnet ]; then
>> +        modprobe rtnet >/dev/null || exit 1
>> +    fi
>>    
>> +    if [ ! -d /proc/rtnet/ipv4 ]; then
>> +        modprobe rtipv4 >/dev/null || exit 1
>> +    fi
>>        for PROTOCOL in $RT_PROTOCOLS; do
>> -	modprobe rt$PROTOCOL >/dev/null || exit 1
>> +        if [ ! -d /sys/modules/rt$PROTOCOL ]; then
>> +            if [ "$PROTOCOL" = "packet" ]; then
>> +                modprobe rt$PROTOCOL >/dev/null
>> +            else
>> +                modprobe rt$PROTOCOL >/dev/null || exit 1
>> +            fi
>> +        fi
>>        done
>>    
>> +    $(cat /proc/rtnet/devices | grep -q rteth0)
>> +    if [ $? -eq 1 ]; then
>> +        modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
>> +
>> +        for dev in $REBIND_RT_NICS; do
>> +            if [ -d /sys/bus/pci/devices/$dev/driver ]; then
>> +                echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
>> +            fi
>> +            echo $dev > /sys/bus/pci/drivers/$RT_DRIVER/bind
>> +        done
>> +    fi
>> +
>>        if [ $RT_LOOPBACK = "yes" ]; then
>> -	modprobe rt_loopback >/dev/null || exit 1
>> +        $(cat /proc/rtnet/devices | grep -q rtlo)
>> +        if [ $? -eq 1 ]; then
>> +
>> +            modprobe rt_loopback >/dev/null || exit 1
>> +        fi
>>        fi
>>    
>> -    if [ $RTCAP = "yes" ]; then
>> -	modprobe rtcap >/dev/null || exit 1
>> +    if [ $RTCAP = "yes" -a ! -d /sys/modules/rtcap ]; then
>> +        modprobe rtcap >/dev/null || exit 1
>>        fi
>>    
>>        if [ $RT_LOOPBACK = "yes" ]; then
>> -	$RTIFCONFIG rtlo up 127.0.0.1
>> +        $RTIFCONFIG rtlo up 127.0.0.1
>>        fi
>>    
>>        if [ $RTCAP = "yes" ]; then
>> -	ifconfig rteth0 up
>> -	ifconfig rteth0-mac up
>> -	if [ $RT_LOOPBACK = "yes" ]; then
>> -	    ifconfig rtlo up
>> -	fi
>> +        ifconfig rteth0 up
>> +        ifconfig rteth0-mac up
>> +        if [ $RT_LOOPBACK = "yes" ]; then
>> +            ifconfig rtlo up
>> +        fi
>>        fi
>>    
>> -    modprobe rtcfg >/dev/null
>> -    modprobe rtmac >/dev/null
>> -    modprobe tdma >/dev/null
>> +    if [ ! -d /proc/rtnet/rtcfg ]; then
>> +        modprobe rtcfg >/dev/null
>> +    fi
>> +    if [ ! -d /proc/rtnet/rtmac ]; then
>> +        modprobe rtmac >/dev/null
>> +    fi
>> +    if [ ! -f /proc/tdma ]; then
>> +        modprobe tdma >/dev/null
>> +    fi
>>    }
>>    
>>    submit_cfg() {
>> @@ -336,34 +360,56 @@ case "$1" in
>>    	;;
>>    
>>        capture)
>> -	modprobe rtnet >/dev/null || exit 1
>> -	modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
>> -	modprobe rtcap >/dev/null || exit 1
>> -	$RTIFCONFIG rteth0 up promisc
>> -	ifconfig rteth0 up
>> -	ifconfig rteth0-mac up
>> -	;;
>> +        if [ ! -d /proc/rtnet ]; then
>> +            modprobe rtnet >/dev/null || exit 1
>> +        fi
>> +        $(cat /proc/rtnet/devices | grep -q rteth0)
>> +        if [ $? -eq 1 ]; then
>> +            modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
>> +        fi
>> +        if [ ! -d /sys/modules/rtcap ]; then
>> +            modprobe rtcap >/dev/null || exit 1
>> +        fi
>> +        $RTIFCONFIG rteth0 up promisc
>> +        ifconfig rteth0 up
>> +        ifconfig rteth0-mac up
>> +        ;;
>>    
>>        loopback)
>> -	modprobe rtnet >/dev/null || exit 1
>> -	modprobe rtipv4 >/dev/null || exit 1
>> -
>> -	for PROTOCOL in $RT_PROTOCOLS; do
>> -	    modprobe rt$PROTOCOL >/dev/null || exit 1
>> -	done
>> -
>> -	modprobe rt_loopback >/dev/null || exit 1
>> -
>> -	if [ $RTCAP = "yes" ]; then
>> -	    modprobe rtcap >/dev/null || exit 1
>> -	fi
>> -
>> -	$RTIFCONFIG rtlo up 127.0.0.1
>> -
>> -	if [ $RTCAP = "yes" ]; then
>> -	    ifconfig rtlo up
>> -	fi
>> -	;;
>> +        if [ ! -d /proc/rtnet ]; then
>> +            modprobe rtnet >/dev/null || exit 1
>> +        fi
>> +        if [ ! -d /proc/rtnet/ipv4 ]; then
>> +            modprobe rtipv4 >/dev/null || exit 1
>> +        fi
>> +        for PROTOCOL in $RT_PROTOCOLS; do
>> +            if [ ! -d /sys/modules/rt$PROTOCOL ]; then
>> +                if [ "$PROTOCOL" = "packet" ]; then
>> +                    modprobe rt$PROTOCOL >/dev/null
>> +                else
>> +                    modprobe rt$PROTOCOL >/dev/null || exit 1
>> +                fi
>> +            fi
>> +        done
>> +
>> +        if [ $RT_LOOPBACK = "yes" ]; then
>> +            $(cat /proc/rtnet/devices | grep -q rtlo)
>> +            if [ $? -eq 1 ]; then
>> +
>> +                modprobe rt_loopback >/dev/null || exit 1
>> +            fi
>> +        fi
>> +
>> +        if [ $RTCAP = "yes" -a ! -d /sys/modules/rtcap ]; then
>> +            modprobe rtcap >/dev/null || exit 1
>> +        fi
>> +
>> +        $RTIFCONFIG rtlo up 127.0.0.1
>> +
>> +        if [ $RTCAP = "yes" ]; then
>> +            ifconfig rtlo up
>> +        fi
>> +        ;;
>>    
>>        *)
>>    	usage
>>
> 
> Could you check if this delta on top works as well?
> 
> diff --git a/utils/net/rtnet.in b/utils/net/rtnet.in
> index fa12a0378a..84f7eed00d 100644
> --- a/utils/net/rtnet.in
> +++ b/utils/net/rtnet.in
> @@ -48,8 +48,7 @@ init_rtnet() {
>           fi
>       done
>   
> -    $(cat /proc/rtnet/devices | grep -q rteth0)
> -    if [ $? -eq 1 ]; then
> +    if grep -vq rteth0 /proc/rtnet/devices; then
>           modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
>   
>           for dev in $REBIND_RT_NICS; do
> @@ -61,9 +60,7 @@ init_rtnet() {
>       fi
>   
>       if [ $RT_LOOPBACK = "yes" ]; then
> -        $(cat /proc/rtnet/devices | grep -q rtlo)
> -        if [ $? -eq 1 ]; then
> -
> +        if grep -vq rtlo /proc/rtnet/devices; then
>               modprobe rt_loopback >/dev/null || exit 1
>           fi
>       fi
> @@ -363,8 +360,7 @@ case "$1" in
>           if [ ! -d /proc/rtnet ]; then
>               modprobe rtnet >/dev/null || exit 1
>           fi
> -        $(cat /proc/rtnet/devices | grep -q rteth0)
> -        if [ $? -eq 1 ]; then
> +        if grep -vq rteth0 /proc/rtnet/devices; then
>               modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
>           fi
>           if [ ! -d /sys/modules/rtcap ]; then
> @@ -393,9 +389,7 @@ case "$1" in
>           done
>   
>           if [ $RT_LOOPBACK = "yes" ]; then
> -            $(cat /proc/rtnet/devices | grep -q rtlo)
> -            if [ $? -eq 1 ]; then
> -
> +            if grep -vq rtlo /proc/rtnet/devices; then
>                   modprobe rt_loopback >/dev/null || exit 1
>               fi
>           fi
> 
> Then I would prefer it and would merge the combination to next. It looks
> safe and orthogonal enough for -rc2.

Nah, not yet. We need to check the drivers first. At least the e1000 have 
non-static symbols that collide with the in-tree version.

Jan

-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux


^ permalink raw reply	[flat|nested] 17+ messages in thread

* Re: [PATCH] Allow RTNet to be builtin kernel
  2019-10-03  8:10 François Legal
@ 2019-10-04 11:10 ` Jan Kiszka
  2019-10-04 13:36   ` Jan Kiszka
  0 siblings, 1 reply; 17+ messages in thread
From: Jan Kiszka @ 2019-10-04 11:10 UTC (permalink / raw)
  To: François Legal, Xenomai

On 03.10.19 10:10, François Legal via Xenomai wrote:
> Subject: [PATCH] Allow RTNet to be builtin kernel
> 
> Makefile is changed because when builtin, the modules
> get loaded in the link order. In the previous version
> protocols would get loaded before stackmgr which
> obviously fails.
> 
> Signed-off-by: François LEGAL <devel@thom.fr.eu.org>
> 
> ---
> 
> This has been tested on Zynq 7000 Hardware (microzed
> board) with MACB/GEM RTNet driver, with linux 4.4.189
> vanilla. Kernel boots up correctly, and the following
> messages get printed on the console during the boot :
> 
> [   13.875451] sdhci-pltfm: SDHCI platform and OF driver helper
> [   13.881627] sdhci-arasan e0100000.sdhci: No vmmc regulator found
> [   13.887581] sdhci-arasan e0100000.sdhci: No vqmmc regulator found
> [   13.927585] mmc0: SDHCI controller on e0100000.sdhci [e0100000.sdhci] using ADMA
> [   13.945085] fpga_manager fpga0: Xilinx Zynq FPGA Manager registered
> [   13.951896]
> [   13.951896] *** RTnet for Xenomai v3.0.9 ***
> [   13.951896]
> [   13.959156] RTnet: initialising real-time networking
> [   13.964928] RTmac/TDMA: init time division multiple access control mechanism
> [   13.972074] RTmac: init realtime media access control
> [   13.977064] RTcfg: init real-time configuration distribution protocol
> [   13.983752] initializing loopback...
> [   13.987295] RTnet: registered rtlo
> [   13.993238] RTnet: registered rteth0
> [   13.996832] libphy: MACB_mii_bus: probed
> [   14.001140] rt_macb: rteth0: Cadence GEM at 0xe000b000 irq 26 (00:0a:35:00:01:22)
> [   14.008630] rt_macb: rteth0: attached PHY driver [Marvell 88E1510] (mii_bus:phy_addr=e000b000.ethernet-ffffffff:00, irq=-1)
> [   14.019845] RTcap: real-time capturing interface
> [   14.026562] RTproxy attached to rteth0
> [   14.031129] rtnetproxy installed as "rtproxy"
> [   14.035693] NET: Registered protocol family 26
> [   14.040309] NET: Registered protocol family 17
> [   14.044686] can: controller area network core (rev 20120528 abi 9)
> [   14.050957] NET: Registered protocol family 29
> [   14.055329] can: raw protocol (rev 20120528)
> [   14.059683] can: broadcast manager protocol (rev 20120528 t)
> 
>   kernel/drivers/net/Kconfig        |  1 -
>   kernel/drivers/net/addons/Kconfig |  4 ++--
>   kernel/drivers/net/stack/Makefile | 16 ++++++++--------
>   utils/net/rtnet.in | 144 +++++++++++++++++++++++++++++++++++------------------
>   4 files changed, 105 insertions(+), 60 deletions(-)
> 
> diff --git a/kernel/drivers/net/Kconfig b/kernel/drivers/net/Kconfig
> index ac3bced..49d2402 100644
> --- a/kernel/drivers/net/Kconfig
> +++ b/kernel/drivers/net/Kconfig
> @@ -1,7 +1,6 @@
>   menu "RTnet"
>   
>   config XENO_DRIVERS_NET
> -    depends on m
>       select NET
>       tristate "RTnet, TCP/IP socket interface"
>   
> diff --git a/kernel/drivers/net/addons/Kconfig b/kernel/drivers/net/addons/Kconfig
> index baa6cbc..616ed40 100644
> --- a/kernel/drivers/net/addons/Kconfig
> +++ b/kernel/drivers/net/addons/Kconfig
> @@ -2,7 +2,7 @@ menu "Add-Ons"
>       depends on XENO_DRIVERS_NET
>   
>   config XENO_DRIVERS_NET_ADDON_RTCAP
> -    depends on XENO_DRIVERS_NET && m
> +    depends on XENO_DRIVERS_NET
>       select ETHERNET
>       tristate "Real-Time Capturing Support"
>       default n
> @@ -18,7 +18,7 @@ config XENO_DRIVERS_NET_ADDON_RTCAP
>       For further information see Documentation/README.rtcap.
>   
>   config XENO_DRIVERS_NET_ADDON_PROXY
> -    depends on XENO_DRIVERS_NET_RTIPV4 && m
> +    depends on XENO_DRIVERS_NET_RTIPV4
>       select ETHERNET
>       tristate "IP protocol proxy for Linux"
>       default n
> diff --git a/kernel/drivers/net/stack/Makefile b/kernel/drivers/net/stack/Makefile
> index d055dc2..f8db6fa 100644
> --- a/kernel/drivers/net/stack/Makefile
> +++ b/kernel/drivers/net/stack/Makefile
> @@ -1,13 +1,5 @@
>   ccflags-y += -Idrivers/xenomai/net/stack/include -Ikernel/
>   
> -obj-$(CONFIG_XENO_DRIVERS_NET_RTIPV4) += ipv4/
> -
> -obj-$(CONFIG_XENO_DRIVERS_NET_RTPACKET) += packet/
> -
> -obj-$(CONFIG_XENO_DRIVERS_NET_RTMAC) += rtmac/
> -
> -obj-$(CONFIG_XENO_DRIVERS_NET_RTCFG) += rtcfg/
> -
>   obj-$(CONFIG_XENO_DRIVERS_NET) += rtnet.o
>   
>   rtnet-y :=  \
> @@ -23,4 +15,12 @@ rtnet-y :=  \
>   	stack_mgr.o \
>   	eth.o
>   
> +obj-$(CONFIG_XENO_DRIVERS_NET_RTIPV4) += ipv4/
> +
> +obj-$(CONFIG_XENO_DRIVERS_NET_RTPACKET) += packet/
> +
> +obj-$(CONFIG_XENO_DRIVERS_NET_RTMAC) += rtmac/
> +
> +obj-$(CONFIG_XENO_DRIVERS_NET_RTCFG) += rtcfg/
> +
>   rtnet-$(CONFIG_XENO_DRIVERS_NET_RTWLAN) += rtwlan.o
> diff --git a/utils/net/rtnet.in b/utils/net/rtnet.in
> index f81a7bb..fa12a03 100644
> --- a/utils/net/rtnet.in
> +++ b/utils/net/rtnet.in
> @@ -31,44 +31,68 @@ EOF
>   }
>   
>   init_rtnet() {
> -    modprobe rtnet >/dev/null || exit 1
> -    modprobe rtipv4 >/dev/null || exit 1
> -    modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
> -
> -    for dev in $REBIND_RT_NICS; do
> -	if [ -d /sys/bus/pci/devices/$dev/driver ]; then
> -	    echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
> -	fi
> -	echo $dev > /sys/bus/pci/drivers/$RT_DRIVER/bind
> -    done
> +    if [ ! -d /proc/rtnet ]; then
> +        modprobe rtnet >/dev/null || exit 1
> +    fi
>   
> +    if [ ! -d /proc/rtnet/ipv4 ]; then
> +        modprobe rtipv4 >/dev/null || exit 1
> +    fi
>       for PROTOCOL in $RT_PROTOCOLS; do
> -	modprobe rt$PROTOCOL >/dev/null || exit 1
> +        if [ ! -d /sys/modules/rt$PROTOCOL ]; then
> +            if [ "$PROTOCOL" = "packet" ]; then
> +                modprobe rt$PROTOCOL >/dev/null
> +            else
> +                modprobe rt$PROTOCOL >/dev/null || exit 1
> +            fi
> +        fi
>       done
>   
> +    $(cat /proc/rtnet/devices | grep -q rteth0)
> +    if [ $? -eq 1 ]; then
> +        modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
> +
> +        for dev in $REBIND_RT_NICS; do
> +            if [ -d /sys/bus/pci/devices/$dev/driver ]; then
> +                echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
> +            fi
> +            echo $dev > /sys/bus/pci/drivers/$RT_DRIVER/bind
> +        done
> +    fi
> +
>       if [ $RT_LOOPBACK = "yes" ]; then
> -	modprobe rt_loopback >/dev/null || exit 1
> +        $(cat /proc/rtnet/devices | grep -q rtlo)
> +        if [ $? -eq 1 ]; then
> +
> +            modprobe rt_loopback >/dev/null || exit 1
> +        fi
>       fi
>   
> -    if [ $RTCAP = "yes" ]; then
> -	modprobe rtcap >/dev/null || exit 1
> +    if [ $RTCAP = "yes" -a ! -d /sys/modules/rtcap ]; then
> +        modprobe rtcap >/dev/null || exit 1
>       fi
>   
>       if [ $RT_LOOPBACK = "yes" ]; then
> -	$RTIFCONFIG rtlo up 127.0.0.1
> +        $RTIFCONFIG rtlo up 127.0.0.1
>       fi
>   
>       if [ $RTCAP = "yes" ]; then
> -	ifconfig rteth0 up
> -	ifconfig rteth0-mac up
> -	if [ $RT_LOOPBACK = "yes" ]; then
> -	    ifconfig rtlo up
> -	fi
> +        ifconfig rteth0 up
> +        ifconfig rteth0-mac up
> +        if [ $RT_LOOPBACK = "yes" ]; then
> +            ifconfig rtlo up
> +        fi
>       fi
>   
> -    modprobe rtcfg >/dev/null
> -    modprobe rtmac >/dev/null
> -    modprobe tdma >/dev/null
> +    if [ ! -d /proc/rtnet/rtcfg ]; then
> +        modprobe rtcfg >/dev/null
> +    fi
> +    if [ ! -d /proc/rtnet/rtmac ]; then
> +        modprobe rtmac >/dev/null
> +    fi
> +    if [ ! -f /proc/tdma ]; then
> +        modprobe tdma >/dev/null
> +    fi
>   }
>   
>   submit_cfg() {
> @@ -336,34 +360,56 @@ case "$1" in
>   	;;
>   
>       capture)
> -	modprobe rtnet >/dev/null || exit 1
> -	modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
> -	modprobe rtcap >/dev/null || exit 1
> -	$RTIFCONFIG rteth0 up promisc
> -	ifconfig rteth0 up
> -	ifconfig rteth0-mac up
> -	;;
> +        if [ ! -d /proc/rtnet ]; then
> +            modprobe rtnet >/dev/null || exit 1
> +        fi
> +        $(cat /proc/rtnet/devices | grep -q rteth0)
> +        if [ $? -eq 1 ]; then
> +            modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
> +        fi
> +        if [ ! -d /sys/modules/rtcap ]; then
> +            modprobe rtcap >/dev/null || exit 1
> +        fi
> +        $RTIFCONFIG rteth0 up promisc
> +        ifconfig rteth0 up
> +        ifconfig rteth0-mac up
> +        ;;
>   
>       loopback)
> -	modprobe rtnet >/dev/null || exit 1
> -	modprobe rtipv4 >/dev/null || exit 1
> -
> -	for PROTOCOL in $RT_PROTOCOLS; do
> -	    modprobe rt$PROTOCOL >/dev/null || exit 1
> -	done
> -
> -	modprobe rt_loopback >/dev/null || exit 1
> -
> -	if [ $RTCAP = "yes" ]; then
> -	    modprobe rtcap >/dev/null || exit 1
> -	fi
> -
> -	$RTIFCONFIG rtlo up 127.0.0.1
> -
> -	if [ $RTCAP = "yes" ]; then
> -	    ifconfig rtlo up
> -	fi
> -	;;
> +        if [ ! -d /proc/rtnet ]; then
> +            modprobe rtnet >/dev/null || exit 1
> +        fi
> +        if [ ! -d /proc/rtnet/ipv4 ]; then
> +            modprobe rtipv4 >/dev/null || exit 1
> +        fi
> +        for PROTOCOL in $RT_PROTOCOLS; do
> +            if [ ! -d /sys/modules/rt$PROTOCOL ]; then
> +                if [ "$PROTOCOL" = "packet" ]; then
> +                    modprobe rt$PROTOCOL >/dev/null
> +                else
> +                    modprobe rt$PROTOCOL >/dev/null || exit 1
> +                fi
> +            fi
> +        done
> +
> +        if [ $RT_LOOPBACK = "yes" ]; then
> +            $(cat /proc/rtnet/devices | grep -q rtlo)
> +            if [ $? -eq 1 ]; then
> +
> +                modprobe rt_loopback >/dev/null || exit 1
> +            fi
> +        fi
> +
> +        if [ $RTCAP = "yes" -a ! -d /sys/modules/rtcap ]; then
> +            modprobe rtcap >/dev/null || exit 1
> +        fi
> +
> +        $RTIFCONFIG rtlo up 127.0.0.1
> +
> +        if [ $RTCAP = "yes" ]; then
> +            ifconfig rtlo up
> +        fi
> +        ;;
>   
>       *)
>   	usage
> 

Could you check if this delta on top works as well?

diff --git a/utils/net/rtnet.in b/utils/net/rtnet.in
index fa12a0378a..84f7eed00d 100644
--- a/utils/net/rtnet.in
+++ b/utils/net/rtnet.in
@@ -48,8 +48,7 @@ init_rtnet() {
         fi
     done
 
-    $(cat /proc/rtnet/devices | grep -q rteth0)
-    if [ $? -eq 1 ]; then
+    if grep -vq rteth0 /proc/rtnet/devices; then
         modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
 
         for dev in $REBIND_RT_NICS; do
@@ -61,9 +60,7 @@ init_rtnet() {
     fi
 
     if [ $RT_LOOPBACK = "yes" ]; then
-        $(cat /proc/rtnet/devices | grep -q rtlo)
-        if [ $? -eq 1 ]; then
-
+        if grep -vq rtlo /proc/rtnet/devices; then
             modprobe rt_loopback >/dev/null || exit 1
         fi
     fi
@@ -363,8 +360,7 @@ case "$1" in
         if [ ! -d /proc/rtnet ]; then
             modprobe rtnet >/dev/null || exit 1
         fi
-        $(cat /proc/rtnet/devices | grep -q rteth0)
-        if [ $? -eq 1 ]; then
+        if grep -vq rteth0 /proc/rtnet/devices; then
             modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
         fi
         if [ ! -d /sys/modules/rtcap ]; then
@@ -393,9 +389,7 @@ case "$1" in
         done
 
         if [ $RT_LOOPBACK = "yes" ]; then
-            $(cat /proc/rtnet/devices | grep -q rtlo)
-            if [ $? -eq 1 ]; then
-
+            if grep -vq rtlo /proc/rtnet/devices; then
                 modprobe rt_loopback >/dev/null || exit 1
             fi
         fi

Then I would prefer it and would merge the combination to next. It looks
safe and orthogonal enough for -rc2.

Thanks,
Jan

-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux


^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [PATCH] Allow RTNet to be builtin kernel
@ 2019-10-03  8:10 François Legal
  2019-10-04 11:10 ` Jan Kiszka
  0 siblings, 1 reply; 17+ messages in thread
From: François Legal @ 2019-10-03  8:10 UTC (permalink / raw)
  To: Xenomai

Subject: [PATCH] Allow RTNet to be builtin kernel

Makefile is changed because when builtin, the modules
get loaded in the link order. In the previous version
protocols would get loaded before stackmgr which
obviously fails.

Signed-off-by: François LEGAL <devel@thom.fr.eu.org>

---

This has been tested on Zynq 7000 Hardware (microzed
board) with MACB/GEM RTNet driver, with linux 4.4.189
vanilla. Kernel boots up correctly, and the following
messages get printed on the console during the boot :

[   13.875451] sdhci-pltfm: SDHCI platform and OF driver helper
[   13.881627] sdhci-arasan e0100000.sdhci: No vmmc regulator found
[   13.887581] sdhci-arasan e0100000.sdhci: No vqmmc regulator found
[   13.927585] mmc0: SDHCI controller on e0100000.sdhci [e0100000.sdhci] using ADMA
[   13.945085] fpga_manager fpga0: Xilinx Zynq FPGA Manager registered
[   13.951896]
[   13.951896] *** RTnet for Xenomai v3.0.9 ***
[   13.951896]
[   13.959156] RTnet: initialising real-time networking
[   13.964928] RTmac/TDMA: init time division multiple access control mechanism
[   13.972074] RTmac: init realtime media access control
[   13.977064] RTcfg: init real-time configuration distribution protocol
[   13.983752] initializing loopback...
[   13.987295] RTnet: registered rtlo
[   13.993238] RTnet: registered rteth0
[   13.996832] libphy: MACB_mii_bus: probed
[   14.001140] rt_macb: rteth0: Cadence GEM at 0xe000b000 irq 26 (00:0a:35:00:01:22)
[   14.008630] rt_macb: rteth0: attached PHY driver [Marvell 88E1510] (mii_bus:phy_addr=e000b000.ethernet-ffffffff:00, irq=-1)
[   14.019845] RTcap: real-time capturing interface
[   14.026562] RTproxy attached to rteth0
[   14.031129] rtnetproxy installed as "rtproxy"
[   14.035693] NET: Registered protocol family 26
[   14.040309] NET: Registered protocol family 17
[   14.044686] can: controller area network core (rev 20120528 abi 9)
[   14.050957] NET: Registered protocol family 29
[   14.055329] can: raw protocol (rev 20120528)
[   14.059683] can: broadcast manager protocol (rev 20120528 t)

 kernel/drivers/net/Kconfig        |  1 -
 kernel/drivers/net/addons/Kconfig |  4 ++--
 kernel/drivers/net/stack/Makefile | 16 ++++++++--------
 utils/net/rtnet.in | 144 +++++++++++++++++++++++++++++++++++------------------
 4 files changed, 105 insertions(+), 60 deletions(-)

diff --git a/kernel/drivers/net/Kconfig b/kernel/drivers/net/Kconfig
index ac3bced..49d2402 100644
--- a/kernel/drivers/net/Kconfig
+++ b/kernel/drivers/net/Kconfig
@@ -1,7 +1,6 @@
 menu "RTnet"

 config XENO_DRIVERS_NET
-    depends on m
     select NET
     tristate "RTnet, TCP/IP socket interface"

diff --git a/kernel/drivers/net/addons/Kconfig b/kernel/drivers/net/addons/Kconfig
index baa6cbc..616ed40 100644
--- a/kernel/drivers/net/addons/Kconfig
+++ b/kernel/drivers/net/addons/Kconfig
@@ -2,7 +2,7 @@ menu "Add-Ons"
     depends on XENO_DRIVERS_NET

 config XENO_DRIVERS_NET_ADDON_RTCAP
-    depends on XENO_DRIVERS_NET && m
+    depends on XENO_DRIVERS_NET
     select ETHERNET
     tristate "Real-Time Capturing Support"
     default n
@@ -18,7 +18,7 @@ config XENO_DRIVERS_NET_ADDON_RTCAP
     For further information see Documentation/README.rtcap.

 config XENO_DRIVERS_NET_ADDON_PROXY
-    depends on XENO_DRIVERS_NET_RTIPV4 && m
+    depends on XENO_DRIVERS_NET_RTIPV4
     select ETHERNET
     tristate "IP protocol proxy for Linux"
     default n
diff --git a/kernel/drivers/net/stack/Makefile b/kernel/drivers/net/stack/Makefile
index d055dc2..f8db6fa 100644
--- a/kernel/drivers/net/stack/Makefile
+++ b/kernel/drivers/net/stack/Makefile
@@ -1,13 +1,5 @@
 ccflags-y += -Idrivers/xenomai/net/stack/include -Ikernel/

-obj-$(CONFIG_XENO_DRIVERS_NET_RTIPV4) += ipv4/
-
-obj-$(CONFIG_XENO_DRIVERS_NET_RTPACKET) += packet/
-
-obj-$(CONFIG_XENO_DRIVERS_NET_RTMAC) += rtmac/
-
-obj-$(CONFIG_XENO_DRIVERS_NET_RTCFG) += rtcfg/
-
 obj-$(CONFIG_XENO_DRIVERS_NET) += rtnet.o

 rtnet-y :=  \
@@ -23,4 +15,12 @@ rtnet-y :=  \
 	stack_mgr.o \
 	eth.o

+obj-$(CONFIG_XENO_DRIVERS_NET_RTIPV4) += ipv4/
+
+obj-$(CONFIG_XENO_DRIVERS_NET_RTPACKET) += packet/
+
+obj-$(CONFIG_XENO_DRIVERS_NET_RTMAC) += rtmac/
+
+obj-$(CONFIG_XENO_DRIVERS_NET_RTCFG) += rtcfg/
+
 rtnet-$(CONFIG_XENO_DRIVERS_NET_RTWLAN) += rtwlan.o
diff --git a/utils/net/rtnet.in b/utils/net/rtnet.in
index f81a7bb..fa12a03 100644
--- a/utils/net/rtnet.in
+++ b/utils/net/rtnet.in
@@ -31,44 +31,68 @@ EOF
 }

 init_rtnet() {
-    modprobe rtnet >/dev/null || exit 1
-    modprobe rtipv4 >/dev/null || exit 1
-    modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
-
-    for dev in $REBIND_RT_NICS; do
-	if [ -d /sys/bus/pci/devices/$dev/driver ]; then
-	    echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
-	fi
-	echo $dev > /sys/bus/pci/drivers/$RT_DRIVER/bind
-    done
+    if [ ! -d /proc/rtnet ]; then
+        modprobe rtnet >/dev/null || exit 1
+    fi

+    if [ ! -d /proc/rtnet/ipv4 ]; then
+        modprobe rtipv4 >/dev/null || exit 1
+    fi
     for PROTOCOL in $RT_PROTOCOLS; do
-	modprobe rt$PROTOCOL >/dev/null || exit 1
+        if [ ! -d /sys/modules/rt$PROTOCOL ]; then
+            if [ "$PROTOCOL" = "packet" ]; then
+                modprobe rt$PROTOCOL >/dev/null
+            else
+                modprobe rt$PROTOCOL >/dev/null || exit 1
+            fi
+        fi
     done

+    $(cat /proc/rtnet/devices | grep -q rteth0)
+    if [ $? -eq 1 ]; then
+        modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
+
+        for dev in $REBIND_RT_NICS; do
+            if [ -d /sys/bus/pci/devices/$dev/driver ]; then
+                echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
+            fi
+            echo $dev > /sys/bus/pci/drivers/$RT_DRIVER/bind
+        done
+    fi
+
     if [ $RT_LOOPBACK = "yes" ]; then
-	modprobe rt_loopback >/dev/null || exit 1
+        $(cat /proc/rtnet/devices | grep -q rtlo)
+        if [ $? -eq 1 ]; then
+
+            modprobe rt_loopback >/dev/null || exit 1
+        fi
     fi

-    if [ $RTCAP = "yes" ]; then
-	modprobe rtcap >/dev/null || exit 1
+    if [ $RTCAP = "yes" -a ! -d /sys/modules/rtcap ]; then
+        modprobe rtcap >/dev/null || exit 1
     fi

     if [ $RT_LOOPBACK = "yes" ]; then
-	$RTIFCONFIG rtlo up 127.0.0.1
+        $RTIFCONFIG rtlo up 127.0.0.1
     fi

     if [ $RTCAP = "yes" ]; then
-	ifconfig rteth0 up
-	ifconfig rteth0-mac up
-	if [ $RT_LOOPBACK = "yes" ]; then
-	    ifconfig rtlo up
-	fi
+        ifconfig rteth0 up
+        ifconfig rteth0-mac up
+        if [ $RT_LOOPBACK = "yes" ]; then
+            ifconfig rtlo up
+        fi
     fi

-    modprobe rtcfg >/dev/null
-    modprobe rtmac >/dev/null
-    modprobe tdma >/dev/null
+    if [ ! -d /proc/rtnet/rtcfg ]; then
+        modprobe rtcfg >/dev/null
+    fi
+    if [ ! -d /proc/rtnet/rtmac ]; then
+        modprobe rtmac >/dev/null
+    fi
+    if [ ! -f /proc/tdma ]; then
+        modprobe tdma >/dev/null
+    fi
 }

 submit_cfg() {
@@ -336,34 +360,56 @@ case "$1" in
 	;;

     capture)
-	modprobe rtnet >/dev/null || exit 1
-	modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
-	modprobe rtcap >/dev/null || exit 1
-	$RTIFCONFIG rteth0 up promisc
-	ifconfig rteth0 up
-	ifconfig rteth0-mac up
-	;;
+        if [ ! -d /proc/rtnet ]; then
+            modprobe rtnet >/dev/null || exit 1
+        fi
+        $(cat /proc/rtnet/devices | grep -q rteth0)
+        if [ $? -eq 1 ]; then
+            modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
+        fi
+        if [ ! -d /sys/modules/rtcap ]; then
+            modprobe rtcap >/dev/null || exit 1
+        fi
+        $RTIFCONFIG rteth0 up promisc
+        ifconfig rteth0 up
+        ifconfig rteth0-mac up
+        ;;

     loopback)
-	modprobe rtnet >/dev/null || exit 1
-	modprobe rtipv4 >/dev/null || exit 1
-
-	for PROTOCOL in $RT_PROTOCOLS; do
-	    modprobe rt$PROTOCOL >/dev/null || exit 1
-	done
-
-	modprobe rt_loopback >/dev/null || exit 1
-
-	if [ $RTCAP = "yes" ]; then
-	    modprobe rtcap >/dev/null || exit 1
-	fi
-
-	$RTIFCONFIG rtlo up 127.0.0.1
-
-	if [ $RTCAP = "yes" ]; then
-	    ifconfig rtlo up
-	fi
-	;;
+        if [ ! -d /proc/rtnet ]; then
+            modprobe rtnet >/dev/null || exit 1
+        fi
+        if [ ! -d /proc/rtnet/ipv4 ]; then
+            modprobe rtipv4 >/dev/null || exit 1
+        fi
+        for PROTOCOL in $RT_PROTOCOLS; do
+            if [ ! -d /sys/modules/rt$PROTOCOL ]; then
+                if [ "$PROTOCOL" = "packet" ]; then
+                    modprobe rt$PROTOCOL >/dev/null
+                else
+                    modprobe rt$PROTOCOL >/dev/null || exit 1
+                fi
+            fi
+        done
+
+        if [ $RT_LOOPBACK = "yes" ]; then
+            $(cat /proc/rtnet/devices | grep -q rtlo)
+            if [ $? -eq 1 ]; then
+
+                modprobe rt_loopback >/dev/null || exit 1
+            fi
+        fi
+
+        if [ $RTCAP = "yes" -a ! -d /sys/modules/rtcap ]; then
+            modprobe rtcap >/dev/null || exit 1
+        fi
+
+        $RTIFCONFIG rtlo up 127.0.0.1
+
+        if [ $RTCAP = "yes" ]; then
+            ifconfig rtlo up
+        fi
+        ;;

     *)
 	usage
--
2.1.4



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH] Allow RTNet to be builtin kernel
  2019-10-02 16:06 ` Jan Kiszka
@ 2019-10-03  8:08   ` François Legal
  0 siblings, 0 replies; 17+ messages in thread
From: François Legal @ 2019-10-03  8:08 UTC (permalink / raw)
  To: Jan Kiszka; +Cc: Xenomai

Subject: [PATCH] Allow RTNet to be builtin kernel

Makefile is changed because when builtin, the modules
get loaded in the link order. In the previous version
protocols would get loaded before stackmgr which
obviously fails.

Signed-off-by: François LEGAL <devel@thom.fr.eu.org>

---

This has been tested on Zynq 7000 Hardware (microzed
board) with MACB/GEM RTNet driver, with linux 4.4.189
vanilla. Kernel boots up correctly, and the following
messages get printed on the console during the boot :

[   13.875451] sdhci-pltfm: SDHCI platform and OF driver helper
[   13.881627] sdhci-arasan e0100000.sdhci: No vmmc regulator found
[   13.887581] sdhci-arasan e0100000.sdhci: No vqmmc regulator found
[   13.927585] mmc0: SDHCI controller on e0100000.sdhci [e0100000.sdhci] using ADMA
[   13.945085] fpga_manager fpga0: Xilinx Zynq FPGA Manager registered
[   13.951896]
[   13.951896] *** RTnet for Xenomai v3.0.9 ***
[   13.951896]
[   13.959156] RTnet: initialising real-time networking
[   13.964928] RTmac/TDMA: init time division multiple access control mechanism
[   13.972074] RTmac: init realtime media access control
[   13.977064] RTcfg: init real-time configuration distribution protocol
[   13.983752] initializing loopback...
[   13.987295] RTnet: registered rtlo
[   13.993238] RTnet: registered rteth0
[   13.996832] libphy: MACB_mii_bus: probed
[   14.001140] rt_macb: rteth0: Cadence GEM at 0xe000b000 irq 26 (00:0a:35:00:01:22)
[   14.008630] rt_macb: rteth0: attached PHY driver [Marvell 88E1510] (mii_bus:phy_addr=e000b000.ethernet-ffffffff:00, irq=-1)
[   14.019845] RTcap: real-time capturing interface
[   14.026562] RTproxy attached to rteth0
[   14.031129] rtnetproxy installed as "rtproxy"
[   14.035693] NET: Registered protocol family 26
[   14.040309] NET: Registered protocol family 17
[   14.044686] can: controller area network core (rev 20120528 abi 9)
[   14.050957] NET: Registered protocol family 29
[   14.055329] can: raw protocol (rev 20120528)
[   14.059683] can: broadcast manager protocol (rev 20120528 t)

 kernel/drivers/net/Kconfig        |  1 -
 kernel/drivers/net/addons/Kconfig |  4 ++--
 kernel/drivers/net/stack/Makefile | 16 ++++++++--------
 utils/net/rtnet.in | 144 +++++++++++++++++++++++++++++++++++------------------
 4 files changed, 105 insertions(+), 60 deletions(-)

diff --git a/kernel/drivers/net/Kconfig b/kernel/drivers/net/Kconfig
index ac3bced..49d2402 100644
--- a/kernel/drivers/net/Kconfig
+++ b/kernel/drivers/net/Kconfig
@@ -1,7 +1,6 @@
 menu "RTnet"

 config XENO_DRIVERS_NET
-    depends on m
     select NET
     tristate "RTnet, TCP/IP socket interface"

diff --git a/kernel/drivers/net/addons/Kconfig b/kernel/drivers/net/addons/Kconfig
index baa6cbc..616ed40 100644
--- a/kernel/drivers/net/addons/Kconfig
+++ b/kernel/drivers/net/addons/Kconfig
@@ -2,7 +2,7 @@ menu "Add-Ons"
     depends on XENO_DRIVERS_NET

 config XENO_DRIVERS_NET_ADDON_RTCAP
-    depends on XENO_DRIVERS_NET && m
+    depends on XENO_DRIVERS_NET
     select ETHERNET
     tristate "Real-Time Capturing Support"
     default n
@@ -18,7 +18,7 @@ config XENO_DRIVERS_NET_ADDON_RTCAP
     For further information see Documentation/README.rtcap.

 config XENO_DRIVERS_NET_ADDON_PROXY
-    depends on XENO_DRIVERS_NET_RTIPV4 && m
+    depends on XENO_DRIVERS_NET_RTIPV4
     select ETHERNET
     tristate "IP protocol proxy for Linux"
     default n
diff --git a/kernel/drivers/net/stack/Makefile b/kernel/drivers/net/stack/Makefile
index d055dc2..f8db6fa 100644
--- a/kernel/drivers/net/stack/Makefile
+++ b/kernel/drivers/net/stack/Makefile
@@ -1,13 +1,5 @@
 ccflags-y += -Idrivers/xenomai/net/stack/include -Ikernel/

-obj-$(CONFIG_XENO_DRIVERS_NET_RTIPV4) += ipv4/
-
-obj-$(CONFIG_XENO_DRIVERS_NET_RTPACKET) += packet/
-
-obj-$(CONFIG_XENO_DRIVERS_NET_RTMAC) += rtmac/
-
-obj-$(CONFIG_XENO_DRIVERS_NET_RTCFG) += rtcfg/
-
 obj-$(CONFIG_XENO_DRIVERS_NET) += rtnet.o

 rtnet-y :=  \
@@ -23,4 +15,12 @@ rtnet-y :=  \
 	stack_mgr.o \
 	eth.o

+obj-$(CONFIG_XENO_DRIVERS_NET_RTIPV4) += ipv4/
+
+obj-$(CONFIG_XENO_DRIVERS_NET_RTPACKET) += packet/
+
+obj-$(CONFIG_XENO_DRIVERS_NET_RTMAC) += rtmac/
+
+obj-$(CONFIG_XENO_DRIVERS_NET_RTCFG) += rtcfg/
+
 rtnet-$(CONFIG_XENO_DRIVERS_NET_RTWLAN) += rtwlan.o
diff --git a/utils/net/rtnet.in b/utils/net/rtnet.in
index f81a7bb..fa12a03 100644
--- a/utils/net/rtnet.in
+++ b/utils/net/rtnet.in
@@ -31,44 +31,68 @@ EOF
 }

 init_rtnet() {
-    modprobe rtnet >/dev/null || exit 1
-    modprobe rtipv4 >/dev/null || exit 1
-    modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
-
-    for dev in $REBIND_RT_NICS; do
-	if [ -d /sys/bus/pci/devices/$dev/driver ]; then
-	    echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
-	fi
-	echo $dev > /sys/bus/pci/drivers/$RT_DRIVER/bind
-    done
+    if [ ! -d /proc/rtnet ]; then
+        modprobe rtnet >/dev/null || exit 1
+    fi

+    if [ ! -d /proc/rtnet/ipv4 ]; then
+        modprobe rtipv4 >/dev/null || exit 1
+    fi
     for PROTOCOL in $RT_PROTOCOLS; do
-	modprobe rt$PROTOCOL >/dev/null || exit 1
+        if [ ! -d /sys/modules/rt$PROTOCOL ]; then
+            if [ "$PROTOCOL" = "packet" ]; then
+                modprobe rt$PROTOCOL >/dev/null
+            else
+                modprobe rt$PROTOCOL >/dev/null || exit 1
+            fi
+        fi
     done

+    $(cat /proc/rtnet/devices | grep -q rteth0)
+    if [ $? -eq 1 ]; then
+        modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
+
+        for dev in $REBIND_RT_NICS; do
+            if [ -d /sys/bus/pci/devices/$dev/driver ]; then
+                echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
+            fi
+            echo $dev > /sys/bus/pci/drivers/$RT_DRIVER/bind
+        done
+    fi
+
     if [ $RT_LOOPBACK = "yes" ]; then
-	modprobe rt_loopback >/dev/null || exit 1
+        $(cat /proc/rtnet/devices | grep -q rtlo)
+        if [ $? -eq 1 ]; then
+
+            modprobe rt_loopback >/dev/null || exit 1
+        fi
     fi

-    if [ $RTCAP = "yes" ]; then
-	modprobe rtcap >/dev/null || exit 1
+    if [ $RTCAP = "yes" -a ! -d /sys/modules/rtcap ]; then
+        modprobe rtcap >/dev/null || exit 1
     fi

     if [ $RT_LOOPBACK = "yes" ]; then
-	$RTIFCONFIG rtlo up 127.0.0.1
+        $RTIFCONFIG rtlo up 127.0.0.1
     fi

     if [ $RTCAP = "yes" ]; then
-	ifconfig rteth0 up
-	ifconfig rteth0-mac up
-	if [ $RT_LOOPBACK = "yes" ]; then
-	    ifconfig rtlo up
-	fi
+        ifconfig rteth0 up
+        ifconfig rteth0-mac up
+        if [ $RT_LOOPBACK = "yes" ]; then
+            ifconfig rtlo up
+        fi
     fi

-    modprobe rtcfg >/dev/null
-    modprobe rtmac >/dev/null
-    modprobe tdma >/dev/null
+    if [ ! -d /proc/rtnet/rtcfg ]; then
+        modprobe rtcfg >/dev/null
+    fi
+    if [ ! -d /proc/rtnet/rtmac ]; then
+        modprobe rtmac >/dev/null
+    fi
+    if [ ! -f /proc/tdma ]; then
+        modprobe tdma >/dev/null
+    fi
 }

 submit_cfg() {
@@ -336,34 +360,56 @@ case "$1" in
 	;;

     capture)
-	modprobe rtnet >/dev/null || exit 1
-	modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
-	modprobe rtcap >/dev/null || exit 1
-	$RTIFCONFIG rteth0 up promisc
-	ifconfig rteth0 up
-	ifconfig rteth0-mac up
-	;;
+        if [ ! -d /proc/rtnet ]; then
+            modprobe rtnet >/dev/null || exit 1
+        fi
+        $(cat /proc/rtnet/devices | grep -q rteth0)
+        if [ $? -eq 1 ]; then
+            modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
+        fi
+        if [ ! -d /sys/modules/rtcap ]; then
+            modprobe rtcap >/dev/null || exit 1
+        fi
+        $RTIFCONFIG rteth0 up promisc
+        ifconfig rteth0 up
+        ifconfig rteth0-mac up
+        ;;

     loopback)
-	modprobe rtnet >/dev/null || exit 1
-	modprobe rtipv4 >/dev/null || exit 1
-
-	for PROTOCOL in $RT_PROTOCOLS; do
-	    modprobe rt$PROTOCOL >/dev/null || exit 1
-	done
-
-	modprobe rt_loopback >/dev/null || exit 1
-
-	if [ $RTCAP = "yes" ]; then
-	    modprobe rtcap >/dev/null || exit 1
-	fi
-
-	$RTIFCONFIG rtlo up 127.0.0.1
-
-	if [ $RTCAP = "yes" ]; then
-	    ifconfig rtlo up
-	fi
-	;;
+        if [ ! -d /proc/rtnet ]; then
+            modprobe rtnet >/dev/null || exit 1
+        fi
+        if [ ! -d /proc/rtnet/ipv4 ]; then
+            modprobe rtipv4 >/dev/null || exit 1
+        fi
+        for PROTOCOL in $RT_PROTOCOLS; do
+            if [ ! -d /sys/modules/rt$PROTOCOL ]; then
+                if [ "$PROTOCOL" = "packet" ]; then
+                    modprobe rt$PROTOCOL >/dev/null
+                else
+                    modprobe rt$PROTOCOL >/dev/null || exit 1
+                fi
+            fi
+        done
+
+        if [ $RT_LOOPBACK = "yes" ]; then
+            $(cat /proc/rtnet/devices | grep -q rtlo)
+            if [ $? -eq 1 ]; then
+
+                modprobe rt_loopback >/dev/null || exit 1
+            fi
+        fi
+
+        if [ $RTCAP = "yes" -a ! -d /sys/modules/rtcap ]; then
+            modprobe rtcap >/dev/null || exit 1
+        fi
+
+        $RTIFCONFIG rtlo up 127.0.0.1
+
+        if [ $RTCAP = "yes" ]; then
+            ifconfig rtlo up
+        fi
+        ;;

     *)
 	usage
--
2.1.4



^ permalink raw reply related	[flat|nested] 17+ messages in thread

* Re: [PATCH] Allow RTNet to be builtin kernel
       [not found] <30dd-5d94c580-17-21e4bb80@177052564>
@ 2019-10-02 16:06 ` Jan Kiszka
  2019-10-03  8:08   ` François Legal
  0 siblings, 1 reply; 17+ messages in thread
From: Jan Kiszka @ 2019-10-02 16:06 UTC (permalink / raw)
  To: François Legal; +Cc: Xenomai

[re-adding the list]

On 02.10.19 17:43, François Legal wrote:
> Le Mercredi, Octobre 02, 2019 17:30 CEST, Jan Kiszka <jan.kiszka@siemens.com> a écrit:
>   
>> On 02.10.19 15:45, François Legal via Xenomai wrote:
>>> From: François LEGAL <devel@thom.fr.eu.org>
>>>
>>> Signed-off-by: François LEGAL <devel@thom.fr.eu.org>
>>>
>>> Subject: [PATCH] Allow RTNet to be builtin kernel
>>>
>>
>> Proper ordering is
>>
>> - one subject (first line of your commit message)
>> - optionally a "From:", specifically when your provider rewrites the
>>     sender address
>> - commit message body
>> - signed-off
>> - separator ("---")
>> - optionally some message that should not be in git afterwards, e.g. a
>>     changelog of what you edited in this revision of the patch. I don't
>>     see all of my comments addressed in code. So you should at least tell
>>     us why you didn't change something.
>> - the diff
> 
> Allright. Thanks for the clarification and sorry to bother you with this kind of stuff.

No problem. This can be a lot when writing a first patch, even worse when that 
is "only" a short one, but it helps a lot to keep the project consistent.

> Regarding the comments in the patch, to be honest, I did not see those in the first place.
> Let me clarify these points here :
> 
>> Maybe we should add "set -x" to the script so that every unhandled failure becomes visible. Can be done separately, though.
> 
> Yes. I did that during testing but removed it afterwards. I thought leaving a set -x in would be a nogo for commit. I'll set it back.

With "can be done separately", I mean that such a change would be desired, not 
needed for this patch, and when done, it should come as an additional patch.

> 
>> rtpacket does not depend on rtipv4.
> 
> I thought the RT_PROTOCOLS would be in udp, icmp, (tcp maybe). I'll have to check how to address rtpacket.
> 
>> Reformatting is appreciated, but this is better done separately, to ease my review. :)
> 
> Got it. I'll restore the tabs.

You can also convert them to something consistent, but then please send two 
patches: One that only does the style conversion without functional changes, and 
one that does the other things.

> 
>> I think you are missing the rmmod in the "stop" path.
> 
> No, I made that intentionally, as the rmmod comes with -f plus > /dev/null
> I thought I could leave it here as any error would be silently discarded. Moreover, I'm not sure how I can handle it as the files/dirs I use to check if RTNet is builtin should probably appear whenever the modular RTNet gets loaded.

Ah, makes sense!

> 
> So if these replies are ok by you, I'll modify the patch and send it back to the list.

Yes, please.

Thanks,
Jan

-- 
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux


^ permalink raw reply	[flat|nested] 17+ messages in thread

* [PATCH] Allow RTNet to be builtin kernel
@ 2019-10-02 12:35 François Legal
  0 siblings, 0 replies; 17+ messages in thread
From: François Legal @ 2019-10-02 12:35 UTC (permalink / raw)
  To: xenomai

From: François LEGAL <devel@thom.fr.eu.org>

Signed-off-by: François LEGAL <devel@thom.fr.eu.org>

Subject: [PATCH] Allow RTNet to be builtin kernel

---
 kernel/drivers/net/Kconfig        |   1 -
 kernel/drivers/net/addons/Kconfig |   4 +-
 kernel/drivers/net/stack/Makefile |  16 ++---
 utils/net/rtnet.in                | 148 +++++++++++++++++++++++---------------
 4 files changed, 101 insertions(+), 68 deletions(-)

diff --git a/kernel/drivers/net/Kconfig b/kernel/drivers/net/Kconfig
index ac3bced..49d2402 100644
--- a/kernel/drivers/net/Kconfig
+++ b/kernel/drivers/net/Kconfig
@@ -1,7 +1,6 @@
 menu "RTnet"

 config XENO_DRIVERS_NET
-    depends on m
     select NET
     tristate "RTnet, TCP/IP socket interface"

diff --git a/kernel/drivers/net/addons/Kconfig b/kernel/drivers/net/addons/Kconfig
index baa6cbc..616ed40 100644
--- a/kernel/drivers/net/addons/Kconfig
+++ b/kernel/drivers/net/addons/Kconfig
@@ -2,7 +2,7 @@ menu "Add-Ons"
     depends on XENO_DRIVERS_NET

 config XENO_DRIVERS_NET_ADDON_RTCAP
-    depends on XENO_DRIVERS_NET && m
+    depends on XENO_DRIVERS_NET
     select ETHERNET
     tristate "Real-Time Capturing Support"
     default n
@@ -18,7 +18,7 @@ config XENO_DRIVERS_NET_ADDON_RTCAP
     For further information see Documentation/README.rtcap.

 config XENO_DRIVERS_NET_ADDON_PROXY
-    depends on XENO_DRIVERS_NET_RTIPV4 && m
+    depends on XENO_DRIVERS_NET_RTIPV4
     select ETHERNET
     tristate "IP protocol proxy for Linux"
     default n
diff --git a/kernel/drivers/net/stack/Makefile b/kernel/drivers/net/stack/Makefile
index d055dc2..f8db6fa 100644
--- a/kernel/drivers/net/stack/Makefile
+++ b/kernel/drivers/net/stack/Makefile
@@ -1,13 +1,5 @@
 ccflags-y += -Idrivers/xenomai/net/stack/include -Ikernel/

-obj-$(CONFIG_XENO_DRIVERS_NET_RTIPV4) += ipv4/
-
-obj-$(CONFIG_XENO_DRIVERS_NET_RTPACKET) += packet/
-
-obj-$(CONFIG_XENO_DRIVERS_NET_RTMAC) += rtmac/
-
-obj-$(CONFIG_XENO_DRIVERS_NET_RTCFG) += rtcfg/
-
 obj-$(CONFIG_XENO_DRIVERS_NET) += rtnet.o

 rtnet-y :=  \
@@ -23,4 +15,12 @@ rtnet-y :=  \
 	stack_mgr.o \
 	eth.o

+obj-$(CONFIG_XENO_DRIVERS_NET_RTIPV4) += ipv4/
+
+obj-$(CONFIG_XENO_DRIVERS_NET_RTPACKET) += packet/
+
+obj-$(CONFIG_XENO_DRIVERS_NET_RTMAC) += rtmac/
+
+obj-$(CONFIG_XENO_DRIVERS_NET_RTCFG) += rtcfg/
+
 rtnet-$(CONFIG_XENO_DRIVERS_NET_RTWLAN) += rtwlan.o
diff --git a/utils/net/rtnet.in b/utils/net/rtnet.in
index f81a7bb..3c3cab9 100644
--- a/utils/net/rtnet.in
+++ b/utils/net/rtnet.in
@@ -31,44 +31,62 @@ EOF
 }

 init_rtnet() {
-    modprobe rtnet >/dev/null || exit 1
-    modprobe rtipv4 >/dev/null || exit 1
-    modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
+    if [ ! -d /proc/rtnet ]; then
+        modprobe rtnet >/dev/null || exit 1
+    fi

-    for dev in $REBIND_RT_NICS; do
-	if [ -d /sys/bus/pci/devices/$dev/driver ]; then
-	    echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
-	fi
-	echo $dev > /sys/bus/pci/drivers/$RT_DRIVER/bind
-    done
+    if [ ! -d /proc/rtnet/ipv4 ]; then
+        modprobe rtipv4 >/dev/null || exit 1
+        for PROTOCOL in $RT_PROTOCOLS; do
+            modprobe rt$PROTOCOL >/dev/null || exit 1
+        done
+    fi

-    for PROTOCOL in $RT_PROTOCOLS; do
-	modprobe rt$PROTOCOL >/dev/null || exit 1
-    done
+    $(cat /proc/rtnet/devices | grep -q rteth0)
+    if [ $? -eq 1 ]; then
+        modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
+
+        for dev in $REBIND_RT_NICS; do
+            if [ -d /sys/bus/pci/devices/$dev/driver ]; then
+                echo $dev > /sys/bus/pci/devices/$dev/driver/unbind
+            fi
+            echo $dev > /sys/bus/pci/drivers/$RT_DRIVER/bind
+        done
+    fi

     if [ $RT_LOOPBACK = "yes" ]; then
-	modprobe rt_loopback >/dev/null || exit 1
+        $(cat /proc/rtnet/devices | grep -q rtlo)
+        if [ $? -eq 1 ]; then
+
+            modprobe rt_loopback >/dev/null || exit 1
+        fi
     fi

-    if [ $RTCAP = "yes" ]; then
-	modprobe rtcap >/dev/null || exit 1
+    if [ $RTCAP = "yes" -a ! -d /sys/modules/rtcap ]; then
+        modprobe rtcap >/dev/null || exit 1
     fi

     if [ $RT_LOOPBACK = "yes" ]; then
-	$RTIFCONFIG rtlo up 127.0.0.1
+        $RTIFCONFIG rtlo up 127.0.0.1
     fi

     if [ $RTCAP = "yes" ]; then
-	ifconfig rteth0 up
-	ifconfig rteth0-mac up
-	if [ $RT_LOOPBACK = "yes" ]; then
-	    ifconfig rtlo up
-	fi
+        ifconfig rteth0 up
+        ifconfig rteth0-mac up
+        if [ $RT_LOOPBACK = "yes" ]; then
+            ifconfig rtlo up
+        fi
     fi

-    modprobe rtcfg >/dev/null
-    modprobe rtmac >/dev/null
-    modprobe tdma >/dev/null
+    if [ ! -d /proc/rtnet/rtcfg ]; then
+        modprobe rtcfg >/dev/null
+    fi
+    if [ ! -d /proc/rtnet/rtmac ]; then
+        modprobe rtmac >/dev/null
+    fi
+    if [ ! -f /proc/tdma ]; then
+        modprobe tdma >/dev/null
+    fi
 }

 submit_cfg() {
@@ -329,43 +347,59 @@ case "$1" in
 	;;

     master)
-	shift
-	init_rtnet
-	TDMA_SLAVES=$*
-	start_master
-	;;
+        shift
+        init_rtnet
+        TDMA_SLAVES=$*
+        start_master
+        ;;

     capture)
-	modprobe rtnet >/dev/null || exit 1
-	modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
-	modprobe rtcap >/dev/null || exit 1
-	$RTIFCONFIG rteth0 up promisc
-	ifconfig rteth0 up
-	ifconfig rteth0-mac up
-	;;
+        if [ ! -d /proc/rtnet ]; then
+            modprobe rtnet >/dev/null || exit 1
+        fi
+        $(cat /proc/rtnet/devices | grep -q rteth0)
+        if [ $? -eq 1 ]; then
+            modprobe $RT_DRIVER $RT_DRIVER_OPTIONS >/dev/null || exit 1
+        fi
+        if [ ! -d /sys/modules/rtcap ]; then
+            modprobe rtcap >/dev/null || exit 1
+        fi
+        $RTIFCONFIG rteth0 up promisc
+        ifconfig rteth0 up
+        ifconfig rteth0-mac up
+        ;;

     loopback)
-	modprobe rtnet >/dev/null || exit 1
-	modprobe rtipv4 >/dev/null || exit 1
-
-	for PROTOCOL in $RT_PROTOCOLS; do
-	    modprobe rt$PROTOCOL >/dev/null || exit 1
-	done
-
-	modprobe rt_loopback >/dev/null || exit 1
-
-	if [ $RTCAP = "yes" ]; then
-	    modprobe rtcap >/dev/null || exit 1
-	fi
-
-	$RTIFCONFIG rtlo up 127.0.0.1
-
-	if [ $RTCAP = "yes" ]; then
-	    ifconfig rtlo up
-	fi
-	;;
+        if [ ! -d /proc/rtnet ]; then
+            modprobe rtnet >/dev/null || exit 1
+        fi
+        if [ ! -d /proc/rtnet/ipv4 ]; then
+            modprobe rtipv4 >/dev/null || exit 1
+            for PROTOCOL in $RT_PROTOCOLS; do
+                modprobe rt$PROTOCOL >/dev/null || exit 1
+            done
+        fi
+
+        if [ $RT_LOOPBACK = "yes" ]; then
+            $(cat /proc/rtnet/devices | grep -q rtlo)
+            if [ $? -eq 1 ]; then
+
+                modprobe rt_loopback >/dev/null || exit 1
+            fi
+        fi
+
+        if [ $RTCAP = "yes" -a ! -d /sys/modules/rtcap ]; then
+            modprobe rtcap >/dev/null || exit 1
+        fi
+
+        $RTIFCONFIG rtlo up 127.0.0.1
+
+        if [ $RTCAP = "yes" ]; then
+            ifconfig rtlo up
+        fi
+        ;;

     *)
-	usage
-	exit 1
+        usage
+        exit 1
 esac
--
2.1.4



^ permalink raw reply related	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2019-10-09 14:25 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-02 13:45 [PATCH] Allow RTNet to be builtin kernel François Legal
2019-10-02 15:30 ` Jan Kiszka
     [not found] <b80-5d9cb700-133-62bca880@213435307>
2019-10-08 16:24 ` Jan Kiszka
2019-10-09  7:21   ` François Legal
2019-10-09  7:24     ` Jan Kiszka
2019-10-09  7:27       ` François Legal
     [not found] <b7f-5d976580-6b-344a2840@235496640>
2019-10-04 16:24 ` Jan Kiszka
  -- strict thread matches above, loose matches on Subject: below --
2019-10-04 15:16 François Legal
2019-10-03  8:10 François Legal
2019-10-04 11:10 ` Jan Kiszka
2019-10-04 13:36   ` Jan Kiszka
2019-10-04 14:22     ` François Legal
2019-10-04 14:31       ` Jan Kiszka
     [not found]         ` <VI1PR05MB59174B531D2FFC88C2E05458F6950@VI1PR05MB5917.eurprd05.prod.outlook.com>
     [not found]           ` <c6b47e60-642a-7779-7639-2ff4a62c805d@siemens.com>
2019-10-09 14:25             ` Lange Norbert
     [not found] <30dd-5d94c580-17-21e4bb80@177052564>
2019-10-02 16:06 ` Jan Kiszka
2019-10-03  8:08   ` François Legal
2019-10-02 12:35 François Legal

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.