Re: [RFC PATCH v3 0/5] can: support CAN XL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Oliver,

On Sunday 17 of July 2022 15:27:25 Oliver Hartkopp wrote:
> V2: Major rework after discussion and feedback on Linux-CAN ML
>
> - rework of struct canxl_frame
> - CANXL_XLF flag is now the switch between CAN XL and CAN/CANFD
> - variable length in r/w operations for CAN XL frames
> - write CAN XL frame to raw socket enforces size <-> canxl_frame.len sync

I generally like the idea but I would like even to extend it to process
all CAN messages types through same API.

+struct canxl_frame {
+       canid_t prio;  /* 11 bit priority for arbitration (canid_t) */
+       __u8    flags; /* additional flags for CAN XL */
+       __u8    sdt;   /* SDU (service data unit) type */
+       __u16   len;   /* frame payload length in byte */
+       __u32   af;    /* acceptance field */
+       __u8    data[CANXL_MAX_DLEN];
+};

I would suggest to think about possibility to have single structure type
for processing of all CAN frames types in usersace. When you define field
prio as anonyous union of prio and can_id

  union {
    canid_t prio;
    canid_t can_id;
  }

then it is possible to define flags such way, that canxl_frame is alternative
for all other formats

+#define CANXL_XLF 0x80 /* mandatory CAN XL frame flag (must always be set!) */
So CANXL_XLF will be changed to CANXLS_SELECT frame structure selected,
then rest of bits can be used for CANXLS_XLF, CANXLS_FD, in ideal case even
RTR, BRS etc.. or RTR can be left as part of ID if that is easier.
This way only single structure can be used to receive and send all
frames over single interface when XL option is selected
by software.

Yes, there would be redundancy in the kernel handling which has to accept
two types of encoding of CAN FD and standard messages but actual complexity
in usespace when you want to support all variants and for example
forward frames between interfaces or process them inside QEMU etc.
is really quite high.

Best wishes,

                Pavel
-- 
                Pavel Pisa
    phone:      +420 603531357
    e-mail:     pisa@xxxxxxxxxxxxxxxx
    Department of Control Engineering FEE CVUT
    Karlovo namesti 13, 121 35, Prague 2
    university: http://control.fel.cvut.cz/
    personal:   http://cmp.felk.cvut.cz/~pisa
    projects:   https://www.openhub.net/accounts/ppisa
    CAN related:http://canbus.pages.fel.cvut.cz/
    RISC-V education: https://comparch.edu.cvut.cz/
    Open Technologies Research Education and Exchange Services
    https://gitlab.fel.cvut.cz/otrees/org/-/wikis/home







[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux