tw_cl_externs.h revision 169400
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 169400 2007-05-09 04:16:32Z scottl $ 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); 89144966Svkashyap 90144966Svkashyap/* Send down a SCSI command to the firmware (usually, an internal Req Sense. */ 91144966Svkashyapextern TW_INT32 tw_cli_send_scsi_cmd(struct tw_cli_req_context *req, 92144966Svkashyap TW_INT32 cmd); 93144966Svkashyap 94144966Svkashyap/* Get an AEN from the firmware (by sending down a Req Sense). */ 95144966Svkashyapextern TW_INT32 tw_cli_get_aen(struct tw_cli_ctlr_context *ctlr); 96144966Svkashyap 97144966Svkashyap/* Fill in the scatter/gather list. */ 98144966Svkashyapextern TW_VOID tw_cli_fill_sg_list(struct tw_cli_ctlr_context *ctlr, 99144966Svkashyap TW_VOID *sgl_src, TW_VOID *sgl_dest, TW_INT32 num_sgl_entries); 100144966Svkashyap 101144966Svkashyap 102144966Svkashyap 103144966Svkashyap/* Functions in tw_cl_intr.c */ 104144966Svkashyap 105144966Svkashyap/* Process a host interrupt. */ 106144966Svkashyapextern TW_VOID tw_cli_process_host_intr(struct tw_cli_ctlr_context *ctlr); 107144966Svkashyap 108144966Svkashyap/* Process an attention interrupt. */ 109144966Svkashyapextern TW_VOID tw_cli_process_attn_intr(struct tw_cli_ctlr_context *ctlr); 110144966Svkashyap 111144966Svkashyap/* Process a command interrupt. */ 112144966Svkashyapextern TW_VOID tw_cli_process_cmd_intr(struct tw_cli_ctlr_context *ctlr); 113144966Svkashyap 114144966Svkashyap/* Process a response interrupt from the controller. */ 115144966Svkashyapextern TW_INT32 tw_cli_process_resp_intr(struct tw_cli_ctlr_context *ctlr); 116144966Svkashyap 117144966Svkashyap/* Submit any requests in the pending queue to the firmware. */ 118144966Svkashyapextern TW_INT32 tw_cli_submit_pending_queue(struct tw_cli_ctlr_context *ctlr); 119144966Svkashyap 120144966Svkashyap/* Process all requests in the complete queue. */ 121144966Svkashyapextern TW_VOID tw_cli_process_complete_queue(struct tw_cli_ctlr_context *ctlr); 122144966Svkashyap 123144966Svkashyap/* CL internal callback for SCSI/fw passthru requests. */ 124144966Svkashyapextern TW_VOID tw_cli_complete_io(struct tw_cli_req_context *req); 125144966Svkashyap 126144966Svkashyap/* Completion routine for SCSI requests. */ 127144966Svkashyapextern TW_VOID tw_cli_scsi_complete(struct tw_cli_req_context *req); 128144966Svkashyap 129144966Svkashyap/* Callback for get/set param requests. */ 130144966Svkashyapextern TW_VOID tw_cli_param_callback(struct tw_cli_req_context *req); 131144966Svkashyap 132144966Svkashyap/* Callback for Req Sense commands to get AEN's. */ 133144966Svkashyapextern TW_VOID tw_cli_aen_callback(struct tw_cli_req_context *req); 134144966Svkashyap 135144966Svkashyap/* Decide what to do with a retrieved AEN. */ 136144966Svkashyapextern TW_UINT16 tw_cli_manage_aen(struct tw_cli_ctlr_context *ctlr, 137144966Svkashyap struct tw_cli_req_context *req); 138144966Svkashyap 139144966Svkashyap/* Enable controller interrupts. */ 140144966Svkashyapextern TW_VOID 141144966Svkashyap tw_cli_enable_interrupts(struct tw_cli_ctlr_context *ctlr_handle); 142144966Svkashyap 143144966Svkashyap/* Disable controller interrupts. */ 144144966Svkashyapextern TW_VOID 145144966Svkashyap tw_cli_disable_interrupts(struct tw_cli_ctlr_context *ctlr_handle); 146144966Svkashyap 147144966Svkashyap 148144966Svkashyap 149144966Svkashyap/* Functions in tw_cl_misc.c */ 150144966Svkashyap 151144966Svkashyap/* Print if dbg_level is appropriate (by calling OS Layer). */ 152144966Svkashyapextern TW_VOID tw_cli_dbg_printf(TW_UINT8 dbg_level, 153144966Svkashyap struct tw_cl_ctlr_handle *ctlr_handle, const TW_INT8 *cur_func, 154144966Svkashyap TW_INT8 *fmt, ...); 155144966Svkashyap 156144966Svkashyap/* Describe meaning of each set bit in the given register. */ 157144966Svkashyapextern TW_INT8 *tw_cli_describe_bits(TW_UINT32 reg, TW_INT8 *str); 158144966Svkashyap 159144966Svkashyap/* Complete all requests in the complete queue with a RESET status. */ 160144966Svkashyapextern TW_VOID tw_cli_drain_complete_queue(struct tw_cli_ctlr_context *ctlr); 161144966Svkashyap 162144966Svkashyap/* Complete all requests in the busy queue with a RESET status. */ 163144966Svkashyapextern TW_VOID tw_cli_drain_busy_queue(struct tw_cli_ctlr_context *ctlr); 164144966Svkashyap 165144966Svkashyap/* Complete all requests in the pending queue with a RESET status. */ 166144966Svkashyapextern TW_VOID tw_cli_drain_pending_queue(struct tw_cli_ctlr_context *ctlr); 167144966Svkashyap 168144966Svkashyap/* Drain the controller response queue. */ 169144966Svkashyapextern TW_INT32 tw_cli_drain_response_queue(struct tw_cli_ctlr_context *ctlr); 170144966Svkashyap 171152213Svkashyap/* Find a particular response in the controller response queue. */ 172152213Svkashyapextern TW_INT32 tw_cli_find_response(struct tw_cli_ctlr_context *ctlr, 173152213Svkashyap TW_INT32 req_id); 174152213Svkashyap 175144966Svkashyap/* Drain the controller AEN queue. */ 176144966Svkashyapextern TW_INT32 tw_cli_drain_aen_queue(struct tw_cli_ctlr_context *ctlr); 177144966Svkashyap 178144966Svkashyap/* Determine if a given AEN has been posted by the firmware. */ 179144966Svkashyapextern TW_INT32 tw_cli_find_aen(struct tw_cli_ctlr_context *ctlr, 180144966Svkashyap TW_UINT16 aen_code); 181144966Svkashyap 182144966Svkashyap/* Poll for a given status to show up in the firmware status register. */ 183144966Svkashyapextern TW_INT32 tw_cli_poll_status(struct tw_cli_ctlr_context *ctlr, 184144966Svkashyap TW_UINT32 status, TW_UINT32 timeout); 185144966Svkashyap 186144966Svkashyap/* Get a free CL internal request context packet. */ 187144966Svkashyapextern struct tw_cli_req_context * 188144966Svkashyap tw_cli_get_request(struct tw_cli_ctlr_context *ctlr 189144966Svkashyap ); 190144966Svkashyap 191144966Svkashyap/* Notify OSL of controller info (fw/BIOS versions, etc.). */ 192144966Svkashyapextern TW_VOID tw_cli_notify_ctlr_info(struct tw_cli_ctlr_context *ctlr); 193144966Svkashyap 194144966Svkashyap/* Make sure that the firmware status register reports a proper status. */ 195144966Svkashyapextern TW_INT32 tw_cli_check_ctlr_state(struct tw_cli_ctlr_context *ctlr, 196144966Svkashyap TW_UINT32 status_reg); 197144966Svkashyap 198144966Svkashyap 199144966Svkashyap 200144966Svkashyap#endif /* TW_CL_EXTERNS_H */ 201