This commit was manufactured by cvs2svn to create branch 'vserver'.
[linux-2.6.git] / drivers / scsi / lpfc / lpfc_crtn.h
1 /*******************************************************************
2  * This file is part of the Emulex Linux Device Driver for         *
3  * Enterprise Fibre Channel Host Bus Adapters.                     *
4  * Refer to the README file included with this package for         *
5  * driver version and adapter support.                             *
6  * Copyright (C) 2004 Emulex Corporation.                          *
7  * www.emulex.com                                                  *
8  *                                                                 *
9  * This program is free software; you can redistribute it and/or   *
10  * modify it under the terms of the GNU General Public License     *
11  * as published by the Free Software Foundation; either version 2  *
12  * of the License, or (at your option) any later version.          *
13  *                                                                 *
14  * This program is distributed in the hope that it will be useful, *
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of  *
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the   *
17  * GNU General Public License for more details, a copy of which    *
18  * can be found in the file COPYING included with this package.    *
19  *******************************************************************/
20
21 /*
22  * $Id: lpfc_crtn.h 1.140 2004/11/17 19:00:57EST sf_support Exp  $
23  */
24
25 #ifndef _H_LPFC_CRTN
26 #define _H_LPFC_CRTN
27
28 #include <linux/delay.h>
29 #include <linux/interrupt.h>
30 #include <asm/uaccess.h>
31
32 #include "lpfc_disc.h"
33 #include "lpfc_logmsg.h"
34 #include "lpfc_scsi.h"
35 #include "lpfc_sli.h"
36
37
38 void lpfc_dump_mem(struct lpfc_hba *, LPFC_MBOXQ_t *);
39 void lpfc_read_nv(struct lpfc_hba *, LPFC_MBOXQ_t *);
40 int lpfc_read_la(struct lpfc_hba *, LPFC_MBOXQ_t *);
41 void lpfc_clear_la(struct lpfc_hba *, LPFC_MBOXQ_t *);
42 void lpfc_config_link(struct lpfc_hba *, LPFC_MBOXQ_t *);
43 int lpfc_read_sparam(struct lpfc_hba *, LPFC_MBOXQ_t *);
44 void lpfc_read_config(struct lpfc_hba *, LPFC_MBOXQ_t *);
45 void lpfc_set_slim(struct lpfc_hba *, LPFC_MBOXQ_t *, uint32_t, uint32_t);
46 int lpfc_reg_login(struct lpfc_hba *, uint32_t, uint8_t *, LPFC_MBOXQ_t *,
47                    uint32_t);
48 void lpfc_unreg_login(struct lpfc_hba *, uint32_t, LPFC_MBOXQ_t *);
49 void lpfc_unreg_did(struct lpfc_hba *, uint32_t, LPFC_MBOXQ_t *);
50 void lpfc_init_link(struct lpfc_hba *, LPFC_MBOXQ_t *, uint32_t, uint32_t);
51
52
53 int lpfc_linkdown(struct lpfc_hba *);
54 void lpfc_mbx_cmpl_read_la(struct lpfc_hba *, LPFC_MBOXQ_t *);
55
56 void lpfc_mbx_cmpl_clear_la(struct lpfc_hba *, LPFC_MBOXQ_t *);
57 void lpfc_mbx_cmpl_reg_login(struct lpfc_hba *, LPFC_MBOXQ_t *);
58 void lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *, LPFC_MBOXQ_t *);
59 void lpfc_mbx_cmpl_ns_reg_login(struct lpfc_hba *, LPFC_MBOXQ_t *);
60 void lpfc_mbx_cmpl_fdmi_reg_login(struct lpfc_hba *, LPFC_MBOXQ_t *);
61 int lpfc_consistent_bind_save(struct lpfc_hba *, struct lpfc_bindlist *);
62 int lpfc_nlp_plogi(struct lpfc_hba *, struct lpfc_nodelist *);
63 int lpfc_nlp_adisc(struct lpfc_hba *, struct lpfc_nodelist *);
64 int lpfc_nlp_unmapped(struct lpfc_hba *, struct lpfc_nodelist *);
65 int lpfc_nlp_mapped(struct lpfc_hba *, struct lpfc_nodelist *,
66                     struct lpfc_bindlist *);
67 int lpfc_nlp_list(struct lpfc_hba *, struct lpfc_nodelist *, int);
68 void lpfc_set_disctmo(struct lpfc_hba *);
69 int lpfc_can_disctmo(struct lpfc_hba *);
70 int lpfc_unreg_rpi(struct lpfc_hba *, struct lpfc_nodelist *);
71 int lpfc_check_sli_ndlp(struct lpfc_hba *, struct lpfc_sli_ring *,
72                     struct lpfc_iocbq *, struct lpfc_nodelist *);
73 int lpfc_nlp_remove(struct lpfc_hba *, struct lpfc_nodelist *);
74 void lpfc_nlp_init(struct lpfc_hba *, struct lpfc_nodelist *, uint32_t);
75 struct lpfc_nodelist *lpfc_setup_disc_node(struct lpfc_hba *, uint32_t);
76 struct lpfc_nodelist *lpfc_setup_rscn_node(struct lpfc_hba *, uint32_t);
77 void lpfc_disc_list_loopmap(struct lpfc_hba *);
78 void lpfc_disc_start(struct lpfc_hba *);
79 void lpfc_disc_flush_list(struct lpfc_hba *);
80 void lpfc_establish_link_tmo(unsigned long);
81 void lpfc_disc_timeout(unsigned long);
82 void lpfc_scan_timeout(unsigned long);
83 struct lpfc_target *lpfc_find_target(struct lpfc_hba *, uint32_t,
84                         struct lpfc_nodelist *);
85 void lpfc_set_failmask(struct lpfc_hba *, struct lpfc_nodelist *, uint32_t,
86                        uint32_t);
87 void lpfc_process_nodev_timeout(struct lpfc_hba *, struct lpfc_nodelist *);
88
89 struct lpfc_nodelist *lpfc_findnode_rpi(struct lpfc_hba * phba, uint16_t rpi);
90 struct lpfc_nodelist *lpfc_findnode_remove_rpi(struct lpfc_hba * phba,
91                                                uint16_t rpi);
92 void lpfc_addnode_rpi(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp,
93                       uint16_t rpi);
94
95 int lpfc_discq_post_event(struct lpfc_hba *, void *, void *, uint32_t);
96 int lpfc_do_dpc(void *);
97 int lpfc_disc_state_machine(struct lpfc_hba *, struct lpfc_nodelist *, void *,
98                             uint32_t);
99
100 uint32_t lpfc_cmpl_prli_reglogin_issue(struct lpfc_hba *,
101                                        struct lpfc_nodelist *, void *,
102                                        uint32_t);
103 uint32_t lpfc_cmpl_plogi_prli_issue(struct lpfc_hba *, struct lpfc_nodelist *,
104                                     void *, uint32_t);
105
106 int lpfc_check_sparm(struct lpfc_hba *, struct lpfc_nodelist *,
107                      struct serv_parm *, uint32_t);
108 int lpfc_els_abort_flogi(struct lpfc_hba *);
109 int lpfc_initial_flogi(struct lpfc_hba *);
110 int lpfc_issue_els_plogi(struct lpfc_hba *, struct lpfc_nodelist *, uint8_t);
111 int lpfc_issue_els_prli(struct lpfc_hba *, struct lpfc_nodelist *, uint8_t);
112 int lpfc_issue_els_adisc(struct lpfc_hba *, struct lpfc_nodelist *, uint8_t);
113 int lpfc_issue_els_logo(struct lpfc_hba *, struct lpfc_nodelist *, uint8_t);
114 int lpfc_issue_els_scr(struct lpfc_hba *, uint32_t, uint8_t);
115 int lpfc_els_free_iocb(struct lpfc_hba *, struct lpfc_iocbq *);
116 int lpfc_els_rsp_acc(struct lpfc_hba *, uint32_t, struct lpfc_iocbq *,
117                      struct lpfc_nodelist *, LPFC_MBOXQ_t *, uint8_t);
118 int lpfc_els_rsp_reject(struct lpfc_hba *, uint32_t, struct lpfc_iocbq *,
119                         struct lpfc_nodelist *);
120 int lpfc_els_rsp_adisc_acc(struct lpfc_hba *, struct lpfc_iocbq *,
121                            struct lpfc_nodelist *);
122 int lpfc_els_rsp_prli_acc(struct lpfc_hba *, struct lpfc_iocbq *,
123                           struct lpfc_nodelist *);
124 void lpfc_els_retry_delay(unsigned long);
125 void lpfc_els_unsol_event(struct lpfc_hba *, struct lpfc_sli_ring *,
126                           struct lpfc_iocbq *);
127 int lpfc_els_handle_rscn(struct lpfc_hba *);
128 int lpfc_els_flush_rscn(struct lpfc_hba *);
129 int lpfc_rscn_payload_check(struct lpfc_hba *, uint32_t);
130 void lpfc_els_flush_cmd(struct lpfc_hba *);
131 int lpfc_els_disc_adisc(struct lpfc_hba *);
132 int lpfc_els_disc_plogi(struct lpfc_hba *);
133 void lpfc_els_timeout_handler(unsigned long ptr);
134
135 void lpfc_ct_unsol_event(struct lpfc_hba *, struct lpfc_sli_ring *,
136                          struct lpfc_iocbq *);
137 int lpfc_ns_cmd(struct lpfc_hba *, struct lpfc_nodelist *, int);
138 int lpfc_fdmi_cmd(struct lpfc_hba *, struct lpfc_nodelist *, int);
139 void lpfc_fdmi_tmo(unsigned long);
140
141 int lpfc_config_port_prep(struct lpfc_hba *);
142 int lpfc_config_port_post(struct lpfc_hba *);
143 int lpfc_hba_down_prep(struct lpfc_hba *);
144 void lpfc_handle_eratt(struct lpfc_hba *, uint32_t);
145 void lpfc_handle_latt(struct lpfc_hba *);
146 void lpfc_hba_init(struct lpfc_hba *, uint32_t *);
147 int lpfc_post_buffer(struct lpfc_hba *, struct lpfc_sli_ring *, int, int);
148 void lpfc_cleanup(struct lpfc_hba *, uint32_t);
149 int lpfc_scsi_free(struct lpfc_hba *);
150 void lpfc_decode_firmware_rev(struct lpfc_hba *, char *, int);
151 uint8_t *lpfc_get_lpfchba_info(struct lpfc_hba *, uint8_t *);
152 int lpfc_fcp_abort(struct lpfc_hba *, int, int, int);
153 int lpfc_put_event(struct lpfc_hba *, uint32_t, uint32_t, void *,
154                        uint32_t, uint32_t);
155 void lpfc_get_hba_model_desc(struct lpfc_hba *, uint8_t *, uint8_t *);
156 int lpfc_online(struct lpfc_hba *);
157 int lpfc_offline(struct lpfc_hba *);
158
159
160
161 int lpfc_sli_queue_setup(struct lpfc_hba *);
162 void lpfc_slim_access(struct lpfc_hba *);
163
164 void lpfc_handle_eratt(struct lpfc_hba *, uint32_t);
165 void lpfc_handle_latt(struct lpfc_hba *);
166 irqreturn_t lpfc_intr_handler(int, void *, struct pt_regs *);
167
168 void lpfc_read_rev(struct lpfc_hba *, LPFC_MBOXQ_t *);
169 void lpfc_config_ring(struct lpfc_hba *, int, LPFC_MBOXQ_t *);
170 void lpfc_config_port(struct lpfc_hba *, LPFC_MBOXQ_t *);
171 void lpfc_mbox_put(struct lpfc_hba *, LPFC_MBOXQ_t *);
172 LPFC_MBOXQ_t *lpfc_mbox_get(struct lpfc_hba *);
173
174 int lpfc_mem_alloc(struct lpfc_hba *);
175 void lpfc_mem_free(struct lpfc_hba *);
176
177 struct lpfc_iocbq *
178 lpfc_prep_els_iocb(struct lpfc_hba * phba,
179                    uint8_t expectRsp,
180                    uint16_t cmdSize,
181                    uint8_t retry, struct lpfc_nodelist * ndlp, uint32_t elscmd);
182
183 int lpfc_sli_hba_setup(struct lpfc_hba *);
184 int lpfc_sli_hba_down(struct lpfc_hba *);
185 int lpfc_sli_intr(struct lpfc_hba *);
186 int lpfc_sli_issue_mbox(struct lpfc_hba *, LPFC_MBOXQ_t *, uint32_t);
187 int lpfc_sli_issue_iocb(struct lpfc_hba *, struct lpfc_sli_ring *,
188                         struct lpfc_iocbq *, uint32_t);
189 void lpfc_sli_pcimem_bcopy(uint32_t *, uint32_t *, uint32_t);
190 int lpfc_sli_ringpostbuf_put(struct lpfc_hba *, struct lpfc_sli_ring *,
191                              struct lpfc_dmabuf *);
192 struct lpfc_dmabuf *lpfc_sli_ringpostbuf_get(struct lpfc_hba *,
193                                              struct lpfc_sli_ring *,
194                                              dma_addr_t);
195 uint32_t lpfc_sli_next_iotag(struct lpfc_hba *, struct lpfc_sli_ring *);
196 int lpfc_sli_issue_abort_iotag32(struct lpfc_hba *, struct lpfc_sli_ring *,
197                                  struct lpfc_iocbq *);
198 int lpfc_sli_abort_iocb_ctx(struct lpfc_hba *, struct lpfc_sli_ring *,
199                             uint32_t);
200 int lpfc_sli_sum_iocb_host(struct lpfc_hba *, struct lpfc_sli_ring *);
201 int lpfc_sli_abort_iocb_host(struct lpfc_hba *, struct lpfc_sli_ring *, int);
202 int lpfc_sli_sum_iocb_lun(struct lpfc_hba *, struct lpfc_sli_ring *, uint16_t,
203                           uint64_t);
204 int lpfc_sli_abort_iocb_lun(struct lpfc_hba *, struct lpfc_sli_ring *, uint16_t,
205                             uint64_t, int);
206 int lpfc_sli_abort_iocb_tgt(struct lpfc_hba *, struct lpfc_sli_ring *,
207                             uint16_t, int);
208 void lpfc_mbox_timeout(unsigned long);
209
210 void lpfc_map_fcp_cmnd_to_bpl(struct lpfc_hba *, struct lpfc_scsi_buf *);
211 void lpfc_free_scsi_cmd(struct lpfc_scsi_buf *);
212 uint32_t lpfc_os_timeout_transform(struct lpfc_hba *, uint32_t);
213
214 struct lpfc_nodelist *
215 lpfc_findnode_wwpn(struct lpfc_hba * phba, uint32_t order,
216                    struct lpfc_name * wwpn);
217 struct lpfc_nodelist *
218 lpfc_findnode_wwnn(struct lpfc_hba * phba, uint32_t order,
219                    struct lpfc_name * wwnn);
220 struct lpfc_nodelist *lpfc_findnode_did(struct lpfc_hba * phba, uint32_t order,
221                                         uint32_t did);
222
223 void lpfc_get_hba_sym_node_name(struct lpfc_hba * phba, uint8_t * symbp);
224
225 int lpfc_sli_issue_mbox_wait(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmboxq,
226                          uint32_t timeout);
227
228 int
229 lpfc_sli_issue_iocb_wait(struct lpfc_hba * phba,
230                          struct lpfc_sli_ring * pring,
231                          struct lpfc_iocbq * piocb,
232                          struct lpfc_iocbq * prspiocbq, uint32_t timeout);
233 int lpfc_sli_issue_iocb_wait_high_priority(struct lpfc_hba * phba,
234                                            struct lpfc_sli_ring * pring,
235                                            struct lpfc_iocbq * piocb,
236                                            uint32_t flag,
237                                            struct lpfc_iocbq * prspiocbq,
238                                            uint32_t timeout);
239 void lpfc_sli_wake_iocb_high_priority(struct lpfc_hba * phba,
240                                       struct lpfc_iocbq * queue1,
241                                       struct lpfc_iocbq * queue2);
242 void *lpfc_mbuf_alloc(struct lpfc_hba *, int, dma_addr_t *);
243 void lpfc_mbuf_free(struct lpfc_hba *, void *, dma_addr_t);
244
245 int  lpfc_stop_timer(struct lpfc_hba *);
246
247
248 /* Function prototypes. */
249 int lpfc_queuecommand(struct scsi_cmnd *, void (*done) (struct scsi_cmnd *));
250 int lpfc_abort_handler(struct scsi_cmnd *);
251 int lpfc_reset_bus_handler(struct scsi_cmnd *);
252 int lpfc_reset_lun_handler(struct scsi_cmnd *);
253
254 #if defined(FC_TRANS_VER1) || defined(FC_TRANS_265_BLKPATCH)
255 void lpfc_target_unblock(struct lpfc_hba *, struct lpfc_target *);
256 void lpfc_target_block(struct lpfc_hba *, struct lpfc_target *);
257 int lpfc_target_remove(struct lpfc_hba *, struct lpfc_target *);
258 int lpfc_target_add(struct lpfc_hba *, struct lpfc_target *);
259 #endif
260
261 #define ScsiResult(host_code, scsi_code) (((host_code) << 16) | scsi_code)
262 #define HBA_EVENT_RSCN                   5
263 #define HBA_EVENT_LINK_UP                2
264 #define HBA_EVENT_LINK_DOWN              3
265 #endif                          /* _H_LPFC_CRTN */