Module: xenomai-gch
Branch: next
Commit: ad97ad16aaf7a859c19356e32b6a28daf120cfb9
URL:    
http://git.xenomai.org/?p=xenomai-gch.git;a=commit;h=ad97ad16aaf7a859c19356e32b6a28daf120cfb9

Author: Gilles Chanteperdrix <gilles.chanteperd...@xenomai.org>
Date:   Sat Oct 31 20:53:09 2015 +0100

cobalt/corectl: allow retrieving RTnet configuration

---

 include/cobalt/uapi/corectl.h       |   17 ++++++++
 kernel/cobalt/posix/Makefile        |    1 +
 kernel/cobalt/posix/corectl.c       |    2 +
 kernel/cobalt/posix/rtnet_corectl.c |   74 +++++++++++++++++++++++++++++++++++
 4 files changed, 94 insertions(+)

diff --git a/include/cobalt/uapi/corectl.h b/include/cobalt/uapi/corectl.h
index 9466743..159bfbc 100644
--- a/include/cobalt/uapi/corectl.h
+++ b/include/cobalt/uapi/corectl.h
@@ -32,6 +32,7 @@
 #   define _CC_COBALT_DEBUG_POSIX_SYNCHRO      64
 #   define _CC_COBALT_DEBUG_LEGACY             128
 #   define _CC_COBALT_DEBUG_TRACE_RELAX                256
+#   define _CC_COBALT_DEBUG_NET                        512
 
 #define _CC_COBALT_GET_POLICIES                4
 #   define _CC_COBALT_SCHED_FIFO       1
@@ -46,6 +47,22 @@
 #define _CC_COBALT_START_CORE          7
 #define _CC_COBALT_STOP_CORE           8
 
