ethtool: allow for a smaller build
Subsystems (3)
PATCH v2 1/1 ethtool: allow for a smaller build
Introduce a new configure script option: --disable-pretty-dump which will disable building the driver specific register, EEPROM and SFP pretty printing objects, the saving are:
~500 Kbytes on a x86_64 build
~337 Kbytes on a arm build
---
Changes in v2:
- reworked the small build around the ETHTOOL_ENABLE_PRETTY_DUMP option which is enabled by default
- updated the ethtool reported version accordingly
- upated the descriptions/comments to a mention of the SFP pretty dumps
Makefile.am | 6 +++++- configure.ac | 9 +++++++++ ethtool.c | 14 +++++++++++--- 3 files changed, 25 insertions(+), 4 deletions(-)
Makefile.am +5 -1
@@ -6,11 +6,15 @@ EXTRA_DIST = LICENSE ethtool.8 ethtool.spec.in aclocal.m4 ChangeLog autogen.sh sbin_PROGRAMS = ethtool ethtool_SOURCES = ethtool.c ethtool-copy.h internal.h net_tstamp-copy.h \ + rxclass.c +if ETHTOOL_ENABLE_PRETTY_DUMP +ethtool_SOURCES += \ amd8111e.c de2104x.c e100.c e1000.c et131x.c igb.c \ fec_8xx.c ibm_emac.c ixgb.c ixgbe.c natsemi.c \ pcnet32.c realtek.c tg3.c marvell.c vioc.c \ smsc911x.c at76c50x-usb.c sfc.c stmmac.c \ - rxclass.c sfpid.c sfpdiag.c ixgbevf.c + sfpid.c sfpdiag.c ixgbevf.c +endif TESTS = test-cmdline test-features check_PROGRAMS = test-cmdline test-features
configure.ac +9 -0
@@ -30,5 +30,14 @@ dnl Checks for library functions. AC_HEADER_STDC AC_CHECK_FUNCS(socket strtol) +dnl Check for options +AC_ARG_ENABLE(pretty-dump, + [ --enable-pretty-dump enable registers, EEPROM and SFP pretty dumps (enabled by default)],, + [if test x$enableval != xno; then + AC_DEFINE(ETHTOOL_ENABLE_PRETTY_DUMP, 1, + [Define this to enable register, EEPROM and SFP pretty dumps.]) enable_prettydump=yes + fi]) +AM_CONDITIONAL([ETHTOOL_ENABLE_PRETTY_DUMP], [test x$enable_prettydump = xyes]) + AC_CONFIG_FILES([Makefile ethtool.spec ethtool.8]) AC_OUTPUT
ethtool.c +11 -3
@@ -474,7 +474,11 @@ static int rxflow_str_to_type(const char *str)static int do_version (struct cmd_context *ctx) {fprintf (stdout, -PACKAGE " version " VERSION "\n" ); + PACKAGE " version " VERSION +#ifndef ETHTOOL_ENABLE_PRETTY_DUMP + " (pretty dumps disabled)" +#endif +"\n" );return 0 ; }
@@ -879,6 +883,7 @@ static const struct {int (*func)(struct ethtool_drvinfo *info,struct ethtool_regs *regs); } driver_list[] = { +#ifdef ETHTOOL_ENABLE_PRETTY_DUMP { "8139cp", realtek_dump_regs }, { "8139too", realtek_dump_regs }, { "r8169", realtek_dump_regs },
@@ -905,6 +910,7 @@ static const struct { { "st_mac100", st_mac100_dump_regs }, { "st_gmac", st_gmac_dump_regs }, { "et131x", et131x_dump_regs }, +#endif }; void dump_hex(FILE *file, const u8 *data, int len, int offset)
@@ -973,13 +979,13 @@ static int dump_eeprom(int geeprom_dump_raw, struct ethtool_drvinfo *info,fwrite (ee->data,1 , ee->len, stdout);return 0 ; } - +#ifdef ETHTOOL_ENABL_PRETTY_DUMP if (!strncmp ("natsemi" , info->driver,ETHTOOL_BUSINFO_LEN )) {return natsemi_dump_eeprom (info, ee); }else if (!strncmp ("tg3" , info->driver,ETHTOOL_BUSINFO_LEN )) {return tg3_dump_eeprom (info, ee); } - +#endif dump_hex (stdout, ee->data, ee->len, ee->offset);return 0 ;
@@ -3635,6 +3641,7 @@ static int do_getmodule(struct cmd_context *ctx) geeprom_dump_hex =1 ; }else if (!geeprom_dump_hex) {switch (modinfo.type) { +#ifdef ETHTOOL_ENABLE_PRETTY_DUMP case ETH_MODULE_SFF_8079 :sff8079_show_all (eeprom->data);break ;
@@ -3642,6 +3649,7 @@ static int do_getmodule(struct cmd_context *ctx)sff8079_show_all (eeprom->data);sff8472_show_all (eeprom->data);break ; +#endif default : geeprom_dump_hex =1 ;break ;
Signature · 1 line
1.8.3.2
Quoted 4 lines · Florian Fainelli
Introduce a new configure script option: --disable-pretty-dump which will disable building the driver specific register, EEPROM and SFP pretty printing objects, the saving are:
Quoted 8 lines
~500 Kbytes on a
x86_64build
~337 Kbytes on a arm buildSigned-off-by Florian Fainelli <[email protected]>---
Changes in v2:
- reworked the small build around theETHTOOL_ENABLE_PRETTY_DUMPoption which is enabled by default
But not if you actually specify the option.
[...]
configure.ac dnl Checks for library functions. · line 35
Quoted 9 lines
configure.ac +3
-0@@ -30,5 +30,14 @@ dnl Checks for library functions. AC_HEADER_STDC AC_CHECK_FUNCS(socket strtol) +dnl Check for options +AC_ARG_ENABLE(pretty-dump, + [ --enable-pretty-dump enable registers, EEPROM and SFP pretty dumps (enabled by default)],,
Too many commas there! The following logic needs to be the third argument to AC_ARG_ENABLE:
configure.ac dnl Checks for library functions. · line 39
Quoted 4 lines
configure.ac +4
-0+ [if test x$enableval != xno; then + AC_DEFINE(ETHTOOL_ENABLE_PRETTY_DUMP, 1, + [Define this to enable register, EEPROM and SFP pretty dumps.]) enable_prettydump=yes + fi])
And then the fourth argument is for the default, which must set enable_prettydump=yes.
[...]
Quoted 2 lines
ethtool.c +0
-0
[...]
ethtool.c static int dump_eeprom(int geeprom_dump_raw, struct ethtool_drvinfo *info, · line 982
Quoted 6 lines
ethtool.c +1
-1@@ -973,13 +979,13 @@ static int dump_eeprom(int geeprom_dump_raw, struct ethtool_drvinfo *info,fwrite (ee->data,1 , ee->len, stdout);return 0 ; } - +#ifdef ETHTOOL_ENABL_PRETTY_DUMP
[...]
Typo.
Ben.
Signature · 2 lines
Ben Hutchings Computers are not intelligent. They only think they are.