1/*-
2 * Implementation of SCSI Direct Access Peripheral driver for CAM.
3 *
4 * Copyright (c) 1997 Justin T. Gibbs.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
--- 13 unchanged lines hidden (view full) ---
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/sys/cam/scsi/scsi_da.c 237478 2012-06-23 12:32:53Z mav $");
31
32#include <sys/param.h>
33
34#ifdef _KERNEL
35#include <sys/systm.h>
36#include <sys/kernel.h>
37#include <sys/bio.h>
38#include <sys/sysctl.h>
--- 1189 unchanged lines hidden (view full) ---
1228
1229 /* Register our shutdown event handler */
1230 if ((EVENTHANDLER_REGISTER(shutdown_post_sync, dashutdown,
1231 NULL, SHUTDOWN_PRI_DEFAULT)) == NULL)
1232 printf("dainit: shutdown event registration failed!\n");
1233 }
1234}
1235
1236static void
1237daoninvalidate(struct cam_periph *periph)
1238{
1239 struct da_softc *softc;
1240
1241 softc = (struct da_softc *)periph->softc;
1242
1243 /*
1244 * De-register any async callbacks.
--- 5 unchanged lines hidden (view full) ---
1250 /*
1251 * Return all queued I/O with ENXIO.
1252 * XXX Handle any transactions queued to the card
1253 * with XPT_ABORT_CCB.
1254 */
1255 bioq_flush(&softc->bio_queue, NULL, ENXIO);
1256 bioq_flush(&softc->delete_queue, NULL, ENXIO);
1257
1258 disk_gone(softc->disk);
1259 xpt_print(periph->path, "lost device - %d outstanding, %d refs\n",
1260 softc->outstanding_cmds, periph->refcount);
1261}
1262
1263static void
1264dacleanup(struct cam_periph *periph)
1265{
1266 struct da_softc *softc;
--- 361 unchanged lines hidden (view full) ---
1628 SID_TYPE(&cgd->inq_data) |
1629 XPORT_DEVSTAT_TYPE(cpi.transport),
1630 DEVSTAT_PRIORITY_DISK);
1631 softc->disk->d_open = daopen;
1632 softc->disk->d_close = daclose;
1633 softc->disk->d_strategy = dastrategy;
1634 softc->disk->d_dump = dadump;
1635 softc->disk->d_getattr = dagetattr;
1636 softc->disk->d_name = "da";
1637 softc->disk->d_drv1 = periph;
1638 if (cpi.maxio == 0)
1639 softc->disk->d_maxsize = DFLTPHYS; /* traditional default */
1640 else if (cpi.maxio > MAXPHYS)
1641 softc->disk->d_maxsize = MAXPHYS; /* for safety */
1642 else
1643 softc->disk->d_maxsize = cpi.maxio;
--- 6 unchanged lines hidden (view full) ---
1650 strlcat(softc->disk->d_descr, " ", sizeof(softc->disk->d_descr));
1651 cam_strvis(&softc->disk->d_descr[strlen(softc->disk->d_descr)],
1652 cgd->inq_data.product, sizeof(cgd->inq_data.product),
1653 sizeof(softc->disk->d_descr) - strlen(softc->disk->d_descr));
1654 softc->disk->d_hba_vendor = cpi.hba_vendor;
1655 softc->disk->d_hba_device = cpi.hba_device;
1656 softc->disk->d_hba_subvendor = cpi.hba_subvendor;
1657 softc->disk->d_hba_subdevice = cpi.hba_subdevice;
1658 disk_create(softc->disk, DISK_VERSION);
1659 mtx_lock(periph->sim->mtx);
1660
1661 /*
1662 * Add async callbacks for events of interest.
1663 * I don't bother checking if this fails as,
1664 * in most cases, the system will function just
1665 * fine without them and the only alternative
--- 1057 unchanged lines hidden ---
2 * Implementation of SCSI Direct Access Peripheral driver for CAM.
3 *
4 * Copyright (c) 1997 Justin T. Gibbs.
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
--- 13 unchanged lines hidden (view full) ---
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * SUCH DAMAGE.
27 */
28
29#include <sys/cdefs.h>
30__FBSDID("$FreeBSD: head/sys/cam/scsi/scsi_da.c 237478 2012-06-23 12:32:53Z mav $");
31
32#include <sys/param.h>
33
34#ifdef _KERNEL
35#include <sys/systm.h>
36#include <sys/kernel.h>
37#include <sys/bio.h>
38#include <sys/sysctl.h>
--- 1189 unchanged lines hidden (view full) ---
1228
1229 /* Register our shutdown event handler */
1230 if ((EVENTHANDLER_REGISTER(shutdown_post_sync, dashutdown,
1231 NULL, SHUTDOWN_PRI_DEFAULT)) == NULL)
1232 printf("dainit: shutdown event registration failed!\n");
1233 }
1234}
1235
1236static void
1237daoninvalidate(struct cam_periph *periph)
1238{
1239 struct da_softc *softc;
1240
1241 softc = (struct da_softc *)periph->softc;
1242
1243 /*
1244 * De-register any async callbacks.
--- 5 unchanged lines hidden (view full) ---
1250 /*
1251 * Return all queued I/O with ENXIO.
1252 * XXX Handle any transactions queued to the card
1253 * with XPT_ABORT_CCB.
1254 */
1255 bioq_flush(&softc->bio_queue, NULL, ENXIO);
1256 bioq_flush(&softc->delete_queue, NULL, ENXIO);
1257
1258 disk_gone(softc->disk);
1259 xpt_print(periph->path, "lost device - %d outstanding, %d refs\n",
1260 softc->outstanding_cmds, periph->refcount);
1261}
1262
1263static void
1264dacleanup(struct cam_periph *periph)
1265{
1266 struct da_softc *softc;
--- 361 unchanged lines hidden (view full) ---
1628 SID_TYPE(&cgd->inq_data) |
1629 XPORT_DEVSTAT_TYPE(cpi.transport),
1630 DEVSTAT_PRIORITY_DISK);
1631 softc->disk->d_open = daopen;
1632 softc->disk->d_close = daclose;
1633 softc->disk->d_strategy = dastrategy;
1634 softc->disk->d_dump = dadump;
1635 softc->disk->d_getattr = dagetattr;
1636 softc->disk->d_name = "da";
1637 softc->disk->d_drv1 = periph;
1638 if (cpi.maxio == 0)
1639 softc->disk->d_maxsize = DFLTPHYS; /* traditional default */
1640 else if (cpi.maxio > MAXPHYS)
1641 softc->disk->d_maxsize = MAXPHYS; /* for safety */
1642 else
1643 softc->disk->d_maxsize = cpi.maxio;
--- 6 unchanged lines hidden (view full) ---
1650 strlcat(softc->disk->d_descr, " ", sizeof(softc->disk->d_descr));
1651 cam_strvis(&softc->disk->d_descr[strlen(softc->disk->d_descr)],
1652 cgd->inq_data.product, sizeof(cgd->inq_data.product),
1653 sizeof(softc->disk->d_descr) - strlen(softc->disk->d_descr));
1654 softc->disk->d_hba_vendor = cpi.hba_vendor;
1655 softc->disk->d_hba_device = cpi.hba_device;
1656 softc->disk->d_hba_subvendor = cpi.hba_subvendor;
1657 softc->disk->d_hba_subdevice = cpi.hba_subdevice;
1658 disk_create(softc->disk, DISK_VERSION);
1659 mtx_lock(periph->sim->mtx);
1660
1661 /*
1662 * Add async callbacks for events of interest.
1663 * I don't bother checking if this fails as,
1664 * in most cases, the system will function just
1665 * fine without them and the only alternative
--- 1057 unchanged lines hidden ---