tw_cl_externs.h revision 144966
1144966Svkashyap/* 2144966Svkashyap * Copyright (c) 2004-05 Applied Micro Circuits Corporation. 3144966Svkashyap * Copyright (c) 2004-05 Vinod Kashyap 4144966Svkashyap * All rights reserved. 5144966Svkashyap * 6144966Svkashyap * Redistribution and use in source and binary forms, with or without 7144966Svkashyap * modification, are permitted provided that the following conditions 8144966Svkashyap * are met: 9144966Svkashyap * 1. Redistributions of source code must retain the above copyright 10144966Svkashyap * notice, this list of conditions and the following disclaimer. 11144966Svkashyap * 2. Redistributions in binary form must reproduce the above copyright 12144966Svkashyap * notice, this list of conditions and the following disclaimer in the 13144966Svkashyap * documentation and/or other materials provided with the distribution. 14144966Svkashyap * 15144966Svkashyap * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16144966Svkashyap * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17144966Svkashyap * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18144966Svkashyap * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19144966Svkashyap * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20144966Svkashyap * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21144966Svkashyap * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22144966Svkashyap * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23144966Svkashyap * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24144966Svkashyap * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25144966Svkashyap * SUCH DAMAGE. 26144966Svkashyap * 27144966Svkashyap * $FreeBSD: head/sys/dev/twa/tw_cl_externs.h 144966 2005-04-12 22:07:11Z vkashyap $ 28144966Svkashyap */ 29144966Svkashyap 30144966Svkashyap/* 31144966Svkashyap * AMCC'S 3ware driver for 9000 series storage controllers. 32144966Svkashyap * 33144966Svkashyap * Author: Vinod Kashyap 34144966Svkashyap */ 35144966Svkashyap 36144966Svkashyap 37144966Svkashyap 38144966Svkashyap#ifndef TW_CL_EXTERNS_H 39144966Svkashyap 40144966Svkashyap#define TW_CL_EXTERNS_H 41144966Svkashyap 42144966Svkashyap 43144966Svkashyap/* 44144966Svkashyap * Data structures and functions global to the Common Layer. 45144966Svkashyap */ 46144966Svkashyap 47144966Svkashyap 48144966Svkashyapextern TW_INT8 tw_cli_fw_img[]; 49144966Svkashyapextern TW_INT32 tw_cli_fw_img_size; 50144966Svkashyapextern TW_INT8 *tw_cli_severity_string_table[]; 51144966Svkashyap 52144966Svkashyap 53144966Svkashyap#ifdef TW_OSL_FLASH_FIRMWARE 54144966Svkashyap 55144966Svkashyap/* Functions in tw_cl_init.c */ 56144966Svkashyap 57144966Svkashyap/* Flash bundled firmware image onto controller. */ 58144966Svkashyapextern TW_INT32 tw_cli_flash_firmware(struct tw_cli_ctlr_context *ctlr); 59144966Svkashyap 60144966Svkashyap/* Hard reset the controller. */ 61144966Svkashyapextern TW_INT32 tw_cli_hard_reset(struct tw_cli_ctlr_context *ctlr); 62144966Svkashyap 63144966Svkashyap#endif /* TW_OSL_FLASH_FIRMWARE */ 64144966Svkashyap 65144966Svkashyap/* Do controller initialization. */ 66144966Svkashyapextern TW_INT32 tw_cli_start_ctlr(struct tw_cli_ctlr_context *ctlr); 67144966Svkashyap 68144966Svkashyap/* Establish a logical connection with the firmware on the controller. */ 69144966Svkashyapextern TW_INT32 tw_cli_init_connection(struct tw_cli_ctlr_context *ctlr, 70144966Svkashyap TW_UINT16 message_credits, TW_UINT32 set_features, 71144966Svkashyap TW_UINT16 current_fw_srl, TW_UINT16 current_fw_arch_id, 72144966Svkashyap TW_UINT16 current_fw_branch, TW_UINT16 current_fw_build, 73144966Svkashyap TW_UINT16 *fw_on_ctlr_srl, TW_UINT16 *fw_on_ctlr_arch_id, 74144966Svkashyap TW_UINT16 *fw_on_ctlr_branch, TW_UINT16 *fw_on_ctlr_build, 75144966Svkashyap TW_UINT32 *init_connect_result); 76144966Svkashyap 77144966Svkashyap 78144966Svkashyap 79144966Svkashyap/* Functions in tw_cl_io.c */ 80144966Svkashyap 81144966Svkashyap/* Submit a command packet to the firmware on the controller. */ 82144966Svkashyapextern TW_INT32 tw_cli_submit_cmd(struct tw_cli_req_context *req); 83144966Svkashyap 84144966Svkashyap/* Get a firmware parameter. */ 85144966Svkashyapextern TW_INT32 tw_cli_get_param(struct tw_cli_ctlr_context *ctlr, 86144966Svkashyap TW_INT32 table_id, TW_INT32 parameter_id, TW_VOID *param_data, 87144966Svkashyap TW_INT32 size, TW_VOID (* callback)(struct tw_cli_req_context *req)); 88144966Svkashyap 89144966Svkashyap/* Set a firmware parameter. */ 90144966Svkashyapextern TW_INT32 tw_cli_set_param(struct tw_cli_ctlr_context *ctlr, 91144966Svkashyap TW_INT32 table_id, TW_INT32 param_id, TW_INT32 param_size, 92144966Svkashyap TW_VOID *data, TW_VOID (* callback)(struct tw_cli_req_context *req)); 93144966Svkashyap 94144966Svkashyap/* Submit a command to the firmware and poll for completion. */ 95144966Svkashyapextern TW_INT32 tw_cli_submit_and_poll_request(struct tw_cli_req_context *req, 96144966Svkashyap TW_UINT32 timeout); 97144966Svkashyap 98144966Svkashyap/* Soft reset the controller. */ 99144966Svkashyapextern TW_INT32 tw_cli_soft_reset(struct tw_cli_ctlr_context *ctlr); 100144966Svkashyap 101144966Svkashyap/* Send down a SCSI command to the firmware (usually, an internal Req Sense. */ 102144966Svkashyapextern TW_INT32 tw_cli_send_scsi_cmd(struct tw_cli_req_context *req, 103144966Svkashyap TW_INT32 cmd); 104144966Svkashyap 105144966Svkashyap/* Get an AEN from the firmware (by sending down a Req Sense). */ 106144966Svkashyapextern TW_INT32 tw_cli_get_aen(struct tw_cli_ctlr_context *ctlr); 107144966Svkashyap 108144966Svkashyap/* Fill in the scatter/gather list. */ 109144966Svkashyapextern TW_VOID tw_cli_fill_sg_list(struct tw_cli_ctlr_context *ctlr, 110144966Svkashyap TW_VOID *sgl_src, TW_VOID *sgl_dest, TW_INT32 num_sgl_entries); 111144966Svkashyap 112144966Svkashyap 113144966Svkashyap 114144966Svkashyap/* Functions in tw_cl_intr.c */ 115144966Svkashyap 116144966Svkashyap/* Process a host interrupt. */ 117144966Svkashyapextern TW_VOID tw_cli_process_host_intr(struct tw_cli_ctlr_context *ctlr); 118144966Svkashyap 119144966Svkashyap/* Process an attention interrupt. */ 120144966Svkashyapextern TW_VOID tw_cli_process_attn_intr(struct tw_cli_ctlr_context *ctlr); 121144966Svkashyap 122144966Svkashyap/* Process a command interrupt. */ 123144966Svkashyapextern TW_VOID tw_cli_process_cmd_intr(struct tw_cli_ctlr_context *ctlr); 124144966Svkashyap 125144966Svkashyap/* Process a response interrupt from the controller. */ 126144966Svkashyapextern TW_INT32 tw_cli_process_resp_intr(struct tw_cli_ctlr_context *ctlr); 127144966Svkashyap 128144966Svkashyap/* Submit any requests in the pending queue to the firmware. */ 129144966Svkashyapextern TW_INT32 tw_cli_submit_pending_queue(struct tw_cli_ctlr_context *ctlr); 130144966Svkashyap 131144966Svkashyap/* Process all requests in the complete queue. */ 132144966Svkashyapextern TW_VOID tw_cli_process_complete_queue(struct tw_cli_ctlr_context *ctlr); 133144966Svkashyap 134144966Svkashyap/* CL internal callback for SCSI/fw passthru requests. */ 135144966Svkashyapextern TW_VOID tw_cli_complete_io(struct tw_cli_req_context *req); 136144966Svkashyap 137144966Svkashyap/* Completion routine for SCSI requests. */ 138144966Svkashyapextern TW_VOID tw_cli_scsi_complete(struct tw_cli_req_context *req); 139144966Svkashyap 140144966Svkashyap/* Callback for get/set param requests. */ 141144966Svkashyapextern TW_VOID tw_cli_param_callback(struct tw_cli_req_context *req); 142144966Svkashyap 143144966Svkashyap/* Callback for Req Sense commands to get AEN's. */ 144144966Svkashyapextern TW_VOID tw_cli_aen_callback(struct tw_cli_req_context *req); 145144966Svkashyap 146144966Svkashyap/* Decide what to do with a retrieved AEN. */ 147144966Svkashyapextern TW_UINT16 tw_cli_manage_aen(struct tw_cli_ctlr_context *ctlr, 148144966Svkashyap struct tw_cli_req_context *req); 149144966Svkashyap 150144966Svkashyap/* Enable controller interrupts. */ 151144966Svkashyapextern TW_VOID 152144966Svkashyap tw_cli_enable_interrupts(struct tw_cli_ctlr_context *ctlr_handle); 153144966Svkashyap 154144966Svkashyap/* Disable controller interrupts. */ 155144966Svkashyapextern TW_VOID 156144966Svkashyap tw_cli_disable_interrupts(struct tw_cli_ctlr_context *ctlr_handle); 157144966Svkashyap 158144966Svkashyap 159144966Svkashyap 160144966Svkashyap/* Functions in tw_cl_misc.c */ 161144966Svkashyap 162144966Svkashyap/* Print if dbg_level is appropriate (by calling OS Layer). */ 163144966Svkashyapextern TW_VOID tw_cli_dbg_printf(TW_UINT8 dbg_level, 164144966Svkashyap struct tw_cl_ctlr_handle *ctlr_handle, const TW_INT8 *cur_func, 165144966Svkashyap TW_INT8 *fmt, ...); 166144966Svkashyap 167144966Svkashyap/* Describe meaning of each set bit in the given register. */ 168144966Svkashyapextern TW_INT8 *tw_cli_describe_bits(TW_UINT32 reg, TW_INT8 *str); 169144966Svkashyap 170144966Svkashyap/* Complete all requests in the complete queue with a RESET status. */ 171144966Svkashyapextern TW_VOID tw_cli_drain_complete_queue(struct tw_cli_ctlr_context *ctlr); 172144966Svkashyap 173144966Svkashyap/* Complete all requests in the busy queue with a RESET status. */ 174144966Svkashyapextern TW_VOID tw_cli_drain_busy_queue(struct tw_cli_ctlr_context *ctlr); 175144966Svkashyap 176144966Svkashyap/* Complete all requests in the pending queue with a RESET status. */ 177144966Svkashyapextern TW_VOID tw_cli_drain_pending_queue(struct tw_cli_ctlr_context *ctlr); 178144966Svkashyap 179144966Svkashyap/* Drain the controller response queue. */ 180144966Svkashyapextern TW_INT32 tw_cli_drain_response_queue(struct tw_cli_ctlr_context *ctlr); 181144966Svkashyap 182144966Svkashyap/* Drain the controller AEN queue. */ 183144966Svkashyapextern TW_INT32 tw_cli_drain_aen_queue(struct tw_cli_ctlr_context *ctlr); 184144966Svkashyap 185144966Svkashyap/* Determine if a given AEN has been posted by the firmware. */ 186144966Svkashyapextern TW_INT32 tw_cli_find_aen(struct tw_cli_ctlr_context *ctlr, 187144966Svkashyap TW_UINT16 aen_code); 188144966Svkashyap 189144966Svkashyap/* Poll for a given status to show up in the firmware status register. */ 190144966Svkashyapextern TW_INT32 tw_cli_poll_status(struct tw_cli_ctlr_context *ctlr, 191144966Svkashyap TW_UINT32 status, TW_UINT32 timeout); 192144966Svkashyap 193144966Svkashyap/* Get a free CL internal request context packet. */ 194144966Svkashyapextern struct tw_cli_req_context * 195144966Svkashyap tw_cli_get_request(struct tw_cli_ctlr_context *ctlr 196144966Svkashyap#ifdef TW_OSL_NON_DMA_MEM_ALLOC_PER_REQUEST 197144966Svkashyap , struct tw_cl_req_packet *req_pkt 198144966Svkashyap#endif /* TW_OSL_NON_DMA_MEM_ALLOC_PER_REQUEST */ 199144966Svkashyap ); 200144966Svkashyap 201144966Svkashyap/* Notify OSL of controller info (fw/BIOS versions, etc.). */ 202144966Svkashyapextern TW_VOID tw_cli_notify_ctlr_info(struct tw_cli_ctlr_context *ctlr); 203144966Svkashyap 204144966Svkashyap/* Make sure that the firmware status register reports a proper status. */ 205144966Svkashyapextern TW_INT32 tw_cli_check_ctlr_state(struct tw_cli_ctlr_context *ctlr, 206144966Svkashyap TW_UINT32 status_reg); 207144966Svkashyap 208144966Svkashyap 209144966Svkashyap 210144966Svkashyap#endif /* TW_CL_EXTERNS_H */ 211