linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
To: Marc Kleine-Budde <mkl@pengutronix.de>,
	linux-can@vger.kernel.org, Thomas.Kopp@microchip.com
Cc: Oliver Hartkopp <socketcan@hartkopp.net>,
	netdev@vger.kernel.org, marex@denx.de,
	Simon Horman <simon.horman@corigine.com>,
	linux-kernel@vger.kernel.org,
	Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Subject: [PATCH v4 0/3] can: length: fix definitions and add bit length calculation
Date: Fri,  2 Jun 2023 01:56:22 +0900	[thread overview]
Message-ID: <20230601165625.100040-1-mailhol.vincent@wanadoo.fr> (raw)
In-Reply-To: <20230507155506.3179711-1-mailhol.vincent@wanadoo.fr>

When created in [1], frames length definitions were added to implement
byte queue limits (bql). Because bql expects lengths in bytes, bit
length definitions were not considered back then.
    
Recently, a need to refer to the exact frame length in bits, with CAN
bit stuffing, appeared in [2].

This series introduces can_frame_bits(): a function-like macro that
can calculate the exact size of a CAN(-FD) frame in bits with or
without bitsuffing.

[1] commit 85d99c3e2a13 ("can: length: can_skb_get_frame_len(): introduce
    function to get data length of frame in data link layer")
Link: https://git.kernel.org/torvalds/c/85d99c3e2a13

[2] RE: [PATCH] can: mcp251xfd: Increase poll timeout
Link: https://lore.kernel.org/linux-can/BL3PR11MB64846C83ACD04E9330B0FE66FB729@BL3PR11MB6484.namprd11.prod.outlook.com/


* Changelog *

v3 -> v4:

  * No functional changes.

  * as reported by Simon Horman, fix typo in the documentation of
    can_bitstuffing_len(): "bitstream_len" -> "destuffed_len".

  * as reported by Thomas Kopp, fix several other typos:
      - "indicatior" -> "indicator"
      - "in on the wire" -> "on the wire"
      - "bitsuffing" -> "bitstuffing".

  * in CAN_FRAME_LEN_MAX comment: specify that only the dynamic
    bitstuffing gets ignored but that the intermission is included.

  * move the Suggested-by: Thomas Kopp tag from patch 2 to patch 3.

  * add Reviewed-by: Thomas Kopp tag on the full series.

  * add an additional line of comment for the @intermission argument
    of can_frame_bits().

Link: https://lore.kernel.org/linux-can/20230530144637.4746-1-mailhol.vincent@wanadoo.fr/

v2 -> v3:

  * turn can_frame_bits() and can_frame_bytes() into function-like
    macros. The fact that inline functions can not be used to
    initialize constant struct fields was bothering me. I did my best
    to make the macro look as less ugly as possible.

  * as reported by Simon Horman, add missing document for the is_fd
    argument of can_frame_bits().

Link: https://lore.kernel.org/linux-can/20230523065218.51227-1-mailhol.vincent@wanadoo.fr/

v1 -> v2:

  * as suggested by Thomas Kopp, add a new patch to the series to fix
    the stuff bit count and the fixed stuff bits definitions

  * and another patch to fix documentation of the Remote Request
    Substitution (RRS).

  * refactor the length definition. Instead of using individual macro,
    rely on an inline function. One reason is to minimize the number
    of definitions. Another reason is that because the dynamic bit
    stuff is calculated differently for CAN and CAN-FD, it is just not
    possible to multiply the existing CANFD_FRAME_OVERHEAD_SFF/EFF by
    the overhead ratio to get the bitsuffing: for CAN-FD, the CRC
    field is already stuffed by the fixed stuff bits and is out of
    scope of the dynamic bitstuffing.

Link: https://lore.kernel.org/linux-can/20230507155506.3179711-1-mailhol.vincent@wanadoo.fr/

Vincent Mailhol (3):
  can: length: fix bitstuffing count
  can: length: fix description of the RRS field
  can: length: refactor frame lengths definition to add size in bits

 drivers/net/can/dev/length.c |  15 +-
 include/linux/can/length.h   | 300 +++++++++++++++++++++++++----------
 2 files changed, 217 insertions(+), 98 deletions(-)

-- 
2.39.3


  parent reply	other threads:[~2023-06-01 16:57 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-07 15:55 [PATCH] can: length: add definitions for frame lengths in bits Vincent Mailhol
2023-05-08  8:54 ` Thomas.Kopp
2023-05-08 12:14   ` Marc Kleine-Budde
2023-05-09  4:16     ` Vincent MAILHOL
2023-05-09  6:43       ` Marc Kleine-Budde
2023-05-09  8:14         ` Vincent MAILHOL
2023-05-09  6:19     ` Thomas.Kopp
2023-05-08 12:20 ` Marc Kleine-Budde
2023-05-09  4:58   ` Vincent MAILHOL
2023-05-09  7:12     ` Thomas.Kopp
2023-05-09  8:06       ` Vincent MAILHOL
2023-05-23  6:52 ` [PATCH v2 0/3] can: length: fix definitions and add bit length calculation Vincent Mailhol
2023-05-23  6:52   ` [PATCH v2 1/3] can: length: fix bitstuffing count Vincent Mailhol
2023-05-23  6:52   ` [PATCH v2 2/3] can: length: fix description of the RRS field Vincent Mailhol
2023-05-23  6:52   ` [PATCH v2 3/3] can: length: refactor frame lengths definition to add size in bits Vincent Mailhol
2023-05-23  7:13     ` Vincent MAILHOL
2023-05-23 11:14     ` Simon Horman
2023-05-30 14:46 ` [PATCH v3 0/3] can: length: fix definitions and add bit length calculation Vincent Mailhol
2023-05-30 14:46   ` [PATCH v3 1/3] can: length: fix bitstuffing count Vincent Mailhol
2023-05-30 14:46   ` [PATCH v3 2/3] can: length: fix description of the RRS field Vincent Mailhol
2023-05-30 14:46   ` [PATCH v3 3/3] can: length: refactor frame lengths definition to add size in bits Vincent Mailhol
2023-05-30 15:51     ` Simon Horman
2023-05-30 17:29       ` Vincent MAILHOL
2023-05-30 19:49         ` Simon Horman
2023-05-31  9:45           ` Vincent MAILHOL
2023-06-01 10:31     ` Thomas.Kopp
2023-06-01 11:00       ` Vincent MAILHOL
2023-06-01 11:26         ` Thomas.Kopp
2023-06-01 16:56 ` Vincent Mailhol [this message]
2023-06-01 16:56   ` [PATCH v4 1/3] can: length: fix bitstuffing count Vincent Mailhol
2023-06-01 16:56   ` [PATCH v4 2/3] can: length: fix description of the RRS field Vincent Mailhol
2023-06-01 16:56   ` [PATCH v4 3/3] can: length: refactor frame lengths definition to add size in bits Vincent Mailhol
2023-06-11  2:57 ` [PATCH v5 0/3] can: length: fix definitions and add bit length calculation Vincent Mailhol
2023-06-11  2:57   ` [PATCH v5 1/3] can: length: fix bitstuffing count Vincent Mailhol
2023-06-11  2:57   ` [PATCH v5 2/3] can: length: fix description of the RRS field Vincent Mailhol
2023-06-11  2:57   ` [PATCH v5 3/3] can: length: refactor frame lengths definition to add size in bits Vincent Mailhol

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=20230601165625.100040-1-mailhol.vincent@wanadoo.fr \
    --to=mailhol.vincent@wanadoo.fr \
    --cc=Thomas.Kopp@microchip.com \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marex@denx.de \
    --cc=mkl@pengutronix.de \
    --cc=netdev@vger.kernel.org \
    --cc=simon.horman@corigine.com \
    --cc=socketcan@hartkopp.net \
    /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;
as well as URLs for NNTP newsgroup(s).