bfad_drv.h 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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.2.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. /* port debugfs specific data */
  98. struct dentry *port_debugfs_root;
  99. };
  100. /*
  101. * VPORT data structure
  102. */
  103. struct bfad_vport_s {
  104. struct bfad_port_s drv_port;
  105. struct bfa_fcs_vport_s fcs_vport;
  106. struct completion *comp_del;
  107. struct list_head list_entry;
  108. struct bfa_port_cfg_s port_cfg;
  109. };
  110. /*
  111. * VF data structure
  112. */
  113. struct bfad_vf_s {
  114. bfa_fcs_vf_t fcs_vf;
  115. struct bfad_port_s base_port; /* base port for vf */
  116. struct bfad_s *bfad;
  117. };
  118. struct bfad_cfg_param_s {
  119. u32 rport_del_timeout;
  120. u32 ioc_queue_depth;
  121. u32 lun_queue_depth;
  122. u32 io_max_sge;
  123. u32 binding_method;
  124. };
  125. /*
  126. * BFAD (PCI function) data structure
  127. */
  128. struct bfad_s {
  129. struct list_head list_entry;
  130. struct bfa_s bfa;
  131. struct bfa_fcs_s bfa_fcs;
  132. struct pci_dev *pcidev;
  133. const char *pci_name;
  134. struct bfa_pcidev_s hal_pcidev;
  135. struct bfa_ioc_pci_attr_s pci_attr;
  136. void __iomem *pci_bar0_kva;
  137. struct completion comp;
  138. struct completion suspend;
  139. struct completion disable_comp;
  140. bfa_boolean_t disable_active;
  141. struct bfad_port_s pport; /* physical port of the BFAD */
  142. struct bfa_meminfo_s meminfo;
  143. struct bfa_iocfc_cfg_s ioc_cfg;
  144. u32 inst_no; /* BFAD instance number */
  145. u32 bfad_flags;
  146. spinlock_t bfad_lock;
  147. struct task_struct *bfad_tsk;
  148. struct bfad_cfg_param_s cfg_data;
  149. struct bfad_msix_s msix_tab[MAX_MSIX_ENTRY];
  150. int nvec;
  151. char adapter_name[BFA_ADAPTER_SYM_NAME_LEN];
  152. char port_name[BFA_ADAPTER_SYM_NAME_LEN];
  153. struct timer_list hal_tmo;
  154. unsigned long hs_start;
  155. struct bfad_im_s *im; /* IM specific data */
  156. struct bfad_tm_s *tm; /* TM specific data */
  157. struct bfad_ipfc_s *ipfc; /* IPFC specific data */
  158. struct bfa_log_mod_s log_data;
  159. struct bfa_trc_mod_s *trcmod;
  160. struct bfa_log_mod_s *logmod;
  161. struct bfa_aen_s *aen;
  162. struct bfa_aen_s aen_buf;
  163. void *file_map[BFA_AEN_MAX_APP];
  164. struct bfa_plog_s plog_buf;
  165. int ref_count;
  166. bfa_boolean_t ipfc_enabled;
  167. struct fc_host_statistics link_stats;
  168. struct list_head pbc_pcfg_list;
  169. atomic_t wq_reqcnt;
  170. /* debugfs specific data */
  171. char *regdata;
  172. u32 reglen;
  173. struct dentry *bfad_dentry_files[5];
  174. };
  175. struct bfad_pcfg_s {
  176. struct list_head list_entry;
  177. struct bfa_port_cfg_s port_cfg;
  178. };
  179. /*
  180. * RPORT data structure
  181. */
  182. struct bfad_rport_s {
  183. struct bfa_fcs_rport_s fcs_rport;
  184. };
  185. struct bfad_buf_info {
  186. void *virt;
  187. dma_addr_t phys;
  188. u32 size;
  189. };
  190. struct bfad_fcxp {
  191. struct bfad_port_s *port;
  192. struct bfa_rport_s *bfa_rport;
  193. bfa_status_t req_status;
  194. u16 tag;
  195. u16 rsp_len;
  196. u16 rsp_maxlen;
  197. u8 use_ireqbuf;
  198. u8 use_irspbuf;
  199. u32 num_req_sgles;
  200. u32 num_rsp_sgles;
  201. struct fchs_s fchs;
  202. void *reqbuf_info;
  203. void *rspbuf_info;
  204. struct bfa_sge_s *req_sge;
  205. struct bfa_sge_s *rsp_sge;
  206. fcxp_send_cb_t send_cbfn;
  207. void *send_cbarg;
  208. void *bfa_fcxp;
  209. struct completion comp;
  210. };
  211. struct bfad_hal_comp {
  212. bfa_status_t status;
  213. struct completion comp;
  214. };
  215. /*
  216. * Macro to obtain the immediate lower power
  217. * of two for the integer.
  218. */
  219. #define nextLowerInt(x) \
  220. do { \
  221. int j; \
  222. (*x)--; \
  223. for (j = 1; j < (sizeof(int) * 8); j <<= 1) \
  224. (*x) = (*x) | (*x) >> j; \
  225. (*x)++; \
  226. (*x) = (*x) >> 1; \
  227. } while (0)
  228. bfa_status_t bfad_vport_create(struct bfad_s *bfad, u16 vf_id,
  229. struct bfa_port_cfg_s *port_cfg, struct device *dev);
  230. bfa_status_t bfad_vf_create(struct bfad_s *bfad, u16 vf_id,
  231. struct bfa_port_cfg_s *port_cfg);
  232. bfa_status_t bfad_cfg_pport(struct bfad_s *bfad, enum bfa_port_role role);
  233. bfa_status_t bfad_drv_init(struct bfad_s *bfad);
  234. bfa_status_t bfad_start_ops(struct bfad_s *bfad);
  235. void bfad_drv_start(struct bfad_s *bfad);
  236. void bfad_uncfg_pport(struct bfad_s *bfad);
  237. void bfad_drv_stop(struct bfad_s *bfad);
  238. void bfad_remove_intr(struct bfad_s *bfad);
  239. void bfad_hal_mem_release(struct bfad_s *bfad);
  240. void bfad_hcb_comp(void *arg, bfa_status_t status);
  241. int bfad_setup_intr(struct bfad_s *bfad);
  242. void bfad_remove_intr(struct bfad_s *bfad);
  243. void bfad_update_hal_cfg(struct bfa_iocfc_cfg_s *bfa_cfg);
  244. bfa_status_t bfad_hal_mem_alloc(struct bfad_s *bfad);
  245. void bfad_bfa_tmo(unsigned long data);
  246. void bfad_init_timer(struct bfad_s *bfad);
  247. int bfad_pci_init(struct pci_dev *pdev, struct bfad_s *bfad);
  248. void bfad_pci_uninit(struct pci_dev *pdev, struct bfad_s *bfad);
  249. void bfad_fcs_port_cfg(struct bfad_s *bfad);
  250. void bfad_drv_uninit(struct bfad_s *bfad);
  251. void bfad_drv_log_level_set(struct bfad_s *bfad);
  252. bfa_status_t bfad_fc4_module_init(void);
  253. void bfad_fc4_module_exit(void);
  254. int bfad_worker(void *ptr);
  255. void bfad_debugfs_init(struct bfad_port_s *port);
  256. void bfad_debugfs_exit(struct bfad_port_s *port);
  257. void bfad_pci_remove(struct pci_dev *pdev);
  258. int bfad_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pid);
  259. void bfad_os_rport_online_wait(struct bfad_s *bfad);
  260. int bfad_os_get_linkup_delay(struct bfad_s *bfad);
  261. int bfad_install_msix_handler(struct bfad_s *bfad);
  262. extern struct idr bfad_im_port_index;
  263. extern struct list_head bfad_list;
  264. extern int bfa_lun_queue_depth;
  265. extern int bfad_supported_fc4s;
  266. extern int bfa_linkup_delay;
  267. extern int bfa_debugfs_enable;
  268. extern struct mutex bfad_mutex;
  269. #endif /* __BFAD_DRV_H__ */