Linux CAN drivers development
 help / color / mirror / Atom feed
From: Oliver Hartkopp <socketcan@hartkopp.net>
To: Vincent Mailhol <vincent.mailhol@gmail.com>
Cc: linux-can@vger.kernel.org
Subject: Re: [RFC PATCH 1/5] can: canxl: introduce CAN XL data structure
Date: Thu, 14 Jul 2022 08:11:23 +0200	[thread overview]
Message-ID: <ae995ec1-8dbd-7484-a250-28d8637eb6ff@hartkopp.net> (raw)
In-Reply-To: <CAMZ6RqLSHAdB-ocj7=74zJqWbv-EH9x8X5ARPK6Gv+FFiTZ7Lg@mail.gmail.com>



On 14.07.22 03:23, Vincent Mailhol wrote:
> On Thu. 14 Jul. 2022 at 05:02, Oliver Hartkopp <socketcan@hartkopp.net> wrote:


> If we follow your idea, use __u8 xlsec in order to avoid undefined behaviours.
> 
>> Where we define
>>
>> #define CANXL_TAG 0x7F
> 
> Here, you "burn" all the flags for future usage.
> FYI, this doesn't have to be 0x7F. It could be any of the length
> values not allowed by CAN-FD, namely (in decimal): 9-11, 13-15, 17-19,
> 21-23, 25-31, 33-47, 49-63

Yes, I detected this issue too when waking up this morning ...

>> #define CANXL_SEC 0x80
> 
> I did not get why CANXL_XLF isn't needed anymore.
> 
>> which has to be set in the xlsec element then.
>>
>> With this move we get rid of any flags problems (we only need the SEC
>> bit anyway) and define a clear 'escape value' in the former length element.
> 
> If I try to bounce on your idea, I will propose:
> 
> /*********** begin **********/
> struct canxl_frame {
>          canid_t prio;  /* 11 bit priority for arbitration (canid_t) */
>          __u8    flags; /* additional flags for CAN XL. MSB must be set */
>          __u8    sdt;   /* SDU (service data unit) type */
>          __u16   len;   /* frame payload length in bytes */
>          __u32   af;    /* acceptance field */
>          __u8    data[];
> };

ACK.

> #define CANXL_XLF 0x01 /* mark CAN XL for dual use of struct canfd_frame */

IMO the dual use stuff between CAN FD & CAN XL is not working anymore 
and became obsolete here.

CAN_XLF needs to be a hard switch for CAN XL - no optional thing.

> #define CANXL_SEC 0x02 /* Simple Extended Content (security/segmentation) */
> #define CANXL_DISCRIMINATOR 0x80; /* Mandatory to distinguish between
> CAN(-FD) and XL frames */
> /*********** end ************/
> 
> This has no undefined behaviour and we still have five flags (0x04 to
> 0x40) for future use.
> 

I would suggest the following:

#define CANXL_XLF 0x80 /* mark CAN XL frame (must be set) */
#define CANXL_SEC 0x40 /* Simple Extended Content (security/segmentation) */

And the rest of the bits are reserved (shall be set to zero).

This way the CAN_XLF value would make the former 'len' element 128 - 
which is a proper distinction for CAN XL frames as such length value 
surely bounces on CAN/CANFD frames.

Best regards,
Oliver

  reply	other threads:[~2022-07-14  6:11 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-11 18:34 [RFC PATCH 0/5] can: support CAN XL Oliver Hartkopp
2022-07-11 18:34 ` [RFC PATCH 1/5] can: canxl: introduce CAN XL data structure Oliver Hartkopp
2022-07-12  0:36   ` Vincent Mailhol
2022-07-12  7:55     ` Oliver Hartkopp
2022-07-12  8:40       ` Vincent Mailhol
2022-07-12  9:31         ` Oliver Hartkopp
2022-07-12 10:19           ` Vincent Mailhol
2022-07-12 12:30             ` Oliver Hartkopp
2022-07-12 14:31               ` Vincent Mailhol
2022-07-12 19:24                 ` Oliver Hartkopp
2022-07-13  1:07                   ` Vincent Mailhol
2022-07-13 20:02                     ` Oliver Hartkopp
2022-07-14  1:23                       ` Vincent Mailhol
2022-07-14  6:11                         ` Oliver Hartkopp [this message]
2022-07-14  9:12                           ` Vincent Mailhol
2022-07-14 10:10                             ` Oliver Hartkopp
2022-07-11 18:34 ` [RFC PATCH 2/5] can: canxl: introduce ETH_P_CANXL ethernet protocol handling Oliver Hartkopp
2022-07-11 19:34   ` Marc Kleine-Budde
2022-07-11 19:41   ` Marc Kleine-Budde
2022-07-12  7:12     ` Oliver Hartkopp
2022-07-12  7:17       ` Marc Kleine-Budde
2022-07-12  8:02         ` Oliver Hartkopp
2022-07-12  8:10           ` Marc Kleine-Budde
2022-07-12  1:23   ` Vincent Mailhol
2022-07-12 20:20     ` Oliver Hartkopp
2022-07-12 23:58       ` Vincent Mailhol
2022-07-13  7:02         ` Marc Kleine-Budde
2022-07-13  7:15           ` Vincent Mailhol
2022-07-13 20:27             ` Oliver Hartkopp
2022-07-14  1:32               ` Vincent Mailhol
2022-07-11 18:34 ` [RFC PATCH 3/5] can: dev: add CAN XL support Oliver Hartkopp
2022-07-11 19:46   ` Marc Kleine-Budde
2022-07-12  7:08     ` Oliver Hartkopp
2022-07-11 18:34 ` [RFC PATCH 4/5] can: vcan: " Oliver Hartkopp
2022-07-11 18:34 ` [RFC PATCH 5/5] can: raw: " Oliver Hartkopp

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ae995ec1-8dbd-7484-a250-28d8637eb6ff@hartkopp.net \
    --to=socketcan@hartkopp.net \
    --cc=linux-can@vger.kernel.org \
    --cc=vincent.mailhol@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox