[PATCH can-next 09/13] can: gs_usb: gs_usb_state_get_by_hf(): optionally print recived CAN error frames
Marc Kleine-Budde <[email protected]> Mon, 20 Jul 2026 15:48:10 +0200
| Newsgroups | org.kernel.vger.linux-can,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
The previous commit introduced gs_usb_state_get_by_hf() to parse the current CAN error state from the received CAN error frame. As there are several gs_usb compatible implementations which slightly differ in their CAN state and CAN error frame handling add a netdev_dbg() that prints the received CAN error frame for easier future debugging. Signed-off-by: Marc Kleine-Budde <[email protected]> --- drivers/net/can/usb/gs_usb.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/net/can/usb/gs_usb.c b/drivers/net/can/usb/gs_usb.c index e41f91b56ab8..2848cb1a75f0 100644 --- a/drivers/net/can/usb/gs_usb.c +++ b/drivers/net/can/usb/gs_usb.c @@ -670,6 +670,21 @@ gs_usb_state_get_by_hf(const struct gs_can *dev, const struct gs_host_frame *hf, else tx_state = CAN_STATE_ERROR_ACTIVE; } + + const u8 tx_err = hf->classic_can->data[6]; + const u8 rx_err = hf->classic_can->data[7]; + + netdev_dbg(dev->netdev, "host_frame: TX-state='%s/%u' RX-state='%s/%u' %s%s%s%s%s%s%s", + can_get_state_str(tx_state), tx_err, + can_get_state_str(rx_state), rx_err, + hf->can_id & cpu_to_le32(CAN_ERR_BUSOFF) ? "bus-off " : "", + hf->can_id & cpu_to_le32(CAN_ERR_RESTARTED) ? + "restarted-after-bus-off " : "", + err_crtl & CAN_ERR_CRTL_RX_PASSIVE ? "rx-error-passive " : "", + err_crtl & CAN_ERR_CRTL_RX_WARNING ? "rx-error-warning " : "", + err_crtl & CAN_ERR_CRTL_TX_PASSIVE ? "tx-error-passive " : "", + err_crtl & CAN_ERR_CRTL_TX_WARNING ? "tx-error-warning " : "", + err_crtl & CAN_ERR_CRTL_ACTIVE ? "back-to-error-active " : ""); } else { tx_state = dev->can.state; rx_state = dev->can.state; -- 2.53.0