main.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
  17. #include <linux/kernel.h>
  18. #include <linux/module.h>
  19. #include "ath.h"
  20. MODULE_AUTHOR("Atheros Communications");
  21. MODULE_DESCRIPTION("Shared library for Atheros wireless LAN cards.");
  22. MODULE_LICENSE("Dual BSD/GPL");
  23. struct sk_buff *ath_rxbuf_alloc(struct ath_common *common,
  24. u32 len,
  25. gfp_t gfp_mask)
  26. {
  27. struct sk_buff *skb;
  28. u32 off;
  29. /*
  30. * Cache-line-align. This is important (for the
  31. * 5210 at least) as not doing so causes bogus data
  32. * in rx'd frames.
  33. */
  34. /* Note: the kernel can allocate a value greater than
  35. * what we ask it to give us. We really only need 4 KB as that
  36. * is this hardware supports and in fact we need at least 3849
  37. * as that is the MAX AMSDU size this hardware supports.
  38. * Unfortunately this means we may get 8 KB here from the
  39. * kernel... and that is actually what is observed on some
  40. * systems :( */
  41. skb = __dev_alloc_skb(len + common->cachelsz - 1, gfp_mask);
  42. if (skb != NULL) {
  43. off = ((unsigned long) skb->data) % common->cachelsz;
  44. if (off != 0)
  45. skb_reserve(skb, common->cachelsz - off);
  46. } else {
  47. pr_err("skbuff alloc of size %u failed\n", len);
  48. return NULL;
  49. }
  50. return skb;
  51. }
  52. EXPORT_SYMBOL(ath_rxbuf_alloc);
  53. void ath_printk(const char *level, const struct ath_common* common,
  54. const char *fmt, ...)
  55. {
  56. struct va_format vaf;
  57. va_list args;
  58. va_start(args, fmt);
  59. vaf.fmt = fmt;
  60. vaf.va = &args;
  61. if (common && common->hw && common->hw->wiphy)
  62. printk("%sath: %s: %pV",
  63. level, wiphy_name(common->hw->wiphy), &vaf);
  64. else
  65. printk("%sath: %pV", level, &vaf);
  66. va_end(args);
  67. }
  68. EXPORT_SYMBOL(ath_printk);