From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 66389C77B75 for ; Tue, 23 May 2023 07:13:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235346AbjEWHNO (ORCPT ); Tue, 23 May 2023 03:13:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229836AbjEWHNN (ORCPT ); Tue, 23 May 2023 03:13:13 -0400 Received: from mail-pl1-f171.google.com (mail-pl1-f171.google.com [209.85.214.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32E56109; Tue, 23 May 2023 00:13:12 -0700 (PDT) Received: by mail-pl1-f171.google.com with SMTP id d9443c01a7336-1ae85b71141so37690405ad.0; Tue, 23 May 2023 00:13:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684825991; x=1687417991; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=03EqkJXrRuiNBz5G1C16TV++ckfGe0uKcUGxtIlIN1c=; b=Zb4idYWQadrH3kXRI8U5kCNJ3Sacwsusl7jhhu33TFZ0+ov7vCD7mCuOd/+R4DU5FU aZwMZmkidkOGioKvsb3766ikx5iVJVQWuaaYF9HhbkUN85QNqyf16tlWazTu1gZj79ye 7JbVySMAN5MdsI5jpu/XmFqt3/HtTXzYCWhvFCsSxqNRQULmm0A2Kc6Co/oesvZxV2zU F8fl1W7vJ238pK4bgcNj12NOCe/59tU+d4+WLvXHCMvQ+AEXeDD5uqXlQ4ZXKgkjojgu gCbnxUkBm16EBiGi4StNQl5rBolSWp7Otnik3XEmLKbtztIIiCCBczHGdJ/ti7AFYKjV 2Pgg== X-Gm-Message-State: AC+VfDz2vDwUF1eBqXiFoZ1s9CqJKE5InEtZS+zQZF8SITZ9k7jFatHy OItPP8iM5433v+cqWqijS/o+8K63urHWgxWY7GuM4TrySvo= X-Google-Smtp-Source: ACHHUZ6ItpQuMW2CtPldc9cn7XBOWsBXE2AZtmcG775brwPZlyqtLqXHSVzRpJt9g7Btt+oQVp/stuHoKGIg57fxV+8= X-Received: by 2002:a17:903:124b:b0:1ae:a44:841c with SMTP id u11-20020a170903124b00b001ae0a44841cmr14940907plh.42.1684825991089; Tue, 23 May 2023 00:13:11 -0700 (PDT) MIME-Version: 1.0 References: <20230507155506.3179711-1-mailhol.vincent@wanadoo.fr> <20230523065218.51227-1-mailhol.vincent@wanadoo.fr> <20230523065218.51227-4-mailhol.vincent@wanadoo.fr> In-Reply-To: <20230523065218.51227-4-mailhol.vincent@wanadoo.fr> From: Vincent MAILHOL Date: Tue, 23 May 2023 16:13:00 +0900 Message-ID: Subject: Re: [PATCH v2 3/3] can: length: refactor frame lengths definition to add size in bits To: Marc Kleine-Budde , linux-can@vger.kernel.org, Thomas.Kopp@microchip.com Cc: Oliver Hartkopp , netdev@vger.kernel.org, marex@denx.de Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-can@vger.kernel.org Sorry for the late reply, I wanted to have this completed earlier but other imperatives and the time needed to debug decided differently. On Tue. 23 May 2023 at 15:52, Vincent Mailhol wrote: > Introduce a method to calculate the exact size in bits of a CAN(-FD) > frame with or without dynamic bitsuffing. > > These are all the possible combinations taken into account: > > - Classical CAN or CAN-FD > - Standard or Extended frame format > - CAN-FD CRC17 or CRC21 > - Include or not intermission > > Instead of doing several macro definitions, declare the > can_frame_bits() static inline function. To this extend, do a full ^^^^^^ Typo: extent (I will not send a v3 just for that). > refactoring of the length definitions. > > If given integer constant expressions as argument, can_frame_bits() > folds into a compile time constant expression, giving no penalty over > the use of macros. > > Also add the can_frame_bytes(). This function replaces the existing > macro: > > - CAN_FRAME_OVERHEAD_SFF: can_frame_bytes(false, false, 0) > - CAN_FRAME_OVERHEAD_EFF: can_frame_bytes(false, true, 0) > - CANFD_FRAME_OVERHEAD_SFF: can_frame_bytes(true, false, 0) > - CANFD_FRAME_OVERHEAD_EFF: can_frame_bytes(true, true, 0) > > The different frame lengths (including intermission) are as follow: > > Frame type bits bytes > ---------------------------------------------------------- > Classic CAN SFF no-bitstuffing 111 14 > Classic CAN EFF no-bitstuffing 131 17 > Classic CAN SFF bitstuffing 135 17 > Classic CAN EFF bitstuffing 160 20 > CAN-FD SFF no-bitstuffing 579 73 > CAN-FD EFF no-bitstuffing 598 75 > CAN-FD SFF bitstuffing 712 89 > CAN-FD EFF bitstuffing 736 92 > > The macro CAN_FRAME_LEN_MAX and CANFD_FRAME_LEN_MAX are kept to be > used in const struct declarations (folding of can_frame_bytes() occurs > too late in the compilation to be used in struct declarations). To be fair, I am not fully happy with that part. The fact that can_frame_bits() and can_frame_bytes() can not be used in structure declaration even if these are compile time constants is unfortunate. But after reflection, I still see those inline functions as a better compromise than a collection of macro definitions. Let me know your thoughts. (...) Yours sincerely, Vincent Mailhol