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