mscp.c revision 1.10 1 1.9 ragge /* $NetBSD: mscp.c,v 1.10 1999/05/29 19:11:02 ragge Exp $ */
2 1.1 ragge
3 1.1 ragge /*
4 1.1 ragge * Copyright (c) 1996 Ludd, University of Lule}, Sweden.
5 1.1 ragge * Copyright (c) 1988 Regents of the University of California.
6 1.1 ragge * All rights reserved.
7 1.1 ragge *
8 1.1 ragge * This code is derived from software contributed to Berkeley by
9 1.1 ragge * Chris Torek.
10 1.1 ragge *
11 1.1 ragge * Redistribution and use in source and binary forms, with or without
12 1.1 ragge * modification, are permitted provided that the following conditions
13 1.1 ragge * are met:
14 1.1 ragge * 1. Redistributions of source code must retain the above copyright
15 1.1 ragge * notice, this list of conditions and the following disclaimer.
16 1.1 ragge * 2. Redistributions in binary form must reproduce the above copyright
17 1.1 ragge * notice, this list of conditions and the following disclaimer in the
18 1.1 ragge * documentation and/or other materials provided with the distribution.
19 1.1 ragge * 3. All advertising materials mentioning features or use of this software
20 1.1 ragge * must display the following acknowledgement:
21 1.1 ragge * This product includes software developed by the University of
22 1.1 ragge * California, Berkeley and its contributors.
23 1.1 ragge * 4. Neither the name of the University nor the names of its contributors
24 1.1 ragge * may be used to endorse or promote products derived from this software
25 1.1 ragge * without specific prior written permission.
26 1.1 ragge *
27 1.1 ragge * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
28 1.1 ragge * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 1.1 ragge * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 1.1 ragge * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
31 1.1 ragge * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
32 1.1 ragge * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
33 1.1 ragge * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
34 1.1 ragge * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 1.1 ragge * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
36 1.1 ragge * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
37 1.1 ragge * SUCH DAMAGE.
38 1.1 ragge *
39 1.1 ragge * @(#)mscp.c 7.5 (Berkeley) 12/16/90
40 1.1 ragge */
41 1.1 ragge
42 1.1 ragge /*
43 1.1 ragge * MSCP generic driver routines
44 1.1 ragge */
45 1.1 ragge
46 1.1 ragge #include <sys/param.h>
47 1.1 ragge #include <sys/buf.h>
48 1.1 ragge #include <sys/malloc.h>
49 1.1 ragge #include <sys/device.h>
50 1.8 ragge #include <sys/proc.h>
51 1.8 ragge #include <sys/systm.h>
52 1.1 ragge
53 1.1 ragge #include <vax/mscp/mscp.h>
54 1.1 ragge #include <vax/mscp/mscpvar.h>
55 1.1 ragge
56 1.7 ragge #define PCMD PSWP /* priority for command packet waits */
57 1.1 ragge
58 1.1 ragge /*
59 1.1 ragge * During transfers, mapping info is saved in the buffer's b_resid.
60 1.1 ragge */
61 1.7 ragge #define b_info b_resid
62 1.1 ragge
63 1.1 ragge /*
64 1.1 ragge * Get a command packet. Second argument is true iff we are
65 1.1 ragge * to wait if necessary. Return NULL if none are available and
66 1.1 ragge * we cannot wait.
67 1.1 ragge */
68 1.1 ragge struct mscp *
69 1.1 ragge mscp_getcp(mi, canwait)
70 1.1 ragge register struct mscp_softc *mi;
71 1.1 ragge int canwait;
72 1.1 ragge {
73 1.7 ragge #define mri (&mi->mi_cmd)
74 1.1 ragge register struct mscp *mp;
75 1.1 ragge register int i;
76 1.1 ragge int s = splbio();
77 1.1 ragge
78 1.1 ragge again:
79 1.1 ragge /*
80 1.1 ragge * Ensure that we have some command credits, and
81 1.1 ragge * that the next command packet is free.
82 1.1 ragge */
83 1.1 ragge if (mi->mi_credits <= MSCP_MINCREDITS) {
84 1.1 ragge if (!canwait) {
85 1.1 ragge splx(s);
86 1.1 ragge return (NULL);
87 1.1 ragge }
88 1.1 ragge mi->mi_wantcredits = 1;
89 1.1 ragge sleep((caddr_t) &mi->mi_wantcredits, PCMD);
90 1.1 ragge goto again;
91 1.1 ragge }
92 1.1 ragge i = mri->mri_next;
93 1.1 ragge if (mri->mri_desc[i] & MSCP_OWN) {
94 1.1 ragge if (!canwait) {
95 1.1 ragge splx(s);
96 1.1 ragge return (NULL);
97 1.1 ragge }
98 1.1 ragge mi->mi_wantcmd = 1;
99 1.1 ragge sleep((caddr_t) &mi->mi_wantcmd, PCMD);
100 1.1 ragge goto again;
101 1.1 ragge }
102 1.1 ragge mi->mi_credits--;
103 1.1 ragge mri->mri_desc[i] &= ~MSCP_INT;
104 1.1 ragge mri->mri_next = (mri->mri_next + 1) % mri->mri_size;
105 1.1 ragge splx(s);
106 1.1 ragge mp = &mri->mri_ring[i];
107 1.1 ragge
108 1.1 ragge /*
109 1.1 ragge * Initialise some often-zero fields.
110 1.1 ragge * ARE THE LAST TWO NECESSARY IN GENERAL? IT SURE WOULD BE
111 1.1 ragge * NICE IF DEC SOLD DOCUMENTATION FOR THEIR OWN CONTROLLERS.
112 1.1 ragge */
113 1.1 ragge mp->mscp_msglen = MSCP_MSGLEN;
114 1.1 ragge mp->mscp_flags = 0;
115 1.1 ragge mp->mscp_modifier = 0;
116 1.1 ragge mp->mscp_seq.seq_bytecount = 0;
117 1.1 ragge mp->mscp_seq.seq_buffer = 0;
118 1.1 ragge mp->mscp_seq.seq_mapbase = 0;
119 1.7 ragge /*???*/ mp->mscp_sccc.sccc_errlgfl = 0;
120 1.7 ragge /*???*/ mp->mscp_sccc.sccc_copyspd = 0;
121 1.1 ragge return (mp);
122 1.1 ragge #undef mri
123 1.1 ragge }
124 1.1 ragge
125 1.1 ragge #ifdef AVOID_EMULEX_BUG
126 1.1 ragge int mscp_aeb_xor = 0x8000bb80;
127 1.1 ragge #endif
128 1.1 ragge
129 1.1 ragge /*
130 1.1 ragge * Handle a response ring transition.
131 1.1 ragge */
132 1.1 ragge void
133 1.1 ragge mscp_dorsp(mi)
134 1.1 ragge register struct mscp_softc *mi;
135 1.1 ragge {
136 1.1 ragge struct device *drive;
137 1.1 ragge struct mscp_device *me = mi->mi_me;
138 1.1 ragge struct mscp_ctlr *mc = mi->mi_mc;
139 1.1 ragge register struct buf *bp;
140 1.1 ragge register struct mscp *mp;
141 1.1 ragge register int nextrsp;
142 1.1 ragge int st, error, info;
143 1.1 ragge extern int cold;
144 1.1 ragge extern struct mscp slavereply;
145 1.1 ragge
146 1.1 ragge nextrsp = mi->mi_rsp.mri_next;
147 1.1 ragge loop:
148 1.1 ragge if (mi->mi_rsp.mri_desc[nextrsp] & MSCP_OWN) {
149 1.1 ragge /*
150 1.1 ragge * No more responses. Remember the next expected
151 1.1 ragge * response index. Check to see if we have some
152 1.1 ragge * credits back, and wake up sleepers if so.
153 1.1 ragge */
154 1.1 ragge mi->mi_rsp.mri_next = nextrsp;
155 1.1 ragge if (mi->mi_wantcredits && mi->mi_credits > MSCP_MINCREDITS) {
156 1.1 ragge mi->mi_wantcredits = 0;
157 1.1 ragge wakeup((caddr_t) &mi->mi_wantcredits);
158 1.1 ragge }
159 1.1 ragge return;
160 1.1 ragge }
161 1.1 ragge
162 1.1 ragge mp = &mi->mi_rsp.mri_ring[nextrsp];
163 1.1 ragge mi->mi_credits += MSCP_CREDITS(mp->mscp_msgtc);
164 1.1 ragge /*
165 1.1 ragge * Controllers are allowed to interrupt as any drive, so we
166 1.1 ragge * must check the command before checking for a drive.
167 1.1 ragge */
168 1.1 ragge if (mp->mscp_opcode == (M_OP_SETCTLRC | M_OP_END)) {
169 1.1 ragge if ((mp->mscp_status & M_ST_MASK) == M_ST_SUCCESS) {
170 1.1 ragge mi->mi_flags |= MSC_READY;
171 1.1 ragge } else {
172 1.4 christos printf("%s: SETCTLRC failed: %d ",
173 1.1 ragge mi->mi_dev.dv_xname, mp->mscp_status);
174 1.1 ragge mscp_printevent(mp);
175 1.1 ragge }
176 1.1 ragge goto done;
177 1.1 ragge }
178 1.1 ragge
179 1.1 ragge /*
180 1.1 ragge * Found a response. Update credit information. If there is
181 1.1 ragge * nothing else to do, jump to `done' to get the next response.
182 1.1 ragge */
183 1.2 ragge if (mp->mscp_unit >= mi->mi_driveno) { /* Must expand drive table */
184 1.2 ragge int tmpno = ((mp->mscp_unit + 32) & 0xffe0) * sizeof(void *);
185 1.2 ragge struct device **tmp = (struct device **)
186 1.2 ragge malloc(tmpno, M_DEVBUF, M_NOWAIT);
187 1.2 ragge bzero(tmp, tmpno);
188 1.2 ragge if (mi->mi_driveno) {
189 1.2 ragge bcopy(mi->mi_dp, tmp, mi->mi_driveno);
190 1.2 ragge free(mi->mi_dp, mi->mi_driveno);
191 1.2 ragge }
192 1.2 ragge mi->mi_driveno = tmpno;
193 1.2 ragge mi->mi_dp = tmp;
194 1.2 ragge }
195 1.2 ragge
196 1.1 ragge drive = mi->mi_dp[mp->mscp_unit];
197 1.1 ragge
198 1.1 ragge switch (MSCP_MSGTYPE(mp->mscp_msgtc)) {
199 1.1 ragge
200 1.1 ragge case MSCPT_SEQ:
201 1.1 ragge break;
202 1.1 ragge
203 1.1 ragge case MSCPT_DATAGRAM:
204 1.2 ragge (*me->me_dgram)(drive, mp, mi);
205 1.1 ragge goto done;
206 1.1 ragge
207 1.1 ragge case MSCPT_CREDITS:
208 1.1 ragge goto done;
209 1.1 ragge
210 1.1 ragge case MSCPT_MAINTENANCE:
211 1.1 ragge default:
212 1.4 christos printf("%s: unit %d: unknown message type 0x%x ignored\n",
213 1.1 ragge mi->mi_dev.dv_xname, mp->mscp_unit,
214 1.1 ragge MSCP_MSGTYPE(mp->mscp_msgtc));
215 1.1 ragge goto done;
216 1.1 ragge }
217 1.1 ragge
218 1.1 ragge /*
219 1.1 ragge * Handle individual responses.
220 1.1 ragge */
221 1.1 ragge st = mp->mscp_status & M_ST_MASK;
222 1.1 ragge error = 0;
223 1.1 ragge switch (mp->mscp_opcode) {
224 1.1 ragge
225 1.1 ragge case M_OP_END:
226 1.1 ragge /*
227 1.1 ragge * The controller presents a bogus END packet when
228 1.1 ragge * a read/write command is given with an illegal
229 1.1 ragge * block number. This is contrary to the MSCP
230 1.1 ragge * specification (ENDs are to be given only for
231 1.1 ragge * invalid commands), but that is the way of it.
232 1.1 ragge */
233 1.1 ragge if (st == M_ST_INVALCMD && mp->mscp_cmdref != 0) {
234 1.4 christos printf("%s: bad lbn (%d)?\n", drive->dv_xname,
235 1.1 ragge (int)mp->mscp_seq.seq_lbn);
236 1.1 ragge error = EIO;
237 1.1 ragge goto rwend;
238 1.1 ragge }
239 1.1 ragge goto unknown;
240 1.1 ragge
241 1.1 ragge case M_OP_ONLINE | M_OP_END:
242 1.1 ragge /*
243 1.7 ragge * Finished an ON LINE request. Call the driver to
244 1.1 ragge * find out whether it succeeded. If so, mark it on
245 1.1 ragge * line.
246 1.1 ragge */
247 1.1 ragge (*me->me_online)(drive, mp);
248 1.1 ragge break;
249 1.1 ragge
250 1.1 ragge case M_OP_GETUNITST | M_OP_END:
251 1.1 ragge /*
252 1.1 ragge * Got unit status. If we are autoconfiguring, save
253 1.1 ragge * the mscp struct so that mscp_attach know what to do.
254 1.1 ragge * If the drive isn't configured, call config_found()
255 1.1 ragge * to set it up, otherwise it's just a "normal" unit
256 1.1 ragge * status.
257 1.1 ragge */
258 1.1 ragge if (cold)
259 1.1 ragge bcopy(mp, &slavereply, sizeof(struct mscp));
260 1.1 ragge
261 1.2 ragge if (mp->mscp_status == (M_ST_OFFLINE|M_OFFLINE_UNKNOWN))
262 1.2 ragge break;
263 1.2 ragge
264 1.1 ragge if (drive == 0) {
265 1.1 ragge struct drive_attach_args da;
266 1.1 ragge
267 1.1 ragge da.da_mp = (struct mscp *)mp;
268 1.2 ragge da.da_typ = mi->mi_type;
269 1.1 ragge config_found(&mi->mi_dev, (void *)&da, mscp_print);
270 1.1 ragge } else
271 1.2 ragge /* Hack to avoid complaints */
272 1.2 ragge if (!(((mp->mscp_event & M_ST_MASK) == M_ST_AVAILABLE)
273 1.2 ragge && cold))
274 1.2 ragge (*me->me_gotstatus)(drive, mp);
275 1.1 ragge break;
276 1.1 ragge
277 1.1 ragge case M_OP_AVAILATTN:
278 1.1 ragge /*
279 1.1 ragge * The drive went offline and we did not notice.
280 1.1 ragge * Mark it off line now, to force an on line request
281 1.1 ragge * next, so we can make sure it is still the same
282 1.1 ragge * drive.
283 1.1 ragge *
284 1.1 ragge * IF THE UDA DRIVER HAS A COMMAND AWAITING UNIBUS
285 1.1 ragge * RESOURCES, THAT COMMAND MAY GO OUT BEFORE THE ON
286 1.1 ragge * LINE. IS IT WORTH FIXING??
287 1.1 ragge */
288 1.1 ragge #ifdef notyet
289 1.1 ragge (*md->md_offline)(ui, mp);
290 1.1 ragge #endif
291 1.1 ragge break;
292 1.1 ragge
293 1.2 ragge case M_OP_POS | M_OP_END:
294 1.2 ragge case M_OP_WRITM | M_OP_END:
295 1.9 ragge case M_OP_AVAILABLE | M_OP_END:
296 1.2 ragge /*
297 1.2 ragge * A non-data transfer operation completed.
298 1.2 ragge */
299 1.2 ragge (*me->me_cmddone)(drive, mp);
300 1.2 ragge break;
301 1.2 ragge
302 1.1 ragge case M_OP_READ | M_OP_END:
303 1.1 ragge case M_OP_WRITE | M_OP_END:
304 1.1 ragge /*
305 1.7 ragge * A transfer finished. Get the buffer, and release its
306 1.7 ragge * map registers via ubadone(). If the command finished
307 1.1 ragge * with an off line or available status, the drive went
308 1.1 ragge * off line (the idiot controller does not tell us until
309 1.1 ragge * it comes back *on* line, or until we try to use it).
310 1.1 ragge */
311 1.6 ragge rwend:
312 1.5 ragge #ifdef DIAGNOSTIC
313 1.1 ragge if (mp->mscp_cmdref == 0) {
314 1.1 ragge /*
315 1.1 ragge * No buffer means there is a bug somewhere!
316 1.1 ragge */
317 1.4 christos printf("%s: io done, but no buffer?\n",
318 1.1 ragge drive->dv_xname);
319 1.1 ragge mscp_hexdump(mp);
320 1.1 ragge break;
321 1.1 ragge }
322 1.5 ragge #endif
323 1.1 ragge bp = (struct buf *) mp->mscp_cmdref;
324 1.1 ragge
325 1.6 ragge if (mp->mscp_cmdref == -1) {
326 1.6 ragge (*me->me_cmddone)(drive, mp);
327 1.6 ragge break;
328 1.6 ragge }
329 1.1 ragge /*
330 1.1 ragge * Mark any error-due-to-bad-LBN (via `goto rwend').
331 1.7 ragge * WHAT STATUS WILL THESE HAVE? IT SURE WOULD BE NICE
332 1.1 ragge * IF DEC SOLD DOCUMENTATION FOR THEIR OWN CONTROLLERS.
333 1.1 ragge */
334 1.1 ragge if (error) {
335 1.1 ragge bp->b_flags |= B_ERROR;
336 1.1 ragge bp->b_error = error;
337 1.1 ragge }
338 1.1 ragge if (st == M_ST_OFFLINE || st == M_ST_AVAILABLE) {
339 1.1 ragge #ifdef notyet
340 1.1 ragge (*md->md_offline)(ui, mp);
341 1.1 ragge #endif
342 1.1 ragge }
343 1.1 ragge
344 1.1 ragge /*
345 1.1 ragge * Unlink the transfer from the wait queue.
346 1.1 ragge */
347 1.2 ragge _remque(&bp->b_actf);
348 1.1 ragge
349 1.1 ragge /*
350 1.1 ragge * If the transfer has something to do with bad
351 1.1 ragge * block forwarding, let the driver handle the
352 1.1 ragge * rest.
353 1.1 ragge */
354 1.1 ragge if ((bp->b_flags & B_BAD) != 0 && me->me_bb != NULL) {
355 1.1 ragge (*me->me_bb)(drive, mp, bp);
356 1.1 ragge goto out;
357 1.1 ragge }
358 1.1 ragge
359 1.1 ragge /*
360 1.1 ragge * If the transfer failed, give the driver a crack
361 1.1 ragge * at fixing things up.
362 1.1 ragge */
363 1.1 ragge if (st != M_ST_SUCCESS) {
364 1.1 ragge switch ((*me->me_ioerr)(drive, mp, bp)) {
365 1.1 ragge
366 1.1 ragge case MSCP_DONE: /* fixed */
367 1.1 ragge break;
368 1.1 ragge
369 1.1 ragge case MSCP_RESTARTED: /* still working on it */
370 1.1 ragge goto out;
371 1.1 ragge
372 1.1 ragge case MSCP_FAILED: /* no luck */
373 1.1 ragge /* XXX must move to ra.c */
374 1.1 ragge mscp_printevent(mp);
375 1.1 ragge break;
376 1.1 ragge }
377 1.1 ragge }
378 1.1 ragge
379 1.1 ragge /*
380 1.1 ragge * Set the residual count and mark the transfer as
381 1.1 ragge * done. If the I/O wait queue is now empty, release
382 1.1 ragge * the shared BDP, if any.
383 1.1 ragge */
384 1.1 ragge info = bp->b_info; /* we are about to clobber it */
385 1.1 ragge bp->b_resid = bp->b_bcount - mp->mscp_seq.seq_bytecount;
386 1.1 ragge
387 1.1 ragge (*mc->mc_ctlrdone)(mi->mi_dev.dv_parent, info);
388 1.1 ragge (*me->me_iodone)(drive, bp);
389 1.1 ragge out:
390 1.1 ragge break;
391 1.1 ragge
392 1.1 ragge case M_OP_REPLACE | M_OP_END:
393 1.1 ragge /*
394 1.1 ragge * A replace operation finished. Just let the driver
395 1.1 ragge * handle it (if it does replaces).
396 1.1 ragge */
397 1.1 ragge if (me->me_replace == NULL)
398 1.4 christos printf("%s: bogus REPLACE end\n", drive->dv_xname);
399 1.1 ragge else
400 1.1 ragge (*me->me_replace)(drive, mp);
401 1.1 ragge break;
402 1.1 ragge
403 1.1 ragge default:
404 1.1 ragge /*
405 1.1 ragge * If it is not one of the above, we cannot handle it.
406 1.1 ragge * (And we should not have received it, for that matter.)
407 1.1 ragge */
408 1.1 ragge unknown:
409 1.4 christos printf("%s: unknown opcode 0x%x status 0x%x ignored\n",
410 1.1 ragge drive->dv_xname, mp->mscp_opcode, mp->mscp_status);
411 1.5 ragge #ifdef DIAGNOSTIC
412 1.1 ragge mscp_hexdump(mp);
413 1.5 ragge #endif
414 1.1 ragge break;
415 1.1 ragge }
416 1.1 ragge
417 1.1 ragge /*
418 1.1 ragge * If the drive needs to be put back in the controller queue,
419 1.7 ragge * do that now. (`bp' below ought to be `dp', but they are all
420 1.1 ragge * struct buf *.) Note that b_active was cleared in the driver;
421 1.1 ragge * we presume that there is something to be done, hence reassert it.
422 1.1 ragge */
423 1.1 ragge #ifdef notyet /* XXX */
424 1.1 ragge if (ui->ui_flags & UNIT_REQUEUE) {
425 1.1 ragge bp = &md->md_utab[ui->ui_unit];
426 1.1 ragge if (bp->b_active) panic("mscp_dorsp requeue");
427 1.1 ragge MSCP_APPEND(bp, mi->mi_XXXtab, b_hash.le_next);
428 1.1 ragge /* Was: MSCP_APPEND(bp, mi->mi_XXXtab, b_forw); */
429 1.1 ragge bp->b_active = 1;
430 1.1 ragge ui->ui_flags &= ~UNIT_REQUEUE;
431 1.1 ragge }
432 1.1 ragge #endif
433 1.1 ragge done:
434 1.1 ragge /*
435 1.1 ragge * Give back the response packet, and take a look at the next.
436 1.1 ragge */
437 1.1 ragge mp->mscp_msglen = MSCP_MSGLEN;
438 1.1 ragge mi->mi_rsp.mri_desc[nextrsp] |= MSCP_OWN;
439 1.1 ragge nextrsp = (nextrsp + 1) % mi->mi_rsp.mri_size;
440 1.1 ragge goto loop;
441 1.1 ragge }
442 1.1 ragge
443 1.1 ragge /*
444 1.1 ragge * Requeue outstanding transfers, e.g., after bus reset.
445 1.1 ragge * Also requeue any drives that have on line or unit status
446 1.1 ragge * info pending.
447 1.1 ragge */
448 1.1 ragge void
449 1.1 ragge mscp_requeue(mi)
450 1.1 ragge struct mscp_softc *mi;
451 1.1 ragge {
452 1.8 ragge #if 0
453 1.1 ragge register struct mscp_device *me = mi->mi_me;
454 1.1 ragge register struct buf *bp, *dp;
455 1.1 ragge register int unit;
456 1.1 ragge struct buf *nextbp;
457 1.8 ragge #endif
458 1.1 ragge
459 1.1 ragge panic("mscp_requeue");
460 1.1 ragge /*
461 1.7 ragge * Clear the controller chain. Mark everything un-busy; we
462 1.1 ragge * will soon fix any that are in fact busy.
463 1.1 ragge */
464 1.1 ragge #ifdef notyet /* XXX */
465 1.1 ragge mi->mi_XXXtab->b_actf = NULL;
466 1.1 ragge mi->mi_XXXtab->b_active = 0;
467 1.1 ragge for (unit = 0, dp = md->md_utab; unit < md->md_nunits; unit++, dp++) {
468 1.1 ragge ui = md->md_dinfo[unit];
469 1.1 ragge if (ui == NULL || !ui->ui_alive || ui->ui_ctlr != mi->mi_ctlr)
470 1.1 ragge continue; /* not ours */
471 1.1 ragge dp->b_hash.le_next = NULL;
472 1.1 ragge dp->b_active = 0;
473 1.1 ragge }
474 1.1 ragge /*
475 1.1 ragge * Scan the wait queue, linking buffers onto drive queues.
476 1.1 ragge * Note that these must be put at the front of the drive queue,
477 1.1 ragge * lest we reorder I/O operations.
478 1.1 ragge */
479 1.1 ragge for (bp = *mi->mi_XXXwtab.b_actb; bp != &mi->mi_XXXwtab; bp = nextbp) {
480 1.1 ragge nextbp = *bp->b_actb;
481 1.1 ragge dp = &md->md_utab[minor(bp->b_dev) >> md->md_unitshift];
482 1.1 ragge bp->b_actf = dp->b_actf;
483 1.1 ragge if (dp->b_actf == NULL)
484 1.1 ragge dp->b_actb = (void *)bp;
485 1.1 ragge dp->b_actf = bp;
486 1.1 ragge }
487 1.1 ragge mi->mi_XXXwtab.b_actf = *mi->mi_XXXwtab.b_actb = &mi->mi_XXXwtab;
488 1.1 ragge
489 1.1 ragge /*
490 1.1 ragge * Scan for drives waiting for on line or status responses,
491 1.1 ragge * and for drives with pending transfers. Put these on the
492 1.1 ragge * controller queue, and mark the controller busy.
493 1.1 ragge */
494 1.1 ragge for (unit = 0, dp = md->md_utab; unit < md->md_nunits; unit++, dp++) {
495 1.1 ragge ui = md->md_dinfo[unit];
496 1.1 ragge if (ui == NULL || !ui->ui_alive || ui->ui_ctlr != mi->mi_ctlr)
497 1.1 ragge continue;
498 1.1 ragge ui->ui_flags &= ~(UNIT_HAVESTATUS | UNIT_ONLINE);
499 1.1 ragge if ((ui->ui_flags & UNIT_REQUEUE) == 0 && dp->b_actf == NULL)
500 1.1 ragge continue;
501 1.1 ragge ui->ui_flags &= ~UNIT_REQUEUE;
502 1.1 ragge MSCP_APPEND(dp, mi->mi_XXXtab, b_hash.le_next);
503 1.1 ragge
504 1.1 ragge dp->b_active = 1;
505 1.1 ragge mi->mi_XXXtab->b_active = 1;
506 1.1 ragge }
507 1.1 ragge
508 1.1 ragge #endif
509 1.1 ragge #ifdef AVOID_EMULEX_BUG
510 1.1 ragge /*
511 1.1 ragge * ... and clear the index-to-buffer table.
512 1.1 ragge */
513 1.1 ragge for (unit = 0; unit < AEB_MAX_BP; unit++)
514 1.1 ragge mi->mi_bp[unit] = 0;
515 1.1 ragge #endif
516 1.1 ragge }
517 1.1 ragge
518