aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/can/dev.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/can/dev.h')
-rw-r--r--include/linux/can/dev.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h
index 3db7767d2a17..cc0bb4961669 100644
--- a/include/linux/can/dev.h
+++ b/include/linux/can/dev.h
@@ -14,6 +14,7 @@
14#ifndef CAN_DEV_H 14#ifndef CAN_DEV_H
15#define CAN_DEV_H 15#define CAN_DEV_H
16 16
17#include <linux/can.h>
17#include <linux/can/netlink.h> 18#include <linux/can/netlink.h>
18#include <linux/can/error.h> 19#include <linux/can/error.h>
19 20
@@ -38,6 +39,7 @@ struct can_priv {
38 39
39 enum can_state state; 40 enum can_state state;
40 u32 ctrlmode; 41 u32 ctrlmode;
42 u32 ctrlmode_supported;
41 43
42 int restart_ms; 44 int restart_ms;
43 struct timer_list restart_timer; 45 struct timer_list restart_timer;
@@ -46,6 +48,8 @@ struct can_priv {
46 int (*do_set_mode)(struct net_device *dev, enum can_mode mode); 48 int (*do_set_mode)(struct net_device *dev, enum can_mode mode);
47 int (*do_get_state)(const struct net_device *dev, 49 int (*do_get_state)(const struct net_device *dev,
48 enum can_state *state); 50 enum can_state *state);
51 int (*do_get_berr_counter)(const struct net_device *dev,
52 struct can_berr_counter *bec);
49 53
50 unsigned int echo_skb_max; 54 unsigned int echo_skb_max;
51 struct sk_buff **echo_skb; 55 struct sk_buff **echo_skb;
@@ -60,6 +64,21 @@ struct can_priv {
60 */ 64 */
61#define get_can_dlc(i) (min_t(__u8, (i), 8)) 65#define get_can_dlc(i) (min_t(__u8, (i), 8))
62 66
67/* Drop a given socketbuffer if it does not contain a valid CAN frame. */
68static inline int can_dropped_invalid_skb(struct net_device *dev,
69 struct sk_buff *skb)
70{
71 const struct can_frame *cf = (struct can_frame *)skb->data;
72
73 if (unlikely(skb->len != sizeof(*cf) || cf->can_dlc > 8)) {
74 kfree_skb(skb);
75 dev->stats.tx_dropped++;
76 return 1;
77 }
78
79 return 0;
80}
81
63struct net_device *alloc_candev(int sizeof_priv, unsigned int echo_skb_max); 82struct net_device *alloc_candev(int sizeof_priv, unsigned int echo_skb_max);
64void free_candev(struct net_device *dev); 83void free_candev(struct net_device *dev);
65 84