1 /*
2  * linux/can/rx-offload.h
3  *
4  * Copyright (c) 2014 David Jander, Protonic Holland
5  * Copyright (c) 2014-2017 Pengutronix, Marc Kleine-Budde <kernel@pengutronix.de>
6  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the version 2 of the GNU General Public License
9  * as published by the Free Software Foundation
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  */
16 
17 #ifndef _CAN_RX_OFFLOAD_H
18 #define _CAN_RX_OFFLOAD_H
19 
20 #include <linux/netdevice.h>
21 #include <linux/can.h>
22 
23 struct can_rx_offload {
24 	struct net_device *dev;
25 
26 	unsigned int (*mailbox_read)(struct can_rx_offload *offload, struct can_frame *cf,
27 				     u32 *timestamp, unsigned int mb);
28 
29 	struct sk_buff_head skb_queue;
30 	u32 skb_queue_len_max;
31 
32 	unsigned int mb_first;
33 	unsigned int mb_last;
34 
35 	struct napi_struct napi;
36 
37 	bool inc;
38 };
39 
40 int can_rx_offload_add_timestamp(struct net_device *dev, struct can_rx_offload *offload);
41 int can_rx_offload_add_fifo(struct net_device *dev, struct can_rx_offload *offload, unsigned int weight);
42 int can_rx_offload_irq_offload_timestamp(struct can_rx_offload *offload, u64 reg);
43 int can_rx_offload_irq_offload_fifo(struct can_rx_offload *offload);
44 int can_rx_offload_queue_sorted(struct can_rx_offload *offload,
45 				struct sk_buff *skb, u32 timestamp);
46 unsigned int can_rx_offload_get_echo_skb(struct can_rx_offload *offload,
47 					 unsigned int idx, u32 timestamp);
48 int can_rx_offload_queue_tail(struct can_rx_offload *offload,
49 			      struct sk_buff *skb);
50 void can_rx_offload_reset(struct can_rx_offload *offload);
51 void can_rx_offload_del(struct can_rx_offload *offload);
52 void can_rx_offload_enable(struct can_rx_offload *offload);
53 
can_rx_offload_schedule(struct can_rx_offload * offload)54 static inline void can_rx_offload_schedule(struct can_rx_offload *offload)
55 {
56 	napi_schedule(&offload->napi);
57 }
58 
can_rx_offload_disable(struct can_rx_offload * offload)59 static inline void can_rx_offload_disable(struct can_rx_offload *offload)
60 {
61 	napi_disable(&offload->napi);
62 }
63 
64 #endif /* !_CAN_RX_OFFLOAD_H */
65