* [Xenomai] Retrieval of user fd from struct rtdm_fd
@ 2018-10-14 19:27 Sebastian Smolorz
2018-10-15 8:26 ` Philippe Gerum
2018-10-15 11:18 ` Jan Kiszka
0 siblings, 2 replies; 8+ messages in thread
From: Sebastian Smolorz @ 2018-10-14 19:27 UTC (permalink / raw)
To: xenomai@xenomai.org
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?
--
Sebastian
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Xenomai] Retrieval of user fd from struct rtdm_fd
2018-10-14 19:27 [Xenomai] Retrieval of user fd from struct rtdm_fd Sebastian Smolorz
@ 2018-10-15 8:26 ` Philippe Gerum
2018-10-15 8:46 ` Sebastian Smolorz
2018-10-15 11:18 ` Jan Kiszka
1 sibling, 1 reply; 8+ messages in thread
From: Philippe Gerum @ 2018-10-15 8:26 UTC (permalink / raw)
To: Sebastian Smolorz, xenomai@xenomai.org
On 10/14/2018 09:27 PM, Sebastian Smolorz wrote:
> 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?
--
Philippe.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Xenomai] Retrieval of user fd from struct rtdm_fd
2018-10-15 8:26 ` Philippe Gerum
@ 2018-10-15 8:46 ` Sebastian Smolorz
0 siblings, 0 replies; 8+ messages in thread
From: Sebastian Smolorz @ 2018-10-15 8:46 UTC (permalink / raw)
To: Philippe Gerum; +Cc: xenomai@xenomai.org
Philippe Gerum wrote:
> On 10/14/2018 09:27 PM, Sebastian Smolorz wrote:
> > 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.
--
Sebastian
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Xenomai] Retrieval of user fd from struct rtdm_fd
2018-10-14 19:27 [Xenomai] Retrieval of user fd from struct rtdm_fd Sebastian Smolorz
2018-10-15 8:26 ` Philippe Gerum
@ 2018-10-15 11:18 ` Jan Kiszka
2018-10-15 13:17 ` Sebastian Smolorz
1 sibling, 1 reply; 8+ messages in thread
From: Jan Kiszka @ 2018-10-15 11:18 UTC (permalink / raw)
To: Sebastian Smolorz, xenomai@xenomai.org
On 14.10.18 21:27, Sebastian Smolorz wrote:
> 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).
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
--
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Xenomai] Retrieval of user fd from struct rtdm_fd
2018-10-15 11:18 ` Jan Kiszka
@ 2018-10-15 13:17 ` Sebastian Smolorz
2018-10-15 13:28 ` Philippe Gerum
0 siblings, 1 reply; 8+ messages in thread
From: Sebastian Smolorz @ 2018-10-15 13:17 UTC (permalink / raw)
To: Jan Kiszka; +Cc: xenomai@xenomai.org
Jan Kiszka wrote:
> On 14.10.18 21:27, Sebastian Smolorz wrote:
> > 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).
>
> 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
--
Sebastian
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Xenomai] Retrieval of user fd from struct rtdm_fd
2018-10-15 13:17 ` Sebastian Smolorz
@ 2018-10-15 13:28 ` Philippe Gerum
2018-10-15 13:30 ` Jan Kiszka
0 siblings, 1 reply; 8+ messages in thread
From: Philippe Gerum @ 2018-10-15 13:28 UTC (permalink / raw)
To: Sebastian Smolorz, Jan Kiszka; +Cc: xenomai@xenomai.org
On 10/15/2018 03:17 PM, Sebastian Smolorz wrote:
> Jan Kiszka wrote:
>
>> On 14.10.18 21:27, Sebastian Smolorz wrote:
>>> 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).
>>
>> 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
>
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).
--
Philippe.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Xenomai] Retrieval of user fd from struct rtdm_fd
2018-10-15 13:28 ` Philippe Gerum
@ 2018-10-15 13:30 ` Jan Kiszka
2018-10-15 13:35 ` Sebastian Smolorz
0 siblings, 1 reply; 8+ messages in thread
From: Jan Kiszka @ 2018-10-15 13:30 UTC (permalink / raw)
To: Philippe Gerum, Sebastian Smolorz; +Cc: xenomai@xenomai.org
On 15.10.18 15:28, Philippe Gerum wrote:
> On 10/15/2018 03:17 PM, Sebastian Smolorz wrote:
>> Jan Kiszka wrote:
>>
>>> On 14.10.18 21:27, Sebastian Smolorz wrote:
>>>> 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).
>>>
>>> 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
>>
>
> 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).
>
Ack.
Jan
--
Siemens AG, Corporate Technology, CT RDA IOT SES-DE
Corporate Competence Center Embedded Linux
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Xenomai] Retrieval of user fd from struct rtdm_fd
2018-10-15 13:30 ` Jan Kiszka
@ 2018-10-15 13:35 ` Sebastian Smolorz
0 siblings, 0 replies; 8+ messages in thread
From: Sebastian Smolorz @ 2018-10-15 13:35 UTC (permalink / raw)
To: Jan Kiszka; +Cc: Philippe Gerum, xenomai@xenomai.org
Jan Kiszka wrote:
> On 15.10.18 15:28, Philippe Gerum wrote:
> > On 10/15/2018 03:17 PM, Sebastian Smolorz wrote:
> >> Jan Kiszka wrote:
> >>
> >>> On 14.10.18 21:27, Sebastian Smolorz wrote:
> >>>> 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).
> >>>
> >>> 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
> >>
> >
> > 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).
> >
>
> Ack.
>
OK, will prepare a patch.
--
Sebastian
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2018-10-15 13:35 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-14 19:27 [Xenomai] Retrieval of user fd from struct rtdm_fd Sebastian Smolorz
2018-10-15 8:26 ` Philippe Gerum
2018-10-15 8:46 ` Sebastian Smolorz
2018-10-15 11:18 ` Jan Kiszka
2018-10-15 13:17 ` Sebastian Smolorz
2018-10-15 13:28 ` Philippe Gerum
2018-10-15 13:30 ` Jan Kiszka
2018-10-15 13:35 ` Sebastian Smolorz
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.