From patchwork Thu Jun 1 16:56:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Mailhol X-Patchwork-Id: 10180 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp486333vqr; Thu, 1 Jun 2023 10:11:42 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5bo8bOZooI1sTG7h+F7xmxaMxWmGWqC0Gwrs0pHEGFCetapPJk32O+I/JQgi3Ac24JvXdp X-Received: by 2002:a05:6a20:a1a0:b0:103:ef39:a829 with SMTP id r32-20020a056a20a1a000b00103ef39a829mr8076248pzk.26.1685639502674; Thu, 01 Jun 2023 10:11:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685639502; cv=none; d=google.com; s=arc-20160816; b=Rxbj67+OjZqhDJRC1VZCW8yK4hvD/nBvS/9NOR4bDfR0DKGWw9Plkd1itcaozWX2BI 9bILd6d2Zsl+ohg94ygCARwSgwE5w/cBY3awcaYpJrGDvoeV/q833ynaJj6DwefWIj+f Sl5lGvcpCq2fQX6eMp0vbb5vRaBozxYLu5hwQKXHGqorJMRW2XAozec3vVFXwApqAyaW YuBNU9UJ7dTwUGUMpqDdKSsf2LHdEENw03FCh9aBzWKJANdYT86Bc2NRTX9yERIOavqy vTR8nVJIzsbFXjZnJNsOB15e9LriJcsTasS8jLzcsr+PzI7pa5DDSQIJSlcdSN22PsHz ak+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from:sender :dkim-signature; bh=3heb74JBl16wDJKB1mNo+GNjKJlaQnxiPl5JWu620PA=; b=IR25tHp1uDyw8fL8Ii+ljO4lJuwjPwkRHxxHwYZbO+VQqklX3DTZ8McYyCuUZyL9uY 2PW/h6q7kSbDVrECKljv+eKXQtUQro6rn6lW4c7JjKPI+V1V5IbFif6dROG3bvz5URBR oTp1eyCVpsXSacKYvocxtACDJqjuYMTnLsLdvloUZp0NWrbcGQLdK2XnBKW2BVRu+R+D WiqukuL63Ly/ICp6NyF9WqcfoHQwnWJ/q1VFRjQugGEcLYYiVgwybYIK1Ly2Nx///TM5 eAjhpSXKs54siGEQU0taG8++RX5KQWE0BOkHuEt8NdoW0gLkwUeRh4PmFw4ub3+P2aBo 4B6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=kVbNiH4O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a134-20020a621a8c000000b0064cf289a327si1956457pfa.129.2023.06.01.10.11.30; Thu, 01 Jun 2023 10:11:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=kVbNiH4O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230491AbjFAQ5U (ORCPT + 99 others); Thu, 1 Jun 2023 12:57:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40040 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229667AbjFAQ5R (ORCPT ); Thu, 1 Jun 2023 12:57:17 -0400 Received: from mail-pl1-x632.google.com (mail-pl1-x632.google.com [IPv6:2607:f8b0:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 328F2193; Thu, 1 Jun 2023 09:57:15 -0700 (PDT) Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-1b075e13a5eso9415485ad.3; Thu, 01 Jun 2023 09:57:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1685638634; x=1688230634; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:from:to:cc:subject:date :message-id:reply-to; bh=3heb74JBl16wDJKB1mNo+GNjKJlaQnxiPl5JWu620PA=; b=kVbNiH4OCe3iCOwpvU24Kso5kf+or8Qv1NHstXz+o/BaR6m+9WCNPswOYV0SDRm6G5 NvLWn0Kuqv4+3TfS/Hwftt/jiQOBrv0toyvqnEKpX/SOACKjKkpV+lTuPtx/jqPjMId1 YqzDDCMUAyVMlpJ5jbhcdFmTzIQnDfuA6bIqGoq5FgOyTJ2tMEdBo4InFEy0z8lwTEOd XFSCNeJCKVfFrQCx1A5+as835T4Dn2SNL4ut+4YeOuDMQIRh8xyDxbwpYunE2+IYGuFs 8jMvLjjSGgZ58AgDErf43zyO5kYfw0eTVBoa9mdsXGa0MwdifJquYyt9aWKpdoMX8JMv fdFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685638634; x=1688230634; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:sender:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=3heb74JBl16wDJKB1mNo+GNjKJlaQnxiPl5JWu620PA=; b=I3AFgiR6stGZ8swTEbtNizO23sVAAKKVlBsbndV6fUyg5sFPLHMgLUxIpbZ6eAV7/G a+Q26JWrUH3KLP1T21NRT3i68+nMGu2lSnpNILD1deC3JQujfFwR8zBjpJ4VLRJMQPmt CxGVTbMMELii11hdUCUGtZU5CaaP3Mbhlz5yPg5XXFXs2ASo0Ll+qCF9hJc/rvN+9BIx 0z7cjeMsTGNRKPgUguBVr+cvRELHqrUVfmtk12JWqHEyvHnIjAIkqLwh/ZLm8s9EsVga 7PuUJWOVhfBlpqV+BF9tqe7tSipQbfwiyYS8OMUWGtYUO+6vcl422nuL2JnBkivCJ5yg 3EVg== X-Gm-Message-State: AC+VfDyZ/SUZmqx0urc2yKY4RW/K9qD6GrjpuzcR74cQ9tOS+QSq05yZ lVup1BR6iKswS49jGTac3Ps= X-Received: by 2002:a17:903:1109:b0:1b0:43fb:407f with SMTP id n9-20020a170903110900b001b043fb407fmr51795plh.10.1685638634456; Thu, 01 Jun 2023 09:57:14 -0700 (PDT) Received: from localhost.localdomain (124x33x176x97.ap124.ftth.ucom.ne.jp. [124.33.176.97]) by smtp.gmail.com with ESMTPSA id q5-20020a170902788500b001b0305757c3sm3744648pll.51.2023.06.01.09.57.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 09:57:13 -0700 (PDT) Sender: Vincent Mailhol From: Vincent Mailhol To: Marc Kleine-Budde , linux-can@vger.kernel.org, Thomas.Kopp@microchip.com Cc: Oliver Hartkopp , netdev@vger.kernel.org, marex@denx.de, Simon Horman , linux-kernel@vger.kernel.org, Vincent Mailhol Subject: [PATCH v4 0/3] can: length: fix definitions and add bit length calculation Date: Fri, 2 Jun 2023 01:56:22 +0900 Message-Id: <20230601165625.100040-1-mailhol.vincent@wanadoo.fr> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20230507155506.3179711-1-mailhol.vincent@wanadoo.fr> References: <20230507155506.3179711-1-mailhol.vincent@wanadoo.fr> MIME-Version: 1.0 X-Spam-Status: No, score=-1.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1767330999157407456?= X-GMAIL-MSGID: =?utf-8?q?1767521126895459534?= 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(-)