util.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * Copyright (C) 2016 Felix Fietkau <nbd@nbd.name>
  3. * Copyright (C) 2004 - 2009 Ivo van Doorn <IvDoorn@gmail.com>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License version 2
  7. * as published by the Free Software Foundation
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. */
  14. #ifndef __MT76_UTIL_H
  15. #define __MT76_UTIL_H
  16. #include <linux/skbuff.h>
  17. #include <linux/bitops.h>
  18. #include <linux/bitfield.h>
  19. #define MT76_INCR(_var, _size) \
  20. _var = (((_var) + 1) % _size)
  21. int mt76_wcid_alloc(unsigned long *mask, int size);
  22. static inline void
  23. mt76_wcid_free(unsigned long *mask, int idx)
  24. {
  25. mask[idx / BITS_PER_LONG] &= ~BIT(idx % BITS_PER_LONG);
  26. }
  27. static inline void
  28. mt76_skb_set_moredata(struct sk_buff *skb, bool enable)
  29. {
  30. struct ieee80211_hdr *hdr = (struct ieee80211_hdr *) skb->data;
  31. if (enable)
  32. hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_MOREDATA);
  33. else
  34. hdr->frame_control &= ~cpu_to_le16(IEEE80211_FCTL_MOREDATA);
  35. }
  36. #endif