bfad_drv.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295
  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.0.0.0"
  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_PORT_DELETE 0x00000001
  56. /*
  57. * BFAD related definition
  58. */
  59. #define SCSI_SCAN_DELAY HZ
  60. #define BFAD_STOP_TIMEOUT 30
  61. #define BFAD_SUSPEND_TIMEOUT BFAD_STOP_TIMEOUT
  62. /*
  63. * BFAD configuration parameter default values
  64. */
  65. #define BFAD_LUN_QUEUE_DEPTH 32
  66. #define BFAD_IO_MAX_SGE SG_ALL
  67. #define bfad_isr_t irq_handler_t
  68. #define MAX_MSIX_ENTRY 22
  69. struct bfad_msix_s {
  70. struct bfad_s *bfad;
  71. struct msix_entry msix;
  72. };
  73. enum bfad_port_pvb_type {
  74. BFAD_PORT_PHYS_BASE = 0,
  75. BFAD_PORT_PHYS_VPORT = 1,
  76. BFAD_PORT_VF_BASE = 2,
  77. BFAD_PORT_VF_VPORT = 3,
  78. };
  79. /*
  80. * PORT data structure
  81. */
  82. struct bfad_port_s {
  83. struct list_head list_entry;
  84. struct bfad_s *bfad;
  85. struct bfa_fcs_port_s *fcs_port;
  86. u32 roles;
  87. s32 flags;
  88. u32 supported_fc4s;
  89. u8 ipfc_flags;
  90. enum bfad_port_pvb_type pvb_type;
  91. struct bfad_im_port_s *im_port; /* IM specific data */
  92. struct bfad_tm_port_s *tm_port; /* TM specific data */
  93. struct bfad_ipfc_port_s *ipfc_port; /* IPFC specific data */
  94. };
  95. /*
  96. * VPORT data structure
  97. */
  98. struct bfad_vport_s {
  99. struct bfad_port_s drv_port;
  100. struct bfa_fcs_vport_s fcs_vport;
  101. struct completion *comp_del;
  102. };
  103. /*
  104. * VF data structure
  105. */
  106. struct bfad_vf_s {
  107. bfa_fcs_vf_t fcs_vf;
  108. struct bfad_port_s base_port; /* base port for vf */
  109. struct bfad_s *bfad;
  110. };
  111. struct bfad_cfg_param_s {
  112. u32 rport_del_timeout;
  113. u32 ioc_queue_depth;
  114. u32 lun_queue_depth;
  115. u32 io_max_sge;
  116. u32 binding_method;
  117. };
  118. #define BFAD_AEN_MAX_APPS 8
  119. struct bfad_aen_file_s {
  120. struct list_head qe;
  121. struct bfad_s *bfad;
  122. s32 ri;
  123. s32 app_id;
  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. unsigned long pci_bar0_map;
  137. void __iomem *pci_bar0_kva;
  138. struct completion comp;
  139. struct completion suspend;
  140. struct completion disable_comp;
  141. bfa_boolean_t disable_active;
  142. struct bfad_port_s pport; /* physical port of the BFAD */
  143. struct bfa_meminfo_s meminfo;
  144. struct bfa_iocfc_cfg_s ioc_cfg;
  145. u32 inst_no; /* BFAD instance number */
  146. u32 bfad_flags;
  147. spinlock_t bfad_lock;
  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. struct bfad_aen_file_s file_buf[BFAD_AEN_MAX_APPS];
  164. struct list_head file_q;
  165. struct list_head file_free_q;
  166. struct bfa_plog_s plog_buf;
  167. int ref_count;
  168. bfa_boolean_t ipfc_enabled;
  169. struct fc_host_statistics link_stats;
  170. struct kobject *bfa_kobj;
  171. struct kobject *ioc_kobj;
  172. struct kobject *pport_kobj;
  173. struct kobject *lport_kobj;
  174. };
  175. /*
  176. * RPORT data structure
  177. */
  178. struct bfad_rport_s {
  179. struct bfa_fcs_rport_s fcs_rport;
  180. };
  181. struct bfad_buf_info {
  182. void *virt;
  183. dma_addr_t phys;
  184. u32 size;
  185. };
  186. struct bfad_fcxp {
  187. struct bfad_port_s *port;
  188. struct bfa_rport_s *bfa_rport;
  189. bfa_status_t req_status;
  190. u16 tag;
  191. u16 rsp_len;
  192. u16 rsp_maxlen;
  193. u8 use_ireqbuf;
  194. u8 use_irspbuf;
  195. u32 num_req_sgles;
  196. u32 num_rsp_sgles;
  197. struct fchs_s fchs;
  198. void *reqbuf_info;
  199. void *rspbuf_info;
  200. struct bfa_sge_s *req_sge;
  201. struct bfa_sge_s *rsp_sge;
  202. fcxp_send_cb_t send_cbfn;
  203. void *send_cbarg;
  204. void *bfa_fcxp;
  205. struct completion comp;
  206. };
  207. struct bfad_hal_comp {
  208. bfa_status_t status;
  209. struct completion comp;
  210. };
  211. /*
  212. * Macro to obtain the immediate lower power
  213. * of two for the integer.
  214. */
  215. #define nextLowerInt(x) \
  216. do { \
  217. int j; \
  218. (*x)--; \
  219. for (j = 1; j < (sizeof(int) * 8); j <<= 1) \
  220. (*x) = (*x) | (*x) >> j; \
  221. (*x)++; \
  222. (*x) = (*x) >> 1; \
  223. } while (0)
  224. bfa_status_t bfad_vport_create(struct bfad_s *bfad, u16 vf_id,
  225. struct bfa_port_cfg_s *port_cfg);
  226. bfa_status_t bfad_vf_create(struct bfad_s *bfad, u16 vf_id,
  227. struct bfa_port_cfg_s *port_cfg);
  228. bfa_status_t bfad_cfg_pport(struct bfad_s *bfad, enum bfa_port_role role);
  229. bfa_status_t bfad_drv_init(struct bfad_s *bfad);
  230. void bfad_drv_start(struct bfad_s *bfad);
  231. void bfad_uncfg_pport(struct bfad_s *bfad);
  232. void bfad_drv_stop(struct bfad_s *bfad);
  233. void bfad_remove_intr(struct bfad_s *bfad);
  234. void bfad_hal_mem_release(struct bfad_s *bfad);
  235. void bfad_hcb_comp(void *arg, bfa_status_t status);
  236. int bfad_setup_intr(struct bfad_s *bfad);
  237. void bfad_remove_intr(struct bfad_s *bfad);
  238. void bfad_update_hal_cfg(struct bfa_iocfc_cfg_s *bfa_cfg);
  239. bfa_status_t bfad_hal_mem_alloc(struct bfad_s *bfad);
  240. void bfad_bfa_tmo(unsigned long data);
  241. void bfad_init_timer(struct bfad_s *bfad);
  242. int bfad_pci_init(struct pci_dev *pdev, struct bfad_s *bfad);
  243. void bfad_pci_uninit(struct pci_dev *pdev, struct bfad_s *bfad);
  244. void bfad_fcs_port_cfg(struct bfad_s *bfad);
  245. void bfad_drv_uninit(struct bfad_s *bfad);
  246. void bfad_drv_log_level_set(struct bfad_s *bfad);
  247. bfa_status_t bfad_fc4_module_init(void);
  248. void bfad_fc4_module_exit(void);
  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. #endif /* __BFAD_DRV_H__ */