aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/netdev_features.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/netdev_features.h')
-rw-r--r--include/linux/netdev_features.h24
1 files changed, 22 insertions, 2 deletions
diff --git a/include/linux/netdev_features.h b/include/linux/netdev_features.h
index 2b2a6dce1630..4c76fe2c8488 100644
--- a/include/linux/netdev_features.h
+++ b/include/linux/netdev_features.h
@@ -11,6 +11,8 @@
11#define _LINUX_NETDEV_FEATURES_H 11#define _LINUX_NETDEV_FEATURES_H
12 12
13#include <linux/types.h> 13#include <linux/types.h>
14#include <linux/bitops.h>
15#include <asm/byteorder.h>
14 16
15typedef u64 netdev_features_t; 17typedef u64 netdev_features_t;
16 18
@@ -154,8 +156,26 @@ enum {
154#define NETIF_F_HW_TLS_TX __NETIF_F(HW_TLS_TX) 156#define NETIF_F_HW_TLS_TX __NETIF_F(HW_TLS_TX)
155#define NETIF_F_HW_TLS_RX __NETIF_F(HW_TLS_RX) 157#define NETIF_F_HW_TLS_RX __NETIF_F(HW_TLS_RX)
156 158
157#define for_each_netdev_feature(mask_addr, bit) \ 159/* Finds the next feature with the highest number of the range of start till 0.
158 for_each_set_bit(bit, (unsigned long *)mask_addr, NETDEV_FEATURE_COUNT) 160 */
161static inline int find_next_netdev_feature(u64 feature, unsigned long start)
162{
163 /* like BITMAP_LAST_WORD_MASK() for u64
164 * this sets the most significant 64 - start to 0.
165 */
166 feature &= ~0ULL >> (-start & ((sizeof(feature) * 8) - 1));
167
168 return fls64(feature) - 1;
169}
170
171/* This goes for the MSB to the LSB through the set feature bits,
172 * mask_addr should be a u64 and bit an int
173 */
174#define for_each_netdev_feature(mask_addr, bit) \
175 for ((bit) = find_next_netdev_feature((mask_addr), \
176 NETDEV_FEATURE_COUNT); \
177 (bit) >= 0; \
178 (bit) = find_next_netdev_feature((mask_addr), (bit) - 1))
159 179
160/* Features valid for ethtool to change */ 180/* Features valid for ethtool to change */
161/* = all defined minus driver/device-class-related */ 181/* = all defined minus driver/device-class-related */