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(unsigned long *mask, int size); 18 19 static inline void 20 mt76_wcid_free(unsigned long *mask, int idx) 21 { 22 mask[idx / BITS_PER_LONG] &= ~BIT(idx % BITS_PER_LONG); 23 } 24 25 static inline void 26 mt76_skb_set_moredata(struct sk_buff *skb, bool enable) 27 { 28 struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data; 29 30 if (enable) 31 hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_MOREDATA); 32 else 33 hdr->frame_control &= ~cpu_to_le16(IEEE80211_FCTL_MOREDATA); 34 } 35 36 #endif 37