]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
network: add CAN Termination tristate option 15036/head
authorMatt Ranostay <matt.ranostay@konsulko.com>
Wed, 12 Feb 2020 02:13:45 +0000 (18:13 -0800)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 6 Mar 2020 17:00:02 +0000 (02:00 +0900)
man/systemd.network.xml
src/libsystemd/sd-netlink/netlink-types.c
src/network/networkd-can.c
src/network/networkd-network-gperf.gperf
src/network/networkd-network.c
src/network/networkd-network.h
test/fuzz/fuzz-network-parser/directives.network

index 209787bf1b280dfa405286948148fa24fd5f521a..6b8aa15ea3e4a54695b740b6137cdaf5441ab58c 100644 (file)
             automatic restart off. By default automatic restart is disabled.</para>
           </listitem>
         </varlistentry>
+        <varlistentry>
+          <term><varname>Termination=</varname></term>
+          <listitem>
+            <para>Takes a boolean. When <literal>yes</literal>, the termination resistor will be selected for
+            the bias network. When unset, the kernel's default will be used.</para>
+          </listitem>
+        </varlistentry>
         <varlistentry>
           <term><varname>TripleSampling=</varname></term>
           <listitem>
index e35127a4cd2ed97526cc3d1b5898dc722afa62dd..3aa7002e80e02f2e8aba80c3a39c49b0976fa4d1 100644 (file)
@@ -316,6 +316,7 @@ static const NLType rtnl_link_info_data_can_types[] = {
         [IFLA_CAN_BITTIMING]            = { .size = sizeof(struct can_bittiming) },
         [IFLA_CAN_RESTART_MS]           = { .type = NETLINK_TYPE_U32 },
         [IFLA_CAN_CTRLMODE]             = { .size = sizeof(struct can_ctrlmode) },
+        [IFLA_CAN_TERMINATION]          = { .type = NETLINK_TYPE_U16 },
 };
 
 static const NLType rtnl_link_info_data_macsec_types[] = {
index 5087dbbc2ea1a7fb348c7fa5fbf921f5a1440f22..c703f94f3ab6d052e54bbabf62c41e3d13abbdd5 100644 (file)
@@ -9,6 +9,8 @@
 #include "networkd-manager.h"
 #include "string-util.h"
 
+#define CAN_TERMINATION_OHM_VALUE 120
+
 static int link_up_handler(sd_netlink *rtnl, sd_netlink_message *m, Link *link) {
         int r;
 
@@ -152,6 +154,17 @@ static int link_set_can(Link *link) {
                         return log_link_error_errno(link, r, "Could not append IFLA_CAN_CTRLMODE attribute: %m");
         }
 
+        if (link->network->can_termination >= 0) {
+
+                log_link_debug(link, "%sabling can-termination", link->network->can_termination ? "En" : "Dis");
+
+                r = sd_netlink_message_append_u16(m, IFLA_CAN_TERMINATION,
+                                link->network->can_termination ? CAN_TERMINATION_OHM_VALUE : 0);
+                if (r < 0)
+                        return log_link_error_errno(link, r, "Could not append IFLA_CAN_TERMINATION attribute: %m");
+
+        }
+
         r = sd_netlink_message_close_container(m);
         if (r < 0)
                 return log_link_error_errno(link, r, "Failed to close netlink container: %m");
index 134f1535d607ff87d45f807494740e569c473bee..9679300b62d8e056eb0d2a0f4e8ac113eb0c0b53 100644 (file)
@@ -251,6 +251,7 @@ CAN.BitRate,                                 config_parse_si_uint64,
 CAN.SamplePoint,                             config_parse_permille,                                    0,                             offsetof(Network, can_sample_point)
 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)
 QDisc.Parent,                                config_parse_qdisc_parent,                                _QDISC_KIND_INVALID,           0
 QDisc.Handle,                                config_parse_qdisc_handle,                                _QDISC_KIND_INVALID,           0
 ControlledDelay.Parent,                      config_parse_qdisc_parent,                                QDISC_KIND_CODEL,              0
index b06ae75c058196d572689d69598fcd07aa0d2418..41f8245c22517e4c06084b3ed5b7d74dfb650e0e 100644 (file)
@@ -455,6 +455,7 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
                 .keep_configuration = _KEEP_CONFIGURATION_INVALID,
 
                 .can_triple_sampling = -1,
+                .can_termination = -1,
                 .ip_service_type = -1,
         };
 
index 66f010a7939fe4744d38673f38a34e412b7ad131..3bcf9ac493691bfffae6ac5f9d09780d96d46e0d 100644 (file)
@@ -199,6 +199,7 @@ struct Network {
         unsigned can_sample_point;
         usec_t can_restart_us;
         int can_triple_sampling;
+        int can_termination;
 
         AddressFamily ip_forward;
         bool ip_masquerade;
index 2b41239b745817f49d6ce4b6e0aaf20861239d12..c1c667d237aa7d2a2ff1af474dc10d8e8a32a6ac 100644 (file)
@@ -198,6 +198,7 @@ SamplePoint=
 BitRate=
 RestartSec=
 TripleSampling=
+Termination=
 [Address]
 DuplicateAddressDetection=
 AutoJoin=