Subject: Re: [PATCH can-next 12/21] can: rockchip_canfd: add TX PATH

From: Simon Horman <[email-masked]>
Date: Tue, 30 Jul 2024 17:44:01 +0100

On Mon, Jul 29, 2024 at 03:05:43PM +0200, Marc Kleine-Budde wrote:
> The IP core has a TX event FIFO. In other IP cores, this type of FIFO
> normally contains the event that a CAN frame has been successfully
> sent. However, the IP core on the rk3568v2 the FIFO also holds events
> of unsuccessful transmission attempts.
> 
> It turned out that the best way to work around this problem is to set
> the IP core to self-receive mode (RXSTX), filter out the self-received
> frames and insert them into the complete TX path.
> 
> Signed-off-by: Marc Kleine-Budde <[email-masked]>

...

> diff --git a/drivers/net/can/rockchip/rockchip_canfd-tx.c b/drivers/net/can/rockchip/rockchip_canfd-tx.c

...

> +void rkcanfd_handle_tx_done_one(struct rkcanfd_priv *priv, const u32 ts,
> +				unsigned int *frame_len_p)
> +{
> +	struct net_device_stats *stats = &priv->ndev->stats;
> +	unsigned int tx_tail;
> +	struct sk_buff *skb;
> +
> +	tx_tail = rkcanfd_get_tx_tail(priv);
> +	skb = priv->can.echo_skb[tx_tail];

nit: skb is set but otherwise unused in this function.

> +	stats->tx_bytes +=
> +		can_rx_offload_get_echo_skb_queue_timestamp(&priv->offload,
> +							    tx_tail, ts,
> +							    frame_len_p);
> +	stats->tx_packets++;
> +}

...