[PATCH 2/3] can-rx-offload: add can_rx_offload_receive_skb

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

 



The can-rx-offload provides a mechanism to rapidly get CAN msgs out of
the CAN chip, and queue them a bit before the napi will process them in
softirq.
The current can-rx-offload only supports a callback that reads the CAN frame
from the chip with only a mailbox index.
This commit provides a netif_receive_skb alike function that uses
the can-rx-offload queueing without 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>
---
 drivers/net/can/rx-offload.c   | 24 ++++++++++++++++++++----
 include/linux/can/rx-offload.h |  2 ++
 2 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/drivers/net/can/rx-offload.c b/drivers/net/can/rx-offload.c
index 4796887..f45b0b6 100644
--- a/drivers/net/can/rx-offload.c
+++ b/drivers/net/can/rx-offload.c
@@ -261,17 +261,33 @@ int can_rx_offload_queue_tail(struct can_rx_offload *offload,
 }
 EXPORT_SYMBOL_GPL(can_rx_offload_queue_tail);
 
-static int can_rx_offload_irq_inval(struct can_rx_offload *offload)
+int can_rx_offload_receive_skb(struct can_rx_offload *offload,
+		struct sk_buff *skb)
 {
-	netdev_err_once(offload->dev, "%s called\n",
-				   __func__);
+	int ret;
+	struct net_device_stats *stats = &offload->dev->stats;
+
+	ret = can_rx_offload_queue_tail(offload, skb);
+	if (ret < 0) {
+		kfree_skb(skb);
+		stats->rx_errors++;
+		stats->rx_fifo_errors++;
+	}
+	return ret;
+}
+EXPORT_SYMBOL_GPL(can_rx_offload_receive_skb);
+
+static unsigned int  can_rx_offload_mb_read_inval(struct can_rx_offload *offload,
+		struct can_frame *cf, u32 *timestamp, unsigned int mb)
+{
+	netdev_err_once(offload->dev, "%s called\n", __func__);
 	return 0;
 }
 
 int can_rx_offload_add_fifo(struct net_device *dev, struct can_rx_offload *offload, unsigned int weight)
 {
 	if (!offload->mailbox_read)
-		return -EINVAL;
+		offload->mailbox_read = can_rx_offload_mb_read_inval;
 
 	offload->dev = dev;
 
diff --git a/include/linux/can/rx-offload.h b/include/linux/can/rx-offload.h
index 9daa111..3c09c56 100644
--- a/include/linux/can/rx-offload.h
+++ b/include/linux/can/rx-offload.h
@@ -43,6 +43,8 @@ int can_rx_offload_queue_tail(struct can_rx_offload *offload,
 void can_rx_offload_del(struct can_rx_offload *offload);
 void can_rx_offload_enable(struct can_rx_offload *offload);
 
+int can_rx_offload_receive_skb(struct can_rx_offload *offload, struct sk_buff *skb);
+
 static inline void can_rx_offload_schedule(struct can_rx_offload *offload)
 {
 	napi_schedule(&offload->napi);
-- 
1.8.5.rc3




[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