summaryrefslogtreecommitdiff
path: root/ethtool-bitops.h
diff options
context:
space:
mode:
authorAlexander Duyck <alexander.h.duyck@intel.com>2011-05-04 11:41:46 -0700
committerBen Hutchings <bhutchings@solarflare.com>2011-05-13 01:04:59 +0100
commit9a7baa6c15344dee34d5a9dd0308dc43fc29c488 (patch)
tree918662021bbc43c575b1f20b3a83f337e20e1a26 /ethtool-bitops.h
parent8a7c0708b6fb7be245c21e9f6aabb0d8fd968a03 (diff)
downloadethtool-9a7baa6c15344dee34d5a9dd0308dc43fc29c488.tar.gz
Add support for __be64 and bitops, centralize several needed macros
This change is meant to add support for __be64 values and bitops to ethtool. In addition the patch pulls the SIOCETHTOOL define and the ARRAY_SIZE define into ethtool-util.h for later use by the rxclass files. These changes will be needed in order to support network flow classifier rule configuration. Signed-off-by: Alexander Duyck <alexander.h.duyck@intel.com> Signed-off-by: Ben Hutchings <bhutchings@solarflare.com>
Diffstat (limited to 'ethtool-bitops.h')
-rw-r--r--ethtool-bitops.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/ethtool-bitops.h b/ethtool-bitops.h
new file mode 100644
index 0000000..b1eb426
--- /dev/null
+++ b/ethtool-bitops.h
@@ -0,0 +1,25 @@
+#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