blob: 2b58b29fe3033083d668c8d7bb824ed76a8c837a [file] [log] [blame]
Jing Huang7725ccf2009-09-23 17:46:15 -07001/*
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/**
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 "bfa_os_inc.h"
30
31#include <bfa.h>
32#include <bfa_svc.h>
33#include <fcs/bfa_fcs.h>
34#include <defs/bfa_defs_pci.h>
35#include <defs/bfa_defs_port.h>
36#include <defs/bfa_defs_rport.h>
37#include <fcs/bfa_fcs_rport.h>
38#include <defs/bfa_defs_vport.h>
39#include <fcs/bfa_fcs_vport.h>
40
41#include <cs/bfa_plog.h>
42#include "aen/bfa_aen.h"
43#include <log/bfa_log_linux.h>
44
45#define BFAD_DRIVER_NAME "bfa"
46#ifdef BFA_DRIVER_VERSION
47#define BFAD_DRIVER_VERSION BFA_DRIVER_VERSION
48#else
Krishna Gudipatid55f88f2010-03-05 19:38:52 -080049#define BFAD_DRIVER_VERSION "2.1.2.1"
Jing Huang7725ccf2009-09-23 17:46:15 -070050#endif
51
52
53#define BFAD_IRQ_FLAGS IRQF_SHARED
54
55/*
56 * BFAD flags
57 */
58#define BFAD_MSIX_ON 0x00000001
59#define BFAD_HAL_INIT_DONE 0x00000002
60#define BFAD_DRV_INIT_DONE 0x00000004
61#define BFAD_CFG_PPORT_DONE 0x00000008
62#define BFAD_HAL_START_DONE 0x00000010
63#define BFAD_PORT_ONLINE 0x00000020
64#define BFAD_RPORT_ONLINE 0x00000040
Krishna Gudipatie6714322010-03-03 17:44:02 -080065#define BFAD_FCS_INIT_DONE 0x00000080
66#define BFAD_HAL_INIT_FAIL 0x00000100
67#define BFAD_FC4_PROBE_DONE 0x00000200
Jing Huang7725ccf2009-09-23 17:46:15 -070068#define BFAD_PORT_DELETE 0x00000001
69
70/*
71 * BFAD related definition
72 */
73#define SCSI_SCAN_DELAY HZ
74#define BFAD_STOP_TIMEOUT 30
75#define BFAD_SUSPEND_TIMEOUT BFAD_STOP_TIMEOUT
76
77/*
78 * BFAD configuration parameter default values
79 */
80#define BFAD_LUN_QUEUE_DEPTH 32
81#define BFAD_IO_MAX_SGE SG_ALL
82
83#define bfad_isr_t irq_handler_t
84
85#define MAX_MSIX_ENTRY 22
86
87struct bfad_msix_s {
88 struct bfad_s *bfad;
89 struct msix_entry msix;
90};
91
92enum bfad_port_pvb_type {
93 BFAD_PORT_PHYS_BASE = 0,
94 BFAD_PORT_PHYS_VPORT = 1,
95 BFAD_PORT_VF_BASE = 2,
96 BFAD_PORT_VF_VPORT = 3,
97};
98
99/*
100 * PORT data structure
101 */
102struct bfad_port_s {
103 struct list_head list_entry;
104 struct bfad_s *bfad;
105 struct bfa_fcs_port_s *fcs_port;
106 u32 roles;
107 s32 flags;
108 u32 supported_fc4s;
109 u8 ipfc_flags;
110 enum bfad_port_pvb_type pvb_type;
111 struct bfad_im_port_s *im_port; /* IM specific data */
112 struct bfad_tm_port_s *tm_port; /* TM specific data */
113 struct bfad_ipfc_port_s *ipfc_port; /* IPFC specific data */
114};
115
116/*
117 * VPORT data structure
118 */
119struct bfad_vport_s {
120 struct bfad_port_s drv_port;
121 struct bfa_fcs_vport_s fcs_vport;
122 struct completion *comp_del;
Jing Huangd9883542010-07-08 19:46:26 -0700123 struct list_head list_entry;
124 struct bfa_port_cfg_s port_cfg;
Jing Huang7725ccf2009-09-23 17:46:15 -0700125};
126
127/*
128 * VF data structure
129 */
130struct bfad_vf_s {
131 bfa_fcs_vf_t fcs_vf;
132 struct bfad_port_s base_port; /* base port for vf */
133 struct bfad_s *bfad;
134};
135
136struct bfad_cfg_param_s {
137 u32 rport_del_timeout;
138 u32 ioc_queue_depth;
139 u32 lun_queue_depth;
140 u32 io_max_sge;
141 u32 binding_method;
142};
143
Krishna Gudipati0a4b1fc2010-03-05 19:37:57 -0800144union bfad_tmp_buf {
145 /* From struct bfa_adapter_attr_s */
146 char manufacturer[BFA_ADAPTER_MFG_NAME_LEN];
147 char serial_num[BFA_ADAPTER_SERIAL_NUM_LEN];
148 char model[BFA_ADAPTER_MODEL_NAME_LEN];
149 char fw_ver[BFA_VERSION_LEN];
150 char optrom_ver[BFA_VERSION_LEN];
151
152 /* From struct bfa_ioc_pci_attr_s */
153 u8 chip_rev[BFA_IOC_CHIP_REV_LEN]; /* chip revision */
154};
155
Jing Huang7725ccf2009-09-23 17:46:15 -0700156/*
157 * BFAD (PCI function) data structure
158 */
159struct bfad_s {
160 struct list_head list_entry;
161 struct bfa_s bfa;
162 struct bfa_fcs_s bfa_fcs;
163 struct pci_dev *pcidev;
164 const char *pci_name;
165 struct bfa_pcidev_s hal_pcidev;
166 struct bfa_ioc_pci_attr_s pci_attr;
Jing Huang7725ccf2009-09-23 17:46:15 -0700167 void __iomem *pci_bar0_kva;
168 struct completion comp;
169 struct completion suspend;
170 struct completion disable_comp;
171 bfa_boolean_t disable_active;
172 struct bfad_port_s pport; /* physical port of the BFAD */
173 struct bfa_meminfo_s meminfo;
174 struct bfa_iocfc_cfg_s ioc_cfg;
175 u32 inst_no; /* BFAD instance number */
176 u32 bfad_flags;
177 spinlock_t bfad_lock;
Krishna Gudipatie6714322010-03-03 17:44:02 -0800178 struct task_struct *bfad_tsk;
Jing Huang7725ccf2009-09-23 17:46:15 -0700179 struct bfad_cfg_param_s cfg_data;
180 struct bfad_msix_s msix_tab[MAX_MSIX_ENTRY];
181 int nvec;
182 char adapter_name[BFA_ADAPTER_SYM_NAME_LEN];
183 char port_name[BFA_ADAPTER_SYM_NAME_LEN];
184 struct timer_list hal_tmo;
185 unsigned long hs_start;
186 struct bfad_im_s *im; /* IM specific data */
187 struct bfad_tm_s *tm; /* TM specific data */
188 struct bfad_ipfc_s *ipfc; /* IPFC specific data */
189 struct bfa_log_mod_s log_data;
190 struct bfa_trc_mod_s *trcmod;
191 struct bfa_log_mod_s *logmod;
192 struct bfa_aen_s *aen;
193 struct bfa_aen_s aen_buf;
Krishna Gudipati2993cc72010-03-05 19:36:47 -0800194 void *file_map[BFA_AEN_MAX_APP];
Jing Huang7725ccf2009-09-23 17:46:15 -0700195 struct bfa_plog_s plog_buf;
196 int ref_count;
197 bfa_boolean_t ipfc_enabled;
Krishna Gudipati0a4b1fc2010-03-05 19:37:57 -0800198 union bfad_tmp_buf tmp_buf;
Jing Huang7725ccf2009-09-23 17:46:15 -0700199 struct fc_host_statistics link_stats;
Jing Huangd9883542010-07-08 19:46:26 -0700200 struct list_head pbc_pcfg_list;
201};
202
203struct bfad_pcfg_s {
204 struct list_head list_entry;
205 struct bfa_port_cfg_s port_cfg;
Jing Huang7725ccf2009-09-23 17:46:15 -0700206};
207
208/*
209 * RPORT data structure
210 */
211struct bfad_rport_s {
212 struct bfa_fcs_rport_s fcs_rport;
213};
214
215struct bfad_buf_info {
216 void *virt;
217 dma_addr_t phys;
218 u32 size;
219};
220
221struct bfad_fcxp {
222 struct bfad_port_s *port;
223 struct bfa_rport_s *bfa_rport;
224 bfa_status_t req_status;
225 u16 tag;
226 u16 rsp_len;
227 u16 rsp_maxlen;
228 u8 use_ireqbuf;
229 u8 use_irspbuf;
230 u32 num_req_sgles;
231 u32 num_rsp_sgles;
232 struct fchs_s fchs;
233 void *reqbuf_info;
234 void *rspbuf_info;
235 struct bfa_sge_s *req_sge;
236 struct bfa_sge_s *rsp_sge;
237 fcxp_send_cb_t send_cbfn;
238 void *send_cbarg;
239 void *bfa_fcxp;
240 struct completion comp;
241};
242
243struct bfad_hal_comp {
244 bfa_status_t status;
245 struct completion comp;
246};
247
248/*
249 * Macro to obtain the immediate lower power
250 * of two for the integer.
251 */
252#define nextLowerInt(x) \
253do { \
254 int j; \
255 (*x)--; \
256 for (j = 1; j < (sizeof(int) * 8); j <<= 1) \
257 (*x) = (*x) | (*x) >> j; \
258 (*x)++; \
259 (*x) = (*x) >> 1; \
260} while (0)
261
262
263bfa_status_t bfad_vport_create(struct bfad_s *bfad, u16 vf_id,
Jing Huangb5042932010-03-19 11:05:39 -0700264 struct bfa_port_cfg_s *port_cfg, struct device *dev);
Jing Huang7725ccf2009-09-23 17:46:15 -0700265bfa_status_t bfad_vf_create(struct bfad_s *bfad, u16 vf_id,
266 struct bfa_port_cfg_s *port_cfg);
267bfa_status_t bfad_cfg_pport(struct bfad_s *bfad, enum bfa_port_role role);
268bfa_status_t bfad_drv_init(struct bfad_s *bfad);
Krishna Gudipatie6714322010-03-03 17:44:02 -0800269bfa_status_t bfad_start_ops(struct bfad_s *bfad);
Jing Huang7725ccf2009-09-23 17:46:15 -0700270void bfad_drv_start(struct bfad_s *bfad);
271void bfad_uncfg_pport(struct bfad_s *bfad);
272void bfad_drv_stop(struct bfad_s *bfad);
273void bfad_remove_intr(struct bfad_s *bfad);
274void bfad_hal_mem_release(struct bfad_s *bfad);
275void bfad_hcb_comp(void *arg, bfa_status_t status);
276
277int bfad_setup_intr(struct bfad_s *bfad);
278void bfad_remove_intr(struct bfad_s *bfad);
279
280void bfad_update_hal_cfg(struct bfa_iocfc_cfg_s *bfa_cfg);
281bfa_status_t bfad_hal_mem_alloc(struct bfad_s *bfad);
282void bfad_bfa_tmo(unsigned long data);
283void bfad_init_timer(struct bfad_s *bfad);
284int bfad_pci_init(struct pci_dev *pdev, struct bfad_s *bfad);
285void bfad_pci_uninit(struct pci_dev *pdev, struct bfad_s *bfad);
286void bfad_fcs_port_cfg(struct bfad_s *bfad);
287void bfad_drv_uninit(struct bfad_s *bfad);
288void bfad_drv_log_level_set(struct bfad_s *bfad);
289bfa_status_t bfad_fc4_module_init(void);
290void bfad_fc4_module_exit(void);
Krishna Gudipatie6714322010-03-03 17:44:02 -0800291int bfad_worker (void *ptr);
292
Jing Huang7725ccf2009-09-23 17:46:15 -0700293void bfad_pci_remove(struct pci_dev *pdev);
294int bfad_pci_probe(struct pci_dev *pdev, const struct pci_device_id *pid);
295void bfad_os_rport_online_wait(struct bfad_s *bfad);
296int bfad_os_get_linkup_delay(struct bfad_s *bfad);
297int bfad_install_msix_handler(struct bfad_s *bfad);
298
299extern struct idr bfad_im_port_index;
300extern struct list_head bfad_list;
301extern int bfa_lun_queue_depth;
302extern int bfad_supported_fc4s;
303extern int bfa_linkup_delay;
Jing Huang42b426e2010-03-19 11:07:09 -0700304extern struct mutex bfad_mutex;
Jing Huang7725ccf2009-09-23 17:46:15 -0700305
306#endif /* __BFAD_DRV_H__ */