mirror of
https://github.com/systemd/systemd.git
synced 2025-03-28 02:50:16 +03:00
network: can: add support for CAN-FD related properties
This commit is contained in:
parent
74a2726869
commit
7e025e9cdb
@ -2360,6 +2360,29 @@
|
||||
<literal>87.5%</literal>) or permille (e.g. <literal>875‰</literal>).</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>DataBitRate=</varname></term>
|
||||
<term><varname>DataSamplePoint=</varname></term>
|
||||
<listitem>
|
||||
<para>The bitrate and sample point for the data phase, if CAN-FD is used. These settings are
|
||||
analogous to the <varname>BitRate=</varname> and <varname>SamplePoint=</varname> keys.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>FDMode=</varname></term>
|
||||
<listitem>
|
||||
<para>Takes a boolean. When <literal>yes</literal>, CAN-FD mode is enabled for the interface.
|
||||
Note, that a bitrate and optional sample point should also be set for the CAN-FD data phase using
|
||||
the <varname>DataBitRate=</varname> and <varname>DataSamplePoint=</varname> keys.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>FDNonISO=</varname></term>
|
||||
<listitem>
|
||||
<para>Takes a boolean. When <literal>yes</literal>, non-ISO CAN-FD mode is enabled for the
|
||||
interface. When unset, the kernel's default will be used.</para>
|
||||
</listitem>
|
||||
</varlistentry>
|
||||
<varlistentry>
|
||||
<term><varname>RestartSec=</varname></term>
|
||||
<listitem>
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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;
|
||||
|
@ -201,6 +201,10 @@ PVID=
|
||||
[CAN]
|
||||
SamplePoint=
|
||||
BitRate=
|
||||
DataSamplePoint=
|
||||
DataBitRate=
|
||||
FDMode=
|
||||
FDNonISO=
|
||||
RestartSec=
|
||||
TripleSampling=
|
||||
Termination=
|
||||
|
Loading…
x
Reference in New Issue
Block a user