Oliver Hartkopp | fba76a5 | 2019-07-23 15:17:55 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */ |
Marc Kleine-Budde | 147d9e9 | 2019-07-24 14:16:29 +0200 | [diff] [blame] | 2 | /* Copyright (c) 2002-2007 Volkswagen Group Electronic Research |
Oliver Hartkopp | 0d66548 | 2007-11-16 15:52:17 -0800 | [diff] [blame] | 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 Hartkopp | 0d66548 | 2007-11-16 15:52:17 -0800 | [diff] [blame] | 38 | */ |
| 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 | |
| 51 | struct receiver { |
| 52 | struct hlist_node list; |
Oliver Hartkopp | 0d66548 | 2007-11-16 15:52:17 -0800 | [diff] [blame] | 53 | canid_t can_id; |
| 54 | canid_t mask; |
| 55 | unsigned long matches; |
Marc Kleine-Budde | 97c3349 | 2019-08-13 11:25:33 +0200 | [diff] [blame] | 56 | void (*func)(struct sk_buff *skb, void *data); |
Oliver Hartkopp | 0d66548 | 2007-11-16 15:52:17 -0800 | [diff] [blame] | 57 | void *data; |
| 58 | char *ident; |
Eric Dumazet | f1712c7 | 2017-01-27 08:11:44 -0800 | [diff] [blame] | 59 | struct sock *sk; |
| 60 | struct rcu_head rcu; |
Oliver Hartkopp | 0d66548 | 2007-11-16 15:52:17 -0800 | [diff] [blame] | 61 | }; |
| 62 | |
Oliver Hartkopp | 0d66548 | 2007-11-16 15:52:17 -0800 | [diff] [blame] | 63 | /* statistic structures */ |
| 64 | |
| 65 | /* can be reset e.g. by can_init_stats() */ |
Marc Kleine-Budde | 6c43bb3 | 2018-10-08 09:02:26 +0200 | [diff] [blame] | 66 | struct can_pkg_stats { |
Oliver Hartkopp | 0d66548 | 2007-11-16 15:52:17 -0800 | [diff] [blame] | 67 | unsigned long jiffies_init; |
| 68 | |
| 69 | unsigned long rx_frames; |
| 70 | unsigned long tx_frames; |
| 71 | unsigned long matches; |
| 72 | |
| 73 | unsigned long total_rx_rate; |
| 74 | unsigned long total_tx_rate; |
| 75 | unsigned long total_rx_match_ratio; |
| 76 | |
| 77 | unsigned long current_rx_rate; |
| 78 | unsigned long current_tx_rate; |
| 79 | unsigned long current_rx_match_ratio; |
| 80 | |
| 81 | unsigned long max_rx_rate; |
| 82 | unsigned long max_tx_rate; |
| 83 | unsigned long max_rx_match_ratio; |
| 84 | |
| 85 | unsigned long rx_frames_delta; |
| 86 | unsigned long tx_frames_delta; |
| 87 | unsigned long matches_delta; |
| 88 | }; |
| 89 | |
| 90 | /* persistent statistics */ |
Marc Kleine-Budde | 6c43bb3 | 2018-10-08 09:02:26 +0200 | [diff] [blame] | 91 | struct can_rcv_lists_stats { |
Oliver Hartkopp | 0d66548 | 2007-11-16 15:52:17 -0800 | [diff] [blame] | 92 | unsigned long stats_reset; |
| 93 | unsigned long user_reset; |
| 94 | unsigned long rcv_entries; |
| 95 | unsigned long rcv_entries_max; |
| 96 | }; |
| 97 | |
Oliver Hartkopp | 0d66548 | 2007-11-16 15:52:17 -0800 | [diff] [blame] | 98 | /* function prototypes for the CAN networklayer procfs (proc.c) */ |
Mario Kicherer | 8e8cda6 | 2017-02-21 12:19:47 +0100 | [diff] [blame] | 99 | void can_init_proc(struct net *net); |
| 100 | void can_remove_proc(struct net *net); |
Kees Cook | 1fccb56 | 2017-10-16 17:29:06 -0700 | [diff] [blame] | 101 | void can_stat_update(struct timer_list *t); |
Oliver Hartkopp | 0d66548 | 2007-11-16 15:52:17 -0800 | [diff] [blame] | 102 | |
Oliver Hartkopp | 0d66548 | 2007-11-16 15:52:17 -0800 | [diff] [blame] | 103 | #endif /* AF_CAN_H */ |