bfad_drv.h 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  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. * Contains base driver definitions.
  19. */
  20. /**
  21. * bfa_drv.h Linux driver data structures.
  22. */
  23. #ifndef __BFAD_DRV_H__
  24. #define __BFAD_DRV_H__
  25. #include "bfa_os_inc.h"
  26. #include <bfa.h>
  27. #include <bfa_svc.h>
  28. #include <fcs/bfa_fcs.h>
  29. #include <defs/bfa_defs_pci.h>
  30. #include <defs/bfa_defs_port.h>
  31. #include <defs/bfa_defs_rport.h>
  32. #include <fcs/bfa_fcs_rport.h>
  33. #include <defs/bfa_defs_vport.h>
  34. #include <fcs/bfa_fcs_vport.h>
  35. #include <cs/bfa_plog.h>
  36. #include "aen/bfa_aen.h"
  37. #include <log/bfa_log_linux.h>
  38. #define BFAD_DRIVER_NAME "bfa"
  39. #ifdef BFA_DRIVER_VERSION
  40. #define BFAD_DRIVER_VERSION BFA_DRIVER_VERSION
  41. #else
  42. #define BFAD_DRIVER_VERSION "2.1.2.1"
  43. #endif
  44. #define BFAD_IRQ_FLAGS IRQF_SHARED
  45. /*
  46. * BFAD flags
  47. */
  48. #define BFAD_MSIX_ON 0x00000001
  49. #define BFAD_HAL_INIT_DONE 0x00000002
  50. #define BFAD_DRV_INIT_DONE 0x00000004
  51. #define BFAD_CFG_PPORT_DONE 0x00000008
  52. #define BFAD_HAL_START_DONE 0x00000010
  53. #define BFAD_PORT_ONLINE 0x00000020
  54. #define BFAD_RPORT_ONLINE 0x00000040
  55. #define BFAD_FCS_INIT_DONE 0x00000080
  56. #define BFAD_HAL_INIT_FAIL 0x00000100
  57. #define BFAD_FC4_PROBE_DONE 0x00000200
  58. #define BFAD_PORT_DELETE 0x00000001
  59. /*
  60. * BFAD related definition
  61. */
  62. #define SCSI_SCAN_DELAY HZ
  63. #define BFAD_STOP_TIMEOUT 30
  64. #define BFAD_SUSPEND_TIMEOUT BFAD_STOP_TIMEOUT
  65. /*
  66. * BFAD configuration parameter default values
  67. */
  68. #define BFAD_LUN_QUEUE_DEPTH 32
  69. #define BFAD_IO_MAX_SGE SG_ALL
  70. #define bfad_isr_t irq_handler_t
  71. #define MAX_MSIX_ENTRY 22
  72. struct bfad_msix_s {
  73. struct bfad_s *bfad;
  74. struct msix_entry msix;
  75. };
  76. enum bfad_port_pvb_type {
  77. BFAD_PORT_PHYS_BASE = 0,
  78. BFAD_PORT_PHYS_VPORT = 1,
  79. BFAD_PORT_VF_BASE = 2,
  80. BFAD_PORT_VF_VPORT = 3,
  81. };
  82. /*
  83. * PORT data structure
  84. */
  85. struct bfad_port_s {
  86. struct list_head list_entry;
  87. struct bfad_s *bfad;
  88. struct bfa_fcs_port_s *fcs_port;
  89. u32 roles;
  90. s32 flags;
  91. u32 supported_fc4s;
  92. u8 ipfc_flags;
  93. enum bfad_port_pvb_type pvb_type;
  94. struct bfad_im_port_s *im_port; /* IM specific data */
  95. struct bfad_tm_port_s *tm_port; /* TM specific data */
  96. struct bfad_ipfc_port_s *ipfc_port; /* IPFC specific data */
  97. };
  98. /*
  99. * VPORT data structure
  100. */
  101. struct bfad_vport_s {
  102. struct bfad_port_s drv_port;
  103. struct bfa_fcs_vport_s fcs_vport;
  104. struct completion *comp_del;
  105. struct list_head list_entry;
  106. struct bfa_port_cfg_s port_cfg;
  107. };
  108. /*
  109. * VF data structure
  110. */
  111. struct bfad_vf_s {
  112. bfa_fcs_vf_t fcs_vf;
  113. struct bfad_port_s base_port; /* base port for vf */
  114. struct bfad_s *bfad;
  115. };
  116. struct bfad_cfg_param_s {
  117. u32 rport_del_timeout;
  118. u32 ioc_queue_depth;
  119. u32 lun_queue_depth;
  120. u32 io_max_sge;
  121. u32 binding_method;
  122. };
  123. /*
  124. * BFAD (PCI function) data structure
  125. */
  126. struct bfad_s {
  127. struct list_head list_entry;
  128. struct bfa_s bfa;
  129. struct bfa_fcs_s bfa_fcs;
  130. struct pci_dev *pcidev;
  131. const char *pci_name;
  132. struct bfa_pcidev_s hal_pcidev;
  133. struct bfa_ioc_pci_attr_s pci_attr;
  134. void __iomem *pci_bar0_kva;
  135. struct completion comp;
  136. struct completion suspend;
  137. struct completion disable_comp;
  138. bfa_boolean_t disable_active;
  139. struct bfad_port_s pport; /* physical port of the BFAD */
  140. struct bfa_meminfo_s meminfo;
  141. struct bfa_iocfc_cfg_s ioc_cfg;
  142. u32 inst_no; /* BFAD instance number */
  143. u32 bfad_flags;
  144. spinlock_t bfad_lock;
  145. struct task_struct *bfad_tsk;
  146. struct bfad_cfg_param_s cfg_data;
  147. struct bfad_msix_s msix_tab[MAX_MSIX_ENTRY];
  148. int nvec;
  149. char adapter_name[BFA_ADAPTER_SYM_NAME_LEN];
  150. char port_name[BFA_ADAPTER_SYM_NAME_LEN];
  151. struct timer_list hal_tmo;
  152. unsigned long hs_start;
  153. struct bfad_im_s *im; /* IM specific data */
  154. struct bfad_tm_s *tm; /* TM specific data */
  155. struct bfad_ipfc_s *ipfc; /* IPFC specific data */
  156. struct bfa_log_mod_s log_data;
  157. struct bfa_trc_mod_s *trcmod;
  158. struct bfa_log_mod_s *logmod;
  159. struct bfa_aen_s *aen;
  160. struct bfa_aen_s aen_buf;
  161. void *file_map[BFA_AEN_MAX_APP];
  162. struct bfa_plog_s plog_buf;
  163. int ref_count;
  164. bfa_boolean_t ipfc_enabled;
  165. struct fc_host_statistics link_stats;
  166. struct list_head pbc_pcfg_list;
  167. atomic_t wq_reqcnt;
  168. };
  169. struct bfad_pcfg_s {
  170. struct list_head list_entry;
  171. struct bfa_port_cfg_s port_cfg;
  172. };
  173. /*
  174. * RPORT data structure
  175. */
  176. struct bfad_rport_s {
  177. struct bfa_fcs_rport_s fcs_rport;
  178. };
  179. struct bfad_buf_info {
  180. void *virt;
  181. dma_addr_t phys;
  182. u32 size;
  183. };
  184. struct bfad_fcxp {
  185. struct bfad_port_s *port;
  186. struct bfa_rport_s *bfa_rport;
  187. bfa_status_t req_status;
  188. u16 tag;
  189. u16 rsp_len;
  190. u16 rsp_maxlen;
  191. u8 use_ireqbuf;
  192. u8 use_irspbuf;
  193. u32 num_req_sgles;
  194. u32 num_rsp_sgles;
  195. struct fchs_s fchs;
  196. void *reqbuf_info;
  197. void *rspbuf_info;
  198. struct bfa_sge_s *req_sge;
  199. struct bfa_sge_s *rsp_sge;
  200. fcxp_send_cb_t send_cbfn;
  201. void *send_cbarg;
  202. void *bfa_fcxp;
  203. struct completion comp;
  204. };
  205. struct bfad_hal_comp {
  206. bfa_status_t status;
  207. struct completion comp;
  208. };
  209. /*
  210. * Macro to obtain the immediate lower power
  211. * of two for the integer.
  212. */
  213. #define nextLowerInt(x) \
  214. do { \
  215. int j; \
  216. (*x)--; \
  217. for (j = 1; j < (sizeof(int) * 8); j <<= 1) \
  218. (*x) = (*x) | (*x) >> j; \
  219. (*x)++; \
  220. (*x) = (*x) >> 1; \
  221. } while (0)
  222. bfa_status_t bfad_vport_create(struct bfad_s *bfad, u16 vf_id,
  223. struct bfa_port_cfg_s *port_cfg, struct device *dev);
  224. bfa_status_t bfad_vf_create(struct bfad_s *bfad, u16 vf_id,
  225. struct bfa_port_cfg_s *port_cfg);
  226. bfa_status_t bfad_cfg_pport(struct bfad_s *bfad, enum bfa_port_role role);
  227. bfa_status_t bfad_drv_init(struct bfad_s *bfad);
  228. bfa_status_t bfad_start_ops(struct bfad_s *bfad);
  229. void bfad_drv_start(struct bfad_s *bfad);
  230. void bfad_uncfg_pport(struct bfad_s *bfad);
  231. void bfad_drv_stop(struct bfad_s *bfad);
  232. void bfad_remove_intr(struct bfad_s *bfad);
  233. void bfad_hal_mem_release(struct bfad_s *bfad);
  234. void bfad_hcb_comp(void *arg, bfa_status_t status);
  235. int bfad_setup_intr(struct bfad_s *bfad);
  236. void bfad_remove_intr(struct bfad_s *bfad);
  237. void bfad_update_hal_cfg(struct bfa_iocfc_cfg_s *bfa_cfg);
  238. bfa_status_t bfad_hal_mem_alloc(struct bfad_s *bfad);
  239. void bfad_bfa_tmo(unsigned long data);
  240. void bfad_init_timer(struct bfad_s *bfad);
  241. int bfad_pci_init(struct pci_dev *pdev, struct bfad_s *bfad);
  242. void bfad_pci_uninit(struct pci_dev *pdev, struct bfad_s *bfad);
  243. void bfad_fcs_port_cfg(struct bfad_s *bfad);
  244. void bfad_drv_uninit(struct bfad_s *bfad);
  245. void bfad_drv_log_level_set(struct bfad_s *bfad);
  246. bfa_status_t bfad_fc4_module_init(void);
  247. void bfad_fc4_module_exit(void);
  248. int bfad_worker (void *ptr);
  249. void bfad_pci_remove(struct pci_dev *pdev);
  250. int bfad_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pid);
  251. void bfad_os_rport_online_wait(struct bfad_s *bfad);
  252. int bfad_os_get_linkup_delay(struct bfad_s *bfad);
  253. int bfad_install_msix_handler(struct bfad_s *bfad);
  254. extern struct idr bfad_im_port_index;
  255. extern struct list_head bfad_list;
  256. extern int bfa_lun_queue_depth;
  257. extern int bfad_supported_fc4s;
  258. extern int bfa_linkup_delay;
  259. extern struct mutex bfad_mutex;
  260. #endif /* __BFAD_DRV_H__ */