Patch "can: length: fix bitstuffing count" has been added to the 5.15-stable tree

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

 



This is a note to let you know that I've just added the patch titled

    can: length: fix bitstuffing count

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     can-length-fix-bitstuffing-count.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 383bfa43bd472f5a3da3f96b0d8662a712867a31
Author: Vincent Mailhol <mailhol.vincent@xxxxxxxxxx>
Date:   Sun Jun 11 11:57:26 2023 +0900

    can: length: fix bitstuffing count
    
    [ Upstream commit 9fde4c557f78ee2f3626e92b4089ce9d54a2573a ]
    
    The Stuff Bit Count is always coded on 4 bits [1]. Update the Stuff
    Bit Count size accordingly.
    
    In addition, the CRC fields of CAN FD Frames contain stuff bits at
    fixed positions called fixed stuff bits [2]. The CRC field starts with
    a fixed stuff bit and then has another fixed stuff bit after each
    fourth bit [2], which allows us to derive this formula:
    
      FSB count = 1 + round_down(len(CRC field)/4)
    
    The length of the CRC field is [1]:
    
      len(CRC field) = len(Stuff Bit Count) + len(CRC)
                     = 4 + len(CRC)
    
    with len(CRC) either 17 or 21 bits depending of the payload length.
    
    In conclusion, for CRC17:
    
      FSB count = 1 + round_down((4 + 17)/4)
                = 6
    
    and for CRC 21:
    
      FSB count = 1 + round_down((4 + 21)/4)
                = 7
    
    Add a Fixed Stuff bits (FSB) field with above values and update
    CANFD_FRAME_OVERHEAD_SFF and CANFD_FRAME_OVERHEAD_EFF accordingly.
    
    [1] ISO 11898-1:2015 section 10.4.2.6 "CRC field":
    
      The CRC field shall contain the CRC sequence followed by a recessive
      CRC delimiter. For FD Frames, the CRC field shall also contain the
      stuff count.
    
      Stuff count
    
      If FD Frames, the stuff count shall be at the beginning of the CRC
      field. It shall consist of the stuff bit count modulo 8 in a 3-bit
      gray code followed by a parity bit [...]
    
    [2] ISO 11898-1:2015 paragraph 10.5 "Frame coding":
    
      In the CRC field of FD Frames, the stuff bits shall be inserted at
      fixed positions; they are called fixed stuff bits. There shall be a
      fixed stuff bit before the first bit of the stuff count, even if the
      last bits of the preceding field are a sequence of five consecutive
      bits of identical value, there shall be only the fixed stuff bit,
      there shall not be two consecutive stuff bits. A further fixed stuff
      bit shall be inserted after each fourth bit of the CRC field [...]
    
    Fixes: 85d99c3e2a13 ("can: length: can_skb_get_frame_len(): introduce function to get data length of frame in data link layer")
    Suggested-by: Thomas Kopp <Thomas.Kopp@xxxxxxxxxxxxx>
    Signed-off-by: Vincent Mailhol <mailhol.vincent@xxxxxxxxxx>
    Reviewed-by: Thomas Kopp <Thomas.Kopp@xxxxxxxxxxxxx>
    Link: https://lore.kernel.org/all/20230611025728.450837-2-mailhol.vincent@xxxxxxxxxx
    Signed-off-by: Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/include/linux/can/length.h b/include/linux/can/length.h
index 6995092b774ec..ef1fd32cef16b 100644
--- a/include/linux/can/length.h
+++ b/include/linux/can/length.h
@@ -69,17 +69,18 @@
  * Error Status Indicator (ESI)		1
  * Data length code (DLC)		4
  * Data field				0...512
- * Stuff Bit Count (SBC)		0...16: 4 20...64:5
+ * Stuff Bit Count (SBC)		4
  * CRC					0...16: 17 20...64:21
  * CRC delimiter (CD)			1
+ * Fixed Stuff bits (FSB)		0...16: 6 20...64:7
  * ACK slot (AS)			1
  * ACK delimiter (AD)			1
  * End-of-frame (EOF)			7
  * Inter frame spacing			3
  *
- * assuming CRC21, rounded up and ignoring bitstuffing
+ * assuming CRC21, rounded up and ignoring dynamic bitstuffing
  */
-#define CANFD_FRAME_OVERHEAD_SFF DIV_ROUND_UP(61, 8)
+#define CANFD_FRAME_OVERHEAD_SFF DIV_ROUND_UP(67, 8)
 
 /*
  * Size of a CAN-FD Extended Frame
@@ -98,17 +99,18 @@
  * Error Status Indicator (ESI)		1
  * Data length code (DLC)		4
  * Data field				0...512
- * Stuff Bit Count (SBC)		0...16: 4 20...64:5
+ * Stuff Bit Count (SBC)		4
  * CRC					0...16: 17 20...64:21
  * CRC delimiter (CD)			1
+ * Fixed Stuff bits (FSB)		0...16: 6 20...64:7
  * ACK slot (AS)			1
  * ACK delimiter (AD)			1
  * End-of-frame (EOF)			7
  * Inter frame spacing			3
  *
- * assuming CRC21, rounded up and ignoring bitstuffing
+ * assuming CRC21, rounded up and ignoring dynamic bitstuffing
  */
-#define CANFD_FRAME_OVERHEAD_EFF DIV_ROUND_UP(80, 8)
+#define CANFD_FRAME_OVERHEAD_EFF DIV_ROUND_UP(86, 8)
 
 /*
  * Maximum size of a Classical CAN frame



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux