* [PATCH can-next v2 01/15] can: kvaser_usb: Add helper functions to convert device timestamp into ktime
2024-07-01 15:49 [PATCH can-next v2 00/15] can: kvaser_usb: Add hardware timestamp support to all devices Jimmy Assarsson
@ 2024-07-01 15:49 ` Jimmy Assarsson
2024-07-02 4:47 ` Vincent MAILHOL
2024-07-01 15:49 ` [PATCH can-next v2 02/15] can: kvaser_usb: hydra: kvaser_usb_hydra_ktime_from_rx_cmd: Drop {rx_} in function name Jimmy Assarsson
` (14 subsequent siblings)
15 siblings, 1 reply; 20+ messages in thread
From: Jimmy Assarsson @ 2024-07-01 15:49 UTC (permalink / raw)
To: linux-can
Cc: Jimmy Assarsson, Marc Kleine-Budde, Vincent Mailhol,
Jimmy Assarsson
Add helper function kvaser_usb_ticks_to_ktime() that converts from
device ticks to ktime.
And kvaser_usb_timestamp{48,64}_to_ktime() that converts from device
48-bit or 64-bit timestamp, to ktime.
Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
---
Changes in v2:
- New in v2. Replaces
can: kvaser_usb: Add function kvaser_usb_ticks_to_ktime()
- Add two more helper functions, kvaser_usb_timestamp{48,64}_to_ktime()
for converting timestamps, suggested by Vincent MAILHOL [2][3]
[2] https://lore.kernel.org/linux-can/CAMZ6RqKSa-6KjvgfmN9eL7A=A65gMkYsRrnaF41Azhsc45FA2Q@mail.gmail.com/
[3] https://lore.kernel.org/linux-can/CAMZ6Rq+Xd7+th=dKV+vrqzRtS+GY-xq2UziH1CURcQ3HxEXMqQ@mail.gmail.com/
drivers/net/can/usb/kvaser_usb/kvaser_usb.h | 24 +++++++++++++++++++
.../net/can/usb/kvaser_usb/kvaser_usb_hydra.c | 10 ++++----
2 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb.h b/drivers/net/can/usb/kvaser_usb/kvaser_usb.h
index ff10b3790d84..4256a0caae20 100644
--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb.h
+++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb.h
@@ -22,6 +22,8 @@
*/
#include <linux/completion.h>
+#include <linux/ktime.h>
+#include <linux/math64.h>
#include <linux/spinlock.h>
#include <linux/types.h>
#include <linux/usb.h>
@@ -216,4 +218,26 @@ int kvaser_usb_can_rx_over_error(struct net_device *netdev);
extern const struct can_bittiming_const kvaser_usb_flexc_bittiming_const;
+static inline ktime_t kvaser_usb_ticks_to_ktime(const struct kvaser_usb_dev_cfg *cfg,
+ u64 ticks)
+{
+ return ns_to_ktime(div_u64(ticks * 1000, cfg->timestamp_freq));
+}
+
+static inline ktime_t kvaser_usb_timestamp48_to_ktime(const struct kvaser_usb_dev_cfg *cfg,
+ const __le16 *timestamp)
+{
+ u64 ticks = le16_to_cpu(timestamp[0]) |
+ (u64)(le16_to_cpu(timestamp[1])) << 16 |
+ (u64)(le16_to_cpu(timestamp[2])) << 32;
+
+ return kvaser_usb_ticks_to_ktime(cfg, ticks);
+}
+
+static inline ktime_t kvaser_usb_timestamp64_to_ktime(const struct kvaser_usb_dev_cfg *cfg,
+ __le64 timestamp)
+{
+ return kvaser_usb_ticks_to_ktime(cfg, le64_to_cpu(timestamp));
+}
+
#endif /* KVASER_USB_H */
diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
index c7ba768dfe17..ad1c6101a0cd 100644
--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
+++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
@@ -526,19 +526,17 @@ static ktime_t
kvaser_usb_hydra_ktime_from_rx_cmd(const struct kvaser_usb_dev_cfg *cfg,
const struct kvaser_cmd *cmd)
{
- u64 ticks;
+ ktime_t hwtstamp = 0;
if (cmd->header.cmd_no == CMD_EXTENDED) {
struct kvaser_cmd_ext *cmd_ext = (struct kvaser_cmd_ext *)cmd;
- ticks = le64_to_cpu(cmd_ext->rx_can.timestamp);
+ hwtstamp = kvaser_usb_timestamp64_to_ktime(cfg, cmd_ext->rx_can.timestamp);
} else {
- ticks = le16_to_cpu(cmd->rx_can.timestamp[0]);
- ticks += (u64)(le16_to_cpu(cmd->rx_can.timestamp[1])) << 16;
- ticks += (u64)(le16_to_cpu(cmd->rx_can.timestamp[2])) << 32;
+ hwtstamp = kvaser_usb_timestamp48_to_ktime(cfg, cmd->rx_can.timestamp);
}
- return ns_to_ktime(div_u64(ticks * 1000, cfg->timestamp_freq));
+ return hwtstamp;
}
static int kvaser_usb_hydra_send_simple_cmd(struct kvaser_usb *dev,
--
2.45.2
^ permalink raw reply related [flat|nested] 20+ messages in thread* Re: [PATCH can-next v2 01/15] can: kvaser_usb: Add helper functions to convert device timestamp into ktime
2024-07-01 15:49 ` [PATCH can-next v2 01/15] can: kvaser_usb: Add helper functions to convert device timestamp into ktime Jimmy Assarsson
@ 2024-07-02 4:47 ` Vincent MAILHOL
2024-07-02 19:37 ` Jimmy Assarsson
0 siblings, 1 reply; 20+ messages in thread
From: Vincent MAILHOL @ 2024-07-02 4:47 UTC (permalink / raw)
To: Jimmy Assarsson; +Cc: linux-can, Jimmy Assarsson, Marc Kleine-Budde
On Tue. 2 juil. 2024 at 00:50, Jimmy Assarsson <extja@kvaser.com> wrote:
> Add helper function kvaser_usb_ticks_to_ktime() that converts from
> device ticks to ktime.
> And kvaser_usb_timestamp{48,64}_to_ktime() that converts from device
> 48-bit or 64-bit timestamp, to ktime.
>
> Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
> ---
> Changes in v2:
> - New in v2. Replaces
> can: kvaser_usb: Add function kvaser_usb_ticks_to_ktime()
> - Add two more helper functions, kvaser_usb_timestamp{48,64}_to_ktime()
> for converting timestamps, suggested by Vincent MAILHOL [2][3]
> [2] https://lore.kernel.org/linux-can/CAMZ6RqKSa-6KjvgfmN9eL7A=A65gMkYsRrnaF41Azhsc45FA2Q@mail.gmail.com/
> [3] https://lore.kernel.org/linux-can/CAMZ6Rq+Xd7+th=dKV+vrqzRtS+GY-xq2UziH1CURcQ3HxEXMqQ@mail.gmail.com/
>
> drivers/net/can/usb/kvaser_usb/kvaser_usb.h | 24 +++++++++++++++++++
> .../net/can/usb/kvaser_usb/kvaser_usb_hydra.c | 10 ++++----
> 2 files changed, 28 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb.h b/drivers/net/can/usb/kvaser_usb/kvaser_usb.h
> index ff10b3790d84..4256a0caae20 100644
> --- a/drivers/net/can/usb/kvaser_usb/kvaser_usb.h
> +++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb.h
> @@ -22,6 +22,8 @@
> */
>
> #include <linux/completion.h>
> +#include <linux/ktime.h>
> +#include <linux/math64.h>
> #include <linux/spinlock.h>
> #include <linux/types.h>
> #include <linux/usb.h>
> @@ -216,4 +218,26 @@ int kvaser_usb_can_rx_over_error(struct net_device *netdev);
>
> extern const struct can_bittiming_const kvaser_usb_flexc_bittiming_const;
>
> +static inline ktime_t kvaser_usb_ticks_to_ktime(const struct kvaser_usb_dev_cfg *cfg,
> + u64 ticks)
> +{
> + return ns_to_ktime(div_u64(ticks * 1000, cfg->timestamp_freq));
> +}
> +
> +static inline ktime_t kvaser_usb_timestamp48_to_ktime(const struct kvaser_usb_dev_cfg *cfg,
> + const __le16 *timestamp)
> +{
> + u64 ticks = le16_to_cpu(timestamp[0]) |
> + (u64)(le16_to_cpu(timestamp[1])) << 16 |
> + (u64)(le16_to_cpu(timestamp[2])) << 32;
> +
> + return kvaser_usb_ticks_to_ktime(cfg, ticks);
> +}
> +
> +static inline ktime_t kvaser_usb_timestamp64_to_ktime(const struct kvaser_usb_dev_cfg *cfg,
> + __le64 timestamp)
> +{
> + return kvaser_usb_ticks_to_ktime(cfg, le64_to_cpu(timestamp));
> +}
> +
> #endif /* KVASER_USB_H */
> diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
> index c7ba768dfe17..ad1c6101a0cd 100644
> --- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
> +++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
> @@ -526,19 +526,17 @@ static ktime_t
> kvaser_usb_hydra_ktime_from_rx_cmd(const struct kvaser_usb_dev_cfg *cfg,
> const struct kvaser_cmd *cmd)
> {
> - u64 ticks;
> + ktime_t hwtstamp = 0;
>
> if (cmd->header.cmd_no == CMD_EXTENDED) {
> struct kvaser_cmd_ext *cmd_ext = (struct kvaser_cmd_ext *)cmd;
>
> - ticks = le64_to_cpu(cmd_ext->rx_can.timestamp);
> + hwtstamp = kvaser_usb_timestamp64_to_ktime(cfg, cmd_ext->rx_can.timestamp);
> } else {
> - ticks = le16_to_cpu(cmd->rx_can.timestamp[0]);
> - ticks += (u64)(le16_to_cpu(cmd->rx_can.timestamp[1])) << 16;
> - ticks += (u64)(le16_to_cpu(cmd->rx_can.timestamp[2])) << 32;
> + hwtstamp = kvaser_usb_timestamp48_to_ktime(cfg, cmd->rx_can.timestamp);
> }
>
> - return ns_to_ktime(div_u64(ticks * 1000, cfg->timestamp_freq));
> + return hwtstamp;
> }
Nitpick: this can slightly be simplified by dropping the hwtstamp
local variable:
kvaser_usb_hydra_ktime_from_rx_cmd(const struct kvaser_usb_dev_cfg *cfg,
const struct kvaser_cmd *cmd)
{
if (cmd->header.cmd_no == CMD_EXTENDED) {
struct kvaser_cmd_ext *cmd_ext = (struct kvaser_cmd_ext *)cmd;
return kvaser_usb_timestamp64_to_ktime(cfg,
cmd_ext->rx_can.timestamp);
} else {
return kvaser_usb_timestamp48_to_ktime(cfg,
cmd->rx_can.timestamp);
}
}
> static int kvaser_usb_hydra_send_simple_cmd(struct kvaser_usb *dev,
> --
> 2.45.2
>
>
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [PATCH can-next v2 01/15] can: kvaser_usb: Add helper functions to convert device timestamp into ktime
2024-07-02 4:47 ` Vincent MAILHOL
@ 2024-07-02 19:37 ` Jimmy Assarsson
0 siblings, 0 replies; 20+ messages in thread
From: Jimmy Assarsson @ 2024-07-02 19:37 UTC (permalink / raw)
To: Vincent MAILHOL, Jimmy Assarsson; +Cc: linux-can, Marc Kleine-Budde
On 7/2/24 06:47, Vincent MAILHOL wrote:
> On Tue. 2 juil. 2024 at 00:50, Jimmy Assarsson <extja@kvaser.com> wrote:
>> Add helper function kvaser_usb_ticks_to_ktime() that converts from
>> device ticks to ktime.
>> And kvaser_usb_timestamp{48,64}_to_ktime() that converts from device
>> 48-bit or 64-bit timestamp, to ktime.
>>
>> Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
>> ---
>> Changes in v2:
>> - New in v2. Replaces
>> can: kvaser_usb: Add function kvaser_usb_ticks_to_ktime()
>> - Add two more helper functions, kvaser_usb_timestamp{48,64}_to_ktime()
>> for converting timestamps, suggested by Vincent MAILHOL [2][3]
>> [2] https://lore.kernel.org/linux-can/CAMZ6RqKSa-6KjvgfmN9eL7A=A65gMkYsRrnaF41Azhsc45FA2Q@mail.gmail.com/
>> [3] https://lore.kernel.org/linux-can/CAMZ6Rq+Xd7+th=dKV+vrqzRtS+GY-xq2UziH1CURcQ3HxEXMqQ@mail.gmail.com/
>>
>> drivers/net/can/usb/kvaser_usb/kvaser_usb.h | 24 +++++++++++++++++++
>> .../net/can/usb/kvaser_usb/kvaser_usb_hydra.c | 10 ++++----
>> 2 files changed, 28 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb.h b/drivers/net/can/usb/kvaser_usb/kvaser_usb.h
>> index ff10b3790d84..4256a0caae20 100644
>> --- a/drivers/net/can/usb/kvaser_usb/kvaser_usb.h
>> +++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb.h
>> @@ -22,6 +22,8 @@
>> */
>>
>> #include <linux/completion.h>
>> +#include <linux/ktime.h>
>> +#include <linux/math64.h>
>> #include <linux/spinlock.h>
>> #include <linux/types.h>
>> #include <linux/usb.h>
>> @@ -216,4 +218,26 @@ int kvaser_usb_can_rx_over_error(struct net_device *netdev);
>>
>> extern const struct can_bittiming_const kvaser_usb_flexc_bittiming_const;
>>
>> +static inline ktime_t kvaser_usb_ticks_to_ktime(const struct kvaser_usb_dev_cfg *cfg,
>> + u64 ticks)
>> +{
>> + return ns_to_ktime(div_u64(ticks * 1000, cfg->timestamp_freq));
>> +}
>> +
>> +static inline ktime_t kvaser_usb_timestamp48_to_ktime(const struct kvaser_usb_dev_cfg *cfg,
>> + const __le16 *timestamp)
>> +{
>> + u64 ticks = le16_to_cpu(timestamp[0]) |
>> + (u64)(le16_to_cpu(timestamp[1])) << 16 |
>> + (u64)(le16_to_cpu(timestamp[2])) << 32;
>> +
>> + return kvaser_usb_ticks_to_ktime(cfg, ticks);
>> +}
>> +
>> +static inline ktime_t kvaser_usb_timestamp64_to_ktime(const struct kvaser_usb_dev_cfg *cfg,
>> + __le64 timestamp)
>> +{
>> + return kvaser_usb_ticks_to_ktime(cfg, le64_to_cpu(timestamp));
>> +}
>> +
>> #endif /* KVASER_USB_H */
>> diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
>> index c7ba768dfe17..ad1c6101a0cd 100644
>> --- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
>> +++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
>> @@ -526,19 +526,17 @@ static ktime_t
>> kvaser_usb_hydra_ktime_from_rx_cmd(const struct kvaser_usb_dev_cfg *cfg,
>> const struct kvaser_cmd *cmd)
>> {
>> - u64 ticks;
>> + ktime_t hwtstamp = 0;
>>
>> if (cmd->header.cmd_no == CMD_EXTENDED) {
>> struct kvaser_cmd_ext *cmd_ext = (struct kvaser_cmd_ext *)cmd;
>>
>> - ticks = le64_to_cpu(cmd_ext->rx_can.timestamp);
>> + hwtstamp = kvaser_usb_timestamp64_to_ktime(cfg, cmd_ext->rx_can.timestamp);
>> } else {
>> - ticks = le16_to_cpu(cmd->rx_can.timestamp[0]);
>> - ticks += (u64)(le16_to_cpu(cmd->rx_can.timestamp[1])) << 16;
>> - ticks += (u64)(le16_to_cpu(cmd->rx_can.timestamp[2])) << 32;
>> + hwtstamp = kvaser_usb_timestamp48_to_ktime(cfg, cmd->rx_can.timestamp);
>> }
>>
>> - return ns_to_ktime(div_u64(ticks * 1000, cfg->timestamp_freq));
>> + return hwtstamp;
>> }
>
> Nitpick: this can slightly be simplified by dropping the hwtstamp
> local variable:
>
> kvaser_usb_hydra_ktime_from_rx_cmd(const struct kvaser_usb_dev_cfg *cfg,
> const struct kvaser_cmd *cmd)
> {
> if (cmd->header.cmd_no == CMD_EXTENDED) {
> struct kvaser_cmd_ext *cmd_ext = (struct kvaser_cmd_ext *)cmd;
>
> return kvaser_usb_timestamp64_to_ktime(cfg,
> cmd_ext->rx_can.timestamp);
> } else {
> return kvaser_usb_timestamp48_to_ktime(cfg,
> cmd->rx_can.timestamp);
> }
> }
I'll keep it as is. I prefer to have a single return at the end of the function.
Regards,
/jimmy
^ permalink raw reply [flat|nested] 20+ messages in thread
* [PATCH can-next v2 02/15] can: kvaser_usb: hydra: kvaser_usb_hydra_ktime_from_rx_cmd: Drop {rx_} in function name
2024-07-01 15:49 [PATCH can-next v2 00/15] can: kvaser_usb: Add hardware timestamp support to all devices Jimmy Assarsson
2024-07-01 15:49 ` [PATCH can-next v2 01/15] can: kvaser_usb: Add helper functions to convert device timestamp into ktime Jimmy Assarsson
@ 2024-07-01 15:49 ` Jimmy Assarsson
2024-07-01 15:49 ` [PATCH can-next v2 03/15] can: kvaser_usb: hydra: Add struct for Tx ACK commands Jimmy Assarsson
` (13 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Jimmy Assarsson @ 2024-07-01 15:49 UTC (permalink / raw)
To: linux-can
Cc: Jimmy Assarsson, Marc Kleine-Budde, Vincent Mailhol,
Jimmy Assarsson
Rename function, since this function will be used for more than just the
rx commands.
Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
---
Changes in v2:
- No changes
drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
index ad1c6101a0cd..84f1f1f9c107 100644
--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
+++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
@@ -522,9 +522,8 @@ kvaser_usb_hydra_net_priv_from_cmd(const struct kvaser_usb *dev,
return priv;
}
-static ktime_t
-kvaser_usb_hydra_ktime_from_rx_cmd(const struct kvaser_usb_dev_cfg *cfg,
- const struct kvaser_cmd *cmd)
+static ktime_t kvaser_usb_hydra_ktime_from_cmd(const struct kvaser_usb_dev_cfg *cfg,
+ const struct kvaser_cmd *cmd)
{
ktime_t hwtstamp = 0;
@@ -1232,7 +1231,7 @@ static void kvaser_usb_hydra_rx_msg_std(const struct kvaser_usb *dev,
stats = &priv->netdev->stats;
flags = cmd->rx_can.flags;
- hwtstamp = kvaser_usb_hydra_ktime_from_rx_cmd(dev->cfg, cmd);
+ hwtstamp = kvaser_usb_hydra_ktime_from_cmd(dev->cfg, cmd);
if (flags & KVASER_USB_HYDRA_CF_FLAG_ERROR_FRAME) {
kvaser_usb_hydra_error_frame(priv, &cmd->rx_can.err_frame_data,
@@ -1300,7 +1299,7 @@ static void kvaser_usb_hydra_rx_msg_ext(const struct kvaser_usb *dev,
KVASER_USB_KCAN_DATA_DLC_SHIFT;
flags = le32_to_cpu(cmd->rx_can.flags);
- hwtstamp = kvaser_usb_hydra_ktime_from_rx_cmd(dev->cfg, std_cmd);
+ hwtstamp = kvaser_usb_hydra_ktime_from_cmd(dev->cfg, std_cmd);
if (flags & KVASER_USB_HYDRA_CF_FLAG_ERROR_FRAME) {
kvaser_usb_hydra_error_frame(priv, &cmd->rx_can.err_frame_data,
--
2.45.2
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH can-next v2 03/15] can: kvaser_usb: hydra: Add struct for Tx ACK commands
2024-07-01 15:49 [PATCH can-next v2 00/15] can: kvaser_usb: Add hardware timestamp support to all devices Jimmy Assarsson
2024-07-01 15:49 ` [PATCH can-next v2 01/15] can: kvaser_usb: Add helper functions to convert device timestamp into ktime Jimmy Assarsson
2024-07-01 15:49 ` [PATCH can-next v2 02/15] can: kvaser_usb: hydra: kvaser_usb_hydra_ktime_from_rx_cmd: Drop {rx_} in function name Jimmy Assarsson
@ 2024-07-01 15:49 ` Jimmy Assarsson
2024-07-01 15:49 ` [PATCH can-next v2 04/15] can: kvaser_usb: hydra: Set hardware timestamp on transmitted packets Jimmy Assarsson
` (12 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Jimmy Assarsson @ 2024-07-01 15:49 UTC (permalink / raw)
To: linux-can
Cc: Jimmy Assarsson, Marc Kleine-Budde, Vincent Mailhol,
Jimmy Assarsson
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 <extja@kvaser.com>
---
Changes in v2:
- Utilize new helper functions, from
can: kvaser_usb: Add helper functions to convert device timestamp into ktime
.../net/can/usb/kvaser_usb/kvaser_usb_hydra.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
index 84f1f1f9c107..f102f9de7d16 100644
--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
+++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
@@ -261,6 +261,15 @@ struct kvaser_cmd_tx_can {
u8 reserved[11];
} __packed;
+struct kvaser_cmd_tx_ack {
+ __le32 id;
+ u8 data[8];
+ u8 dlc;
+ u8 flags;
+ __le16 timestamp[3];
+ u8 reserved0[8];
+} __packed;
+
struct kvaser_cmd_header {
u8 cmd_no;
/* The destination HE address is stored in 0..5 of he_addr.
@@ -297,6 +306,7 @@ struct kvaser_cmd {
struct kvaser_cmd_rx_can rx_can;
struct kvaser_cmd_tx_can tx_can;
+ struct kvaser_cmd_tx_ack tx_ack;
} __packed;
} __packed;
@@ -530,9 +540,14 @@ static ktime_t kvaser_usb_hydra_ktime_from_cmd(const struct kvaser_usb_dev_cfg *
if (cmd->header.cmd_no == CMD_EXTENDED) {
struct kvaser_cmd_ext *cmd_ext = (struct kvaser_cmd_ext *)cmd;
- hwtstamp = kvaser_usb_timestamp64_to_ktime(cfg, cmd_ext->rx_can.timestamp);
- } else {
+ if (cmd_ext->cmd_no_ext == CMD_RX_MESSAGE_FD)
+ hwtstamp = kvaser_usb_timestamp64_to_ktime(cfg, cmd_ext->rx_can.timestamp);
+ else if (cmd_ext->cmd_no_ext == CMD_TX_ACKNOWLEDGE_FD)
+ hwtstamp = kvaser_usb_timestamp64_to_ktime(cfg, cmd_ext->tx_ack.timestamp);
+ } else if (cmd->header.cmd_no == CMD_RX_MESSAGE) {
hwtstamp = kvaser_usb_timestamp48_to_ktime(cfg, cmd->rx_can.timestamp);
+ } else if (cmd->header.cmd_no == CMD_TX_ACKNOWLEDGE) {
+ hwtstamp = kvaser_usb_timestamp48_to_ktime(cfg, cmd->tx_ack.timestamp);
}
return hwtstamp;
--
2.45.2
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH can-next v2 04/15] can: kvaser_usb: hydra: Set hardware timestamp on transmitted packets
2024-07-01 15:49 [PATCH can-next v2 00/15] can: kvaser_usb: Add hardware timestamp support to all devices Jimmy Assarsson
` (2 preceding siblings ...)
2024-07-01 15:49 ` [PATCH can-next v2 03/15] can: kvaser_usb: hydra: Add struct for Tx ACK commands Jimmy Assarsson
@ 2024-07-01 15:49 ` Jimmy Assarsson
2024-07-01 15:49 ` [PATCH can-next v2 05/15] can: kvaser_usb: leaf: Add struct for Tx ACK commands Jimmy Assarsson
` (11 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Jimmy Assarsson @ 2024-07-01 15:49 UTC (permalink / raw)
To: linux-can
Cc: Jimmy Assarsson, Marc Kleine-Budde, Vincent Mailhol,
Jimmy Assarsson
Set hardware timestamp on transmitted packets.
Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
---
Changes in v2:
- No changes
drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
index f102f9de7d16..3764b263add3 100644
--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
+++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_hydra.c
@@ -10,7 +10,6 @@
* - Transition from CAN_STATE_ERROR_WARNING to CAN_STATE_ERROR_ACTIVE is only
* reported after a call to do_get_berr_counter(), since firmware does not
* distinguish between ERROR_WARNING and ERROR_ACTIVE.
- * - Hardware timestamps are not set for CAN Tx frames.
*/
#include <linux/completion.h>
@@ -1187,6 +1186,7 @@ static void kvaser_usb_hydra_tx_acknowledge(const struct kvaser_usb *dev,
bool one_shot_fail = false;
bool is_err_frame = false;
u16 transid = kvaser_usb_hydra_get_cmd_transid(cmd);
+ struct sk_buff *skb;
priv = kvaser_usb_hydra_net_priv_from_cmd(dev, cmd);
if (!priv)
@@ -1213,6 +1213,9 @@ static void kvaser_usb_hydra_tx_acknowledge(const struct kvaser_usb *dev,
spin_lock_irqsave(&priv->tx_contexts_lock, irq_flags);
+ skb = priv->can.echo_skb[context->echo_index];
+ if (skb)
+ skb_hwtstamps(skb)->hwtstamp = kvaser_usb_hydra_ktime_from_cmd(dev->cfg, cmd);
len = can_get_echo_skb(priv->netdev, context->echo_index, NULL);
context->echo_index = dev->max_tx_urbs;
--priv->active_tx_contexts;
--
2.45.2
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH can-next v2 05/15] can: kvaser_usb: leaf: Add struct for Tx ACK commands
2024-07-01 15:49 [PATCH can-next v2 00/15] can: kvaser_usb: Add hardware timestamp support to all devices Jimmy Assarsson
` (3 preceding siblings ...)
2024-07-01 15:49 ` [PATCH can-next v2 04/15] can: kvaser_usb: hydra: Set hardware timestamp on transmitted packets Jimmy Assarsson
@ 2024-07-01 15:49 ` Jimmy Assarsson
2024-07-01 15:49 ` [PATCH can-next v2 06/15] can: kvaser_usb: leaf: Assign correct timestamp_freq for kvaser_usb_leaf_imx_dev_cfg_{16,24,32}mhz Jimmy Assarsson
` (10 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Jimmy Assarsson @ 2024-07-01 15:49 UTC (permalink / raw)
To: linux-can
Cc: Jimmy Assarsson, Marc Kleine-Budde, Vincent Mailhol,
Jimmy Assarsson
Add, struct leaf_cmd_tx_acknowledge, for Tx ACK commands received from leaf
devices (M32C and leafimx28).
Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
---
Changes in v2:
- No changes
drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
index 23bd7574b1c7..70511e151a3b 100644
--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
+++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
@@ -235,6 +235,13 @@ struct kvaser_cmd_tx_acknowledge_header {
u8 tid;
} __packed;
+struct leaf_cmd_tx_acknowledge {
+ u8 channel;
+ u8 tid;
+ __le16 time[3];
+ u8 padding[2];
+} __packed;
+
struct leaf_cmd_can_error_event {
u8 tid;
u8 flags;
@@ -347,6 +354,7 @@ struct kvaser_cmd {
struct leaf_cmd_error_event error_event;
struct kvaser_cmd_cap_req cap_req;
struct kvaser_cmd_cap_res cap_res;
+ struct leaf_cmd_tx_acknowledge tx_ack;
} __packed leaf;
union {
@@ -370,7 +378,7 @@ static const u8 kvaser_usb_leaf_cmd_sizes_leaf[] = {
[CMD_START_CHIP_REPLY] = kvaser_fsize(u.simple),
[CMD_STOP_CHIP_REPLY] = kvaser_fsize(u.simple),
[CMD_GET_CARD_INFO_REPLY] = kvaser_fsize(u.cardinfo),
- [CMD_TX_ACKNOWLEDGE] = kvaser_fsize(u.tx_acknowledge_header),
+ [CMD_TX_ACKNOWLEDGE] = kvaser_fsize(u.leaf.tx_ack),
[CMD_GET_SOFTWARE_INFO_REPLY] = kvaser_fsize(u.leaf.softinfo),
[CMD_RX_STD_MESSAGE] = kvaser_fsize(u.leaf.rx_can),
[CMD_RX_EXT_MESSAGE] = kvaser_fsize(u.leaf.rx_can),
--
2.45.2
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH can-next v2 06/15] can: kvaser_usb: leaf: Assign correct timestamp_freq for kvaser_usb_leaf_imx_dev_cfg_{16,24,32}mhz
2024-07-01 15:49 [PATCH can-next v2 00/15] can: kvaser_usb: Add hardware timestamp support to all devices Jimmy Assarsson
` (4 preceding siblings ...)
2024-07-01 15:49 ` [PATCH can-next v2 05/15] can: kvaser_usb: leaf: Add struct for Tx ACK commands Jimmy Assarsson
@ 2024-07-01 15:49 ` Jimmy Assarsson
2024-07-01 15:49 ` [PATCH can-next v2 07/15] can: kvaser_usb: leaf: Replace kvaser_usb_leaf_m32c_dev_cfg with kvaser_usb_leaf_m32c_dev_cfg_{16,24,32}mhz Jimmy Assarsson
` (9 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Jimmy Assarsson @ 2024-07-01 15:49 UTC (permalink / raw)
To: linux-can
Cc: Jimmy Assarsson, Marc Kleine-Budde, Vincent Mailhol,
Jimmy Assarsson
Assign correct timestamp_freq to kvaser_usb_leaf_imx_dev_cfg_{16,24,32}mhz.
Since the driver didn't utilize the value, this didn't cause any problems.
Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
---
Changes in v2:
- No changes
drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
index 70511e151a3b..00fe7410e36d 100644
--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
+++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
@@ -483,7 +483,7 @@ static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_imx_dev_cfg_16mhz = {
.clock = {
.freq = 16 * MEGA /* Hz */,
},
- .timestamp_freq = 1,
+ .timestamp_freq = 16,
.bittiming_const = &kvaser_usb_flexc_bittiming_const,
};
@@ -491,7 +491,7 @@ static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_imx_dev_cfg_24mhz = {
.clock = {
.freq = 24 * MEGA /* Hz */,
},
- .timestamp_freq = 1,
+ .timestamp_freq = 24,
.bittiming_const = &kvaser_usb_flexc_bittiming_const,
};
@@ -499,7 +499,7 @@ static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_imx_dev_cfg_32mhz = {
.clock = {
.freq = 32 * MEGA /* Hz */,
},
- .timestamp_freq = 1,
+ .timestamp_freq = 32,
.bittiming_const = &kvaser_usb_flexc_bittiming_const,
};
--
2.45.2
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH can-next v2 07/15] can: kvaser_usb: leaf: Replace kvaser_usb_leaf_m32c_dev_cfg with kvaser_usb_leaf_m32c_dev_cfg_{16,24,32}mhz
2024-07-01 15:49 [PATCH can-next v2 00/15] can: kvaser_usb: Add hardware timestamp support to all devices Jimmy Assarsson
` (5 preceding siblings ...)
2024-07-01 15:49 ` [PATCH can-next v2 06/15] can: kvaser_usb: leaf: Assign correct timestamp_freq for kvaser_usb_leaf_imx_dev_cfg_{16,24,32}mhz Jimmy Assarsson
@ 2024-07-01 15:49 ` Jimmy Assarsson
2024-07-01 15:49 ` [PATCH can-next v2 08/15] can: kvaser_usb: leaf: kvaser_usb_leaf_tx_acknowledge: Rename local variable Jimmy Assarsson
` (8 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Jimmy Assarsson @ 2024-07-01 15:49 UTC (permalink / raw)
To: linux-can
Cc: Jimmy Assarsson, Marc Kleine-Budde, Vincent Mailhol,
Jimmy Assarsson
Add new struct kvaser_usb_dev_cfg constants,
kvaser_usb_leaf_m32c_dev_cfg_{16,24,32}mhz,
for M32C based leaf devices.
Note that the bittiming parameters are always calculated for 16MHz clock,
while the timestamps are in the actual clock frequency of the device.
Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
---
Changes in v2:
- No changes
.../net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 33 +++++++++++++++++--
1 file changed, 30 insertions(+), 3 deletions(-)
diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
index 00fe7410e36d..3245471e906b 100644
--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
+++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
@@ -471,11 +471,27 @@ static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_usbcan_dev_cfg = {
.bittiming_const = &kvaser_usb_leaf_m16c_bittiming_const,
};
-static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_m32c_dev_cfg = {
+static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_m32c_dev_cfg_16mhz = {
.clock = {
.freq = 16 * MEGA /* Hz */,
},
- .timestamp_freq = 1,
+ .timestamp_freq = 16,
+ .bittiming_const = &kvaser_usb_leaf_m32c_bittiming_const,
+};
+
+static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_m32c_dev_cfg_24mhz = {
+ .clock = {
+ .freq = 16 * MEGA /* Hz */,
+ },
+ .timestamp_freq = 24,
+ .bittiming_const = &kvaser_usb_leaf_m32c_bittiming_const,
+};
+
+static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_m32c_dev_cfg_32mhz = {
+ .clock = {
+ .freq = 16 * MEGA /* Hz */,
+ },
+ .timestamp_freq = 32,
.bittiming_const = &kvaser_usb_leaf_m32c_bittiming_const,
};
@@ -686,8 +702,19 @@ static void kvaser_usb_leaf_get_software_info_leaf(struct kvaser_usb *dev,
if (dev->driver_info->quirks & KVASER_USB_QUIRK_IGNORE_CLK_FREQ) {
/* Firmware expects bittiming parameters calculated for 16MHz
* clock, regardless of the actual clock
+ * Though, the reported freq is used for timestamps
*/
- dev->cfg = &kvaser_usb_leaf_m32c_dev_cfg;
+ switch (sw_options & KVASER_USB_LEAF_SWOPTION_FREQ_MASK) {
+ case KVASER_USB_LEAF_SWOPTION_FREQ_16_MHZ_CLK:
+ dev->cfg = &kvaser_usb_leaf_m32c_dev_cfg_16mhz;
+ break;
+ case KVASER_USB_LEAF_SWOPTION_FREQ_24_MHZ_CLK:
+ dev->cfg = &kvaser_usb_leaf_m32c_dev_cfg_24mhz;
+ break;
+ case KVASER_USB_LEAF_SWOPTION_FREQ_32_MHZ_CLK:
+ dev->cfg = &kvaser_usb_leaf_m32c_dev_cfg_32mhz;
+ break;
+ }
} else {
switch (sw_options & KVASER_USB_LEAF_SWOPTION_FREQ_MASK) {
case KVASER_USB_LEAF_SWOPTION_FREQ_16_MHZ_CLK:
--
2.45.2
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH can-next v2 08/15] can: kvaser_usb: leaf: kvaser_usb_leaf_tx_acknowledge: Rename local variable
2024-07-01 15:49 [PATCH can-next v2 00/15] can: kvaser_usb: Add hardware timestamp support to all devices Jimmy Assarsson
` (6 preceding siblings ...)
2024-07-01 15:49 ` [PATCH can-next v2 07/15] can: kvaser_usb: leaf: Replace kvaser_usb_leaf_m32c_dev_cfg with kvaser_usb_leaf_m32c_dev_cfg_{16,24,32}mhz Jimmy Assarsson
@ 2024-07-01 15:49 ` Jimmy Assarsson
2024-07-01 15:49 ` [PATCH can-next v2 09/15] can: kvaser_usb: leaf: Add hardware timestamp support to leaf based devices Jimmy Assarsson
` (7 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Jimmy Assarsson @ 2024-07-01 15:49 UTC (permalink / raw)
To: linux-can
Cc: Jimmy Assarsson, Marc Kleine-Budde, Vincent Mailhol,
Jimmy Assarsson
Rename local variable skb to err_skb.
Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
---
Changes in v2:
- No changes
drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
index 3245471e906b..caef1f26a95c 100644
--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
+++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
@@ -936,14 +936,14 @@ static void kvaser_usb_leaf_tx_acknowledge(const struct kvaser_usb *dev,
/* Sometimes the state change doesn't come after a bus-off event */
if (priv->can.restart_ms && priv->can.state == CAN_STATE_BUS_OFF) {
- struct sk_buff *skb;
+ struct sk_buff *err_skb;
struct can_frame *cf;
- skb = alloc_can_err_skb(priv->netdev, &cf);
- if (skb) {
+ err_skb = alloc_can_err_skb(priv->netdev, &cf);
+ if (err_skb) {
cf->can_id |= CAN_ERR_RESTARTED;
- netif_rx(skb);
+ netif_rx(err_skb);
} else {
netdev_err(priv->netdev,
"No memory left for err_skb\n");
--
2.45.2
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH can-next v2 09/15] can: kvaser_usb: leaf: Add hardware timestamp support to leaf based devices
2024-07-01 15:49 [PATCH can-next v2 00/15] can: kvaser_usb: Add hardware timestamp support to all devices Jimmy Assarsson
` (7 preceding siblings ...)
2024-07-01 15:49 ` [PATCH can-next v2 08/15] can: kvaser_usb: leaf: kvaser_usb_leaf_tx_acknowledge: Rename local variable Jimmy Assarsson
@ 2024-07-01 15:49 ` Jimmy Assarsson
2024-07-01 15:49 ` [PATCH can-next v2 10/15] can: kvaser_usb: leaf: Add structs for Tx ACK and clock overflow commands Jimmy Assarsson
` (6 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Jimmy Assarsson @ 2024-07-01 15:49 UTC (permalink / raw)
To: linux-can
Cc: Jimmy Assarsson, Marc Kleine-Budde, Vincent Mailhol,
Jimmy Assarsson
Add hardware timestamp support to leaf based devices (M32C and leafimx).
Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
---
Changes in v2:
- Utilize new helper functions, from
can: kvaser_usb: Add helper functions to convert device timestamp into ktime
drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c | 11 +++++++----
drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 15 +++++++++++++++
2 files changed, 22 insertions(+), 4 deletions(-)
diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c
index daa34b532aa8..b5d762d38d5d 100644
--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c
+++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c
@@ -106,14 +106,16 @@ static const struct kvaser_usb_driver_info kvaser_usb_driver_info_usbcan = {
};
static const struct kvaser_usb_driver_info kvaser_usb_driver_info_leaf = {
- .quirks = KVASER_USB_QUIRK_IGNORE_CLK_FREQ,
+ .quirks = KVASER_USB_QUIRK_IGNORE_CLK_FREQ |
+ KVASER_USB_QUIRK_HAS_HARDWARE_TIMESTAMP,
.family = KVASER_LEAF,
.ops = &kvaser_usb_leaf_dev_ops,
};
static const struct kvaser_usb_driver_info kvaser_usb_driver_info_leaf_err = {
.quirks = KVASER_USB_QUIRK_HAS_TXRX_ERRORS |
- KVASER_USB_QUIRK_IGNORE_CLK_FREQ,
+ KVASER_USB_QUIRK_IGNORE_CLK_FREQ |
+ KVASER_USB_QUIRK_HAS_HARDWARE_TIMESTAMP,
.family = KVASER_LEAF,
.ops = &kvaser_usb_leaf_dev_ops,
};
@@ -121,13 +123,14 @@ static const struct kvaser_usb_driver_info kvaser_usb_driver_info_leaf_err = {
static const struct kvaser_usb_driver_info kvaser_usb_driver_info_leaf_err_listen = {
.quirks = KVASER_USB_QUIRK_HAS_TXRX_ERRORS |
KVASER_USB_QUIRK_HAS_SILENT_MODE |
- KVASER_USB_QUIRK_IGNORE_CLK_FREQ,
+ KVASER_USB_QUIRK_IGNORE_CLK_FREQ |
+ KVASER_USB_QUIRK_HAS_HARDWARE_TIMESTAMP,
.family = KVASER_LEAF,
.ops = &kvaser_usb_leaf_dev_ops,
};
static const struct kvaser_usb_driver_info kvaser_usb_driver_info_leafimx = {
- .quirks = 0,
+ .quirks = KVASER_USB_QUIRK_HAS_HARDWARE_TIMESTAMP,
.family = KVASER_LEAF,
.ops = &kvaser_usb_leaf_dev_ops,
};
diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
index caef1f26a95c..5839333eb5ae 100644
--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
+++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
@@ -915,6 +915,8 @@ static void kvaser_usb_leaf_tx_acknowledge(const struct kvaser_usb *dev,
struct kvaser_usb_net_priv *priv;
unsigned long flags;
u8 channel, tid;
+ struct sk_buff *skb;
+ ktime_t hwtstamp = 0;
channel = cmd->u.tx_acknowledge_header.channel;
tid = cmd->u.tx_acknowledge_header.tid;
@@ -954,9 +956,19 @@ static void kvaser_usb_leaf_tx_acknowledge(const struct kvaser_usb *dev,
priv->can.state = CAN_STATE_ERROR_ACTIVE;
}
+ switch (dev->driver_info->family) {
+ case KVASER_LEAF:
+ hwtstamp = kvaser_usb_timestamp48_to_ktime(dev->cfg, cmd->u.leaf.tx_ack.time);
+ break;
+ case KVASER_USBCAN:
+ break;
+ }
spin_lock_irqsave(&priv->tx_contexts_lock, flags);
+ skb = priv->can.echo_skb[context->echo_index];
+ if (skb)
+ skb_hwtstamps(skb)->hwtstamp = hwtstamp;
stats->tx_packets++;
stats->tx_bytes += can_get_echo_skb(priv->netdev,
context->echo_index, NULL);
@@ -1334,6 +1346,7 @@ static void kvaser_usb_leaf_rx_can_msg(const struct kvaser_usb *dev,
struct net_device_stats *stats;
u8 channel = cmd->u.rx_can_header.channel;
const u8 *rx_data = NULL; /* GCC */
+ ktime_t hwtstamp = 0;
if (channel >= dev->nchannels) {
dev_err(&dev->intf->dev,
@@ -1364,6 +1377,7 @@ static void kvaser_usb_leaf_rx_can_msg(const struct kvaser_usb *dev,
switch (dev->driver_info->family) {
case KVASER_LEAF:
rx_data = cmd->u.leaf.rx_can.data;
+ hwtstamp = kvaser_usb_timestamp48_to_ktime(dev->cfg, cmd->u.leaf.rx_can.time);
break;
case KVASER_USBCAN:
rx_data = cmd->u.usbcan.rx_can.data;
@@ -1410,6 +1424,7 @@ static void kvaser_usb_leaf_rx_can_msg(const struct kvaser_usb *dev,
memcpy(cf->data, &rx_data[6], cf->len);
}
+ skb_hwtstamps(skb)->hwtstamp = hwtstamp;
stats->rx_packets++;
if (!(cf->can_id & CAN_RTR_FLAG))
stats->rx_bytes += cf->len;
--
2.45.2
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH can-next v2 10/15] can: kvaser_usb: leaf: Add structs for Tx ACK and clock overflow commands
2024-07-01 15:49 [PATCH can-next v2 00/15] can: kvaser_usb: Add hardware timestamp support to all devices Jimmy Assarsson
` (8 preceding siblings ...)
2024-07-01 15:49 ` [PATCH can-next v2 09/15] can: kvaser_usb: leaf: Add hardware timestamp support to leaf based devices Jimmy Assarsson
@ 2024-07-01 15:49 ` Jimmy Assarsson
2024-07-01 15:49 ` [PATCH can-next v2 11/15] can: kvaser_usb: leaf: Store MSB of timestamp Jimmy Assarsson
` (5 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Jimmy Assarsson @ 2024-07-01 15:49 UTC (permalink / raw)
To: linux-can
Cc: Jimmy Assarsson, Marc Kleine-Budde, Vincent Mailhol,
Jimmy Assarsson
For usbcan devices (M16C), add struct usbcan_cmd_tx_acknowledge for Tx ACK
commands and struct usbcan_cmd_clk_overflow_event for clock overflow event
commands.
Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
---
Changes in v2:
- Keep the "ignored events/commands" comments, since the patch that
actually dispatches the command, is later in this series
Pointed out by Vincent MAILHOL [1]
[1] https://lore.kernel.org/linux-can/CAMZ6RqKqJX6eqogS2598BFm-AN1uOBbBGL+MkoJtR=-z379Q=w@mail.gmail.com/
.../net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
index 5839333eb5ae..2c0313c8f63e 100644
--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
+++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
@@ -242,6 +242,13 @@ struct leaf_cmd_tx_acknowledge {
u8 padding[2];
} __packed;
+struct usbcan_cmd_tx_acknowledge {
+ u8 channel;
+ u8 tid;
+ __le16 time;
+ u8 padding[2];
+} __packed;
+
struct leaf_cmd_can_error_event {
u8 tid;
u8 flags;
@@ -288,6 +295,12 @@ struct usbcan_cmd_error_event {
__le16 padding;
} __packed;
+struct usbcan_cmd_clk_overflow_event {
+ u8 tid;
+ u8 padding;
+ __le32 time;
+} __packed;
+
struct kvaser_cmd_ctrl_mode {
u8 tid;
u8 channel;
@@ -363,6 +376,8 @@ struct kvaser_cmd {
struct usbcan_cmd_chip_state_event chip_state_event;
struct usbcan_cmd_can_error_event can_error_event;
struct usbcan_cmd_error_event error_event;
+ struct usbcan_cmd_tx_acknowledge tx_ack;
+ struct usbcan_cmd_clk_overflow_event clk_overflow_event;
} __packed usbcan;
struct kvaser_cmd_tx_can tx_can;
@@ -396,7 +411,7 @@ static const u8 kvaser_usb_leaf_cmd_sizes_usbcan[] = {
[CMD_START_CHIP_REPLY] = kvaser_fsize(u.simple),
[CMD_STOP_CHIP_REPLY] = kvaser_fsize(u.simple),
[CMD_GET_CARD_INFO_REPLY] = kvaser_fsize(u.cardinfo),
- [CMD_TX_ACKNOWLEDGE] = kvaser_fsize(u.tx_acknowledge_header),
+ [CMD_TX_ACKNOWLEDGE] = kvaser_fsize(u.usbcan.tx_ack),
[CMD_GET_SOFTWARE_INFO_REPLY] = kvaser_fsize(u.usbcan.softinfo),
[CMD_RX_STD_MESSAGE] = kvaser_fsize(u.usbcan.rx_can),
[CMD_RX_EXT_MESSAGE] = kvaser_fsize(u.usbcan.rx_can),
@@ -404,7 +419,7 @@ static const u8 kvaser_usb_leaf_cmd_sizes_usbcan[] = {
[CMD_CAN_ERROR_EVENT] = kvaser_fsize(u.usbcan.can_error_event),
[CMD_ERROR_EVENT] = kvaser_fsize(u.usbcan.error_event),
/* ignored events: */
- [CMD_USBCAN_CLOCK_OVERFLOW_EVENT] = CMD_SIZE_ANY,
+ [CMD_USBCAN_CLOCK_OVERFLOW_EVENT] = kvaser_fsize(u.usbcan.clk_overflow_event),
};
/* Summary of a kvaser error event, for a unified Leaf/Usbcan error
--
2.45.2
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH can-next v2 11/15] can: kvaser_usb: leaf: Store MSB of timestamp
2024-07-01 15:49 [PATCH can-next v2 00/15] can: kvaser_usb: Add hardware timestamp support to all devices Jimmy Assarsson
` (9 preceding siblings ...)
2024-07-01 15:49 ` [PATCH can-next v2 10/15] can: kvaser_usb: leaf: Add structs for Tx ACK and clock overflow commands Jimmy Assarsson
@ 2024-07-01 15:49 ` Jimmy Assarsson
2024-07-01 15:49 ` [PATCH can-next v2 12/15] can: kvaser_usb: leaf: Add hardware timestamp support to usbcan devices Jimmy Assarsson
` (4 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Jimmy Assarsson @ 2024-07-01 15:49 UTC (permalink / raw)
To: linux-can
Cc: Jimmy Assarsson, Marc Kleine-Budde, Vincent Mailhol,
Jimmy Assarsson
Store MSB of timestamp, provided from the device via the clock overflow
event, for usbcan devices (M16C).
Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
---
Changes in v2:
- Remove the "ignored events/commands" comments, since here we
handle the clock overflow command
drivers/net/can/usb/kvaser_usb/kvaser_usb.h | 1 +
drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 11 ++++++++---
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb.h b/drivers/net/can/usb/kvaser_usb/kvaser_usb.h
index 4256a0caae20..591f707d2895 100644
--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb.h
+++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb.h
@@ -70,6 +70,7 @@ struct kvaser_usb_dev_card_data {
u32 ctrlmode_supported;
u32 capabilities;
struct kvaser_usb_dev_card_data_hydra hydra;
+ u32 usbcan_timestamp_msb;
};
/* Context for an outstanding, not yet ACKed, transmission */
diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
index 2c0313c8f63e..465707174f2e 100644
--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
+++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
@@ -119,6 +119,9 @@
/* Extended CAN identifier flag */
#define KVASER_EXTENDED_FRAME BIT(31)
+/* USBCanII timestamp */
+#define KVASER_USB_USBCAN_CLK_OVERFLOW_MASK GENMASK(31, 16)
+
struct kvaser_cmd_simple {
u8 tid;
u8 channel;
@@ -418,7 +421,6 @@ static const u8 kvaser_usb_leaf_cmd_sizes_usbcan[] = {
[CMD_CHIP_STATE_EVENT] = kvaser_fsize(u.usbcan.chip_state_event),
[CMD_CAN_ERROR_EVENT] = kvaser_fsize(u.usbcan.can_error_event),
[CMD_ERROR_EVENT] = kvaser_fsize(u.usbcan.error_event),
- /* ignored events: */
[CMD_USBCAN_CLOCK_OVERFLOW_EVENT] = kvaser_fsize(u.usbcan.clk_overflow_event),
};
@@ -1573,7 +1575,7 @@ static void kvaser_usb_leaf_get_busparams_reply(const struct kvaser_usb *dev,
complete(&priv->get_busparams_comp);
}
-static void kvaser_usb_leaf_handle_command(const struct kvaser_usb *dev,
+static void kvaser_usb_leaf_handle_command(struct kvaser_usb *dev,
const struct kvaser_cmd *cmd)
{
if (kvaser_usb_leaf_verify_size(dev, cmd) < 0)
@@ -1619,12 +1621,15 @@ static void kvaser_usb_leaf_handle_command(const struct kvaser_usb *dev,
kvaser_usb_leaf_get_busparams_reply(dev, cmd);
break;
- /* Ignored commands */
case CMD_USBCAN_CLOCK_OVERFLOW_EVENT:
if (dev->driver_info->family != KVASER_USBCAN)
goto warn;
+ dev->card_data.usbcan_timestamp_msb =
+ le32_to_cpu(cmd->u.usbcan.clk_overflow_event.time) &
+ KVASER_USB_USBCAN_CLK_OVERFLOW_MASK;
break;
+ /* Ignored commands */
case CMD_FLUSH_QUEUE_REPLY:
if (dev->driver_info->family != KVASER_LEAF)
goto warn;
--
2.45.2
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH can-next v2 12/15] can: kvaser_usb: leaf: Add hardware timestamp support to usbcan devices
2024-07-01 15:49 [PATCH can-next v2 00/15] can: kvaser_usb: Add hardware timestamp support to all devices Jimmy Assarsson
` (10 preceding siblings ...)
2024-07-01 15:49 ` [PATCH can-next v2 11/15] can: kvaser_usb: leaf: Store MSB of timestamp Jimmy Assarsson
@ 2024-07-01 15:49 ` Jimmy Assarsson
2024-07-01 15:49 ` [PATCH can-next v2 13/15] can: kvaser_usb: Remove KVASER_USB_QUIRK_HAS_HARDWARE_TIMESTAMP Jimmy Assarsson
` (3 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Jimmy Assarsson @ 2024-07-01 15:49 UTC (permalink / raw)
To: linux-can
Cc: Jimmy Assarsson, Marc Kleine-Budde, Vincent Mailhol,
Jimmy Assarsson
Add hardware timestamp support for all usbcan based devices (M16C).
The usbcan firmware is slightly different compared to the other Kvaser USB
interfaces:
- The timestamp is provided by a 32-bit counter, with 10us resolution.
Hence, the hardware timestamp will wrap after less than 12 hours.
- Each Rx CAN or Tx ACK command only contains the 16-bits LSB of the
timestamp counter.
- The 16-bits MSB are sent in an asynchronous event (command), if any
change occurred in the MSB since the last event.
Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
---
Changes in v2:
- Add new helper function kvaser_usb_usbcan_timestamp_to_ktime()
drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c | 3 ++-
drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c | 12 ++++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c
index b5d762d38d5d..576ddf932f47 100644
--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c
+++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c
@@ -100,7 +100,8 @@ static const struct kvaser_usb_driver_info kvaser_usb_driver_info_hydra = {
static const struct kvaser_usb_driver_info kvaser_usb_driver_info_usbcan = {
.quirks = KVASER_USB_QUIRK_HAS_TXRX_ERRORS |
- KVASER_USB_QUIRK_HAS_SILENT_MODE,
+ KVASER_USB_QUIRK_HAS_SILENT_MODE |
+ KVASER_USB_QUIRK_HAS_HARDWARE_TIMESTAMP,
.family = KVASER_USBCAN,
.ops = &kvaser_usb_leaf_dev_ops,
};
diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
index 465707174f2e..6b9122ab1464 100644
--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
+++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_leaf.c
@@ -121,6 +121,7 @@
/* USBCanII timestamp */
#define KVASER_USB_USBCAN_CLK_OVERFLOW_MASK GENMASK(31, 16)
+#define KVASER_USB_USBCAN_TIMESTAMP_FACTOR 10
struct kvaser_cmd_simple {
u8 tid;
@@ -536,6 +537,15 @@ static const struct kvaser_usb_dev_cfg kvaser_usb_leaf_imx_dev_cfg_32mhz = {
.bittiming_const = &kvaser_usb_flexc_bittiming_const,
};
+static inline ktime_t kvaser_usb_usbcan_timestamp_to_ktime(const struct kvaser_usb *dev,
+ __le16 timestamp)
+{
+ u64 ticks = le16_to_cpu(timestamp) |
+ dev->card_data.usbcan_timestamp_msb;
+
+ return kvaser_usb_ticks_to_ktime(dev->cfg, ticks * KVASER_USB_USBCAN_TIMESTAMP_FACTOR);
+}
+
static int kvaser_usb_leaf_verify_size(const struct kvaser_usb *dev,
const struct kvaser_cmd *cmd)
{
@@ -978,6 +988,7 @@ static void kvaser_usb_leaf_tx_acknowledge(const struct kvaser_usb *dev,
hwtstamp = kvaser_usb_timestamp48_to_ktime(dev->cfg, cmd->u.leaf.tx_ack.time);
break;
case KVASER_USBCAN:
+ hwtstamp = kvaser_usb_usbcan_timestamp_to_ktime(dev, cmd->u.usbcan.tx_ack.time);
break;
}
@@ -1398,6 +1409,7 @@ static void kvaser_usb_leaf_rx_can_msg(const struct kvaser_usb *dev,
break;
case KVASER_USBCAN:
rx_data = cmd->u.usbcan.rx_can.data;
+ hwtstamp = kvaser_usb_usbcan_timestamp_to_ktime(dev, cmd->u.usbcan.rx_can.time);
break;
}
--
2.45.2
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH can-next v2 13/15] can: kvaser_usb: Remove KVASER_USB_QUIRK_HAS_HARDWARE_TIMESTAMP
2024-07-01 15:49 [PATCH can-next v2 00/15] can: kvaser_usb: Add hardware timestamp support to all devices Jimmy Assarsson
` (11 preceding siblings ...)
2024-07-01 15:49 ` [PATCH can-next v2 12/15] can: kvaser_usb: leaf: Add hardware timestamp support to usbcan devices Jimmy Assarsson
@ 2024-07-01 15:49 ` Jimmy Assarsson
2024-07-01 15:49 ` [PATCH can-next v2 14/15] can: kvaser_usb: Remove struct variables kvaser_usb_{ethtool,netdev}_ops Jimmy Assarsson
` (2 subsequent siblings)
15 siblings, 0 replies; 20+ messages in thread
From: Jimmy Assarsson @ 2024-07-01 15:49 UTC (permalink / raw)
To: linux-can
Cc: Jimmy Assarsson, Marc Kleine-Budde, Vincent Mailhol,
Jimmy Assarsson
Remove KVASER_USB_QUIRK_HAS_HARDWARE_TIMESTAMP, since all devices got
hardware timestamp support.
Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
---
Changes in v2:
- No changes
drivers/net/can/usb/kvaser_usb/kvaser_usb.h | 1 -
.../net/can/usb/kvaser_usb/kvaser_usb_core.c | 26 ++++++-------------
2 files changed, 8 insertions(+), 19 deletions(-)
diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb.h b/drivers/net/can/usb/kvaser_usb/kvaser_usb.h
index 591f707d2895..078496d9b7ba 100644
--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb.h
+++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb.h
@@ -41,7 +41,6 @@
#define KVASER_USB_QUIRK_HAS_SILENT_MODE BIT(0)
#define KVASER_USB_QUIRK_HAS_TXRX_ERRORS BIT(1)
#define KVASER_USB_QUIRK_IGNORE_CLK_FREQ BIT(2)
-#define KVASER_USB_QUIRK_HAS_HARDWARE_TIMESTAMP BIT(3)
/* Device capabilities */
#define KVASER_USB_CAP_BERR_CAP 0x01
diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c
index 576ddf932f47..a4f32d57173a 100644
--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c
+++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c
@@ -94,29 +94,26 @@
#define USB_MINI_PCIE_1XCAN_PRODUCT_ID 0x011B
static const struct kvaser_usb_driver_info kvaser_usb_driver_info_hydra = {
- .quirks = KVASER_USB_QUIRK_HAS_HARDWARE_TIMESTAMP,
+ .quirks = 0,
.ops = &kvaser_usb_hydra_dev_ops,
};
static const struct kvaser_usb_driver_info kvaser_usb_driver_info_usbcan = {
.quirks = KVASER_USB_QUIRK_HAS_TXRX_ERRORS |
- KVASER_USB_QUIRK_HAS_SILENT_MODE |
- KVASER_USB_QUIRK_HAS_HARDWARE_TIMESTAMP,
+ KVASER_USB_QUIRK_HAS_SILENT_MODE,
.family = KVASER_USBCAN,
.ops = &kvaser_usb_leaf_dev_ops,
};
static const struct kvaser_usb_driver_info kvaser_usb_driver_info_leaf = {
- .quirks = KVASER_USB_QUIRK_IGNORE_CLK_FREQ |
- KVASER_USB_QUIRK_HAS_HARDWARE_TIMESTAMP,
+ .quirks = KVASER_USB_QUIRK_IGNORE_CLK_FREQ,
.family = KVASER_LEAF,
.ops = &kvaser_usb_leaf_dev_ops,
};
static const struct kvaser_usb_driver_info kvaser_usb_driver_info_leaf_err = {
.quirks = KVASER_USB_QUIRK_HAS_TXRX_ERRORS |
- KVASER_USB_QUIRK_IGNORE_CLK_FREQ |
- KVASER_USB_QUIRK_HAS_HARDWARE_TIMESTAMP,
+ KVASER_USB_QUIRK_IGNORE_CLK_FREQ,
.family = KVASER_LEAF,
.ops = &kvaser_usb_leaf_dev_ops,
};
@@ -124,14 +121,13 @@ static const struct kvaser_usb_driver_info kvaser_usb_driver_info_leaf_err = {
static const struct kvaser_usb_driver_info kvaser_usb_driver_info_leaf_err_listen = {
.quirks = KVASER_USB_QUIRK_HAS_TXRX_ERRORS |
KVASER_USB_QUIRK_HAS_SILENT_MODE |
- KVASER_USB_QUIRK_IGNORE_CLK_FREQ |
- KVASER_USB_QUIRK_HAS_HARDWARE_TIMESTAMP,
+ KVASER_USB_QUIRK_IGNORE_CLK_FREQ,
.family = KVASER_LEAF,
.ops = &kvaser_usb_leaf_dev_ops,
};
static const struct kvaser_usb_driver_info kvaser_usb_driver_info_leafimx = {
- .quirks = KVASER_USB_QUIRK_HAS_HARDWARE_TIMESTAMP,
+ .quirks = 0,
.family = KVASER_LEAF,
.ops = &kvaser_usb_leaf_dev_ops,
};
@@ -862,14 +858,8 @@ static int kvaser_usb_init_one(struct kvaser_usb *dev, int channel)
netdev->flags |= IFF_ECHO;
- netdev->netdev_ops = &kvaser_usb_netdev_ops;
- if (driver_info->quirks & KVASER_USB_QUIRK_HAS_HARDWARE_TIMESTAMP) {
- netdev->netdev_ops = &kvaser_usb_netdev_ops_hwts;
- netdev->ethtool_ops = &kvaser_usb_ethtool_ops_hwts;
- } else {
- netdev->netdev_ops = &kvaser_usb_netdev_ops;
- netdev->ethtool_ops = &kvaser_usb_ethtool_ops;
- }
+ netdev->netdev_ops = &kvaser_usb_netdev_ops_hwts;
+ netdev->ethtool_ops = &kvaser_usb_ethtool_ops_hwts;
SET_NETDEV_DEV(netdev, &dev->intf->dev);
netdev->dev_id = channel;
--
2.45.2
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH can-next v2 14/15] can: kvaser_usb: Remove struct variables kvaser_usb_{ethtool,netdev}_ops
2024-07-01 15:49 [PATCH can-next v2 00/15] can: kvaser_usb: Add hardware timestamp support to all devices Jimmy Assarsson
` (12 preceding siblings ...)
2024-07-01 15:49 ` [PATCH can-next v2 13/15] can: kvaser_usb: Remove KVASER_USB_QUIRK_HAS_HARDWARE_TIMESTAMP Jimmy Assarsson
@ 2024-07-01 15:49 ` Jimmy Assarsson
2024-07-01 15:49 ` [PATCH can-next v2 15/15] can: kvaser_usb: Rename kvaser_usb_{ethtool,netdev}_ops_hwts to kvaser_usb_{ethtool,netdev}_ops Jimmy Assarsson
2024-07-02 4:52 ` [PATCH can-next v2 00/15] can: kvaser_usb: Add hardware timestamp support to all devices Vincent MAILHOL
15 siblings, 0 replies; 20+ messages in thread
From: Jimmy Assarsson @ 2024-07-01 15:49 UTC (permalink / raw)
To: linux-can
Cc: Jimmy Assarsson, Marc Kleine-Budde, Vincent Mailhol,
Jimmy Assarsson
Remove no longer used struct variables, kvaser_usb_ethtool_ops and
kvaser_usb_netdev_ops.
Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
---
Changes in v2:
- No changes
drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c | 11 -----------
1 file changed, 11 deletions(-)
diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c
index a4f32d57173a..4b6c23121b5d 100644
--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c
+++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c
@@ -753,13 +753,6 @@ static netdev_tx_t kvaser_usb_start_xmit(struct sk_buff *skb,
return ret;
}
-static const struct net_device_ops kvaser_usb_netdev_ops = {
- .ndo_open = kvaser_usb_open,
- .ndo_stop = kvaser_usb_close,
- .ndo_start_xmit = kvaser_usb_start_xmit,
- .ndo_change_mtu = can_change_mtu,
-};
-
static const struct net_device_ops kvaser_usb_netdev_ops_hwts = {
.ndo_open = kvaser_usb_open,
.ndo_stop = kvaser_usb_close,
@@ -768,10 +761,6 @@ static const struct net_device_ops kvaser_usb_netdev_ops_hwts = {
.ndo_change_mtu = can_change_mtu,
};
-static const struct ethtool_ops kvaser_usb_ethtool_ops = {
- .get_ts_info = ethtool_op_get_ts_info,
-};
-
static const struct ethtool_ops kvaser_usb_ethtool_ops_hwts = {
.get_ts_info = can_ethtool_op_get_ts_info_hwts,
};
--
2.45.2
^ permalink raw reply related [flat|nested] 20+ messages in thread* [PATCH can-next v2 15/15] can: kvaser_usb: Rename kvaser_usb_{ethtool,netdev}_ops_hwts to kvaser_usb_{ethtool,netdev}_ops
2024-07-01 15:49 [PATCH can-next v2 00/15] can: kvaser_usb: Add hardware timestamp support to all devices Jimmy Assarsson
` (13 preceding siblings ...)
2024-07-01 15:49 ` [PATCH can-next v2 14/15] can: kvaser_usb: Remove struct variables kvaser_usb_{ethtool,netdev}_ops Jimmy Assarsson
@ 2024-07-01 15:49 ` Jimmy Assarsson
2024-07-02 4:52 ` [PATCH can-next v2 00/15] can: kvaser_usb: Add hardware timestamp support to all devices Vincent MAILHOL
15 siblings, 0 replies; 20+ messages in thread
From: Jimmy Assarsson @ 2024-07-01 15:49 UTC (permalink / raw)
To: linux-can
Cc: Jimmy Assarsson, Marc Kleine-Budde, Vincent Mailhol,
Jimmy Assarsson
Now when we only got one set of ethtool_ops and netdev_ops, remove the
"hwts" suffix from the struct variables
kvaser_usb_{ethtool,netdev}_ops_hwts.
Signed-off-by: Jimmy Assarsson <extja@kvaser.com>
---
Changes in v2:
- No changes
drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c
index 4b6c23121b5d..35b4132b0639 100644
--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c
+++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c
@@ -753,7 +753,7 @@ static netdev_tx_t kvaser_usb_start_xmit(struct sk_buff *skb,
return ret;
}
-static const struct net_device_ops kvaser_usb_netdev_ops_hwts = {
+static const struct net_device_ops kvaser_usb_netdev_ops = {
.ndo_open = kvaser_usb_open,
.ndo_stop = kvaser_usb_close,
.ndo_eth_ioctl = can_eth_ioctl_hwts,
@@ -761,7 +761,7 @@ static const struct net_device_ops kvaser_usb_netdev_ops_hwts = {
.ndo_change_mtu = can_change_mtu,
};
-static const struct ethtool_ops kvaser_usb_ethtool_ops_hwts = {
+static const struct ethtool_ops kvaser_usb_ethtool_ops = {
.get_ts_info = can_ethtool_op_get_ts_info_hwts,
};
@@ -847,8 +847,8 @@ static int kvaser_usb_init_one(struct kvaser_usb *dev, int channel)
netdev->flags |= IFF_ECHO;
- netdev->netdev_ops = &kvaser_usb_netdev_ops_hwts;
- netdev->ethtool_ops = &kvaser_usb_ethtool_ops_hwts;
+ netdev->netdev_ops = &kvaser_usb_netdev_ops;
+ netdev->ethtool_ops = &kvaser_usb_ethtool_ops;
SET_NETDEV_DEV(netdev, &dev->intf->dev);
netdev->dev_id = channel;
--
2.45.2
^ permalink raw reply related [flat|nested] 20+ messages in thread* Re: [PATCH can-next v2 00/15] can: kvaser_usb: Add hardware timestamp support to all devices
2024-07-01 15:49 [PATCH can-next v2 00/15] can: kvaser_usb: Add hardware timestamp support to all devices Jimmy Assarsson
` (14 preceding siblings ...)
2024-07-01 15:49 ` [PATCH can-next v2 15/15] can: kvaser_usb: Rename kvaser_usb_{ethtool,netdev}_ops_hwts to kvaser_usb_{ethtool,netdev}_ops Jimmy Assarsson
@ 2024-07-02 4:52 ` Vincent MAILHOL
2024-07-02 19:37 ` Jimmy Assarsson
15 siblings, 1 reply; 20+ messages in thread
From: Vincent MAILHOL @ 2024-07-02 4:52 UTC (permalink / raw)
To: Jimmy Assarsson; +Cc: linux-can, Jimmy Assarsson, Marc Kleine-Budde
On Tue. 2 Jul. 2024 at 00:50, Jimmy Assarsson <extja@kvaser.com> wrote:
> From: Jimmy Assarsson <jimmyassarsson@gmail.com>
>
> This patch series add hardware timestamp support to all devices supported
> by the kvaser_usb driver.
>
> The first patches resolves a known issue; "Hardware timestamps are not set
> for CAN Tx frames". I can't remember why this wasn't implemented in the
> first version of the hydra driver.
>
> Followed by, hardware timestamp support for leaf and usbcan based devices.
>
> The final patches are removing code used for selecting the correct ethtool
> and netdev ops.
>
> Note: This patch series depends on patch
> "can: kvaser_usb: Explicitly initialize family in leafimx..." [1].
>
> [1] https://lore.kernel.org/linux-can/20240628194529.312968-1-extja@kvaser.com
Thanks for taking care of the TX timestamps!
I left one nitpick which is notwithstanding. With or without my
comment addressed and for the full series:
Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
^ permalink raw reply [flat|nested] 20+ messages in thread* Re: [PATCH can-next v2 00/15] can: kvaser_usb: Add hardware timestamp support to all devices
2024-07-02 4:52 ` [PATCH can-next v2 00/15] can: kvaser_usb: Add hardware timestamp support to all devices Vincent MAILHOL
@ 2024-07-02 19:37 ` Jimmy Assarsson
0 siblings, 0 replies; 20+ messages in thread
From: Jimmy Assarsson @ 2024-07-02 19:37 UTC (permalink / raw)
To: Vincent MAILHOL, Jimmy Assarsson; +Cc: linux-can, Marc Kleine-Budde
On 7/2/24 06:52, Vincent MAILHOL wrote:
> On Tue. 2 Jul. 2024 at 00:50, Jimmy Assarsson <extja@kvaser.com> wrote:
>> From: Jimmy Assarsson <jimmyassarsson@gmail.com>
>>
>> This patch series add hardware timestamp support to all devices supported
>> by the kvaser_usb driver.
>>
>> The first patches resolves a known issue; "Hardware timestamps are not set
>> for CAN Tx frames". I can't remember why this wasn't implemented in the
>> first version of the hydra driver.
>>
>> Followed by, hardware timestamp support for leaf and usbcan based devices.
>>
>> The final patches are removing code used for selecting the correct ethtool
>> and netdev ops.
>>
>> Note: This patch series depends on patch
>> "can: kvaser_usb: Explicitly initialize family in leafimx..." [1].
>>
>> [1] https://lore.kernel.org/linux-can/20240628194529.312968-1-extja@kvaser.com
>
> Thanks for taking care of the TX timestamps!
>
> I left one nitpick which is notwithstanding. With or without my
> comment addressed and for the full series:
>
> Reviewed-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Again, thanks for reviewing!
Regards,
jimmy
^ permalink raw reply [flat|nested] 20+ messages in thread