Retrieval of user fd from struct rtdm_fd
Hello Philippe or Jan,
I need to retrieve the socket file descriptor from an RTDM device driver routine. From what I have seen there is no simple way to obtain this int value from struct rtdm_fd. I have identified three possible ways to do this, all of them necessitate modification of Xenomai code outside the driver:
1. Iterate over the rb_tree rtdm_fd->owner->fds by means of the macro xntree_for_each_entry(pos, root, member). For this macro to work the definition of struct rtdm_fd_index must be known to the driver which means that it would have to be moved from kernel/cobalt/rtdm/fd.c to e.g. include/cobalt/kernel/rtdm/fd.h.
2. Similar to 1. but offer a new function rtdm_fd_get_ufd(struct rtdm_fd *fd) in which the rb_tree is searched.
3. Introduce a new value "int ufd" in struct rtdm_fd for setting and getting the ufd directly (which would be overkill I suppose because the vast majority of drivers don't need it).
What do you think, which of the above would you prefer?
Signature · 1 line
Sebastian
Quoted 4 lines · Sebastian Smolorz
Hello Philippe or Jan,
I need to retrieve the socket file descriptor from an RTDM device driver routine.
Could you elaborate on the reason to need this?
Signature · 1 line
Philippe.
Quoted 7 lines · Philippe Gerum
Quoted 4 lines · Sebastian Smolorz
Hello Philippe or Jan,
I need to retrieve the socket file descriptor from an RTDM device driver routine.
Could you elaborate on the reason to need this?
The rttcp driver was programmed to only accept one connection and not create a new socket for it but instead use the existing one. So rt_tcp_accept() returns its socket's fd number.
Signature · 1 line
Sebastian
Quoted 14 lines · Sebastian Smolorz
Hello Philippe or Jan,
I need to retrieve the socket file descriptor from an RTDM device driver routine. From what I have seen there is no simple way to obtain this int value from struct
rtdm_fd. I have identified three possible ways to do this, all of them necessitate modification of Xenomai code outside the driver:1. Iterate over the
rb_treertdm_fd->owner->fdsby means of the macroxntree_for_each_entry(pos, root, member). For this macro to work the definition of structrtdm_fd_indexmust be known to the driver which means that it would have to be moved fromkernel/cobalt/rtdm/fd.cto e.g.include/cobalt/kernel/rtdm/fd.h.
Quoted 6 lines
2. Similar to 1. but offer a new function
rtdm_fd_get_ufd(struct rtdm_fd *fd)in which therb_treeis searched.3. Introduce a new value "int ufd" in struct
rtdm_fdfor setting and getting the ufd directly (which would be overkill I suppose because the vast majority of drivers don't need it).
OTOH, that structure is not really optimized for size. So I do not see why it shouldn't take yet another int, which would also be a faster API than the other options.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux
Quoted 18 lines · Jan Kiszka
Quoted 17 lines · Sebastian Smolorz
Hello Philippe or Jan,
I need to retrieve the socket file descriptor from an RTDM device driver routine. From what I have seen there is no simple way to obtain this int value from struct
rtdm_fd. I have identified three possible ways to do this, all of them necessitate modification of Xenomai code outside the driver:1. Iterate over the
rb_treertdm_fd->owner->fdsby means of the macroxntree_for_each_entry(pos, root, member). For this macro to work the definition of structrtdm_fd_indexmust be known to the driver which means that it would have to be moved fromkernel/cobalt/rtdm/fd.cto e.g.include/cobalt/kernel/rtdm/fd.h.2. Similar to 1. but offer a new function
rtdm_fd_get_ufd(struct rtdm_fd *fd)in which therb_treeis searched.
Quoted 7 lines
Quoted 3 lines
3. Introduce a new value "int ufd" in struct
rtdm_fdfor setting and getting the ufd directly (which would be overkill I suppose because the vast majority of drivers don't need it).OTOH, that structure is not really optimized for size. So I do not see why it shouldn't take yet another int, which would also be a faster API than the other options.
Correct. Nevertheless, we could mitigate the effect of this change by surrounding the new ufd field with
#ifdef CONFIG_XENO_DRIVERS_NET_RTIPV4_TCP
Signature · 1 line
Sebastian
Quoted 24 lines · Sebastian Smolorz
Quoted 22 lines · Jan Kiszka
Quoted 20 lines · Sebastian Smolorz
Hello Philippe or Jan,
I need to retrieve the socket file descriptor from an RTDM device driver routine. From what I have seen there is no simple way to obtain this int value from struct
rtdm_fd. I have identified three possible ways to do this, all of them necessitate modification of Xenomai code outside the driver:1. Iterate over the
rb_treertdm_fd->owner->fdsby means of the macroxntree_for_each_entry(pos, root, member). For this macro to work the definition of structrtdm_fd_indexmust be known to the driver which means that it would have to be moved fromkernel/cobalt/rtdm/fd.cto e.g.include/cobalt/kernel/rtdm/fd.h.2. Similar to 1. but offer a new function
rtdm_fd_get_ufd(struct rtdm_fd *fd)in which therb_treeis searched.3. Introduce a new value "int ufd" in struct
rtdm_fdfor setting and getting the ufd directly (which would be overkill I suppose because the vast majority of drivers don't need it).
Quoted 8 lines
Quoted 3 lines
OTOH, that structure is not really optimized for size. So I do not see why it shouldn't take yet another int, which would also be a faster API than the other options.
Correct. Nevertheless, we could mitigate the effect of this change by surrounding the new ufd field with
#ifdefCONFIG_XENO_DRIVERS_NET_RTIPV4_TCP
The core layer implementing RTDM fd is not supposed to depend on high level remote features such as tcp protocol over rtnet.
Let's just add the missing info to rtdm_fd unconditionally, we are talking about a few tenths of additional bytes in a typical Xenomai system fitted with several MB of memory (likely less than what would be needed to scan the fd tree to retrieve the same information btw).
Signature · 1 line
Philippe.
Quoted 34 lines · Philippe Gerum
Quoted 24 lines · Sebastian Smolorz
Quoted 22 lines · Jan Kiszka
Quoted 20 lines · Sebastian Smolorz
Hello Philippe or Jan,
I need to retrieve the socket file descriptor from an RTDM device driver routine. From what I have seen there is no simple way to obtain this int value from struct
rtdm_fd. I have identified three possible ways to do this, all of them necessitate modification of Xenomai code outside the driver:1. Iterate over the
rb_treertdm_fd->owner->fdsby means of the macroxntree_for_each_entry(pos, root, member). For this macro to work the definition of structrtdm_fd_indexmust be known to the driver which means that it would have to be moved fromkernel/cobalt/rtdm/fd.cto e.g.include/cobalt/kernel/rtdm/fd.h.2. Similar to 1. but offer a new function
rtdm_fd_get_ufd(struct rtdm_fd *fd)in which therb_treeis searched.3. Introduce a new value "int ufd" in struct
rtdm_fdfor setting and getting the ufd directly (which would be overkill I suppose because the vast majority of drivers don't need it).Quoted 8 lines
Quoted 3 lines
OTOH, that structure is not really optimized for size. So I do not see why it shouldn't take yet another int, which would also be a faster API than the other options.
Correct. Nevertheless, we could mitigate the effect of this change by surrounding the new ufd field with
#ifdefCONFIG_XENO_DRIVERS_NET_RTIPV4_TCP
Quoted 8 lines
The core layer implementing RTDM fd is not supposed to depend on high level remote features such as tcp protocol over rtnet.
Let's just add the missing info to
rtdm_fdunconditionally, we are talking about a few tenths of additional bytes in a typical Xenomai system fitted with several MB of memory (likely less than what would be needed to scan the fd tree to retrieve the same information btw).
Ack.
Jan
Signature · 2 lines
Siemens AG, Corporate Technology, CT RDA IOT SES-DE Corporate Competence Center Embedded Linux
Quoted 38 lines · Jan Kiszka
Quoted 37 lines · Philippe Gerum
Quoted 24 lines · Sebastian Smolorz
Quoted 22 lines · Jan Kiszka
Quoted 20 lines · Sebastian Smolorz
Hello Philippe or Jan,
I need to retrieve the socket file descriptor from an RTDM device driver routine. From what I have seen there is no simple way to obtain this int value from struct
rtdm_fd. I have identified three possible ways to do this, all of them necessitate modification of Xenomai code outside the driver:1. Iterate over the
rb_treertdm_fd->owner->fdsby means of the macroxntree_for_each_entry(pos, root, member). For this macro to work the definition of structrtdm_fd_indexmust be known to the driver which means that it would have to be moved fromkernel/cobalt/rtdm/fd.cto e.g.include/cobalt/kernel/rtdm/fd.h.2. Similar to 1. but offer a new function
rtdm_fd_get_ufd(struct rtdm_fd *fd)in which therb_treeis searched.3. Introduce a new value "int ufd" in struct
rtdm_fdfor setting and getting the ufd directly (which would be overkill I suppose because the vast majority of drivers don't need it).Quoted 8 lines
Quoted 3 lines
OTOH, that structure is not really optimized for size. So I do not see why it shouldn't take yet another int, which would also be a faster API than the other options.
Correct. Nevertheless, we could mitigate the effect of this change by surrounding the new ufd field with
#ifdefCONFIG_XENO_DRIVERS_NET_RTIPV4_TCPThe core layer implementing RTDM fd is not supposed to depend on high level remote features such as tcp protocol over rtnet.
Quoted 8 lines
Quoted 5 lines
Let's just add the missing info to
rtdm_fdunconditionally, we are talking about a few tenths of additional bytes in a typical Xenomai system fitted with several MB of memory (likely less than what would be needed to scan the fd tree to retrieve the same information btw).Ack.
OK, will prepare a patch.
Signature · 1 line
Sebastian