Blame view

drivers/scsi/bfa/bfad_drv.h 9.05 KB
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
1
  /*
a36c61f90   Krishna Gudipati   [SCSI] bfa: clean...
2
   * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
3
4
5
6
7
8
9
10
11
12
13
14
15
16
   * All rights reserved
   * www.brocade.com
   *
   * Linux driver for Brocade Fibre Channel Host Bus Adapter.
   *
   * This program is free software; you can redistribute it and/or modify it
   * under the terms of the GNU General Public License (GPL) Version 2 as
   * published by the Free Software Foundation
   *
   * This program is distributed in the hope that it will be useful, but
   * WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   * General Public License for more details.
   */
acdc79a60   Jing Huang   [SCSI] bfa: fix c...
17
  /*
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
18
19
   * Contains base driver definitions.
   */
acdc79a60   Jing Huang   [SCSI] bfa: fix c...
20
  /*
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
21
22
23
24
25
   *  bfa_drv.h Linux driver data structures.
   */
  
  #ifndef __BFAD_DRV_H__
  #define __BFAD_DRV_H__
f16a17507   Maggie Zhang   [SCSI] bfa: remov...
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
  #include <linux/types.h>
  #include <linux/version.h>
  #include <linux/pci.h>
  #include <linux/dma-mapping.h>
  #include <linux/idr.h>
  #include <linux/interrupt.h>
  #include <linux/cdev.h>
  #include <linux/fs.h>
  #include <linux/delay.h>
  #include <linux/vmalloc.h>
  #include <linux/workqueue.h>
  #include <linux/bitops.h>
  #include <scsi/scsi.h>
  #include <scsi/scsi_host.h>
  #include <scsi/scsi_tcq.h>
  #include <scsi/scsi_transport_fc.h>
  #include <scsi/scsi_transport.h>
b85daafe4   Krishna Gudipati   [SCSI] bfa: Add B...
43
  #include <scsi/scsi_bsg_fc.h>
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
44

a36c61f90   Krishna Gudipati   [SCSI] bfa: clean...
45
46
47
48
49
50
51
52
  #include "bfa_modules.h"
  #include "bfa_fcs.h"
  #include "bfa_defs_fcs.h"
  
  #include "bfa_plog.h"
  #include "bfa_cs.h"
  
  #define BFAD_DRIVER_NAME	"bfa"
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
53
54
55
  #ifdef BFA_DRIVER_VERSION
  #define BFAD_DRIVER_VERSION    BFA_DRIVER_VERSION
  #else
154fbf064   Krishna Gudipati   [SCSI] bfa: Updat...
56
  #define BFAD_DRIVER_VERSION    "3.0.2.2"
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
57
  #endif
a36c61f90   Krishna Gudipati   [SCSI] bfa: clean...
58
  #define BFAD_PROTO_NAME FCPI_NAME
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
59
  #define BFAD_IRQ_FLAGS IRQF_SHARED
a36c61f90   Krishna Gudipati   [SCSI] bfa: clean...
60
61
62
  #ifndef FC_PORTSPEED_8GBIT
  #define FC_PORTSPEED_8GBIT 0x10
  #endif
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
63
64
65
66
67
68
69
70
71
72
  /*
   * BFAD flags
   */
  #define BFAD_MSIX_ON				0x00000001
  #define BFAD_HAL_INIT_DONE			0x00000002
  #define BFAD_DRV_INIT_DONE			0x00000004
  #define BFAD_CFG_PPORT_DONE			0x00000008
  #define BFAD_HAL_START_DONE			0x00000010
  #define BFAD_PORT_ONLINE			0x00000020
  #define BFAD_RPORT_ONLINE			0x00000040
a36c61f90   Krishna Gudipati   [SCSI] bfa: clean...
73
74
75
  #define BFAD_FCS_INIT_DONE			0x00000080
  #define BFAD_HAL_INIT_FAIL			0x00000100
  #define BFAD_FC4_PROBE_DONE			0x00000200
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
76
  #define BFAD_PORT_DELETE			0x00000001
