[RTnet-developers] SO_TIMESTAMPNS for RTnet
Brought to you by:
bet-frogger,
kiszka
From: Manuel H. <man...@gm...> - 2013-05-19 08:25:22
|
Hello! I'm currently working on a patch for RTnet (https://bitbucket.org/robinreal/rtnetts/overview exp branch) that enables the user to retrieve time stamps from the driver (via recvmsg). Currently development is not finished, there are still bugs and I need to rewrite commit messages. Overview: * I hooked into the rt_udp_recvmsg function to optionally add time stamps to the msghdr struct. The rt_socket_recv_timestamp function is used to actually retrieve put the time stamp into the cmsg buffer. This could maybe also be used for other protocols (?). * In stack/scm.c the original put_cmsg function has been ported to RTDM. Currently I haven't yet implemented the put_cmsg_compat function. * In rtnet_socket.h I added a member sk_flags, which could be used for various other functions. This is used to activate and deactivate passing time stamps to the user (through msghdr structure). * CONFIG_RTNET_SO_TIMESTAMPNS can be used to control whether RTnet stack supports passing timestamps to user-space or not. During implementation I ran into some problems: * I couldn't really find out, where the "normal" Linux Kernel fixes the cmsg structure. After all messages have been added to the buffer, the original start address and the resulting length has to be written to the structure. I'm currently doing this in rt_udp_recvmsg (just before "return") but I believe there is a better place... * I don't understand how to implement socket options. Is it okay to just introduce a new ioctl, or is it better to use setsockopt? I'm just unsure where to implement this. Currently I wrote some code to ip_sock.c in stack/ipv4 but that's wrong. It currently doesn't work because of the level... The Linux Kernel has got the file sock.c which implements a handler for SOL_SOCKET. Is there a simple method to use setsockopt, or is it better to just introduce a new ioctl? * Is it a good idea to support a similar interface as normal SO_TIMESTAMPNS which requires to transform nanosecs_abs_t to a timespec structure? To support this, I would have to evaluate a division and a modulo operation of a 64bits variable and a 32bit constant. I'm not sure whether this is a good idea or not. Currently I'm thinking about inventing a new cmsg identifier and flag to just copy the nanosecs variable and also support SO_TIMESTAMPNS (which will introduce some extra latency when active). I'm looking forward to your comments. Please let me know if you have better ideas to implement this, I would love to improve the current implementation ;) Best regards, Manuel |