Commit Graph

40 Commits (a24bff8b08beebe8310cdea8cfa8600b05a4e4ca)

Author SHA1 Message Date
Oliver Hartkopp 99c5c14790 can.h: canxl: support Remote Request Substitution bit access
The Remote Request Substitution bit is a dominant bit ("0") in the CAN XL
frame. As some CAN XL controllers support to access this bit a new
CANXL_RRS value has been defined for the canxl_frame.flags element.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2025-01-24 14:22:21 +01:00
Oleksij Rempel 69c1e8289d add pr_err and pr_warn macros
This variant will be used in the j19393-timeday code.

Signed-off-by: Oleksij Rempel <linux@rempel-privat.de>
2024-05-30 09:40:23 +02:00
Oliver Hartkopp 8ba360ea31 include: update includes to Linux v6.9 upstream
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-02-14 20:18:29 +01:00
Oliver Hartkopp cfe41963f3 include: update includes to latest Linux v6.2 upstream
Update includes to support CAN XL and latest CAN netlink features.

Upstream commits:

(1a3e3034c049) "can: canxl: introduce CAN XL data structure"
(061834624c87) "can: set CANFD_FDF flag in all CAN FD frame structures"
(94dfc73e7cf4) "treewide: uapi: Replace zero-length arrays with flexible-array members"
(383f0993fc77) "can: netlink: report the CAN controller mode supported flags"
(d99755f71a80) "can: netlink: add interface for CAN-FD Transmitter Delay Compensation (TDC)"
(63dfe0709643) "can: bittiming: allow TDC{V,O} to be zero and add can_tdc_const::tdc{v,o,f}_min"
(626332696d75) "can: raw: add CAN XL support"

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2023-02-25 14:55:00 +01:00
Vincent Mailhol f3ce3efe66 include: update linux/can/error.h
Update the linux/can/error.h hearder to incorporate the changes made
in Linux 6.0.0. Namely:

  - commit 3e5c291c7942 ("can: add CAN_ERR_CNT flag to notify
    availability of error counter")
    Link: https://git.kernel.org/torvalds/linux/c/3e5c291c7942

  - commit 3f9c26210cf8 ("can: error: add definitions for the
    different CAN error thresholds")
    Link: https://git.kernel.org/torvalds/linux/c/3f9c26210cf8

Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Link: https://lore.kernel.org/all/20221114163848.3398-3-mailhol.vincent@wanadoo.fr
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2022-11-15 09:44:51 +01:00
Oliver Hartkopp 6e7f845a68 isotpsend: add support for transmission without flow control
Usually the ISO 15765-2 protocol is a point-to-point protocol to transfer
segmented PDUs to a dedicated receiver. This receiver sends a flow control
message to specify protocol options and timings (e.g. block size / STmin).

The so called functional addressing communication allows a 1:N
communication but is limited to a single frame length.

The new CAN_ISOTP_CF_BROADCAST flag introduced in Linux 5.19 allows an
unconfirmed 1:N communication with PDU lengths that would not fit into a
single frame. This feature is not covered by the ISO 15765-2 standard.

The isotpsend tool gets a new option '-C' to enable this unconfirmed 1:N
communication by setting the CAN_ISOTP_CF_BROADCAST flag.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2022-05-13 20:00:45 +02:00
Oliver Hartkopp 84d3294132 isotp: support Linux 5.18 features
- update isotp.h include file
- update maximum PDU (buffer) size to 64kByte buffer
- support setting of N_As (frame_txtime) to zero

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2022-03-12 18:09:48 +01:00
Oleksij Rempel 0107f07d83 include: import j1939.h from kernel v5.14-rc5+netdev-next
Import latest j1939.h to provide support for the RX state notifications

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
2021-08-20 10:21:20 +02:00
Oliver Hartkopp affdc1b799 can: uapi: update can.h to latest upstream version
This update includes:

commit f5076c6ba02e ("can: uapi: can.h: mark union inside struct can_frame packed")
commit 7e97d274db92 ("can: uapi: update CAN-FD frame description")
commit 025468842212 ("can: uapi: introduce CANFD_FDF flag for mixed content in struct canfd_frame")

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2021-06-01 19:55:40 +02:00
Marc Kleine-Budde 66de96d337 mcp251xfd-dump: add tool to decode chip and driver state of mcp251xfd
It works on dev coredump data generated by the mcp251xfd driver in
case of failures, as well as on regmap based register dumps.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2021-02-13 23:36:43 +01:00
Oliver Hartkopp 280ea436d4 isotp: add define for SF_BROADCAST support
When CAN_ISOTP_SF_BROADCAST is set in the CAN_ISOTP_OPTS flags the
CAN_ISOTP socket is switched into functional addressing mode, where
only single frame (SF) protocol data units can be send on the specified
CAN interface and the given tp.tx_id after bind().

Add the CAN_ISOTP_SF_BROADCAST define from Linux UAPI includes.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-12-06 14:17:36 +01:00
Oliver Hartkopp c3d9cc2027 cangw: support len8_dlc for Classical CAN frames
The can_dlc value that is passed to the kernel is not sanitized in cangw
therefore we only update the help text and some comments in gw.h.

In the case that the CAN interface supports len8_dlc by setting
CAN_CTRLMODE_CC_LEN8_DLC the can-gw module can modify the full DLC value
range (0 .. 15) for Classic CAN frames.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-11-22 19:57:27 +01:00
Oliver Hartkopp c398e56afb can: add optional DLC element to Classical CAN frame structure
ISO 11898-1 Chapter 8.4.2.3 defines a 4 bit data length code (DLC) table which
maps the DLC to the payload length of the CAN frame in bytes:

    DLC      ->  payload length
    0 .. 8   ->  0 .. 8
    9 .. 15  ->  8

Although the DLC values 8 .. 15 in Classical CAN always result in a payload
length of 8 bytes these DLC values are transparently transmitted on the CAN
bus. As the struct can_frame only provides a 'len' element (formerly 'can_dlc')
which contains the plain payload length ( 0 .. 8 ) of the CAN frame, the raw
DLC is not visible to the application programmer, e.g. for testing use-cases.

To access the raw DLC values 9 .. 15 the len8_dlc element is introduced, which
is only valid when the payload length 'len' is 8 and the DLC is greater than 8.

The len8_dlc element is filled by the CAN interface driver and used for CAN
frame creation by the CAN driver when the CAN_CTRLMODE_CC_LEN8_DLC flag is
supported by the driver and enabled via netlink configuration interface.

Reported-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-11-22 18:41:38 +01:00
Oliver Hartkopp d3b29dfa48 includes: update to Linux 5.10 include files
- isotp.h: use latest version and formatting
- raw.h: introduce SCM_CAN_RAW_ERRQUEUE

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-10-14 09:28:22 +02:00
Oliver Hartkopp f6d963b5d9 isotpsend: add support for blocking write flag
With the new flag 'CAN_ISOTP_WAIT_TX_DONE' the send()/write() syscall returns
when the PDU is completely passed to the CAN netdevice queue. Depending on
STmin and other settings for the tx-queue-len this does not necessarily mean
that the PDU has been completely sent on the CAN interface at that time.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-10-01 20:42:50 +02:00
Gary Bisson 46895a41c5 Fix comparison type mismatch warnings
Signed-off-by: Gary Bisson <gary.bisson@boundarydevices.com>
2020-05-28 20:54:37 +02:00
Yegor Yefremov ffd60c9b74 include: import header files from kernel v5.4-rc7
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
2019-11-12 08:59:58 +01:00
Oleksij Rempel d5ba0e2d23 can/j1939.h: sync with latest kernel state
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
2019-08-26 11:03:36 +02:00
Oliver Hartkopp 0669215a4b cangw: update include files for CAN FD support
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2019-08-16 15:26:41 +02:00
Oleksij Rempel 9ff370ea82 include: add errqueue.h, net_tstamp.h, netlink.h
this headers are take from kernel v5.0 and needed for
error queue support.

Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
2019-05-09 14:36:53 +02:00
Oleksij Rempel 38fa644069 include: import header files from linux-5.0 (including new j1939 filter struct)
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
2019-05-08 10:53:00 +02:00
Marc Kleine-Budde 06d3beb08c include: import header files from linux-5.0 (including new j1939 patches)
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2019-04-04 10:19:11 +02:00
Marc Kleine-Budde c5fd57df34 include: import header files from kernel 2018-02-11 14:39:01 +01:00
Kurt Van Dijck 19ee95491a can-j1939: update headers with j1939
Signed-off-by: Kurt Van Dijck <kurt.van.dijck@eia.be>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2018-01-18 11:04:15 +01:00
Marc Kleine-Budde 9a967265bc include: import header files from kernel v4.15-rc5
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2018-01-17 15:51:31 +01:00
Oliver Hartkopp 73ae306a11 bcm: add support for CAN FD frames
Update bcm.h following Linux mainline commit 6f3b911d5f29b98752

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2016-10-10 14:19:42 +02:00
Oliver Hartkopp cda61171f1 can: avoid using timeval for uapi
Upstream commit ba61a8d9d780980e8284355a0be750897e7af212

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit?id=ba61a8d9d780980e8284355a0be750897e7af212

The can subsystem communicates with user space using a bcm_msg_head
header, which contains two timestamps. This is problematic for
multiple reasons:

a) The structure layout is currently incompatible between 64-bit
   user space and 32-bit user space, and cannot work in compat
   mode (other than x32).

b) The timeval structure layout will change in 32-bit user
   space when we fix the y2038 overflow problem by redefining
   time_t to 64-bit, making new 32-bit user space incompatible
   with the current kernel interface.
   Cars last a long time and often use old kernels, so the actual
   users of this code are the most likely ones to migrate to y2038
   safe user space.