61e62e21a   Krishna Gudipati   [SCSI] bfa: Drive...
77
  #define BFAD_INTX_ON				0x00000400
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
78
79
80
81
82
83
84
85
86
87
  /*
   * BFAD related definition
   */
  #define SCSI_SCAN_DELAY		HZ
  #define BFAD_STOP_TIMEOUT	30
  #define BFAD_SUSPEND_TIMEOUT	BFAD_STOP_TIMEOUT
  
  /*
   * BFAD configuration parameter default values
   */
a36c61f90   Krishna Gudipati   [SCSI] bfa: clean...
88
89
  #define BFAD_LUN_QUEUE_DEPTH	32
  #define BFAD_IO_MAX_SGE		SG_ALL
61e62e21a   Krishna Gudipati   [SCSI] bfa: Drive...
90
91
  #define BFAD_MIN_SECTORS	128 /* 64k   */
  #define BFAD_MAX_SECTORS	0xFFFF  /* 32 MB */
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
92
93
94
95
96
97
98
99
  
  #define bfad_isr_t irq_handler_t
  
  #define MAX_MSIX_ENTRY 22
  
  struct bfad_msix_s {
  	struct bfad_s *bfad;
  	struct msix_entry msix;
a36c61f90   Krishna Gudipati   [SCSI] bfa: clean...
100
101
102
103
104
105
106
107
108
109
  	char name[32];
  };
  
  /*
   * Only append to the enums defined here to avoid any versioning
   * needed between trace utility and driver version
   */
  enum {
  	BFA_TRC_LDRV_BFAD		= 1,
  	BFA_TRC_LDRV_IM			= 2,
b85daafe4   Krishna Gudipati   [SCSI] bfa: Add B...
110
  	BFA_TRC_LDRV_BSG		= 3,
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
111
112
113
114
115
116
117
118
119
120
121
122
123
124
  };
  
  enum bfad_port_pvb_type {
  	BFAD_PORT_PHYS_BASE = 0,
  	BFAD_PORT_PHYS_VPORT = 1,
  	BFAD_PORT_VF_BASE = 2,
  	BFAD_PORT_VF_VPORT = 3,
  };
  
  /*
   * PORT data structure
   */
  struct bfad_port_s {
  	struct list_head list_entry;
a36c61f90   Krishna Gudipati   [SCSI] bfa: clean...
125
126
127
128
129
  	struct bfad_s	*bfad;
  	struct bfa_fcs_lport_s *fcs_port;
  	u32	roles;
  	s32		flags;
  	u32	supported_fc4s;
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
130
131
  	enum bfad_port_pvb_type pvb_type;
  	struct bfad_im_port_s *im_port;	/* IM specific data */
ab2a9ba18   Jing Huang   [SCSI] bfa: add d...
132
133
  	/* port debugfs specific data */
  	struct dentry *port_debugfs_root;
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
134
135
136
137
138
139
140
141
142
  };
  
  /*
   * VPORT data structure
   */
  struct bfad_vport_s {
  	struct bfad_port_s     drv_port;
  	struct bfa_fcs_vport_s fcs_vport;
  	struct completion *comp_del;
d9883548a   Jing Huang   [SCSI] bfa: PBC v...
143
  	struct list_head list_entry;
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
144
145
146
147
148
149
150
151
152
153
154
155
  };
  
  /*
   * VF data structure
   */
  struct bfad_vf_s {
  	bfa_fcs_vf_t    fcs_vf;
  	struct bfad_port_s    base_port;	/* base port for vf */
  	struct bfad_s   *bfad;
  };
  
  struct bfad_cfg_param_s {
a36c61f90   Krishna Gudipati   [SCSI] bfa: clean...
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
  	u32	rport_del_timeout;
  	u32	ioc_queue_depth;
  	u32	lun_queue_depth;
  	u32	io_max_sge;
  	u32	binding_method;
  };
  
  union bfad_tmp_buf {
  	/* From struct bfa_adapter_attr_s */
  	char		manufacturer[BFA_ADAPTER_MFG_NAME_LEN];
  	char		serial_num[BFA_ADAPTER_SERIAL_NUM_LEN];
  	char		model[BFA_ADAPTER_MODEL_NAME_LEN];
  	char		fw_ver[BFA_VERSION_LEN];
  	char		optrom_ver[BFA_VERSION_LEN];
  
  	/* From struct bfa_ioc_pci_attr_s */
  	u8		chip_rev[BFA_IOC_CHIP_REV_LEN];  /*  chip revision */
  
  	wwn_t		wwn[BFA_FCS_MAX_LPORTS];
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
175
  };
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
176
177
178
179
  /*
   * BFAD (PCI function) data structure
   */
  struct bfad_s {
a36c61f90   Krishna Gudipati   [SCSI] bfa: clean...
180
  	bfa_sm_t	sm;	/* state machine */
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
181
  	struct list_head list_entry;
a36c61f90   Krishna Gudipati   [SCSI] bfa: clean...
182
183
  	struct bfa_s	bfa;
  	struct bfa_fcs_s bfa_fcs;
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
184
185
186
187
  	struct pci_dev *pcidev;
  	const char *pci_name;
  	struct bfa_pcidev_s hal_pcidev;
  	struct bfa_ioc_pci_attr_s pci_attr;
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
188
  	void __iomem   *pci_bar0_kva;
111892082   Krishna Gudipati   [SCSI] bfa: Broca...
189
  	void __iomem   *pci_bar2_kva;
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
190
191
  	struct completion comp;
  	struct completion suspend;
601380669   Krishna Gudipati   [SCSI] bfa: Exten...
192
  	struct completion enable_comp;
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
193
194
195
196
197
  	struct completion disable_comp;
  	bfa_boolean_t   disable_active;
  	struct bfad_port_s     pport;	/* physical port of the BFAD */
  	struct bfa_meminfo_s meminfo;
  	struct bfa_iocfc_cfg_s   ioc_cfg;
a36c61f90   Krishna Gudipati   [SCSI] bfa: clean...
198
199
  	u32	inst_no;	/* BFAD instance number */
  	u32	bfad_flags;
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
200
  	spinlock_t      bfad_lock;
e67143243   Krishna Gudipati   [SCSI] bfa: Resum...
201
  	struct task_struct *bfad_tsk;
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
202
203
  	struct bfad_cfg_param_s cfg_data;
  	struct bfad_msix_s msix_tab[MAX_MSIX_ENTRY];
a36c61f90   Krishna Gudipati   [SCSI] bfa: clean...
204
205
206
  	int		nvec;
  	char	adapter_name[BFA_ADAPTER_SYM_NAME_LEN];
  	char	port_name[BFA_ADAPTER_SYM_NAME_LEN];
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
207
208
209
  	struct timer_list hal_tmo;
  	unsigned long   hs_start;
  	struct bfad_im_s *im;		/* IM specific data */
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
210
  	struct bfa_trc_mod_s  *trcmod;
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
211
  	struct bfa_plog_s      plog_buf;
a36c61f90   Krishna Gudipati   [SCSI] bfa: clean...
212
213
  	int		ref_count;
  	union bfad_tmp_buf tmp_buf;
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
214
  	struct fc_host_statistics link_stats;
a36c61f90   Krishna Gudipati   [SCSI] bfa: clean...
215
  	struct list_head pbc_vport_list;
ab2a9ba18   Jing Huang   [SCSI] bfa: add d...
216
217
218
219
  	/* debugfs specific data */
  	char *regdata;
  	u32 reglen;
  	struct dentry *bfad_dentry_files[5];
7826f304b   Krishna Gudipati   [SCSI] bfa: Add F...
220
221
222
223
  	struct list_head	free_aen_q;
  	struct list_head	active_aen_q;
  	struct bfa_aen_entry_s	aen_list[BFA_AEN_MAX_ENTRY];
  	spinlock_t		bfad_aen_spinlock;
d9883548a   Jing Huang   [SCSI] bfa: PBC v...
224
  };
