Commit | Line | Data |
---|---|---|
7725ccfd | 1 | /* |
a36c61f9 | 2 | * Copyright (c) 2005-2010 Brocade Communications Systems, Inc. |
7725ccfd JH |
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 | ||
acdc79a6 | 18 | /* |
7725ccfd JH |
19 | * Contains base driver definitions. |
20 | */ | |
21 | ||
acdc79a6 | 22 | /* |
7725ccfd JH |
23 | * bfa_drv.h Linux driver data structures. |
24 | */ | |
25 | ||
26 | #ifndef __BFAD_DRV_H__ | |
27 | #define __BFAD_DRV_H__ | |
28 | ||
f16a1750 | 29 | #include <linux/types.h> |
f16a1750 MZ |
30 | #include <linux/pci.h> |
31 | #include <linux/dma-mapping.h> | |
32 | #include <linux/idr.h> | |
33 | #include <linux/interrupt.h> | |
34 | #include <linux/cdev.h> | |
35 | #include <linux/fs.h> | |
36 | #include <linux/delay.h> | |
37 | #include <linux/vmalloc.h> | |
38 | #include <linux/workqueue.h> | |
39 | #include <linux/bitops.h> | |
40 | #include <scsi/scsi.h> | |
41 | #include <scsi/scsi_host.h> | |
42 | #include <scsi/scsi_tcq.h> | |
43 | #include <scsi/scsi_transport_fc.h> | |
44 | #include <scsi/scsi_transport.h> | |
b85daafe | 45 | #include <scsi/scsi_bsg_fc.h> |
5b7db7af | 46 | #include <scsi/scsi_devinfo.h> |
7725ccfd | 47 | |
a36c61f9 KG |
48 | #include "bfa_modules.h" |
49 | #include "bfa_fcs.h" | |
50 | #include "bfa_defs_fcs.h" | |
51 | ||
52 | #include "bfa_plog.h" | |
53 | #include "bfa_cs.h" | |
54 | ||
55 | #define BFAD_DRIVER_NAME "bfa" | |
7725ccfd JH |
56 | #ifdef BFA_DRIVER_VERSION |
57 | #define BFAD_DRIVER_VERSION BFA_DRIVER_VERSION | |
58 | #else | |
154fbf06 | 59 | #define BFAD_DRIVER_VERSION "3.0.2.2" |
7725ccfd JH |
60 | #endif |
61 | ||
a36c61f9 | 62 | #define BFAD_PROTO_NAME FCPI_NAME |
7725ccfd JH |
63 | #define BFAD_IRQ_FLAGS IRQF_SHARED |
64 | ||
a36c61f9 KG |
65 | #ifndef FC_PORTSPEED_8GBIT |
66 | #define FC_PORTSPEED_8GBIT 0x10 | |
67 | #endif | |
68 | ||
7725ccfd JH |
69 | /* |
70 | * BFAD flags | |
71 | */ | |
72 | #define BFAD_MSIX_ON 0x00000001 | |
73 | #define BFAD_HAL_INIT_DONE 0x00000002 | |
74 | #define BFAD_DRV_INIT_DONE 0x00000004 | |
75 | #define BFAD_CFG_PPORT_DONE 0x00000008 | |
76 | #define BFAD_HAL_START_DONE 0x00000010 | |
77 | #define BFAD_PORT_ONLINE 0x00000020 | |
78 | #define BFAD_RPORT_ONLINE 0x00000040 | |
a36c61f9 KG |
79 | #define BFAD_FCS_INIT_DONE 0x00000080 |
80 | #define BFAD_HAL_INIT_FAIL 0x00000100 | |
81 | #define BFAD_FC4_PROBE_DONE 0x00000200 | |
7725ccfd | 82 | #define BFAD_PORT_DELETE 0x00000001 |
61e62e21 | 83 | #define BFAD_INTX_ON 0x00000400 |
7725ccfd JH |
84 | /* |
85 | * BFAD related definition | |
86 | */ | |
87 | #define SCSI_SCAN_DELAY HZ | |
88 | #define BFAD_STOP_TIMEOUT 30 | |
89 | #define BFAD_SUSPEND_TIMEOUT BFAD_STOP_TIMEOUT | |
90 | ||
91 | /* | |
92 | * BFAD configuration parameter default values | |
93 | */ | |
a36c61f9 KG |
94 | #define BFAD_LUN_QUEUE_DEPTH 32 |
95 | #define BFAD_IO_MAX_SGE SG_ALL | |
61e62e21 KG |
96 | #define BFAD_MIN_SECTORS 128 /* 64k */ |
97 | #define BFAD_MAX_SECTORS 0xFFFF /* 32 MB */ | |
7725ccfd JH |
98 | |
99 | #define bfad_isr_t irq_handler_t | |
100 | ||
101 | #define MAX_MSIX_ENTRY 22 | |
102 | ||
103 | struct bfad_msix_s { | |
104 | struct bfad_s *bfad; | |
105 | struct msix_entry msix; | |
a36c61f9 KG |
106 | char name[32]; |
107 | }; | |
108 | ||
109 | /* | |
110 | * Only append to the enums defined here to avoid any versioning | |
111 | * needed between trace utility and driver version | |
112 | */ | |
113 | enum { | |
114 | BFA_TRC_LDRV_BFAD = 1, | |
115 | BFA_TRC_LDRV_IM = 2, | |
b85daafe | 116 | BFA_TRC_LDRV_BSG = 3, |
7725ccfd JH |
117 | }; |
118 | ||
119 | enum bfad_port_pvb_type { | |
120 | BFAD_PORT_PHYS_BASE = 0, | |
121 | BFAD_PORT_PHYS_VPORT = 1, | |
122 | BFAD_PORT_VF_BASE = 2, | |
123 | BFAD_PORT_VF_VPORT = 3, | |
124 | }; | |
125 | ||
126 | /* | |
127 | * PORT data structure | |
128 | */ | |
129 | struct bfad_port_s { | |
130 | struct list_head list_entry; | |
a36c61f9 KG |
131 | struct bfad_s *bfad; |
132 | struct bfa_fcs_lport_s *fcs_port; | |
133 | u32 roles; | |
134 | s32 flags; | |
135 | u32 supported_fc4s; | |
7725ccfd JH |
136 | enum bfad_port_pvb_type pvb_type; |
137 | struct bfad_im_port_s *im_port; /* IM specific data */ | |
ab2a9ba1 JH |
138 | /* port debugfs specific data */ |
139 | struct dentry *port_debugfs_root; | |
7725ccfd JH |
140 | }; |
141 | ||
142 | /* | |
143 | * VPORT data structure | |
144 | */ | |
145 | struct bfad_vport_s { | |
146 | struct bfad_port_s drv_port; | |
147 | struct bfa_fcs_vport_s fcs_vport; | |
148 | struct completion *comp_del; | |
d9883548 | 149 | struct list_head list_entry; |
7725ccfd JH |
150 | }; |
151 | ||
152 | /* | |
153 | * VF data structure | |
154 | */ | |
155 | struct bfad_vf_s { | |
156 | bfa_fcs_vf_t fcs_vf; | |
157 | struct bfad_port_s base_port; /* base port for vf */ | |
158 | struct bfad_s *bfad; | |
159 | }; | |
160 | ||
161 | struct bfad_cfg_param_s { | |
a36c61f9 KG |
162 | u32 rport_del_timeout; |
163 | u32 ioc_queue_depth; | |
164 | u32 lun_queue_depth; | |
165 | u32 io_max_sge; | |
166 | u32 binding_method; | |
167 | }; | |
168 | ||
169 | union bfad_tmp_buf { | |
170 | /* From struct bfa_adapter_attr_s */ | |
171 | char manufacturer[BFA_ADAPTER_MFG_NAME_LEN]; | |
172 | char serial_num[BFA_ADAPTER_SERIAL_NUM_LEN]; | |
173 | char model[BFA_ADAPTER_MODEL_NAME_LEN]; | |
174 | char fw_ver[BFA_VERSION_LEN]; | |
175 | char optrom_ver[BFA_VERSION_LEN]; | |
176 | ||
177 | /* From struct bfa_ioc_pci_attr_s */ | |
178 | u8 chip_rev[BFA_IOC_CHIP_REV_LEN]; /* chip revision */ | |
179 | ||
180 | wwn_t wwn[BFA_FCS_MAX_LPORTS]; | |
7725ccfd JH |
181 | }; |
182 | ||
7725ccfd JH |
183 | /* |
184 | * BFAD (PCI function) data structure | |
185 | */ | |
186 | struct bfad_s { | |
a36c61f9 | 187 | bfa_sm_t sm; /* state machine */ |
7725ccfd | 188 | struct list_head list_entry; |
a36c61f9 KG |
189 | struct bfa_s bfa; |
190 | struct bfa_fcs_s bfa_fcs; | |
7725ccfd JH |
191 | struct pci_dev *pcidev; |
192 | const char *pci_name; | |
193 | struct bfa_pcidev_s hal_pcidev; | |
194 | struct bfa_ioc_pci_attr_s pci_attr; | |
7725ccfd | 195 | void __iomem *pci_bar0_kva; |
11189208 | 196 | void __iomem *pci_bar2_kva; |
7725ccfd JH |
197 | struct completion comp; |
198 | struct completion suspend; | |
60138066 | 199 | struct completion enable_comp; |
7725ccfd JH |
200 | struct completion disable_comp; |
201 | bfa_boolean_t disable_active; | |
202 | struct bfad_port_s pport; /* physical port of the BFAD */ | |
203 | struct bfa_meminfo_s meminfo; | |
204 | struct bfa_iocfc_cfg_s ioc_cfg; | |
a36c61f9 KG |
205 | u32 inst_no; /* BFAD instance number */ |
206 | u32 bfad_flags; | |
7725ccfd | 207 | spinlock_t bfad_lock; |
e6714324 | 208 | struct task_struct *bfad_tsk; |
7725ccfd JH |
209 | struct bfad_cfg_param_s cfg_data; |
210 | struct bfad_msix_s msix_tab[MAX_MSIX_ENTRY]; | |
a36c61f9 KG |
211 | int nvec; |
212 | char adapter_name[BFA_ADAPTER_SYM_NAME_LEN]; | |
213 | char port_name[BFA_ADAPTER_SYM_NAME_LEN]; | |
7725ccfd JH |
214 | struct timer_list hal_tmo; |
215 | unsigned long hs_start; | |
216 | struct bfad_im_s *im; /* IM specific data */ | |
7725ccfd | 217 | struct bfa_trc_mod_s *trcmod; |
7725ccfd | 218 | struct bfa_plog_s plog_buf; |
a36c61f9 KG |
219 | int ref_count; |
220 | union bfad_tmp_buf tmp_buf; | |
7725ccfd | 221 | struct fc_host_statistics link_stats; |
a36c61f9 | 222 | struct list_head pbc_vport_list; |
ab2a9ba1 JH |
223 | /* debugfs specific data */ |
224 | char *regdata; | |
225 | u32 reglen; | |
226 | struct dentry *bfad_dentry_files[5]; | |
7826f304 KG |
227 | struct list_head free_aen_q; |
228 | struct list_head active_aen_q; | |
229 | struct bfa_aen_entry_s aen_list[BFA_AEN_MAX_ENTRY]; | |
230 | spinlock_t bfad_aen_spinlock; | |
5b7db7af | 231 | struct list_head vport_list; |
d9883548 JH |
232 | }; |
233 | ||
a36c61f9 KG |
234 | /* BFAD state machine events */ |
235 | enum bfad_sm_event { | |
236 | BFAD_E_CREATE = 1, | |
237 | BFAD_E_KTHREAD_CREATE_FAILED = 2, | |
238 | BFAD_E_INIT = 3, | |
239 | BFAD_E_INIT_SUCCESS = 4, | |
240 | BFAD_E_INIT_FAILED = 5, | |
241 | BFAD_E_INTR_INIT_FAILED = 6, | |
242 | BFAD_E_FCS_EXIT_COMP = 7, | |
243 | BFAD_E_EXIT_COMP = 8, | |
244 | BFAD_E_STOP = 9 | |
7725ccfd JH |
245 | }; |
246 | ||
247 | /* | |
248 | * RPORT data structure | |
249 | */ | |
250 | struct bfad_rport_s { | |
251 | struct bfa_fcs_rport_s fcs_rport; | |
252 | }; | |
253 | ||
254 | struct bfad_buf_info { | |
a36c61f9 | 255 | void *virt; |
7725ccfd | 256 | dma_addr_t phys; |
a36c61f9 | 257 | u32 size; |
7725ccfd JH |
258 | }; |
259 | ||
260 | struct bfad_fcxp { | |
261 | struct bfad_port_s *port; | |
262 | struct bfa_rport_s *bfa_rport; | |
263 | bfa_status_t req_status; | |
a36c61f9 KG |
264 | u16 tag; |
265 | u16 rsp_len; | |
266 | u16 rsp_maxlen; | |
267 | u8 use_ireqbuf; | |
268 | u8 use_irspbuf; | |
269 | u32 num_req_sgles; | |
270 | u32 num_rsp_sgles; | |
271 | struct fchs_s fchs; | |
272 | void *reqbuf_info; | |
273 | void *rspbuf_info; | |
7725ccfd JH |
274 | struct bfa_sge_s *req_sge; |
275 | struct bfa_sge_s *rsp_sge; | |
276 | fcxp_send_cb_t send_cbfn; | |
a36c61f9 KG |
277 | void *send_cbarg; |
278 | void *bfa_fcxp; | |
7725ccfd JH |
279 | struct completion comp; |
280 | }; | |
281 | ||
282 | struct bfad_hal_comp { | |
283 | bfa_status_t status; | |
284 | struct completion comp; | |
285 | }; | |
286 | ||
f16a1750 MZ |
287 | #define BFA_LOG(level, bfad, mask, fmt, arg...) \ |
288 | do { \ | |
289 | if (((mask) == 4) || (level[1] <= '4')) \ | |
290 | dev_printk(level, &((bfad)->pcidev)->dev, fmt, ##arg); \ | |
a36c61f9 | 291 | } while (0) |
7725ccfd | 292 | |
a36c61f9 KG |
293 | bfa_status_t bfad_vport_create(struct bfad_s *bfad, u16 vf_id, |
294 | struct bfa_lport_cfg_s *port_cfg, | |
295 | struct device *dev); | |
296 | bfa_status_t bfad_vf_create(struct bfad_s *bfad, u16 vf_id, | |
297 | struct bfa_lport_cfg_s *port_cfg); | |
298 | bfa_status_t bfad_cfg_pport(struct bfad_s *bfad, enum bfa_lport_role role); | |
299 | bfa_status_t bfad_drv_init(struct bfad_s *bfad); | |
300 | bfa_status_t bfad_start_ops(struct bfad_s *bfad); | |
301 | void bfad_drv_start(struct bfad_s *bfad); | |
302 | void bfad_uncfg_pport(struct bfad_s *bfad); | |
303 | void bfad_stop(struct bfad_s *bfad); | |
304 | void bfad_fcs_stop(struct bfad_s *bfad); | |
305 | void bfad_remove_intr(struct bfad_s *bfad); | |
306 | void bfad_hal_mem_release(struct bfad_s *bfad); | |
307 | void bfad_hcb_comp(void *arg, bfa_status_t status); | |
308 | ||
309 | int bfad_setup_intr(struct bfad_s *bfad); | |
310 | void bfad_remove_intr(struct bfad_s *bfad); | |
7725ccfd JH |
311 | void bfad_update_hal_cfg(struct bfa_iocfc_cfg_s *bfa_cfg); |
312 | bfa_status_t bfad_hal_mem_alloc(struct bfad_s *bfad); | |
313 | void bfad_bfa_tmo(unsigned long data); | |
314 | void bfad_init_timer(struct bfad_s *bfad); | |
315 | int bfad_pci_init(struct pci_dev *pdev, struct bfad_s *bfad); | |
316 | void bfad_pci_uninit(struct pci_dev *pdev, struct bfad_s *bfad); | |
7725ccfd | 317 | void bfad_drv_uninit(struct bfad_s *bfad); |
ab2a9ba1 JH |
318 | int bfad_worker(void *ptr); |
319 | void bfad_debugfs_init(struct bfad_port_s *port); | |
320 | void bfad_debugfs_exit(struct bfad_port_s *port); | |
e6714324 | 321 | |
7725ccfd JH |
322 | void bfad_pci_remove(struct pci_dev *pdev); |
323 | int bfad_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pid); | |
f16a1750 MZ |
324 | void bfad_rport_online_wait(struct bfad_s *bfad); |
325 | int bfad_get_linkup_delay(struct bfad_s *bfad); | |
7725ccfd JH |
326 | int bfad_install_msix_handler(struct bfad_s *bfad); |
327 | ||
328 | extern struct idr bfad_im_port_index; | |
a36c61f9 | 329 | extern struct pci_device_id bfad_id_table[]; |
7725ccfd | 330 | extern struct list_head bfad_list; |
a36c61f9 KG |
331 | extern char *os_name; |
332 | extern char *os_patch; | |
333 | extern char *host_name; | |
334 | extern int num_rports; | |
335 | extern int num_ios; | |
336 | extern int num_tms; | |
337 | extern int num_fcxps; | |
338 | extern int num_ufbufs; | |
339 | extern int reqq_size; | |
340 | extern int rspq_size; | |
341 | extern int num_sgpgs; | |
342 | extern int rport_del_timeout; | |
343 | extern int bfa_lun_queue_depth; | |
344 | extern int bfa_io_max_sge; | |
88166242 | 345 | extern int bfa_log_level; |
a36c61f9 KG |
346 | extern int ioc_auto_recover; |
347 | extern int bfa_linkup_delay; | |
348 | extern int msix_disable_cb; | |
349 | extern int msix_disable_ct; | |
350 | extern int fdmi_enable; | |
351 | extern int supported_fc4s; | |
352 | extern int pcie_max_read_reqsz; | |
61e62e21 | 353 | extern int max_xfer_size; |
ab2a9ba1 | 354 | extern int bfa_debugfs_enable; |
42b426ec | 355 | extern struct mutex bfad_mutex; |
7725ccfd JH |
356 | |
357 | #endif /* __BFAD_DRV_H__ */ |