~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/uapi/linux/can/gw.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /include/uapi/linux/can/gw.h (Architecture sparc) and /include/uapi/linux/can/gw.h (Architecture m68k)


  1 /* SPDX-License-Identifier: ((GPL-2.0-only WIT      1 /* SPDX-License-Identifier: ((GPL-2.0-only WITH Linux-syscall-note) OR BSD-3-Clause) */
  2 /*                                                  2 /*
  3  * linux/can/gw.h                                   3  * linux/can/gw.h
  4  *                                                  4  *
  5  * Definitions for CAN frame Gateway/Router/Br      5  * Definitions for CAN frame Gateway/Router/Bridge
  6  *                                                  6  *
  7  * Author: Oliver Hartkopp <oliver.hartkopp@vo      7  * Author: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
  8  * Copyright (c) 2011 Volkswagen Group Electro      8  * Copyright (c) 2011 Volkswagen Group Electronic Research
  9  * All rights reserved.                             9  * All rights reserved.
 10  *                                                 10  *
 11  * Redistribution and use in source and binary     11  * Redistribution and use in source and binary forms, with or without
 12  * modification, are permitted provided that t     12  * modification, are permitted provided that the following conditions
 13  * are met:                                        13  * are met:
 14  * 1. Redistributions of source code must reta     14  * 1. Redistributions of source code must retain the above copyright
 15  *    notice, this list of conditions and the      15  *    notice, this list of conditions and the following disclaimer.
 16  * 2. Redistributions in binary form must repr     16  * 2. Redistributions in binary form must reproduce the above copyright
 17  *    notice, this list of conditions and the      17  *    notice, this list of conditions and the following disclaimer in the
 18  *    documentation and/or other materials pro     18  *    documentation and/or other materials provided with the distribution.
 19  * 3. Neither the name of Volkswagen nor the n     19  * 3. Neither the name of Volkswagen nor the names of its contributors
 20  *    may be used to endorse or promote produc     20  *    may be used to endorse or promote products derived from this software
 21  *    without specific prior written permissio     21  *    without specific prior written permission.
 22  *                                                 22  *
 23  * Alternatively, provided that this notice is     23  * Alternatively, provided that this notice is retained in full, this
 24  * software may be distributed under the terms     24  * software may be distributed under the terms of the GNU General
 25  * Public License ("GPL") version 2, in which      25  * Public License ("GPL") version 2, in which case the provisions of the
 26  * GPL apply INSTEAD OF those given above.         26  * GPL apply INSTEAD OF those given above.
 27  *                                                 27  *
 28  * The provided data structures and external i     28  * The provided data structures and external interfaces from this code
 29  * are not restricted to be used by modules wi     29  * are not restricted to be used by modules with a GPL compatible license.
 30  *                                                 30  *
 31  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT      31  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 32  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTI     32  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 33  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCH     33  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 34  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO      34  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 35  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIR     35  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 36  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGE     36  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 37  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS     37  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 38  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION)     38  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 39  * THEORY OF LIABILITY, WHETHER IN CONTRACT, S     39  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 40  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING     40  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 41  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE PO     41  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
 42  * DAMAGE.                                         42  * DAMAGE.
 43  */                                                43  */
 44                                                    44 
 45 #ifndef _UAPI_CAN_GW_H                             45 #ifndef _UAPI_CAN_GW_H
 46 #define _UAPI_CAN_GW_H                             46 #define _UAPI_CAN_GW_H
 47                                                    47 
 48 #include <linux/types.h>                           48 #include <linux/types.h>
 49 #include <linux/can.h>                             49 #include <linux/can.h>
 50                                                    50 
 51 struct rtcanmsg {                                  51 struct rtcanmsg {
 52         __u8  can_family;                          52         __u8  can_family;
 53         __u8  gwtype;                              53         __u8  gwtype;
 54         __u16 flags;                               54         __u16 flags;
 55 };                                                 55 };
 56                                                    56 
 57 /* CAN gateway types */                            57 /* CAN gateway types */
 58 enum {                                             58 enum {
 59         CGW_TYPE_UNSPEC,                           59         CGW_TYPE_UNSPEC,
 60         CGW_TYPE_CAN_CAN,       /* CAN->CAN ro     60         CGW_TYPE_CAN_CAN,       /* CAN->CAN routing */
 61         __CGW_TYPE_MAX                             61         __CGW_TYPE_MAX
 62 };                                                 62 };
 63                                                    63 
 64 #define CGW_TYPE_MAX (__CGW_TYPE_MAX - 1)          64 #define CGW_TYPE_MAX (__CGW_TYPE_MAX - 1)
 65                                                    65 
 66 /* CAN rtnetlink attribute definitions */          66 /* CAN rtnetlink attribute definitions */
 67 enum {                                             67 enum {
 68         CGW_UNSPEC,                                68         CGW_UNSPEC,
 69         CGW_MOD_AND,    /* CAN frame modificat     69         CGW_MOD_AND,    /* CAN frame modification binary AND */
 70         CGW_MOD_OR,     /* CAN frame modificat     70         CGW_MOD_OR,     /* CAN frame modification binary OR */
 71         CGW_MOD_XOR,    /* CAN frame modificat     71         CGW_MOD_XOR,    /* CAN frame modification binary XOR */
 72         CGW_MOD_SET,    /* CAN frame modificat     72         CGW_MOD_SET,    /* CAN frame modification set alternate values */
 73         CGW_CS_XOR,     /* set data[] XOR chec     73         CGW_CS_XOR,     /* set data[] XOR checksum into data[index] */
 74         CGW_CS_CRC8,    /* set data[] CRC8 che     74         CGW_CS_CRC8,    /* set data[] CRC8 checksum into data[index] */
 75         CGW_HANDLED,    /* number of handled C     75         CGW_HANDLED,    /* number of handled CAN frames */
 76         CGW_DROPPED,    /* number of dropped C     76         CGW_DROPPED,    /* number of dropped CAN frames */
 77         CGW_SRC_IF,     /* ifindex of source n     77         CGW_SRC_IF,     /* ifindex of source network interface */
 78         CGW_DST_IF,     /* ifindex of destinat     78         CGW_DST_IF,     /* ifindex of destination network interface */
 79         CGW_FILTER,     /* specify struct can_     79         CGW_FILTER,     /* specify struct can_filter on source CAN device */
 80         CGW_DELETED,    /* number of deleted C     80         CGW_DELETED,    /* number of deleted CAN frames (see max_hops param) */
 81         CGW_LIM_HOPS,   /* limit the number of     81         CGW_LIM_HOPS,   /* limit the number of hops of this specific rule */
 82         CGW_MOD_UID,    /* user defined identi     82         CGW_MOD_UID,    /* user defined identifier for modification updates */
 83         CGW_FDMOD_AND,  /* CAN FD frame modifi     83         CGW_FDMOD_AND,  /* CAN FD frame modification binary AND */
 84         CGW_FDMOD_OR,   /* CAN FD frame modifi     84         CGW_FDMOD_OR,   /* CAN FD frame modification binary OR */
 85         CGW_FDMOD_XOR,  /* CAN FD frame modifi     85         CGW_FDMOD_XOR,  /* CAN FD frame modification binary XOR */
 86         CGW_FDMOD_SET,  /* CAN FD frame modifi     86         CGW_FDMOD_SET,  /* CAN FD frame modification set alternate values */
 87         __CGW_MAX                                  87         __CGW_MAX
 88 };                                                 88 };
 89                                                    89 
 90 #define CGW_MAX (__CGW_MAX - 1)                    90 #define CGW_MAX (__CGW_MAX - 1)
 91                                                    91 
 92 #define CGW_FLAGS_CAN_ECHO 0x01                    92 #define CGW_FLAGS_CAN_ECHO 0x01
 93 #define CGW_FLAGS_CAN_SRC_TSTAMP 0x02              93 #define CGW_FLAGS_CAN_SRC_TSTAMP 0x02
 94 #define CGW_FLAGS_CAN_IIF_TX_OK 0x04               94 #define CGW_FLAGS_CAN_IIF_TX_OK 0x04
 95 #define CGW_FLAGS_CAN_FD 0x08                      95 #define CGW_FLAGS_CAN_FD 0x08
 96                                                    96 
 97 #define CGW_MOD_FUNCS 4 /* AND OR XOR SET */       97 #define CGW_MOD_FUNCS 4 /* AND OR XOR SET */
 98                                                    98 
 99 /* CAN frame elements that are affected by cur     99 /* CAN frame elements that are affected by curr. 3 CAN frame modifications */
