^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /* Copyright (c) 2002-2007 Volkswagen Group Electronic Research
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Redistribution and use in source and binary forms, with or without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * modification, are permitted provided that the following conditions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) * are met:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * 1. Redistributions of source code must retain the above copyright
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * notice, this list of conditions and the following disclaimer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * 2. Redistributions in binary form must reproduce the above copyright
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * notice, this list of conditions and the following disclaimer in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * documentation and/or other materials provided with the distribution.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * 3. Neither the name of Volkswagen nor the names of its contributors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * may be used to endorse or promote products derived from this software
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * without specific prior written permission.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * Alternatively, provided that this notice is retained in full, this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * software may be distributed under the terms of the GNU General
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) * Public License ("GPL") version 2, in which case the provisions of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * GPL apply INSTEAD OF those given above.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * The provided data structures and external interfaces from this code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * are not restricted to be used by modules with a GPL compatible license.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) * DAMAGE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #ifndef AF_CAN_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #define AF_CAN_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #include <linux/skbuff.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #include <linux/netdevice.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) #include <linux/list.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #include <linux/rcupdate.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) #include <linux/can.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) /* af_can rx dispatcher structures */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) struct receiver {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) struct hlist_node list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) canid_t can_id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) canid_t mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) unsigned long matches;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) void (*func)(struct sk_buff *skb, void *data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) void *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) char *ident;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) struct sock *sk;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) struct rcu_head rcu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) /* statistic structures */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) /* can be reset e.g. by can_init_stats() */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) struct can_pkg_stats {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) unsigned long jiffies_init;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) unsigned long rx_frames;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) unsigned long tx_frames;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) unsigned long matches;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) unsigned long total_rx_rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) unsigned long total_tx_rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) unsigned long total_rx_match_ratio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) unsigned long current_rx_rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) unsigned long current_tx_rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) unsigned long current_rx_match_ratio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) unsigned long max_rx_rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) unsigned long max_tx_rate;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) unsigned long max_rx_match_ratio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) unsigned long rx_frames_delta;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) unsigned long tx_frames_delta;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) unsigned long matches_delta;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) /* persistent statistics */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) struct can_rcv_lists_stats {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) unsigned long stats_reset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) unsigned long user_reset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) unsigned long rcv_entries;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) unsigned long rcv_entries_max;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) /* function prototypes for the CAN networklayer procfs (proc.c) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) void can_init_proc(struct net *net);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) void can_remove_proc(struct net *net);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) void can_stat_update(struct timer_list *t);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) #endif /* AF_CAN_H */