daandemeyer / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
d63baa
From 72328a5977d240d33b78b24e7a6b65b1074000b9 Mon Sep 17 00:00:00 2001
d63baa
From: Yu Watanabe <watanabe.yu+github@gmail.com>
d63baa
Date: Thu, 26 Aug 2021 03:31:05 +0900
d63baa
Subject: [PATCH 1/2] ethtool: move function
d63baa
d63baa
I'd like to locate all conf parsers at end of file.
d63baa
---
d63baa
 src/shared/ethtool-util.c | 250 +++++++++++++++++++-------------------
d63baa
 1 file changed, 125 insertions(+), 125 deletions(-)
d63baa
d63baa
diff --git a/src/shared/ethtool-util.c b/src/shared/ethtool-util.c
d63baa
index c47d819f0596..af3b917c75cb 100644
d63baa
--- a/src/shared/ethtool-util.c
d63baa
+++ b/src/shared/ethtool-util.c
d63baa
@@ -932,6 +932,131 @@ int ethtool_set_flow_control(int *fd, const char *ifname, int rx, int tx, int au
d63baa
         return 0;
d63baa
 }
d63baa
 
d63baa
+int ethtool_set_nic_coalesce_settings(int *ethtool_fd, const char *ifname, const netdev_coalesce_param *coalesce) {
d63baa
+        struct ethtool_coalesce ecmd = {
d63baa
+                .cmd = ETHTOOL_GCOALESCE,
d63baa
+        };
d63baa
+        struct ifreq ifr = {
d63baa
+                .ifr_data = (void*) &ecmd,
d63baa
+        };
d63baa
+        bool need_update = false;
d63baa
+        int r;
d63baa
+
d63baa
+        assert(ethtool_fd);
d63baa
+        assert(ifname);
d63baa
+        assert(coalesce);
d63baa
+
d63baa
+        if (coalesce->use_adaptive_rx_coalesce < 0 &&
d63baa
+            coalesce->use_adaptive_tx_coalesce < 0 &&
d63baa
+            !coalesce->rx_coalesce_usecs.set &&
d63baa
+            !coalesce->rx_max_coalesced_frames.set &&
d63baa
+            !coalesce->rx_coalesce_usecs_irq.set &&
d63baa
+            !coalesce->rx_max_coalesced_frames_irq.set &&
d63baa
+            !coalesce->tx_coalesce_usecs.set &&
d63baa
+            !coalesce->tx_max_coalesced_frames.set &&
d63baa
+            !coalesce->tx_coalesce_usecs_irq.set &&
d63baa
+            !coalesce->tx_max_coalesced_frames_irq.set &&
d63baa
+            !coalesce->stats_block_coalesce_usecs.set &&
d63baa
+            !coalesce->pkt_rate_low.set &&
d63baa
+            !coalesce->rx_coalesce_usecs_low.set &&
d63baa
+            !coalesce->rx_max_coalesced_frames_low.set &&
d63baa
+            !coalesce->tx_coalesce_usecs_low.set &&
d63baa
+            !coalesce->tx_max_coalesced_frames_low.set &&
d63baa
+            !coalesce->pkt_rate_high.set &&
d63baa
+            !coalesce->rx_coalesce_usecs_high.set &&
d63baa
+            !coalesce->rx_max_coalesced_frames_high.set &&
d63baa
+            !coalesce->tx_coalesce_usecs_high.set &&
d63baa
+            !coalesce->tx_max_coalesced_frames_high.set &&
d63baa
+            !coalesce->rate_sample_interval.set)
d63baa
+                return 0;
d63baa
+
d63baa
+        r = ethtool_connect(ethtool_fd);
d63baa
+        if (r < 0)
d63baa
+                return r;
d63baa
+
d63baa
+        strscpy(ifr.ifr_name, IFNAMSIZ, ifname);
d63baa
+
d63baa
+        r = ioctl(*ethtool_fd, SIOCETHTOOL, &ifr);
d63baa
+        if (r < 0)
d63baa
+                return -errno;
d63baa
+
d63baa
+        if (coalesce->use_adaptive_rx_coalesce >= 0)
d63baa
+                UPDATE(ecmd.use_adaptive_rx_coalesce, (uint32_t) coalesce->use_adaptive_rx_coalesce, need_update);
d63baa
+
d63baa
+        if (coalesce->use_adaptive_tx_coalesce >= 0)
d63baa
+                UPDATE(ecmd.use_adaptive_tx_coalesce, (uint32_t) coalesce->use_adaptive_tx_coalesce, need_update);
d63baa
+
d63baa
+        if (coalesce->rx_coalesce_usecs.set)
d63baa
+                UPDATE(ecmd.rx_coalesce_usecs, coalesce->rx_coalesce_usecs.value, need_update);
d63baa
+
d63baa
+        if (coalesce->rx_max_coalesced_frames.set)
d63baa
+                UPDATE(ecmd.rx_max_coalesced_frames, coalesce->rx_max_coalesced_frames.value, need_update);
d63baa
+
d63baa
+        if (coalesce->rx_coalesce_usecs_irq.set)
d63baa
+                UPDATE(ecmd.rx_coalesce_usecs_irq, coalesce->rx_coalesce_usecs_irq.value, need_update);
d63baa
+
d63baa
+        if (coalesce->rx_max_coalesced_frames_irq.set)
d63baa
+                UPDATE(ecmd.rx_max_coalesced_frames_irq, coalesce->rx_max_coalesced_frames_irq.value, need_update);
d63baa
+
d63baa
+        if (coalesce->tx_coalesce_usecs.set)
d63baa
+                UPDATE(ecmd.tx_coalesce_usecs, coalesce->tx_coalesce_usecs.value, need_update);
d63baa
+
d63baa
+        if (coalesce->tx_max_coalesced_frames.set)
d63baa
+                UPDATE(ecmd.tx_max_coalesced_frames, coalesce->tx_max_coalesced_frames.value, need_update);
d63baa
+
d63baa
+        if (coalesce->tx_coalesce_usecs_irq.set)
d63baa
+                UPDATE(ecmd.tx_coalesce_usecs_irq, coalesce->tx_coalesce_usecs_irq.value, need_update);
d63baa
+
d63baa
+        if (coalesce->tx_max_coalesced_frames_irq.set)
d63baa
+                UPDATE(ecmd.tx_max_coalesced_frames_irq, coalesce->tx_max_coalesced_frames_irq.value, need_update);
d63baa
+
d63baa
+        if (coalesce->stats_block_coalesce_usecs.set)
d63baa
+                UPDATE(ecmd.stats_block_coalesce_usecs, coalesce->stats_block_coalesce_usecs.value, need_update);
d63baa
+
d63baa
+        if (coalesce->pkt_rate_low.set)
d63baa
+                UPDATE(ecmd.pkt_rate_low, coalesce->pkt_rate_low.value, need_update);
d63baa
+
d63baa
+        if (coalesce->rx_coalesce_usecs_low.set)
d63baa
+                UPDATE(ecmd.rx_coalesce_usecs_low, coalesce->rx_coalesce_usecs_low.value, need_update);
d63baa
+
d63baa
+        if (coalesce->rx_max_coalesced_frames_low.set)
d63baa
+                UPDATE(ecmd.rx_max_coalesced_frames_low, coalesce->rx_max_coalesced_frames_low.value, need_update);
d63baa
+
d63baa
+        if (coalesce->tx_coalesce_usecs_low.set)
d63baa
+                UPDATE(ecmd.tx_coalesce_usecs_low, coalesce->tx_coalesce_usecs_low.value, need_update);
d63baa
+
d63baa
+        if (coalesce->tx_max_coalesced_frames_low.set)
d63baa
+                UPDATE(ecmd.tx_max_coalesced_frames_low, coalesce->tx_max_coalesced_frames_low.value, need_update);
d63baa
+
d63baa
+        if (coalesce->pkt_rate_high.set)
d63baa
+                UPDATE(ecmd.pkt_rate_high, coalesce->pkt_rate_high.value, need_update);
d63baa
+
d63baa
+        if (coalesce->rx_coalesce_usecs_high.set)
d63baa
+                UPDATE(ecmd.rx_coalesce_usecs_high, coalesce->rx_coalesce_usecs_high.value, need_update);
d63baa
+
d63baa
+        if (coalesce->rx_max_coalesced_frames_high.set)
d63baa
+                UPDATE(ecmd.rx_max_coalesced_frames_high, coalesce->rx_max_coalesced_frames_high.value, need_update);
d63baa
+
d63baa
+        if (coalesce->tx_coalesce_usecs_high.set)
d63baa
+                UPDATE(ecmd.tx_coalesce_usecs_high, coalesce->tx_coalesce_usecs_high.value, need_update);
d63baa
+
d63baa
+        if (coalesce->tx_max_coalesced_frames_high.set)
d63baa
+                UPDATE(ecmd.tx_max_coalesced_frames_high, coalesce->tx_max_coalesced_frames_high.value, need_update);
d63baa
+
d63baa
+        if (coalesce->rate_sample_interval.set)
d63baa
+                UPDATE(ecmd.rate_sample_interval, DIV_ROUND_UP(coalesce->rate_sample_interval.value, USEC_PER_SEC), need_update);
d63baa
+
d63baa
+        if (!need_update)
d63baa
+                return 0;
d63baa
+
d63baa
+        ecmd.cmd = ETHTOOL_SCOALESCE;
d63baa
+        r = ioctl(*ethtool_fd, SIOCETHTOOL, &ifr);
d63baa
+        if (r < 0)
d63baa
+                return -errno;
d63baa
+
d63baa
+        return 0;
d63baa
+}
d63baa
+
d63baa
 int config_parse_advertise(
d63baa
                 const char *unit,
d63baa
                 const char *filename,
d63baa
@@ -1182,128 +1307,3 @@ int config_parse_coalesce_sec(
d63baa
 
d63baa
         return 0;
d63baa
 }
d63baa
-
d63baa
-int ethtool_set_nic_coalesce_settings(int *ethtool_fd, const char *ifname, const netdev_coalesce_param *coalesce) {
d63baa
-        struct ethtool_coalesce ecmd = {
d63baa
-                .cmd = ETHTOOL_GCOALESCE,
d63baa
-        };
d63baa
-        struct ifreq ifr = {
d63baa
-                .ifr_data = (void*) &ecmd,
d63baa
-        };
d63baa
-        bool need_update = false;
d63baa
-        int r;
d63baa
-
d63baa
-        assert(ethtool_fd);
d63baa
-        assert(ifname);
d63baa
-        assert(coalesce);
d63baa
-
d63baa
-        if (coalesce->use_adaptive_rx_coalesce < 0 &&
d63baa
-            coalesce->use_adaptive_tx_coalesce < 0 &&
d63baa
-            !coalesce->rx_coalesce_usecs.set &&
d63baa
-            !coalesce->rx_max_coalesced_frames.set &&
d63baa
-            !coalesce->rx_coalesce_usecs_irq.set &&
d63baa
-            !coalesce->rx_max_coalesced_frames_irq.set &&
d63baa
-            !coalesce->tx_coalesce_usecs.set &&
d63baa
-            !coalesce->tx_max_coalesced_frames.set &&
d63baa
-            !coalesce->tx_coalesce_usecs_irq.set &&
d63baa
-            !coalesce->tx_max_coalesced_frames_irq.set &&
d63baa
-            !coalesce->stats_block_coalesce_usecs.set &&
d63baa
-            !coalesce->pkt_rate_low.set &&
d63baa
-            !coalesce->rx_coalesce_usecs_low.set &&
d63baa
-            !coalesce->rx_max_coalesced_frames_low.set &&
d63baa
-            !coalesce->tx_coalesce_usecs_low.set &&
d63baa
-            !coalesce->tx_max_coalesced_frames_low.set &&
d63baa
-            !coalesce->pkt_rate_high.set &&
d63baa
-            !coalesce->rx_coalesce_usecs_high.set &&
d63baa
-            !coalesce->rx_max_coalesced_frames_high.set &&
d63baa
-            !coalesce->tx_coalesce_usecs_high.set &&
d63baa
-            !coalesce->tx_max_coalesced_frames_high.set &&
d63baa
-            !coalesce->rate_sample_interval.set)
d63baa
-                return 0;
d63baa
-
d63baa
-        r = ethtool_connect(ethtool_fd);
d63baa
-        if (r < 0)
d63baa
-                return r;
d63baa
-
d63baa
-        strscpy(ifr.ifr_name, IFNAMSIZ, ifname);
d63baa
-
d63baa
-        r = ioctl(*ethtool_fd, SIOCETHTOOL, &ifr);
d63baa
-        if (r < 0)
d63baa
-                return -errno;
d63baa
-
d63baa
-        if (coalesce->use_adaptive_rx_coalesce >= 0)
d63baa
-                UPDATE(ecmd.use_adaptive_rx_coalesce, (uint32_t) coalesce->use_adaptive_rx_coalesce, need_update);
d63baa
-
d63baa
-        if (coalesce->use_adaptive_tx_coalesce >= 0)
d63baa
-                UPDATE(ecmd.use_adaptive_tx_coalesce, (uint32_t) coalesce->use_adaptive_tx_coalesce, need_update);
d63baa
-
d63baa
-        if (coalesce->rx_coalesce_usecs.set)
d63baa
-                UPDATE(ecmd.rx_coalesce_usecs, coalesce->rx_coalesce_usecs.value, need_update);
d63baa
-
d63baa
-        if (coalesce->rx_max_coalesced_frames.set)
d63baa
-                UPDATE(ecmd.rx_max_coalesced_frames, coalesce->rx_max_coalesced_frames.value, need_update);
d63baa
-
d63baa
-        if (coalesce->rx_coalesce_usecs_irq.set)
d63baa
-                UPDATE(ecmd.rx_coalesce_usecs_irq, coalesce->rx_coalesce_usecs_irq.value, need_update);
d63baa
-
d63baa
-        if (coalesce->rx_max_coalesced_frames_irq.set)
d63baa
-                UPDATE(ecmd.rx_max_coalesced_frames_irq, coalesce->rx_max_coalesced_frames_irq.value, need_update);
d63baa
-
d63baa
-        if (coalesce->tx_coalesce_usecs.set)
d63baa
-                UPDATE(ecmd.tx_coalesce_usecs, coalesce->tx_coalesce_usecs.value, need_update);
d63baa
-
d63baa
-        if (coalesce->tx_max_coalesced_frames.set)
d63baa
-                UPDATE(ecmd.tx_max_coalesced_frames, coalesce->tx_max_coalesced_frames.value, need_update);
d63baa
-
d63baa
-        if (coalesce->tx_coalesce_usecs_irq.set)
d63baa
-                UPDATE(ecmd.tx_coalesce_usecs_irq, coalesce->tx_coalesce_usecs_irq.value, need_update);
d63baa
-
d63baa
-        if (coalesce->tx_max_coalesced_frames_irq.set)
d63baa
-                UPDATE(ecmd.tx_max_coalesced_frames_irq, coalesce->tx_max_coalesced_frames_irq.value, need_update);
d63baa
-
d63baa
-        if (coalesce->stats_block_coalesce_usecs.set)
d63baa
-                UPDATE(ecmd.stats_block_coalesce_usecs, coalesce->stats_block_coalesce_usecs.value, need_update);
d63baa
-
d63baa
-        if (coalesce->pkt_rate_low.set)
d63baa
-                UPDATE(ecmd.pkt_rate_low, coalesce->pkt_rate_low.value, need_update);
d63baa
-
d63baa
-        if (coalesce->rx_coalesce_usecs_low.set)
d63baa
-                UPDATE(ecmd.rx_coalesce_usecs_low, coalesce->rx_coalesce_usecs_low.value, need_update);
d63baa
-
d63baa
-        if (coalesce->rx_max_coalesced_frames_low.set)
d63baa
-                UPDATE(ecmd.rx_max_coalesced_frames_low, coalesce->rx_max_coalesced_frames_low.value, need_update);
d63baa
-
d63baa
-        if (coalesce->tx_coalesce_usecs_low.set)
d63baa
-                UPDATE(ecmd.tx_coalesce_usecs_low, coalesce->tx_coalesce_usecs_low.value, need_update);
d63baa
-
d63baa
-        if (coalesce->tx_max_coalesced_frames_low.set)
d63baa
-                UPDATE(ecmd.tx_max_coalesced_frames_low, coalesce->tx_max_coalesced_frames_low.value, need_update);
d63baa
-
d63baa
-        if (coalesce->pkt_rate_high.set)
d63baa
-                UPDATE(ecmd.pkt_rate_high, coalesce->pkt_rate_high.value, need_update);
d63baa
-
d63baa
-        if (coalesce->rx_coalesce_usecs_high.set)
d63baa
-                UPDATE(ecmd.rx_coalesce_usecs_high, coalesce->rx_coalesce_usecs_high.value, need_update);
d63baa
-
d63baa
-        if (coalesce->rx_max_coalesced_frames_high.set)
d63baa
-                UPDATE(ecmd.rx_max_coalesced_frames_high, coalesce->rx_max_coalesced_frames_high.value, need_update);
d63baa
-
d63baa
-        if (coalesce->tx_coalesce_usecs_high.set)
d63baa
-                UPDATE(ecmd.tx_coalesce_usecs_high, coalesce->tx_coalesce_usecs_high.value, need_update);
d63baa
-
d63baa
-        if (coalesce->tx_max_coalesced_frames_high.set)
d63baa
-                UPDATE(ecmd.tx_max_coalesced_frames_high, coalesce->tx_max_coalesced_frames_high.value, need_update);
d63baa
-
d63baa
-        if (coalesce->rate_sample_interval.set)
d63baa
-                UPDATE(ecmd.rate_sample_interval, DIV_ROUND_UP(coalesce->rate_sample_interval.value, USEC_PER_SEC), need_update);
d63baa
-
d63baa
-        if (!need_update)
d63baa
-                return 0;
d63baa
-
d63baa
-        ecmd.cmd = ETHTOOL_SCOALESCE;
d63baa
-        r = ioctl(*ethtool_fd, SIOCETHTOOL, &ifr);
d63baa
-        if (r < 0)
d63baa
-                return -errno;
d63baa
-
d63baa
-        return 0;
d63baa
-}
d63baa
d63baa
From ee7512404b5de7c5ac36e09436379fada2ed84e7 Mon Sep 17 00:00:00 2001
d63baa
From: Yu Watanabe <watanabe.yu+github@gmail.com>
d63baa
Date: Thu, 26 Aug 2021 03:34:23 +0900
d63baa
Subject: [PATCH 2/2] udev/net: initialize coalesce tristate variables
d63baa
d63baa
Otherwise, 99-default.link may introduce something like the
d63baa
following warnings:
d63baa
----
d63baa
Aug 26 03:23:59 systemd-udevd[519]: wlan0: Could not set coalesce settings, ignoring: Operation not supported
d63baa
Aug 26 03:24:00 systemd-udevd[547]: wlp59s0: Could not set coalesce settings, ignoring: Operation not supported
d63baa
----
d63baa
d63baa
Follow-up for 6c35ea5ef0231d519ff24d43a57a72cebab6a121.
d63baa
---
d63baa
 src/udev/net/link-config.c | 2 ++
d63baa
 1 file changed, 2 insertions(+)
d63baa
d63baa
diff --git a/src/udev/net/link-config.c b/src/udev/net/link-config.c
d63baa
index 69f651435034..4963ba2fae81 100644
d63baa
--- a/src/udev/net/link-config.c
d63baa
+++ b/src/udev/net/link-config.c
d63baa
@@ -142,6 +142,8 @@ int link_load_one(LinkConfigContext *ctx, const char *filename) {
d63baa
                 .tx_flow_control = -1,
d63baa
                 .autoneg_flow_control = -1,
d63baa
                 .txqueuelen = UINT32_MAX,
d63baa
+                .coalesce.use_adaptive_rx_coalesce = -1,
d63baa
+                .coalesce.use_adaptive_tx_coalesce = -1,
d63baa
         };
d63baa
 
d63baa
         for (i = 0; i < ELEMENTSOF(link->features); i++)