PageRenderTime 74ms CodeModel.GetById 14ms RepoModel.GetById 1ms app.codeStats 0ms

/drivers/scsi/bfa/include/bfa.h

https://bitbucket.org/abioy/linux
C Header | 199 lines | 138 code | 24 blank | 37 comment | 1 complexity | b3c16569064e55a3ad9a98658c6cc8bd MD5 | raw file
Possible License(s): CC-BY-SA-3.0, GPL-2.0, LGPL-2.0, AGPL-1.0
  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. #ifndef __BFA_H__
  18. #define __BFA_H__
  19. #include <bfa_os_inc.h>
  20. #include <cs/bfa_debug.h>
  21. #include <cs/bfa_q.h>
  22. #include <cs/bfa_trc.h>
  23. #include <cs/bfa_log.h>
  24. #include <cs/bfa_plog.h>
  25. #include <defs/bfa_defs_status.h>
  26. #include <defs/bfa_defs_ioc.h>
  27. #include <defs/bfa_defs_iocfc.h>
  28. #include <aen/bfa_aen.h>
  29. #include <bfi/bfi.h>
  30. struct bfa_s;
  31. #include <bfa_intr_priv.h>
  32. struct bfa_pcidev_s;
  33. /**
  34. * PCI devices supported by the current BFA
  35. */
  36. struct bfa_pciid_s {
  37. u16 device_id;
  38. u16 vendor_id;
  39. };
  40. extern char bfa_version[];
  41. /**
  42. * BFA Power Mgmt Commands
  43. */
  44. enum bfa_pm_cmd {
  45. BFA_PM_CTL_D0 = 0,
  46. BFA_PM_CTL_D1 = 1,
  47. BFA_PM_CTL_D2 = 2,
  48. BFA_PM_CTL_D3 = 3,
  49. };
  50. /**
  51. * BFA memory resources
  52. */
  53. enum bfa_mem_type {
  54. BFA_MEM_TYPE_KVA = 1, /*! Kernel Virtual Memory *(non-dma-able) */
  55. BFA_MEM_TYPE_DMA = 2, /*! DMA-able memory */
  56. BFA_MEM_TYPE_MAX = BFA_MEM_TYPE_DMA,
  57. };
  58. struct bfa_mem_elem_s {
  59. enum bfa_mem_type mem_type; /* see enum bfa_mem_type */
  60. u32 mem_len; /* Total Length in Bytes */
  61. u8 *kva; /* kernel virtual address */
  62. u64 dma; /* dma address if DMA memory */
  63. u8 *kva_curp; /* kva allocation cursor */
  64. u64 dma_curp; /* dma allocation cursor */
  65. };
  66. struct bfa_meminfo_s {
  67. struct bfa_mem_elem_s meminfo[BFA_MEM_TYPE_MAX];
  68. };
  69. #define bfa_meminfo_kva(_m) \
  70. ((_m)->meminfo[BFA_MEM_TYPE_KVA - 1].kva_curp)
  71. #define bfa_meminfo_dma_virt(_m) \
  72. ((_m)->meminfo[BFA_MEM_TYPE_DMA - 1].kva_curp)
  73. #define bfa_meminfo_dma_phys(_m) \
  74. ((_m)->meminfo[BFA_MEM_TYPE_DMA - 1].dma_curp)
  75. /**
  76. * Generic Scatter Gather Element used by driver
  77. */
  78. struct bfa_sge_s {
  79. u32 sg_len;
  80. void *sg_addr;
  81. };
  82. #define bfa_sge_to_be(__sge) do { \
  83. ((u32 *)(__sge))[0] = bfa_os_htonl(((u32 *)(__sge))[0]); \
  84. ((u32 *)(__sge))[1] = bfa_os_htonl(((u32 *)(__sge))[1]); \
  85. ((u32 *)(__sge))[2] = bfa_os_htonl(((u32 *)(__sge))[2]); \
  86. } while (0)
  87. /*
  88. * bfa stats interfaces
  89. */
  90. #define bfa_stats(_mod, _stats) ((_mod)->stats._stats++)
  91. #define bfa_ioc_get_stats(__bfa, __ioc_stats) \
  92. bfa_ioc_fetch_stats(&(__bfa)->ioc, __ioc_stats)
  93. #define bfa_ioc_clear_stats(__bfa) \
  94. bfa_ioc_clr_stats(&(__bfa)->ioc)
  95. #define bfa_get_nports(__bfa) \
  96. bfa_ioc_get_nports(&(__bfa)->ioc)
  97. #define bfa_get_adapter_manufacturer(__bfa, __manufacturer) \
  98. bfa_ioc_get_adapter_manufacturer(&(__bfa)->ioc, __manufacturer)
  99. #define bfa_get_adapter_model(__bfa, __model) \
  100. bfa_ioc_get_adapter_model(&(__bfa)->ioc, __model)
  101. #define bfa_get_adapter_serial_num(__bfa, __serial_num) \
  102. bfa_ioc_get_adapter_serial_num(&(__bfa)->ioc, __serial_num)
  103. #define bfa_get_adapter_fw_ver(__bfa, __fw_ver) \
  104. bfa_ioc_get_adapter_fw_ver(&(__bfa)->ioc, __fw_ver)
  105. #define bfa_get_adapter_optrom_ver(__bfa, __optrom_ver) \
  106. bfa_ioc_get_adapter_optrom_ver(&(__bfa)->ioc, __optrom_ver)
  107. #define bfa_get_pci_chip_rev(__bfa, __chip_rev) \
  108. bfa_ioc_get_pci_chip_rev(&(__bfa)->ioc, __chip_rev)
  109. #define bfa_get_ioc_state(__bfa) \
  110. bfa_ioc_get_state(&(__bfa)->ioc)
  111. #define bfa_get_type(__bfa) \
  112. bfa_ioc_get_type(&(__bfa)->ioc)
  113. #define bfa_get_mac(__bfa) \
  114. bfa_ioc_get_mac(&(__bfa)->ioc)
  115. /*
  116. * bfa API functions
  117. */
  118. void bfa_get_pciids(struct bfa_pciid_s **pciids, int *npciids);
  119. void bfa_cfg_get_default(struct bfa_iocfc_cfg_s *cfg);
  120. void bfa_cfg_get_min(struct bfa_iocfc_cfg_s *cfg);
  121. void bfa_cfg_get_meminfo(struct bfa_iocfc_cfg_s *cfg,
  122. struct bfa_meminfo_s *meminfo);
  123. void bfa_attach(struct bfa_s *bfa, void *bfad, struct bfa_iocfc_cfg_s *cfg,
  124. struct bfa_meminfo_s *meminfo,
  125. struct bfa_pcidev_s *pcidev);
  126. void bfa_init_trc(struct bfa_s *bfa, struct bfa_trc_mod_s *trcmod);
  127. void bfa_init_log(struct bfa_s *bfa, struct bfa_log_mod_s *logmod);
  128. void bfa_init_aen(struct bfa_s *bfa, struct bfa_aen_s *aen);
  129. void bfa_init_plog(struct bfa_s *bfa, struct bfa_plog_s *plog);
  130. void bfa_detach(struct bfa_s *bfa);
  131. void bfa_init(struct bfa_s *bfa);
  132. void bfa_start(struct bfa_s *bfa);
  133. void bfa_stop(struct bfa_s *bfa);
  134. void bfa_attach_fcs(struct bfa_s *bfa);
  135. void bfa_cb_init(void *bfad, bfa_status_t status);
  136. void bfa_cb_stop(void *bfad, bfa_status_t status);
  137. void bfa_cb_updateq(void *bfad, bfa_status_t status);
  138. bfa_boolean_t bfa_intx(struct bfa_s *bfa);
  139. void bfa_isr_enable(struct bfa_s *bfa);
  140. void bfa_isr_disable(struct bfa_s *bfa);
  141. void bfa_msix_getvecs(struct bfa_s *bfa, u32 *msix_vecs_bmap,
  142. u32 *num_vecs, u32 *max_vec_bit);
  143. #define bfa_msix(__bfa, __vec) ((__bfa)->msix.handler[__vec](__bfa, __vec))
  144. void bfa_comp_deq(struct bfa_s *bfa, struct list_head *comp_q);
  145. void bfa_comp_process(struct bfa_s *bfa, struct list_head *comp_q);
  146. void bfa_comp_free(struct bfa_s *bfa, struct list_head *comp_q);
  147. typedef void (*bfa_cb_ioc_t) (void *cbarg, enum bfa_status status);
  148. void bfa_iocfc_get_attr(struct bfa_s *bfa, struct bfa_iocfc_attr_s *attr);
  149. bfa_status_t bfa_iocfc_get_stats(struct bfa_s *bfa,
  150. struct bfa_iocfc_stats_s *stats,
  151. bfa_cb_ioc_t cbfn, void *cbarg);
  152. bfa_status_t bfa_iocfc_clear_stats(struct bfa_s *bfa,
  153. bfa_cb_ioc_t cbfn, void *cbarg);
  154. void bfa_get_attr(struct bfa_s *bfa, struct bfa_ioc_attr_s *ioc_attr);
  155. void bfa_adapter_get_attr(struct bfa_s *bfa,
  156. struct bfa_adapter_attr_s *ad_attr);
  157. u64 bfa_adapter_get_id(struct bfa_s *bfa);
  158. bfa_status_t bfa_iocfc_israttr_set(struct bfa_s *bfa,
  159. struct bfa_iocfc_intr_attr_s *attr);
  160. void bfa_iocfc_enable(struct bfa_s *bfa);
  161. void bfa_iocfc_disable(struct bfa_s *bfa);
  162. void bfa_ioc_auto_recover(bfa_boolean_t auto_recover);
  163. void bfa_chip_reset(struct bfa_s *bfa);
  164. void bfa_cb_ioc_disable(void *bfad);
  165. void bfa_timer_tick(struct bfa_s *bfa);
  166. #define bfa_timer_start(_bfa, _timer, _timercb, _arg, _timeout) \
  167. bfa_timer_begin(&(_bfa)->timer_mod, _timer, _timercb, _arg, _timeout)
  168. /*
  169. * BFA debug API functions
  170. */
  171. bfa_status_t bfa_debug_fwtrc(struct bfa_s *bfa, void *trcdata, int *trclen);
  172. bfa_status_t bfa_debug_fwsave(struct bfa_s *bfa, void *trcdata, int *trclen);
  173. void bfa_debug_fwsave_clear(struct bfa_s *bfa);
  174. #include "bfa_priv.h"
  175. #endif /* __BFA_H__ */