18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
28c2ecf20Sopenharmony_ci/* Copyright (c) 2002-2007 Volkswagen Group Electronic Research
38c2ecf20Sopenharmony_ci * All rights reserved.
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Redistribution and use in source and binary forms, with or without
68c2ecf20Sopenharmony_ci * modification, are permitted provided that the following conditions
78c2ecf20Sopenharmony_ci * are met:
88c2ecf20Sopenharmony_ci * 1. Redistributions of source code must retain the above copyright
98c2ecf20Sopenharmony_ci *    notice, this list of conditions and the following disclaimer.
108c2ecf20Sopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright
118c2ecf20Sopenharmony_ci *    notice, this list of conditions and the following disclaimer in the
128c2ecf20Sopenharmony_ci *    documentation and/or other materials provided with the distribution.
138c2ecf20Sopenharmony_ci * 3. Neither the name of Volkswagen nor the names of its contributors
148c2ecf20Sopenharmony_ci *    may be used to endorse or promote products derived from this software
158c2ecf20Sopenharmony_ci *    without specific prior written permission.
168c2ecf20Sopenharmony_ci *
178c2ecf20Sopenharmony_ci * Alternatively, provided that this notice is retained in full, this
188c2ecf20Sopenharmony_ci * software may be distributed under the terms of the GNU General
198c2ecf20Sopenharmony_ci * Public License ("GPL") version 2, in which case the provisions of the
208c2ecf20Sopenharmony_ci * GPL apply INSTEAD OF those given above.
218c2ecf20Sopenharmony_ci *
228c2ecf20Sopenharmony_ci * The provided data structures and external interfaces from this code
238c2ecf20Sopenharmony_ci * are not restricted to be used by modules with a GPL compatible license.
248c2ecf20Sopenharmony_ci *
258c2ecf20Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
268c2ecf20Sopenharmony_ci * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
278c2ecf20Sopenharmony_ci * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
288c2ecf20Sopenharmony_ci * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
298c2ecf20Sopenharmony_ci * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
308c2ecf20Sopenharmony_ci * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
318c2ecf20Sopenharmony_ci * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
328c2ecf20Sopenharmony_ci * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
338c2ecf20Sopenharmony_ci * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
348c2ecf20Sopenharmony_ci * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
358c2ecf20Sopenharmony_ci * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
368c2ecf20Sopenharmony_ci * DAMAGE.
378c2ecf20Sopenharmony_ci *
388c2ecf20Sopenharmony_ci */
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci#ifndef AF_CAN_H
418c2ecf20Sopenharmony_ci#define AF_CAN_H
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci#include <linux/skbuff.h>
448c2ecf20Sopenharmony_ci#include <linux/netdevice.h>
458c2ecf20Sopenharmony_ci#include <linux/list.h>
468c2ecf20Sopenharmony_ci#include <linux/rcupdate.h>
478c2ecf20Sopenharmony_ci#include <linux/can.h>
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ci/* af_can rx dispatcher structures */
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_cistruct receiver {
528c2ecf20Sopenharmony_ci	struct hlist_node list;
538c2ecf20Sopenharmony_ci	canid_t can_id;
548c2ecf20Sopenharmony_ci	canid_t mask;
558c2ecf20Sopenharmony_ci	unsigned long matches;
568c2ecf20Sopenharmony_ci	void (*func)(struct sk_buff *skb, void *data);
578c2ecf20Sopenharmony_ci	void *data;
588c2ecf20Sopenharmony_ci	char *ident;
598c2ecf20Sopenharmony_ci	struct sock *sk;
608c2ecf20Sopenharmony_ci	struct rcu_head rcu;
618c2ecf20Sopenharmony_ci};
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci/* statistic structures */
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci/* can be reset e.g. by can_init_stats() */
668c2ecf20Sopenharmony_cistruct can_pkg_stats {
678c2ecf20Sopenharmony_ci	unsigned long jiffies_init;
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ci	unsigned long rx_frames;
708c2ecf20Sopenharmony_ci	unsigned long tx_frames;
718c2ecf20Sopenharmony_ci	unsigned long matches;
728c2ecf20Sopenharmony_ci
738c2ecf20Sopenharmony_ci	unsigned long total_rx_rate;
748c2ecf20Sopenharmony_ci	unsigned long total_tx_rate;
758c2ecf20Sopenharmony_ci	unsigned long total_rx_match_ratio;
768c2ecf20Sopenharmony_ci
778c2ecf20Sopenharmony_ci	unsigned long current_rx_rate;
788c2ecf20Sopenharmony_ci	unsigned long current_tx_rate;
798c2ecf20Sopenharmony_ci	unsigned long current_rx_match_ratio;
808c2ecf20Sopenharmony_ci
818c2ecf20Sopenharmony_ci	unsigned long max_rx_rate;
828c2ecf20Sopenharmony_ci	unsigned long max_tx_rate;
838c2ecf20Sopenharmony_ci	unsigned long max_rx_match_ratio;
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci	unsigned long rx_frames_delta;
868c2ecf20Sopenharmony_ci	unsigned long tx_frames_delta;
878c2ecf20Sopenharmony_ci	unsigned long matches_delta;
888c2ecf20Sopenharmony_ci};
898c2ecf20Sopenharmony_ci
908c2ecf20Sopenharmony_ci/* persistent statistics */
918c2ecf20Sopenharmony_cistruct can_rcv_lists_stats {
928c2ecf20Sopenharmony_ci	unsigned long stats_reset;
938c2ecf20Sopenharmony_ci	unsigned long user_reset;
948c2ecf20Sopenharmony_ci	unsigned long rcv_entries;
958c2ecf20Sopenharmony_ci	unsigned long rcv_entries_max;
968c2ecf20Sopenharmony_ci};
978c2ecf20Sopenharmony_ci
988c2ecf20Sopenharmony_ci/* function prototypes for the CAN networklayer procfs (proc.c) */
998c2ecf20Sopenharmony_civoid can_init_proc(struct net *net);
1008c2ecf20Sopenharmony_civoid can_remove_proc(struct net *net);
1018c2ecf20Sopenharmony_civoid can_stat_update(struct timer_list *t);
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_ci#endif /* AF_CAN_H */
104