This tries to work around part of the problem by changing the
publicly visible user interface in the header, but not the binary
interface. Fortunately, the values passed around in the structure
are relative times and do not actually suffer from the y2038
overflow, so 32-bit is enough here.

We replace the use of 'struct timeval' with a newly defined
'struct bcm_timeval' that uses the exact same binary layout
as before and that still suffers from problem a) but not problem
b).

The downside of this approach is that any user space program
that currently assigns a timeval structure to these members
rather than writing the tv_sec/tv_usec portions individually
will suffer a compile-time error when built with an updated
kernel header. Fixing this error makes it work fine with old
and new headers though.

We could address problem a) by using '__u32' or 'int' members
rather than 'long', but that would have a more significant
downside in also breaking support for all existing 64-bit user
binaries that might be using this interface, which is likely
not acceptable.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Cc: linux-can@vger.kernel.org
Cc: linux-api@vger.kernel.org
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2015-11-05 21:36:42 +01:00
Oliver Hartkopp 8af831f377 cangw: introduce uid command line option
Similar to referencing iptables rules by their line number this UID allows to
reference created routing jobs, e.g. to alter configured data modifications.

The UID is an optional non-zero value which can be provided at routing job
creation time. When the UID is set the UID replaces the data modification
configuration as job identification attribute e.g. at job removal time.

