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 | |
parent | 74a27268699e7cf83f0dd4c9d1a24d0e46038be8 (diff) | |
download | systemd-7e025e9cdba1bce4e7e8259df0a9440f886c3be7.tar.gz |
network: can: add support for CAN-FD related properties
Diffstat (limited to 'src')
-rw-r--r-- | src/network/networkd-can.c | 29 | ||||
-rw-r--r-- | src/network/networkd-network-gperf.gperf | 4 | ||||
-rw-r--r-- | src/network/networkd-network.h | 4 |
3 files changed, 37 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; diff --git a/src/network/networkd-network-gperf.gperf b/src/network/networkd-network-gperf.gperf index ee50da098d..7833eec1cf 100644 --- a/src/network/networkd-network-gperf.gperf +++ b/src/network/networkd-network-gperf.gperf @@ -260,6 +260,10 @@ IPv6RoutePrefix.Route, config_parse_route_prefix, IPv6RoutePrefix.LifetimeSec, config_parse_route_prefix_lifetime, 0, 0 CAN.BitRate, config_parse_can_bitrate, 0, offsetof(Network, can_bitrate) CAN.SamplePoint, config_parse_permille, 0, offsetof(Network, can_sample_point) +CAN.DataBitRate, config_parse_can_bitrate, 0, offsetof(Network, can_data_bitrate) +CAN.DataSamplePoint, config_parse_permille, 0, offsetof(Network, can_data_sample_point) +CAN.FDMode, config_parse_tristate, 0, offsetof(Network, can_fd_mode) +CAN.FDNonISO, config_parse_tristate, 0, offsetof(Network, can_non_iso) CAN.RestartSec, config_parse_sec, 0, offsetof(Network, can_restart_us) CAN.TripleSampling, config_parse_tristate, 0, offsetof(Network, can_triple_sampling) CAN.Termination, config_parse_tristate, 0, offsetof(Network, can_termination) diff --git a/src/network/networkd-network.h b/src/network/networkd-network.h index 7acb4a5461..8bd380c6a8 100644 --- a/src/network/networkd-network.h +++ b/src/network/networkd-network.h @@ -207,10 +207,14 @@ struct Network { /* CAN support */ uint32_t can_bitrate; unsigned can_sample_point; + uint32_t can_data_bitrate; + unsigned can_data_sample_point; usec_t can_restart_us; int can_triple_sampling; int can_termination; int can_listen_only; + int can_fd_mode; + int can_non_iso; AddressFamily ip_forward; bool ip_masquerade; |