Jan Kiszka wrote:
> Rob Gubler wrote:
>>> There is no select support in RTnet yet. Recent Xenomai does support it,
>>> but the (tiny) patch to enable RTnet to use it is not yet merged.
>>>
>>>
>> Back in April Jan posted a reply in regards to select() not yet being
>> supported in Xenomai.   Has the patch Jan mentions above been merged into
>> the mainstream project yet?
> 
> Not yet. But this is something we should address quickly. It needs some
> update after the select API of RTDM now matured, and some cleaner
> solution for selecting of write operations [1].
> 
>> I am running Xenomai version 2.4.3 and RTnet version 0.9.10.  I don't see
>> any response from select() that indicates it is working.
> 
> You will need 2.4.4 for the to-be-written version of the patch. 2.4.3
> did not yet include the RTDM revision 7 we need.
> 
> I will try to look into this the next days. If you are interested in it,
> you could support this by preparing some test case, ideally ready to be
> merged into RTnet's examples gallery.
> 

And here is a first version of the select patch already. Was easier as I
thought. Applies against SVN head, only compile tested. Note that you
have to enable XENO_OPT_RTDM_SELECT in your kernel config.

Feedback welcome.

Jan

---
 config/rtnet_config_pre.h.in |    3 +++
 configure                    |   11 +++++++++++
 configure.ac                 |    5 +++++
 stack/include/rtnet_socket.h |   22 ++++++++++++++--------
 stack/ipv4/af_inet.c         |    3 +++
 stack/packet/af_packet.c     |   10 ++++++++--
 stack/rtnet_module.c         |    5 +++++
 stack/socket.c               |   31 +++++++++++++++++++++++++++++++
 8 files changed, 80 insertions(+), 10 deletions(-)

Index: rtnet/configure
===================================================================
--- rtnet/configure     (Revision 1185)
+++ rtnet/configure     (Arbeitskopie)
@@ -21980,6 +21980,17 @@ _ACEOF
 
 fi
 
+{ echo "$as_me:$LINENO: checking whether to enable select-like support" >&5
+echo $ECHO_N "checking whether to enable select-like support... $ECHO_C" >&6; }
+if test "$CONFIG_XENO_OPT_RTDM_SELECT" = "y"; then
+
+cat >>confdefs.h <<\_ACEOF
+#define CONFIG_RTNET_SELECT_SUPPORT 1
+_ACEOF
+
+fi
+{ echo "$as_me:$LINENO: result: ${CONFIG_XENO_OPT_RTDM_SELECT:-n}" >&5
+echo "${ECHO_T}${CONFIG_XENO_OPT_RTDM_SELECT:-n}" >&6; }
 
 
 
Index: rtnet/configure.ac
===================================================================
--- rtnet/configure.ac  (Revision 1185)
+++ rtnet/configure.ac  (Arbeitskopie)
@@ -1263,6 +1263,11 @@ if test "$CONFIG_RTNET_CHECKED" = "y"; t
     AC_DEFINE(CONFIG_RTNET_CHECKED, 1, [Bug checks])
 fi
 
+AC_MSG_CHECKING([whether to enable select-like support])
+if test "$CONFIG_XENO_OPT_RTDM_SELECT" = "y"; then
+    AC_DEFINE(CONFIG_RTNET_SELECT_SUPPORT, 1, [Select support])
+fi
+AC_MSG_RESULT([${CONFIG_XENO_OPT_RTDM_SELECT:-n}])
 
 dnl ======================================================================
 dnl             hac^H^H^Hfix problem with multible defined symbols problem
Index: rtnet/config/rtnet_config_pre.h.in
===================================================================
--- rtnet/config/rtnet_config_pre.h.in  (Revision 1185)
+++ rtnet/config/rtnet_config_pre.h.in  (Arbeitskopie)
@@ -66,6 +66,9 @@
 /* RX-FIFO size */
 #undef CONFIG_RTNET_RX_FIFO_SIZE
 
+/* Select support */
+#undef CONFIG_RTNET_SELECT_SUPPORT
+
 /* TDMA master support */
 #undef CONFIG_RTNET_TDMA_MASTER
 
Index: rtnet/stack/rtnet_module.c
===================================================================
--- rtnet/stack/rtnet_module.c  (Revision 1183)
+++ rtnet/stack/rtnet_module.c  (Arbeitskopie)
@@ -30,6 +30,7 @@
 #include <rtdev_mgr.h>
 #include <rtnet_chrdev.h>
 #include <rtnet_internal.h>
+#include <rtnet_socket.h>
 #include <rtnet_rtpc.h>
 #include <stack_mgr.h>
 #include <rtwlan.h>
@@ -304,6 +305,10 @@ int __init rtnet_init(void)
            " ***\n\n");
     printk("RTnet: initialising real-time networking\n");
 
+#ifdef CONFIG_RTNET_SELECT_SUPPORT
+    rtdm_event_init(&pseudo_select_event, 1);
+#endif
+
     if ((err = rtskb_pools_init()) != 0)
         goto err_out1;
 
Index: rtnet/stack/ipv4/af_inet.c
===================================================================
--- rtnet/stack/ipv4/af_inet.c  (Revision 1183)
+++ rtnet/stack/ipv4/af_inet.c  (Arbeitskopie)
@@ -306,6 +306,9 @@ static struct rtdm_device ipv4_device =
         .ioctl_nrt =    rt_udp_ioctl,
         .recvmsg_rt =   rt_udp_recvmsg,
         .sendmsg_rt =   rt_udp_sendmsg,
