nrelease - fix/improve livecd
[dragonfly.git] / sys / dev / raid / tws / tws_services.h
1 /*
2  * Copyright (c) 2010, LSI Corp.
3  * All rights reserved.
4  * Author : Manjunath Ranganathaiah
5  * Support: freebsdraid@lsi.com
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  *
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
15  *    the documentation and/or other materials provided with the
16  *    distribution.
17  * 3. Neither the name of the <ORGANIZATION> nor the names of its
18  *    contributors may be used to endorse or promote products derived
19  *    from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32  * POSSIBILITY OF SUCH DAMAGE.
33  *
34  * $FreeBSD: src/sys/dev/tws/tws_services.h,v 1.3 2007/05/09 04:16:32 mrangana Exp $
35  */
36
37
38 /* #define TWS_DEBUG on */
39
40 void tws_trace(const char *file, const char *fun, int linenum,
41          struct tws_softc *sc,  char *desc, u_int64_t val1, u_int64_t val2);
42 void tws_log(struct tws_softc *sc, int index);
43 u_int32_t tws_read_reg(struct tws_softc *sc,
44                   int offset, int size);
45 void tws_write_reg(struct tws_softc *sc, int offset,
46                   u_int32_t value, int size);
47
48 u_int16_t tws_swap16(u_int16_t val);
49 u_int32_t tws_swap32(u_int32_t val);
50 u_int64_t tws_swap64(u_int64_t val);
51
52 void tws_init_qs(struct tws_softc *sc);
53
54
55
56 /* ----------------- trace ----------------- */
57
58 #define TWS_TRACE_ON on /* Alawys on - use wisely to trace errors */
59
60 #ifdef TWS_DEBUG
61     #define TWS_TRACE_DEBUG_ON on
62 #endif
63
64 #ifdef TWS_TRACE_DEBUG_ON
65     #define TWS_TRACE_DEBUG(sc, desc, val1, val2) \
66             tws_trace(__FILE__, __func__, __LINE__, sc, desc, \
67                                    (u_int64_t)val1, (u_int64_t)val2)
68 #else
69     #define TWS_TRACE_DEBUG(sc, desc, val1, val2) do { } while (0)
70 #endif
71
72 #ifdef TWS_TRACE_ON
73     #define TWS_TRACE(sc, desc, val1, val2) \
74             tws_trace(__FILE__, __func__, __LINE__, sc, desc, \
75                                    (u_int64_t)val1, (u_int64_t)val2)
76 #else
77     #define TWS_TRACE(sc, desc, val1, val2)     do { } while (0)
78 #endif
79
80 /* ---------------- logging ---------------- */
81
82
83 /* ---------------- logging ---------------- */
84 enum error_index {
85     SYSCTL_TREE_NODE_ADD,
86     PCI_COMMAND_READ,
87     ALLOC_MEMORY_RES,
88     ALLOC_IRQ_RES,
89     SETUP_INTR_RES,
90     TWS_CAM_ATTACH,
91     CAM_SIMQ_ALLOC,
92     CAM_SIM_ALLOC,
93     TWS_XPT_BUS_REGISTER,
94     TWS_XPT_CREATE_PATH,
95     TWS_BUS_SCAN_REQ,
96     TWS_INIT_FAILURE,
97     TWS_CTLR_INIT_FAILURE,
98 };
99
100 enum severity {
101     ERROR = 1,
102     WARNING,
103     INFO,
104     _DEBUG,                     /* XXX swildner: conflict with DEBUG option */
105 };
106
107 struct error_desc {
108     char desc[256];
109     u_int32_t error_code;
110     int severity_level;
111     char *fmt;
112     char *error_str;
113 };
114
115 extern struct error_desc array[];
116 /* ----------- q services ------------- */
117
118 #define TWS_FREE_Q        0
119 #define TWS_PENDING_Q     1
120 #define TWS_BUSY_Q        2
121 #define TWS_COMPLETE_Q    3
122
123 #define TWS_REQ_SUBMIT_SUCCESS 0
124 /* req error codes */
125 #define TWS_REQ_ERR_INPROGRESS 1
126 #define TWS_REQ_ERR_PEND_NOMFA 2
127 #define TWS_REQ_REQUEUE        3
128
129 #define TWS_REQ_ERR_INVALID    0xdead
130
131
132 /* ------------------------ */
133 #define TWS_LOCAL_TIME          time_uptime