Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) */
0002 /* Copyright (c) 2002-2007 Volkswagen Group Electronic Research
0003  * Copyright (c) 2017 Pengutronix, Marc Kleine-Budde <kernel@pengutronix.de>
0004  *
0005  * All rights reserved.
0006  *
0007  * Redistribution and use in source and binary forms, with or without
0008  * modification, are permitted provided that the following conditions
0009  * are met:
0010  * 1. Redistributions of source code must retain the above copyright
0011  *    notice, this list of conditions and the following disclaimer.
0012  * 2. Redistributions in binary form must reproduce the above copyright
0013  *    notice, this list of conditions and the following disclaimer in the
0014  *    documentation and/or other materials provided with the distribution.
0015  * 3. Neither the name of Volkswagen nor the names of its contributors
0016  *    may be used to endorse or promote products derived from this software
0017  *    without specific prior written permission.
0018  *
0019  * Alternatively, provided that this notice is retained in full, this
0020  * software may be distributed under the terms of the GNU General
0021  * Public License ("GPL") version 2, in which case the provisions of the
0022  * GPL apply INSTEAD OF those given above.
0023  *
0024  * The provided data structures and external interfaces from this code
0025  * are not restricted to be used by modules with a GPL compatible license.
0026  *
0027  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
0028  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
0029  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
0030  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
0031  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
0032  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
0033  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
0034  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
0035  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
0036  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
0037  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
0038  * DAMAGE.
0039  *
0040  */
0041 
0042 #ifndef CAN_ML_H
0043 #define CAN_ML_H
0044 
0045 #include <linux/can.h>
0046 #include <linux/list.h>
0047 #include <linux/netdevice.h>
0048 
0049 #define CAN_SFF_RCV_ARRAY_SZ (1 << CAN_SFF_ID_BITS)
0050 #define CAN_EFF_RCV_HASH_BITS 10
0051 #define CAN_EFF_RCV_ARRAY_SZ (1 << CAN_EFF_RCV_HASH_BITS)
0052 
0053 enum { RX_ERR, RX_ALL, RX_FIL, RX_INV, RX_MAX };
0054 
0055 struct can_dev_rcv_lists {
0056     struct hlist_head rx[RX_MAX];
0057     struct hlist_head rx_sff[CAN_SFF_RCV_ARRAY_SZ];
0058     struct hlist_head rx_eff[CAN_EFF_RCV_ARRAY_SZ];
0059     int entries;
0060 };
0061 
0062 struct can_ml_priv {
0063     struct can_dev_rcv_lists dev_rcv_lists;
0064 #ifdef CAN_J1939
0065     struct j1939_priv *j1939_priv;
0066 #endif
0067 };
0068 
0069 static inline struct can_ml_priv *can_get_ml_priv(struct net_device *dev)
0070 {
0071     return netdev_get_ml_priv(dev, ML_PRIV_CAN);
0072 }
0073 
0074 static inline void can_set_ml_priv(struct net_device *dev,
0075                    struct can_ml_priv *ml_priv)
0076 {
0077     netdev_set_ml_priv(dev, ml_priv, ML_PRIV_CAN);
0078 }
0079 
0080 #endif /* CAN_ML_H */