blob: cb31683bbe154ab1f5b58319369aa7fe32da1c44 [file] [log] [blame]
David Janderd2545862014-10-10 17:30:10 +02001/*
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
23struct can_rx_offload {
24 struct net_device *dev;
25
Marc Kleine-Budde3abbac02014-09-23 15:28:21 +020026 unsigned int (*mailbox_read)(struct can_rx_offload *offload, struct can_frame *cf,
27 u32 *timestamp, unsigned int mb);
David Janderd2545862014-10-10 17:30:10 +020028
29 struct sk_buff_head skb_queue;
30 u32 skb_queue_len_max;
31
Marc Kleine-Budde3abbac02014-09-23 15:28:21 +020032 unsigned int mb_first;
33 unsigned int mb_last;
34
David Janderd2545862014-10-10 17:30:10 +020035 struct napi_struct napi;
Marc Kleine-Budde3abbac02014-09-23 15:28:21 +020036
37 bool inc;
David Janderd2545862014-10-10 17:30:10 +020038};
39
Marc Kleine-Budde3abbac02014-09-23 15:28:21 +020040int can_rx_offload_add_timestamp(struct net_device *dev, struct can_rx_offload *offload);
David Janderd2545862014-10-10 17:30:10 +020041int can_rx_offload_add_fifo(struct net_device *dev, struct can_rx_offload *offload, unsigned int weight);
Marc Kleine-Budde3abbac02014-09-23 15:28:21 +020042int can_rx_offload_irq_offload_timestamp(struct can_rx_offload *offload, u64 reg);
David Janderd2545862014-10-10 17:30:10 +020043int can_rx_offload_irq_offload_fifo(struct can_rx_offload *offload);
44int can_rx_offload_irq_queue_err_skb(struct can_rx_offload *offload, struct sk_buff *skb);
45void can_rx_offload_reset(struct can_rx_offload *offload);
46void can_rx_offload_del(struct can_rx_offload *offload);
47void can_rx_offload_enable(struct can_rx_offload *offload);
48
49static inline void can_rx_offload_schedule(struct can_rx_offload *offload)
50{
51 napi_schedule(&offload->napi);
52}
53
54static inline void can_rx_offload_disable(struct can_rx_offload *offload)
55{
56 napi_disable(&offload->napi);
57}
58
59#endif /* !_CAN_RX_OFFLOAD_H */