The UID option is provided by mainline Linux 4.2+

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2015-06-11 20:48:43 +02:00
Oliver Hartkopp 1a2467ed29 candump: support new raw socket option to join the given CAN filters
The CAN_RAW socket can set multiple CAN identifier specific filters that lead
to multiple filters in the af_can.c filter processing. These filters are
indenpendent from each other which leads to logical OR'ed filters when applied.

This socket option joines the given CAN filters in the way that only CAN frames
are passed to user space that matched *all* given CAN filters. The semantic for
the applied filters is therefore changed to a logical AND.

This is useful especially when the filterset is a combination of filters where
the CAN_INV_FILTER flag is set in order to notch single CAN IDs or CAN ID
ranges from the incoming traffic.

Example:
	candump can0,100~7FF,200~7FF,400~7FF	(logical OR'ed filters)
	candump can0,100~7FF,200~7FF,400~7FF,J	(logical AND'ed filters)

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2015-03-17 20:30:54 +01:00
Oliver Hartkopp 8150e21a11 isotp: add tool support for ISO 15765-2:2015 with CAN FD
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2014-11-16 22:24:04 +01:00
Oliver Hartkopp 4ffb7fe5c7 isotp: added support for separate extended address in rx path
As requested by Laurent Vaudoit the extended address can be different in the
tx and he rx path:

(..) how can i have a segmented transfer like this:
0x6a7  0x55 0x10 0x08 ........
0x687  0xAA 0x30 0x00 0x00
0x6a7  0x55 0x21 .....

The connection i need is between two ECU, using IDs 0x6a7/687 and one has
adress extension 0x55, the other 0xAA (this adressing method is used on some
FIAT ECUs for example).

http://marc.info/?l=linux-can&m=140354647413513&w=2

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2014-11-16 20:38:31 +01:00
Oliver Hartkopp 111f8d3acf isotp: fix path mentioned in file
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2014-01-23 14:31:10 +01:00
Marc Kleine-Budde a51381e548 include: import copyright information from the kernel
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2014-01-23 14:22:43 +01:00
Marc Kleine-Budde 8d7a603c18 include: gw.h: update comment
This comment was added to the kernel in patch:

    391ac12 can: gw: add a per rule limitation of frame hops

The corresponding can-utils commit is:

    ad7f44095a (cangw: add an option for the per rule limitation of frame hops)

which somehow introduced the difference even though it referenced commit
391ac12.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2014-01-23 14:22:19 +01:00
Marc Kleine-Budde 9db35b68ef include: can.h: add typedef for __kernel_sa_family_t to make headers self-contained
This patch adds the typedef for __kernel_sa_family_t that was introduced in
Linux v3.1-rc2 (commit 6602a4b net: Make userland include of netlink.h more sane)
in <linux/socket.h>. It must be duplicated here to make the CAN headers
self-contained.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2014-01-23 13:57:29 +01:00
Marc Kleine-Budde fb5f0cca7d include: can.h: remove unused include of version.h
This patch remove the include of version.h, as it's not used and also not
present in the kernel headers.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2014-01-23 13:57:12 +01:00
Marc Kleine-Budde 08d2c63e00 include: fix paths mentioned in files
This patch fixes paths mentioned in the files which are wrong now, due the move
of the files in the previous patch.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2014-01-23 13:48:09 +01:00
Uwe Kleine-König ed7bc7d366 include: Move all includes from include/socketcan to include/linux
This makes it possible to import header from the kernel more easily, e.g.:

	cd $path_to_linux_repo
	make headers_install
	rsync -a --exclude .\* usr/include/linux/can* $path_to_can_utils/include/linux

[mkl: also move isotp.h although Uwe skipped it as it is not
      part of the upstream kernel; adapt commit log accordingly]

Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2014-01-23 13:48:09 +01:00
Uwe Kleine-König a9dbbbc214 include: Remove two unused header files
These seem to have never been used. They entered can-utils in commit
77de10356f (include: import kernel header files into tree) and already
back then only consisted in an #include of a non-existing file.

Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2014-01-23 13:48:07 +01:00
Marc Kleine-Budde 77de10356f include: import kernel header files into tree
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Tested-by: Jan-Niklas Meier <dschanoeh@googlemail.com>
2012-01-11 12:14:15 +01:00