Skip to content

Commit 8e0e295

Browse files
can: rx-offload: add can_rx_offload_get_echo_skb_queue_tail()
Add can_rx_offload_get_echo_skb_queue_tail(). This function addds the echo skb at the end of rx-offload the queue. This is intended for devices without timestamp support. Link: https://lore.kernel.org/all/20230718-gs_usb-rx-offload-v2-2-716e542d14d5@pengutronix.de Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
1 parent 2e3df4a commit 8e0e295

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

drivers/net/can/dev/rx-offload.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// SPDX-License-Identifier: GPL-2.0-only
22
/* Copyright (c) 2014 Protonic Holland,
33
* David Jander
4-
* Copyright (C) 2014-2021 Pengutronix,
4+
* Copyright (C) 2014-2021, 2023 Pengutronix,
55
* Marc Kleine-Budde <kernel@pengutronix.de>
66
*/
77

@@ -280,6 +280,31 @@ int can_rx_offload_queue_tail(struct can_rx_offload *offload,
280280
}
281281
EXPORT_SYMBOL_GPL(can_rx_offload_queue_tail);
282282

283+
unsigned int
284+
can_rx_offload_get_echo_skb_queue_tail(struct can_rx_offload *offload,
285+
unsigned int idx,
286+
unsigned int *frame_len_ptr)
287+
{
288+
struct net_device *dev = offload->dev;
289+
struct net_device_stats *stats = &dev->stats;
290+
struct sk_buff *skb;
291+
unsigned int len;
292+
int err;
293+
294+
skb = __can_get_echo_skb(dev, idx, &len, frame_len_ptr);
295+
if (!skb)
296+
return 0;
297+
298+
err = can_rx_offload_queue_tail(offload, skb);
299+
if (err) {
300+
stats->rx_errors++;
301+
stats->tx_fifo_errors++;
302+
}
303+
304+
return len;
305+
}
306+
EXPORT_SYMBOL_GPL(can_rx_offload_get_echo_skb_queue_tail);
307+
283308
void can_rx_offload_irq_finish(struct can_rx_offload *offload)
284309
{
285310
unsigned long flags;

include/linux/can/rx-offload.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* linux/can/rx-offload.h
44
*
55
* Copyright (c) 2014 David Jander, Protonic Holland
6-
* Copyright (c) 2014-2017 Pengutronix, Marc Kleine-Budde <kernel@pengutronix.de>
6+
* Copyright (c) 2014-2017, 2023 Pengutronix, Marc Kleine-Budde <kernel@pengutronix.de>
77
*/
88

99
#ifndef _CAN_RX_OFFLOAD_H
@@ -49,6 +49,9 @@ unsigned int can_rx_offload_get_echo_skb_queue_timestamp(struct can_rx_offload *
4949
unsigned int *frame_len_ptr);
5050
int can_rx_offload_queue_tail(struct can_rx_offload *offload,
5151
struct sk_buff *skb);
52+
unsigned int can_rx_offload_get_echo_skb_queue_tail(struct can_rx_offload *offload,
53+
unsigned int idx,
54+
unsigned int *frame_len_ptr);
5255
void can_rx_offload_irq_finish(struct can_rx_offload *offload);
5356
void can_rx_offload_threaded_irq_finish(struct can_rx_offload *offload);
5457
void can_rx_offload_del(struct can_rx_offload *offload);

0 commit comments

Comments
 (0)