summaryrefslogtreecommitdiff
path: root/drivers/net/can/c_can/c_can.h
diff options
context:
space:
mode:
authorDario Binacchi <dariobin@libero.it>2021-08-07 15:08:00 +0200
committerMarc Kleine-Budde <mkl@pengutronix.de>2021-08-19 15:07:06 +0200
commit387da6bc7a826cc6d532b1c0002b7c7513238d5f (patch)
treea9206840eaf83c92167e6fee27413fdd3277a692 /drivers/net/can/c_can/c_can.h
parent28e86e9ab522e65b08545e5008d0f1ac5b19dad1 (diff)
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>
Diffstat (limited to 'drivers/net/can/c_can/c_can.h')
-rw-r--r--drivers/net/can/c_can/c_can.h11
1 files changed, 1 insertions, 10 deletions
diff --git a/drivers/net/can/c_can/c_can.h b/drivers/net/can/c_can/c_can.h
index 9b4e54c950a6..08b6efa7a1a7 100644
--- a/drivers/net/can/c_can/c_can.h
+++ b/drivers/net/can/c_can/c_can.h
@@ -238,16 +238,7 @@ static inline u8 c_can_get_tx_tail(const struct c_can_tx_ring *ring)
static inline u8 c_can_get_tx_free(const struct c_can_tx_ring *ring)
{
- u8 head = c_can_get_tx_head(ring);
- u8 tail = c_can_get_tx_tail(ring);
-
- /* This is not a FIFO. C/D_CAN sends out the buffers
- * prioritized. The lowest buffer number wins.
- */
- if (head < tail)
- return 0;
-
- return ring->obj_num - head;
+ return ring->obj_num - (ring->head - ring->tail);
}
#endif /* C_CAN_H */