--- ethtool-6+20080227.orig/debian/changelog +++ ethtool-6+20080227/debian/changelog @@ -0,0 +1,118 @@ +ethtool (6+20080227-1) unstable; urgency=low + + * New git pull + - Recent fixes for 10000 support. Closes: #468089 + * Fixed debian/watch + Patch by Raphael Geissert + Closes: #449638 + * Bumped Standards-Version to 3.7.3 + * Added homepage control header + * Running autoconf and automake in debian/rules + * Updated debian/copyright + + -- Anibal Monsalve Salazar Wed, 27 Feb 2008 18:08:04 +1100 + +ethtool (6-0) unstable; urgency=low + + * New upstream release. + * Fixed "Reports 10GbE speed as 'Unknown! (10000)'". Closes: #398438. + * Fixed the following lintian message: + - W: ethtool source: debian-rules-ignores-make-clean-error line 22 + + -- Anibal Monsalve Salazar Sat, 11 Aug 2007 20:43:55 +1000 + +ethtool (5-2) unstable; urgency=low + + * Removed outdated information in package description. + Closes: #389689. + + -- Anibal Monsalve Salazar Fri, 11 May 2007 22:12:08 +1000 + +ethtool (5-1) unstable; urgency=low + + * New maintainer. + * New upstream release. Closes: #380681. + * Set Standards-Version to 3.7.2. + * Set debhelper compatibility to 5. + * Added debian/watch. + + -- Anibal Monsalve Salazar Fri, 27 Oct 2006 13:05:16 +1000 + +ethtool (3-1) unstable; urgency=low + + * New upstream release. Closes: #308954. + * Lintian cleanup (debhelper V4 compatibility, updated standard-version). + + -- Eric Delaunay Tue, 25 Oct 2005 22:50:55 +0000 + +ethtool (2-1) unstable; urgency=low + + * New upstream release (new upstream version scheme using only 1 number). + Closes: #275982. + * Removed autoconf build-dependency (don't patch configure.in not to trigger + an autoconf run when building this package; PRE24_COMPAT option is + directly passed to Makefile through CFLAGS). Closes: #213921. + * Strip binary. Closes: #273715. + * Updated README.Debian. Closes: #213699. + * Don't be so verbose when called with bad arg. Display long help message + (ethtool -h) to stdout. Closes: #256249. + + -- Eric Delaunay Tue, 9 Nov 2004 23:40:54 +0100 + +ethtool (1.8-2) unstable; urgency=low + + * Fixed autoconf troubles. Closes: #211982. + * Fixed package and manpage description about which kernel revision ethtool + is compatible with. Closes: #207798. + + -- Eric Delaunay Wed, 24 Sep 2003 19:23:36 +0200 + +ethtool (1.8-1) unstable; urgency=low + + * New upstream release. Closes: #203577. + * Fixed typo in man page. Closes: #199711. + + -- Eric Delaunay Sun, 17 Aug 2003 19:41:14 +0200 + +ethtool (1.7-1) unstable; urgency=low + + * New upstream release. Closes: #179413. + * Build-Depends on debhelper. Closes: #189636. + + -- Eric Delaunay Thu, 24 Apr 2003 23:08:27 +0200 + +ethtool (1.6-1) unstable; urgency=low + + * New upstream release. + * Moved to utils section. Closes: #145095. + + -- Eric Delaunay Sat, 13 Jul 2002 17:41:06 +0200 + +ethtool (1.5-2) unstable; urgency=low + + * Moved ethtool-sparc22.h into ethtool-util.h to get u8 & u32 defined before + use. Closes: #143431. + + -- Eric Delaunay Sat, 20 Apr 2002 21:50:19 +0200 + +ethtool (1.5-1) unstable; urgency=low + + * New upstream release. + * New maintainer address. + * Updated list of drivers that support ethtool protocol in README.debian + based on infos found in 2.4.18 kernel tree. + + -- Eric Delaunay Sun, 14 Apr 2002 19:24:18 +0200 + +ethtool (1.3-1) unstable; urgency=low + + * Initial release forked from sparc-utils 1.8-2 to enable multi-arch support. + * Updated from ethtool 1.0 to 1.3 to enable 2.4 kernel support. + * Hacked backward compatibility with pre-2.4 kernels for use with sparc Happy + Meal (hme) Ethernet cards. + + -- Eric Delaunay Tue, 2 Oct 2001 20:25:05 +0200 + +Local variables: +mode: debian-changelog +End: --- ethtool-6+20080227.orig/debian/control +++ ethtool-6+20080227/debian/control @@ -0,0 +1,14 @@ +Source: ethtool +Section: utils +Priority: extra +Maintainer: Anibal Monsalve Salazar +Standards-Version: 3.7.3 +Build-Depends: debhelper (>= 5), autoconf, automake1.9 +Homepage: http://sourceforge.net/projects/gkernel/ + +Package: ethtool +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Conflicts: sparc-utils (<< 1.9-1) +Description: display or change ethernet card settings + ethtool is used for querying settings of an ethernet device and changing them. --- ethtool-6+20080227.orig/debian/copyright +++ ethtool-6+20080227/debian/copyright @@ -0,0 +1,77 @@ +This is the Debian GNU/Linux prepackaged version of "ethtool". + +This package is currently maintained by +Anibal Monsalve Salazar + +Sources obtained from: +http://sourceforge.net/projects/gkernel/ + +Copyright Notices + + amd8111e.c + Copyright (C) 2003 Advanced Micro Devices Inc. + + de2104x.c + Copyright 2001 Sun Microsystems (thockin@sun.com) + + e100.c + e1000.c + Copyright (c) 2002 Intel Corporation + + ethtool-copy.h + Copyright (C) 1998 David S. Miller (davem@redhat.com) + Copyright 2001 Jeff Garzik + Portions Copyright 2001 Sun Microsystems (thockin@sun.com) + Portions Copyright 2002 Intel (eli.kupermann@intel.com, + Portions Copyright 2001 Sun Microsystems (thockin@sun.com) + Portions Copyright 2002 Intel (scott.feldman@intel.com) + + ethtool.8: + Copyright 1999 by David S. Miller. All Rights Reserved. + + ethtool.8: + Portions Copyright 2001 Sun Microsystems + + ethtool.c + Copyright (C) 1998 David S. Miller (davem@dm.cobaltmicro.com) + Portions Copyright 2001 Sun Microsystems + Copyright 2001 Jeff Garzik + Portions Copyright 2002 Intel + + fec_8xx.c + Copyright (C) 2004 Intracom S.A. + + ibm_emac.c + Copyright (c) 2004, 2005 Zultys Technologies + + igb.c + Copyright (c) 2007 Intel Corporation + + ixgb.c + Copyright (c) 2006 Intel Corporation + + ixgbe.c + Copyright (c) 2007 Intel Corporation + + marvell.c + Copyright (C) 2004, 2006 + + natsemi.c + Copyright 2001 Sun Microsystems (thockin@sun.com) + + pcnet32.c + Copyright 2004 IBM Corporation (jklewis@us.ibm.com) + + realtek.c + Copyright 2001 Sun Microsystems (thockin@sun.com) + + vioc.c + Copyright 2006 Fabric7 Systems, Inc + + ethtool-sparc22.h + Copyright (C) 1998 David S. Miller (davem@redhat.com) + +ethtool is GPL lincensed. + +On Debian GNU/Linux systems, the complete text of the GNU General +Public License can be found in `/usr/share/common-licenses/GPL'. --- ethtool-6+20080227.orig/debian/rules +++ ethtool-6+20080227/debian/rules @@ -0,0 +1,54 @@ +#! /usr/bin/make -f +# (C) 2001, Eric Delaunay + +CC=gcc +# PRE24_COMPAT is adding support for old Sparc HME ethernet driver on 2.2 kernel +CFLAGS=-O2 -DPRE24_COMPAT + +a=$(shell dpkg --print-architecture) +p=ethtool + +build: build-stamp +build-stamp: + dh_testdir + ./autogen.sh + ./configure --prefix=/usr --mandir=/usr/share/man --enable-compat + $(MAKE) all CC=$(CC) CFLAGS="$(CFLAGS)" + touch $@ + +clean: + dh_testdir + dh_testroot + rm -f build-stamp + [ ! -f Makefile ] || $(MAKE) distclean + dh_clean + +binary: binary-arch binary-indep + +binary-indep: +# nothing to do for arch independent binary packages + +binary-arch: build + dh_testdir + dh_testroot + dh_clean -k + # install binaries + $(MAKE) install-strip DESTDIR=`pwd`/debian/ethtool + # force removing .comment section from binary (lintian check) + strip -R .comment debian/ethtool/usr/sbin/ethtool + # install documentation + dh_installmanpages + dh_installdocs AUTHORS NEWS README + dh_installchangelogs ChangeLog + dh_compress + dh_fixperms + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +source diff: + @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false + +.PHONY: binary-arch binary-indep binary build clean --- ethtool-6+20080227.orig/debian/README.Debian +++ ethtool-6+20080227/debian/README.Debian @@ -0,0 +1,78 @@ +ethtool for Debian +------------------ + +ethtool is a small utility for examining and tuning your ethernet-based network +interface. See the man page for more details. + +ethtool is only supported on 2.2 kernel for use with Sparc Happy Meal (hme) +ethernet cards. +On 2.4 or newer kernel, more architectures and cards are supported (see below). + +Note: as of nov. 2004, this file is quite out of date (need to be synchronized +on kernel sources). + + +2.4 kernel support for ETHTOOL protocol +--------------------------------------- + +Informations shown below were extracted from 2.4.18 kernel sources. +Please, report back to me misinterpretation of it contents. + +Last column show current capabilities of these drivers: + D = get driver infos + C = get/set card settings + W = get/set wake-on-lan settings + M = get/set message-level + L = get link status + R = restart autonegotiation + G = get registers + P = get EEPROM + +An 'x' indicates that the feature is available, a '.' indicates not. + +Ethernet card family linux driver DCWMLRGP +-------------------------------------------------------------------- +3Com 3c501 cards 3c501 x..x.... +3Com 3c503 and 3c503/16 cards 3c503 x....... +3Com Etherlink Plus (3C505) cards 3c505 x..x.... +3Com EtherLink16 (3c507) cards 3c507 x..x.... +3Com EtherLink3 (3c509) cards 3c509 x..x.... +3Com ISA EtherLink XL (3c515) cards 3c515 x..x.... +3Com Etherlink/MC (3c523) cards (i82586) 3c523 x....... +3Com Etherlink/MC32 (3c527) cards 3c527 x..x.... +3Com "Vortex" and "Boomerang" series 3c59x x....... +RealTek RTL-8139C+ Ethernet cards 8139cp xx.xxx.. +RealTek RTL-8139 Fast Ethernet 8139too xxxxxx.. +Alteon AceNIC Gigabit Ethernet acenic .x...... +Davicom DM9102* NIC Fast Ethernet dfme x....... +Intel i82544EI Gigabit Ethernet e1000 x....... +Intel i82557-559 Ethernet cards eepro100 x....... +SMC 83c170 EPIC/100 Fast Ethernet epic100 xx.xxx.. +Myson MTD-8xx 100/10M Ethernet PCI fealnx xx.xxx.. +Packet Engines GNIC-II Gigabit Ethernet hamachi x....... +SGI's IOC3 based Ethernet cards ioc3-eth .x...... +NatSemi DP8381x series natsemi xxxxxxxx +NE2000 clone on PCI bus ne2k-pci x....... +National Semiconductor DP83820 10/100/1000 ns83820 x...x... +AMD PCnet32 ethernet cards pcnet32 xx.xxx.. +SiS 900/7016 PCI Fast Ethernet sis900 x....... +Adaptec Starfire starfire xx.xxx.. +Sundance ST201 "Alta" sundance x....... +Sun GEM Gbit ethernet sungem xx.xx... +SUN Happy Meal (BigMac) Ethernet sunhme .x...... +Digital 21*4* Tulip ethernet cards tulip x....... +VIA Rhine PCI Fast Ethernet via-rhine xx.xxx.. +Winbond W89c840 PCI Ethernet winbond-840 xx.xxx.. +Packet Engines G-NIC PCI Gigabit Ethernet yellowfin x....... + +PCMCIA Ethernet card family linux driver DCWMLRGP +-------------------------------------------------------------------- +3com 3c589 PCMCIA ethernet cards 3c589_cs x..x.... +Aironet 4500 Pcmcia ethernet cards aironet4500_cs x..x.... +fmvj18x (and compatibles) PCMCIA cards fmvj18x_cs x..x.... +Netwave AirSurfer Wireless LAN PC Card netwave_cs x..x.... +New Media PCMCIA ethernet cards nmclan_cs x..x.... +Xircom CBE-100 ethernet cards xircom_tulip_cb xx...... + +-- + Eric Delaunay --- ethtool-6+20080227.orig/debian/compat +++ ethtool-6+20080227/debian/compat @@ -0,0 +1 @@ +5 --- ethtool-6+20080227.orig/debian/watch +++ ethtool-6+20080227/debian/watch @@ -0,0 +1,2 @@ +version=3 +http://sf.net/gkernel/ ethtool-([\d]+[\.\d]*).tar.gz --- ethtool-6+20080227.orig/ethtool-util.h +++ ethtool-6+20080227/ethtool-util.h @@ -18,6 +18,9 @@ typedef __uint8_t u8; /* ditto */ #include "ethtool-copy.h" +#if defined(PRE24_COMPAT) && defined(__sparc__) +# include "ethtool-sparc22.h" +#endif /* National Semiconductor DP83815, DP83816 */ int natsemi_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); --- ethtool-6+20080227.orig/ethtool.8 +++ ethtool-6+20080227/ethtool.8 @@ -414,7 +414,11 @@ .BI msglvl \ N Sets the driver message level. Meanings differ per driver. .SH BUGS -Not supported (in part or whole) on all ethernet drivers. +Not supported (in part or whole) on all ethernet drivers (read +/usr/share/doc/ethtool/README.Debian to get an idea about supported features). +.SH COMPATIBILITY +Requires 2.4 or newer kernel to be effective. +Also work on Sparc running 2.2 kernel with Happy Meal ethernet card. .SH AUTHOR .B ethtool was written by David Miller. --- ethtool-6+20080227.orig/ethtool.c +++ ethtool-6+20080227/ethtool.c @@ -37,10 +37,12 @@ #include #include #include +#include #include #include "ethtool-util.h" + #ifndef SIOCETHTOOL #define SIOCETHTOOL 0x8946 #endif @@ -69,6 +71,8 @@ static int do_goffload(int fd, struct ifreq *ifr); static int do_soffload(int fd, struct ifreq *ifr); static int do_gstats(int fd, struct ifreq *ifr); +static int send_ioctl(int fd, struct ifreq *ifr); +static int check_for_pre24_kernel(); static enum { MODE_HELP = -1, @@ -178,15 +182,24 @@ static void show_usage(int badarg) { int i; - fprintf(stderr, PACKAGE " version " VERSION "\n"); - fprintf(stderr, + if (badarg != 0) { + fprintf(stderr, + "ethtool: bad command line argument(s)\n" + "For more information run ethtool -h\n" + ); + } + else { + /* ethtool -h */ + fprintf(stdout, PACKAGE " version " VERSION "\n"); + fprintf(stdout, "Usage:\n" "ethtool DEVNAME\tDisplay standard information about device\n"); - for (i = 0; args[i].srt; i++) { - fprintf(stderr, " ethtool %s|%s DEVNAME\t%s\n%s", - args[i].srt, args[i].lng, - args[i].help, - args[i].opthelp ? args[i].opthelp : ""); + for (i = 0; args[i].srt; i++) { + fprintf(stderr, " ethtool %s|%s DEVNAME\t%s\n%s", + args[i].srt, args[i].lng, + args[i].help, + args[i].opthelp ? args[i].opthelp : ""); + } } exit(badarg); } @@ -254,6 +267,7 @@ static int gwol_changed = 0; /* did anything in GWOL change? */ static int msglvl_wanted = -1; static int phys_id_time = 0; +static int is_pre24_kernel = 0; static int gregs_changed = 0; static int gregs_dump_raw = 0; static int gregs_dump_hex = 0; @@ -1301,7 +1315,7 @@ drvinfo.cmd = ETHTOOL_GDRVINFO; ifr->ifr_data = (caddr_t)&drvinfo; - err = ioctl(fd, SIOCETHTOOL, ifr); + err = send_ioctl(fd, ifr); if (err < 0) { perror("Cannot get driver information"); return 71; @@ -1317,7 +1331,7 @@ epause.cmd = ETHTOOL_GPAUSEPARAM; ifr->ifr_data = (caddr_t)&epause; - err = ioctl(fd, SIOCETHTOOL, ifr); + err = send_ioctl(fd, ifr); if (err == 0) { err = dump_pause(); if (err) @@ -1365,7 +1379,7 @@ epause.cmd = ETHTOOL_GPAUSEPARAM; ifr->ifr_data = (caddr_t)&epause; - err = ioctl(fd, SIOCETHTOOL, ifr); + err = send_ioctl(fd, ifr); if (err) { perror("Cannot get device pause settings"); return 77; @@ -1380,7 +1394,7 @@ epause.cmd = ETHTOOL_SPAUSEPARAM; ifr->ifr_data = (caddr_t)&epause; - err = ioctl(fd, SIOCETHTOOL, ifr); + err = send_ioctl(fd, ifr); if (err) { perror("Cannot set device pause parameters"); return 79; @@ -1395,7 +1409,7 @@ ering.cmd = ETHTOOL_GRINGPARAM; ifr->ifr_data = (caddr_t)&ering; - err = ioctl(fd, SIOCETHTOOL, ifr); + err = send_ioctl(fd, ifr); if (err) { perror("Cannot get device ring settings"); return 76; @@ -1410,7 +1424,7 @@ ering.cmd = ETHTOOL_SRINGPARAM; ifr->ifr_data = (caddr_t)&ering; - err = ioctl(fd, SIOCETHTOOL, ifr); + err = send_ioctl(fd, ifr); if (err) { perror("Cannot set device ring parameters"); return 81; @@ -1427,7 +1441,7 @@ ering.cmd = ETHTOOL_GRINGPARAM; ifr->ifr_data = (caddr_t)&ering; - err = ioctl(fd, SIOCETHTOOL, ifr); + err = send_ioctl(fd, ifr); if (err == 0) { err = dump_ring(); if (err) @@ -1448,7 +1462,7 @@ ecoal.cmd = ETHTOOL_GCOALESCE; ifr->ifr_data = (caddr_t)&ecoal; - err = ioctl(fd, SIOCETHTOOL, ifr); + err = send_ioctl(fd, ifr); if (err == 0) { err = dump_coalesce(); if (err) @@ -1467,7 +1481,7 @@ ecoal.cmd = ETHTOOL_GCOALESCE; ifr->ifr_data = (caddr_t)&ecoal; - err = ioctl(fd, SIOCETHTOOL, ifr); + err = send_ioctl(fd, ifr); if (err) { perror("Cannot get device coalesce settings"); return 76; @@ -1483,7 +1497,7 @@ ecoal.cmd = ETHTOOL_SCOALESCE; ifr->ifr_data = (caddr_t)&ecoal; - err = ioctl(fd, SIOCETHTOOL, ifr); + err = send_ioctl(fd, ifr); if (err) { perror("Cannot set device coalesce parameters"); return 81; @@ -1501,7 +1515,7 @@ eval.cmd = ETHTOOL_GRXCSUM; ifr->ifr_data = (caddr_t)&eval; - err = ioctl(fd, SIOCETHTOOL, ifr); + err = send_ioctl(fd, ifr); if (err) perror("Cannot get device rx csum settings"); else { @@ -1511,7 +1525,7 @@ eval.cmd = ETHTOOL_GTXCSUM; ifr->ifr_data = (caddr_t)&eval; - err = ioctl(fd, SIOCETHTOOL, ifr); + err = send_ioctl(fd, ifr); if (err) perror("Cannot get device tx csum settings"); else { @@ -1521,7 +1535,7 @@ eval.cmd = ETHTOOL_GSG; ifr->ifr_data = (caddr_t)&eval; - err = ioctl(fd, SIOCETHTOOL, ifr); + err = send_ioctl(fd, ifr); if (err) perror("Cannot get device scatter-gather settings"); else { @@ -1531,7 +1545,7 @@ eval.cmd = ETHTOOL_GTSO; ifr->ifr_data = (caddr_t)&eval; - err = ioctl(fd, SIOCETHTOOL, ifr); + err = send_ioctl(fd, ifr); if (err) perror("Cannot get device tcp segmentation offload settings"); else { @@ -1577,7 +1591,7 @@ eval.cmd = ETHTOOL_SRXCSUM; eval.data = (off_csum_rx_wanted == 1); ifr->ifr_data = (caddr_t)&eval; - err = ioctl(fd, SIOCETHTOOL, ifr); + err = send_ioctl(fd, ifr); if (err) { perror("Cannot set device rx csum settings"); return 84; @@ -1589,7 +1603,7 @@ eval.cmd = ETHTOOL_STXCSUM; eval.data = (off_csum_tx_wanted == 1); ifr->ifr_data = (caddr_t)&eval; - err = ioctl(fd, SIOCETHTOOL, ifr); + err = send_ioctl(fd, ifr); if (err) { perror("Cannot set device tx csum settings"); return 85; @@ -1601,7 +1615,7 @@ eval.cmd = ETHTOOL_SSG; eval.data = (off_sg_wanted == 1); ifr->ifr_data = (caddr_t)&eval; - err = ioctl(fd, SIOCETHTOOL, ifr); + err = send_ioctl(fd, ifr); if (err) { perror("Cannot set device scatter-gather settings"); return 86; @@ -1613,7 +1627,7 @@ eval.cmd = ETHTOOL_STSO; eval.data = (off_tso_wanted == 1); ifr->ifr_data = (caddr_t)&eval; - err = ioctl(fd, SIOCETHTOOL, ifr); + err = send_ioctl(fd, ifr); if (err) { perror("Cannot set device tcp segmentation offload settings"); return 88; @@ -1660,7 +1674,7 @@ ecmd.cmd = ETHTOOL_GSET; ifr->ifr_data = (caddr_t)&ecmd; - err = ioctl(fd, SIOCETHTOOL, ifr); + err = send_ioctl(fd, ifr); if (err == 0) { err = dump_ecmd(&ecmd); if (err) @@ -1672,7 +1686,7 @@ wolinfo.cmd = ETHTOOL_GWOL; ifr->ifr_data = (caddr_t)&wolinfo; - err = ioctl(fd, SIOCETHTOOL, ifr); + err = send_ioctl(fd, ifr); if (err == 0) { err = dump_wol(&wolinfo); if (err) @@ -1684,7 +1698,7 @@ edata.cmd = ETHTOOL_GMSGLVL; ifr->ifr_data = (caddr_t)&edata; - err = ioctl(fd, SIOCETHTOOL, ifr); + err = send_ioctl(fd, ifr); if (err == 0) { fprintf(stdout, " Current message level: 0x%08x (%d)\n", edata.data, edata.data); @@ -1695,7 +1709,7 @@ edata.cmd = ETHTOOL_GLINK; ifr->ifr_data = (caddr_t)&edata; - err = ioctl(fd, SIOCETHTOOL, ifr); + err = send_ioctl(fd, ifr); if (err == 0) { fprintf(stdout, " Link detected: %s\n", edata.data ? "yes":"no"); @@ -1720,7 +1734,7 @@ ecmd.cmd = ETHTOOL_GSET; ifr->ifr_data = (caddr_t)&ecmd; - err = ioctl(fd, SIOCETHTOOL, ifr); + err = send_ioctl(fd, ifr); if (err < 0) { perror("Cannot get current device settings"); } else { @@ -1755,7 +1769,7 @@ /* Try to perform the update. */ ecmd.cmd = ETHTOOL_SSET; ifr->ifr_data = (caddr_t)&ecmd; - err = ioctl(fd, SIOCETHTOOL, ifr); + err = send_ioctl(fd, ifr); if (err < 0) perror("Cannot set new settings"); } @@ -1780,7 +1794,7 @@ wol.cmd = ETHTOOL_GWOL; ifr->ifr_data = (caddr_t)&wol; - err = ioctl(fd, SIOCETHTOOL, ifr); + err = send_ioctl(fd, ifr); if (err < 0) { perror("Cannot get current wake-on-lan settings"); } else { @@ -1798,7 +1812,7 @@ /* Try to perform the update. */ wol.cmd = ETHTOOL_SWOL; ifr->ifr_data = (caddr_t)&wol; - err = ioctl(fd, SIOCETHTOOL, ifr); + err = send_ioctl(fd, ifr); if (err < 0) perror("Cannot set new wake-on-lan settings"); } @@ -1816,7 +1830,7 @@ edata.cmd = ETHTOOL_SMSGLVL; edata.data = msglvl_wanted; ifr->ifr_data = (caddr_t)&edata;; - err = ioctl(fd, SIOCETHTOOL, ifr); + err = send_ioctl(fd, ifr); if (err < 0) perror("Cannot set new msglvl"); } @@ -1832,7 +1846,7 @@ drvinfo.cmd = ETHTOOL_GDRVINFO; ifr->ifr_data = (caddr_t)&drvinfo; - err = ioctl(fd, SIOCETHTOOL, ifr); + err = send_ioctl(fd, ifr); if (err < 0) { perror("Cannot get driver information"); return 72; @@ -1846,7 +1860,7 @@ regs->cmd = ETHTOOL_GREGS; regs->len = drvinfo.regdump_len; ifr->ifr_data = (caddr_t)regs; - err = ioctl(fd, SIOCETHTOOL, ifr); + err = send_ioctl(fd, ifr); if (err < 0) { perror("Cannot get register dump"); free(regs); @@ -1869,7 +1883,7 @@ edata.cmd = ETHTOOL_NWAY_RST; ifr->ifr_data = (caddr_t)&edata; - err = ioctl(fd, SIOCETHTOOL, ifr); + err = send_ioctl(fd, ifr); if (err < 0) perror("Cannot restart autonegotiation"); @@ -1884,7 +1898,7 @@ drvinfo.cmd = ETHTOOL_GDRVINFO; ifr->ifr_data = (caddr_t)&drvinfo; - err = ioctl(fd, SIOCETHTOOL, ifr); + err = send_ioctl(fd, ifr); if (err < 0) { perror("Cannot get driver information"); return 74; @@ -1905,7 +1919,7 @@ eeprom->len = geeprom_length; eeprom->offset = geeprom_offset; ifr->ifr_data = (caddr_t)eeprom; - err = ioctl(fd, SIOCETHTOOL, ifr); + err = send_ioctl(fd, ifr); if (err < 0) { perror("Cannot get EEPROM data"); free(eeprom); @@ -1931,7 +1945,7 @@ edata.eeprom.magic = seeprom_magic; edata.data = seeprom_value; ifr->ifr_data = (caddr_t)&edata.eeprom; - err = ioctl(fd, SIOCETHTOOL, ifr); + err = send_ioctl(fd, ifr); if (err < 0) { perror("Cannot set EEPROM data"); return 87; @@ -1949,7 +1963,7 @@ drvinfo.cmd = ETHTOOL_GDRVINFO; ifr->ifr_data = (caddr_t)&drvinfo; - err = ioctl(fd, SIOCETHTOOL, ifr); + err = send_ioctl(fd, ifr); if (err < 0) { perror("Cannot get driver information"); return 72; @@ -1968,7 +1982,7 @@ else test->flags = 0; ifr->ifr_data = (caddr_t)test; - err = ioctl(fd, SIOCETHTOOL, ifr); + err = send_ioctl(fd, ifr); if (err < 0) { perror("Cannot test"); free (test); @@ -1987,7 +2001,7 @@ strings->string_set = ETH_SS_TEST; strings->len = drvinfo.testinfo_len; ifr->ifr_data = (caddr_t)strings; - err = ioctl(fd, SIOCETHTOOL, ifr); + err = send_ioctl(fd, ifr); if (err < 0) { perror("Cannot get strings"); free (test); @@ -2009,7 +2023,7 @@ edata.cmd = ETHTOOL_PHYS_ID; edata.data = phys_id_time; ifr->ifr_data = (caddr_t)&edata; - err = ioctl(fd, SIOCETHTOOL, ifr); + err = send_ioctl(fd, ifr); if (err < 0) perror("Cannot identify NIC"); @@ -2026,7 +2040,7 @@ drvinfo.cmd = ETHTOOL_GDRVINFO; ifr->ifr_data = (caddr_t)&drvinfo; - err = ioctl(fd, SIOCETHTOOL, ifr); + err = send_ioctl(fd, ifr); if (err < 0) { perror("Cannot get driver information"); return 71; @@ -2052,7 +2066,7 @@ strings->string_set = ETH_SS_STATS; strings->len = n_stats; ifr->ifr_data = (caddr_t) strings; - err = ioctl(fd, SIOCETHTOOL, ifr); + err = send_ioctl(fd, ifr); if (err < 0) { perror("Cannot get stats strings information"); free(strings); @@ -2063,7 +2077,7 @@ stats->cmd = ETHTOOL_GSTATS; stats->n_stats = n_stats; ifr->ifr_data = (caddr_t) stats; - err = ioctl(fd, SIOCETHTOOL, ifr); + err = send_ioctl(fd, ifr); if (err < 0) { perror("Cannot get stats information"); free(strings); @@ -2085,8 +2099,75 @@ return 0; } +static int send_ioctl(int fd, struct ifreq *ifr) +{ + int err; + if (! is_pre24_kernel) { + err = ioctl(fd, SIOCETHTOOL, ifr); + } + else { +#if defined(__sparc__) && defined(PRE24_COMPAT) + /* this part is working only on sparc HME ethernet driver */ + struct ethtool_cmd_22 old_ecmd; + struct ethtool_cmd *ecmd = (struct ethtool_cmd *)ifr->ifr_data; + /* fill in old pre-2.4 ethtool struct */ + old_ecmd.cmd = ecmd->cmd; + old_ecmd.supported = ecmd->supported; + old_ecmd.speed = ecmd->speed; + old_ecmd.duplex = ecmd->duplex; + old_ecmd.port = ecmd->port; + old_ecmd.phy_address = ecmd->phy_address; + old_ecmd.transceiver = ecmd->transceiver; + old_ecmd.autoneg = ecmd->autoneg; + /* issue the ioctl */ + ifr->ifr_data = (caddr_t) &old_ecmd; + err = ioctl( fd, SIOCETHTOOL_22, ifr ); + ifr->ifr_data = (caddr_t) ecmd; + /* copy back results from ioctl (on get cmd) */ + if (ecmd->cmd == ETHTOOL_GSET) { + ecmd->supported = old_ecmd.supported; + ecmd->speed = old_ecmd.speed; + ecmd->duplex = old_ecmd.duplex; + ecmd->port = old_ecmd.port; + ecmd->phy_address = old_ecmd.phy_address; + ecmd->transceiver = old_ecmd.transceiver; + ecmd->autoneg = old_ecmd.autoneg; + } +#else + err = -1; + errno = EOPNOTSUPP; +#endif + } + return err; +} + +#ifdef PRE24_COMPAT +static int check_for_pre24_kernel() +{ + struct utsname sysinfo; + int rmaj, rmin, rpl; + if (uname( &sysinfo ) < 0) { + perror( "Cannot get system informations:" ); + return 68; + } + if (sscanf( sysinfo.release, "%d.%d.%d", &rmaj, &rmin, &rpl ) != 3) { + fprintf( stderr, "Cannot parse kernel revision: %s\n", sysinfo.release ); + return 68; + } + if (rmaj < 2 || (rmaj == 2 && rmin < 4)) + is_pre24_kernel = 1; + return 0; +} +#endif + int main(int argc, char **argp, char **envp) { + int err; +#ifdef PRE24_COMPAT + err = check_for_pre24_kernel(); + if (err != 0) + return err; +#endif parse_cmdline(argc, argp); return doit(); } --- ethtool-6+20080227.orig/ethtool-sparc22.h +++ ethtool-6+20080227/ethtool-sparc22.h @@ -0,0 +1,29 @@ +/* + * This is an excerpt from kernel-source-2.2.19 include/asm-sparc/ethtool.h. + */ + +/* $Id: ethtool.h,v 1.1.2.1 2000/01/31 05:02:42 davem Exp $ + * ethtool.h: Defines for SparcLinux ethtool. + * + * Copyright (C) 1998 David S. Miller (davem@redhat.com) + */ + +#ifndef _SPARC_ETHTOOL_H +#define _SPARC_ETHTOOL_H + +/* pre-2.4 value of SIOCETHTOOL */ +#define SIOCETHTOOL_22 (SIOCDEVPRIVATE + 0x0f) + +/* This should work for both 32 and 64 bit userland. */ +struct ethtool_cmd_22 { + u32 cmd; + u32 supported; + u16 speed; + u8 duplex; + u8 port; + u8 phy_address; + u8 transceiver; + u8 autoneg; +}; + +#endif /* _SPARC_ETHTOOL_H */