+#ifdef CONFIG_RTNET_SELECT_SUPPORT
+        .select_bind =  rt_socket_select_bind,
+#endif
     },
 
     .device_class =     RTDM_CLASS_NETWORK,
Index: rtnet/stack/include/rtnet_socket.h
===================================================================
--- rtnet/stack/include/rtnet_socket.h  (Revision 1183)
+++ rtnet/stack/include/rtnet_socket.h  (Arbeitskopie)
@@ -89,13 +89,19 @@ static inline struct rtdm_dev_context *r
 #define rt_socket_dereference(sock) \
     atomic_dec(&(rt_socket_context(sock)->close_lock_count))
 
-extern int rt_socket_init(struct rtdm_dev_context *context);
-extern int rt_socket_cleanup(struct rtdm_dev_context *context);
-extern int rt_socket_common_ioctl(struct rtdm_dev_context *context,
-                                  rtdm_user_info_t *user_info,
-                                  int request, void *arg);
-extern int rt_socket_if_ioctl(struct rtdm_dev_context *context,
-                              rtdm_user_info_t *user_info,
-                              int request, void *arg);
+extern rtdm_event_t pseudo_select_event;
+
+int rt_socket_init(struct rtdm_dev_context *context);
+int rt_socket_cleanup(struct rtdm_dev_context *context);
+int rt_socket_common_ioctl(struct rtdm_dev_context *context,
+                           rtdm_user_info_t *user_info,
+                           int request, void *arg);
+int rt_socket_if_ioctl(struct rtdm_dev_context *context,
+                       rtdm_user_info_t *user_info,
+                       int request, void *arg);
+int rt_socket_select_bind(struct rtdm_dev_context *context,
+                          rtdm_selector_t *selector,
+                          enum rtdm_selecttype type,
+                          unsigned fd_index);
 
 #endif  /* __RTNET_SOCKET_H_ */
Index: rtnet/stack/packet/af_packet.c
===================================================================
--- rtnet/stack/packet/af_packet.c      (Revision 1183)
+++ rtnet/stack/packet/af_packet.c      (Arbeitskopie)
@@ -466,7 +466,10 @@ static struct rtdm_device   packet_proto
         .ioctl_rt =     rt_packet_ioctl,
         .ioctl_nrt =    rt_packet_ioctl,
         .recvmsg_rt =   rt_packet_recvmsg,
-        .sendmsg_rt =   rt_packet_sendmsg
+        .sendmsg_rt =   rt_packet_sendmsg,
+#ifdef CONFIG_RTNET_SELECT_SUPPORT
+        .select_bind =  rt_socket_select_bind,
+#endif
     },
 
     .device_class =     RTDM_CLASS_NETWORK,
@@ -496,7 +499,10 @@ static struct rtdm_device   raw_packet_p
         .ioctl_rt =     rt_packet_ioctl,
         .ioctl_nrt =    rt_packet_ioctl,
         .recvmsg_rt =   rt_packet_recvmsg,
-        .sendmsg_rt =   rt_packet_sendmsg
+        .sendmsg_rt =   rt_packet_sendmsg,
+#ifdef CONFIG_RTNET_SELECT_SUPPORT
+        .select_bind =  rt_socket_select_bind,
+#endif
     },
 
     .device_class =     RTDM_CLASS_NETWORK,
Index: rtnet/stack/socket.c
===================================================================
--- rtnet/stack/socket.c        (Revision 1183)
+++ rtnet/stack/socket.c        (Arbeitskopie)
@@ -290,6 +290,37 @@ int rt_socket_if_ioctl(struct rtdm_dev_c
 }
 
 
+#ifdef CONFIG_RTNET_SELECT_SUPPORT
+/* Remains always signaled, used for immediately completing write */
+rtdm_event_t pseudo_select_event;
+
+int rt_socket_select_bind(struct rtdm_dev_context *context,
+                          rtdm_selector_t *selector,
+                          enum rtdm_selecttype type,
+                          unsigned fd_index)
+{
+    struct rtsocket *sock = (struct rtsocket *)&context->dev_private;
+
+    switch (type) {
+        case XNSELECT_READ:
+            return rtdm_sem_select_bind(&sock->pending_sem, selector,
+                                        XNSELECT_READ, fd_index);
+        case XNSELECT_WRITE:
+            return rtdm_event_select_bind(&pseudo_select_event, selector,
+                                          XNSELECT_WRITE, fd_index);
+
+        case XNSELECT_EXCEPT:
+            return -EBADF;
+    }
+
+    return -EINVAL;
+}
+
+EXPORT_SYMBOL(rt_socket_select_bind);
+#endif /* CONFIG_RTNET_SELECT_SUPPORT */
+
+
+
 EXPORT_SYMBOL(rt_socket_init);
 EXPORT_SYMBOL(rt_socket_cleanup);
 EXPORT_SYMBOL(rt_socket_common_ioctl);

Attachment: signature.asc
Description: OpenPGP digital signature

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
RTnet-users mailing list
RTnet-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/rtnet-users

Reply via email to