1# ISO-TP configuration options
2
3# Copyright (c) 2019 Alexander Wachter
4# SPDX-License-Identifier: Apache-2.0
5
6menuconfig ISOTP
7	bool "ISO-TP Transport [EXPERIMENTAL]"
8	depends on CAN
9	select NET_BUF
10	select POLL
11	select EXPERIMENTAL
12	help
13	  Enable ISO TP support for CAN
14
15if ISOTP
16
17module = ISOTP
18module-str = ISOTP
19source "subsys/logging/Kconfig.template.log_config"
20
21config ISOTP_WFTMAX
22	int "WFTmax (Max WAIT frames before aborting)."
23	default 10
24	range 0 254
25	help
26	  This value defines the maximum number of WAIT frames before the transmission
27	  is aborted.
28
29config ISOTP_BS_TIMEOUT
30	int "Bs timeout [ms] (timeout for receiving the frame control)"
31	default 1000
32	range 200 10000
33	help
34	  Timeout for the reception of the next FC frame. ISO 15765-2: 1000ms
35
36config ISOTP_A_TIMEOUT
37	int "Ar and As timeout [ms] (sending and receiving timeout)"
38	default 1000
39	range 200 10000
40	help
41	  As (sender transmit timeout) and Ar (receiver transmit timeout).
42	  ISO 15765-2: 1000ms
43
44config ISOTP_CR_TIMEOUT
45	int "Cr timeout [ms] (timeout for consecutive frames)"
46	default 1000
47	range 200 10000
48	help
49	  Cr (receiver consecutive frame) timeout.
50	  ISO 15765-2: 1000ms
51
52config ISOTP_REQUIRE_RX_PADDING
53	bool "Require padding for received messages"
54	help
55	  If enabled, SFs, FCs and the last CF must always have a DLC of 8 bytes
56	  (for classic CAN) and unused bytes must be padded by the sending
57	  device. This setting allows to be compliant to AUTOSAR Specification
58	  of CAN Transport Layer.
59
60	  By default, received CAN frames with or without padding are accepted.
61
62config ISOTP_ENABLE_TX_PADDING
63	bool "Padding for transmitted messages"
64	default y if ISOTP_REQUIRE_RX_PADDING
65	help
66	  Add padding bytes 0xCC (as recommended by Bosch) if the PDU payload
67	  does not fit exactly into the CAN frame.
68
69config ISOTP_RX_BUF_COUNT
70	int "Number of data buffers for receiving data"
71	default 4
72	help
73	  Each data buffer will occupy ISOTP_RX_BUF_SIZE + smallish
74	  header (sizeof(struct net_buf)) amount of data.
75
76config ISOTP_RX_BUF_SIZE
77	int "Size of one buffer data block"
78	default 63 if CAN_FD_MODE
79	default 56
80	help
81	  This value defines the size of a single block in the pool. The number of
82	  blocks is given by ISOTP_RX_BUF_COUNT. To be efficient use a multiple of
83	  CAN_MAX_DLEN - 1 (for classic CAN : 8 - 1 = 7, for CAN FD : 64 - 1 = 63).
84
85config ISOTP_RX_SF_FF_BUF_COUNT
86	int "Number of SF and FF data buffers for receiving data"
87	default 4
88	help
89	  This buffer is used for first and single frames. It is extra because the
90	  buffer has to be ready for the first reception in isr context and therefor
91	  is allocated when binding.
92	  Each buffer will occupy CAN_MAX_DLEN - 1 byte + header (sizeof(struct net_buf))
93	  amount of data.
94
95config ISOTP_USE_TX_BUF
96	bool "Buffer tx writes"
97	help
98	  Copy the outgoing data to a net buffer so that the calling function
99	  can discard the data.
100
101if ISOTP_USE_TX_BUF
102
103config ISOTP_TX_BUF_COUNT
104	int "Number of data buffers for sending data"
105	default 4
106	help
107	  Each data buffer will occupy CONFIG_NET_BUF_DATA_SIZE + smallish
108	  header (sizeof(struct net_buf)) amount of data. If context buffers
109	  are used, use the same size here.
110
111config ISOTP_BUF_TX_DATA_POOL_SIZE
112	int "Size of the memory pool where buffers are allocated from"
113	default 256
114	help
115	  This value defines the size of the memory pool where the buffers
116	  for sending are allocated from.
117
118endif # ISOTP_USE_TX_BUF
119
120config ISOTP_ENABLE_CONTEXT_BUFFERS
121	bool "Buffered tx contexts"
122	default y
123	help
124	  This option enables buffered sending contexts. This makes send and
125	  forget possible. A memory slab is used to buffer the context.
126
127config ISOTP_TX_CONTEXT_BUF_COUNT
128	int "Amount of context buffers for sending data"
129	default 4
130	depends on ISOTP_ENABLE_CONTEXT_BUFFERS
131	help
132	  This defines the size of the memory slab where the buffers are
133	  allocated from.
134
135config ISOTP_CUSTOM_FIXED_ADDR
136	bool "Use fixed address not compatible with SAE J1939"
137	default n
138	help
139	  This option allow to use an alternative CAN frame id format.
140	  If not set ISO-TP fixed addressing use SAE J1939 standard.
141
142menu "Fixed address definition"
143	visible if ISOTP_CUSTOM_FIXED_ADDR
144
145config ISOTP_FIXED_ADDR_SA_POS
146	int "Position of fixed source address (SA)"
147	default 0
148	help
149	  Source address position in bits.
150
151config ISOTP_FIXED_ADDR_SA_MASK
152	hex "Mask to obtain fixed source address (SA)"
153	default 0xFF
154	help
155	  Source address mask.
156
157config ISOTP_FIXED_ADDR_TA_POS
158	int "Position of fixed target address (TA)"
159	default 8
160	help
161	  Target address position in bits.
162
163config ISOTP_FIXED_ADDR_TA_MASK
164	hex "Mask to obtain fixed target address (TA)"
165	default 0xFF00
166	help
167	  Target address mask.
168
169config ISOTP_FIXED_ADDR_PRIO_POS
170	int "Position of priority in fixed addressing mode"
171	default 26
172	help
173	  Priority address position in bits.
174
175config ISOTP_FIXED_ADDR_PRIO_MASK
176	hex "Mask for priority in fixed addressing mode"
177	default 0x1C000000
178	help
179	  Priority address mask.
180
181config ISOTP_FIXED_ADDR_RX_MASK
182	hex "CAN filter RX mask to match any priority and source address (SA)"
183	default 0x03FFFF00
184	help
185	  CAN filter RX mask
186
187endmenu
188
189endif # ISOTP
190