iplink_can: add CAN XL support RFC based on Vincent cleanups
PATCH 1/5 iplink_can: add CAN XL support RFC based on Vincent cleanups
Fixes from Oliver:
- remove newline before tdc information to increase readability
- fix copy/paste issue in CAN_CTRLMODE_XL_TDC_ definitions
Based on the iproute2 CAN XL preparations patch set at
https://lore.kernel.org/linux-can/173194923075.4109060.18408610499610779344.git-patchwork-notify@kernel.org/T/#t
which was already merged into iproute2-next tree:
https://git.kernel.org/pub/scm/network/iproute2/iproute2-next.git/commit/?id=7b4d64895f7c58a12c01d2f394f75b0d1938eb9c
--- include/uapi/linux/can/netlink.h | 21 ++- ip/iplink_can.c | 223 ++++++++++++++++++++++++++++--- 2 files changed, 216 insertions(+), 28 deletions(-)
include/uapi/linux/can/netlink.h +14 -7
@@ -99,12 +99,15 @@ struct can_ctrlmode {#define CAN_CTRLMODE_BERR_REPORTING 0x10/* Bus-error reporting */ #define CAN_CTRLMODE_FD 0x20/* CAN FD mode */ #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_MANUAL 0x400/* TDCV is manually set up by user */ +#define CAN_CTRLMODE_TDC_AUTO 0x200/* FD transceiver automatically calculates TDCV */ +#define CAN_CTRLMODE_TDC_MANUAL 0x400/* FD TDCV is manually set up by user */ +#define CAN_CTRLMODE_XL 0x800/* CAN XL mode */ +#define CAN_CTRLMODE_XL_TDC_AUTO 0x1000/* XL transceiver automatically calculates TDCV */ +#define CAN_CTRLMODE_XL_TDC_MANUAL 0x2000/* XL TDCV is manually set up by user */ /* * CAN device statistics */ struct can_device_stats {
@@ -127,27 +130,31 @@ enum {IFLA_CAN_STATE ,IFLA_CAN_CTRLMODE ,IFLA_CAN_RESTART_MS ,IFLA_CAN_RESTART ,IFLA_CAN_BERR_COUNTER , -IFLA_CAN_DATA_BITTIMING , -IFLA_CAN_DATA_BITTIMING_CONST , +IFLA_CAN_DATA_BITTIMING ,/* FD */ +IFLA_CAN_DATA_BITTIMING_CONST ,/* FD */ IFLA_CAN_TERMINATION ,IFLA_CAN_TERMINATION_CONST ,IFLA_CAN_BITRATE_CONST , -IFLA_CAN_DATA_BITRATE_CONST , +IFLA_CAN_DATA_BITRATE_CONST ,/* FD */ IFLA_CAN_BITRATE_MAX , -IFLA_CAN_TDC , +IFLA_CAN_TDC ,/* FD */ IFLA_CAN_CTRLMODE_EXT , +IFLA_CAN_XL_DATA_BITTIMING , +IFLA_CAN_XL_DATA_BITTIMING_CONST , +IFLA_CAN_XL_DATA_BITRATE_CONST , +IFLA_CAN_XL_TDC ,/* add new constants above here */ __IFLA_CAN_MAX,IFLA_CAN_MAX = __IFLA_CAN_MAX -1 };/* -* CAN FD Transmitter Delay Compensation (TDC) +* CAN FD/XL Transmitter Delay Compensation (TDC) * * Please refer to struct can_tdc_const and can_tdc in * include/linux/can/bittiming.h for further details. */ enum {
ip/iplink_can.c +202 -21
395 lines not on this page · raw message
Signature · 1 line
2.47.2
PATCH 2/5 iplink_can: 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.
To read/write the Remote Request Substitution (RRS) bit in the CAN XL frame the CAN_CTRLMODE_XL_RRS has to be enabled in CAN driver.
--- include/uapi/linux/can/netlink.h | 1 + ip/iplink_can.c | 6 ++++++ 2 files changed, 7 insertions(+)
include/uapi/linux/can/netlink.h +1 -0
@@ -104,10 +104,11 @@ struct can_ctrlmode {#define CAN_CTRLMODE_TDC_AUTO 0x200/* FD transceiver automatically calculates TDCV */ #define CAN_CTRLMODE_TDC_MANUAL 0x400/* FD TDCV is manually set up by user */ #define CAN_CTRLMODE_XL 0x800/* CAN XL mode */ #define CAN_CTRLMODE_XL_TDC_AUTO 0x1000/* XL transceiver automatically calculates TDCV */ #define CAN_CTRLMODE_XL_TDC_MANUAL 0x2000/* XL TDCV is manually set up by user */ +#define CAN_CTRLMODE_XL_RRS 0x4000/* XL enable RRS bit access */ /* * CAN device statistics */ struct can_device_stats {
ip/iplink_can.c +6 -0
@@ -40,10 +40,11 @@ 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[ xl { on | off } ]\n" "\t[ xtdc-mode { auto | manual | off } ]\n" +"\t[ xlrrs { on | off } ]\n" "\n" "\t[ restart-ms TIME-MS ]\n" "\t[ restart ]\n" "\n" "\t[ termination { 0..65535 } ]\n"
@@ -123,10 +124,11 @@ static void print_ctrlmode(enum output_type t, __u32 flags, const char* key)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_XL ,"XL" );print_flag (t, &flags,CAN_CTRLMODE_XL_TDC_AUTO ,"XL-TDC-AUTO" );print_flag (t, &flags,CAN_CTRLMODE_XL_TDC_MANUAL ,"XL-TDC-MANUAL" ); +print_flag (t, &flags,CAN_CTRLMODE_XL_RRS ,"XL-RRS" );if (flags)print_hex (t,NULL ,"%x" , flags);close_json_array (t,"> " );
@@ -333,10 +335,14 @@ static int can_parse_opt(struct link_util *lu, int argc, char **argv,CAN_CTRLMODE_XL_TDC_MANUAL ; }else {invarg ("\"xtdc-mode\" must be either of \"auto\", \"manual\" or \"off\"" , *argv); } + }else if (matches (*argv,"xlrrs" ) ==0 ) { +NEXT_ARG (); +set_ctrlmode ("xlrrs" , *argv, &cm, +CAN_CTRLMODE_XL_RRS ); }else if (matches (*argv,"restart" ) ==0 ) {__u32 val =1 ;addattr32 (n,1024 ,IFLA_CAN_RESTART , val); }else if (matches (*argv,"restart-ms" ) ==0 ) {
Signature · 1 line
2.47.2
PATCH 3/5 iplink_can: canxl: support CAN XL transceiver switching in data phase
In reply to Oliver HartkoppIn the CAN XL data phase the CAN XL controller can advise the CAN XL transceiver to switch the physical layer.
To enable this feature the CAN_CTRLMODE_XL_TRX has to be set in the driver control mode.
--- include/uapi/linux/can/netlink.h | 1 + ip/iplink_can.c | 6 ++++++ 2 files changed, 7 insertions(+)
include/uapi/linux/can/netlink.h +1 -0
@@ -105,10 +105,11 @@ struct can_ctrlmode {#define CAN_CTRLMODE_TDC_MANUAL 0x400/* FD TDCV is manually set up by user */ #define CAN_CTRLMODE_XL 0x800/* CAN XL mode */ #define CAN_CTRLMODE_XL_TDC_AUTO 0x1000/* XL transceiver automatically calculates TDCV */ #define CAN_CTRLMODE_XL_TDC_MANUAL 0x2000/* XL TDCV is manually set up by user */ #define CAN_CTRLMODE_XL_RRS 0x4000/* XL enable RRS bit access */ +#define CAN_CTRLMODE_XL_TRX 0x8000/* XL switch trx in data phase */ /* * CAN device statistics */ struct can_device_stats {
ip/iplink_can.c +6 -0
@@ -41,10 +41,11 @@ static void print_usage(FILE *f)"\t[ cc-len8-dlc { on | off } ]\n" "\t[ tdc-mode { auto | manual | off } ]\n" "\t[ xl { on | off } ]\n" "\t[ xtdc-mode { auto | manual | off } ]\n" "\t[ xlrrs { on | off } ]\n" +"\t[ xltrx { on | off } ]\n" "\n" "\t[ restart-ms TIME-MS ]\n" "\t[ restart ]\n" "\n" "\t[ termination { 0..65535 } ]\n"
@@ -125,10 +126,11 @@ static void print_ctrlmode(enum output_type t, __u32 flags, const char* key)print_flag (t, &flags,CAN_CTRLMODE_TDC_MANUAL ,"TDC-MANUAL" );print_flag (t, &flags,CAN_CTRLMODE_XL ,"XL" );print_flag (t, &flags,CAN_CTRLMODE_XL_TDC_AUTO ,"XL-TDC-AUTO" );print_flag (t, &flags,CAN_CTRLMODE_XL_TDC_MANUAL ,"XL-TDC-MANUAL" );print_flag (t, &flags,CAN_CTRLMODE_XL_RRS ,"XL-RRS" ); +print_flag (t, &flags,CAN_CTRLMODE_XL_TRX ,"XL-TRX" );if (flags)print_hex (t,NULL ,"%x" , flags);close_json_array (t,"> " );
@@ -339,10 +341,14 @@ static int can_parse_opt(struct link_util *lu, int argc, char **argv, } }else if (matches (*argv,"xlrrs" ) ==0 ) {NEXT_ARG ();set_ctrlmode ("xlrrs" , *argv, &cm,CAN_CTRLMODE_XL_RRS ); + }else if (matches (*argv,"xltrx" ) ==0 ) { +NEXT_ARG (); +set_ctrlmode ("xltrx" , *argv, &cm, +CAN_CTRLMODE_XL_TRX ); }else if (matches (*argv,"restart" ) ==0 ) {__u32 val =1 ;addattr32 (n,1024 ,IFLA_CAN_RESTART , val); }else if (matches (*argv,"restart-ms" ) ==0 ) {
Signature · 1 line
2.47.2
PATCH 4/5 iplink_can: canxl: support CAN XL error signalling switching
In reply to Oliver HartkoppFor CAN CC and CAN FD the generation of error frames on the CAN bus in the case of detected protocol violations is a mandatory feature. With CAN XL utilizing a switchable CAN XL transceiver with a different physical layer the error signalling is not possible when the transceiver is switched into the new data mode physical layer.
When operating a CAN controller in CAN CC/FD/XL mode (XL = enabled!) with a 'normal' CAN (FD) transceiver that does not switch the physical layer in the data section the user can decide whether the error signalling is enabled/disabled for all CAN protocols.
--- include/uapi/linux/can/netlink.h | 1 + ip/iplink_can.c | 6 ++++++ 2 files changed, 7 insertions(+)
include/uapi/linux/can/netlink.h +1 -0
@@ -106,10 +106,11 @@ struct can_ctrlmode {#define CAN_CTRLMODE_XL 0x800/* CAN XL mode */ #define CAN_CTRLMODE_XL_TDC_AUTO 0x1000/* XL transceiver automatically calculates TDCV */ #define CAN_CTRLMODE_XL_TDC_MANUAL 0x2000/* XL TDCV is manually set up by user */ #define CAN_CTRLMODE_XL_RRS 0x4000/* XL enable RRS bit access */ #define CAN_CTRLMODE_XL_TRX 0x8000/* XL switch trx in data phase */ +#define CAN_CTRLMODE_XL_ERR_SIGNAL 0x10000/* XL error signalling */ /* * CAN device statistics */ struct can_device_stats {
ip/iplink_can.c +6 -0
@@ -42,10 +42,11 @@ static void print_usage(FILE *f)"\t[ tdc-mode { auto | manual | off } ]\n" "\t[ xl { on | off } ]\n" "\t[ xtdc-mode { auto | manual | off } ]\n" "\t[ xlrrs { on | off } ]\n" "\t[ xltrx { on | off } ]\n" +"\t[ xlerrsig { on | off } ]\n" "\n" "\t[ restart-ms TIME-MS ]\n" "\t[ restart ]\n" "\n" "\t[ termination { 0..65535 } ]\n"
@@ -127,10 +128,11 @@ static void print_ctrlmode(enum output_type t, __u32 flags, const char* key)print_flag (t, &flags,CAN_CTRLMODE_XL ,"XL" );print_flag (t, &flags,CAN_CTRLMODE_XL_TDC_AUTO ,"XL-TDC-AUTO" );print_flag (t, &flags,CAN_CTRLMODE_XL_TDC_MANUAL ,"XL-TDC-MANUAL" );print_flag (t, &flags,CAN_CTRLMODE_XL_RRS ,"XL-RRS" );print_flag (t, &flags,CAN_CTRLMODE_XL_TRX ,"XL-TRX" ); +print_flag (t, &flags,CAN_CTRLMODE_XL_ERR_SIGNAL ,"XL-ERR-SIGNAL" );if (flags)print_hex (t,NULL ,"%x" , flags);close_json_array (t,"> " );
@@ -345,10 +347,14 @@ static int can_parse_opt(struct link_util *lu, int argc, char **argv, CAN_CTRLMODE_XL_RRS); }else if (matches (*argv,"xltrx" ) ==0 ) {NEXT_ARG ();set_ctrlmode ("xltrx" , *argv, &cm,CAN_CTRLMODE_XL_TRX ); + }else if (matches (*argv,"xlerrsig" ) ==0 ) { +NEXT_ARG (); +set_ctrlmode ("xlerrsig" , *argv, &cm, +CAN_CTRLMODE_XL_ERR_SIGNAL ); }else if (matches (*argv,"restart" ) ==0 ) {__u32 val =1 ;addattr32 (n,1024 ,IFLA_CAN_RESTART , val); }else if (matches (*argv,"restart-ms" ) ==0 ) {
Signature · 1 line
2.47.2
PATCH 5/5 iplink_can: canxl: add PWM config support
In reply to Oliver Hartkopp--- include/uapi/linux/can/netlink.h | 15 +++++++++++ ip/iplink_can.c | 44 ++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+)
include/uapi/linux/can/netlink.h +15 -0
@@ -146,16 +146,31 @@ enum {IFLA_CAN_CTRLMODE_EXT ,IFLA_CAN_XL_DATA_BITTIMING ,IFLA_CAN_XL_DATA_BITTIMING_CONST ,IFLA_CAN_XL_DATA_BITRATE_CONST ,IFLA_CAN_XL_TDC , +IFLA_CAN_XL_PWM ,/* add new constants above here */ __IFLA_CAN_MAX, IFLA_CAN_MAX = __IFLA_CAN_MAX - 1 }; +/* +* CAN XL Transceiver data mode switching PWM configuration +*/ +enum { +IFLA_CAN_PWM_UNSPEC , +IFLA_CAN_PWM_OFFSET ,/* u8 */ +IFLA_CAN_PWM_LONG ,/* u8 */ +IFLA_CAN_PWM_SHORT ,/* u8 */ + +/* add new constants above here */ + __IFLA_CAN_PWM, +IFLA_CAN_PWM_MAX = __IFLA_CAN_PWM -1 +}; +/* * CAN FD/XL Transmitter Delay Compensation (TDC) * * Please refer to struct can_tdc_const and can_tdc in * include/linux/can/bittiming.h for further details.
ip/iplink_can.c +44 -0
101 lines not on this page · raw message
Signature · 1 line
2.47.2