main.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /*
  2. * Copyright (c) 2009 Atheros Communications Inc.
  3. *
  4. * Permission to use, copy, modify, and/or distribute this software for any
  5. * purpose with or without fee is hereby granted, provided that the above
  6. * copyright notice and this permission notice appear in all copies.
  7. *
  8. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  9. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  10. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  11. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  12. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  13. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  14. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  15. */
  16. #include <linux/kernel.h>
  17. #include <linux/module.h>
  18. #include "ath.h"
  19. MODULE_AUTHOR("Atheros Communications");
  20. MODULE_DESCRIPTION("Shared library for Atheros wireless LAN cards.");
  21. MODULE_LICENSE("Dual BSD/GPL");
  22. struct sk_buff *ath_rxbuf_alloc(struct ath_common *common,
  23. u32 len,
  24. gfp_t gfp_mask)
  25. {
  26. struct sk_buff *skb;
  27. u32 off;
  28. /*
  29. * Cache-line-align. This is important (for the
  30. * 5210 at least) as not doing so causes bogus data
  31. * in rx'd frames.
  32. */
  33. /* Note: the kernel can allocate a value greater than
  34. * what we ask it to give us. We really only need 4 KB as that
  35. * is this hardware supports and in fact we need at least 3849
  36. * as that is the MAX AMSDU size this hardware supports.
  37. * Unfortunately this means we may get 8 KB here from the
  38. * kernel... and that is actually what is observed on some
  39. * systems :( */
  40. skb = __dev_alloc_skb(len + common->cachelsz - 1, gfp_mask);
  41. if (skb != NULL) {
  42. off = ((unsigned long) skb->data) % common->cachelsz;
  43. if (off != 0)
  44. skb_reserve(skb, common->cachelsz - off);
  45. } else {
  46. printk(KERN_ERR "skbuff alloc of size %u failed\n", len);
  47. return NULL;
  48. }
  49. return skb;
  50. }
  51. EXPORT_SYMBOL(ath_rxbuf_alloc);
  52. void ath_printk(const char *level, const char *fmt, ...)
  53. {
  54. struct va_format vaf;
  55. va_list args;
  56. va_start(args, fmt);
  57. vaf.fmt = fmt;
  58. vaf.va = &args;
  59. printk("%sath: %pV", level, &vaf);
  60. va_end(args);
  61. }
  62. EXPORT_SYMBOL(ath_printk);