#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#

menu "SocketCAN Support"

config NET_CAN
	bool "SocketCAN support"
	default n
	select NET_READAHEAD
	depends on NET
	---help---
		Enable support for SocketCAN sockets.

		This requires a lower-half driver compatible with the SocketCAN
		API.

if NET_CAN

config NET_CAN_HAVE_TX_DEADLINE
	bool
	default n

config NET_CAN_HAVE_CANFD
	bool
	default n

config NET_CAN_HAVE_ERRORS
	bool
	default n

config CAN_PREALLOC_CONNS
	int "Preallocated CAN socket connections"
	default 4
	---help---
		Number of CAN connections (all tasks).

		This number of connections will be pre-allocated during system boot.
		If dynamic connections allocation is enabled, more connections may
		be allocated at a later time, as the system needs them. Else this
		will be the maximum number of connections available to the system
		at all times.

		Set to 0 to disable (and rely only on dynamic allocations).

config CAN_ALLOC_CONNS
	int "Dynamic CAN connections allocation"
	default 0
	---help---
		Dynamic memory allocations for CAN.

		When set to 0 all dynamic allocations are disabled.

		When set to 1 a new connection will be allocated every time,
		and it will be free'd when no longer needed.

		Setting this to 2 or more will allocate the connections in
		batches (with batch size equal to this config). When a
		connection is no longer needed, it will be returned to the
		free connections pool, and it will never be deallocated!

config CAN_MAX_CONNS
	int "Maximum number of CAN connections"
	default 0
	depends on CAN_ALLOC_CONNS > 0
	---help---
		If dynamic connections allocation is selected (CAN_ALLOC_CONNS > 0)
		this will limit the number of connections that can be allocated.

		This is useful in case the system is under very heavy load (or
		under attack), ensuring that the heap will not be exhausted.

config NET_CAN_EXTID
	bool "Enable CAN extended IDs"
	default n
	---help---
		Enables support for the 29-bit extended ID in SocketCAN stack.
		Default Standard 11-bit IDs.

config NET_CAN_CANFD
	bool "Enable CAN FD support"
	default y
	depends on NET_CAN_HAVE_CANFD
	---help---
		Enable CAN FD support in SocketCAN stack

config NET_CAN_ERRORS
	bool "Enable CAN errors support"
	default n
	depends on NET_CAN_HAVE_ERRORS
	---help---
		Enable CAN errors support in SocketCAN stack

config NET_CAN_SOCK_OPTS
	bool "sockopt support"
	default n
	select NET_SOCKOPTS
	select NET_CANPROTO_OPTIONS
	---help---
		Enable support for the CAN socket options

config NET_CAN_RAW_TX_DEADLINE
	bool "TX deadline sockopt"
	default n
	depends on NET_CAN_SOCK_OPTS && NET_CAN_HAVE_TX_DEADLINE
	---help---
		Note: Non-standard SocketCAN sockopt, but this options helps us in
		real-time use cases.

		When the CAN_RAW_TX_DEADLINE sockopt is enabled. The user can send
		CAN frames using sendmsg() function and add a deadline timespec
		value in the CMSG data. When the deadline has been passed and the
		CAN frame is still in the HW TX mailbox then the CAN driver will
		discard the CAN frame automatically.

config NET_CAN_RAW_DEFAULT_TX_DEADLINE
	int "Default TX deadline when no deadline is given (us)"
	default 0
	depends on NET_CAN_RAW_TX_DEADLINE
	---help---
		Some applications may not use the NET_CAN_RAW_TX_DEADLINE flag.
		By default their deadline becomes 0 which means it becomes infinite.
		This would mean that packets from applications without the
		NET_CAN_RAW_TX_DEADLINE flag, can block the TX mailboxes forever.
		This config can set the default deadline when no deadline has been
		given.

config NET_CAN_RAW_FILTER_MAX
	int "CAN_RAW_FILTER max filter count"
	default 32
	depends on NET_CANPROTO_OPTIONS
	---help---
		Maximum number of CAN_RAW filters that can be set per CAN connection.

config NET_CAN_NOTIFIER
	bool "Support CAN notifications"
	default n
	depends on SCHED_WORKQUEUE
	select WQUEUE_NOTIFIER
	---help---
		Enable building of CAN notifier logic that will execute a worker
		function on the low priority work queue when read-ahead data
		is available or when a CAN connection is lost.  This is is a general
		purpose notifier, but was developed specifically to support poll()
		logic where the poll must wait for these events.

endif # NET_CAN
endmenu # CAN Socket Support
