summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAntonio Cardace <acardace@redhat.com>2020-05-07 17:12:19 +0200
committerAntonio Cardace <acardace@redhat.com>2020-05-13 10:15:23 +0200
commit4fce8b3efbd633d6fd99f96e468818f7a7ddd02f (patch)
tree29d0b756bceacde61a328d8bf57337be0b7f9cfa
parentb0240db06883157636c0efb364c9fad0066dafa4 (diff)
ifcfg-rh: add support for ethtool coalesce settings
Also update unit tests. https://bugzilla.redhat.com/show_bug.cgi?id=1614700
-rw-r--r--src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c42
-rw-r--r--src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c49
-rw-r--r--src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h10
-rw-r--r--src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c17
-rw-r--r--src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test_write_wired_auto_negotiate_on.cexpected2
-rw-r--r--src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c12
6 files changed, 115 insertions, 17 deletions
diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
index 6b1f16956..11754e70f 100644
--- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
+++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-reader.c
@@ -4288,7 +4288,8 @@ parse_ethtool_option (const char *value,
d = nms_ifcfg_rh_utils_get_ethtool_by_name (opt);
- if (!d) {
+ if ( !d
+ || !nm_ethtool_id_is_feature (d->id)) {
if (onoff != NM_TERNARY_DEFAULT) {
/* the next value is just the on/off argument. Skip it too. */
i++;
@@ -4309,6 +4310,45 @@ parse_ethtool_option (const char *value,
d->optname,
onoff);
}
+ } else if (NM_IN_STRSET (words[0], "-C", "--coalesce")) {
+ if (!words[1]) {
+ /* first argument must be the interface name. This is invalid. */
+ return;
+ }
+
+ if (!*out_s_ethtool)
+ *out_s_ethtool = NM_SETTING_ETHTOOL (nm_setting_ethtool_new ());
+
+ for (i = 2; words[i]; ) {
+ const char *opt = words[i];
+ const char *opt_val = words[++i];
+ const NMEthtoolData *d = NULL;
+ gint64 i64;
+
+ i64 = _nm_utils_ascii_str_to_int64 (opt_val, 10, 0, G_MAXUINT32, -1);
+ d = nms_ifcfg_rh_utils_get_ethtool_by_name (opt);
+
+ if ( !d
+ || !nm_ethtool_id_is_coalesce (d->id)) {
+ if (i64 != -1) {
+ /* the next value is just the argument. Skip it too. */
+ i++;
+ }
+ /* silently ignore unsupported coalesce settings. */
+ continue;
+ }
+
+ i++;
+
+ if (i64 == -1) {
+ PARSE_WARNING ("Expects integer argument for setting '%s'", opt);
+ continue;
+ }
+
+ nm_setting_ethtool_set_coalesce (*out_s_ethtool,
+ d->optname,
+ (guint32) i64);
+ }
}
return;
}
diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c
index 06d4928ae..08700a8a2 100644
--- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c
+++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.c
@@ -522,9 +522,30 @@ nms_ifcfg_rh_utils_user_key_decode (const char *name, GString *str_buffer)
/*****************************************************************************/
const char *const _nm_ethtool_ifcfg_names[] = {
-#define ETHT_NAME(eid, ename) \
-[eid - _NM_ETHTOOL_ID_FEATURE_FIRST] = ""ename""
- /* indexed by NMEthtoolID - _NM_ETHTOOL_ID_FEATURE_FIRST */
+#define ETHT_NAME(eid, ename) [eid] = ""ename""
+ /* indexed by NMEthtoolID */
+ ETHT_NAME (NM_ETHTOOL_ID_COALESCE_ADAPTIVE_RX, "adaptive-rx"),
+ ETHT_NAME (NM_ETHTOOL_ID_COALESCE_ADAPTIVE_TX, "adaptive-tx"),
+ ETHT_NAME (NM_ETHTOOL_ID_COALESCE_RX_FRAMES, "rx-frames"),
+ ETHT_NAME (NM_ETHTOOL_ID_COALESCE_RX_FRAMES_HIGH, "rx-frames-high"),
+ ETHT_NAME (NM_ETHTOOL_ID_COALESCE_RX_FRAMES_IRQ, "rx-frames-irq"),
+ ETHT_NAME (NM_ETHTOOL_ID_COALESCE_RX_FRAMES_LOW, "rx-frames-low"),
+ ETHT_NAME (NM_ETHTOOL_ID_COALESCE_PKT_RATE_HIGH, "pkt-rate-high"),
+ ETHT_NAME (NM_ETHTOOL_ID_COALESCE_PKT_RATE_LOW, "pkt-rate-low"),
+ ETHT_NAME (NM_ETHTOOL_ID_COALESCE_RX_USECS, "rx-usecs"),
+ ETHT_NAME (NM_ETHTOOL_ID_COALESCE_RX_USECS_HIGH, "rx-usecs-high"),
+ ETHT_NAME (NM_ETHTOOL_ID_COALESCE_RX_USECS_IRQ, "rx-usecs-irq"),
+ ETHT_NAME (NM_ETHTOOL_ID_COALESCE_RX_USECS_LOW, "rx-usecs-low"),
+ ETHT_NAME (NM_ETHTOOL_ID_COALESCE_SAMPLE_INTERVAL, "sample-interval"),
+ ETHT_NAME (NM_ETHTOOL_ID_COALESCE_STATS_BLOCK_USECS, "stats-block-usecs"),
+ ETHT_NAME (NM_ETHTOOL_ID_COALESCE_TX_FRAMES, "tx-frames"),
+ ETHT_NAME (NM_ETHTOOL_ID_COALESCE_TX_FRAMES_HIGH, "tx-frames-high"),
+ ETHT_NAME (NM_ETHTOOL_ID_COALESCE_TX_FRAMES_IRQ, "tx-frames-irq"),
+ ETHT_NAME (NM_ETHTOOL_ID_COALESCE_TX_FRAMES_LOW, "tx-frames-low"),
+ ETHT_NAME (NM_ETHTOOL_ID_COALESCE_TX_USECS, "tx-usecs"),
+ ETHT_NAME (NM_ETHTOOL_ID_COALESCE_TX_USECS_HIGH, "tx-usecs-high"),
+ ETHT_NAME (NM_ETHTOOL_ID_COALESCE_TX_USECS_IRQ, "tx-usecs-irq"),
+ ETHT_NAME (NM_ETHTOOL_ID_COALESCE_TX_USECS_LOW, "tx-usecs-low"),
ETHT_NAME (NM_ETHTOOL_ID_FEATURE_ESP_HW_OFFLOAD, "esp-hw-offload"),
ETHT_NAME (NM_ETHTOOL_ID_FEATURE_ESP_TX_CSUM_HW_OFFLOAD, "esp-tx-csum-hw-offload"),
ETHT_NAME (NM_ETHTOOL_ID_FEATURE_FCOE_MTU, "fcoe-mtu"),
@@ -598,6 +619,8 @@ NM_UTILS_STRING_TABLE_LOOKUP_DEFINE (
* the case and if yes, map them to the corresponding NetworkManager's features.
*
* That is why there are duplicate IDs in this list. */
+ { "adaptive-rx", NM_ETHTOOL_ID_COALESCE_ADAPTIVE_RX },
+ { "adaptive-tx", NM_ETHTOOL_ID_COALESCE_ADAPTIVE_TX },
{ "esp-hw-offload", NM_ETHTOOL_ID_FEATURE_ESP_HW_OFFLOAD },
{ "esp-tx-csum-hw-offload", NM_ETHTOOL_ID_FEATURE_ESP_TX_CSUM_HW_OFFLOAD },
{ "fcoe-mtu", NM_ETHTOOL_ID_FEATURE_FCOE_MTU },
@@ -609,23 +632,35 @@ NM_UTILS_STRING_TABLE_LOOKUP_DEFINE (
{ "loopback", NM_ETHTOOL_ID_FEATURE_LOOPBACK },
{ "lro", NM_ETHTOOL_ID_FEATURE_LRO },
{ "ntuple", NM_ETHTOOL_ID_FEATURE_NTUPLE },
+ { "pkt-rate-high", NM_ETHTOOL_ID_COALESCE_PKT_RATE_HIGH },
+ { "pkt-rate-low", NM_ETHTOOL_ID_COALESCE_PKT_RATE_LOW },
{ "rx", NM_ETHTOOL_ID_FEATURE_RX },
{ "rx-all", NM_ETHTOOL_ID_FEATURE_RX_ALL },
{ "rx-checksum", NM_ETHTOOL_ID_FEATURE_RX }, // kernel-only name
{ "rx-fcs", NM_ETHTOOL_ID_FEATURE_RX_FCS },
+ { "rx-frames", NM_ETHTOOL_ID_COALESCE_RX_FRAMES },
+ { "rx-frames-high", NM_ETHTOOL_ID_COALESCE_RX_FRAMES_HIGH },
+ { "rx-frames-irq", NM_ETHTOOL_ID_COALESCE_RX_FRAMES_IRQ },
+ { "rx-frames-low", NM_ETHTOOL_ID_COALESCE_RX_FRAMES_LOW },
{ "rx-gro", NM_ETHTOOL_ID_FEATURE_GRO }, // kernel-only name
{ "rx-gro-hw", NM_ETHTOOL_ID_FEATURE_RX_GRO_HW },
{ "rx-hashing", NM_ETHTOOL_ID_FEATURE_RXHASH }, // kernel-only name
{ "rx-lro", NM_ETHTOOL_ID_FEATURE_LRO }, // kernel-only name
{ "rx-ntuple-filter", NM_ETHTOOL_ID_FEATURE_NTUPLE }, // kernel-only name
{ "rx-udp_tunnel-port-offload", NM_ETHTOOL_ID_FEATURE_RX_UDP_TUNNEL_PORT_OFFLOAD },
+ { "rx-usecs", NM_ETHTOOL_ID_COALESCE_RX_USECS },
+ { "rx-usecs-high", NM_ETHTOOL_ID_COALESCE_RX_USECS_HIGH },
+ { "rx-usecs-irq", NM_ETHTOOL_ID_COALESCE_RX_USECS_IRQ },
+ { "rx-usecs-low", NM_ETHTOOL_ID_COALESCE_RX_USECS_LOW },
{ "rx-vlan-filter", NM_ETHTOOL_ID_FEATURE_RX_VLAN_FILTER },
{ "rx-vlan-hw-parse", NM_ETHTOOL_ID_FEATURE_RXVLAN }, // kernel-only name
{ "rx-vlan-stag-filter", NM_ETHTOOL_ID_FEATURE_RX_VLAN_STAG_FILTER },
{ "rx-vlan-stag-hw-parse", NM_ETHTOOL_ID_FEATURE_RX_VLAN_STAG_HW_PARSE },
{ "rxhash", NM_ETHTOOL_ID_FEATURE_RXHASH },
{ "rxvlan", NM_ETHTOOL_ID_FEATURE_RXVLAN },
+ { "sample-interval", NM_ETHTOOL_ID_COALESCE_SAMPLE_INTERVAL },
{ "sg", NM_ETHTOOL_ID_FEATURE_SG },
+ { "stats-block-usecs", NM_ETHTOOL_ID_COALESCE_STATS_BLOCK_USECS },
{ "tls-hw-record", NM_ETHTOOL_ID_FEATURE_TLS_HW_RECORD },
{ "tls-hw-tx-offload", NM_ETHTOOL_ID_FEATURE_TLS_HW_TX_OFFLOAD },
{ "tso", NM_ETHTOOL_ID_FEATURE_TSO },
@@ -637,6 +672,10 @@ NM_UTILS_STRING_TABLE_LOOKUP_DEFINE (
{ "tx-checksum-sctp", NM_ETHTOOL_ID_FEATURE_TX_CHECKSUM_SCTP },
{ "tx-esp-segmentation", NM_ETHTOOL_ID_FEATURE_TX_ESP_SEGMENTATION },
{ "tx-fcoe-segmentation", NM_ETHTOOL_ID_FEATURE_TX_FCOE_SEGMENTATION },
+ { "tx-frames", NM_ETHTOOL_ID_COALESCE_TX_FRAMES },
+ { "tx-frames-high", NM_ETHTOOL_ID_COALESCE_TX_FRAMES_HIGH },
+ { "tx-frames-irq", NM_ETHTOOL_ID_COALESCE_TX_FRAMES_IRQ },
+ { "tx-frames-low", NM_ETHTOOL_ID_COALESCE_TX_FRAMES_LOW },
{ "tx-generic-segmentation", NM_ETHTOOL_ID_FEATURE_GSO }, // kernel-only name
{ "tx-gre-csum-segmentation", NM_ETHTOOL_ID_FEATURE_TX_GRE_CSUM_SEGMENTATION },
{ "tx-gre-segmentation", NM_ETHTOOL_ID_FEATURE_TX_GRE_SEGMENTATION },
@@ -655,6 +694,10 @@ NM_UTILS_STRING_TABLE_LOOKUP_DEFINE (
{ "tx-udp-segmentation", NM_ETHTOOL_ID_FEATURE_TX_UDP_SEGMENTATION },
{ "tx-udp_tnl-csum-segmentation", NM_ETHTOOL_ID_FEATURE_TX_UDP_TNL_CSUM_SEGMENTATION },
{ "tx-udp_tnl-segmentation", NM_ETHTOOL_ID_FEATURE_TX_UDP_TNL_SEGMENTATION },
+ { "tx-usecs", NM_ETHTOOL_ID_COALESCE_TX_USECS },
+ { "tx-usecs-high", NM_ETHTOOL_ID_COALESCE_TX_USECS_HIGH },
+ { "tx-usecs-irq", NM_ETHTOOL_ID_COALESCE_TX_USECS_IRQ },
+ { "tx-usecs-low", NM_ETHTOOL_ID_COALESCE_TX_USECS_LOW },
{ "tx-vlan-hw-insert", NM_ETHTOOL_ID_FEATURE_TXVLAN }, // kernel-only name
{ "tx-vlan-stag-hw-insert", NM_ETHTOOL_ID_FEATURE_TX_VLAN_STAG_HW_INSERT },
{ "txvlan", NM_ETHTOOL_ID_FEATURE_TXVLAN },
diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h
index 805f1581f..ed41a3eab 100644
--- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h
+++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-utils.h
@@ -141,16 +141,16 @@ const NMSIfcfgKeyTypeInfo *nms_ifcfg_rh_utils_is_well_known_key (const char *key
/*****************************************************************************/
-extern const char *const _nm_ethtool_ifcfg_names[_NM_ETHTOOL_ID_FEATURE_NUM];
+extern const char *const _nm_ethtool_ifcfg_names[_NM_ETHTOOL_ID_NUM];
static inline const char *
nms_ifcfg_rh_utils_get_ethtool_name (NMEthtoolID ethtool_id)
{
- nm_assert (ethtool_id >= _NM_ETHTOOL_ID_FEATURE_FIRST && ethtool_id <= _NM_ETHTOOL_ID_FEATURE_LAST);
- nm_assert ((ethtool_id - _NM_ETHTOOL_ID_FEATURE_FIRST) < G_N_ELEMENTS (_nm_ethtool_ifcfg_names));
- nm_assert (_nm_ethtool_ifcfg_names[ethtool_id - _NM_ETHTOOL_ID_FEATURE_FIRST]);
+ nm_assert (ethtool_id >= _NM_ETHTOOL_ID_FIRST && ethtool_id <= _NM_ETHTOOL_ID_LAST);
+ nm_assert (ethtool_id < G_N_ELEMENTS (_nm_ethtool_ifcfg_names));
+ nm_assert (_nm_ethtool_ifcfg_names[ethtool_id]);
- return _nm_ethtool_ifcfg_names[ethtool_id - _NM_ETHTOOL_ID_FEATURE_FIRST];
+ return _nm_ethtool_ifcfg_names[ethtool_id];
}
const NMEthtoolData *nms_ifcfg_rh_utils_get_ethtool_by_name (const char *name);
diff --git a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c
index b9f8161b9..64fdd8b18 100644
--- a/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c
+++ b/src/settings/plugins/ifcfg-rh/nms-ifcfg-rh-writer.c
@@ -1195,6 +1195,23 @@ write_ethtool_setting (NMConnection *connection, shvarFile *ifcfg, GError **erro
g_string_append (str, nms_ifcfg_rh_utils_get_ethtool_name (ethtool_id));
g_string_append (str, val == NM_TERNARY_TRUE ? " on" : " off");
}
+
+ g_string_append (str, " ; -C ");
+ g_string_append (str, iface ?: "net0");
+
+ for (ethtool_id = _NM_ETHTOOL_ID_COALESCE_FIRST; ethtool_id <= _NM_ETHTOOL_ID_COALESCE_LAST; ethtool_id++) {
+ const NMEthtoolData *ed = nm_ethtool_data[ethtool_id];
+ guint32 val;
+
+ nm_assert (nms_ifcfg_rh_utils_get_ethtool_name (ethtool_id));
+
+ if (!nm_setting_ethtool_get_coalesce (s_ethtool, ed->optname, &val))
+ continue;
+
+ g_string_append_c (str, ' ');
+ g_string_append (str, nms_ifcfg_rh_utils_get_ethtool_name (ethtool_id));
+ g_string_append_printf (str, " %"G_GUINT32_FORMAT, val);
+ }
}
if (str) {
diff --git a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test_write_wired_auto_negotiate_on.cexpected b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test_write_wired_auto_negotiate_on.cexpected
index 426085765..39fdce868 100644
--- a/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test_write_wired_auto_negotiate_on.cexpected
+++ b/src/settings/plugins/ifcfg-rh/tests/network-scripts/ifcfg-test_write_wired_auto_negotiate_on.cexpected
@@ -1,7 +1,7 @@
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
-ETHTOOL_OPTS="autoneg on ; -K net0 rxvlan off tx on"
+ETHTOOL_OPTS="autoneg on ; -K net0 rxvlan off tx on ; -C net0"
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
diff --git a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
index d0b9ffb8d..34d4061b1 100644
--- a/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
+++ b/src/settings/plugins/ifcfg-rh/tests/test-ifcfg-rh.c
@@ -10368,18 +10368,16 @@ test_ethtool_names (void)
NMEthtoolID id;
int i;
- for (id = _NM_ETHTOOL_ID_FEATURE_FIRST; id <= _NM_ETHTOOL_ID_FEATURE_LAST; id++) {
+ for (id = _NM_ETHTOOL_ID_FIRST; id <= _NM_ETHTOOL_ID_LAST; id++) {
const char *ifcfg_rh_name;
- int idx;
- idx = id - _NM_ETHTOOL_ID_FEATURE_FIRST;
- g_assert (idx >= 0);
- g_assert (idx < G_N_ELEMENTS (_nm_ethtool_ifcfg_names));
- ifcfg_rh_name = _nm_ethtool_ifcfg_names[idx];
+ g_assert (id >= 0);
+ g_assert (id < G_N_ELEMENTS (_nm_ethtool_ifcfg_names));
+ ifcfg_rh_name = _nm_ethtool_ifcfg_names[id];
g_assert (ifcfg_rh_name && ifcfg_rh_name[0]);
for (i = 0; i < G_N_ELEMENTS (_nm_ethtool_ifcfg_names); i++) {
- if (i != idx)
+ if (i != id)
g_assert_cmpstr (ifcfg_rh_name, !=, _nm_ethtool_ifcfg_names[i]);
}