1 #ifndef __LINKMODE_H 2 #define __LINKMODE_H 3 4 #include <linux/bitmap.h> 5 #include <linux/ethtool.h> 6 #include <uapi/linux/ethtool.h> 7 8 static inline void linkmode_zero(unsigned long *dst) 9 { 10 bitmap_zero(dst, __ETHTOOL_LINK_MODE_MASK_NBITS); 11 } 12 13 static inline void linkmode_fill(unsigned long *dst) 14 { 15 bitmap_fill(dst, __ETHTOOL_LINK_MODE_MASK_NBITS); 16 } 17 18 static inline void linkmode_copy(unsigned long *dst, const unsigned long *src) 19 { 20 bitmap_copy(dst, src, __ETHTOOL_LINK_MODE_MASK_NBITS); 21 } 22 23 static inline void linkmode_and(unsigned long *dst, const unsigned long *a, 24 const unsigned long *b) 25 { 26 bitmap_and(dst, a, b, __ETHTOOL_LINK_MODE_MASK_NBITS); 27 } 28 29 static inline void linkmode_or(unsigned long *dst, const unsigned long *a, 30 const unsigned long *b) 31 { 32 bitmap_or(dst, a, b, __ETHTOOL_LINK_MODE_MASK_NBITS); 33 } 34 35 static inline bool linkmode_empty(const unsigned long *src) 36 { 37 return bitmap_empty(src, __ETHTOOL_LINK_MODE_MASK_NBITS); 38 } 39 40 static inline bool linkmode_andnot(unsigned long *dst, 41 const unsigned long *src1, 42 const unsigned long *src2) 43 { 44 return bitmap_andnot(dst, src1, src2, __ETHTOOL_LINK_MODE_MASK_NBITS); 45 } 46 47 #define linkmode_test_bit test_bit 48 #define linkmode_set_bit __set_bit 49 #define linkmode_clear_bit __clear_bit 50 #define linkmode_mod_bit __assign_bit 51 52 static inline void linkmode_set_bit_array(const int *array, int array_size, 53 unsigned long *addr) 54 { 55 int i; 56 57 for (i = 0; i < array_size; i++) 58 linkmode_set_bit(array[i], addr); 59 } 60 61 static inline int linkmode_equal(const unsigned long *src1, 62 const unsigned long *src2) 63 { 64 return bitmap_equal(src1, src2, __ETHTOOL_LINK_MODE_MASK_NBITS); 65 } 66 67 static inline int linkmode_intersects(const unsigned long *src1, 68 const unsigned long *src2) 69 { 70 return bitmap_intersects(src1, src2, __ETHTOOL_LINK_MODE_MASK_NBITS); 71 } 72 73 static inline int linkmode_subset(const unsigned long *src1, 74 const unsigned long *src2) 75 { 76 return bitmap_subset(src1, src2, __ETHTOOL_LINK_MODE_MASK_NBITS); 77 } 78 79 void linkmode_resolve_pause(const unsigned long *local_adv, 80 const unsigned long *partner_adv, 81 bool *tx_pause, bool *rx_pause); 82 83 void linkmode_set_pause(unsigned long *advertisement, bool tx, bool rx); 84 85 #endif /* __LINKMODE_H */ 86