1c4d83
From 0e5c20b7a4f47fd3f8edbc2735810ea3513360bb Mon Sep 17 00:00:00 2001
1c4d83
From: Daan De Meyer <daan.j.demeyer@gmail.com>
1c4d83
Date: Thu, 19 Aug 2021 13:44:35 +0100
1c4d83
Subject: [PATCH] link: Add support for rx-gro-hw nic feature
1c4d83
1c4d83
---
1c4d83
 man/systemd.link.xml                       |  7 +++++++
1c4d83
 src/shared/ethtool-util.c                  | 15 ++++++++-------
1c4d83
 src/shared/ethtool-util.h                  |  1 +
1c4d83
 src/udev/net/link-config-gperf.gperf       |  1 +
1c4d83
 test/fuzz/fuzz-link-parser/directives.link |  1 +
1c4d83
 5 files changed, 18 insertions(+), 7 deletions(-)
1c4d83
1c4d83
diff --git a/man/systemd.link.xml b/man/systemd.link.xml
1c4d83
index 6d8dcb9af7..638a1522cd 100644
1c4d83
--- a/man/systemd.link.xml
1c4d83
+++ b/man/systemd.link.xml
1c4d83
@@ -701,6 +701,13 @@
1c4d83
           When unset, the kernel's default will be used.</para>
1c4d83
         </listitem>
1c4d83
       </varlistentry>
1c4d83
+      <varlistentry>
1c4d83
+        <term><varname>GenericReceiveOffloadHardware=</varname></term>
1c4d83
+        <listitem>
1c4d83
+          <para>Takes a boolean. If set to true, hardware accelerated Generic Receive Offload (GRO) is
1c4d83
+          enabled. When unset, the kernel's default will be used.</para>
1c4d83
+        </listitem>
1c4d83
+      </varlistentry>
1c4d83
       <varlistentry>
1c4d83
         <term><varname>LargeReceiveOffload=</varname></term>
1c4d83
         <listitem>
1c4d83
diff --git a/src/shared/ethtool-util.c b/src/shared/ethtool-util.c
1c4d83
index f7f553dd29..a08bb2b7f5 100644
1c4d83
--- a/src/shared/ethtool-util.c
1c4d83
+++ b/src/shared/ethtool-util.c
1c4d83
@@ -70,13 +70,14 @@ DEFINE_STRING_TABLE_LOOKUP(port, NetDevPort);
1c4d83
 DEFINE_CONFIG_PARSE_ENUM(config_parse_port, port, NetDevPort, "Failed to parse Port setting");
1c4d83
 
1c4d83
 static const char* const netdev_feature_table[_NET_DEV_FEAT_MAX] = {
1c4d83
-        [NET_DEV_FEAT_RX]   = "rx-checksum",
1c4d83
-        [NET_DEV_FEAT_TX]   = "tx-checksum-", /* The suffix "-" means any feature beginning with "tx-checksum-" */
1c4d83
-        [NET_DEV_FEAT_GSO]  = "tx-generic-segmentation",
1c4d83
-        [NET_DEV_FEAT_GRO]  = "rx-gro",
1c4d83
-        [NET_DEV_FEAT_LRO]  = "rx-lro",
1c4d83
-        [NET_DEV_FEAT_TSO]  = "tx-tcp-segmentation",
1c4d83
-        [NET_DEV_FEAT_TSO6] = "tx-tcp6-segmentation",
1c4d83
+        [NET_DEV_FEAT_RX]     = "rx-checksum",
1c4d83
+        [NET_DEV_FEAT_TX]     = "tx-checksum-", /* The suffix "-" means any feature beginning with "tx-checksum-" */
1c4d83
+        [NET_DEV_FEAT_GSO]    = "tx-generic-segmentation",
1c4d83
+        [NET_DEV_FEAT_GRO]    = "rx-gro",
1c4d83
+        [NET_DEV_FEAT_GRO_HW] = "rx-gro-hw",
1c4d83
+        [NET_DEV_FEAT_LRO]    = "rx-lro",
1c4d83
+        [NET_DEV_FEAT_TSO]    = "tx-tcp-segmentation",
1c4d83
+        [NET_DEV_FEAT_TSO6]   = "tx-tcp6-segmentation",
1c4d83
 };
1c4d83
 
1c4d83
 static const char* const ethtool_link_mode_bit_table[] = {
1c4d83
diff --git a/src/shared/ethtool-util.h b/src/shared/ethtool-util.h
1c4d83
index bb0333775c..2181ab6fd6 100644
1c4d83
--- a/src/shared/ethtool-util.h
1c4d83
+++ b/src/shared/ethtool-util.h
1c4d83
@@ -23,6 +23,7 @@ typedef enum NetDevFeature {
1c4d83
         NET_DEV_FEAT_TX,
1c4d83
         NET_DEV_FEAT_GSO,
1c4d83
         NET_DEV_FEAT_GRO,
1c4d83
+        NET_DEV_FEAT_GRO_HW,
1c4d83
         NET_DEV_FEAT_LRO,
1c4d83
         NET_DEV_FEAT_TSO,
1c4d83
         NET_DEV_FEAT_TSO6,
1c4d83
diff --git a/src/udev/net/link-config-gperf.gperf b/src/udev/net/link-config-gperf.gperf
1c4d83
index f800de8386..44b46cb17c 100644
1c4d83
--- a/src/udev/net/link-config-gperf.gperf
1c4d83
+++ b/src/udev/net/link-config-gperf.gperf
1c4d83
@@ -57,6 +57,7 @@ Link.TCPSegmentationOffload,              config_parse_tristate,
1c4d83
 Link.TCP6SegmentationOffload,             config_parse_tristate,                 0,                             offsetof(LinkConfig, features[NET_DEV_FEAT_TSO6])
1c4d83
 Link.UDPSegmentationOffload,              config_parse_warn_compat,              DISABLED_LEGACY,               0
1c4d83
 Link.GenericReceiveOffload,               config_parse_tristate,                 0,                             offsetof(LinkConfig, features[NET_DEV_FEAT_GRO])
1c4d83
+Link.GenericReceiveOffloadHardware,       config_parse_tristate,                 0,                             offsetof(LinkConfig, features[NET_DEV_FEAT_GRO_HW])
1c4d83
 Link.LargeReceiveOffload,                 config_parse_tristate,                 0,                             offsetof(LinkConfig, features[NET_DEV_FEAT_LRO])
1c4d83
 Link.RxChannels,                          config_parse_ring_buffer_or_channel,   0,                             offsetof(LinkConfig, channels.rx)
1c4d83
 Link.TxChannels,                          config_parse_ring_buffer_or_channel,   0,                             offsetof(LinkConfig, channels.tx)
1c4d83
diff --git a/test/fuzz/fuzz-link-parser/directives.link b/test/fuzz/fuzz-link-parser/directives.link
1c4d83
index 5f232ce698..b5cffb1a27 100644
1c4d83
--- a/test/fuzz/fuzz-link-parser/directives.link
1c4d83
+++ b/test/fuzz/fuzz-link-parser/directives.link
1c4d83
@@ -36,6 +36,7 @@ TCPSegmentationOffload=
1c4d83
 TCP6SegmentationOffload=
1c4d83
 UDPSegmentationOffload=
1c4d83
 GenericReceiveOffload=
1c4d83
+GenericReceiveOffloadHardware=
1c4d83
 LargeReceiveOffload=
1c4d83
 RxChannels=
1c4d83
 TxChannels=
1c4d83
-- 
1c4d83
2.31.1
1c4d83