100 #define CGW_MOD_ID      0x01                      100 #define CGW_MOD_ID      0x01
101 #define CGW_MOD_DLC     0x02            /* Cla    101 #define CGW_MOD_DLC     0x02            /* Classical CAN data length code */
102 #define CGW_MOD_LEN     CGW_MOD_DLC     /* CAN    102 #define CGW_MOD_LEN     CGW_MOD_DLC     /* CAN FD (plain) data length */
103 #define CGW_MOD_DATA    0x04                      103 #define CGW_MOD_DATA    0x04
104 #define CGW_MOD_FLAGS   0x08            /* CAN    104 #define CGW_MOD_FLAGS   0x08            /* CAN FD flags */
105                                                   105 
106 #define CGW_FRAME_MODS 4 /* ID DLC/LEN DATA FL    106 #define CGW_FRAME_MODS 4 /* ID DLC/LEN DATA FLAGS */
107                                                   107 
108 #define MAX_MODFUNCTIONS (CGW_MOD_FUNCS * CGW_    108 #define MAX_MODFUNCTIONS (CGW_MOD_FUNCS * CGW_FRAME_MODS)
109                                                   109 
110 struct cgw_frame_mod {                            110 struct cgw_frame_mod {
111         struct can_frame cf;                      111         struct can_frame cf;
112         __u8 modtype;                             112         __u8 modtype;
113 } __attribute__((packed));                        113 } __attribute__((packed));
114                                                   114 
115 struct cgw_fdframe_mod {                          115 struct cgw_fdframe_mod {
116         struct canfd_frame cf;                    116         struct canfd_frame cf;
117         __u8 modtype;                             117         __u8 modtype;
118 } __attribute__((packed));                        118 } __attribute__((packed));
119                                                   119 
120 #define CGW_MODATTR_LEN sizeof(struct cgw_fram    120 #define CGW_MODATTR_LEN sizeof(struct cgw_frame_mod)
121 #define CGW_FDMODATTR_LEN sizeof(struct cgw_fd    121 #define CGW_FDMODATTR_LEN sizeof(struct cgw_fdframe_mod)
122                                                   122 
123 struct cgw_csum_xor {                             123 struct cgw_csum_xor {
124         __s8 from_idx;                            124         __s8 from_idx;
125         __s8 to_idx;                              125         __s8 to_idx;
126         __s8 result_idx;                          126         __s8 result_idx;
127         __u8 init_xor_val;                        127         __u8 init_xor_val;
128 } __attribute__((packed));                        128 } __attribute__((packed));
129                                                   129 
130 struct cgw_csum_crc8 {                            130 struct cgw_csum_crc8 {
131         __s8 from_idx;                            131         __s8 from_idx;
132         __s8 to_idx;                              132         __s8 to_idx;
133         __s8 result_idx;                          133         __s8 result_idx;
134         __u8 init_crc_val;                        134         __u8 init_crc_val;
135         __u8 final_xor_val;                       135         __u8 final_xor_val;
136         __u8 crctab[256];                         136         __u8 crctab[256];
137         __u8 profile;                             137         __u8 profile;
138         __u8 profile_data[20];                    138         __u8 profile_data[20];
139 } __attribute__((packed));                        139 } __attribute__((packed));
140                                                   140 
141 /* length of checksum operation parameters. id    141 /* length of checksum operation parameters. idx = index in CAN frame data[] */
142 #define CGW_CS_XOR_LEN  sizeof(struct cgw_csum    142 #define CGW_CS_XOR_LEN  sizeof(struct cgw_csum_xor)
143 #define CGW_CS_CRC8_LEN  sizeof(struct cgw_csu    143 #define CGW_CS_CRC8_LEN  sizeof(struct cgw_csum_crc8)
144                                                   144 
145 /* CRC8 profiles (compute CRC for additional d    145 /* CRC8 profiles (compute CRC for additional data elements - see below) */
146 enum {                                            146 enum {
147         CGW_CRC8PRF_UNSPEC,                       147         CGW_CRC8PRF_UNSPEC,
148         CGW_CRC8PRF_1U8,        /* compute one    148         CGW_CRC8PRF_1U8,        /* compute one additional u8 value */
149         CGW_CRC8PRF_16U8,       /* u8 value ta    149         CGW_CRC8PRF_16U8,       /* u8 value table indexed by data[1] & 0xF */
150         CGW_CRC8PRF_SFFID_XOR,  /* (can_id & 0    150         CGW_CRC8PRF_SFFID_XOR,  /* (can_id & 0xFF) ^ (can_id >> 8 & 0xFF) */
151         __CGW_CRC8PRF_MAX                         151         __CGW_CRC8PRF_MAX
152 };                                                152 };
153                                                   153 
154 #define CGW_CRC8PRF_MAX (__CGW_CRC8PRF_MAX - 1    154 #define CGW_CRC8PRF_MAX (__CGW_CRC8PRF_MAX - 1)
155                                                   155 
156 /*                                                156 /*
157  * CAN rtnetlink attribute contents in detail     157  * CAN rtnetlink attribute contents in detail
158  *                                                158  *
159  * CGW_XXX_IF (length 4 bytes):                   159  * CGW_XXX_IF (length 4 bytes):
160  * Sets an interface index for source/destinat    160  * Sets an interface index for source/destination network interfaces.
161  * For the CAN->CAN gwtype the indices of _two    161  * For the CAN->CAN gwtype the indices of _two_ CAN interfaces are mandatory.
162  *                                                162  *
163  * CGW_FILTER (length 8 bytes):                   163  * CGW_FILTER (length 8 bytes):
164  * Sets a CAN receive filter for the gateway j    164  * Sets a CAN receive filter for the gateway job specified by the
165  * struct can_filter described in include/linu    165  * struct can_filter described in include/linux/can.h
166  *                                                166  *
167  * CGW_MOD_(AND|OR|XOR|SET) (length 17 bytes):    167  * CGW_MOD_(AND|OR|XOR|SET) (length 17 bytes):
168  * Specifies a modification that's done to a r    168  * Specifies a modification that's done to a received CAN frame before it is
169  * send out to the destination interface.         169  * send out to the destination interface.
170  *                                                170  *
171  * <struct can_frame> data used as operator       171  * <struct can_frame> data used as operator
172  * <u8> affected CAN frame elements               172  * <u8> affected CAN frame elements
173  *                                                173  *
174  * CGW_LIM_HOPS (length 1 byte):                  174  * CGW_LIM_HOPS (length 1 byte):
175  * Limit the number of hops of this specific r    175  * Limit the number of hops of this specific rule. Usually the received CAN
176  * frame can be processed as much as 'max_hops    176  * frame can be processed as much as 'max_hops' times (which is given at module
177  * load time of the can-gw module). This value    177  * load time of the can-gw module). This value is used to reduce the number of
178  * possible hops for this gateway rule to a va    178  * possible hops for this gateway rule to a value smaller then max_hops.
179  *                                                179  *
180  * CGW_MOD_UID (length 4 bytes):                  180  * CGW_MOD_UID (length 4 bytes):
181  * Optional non-zero user defined routing job     181  * Optional non-zero user defined routing job identifier to alter existing
182  * modification settings at runtime.              182  * modification settings at runtime.
183  *                                                183  *
184  * CGW_CS_XOR (length 4 bytes):                   184  * CGW_CS_XOR (length 4 bytes):
185  * Set a simple XOR checksum starting with an     185  * Set a simple XOR checksum starting with an initial value into
186  * data[result-idx] using data[start-idx] .. d    186  * data[result-idx] using data[start-idx] .. data[end-idx]
187  *                                                187  *
188  * The XOR checksum is calculated like this:      188  * The XOR checksum is calculated like this:
189  *                                                189  *
190  * xor = init_xor_val                             190  * xor = init_xor_val
191  *                                                191  *
192  * for (i = from_idx .. to_idx)                   192  * for (i = from_idx .. to_idx)
193  *      xor ^= can_frame.data[i]                  193  *      xor ^= can_frame.data[i]
194  *                                                194  *
195  * can_frame.data[ result_idx ] = xor             195  * can_frame.data[ result_idx ] = xor
196  *                                                196  *
197  * CGW_CS_CRC8 (length 282 bytes):                197  * CGW_CS_CRC8 (length 282 bytes):
198  * Set a CRC8 value into data[result-idx] usin    198  * Set a CRC8 value into data[result-idx] using a given 256 byte CRC8 table,
199  * a given initial value and a defined input d    199  * a given initial value and a defined input data[start-idx] .. data[end-idx].
200  * Finally the result value is XOR'ed with the    200  * Finally the result value is XOR'ed with the final_xor_val.
201  *                                                201  *
202  * The CRC8 checksum is calculated like this:     202  * The CRC8 checksum is calculated like this:
203  *                                                203  *
204  * crc = init_crc_val                             204  * crc = init_crc_val
205  *                                                205  *
206  * for (i = from_idx .. to_idx)                   206  * for (i = from_idx .. to_idx)
207  *      crc = crctab[ crc ^ can_frame.data[i]     207  *      crc = crctab[ crc ^ can_frame.data[i] ]
208  *                                                208  *
209  * can_frame.data[ result_idx ] = crc ^ final_    209  * can_frame.data[ result_idx ] = crc ^ final_xor_val
210  *                                                210  *
211  * The calculated CRC may contain additional s    211  * The calculated CRC may contain additional source data elements that can be
212  * defined in the handling of 'checksum profil    212  * defined in the handling of 'checksum profiles' e.g. shown in AUTOSAR specs
213  * like http://www.autosar.org/download/R4.0/A    213  * like http://www.autosar.org/download/R4.0/AUTOSAR_SWS_E2ELibrary.pdf
214  * E.g. the profile_data[] may contain additio    214  * E.g. the profile_data[] may contain additional u8 values (called DATA_IDs)
215  * that are used depending on counter values i    215  * that are used depending on counter values inside the CAN frame data[].
216  * So far only three profiles have been implem    216  * So far only three profiles have been implemented for illustration.
217  *                                                217  *
218  * Remark: In general the attribute data is a     218  * Remark: In general the attribute data is a linear buffer.
219  *         Beware of sending unpacked or align    219  *         Beware of sending unpacked or aligned structs!
220  */                                               220  */
221                                                   221 
222 #endif /* !_UAPI_CAN_GW_H */                      222 #endif /* !_UAPI_CAN_GW_H */
223                                                   223 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php