network: can: add support for bus error reporting

Enhance systemd-networkd to be able to control a CAN device's berr-reporting
flag via the new boolean directive BusErrorReporting= to be used in network
files.
master
Ulrich Ölmann 2 years ago
parent 3757912db4
commit 77b674049b
  1. 10
      man/systemd.network.xml
  2. 6
      src/network/networkd-can.c
  3. 1
      src/network/networkd-network-gperf.gperf
  4. 1
      src/network/networkd-network.c
  5. 1
      src/network/networkd-network.h
  6. 1
      test/fuzz/fuzz-network-parser/directives.network

@ -2742,6 +2742,16 @@ IPv6Token=prefixstable:2002:da8:1::</programlisting></para>
the value of a received bit by majority rule. When unset, the kernel's default will be used.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>BusErrorReporting=</varname></term>
<listitem>
<para>Takes a boolean. When <literal>yes</literal>, reporting of CAN bus errors is activated
(those include single bit, frame format, and bit stuffing errors, unable to send dominant bit,
unable to send recessive bit, bus overload, active error announcement, error occurred on
transmission). When unset, the kernel's default will be used. Note: in case of a CAN bus with a
single CAN device, sending a CAN frame may result in a huge number of CAN bus errors.</para>
</listitem>
</varlistentry>
<varlistentry>
<term><varname>ListenOnly=</varname></term>
<listitem>

@ -211,6 +211,12 @@ static int link_set_can(Link *link) {
log_link_debug(link, "Setting triple-sampling to '%s'.", yes_no(link->network->can_triple_sampling));
}
if (link->network->can_berr_reporting >= 0) {
cm.mask |= CAN_CTRLMODE_BERR_REPORTING;
SET_FLAG(cm.flags, CAN_CTRLMODE_BERR_REPORTING, link->network->can_berr_reporting);
log_link_debug(link, "Setting bus error reporting to '%s'.", yes_no(link->network->can_berr_reporting));
}
if (link->network->can_listen_only >= 0) {
cm.mask |= CAN_CTRLMODE_LISTENONLY;
SET_FLAG(cm.flags, CAN_CTRLMODE_LISTENONLY, link->network->can_listen_only);

@ -320,6 +320,7 @@ CAN.FDMode, config_parse_tristate,
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.BusErrorReporting, config_parse_tristate, 0, offsetof(Network, can_berr_reporting)
CAN.Termination, config_parse_tristate, 0, offsetof(Network, can_termination)
CAN.ListenOnly, config_parse_tristate, 0, offsetof(Network, can_listen_only)
QDisc.Parent, config_parse_qdisc_parent, _QDISC_KIND_INVALID, 0

@ -415,6 +415,7 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
.ipv6_accept_ra_start_dhcp6_client = IPV6_ACCEPT_RA_START_DHCP6_CLIENT_YES,
.can_triple_sampling = -1,
.can_berr_reporting = -1,
.can_termination = -1,
.can_listen_only = -1,
.can_fd_mode = -1,

@ -231,6 +231,7 @@ struct Network {
unsigned can_data_sample_point;
usec_t can_restart_us;
int can_triple_sampling;
int can_berr_reporting;
int can_termination;
int can_listen_only;
int can_fd_mode;

@ -246,6 +246,7 @@ FDMode=
FDNonISO=
RestartSec=
TripleSampling=
BusErrorReporting=
Termination=
ListenOnly=
[Address]

Loading…
Cancel
Save