]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/twa/tw_cl_externs.h
[PowerPC] hwpmc: add support for POWER8/9 PMCs
[FreeBSD/FreeBSD.git] / sys / dev / twa / tw_cl_externs.h
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3  *
4  * Copyright (c) 2004-07 Applied Micro Circuits Corporation.
5  * Copyright (c) 2004-05 Vinod Kashyap
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27  * SUCH DAMAGE.
28  *
29  *      $FreeBSD$
30  */
31
32 /*
33  * AMCC'S 3ware driver for 9000 series storage controllers.
34  *
35  * Author: Vinod Kashyap
36  * Modifications by: Adam Radford
37  */
38
39 #ifndef TW_CL_EXTERNS_H
40
41 #define TW_CL_EXTERNS_H
42
43 /*
44  * Data structures and functions global to the Common Layer.
45  */
46
47 extern TW_INT8                  tw_cli_fw_img[];
48 extern TW_INT32                 tw_cli_fw_img_size;
49 extern TW_INT8                  *tw_cli_severity_string_table[];
50
51 /* Do controller initialization. */
52 extern TW_INT32 tw_cli_start_ctlr(struct tw_cli_ctlr_context *ctlr);
53
54 /* Establish a logical connection with the firmware on the controller. */
55 extern TW_INT32 tw_cli_init_connection(struct tw_cli_ctlr_context *ctlr,
56         TW_UINT16 message_credits, TW_UINT32 set_features,
57         TW_UINT16 current_fw_srl, TW_UINT16 current_fw_arch_id,
58         TW_UINT16 current_fw_branch, TW_UINT16 current_fw_build,
59         TW_UINT16 *fw_on_ctlr_srl, TW_UINT16 *fw_on_ctlr_arch_id,
60         TW_UINT16 *fw_on_ctlr_branch, TW_UINT16 *fw_on_ctlr_build,
61         TW_UINT32 *init_connect_result);
62
63 /* Functions in tw_cl_io.c */
64
65 /* Submit a command packet to the firmware on the controller. */
66 extern TW_INT32 tw_cli_submit_cmd(struct tw_cli_req_context *req);
67
68 /* Get a firmware parameter. */
69 extern TW_INT32 tw_cli_get_param(struct tw_cli_ctlr_context *ctlr,
70         TW_INT32 table_id, TW_INT32 parameter_id, TW_VOID *param_data,
71         TW_INT32 size, TW_VOID (* callback)(struct tw_cli_req_context *req));
72
73 /* Set a firmware parameter. */
74 extern TW_INT32 tw_cli_set_param(struct tw_cli_ctlr_context *ctlr,
75         TW_INT32 table_id, TW_INT32 param_id, TW_INT32 param_size,
76         TW_VOID *data, TW_VOID (* callback)(struct tw_cli_req_context *req));
77
78 /* Submit a command to the firmware and poll for completion. */
79 extern TW_INT32 tw_cli_submit_and_poll_request(struct tw_cli_req_context *req,
80         TW_UINT32 timeout);
81
82 /* Soft reset the controller. */
83 extern TW_INT32 tw_cli_soft_reset(struct tw_cli_ctlr_context *ctlr);
84 extern int twa_setup_intr(struct twa_softc *sc);
85 extern int twa_teardown_intr(struct twa_softc *sc);
86
87 /* Send down a SCSI command to the firmware (usually, an internal Req Sense. */
88 extern TW_INT32 tw_cli_send_scsi_cmd(struct tw_cli_req_context *req,
89         TW_INT32 cmd);
90
91 /* Get an AEN from the firmware (by sending down a Req Sense). */
92 extern TW_INT32 tw_cli_get_aen(struct tw_cli_ctlr_context *ctlr);
93
94 /* Fill in the scatter/gather list. */
95 extern TW_VOID tw_cli_fill_sg_list(struct tw_cli_ctlr_context *ctlr,
96         TW_VOID *sgl_src, TW_VOID *sgl_dest, TW_INT32 num_sgl_entries);
97
98 /* Functions in tw_cl_intr.c */
99
100 /* Process a host interrupt. */
101 extern TW_VOID  tw_cli_process_host_intr(struct tw_cli_ctlr_context *ctlr);
102
103 /* Process an attention interrupt. */
104 extern TW_VOID  tw_cli_process_attn_intr(struct tw_cli_ctlr_context *ctlr);
105
106 /* Process a command interrupt. */
107 extern TW_VOID  tw_cli_process_cmd_intr(struct tw_cli_ctlr_context *ctlr);
108
109 /* Process a response interrupt from the controller. */
110 extern TW_INT32 tw_cli_process_resp_intr(struct tw_cli_ctlr_context *ctlr);
111
112 /* Submit any requests in the pending queue to the firmware. */
113 extern TW_INT32 tw_cli_submit_pending_queue(struct tw_cli_ctlr_context *ctlr);
114
115 /* Process all requests in the complete queue. */
116 extern TW_VOID  tw_cli_process_complete_queue(struct tw_cli_ctlr_context *ctlr);
117
118 /* CL internal callback for SCSI/fw passthru requests. */
119 extern TW_VOID  tw_cli_complete_io(struct tw_cli_req_context *req);
120
121 /* Completion routine for SCSI requests. */
122 extern TW_VOID  tw_cli_scsi_complete(struct tw_cli_req_context *req);
123
124 /* Callback for get/set param requests. */
125 extern TW_VOID  tw_cli_param_callback(struct tw_cli_req_context *req);
126
127 /* Callback for Req Sense commands to get AEN's. */
128 extern TW_VOID  tw_cli_aen_callback(struct tw_cli_req_context *req);
129
130 /* Decide what to do with a retrieved AEN. */
131 extern TW_UINT16        tw_cli_manage_aen(struct tw_cli_ctlr_context *ctlr,
132         struct tw_cli_req_context *req);
133
134 /* Enable controller interrupts. */
135 extern TW_VOID
136         tw_cli_enable_interrupts(struct tw_cli_ctlr_context *ctlr_handle);
137
138 /* Disable controller interrupts. */
139 extern TW_VOID
140         tw_cli_disable_interrupts(struct tw_cli_ctlr_context *ctlr_handle);
141
142 /* Functions in tw_cl_misc.c */
143
144 /* Print if dbg_level is appropriate (by calling OS Layer). */
145 extern TW_VOID  tw_cli_dbg_printf(TW_UINT8 dbg_level,
146         struct tw_cl_ctlr_handle *ctlr_handle, const TW_INT8 *cur_func,
147         TW_INT8 *fmt, ...);
148
149 /* Describe meaning of each set bit in the given register. */
150 extern TW_INT8  *tw_cli_describe_bits(TW_UINT32 reg, TW_INT8 *str);
151
152 /* Complete all requests in the complete queue with a RESET status. */
153 extern TW_VOID  tw_cli_drain_complete_queue(struct tw_cli_ctlr_context *ctlr);
154
155 /* Complete all requests in the busy queue with a RESET status. */
156 extern TW_VOID  tw_cli_drain_busy_queue(struct tw_cli_ctlr_context *ctlr);
157
158 /* Complete all requests in the pending queue with a RESET status. */
159 extern TW_VOID  tw_cli_drain_pending_queue(struct tw_cli_ctlr_context *ctlr);
160
161 /* Drain the controller response queue. */
162 extern TW_INT32 tw_cli_drain_response_queue(struct tw_cli_ctlr_context *ctlr);
163
164 /* Find a particular response in the controller response queue. */
165 extern TW_INT32 tw_cli_find_response(struct tw_cli_ctlr_context *ctlr,
166         TW_INT32 req_id);
167
168 /* Drain the controller AEN queue. */
169 extern TW_INT32 tw_cli_drain_aen_queue(struct tw_cli_ctlr_context *ctlr);
170
171 /* Determine if a given AEN has been posted by the firmware. */
172 extern TW_INT32 tw_cli_find_aen(struct tw_cli_ctlr_context *ctlr,
173         TW_UINT16 aen_code);
174
175 /* Poll for a given status to show up in the firmware status register. */
176 extern TW_INT32 tw_cli_poll_status(struct tw_cli_ctlr_context *ctlr,
177         TW_UINT32 status, TW_UINT32 timeout);
178
179 /* Get a free CL internal request context packet. */
180 extern struct tw_cli_req_context *
181         tw_cli_get_request(struct tw_cli_ctlr_context *ctlr
182         );
183
184 /* Notify OSL of controller info (fw/BIOS versions, etc.). */
185 extern TW_VOID  tw_cli_notify_ctlr_info(struct tw_cli_ctlr_context *ctlr);
186
187 /* Make sure that the firmware status register reports a proper status. */
188 extern TW_INT32 tw_cli_check_ctlr_state(struct tw_cli_ctlr_context *ctlr,
189         TW_UINT32 status_reg);
190
191 #endif /* TW_CL_EXTERNS_H */