On Sun. 10 Jan 2021 at 02:40, Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx> wrote: > > Hello, > > this series splits the CAN driver related infrastructure into several files > (patches 1...6), followed by some cleanup patches (7, 8), and support for > CAN frame length handling (9...13). > > I took the path and put the calculated frame length into the struct > can_skb_priv and extended the can_get_echo_skb() and > can_rx_offload_get_echo_skb() to optionally return the CAN frame length. > > This patch illustrated how the new code can be used. I'll send mcp251xfd BQL > support in a separate series, once details about this code have settled. > > @@ -1352,7 +1357,9 @@ static int mcp251xfd_handle_tefif(struct mcp251xfd_priv *priv) > } > > for (i = 0; i < len; i++) { > - err = mcp251xfd_handle_tefif_one(priv, &hw_tef_obj[i]); > + unsigned int frame_len; > + > + err = mcp251xfd_handle_tefif_one(priv, &hw_tef_obj[i], &frame_len); > /* -EAGAIN means the Sequence Number in the TEF > * doesn't match our tef_tail. This can happen if we > * read the TEF objects too early. Leave loop let the > @@ -1362,6 +1369,8 @@ static int mcp251xfd_handle_tefif(struct mcp251xfd_priv *priv) > goto out_netif_wake_queue; > if (err) > return err; > + > + total_frame_len += frame_len; > } > > out_netif_wake_queue: > @@ -1393,6 +1402,7 @@ static int mcp251xfd_handle_tefif(struct mcp251xfd_priv *priv) > return err; > > tx_ring->tail += len; > + netdev_completed_queue(priv->ndev, len, total_frame_len); > > err = mcp251xfd_check_tef_tail(priv); > if (err) > @@ -2433,6 +2443,7 @@ static bool mcp251xfd_tx_busy(const struct mcp251xfd_priv *priv, > static netdev_tx_t mcp251xfd_start_xmit(struct sk_buff *skb, > struct net_device *ndev) > { > + struct can_skb_priv *can_skb_priv = can_skb_prv(skb); > struct mcp251xfd_priv *priv = netdev_priv(ndev); > struct mcp251xfd_tx_ring *tx_ring = priv->tx; > struct mcp251xfd_tx_obj *tx_obj; > @@ -2455,6 +2466,8 @@ static netdev_tx_t mcp251xfd_start_xmit(struct sk_buff *skb, > netif_stop_queue(ndev); > > can_put_echo_skb(skb, ndev, tx_head); > + can_skb_priv->frame_len = can_skb_get_frame_len(skb); > + netdev_sent_queue(priv->ndev, can_skb_priv->frame_len); > > err = mcp251xfd_tx_obj_write(priv, tx_obj); > if (err) > > regards, > Marc > Did you test it after the occurence of a can_bus_off() event? When the device restarts, you normally have to call netdev_reset_queue(netdev) in order to reset all the BQL statistics.