From: Arun Muthusamy <arun.muthusamy@gaisler.com>
To: Marc Kleine-Budde <mkl@pengutronix.de>
Cc: robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org,
mailhol@kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-can@vger.kernel.org
Subject: Re: [PATCH v3 13/15] can: grcan: Add CANFD TX support alongside legacy CAN
Date: Tue, 27 Jan 2026 15:17:58 +0100 [thread overview]
Message-ID: <99495edc-83aa-4427-89dc-bbeb0faac72f@gaisler.com> (raw)
In-Reply-To: <20260127-fancy-fast-bird-e7c4c3-mkl@pengutronix.de>
On 1/27/26 15:12, Marc Kleine-Budde wrote:
> On 27.01.2026 15:06:55, Arun Muthusamy wrote:
>> On 1/23/26 15:25, Marc Kleine-Budde wrote:
>>> On 22.01.2026 13:10:36, Arun Muthusamy wrote:
>>>> Include CANFD TX support with the legacy CAN support, enabling
>>>> support for extended data payloads to provide higher bit rates.
>>>>
>>>> Signed-off-by: Arun Muthusamy <arun.muthusamy@gaisler.com>
>>>> ---
>>>> drivers/net/can/grcan.c | 102 +++++++++++++++++++++++++++++-----------
>>>> 1 file changed, 74 insertions(+), 28 deletions(-)
>>>>
>>>> diff --git a/drivers/net/can/grcan.c b/drivers/net/can/grcan.c
>>>> index 9fc18064fab1..508ad5320cff 100644
>>>> --- a/drivers/net/can/grcan.c
>>>> +++ b/drivers/net/can/grcan.c
>>>> @@ -174,6 +174,7 @@ struct grcan_registers {
>>>> #define GRCAN_IRQ_DEFAULT (GRCAN_IRQ_RX | GRCAN_IRQ_TX | GRCAN_IRQ_ERRORS)
>>>>
>>>> #define GRCAN_MSG_SIZE 16
>>>> +#define GRCAN_CLASSIC_DATA_SIZE 8
>>>>
>>>> #define GRCAN_MSG_IDE 0x80000000
>>>> #define GRCAN_MSG_RTR 0x40000000
>>>> @@ -195,6 +196,10 @@ struct grcan_registers {
>>>> #define GRCAN_MSG_OFF 0x00000002
>>>> #define GRCAN_MSG_PASS 0x00000001
>>>>
>>>> +#define GRCAN_MSG_EID_MASK GENMASK(28, 0)
>>>> +#define GRCAN_MSG_BID_MASK GENMASK(28, 18)
>>>> +#define GRCAN_MSG_DLC_MASK GENMASK(31, 28)
>>>> +
>>>> #define GRCAN_BUFFER_ALIGNMENT 1024
>>>> #define GRCAN_DEFAULT_BUFFER_SIZE 1024
>>>> #define GRCAN_VALID_TR_SIZE_MASK 0x001fffc0
>>>> @@ -227,6 +232,9 @@ struct grcan_registers {
>>>> #define GRCANFD_FDBTR_PS2_BIT 5
>>>> #define GRCANFD_FDBTR_SJW_BIT 0
>>>>
>>>> +#define GRCAN_TX_BRS BIT(25)
>>>> +#define GRCAN_TX_FDF BIT(26)
>>>> +
>>>> /* Hardware capabilities */
>>>> struct grcan_hwcap {
>>>> /* CAN-FD capable, indicates GRCANFD IP.
>>>> @@ -1218,6 +1226,13 @@ static void grcan_transmit_catch_up(struct net_device *dev)
>>>> spin_unlock_irqrestore(&priv->lock, flags);
>>>> }
>>>>
>>>> +static int grcan_numbds(int len)
>>>> +{
>>>> + if (len <= GRCAN_CLASSIC_DATA_SIZE)
>>>> + return 1;
>>>> + return 1 + ((len - GRCAN_CLASSIC_DATA_SIZE + GRCAN_MSG_SIZE) / GRCAN_MSG_SIZE);
>>> This looks strange, what is calculated here? Why is "<=
>>> GRCAN_CLASSIC_DATA_SIZE" a special case?
>> grcan_numbds() calculates the number of buffer descriptors needed based on the data length.
>> The condition "len <= GRCAN_CLASSIC_DATA_SIZE" addresses cases where the data length fits within a one buffer descriptor.
>> For data lengths greater than "GRCAN_CLASSIC_DATA_SIZE", it computes additional descriptors needed.
> What happens if "len = GRCAN_CLASSIC_DATA_SIZE + GRCAN_MSG_SIZE"?
>
> | return 1 + ((len - GRCAN_CLASSIC_DATA_SIZE + GRCAN_MSG_SIZE) / GRCAN_MSG_SIZE);
>
> = 1 + ((GRCAN_CLASSIC_DATA_SIZE + GRCAN_MSG_SIZE - GRCAN_CLASSIC_DATA_SIZE + GRCAN_MSG_SIZE) / GRCAN_MSG_SIZE);
> = 1 + (( GRCAN_MSG_SIZE - + GRCAN_MSG_SIZE) / GRCAN_MSG_SIZE);
> = 1 + 2;
> = 3
>
> Is this correct?
>
Thanks for pointing out.
That's not correct. It will be addressed in the next patch series.
--
--
BR,
Arun Muthusamy
Software Engineer
Frontgrade Gaisler
T : +46 (0) 700 558 528
arun.muthusamy@gaisler.com
Frontgrade Gaisler AB, Kungsgatan 12, SE-411 19 GÖTEBORG, Sweden.
+46 (0) 31 775 8650, www.gaisler.com
next prev parent reply other threads:[~2026-01-27 14:18 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-22 12:10 [PATCH v3 00/15] can: grcan: Enhance driver with CANFD Support and Improvemens Arun Muthusamy
2026-01-22 12:10 ` [PATCH v3 01/15] dt-bindings: Add vendor prefix for Frontgrade Gaisler AB Arun Muthusamy
2026-01-22 12:44 ` Krzysztof Kozlowski
2026-01-22 12:10 ` [PATCH v3 02/15] net: can: Convert gaisler,grcan to DT schema Arun Muthusamy
2026-01-22 12:10 ` [PATCH v3 03/15] MAINTAINERS: Add maintainers for GRCAN CAN network driver Arun Muthusamy
2026-01-22 12:10 ` [PATCH v3 04/15] can: grcan: Add clock handling Arun Muthusamy
2026-01-23 13:44 ` Marc Kleine-Budde
2026-01-27 13:27 ` Arun Muthusamy
2026-01-22 12:10 ` [PATCH v3 05/15] can: grcan: Replace bit timing macros with literal values Arun Muthusamy
2026-01-22 12:10 ` [PATCH v3 06/15] can: grcan: Simplify timing configuration Arun Muthusamy
2026-01-22 12:10 ` [PATCH v3 07/15] can: grcan: add FD capability detection and nominal bit-timing Arun Muthusamy
2026-01-23 13:52 ` Marc Kleine-Budde
2026-01-22 12:10 ` [PATCH v3 08/15] can: grcan: optimize DMA by 32-bit accesses Arun Muthusamy
2026-01-22 12:10 ` [PATCH v3 09/15] can: grcan: set DMA mask for GRCAN and GRCANFD to 32-bit Arun Muthusamy
2026-01-22 12:10 ` [PATCH v3 10/15] can: grcan: Add saving and restoring of CAN FD baud-rate registers Arun Muthusamy
2026-01-23 14:00 ` Marc Kleine-Budde
2026-01-28 8:35 ` Arun Muthusamy
2026-01-22 12:10 ` [PATCH v3 11/15] can: grcan: Reserve space between cap and next register to align with address layout Arun Muthusamy
2026-01-22 12:10 ` [PATCH v3 12/15] can: grcan: Advertise CANFD capability Arun Muthusamy
2026-01-22 12:10 ` [PATCH v3 13/15] can: grcan: Add CANFD TX support alongside legacy CAN Arun Muthusamy
2026-01-23 14:25 ` Marc Kleine-Budde
2026-01-27 14:06 ` Arun Muthusamy
2026-01-27 14:12 ` Marc Kleine-Budde
2026-01-27 14:17 ` Arun Muthusamy [this message]
2026-01-27 14:18 ` Marc Kleine-Budde
2026-01-22 12:10 ` [PATCH v3 14/15] can: grcan: Add CANFD RX " Arun Muthusamy
2026-01-22 12:10 ` [PATCH v3 15/15] can: grcan: Update echo skb handling to match variable length CANFD frame Arun Muthusamy
2026-01-23 14:12 ` Marc Kleine-Budde
2026-01-23 14:17 ` Marc Kleine-Budde
2026-01-28 8:14 ` Arun Muthusamy
2026-01-23 14:30 ` [PATCH v3 00/15] can: grcan: Enhance driver with CANFD Support and Improvemens Marc Kleine-Budde
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=99495edc-83aa-4427-89dc-bbeb0faac72f@gaisler.com \
--to=arun.muthusamy@gaisler.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mailhol@kernel.org \
--cc=mkl@pengutronix.de \
--cc=robh@kernel.org \
/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
all inboxes | Powered by JetHome®