tw_cl_externs.h revision 212008
1144966Svkashyap/* 2169400Sscottl * Copyright (c) 2004-07 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 212008 2010-08-30 19:15:04Z delphij $ 28144966Svkashyap */ 29144966Svkashyap 30144966Svkashyap/* 31144966Svkashyap * AMCC'S 3ware driver for 9000 series storage controllers. 32144966Svkashyap * 33144966Svkashyap * Author: Vinod Kashyap 34169400Sscottl * Modifications by: Adam Radford 35144966Svkashyap */ 36144966Svkashyap 37144966Svkashyap 38144966Svkashyap 39144966Svkashyap#ifndef TW_CL_EXTERNS_H 40144966Svkashyap 41144966Svkashyap#define TW_CL_EXTERNS_H 42144966Svkashyap 43144966Svkashyap 44144966Svkashyap/* 45144966Svkashyap * Data structures and functions global to the Common Layer. 46144966Svkashyap */ 47144966Svkashyap 48144966Svkashyap 49144966Svkashyapextern TW_INT8 tw_cli_fw_img[]; 50144966Svkashyapextern TW_INT32 tw_cli_fw_img_size; 51144966Svkashyapextern TW_INT8 *tw_cli_severity_string_table[]; 52144966Svkashyap 53144966Svkashyap 54144966Svkashyap/* Do controller initialization. */ 55144966Svkashyapextern TW_INT32 tw_cli_start_ctlr(struct tw_cli_ctlr_context *ctlr); 56144966Svkashyap 57144966Svkashyap/* Establish a logical connection with the firmware on the controller. */ 58144966Svkashyapextern TW_INT32 tw_cli_init_connection(struct tw_cli_ctlr_context *ctlr, 59144966Svkashyap TW_UINT16 message_credits, TW_UINT32 set_features, 60144966Svkashyap TW_UINT16 current_fw_srl, TW_UINT16 current_fw_arch_id, 61144966Svkashyap TW_UINT16 current_fw_branch, TW_UINT16 current_fw_build, 62144966Svkashyap TW_UINT16 *fw_on_ctlr_srl, TW_UINT16 *fw_on_ctlr_arch_id, 63144966Svkashyap TW_UINT16 *fw_on_ctlr_branch, TW_UINT16 *fw_on_ctlr_build, 64144966Svkashyap TW_UINT32 *init_connect_result); 65144966Svkashyap 66144966Svkashyap 67144966Svkashyap 68144966Svkashyap/* Functions in tw_cl_io.c */ 69144966Svkashyap 70144966Svkashyap/* Submit a command packet to the firmware on the controller. */ 71144966Svkashyapextern TW_INT32 tw_cli_submit_cmd(struct tw_cli_req_context *req); 72144966Svkashyap 73144966Svkashyap/* Get a firmware parameter. */ 74144966Svkashyapextern TW_INT32 tw_cli_get_param(struct tw_cli_ctlr_context *ctlr, 75144966Svkashyap TW_INT32 table_id, TW_INT32 parameter_id, TW_VOID *param_data, 76144966Svkashyap TW_INT32 size, TW_VOID (* callback)(struct tw_cli_req_context *req)); 77144966Svkashyap 78144966Svkashyap/* Set a firmware parameter. */ 79144966Svkashyapextern TW_INT32 tw_cli_set_param(struct tw_cli_ctlr_context *ctlr, 80144966Svkashyap TW_INT32 table_id, TW_INT32 param_id, TW_INT32 param_size, 81144966Svkashyap TW_VOID *data, TW_VOID (* callback)(struct tw_cli_req_context *req)); 82144966Svkashyap 83144966Svkashyap/* Submit a command to the firmware and poll for completion. */ 84144966Svkashyapextern TW_INT32 tw_cli_submit_and_poll_request(struct tw_cli_req_context *req, 85144966Svkashyap TW_UINT32 timeout); 86144966Svkashyap 87144966Svkashyap/* Soft reset the controller. */ 88144966Svkashyapextern TW_INT32 tw_cli_soft_reset(struct tw_cli_ctlr_context *ctlr); 89212008Sdelphijextern int twa_setup_intr(struct twa_softc *sc); 90212008Sdelphijextern int twa_teardown_intr(struct twa_softc *sc); 91144966Svkashyap 92144966Svkashyap/* Send down a SCSI command to the firmware (usually, an internal Req Sense. */ 93144966Svkashyapextern TW_INT32 tw_cli_send_scsi_cmd(struct tw_cli_req_context *req, 94144966Svkashyap TW_INT32 cmd); 95144966Svkashyap 96144966Svkashyap/* Get an AEN from the firmware (by sending down a Req Sense). */ 97144966Svkashyapextern TW_INT32 tw_cli_get_aen(struct tw_cli_ctlr_context *ctlr); 98144966Svkashyap 99144966Svkashyap/* Fill in the scatter/gather list. */ 100144966Svkashyapextern TW_VOID tw_cli_fill_sg_list(struct tw_cli_ctlr_context *ctlr, 101144966Svkashyap TW_VOID *sgl_src, TW_VOID *sgl_dest, TW_INT32 num_sgl_entries); 102144966Svkashyap 103144966Svkashyap 104144966Svkashyap 105144966Svkashyap/* Functions in tw_cl_intr.c */ 106144966Svkashyap 107144966Svkashyap/* Process a host interrupt. */ 108144966Svkashyapextern TW_VOID tw_cli_process_host_intr(struct tw_cli_ctlr_context *ctlr); 109144966Svkashyap 110144966Svkashyap/* Process an attention interrupt. */ 111144966Svkashyapextern TW_VOID tw_cli_process_attn_intr(struct tw_cli_ctlr_context *ctlr); 112144966Svkashyap 113144966Svkashyap/* Process a command interrupt. */ 114144966Svkashyapextern TW_VOID tw_cli_process_cmd_intr(struct tw_cli_ctlr_context *ctlr); 115144966Svkashyap 116144966Svkashyap/* Process a response interrupt from the controller. */ 117144966Svkashyapextern TW_INT32 tw_cli_process_resp_intr(struct tw_cli_ctlr_context *ctlr); 118144966Svkashyap 119144966Svkashyap/* Submit any requests in the pending queue to the firmware. */ 120144966Svkashyapextern TW_INT32 tw_cli_submit_pending_queue(struct tw_cli_ctlr_context *ctlr); 121144966Svkashyap 122144966Svkashyap/* Process all requests in the complete queue. */ 123144966Svkashyapextern TW_VOID tw_cli_process_complete_queue(struct tw_cli_ctlr_context *ctlr); 124144966Svkashyap 125144966Svkashyap/* CL internal callback for SCSI/fw passthru requests. */ 126144966Svkashyapextern TW_VOID tw_cli_complete_io(struct tw_cli_req_context *req); 127144966Svkashyap 128144966Svkashyap/* Completion routine for SCSI requests. */ 129144966Svkashyapextern TW_VOID tw_cli_scsi_complete(struct tw_cli_req_context *req); 130144966Svkashyap 131144966Svkashyap/* Callback for get/set param requests. */ 132144966Svkashyapextern TW_VOID tw_cli_param_callback(struct tw_cli_req_context *req); 133144966Svkashyap 134144966Svkashyap/* Callback for Req Sense commands to get AEN's. */ 135144966Svkashyapextern TW_VOID tw_cli_aen_callback(struct tw_cli_req_context *req); 136144966Svkashyap 137144966Svkashyap/* Decide what to do with a retrieved AEN. */ 138144966Svkashyapextern TW_UINT16 tw_cli_manage_aen(struct tw_cli_ctlr_context *ctlr, 139144966Svkashyap struct tw_cli_req_context *req); 140144966Svkashyap 141144966Svkashyap/* Enable controller interrupts. */ 142144966Svkashyapextern TW_VOID 143144966Svkashyap tw_cli_enable_interrupts(struct tw_cli_ctlr_context *ctlr_handle); 144144966Svkashyap 145144966Svkashyap/* Disable controller interrupts. */ 146144966Svkashyapextern TW_VOID 147144966Svkashyap tw_cli_disable_interrupts(struct tw_cli_ctlr_context *ctlr_handle); 148144966Svkashyap 149144966Svkashyap 150144966Svkashyap 151144966Svkashyap/* Functions in tw_cl_misc.c */ 152144966Svkashyap 153144966Svkashyap/* Print if dbg_level is appropriate (by calling OS Layer). */ 154144966Svkashyapextern TW_VOID tw_cli_dbg_printf(TW_UINT8 dbg_level, 155144966Svkashyap struct tw_cl_ctlr_handle *ctlr_handle, const TW_INT8 *cur_func, 156144966Svkashyap TW_INT8 *fmt, ...); 157144966Svkashyap 158144966Svkashyap/* Describe meaning of each set bit in the given register. */ 159144966Svkashyapextern TW_INT8 *tw_cli_describe_bits(TW_UINT32 reg, TW_INT8 *str); 160144966Svkashyap 161144966Svkashyap/* Complete all requests in the complete queue with a RESET status. */ 162144966Svkashyapextern TW_VOID tw_cli_drain_complete_queue(struct tw_cli_ctlr_context *ctlr); 163144966Svkashyap 164144966Svkashyap/* Complete all requests in the busy queue with a RESET status. */ 165144966Svkashyapextern TW_VOID tw_cli_drain_busy_queue(struct tw_cli_ctlr_context *ctlr); 166144966Svkashyap 167144966Svkashyap/* Complete all requests in the pending queue with a RESET status. */ 168144966Svkashyapextern TW_VOID tw_cli_drain_pending_queue(struct tw_cli_ctlr_context *ctlr); 169144966Svkashyap 170144966Svkashyap/* Drain the controller response queue. */ 171144966Svkashyapextern TW_INT32 tw_cli_drain_response_queue(struct tw_cli_ctlr_context *ctlr); 172144966Svkashyap 173152213Svkashyap/* Find a particular response in the controller response queue. */ 174152213Svkashyapextern TW_INT32 tw_cli_find_response(struct tw_cli_ctlr_context *ctlr, 175152213Svkashyap TW_INT32 req_id); 176152213Svkashyap 177144966Svkashyap/* Drain the controller AEN queue. */ 178144966Svkashyapextern TW_INT32 tw_cli_drain_aen_queue(struct tw_cli_ctlr_context *ctlr); 179144966Svkashyap 180144966Svkashyap/* Determine if a given AEN has been posted by the firmware. */ 181144966Svkashyapextern TW_INT32 tw_cli_find_aen(struct tw_cli_ctlr_context *ctlr, 182144966Svkashyap TW_UINT16 aen_code); 183144966Svkashyap 184144966Svkashyap/* Poll for a given status to show up in the firmware status register. */ 185144966Svkashyapextern TW_INT32 tw_cli_poll_status(struct tw_cli_ctlr_context *ctlr, 186144966Svkashyap TW_UINT32 status, TW_UINT32 timeout); 187144966Svkashyap 188144966Svkashyap/* Get a free CL internal request context packet. */ 189144966Svkashyapextern struct tw_cli_req_context * 190144966Svkashyap tw_cli_get_request(struct tw_cli_ctlr_context *ctlr 191144966Svkashyap ); 192144966Svkashyap 193144966Svkashyap/* Notify OSL of controller info (fw/BIOS versions, etc.). */ 194144966Svkashyapextern TW_VOID tw_cli_notify_ctlr_info(struct tw_cli_ctlr_context *ctlr); 195144966Svkashyap 196144966Svkashyap/* Make sure that the firmware status register reports a proper status. */ 197144966Svkashyapextern TW_INT32 tw_cli_check_ctlr_state(struct tw_cli_ctlr_context *ctlr, 198144966Svkashyap TW_UINT32 status_reg); 199144966Svkashyap 200144966Svkashyap 201144966Svkashyap 202144966Svkashyap#endif /* TW_CL_EXTERNS_H */ 203