blob: fca0fe9fc45a497cdf3da82d5414e846e7cc61b7 [file] [log] [blame]
Oliver Hartkopp0d665482007-11-16 15:52:17 -08001/*
2 * Copyright (c) 2002-2007 Volkswagen Group Electronic Research
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. Neither the name of Volkswagen nor the names of its contributors
14 * may be used to endorse or promote products derived from this software
15 * without specific prior written permission.
16 *
17 * Alternatively, provided that this notice is retained in full, this
18 * software may be distributed under the terms of the GNU General
19 * Public License ("GPL") version 2, in which case the provisions of the
20 * GPL apply INSTEAD OF those given above.
21 *
22 * The provided data structures and external interfaces from this code
23 * are not restricted to be used by modules with a GPL compatible license.
24 *
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
30 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
31 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
34 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
35 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
36 * DAMAGE.
37 *
Oliver Hartkopp0d665482007-11-16 15:52:17 -080038 */
39
40#ifndef AF_CAN_H
41#define AF_CAN_H
42
43#include <linux/skbuff.h>
44#include <linux/netdevice.h>
45#include <linux/list.h>
46#include <linux/rcupdate.h>
47#include <linux/can.h>
48
49/* af_can rx dispatcher structures */
50
51struct receiver {
52 struct hlist_node list;
53 struct rcu_head rcu;
54 canid_t can_id;
55 canid_t mask;
56 unsigned long matches;
57 void (*func)(struct sk_buff *, void *);
58 void *data;
59 char *ident;
60};
61
Oliver Hartkoppe3d39172014-04-02 20:25:25 +020062#define CAN_SFF_RCV_ARRAY_SZ (1 << CAN_SFF_ID_BITS)
Oliver Hartkopp45c70022014-04-02 20:25:26 +020063#define CAN_EFF_RCV_HASH_BITS 10
64#define CAN_EFF_RCV_ARRAY_SZ (1 << CAN_EFF_RCV_HASH_BITS)
Oliver Hartkoppe3d39172014-04-02 20:25:25 +020065
Oliver Hartkopp45c70022014-04-02 20:25:26 +020066enum { RX_ERR, RX_ALL, RX_FIL, RX_INV, RX_MAX };
Oliver Hartkopp0d665482007-11-16 15:52:17 -080067
Oliver Hartkopp20dd3852009-12-25 06:47:47 +000068/* per device receive filters linked at dev->ml_priv */
Oliver Hartkopp0d665482007-11-16 15:52:17 -080069struct dev_rcv_lists {
Oliver Hartkopp0d665482007-11-16 15:52:17 -080070 struct hlist_head rx[RX_MAX];
Oliver Hartkoppe3d39172014-04-02 20:25:25 +020071 struct hlist_head rx_sff[CAN_SFF_RCV_ARRAY_SZ];
Oliver Hartkopp45c70022014-04-02 20:25:26 +020072 struct hlist_head rx_eff[CAN_EFF_RCV_ARRAY_SZ];
Oliver Hartkopp0d665482007-11-16 15:52:17 -080073 int remove_on_zero_entries;
74 int entries;
75};
76
77/* statistic structures */
78
79/* can be reset e.g. by can_init_stats() */
80struct s_stats {
81 unsigned long jiffies_init;
82
83 unsigned long rx_frames;
84 unsigned long tx_frames;
85 unsigned long matches;
86
87 unsigned long total_rx_rate;
88 unsigned long total_tx_rate;
89 unsigned long total_rx_match_ratio;
90
91 unsigned long current_rx_rate;
92 unsigned long current_tx_rate;
93 unsigned long current_rx_match_ratio;
94
95 unsigned long max_rx_rate;
96 unsigned long max_tx_rate;
97 unsigned long max_rx_match_ratio;
98
99 unsigned long rx_frames_delta;
100 unsigned long tx_frames_delta;
101 unsigned long matches_delta;
102};
103
104/* persistent statistics */
105struct s_pstats {
106 unsigned long stats_reset;
107 unsigned long user_reset;
108 unsigned long rcv_entries;
109 unsigned long rcv_entries_max;
110};
111
Oliver Hartkoppec00f042012-06-20 17:46:56 +0200112/* receive filters subscribed for 'all' CAN devices */
113extern struct dev_rcv_lists can_rx_alldev_list;
114
Oliver Hartkopp0d665482007-11-16 15:52:17 -0800115/* function prototypes for the CAN networklayer procfs (proc.c) */
Joe Perches348662a2013-10-18 13:48:22 -0700116void can_init_proc(void);
117void can_remove_proc(void);
118void can_stat_update(unsigned long data);
Oliver Hartkopp0d665482007-11-16 15:52:17 -0800119
120/* structures and variables from af_can.c needed in proc.c for reading */
121extern struct timer_list can_stattimer; /* timer for statistics update */
122extern struct s_stats can_stats; /* packet statistics */
123extern struct s_pstats can_pstats; /* receive list statistics */
124extern struct hlist_head can_rx_dev_list; /* rx dispatcher structures */
125
126#endif /* AF_CAN_H */