diff options
| author | Thomas Haller <thaller@redhat.com> | 2020-05-26 19:02:18 +0200 |
|---|---|---|
| committer | Thomas Haller <thaller@redhat.com> | 2020-05-29 12:49:04 +0200 |
| commit | 23d0a76b16205bcda082ba07786efbd49030d171 (patch) | |
| tree | e049db774e346e193e0f16c827897d90c3dd289b /src/devices/nm-device.c | |
| parent | 9c236416c854ddfb1e99ddd7215cc197e8b86c64 (diff) | |
| download | NetworkManager-23d0a76b16205bcda082ba07786efbd49030d171.tar.gz | |
device: inline nm_platform_ethtool_init_ring() function
nm_platform_ethtool_init_ring() only has one caller. It's simpler to
drop the function and implement it at the only place where it is needed.
Maybe there could be a place for a function to initialize NMEthtoolRingState,
one option after the other. However, at the moment there is only one
user, so don't implement it.
This fixes various minor issues:
- the function had a NMPlatform argument, although the argument
is not used. Thus function merely operates on a NMEthtoolRingState
instance and shouldn't have a nm_platform_*() name.
- nm_platform_ethtool_init_ring() returned a boolean, but all
code paths (except assertion failures) returned success.
- as the function returned an error status, the caller was compelled
to handle an error that could never happen.
- the option was specified by name, although we already have a more
efficient way to express the option: the NMEthtoolID. Also, the
caller already needed to resolve the name to the NMEthtoolID, so
there was no need to again lookup the ID by name.
Diffstat (limited to 'src/devices/nm-device.c')
| -rw-r--r-- | src/devices/nm-device.c | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/src/devices/nm-device.c b/src/devices/nm-device.c index aae1949887..327df52c6c 100644 --- a/src/devices/nm-device.c +++ b/src/devices/nm-device.c @@ -999,8 +999,12 @@ _ethtool_ring_set (NMDevice *self, g_hash_table_iter_init (&iter, hash); while (g_hash_table_iter_next (&iter, (gpointer *) &name, (gpointer *) &variant)) { - if (!nm_ethtool_optname_is_ring (name)) + NMEthtoolID ethtool_id = nm_ethtool_id_get_by_name (name); + guint32 u32; + + if (!nm_ethtool_id_is_ring (ethtool_id)) continue; + nm_assert (g_variant_is_of_type (variant, G_VARIANT_TYPE_UINT32)); if (!has_old) { @@ -1014,12 +1018,23 @@ _ethtool_ring_set (NMDevice *self, ring_new = ring_old; } - if (!nm_platform_ethtool_init_ring (platform, - &ring_new, - name, - g_variant_get_uint32 (variant))) { - _LOGW (LOGD_DEVICE, "ethtool: invalid ring setting %s", name); - return; + u32 = g_variant_get_uint32 (variant); + + switch (ethtool_id) { + case NM_ETHTOOL_ID_RING_RX: + ring_new.rx_pending = u32; + break; + case NM_ETHTOOL_ID_RING_RX_JUMBO: + ring_new.rx_jumbo_pending = u32; + break; + case NM_ETHTOOL_ID_RING_RX_MINI: + ring_new.rx_mini_pending = u32; + break; + case NM_ETHTOOL_ID_RING_TX: + ring_new.tx_pending = u32; + break; + default: + nm_assert_not_reached (); } } @@ -1056,8 +1071,6 @@ _ethtool_state_reset (NMDevice *self) _ethtool_ring_reset (self, platform, ethtool_state); } - - static void _ethtool_state_set (NMDevice *self) { |
