Lines Matching refs:softc

371 #define	SA_PROT_ENABLED(softc) ((softc->flags & SA_FLAG_PROTECT_SUPP)	\  argument
372 && (softc->prot_info.cur_prot_state.initialized != 0) \
373 && (softc->prot_info.cur_prot_state.prot_method != 0))
375 #define SA_PROT_LEN(softc) softc->prot_info.cur_prot_state.pi_length argument
626 static void safillprot(struct sa_softc *softc, int *indent,
640 static int saparamget(struct sa_softc *softc, struct sbuf *sb);
646 static void sasetupdev(struct sa_softc *softc, struct cdev *dev);
647 static void saloadtotunables(struct sa_softc *softc);
664 static void safilldensitysb(struct sa_softc *softc, int *indent,
666 static void saloadtimeouts(struct sa_softc *softc, union ccb *ccb);
714 struct sa_softc *softc; in saopen() local
724 softc = (struct sa_softc *)periph->softc; in saopen()
727 ("saopen(%s): softc=0x%x\n", devtoname(dev), softc->flags)); in saopen()
730 softc->ctrl_mode = 1; in saopen()
731 softc->open_count++; in saopen()
742 if (softc->flags & SA_FLAG_OPEN) { in saopen()
744 } else if (softc->flags & SA_FLAG_INVALID) { in saopen()
750 softc->open_rdonly = (flags & O_RDWR) == O_RDONLY; in saopen()
761 softc->flags |= SA_FLAG_OPEN; in saopen()
762 softc->open_pending_mount = 1; in saopen()
763 softc->open_count++; in saopen()
778 softc->flags |= SA_FLAG_OPEN; in saopen()
779 softc->open_count++; in saopen()
790 struct sa_softc *softc; in saclose() local
798 softc = (struct sa_softc *)periph->softc; in saclose()
801 ("saclose(%s): softc=0x%x\n", devtoname(dev), softc->flags)); in saclose()
803 softc->open_rdonly = 0; in saclose()
805 softc->ctrl_mode = 0; in saclose()
806 softc->open_count--; in saclose()
812 if (softc->open_pending_mount) { in saclose()
813 softc->flags &= ~SA_FLAG_OPEN; in saclose()
814 softc->open_pending_mount = 0; in saclose()
815 softc->open_count--; in saclose()
829 writing = (softc->flags & SA_FLAG_TAPE_WRITTEN) != 0; in saclose()
840 softc->flags |= SA_FLAG_TAPE_FROZEN; in saclose()
851 if ((softc->flags & SA_FLAG_TAPE_MOUNTED) == 0) { in saclose()
891 if (error == 0 && writing && (softc->quirks & SA_QUIRK_2FM)) { in saclose()
900 softc->flags |= SA_FLAG_TAPE_FROZEN; in saclose()
913 softc->filemarks = 0; in saclose()
914 softc->flags &= ~SA_FLAG_TAPE_WRITTEN; in saclose()
919 softc->flags &= ~closedbits; in saclose()
920 softc->open_count--; in saclose()
927 if (softc->density_type_bits[i] & SRDS_MEDIA) in saclose()
928 softc->density_info_valid[i] = 0; in saclose()
934 if (softc->flags & SA_FLAG_TAPE_FROZEN) { in saclose()
940 if ((softc->flags & SA_FLAG_TAPE_MOUNTED) == 0) in saclose()
959 struct sa_softc *softc; in sastrategy() local
969 softc = (struct sa_softc *)periph->softc; in sastrategy()
971 if (softc->flags & SA_FLAG_INVALID) { in sastrategy()
977 if (softc->flags & SA_FLAG_TAPE_FROZEN) { in sastrategy()
988 if (bp->bio_cmd == BIO_WRITE && softc->open_rdonly) { in sastrategy()
994 if (softc->open_pending_mount) { in sastrategy()
1002 softc->open_pending_mount = 0; in sastrategy()
1015 if (softc->flags & SA_FLAG_FIXED) { in sastrategy()
1020 if (((softc->blk_mask != ~0) && in sastrategy()
1021 ((bp->bio_bcount & softc->blk_mask) != 0)) || in sastrategy()
1022 ((softc->blk_mask == ~0) && in sastrategy()
1023 ((bp->bio_bcount % softc->min_blk) != 0))) { in sastrategy()
1026 softc->min_blk); in sastrategy()
1031 } else if ((bp->bio_bcount > softc->max_blk) || in sastrategy()
1032 (bp->bio_bcount < softc->min_blk) || in sastrategy()
1033 (bp->bio_bcount & softc->blk_mask) != 0) { in sastrategy()
1037 if (softc->blk_mask != 0) { in sastrategy()
1038 printf("a multiple of %d ", (0x1 << softc->blk_gran)); in sastrategy()
1040 printf("between %d and %d bytes\n", softc->min_blk, in sastrategy()
1041 softc->max_blk); in sastrategy()
1050 bioq_insert_tail(&softc->bio_queue, bp); in sastrategy()
1051 softc->queue_count++; in sastrategy()
1055 (softc->flags & SA_FLAG_FIXED)? "fixed" : "variable", in sastrategy()
1058 if (softc->queue_count > 1) { in sastrategy()
1060 ("sastrategy: queue count now %d\n", softc->queue_count)); in sastrategy()
1076 struct sa_softc *softc; in sasetsili() local
1080 softc = (struct sa_softc *)periph->softc; in sasetsili()
1098 if (softc->flags & SA_FLAG_FIXED) { in sasetsili()
1103 if (softc->sili == ps->value.value_signed) in sasetsili()
1119 softc->sili = ps->value.value_signed; in sasetsili()
1136 struct sa_softc *softc; in saseteotwarn() local
1140 softc = (struct sa_softc *)periph->softc; in saseteotwarn()
1156 softc->eot_warn = ps->value.value_signed; in saseteotwarn()
1166 safillprot(struct sa_softc *softc, int *indent, struct sbuf *sb) in safillprot() argument
1171 if (softc->flags & SA_FLAG_PROTECT_SUPP) in safillprot()
1179 && (softc->prot_info.cur_prot_state.initialized != 0)) { in safillprot()
1182 prot = &softc->prot_info.cur_prot_state; in safillprot()
1243 struct sa_softc *softc; in sasetprotents() local
1249 softc = (struct sa_softc *)periph->softc; in sasetprotents()
1256 if ((softc->flags & SA_FLAG_PROTECT_SUPP) == 0) { in sasetprotents()
1269 if ((softc->si_flags & SI_NOSPLIT) == 0) { in sasetprotents()
1281 bcopy(&softc->prot_info.cur_prot_state, &new_state, sizeof(new_state)); in sasetprotents()
1513 struct sa_softc *softc; in sagetparams_common() local
1517 softc = (struct sa_softc *)periph->softc; in sagetparams_common()
1519 if (softc->open_pending_mount) in sagetparams_common()
1523 if (SA_IS_CTRL(dev) && (softc->flags & SA_FLAG_OPEN) != 0) in sagetparams_common()
1526 error = sagetparams(periph, SA_PARAM_ALL, &softc->media_blksize, in sagetparams_common()
1527 &softc->media_density, &softc->media_numblks, &softc->buffer_mode, in sagetparams_common()
1528 &write_protect, &softc->speed, &comp_supported, &comp_enabled, in sagetparams_common()
1529 &softc->comp_algorithm, NULL, NULL, 0, 0); in sagetparams_common()
1533 softc->flags |= SA_FLAG_TAPE_WP; in sagetparams_common()
1535 softc->flags &= ~SA_FLAG_TAPE_WP; in sagetparams_common()
1536 softc->flags &= ~SA_FLAG_COMPRESSION; in sagetparams_common()
1538 if (softc->saved_comp_algorithm == 0) in sagetparams_common()
1539 softc->saved_comp_algorithm = in sagetparams_common()
1540 softc->comp_algorithm; in sagetparams_common()
1541 softc->flags |= SA_FLAG_COMP_SUPP; in sagetparams_common()
1543 softc->flags |= SA_FLAG_COMP_ENABLED; in sagetparams_common()
1545 softc->flags |= SA_FLAG_COMP_UNSUPP; in sagetparams_common()
1550 #define PENDING_MOUNT_CHECK(softc, periph, dev) \ argument
1551 if (softc->open_pending_mount) { \
1557 softc->open_pending_mount = 0; \
1564 struct sa_softc *softc; in saioctl() local
1576 softc = (struct sa_softc *)periph->softc; in saioctl()
1669 if (softc->flags & SA_FLAG_COMP_UNSUPP) { in saioctl()
1676 if ((softc->flags & SA_FLAG_COMP_ENABLED) == 0) { in saioctl()
1679 g->mt_comp = softc->comp_algorithm; in saioctl()
1681 g->mt_comp0 = softc->comp_algorithm; in saioctl()
1682 g->mt_comp1 = softc->comp_algorithm; in saioctl()
1683 g->mt_comp2 = softc->comp_algorithm; in saioctl()
1684 g->mt_comp3 = softc->comp_algorithm; in saioctl()
1686 g->mt_density = softc->media_density; in saioctl()
1687 g->mt_density0 = softc->media_density; in saioctl()
1688 g->mt_density1 = softc->media_density; in saioctl()
1689 g->mt_density2 = softc->media_density; in saioctl()
1690 g->mt_density3 = softc->media_density; in saioctl()
1691 g->mt_blksiz = softc->media_blksize; in saioctl()
1692 g->mt_blksiz0 = softc->media_blksize; in saioctl()
1693 g->mt_blksiz1 = softc->media_blksize; in saioctl()
1694 g->mt_blksiz2 = softc->media_blksize; in saioctl()
1695 g->mt_blksiz3 = softc->media_blksize; in saioctl()
1696 g->mt_fileno = softc->fileno; in saioctl()
1697 g->mt_blkno = softc->blkno; in saioctl()
1698 g->mt_dsreg = (short) softc->dsreg; in saioctl()
1702 if (softc->last_resid_was_io) { in saioctl()
1703 if ((g->mt_resid = (short) softc->last_io_resid) != 0) { in saioctl()
1705 softc->last_io_resid = 0; in saioctl()
1709 if ((g->mt_resid = (short)softc->last_ctl_resid) != 0) { in saioctl()
1711 softc->last_ctl_resid = 0; in saioctl()
1747 error = saparamget(softc, sb); in saioctl()
1805 sep->io_resid = softc->last_io_resid; in saioctl()
1806 bcopy((caddr_t) &softc->last_io_sense, sep->io_sense, in saioctl()
1808 bcopy((caddr_t) &softc->last_io_cdb, sep->io_cdb, in saioctl()
1810 sep->ctl_resid = softc->last_ctl_resid; in saioctl()
1811 bcopy((caddr_t) &softc->last_ctl_sense, sep->ctl_sense, in saioctl()
1813 bcopy((caddr_t) &softc->last_ctl_cdb, sep->ctl_cdb, in saioctl()
1816 if ((SA_IS_CTRL(dev) == 0 && !softc->open_pending_mount) || in saioctl()
1818 bzero((caddr_t) &softc->errinfo, in saioctl()
1819 sizeof (softc->errinfo)); in saioctl()
1828 PENDING_MOUNT_CHECK(softc, periph, dev); in saioctl()
1865 nmarks = softc->filemarks; in saioctl()
1870 softc->flags |= SA_FLAG_EIO_PENDING; in saioctl()
1873 nmarks -= softc->filemarks; in saioctl()
1904 nmarks = softc->filemarks; in saioctl()
1911 nmarks -= softc->filemarks; in saioctl()
1922 softc->flags &= in saioctl()
1924 softc->filemarks = 0; in saioctl()
1928 PENDING_MOUNT_CHECK(softc, periph, dev); in saioctl()
1932 softc->flags &= in saioctl()
1934 softc->flags &= ~SA_FLAG_ERR_PENDING; in saioctl()
1935 softc->filemarks = 0; in saioctl()
1938 PENDING_MOUNT_CHECK(softc, periph, dev); in saioctl()
1940 softc->flags &= in saioctl()
1942 softc->flags &= ~SA_FLAG_ERR_PENDING; in saioctl()
1945 PENDING_MOUNT_CHECK(softc, periph, dev); in saioctl()
1947 softc->flags &= in saioctl()
1949 softc->flags &= ~SA_FLAG_ERR_PENDING; in saioctl()
1953 PENDING_MOUNT_CHECK(softc, periph, dev); in saioctl()
1957 softc->flags &= ~SA_FLAG_TAPE_WRITTEN; in saioctl()
1958 softc->filemarks = 0; in saioctl()
1962 softc->flags &= ~SA_FLAG_TAPE_FROZEN; in saioctl()
1972 softc->flags &= ~SA_FLAG_TAPE_MOUNTED; in saioctl()
1988 PENDING_MOUNT_CHECK(softc, periph, dev); in saioctl()
1990 if ((softc->sili != 0) in saioctl()
2000 softc->last_media_blksize = in saioctl()
2001 softc->media_blksize; in saioctl()
2002 softc->media_blksize = count; in saioctl()
2004 softc->flags |= SA_FLAG_FIXED; in saioctl()
2006 softc->blk_shift = in saioctl()
2008 softc->blk_mask = count - 1; in saioctl()
2010 softc->blk_mask = ~0; in saioctl()
2011 softc->blk_shift = 0; in saioctl()
2016 softc->quirks &= ~SA_QUIRK_VARIABLE; in saioctl()
2017 softc->quirks |= SA_QUIRK_FIXED; in saioctl()
2019 softc->flags &= ~SA_FLAG_FIXED; in saioctl()
2020 if (softc->max_blk == 0) { in saioctl()
2021 softc->max_blk = ~0; in saioctl()
2023 softc->blk_shift = 0; in saioctl()
2024 if (softc->blk_gran != 0) { in saioctl()
2025 softc->blk_mask = in saioctl()
2026 softc->blk_gran - 1; in saioctl()
2028 softc->blk_mask = 0; in saioctl()
2033 softc->quirks |= SA_QUIRK_VARIABLE; in saioctl()
2034 softc->quirks &= ~SA_QUIRK_FIXED; in saioctl()
2039 PENDING_MOUNT_CHECK(softc, periph, dev); in saioctl()
2050 PENDING_MOUNT_CHECK(softc, periph, dev); in saioctl()
2056 if ((softc->quirks & SA_QUIRK_NOCOMP) || in saioctl()
2057 (softc->flags & SA_FLAG_COMP_UNSUPP)) { in saioctl()
2074 PENDING_MOUNT_CHECK(softc, periph, dev); in saioctl()
2078 PENDING_MOUNT_CHECK(softc, periph, dev); in saioctl()
2093 PENDING_MOUNT_CHECK(softc, periph, dev); in saioctl()
2099 PENDING_MOUNT_CHECK(softc, periph, dev); in saioctl()
2101 softc->flags &= in saioctl()
2103 softc->flags &= ~SA_FLAG_ERR_PENDING; in saioctl()
2104 softc->filemarks = 0; in saioctl()
2108 if (softc->quirks & SA_QUIRK_1FM) in saioctl()
2118 softc->quirks &= ~SA_QUIRK_2FM; in saioctl()
2119 softc->quirks |= SA_QUIRK_1FM; in saioctl()
2122 softc->quirks &= ~SA_QUIRK_1FM; in saioctl()
2123 softc->quirks |= SA_QUIRK_2FM; in saioctl()
2135 rblim->granularity = softc->blk_gran; in saioctl()
2136 rblim->min_block_length = softc->min_blk; in saioctl()
2137 rblim->max_block_length = softc->max_blk; in saioctl()
2148 if (error == 0 && (softc->flags & SA_FLAG_TAPE_FROZEN)) { in saioctl()
2157 softc->fileno = (daddr_t) -1; in saioctl()
2158 softc->blkno = (daddr_t) -1; in saioctl()
2159 softc->rep_blkno = (daddr_t) -1; in saioctl()
2160 softc->rep_fileno = (daddr_t) -1; in saioctl()
2161 softc->partition = (daddr_t) -1; in saioctl()
2162 softc->flags &= ~SA_FLAG_TAPE_FROZEN; in saioctl()
2198 struct sa_softc *softc; in sadevgonecb() local
2201 softc = (struct sa_softc *)periph->softc; in sadevgonecb()
2206 softc->num_devs_to_destroy--; in sadevgonecb()
2207 if (softc->num_devs_to_destroy == 0) { in sadevgonecb()
2216 for (i = 0; i < softc->open_count; i++) in sadevgonecb()
2219 softc->open_count = 0; in sadevgonecb()
2241 struct sa_softc *softc; in saoninvalidate() local
2243 softc = (struct sa_softc *)periph->softc; in saoninvalidate()
2250 softc->flags |= SA_FLAG_INVALID; in saoninvalidate()
2257 bioq_flush(&softc->bio_queue, NULL, ENXIO); in saoninvalidate()
2258 softc->queue_count = 0; in saoninvalidate()
2264 destroy_dev_sched_cb(softc->devs.ctl_dev, sadevgonecb, periph); in saoninvalidate()
2265 destroy_dev_sched_cb(softc->devs.r_dev, sadevgonecb, periph); in saoninvalidate()
2266 destroy_dev_sched_cb(softc->devs.nr_dev, sadevgonecb, periph); in saoninvalidate()
2267 destroy_dev_sched_cb(softc->devs.er_dev, sadevgonecb, periph); in saoninvalidate()
2273 struct sa_softc *softc; in sacleanup() local
2275 softc = (struct sa_softc *)periph->softc; in sacleanup()
2279 if ((softc->flags & SA_FLAG_SCTX_INIT) != 0 in sacleanup()
2280 && (((softc->sysctl_timeout_tree != NULL) in sacleanup()
2281 && (sysctl_ctx_free(&softc->sysctl_timeout_ctx) != 0)) in sacleanup()
2282 || sysctl_ctx_free(&softc->sysctl_ctx) != 0)) in sacleanup()
2287 devstat_remove_entry(softc->device_stats); in sacleanup()
2289 free(softc, M_SCSISA); in sacleanup()
2339 sasetupdev(struct sa_softc *softc, struct cdev *dev) in sasetupdev() argument
2342 dev->si_iosize_max = softc->maxio; in sasetupdev()
2343 dev->si_flags |= softc->si_flags; in sasetupdev()
2350 softc->num_devs_to_destroy++; in sasetupdev()
2360 saloadtotunables(struct sa_softc *softc) in saloadtotunables() argument
2373 softc->timeout_info[i] = tmpval; in saloadtotunables()
2380 softc->periph->unit_number, sa_default_timeouts[i].desc); in saloadtotunables()
2383 softc->timeout_info[i] = tmpval; in saloadtotunables()
2391 struct sa_softc *softc; in sasysctlinit() local
2402 softc = (struct sa_softc *)periph->softc; in sasysctlinit()
2407 sysctl_ctx_init(&softc->sysctl_ctx); in sasysctlinit()
2408 softc->flags |= SA_FLAG_SCTX_INIT; in sasysctlinit()
2409 softc->sysctl_tree = SYSCTL_ADD_NODE_WITH_LABEL(&softc->sysctl_ctx, in sasysctlinit()
2412 if (softc->sysctl_tree == NULL) in sasysctlinit()
2415 SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), in sasysctlinit()
2417 &softc->allow_io_split, 0, "Allow Splitting I/O"); in sasysctlinit()
2418 SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), in sasysctlinit()
2420 &softc->maxio, 0, "Maximum I/O size"); in sasysctlinit()
2421 SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), in sasysctlinit()
2423 &softc->cpi_maxio, 0, "Maximum Controller I/O size"); in sasysctlinit()
2424 SYSCTL_ADD_INT(&softc->sysctl_ctx, SYSCTL_CHILDREN(softc->sysctl_tree), in sasysctlinit()
2426 &softc->inject_eom, 0, "Queue EOM for the next write/read"); in sasysctlinit()
2428 sysctl_ctx_init(&softc->sysctl_timeout_ctx); in sasysctlinit()
2429 softc->sysctl_timeout_tree = SYSCTL_ADD_NODE(&softc->sysctl_timeout_ctx, in sasysctlinit()
2430 SYSCTL_CHILDREN(softc->sysctl_tree), OID_AUTO, "timeout", in sasysctlinit()
2432 if (softc->sysctl_timeout_tree == NULL) in sasysctlinit()
2448 SYSCTL_ADD_INT(&softc->sysctl_timeout_ctx, in sasysctlinit()
2449 SYSCTL_CHILDREN(softc->sysctl_timeout_tree), in sasysctlinit()
2451 &softc->timeout_info[i], 0, tmpstr); in sasysctlinit()
2464 struct sa_softc *softc; in saregister() local
2479 softc = (struct sa_softc *) in saregister()
2480 malloc(sizeof (*softc), M_SCSISA, M_NOWAIT | M_ZERO); in saregister()
2481 if (softc == NULL) { in saregister()
2486 softc->scsi_rev = SID_ANSI_REV(&cgd->inq_data); in saregister()
2487 softc->state = SA_STATE_NORMAL; in saregister()
2488 softc->fileno = (daddr_t) -1; in saregister()
2489 softc->blkno = (daddr_t) -1; in saregister()
2490 softc->rep_fileno = (daddr_t) -1; in saregister()
2491 softc->rep_blkno = (daddr_t) -1; in saregister()
2492 softc->partition = (daddr_t) -1; in saregister()
2493 softc->bop = -1; in saregister()
2494 softc->eop = -1; in saregister()
2495 softc->bpew = -1; in saregister()
2497 bioq_init(&softc->bio_queue); in saregister()
2498 softc->periph = periph; in saregister()
2499 periph->softc = softc; in saregister()
2510 softc->quirks = ((struct sa_quirk_entry *)match)->quirks; in saregister()
2511 softc->last_media_blksize = in saregister()
2514 softc->quirks = SA_QUIRK_NONE; in saregister()
2523 softc->timeout_info[i] = sa_default_timeouts[i].value; in saregister()
2536 softc->quirks |= SA_QUIRK_NO_LONG_POS; in saregister()
2549 softc->flags |= SA_FLAG_RSOC_TO_TRY; in saregister()
2571 softc->flags |= SA_FLAG_PROTECT_SUPP; in saregister()
2582 softc->device_stats = devstat_new_entry("sa", periph->unit_number, 0, in saregister()
2590 softc->allow_io_split = sa_allow_io_split; in saregister()
2598 TUNABLE_INT_FETCH(tmpstr, &softc->allow_io_split); in saregister()
2605 softc->maxio = DFLTPHYS; in saregister()
2607 softc->maxio = maxphys; in saregister()
2609 softc->maxio = cpi.maxio; in saregister()
2615 softc->cpi_maxio = cpi.maxio; in saregister()
2623 if (softc->allow_io_split == 0) in saregister()
2624 softc->si_flags = SI_NOSPLIT; in saregister()
2626 softc->si_flags = 0; in saregister()
2628 TASK_INIT(&softc->sysctl_task, 0, sasysctlinit, periph); in saregister()
2635 softc->si_flags |= SI_UNMAPPED; in saregister()
2651 args.mda_si_drv1 = softc->periph; in saregister()
2657 error = make_dev_s(&args, &softc->devs.ctl_dev, "%s%d.ctl", in saregister()
2663 sasetupdev(softc, softc->devs.ctl_dev); in saregister()
2666 error = make_dev_s(&args, &softc->devs.r_dev, "%s%d", in saregister()
2672 sasetupdev(softc, softc->devs.r_dev); in saregister()
2675 error = make_dev_s(&args, &softc->devs.nr_dev, "n%s%d", in saregister()
2681 sasetupdev(softc, softc->devs.nr_dev); in saregister()
2684 error = make_dev_s(&args, &softc->devs.er_dev, "e%s%d", in saregister()
2690 sasetupdev(softc, softc->devs.er_dev); in saregister()
2694 softc->density_type_bits[0] = 0; in saregister()
2695 softc->density_type_bits[1] = SRDS_MEDIA; in saregister()
2696 softc->density_type_bits[2] = SRDS_MEDIUM_TYPE; in saregister()
2697 softc->density_type_bits[3] = SRDS_MEDIUM_TYPE | SRDS_MEDIA; in saregister()
2705 taskqueue_enqueue(taskqueue_thread, &softc->sysctl_task); in saregister()
2730 if (softc->flags & SA_FLAG_RSOC_TO_TRY) { in saregister()
2735 softc->state = SA_STATE_PROBE; in saregister()
2743 saloadtotunables(softc); in saregister()
2746 xpt_announce_quirks(periph, softc->quirks, SA_QUIRK_BIT_STRING); in saregister()
2755 struct sa_softc *softc; in sastart() local
2757 softc = (struct sa_softc *)periph->softc; in sastart()
2761 switch (softc->state) { in sastart()
2770 bp = bioq_first(&softc->bio_queue); in sastart()
2773 } else if (((softc->flags & SA_FLAG_ERR_PENDING) != 0) in sastart()
2774 || (softc->inject_eom != 0)) { in sastart()
2777 if (softc->inject_eom != 0) { in sastart()
2778 softc->flags |= SA_FLAG_EOM_PENDING; in sastart()
2779 softc->inject_eom = 0; in sastart()
2790 softc->set_pews_status = 3; in sastart()
2792 softc->set_pews_status = 1; in sastart()
2795 softc->queue_count--; in sastart()
2796 bioq_remove(&softc->bio_queue, bp); in sastart()
2799 if ((softc->flags & SA_FLAG_EOM_PENDING) != 0) { in sastart()
2823 if (softc->eot_warn != 0) { in sastart()
2828 } else if ((softc->flags & SA_FLAG_EOF_PENDING) != 0) { in sastart()
2836 if (bioq_first(&softc->bio_queue) != NULL) { in sastart()
2840 } else if ((softc->flags & SA_FLAG_EIO_PENDING) != 0) { in sastart()
2844 bp = bioq_first(&softc->bio_queue); in sastart()
2850 softc->flags &= ~SA_FLAG_ERR_PENDING; in sastart()
2854 (softc->flags & SA_FLAG_ERR_PENDING), in sastart()
2855 (bp != NULL)? "not " : " ", softc->queue_count)); in sastart()
2861 bioq_remove(&softc->bio_queue, bp); in sastart()
2862 softc->queue_count--; in sastart()
2872 if ((softc->flags & SA_FLAG_FIXED) != 0) { in sastart()
2873 if (softc->blk_shift != 0) { in sastart()
2874 length = length >> softc->blk_shift; in sastart()
2875 } else if (softc->media_blksize != 0) { in sastart()
2876 length = length / softc->media_blksize; in sastart()
2898 devstat_start_transaction_bio(softc->device_stats, bp); in sastart()
2932 softc->dsreg = (bp->bio_cmd == BIO_READ)? in sastart()
2938 SCSI_RW_BIO : 0), softc->sili, in sastart()
2939 (softc->flags & SA_FLAG_FIXED) != 0, length, in sastart()
2943 softc->timeout_info[SA_TIMEOUT_READ] : in sastart()
2944 softc->timeout_info[SA_TIMEOUT_WRITE]); in sastart()
2947 bp = bioq_first(&softc->bio_queue); in sastart()
2983 saloadtotunables(softc); in sastart()
2985 softc->state = SA_STATE_NORMAL; in sastart()
2988 xpt_announce_quirks(periph, softc->quirks, in sastart()
3005 /*timeout*/ softc->timeout_info[SA_TIMEOUT_TUR]); in sastart()
3012 panic("state 0x%x in sastart", softc->state); in sastart()
3020 struct sa_softc *softc; in sadone() local
3025 softc = (struct sa_softc *)periph->softc; in sadone()
3029 if (softc->state == SA_STATE_NORMAL) { in sadone()
3030 softc->dsreg = MTIO_DSREG_REST; in sadone()
3041 } else if (softc->state == SA_STATE_PROBE) { in sadone()
3062 saloadtotunables(softc); in sadone()
3064 softc->state = SA_STATE_NORMAL; in sadone()
3069 xpt_announce_quirks(periph, softc->quirks, in sadone()
3079 softc->state = SA_STATE_NORMAL; in sadone()
3084 saloadtimeouts(softc, done_ccb); in sadone()
3090 saloadtotunables(softc); in sadone()
3094 xpt_announce_quirks(periph, softc->quirks, in sadone()
3099 panic("state 0x%x in sadone", softc->state); in sadone()
3114 softc->flags |= SA_FLAG_TAPE_FROZEN; in sadone()
3115 bioq_flush(&softc->bio_queue, NULL, EIO); in sadone()
3131 softc->flags |= SA_FLAG_TAPE_WRITTEN; in sadone()
3132 softc->filemarks = 0; in sadone()
3135 (softc->blkno != (daddr_t) -1)) { in sadone()
3136 if ((softc->flags & SA_FLAG_FIXED) != 0) { in sadone()
3138 if (softc->blk_shift != 0) { in sadone()
3140 softc->blk_shift; in sadone()
3143 softc->media_blksize; in sadone()
3145 softc->blkno += (daddr_t) l; in sadone()
3147 softc->blkno++; in sadone()
3155 if (error || (softc->flags & SA_FLAG_ERR_PENDING)) in sadone()
3162 biofinish(bp, softc->device_stats, 0); in sadone()
3172 struct sa_softc *softc; in samount() local
3183 softc = (struct sa_softc *)periph->softc; in samount()
3194 if (softc->flags & SA_FLAG_TAPE_MOUNTED) { in samount()
3198 softc->timeout_info[SA_TIMEOUT_TUR]); in samount()
3200 softc->device_stats); in samount()
3202 softc->flags &= ~SA_FLAG_TAPE_MOUNTED; in samount()
3205 softc->timeout_info[SA_TIMEOUT_TUR]); in samount()
3207 softc->device_stats); in samount()
3213 softc->flags &= ~SA_FLAG_TAPE_MOUNTED; in samount()
3227 softc->timeout_info[SA_TIMEOUT_TUR]); in samount()
3229 softc->device_stats); in samount()
3232 if ((softc->flags & SA_FLAG_TAPE_MOUNTED) == 0) { in samount()
3240 softc->flags &= ~(SA_FLAG_TAPE_WP|SA_FLAG_TAPE_WRITTEN| in samount()
3242 softc->filemarks = 0; in samount()
3249 softc->timeout_info[SA_TIMEOUT_LOAD]); in samount()
3251 softc->device_stats); in samount()
3259 softc->timeout_info[SA_TIMEOUT_REWIND]); in samount()
3261 softc->device_stats); in samount()
3284 if ((softc->quirks & SA_QUIRK_NODREAD) == 0) { in samount()
3288 softc->timeout_info[SA_TIMEOUT_READ]); in samount()
3290 softc->device_stats); in samount()
3293 softc->timeout_info[SA_TIMEOUT_REWIND]); in samount()
3296 softc->device_stats); in samount()
3310 softc->timeout_info[SA_TIMEOUT_READ_BLOCK_LIMITS]); in samount()
3313 SF_NO_PRINT | SF_RETRY_UA, softc->device_stats); in samount()
3323 softc->blk_gran = 0; in samount()
3324 softc->max_blk = ~0; in samount()
3325 softc->min_blk = 0; in samount()
3327 if (softc->scsi_rev >= SCSI_REV_SPC) { in samount()
3328 softc->blk_gran = RBL_GRAN(rblim); in samount()
3330 softc->blk_gran = 0; in samount()
3338 softc->max_blk = scsi_3btoul(rblim->maximum); in samount()
3339 softc->min_blk = scsi_2btoul(rblim->minimum); in samount()
3346 &softc->media_blksize, in samount()
3347 &softc->media_density, in samount()
3348 &softc->media_numblks, in samount()
3349 &softc->buffer_mode, &write_protect, in samount()
3350 &softc->speed, &comp_supported, in samount()
3351 &comp_enabled, &softc->comp_algorithm, in samount()
3369 if ((softc->quirks & (SA_QUIRK_FIXED|SA_QUIRK_VARIABLE)) == 0) { in samount()
3378 if (softc->media_density == SCSI_DEFAULT_DENSITY) { in samount()
3403 softc->media_density = ctry[i]; in samount()
3408 switch (softc->media_density) { in samount()
3417 softc->quirks &= ~SA_QUIRK_2FM; in samount()
3418 softc->quirks |= SA_QUIRK_FIXED|SA_QUIRK_1FM; in samount()
3419 softc->last_media_blksize = 512; in samount()
3423 softc->quirks &= ~SA_QUIRK_2FM; in samount()
3424 softc->quirks |= SA_QUIRK_FIXED|SA_QUIRK_1FM; in samount()
3425 softc->last_media_blksize = 1024; in samount()
3428 softc->last_media_blksize = in samount()
3429 softc->media_blksize; in samount()
3430 softc->quirks |= SA_QUIRK_VARIABLE; in samount()
3440 if ((softc->quirks & SA_QUIRK_2FM) == 0) { in samount()
3441 switch (softc->media_density) { in samount()
3447 softc->quirks &= ~SA_QUIRK_1FM; in samount()
3448 softc->quirks |= SA_QUIRK_2FM; in samount()
3458 if ((softc->max_blk < softc->media_blksize) || in samount()
3459 (softc->min_blk > softc->media_blksize && in samount()
3460 softc->media_blksize)) { in samount()
3463 "block settings (%d)- adjusting\n", softc->min_blk, in samount()
3464 softc->max_blk, softc->media_blksize); in samount()
3465 softc->max_blk = softc->min_blk = in samount()
3466 softc->media_blksize; in samount()
3483 if ((softc->quirks & SA_QUIRK_FIXED) && in samount()
3484 (softc->quirks & SA_QUIRK_NO_MODESEL) == 0 && in samount()
3485 (softc->media_blksize != softc->last_media_blksize)) { in samount()
3486 softc->media_blksize = softc->last_media_blksize; in samount()
3487 if (softc->media_blksize == 0) { in samount()
3488 softc->media_blksize = 512; in samount()
3489 if (softc->media_blksize < softc->min_blk) { in samount()
3490 softc->media_blksize = softc->min_blk; in samount()
3494 softc->media_blksize, 0, 0, SF_NO_PRINT); in samount()
3498 softc->media_blksize); in samount()
3503 if ((softc->quirks & SA_QUIRK_VARIABLE) && in samount()
3504 (softc->media_blksize != 0)) { in samount()
3505 softc->last_media_blksize = softc->media_blksize; in samount()
3506 softc->media_blksize = 0; in samount()
3517 softc->quirks &= ~SA_QUIRK_VARIABLE; in samount()
3518 softc->quirks |= SA_QUIRK_FIXED; in samount()
3519 if (softc->last_media_blksize == 0) in samount()
3520 softc->last_media_blksize = 512; in samount()
3533 if (softc->media_blksize) { in samount()
3534 softc->flags |= SA_FLAG_FIXED; in samount()
3535 if (powerof2(softc->media_blksize)) { in samount()
3536 softc->blk_shift = in samount()
3537 ffs(softc->media_blksize) - 1; in samount()
3538 softc->blk_mask = softc->media_blksize - 1; in samount()
3540 softc->blk_mask = ~0; in samount()
3541 softc->blk_shift = 0; in samount()
3550 if (softc->max_blk == 0) { in samount()
3551 softc->max_blk = ~0; in samount()
3553 softc->blk_shift = 0; in samount()
3554 if (softc->blk_gran != 0) { in samount()
3555 softc->blk_mask = softc->blk_gran - 1; in samount()
3557 softc->blk_mask = 0; in samount()
3562 softc->flags |= SA_FLAG_TAPE_WP; in samount()
3565 if (softc->saved_comp_algorithm == 0) in samount()
3566 softc->saved_comp_algorithm = in samount()
3567 softc->comp_algorithm; in samount()
3568 softc->flags |= SA_FLAG_COMP_SUPP; in samount()
3570 softc->flags |= SA_FLAG_COMP_ENABLED; in samount()
3572 softc->flags |= SA_FLAG_COMP_UNSUPP; in samount()
3574 if ((softc->buffer_mode == SMH_SA_BUF_MODE_NOBUF) && in samount()
3575 (softc->quirks & SA_QUIRK_NO_MODESEL) == 0) { in samount()
3579 softc->buffer_mode = SMH_SA_BUF_MODE_SIBUF; in samount()
3588 softc->flags |= SA_FLAG_TAPE_MOUNTED; in samount()
3595 softc->dsreg = MTIO_DSREG_NIL; in samount()
3597 softc->fileno = softc->blkno = 0; in samount()
3598 softc->rep_fileno = softc->rep_blkno = -1; in samount()
3599 softc->partition = 0; in samount()
3600 softc->dsreg = MTIO_DSREG_REST; in samount()
3603 if ((softc->quirks & SA_QUIRK_2FM) == 0) in samount()
3604 softc->quirks |= SA_QUIRK_1FM; in samount()
3606 if ((softc->quirks & SA_QUIRK_1FM) == 0) in samount()
3607 softc->quirks |= SA_QUIRK_2FM; in samount()
3622 softc->last_io_resid = 0; in samount()
3623 softc->last_ctl_resid = 0; in samount()
3637 struct sa_softc *softc; in samarkswanted() local
3639 softc = (struct sa_softc *)periph->softc; in samarkswanted()
3641 if ((softc->flags & SA_FLAG_TAPE_WRITTEN) != 0) { in samarkswanted()
3643 if (softc->quirks & SA_QUIRK_2FM) in samarkswanted()
3646 markswanted -= softc->filemarks; in samarkswanted()
3672 struct sa_softc *softc; in saerror() local
3683 softc = (struct sa_softc *)periph->softc; in saerror()
3709 if ((softc->flags & SA_FLAG_FIXED) != 0) in saerror()
3710 resid *= softc->media_blksize; in saerror()
3714 if ((softc->flags & SA_FLAG_FIXED) != 0) { in saerror()
3715 if (softc->media_blksize) in saerror()
3716 info /= softc->media_blksize; in saerror()
3721 bcopy((caddr_t) sense, (caddr_t) &softc->last_io_sense, in saerror()
3723 bcopy(csio->cdb_io.cdb_bytes, softc->last_io_cdb, in saerror()
3725 softc->last_io_resid = resid; in saerror()
3726 softc->last_resid_was_io = 1; in saerror()
3728 bcopy((caddr_t) sense, (caddr_t) &softc->last_ctl_sense, in saerror()
3730 bcopy(csio->cdb_io.cdb_bytes, softc->last_ctl_cdb, in saerror()
3732 softc->last_ctl_resid = resid; in saerror()
3733 softc->last_resid_was_io = 0; in saerror()
3799 softc->flags |= SA_FLAG_EOM_PENDING; in saerror()
3811 if (softc->quirks & SA_QUIRK_1FM) { in saerror()
3813 softc->flags |= SA_FLAG_EOM_PENDING; in saerror()
3818 if (softc->flags & SA_FLAG_FIXED) { in saerror()
3820 softc->flags |= SA_FLAG_EOF_PENDING; in saerror()
3826 if (softc->fileno != (daddr_t) -1) { in saerror()
3827 softc->fileno++; in saerror()
3828 softc->blkno = 0; in saerror()
3845 if (softc->flags & SA_FLAG_FIXED) { in saerror()
3846 softc->flags |= SA_FLAG_EIO_PENDING; in saerror()
3854 if (softc->blkno != (daddr_t) -1) { in saerror()
3855 softc->blkno++; in saerror()
3888 struct sa_softc *softc; in sagetparams() local
3893 softc = (struct sa_softc *)periph->softc; in sagetparams()
3895 if (softc->quirks & SA_QUIRK_NO_CPAGE) in sagetparams()
3904 if (softc->quirks & SA_QUIRK_NOCOMP) { in sagetparams()
3924 SSD_FULL_SIZE, softc->timeout_info[SA_TIMEOUT_MODE_SENSE]); in sagetparams()
3927 softc->device_stats); in sagetparams()
3943 softc->quirks |= SA_QUIRK_NOCOMP; in sagetparams()
3986 softc->timeout_info[SA_TIMEOUT_MODE_SENSE]); in sagetparams()
3989 softc->device_stats); in sagetparams()
4039 && (softc->scsi_rev >= SCSI_REV_SPC)) { in sagetparams()
4047 /*media*/ softc->density_type_bits[i] & SRDS_MEDIA, in sagetparams()
4048 /*medium_type*/ softc->density_type_bits[i] & in sagetparams()
4050 /*data_ptr*/ softc->density_info[i], in sagetparams()
4051 /*length*/ sizeof(softc->density_info[i]), in sagetparams()
4054 softc->timeout_info[SA_TIMEOUT_REP_DENSITY]); in sagetparams()
4056 softc->device_stats); in sagetparams()
4071 softc->density_info_valid[i] = 0; in sagetparams()
4072 if (softc->density_type_bits[i] == 0) in sagetparams()
4077 softc->density_info_valid[i] = ccb->csio.dxfer_len - in sagetparams()
4086 && (softc->flags & SA_FLAG_PROTECT_SUPP)) { in sagetparams()
4117 softc->timeout_info[SA_TIMEOUT_MODE_SENSE]); in sagetparams()
4126 softc->device_stats); in sagetparams()
4169 prot = &softc->prot_info.cur_prot_state; in sagetparams()
4209 struct sa_softc *softc; in sasetprot() local
4218 softc = (struct sa_softc *)periph->softc; in sasetprot()
4296 if (softc->buffer_mode == SMH_SA_BUF_MODE_SIBUF) { in sasetprot()
4346 softc->timeout_info[SA_TIMEOUT_MODE_SELECT]); in sasetprot()
4348 error = cam_periph_runccb(ccb, saerror, 0, 0, softc->device_stats); in sasetprot()
4395 struct sa_softc *softc; in sasetparams() local
4410 softc = (struct sa_softc *)periph->softc; in sasetparams()
4479 } else if (softc->scsi_rev > SCSI_REV_CCS) { in sasetparams()
4482 mode_blk->density = softc->media_density; in sasetparams()
4496 if (softc->buffer_mode == SMH_SA_BUF_MODE_SIBUF) { in sasetparams()
4534 softc->saved_comp_algorithm != 0) { in sasetparams()
4535 dcp->sel_comp_alg = softc->saved_comp_algorithm; in sasetparams()
4566 softc->saved_comp_algorithm != 0) { in sasetparams()
4567 scsi_ulto4b(softc->saved_comp_algorithm, in sasetparams()
4569 scsi_ulto4b(softc->saved_comp_algorithm, in sasetparams()
4617 softc->timeout_info[SA_TIMEOUT_MODE_SELECT]); in sasetparams()
4620 sense_flags, softc->device_stats); in sasetparams()
4661 } else if (softc->scsi_rev > SCSI_REV_CCS) { in sasetparams()
4664 mode_blk->density = softc->media_density; in sasetparams()
4676 softc->device_stats); in sasetparams()
4686 softc->flags &= ~SA_FLAG_COMP_ENABLED; in sasetparams()
4693 softc->saved_comp_algorithm = softc->comp_algorithm; in sasetparams()
4694 softc->comp_algorithm = 0; in sasetparams()
4696 softc->flags |= SA_FLAG_COMP_ENABLED; in sasetparams()
4697 softc->comp_algorithm = calg; in sasetparams()
4711 struct sa_softc *softc; in saextget() local
4716 softc = (struct sa_softc *)periph->softc; in saextget()
4723 if (!SA_IS_CTRL(dev) && !softc->open_pending_mount) in saextget()
4803 SASBADDUINTDESC(sb, indent, softc->maxio, %u, maxio, in saextget()
4806 SASBADDUINTDESC(sb, indent, softc->cpi_maxio, %u, cpi_maxio, in saextget()
4809 SASBADDUINTDESC(sb, indent, softc->max_blk, %u, max_blk, in saextget()
4812 SASBADDUINTDESC(sb, indent, softc->min_blk, %u, min_blk, in saextget()
4815 SASBADDUINTDESC(sb, indent, softc->blk_gran, %u, blk_gran, in saextget()
4818 maxio_tmp = min(softc->max_blk, softc->maxio); in saextget()
4823 SASBADDINTDESC(sb, indent, softc->flags & SA_FLAG_FIXED ? 1 : 0, %d, in saextget()
4829 if (softc->flags & SA_FLAG_COMP_UNSUPP) in saextget()
4835 if (softc->flags & SA_FLAG_COMP_ENABLED) in saextget()
4841 SASBADDUINTDESC(sb, indent, softc->comp_algorithm, %u, in saextget()
4844 safillprot(softc, &indent, sb); in saextget()
4846 SASBADDUINTDESC(sb, indent, softc->media_blksize, %u, in saextget()
4848 SASBADDINTDESC(sb, indent, (intmax_t)softc->fileno, %jd, in saextget()
4850 SASBADDINTDESC(sb, indent, (intmax_t)softc->blkno, %jd, in saextget()
4853 SASBADDINTDESC(sb, indent, (intmax_t)softc->rep_fileno, %jd, in saextget()
4855 SASBADDINTDESC(sb, indent, (intmax_t)softc->rep_blkno, %jd, in saextget()
4858 SASBADDINTDESC(sb, indent, (intmax_t)softc->partition, %jd, in saextget()
4860 SASBADDINTDESC(sb, indent, softc->bop, %d, bop, in saextget()
4863 SASBADDINTDESC(sb, indent, softc->eop, %d, eop, in saextget()
4865 SASBADDINTDESC(sb, indent, softc->bpew, %d, bpew, in saextget()
4868 SASBADDINTDESC(sb, indent, (intmax_t)softc->last_io_resid, %jd, in saextget()
4874 SASBADDINTDESC(sb, indent, softc->dsreg, %d, dsreg, in saextget()
4877 safilldensitysb(softc, &indent, sb); in saextget()
4887 saparamget(struct sa_softc *softc, struct sbuf *sb) in saparamget() argument
4893 SASBADDINTDESC(sb, indent, softc->sili, %d, sili, in saparamget()
4895 SASBADDINTDESC(sb, indent, softc->eot_warn, %d, eot_warn, in saparamget()
4897 safillprot(softc, &indent, sb); in saparamget()
4906 struct sa_softc *softc; in saprevent() local
4910 softc = (struct sa_softc *)periph->softc; in saprevent()
4912 if ((action == PR_ALLOW) && (softc->flags & SA_FLAG_TAPE_LOCKED) == 0) in saprevent()
4914 if ((action == PR_PREVENT) && (softc->flags & SA_FLAG_TAPE_LOCKED) != 0) in saprevent()
4929 SSD_FULL_SIZE, softc->timeout_info[SA_TIMEOUT_PREVENT]); in saprevent()
4931 error = cam_periph_runccb(ccb, saerror, 0, sf, softc->device_stats); in saprevent()
4934 softc->flags &= ~SA_FLAG_TAPE_LOCKED; in saprevent()
4936 softc->flags |= SA_FLAG_TAPE_LOCKED; in saprevent()
4946 struct sa_softc *softc; in sarewind() local
4949 softc = (struct sa_softc *)periph->softc; in sarewind()
4955 SSD_FULL_SIZE, softc->timeout_info[SA_TIMEOUT_REWIND]); in sarewind()
4957 softc->dsreg = MTIO_DSREG_REW; in sarewind()
4958 error = cam_periph_runccb(ccb, saerror, 0, 0, softc->device_stats); in sarewind()
4959 softc->dsreg = MTIO_DSREG_REST; in sarewind()
4963 softc->partition = softc->fileno = softc->blkno = (daddr_t) 0; in sarewind()
4964 softc->rep_fileno = softc->rep_blkno = (daddr_t) 0; in sarewind()
4966 softc->fileno = softc->blkno = (daddr_t) -1; in sarewind()
4967 softc->partition = (daddr_t) -1; in sarewind()
4968 softc->rep_fileno = softc->rep_blkno = (daddr_t) -1; in sarewind()
4977 struct sa_softc *softc; in saspace() local
4980 softc = (struct sa_softc *)periph->softc; in saspace()
4987 SSD_FULL_SIZE, softc->timeout_info[SA_TIMEOUT_SPACE]); in saspace()
4992 softc->last_ctl_resid = 0; in saspace()
4994 softc->dsreg = (count < 0)? MTIO_DSREG_REV : MTIO_DSREG_FWD; in saspace()
4995 error = cam_periph_runccb(ccb, saerror, 0, 0, softc->device_stats); in saspace()
4996 softc->dsreg = MTIO_DSREG_REST; in saspace()
5020 softc->fileno = softc->blkno = (daddr_t) -1; in saspace()
5021 softc->rep_blkno = softc->partition = (daddr_t) -1; in saspace()
5022 softc->rep_fileno = (daddr_t) -1; in saspace()
5024 softc->fileno = softc->blkno = (daddr_t) -1; in saspace()
5025 } else if (code == SS_FILEMARKS && softc->fileno != (daddr_t) -1) { in saspace()
5026 softc->fileno += (count - softc->last_ctl_resid); in saspace()
5027 if (softc->fileno < 0) /* we must of hit BOT */ in saspace()
5028 softc->fileno = 0; in saspace()
5029 softc->blkno = 0; in saspace()
5030 } else if (code == SS_BLOCKS && softc->blkno != (daddr_t) -1) { in saspace()
5031 softc->blkno += (count - softc->last_ctl_resid); in saspace()
5033 if (softc->last_ctl_resid || softc->blkno < 0) { in saspace()
5034 if (softc->fileno == 0) { in saspace()
5035 softc->blkno = 0; in saspace()
5037 softc->blkno = (daddr_t) -1; in saspace()
5052 struct sa_softc *softc; in sawritefilemarks() local
5055 softc = (struct sa_softc *)periph->softc; in sawritefilemarks()
5056 if (softc->open_rdonly) in sawritefilemarks()
5063 softc->last_ctl_resid = 0; in sawritefilemarks()
5065 softc->dsreg = MTIO_DSREG_FMK; in sawritefilemarks()
5069 softc->timeout_info[SA_TIMEOUT_WRITE_FILEMARKS]); in sawritefilemarks()
5070 softc->dsreg = MTIO_DSREG_REST; in sawritefilemarks()
5072 error = cam_periph_runccb(ccb, saerror, 0, 0, softc->device_stats); in sawritefilemarks()
5075 struct sa_softc *softc = (struct sa_softc *)periph->softc; in sawritefilemarks() local
5076 nwm = nmarks - softc->last_ctl_resid; in sawritefilemarks()
5077 softc->filemarks += nwm; in sawritefilemarks()
5086 softc->fileno = softc->blkno = softc->partition = (daddr_t) -1; in sawritefilemarks()
5087 } else if (softc->fileno != (daddr_t) -1) { in sawritefilemarks()
5088 softc->fileno += nwm; in sawritefilemarks()
5089 softc->blkno = 0; in sawritefilemarks()
5102 if (softc->rep_fileno != (daddr_t) -1) { in sawritefilemarks()
5103 softc->fileno = softc->rep_fileno; in sawritefilemarks()
5104 softc->blkno = 0; in sawritefilemarks()
5115 struct sa_softc *softc = (struct sa_softc *)periph->softc; in sagetpos() local
5118 if (softc->quirks & SA_QUIRK_NO_LONG_POS) { in sagetpos()
5119 softc->rep_fileno = (daddr_t) -1; in sagetpos()
5120 softc->rep_blkno = (daddr_t) -1; in sagetpos()
5121 softc->bop = softc->eop = softc->bpew = -1; in sagetpos()
5137 softc->timeout_info[SA_TIMEOUT_READ_POSITION]); in sagetpos()
5139 softc->dsreg = MTIO_DSREG_RBSY; in sagetpos()
5141 softc->device_stats); in sagetpos()
5142 softc->dsreg = MTIO_DSREG_REST; in sagetpos()
5151 softc->fileno = (daddr_t) -1; in sagetpos()
5152 softc->rep_fileno = (daddr_t) -1; in sagetpos()
5154 softc->fileno = softc->rep_fileno = in sagetpos()
5159 softc->partition = (daddr_t) -1; in sagetpos()
5160 softc->rep_blkno = (daddr_t) -1; in sagetpos()
5165 softc->blkno = (daddr_t) -1; in sagetpos()
5167 softc->partition = scsi_4btoul(long_pos.partition); in sagetpos()
5168 softc->rep_blkno = in sagetpos()
5172 softc->bop = 1; in sagetpos()
5174 softc->bop = 0; in sagetpos()
5177 softc->eop = 1; in sagetpos()
5179 softc->eop = 0; in sagetpos()
5182 || (softc->set_pews_status != 0)) { in sagetpos()
5183 softc->bpew = 1; in sagetpos()
5184 if (softc->set_pews_status > 0) in sagetpos()
5185 softc->set_pews_status--; in sagetpos()
5187 softc->bpew = 0; in sagetpos()
5193 softc->quirks |= SA_QUIRK_NO_LONG_POS; in sagetpos()
5197 softc->rep_fileno = softc->rep_blkno = (daddr_t) -1; in sagetpos()
5198 softc->partition = (daddr_t) -1; in sagetpos()
5199 softc->bop = softc->eop = softc->bpew = -1; in sagetpos()
5212 struct sa_softc *softc = (struct sa_softc *)periph->softc; in sardpos() local
5225 if (hard && (softc->flags & SA_FLAG_TAPE_WRITTEN)) { in sardpos()
5234 softc->timeout_info[SA_TIMEOUT_READ_POSITION]); in sardpos()
5235 softc->dsreg = MTIO_DSREG_RBSY; in sardpos()
5236 error = cam_periph_runccb(ccb, saerror, 0, 0, softc->device_stats); in sardpos()
5237 softc->dsreg = MTIO_DSREG_REST; in sardpos()
5255 struct sa_softc *softc; in sasetpos() local
5268 softc = (struct sa_softc *)periph->softc; in sasetpos()
5303 softc->timeout_info[SA_TIMEOUT_LOCATE]); in sasetpos()
5316 softc->timeout_info[SA_TIMEOUT_LOCATE]); in sasetpos()
5319 softc->dsreg = MTIO_DSREG_POS; in sasetpos()
5320 error = cam_periph_runccb(ccb, saerror, 0, 0, softc->device_stats); in sasetpos()
5321 softc->dsreg = MTIO_DSREG_REST; in sasetpos()
5328 softc->fileno = softc->blkno = (daddr_t) -1; in sasetpos()
5336 softc->partition = locate_info->partition; in sasetpos()
5338 softc->partition = (daddr_t) -1; in sasetpos()
5347 softc->fileno = locate_info->logical_id; in sasetpos()
5348 softc->blkno = 0; in sasetpos()
5370 struct sa_softc *softc; in saretension() local
5373 softc = (struct sa_softc *)periph->softc; in saretension()
5380 softc->timeout_info[SA_TIMEOUT_LOAD]); in saretension()
5382 softc->dsreg = MTIO_DSREG_TEN; in saretension()
5383 error = cam_periph_runccb(ccb, saerror, 0, 0, softc->device_stats); in saretension()
5384 softc->dsreg = MTIO_DSREG_REST; in saretension()
5388 softc->partition = softc->fileno = softc->blkno = (daddr_t) 0; in saretension()
5391 softc->partition = softc->fileno = softc->blkno = (daddr_t) -1; in saretension()
5399 struct sa_softc *softc; in sareservereleaseunit() local
5402 softc = (struct sa_softc *)periph->softc; in sareservereleaseunit()
5407 FALSE, 0, SSD_FULL_SIZE, softc->timeout_info[SA_TIMEOUT_RESERVE], in sareservereleaseunit()
5409 softc->dsreg = MTIO_DSREG_RBSY; in sareservereleaseunit()
5411 SF_RETRY_UA | SF_NO_PRINT, softc->device_stats); in sareservereleaseunit()
5412 softc->dsreg = MTIO_DSREG_REST; in sareservereleaseunit()
5430 struct sa_softc *softc; in saloadunload() local
5433 softc = (struct sa_softc *)periph->softc; in saloadunload()
5440 softc->timeout_info[SA_TIMEOUT_LOAD]); in saloadunload()
5442 softc->dsreg = (load)? MTIO_DSREG_LD : MTIO_DSREG_UNL; in saloadunload()
5443 error = cam_periph_runccb(ccb, saerror, 0, 0, softc->device_stats); in saloadunload()
5444 softc->dsreg = MTIO_DSREG_REST; in saloadunload()
5448 softc->partition = softc->fileno = softc->blkno = (daddr_t) -1; in saloadunload()
5449 softc->rep_fileno = softc->rep_blkno = (daddr_t) -1; in saloadunload()
5451 softc->partition = softc->fileno = softc->blkno = (daddr_t) 0; in saloadunload()
5462 struct sa_softc *softc; in saerase() local
5465 softc = (struct sa_softc *)periph->softc; in saerase()
5466 if (softc->open_rdonly) in saerase()
5472 SSD_FULL_SIZE, softc->timeout_info[SA_TIMEOUT_ERASE]); in saerase()
5474 softc->dsreg = MTIO_DSREG_ZER; in saerase()
5475 error = cam_periph_runccb(ccb, saerror, 0, 0, softc->device_stats); in saerase()
5476 softc->dsreg = MTIO_DSREG_REST; in saerase()
5732 safilldensitysb(struct sa_softc *softc, int *indent, struct sbuf *sb) in safilldensitysb() argument
5737 SASBADDUINTDESC(sb, *indent, softc->media_density, %u, media_density, in safilldensitysb()
5743 if (softc->density_info_valid[i] == 0) in safilldensitysb()
5747 if (softc->density_type_bits[i] & SRDS_MEDIUM_TYPE) { in safilldensitysb()
5757 if (softc->density_type_bits[i] & SRDS_MEDIA) in safilldensitysb()
5764 safilldenstypesb(sb, indent, softc->density_info[i], in safilldensitysb()
5765 softc->density_info_valid[i], is_density); in safilldensitysb()
5777 saloadtimeouts(struct sa_softc *softc, union ccb *ccb) in saloadtimeouts() argument
5793 xpt_print(softc->periph->path, "WARNING: available timeout " in saloadtimeouts()
5845 softc->timeout_info[SA_TIMEOUT_ERASE] = rec_time; in saloadtimeouts()
5848 softc->timeout_info[SA_TIMEOUT_LOAD] = rec_time; in saloadtimeouts()
5855 softc->timeout_info[SA_TIMEOUT_LOCATE] = rec_time; in saloadtimeouts()
5862 softc->timeout_info[SA_TIMEOUT_MODE_SELECT] = rec_time; in saloadtimeouts()
5869 softc->timeout_info[SA_TIMEOUT_MODE_SENSE] = rec_time; in saloadtimeouts()
5872 softc->timeout_info[SA_TIMEOUT_PREVENT] = rec_time; in saloadtimeouts()
5875 softc->timeout_info[SA_TIMEOUT_READ] = rec_time; in saloadtimeouts()
5878 softc->timeout_info[SA_TIMEOUT_READ_BLOCK_LIMITS] = in saloadtimeouts()
5888 softc->timeout_info[SA_TIMEOUT_READ_POSITION] =rec_time; in saloadtimeouts()
5891 softc->timeout_info[SA_TIMEOUT_REP_DENSITY] = rec_time; in saloadtimeouts()
5896 softc->timeout_info[SA_TIMEOUT_RESERVE] = rec_time; in saloadtimeouts()
5899 softc->timeout_info[SA_TIMEOUT_REWIND] = rec_time; in saloadtimeouts()
5902 softc->timeout_info[SA_TIMEOUT_SPACE] = rec_time; in saloadtimeouts()
5905 softc->timeout_info[SA_TIMEOUT_TUR] = rec_time; in saloadtimeouts()
5908 softc->timeout_info[SA_TIMEOUT_WRITE] = rec_time; in saloadtimeouts()
5911 softc->timeout_info[SA_TIMEOUT_WRITE_FILEMARKS] = in saloadtimeouts()