update code

This commit is contained in:
zhuchunyi 2019-11-06 19:06:33 +08:00
parent 7506c3bd33
commit cdfab73072
7 changed files with 37 additions and 337 deletions

View File

@ -1,179 +0,0 @@
From 8fb3b26d62aa31893608ef702d28e1029569ce79 Mon Sep 17 00:00:00 2001
From: Nicholas Nunley <nicholas.d.nunley@intel.com>
Date: Fri, 1 Mar 2019 00:15:28 -0800
Subject: [PATCH 26/39] ethtool: move cmdline_coalesce out of do_scoalesce
Move the definition of cmdline_coalesce out of do_scoalesce and into a
macro so it can be resused across functions.
No behavior change.
Based on patch by Kan Liang <kan.liang@intel.com>
Signed-off-by: Nicholas Nunley <nicholas.d.nunley@intel.com>
Reviewed-by: Michal Kubecek <mkubecek@suse.cz>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
---
ethtool.c | 142 ++++++++++++++++++++++++++++++++------------------------------
1 file changed, 74 insertions(+), 68 deletions(-)
diff --git a/ethtool.c b/ethtool.c
index 4ba98bf..25339fb 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -2148,78 +2148,84 @@ static int do_gcoalesce(struct cmd_context *ctx)
return 0;
}
+#define DECLARE_COALESCE_OPTION_VARS() \
+ s32 coal_stats_wanted = -1; \
+ int coal_adaptive_rx_wanted = -1; \
+ int coal_adaptive_tx_wanted = -1; \
+ s32 coal_sample_rate_wanted = -1; \
+ s32 coal_pkt_rate_low_wanted = -1; \
+ s32 coal_pkt_rate_high_wanted = -1; \
+ s32 coal_rx_usec_wanted = -1; \
+ s32 coal_rx_frames_wanted = -1; \
+ s32 coal_rx_usec_irq_wanted = -1; \
+ s32 coal_rx_frames_irq_wanted = -1; \
+ s32 coal_tx_usec_wanted = -1; \
+ s32 coal_tx_frames_wanted = -1; \
+ s32 coal_tx_usec_irq_wanted = -1; \
+ s32 coal_tx_frames_irq_wanted = -1; \
+ s32 coal_rx_usec_low_wanted = -1; \
+ s32 coal_rx_frames_low_wanted = -1; \
+ s32 coal_tx_usec_low_wanted = -1; \
+ s32 coal_tx_frames_low_wanted = -1; \
+ s32 coal_rx_usec_high_wanted = -1; \
+ s32 coal_rx_frames_high_wanted = -1; \
+ s32 coal_tx_usec_high_wanted = -1; \
+ s32 coal_tx_frames_high_wanted = -1
+
+#define COALESCE_CMDLINE_INFO(__ecoal) \
+{ \
+ { "adaptive-rx", CMDL_BOOL, &coal_adaptive_rx_wanted, \
+ &__ecoal.use_adaptive_rx_coalesce }, \
+ { "adaptive-tx", CMDL_BOOL, &coal_adaptive_tx_wanted, \
+ &__ecoal.use_adaptive_tx_coalesce }, \
+ { "sample-interval", CMDL_S32, &coal_sample_rate_wanted, \
+ &__ecoal.rate_sample_interval }, \
+ { "stats-block-usecs", CMDL_S32, &coal_stats_wanted, \
+ &__ecoal.stats_block_coalesce_usecs }, \
+ { "pkt-rate-low", CMDL_S32, &coal_pkt_rate_low_wanted, \
+ &__ecoal.pkt_rate_low }, \
+ { "pkt-rate-high", CMDL_S32, &coal_pkt_rate_high_wanted, \
+ &__ecoal.pkt_rate_high }, \
+ { "rx-usecs", CMDL_S32, &coal_rx_usec_wanted, \
+ &__ecoal.rx_coalesce_usecs }, \
+ { "rx-frames", CMDL_S32, &coal_rx_frames_wanted, \
+ &__ecoal.rx_max_coalesced_frames }, \
+ { "rx-usecs-irq", CMDL_S32, &coal_rx_usec_irq_wanted, \
+ &__ecoal.rx_coalesce_usecs_irq }, \
+ { "rx-frames-irq", CMDL_S32, &coal_rx_frames_irq_wanted, \
+ &__ecoal.rx_max_coalesced_frames_irq }, \
+ { "tx-usecs", CMDL_S32, &coal_tx_usec_wanted, \
+ &__ecoal.tx_coalesce_usecs }, \
+ { "tx-frames", CMDL_S32, &coal_tx_frames_wanted, \
+ &__ecoal.tx_max_coalesced_frames }, \
+ { "tx-usecs-irq", CMDL_S32, &coal_tx_usec_irq_wanted, \
+ &__ecoal.tx_coalesce_usecs_irq }, \
+ { "tx-frames-irq", CMDL_S32, &coal_tx_frames_irq_wanted, \
+ &__ecoal.tx_max_coalesced_frames_irq }, \
+ { "rx-usecs-low", CMDL_S32, &coal_rx_usec_low_wanted, \
+ &__ecoal.rx_coalesce_usecs_low }, \
+ { "rx-frames-low", CMDL_S32, &coal_rx_frames_low_wanted, \
+ &__ecoal.rx_max_coalesced_frames_low }, \
+ { "tx-usecs-low", CMDL_S32, &coal_tx_usec_low_wanted, \
+ &__ecoal.tx_coalesce_usecs_low }, \
+ { "tx-frames-low", CMDL_S32, &coal_tx_frames_low_wanted, \
+ &__ecoal.tx_max_coalesced_frames_low }, \
+ { "rx-usecs-high", CMDL_S32, &coal_rx_usec_high_wanted, \
+ &__ecoal.rx_coalesce_usecs_high }, \
+ { "rx-frames-high", CMDL_S32, &coal_rx_frames_high_wanted, \
+ &__ecoal.rx_max_coalesced_frames_high }, \
+ { "tx-usecs-high", CMDL_S32, &coal_tx_usec_high_wanted, \
+ &__ecoal.tx_coalesce_usecs_high }, \
+ { "tx-frames-high", CMDL_S32, &coal_tx_frames_high_wanted, \
+ &__ecoal.tx_max_coalesced_frames_high }, \
+}
+
static int do_scoalesce(struct cmd_context *ctx)
{
struct ethtool_coalesce ecoal;
int gcoalesce_changed = 0;
- s32 coal_stats_wanted = -1;
- int coal_adaptive_rx_wanted = -1;
- int coal_adaptive_tx_wanted = -1;
- s32 coal_sample_rate_wanted = -1;
- s32 coal_pkt_rate_low_wanted = -1;
- s32 coal_pkt_rate_high_wanted = -1;
- s32 coal_rx_usec_wanted = -1;
- s32 coal_rx_frames_wanted = -1;
- s32 coal_rx_usec_irq_wanted = -1;
- s32 coal_rx_frames_irq_wanted = -1;
- s32 coal_tx_usec_wanted = -1;
- s32 coal_tx_frames_wanted = -1;
- s32 coal_tx_usec_irq_wanted = -1;
- s32 coal_tx_frames_irq_wanted = -1;
- s32 coal_rx_usec_low_wanted = -1;
- s32 coal_rx_frames_low_wanted = -1;
- s32 coal_tx_usec_low_wanted = -1;
- s32 coal_tx_frames_low_wanted = -1;
- s32 coal_rx_usec_high_wanted = -1;
- s32 coal_rx_frames_high_wanted = -1;
- s32 coal_tx_usec_high_wanted = -1;
- s32 coal_tx_frames_high_wanted = -1;
- struct cmdline_info cmdline_coalesce[] = {
- { "adaptive-rx", CMDL_BOOL, &coal_adaptive_rx_wanted,
- &ecoal.use_adaptive_rx_coalesce },
- { "adaptive-tx", CMDL_BOOL, &coal_adaptive_tx_wanted,
- &ecoal.use_adaptive_tx_coalesce },
- { "sample-interval", CMDL_S32, &coal_sample_rate_wanted,
- &ecoal.rate_sample_interval },
- { "stats-block-usecs", CMDL_S32, &coal_stats_wanted,
- &ecoal.stats_block_coalesce_usecs },
- { "pkt-rate-low", CMDL_S32, &coal_pkt_rate_low_wanted,
- &ecoal.pkt_rate_low },
- { "pkt-rate-high", CMDL_S32, &coal_pkt_rate_high_wanted,
- &ecoal.pkt_rate_high },
- { "rx-usecs", CMDL_S32, &coal_rx_usec_wanted,
- &ecoal.rx_coalesce_usecs },
- { "rx-frames", CMDL_S32, &coal_rx_frames_wanted,
- &ecoal.rx_max_coalesced_frames },
- { "rx-usecs-irq", CMDL_S32, &coal_rx_usec_irq_wanted,
- &ecoal.rx_coalesce_usecs_irq },
- { "rx-frames-irq", CMDL_S32, &coal_rx_frames_irq_wanted,
- &ecoal.rx_max_coalesced_frames_irq },
- { "tx-usecs", CMDL_S32, &coal_tx_usec_wanted,
- &ecoal.tx_coalesce_usecs },
- { "tx-frames", CMDL_S32, &coal_tx_frames_wanted,
- &ecoal.tx_max_coalesced_frames },
- { "tx-usecs-irq", CMDL_S32, &coal_tx_usec_irq_wanted,
- &ecoal.tx_coalesce_usecs_irq },
- { "tx-frames-irq", CMDL_S32, &coal_tx_frames_irq_wanted,
- &ecoal.tx_max_coalesced_frames_irq },
- { "rx-usecs-low", CMDL_S32, &coal_rx_usec_low_wanted,
- &ecoal.rx_coalesce_usecs_low },
- { "rx-frames-low", CMDL_S32, &coal_rx_frames_low_wanted,
- &ecoal.rx_max_coalesced_frames_low },
- { "tx-usecs-low", CMDL_S32, &coal_tx_usec_low_wanted,
- &ecoal.tx_coalesce_usecs_low },
- { "tx-frames-low", CMDL_S32, &coal_tx_frames_low_wanted,
- &ecoal.tx_max_coalesced_frames_low },
- { "rx-usecs-high", CMDL_S32, &coal_rx_usec_high_wanted,
- &ecoal.rx_coalesce_usecs_high },
- { "rx-frames-high", CMDL_S32, &coal_rx_frames_high_wanted,
- &ecoal.rx_max_coalesced_frames_high },
- { "tx-usecs-high", CMDL_S32, &coal_tx_usec_high_wanted,
- &ecoal.tx_coalesce_usecs_high },
- { "tx-frames-high", CMDL_S32, &coal_tx_frames_high_wanted,
- &ecoal.tx_max_coalesced_frames_high },
- };
+ DECLARE_COALESCE_OPTION_VARS();
+ struct cmdline_info cmdline_coalesce[] = COALESCE_CMDLINE_INFO(ecoal);
int err, changed = 0;
parse_generic_cmdline(ctx, &gcoalesce_changed,
--
2.7.4

View File

@ -1,47 +0,0 @@
From 66501a7e93decf629ea8cd00a0539653ed7ac7c5 Mon Sep 17 00:00:00 2001
From: Nicholas Nunley <nicholas.d.nunley@intel.com>
Date: Fri, 1 Mar 2019 00:15:32 -0800
Subject: [PATCH 30/39] ethtool: fix up dump_coalesce output to match actual
option names
When the coalesce settings are printed with --show-coalesce a few of the
option names lack the pluralization that is present in the man page and
usage info, but are otherwise identical.
This inconsistency could lead to some confusion if a user attempts to set
the coalesce settings by matching the output they see from --show-coalesce,
so fix this.
Signed-off-by: Nicholas Nunley <nicholas.d.nunley@intel.com>
Reviewed-by: Michal Kubecek <mkubecek@suse.cz>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
---
ethtool.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/ethtool.c b/ethtool.c
index d1b82f0..8fbb4bd 100644
--- a/ethtool.c
+++ b/ethtool.c
@@ -1420,14 +1420,14 @@ static int dump_coalesce(const struct ethtool_coalesce *ecoal)
"tx-frames-irq: %u\n"
"\n"
"rx-usecs-low: %u\n"
- "rx-frame-low: %u\n"
+ "rx-frames-low: %u\n"
"tx-usecs-low: %u\n"
- "tx-frame-low: %u\n"
+ "tx-frames-low: %u\n"
"\n"
"rx-usecs-high: %u\n"
- "rx-frame-high: %u\n"
+ "rx-frames-high: %u\n"
"tx-usecs-high: %u\n"
- "tx-frame-high: %u\n"
+ "tx-frames-high: %u\n"
"\n",
ecoal->stats_block_coalesce_usecs,
ecoal->rate_sample_interval,
--
2.7.4

View File

@ -1,40 +0,0 @@
From 5da4e23263a21a25cc8615427a6a55b4d38c1e9b Mon Sep 17 00:00:00 2001
From: Michal Kubecek <mkubecek@suse.cz>
Date: Thu, 14 Mar 2019 19:33:16 +0100
Subject: [PATCH 32/39] ethtool: qsfp: fix special value comparison
One of the warnings gcc issues when building ethtool with -Wall seems to
point to an actual problem:
qsfp.c: In function 'sff8636_show_dom':
qsfp.c:709:57: warning: comparison is always false due to limited range of data type [-Wtype-limits]
if ((sd.sfp_temp[MCURR] == 0x0) || (sd.sfp_temp[MCURR] == 0xFFFF))
^~
Rather than writing the special value as -1 which would be a bit confusing,
cast 0xFFFF to __s16.
Fixes: a5e73bb05ee4 ("ethtool:QSFP Plus/QSFP28 Diagnostics Information Support")
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
---
qsfp.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/qsfp.c b/qsfp.c
index d196aa1..d0774b0 100644
--- a/qsfp.c
+++ b/qsfp.c
@@ -706,7 +706,8 @@ static void sff8636_show_dom(const __u8 *id, __u32 eeprom_len)
* current fields are supported or not. A valid temperature
* reading is used as existence for TX/RX power.
*/
- if ((sd.sfp_temp[MCURR] == 0x0) || (sd.sfp_temp[MCURR] == 0xFFFF))
+ if ((sd.sfp_temp[MCURR] == 0x0) ||
+ (sd.sfp_temp[MCURR] == (__s16)0xFFFF))
return;
printf("\t%-41s : %s\n", "Alarm/warning flags implemented",
--
2.7.4

View File

@ -1,49 +0,0 @@
author Eran Ben Elisha <eranbe@mellanox.com> 2018-10-02 10:24:19 +0300
committer John W. Linville <linville@tuxdriver.com> 2018-10-04 15:02:21 -0400
commit ecdf2952521c8e37bb608bb61384be95bceb68cd (patch)
tree 67f0321651b8493af4bb0ffa9c7a2f83f9e64239
parent 98c148e8651b01561a8fb1ad8201c1d4a6c30d64 (diff)
download ethtool-ecdf2952521c8e37bb608bb61384be95bceb68cd.tar.gz
ethtool: Fix uninitialized variable use at qsfp dump
Struct sff_diags can be used uninitialized at sff8636_show_dom, this
caused the tool to show unreported fields (supports_alarms) by the lower
level driver.
In addition, make sure the same struct is being initialized at
sff8472_parse_eeprom function, to avoid the same issue here.
Fixes: a5e73bb05ee4 ("ethtool:QSFP Plus/QSFP28 Diagnostics Information Support")
Signed-off-by: Eran Ben Elisha <eranbe@mellanox.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat
-rw-r--r-- qsfp.c 2
-rw-r--r-- sfpdiag.c 2
2 files changed, 2 insertions, 2 deletions
diff --git a/qsfp.c b/qsfp.c
index 32e195d..d196aa1 100644
--- a/qsfp.c
+++ b/qsfp.c
@@ -671,7 +671,7 @@ static void sff8636_dom_parse(const __u8 *id, struct sff_diags *sd)
static void sff8636_show_dom(const __u8 *id, __u32 eeprom_len)
{
- struct sff_diags sd;
+ struct sff_diags sd = {0};
char *rx_power_string = NULL;
char power_string[MAX_DESC_SIZE];
int i;
diff --git a/sfpdiag.c b/sfpdiag.c
index 32e4cd8..fa41651 100644
--- a/sfpdiag.c
+++ b/sfpdiag.c
@@ -241,7 +241,7 @@ static void sff8472_parse_eeprom(const __u8 *id, struct sff_diags *sd)
void sff8472_show_all(const __u8 *id)
{
- struct sff_diags sd;
+ struct sff_diags sd = {0};
char *rx_power_string = NULL;
int i;

Binary file not shown.

BIN
ethtool-5.3.tar.xz Normal file

Binary file not shown.

View File

@ -1,22 +1,26 @@
Name: ethtool Name: ethtool
Version: 4.17
Release: 4
Epoch: 2 Epoch: 2
Summary: Query or control network driver and hardware settings Version: 5.3
Release: 1
Summary: Settings tool for Ethernet NICs
License: GPLv2 License: GPLv2
URL: https://linux.die.net/man/8/ethtool URL: https://www.kernel.org/pub/software/network/ethtool
Source0: https://mirrors.edge.kernel.org/pub/software/network/ethtool/%{name}-%{version}.tar.xz Source0: https://www.kernel.org/pub/software/network/%{name}/%{name}-%{version}.tar.xz
BuildRequires: gcc
Patch6000: Fix-uninitialized-variable-use-at-qsfp-dump.patch BuildRequires: gcc
Patch6001: 0026-ethtool-move-cmdline_coalesce-out-of-do_scoalesce.patch Conflicts: filesystem < 3
Patch6002: 0030-ethtool-fix-up-dump_coalesce-output-to-match-actual-.patch
Patch6003: 0032-ethtool-qsfp-fix-special-value-comparison.patch
%description %description
Ethtool is used to query and control network device driver and hardware Ethtool is the standard Linux utility for controlling network drivers and
settings, particularly for wired Ethernet devices. hardware, particularly for wired Ethernet devices. It can be used to:
- Get identification and diagnostic information
- Get extended device statistics
- Control speed, duplex, autonegotiation and flow control for Ethernet devices
- Control checksum offload and other hardware offload features
- Control DMA ring sizes and interrupt moderation
- Control receive queue selection for multiqueue devices
- Upgrade firmware in flash memory
%package_help %package_help
@ -28,18 +32,29 @@ settings, particularly for wired Ethernet devices.
%make_build %make_build
%install %install
make install DESTDIR=%{buildroot} INSTALL='install -p' %make_install
%files %files
%doc ChangeLog* AUTHORS %defattr(-,root,root)
%doc AUTHORS
%license COPYING LICENSE %license COPYING LICENSE
%{_sbindir}/ethtool %{_sbindir}/%{name}
%dir %{_datadir}/bash-completion/
%dir %{_datadir}/bash-completion/completions/
%{_datadir}/bash-completion/completions/ethtool
%files help %files help
%doc README NEWS %defattr(-,root,root)
%{_mandir}/man8/ethtool.8.gz %doc ChangeLog* NEWS README
%{_mandir}/man8/%{name}.8*
%changelog %changelog
* Thu Oct 31 2019 openEuler Buildteam <buildteam@openeuler.org> - 2:5.3-1
- Type:bugfix
- Id:NA
- SUG:NA
- DESC:update to 5.3
* Wed Sep 4 2019 openEuler Buildteam <buildteam@openeuler.org> - 2:4.17-4 * Wed Sep 4 2019 openEuler Buildteam <buildteam@openeuler.org> - 2:4.17-4
- Type:enhancement - Type:enhancement
- ID:NA - ID:NA