a36c61f90   Krishna Gudipati   [SCSI] bfa: clean...
225
226
227
228
229
230
231
232
233
234
235
  /* BFAD state machine events */
  enum bfad_sm_event {
  	BFAD_E_CREATE			= 1,
  	BFAD_E_KTHREAD_CREATE_FAILED	= 2,
  	BFAD_E_INIT			= 3,
  	BFAD_E_INIT_SUCCESS		= 4,
  	BFAD_E_INIT_FAILED		= 5,
  	BFAD_E_INTR_INIT_FAILED		= 6,
  	BFAD_E_FCS_EXIT_COMP		= 7,
  	BFAD_E_EXIT_COMP		= 8,
  	BFAD_E_STOP			= 9
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
236
237
238
239
240
241
242
243
244
245
  };
  
  /*
   * RPORT data structure
   */
  struct bfad_rport_s {
  	struct bfa_fcs_rport_s fcs_rport;
  };
  
  struct bfad_buf_info {
a36c61f90   Krishna Gudipati   [SCSI] bfa: clean...
246
  	void		*virt;
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
247
  	dma_addr_t      phys;
a36c61f90   Krishna Gudipati   [SCSI] bfa: clean...
248
  	u32	size;
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
249
250
251
252
253
254
  };
  
  struct bfad_fcxp {
  	struct bfad_port_s    *port;
  	struct bfa_rport_s *bfa_rport;
  	bfa_status_t    req_status;
a36c61f90   Krishna Gudipati   [SCSI] bfa: clean...
255
256
257
258
259
260
261
262
263
264
  	u16	tag;
  	u16	rsp_len;
  	u16	rsp_maxlen;
  	u8		use_ireqbuf;
  	u8		use_irspbuf;
  	u32	num_req_sgles;
  	u32	num_rsp_sgles;
  	struct fchs_s	fchs;
  	void		*reqbuf_info;
  	void		*rspbuf_info;
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
265
266
267
  	struct bfa_sge_s  *req_sge;
  	struct bfa_sge_s  *rsp_sge;
  	fcxp_send_cb_t  send_cbfn;
a36c61f90   Krishna Gudipati   [SCSI] bfa: clean...
268
269
  	void		*send_cbarg;
  	void		*bfa_fcxp;
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
270
271
272
273
274
275
276
  	struct completion comp;
  };
  
  struct bfad_hal_comp {
  	bfa_status_t    status;
  	struct completion comp;
  };
