Request with CAN_CTRLMODE_FD_COMMON_BRP for CAN FD the usage of a common BRP for both nominal and the data bit rate. This is on the one hand a request to the kernel bit rate calculation algorithm. On the other hand drivers for CAN controllers with only a single BRP register can enforce the usage of a common BRP for both bit rates by setting this control mode statically. Using a common BRP for both (nominal and data) bit rates reduces the phase tolerance and thus increases the resistance to interference, thereby reducing the probability of errors (need for a retransmission) on the CAN bus. Signed-off-by: Stefan Mätje <stefan.maetje@xxxxxx> --- include/uapi/linux/can/netlink.h | 7 ++++--- ip/iplink_can.c | 6 ++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/include/uapi/linux/can/netlink.h b/include/uapi/linux/can/netlink.h index 8ec98c21..cfcb4205 100644 --- a/include/uapi/linux/can/netlink.h +++ b/include/uapi/linux/can/netlink.h @@ -16,8 +16,8 @@ * GNU General Public License for more details. */ -#ifndef _CAN_NETLINK_H -#define _CAN_NETLINK_H +#ifndef _UAPI_CAN_NETLINK_H +#define _UAPI_CAN_NETLINK_H #include <linux/types.h> @@ -101,8 +101,9 @@ struct can_ctrlmode { #define CAN_CTRLMODE_PRESUME_ACK 0x40 /* Ignore missing CAN ACKs */ #define CAN_CTRLMODE_FD_NON_ISO 0x80 /* CAN FD in non-ISO mode */ #define CAN_CTRLMODE_CC_LEN8_DLC 0x100 /* Classic CAN DLC option */ -#define CAN_CTRLMODE_TDC_AUTO 0x200 /* CAN transiver automatically calculates TDCV */ +#define CAN_CTRLMODE_TDC_AUTO 0x200 /* CAN controller automatically calculates TDCV */ #define CAN_CTRLMODE_TDC_MANUAL 0x400 /* TDCV is manually set up by user */ +#define CAN_CTRLMODE_FD_COMMON_BRP 0x800 /* CAN FD common BRP for nom and data bitrates */ /* * CAN device statistics diff --git a/ip/iplink_can.c b/ip/iplink_can.c index fcffa852..186e145a 100644 --- a/ip/iplink_can.c +++ b/ip/iplink_can.c @@ -42,6 +42,7 @@ static void print_usage(FILE *f) "\t[ presume-ack { on | off } ]\n" "\t[ cc-len8-dlc { on | off } ]\n" "\t[ tdc-mode { auto | manual | off } ]\n" + "\t[ fd-common-brp { on | off } ]\n" "\n" "\t[ restart-ms TIME-MS ]\n" "\t[ restart ]\n" @@ -122,6 +123,7 @@ static void print_ctrlmode(enum output_type t, __u32 flags, const char* key) print_flag(t, &flags, CAN_CTRLMODE_CC_LEN8_DLC, "CC-LEN8-DLC"); print_flag(t, &flags, CAN_CTRLMODE_TDC_AUTO, "TDC-AUTO"); print_flag(t, &flags, CAN_CTRLMODE_TDC_MANUAL, "TDC-MANUAL"); + print_flag(t, &flags, CAN_CTRLMODE_FD_COMMON_BRP, "FD-COMMON-BRP"); if (flags) print_hex(t, NULL, "%x", flags); @@ -263,6 +265,10 @@ static int can_parse_opt(struct link_util *lu, int argc, char **argv, invarg("\"tdc-mode\" must be either of \"auto\", \"manual\" or \"off\"", *argv); } + } else if (matches(*argv, "fd-common-brp") == 0) { + NEXT_ARG(); + set_ctrlmode("fd-common-brp", *argv, &cm, + CAN_CTRLMODE_FD_COMMON_BRP); } else if (matches(*argv, "restart") == 0) { __u32 val = 1; -- 2.34.1