xref: /netbsd-src/sys/dev/pci/ld_twa.c (revision afe4d516fc386ba882600d0b5cf1168105763a8d)
1a4dd1e26Swrstuden /*	$wasabi: ld_twa.c,v 1.9 2006/02/14 18:44:37 jordanr Exp $	*/
2*afe4d516Sjdolecek /*	$NetBSD: ld_twa.c,v 1.20 2017/02/27 21:32:33 jdolecek Exp $ */
3ab38c1f3Sad 
4a4dd1e26Swrstuden /*-
5ab38c1f3Sad  * Copyright (c) 2000, 2001, 2002, 2003, 2004 The NetBSD Foundation, Inc.
6a4dd1e26Swrstuden  * All rights reserved.
7a4dd1e26Swrstuden  *
8a4dd1e26Swrstuden  * This code is derived from software contributed to The NetBSD Foundation
9ab38c1f3Sad  * by Andrew Doran, and by Jason R. Thorpe and Jordan Rhody of Wasabi
10ab38c1f3Sad  * Systems, Inc.
11a4dd1e26Swrstuden  *
12a4dd1e26Swrstuden  * Redistribution and use in source and binary forms, with or without
13a4dd1e26Swrstuden  * modification, are permitted provided that the following conditions
14a4dd1e26Swrstuden  * are met:
15a4dd1e26Swrstuden  * 1. Redistributions of source code must retain the above copyright
16a4dd1e26Swrstuden  *    notice, this list of conditions and the following disclaimer.
17a4dd1e26Swrstuden  * 2. Redistributions in binary form must reproduce the above copyright
18a4dd1e26Swrstuden  *    notice, this list of conditions and the following disclaimer in the
19a4dd1e26Swrstuden  *    documentation and/or other materials provided with the distribution.
20a4dd1e26Swrstuden  *
21a4dd1e26Swrstuden  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
22a4dd1e26Swrstuden  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
23a4dd1e26Swrstuden  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24a4dd1e26Swrstuden  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
25a4dd1e26Swrstuden  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26a4dd1e26Swrstuden  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27a4dd1e26Swrstuden  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28a4dd1e26Swrstuden  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29a4dd1e26Swrstuden  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30a4dd1e26Swrstuden  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31a4dd1e26Swrstuden  * POSSIBILITY OF SUCH DAMAGE.
32a4dd1e26Swrstuden  */
33a4dd1e26Swrstuden 
34a4dd1e26Swrstuden /*
35a4dd1e26Swrstuden  * 3ware "Apache" RAID controller front-end for ld(4) driver.
36a4dd1e26Swrstuden  */
37a4dd1e26Swrstuden 
38a4dd1e26Swrstuden #include <sys/cdefs.h>
39*afe4d516Sjdolecek __KERNEL_RCSID(0, "$NetBSD: ld_twa.c,v 1.20 2017/02/27 21:32:33 jdolecek Exp $");
40a4dd1e26Swrstuden 
41a4dd1e26Swrstuden #include <sys/param.h>
42a4dd1e26Swrstuden #include <sys/systm.h>
43a4dd1e26Swrstuden #include <sys/kernel.h>
44a4dd1e26Swrstuden #include <sys/device.h>
45a4dd1e26Swrstuden #include <sys/buf.h>
46a4dd1e26Swrstuden #include <sys/bufq.h>
47a4dd1e26Swrstuden #include <sys/endian.h>
48a4dd1e26Swrstuden #include <sys/dkio.h>
49a4dd1e26Swrstuden #include <sys/disk.h>
50744a92f0Sad #include <sys/proc.h>
51916bdfa5Spgoyette #include <sys/module.h>
52a2a38285Sad #include <sys/bus.h>
53a4dd1e26Swrstuden 
54a4dd1e26Swrstuden #include <dev/ldvar.h>
55a4dd1e26Swrstuden 
56a4dd1e26Swrstuden #include <dev/scsipi/scsipi_all.h>
57a4dd1e26Swrstuden #include <dev/scsipi/scsipi_disk.h>
58a4dd1e26Swrstuden #include <dev/scsipi/scsipiconf.h>
59a4dd1e26Swrstuden #include <dev/scsipi/scsi_disk.h>
60a4dd1e26Swrstuden 
61a4dd1e26Swrstuden 
62a4dd1e26Swrstuden #include <dev/pci/pcireg.h>
63a4dd1e26Swrstuden #include <dev/pci/pcivar.h>
64a4dd1e26Swrstuden #include <dev/pci/twareg.h>
65a4dd1e26Swrstuden #include <dev/pci/twavar.h>
66a4dd1e26Swrstuden 
67916bdfa5Spgoyette #include "ioconf.h"
68916bdfa5Spgoyette 
69a4dd1e26Swrstuden struct ld_twa_softc {
70a4dd1e26Swrstuden 	struct	ld_softc sc_ld;
71a4dd1e26Swrstuden 	int	sc_hwunit;
72a4dd1e26Swrstuden };
73a4dd1e26Swrstuden 
74362b2f2bStron static void	ld_twa_attach(device_t, device_t, void *);
75362b2f2bStron static int	ld_twa_detach(device_t, int);
76ab38c1f3Sad static int	ld_twa_dobio(struct ld_twa_softc *, void *, size_t, daddr_t,
77a4dd1e26Swrstuden 			     struct buf *);
78a4dd1e26Swrstuden static int	ld_twa_dump(struct ld_softc *, void *, int, int);
79*afe4d516Sjdolecek static int	ld_twa_flush(struct ld_softc *, bool);
80*afe4d516Sjdolecek static int	ld_twa_ioctl(struct ld_softc *, u_long, void *, int32_t, bool);
81a4dd1e26Swrstuden static void	ld_twa_handler(struct twa_request *);
82362b2f2bStron static int	ld_twa_match(device_t, cfdata_t, void *);
83a4dd1e26Swrstuden static int	ld_twa_start(struct ld_softc *, struct buf *);
84a4dd1e26Swrstuden 
85362b2f2bStron static void	ld_twa_adjqparam(device_t, int);
86a4dd1e26Swrstuden 
87a4dd1e26Swrstuden static int ld_twa_scsicmd(struct ld_twa_softc *,
88a4dd1e26Swrstuden 	struct twa_request *, struct buf *);
89a4dd1e26Swrstuden 
90362b2f2bStron CFATTACH_DECL_NEW(ld_twa, sizeof(struct ld_twa_softc),
91a4dd1e26Swrstuden     ld_twa_match, ld_twa_attach, ld_twa_detach, NULL);
92a4dd1e26Swrstuden 
93a4dd1e26Swrstuden static const struct twa_callbacks ld_twa_callbacks = {
94a4dd1e26Swrstuden 	ld_twa_adjqparam,
95a4dd1e26Swrstuden };
96a4dd1e26Swrstuden 
97a4dd1e26Swrstuden static int
ld_twa_match(device_t parent,cfdata_t match,void * aux)98362b2f2bStron ld_twa_match(device_t parent, cfdata_t match, void *aux)
99a4dd1e26Swrstuden {
100a4dd1e26Swrstuden 
101a4dd1e26Swrstuden 	return (1);
102a4dd1e26Swrstuden }
103a4dd1e26Swrstuden 
104a4dd1e26Swrstuden static void
ld_twa_attach(device_t parent,device_t self,void * aux)105362b2f2bStron ld_twa_attach(device_t parent, device_t self, void *aux)
106a4dd1e26Swrstuden {
107362b2f2bStron 	struct twa_attach_args *twa_args = aux;
108362b2f2bStron 	struct ld_twa_softc *sc = device_private(self);
109362b2f2bStron 	struct ld_softc *ld = &sc->sc_ld;
110362b2f2bStron 	struct twa_softc *twa = device_private(parent);
111a4dd1e26Swrstuden 
112362b2f2bStron 	ld->sc_dv = self;
113a4dd1e26Swrstuden 
114a4dd1e26Swrstuden 	twa_register_callbacks(twa, twa_args->twaa_unit, &ld_twa_callbacks);
115a4dd1e26Swrstuden 
116a4dd1e26Swrstuden 	sc->sc_hwunit = twa_args->twaa_unit;
117a4dd1e26Swrstuden 	ld->sc_maxxfer = twa_get_maxxfer(twa_get_maxsegs());
118a4dd1e26Swrstuden 	ld->sc_secperunit = twa->sc_units[sc->sc_hwunit].td_size;
119a4dd1e26Swrstuden 	ld->sc_flags = LDF_ENABLED;
120a4dd1e26Swrstuden 	ld->sc_secsize = TWA_SECTOR_SIZE;
121d72a9bc7Sjoerg 	ld->sc_maxqueuecnt = twa->sc_units[sc->sc_hwunit].td_openings;
122a4dd1e26Swrstuden 	ld->sc_start = ld_twa_start;
123a4dd1e26Swrstuden 	ld->sc_dump = ld_twa_dump;
124*afe4d516Sjdolecek 	ld->sc_ioctl = ld_twa_ioctl;
125e90b5bddSjdolecek 	ldattach(ld, BUFQ_DISK_DEFAULT_STRAT);
126a4dd1e26Swrstuden }
127a4dd1e26Swrstuden 
128a4dd1e26Swrstuden static int
ld_twa_detach(device_t self,int flags)129362b2f2bStron ld_twa_detach(device_t self, int flags)
130a4dd1e26Swrstuden {
131362b2f2bStron 	struct ld_twa_softc *sc = device_private(self);
132362b2f2bStron 	struct ld_softc *ld = &sc->sc_ld;
133a4dd1e26Swrstuden 	int error;
134a4dd1e26Swrstuden 
135362b2f2bStron 	if ((error = ldbegindetach(ld, flags)) != 0)
136a4dd1e26Swrstuden 		return (error);
137362b2f2bStron 	ldenddetach(ld);
138a4dd1e26Swrstuden 
139a4dd1e26Swrstuden 	return (0);
140a4dd1e26Swrstuden }
141a4dd1e26Swrstuden 
142a4dd1e26Swrstuden static int
ld_twa_dobio(struct ld_twa_softc * sc,void * data,size_t datasize,daddr_t blkno,struct buf * bp)143ab38c1f3Sad ld_twa_dobio(struct ld_twa_softc *sc, void *data, size_t datasize,
144ab38c1f3Sad 	     daddr_t blkno, struct buf *bp)
145a4dd1e26Swrstuden {
146a4dd1e26Swrstuden 	int rv;
147a4dd1e26Swrstuden 	struct twa_request	*tr;
148a4dd1e26Swrstuden 	struct twa_softc *twa;
149a4dd1e26Swrstuden 
150362b2f2bStron 	twa = device_private(device_parent(sc->sc_ld.sc_dv));
151a4dd1e26Swrstuden 
152a4dd1e26Swrstuden 	if ((tr = twa_get_request(twa, 0)) == NULL) {
153a4dd1e26Swrstuden 		return (EAGAIN);
154a4dd1e26Swrstuden 	}
155a4dd1e26Swrstuden 	if (bp->b_flags & B_READ) {
156a4dd1e26Swrstuden 		tr->tr_flags = TWA_CMD_DATA_OUT;
157a4dd1e26Swrstuden 	} else {
158a4dd1e26Swrstuden 		tr->tr_flags = TWA_CMD_DATA_IN;
159a4dd1e26Swrstuden 	}
160a4dd1e26Swrstuden 
161a4dd1e26Swrstuden 	tr->tr_data = data;
162a4dd1e26Swrstuden 	tr->tr_length = datasize;
163a4dd1e26Swrstuden 	tr->tr_cmd_pkt_type =
164a4dd1e26Swrstuden 		(TWA_CMD_PKT_TYPE_9K | TWA_CMD_PKT_TYPE_EXTERNAL);
165a4dd1e26Swrstuden 
166a4dd1e26Swrstuden 	tr->tr_command->cmd_hdr.header_desc.size_header = 128;
167a4dd1e26Swrstuden 
168a4dd1e26Swrstuden 	tr->tr_command->command.cmd_pkt_9k.command.opcode =
169a4dd1e26Swrstuden 		TWA_OP_EXECUTE_SCSI_COMMAND;
170a4dd1e26Swrstuden 	tr->tr_command->command.cmd_pkt_9k.unit =
171a4dd1e26Swrstuden 		sc->sc_hwunit;
172a4dd1e26Swrstuden 	tr->tr_command->command.cmd_pkt_9k.request_id =
173a4dd1e26Swrstuden 		tr->tr_request_id;
174a4dd1e26Swrstuden 	tr->tr_command->command.cmd_pkt_9k.status = 0;
175a4dd1e26Swrstuden 	tr->tr_command->command.cmd_pkt_9k.sgl_entries = 1;
176a4dd1e26Swrstuden 	tr->tr_command->command.cmd_pkt_9k.sgl_offset = 16;
177a4dd1e26Swrstuden 
178a4dd1e26Swrstuden 	/* offset from end of hdr = max cdb len */
179a4dd1e26Swrstuden 	ld_twa_scsicmd(sc, tr, bp);
180a4dd1e26Swrstuden 
181a4dd1e26Swrstuden 	tr->tr_callback = ld_twa_handler;
182a4dd1e26Swrstuden 	tr->tr_ld_sc = sc;
183a4dd1e26Swrstuden 
184a4dd1e26Swrstuden 	tr->bp = bp;
185a4dd1e26Swrstuden 
186a4dd1e26Swrstuden 	rv = twa_map_request(tr);
187a4dd1e26Swrstuden 
188a4dd1e26Swrstuden 	return (rv);
189a4dd1e26Swrstuden }
190a4dd1e26Swrstuden 
191a4dd1e26Swrstuden static int
ld_twa_start(struct ld_softc * ld,struct buf * bp)192a4dd1e26Swrstuden ld_twa_start(struct ld_softc *ld, struct buf *bp)
193a4dd1e26Swrstuden {
194a4dd1e26Swrstuden 
195a4dd1e26Swrstuden 	return (ld_twa_dobio((struct ld_twa_softc *)ld, bp->b_data,
196a4dd1e26Swrstuden 	    bp->b_bcount, bp->b_rawblkno, bp));
197a4dd1e26Swrstuden }
198a4dd1e26Swrstuden 
199a4dd1e26Swrstuden static void
ld_twa_handler(struct twa_request * tr)200a4dd1e26Swrstuden ld_twa_handler(struct twa_request *tr)
201a4dd1e26Swrstuden {
202a4dd1e26Swrstuden 	uint8_t	status;
203a4dd1e26Swrstuden 	struct buf *bp;
204a4dd1e26Swrstuden 	struct ld_twa_softc *sc;
205a4dd1e26Swrstuden 
206a4dd1e26Swrstuden 	bp = tr->bp;
207a4dd1e26Swrstuden 	sc = (struct ld_twa_softc *)tr->tr_ld_sc;
208a4dd1e26Swrstuden 
209a4dd1e26Swrstuden 	status = tr->tr_command->command.cmd_pkt_9k.status;
210a4dd1e26Swrstuden 
211a4dd1e26Swrstuden 	if (status != 0) {
212a4dd1e26Swrstuden 		bp->b_error = EIO;
213a4dd1e26Swrstuden 		bp->b_resid = bp->b_bcount;
214a4dd1e26Swrstuden 	} else {
215a4dd1e26Swrstuden 		bp->b_resid = 0;
216a4dd1e26Swrstuden 		bp->b_error = 0;
217a4dd1e26Swrstuden 	}
218a4dd1e26Swrstuden 	twa_release_request(tr);
219a4dd1e26Swrstuden 
220a4dd1e26Swrstuden 	lddone(&sc->sc_ld, bp);
221a4dd1e26Swrstuden }
222a4dd1e26Swrstuden 
223a4dd1e26Swrstuden static int
ld_twa_dump(struct ld_softc * ld,void * data,int blkno,int blkcnt)224a4dd1e26Swrstuden ld_twa_dump(struct ld_softc *ld, void *data, int blkno, int blkcnt)
225a4dd1e26Swrstuden {
226a4dd1e26Swrstuden 
227ab38c1f3Sad #if 0
228ab38c1f3Sad 	/* XXX Unsafe right now. */
229a4dd1e26Swrstuden 	return (ld_twa_dobio((struct ld_twa_softc *)ld, data,
230a4dd1e26Swrstuden 	    blkcnt * ld->sc_secsize, blkno, NULL));
231ab38c1f3Sad #else
232ab38c1f3Sad 	return EIO;
233ab38c1f3Sad #endif
234ab38c1f3Sad 
235a4dd1e26Swrstuden }
236a4dd1e26Swrstuden 
237a4dd1e26Swrstuden 
238a4dd1e26Swrstuden static int
ld_twa_flush(struct ld_softc * ld,bool poll)239*afe4d516Sjdolecek ld_twa_flush(struct ld_softc *ld, bool poll)
240a4dd1e26Swrstuden {
241a4dd1e26Swrstuden 	int s, rv = 0;
242a4dd1e26Swrstuden 	struct twa_request *tr;
243362b2f2bStron 	struct twa_softc *twa = device_private(device_parent(ld->sc_dv));
244a4dd1e26Swrstuden 	struct ld_twa_softc *sc = (void *)ld;
245a4dd1e26Swrstuden 	struct twa_command_generic *generic_cmd;
246a4dd1e26Swrstuden 
247a4dd1e26Swrstuden 	/* Get a request packet. */
248a4dd1e26Swrstuden 	tr = twa_get_request_wait(twa, 0);
249a4dd1e26Swrstuden 	KASSERT(tr != NULL);
250a4dd1e26Swrstuden 
251a4dd1e26Swrstuden 	tr->tr_cmd_pkt_type =
252a4dd1e26Swrstuden 		(TWA_CMD_PKT_TYPE_9K | TWA_CMD_PKT_TYPE_EXTERNAL);
253a4dd1e26Swrstuden 
254a4dd1e26Swrstuden 	tr->tr_callback = twa_request_wait_handler;
255a4dd1e26Swrstuden 	tr->tr_ld_sc = sc;
256a4dd1e26Swrstuden 
257a4dd1e26Swrstuden 	tr->tr_command->cmd_hdr.header_desc.size_header = 128;
258a4dd1e26Swrstuden 
259a4dd1e26Swrstuden 	generic_cmd = &(tr->tr_command->command.cmd_pkt_7k.generic);
260a4dd1e26Swrstuden 	generic_cmd->opcode = TWA_OP_FLUSH;
261a4dd1e26Swrstuden 	generic_cmd->size = 2;
262a4dd1e26Swrstuden 	generic_cmd->unit = sc->sc_hwunit;
263a4dd1e26Swrstuden 	generic_cmd->request_id = tr->tr_request_id;
264a4dd1e26Swrstuden 	generic_cmd->sgl_offset = 0;
265a4dd1e26Swrstuden 	generic_cmd->host_id = 0;
266a4dd1e26Swrstuden 	generic_cmd->status = 0;
267a4dd1e26Swrstuden 	generic_cmd->flags = 0;
268a4dd1e26Swrstuden 	generic_cmd->count = 0;
269a4dd1e26Swrstuden 	rv = twa_map_request(tr);
270a4dd1e26Swrstuden 	s = splbio();
271a4dd1e26Swrstuden 	while (tr->tr_status != TWA_CMD_COMPLETE)
272a4dd1e26Swrstuden 		if ((rv = tsleep(tr, PRIBIO, "twaflush", 60 * hz)) != 0)
273a4dd1e26Swrstuden 			break;
274a4dd1e26Swrstuden 	twa_release_request(tr);
275a4dd1e26Swrstuden 	splx(s);
276a4dd1e26Swrstuden 
277a4dd1e26Swrstuden 	return (rv);
278a4dd1e26Swrstuden }
279a4dd1e26Swrstuden 
280*afe4d516Sjdolecek static int
ld_twa_ioctl(struct ld_softc * ld,u_long cmd,void * addr,int32_t flag,bool poll)281*afe4d516Sjdolecek ld_twa_ioctl(struct ld_softc *ld, u_long cmd, void *addr, int32_t flag, bool poll)
282*afe4d516Sjdolecek {
283*afe4d516Sjdolecek         int error;
284*afe4d516Sjdolecek 
285*afe4d516Sjdolecek         switch (cmd) {
286*afe4d516Sjdolecek         case DIOCCACHESYNC:
287*afe4d516Sjdolecek 		error = ld_twa_flush(ld, poll);
288*afe4d516Sjdolecek 		break;
289*afe4d516Sjdolecek 
290*afe4d516Sjdolecek 	default:
291*afe4d516Sjdolecek 		error = EPASSTHROUGH;
292*afe4d516Sjdolecek 		break;
293*afe4d516Sjdolecek 	}
294*afe4d516Sjdolecek 
295*afe4d516Sjdolecek 	return error;
296*afe4d516Sjdolecek }
297*afe4d516Sjdolecek 
298a4dd1e26Swrstuden static void
ld_twa_adjqparam(device_t self,int openings)299362b2f2bStron ld_twa_adjqparam(device_t self, int openings)
300a4dd1e26Swrstuden {
301362b2f2bStron 	struct ld_twa_softc *sc = device_private(self);
302362b2f2bStron 	struct ld_softc *ld = &sc->sc_ld;
303a4dd1e26Swrstuden 
304362b2f2bStron 	ldadjqparam(ld, openings);
305a4dd1e26Swrstuden }
306a4dd1e26Swrstuden 
307a4dd1e26Swrstuden 
308a4dd1e26Swrstuden static int
ld_twa_scsicmd(struct ld_twa_softc * sc,struct twa_request * tr,struct buf * bp)309a4dd1e26Swrstuden ld_twa_scsicmd(struct ld_twa_softc *sc,
310a4dd1e26Swrstuden 	struct twa_request *tr, struct buf *bp)
311a4dd1e26Swrstuden {
312a4dd1e26Swrstuden 	if (tr->tr_flags == TWA_CMD_DATA_IN) {
313a4dd1e26Swrstuden 		tr->tr_command->command.cmd_pkt_9k.cdb[0] = WRITE_16;
314a4dd1e26Swrstuden 	} else {
315a4dd1e26Swrstuden 		tr->tr_command->command.cmd_pkt_9k.cdb[0] = READ_16;
316a4dd1e26Swrstuden 	}
317a4dd1e26Swrstuden 	tr->tr_command->command.cmd_pkt_9k.cdb[1] =
318a4dd1e26Swrstuden 		(sc->sc_hwunit << 5);			/* lun for CDB */
319a4dd1e26Swrstuden 
320a4dd1e26Swrstuden 	_lto8b(htole64(bp->b_rawblkno),
321a4dd1e26Swrstuden 		&tr->tr_command->command.cmd_pkt_9k.cdb[2]);
322a4dd1e26Swrstuden 	_lto4b(htole32((bp->b_bcount / TWA_SECTOR_SIZE)),
323a4dd1e26Swrstuden 		&tr->tr_command->command.cmd_pkt_9k.cdb[10]);
324a4dd1e26Swrstuden 
325a4dd1e26Swrstuden 	tr->tr_command->command.cmd_pkt_9k.cdb[14] = 0;
326a4dd1e26Swrstuden 	tr->tr_command->command.cmd_pkt_9k.cdb[15] = 0;
327a4dd1e26Swrstuden 
328a4dd1e26Swrstuden 	return (0);
329a4dd1e26Swrstuden }
330916bdfa5Spgoyette 
331916bdfa5Spgoyette MODULE(MODULE_CLASS_DRIVER, ld_twa, "ld,twa");
332916bdfa5Spgoyette 
333916bdfa5Spgoyette #ifdef _MODULE
334916bdfa5Spgoyette /*
335916bdfa5Spgoyette  * XXX Don't allow ioconf.c to redefine the "struct cfdriver ld_cd"
336916bdfa5Spgoyette  * XXX it will be defined in the common-code module
337916bdfa5Spgoyette  */
338916bdfa5Spgoyette #undef  CFDRIVER_DECL
339916bdfa5Spgoyette #define CFDRIVER_DECL(name, class, attr)
340916bdfa5Spgoyette #include "ioconf.c"
341916bdfa5Spgoyette #endif
342916bdfa5Spgoyette 
343916bdfa5Spgoyette static int
ld_twa_modcmd(modcmd_t cmd,void * opaque)344916bdfa5Spgoyette ld_twa_modcmd(modcmd_t cmd, void *opaque)
345916bdfa5Spgoyette {
346916bdfa5Spgoyette #ifdef _MODULE
347916bdfa5Spgoyette 	/*
348916bdfa5Spgoyette 	 * We ignore the cfdriver_vec[] that ioconf provides, since
349916bdfa5Spgoyette 	 * the cfdrivers are attached already.
350916bdfa5Spgoyette 	 */
351916bdfa5Spgoyette 	static struct cfdriver * const no_cfdriver_vec[] = { NULL };
352916bdfa5Spgoyette #endif
353916bdfa5Spgoyette 	int error = 0;
354916bdfa5Spgoyette 
355916bdfa5Spgoyette #ifdef _MODULE
356916bdfa5Spgoyette 	switch (cmd) {
357916bdfa5Spgoyette 	case MODULE_CMD_INIT:
358916bdfa5Spgoyette 		error = config_init_component(no_cfdriver_vec,
359916bdfa5Spgoyette 		    cfattach_ioconf_ld_twa, cfdata_ioconf_ld_twa);
360916bdfa5Spgoyette 		break;
361916bdfa5Spgoyette 	case MODULE_CMD_FINI:
362916bdfa5Spgoyette 		error = config_fini_component(no_cfdriver_vec,
363916bdfa5Spgoyette 		    cfattach_ioconf_ld_twa, cfdata_ioconf_ld_twa);
364916bdfa5Spgoyette 		break;
365916bdfa5Spgoyette 	default:
366916bdfa5Spgoyette 		error = ENOTTY;
367916bdfa5Spgoyette 		break;
368916bdfa5Spgoyette 	}
369916bdfa5Spgoyette #endif
370916bdfa5Spgoyette 
371916bdfa5Spgoyette 	return error;
372916bdfa5Spgoyette }
373