From 5ba70c0086c0d474c7cd1a4afcd131d42b941176 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Tue, 1 Nov 2011 16:48:31 +0000 Subject: Combine ethtool-{bitops,util}.h into internal.h ethtool-util.h contains all kinds of declarations, not just utility functions or macros. ethtool-bitops.h contains just a few extra definitions, and its only user also includes ethtool-util.h. Signed-off-by: Ben Hutchings --- Makefile.am | 2 +- amd8111e.c | 2 +- at76c50x-usb.c | 2 +- de2104x.c | 2 +- e100.c | 2 +- e1000.c | 2 +- ethtool-bitops.h | 25 --------- ethtool-util.h | 143 ------------------------------------------------ ethtool.c | 2 +- fec_8xx.c | 2 +- ibm_emac.c | 2 +- igb.c | 2 +- internal.h | 164 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ ixgb.c | 2 +- ixgbe.c | 2 +- marvell.c | 2 +- natsemi.c | 2 +- pcnet32.c | 2 +- realtek.c | 2 +- rxclass.c | 3 +- sfc.c | 2 +- smsc911x.c | 2 +- stmmac.c | 2 +- tg3.c | 2 +- vioc.c | 2 +- 25 files changed, 186 insertions(+), 191 deletions(-) delete mode 100644 ethtool-bitops.h delete mode 100644 ethtool-util.h create mode 100644 internal.h diff --git a/Makefile.am b/Makefile.am index c87fb39..1e05640 100644 --- a/Makefile.am +++ b/Makefile.am @@ -4,7 +4,7 @@ man_MANS = ethtool.8 EXTRA_DIST = LICENSE ethtool.8 ethtool.spec.in aclocal.m4 ChangeLog autogen.sh sbin_PROGRAMS = ethtool -ethtool_SOURCES = ethtool.c ethtool-bitops.h ethtool-copy.h ethtool-util.h \ +ethtool_SOURCES = ethtool.c ethtool-copy.h internal.h \ amd8111e.c de2104x.c e100.c e1000.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 \ diff --git a/amd8111e.c b/amd8111e.c index b4cd65d..23478f0 100644 --- a/amd8111e.c +++ b/amd8111e.c @@ -1,7 +1,7 @@ /* Copyright (C) 2003 Advanced Micro Devices Inc. */ #include -#include "ethtool-util.h" +#include "internal.h" typedef enum { /* VAL2 */ diff --git a/at76c50x-usb.c b/at76c50x-usb.c index 4c2a1a8..39e24a4 100644 --- a/at76c50x-usb.c +++ b/at76c50x-usb.c @@ -1,5 +1,5 @@ #include -#include "ethtool-util.h" +#include "internal.h" static char *hw_versions[] = { "503_ISL3861", diff --git a/de2104x.c b/de2104x.c index f64e1b2..856e0c0 100644 --- a/de2104x.c +++ b/de2104x.c @@ -1,6 +1,6 @@ /* Copyright 2001 Sun Microsystems (thockin@sun.com) */ #include -#include "ethtool-util.h" +#include "internal.h" static const char * const csr0_tap[4] = { "No transmit automatic polling", diff --git a/e100.c b/e100.c index 4d1cef3..65627ab 100644 --- a/e100.c +++ b/e100.c @@ -1,6 +1,6 @@ /* Copyright (c) 2002 Intel Corporation */ #include -#include "ethtool-util.h" +#include "internal.h" #define D102_REV_ID 12 diff --git a/e1000.c b/e1000.c index 2eb3ac6..d1d3c73 100644 --- a/e1000.c +++ b/e1000.c @@ -1,6 +1,6 @@ /* Copyright (c) 2002 Intel Corporation */ #include -#include "ethtool-util.h" +#include "internal.h" /* Register Bit Masks */ /* Device Control */ diff --git a/ethtool-bitops.h b/ethtool-bitops.h deleted file mode 100644 index b1eb426..0000000 --- a/ethtool-bitops.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef ETHTOOL_BITOPS_H__ -#define ETHTOOL_BITOPS_H__ - -#define BITS_PER_BYTE 8 -#define BITS_PER_LONG (BITS_PER_BYTE * sizeof(long)) -#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) -#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_LONG) - -static inline void set_bit(int nr, unsigned long *addr) -{ - addr[nr / BITS_PER_LONG] |= 1UL << (nr % BITS_PER_LONG); -} - -static inline void clear_bit(int nr, unsigned long *addr) -{ - addr[nr / BITS_PER_LONG] &= ~(1UL << (nr % BITS_PER_LONG)); -} - -static inline int test_bit(unsigned int nr, const unsigned long *addr) -{ - return !!((1UL << (nr % BITS_PER_LONG)) & - (((unsigned long *)addr)[nr / BITS_PER_LONG])); -} - -#endif diff --git a/ethtool-util.h b/ethtool-util.h deleted file mode 100644 index 79be7f2..0000000 --- a/ethtool-util.h +++ /dev/null @@ -1,143 +0,0 @@ -/* Portions Copyright 2001 Sun Microsystems (thockin@sun.com) */ -/* Portions Copyright 2002 Intel (scott.feldman@intel.com) */ -#ifndef ETHTOOL_UTIL_H__ -#define ETHTOOL_UTIL_H__ - -#ifdef HAVE_CONFIG_H -#include "ethtool-config.h" -#endif -#include -#include -#include -#include - -/* ethtool.h expects these to be defined by */ -#ifndef HAVE_BE_TYPES -typedef __uint16_t __be16; -typedef __uint32_t __be32; -typedef unsigned long long __be64; -#endif - -typedef unsigned long long u64; -typedef __uint32_t u32; -typedef __uint16_t u16; -typedef __uint8_t u8; -typedef __int32_t s32; - -#include "ethtool-copy.h" - -#if __BYTE_ORDER == __BIG_ENDIAN -static inline u16 cpu_to_be16(u16 value) -{ - return value; -} -static inline u32 cpu_to_be32(u32 value) -{ - return value; -} -static inline u64 cpu_to_be64(u64 value) -{ - return value; -} -#else -static inline u16 cpu_to_be16(u16 value) -{ - return (value >> 8) | (value << 8); -} -static inline u32 cpu_to_be32(u32 value) -{ - return cpu_to_be16(value >> 16) | (cpu_to_be16(value) << 16); -} -static inline u64 cpu_to_be64(u64 value) -{ - return cpu_to_be32(value >> 32) | ((u64)cpu_to_be32(value) << 32); -} -#endif - -#define ntohll cpu_to_be64 -#define htonll cpu_to_be64 - -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) -#endif - -#ifndef SIOCETHTOOL -#define SIOCETHTOOL 0x8946 -#endif - -#define RX_CLS_LOC_UNSPEC 0xffffffffUL - -/* National Semiconductor DP83815, DP83816 */ -int natsemi_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); -int natsemi_dump_eeprom(struct ethtool_drvinfo *info, - struct ethtool_eeprom *ee); - -/* Digital/Intel 21040 and 21041 */ -int de2104x_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); - -/* Intel(R) PRO/1000 Gigabit Adapter Family */ -int e1000_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); - -int igb_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); - -/* RealTek PCI */ -int realtek_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); - -/* Intel(R) PRO/100 Fast Ethernet Adapter Family */ -int e100_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); - -/* Tigon3 */ -int tg3_dump_eeprom(struct ethtool_drvinfo *info, struct ethtool_eeprom *ee); - -/* Advanced Micro Devices AMD8111 based Adapter */ -int amd8111e_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); - -/* Advanced Micro Devices PCnet32 Adapter */ -int pcnet32_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); - -/* Motorola 8xx FEC Ethernet controller */ -int fec_8xx_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); - -/* PowerPC 4xx on-chip Ethernet controller */ -int ibm_emac_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); - -/* Intel(R) PRO/10GBe Gigabit Adapter Family */ -int ixgb_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); - -int ixgbe_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); - -/* Broadcom Tigon3 Ethernet controller */ -int tg3_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); - -/* SysKonnect Gigabit (Genesis and Yukon) */ -int skge_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); - -/* SysKonnect Gigabit (Yukon2) */ -int sky2_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); - -/* Fabric7 VIOC */ -int vioc_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); - -/* SMSC LAN911x/LAN921x embedded ethernet controller */ -int smsc911x_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); - -int at76c50x_usb_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); - -/* Solarflare Solarstorm controllers */ -int sfc_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); - -/* STMMAC embedded ethernet controller */ -int st_mac100_dump_regs(struct ethtool_drvinfo *info, - struct ethtool_regs *regs); -int st_gmac_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); - -/* Rx flow classification */ -int rxclass_parse_ruleopts(char **optstr, int opt_cnt, - struct ethtool_rx_flow_spec *fsp); -int rxclass_rule_getall(int fd, struct ifreq *ifr); -int rxclass_rule_get(int fd, struct ifreq *ifr, __u32 loc); -int rxclass_rule_ins(int fd, struct ifreq *ifr, - struct ethtool_rx_flow_spec *fsp); -int rxclass_rule_del(int fd, struct ifreq *ifr, __u32 loc); - -#endif /* ETHTOOL_UTIL_H__ */ diff --git a/ethtool.c b/ethtool.c index ad2d583..f772f61 100644 --- a/ethtool.c +++ b/ethtool.c @@ -23,7 +23,7 @@ * * show settings for all devices */ -#include "ethtool-util.h" +#include "internal.h" #include #include #include diff --git a/fec_8xx.c b/fec_8xx.c index 06a25d9..69db8c8 100644 --- a/fec_8xx.c +++ b/fec_8xx.c @@ -7,7 +7,7 @@ #include #include -#include "ethtool-util.h" +#include "internal.h" struct fec { uint32_t addr_low; /* lower 32 bits of station address */ diff --git a/ibm_emac.c b/ibm_emac.c index 7974836..e128e48 100644 --- a/ibm_emac.c +++ b/ibm_emac.c @@ -6,7 +6,7 @@ #include #include -#include "ethtool-util.h" +#include "internal.h" /* Ethtool get_regs complex data. * we want to get not just EMAC registers, but also MAL, ZMII, RGMII, TAH diff --git a/igb.c b/igb.c index 4b836d9..ec35d36 100644 --- a/igb.c +++ b/igb.c @@ -1,6 +1,6 @@ /* Copyright (c) 2007 Intel Corporation */ #include -#include "ethtool-util.h" +#include "internal.h" /* Register Bit Masks */ /* Device Control */ diff --git a/internal.h b/internal.h new file mode 100644 index 0000000..693b091 --- /dev/null +++ b/internal.h @@ -0,0 +1,164 @@ +/* Portions Copyright 2001 Sun Microsystems (thockin@sun.com) */ +/* Portions Copyright 2002 Intel (scott.feldman@intel.com) */ +#ifndef ETHTOOL_INTERNAL_H__ +#define ETHTOOL_INTERNAL_H__ + +#ifdef HAVE_CONFIG_H +#include "ethtool-config.h" +#endif +#include +#include +#include +#include + +/* ethtool.h expects these to be defined by */ +#ifndef HAVE_BE_TYPES +typedef __uint16_t __be16; +typedef __uint32_t __be32; +typedef unsigned long long __be64; +#endif + +typedef unsigned long long u64; +typedef __uint32_t u32; +typedef __uint16_t u16; +typedef __uint8_t u8; +typedef __int32_t s32; + +#include "ethtool-copy.h" + +#if __BYTE_ORDER == __BIG_ENDIAN +static inline u16 cpu_to_be16(u16 value) +{ + return value; +} +static inline u32 cpu_to_be32(u32 value) +{ + return value; +} +static inline u64 cpu_to_be64(u64 value) +{ + return value; +} +#else +static inline u16 cpu_to_be16(u16 value) +{ + return (value >> 8) | (value << 8); +} +static inline u32 cpu_to_be32(u32 value) +{ + return cpu_to_be16(value >> 16) | (cpu_to_be16(value) << 16); +} +static inline u64 cpu_to_be64(u64 value) +{ + return cpu_to_be32(value >> 32) | ((u64)cpu_to_be32(value) << 32); +} +#endif + +#define ntohll cpu_to_be64 +#define htonll cpu_to_be64 + +#define BITS_PER_BYTE 8 +#define BITS_PER_LONG (BITS_PER_BYTE * sizeof(long)) +#define DIV_ROUND_UP(n, d) (((n) + (d) - 1) / (d)) +#define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_LONG) + +static inline void set_bit(int nr, unsigned long *addr) +{ + addr[nr / BITS_PER_LONG] |= 1UL << (nr % BITS_PER_LONG); +} + +static inline void clear_bit(int nr, unsigned long *addr) +{ + addr[nr / BITS_PER_LONG] &= ~(1UL << (nr % BITS_PER_LONG)); +} + +static inline int test_bit(unsigned int nr, const unsigned long *addr) +{ + return !!((1UL << (nr % BITS_PER_LONG)) & + (((unsigned long *)addr)[nr / BITS_PER_LONG])); +} + +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) +#endif + +#ifndef SIOCETHTOOL +#define SIOCETHTOOL 0x8946 +#endif + +#define RX_CLS_LOC_UNSPEC 0xffffffffUL + +/* National Semiconductor DP83815, DP83816 */ +int natsemi_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); +int natsemi_dump_eeprom(struct ethtool_drvinfo *info, + struct ethtool_eeprom *ee); + +/* Digital/Intel 21040 and 21041 */ +int de2104x_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); + +/* Intel(R) PRO/1000 Gigabit Adapter Family */ +int e1000_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); + +int igb_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); + +/* RealTek PCI */ +int realtek_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); + +/* Intel(R) PRO/100 Fast Ethernet Adapter Family */ +int e100_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); + +/* Tigon3 */ +int tg3_dump_eeprom(struct ethtool_drvinfo *info, struct ethtool_eeprom *ee); + +/* Advanced Micro Devices AMD8111 based Adapter */ +int amd8111e_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); + +/* Advanced Micro Devices PCnet32 Adapter */ +int pcnet32_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); + +/* Motorola 8xx FEC Ethernet controller */ +int fec_8xx_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); + +/* PowerPC 4xx on-chip Ethernet controller */ +int ibm_emac_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); + +/* Intel(R) PRO/10GBe Gigabit Adapter Family */ +int ixgb_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); + +int ixgbe_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); + +/* Broadcom Tigon3 Ethernet controller */ +int tg3_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); + +/* SysKonnect Gigabit (Genesis and Yukon) */ +int skge_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); + +/* SysKonnect Gigabit (Yukon2) */ +int sky2_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); + +/* Fabric7 VIOC */ +int vioc_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); + +/* SMSC LAN911x/LAN921x embedded ethernet controller */ +int smsc911x_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); + +int at76c50x_usb_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); + +/* Solarflare Solarstorm controllers */ +int sfc_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); + +/* STMMAC embedded ethernet controller */ +int st_mac100_dump_regs(struct ethtool_drvinfo *info, + struct ethtool_regs *regs); +int st_gmac_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs); + +/* Rx flow classification */ +int rxclass_parse_ruleopts(char **optstr, int opt_cnt, + struct ethtool_rx_flow_spec *fsp); +int rxclass_rule_getall(int fd, struct ifreq *ifr); +int rxclass_rule_get(int fd, struct ifreq *ifr, __u32 loc); +int rxclass_rule_ins(int fd, struct ifreq *ifr, + struct ethtool_rx_flow_spec *fsp); +int rxclass_rule_del(int fd, struct ifreq *ifr, __u32 loc); + +#endif /* ETHTOOL_INTERNAL_H__ */ diff --git a/ixgb.c b/ixgb.c index 00c90d3..8687c21 100644 --- a/ixgb.c +++ b/ixgb.c @@ -1,6 +1,6 @@ /* Copyright (c) 2006 Intel Corporation */ #include -#include "ethtool-util.h" +#include "internal.h" /* CTRL0 Bit Masks */ #define IXGB_CTRL0_LRST 0x00000008 diff --git a/ixgbe.c b/ixgbe.c index e64d34a..dae11d4 100644 --- a/ixgbe.c +++ b/ixgbe.c @@ -1,6 +1,6 @@ /* Copyright (c) 2007 Intel Corporation */ #include -#include "ethtool-util.h" +#include "internal.h" /* Register Bit Masks */ #define IXGBE_FCTRL_SBP 0x00000002 diff --git a/marvell.c b/marvell.c index af38c21..e583c82 100644 --- a/marvell.c +++ b/marvell.c @@ -7,7 +7,7 @@ #include -#include "ethtool-util.h" +#include "internal.h" static void dump_addr(int n, const u8 *a) { diff --git a/natsemi.c b/natsemi.c index 24a7cb3..eaf83e2 100644 --- a/natsemi.c +++ b/natsemi.c @@ -1,6 +1,6 @@ /* Copyright 2001 Sun Microsystems (thockin@sun.com) */ #include -#include "ethtool-util.h" +#include "internal.h" #define PCI_VENDOR_NATSEMI 0x100b #define PCI_DEVICE_DP83815 0x0020 diff --git a/pcnet32.c b/pcnet32.c index 1dac02d..b87cee7 100644 --- a/pcnet32.c +++ b/pcnet32.c @@ -2,7 +2,7 @@ #include #include -#include "ethtool-util.h" +#include "internal.h" #define BIT0 0x0001 #define BIT1 0x0002 diff --git a/realtek.c b/realtek.c index 11ed835..c3d7ae5 100644 --- a/realtek.c +++ b/realtek.c @@ -1,7 +1,7 @@ /* Copyright 2001 Sun Microsystems (thockin@sun.com) */ #include #include -#include "ethtool-util.h" +#include "internal.h" #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) diff --git a/rxclass.c b/rxclass.c index b227901..809b073 100644 --- a/rxclass.c +++ b/rxclass.c @@ -10,8 +10,7 @@ #include #include -#include "ethtool-util.h" -#include "ethtool-bitops.h" +#include "internal.h" static void invert_flow_mask(struct ethtool_rx_flow_spec *fsp) { diff --git a/sfc.c b/sfc.c index c8ca74a..46a617b 100644 --- a/sfc.c +++ b/sfc.c @@ -9,7 +9,7 @@ #include #include -#include "ethtool-util.h" +#include "internal.h" #ifndef ARRAY_SIZE #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) diff --git a/smsc911x.c b/smsc911x.c index 1aa39a1..c55b97b 100644 --- a/smsc911x.c +++ b/smsc911x.c @@ -1,6 +1,6 @@ #include #include -#include "ethtool-util.h" +#include "internal.h" int smsc911x_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs) { diff --git a/stmmac.c b/stmmac.c index ad4311c..fb69bfe 100644 --- a/stmmac.c +++ b/stmmac.c @@ -12,7 +12,7 @@ #include #include -#include "ethtool-util.h" +#include "internal.h" int st_mac100_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs) diff --git a/tg3.c b/tg3.c index 4868504..3232339 100644 --- a/tg3.c +++ b/tg3.c @@ -1,6 +1,6 @@ #include #include -#include "ethtool-util.h" +#include "internal.h" #define TG3_MAGIC 0x669955aa diff --git a/vioc.c b/vioc.c index c771737..eff533d 100644 --- a/vioc.c +++ b/vioc.c @@ -2,7 +2,7 @@ #include #include -#include "ethtool-util.h" +#include "internal.h" struct regs_line { u32 addr; -- cgit v1.2.1