Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
bfad_drv.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2005-2010 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 /*
19  * Contains base driver definitions.
20  */
21 
22 /*
23  * bfa_drv.h Linux driver data structures.
24  */
25 
26 #ifndef __BFAD_DRV_H__
27 #define __BFAD_DRV_H__
28 
29 #include <linux/types.h>
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 <linux/aer.h>
41 #include <scsi/scsi.h>
42 #include <scsi/scsi_host.h>
43 #include <scsi/scsi_tcq.h>
44 #include <scsi/scsi_transport_fc.h>
45 #include <scsi/scsi_transport.h>
46 #include <scsi/scsi_bsg_fc.h>
47 #include <scsi/scsi_devinfo.h>
48 
49 #include "bfa_modules.h"
50 #include "bfa_fcs.h"
51 #include "bfa_defs_fcs.h"
52 
53 #include "bfa_plog.h"
54 #include "bfa_cs.h"
55 
56 #define BFAD_DRIVER_NAME "bfa"
57 #ifdef BFA_DRIVER_VERSION
58 #define BFAD_DRIVER_VERSION BFA_DRIVER_VERSION
59 #else
60 #define BFAD_DRIVER_VERSION "3.1.2.1"
61 #endif
62 
63 #define BFAD_PROTO_NAME FCPI_NAME
64 #define BFAD_IRQ_FLAGS IRQF_SHARED
65 
66 #ifndef FC_PORTSPEED_8GBIT
67 #define FC_PORTSPEED_8GBIT 0x10
68 #endif
69 
70 /*
71  * BFAD flags
72  */
73 #define BFAD_MSIX_ON 0x00000001
74 #define BFAD_HAL_INIT_DONE 0x00000002
75 #define BFAD_DRV_INIT_DONE 0x00000004
76 #define BFAD_CFG_PPORT_DONE 0x00000008
77 #define BFAD_HAL_START_DONE 0x00000010
78 #define BFAD_PORT_ONLINE 0x00000020
79 #define BFAD_RPORT_ONLINE 0x00000040
80 #define BFAD_FCS_INIT_DONE 0x00000080
81 #define BFAD_HAL_INIT_FAIL 0x00000100
82 #define BFAD_FC4_PROBE_DONE 0x00000200
83 #define BFAD_PORT_DELETE 0x00000001
84 #define BFAD_INTX_ON 0x00000400
85 #define BFAD_EEH_BUSY 0x00000800
86 #define BFAD_EEH_PCI_CHANNEL_IO_PERM_FAILURE 0x00001000
87 /*
88  * BFAD related definition
89  */
90 #define SCSI_SCAN_DELAY HZ
91 #define BFAD_STOP_TIMEOUT 30
92 #define BFAD_SUSPEND_TIMEOUT BFAD_STOP_TIMEOUT
93 
94 /*
95  * BFAD configuration parameter default values
96  */
97 #define BFAD_LUN_QUEUE_DEPTH 32
98 #define BFAD_IO_MAX_SGE SG_ALL
99 #define BFAD_MIN_SECTORS 128 /* 64k */
100 #define BFAD_MAX_SECTORS 0xFFFF /* 32 MB */
101 
102 #define bfad_isr_t irq_handler_t
103 
104 #define MAX_MSIX_ENTRY 22
105 
106 struct bfad_msix_s {
107  struct bfad_s *bfad;
108  struct msix_entry msix;
109  char name[32];
110 };
111 
112 /*
113  * Only append to the enums defined here to avoid any versioning
114  * needed between trace utility and driver version
115  */
116 enum {
120 };
121 
127 };
128 
129 /*
130  * PORT data structure
131  */
132 struct bfad_port_s {
134  struct bfad_s *bfad;
140  struct bfad_im_port_s *im_port; /* IM specific data */
141  /* port debugfs specific data */
143 };
144 
145 /*
146  * VPORT data structure
147  */
148 struct bfad_vport_s {
153 };
154 
155 /*
156  * VF data structure
157  */
158 struct bfad_vf_s {
160  struct bfad_port_s base_port; /* base port for vf */
161  struct bfad_s *bfad;
162 };
163 
170 };
171 
173  /* From struct bfa_adapter_attr_s */
179 
180  /* From struct bfa_ioc_pci_attr_s */
181  u8 chip_rev[BFA_IOC_CHIP_REV_LEN]; /* chip revision */
182 
184 };
185 
186 /*
187  * BFAD (PCI function) data structure
188  */
189 struct bfad_s {
190  bfa_sm_t sm; /* state machine */
192  struct bfa_s bfa;
194  struct pci_dev *pcidev;
195  const char *pci_name;
200  struct completion comp;
205  struct bfad_port_s pport; /* physical port of the BFAD */
208  u32 inst_no; /* BFAD instance number */
214  int nvec;
218  unsigned long hs_start;
219  struct bfad_im_s *im; /* IM specific data */
226  /* debugfs specific data */
227  char *regdata;
235 };
236 
237 /* BFAD state machine events */
248 };
249 
250 /*
251  * RPORT data structure
252  */
253 struct bfad_rport_s {
255 };
256 
258  void *virt;
261 };
262 
263 struct bfad_fcxp {
264  struct bfad_port_s *port;
274  struct fchs_s fchs;
275  void *reqbuf_info;
276  void *rspbuf_info;
280  void *send_cbarg;
281  void *bfa_fcxp;
282  struct completion comp;
283 };
284 
287  struct completion comp;
288 };
289 
290 #define BFA_LOG(level, bfad, mask, fmt, arg...) \
291 do { \
292  if (((mask) == 4) || (level[1] <= '4')) \
293  dev_printk(level, &((bfad)->pcidev)->dev, fmt, ##arg); \
294 } while (0)
295 
296 bfa_status_t bfad_vport_create(struct bfad_s *bfad, u16 vf_id,
297  struct bfa_lport_cfg_s *port_cfg,
298  struct device *dev);
299 bfa_status_t bfad_vf_create(struct bfad_s *bfad, u16 vf_id,
300  struct bfa_lport_cfg_s *port_cfg);
302 bfa_status_t bfad_drv_init(struct bfad_s *bfad);
303 bfa_status_t bfad_start_ops(struct bfad_s *bfad);
304 void bfad_drv_start(struct bfad_s *bfad);
305 void bfad_uncfg_pport(struct bfad_s *bfad);
306 void bfad_stop(struct bfad_s *bfad);
307 void bfad_fcs_stop(struct bfad_s *bfad);
308 void bfad_remove_intr(struct bfad_s *bfad);
309 void bfad_hal_mem_release(struct bfad_s *bfad);
310 void bfad_hcb_comp(void *arg, bfa_status_t status);
311 
312 int bfad_setup_intr(struct bfad_s *bfad);
313 void bfad_remove_intr(struct bfad_s *bfad);
314 void bfad_update_hal_cfg(struct bfa_iocfc_cfg_s *bfa_cfg);
316 void bfad_bfa_tmo(unsigned long data);
317 void bfad_init_timer(struct bfad_s *bfad);
318 int bfad_pci_init(struct pci_dev *pdev, struct bfad_s *bfad);
319 void bfad_pci_uninit(struct pci_dev *pdev, struct bfad_s *bfad);
320 void bfad_drv_uninit(struct bfad_s *bfad);
321 int bfad_worker(void *ptr);
322 void bfad_debugfs_init(struct bfad_port_s *port);
323 void bfad_debugfs_exit(struct bfad_port_s *port);
324 
325 void bfad_pci_remove(struct pci_dev *pdev);
326 int bfad_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pid);
327 void bfad_rport_online_wait(struct bfad_s *bfad);
328 int bfad_get_linkup_delay(struct bfad_s *bfad);
329 int bfad_install_msix_handler(struct bfad_s *bfad);
330 
331 extern struct idr bfad_im_port_index;
332 extern struct pci_device_id bfad_id_table[];
333 extern struct list_head bfad_list;
334 extern char *os_name;
335 extern char *os_patch;
336 extern char *host_name;
337 extern int num_rports;
338 extern int num_ios;
339 extern int num_tms;
340 extern int num_fcxps;
341 extern int num_ufbufs;
342 extern int reqq_size;
343 extern int rspq_size;
344 extern int num_sgpgs;
345 extern int rport_del_timeout;
346 extern int bfa_lun_queue_depth;
347 extern int bfa_io_max_sge;
348 extern int bfa_log_level;
349 extern int ioc_auto_recover;
350 extern int bfa_linkup_delay;
351 extern int msix_disable_cb;
352 extern int msix_disable_ct;
353 extern int fdmi_enable;
354 extern int supported_fc4s;
355 extern int pcie_max_read_reqsz;
356 extern int max_xfer_size;
357 extern int bfa_debugfs_enable;
358 extern struct mutex bfad_mutex;
359 
360 #endif /* __BFAD_DRV_H__ */