On 20.09.2010 16:28, [email protected] wrote:
> Hello all,
>
Hello Vladislav,
>
> So, for getting the really correct Tx time stamp, the self reception
> message shall be written back to Rx queue and "labeled" with
> timestamp at the moment it really sent on the CAN, means in Tx
> interrupt:
>
>
> socket
> write
> |
> (1)
> |
> TxQueue --********--------------------
> |
> (2a)
> |
> CAN buff ---------********-------------
> | |
> | (3)
> | |
> CANbus --------------***--------------
> |
> RxQueue -----------------*********-----
> |
> (2)
> |
> socket
> read
>
>
> If the self reception message is looped back to Rx queue in Tx
> interrupt (3) end becomes time stamp exactly at this moment - when we
> are getting the correct starting point for our timeout countdown. And
> important issue - if we are using active CAN interface (the one with
> own microcontroller), the timestamp shall be generated by
> microcontroller and passed to SocketCAN driver.
The timestamp is set in netif_rx(). In the case above it's done at tx
completion interrupt, which looks like the behaviour you prefer to have.
Especially i would take a look into the per-socket filters, that would allow
you to filter for exact CAN-Identifiers, which prevents your socket rx-queue
to contain other stuff, that's sorted out in userspace. The used rx-queue
could be really short then.
E.g. you could use different sockets for different CAN-ID filters (and the
select()-syscall) to handle all of them in your userspace app.
>
> <-------------------------------------------------------------------->
>
>
> So, to sum that much stuff up:
>
> A) The proposal to extend CAN message with self reception flag. The
> self-received messages will have that flag set. One of the 4 unused
> bits of the can_frame.can_dlc may be e.g. used for that.
I do not have a general problem with providing a flag - but *not* inside
can_dlc ... which would break the userspace API as everyone would need to mask
the bits then.
Maybe we could use an existing/new information provided within a control
message - see answer for "C)"
> B) Is it possible to label CAN packets in the similar way as done by
> "--set-mark" in iptables?
??? Need to look into the ideas there. Maybe i can go for that tommorow.
> C) The looping back of self reception messages shall be done in CAN
> Tx interrupt and not in the ".ndo_start_xmit" .
The correct implementation with Wolfgangs echo_skb approach sends the sent CAN
frame at tx completion interrupt. See sja1000.c sja1000_interrupt().
The timestamp is generated at tx completion interrupt.
> D) Do we still need extra ioctl call to get the Rx message timestamp?
> I remember the discussion about the possibility to pass timestamp
> with the message itself about two years ago.
You can use recvmsg() - an example can be found for the timestamp and the
dropcounter in trunk/can-utils/candump.c
602 nbytes = recvmsg(s[i], &msg, 0);
(..)
627 for (cmsg = CMSG_FIRSTHDR(&msg);
628 cmsg && (cmsg->cmsg_level == SOL_SOCKET);
629 cmsg = CMSG_NXTHDR(&msg,cmsg)) {
630 if (cmsg->cmsg_type == SO_TIMESTAMP)
631 tv = *(struct timeval *)CMSG_DATA(cmsg);
632 else if (cmsg->cmsg_type == SO_RXQ_OVFL)
633 dropcnt[i] = *(__u32 *)CMSG_DATA(cmsg);
634 }
>
> Regards and RFC,
> Vladislav
Thanks for your ideas!
Oliver
_______________________________________________
Socketcan-core mailing list
[email protected]
https://lists.berlios.de/mailman/listinfo/socketcan-core