bfa_sgpg_priv.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright (c) 2005-2009 Brocade Communications Systems, Inc.
  3. * All rights reserved
  4. * www.brocade.com
  5. *
  6. * Linux driver for Brocade Fibre Channel Host Bus Adapter.
  7. *
  8. * This program is free software; you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License (GPL) Version 2 as
  10. * published by the Free Software Foundation
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. */
  17. /**
  18. * hal_sgpg.h BFA SG page module
  19. */
  20. #ifndef __BFA_SGPG_PRIV_H__
  21. #define __BFA_SGPG_PRIV_H__
  22. #include <cs/bfa_q.h>
  23. #define BFA_SGPG_MIN (16)
  24. /**
  25. * Alignment macro for SG page allocation
  26. */
  27. #define BFA_SGPG_ROUNDUP(_l) (((_l) + (sizeof(struct bfi_sgpg_s) - 1)) \
  28. & ~(sizeof(struct bfi_sgpg_s) - 1))
  29. struct bfa_sgpg_wqe_s {
  30. struct list_head qe; /* queue sg page element */
  31. int nsgpg; /* pages to be allocated */
  32. int nsgpg_total; /* total pages required */
  33. void (*cbfn) (void *cbarg);
  34. /* callback function */
  35. void *cbarg; /* callback arg */
  36. struct list_head sgpg_q; /* queue of alloced sgpgs */
  37. };
  38. struct bfa_sgpg_s {
  39. struct list_head qe; /* queue sg page element */
  40. struct bfi_sgpg_s *sgpg; /* va of SG page */
  41. union bfi_addr_u sgpg_pa;/* pa of SG page */
  42. };
  43. /**
  44. * Given number of SG elements, BFA_SGPG_NPAGE() returns the number of
  45. * SG pages required.
  46. */
  47. #define BFA_SGPG_NPAGE(_nsges) (((_nsges) / BFI_SGPG_DATA_SGES) + 1)
  48. struct bfa_sgpg_mod_s {
  49. struct bfa_s *bfa;
  50. int num_sgpgs; /* number of SG pages */
  51. int free_sgpgs; /* number of free SG pages */
  52. struct bfa_sgpg_s *hsgpg_arr; /* BFA SG page array */
  53. struct bfi_sgpg_s *sgpg_arr; /* actual SG page array */
  54. u64 sgpg_arr_pa; /* SG page array DMA addr */
  55. struct list_head sgpg_q; /* queue of free SG pages */
  56. struct list_head sgpg_wait_q; /* wait queue for SG pages */
  57. };
  58. #define BFA_SGPG_MOD(__bfa) (&(__bfa)->modules.sgpg_mod)
  59. bfa_status_t bfa_sgpg_malloc(struct bfa_s *bfa, struct list_head *sgpg_q,
  60. int nsgpgs);
  61. void bfa_sgpg_mfree(struct bfa_s *bfa, struct list_head *sgpg_q,
  62. int nsgpgs);
  63. void bfa_sgpg_winit(struct bfa_sgpg_wqe_s *wqe,
  64. void (*cbfn) (void *cbarg), void *cbarg);
  65. void bfa_sgpg_wait(struct bfa_s *bfa, struct bfa_sgpg_wqe_s *wqe,
  66. int nsgpgs);
  67. void bfa_sgpg_wcancel(struct bfa_s *bfa, struct bfa_sgpg_wqe_s *wqe);
  68. #endif /* __BFA_SGPG_PRIV_H__ */