2 * Copyright (c) 2004-05 Applied Micro Circuits Corporation.
3 * Copyright (c) 2004-05 Vinod Kashyap
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * AMCC'S 3ware driver for 9000 series storage controllers.
33 * Author: Vinod Kashyap
38 #ifndef TW_CL_EXTERNS_H
40 #define TW_CL_EXTERNS_H
44 * Data structures and functions global to the Common Layer.
48 extern TW_INT8 tw_cli_fw_img[];
49 extern TW_INT32 tw_cli_fw_img_size;
50 extern TW_INT8 *tw_cli_severity_string_table[];
53 #ifdef TW_OSL_FLASH_FIRMWARE
55 /* Functions in tw_cl_init.c */
57 /* Flash bundled firmware image onto controller. */
58 extern TW_INT32 tw_cli_flash_firmware(struct tw_cli_ctlr_context *ctlr);
60 /* Hard reset the controller. */
61 extern TW_INT32 tw_cli_hard_reset(struct tw_cli_ctlr_context *ctlr);
63 #endif /* TW_OSL_FLASH_FIRMWARE */
65 /* Do controller initialization. */
66 extern TW_INT32 tw_cli_start_ctlr(struct tw_cli_ctlr_context *ctlr);
68 /* Establish a logical connection with the firmware on the controller. */
69 extern TW_INT32 tw_cli_init_connection(struct tw_cli_ctlr_context *ctlr,
70 TW_UINT16 message_credits, TW_UINT32 set_features,
71 TW_UINT16 current_fw_srl, TW_UINT16 current_fw_arch_id,
72 TW_UINT16 current_fw_branch, TW_UINT16 current_fw_build,
73 TW_UINT16 *fw_on_ctlr_srl, TW_UINT16 *fw_on_ctlr_arch_id,
74 TW_UINT16 *fw_on_ctlr_branch, TW_UINT16 *fw_on_ctlr_build,
75 TW_UINT32 *init_connect_result);
79 /* Functions in tw_cl_io.c */
81 /* Submit a command packet to the firmware on the controller. */
82 extern TW_INT32 tw_cli_submit_cmd(struct tw_cli_req_context *req);
84 /* Get a firmware parameter. */
85 extern TW_INT32 tw_cli_get_param(struct tw_cli_ctlr_context *ctlr,
86 TW_INT32 table_id, TW_INT32 parameter_id, TW_VOID *param_data,
87 TW_INT32 size, TW_VOID (* callback)(struct tw_cli_req_context *req));
89 /* Set a firmware parameter. */
90 extern TW_INT32 tw_cli_set_param(struct tw_cli_ctlr_context *ctlr,
91 TW_INT32 table_id, TW_INT32 param_id, TW_INT32 param_size,
92 TW_VOID *data, TW_VOID (* callback)(struct tw_cli_req_context *req));
94 /* Submit a command to the firmware and poll for completion. */
95 extern TW_INT32 tw_cli_submit_and_poll_request(struct tw_cli_req_context *req,
98 /* Soft reset the controller. */
99 extern TW_INT32 tw_cli_soft_reset(struct tw_cli_ctlr_context *ctlr);
101 /* Send down a SCSI command to the firmware (usually, an internal Req Sense. */
102 extern TW_INT32 tw_cli_send_scsi_cmd(struct tw_cli_req_context *req,
105 /* Get an AEN from the firmware (by sending down a Req Sense). */
106 extern TW_INT32 tw_cli_get_aen(struct tw_cli_ctlr_context *ctlr);
108 /* Fill in the scatter/gather list. */
109 extern TW_VOID tw_cli_fill_sg_list(struct tw_cli_ctlr_context *ctlr,
110 TW_VOID *sgl_src, TW_VOID *sgl_dest, TW_INT32 num_sgl_entries);
114 /* Functions in tw_cl_intr.c */
116 /* Process a host interrupt. */
117 extern TW_VOID tw_cli_process_host_intr(struct tw_cli_ctlr_context *ctlr);
119 /* Process an attention interrupt. */
120 extern TW_VOID tw_cli_process_attn_intr(struct tw_cli_ctlr_context *ctlr);
122 /* Process a command interrupt. */
123 extern TW_VOID tw_cli_process_cmd_intr(struct tw_cli_ctlr_context *ctlr);
125 /* Process a response interrupt from the controller. */
126 extern TW_INT32 tw_cli_process_resp_intr(struct tw_cli_ctlr_context *ctlr);
128 /* Submit any requests in the pending queue to the firmware. */
129 extern TW_INT32 tw_cli_submit_pending_queue(struct tw_cli_ctlr_context *ctlr);
131 /* Process all requests in the complete queue. */
132 extern TW_VOID tw_cli_process_complete_queue(struct tw_cli_ctlr_context *ctlr);
134 /* CL internal callback for SCSI/fw passthru requests. */
135 extern TW_VOID tw_cli_complete_io(struct tw_cli_req_context *req);
137 /* Completion routine for SCSI requests. */
138 extern TW_VOID tw_cli_scsi_complete(struct tw_cli_req_context *req);
140 /* Callback for get/set param requests. */
141 extern TW_VOID tw_cli_param_callback(struct tw_cli_req_context *req);
143 /* Callback for Req Sense commands to get AEN's. */
144 extern TW_VOID tw_cli_aen_callback(struct tw_cli_req_context *req);
146 /* Decide what to do with a retrieved AEN. */
147 extern TW_UINT16 tw_cli_manage_aen(struct tw_cli_ctlr_context *ctlr,
148 struct tw_cli_req_context *req);
150 /* Enable controller interrupts. */
152 tw_cli_enable_interrupts(struct tw_cli_ctlr_context *ctlr_handle);
154 /* Disable controller interrupts. */
156 tw_cli_disable_interrupts(struct tw_cli_ctlr_context *ctlr_handle);
160 /* Functions in tw_cl_misc.c */
162 /* Print if dbg_level is appropriate (by calling OS Layer). */
163 extern TW_VOID tw_cli_dbg_printf(TW_UINT8 dbg_level,
164 struct tw_cl_ctlr_handle *ctlr_handle, const TW_INT8 *cur_func,
167 /* Describe meaning of each set bit in the given register. */
168 extern TW_INT8 *tw_cli_describe_bits(TW_UINT32 reg, TW_INT8 *str);
170 /* Complete all requests in the complete queue with a RESET status. */
171 extern TW_VOID tw_cli_drain_complete_queue(struct tw_cli_ctlr_context *ctlr);
173 /* Complete all requests in the busy queue with a RESET status. */
174 extern TW_VOID tw_cli_drain_busy_queue(struct tw_cli_ctlr_context *ctlr);
176 /* Complete all requests in the pending queue with a RESET status. */
177 extern TW_VOID tw_cli_drain_pending_queue(struct tw_cli_ctlr_context *ctlr);
179 /* Drain the controller response queue. */
180 extern TW_INT32 tw_cli_drain_response_queue(struct tw_cli_ctlr_context *ctlr);
182 /* Find a particular response in the controller response queue. */
183 extern TW_INT32 tw_cli_find_response(struct tw_cli_ctlr_context *ctlr,
186 /* Drain the controller AEN queue. */
187 extern TW_INT32 tw_cli_drain_aen_queue(struct tw_cli_ctlr_context *ctlr);
189 /* Determine if a given AEN has been posted by the firmware. */
190 extern TW_INT32 tw_cli_find_aen(struct tw_cli_ctlr_context *ctlr,
193 /* Poll for a given status to show up in the firmware status register. */
194 extern TW_INT32 tw_cli_poll_status(struct tw_cli_ctlr_context *ctlr,
195 TW_UINT32 status, TW_UINT32 timeout);
197 /* Get a free CL internal request context packet. */
198 extern struct tw_cli_req_context *
199 tw_cli_get_request(struct tw_cli_ctlr_context *ctlr
200 #ifdef TW_OSL_NON_DMA_MEM_ALLOC_PER_REQUEST
201 , struct tw_cl_req_packet *req_pkt
202 #endif /* TW_OSL_NON_DMA_MEM_ALLOC_PER_REQUEST */
205 /* Notify OSL of controller info (fw/BIOS versions, etc.). */
206 extern TW_VOID tw_cli_notify_ctlr_info(struct tw_cli_ctlr_context *ctlr);
208 /* Make sure that the firmware status register reports a proper status. */
209 extern TW_INT32 tw_cli_check_ctlr_state(struct tw_cli_ctlr_context *ctlr,
210 TW_UINT32 status_reg);
214 #endif /* TW_CL_EXTERNS_H */