diff options
author | Richard Petri <git@rpls.de> | 2020-03-26 22:27:41 +0100 |
---|---|---|
committer | Richard Petri <git@rpls.de> | 2020-04-01 20:07:20 +0200 |
commit | 7e025e9cdba1bce4e7e8259df0a9440f886c3be7 (patch) | |
tree | bca6b9341c9ce795a53a21fc2f6bf8b9b21a181d /src/network/networkd-can.c | |
parent | 74a27268699e7cf83f0dd4c9d1a24d0e46038be8 (diff) | |
download | systemd-7e025e9cdba1bce4e7e8259df0a9440f886c3be7.tar.gz |
network: can: add support for CAN-FD related properties
Diffstat (limited to 'src/network/networkd-can.c')
-rw-r--r-- | src/network/networkd-can.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/network/networkd-can.c b/src/network/networkd-can.c index 4118fcf859..fdd99a3a18 100644 --- a/src/network/networkd-can.c +++ b/src/network/networkd-can.c @@ -155,6 +155,35 @@ static int link_set_can(Link *link) { return log_link_error_errno(link, r, "Could not append IFLA_CAN_BITTIMING attribute: %m"); } + if (link->network->can_data_bitrate > 0 || link->network->can_data_sample_point > 0) { + struct can_bittiming bt = { + .bitrate = link->network->can_data_bitrate, + .sample_point = link->network->can_data_sample_point, + }; + + log_link_debug(link, "Setting data bitrate = %d bit/s", bt.bitrate); + if (link->network->can_data_sample_point > 0) + log_link_debug(link, "Setting data sample point = %d.%d%%", bt.sample_point / 10, bt.sample_point % 10); + else + log_link_debug(link, "Using default data sample point"); + + r = sd_netlink_message_append_data(m, IFLA_CAN_DATA_BITTIMING, &bt, sizeof(bt)); + if (r < 0) + return log_link_error_errno(link, r, "Could not append IFLA_CAN_DATA_BITTIMING attribute: %m"); + } + + if (link->network->can_fd_mode >= 0) { + cm.mask |= CAN_CTRLMODE_FD; + SET_FLAG(cm.flags, CAN_CTRLMODE_FD, link->network->can_fd_mode > 0); + log_link_debug(link, "%sabling FD mode", link->network->can_fd_mode > 0 ? "En" : "Dis"); + } + + if (link->network->can_non_iso >= 0) { + cm.mask |= CAN_CTRLMODE_FD_NON_ISO; + SET_FLAG(cm.flags, CAN_CTRLMODE_FD_NON_ISO, link->network->can_non_iso > 0); + log_link_debug(link, "%sabling FD non-ISO mode", link->network->can_non_iso > 0 ? "En" : "Dis"); + } + if (link->network->can_restart_us > 0) { char time_string[FORMAT_TIMESPAN_MAX]; uint64_t restart_ms; |