iopvar.h revision 1.3 1 1.3 ad /* $NetBSD: iopvar.h,v 1.3 2000/12/03 13:17:03 ad Exp $ */
2 1.1 ad
3 1.1 ad /*-
4 1.1 ad * Copyright (c) 2000 The NetBSD Foundation, Inc.
5 1.1 ad * All rights reserved.
6 1.1 ad *
7 1.1 ad * This code is derived from software contributed to The NetBSD Foundation
8 1.1 ad * by Andrew Doran.
9 1.1 ad *
10 1.1 ad * Redistribution and use in source and binary forms, with or without
11 1.1 ad * modification, are permitted provided that the following conditions
12 1.1 ad * are met:
13 1.1 ad * 1. Redistributions of source code must retain the above copyright
14 1.1 ad * notice, this list of conditions and the following disclaimer.
15 1.1 ad * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 ad * notice, this list of conditions and the following disclaimer in the
17 1.1 ad * documentation and/or other materials provided with the distribution.
18 1.1 ad * 3. All advertising materials mentioning features or use of this software
19 1.1 ad * must display the following acknowledgement:
20 1.1 ad * This product includes software developed by the NetBSD
21 1.1 ad * Foundation, Inc. and its contributors.
22 1.1 ad * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1 ad * contributors may be used to endorse or promote products derived
24 1.1 ad * from this software without specific prior written permission.
25 1.1 ad *
26 1.1 ad * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1 ad * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1 ad * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1 ad * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.1 ad * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1 ad * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1 ad * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1 ad * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1 ad * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1 ad * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1 ad * POSSIBILITY OF SUCH DAMAGE.
37 1.1 ad */
38 1.1 ad
39 1.1 ad #ifndef _I2O_IOPVAR_H_
40 1.1 ad #define _I2O_IOPVAR_H_
41 1.1 ad
42 1.1 ad /* Per-IOP statistics; not particularly useful at the moment. */
43 1.1 ad struct iop_stat {
44 1.1 ad int is_cur_swqueue;
45 1.1 ad int is_peak_swqueue;
46 1.1 ad int is_cur_hwqueue;
47 1.1 ad int is_peak_hwqueue;
48 1.1 ad int64_t is_requests;
49 1.1 ad int64_t is_bytes;
50 1.1 ad };
51 1.1 ad
52 1.1 ad /*
53 1.1 ad * XXX The following should be adjusted if and when:
54 1.1 ad *
55 1.1 ad * o MAXPHYS exceeds 64kB.
56 1.1 ad * o A new message or reply is defined in i2o.h.
57 1.1 ad *
58 1.1 ad * As it stands, these make for a message frame of 200 bytes.
59 1.1 ad */
60 1.1 ad #define IOP_MAX_SGL_SIZE 132 /* Maximum S/G list size */
61 1.1 ad #define IOP_MAX_BASE_MSG_SIZE 68 /* Maximum base message size */
62 1.1 ad #define IOP_MAX_XFER 65536 /* Maximum transfer size */
63 1.1 ad #define IOP_MAX_MSG_XFERS 3 /* Maximum transfer count per msg */
64 1.1 ad
65 1.1 ad #define IOP_MAX_SGL_ENTRIES (IOP_MAX_SGL_SIZE / 8)
66 1.1 ad #define IOP_MAX_MSG_SIZE (IOP_MAX_BASE_MSG_SIZE + IOP_MAX_SGL_SIZE)
67 1.1 ad
68 1.3 ad /* Linux sez that some IOPs don't like reply frame sizes other than 128. */
69 1.3 ad #define IOP_MAX_REPLY_SIZE 128
70 1.3 ad
71 1.3 ad #define IOP_MAX_HW_QUEUECNT 256
72 1.3 ad #define IOP_MAX_HW_REPLYCNT 256
73 1.3 ad
74 1.3 ad #ifdef _KERNEL
75 1.3 ad
76 1.3 ad #include "locators.h"
77 1.3 ad
78 1.1 ad /*
79 1.1 ad * Transfer descriptor.
80 1.1 ad */
81 1.1 ad struct iop_xfer {
82 1.1 ad bus_dmamap_t ix_map;
83 1.1 ad u_int ix_size;
84 1.1 ad u_int ix_flags;
85 1.1 ad };
86 1.1 ad #define IX_IN 0x0001 /* Data transfer from IOP */
87 1.1 ad #define IX_OUT 0x0002 /* Data transfer to IOP */
88 1.1 ad
89 1.1 ad /*
90 1.1 ad * Message wrapper.
91 1.1 ad */
92 1.1 ad struct iop_msg {
93 1.1 ad SIMPLEQ_ENTRY(iop_msg) im_queue; /* Next queued message */
94 1.1 ad TAILQ_ENTRY(iop_msg) im_hash; /* Hash chain */
95 1.1 ad u_int im_flags; /* Control flags */
96 1.1 ad u_int im_tctx; /* Transaction context */
97 1.1 ad void *im_dvcontext; /* Un*x device context */
98 1.1 ad u_int32_t im_msg[IOP_MAX_MSG_SIZE / sizeof(u_int32_t)];
99 1.1 ad struct iop_xfer im_xfer[IOP_MAX_MSG_XFERS];
100 1.1 ad };
101 1.1 ad #define IM_SYSMASK 0x00ff
102 1.1 ad #define IM_REPLIED 0x0001 /* Message has been replied to */
103 1.1 ad #define IM_ALLOCED 0x0002 /* This message wrapper is allocated */
104 1.1 ad #define IM_SGLOFFADJ 0x0008 /* S/G list offset adjusted */
105 1.1 ad #define IM_DISCARD 0x0010 /* Discard message wrapper once sent */
106 1.3 ad #define IM_WAITING 0x0020 /* Waiting for completion */
107 1.1 ad
108 1.1 ad #define IM_USERMASK 0xff00
109 1.1 ad #define IM_NOWAIT 0x0100 /* Don't sleep when processing */
110 1.1 ad #define IM_NOICTX 0x0200 /* No initiator context field */
111 1.1 ad #define IM_NOINTR 0x0400 /* Don't interrupt when complete */
112 1.3 ad #define IM_NOSTATUS 0x0800 /* Don't check status if waiting */
113 1.1 ad
114 1.1 ad struct iop_initiator {
115 1.3 ad LIST_ENTRY(iop_initiator) ii_list;
116 1.3 ad LIST_ENTRY(iop_initiator) ii_hash;
117 1.3 ad
118 1.3 ad void (*ii_intr)(struct device *, struct iop_msg *, void *);
119 1.3 ad int (*ii_reconfig)(struct device *);
120 1.1 ad struct device *ii_dv;
121 1.1 ad int ii_flags;
122 1.3 ad int ii_ictx; /* Initiator context */
123 1.3 ad int ii_stctx; /* Static transaction context */
124 1.3 ad int ii_tid;
125 1.1 ad };
126 1.1 ad #define II_DISCARD 0x0001 /* Don't track state; discard msg wrappers */
127 1.3 ad #define II_CONFIGURED 0x0002 /* Already configured */
128 1.3 ad #define II_UTILITY 0x0004 /* Utility initiator (not a `real device') */
129 1.1 ad
130 1.1 ad #define IOP_ICTX 0
131 1.1 ad
132 1.3 ad struct iop_tidmap {
133 1.3 ad u_short it_tid;
134 1.3 ad u_short it_flags;
135 1.3 ad };
136 1.3 ad #define IT_CONFIGURED 0x02 /* target configured */
137 1.3 ad
138 1.1 ad /*
139 1.1 ad * Per-IOP context.
140 1.1 ad */
141 1.1 ad struct iop_softc {
142 1.1 ad struct device sc_dv; /* generic device data */
143 1.1 ad bus_space_handle_t sc_ioh; /* bus space handle */
144 1.1 ad bus_space_tag_t sc_iot; /* bus space tag */
145 1.1 ad bus_dma_tag_t sc_dmat; /* bus DMA tag */
146 1.1 ad void *sc_ih; /* interrupt handler cookie */
147 1.3 ad struct lock sc_conflock; /* autoconfiguration lock */
148 1.3 ad bus_addr_t sc_memaddr; /* register window address */
149 1.3 ad bus_size_t sc_memsize; /* register window size */
150 1.1 ad
151 1.1 ad struct i2o_hrt *sc_hrt; /* hardware resource table */
152 1.1 ad struct i2o_lct *sc_lct; /* logical configuration table */
153 1.1 ad int sc_nlctent; /* number of LCT entries */
154 1.3 ad struct iop_tidmap *sc_tidmap; /* tid map (per-lct-entry flags) */
155 1.1 ad struct i2o_status sc_status; /* status */
156 1.1 ad struct iop_stat sc_stat; /* counters */
157 1.1 ad int sc_flags; /* IOP-wide flags */
158 1.2 ad int sc_maxreplycnt; /* reply queue size */
159 1.3 ad u_int32_t sc_chgindicator;/* autoconfig vs. LCT change ind. */
160 1.3 ad LIST_HEAD(, iop_initiator) sc_iilist;/* initiator list */
161 1.1 ad SIMPLEQ_HEAD(,iop_msg) sc_queue;/* software queue */
162 1.1 ad int sc_maxqueuecnt; /* maximum # of msgs on h/w queue */
163 1.3 ad struct iop_initiator sc_eventii;/* IOP event handler */
164 1.3 ad struct proc *sc_reconf_proc;/* reconfiguration process */
165 1.1 ad
166 1.1 ad /*
167 1.1 ad * Reply queue.
168 1.1 ad */
169 1.1 ad bus_dmamap_t sc_rep_dmamap;
170 1.1 ad int sc_rep_size;
171 1.1 ad bus_addr_t sc_rep_phys;
172 1.1 ad caddr_t sc_rep;
173 1.1 ad };
174 1.1 ad #define IOP_OPEN 0x01 /* Device interface open */
175 1.3 ad #define IOP_HAVESTATUS 0x02 /* Successfully retrieved status */
176 1.3 ad #define IOP_ONLINE 0x04 /* Can use ioctl interface */
177 1.1 ad
178 1.1 ad struct iop_attach_args {
179 1.1 ad int ia_class; /* device class */
180 1.1 ad int ia_tid; /* target ID */
181 1.1 ad };
182 1.1 ad #define iopcf_tid cf_loc[IOPCF_TID] /* TID */
183 1.1 ad
184 1.3 ad void iop_init(struct iop_softc *, const char *);
185 1.1 ad int iop_intr(void *);
186 1.3 ad int iop_lct_get(struct iop_softc *);
187 1.3 ad int iop_param_op(struct iop_softc *, int, int, int, void *, int);
188 1.3 ad int iop_simple_cmd(struct iop_softc *, int, int, int, int, int);
189 1.3 ad void iop_strvis(struct iop_softc *, const char *, int, char *, int);
190 1.1 ad
191 1.1 ad int iop_initiator_register(struct iop_softc *, struct iop_initiator *);
192 1.1 ad void iop_initiator_unregister(struct iop_softc *, struct iop_initiator *);
193 1.1 ad
194 1.1 ad int iop_msg_alloc(struct iop_softc *, struct iop_initiator *,
195 1.1 ad struct iop_msg **, int);
196 1.3 ad int iop_msg_enqueue(struct iop_softc *, struct iop_msg *, int);
197 1.1 ad void iop_msg_free(struct iop_softc *, struct iop_initiator *,
198 1.1 ad struct iop_msg *);
199 1.1 ad int iop_msg_map(struct iop_softc *, struct iop_msg *, void *, int, int);
200 1.1 ad int iop_msg_send(struct iop_softc *, struct iop_msg *, int);
201 1.1 ad void iop_msg_unmap(struct iop_softc *, struct iop_msg *);
202 1.1 ad
203 1.3 ad int iop_util_abort(struct iop_softc *, struct iop_initiator *, int, int,
204 1.3 ad int);
205 1.3 ad int iop_util_claim(struct iop_softc *, struct iop_initiator *, int, int);
206 1.3 ad int iop_util_eventreg(struct iop_softc *, struct iop_initiator *, int);
207 1.1 ad
208 1.1 ad #endif /* _KERNEL */
209 1.3 ad
210 1.3 ad /*
211 1.3 ad * ioctl() interface.
212 1.3 ad */
213 1.3 ad
214 1.3 ad struct ioppt_buf {
215 1.3 ad void *ptb_data;
216 1.3 ad size_t ptb_datalen;
217 1.3 ad int ptb_out;
218 1.3 ad };
219 1.3 ad
220 1.3 ad struct ioppt {
221 1.3 ad void *pt_msg;
222 1.3 ad size_t pt_msglen;
223 1.3 ad void *pt_reply;
224 1.3 ad size_t pt_replylen;
225 1.3 ad int pt_timo;
226 1.3 ad int pt_nbufs;
227 1.3 ad struct ioppt_buf pt_bufs[IOP_MAX_MSG_XFERS];
228 1.3 ad };
229 1.3 ad
230 1.3 ad #define IOPIOCPT _IOWR('u', 0, struct ioppt)
231 1.3 ad #define IOPIOCGLCT _IOW('u', 1, struct iovec)
232 1.3 ad #define IOPIOCGSTATUS _IOW('u', 2, struct iovec)
233 1.3 ad #define IOPIOCRECONFIG _IO('u', 3)
234 1.1 ad
235 1.1 ad #endif /* !_I2O_IOPVAR_H_ */
236