Skip to content

Commit 0512cc6

Browse files
Jimmy Assarssonmarckleinebudde
authored andcommitted
can: kvaser_usb: hydra: Add struct for Tx ACK commands
Add, struct kvaser_cmd_tx_ack, for standard Tx ACK commands. Expand kvaser_usb_hydra_ktime_from_cmd() to extract timestamps from both standard and extended Tx ACK commands. Unsupported commands are silently ignored, and 0 is returned. Signed-off-by: Jimmy Assarsson <[email protected]> Reviewed-by: Vincent Mailhol <[email protected]> Link: https://lore.kernel.org/all/[email protected] Signed-off-by: Marc Kleine-Budde <[email protected]>
1 parent 7cb0450 commit 0512cc6

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,15 @@ struct kvaser_cmd_tx_can {
261261
u8 reserved[11];
262262
} __packed;
263263

264+
struct kvaser_cmd_tx_ack {
265+
__le32 id;
266+
u8 data[8];
267+
u8 dlc;
268+
u8 flags;
269+
__le16 timestamp[3];
270+
u8 reserved0[8];
271+
} __packed;
272+
264273
struct kvaser_cmd_header {
265274
u8 cmd_no;
266275
/* The destination HE address is stored in 0..5 of he_addr.
@@ -297,6 +306,7 @@ struct kvaser_cmd {
297306

298307
struct kvaser_cmd_rx_can rx_can;
299308
struct kvaser_cmd_tx_can tx_can;
309+
struct kvaser_cmd_tx_ack tx_ack;
300310
} __packed;
301311
} __packed;
302312

@@ -530,9 +540,14 @@ static ktime_t kvaser_usb_hydra_ktime_from_cmd(const struct kvaser_usb_dev_cfg *
530540
if (cmd->header.cmd_no == CMD_EXTENDED) {
531541
struct kvaser_cmd_ext *cmd_ext = (struct kvaser_cmd_ext *)cmd;
532542

533-
hwtstamp = kvaser_usb_timestamp64_to_ktime(cfg, cmd_ext->rx_can.timestamp);
534-
} else {
543+
if (cmd_ext->cmd_no_ext == CMD_RX_MESSAGE_FD)
544+
hwtstamp = kvaser_usb_timestamp64_to_ktime(cfg, cmd_ext->rx_can.timestamp);
545+
else if (cmd_ext->cmd_no_ext == CMD_TX_ACKNOWLEDGE_FD)
546+
hwtstamp = kvaser_usb_timestamp64_to_ktime(cfg, cmd_ext->tx_ack.timestamp);
547+
} else if (cmd->header.cmd_no == CMD_RX_MESSAGE) {
535548
hwtstamp = kvaser_usb_timestamp48_to_ktime(cfg, cmd->rx_can.timestamp);
549+
} else if (cmd->header.cmd_no == CMD_TX_ACKNOWLEDGE) {
550+
hwtstamp = kvaser_usb_timestamp48_to_ktime(cfg, cmd->tx_ack.timestamp);
536551
}
537552

538553
return hwtstamp;

0 commit comments

Comments
 (0)