f16a17507   Maggie Zhang   [SCSI] bfa: remov...
277
278
279
280
  #define BFA_LOG(level, bfad, mask, fmt, arg...)				\
  do {									\
  	if (((mask) == 4) || (level[1] <= '4'))				\
  		dev_printk(level, &((bfad)->pcidev)->dev, fmt, ##arg);	\
a36c61f90   Krishna Gudipati   [SCSI] bfa: clean...
281
  } while (0)
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
282

a36c61f90   Krishna Gudipati   [SCSI] bfa: clean...
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
  bfa_status_t	bfad_vport_create(struct bfad_s *bfad, u16 vf_id,
  				  struct bfa_lport_cfg_s *port_cfg,
  				  struct device *dev);
  bfa_status_t	bfad_vf_create(struct bfad_s *bfad, u16 vf_id,
  			       struct bfa_lport_cfg_s *port_cfg);
  bfa_status_t	bfad_cfg_pport(struct bfad_s *bfad, enum bfa_lport_role role);
  bfa_status_t	bfad_drv_init(struct bfad_s *bfad);
  bfa_status_t	bfad_start_ops(struct bfad_s *bfad);
  void		bfad_drv_start(struct bfad_s *bfad);
  void		bfad_uncfg_pport(struct bfad_s *bfad);
  void		bfad_stop(struct bfad_s *bfad);
  void		bfad_fcs_stop(struct bfad_s *bfad);
  void		bfad_remove_intr(struct bfad_s *bfad);
  void		bfad_hal_mem_release(struct bfad_s *bfad);
  void		bfad_hcb_comp(void *arg, bfa_status_t status);
  
  int		bfad_setup_intr(struct bfad_s *bfad);
  void		bfad_remove_intr(struct bfad_s *bfad);
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
301
302
303
304
305
306
  void		bfad_update_hal_cfg(struct bfa_iocfc_cfg_s *bfa_cfg);
  bfa_status_t	bfad_hal_mem_alloc(struct bfad_s *bfad);
  void		bfad_bfa_tmo(unsigned long data);
  void		bfad_init_timer(struct bfad_s *bfad);
  int		bfad_pci_init(struct pci_dev *pdev, struct bfad_s *bfad);
  void		bfad_pci_uninit(struct pci_dev *pdev, struct bfad_s *bfad);
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
307
  void		bfad_drv_uninit(struct bfad_s *bfad);
ab2a9ba18   Jing Huang   [SCSI] bfa: add d...
308
309
310
  int		bfad_worker(void *ptr);
  void		bfad_debugfs_init(struct bfad_port_s *port);
  void		bfad_debugfs_exit(struct bfad_port_s *port);
e67143243   Krishna Gudipati   [SCSI] bfa: Resum...
311

7725ccfda   Jing Huang   [SCSI] bfa: Broca...
312
313
  void bfad_pci_remove(struct pci_dev *pdev);
  int bfad_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pid);
