aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/can
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/can')
-rw-r--r--include/linux/can/core.h4
-rw-r--r--include/linux/can/dev.h35
-rw-r--r--include/linux/can/error.h4
-rw-r--r--include/linux/can/raw.h3
4 files changed, 32 insertions, 14 deletions
diff --git a/include/linux/can/core.h b/include/linux/can/core.h
index 0ccc1cd28b95..78c6c52073ad 100644
--- a/include/linux/can/core.h
+++ b/include/linux/can/core.h
@@ -17,10 +17,10 @@
17#include <linux/skbuff.h> 17#include <linux/skbuff.h>
18#include <linux/netdevice.h> 18#include <linux/netdevice.h>
19 19
20#define CAN_VERSION "20090105" 20#define CAN_VERSION "20120528"
21 21
22/* increment this number each time you change some user-space interface */ 22/* increment this number each time you change some user-space interface */
23#define CAN_ABI_VERSION "8" 23#define CAN_ABI_VERSION "9"
24 24
25#define CAN_VERSION_STRING "rev " CAN_VERSION " abi " CAN_ABI_VERSION 25#define CAN_VERSION_STRING "rev " CAN_VERSION " abi " CAN_ABI_VERSION
26 26
diff --git a/include/linux/can/dev.h b/include/linux/can/dev.h
index 5d2efe7e3f1b..2b2fc345afca 100644
--- a/include/linux/can/dev.h
+++ b/include/linux/can/dev.h
@@ -33,7 +33,7 @@ struct can_priv {
33 struct can_device_stats can_stats; 33 struct can_device_stats can_stats;
34 34
35 struct can_bittiming bittiming; 35 struct can_bittiming bittiming;
36 struct can_bittiming_const *bittiming_const; 36 const struct can_bittiming_const *bittiming_const;
37 struct can_clock clock; 37 struct can_clock clock;
38 38
39 enum can_state state; 39 enum can_state state;
@@ -61,23 +61,40 @@ struct can_priv {
61 * To be used in the CAN netdriver receive path to ensure conformance with 61 * To be used in the CAN netdriver receive path to ensure conformance with
62 * ISO 11898-1 Chapter 8.4.2.3 (DLC field) 62 * ISO 11898-1 Chapter 8.4.2.3 (DLC field)
63 */ 63 */
64#define get_can_dlc(i) (min_t(__u8, (i), 8)) 64#define get_can_dlc(i) (min_t(__u8, (i), CAN_MAX_DLC))
65#define get_canfd_dlc(i) (min_t(__u8, (i), CANFD_MAX_DLC))
65 66
66/* Drop a given socketbuffer if it does not contain a valid CAN frame. */ 67/* Drop a given socketbuffer if it does not contain a valid CAN frame. */
67static inline int can_dropped_invalid_skb(struct net_device *dev, 68static inline int can_dropped_invalid_skb(struct net_device *dev,
68 struct sk_buff *skb) 69 struct sk_buff *skb)
69{ 70{
70 const struct can_frame *cf = (struct can_frame *)skb->data; 71 const struct canfd_frame *cfd = (struct canfd_frame *)skb->data;
71 72
72 if (unlikely(skb->len != sizeof(*cf) || cf->can_dlc > 8)) { 73 if (skb->protocol == htons(ETH_P_CAN)) {
73 kfree_skb(skb); 74 if (unlikely(skb->len != CAN_MTU ||
74 dev->stats.tx_dropped++; 75 cfd->len > CAN_MAX_DLEN))
75 return 1; 76 goto inval_skb;
76 } 77 } else if (skb->protocol == htons(ETH_P_CANFD)) {
78 if (unlikely(skb->len != CANFD_MTU ||
79 cfd->len > CANFD_MAX_DLEN))
80 goto inval_skb;
81 } else
82 goto inval_skb;
77 83
78 return 0; 84 return 0;
85
86inval_skb:
87 kfree_skb(skb);
88 dev->stats.tx_dropped++;
89 return 1;
79} 90}
80 91
92/* get data length from can_dlc with sanitized can_dlc */
93u8 can_dlc2len(u8 can_dlc);
94
95/* map the sanitized data length to an appropriate data length code */
96u8 can_len2dlc(u8 len);
97
81struct net_device *alloc_candev(int sizeof_priv, unsigned int echo_skb_max); 98struct net_device *alloc_candev(int sizeof_priv, unsigned int echo_skb_max);
82void free_candev(struct net_device *dev); 99void free_candev(struct net_device *dev);
83 100
diff --git a/include/linux/can/error.h b/include/linux/can/error.h
index 63e855ea6b84..7b7148bded71 100644
--- a/include/linux/can/error.h
+++ b/include/linux/can/error.h
@@ -1,7 +1,7 @@
1/* 1/*
2 * linux/can/error.h 2 * linux/can/error.h
3 * 3 *
4 * Definitions of the CAN error frame to be filtered and passed to the user. 4 * Definitions of the CAN error messages to be filtered and passed to the user.
5 * 5 *
6 * Author: Oliver Hartkopp <oliver.hartkopp@volkswagen.de> 6 * Author: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
7 * Copyright (c) 2002-2007 Volkswagen Group Electronic Research 7 * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
@@ -12,7 +12,7 @@
12#ifndef CAN_ERROR_H 12#ifndef CAN_ERROR_H
13#define CAN_ERROR_H 13#define CAN_ERROR_H
14 14
15#define CAN_ERR_DLC 8 /* dlc for error frames */ 15#define CAN_ERR_DLC 8 /* dlc for error message frames */
16 16
17/* error class (mask) in can_id */ 17/* error class (mask) in can_id */
18#define CAN_ERR_TX_TIMEOUT 0x00000001U /* TX timeout (by netdevice driver) */ 18#define CAN_ERR_TX_TIMEOUT 0x00000001U /* TX timeout (by netdevice driver) */
diff --git a/include/linux/can/raw.h b/include/linux/can/raw.h
index 781f3a3701be..a814062b0719 100644
--- a/include/linux/can/raw.h
+++ b/include/linux/can/raw.h
@@ -23,7 +23,8 @@ enum {
23 CAN_RAW_FILTER = 1, /* set 0 .. n can_filter(s) */ 23 CAN_RAW_FILTER = 1, /* set 0 .. n can_filter(s) */
24 CAN_RAW_ERR_FILTER, /* set filter for error frames */ 24 CAN_RAW_ERR_FILTER, /* set filter for error frames */
25 CAN_RAW_LOOPBACK, /* local loopback (default:on) */ 25 CAN_RAW_LOOPBACK, /* local loopback (default:on) */
26 CAN_RAW_RECV_OWN_MSGS /* receive my own msgs (default:off) */ 26 CAN_RAW_RECV_OWN_MSGS, /* receive my own msgs (default:off) */
27 CAN_RAW_FD_FRAMES, /* allow CAN FD frames (default:off) */
27}; 28};
28 29
29#endif 30#endif