You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ath_main.c 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright (c) 2009 Atheros Communications Inc.
  3. *
  4. * Modified for iPXE by Scott K Logan <logans@cottsay.net> July 2011
  5. * Original from Linux kernel 3.0.1
  6. *
  7. * Permission to use, copy, modify, and/or distribute this software for any
  8. * purpose with or without fee is hereby granted, provided that the above
  9. * copyright notice and this permission notice appear in all copies.
  10. *
  11. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  12. * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  13. * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  14. * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  15. * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  16. * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  17. * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  18. */
  19. #include <ipxe/io.h>
  20. #include "ath.h"
  21. struct io_buffer *ath_rxbuf_alloc(struct ath_common *common,
  22. u32 len,
  23. u32 *iob_addr)
  24. {
  25. struct io_buffer *iob;
  26. u32 off;
  27. /*
  28. * Cache-line-align. This is important (for the
  29. * 5210 at least) as not doing so causes bogus data
  30. * in rx'd frames.
  31. */
  32. /* Note: the kernel can allocate a value greater than
  33. * what we ask it to give us. We really only need 4 KB as that
  34. * is this hardware supports and in fact we need at least 3849
  35. * as that is the MAX AMSDU size this hardware supports.
  36. * Unfortunately this means we may get 8 KB here from the
  37. * kernel... and that is actually what is observed on some
  38. * systems :( */
  39. iob = alloc_iob(len + common->cachelsz - 1);
  40. if (iob != NULL) {
  41. *iob_addr = virt_to_bus(iob->data);
  42. off = ((unsigned long) iob->data) % common->cachelsz;
  43. if (off != 0)
  44. {
  45. iob_reserve(iob, common->cachelsz - off);
  46. *iob_addr += common->cachelsz - off;
  47. }
  48. } else {
  49. DBG("ath: iobuffer alloc of size %d failed\n", len);
  50. return NULL;
  51. }
  52. return iob;
  53. }