diff options
Diffstat (limited to 'drivers/scsi/bfa/bfa_ioc.h')
-rw-r--r-- | drivers/scsi/bfa/bfa_ioc.h | 259 |
1 files changed, 259 insertions, 0 deletions
diff --git a/drivers/scsi/bfa/bfa_ioc.h b/drivers/scsi/bfa/bfa_ioc.h new file mode 100644 index 000000000000..58efd4b13143 --- /dev/null +++ b/drivers/scsi/bfa/bfa_ioc.h | |||
@@ -0,0 +1,259 @@ | |||
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 | #ifndef __BFA_IOC_H__ | ||
19 | #define __BFA_IOC_H__ | ||
20 | |||
21 | #include <cs/bfa_sm.h> | ||
22 | #include <bfi/bfi.h> | ||
23 | #include <bfi/bfi_ioc.h> | ||
24 | #include <bfi/bfi_boot.h> | ||
25 | #include <bfa_timer.h> | ||
26 | |||
27 | /** | ||
28 | * PCI device information required by IOC | ||
29 | */ | ||
30 | struct bfa_pcidev_s { | ||
31 | int pci_slot; | ||
32 | u8 pci_func; | ||
33 | u16 device_id; | ||
34 | bfa_os_addr_t pci_bar_kva; | ||
35 | }; | ||
36 | |||
37 | /** | ||
38 | * Structure used to remember the DMA-able memory block's KVA and Physical | ||
39 | * Address | ||
40 | */ | ||
41 | struct bfa_dma_s { | ||
42 | void *kva; /*! Kernel virtual address */ | ||
43 | u64 pa; /*! Physical address */ | ||
44 | }; | ||
45 | |||
46 | #define BFA_DMA_ALIGN_SZ 256 | ||
47 | #define BFA_ROUNDUP(_l, _s) (((_l) + ((_s) - 1)) & ~((_s) - 1)) | ||
48 | |||
49 | |||
50 | |||
51 | #define bfa_dma_addr_set(dma_addr, pa) \ | ||
52 | __bfa_dma_addr_set(&dma_addr, (u64)pa) | ||
53 | |||
54 | static inline void | ||
55 | __bfa_dma_addr_set(union bfi_addr_u *dma_addr, u64 pa) | ||
56 | { | ||
57 | dma_addr->a32.addr_lo = (u32) pa; | ||
58 | dma_addr->a32.addr_hi = (u32) (bfa_os_u32(pa)); | ||
59 | } | ||
60 | |||
61 | |||
62 | #define bfa_dma_be_addr_set(dma_addr, pa) \ | ||
63 | __bfa_dma_be_addr_set(&dma_addr, (u64)pa) | ||
64 | static inline void | ||
65 | __bfa_dma_be_addr_set(union bfi_addr_u *dma_addr, u64 pa) | ||
66 | { | ||
67 | dma_addr->a32.addr_lo = (u32) bfa_os_htonl(pa); | ||
68 | dma_addr->a32.addr_hi = (u32) bfa_os_htonl(bfa_os_u32(pa)); | ||
69 | } | ||
70 | |||
71 | struct bfa_ioc_regs_s { | ||
72 | bfa_os_addr_t hfn_mbox_cmd; | ||
73 | bfa_os_addr_t hfn_mbox; | ||
74 | bfa_os_addr_t lpu_mbox_cmd; | ||
75 | bfa_os_addr_t lpu_mbox; | ||
76 | bfa_os_addr_t pss_ctl_reg; | ||
77 | bfa_os_addr_t app_pll_fast_ctl_reg; | ||
78 | bfa_os_addr_t app_pll_slow_ctl_reg; | ||
79 | bfa_os_addr_t ioc_sem_reg; | ||
80 | bfa_os_addr_t ioc_usage_sem_reg; | ||
81 | bfa_os_addr_t ioc_usage_reg; | ||
82 | bfa_os_addr_t host_page_num_fn; | ||
83 | bfa_os_addr_t heartbeat; | ||
84 | bfa_os_addr_t ioc_fwstate; | ||
85 | bfa_os_addr_t ll_halt; | ||
86 | bfa_os_addr_t shirq_isr_next; | ||
87 | bfa_os_addr_t shirq_msk_next; | ||
88 | bfa_os_addr_t smem_page_start; | ||
89 | u32 smem_pg0; | ||
90 | }; | ||
91 | |||
92 | #define bfa_reg_read(_raddr) bfa_os_reg_read(_raddr) | ||
93 | #define bfa_reg_write(_raddr, _val) bfa_os_reg_write(_raddr, _val) | ||
94 | #define bfa_mem_read(_raddr, _off) bfa_os_mem_read(_raddr, _off) | ||
95 | #define bfa_mem_write(_raddr, _off, _val) \ | ||
96 | bfa_os_mem_write(_raddr, _off, _val) | ||
97 | /** | ||
98 | * IOC Mailbox structures | ||
99 | */ | ||
100 | struct bfa_mbox_cmd_s { | ||
101 | struct list_head qe; | ||
102 | u32 msg[BFI_IOC_MSGSZ]; | ||
103 | }; | ||
104 | |||
105 | /** | ||
106 | * IOC mailbox module | ||
107 | */ | ||
108 | typedef void (*bfa_ioc_mbox_mcfunc_t)(void *cbarg, struct bfi_mbmsg_s *m); | ||
109 | struct bfa_ioc_mbox_mod_s { | ||
110 | struct list_head cmd_q; /* pending mbox queue */ | ||
111 | int nmclass; /* number of handlers */ | ||
112 | struct { | ||
113 | bfa_ioc_mbox_mcfunc_t cbfn; /* message handlers */ | ||
114 | void *cbarg; | ||
115 | } mbhdlr[BFI_MC_MAX]; | ||
116 | }; | ||
117 | |||
118 | /** | ||
119 | * IOC callback function interfaces | ||
120 | */ | ||
121 | typedef void (*bfa_ioc_enable_cbfn_t)(void *bfa, enum bfa_status status); | ||
122 | typedef void (*bfa_ioc_disable_cbfn_t)(void *bfa); | ||
123 | typedef void (*bfa_ioc_hbfail_cbfn_t)(void *bfa); | ||
124 | typedef void (*bfa_ioc_reset_cbfn_t)(void *bfa); | ||
125 | struct bfa_ioc_cbfn_s { | ||
126 | bfa_ioc_enable_cbfn_t enable_cbfn; | ||
127 | bfa_ioc_disable_cbfn_t disable_cbfn; | ||
128 | bfa_ioc_hbfail_cbfn_t hbfail_cbfn; | ||
129 | bfa_ioc_reset_cbfn_t reset_cbfn; | ||
130 | }; | ||
131 | |||
132 | /** | ||
133 | * Heartbeat failure notification queue element. | ||
134 | */ | ||
135 | struct bfa_ioc_hbfail_notify_s { | ||
136 | struct list_head qe; | ||
137 | bfa_ioc_hbfail_cbfn_t cbfn; | ||
138 | void *cbarg; | ||
139 | }; | ||
140 | |||
141 | /** | ||
142 | * Initialize a heartbeat failure notification structure | ||
143 | */ | ||
144 | #define bfa_ioc_hbfail_init(__notify, __cbfn, __cbarg) do { \ | ||
145 | (__notify)->cbfn = (__cbfn); \ | ||
146 | (__notify)->cbarg = (__cbarg); \ | ||
147 | } while (0) | ||
148 | |||
149 | struct bfa_ioc_s { | ||
150 | bfa_fsm_t fsm; | ||
151 | struct bfa_s *bfa; | ||
152 | struct bfa_pcidev_s pcidev; | ||
153 | struct bfa_timer_mod_s *timer_mod; | ||
154 | struct bfa_timer_s ioc_timer; | ||
155 | struct bfa_timer_s sem_timer; | ||
156 | u32 hb_count; | ||
157 | u32 hb_fail; | ||
158 | u32 retry_count; | ||
159 | struct list_head hb_notify_q; | ||
160 | void *dbg_fwsave; | ||
161 | int dbg_fwsave_len; | ||
162 | bfa_boolean_t dbg_fwsave_once; | ||
163 | enum bfi_mclass ioc_mc; | ||
164 | struct bfa_ioc_regs_s ioc_regs; | ||
165 | struct bfa_trc_mod_s *trcmod; | ||
166 | struct bfa_aen_s *aen; | ||
167 | struct bfa_log_mod_s *logm; | ||
168 | struct bfa_ioc_drv_stats_s stats; | ||
169 | bfa_boolean_t auto_recover; | ||
170 | bfa_boolean_t fcmode; | ||
171 | bfa_boolean_t ctdev; | ||
172 | bfa_boolean_t cna; | ||
173 | bfa_boolean_t pllinit; | ||
174 | u8 port_id; | ||
175 | |||
176 | struct bfa_dma_s attr_dma; | ||
177 | struct bfi_ioc_attr_s *attr; | ||
178 | struct bfa_ioc_cbfn_s *cbfn; | ||
179 | struct bfa_ioc_mbox_mod_s mbox_mod; | ||
180 | }; | ||
181 | |||
182 | #define bfa_ioc_pcifn(__ioc) (__ioc)->pcidev.pci_func | ||
183 | #define bfa_ioc_devid(__ioc) (__ioc)->pcidev.device_id | ||
184 | #define bfa_ioc_bar0(__ioc) (__ioc)->pcidev.pci_bar_kva | ||
185 | #define bfa_ioc_portid(__ioc) ((__ioc)->port_id) | ||
186 | #define bfa_ioc_fetch_stats(__ioc, __stats) \ | ||
187 | ((__stats)->drv_stats) = (__ioc)->stats | ||
188 | #define bfa_ioc_clr_stats(__ioc) \ | ||
189 | bfa_os_memset(&(__ioc)->stats, 0, sizeof((__ioc)->stats)) | ||
190 | #define bfa_ioc_maxfrsize(__ioc) (__ioc)->attr->maxfrsize | ||
191 | #define bfa_ioc_rx_bbcredit(__ioc) (__ioc)->attr->rx_bbcredit | ||
192 | #define bfa_ioc_speed_sup(__ioc) \ | ||
193 | BFI_ADAPTER_GETP(SPEED, (__ioc)->attr->adapter_prop) | ||
194 | |||
195 | /** | ||
196 | * IOC mailbox interface | ||
197 | */ | ||
198 | void bfa_ioc_mbox_queue(struct bfa_ioc_s *ioc, struct bfa_mbox_cmd_s *cmd); | ||
199 | void bfa_ioc_mbox_register(struct bfa_ioc_s *ioc, | ||
200 | bfa_ioc_mbox_mcfunc_t *mcfuncs); | ||
201 | void bfa_ioc_mbox_isr(struct bfa_ioc_s *ioc); | ||
202 | void bfa_ioc_mbox_send(struct bfa_ioc_s *ioc, void *ioc_msg, int len); | ||
203 | void bfa_ioc_msgget(struct bfa_ioc_s *ioc, void *mbmsg); | ||
204 | void bfa_ioc_mbox_regisr(struct bfa_ioc_s *ioc, enum bfi_mclass mc, | ||
205 | bfa_ioc_mbox_mcfunc_t cbfn, void *cbarg); | ||
206 | |||
207 | /** | ||
208 | * IOC interfaces | ||
209 | */ | ||
210 | void bfa_ioc_attach(struct bfa_ioc_s *ioc, void *bfa, | ||
211 | struct bfa_ioc_cbfn_s *cbfn, struct bfa_timer_mod_s *timer_mod, | ||
212 | struct bfa_trc_mod_s *trcmod, | ||
213 | struct bfa_aen_s *aen, struct bfa_log_mod_s *logm); | ||
214 | void bfa_ioc_detach(struct bfa_ioc_s *ioc); | ||
215 | void bfa_ioc_pci_init(struct bfa_ioc_s *ioc, struct bfa_pcidev_s *pcidev, | ||
216 | enum bfi_mclass mc); | ||
217 | u32 bfa_ioc_meminfo(void); | ||
218 | void bfa_ioc_mem_claim(struct bfa_ioc_s *ioc, u8 *dm_kva, u64 dm_pa); | ||
219 | void bfa_ioc_enable(struct bfa_ioc_s *ioc); | ||
220 | void bfa_ioc_disable(struct bfa_ioc_s *ioc); | ||
221 | bfa_boolean_t bfa_ioc_intx_claim(struct bfa_ioc_s *ioc); | ||
222 | |||
223 | void bfa_ioc_boot(struct bfa_ioc_s *ioc, u32 boot_type, u32 boot_param); | ||
224 | void bfa_ioc_isr(struct bfa_ioc_s *ioc, struct bfi_mbmsg_s *msg); | ||
225 | void bfa_ioc_error_isr(struct bfa_ioc_s *ioc); | ||
226 | void bfa_ioc_isr_mode_set(struct bfa_ioc_s *ioc, bfa_boolean_t intx); | ||
227 | bfa_status_t bfa_ioc_pll_init(struct bfa_ioc_s *ioc); | ||
228 | bfa_boolean_t bfa_ioc_is_operational(struct bfa_ioc_s *ioc); | ||
229 | bfa_boolean_t bfa_ioc_is_disabled(struct bfa_ioc_s *ioc); | ||
230 | bfa_boolean_t bfa_ioc_fw_mismatch(struct bfa_ioc_s *ioc); | ||
231 | bfa_boolean_t bfa_ioc_adapter_is_disabled(struct bfa_ioc_s *ioc); | ||
232 | void bfa_ioc_cfg_complete(struct bfa_ioc_s *ioc); | ||
233 | void bfa_ioc_get_attr(struct bfa_ioc_s *ioc, struct bfa_ioc_attr_s *ioc_attr); | ||
234 | void bfa_ioc_get_adapter_attr(struct bfa_ioc_s *ioc, | ||
235 | struct bfa_adapter_attr_s *ad_attr); | ||
236 | int bfa_ioc_debug_trcsz(bfa_boolean_t auto_recover); | ||
237 | void bfa_ioc_debug_memclaim(struct bfa_ioc_s *ioc, void *dbg_fwsave); | ||
238 | bfa_status_t bfa_ioc_debug_fwsave(struct bfa_ioc_s *ioc, void *trcdata, | ||
239 | int *trclen); | ||
240 | bfa_status_t bfa_ioc_debug_fwtrc(struct bfa_ioc_s *ioc, void *trcdata, | ||
241 | int *trclen); | ||
242 | u32 bfa_ioc_smem_pgnum(struct bfa_ioc_s *ioc, u32 fmaddr); | ||
243 | u32 bfa_ioc_smem_pgoff(struct bfa_ioc_s *ioc, u32 fmaddr); | ||
244 | void bfa_ioc_set_fcmode(struct bfa_ioc_s *ioc); | ||
245 | bfa_boolean_t bfa_ioc_get_fcmode(struct bfa_ioc_s *ioc); | ||
246 | void bfa_ioc_hbfail_register(struct bfa_ioc_s *ioc, | ||
247 | struct bfa_ioc_hbfail_notify_s *notify); | ||
248 | |||
249 | /* | ||
250 | * bfa mfg wwn API functions | ||
251 | */ | ||
252 | wwn_t bfa_ioc_get_pwwn(struct bfa_ioc_s *ioc); | ||
253 | wwn_t bfa_ioc_get_nwwn(struct bfa_ioc_s *ioc); | ||
254 | wwn_t bfa_ioc_get_wwn_naa5(struct bfa_ioc_s *ioc, u16 inst); | ||
255 | mac_t bfa_ioc_get_mac(struct bfa_ioc_s *ioc); | ||
256 | u64 bfa_ioc_get_adid(struct bfa_ioc_s *ioc); | ||
257 | |||
258 | #endif /* __BFA_IOC_H__ */ | ||
259 | |||