vserver 2.0 rc7
[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.166 2005/04/07 08:46:47EDT sf_support Exp  $
23  */
24
25 void lpfc_dump_mem(struct lpfc_hba *, LPFC_MBOXQ_t *, uint16_t);
26 void lpfc_read_nv(struct lpfc_hba *, LPFC_MBOXQ_t *);
27 int lpfc_read_la(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmb,
28                  struct lpfc_dmabuf *mp);
29 void lpfc_clear_la(struct lpfc_hba *, LPFC_MBOXQ_t *);
30 void lpfc_config_link(struct lpfc_hba *, LPFC_MBOXQ_t *);
31 int lpfc_read_sparam(struct lpfc_hba *, LPFC_MBOXQ_t *);
32 void lpfc_read_config(struct lpfc_hba *, LPFC_MBOXQ_t *);
33 void lpfc_set_slim(struct lpfc_hba *, LPFC_MBOXQ_t *, uint32_t, uint32_t);
34 int lpfc_reg_login(struct lpfc_hba *, uint32_t, uint8_t *, LPFC_MBOXQ_t *,
35                    uint32_t);
36 void lpfc_unreg_login(struct lpfc_hba *, uint32_t, LPFC_MBOXQ_t *);
37 void lpfc_unreg_did(struct lpfc_hba *, uint32_t, LPFC_MBOXQ_t *);
38 void lpfc_init_link(struct lpfc_hba *, LPFC_MBOXQ_t *, uint32_t, uint32_t);
39
40
41 int lpfc_linkdown(struct lpfc_hba *);
42 void lpfc_mbx_cmpl_read_la(struct lpfc_hba *, LPFC_MBOXQ_t *);
43
44 void lpfc_mbx_cmpl_clear_la(struct lpfc_hba *, LPFC_MBOXQ_t *);
45 void lpfc_mbx_cmpl_reg_login(struct lpfc_hba *, LPFC_MBOXQ_t *);
46 void lpfc_mbx_cmpl_fabric_reg_login(struct lpfc_hba *, LPFC_MBOXQ_t *);
47 void lpfc_mbx_cmpl_ns_reg_login(struct lpfc_hba *, LPFC_MBOXQ_t *);
48 void lpfc_mbx_cmpl_fdmi_reg_login(struct lpfc_hba *, LPFC_MBOXQ_t *);
49 int lpfc_nlp_plogi(struct lpfc_hba *, struct lpfc_nodelist *);
50 int lpfc_nlp_adisc(struct lpfc_hba *, struct lpfc_nodelist *);
51 int lpfc_nlp_unmapped(struct lpfc_hba *, struct lpfc_nodelist *);
52 int lpfc_nlp_list(struct lpfc_hba *, struct lpfc_nodelist *, int);
53 void lpfc_set_disctmo(struct lpfc_hba *);
54 int lpfc_can_disctmo(struct lpfc_hba *);
55 int lpfc_unreg_rpi(struct lpfc_hba *, struct lpfc_nodelist *);
56 int lpfc_check_sli_ndlp(struct lpfc_hba *, struct lpfc_sli_ring *,
57                     struct lpfc_iocbq *, struct lpfc_nodelist *);
58 int lpfc_nlp_remove(struct lpfc_hba *, struct lpfc_nodelist *);
59 void lpfc_nlp_init(struct lpfc_hba *, struct lpfc_nodelist *, uint32_t);
60 struct lpfc_nodelist *lpfc_setup_disc_node(struct lpfc_hba *, uint32_t);
61 struct lpfc_nodelist *lpfc_setup_rscn_node(struct lpfc_hba *, uint32_t);
62 void lpfc_disc_list_loopmap(struct lpfc_hba *);
63 void lpfc_disc_start(struct lpfc_hba *);
64 void lpfc_disc_flush_list(struct lpfc_hba *);
65 void lpfc_disc_timeout(unsigned long);
66 void lpfc_scan_timeout(unsigned long);
67
68 struct lpfc_nodelist *lpfc_findnode_rpi(struct lpfc_hba * phba, uint16_t rpi);
69 struct lpfc_nodelist *lpfc_findnode_remove_rpi(struct lpfc_hba * phba,
70                                                uint16_t rpi);
71 void lpfc_addnode_rpi(struct lpfc_hba * phba, struct lpfc_nodelist * ndlp,
72                       uint16_t rpi);
73
74 int lpfc_workq_post_event(struct lpfc_hba *, void *, void *, uint32_t);
75 int lpfc_do_work(void *);
76 int lpfc_disc_state_machine(struct lpfc_hba *, struct lpfc_nodelist *, void *,
77                             uint32_t);
78
79 uint32_t lpfc_cmpl_prli_reglogin_issue(struct lpfc_hba *,
80                                        struct lpfc_nodelist *, void *,
81                                        uint32_t);
82 uint32_t lpfc_cmpl_plogi_prli_issue(struct lpfc_hba *, struct lpfc_nodelist *,
83                                     void *, uint32_t);
84
85 int lpfc_check_sparm(struct lpfc_hba *, struct lpfc_nodelist *,
86                      struct serv_parm *, uint32_t);
87 int lpfc_els_abort(struct lpfc_hba *, struct lpfc_nodelist * ndlp,
88                         int);
89 int lpfc_els_abort_flogi(struct lpfc_hba *);
90 int lpfc_initial_flogi(struct lpfc_hba *);
91 int lpfc_issue_els_plogi(struct lpfc_hba *, struct lpfc_nodelist *, uint8_t);
92 int lpfc_issue_els_prli(struct lpfc_hba *, struct lpfc_nodelist *, uint8_t);
93 int lpfc_issue_els_adisc(struct lpfc_hba *, struct lpfc_nodelist *, uint8_t);
94 int lpfc_issue_els_logo(struct lpfc_hba *, struct lpfc_nodelist *, uint8_t);
95 int lpfc_issue_els_scr(struct lpfc_hba *, uint32_t, uint8_t);
96 int lpfc_els_free_iocb(struct lpfc_hba *, struct lpfc_iocbq *);
97 int lpfc_els_rsp_acc(struct lpfc_hba *, uint32_t, struct lpfc_iocbq *,
98                      struct lpfc_nodelist *, LPFC_MBOXQ_t *, uint8_t);
99 int lpfc_els_rsp_reject(struct lpfc_hba *, uint32_t, struct lpfc_iocbq *,
100                         struct lpfc_nodelist *);
101 int lpfc_els_rsp_adisc_acc(struct lpfc_hba *, struct lpfc_iocbq *,
102                            struct lpfc_nodelist *);
103 int lpfc_els_rsp_prli_acc(struct lpfc_hba *, struct lpfc_iocbq *,
104                           struct lpfc_nodelist *);
105 void lpfc_els_retry_delay(unsigned long);
106 void lpfc_els_retry_delay_handler(struct lpfc_nodelist *);
107 void lpfc_els_unsol_event(struct lpfc_hba *, struct lpfc_sli_ring *,
108                           struct lpfc_iocbq *);
109 int lpfc_els_handle_rscn(struct lpfc_hba *);
110 int lpfc_els_flush_rscn(struct lpfc_hba *);
111 int lpfc_rscn_payload_check(struct lpfc_hba *, uint32_t);
112 void lpfc_els_flush_cmd(struct lpfc_hba *);
113 int lpfc_els_disc_adisc(struct lpfc_hba *);
114 int lpfc_els_disc_plogi(struct lpfc_hba *);
115 void lpfc_els_timeout(unsigned long);
116 void lpfc_els_timeout_handler(struct lpfc_hba *);
117
118 void lpfc_ct_unsol_event(struct lpfc_hba *, struct lpfc_sli_ring *,
119                          struct lpfc_iocbq *);
120 int lpfc_ns_cmd(struct lpfc_hba *, struct lpfc_nodelist *, int);
121 int lpfc_fdmi_cmd(struct lpfc_hba *, struct lpfc_nodelist *, int);
122 void lpfc_fdmi_tmo(unsigned long);
123 void lpfc_fdmi_tmo_handler(struct lpfc_hba *);
124
125 int lpfc_config_port_prep(struct lpfc_hba *);
126 int lpfc_config_port_post(struct lpfc_hba *);
127 int lpfc_hba_down_prep(struct lpfc_hba *);
128 void lpfc_hba_init(struct lpfc_hba *, uint32_t *);
129 int lpfc_post_buffer(struct lpfc_hba *, struct lpfc_sli_ring *, int, int);
130 void lpfc_decode_firmware_rev(struct lpfc_hba *, char *, int);
131 uint8_t *lpfc_get_lpfchba_info(struct lpfc_hba *, uint8_t *);
132 int lpfc_fcp_abort(struct lpfc_hba *, int, int, int);
133 int lpfc_online(struct lpfc_hba *);
134 int lpfc_offline(struct lpfc_hba *);
135
136
137 int lpfc_sli_setup(struct lpfc_hba *);
138 int lpfc_sli_queue_setup(struct lpfc_hba *);
139 void lpfc_slim_access(struct lpfc_hba *);
140
141 void lpfc_handle_eratt(struct lpfc_hba *);
142 void lpfc_handle_latt(struct lpfc_hba *);
143 irqreturn_t lpfc_intr_handler(int, void *, struct pt_regs *);
144
145 void lpfc_read_rev(struct lpfc_hba *, LPFC_MBOXQ_t *);
146 void lpfc_config_ring(struct lpfc_hba *, int, LPFC_MBOXQ_t *);
147 void lpfc_config_port(struct lpfc_hba *, LPFC_MBOXQ_t *);
148 void lpfc_mbox_put(struct lpfc_hba *, LPFC_MBOXQ_t *);
149 LPFC_MBOXQ_t *lpfc_mbox_get(struct lpfc_hba *);
150
151 int lpfc_mem_alloc(struct lpfc_hba *);
152 void lpfc_mem_free(struct lpfc_hba *);
153
154 int lpfc_sli_hba_setup(struct lpfc_hba *);
155 int lpfc_sli_hba_down(struct lpfc_hba *);
156 int lpfc_sli_issue_mbox(struct lpfc_hba *, LPFC_MBOXQ_t *, uint32_t);
157 int lpfc_sli_handle_mb_event(struct lpfc_hba *);
158 int lpfc_sli_handle_slow_ring_event(struct lpfc_hba *,
159                                     struct lpfc_sli_ring *, uint32_t);
160 void lpfc_sli_def_mbox_cmpl(struct lpfc_hba *, LPFC_MBOXQ_t *);
161 int lpfc_sli_issue_iocb(struct lpfc_hba *, struct lpfc_sli_ring *,
162                         struct lpfc_iocbq *, uint32_t);
163 void lpfc_sli_pcimem_bcopy(void *, void *, uint32_t);
164 int lpfc_sli_abort_iocb_ring(struct lpfc_hba *, struct lpfc_sli_ring *);
165 int lpfc_sli_ringpostbuf_put(struct lpfc_hba *, struct lpfc_sli_ring *,
166                              struct lpfc_dmabuf *);
167 struct lpfc_dmabuf *lpfc_sli_ringpostbuf_get(struct lpfc_hba *,
168                                              struct lpfc_sli_ring *,
169                                              dma_addr_t);
170 int lpfc_sli_issue_abort_iotag32(struct lpfc_hba *, struct lpfc_sli_ring *,
171                                  struct lpfc_iocbq *);
172 int lpfc_sli_sum_iocb(struct lpfc_hba *, struct lpfc_sli_ring *, uint16_t,
173                           uint64_t, lpfc_ctx_cmd);
174 int lpfc_sli_abort_iocb(struct lpfc_hba *, struct lpfc_sli_ring *, uint16_t,
175                             uint64_t, uint32_t, lpfc_ctx_cmd);
176
177 void lpfc_mbox_timeout(unsigned long);
178 void lpfc_mbox_timeout_handler(struct lpfc_hba *);
179 void lpfc_map_fcp_cmnd_to_bpl(struct lpfc_hba *, struct lpfc_scsi_buf *);
180 void lpfc_free_scsi_cmd(struct lpfc_scsi_buf *);
181 uint32_t lpfc_os_timeout_transform(struct lpfc_hba *, uint32_t);
182
183 struct lpfc_nodelist *lpfc_findnode_did(struct lpfc_hba * phba, uint32_t order,
184                                         uint32_t did);
185
186 int lpfc_sli_issue_mbox_wait(struct lpfc_hba * phba, LPFC_MBOXQ_t * pmboxq,
187                          uint32_t timeout);
188
189 int lpfc_sli_issue_iocb_wait_high_priority(struct lpfc_hba * phba,
190                                            struct lpfc_sli_ring * pring,
191                                            struct lpfc_iocbq * piocb,
192                                            uint32_t flag,
193                                            struct lpfc_iocbq * prspiocbq,
194                                            uint32_t timeout);
195 void lpfc_sli_wake_iocb_high_priority(struct lpfc_hba * phba,
196                                       struct lpfc_iocbq * queue1,
197                                       struct lpfc_iocbq * queue2);
198
199 void *lpfc_mbuf_alloc(struct lpfc_hba *, int, dma_addr_t *);
200 void lpfc_mbuf_free(struct lpfc_hba *, void *, dma_addr_t);
201
202 /* Function prototypes. */
203 const char* lpfc_info(struct Scsi_Host *);
204 void lpfc_get_cfgparam(struct lpfc_hba *);
205 int lpfc_alloc_sysfs_attr(struct lpfc_hba *);
206 void lpfc_free_sysfs_attr(struct lpfc_hba *);
207 extern struct class_device_attribute *lpfc_host_attrs[];
208 extern struct scsi_host_template lpfc_template;
209 extern struct fc_function_template lpfc_transport_functions;
210
211 void lpfc_get_hba_sym_node_name(struct lpfc_hba * phba, uint8_t * symbp);
212
213 #define ScsiResult(host_code, scsi_code) (((host_code) << 16) | scsi_code)
214 #define HBA_EVENT_RSCN                   5
215 #define HBA_EVENT_LINK_UP                2
216 #define HBA_EVENT_LINK_DOWN              3