OSDN Git Service

can: c_can: cache frames to operate as a true FIFO
authorDario Binacchi <dariobin@libero.it>
Sat, 7 Aug 2021 13:08:00 +0000 (15:08 +0200)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Thu, 19 Aug 2021 13:07:06 +0000 (15:07 +0200)
commit387da6bc7a826cc6d532b1c0002b7c7513238d5f
treea9206840eaf83c92167e6fee27413fdd3277a692
parent28e86e9ab522e65b08545e5008d0f1ac5b19dad1
can: c_can: cache frames to operate as a true FIFO

As reported by a comment in the c_can_start_xmit() this was not a FIFO.
C/D_CAN controller sends out the buffers prioritized so that the lowest
buffer number wins.

What did c_can_start_xmit() do if head was less tail in the tx ring ? It
waited until all the frames queued in the FIFO was actually transmitted
by the controller before accepting a new CAN frame to transmit, even if
the FIFO was not full, to ensure that the messages were transmitted in
the order in which they were loaded.

By storing the frames in the FIFO without requiring its transmission, we
will be able to use the full size of the FIFO even in cases such as the
one described above. The transmission interrupt will trigger their
transmission only when all the messages previously loaded but stored in
less priority positions of the buffers have been transmitted.

Link: https://lore.kernel.org/r/20210807130800.5246-5-dariobin@libero.it
Suggested-by: Gianluca Falavigna <gianluca.falavigna@inwind.it>
Signed-off-by: Dario Binacchi <dariobin@libero.it>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
drivers/net/can/c_can/c_can.h
drivers/net/can/c_can/c_can_main.c