f16a17507   Maggie Zhang   [SCSI] bfa: remov...
314
315
  void bfad_rport_online_wait(struct bfad_s *bfad);
  int bfad_get_linkup_delay(struct bfad_s *bfad);
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
316
317
318
  int bfad_install_msix_handler(struct bfad_s *bfad);
  
  extern struct idr bfad_im_port_index;
a36c61f90   Krishna Gudipati   [SCSI] bfa: clean...
319
  extern struct pci_device_id bfad_id_table[];
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
320
  extern struct list_head bfad_list;
a36c61f90   Krishna Gudipati   [SCSI] bfa: clean...
321
322
323
324
325
326
327
328
329
330
331
332
333
334
  extern char	*os_name;
  extern char	*os_patch;
  extern char	*host_name;
  extern int	num_rports;
  extern int	num_ios;
  extern int	num_tms;
  extern int	num_fcxps;
  extern int	num_ufbufs;
  extern int	reqq_size;
  extern int	rspq_size;
  extern int	num_sgpgs;
  extern int      rport_del_timeout;
  extern int      bfa_lun_queue_depth;
  extern int      bfa_io_max_sge;
881662422   Jing Huang   [SCSI] bfa: renam...
335
  extern int      bfa_log_level;
a36c61f90   Krishna Gudipati   [SCSI] bfa: clean...
336
337
338
339
340
341
342
  extern int      ioc_auto_recover;
  extern int      bfa_linkup_delay;
  extern int      msix_disable_cb;
  extern int      msix_disable_ct;
  extern int      fdmi_enable;
  extern int      supported_fc4s;
  extern int	pcie_max_read_reqsz;
61e62e21a   Krishna Gudipati   [SCSI] bfa: Drive...
343
  extern int	max_xfer_size;
ab2a9ba18   Jing Huang   [SCSI] bfa: add d...
344
  extern int bfa_debugfs_enable;
42b426ecb   Jing Huang   [SCSI] bfa: prote...
345
  extern struct mutex bfad_mutex;
7725ccfda   Jing Huang   [SCSI] bfa: Broca...
346
347
  
  #endif /* __BFAD_DRV_H__ */