+#define _CC_COBALT_GET_NET_CONFIG      9
+#   define _CC_COBALT_NET              0x00000001
+#   define _CC_COBALT_NET_ETH_P_ALL    0x00000002
+#   define _CC_COBALT_NET_IPV4         0x00000004
+#   define _CC_COBALT_NET_ICMP         0x00000008
+#   define _CC_COBALT_NET_NETROUTING   0x00000010
+#   define _CC_COBALT_NET_ROUTER       0x00000020
+#   define _CC_COBALT_NET_UDP          0x00000040
+#   define _CC_COBALT_NET_AF_PACKET    0x00000080
+#   define _CC_COBALT_NET_TDMA         0x00000100
+#   define _CC_COBALT_NET_NOMAC                0x00000200
+#   define _CC_COBALT_NET_CFG          0x00000400
+#   define _CC_COBALT_NET_CAP          0x00000800
+#   define _CC_COBALT_NET_PROXY                0x00001000
+
+
 enum cobalt_run_states {
        COBALT_STATE_DISABLED,
        COBALT_STATE_RUNNING,
diff --git a/kernel/cobalt/posix/Makefile b/kernel/cobalt/posix/Makefile
index f194bff..0b74359 100644
--- a/kernel/cobalt/posix/Makefile
+++ b/kernel/cobalt/posix/Makefile
@@ -15,6 +15,7 @@ xenomai-y :=          \
        mutex.o         \
        nsem.o          \
        process.o       \
+       rtnet_corectl.o \
        sched.o         \
        sem.o           \
        signal.o        \
diff --git a/kernel/cobalt/posix/corectl.c b/kernel/cobalt/posix/corectl.c
index de8fa5b..f01a562 100644
--- a/kernel/cobalt/posix/corectl.c
+++ b/kernel/cobalt/posix/corectl.c
@@ -79,6 +79,8 @@ static int do_conf_option(int option, void __user *u_buf, 
size_t u_bufsz)
                        val |= _CC_COBALT_DEBUG_LEGACY;
                if (IS_ENABLED(CONFIG_XENO_OPT_DEBUG_TRACE_RELAX))
                        val |= _CC_COBALT_DEBUG_TRACE_RELAX;
+               if (IS_ENABLED(CONFIG_XENO_DRIVERS_RTNET_CHECKED))
+                       val |= _CC_COBALT_DEBUG_NET;
                break;
        case _CC_COBALT_GET_WATCHDOG:
 #ifdef CONFIG_XENO_OPT_WATCHDOG
diff --git a/kernel/cobalt/posix/rtnet_corectl.c 
b/kernel/cobalt/posix/rtnet_corectl.c
new file mode 100644
index 0000000..8153d3c
--- /dev/null
+++ b/kernel/cobalt/posix/rtnet_corectl.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2016 Gilles Chanteperdrix <g...@xenomai.org>.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+#include <asm/xenomai/syscall.h>
+#include "corectl.h"
+
+static int
+rtnet_corectl_call(struct notifier_block *self, unsigned long arg, void 
*cookie)
+{
+       struct cobalt_config_vector *vec = cookie;
+       int ret = 0;
+
+       if (arg != _CC_COBALT_GET_NET_CONFIG)
+               return NOTIFY_DONE;
+
+       if (vec->u_bufsz < sizeof(ret))
+               return notifier_from_errno(-EINVAL);
+
+       if (IS_ENABLED(CONFIG_XENO_DRIVERS_NET))
+               ret |= _CC_COBALT_NET;
+       if (IS_ENABLED(CONFIG_XENO_DRIVERS_NET_ETH_P_ALL))
+               ret |= _CC_COBALT_NET_ETH_P_ALL;
+       if (IS_ENABLED(CONFIG_XENO_DRIVERS_NET_RTIPV4))
+               ret |= _CC_COBALT_NET_IPV4;
+       if (IS_ENABLED(CONFIG_XENO_DRIVERS_NET_RTIPV4_ICMP))
+               ret |= _CC_COBALT_NET_ICMP;
+       if (IS_ENABLED(CONFIG_XENO_DRIVERS_NET_RTIPV4_NETROUTING))
+               ret |= _CC_COBALT_NET_NETROUTING;
+       if (IS_ENABLED(CONFIG_XENO_DRIVERS_NET_RTIPV4_ROUTE))
+               ret |= _CC_COBALT_NET_ROUTER;
+       if (IS_ENABLED(CONFIG_XENO_DRIVERS_NET_RTIPV4_UDP))
+               ret |= _CC_COBALT_NET_UDP;
+       if (IS_ENABLED(CONFIG_XENO_DRIVERS_NET_RTPACKET))
+               ret |= _CC_COBALT_NET_AF_PACKET;
+       if (IS_ENABLED(CONFIG_XENO_DRIVERS_NET_TDMA))
+               ret |= _CC_COBALT_NET_TDMA;
+       if (IS_ENABLED(CONFIG_XENO_DRIVERS_NET_NOMAC))
+               ret |= _CC_COBALT_NET_NOMAC;
+       if (IS_ENABLED(CONFIG_XENO_DRIVERS_NET_RTCFG))
+               ret |= _CC_COBALT_NET_CFG;
+       if (IS_ENABLED(CONFIG_XENO_DRIVERS_NET_ADDON_RTCAP))
+               ret |= _CC_COBALT_NET_CAP;
+       if (IS_ENABLED(CONFIG_XENO_DRIVERS_NET_ADDON_PROXY))
+               ret |= _CC_COBALT_NET_PROXY;
+
+       ret = cobalt_copy_to_user(vec->u_buf, &ret, sizeof(ret));
+
+       return ret ? notifier_from_errno(-EFAULT) : NOTIFY_STOP;
+}
+
+static struct notifier_block rtnet_corectl_notifier = {
+       .notifier_call = rtnet_corectl_call,
+};
+
+static int rtnet_corectl_register(void)
+{
+       cobalt_add_config_chain(&rtnet_corectl_notifier);
+       return 0;
+}
+device_initcall(rtnet_corectl_register);


_______________________________________________
Xenomai-git mailing list
Xenomai-git@xenomai.org
http://xenomai.org/mailman/listinfo/xenomai-git

Reply via email to