1 /* SPDX-License-Identifier: GPL-2.0-only */ 2 /* 3 * Copyright (C) 2016 Felix Fietkau <nbd@nbd.name> 4 * Copyright (C) 2004 - 2009 Ivo van Doorn <IvDoorn@gmail.com> 5 */ 6 7 #ifndef __MT76_UTIL_H 8 #define __MT76_UTIL_H 9 10 #include <linux/skbuff.h> 11 #include <linux/bitops.h> 12 #include <linux/bitfield.h> 13 14 #define MT76_INCR(_var, _size) \ 15 (_var = (((_var) + 1) % (_size))) 16 17 int mt76_wcid_alloc(u32 *mask, int size); 18 19 static inline bool 20 mt76_wcid_mask_test(u32 *mask, int idx) 21 { 22 return mask[idx / 32] & BIT(idx % 32); 23 } 24 25 static inline void 26 mt76_wcid_mask_set(u32 *mask, int idx) 27 { 28 mask[idx / 32] |= BIT(idx % 32); 29 } 30 31 static inline void 32 mt76_wcid_mask_clear(u32 *mask, int idx) 33 { 34 mask[idx / 32] &= ~BIT(idx % 32); 35 } 36 37 static inline void 38 mt76_skb_set_moredata(struct sk_buff *skb, bool enable) 39 { 40 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; 41 42 if (enable) 43 hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_MOREDATA); 44 else 45 hdr->frame_control &= ~cpu_to_le16(IEEE80211_FCTL_MOREDATA); 46 } 47 48 #endif 49