[PATCH v3 2/4] can: rx-offload: can_rx_offload_receive_skb(): add new function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Kurt Van Dijck <dev.kurt@xxxxxxxxxxxxxxxxxxxxxx>

The CAN rx-offload provides a mechanism to rapidly read CAN msgs from
the CAN chip, and queue them before the NAPI will process them in a
softirq.

The current CAN rx-offload only supports a callback that reads the CAN
frame from the chip with its only parameter being a mailbox index.

This commit provides a netif_receive_skb() alike function
"can_rx_offload_receive_skb()" that uses the CAN rx-offload queueing
directly without a callback.

This makes transition easier, especially when more context info is
required which makes the callback method harder.

Signed-off-by: Kurt Van Dijck <dev.kurt@xxxxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx>
---
 drivers/net/can/rx-offload.c   | 17 +++++++++++++++++
 include/linux/can/rx-offload.h |  2 ++
 2 files changed, 19 insertions(+)

diff --git a/drivers/net/can/rx-offload.c b/drivers/net/can/rx-offload.c
index e90f11e79ab4..138b8b8e3700 100644
--- a/drivers/net/can/rx-offload.c
+++ b/drivers/net/can/rx-offload.c
@@ -270,6 +270,23 @@ int can_rx_offload_queue_tail(struct can_rx_offload *offload,
 }
 EXPORT_SYMBOL_GPL(can_rx_offload_queue_tail);
 
+int can_rx_offload_receive_skb(struct can_rx_offload *offload,
+			       struct sk_buff *skb)
+{
+	struct net_device_stats *stats = &offload->dev->stats;
+	int err;
+
+	err = can_rx_offload_queue_tail(offload, skb);
+	if (err) {
+		kfree_skb(skb);
+		stats->rx_errors++;
+		stats->rx_fifo_errors++;
+	}
+
+	return err;
+}
+EXPORT_SYMBOL_GPL(can_rx_offload_receive_skb);
+
 static int can_rx_offload_init_queue(struct net_device *dev,
 				     struct can_rx_offload *offload,
 				     unsigned int weight)
diff --git a/include/linux/can/rx-offload.h b/include/linux/can/rx-offload.h
index cdeb8834382d..c32423318717 100644
--- a/include/linux/can/rx-offload.h
+++ b/include/linux/can/rx-offload.h
@@ -47,6 +47,8 @@ unsigned int can_rx_offload_get_echo_skb(struct can_rx_offload *offload,
 					 unsigned int idx, u32 timestamp);
 int can_rx_offload_queue_tail(struct can_rx_offload *offload,
 			      struct sk_buff *skb);
+int can_rx_offload_receive_skb(struct can_rx_offload *offload,
+			       struct sk_buff *skb);
 void can_rx_offload_del(struct can_rx_offload *offload);
 void can_rx_offload_enable(struct can_rx_offload *offload);
 
-- 
2.23.0




[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux