Lines Matching +full:conf +full:- +full:cmd +full:- +full:dat

1 /*-
4 * SPDX-License-Identifier: BSD-2-Clause
45 #include <sys/conf.h>
105 if (((ccb)->ccb_h.status & CAM_DEV_QFRZN) != 0) \
106 cam_release_devq((ccb)->ccb_h.path, 0, 0, 0, FALSE)
182 * CODES. (If the drive supports it, SPC-4/LTO-5 and newer should.)
185 * 4. Instance-specific loader tunables, used for say sa5.
321 indent -= 2; \
371 #define SA_PROT_ENABLED(softc) ((softc->flags & SA_FLAG_PROTECT_SUPP) \
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
422 * Current position information. -1 means that the given value is
466 open_rdonly : 1, /* open read-only */
508 "VIPER 2525 25462", "-011"},
535 "HP-88780*", "*"}, SA_QUIRK_VARIABLE|SA_QUIRK_2FM, 0
555 "DAT 06241-XXX", "*"}, SA_QUIRK_VARIABLE|SA_QUIRK_2FM, 0
693 /* For 2.2-stable support */
717 periph = (struct cam_periph *)dev->si_drv1; in saopen()
724 softc = (struct sa_softc *)periph->softc; in saopen()
726 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE|CAM_DEBUG_INFO, 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()
756 * If the mount fails and this was a non-blocking open, 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()
795 periph = (struct cam_periph *)dev->si_drv1; in saclose()
798 softc = (struct sa_softc *)periph->softc; in saclose()
800 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE|CAM_DEBUG_INFO, 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()
838 xpt_print(periph->path, in saclose()
840 softc->flags |= SA_FLAG_TAPE_FROZEN; in saclose()
851 if ((softc->flags & SA_FLAG_TAPE_MOUNTED) == 0) { in saclose()
870 * If the rewind fails, return an error- if anyone cares, in saclose()
891 if (error == 0 && writing && (softc->quirks & SA_QUIRK_2FM)) { in saclose()
892 tmp = saspace(periph, -1, SS_FILEMARKS); in saclose()
894 xpt_print(periph->path, "unable to backspace " in saclose()
897 xpt_print(periph->path, "it is possible that " in saclose()
900 softc->flags |= SA_FLAG_TAPE_FROZEN; in saclose()
905 xpt_print(periph->path, "unknown mode 0x%x in saclose\n", mode); 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()
935 xpt_print(periph->path, "tape is now frozen- use an OFFLINE, " in saclose()
940 if ((softc->flags & SA_FLAG_TAPE_MOUNTED) == 0) in saclose()
961 bp->bio_resid = bp->bio_bcount; in sastrategy()
962 if (SA_IS_CTRL(bp->bio_dev)) { in sastrategy()
966 periph = (struct cam_periph *)bp->bio_dev->si_drv1; in sastrategy()
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()
985 * system call traps attempts to write to a read-only in sastrategy()
988 if (bp->bio_cmd == BIO_WRITE && softc->open_rdonly) { in sastrategy()
994 if (softc->open_pending_mount) { in sastrategy()
995 int error = samount(periph, 0, bp->bio_dev); in sastrategy()
1002 softc->open_pending_mount = 0; in sastrategy()
1008 if (bp->bio_bcount == 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()
1024 xpt_print(periph->path, "Invalid request. Fixed block " 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()
1034 xpt_print_path(periph->path); 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()
1053 CAM_DEBUG(periph->path, CAM_DEBUG_INFO, in sastrategy()
1054 ("sastrategy: queuing a %ld %s byte %s\n", bp->bio_bcount, in sastrategy()
1055 (softc->flags & SA_FLAG_FIXED)? "fixed" : "variable", in sastrategy()
1056 (bp->bio_cmd == BIO_READ)? "read" : "write")); in sastrategy()
1058 if (softc->queue_count > 1) { in sastrategy()
1059 CAM_DEBUG(periph->path, CAM_DEBUG_INFO, in sastrategy()
1060 ("sastrategy: queue count now %d\n", softc->queue_count)); in sastrategy()
1080 softc = (struct sa_softc *)periph->softc; in sasetsili()
1082 if (ps->value_type != MT_PARAM_SET_SIGNED) { in sasetsili()
1083 snprintf(ps->error_str, sizeof(ps->error_str), in sasetsili()
1087 if ((ps->value.value_signed < 0) in sasetsili()
1088 || (ps->value.value_signed > 1)) { in sasetsili()
1089 snprintf(ps->error_str, sizeof(ps->error_str), in sasetsili()
1090 "invalid sili value %jd", (intmax_t)ps->value.value_signed); in sasetsili()
1098 if (softc->flags & SA_FLAG_FIXED) { in sasetsili()
1099 snprintf(ps->error_str, sizeof(ps->error_str), in sasetsili()
1103 if (softc->sili == ps->value.value_signed) in sasetsili()
1106 if (ps->value.value_signed == 1) in sasetsili()
1114 snprintf(ps->error_str, sizeof(ps->error_str), in sasetsili()
1119 softc->sili = ps->value.value_signed; in sasetsili()
1122 ps->status = MT_PARAM_STATUS_OK; in sasetsili()
1126 ps->status = MT_PARAM_STATUS_ERROR; in sasetsili()
1140 softc = (struct sa_softc *)periph->softc; in saseteotwarn()
1142 if (ps->value_type != MT_PARAM_SET_SIGNED) { in saseteotwarn()
1143 snprintf(ps->error_str, sizeof(ps->error_str), in saseteotwarn()
1145 ps->status = MT_PARAM_STATUS_ERROR; in saseteotwarn()
1148 if ((ps->value.value_signed < 0) in saseteotwarn()
1149 || (ps->value.value_signed > 1)) { in saseteotwarn()
1150 snprintf(ps->error_str, sizeof(ps->error_str), in saseteotwarn()
1152 (intmax_t)ps->value.value_signed); in saseteotwarn()
1153 ps->status = MT_PARAM_STATUS_ERROR; in saseteotwarn()
1156 softc->eot_warn = ps->value.value_signed; in saseteotwarn()
1157 ps->status = MT_PARAM_STATUS_OK; in saseteotwarn()
1159 if (ps->status != MT_PARAM_STATUS_OK) in saseteotwarn()
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()
1184 SASBADDUINTDESC(sb, *indent, prot->prot_method, %u, in safillprot()
1186 SASBADDUINTDESC(sb, *indent, prot->pi_length, %u, in safillprot()
1188 SASBADDUINTDESC(sb, *indent, prot->lbp_w, %u, in safillprot()
1190 SASBADDUINTDESC(sb, *indent, prot->lbp_r, %u, in safillprot()
1192 SASBADDUINTDESC(sb, *indent, prot->rbdp, %u, in safillprot()
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()
1306 if (ent->param_type != ps[i].value_type) { in sasetprotents()
1310 ps[i].value_type, ent->param_type); in sasetprotents()
1314 if ((ps[i].value.value_unsigned < ent->min_val) in sasetprotents()
1315 || (ps[i].value.value_unsigned > ent->max_val)) { in sasetprotents()
1318 "Value %ju is outside valid range %u - %u", in sasetprotents()
1319 (uintmax_t)ps[i].value.value_unsigned, ent->min_val, in sasetprotents()
1320 ent->max_val); in sasetprotents()
1324 *(ent->value) = ps[i].value.value_unsigned; in sasetprotents()
1381 if (strcmp(ps->value_name, sa_param_table[i].name) != 0) in safindparament()
1384 if (strncmp(ps->value_name, sa_param_table[i].name, in safindparament()
1410 if (list->num_params == 0) in saparamsetlist()
1417 if ((list->num_params * sizeof(struct mtparamset)) != in saparamsetlist()
1418 list->param_len) { in saparamsetlist()
1419 xpt_print(periph->path, "%s: length of params %d != " in saparamsetlist()
1421 __func__, list->param_len, sizeof(struct mtparamset), in saparamsetlist()
1422 list->num_params); in saparamsetlist()
1432 params = malloc(list->param_len, M_SCSISA, M_WAITOK | M_ZERO); in saparamsetlist()
1433 error = copyin(list->params, params, list->param_len); in saparamsetlist()
1439 params = list->params; in saparamsetlist()
1445 for (i = 0; i < list->num_params; i++) { in saparamsetlist()
1468 error = first_ent->set_func(periph, first, in saparamsetlist()
1479 if (ent->param_type == SA_PARAM_TYPE_NODE) { in saparamsetlist()
1484 error = ent->set_func(periph, &params[i], 1); in saparamsetlist()
1492 first_ent->set_func(periph, first, contig_ents); in saparamsetlist()
1500 error1 = copyout(params, list->params, list->param_len); in saparamsetlist()
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()
1551 if (softc->open_pending_mount) { \
1557 softc->open_pending_mount = 0; \
1561 saioctl(struct cdev *dev, u_long cmd, caddr_t arg, int flag, struct thread *td) in saioctl() argument
1574 periph = (struct cam_periph *)dev->si_drv1; in saioctl()
1576 softc = (struct sa_softc *)periph->softc; in saioctl()
1587 switch (cmd) { in saioctl()
1604 if ((periph->flags & CAM_PERIPH_LOCKED) == 0) { in saioctl()
1622 switch (mt->mt_op) { in saioctl()
1659 switch (cmd) { in saioctl()
1668 g->mt_type = MT_ISAR; in saioctl()
1669 if (softc->flags & SA_FLAG_COMP_UNSUPP) { in saioctl()
1670 g->mt_comp = MT_COMP_UNSUPP; in saioctl()
1671 g->mt_comp0 = MT_COMP_UNSUPP; in saioctl()
1672 g->mt_comp1 = MT_COMP_UNSUPP; in saioctl()
1673 g->mt_comp2 = MT_COMP_UNSUPP; in saioctl()
1674 g->mt_comp3 = MT_COMP_UNSUPP; in saioctl()
1676 if ((softc->flags & SA_FLAG_COMP_ENABLED) == 0) { in saioctl()
1677 g->mt_comp = MT_COMP_DISABLED; 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()
1733 sb = sbuf_new(NULL, NULL, g->alloc_len, SBUF_FIXEDLEN); in saioctl()
1735 g->status = MT_EXT_GET_ERROR; in saioctl()
1736 snprintf(g->error_str, sizeof(g->error_str), in saioctl()
1738 g->alloc_len); in saioctl()
1744 if (cmd == MTIOCEXTGET) in saioctl()
1754 g->status = MT_EXT_GET_NEED_MORE_SPACE; in saioctl()
1757 g->status = MT_EXT_GET_ERROR; in saioctl()
1758 snprintf(g->error_str, sizeof(g->error_str), in saioctl()
1761 g->status = MT_EXT_GET_OK; in saioctl()
1765 g->fill_len = strlen(tmpstr2) + 1; in saioctl()
1768 error = copyout(tmpstr2, g->status_xml, g->fill_len); in saioctl()
1799 &((union mterrstat *)arg)->scsi_errstat; in saioctl()
1801 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, 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()
1807 sizeof (sep->io_sense)); in saioctl()
1808 bcopy((caddr_t) &softc->last_io_cdb, sep->io_cdb, in saioctl()
1809 sizeof (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()
1812 sizeof (sep->ctl_sense)); in saioctl()
1813 bcopy((caddr_t) &softc->last_ctl_cdb, sep->ctl_cdb, in saioctl()
1814 sizeof (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()
1832 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, in saioctl()
1834 mt->mt_op, mt->mt_count)); in saioctl()
1836 count = mt->mt_count; in saioctl()
1837 switch (mt->mt_op) { in saioctl()
1838 case MTWEOF: /* write an end-of-file marker */ in saioctl()
1848 /* write an end-of-file marker without waiting */ in saioctl()
1865 nmarks = softc->filemarks; in saioctl()
1868 xpt_print(periph->path, in saioctl()
1870 softc->flags |= SA_FLAG_EIO_PENDING; in saioctl()
1873 nmarks -= softc->filemarks; in saioctl()
1874 switch(mt->mt_op) { in saioctl()
1876 count = -count; in saioctl()
1882 count = -count; in saioctl()
1887 count = -count; in saioctl()
1904 nmarks = softc->filemarks; in saioctl()
1911 nmarks -= softc->filemarks; in saioctl()
1912 error = saspace(periph, count - nmarks, spaceop); in saioctl()
1916 * don't know what the applications wishes to do next- in saioctl()
1922 softc->flags &= in saioctl()
1924 softc->filemarks = 0; in saioctl()
1932 softc->flags &= in saioctl()
1934 softc->flags &= ~SA_FLAG_ERR_PENDING; in saioctl()
1935 softc->filemarks = 0; in saioctl()
1940 softc->flags &= in saioctl()
1942 softc->flags &= ~SA_FLAG_ERR_PENDING; in saioctl()
1944 case MTRETENS: /* re-tension tape */ in saioctl()
1947 softc->flags &= in saioctl()
1949 softc->flags &= ~SA_FLAG_ERR_PENDING; 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()
1990 if ((softc->sili != 0) in saioctl()
1992 xpt_print(periph->path, "Can't enter fixed " 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()
2007 ffs(count) - 1; 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()
2056 if ((softc->quirks & SA_QUIRK_NOCOMP) || in saioctl()
2057 (softc->flags & SA_FLAG_COMP_UNSUPP)) { in saioctl()
2088 if (cmd == MTIOCSLOCATE) 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()
2141 error = cam_periph_ioctl(periph, cmd, arg, saerror); in saioctl()
2148 if (error == 0 && (softc->flags & SA_FLAG_TAPE_FROZEN)) { in saioctl()
2149 switch(cmd) { 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()
2163 xpt_print(periph->path, in saioctl()
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()
2243 softc = (struct sa_softc *)periph->softc; in saoninvalidate()
2246 * De-register any async callbacks. in saoninvalidate()
2248 xpt_register_async(0, saasync, periph, periph->path); 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()
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()
2283 xpt_print(periph->path, "can't remove sysctl context\n"); in sacleanup()
2287 devstat_remove_entry(softc->device_stats); in sacleanup()
2309 if (cgd->protocol != PROTO_SCSI) in saasync()
2311 if (SID_QUAL(&cgd->inq_data) != SID_QUAL_LU_CONNECTED) in saasync()
2313 if (SID_TYPE(&cgd->inq_data) != T_SEQUENTIAL) in saasync()
2342 dev->si_iosize_max = softc->maxio; in sasetupdev()
2343 dev->si_flags |= softc->si_flags; in sasetupdev()
2345 * Keep a count of how many non-alias devices we have created, in sasetupdev()
2349 if ((dev->si_flags & SI_ALIAS) == 0) in sasetupdev()
2350 softc->num_devs_to_destroy++; in sasetupdev()
2354 * Load the global (for all sa(4) instances) and per-instance tunable
2373 softc->timeout_info[i] = tmpval; in saloadtotunables()
2377 * per-instance timeout settings. in saloadtotunables()
2380 softc->periph->unit_number, sa_default_timeouts[i].desc); in saloadtotunables()
2383 softc->timeout_info[i] = tmpval; in saloadtotunables()
2399 if (periph->flags & CAM_PERIPH_INVALID) in sasysctlinit()
2402 softc = (struct sa_softc *)periph->softc; in sasysctlinit()
2404 snprintf(tmpstr, sizeof(tmpstr), "CAM SA unit %d", periph->unit_number); in sasysctlinit()
2405 snprintf(tmpstr2, sizeof(tmpstr2), "%u", periph->unit_number); 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()
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()
2504 match = cam_quirkmatch((caddr_t)&cgd->inq_data, in saregister()
2510 softc->quirks = ((struct sa_quirk_entry *)match)->quirks; in saregister()
2511 softc->last_media_blksize = in saregister()
2512 ((struct sa_quirk_entry *)match)->prefblk; in saregister()
2514 softc->quirks = SA_QUIRK_NONE; in saregister()
2523 softc->timeout_info[i] = sa_default_timeouts[i].value; in saregister()
2527 * was after SCSI-2. (Roughly equivalent to SCSI-3.) If the drive in saregister()
2528 * reports that it is SCSI-2 or older, it is unlikely to support in saregister()
2530 * claim to be SCSI-2, but do support long position information. in saregister()
2532 * for SCSI-2 devices, we'll try one pass through sagetpos(), and in saregister()
2535 if (cgd->inq_data.version <= SCSI_REV_CCS) in saregister()
2536 softc->quirks |= SA_QUIRK_NO_LONG_POS; in saregister()
2540 * SPC-4. That command optionally includes timeout data for in saregister()
2546 * timeouts with any user-specified values. in saregister()
2548 if (SID_ANSI_REV(&cgd->inq_data) >= SCSI_REV_SPC4) in saregister()
2549 softc->flags |= SA_FLAG_RSOC_TO_TRY; in saregister()
2551 if (cgd->inq_data.spc3_flags & SPC3_SID_PROTECT) { in saregister()
2558 xpt_setup_ccb(&cdai.ccb_h, periph->path, CAM_PRIORITY_NORMAL); in saregister()
2571 softc->flags |= SA_FLAG_PROTECT_SUPP; in saregister()
2574 xpt_path_inq(&cpi, periph->path); in saregister()
2582 softc->device_stats = devstat_new_entry("sa", periph->unit_number, 0, in saregister()
2583 DEVSTAT_BS_UNAVAILABLE, SID_TYPE(&cgd->inq_data) | in saregister()
2590 softc->allow_io_split = sa_allow_io_split; in saregister()
2593 * Load a per-instance tunable, if it exists. NOTE that this in saregister()
2597 periph->unit_number); 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()
2643 xpt_print(periph->path, "%s: lost periph during " 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()
2658 periph->periph_name, periph->unit_number); 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()
2667 periph->periph_name, periph->unit_number); 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()
2676 periph->periph_name, periph->unit_number); 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()
2685 periph->periph_name, periph->unit_number); 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()
2711 xpt_register_async(AC_LOST_DEVICE, saasync, periph, periph->path); in saregister()
2724 * 4. Instance-specific loader tunables, used for say sa5. in saregister()
2730 if (softc->flags & SA_FLAG_RSOC_TO_TRY) { in saregister()
2735 softc->state = SA_STATE_PROBE; in saregister()
2746 xpt_announce_quirks(periph, softc->quirks, SA_QUIRK_BIT_STRING); in saregister()
2757 softc = (struct sa_softc *)periph->softc; in sastart()
2759 CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("sastart\n")); 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()
2789 if (bp->bio_cmd == BIO_WRITE) 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()
2797 bp->bio_resid = bp->bio_bcount; in sastart()
2799 if ((softc->flags & SA_FLAG_EOM_PENDING) != 0) { in sastart()
2823 if (softc->eot_warn != 0) { in sastart()
2824 bp->bio_flags |= BIO_ERROR; in sastart()
2825 bp->bio_error = ENOSPC; in sastart()
2827 bp->bio_error = 0; in sastart()
2828 } else if ((softc->flags & SA_FLAG_EOF_PENDING) != 0) { in sastart()
2835 bp->bio_error = 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()
2841 bp->bio_error = EIO; in sastart()
2842 bp->bio_flags |= BIO_ERROR; in sastart()
2844 bp = bioq_first(&softc->bio_queue); in sastart()
2850 softc->flags &= ~SA_FLAG_ERR_PENDING; in sastart()
2851 CAM_DEBUG(periph->path, CAM_DEBUG_INFO, in sastart()
2852 ("sastart- ERR_PENDING now 0x%x, bp is %sNULL, " 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()
2864 if ((bp->bio_cmd != BIO_READ) && in sastart()
2865 (bp->bio_cmd != BIO_WRITE)) { in sastart()
2870 length = bp->bio_bcount; 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()
2878 bp->bio_error = EIO; in sastart()
2879 xpt_print(periph->path, "zero blocksize" in sastart()
2885 CAM_DEBUG(start_ccb->ccb_h.path, CAM_DEBUG_INFO, in sastart()
2887 length, (bp->bio_cmd == BIO_READ)? "read" : in sastart()
2892 CAM_DEBUG(start_ccb->ccb_h.path, CAM_DEBUG_INFO, in sastart()
2894 length, (bp->bio_cmd == BIO_READ)? "read" : in sastart()
2898 devstat_start_transaction_bio(softc->device_stats, bp); in sastart()
2912 * I believe that this is a non-issue. If user apps in sastart()
2928 * non-packetized SCSI, where you have to go back in sastart()
2932 softc->dsreg = (bp->bio_cmd == BIO_READ)? in sastart()
2934 scsi_sa_read_write(&start_ccb->csio, 0, sadone, in sastart()
2935 MSG_SIMPLE_Q_TAG, (bp->bio_cmd == BIO_READ ? in sastart()
2937 ((bp->bio_flags & BIO_UNMAPPED) != 0 ? in sastart()
2938 SCSI_RW_BIO : 0), softc->sili, in sastart()
2939 (softc->flags & SA_FLAG_FIXED) != 0, length, in sastart()
2940 (bp->bio_flags & BIO_UNMAPPED) != 0 ? (void *)bp : in sastart()
2941 bp->bio_data, bp->bio_bcount, SSD_FULL_SIZE, in sastart()
2942 (bp->bio_cmd == BIO_READ) ? in sastart()
2943 softc->timeout_info[SA_TIMEOUT_READ] : in sastart()
2944 softc->timeout_info[SA_TIMEOUT_WRITE]); in sastart()
2945 start_ccb->ccb_h.ccb_pflags &= ~SA_POSITION_UPDATED; in sastart()
2946 start_ccb->ccb_h.ccb_bp = bp; in sastart()
2947 bp = bioq_first(&softc->bio_queue); in sastart()
2963 * This is an arbitrary number. An IBM LTO-6 drive reports in sastart()
2964 * 67 entries, and an IBM LTO-9 drive reports 71 entries. in sastart()
2985 softc->state = SA_STATE_NORMAL; in sastart()
2988 xpt_announce_quirks(periph, softc->quirks, in sastart()
2995 scsi_report_supported_opcodes(&start_ccb->csio, in sastart()
3005 /*timeout*/ softc->timeout_info[SA_TIMEOUT_TUR]); in sastart()
3012 panic("state 0x%x in sastart", softc->state); in sastart()
3025 softc = (struct sa_softc *)periph->softc; in sadone()
3026 csio = &done_ccb->csio; in sadone()
3029 if (softc->state == SA_STATE_NORMAL) { in sadone()
3030 softc->dsreg = MTIO_DSREG_REST; in sadone()
3031 bp = (struct bio *)done_ccb->ccb_h.ccb_bp; in sadone()
3033 if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { in sadone()
3041 } else if (softc->state == SA_STATE_PROBE) { in sadone()
3043 if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { 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()
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()
3118 bp->bio_resid = bp->bio_bcount; in sadone()
3119 bp->bio_error = error; in sadone()
3120 bp->bio_flags |= BIO_ERROR; in sadone()
3125 bp->bio_resid = csio->resid; in sadone()
3126 bp->bio_error = 0; in sadone()
3127 if (csio->resid != 0) { in sadone()
3128 bp->bio_flags |= BIO_ERROR; in sadone()
3130 if (bp->bio_cmd == BIO_WRITE) { in sadone()
3131 softc->flags |= SA_FLAG_TAPE_WRITTEN; in sadone()
3132 softc->filemarks = 0; in sadone()
3134 if (!(csio->ccb_h.ccb_pflags & SA_POSITION_UPDATED) && 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()
3139 l = bp->bio_bcount >> in sadone()
3140 softc->blk_shift; in sadone()
3142 l = bp->bio_bcount / 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()
3156 cam_release_devq(done_ccb->ccb_h.path, 0, 0, 0, 0); in sadone()
3157 if (error || bp->bio_resid) { in sadone()
3158 CAM_DEBUG(periph->path, CAM_DEBUG_INFO, in sadone()
3160 bp->bio_resid, bp->bio_bcount)); in sadone()
3162 biofinish(bp, softc->device_stats, 0); in sadone()
3177 * oflags can be checked for 'kind' of open (read-only check) - later in samount()
3178 * dev can be checked for a control-mode or compression open - later in samount()
3183 softc = (struct sa_softc *)periph->softc; in samount()
3188 * to retry this command- we just want the status. But we only in samount()
3189 * do this if we're mounted already- if we're not mounted, in samount()
3194 if (softc->flags & SA_FLAG_TAPE_MOUNTED) { in samount()
3196 scsi_test_unit_ready(&ccb->csio, 0, NULL, 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()
3203 scsi_test_unit_ready(&ccb->csio, 0, NULL, 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()
3214 if (CAM_DEBUGGED(periph->path, CAM_DEBUG_INFO)) { in samount()
3215 xpt_print(periph->path, in samount()
3225 scsi_test_unit_ready(&ccb->csio, 0, NULL, 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()
3247 scsi_load_unload(&ccb->csio, 2, NULL, MSG_SIMPLE_Q_TAG, FALSE, in samount()
3249 softc->timeout_info[SA_TIMEOUT_LOAD]); in samount()
3251 softc->device_stats); in samount()
3257 scsi_rewind(&ccb->csio, 2, NULL, MSG_SIMPLE_Q_TAG, in samount()
3259 softc->timeout_info[SA_TIMEOUT_REWIND]); in samount()
3261 softc->device_stats); in samount()
3278 xpt_print(periph->path, "no memory for test read\n"); in samount()
3284 if ((softc->quirks & SA_QUIRK_NODREAD) == 0) { in samount()
3285 scsi_sa_read_write(&ccb->csio, 0, NULL, in samount()
3288 softc->timeout_info[SA_TIMEOUT_READ]); in samount()
3290 softc->device_stats); in samount()
3291 scsi_rewind(&ccb->csio, 1, NULL, MSG_SIMPLE_Q_TAG, in samount()
3293 softc->timeout_info[SA_TIMEOUT_REWIND]); in samount()
3296 softc->device_stats); in samount()
3298 xpt_print(periph->path, in samount()
3308 scsi_read_block_limits(&ccb->csio, 5, NULL, MSG_SIMPLE_Q_TAG, 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()
3319 * If it's less than SCSI-2, READ BLOCK LIMITS is not in samount()
3320 * a MANDATORY command. Anyway- it doesn't matter- 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()
3334 * fixed mode- but note that whatever we get out of 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()
3461 xpt_print(periph->path, 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()
3496 xpt_print(periph->path, 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()
3523 xpt_print(periph->path, 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()
3545 * The SCSI-3 spec allows 0 to mean "unspecified". in samount()
3546 * The SCSI-1 spec allows 0 to mean 'infinite'. 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()
3581 xpt_print(periph->path, 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()
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()
3670 "%d-byte tape record bigger than supplied buffer\n"; in saerror()
3682 periph = xpt_path_periph(ccb->ccb_h.path); in saerror()
3683 softc = (struct sa_softc *)periph->softc; in saerror()
3684 csio = &ccb->csio; in saerror()
3685 sense = &csio->sense_data; in saerror()
3686 sense_len = csio->sense_len - csio->sense_resid; in saerror()
3689 if (asc != -1 && ascq != -1) in saerror()
3699 status = csio->ccb_h.status & CAM_STATUS_MASK; in saerror()
3702 * Calculate/latch up, any residuals... We do this in a funny 2-step in saerror()
3709 if ((softc->flags & SA_FLAG_FIXED) != 0) in saerror()
3710 resid *= softc->media_blksize; in saerror()
3712 resid = csio->dxfer_len; 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()
3719 if (csio->cdb_io.cdb_bytes[0] == SA_READ || in saerror()
3720 csio->cdb_io.cdb_bytes[0] == SA_WRITE) { 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()
3724 (int) csio->cdb_len); 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()
3731 (int) csio->cdb_len); in saerror()
3732 softc->last_ctl_resid = resid; in saerror()
3733 softc->last_resid_was_io = 0; in saerror()
3735 CAM_DEBUG(periph->path, CAM_DEBUG_INFO, ("CDB[0]=0x%x Key 0x%x " in saerror()
3737 "dxfer_len %d\n", csio->cdb_io.cdb_bytes[0] & 0xff, in saerror()
3740 csio->dxfer_len)); in saerror()
3742 CAM_DEBUG(periph->path, CAM_DEBUG_INFO, in saerror()
3753 if (csio->cdb_io.cdb_bytes[0] == SA_READ || in saerror()
3754 csio->cdb_io.cdb_bytes[0] == SA_WRITE) { in saerror()
3765 csio->resid = resid; in saerror()
3780 if (ccb->ccb_h.retry_count <= 0) { in saerror()
3794 if (csio->cdb_io.cdb_bytes[0] == SA_WRITE) { in saerror()
3796 csio->resid = resid; in saerror()
3799 softc->flags |= SA_FLAG_EOM_PENDING; in saerror()
3802 * I've actually seen a non-zero resid, in saerror()
3806 csio->resid = 0; in saerror()
3809 csio->resid = resid; 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()
3819 error = -1; 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()
3829 csio->ccb_h.ccb_pflags |= SA_POSITION_UPDATED; in saerror()
3839 xpt_print(csio->ccb_h.path, toobig, in saerror()
3840 csio->dxfer_len - info); in saerror()
3841 csio->resid = csio->dxfer_len; in saerror()
3844 csio->resid = resid; 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()
3856 csio->ccb_h.ccb_pflags |= in saerror()
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()
3921 scsi_mode_sense(&ccb->csio, 5, NULL, MSG_SIMPLE_Q_TAG, FALSE, in sagetparams()
3924 SSD_FULL_SIZE, softc->timeout_info[SA_TIMEOUT_MODE_SENSE]); in sagetparams()
3927 softc->device_stats); in sagetparams()
3929 status = ccb->ccb_h.status & CAM_STATUS_MASK; in sagetparams()
3943 softc->quirks |= SA_QUIRK_NOCOMP; in sagetparams()
3948 scsi_sense_print(&ccb->csio); in sagetparams()
3960 if ((mode_hdr->blk_desc_len == 0) && in sagetparams()
3968 mode_buffer_len -= sizeof (sa_comp_t); in sagetparams()
3983 scsi_mode_sense(&ccb->csio, 2, NULL, MSG_SIMPLE_Q_TAG, FALSE, in sagetparams()
3986 softc->timeout_info[SA_TIMEOUT_MODE_SENSE]); in sagetparams()
3989 softc->device_stats); in sagetparams()
3996 *blocksize = scsi_3btoul(mode_blk->blklen); in sagetparams()
3999 *numblocks = scsi_3btoul(mode_blk->nblocks); in sagetparams()
4002 *buff_mode = mode_hdr->dev_spec & SMH_SA_BUF_MODE_MASK; in sagetparams()
4005 *density = mode_blk->density; in sagetparams()
4008 *write_protect = (mode_hdr->dev_spec & SMH_SA_WP)? TRUE : FALSE; in sagetparams()
4011 *speed = mode_hdr->dev_spec & SMH_SA_SPEED_MASK; in sagetparams()
4016 struct scsi_data_compression_page *cp = &ntcs->dcomp; in sagetparams()
4018 (cp->dce_and_dcc & SA_DCP_DCC)? TRUE : FALSE; in sagetparams()
4020 (cp->dce_and_dcc & SA_DCP_DCE)? TRUE : FALSE; in sagetparams()
4021 *comp_algorithm = scsi_4btoul(cp->comp_algorithm); in sagetparams()
4023 struct scsi_dev_conf_page *cp = &ntcs->dconf; in sagetparams()
4031 (cp->sel_comp_alg != SA_COMP_NONE)? TRUE : FALSE; in sagetparams()
4032 *comp_algorithm = cp->sel_comp_alg; in sagetparams()
4039 && (softc->scsi_rev >= SCSI_REV_SPC)) { in sagetparams()
4043 scsi_report_density_support(&ccb->csio, 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()
4057 status = ccb->ccb_h.status & CAM_STATUS_MASK; 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()
4078 ccb->csio.resid; in sagetparams()
4086 && (softc->flags & SA_FLAG_PROTECT_SUPP)) { in sagetparams()
4103 scsi_mode_sense_len(&ccb->csio, in sagetparams()
4117 softc->timeout_info[SA_TIMEOUT_MODE_SENSE]); in sagetparams()
4122 cdb = (struct scsi_mode_sense_10 *)ccb->csio.cdb_io.cdb_bytes; in sagetparams()
4123 cdb->subpage = SA_CTRL_DP_SUBPAGE_CODE; in sagetparams()
4126 softc->device_stats); in sagetparams()
4132 status = ccb->ccb_h.status & CAM_STATUS_MASK; in sagetparams()
4143 returned_len = ccb->csio.dxfer_len - ccb->csio.resid; in sagetparams()
4144 if (returned_len < sizeof(mode10_hdr->data_length)) { in sagetparams()
4151 sizeof(mode10_hdr->data_length) + in sagetparams()
4152 scsi_2btoul(mode10_hdr->data_length)); in sagetparams()
4163 + sizeof(dp_page->prot_bits))) { in sagetparams()
4169 prot = &softc->prot_info.cur_prot_state; in sagetparams()
4170 prot->prot_method = dp_page->prot_method; in sagetparams()
4171 prot->pi_length = dp_page->pi_length & in sagetparams()
4173 prot->lbp_w = (dp_page->prot_bits & SA_CTRL_DP_LBP_W) ? 1 :0; in sagetparams()
4174 prot->lbp_r = (dp_page->prot_bits & SA_CTRL_DP_LBP_R) ? 1 :0; in sagetparams()
4175 prot->rbdp = (dp_page->prot_bits & SA_CTRL_DP_RBDP) ? 1 :0; in sagetparams()
4176 prot->initialized = 1; in sagetparams()
4185 if (CAM_DEBUGGED(periph->path, CAM_DEBUG_INFO)) { in sagetparams()
4188 xpt_print_path(periph->path); in sagetparams()
4218 softc = (struct sa_softc *)periph->softc; in sasetprot()
4228 dp_page_length = dp_size - in sasetprot()
4261 if (scsi_2btoul(dp_changeable->length) > dp_page_length) { in sasetprot()
4262 dp_page_length = scsi_2btoul(dp_changeable->length); in sasetprot()
4289 scsi_ulto2b(0, mode10_hdr->data_length); in sasetprot()
4290 mode10_hdr->medium_type = 0; in sasetprot()
4292 scsi_ulto2b(0, mode10_hdr->blk_desc_len); in sasetprot()
4294 mode10_hdr->dev_spec = current_speed; in sasetprot()
4295 /* if set, set single-initiator buffering mode */ in sasetprot()
4296 if (softc->buffer_mode == SMH_SA_BUF_MODE_SIBUF) { in sasetprot()
4297 mode10_hdr->dev_spec |= SMH_SA_BUF_MODE_SIBUF; in sasetprot()
4304 if (dp_changeable->prot_method != 0) in sasetprot()
4305 dp_page->prot_method = new_prot->prot_method; in sasetprot()
4307 if (dp_changeable->pi_length & SA_CTRL_DP_PI_LENGTH_MASK) { in sasetprot()
4308 dp_page->pi_length &= ~SA_CTRL_DP_PI_LENGTH_MASK; in sasetprot()
4309 dp_page->pi_length |= (new_prot->pi_length & in sasetprot()
4312 if (dp_changeable->prot_bits & SA_CTRL_DP_LBP_W) { in sasetprot()
4313 if (new_prot->lbp_w) in sasetprot()
4314 dp_page->prot_bits |= SA_CTRL_DP_LBP_W; in sasetprot()
4316 dp_page->prot_bits &= ~SA_CTRL_DP_LBP_W; in sasetprot()
4319 if (dp_changeable->prot_bits & SA_CTRL_DP_LBP_R) { in sasetprot()
4320 if (new_prot->lbp_r) in sasetprot()
4321 dp_page->prot_bits |= SA_CTRL_DP_LBP_R; in sasetprot()
4323 dp_page->prot_bits &= ~SA_CTRL_DP_LBP_R; in sasetprot()
4326 if (dp_changeable->prot_bits & SA_CTRL_DP_RBDP) { in sasetprot()
4327 if (new_prot->rbdp) in sasetprot()
4328 dp_page->prot_bits |= SA_CTRL_DP_RBDP; in sasetprot()
4330 dp_page->prot_bits &= ~SA_CTRL_DP_RBDP; in sasetprot()
4335 scsi_mode_select_len(&ccb->csio, 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()
4352 if ((ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) { in sasetprot()
4377 * - blocksize
4378 * - density
4379 * - compression / compression algorithm
4380 * - buffering mode
4410 softc = (struct sa_softc *)periph->softc; in sasetparams()
4457 cpage->hdr.pagecode &= ~0x80; in sasetparams()
4468 scsi_ulto3b(blocksize, mode_blk->blklen); in sasetparams()
4470 scsi_ulto3b(current_blocksize, mode_blk->blklen); in sasetparams()
4474 * SCSI_SAME_DENSITY only applies to SCSI-2 or better in sasetparams()
4478 mode_blk->density = density; in sasetparams()
4479 } else if (softc->scsi_rev > SCSI_REV_CCS) { in sasetparams()
4480 mode_blk->density = SCSI_SAME_DENSITY; in sasetparams()
4482 mode_blk->density = softc->media_density; in sasetparams()
4489 mode_hdr->data_length = 0; in sasetparams()
4490 mode_hdr->medium_type = 0; in sasetparams()
4493 mode_hdr->dev_spec = current_speed; in sasetparams()
4495 /* if set, set single-initiator buffering mode */ in sasetparams()
4496 if (softc->buffer_mode == SMH_SA_BUF_MODE_SIBUF) { in sasetparams()
4497 mode_hdr->dev_spec |= SMH_SA_BUF_MODE_SIBUF; in sasetparams()
4501 mode_hdr->blk_desc_len = sizeof(struct scsi_mode_blk_desc); in sasetparams()
4503 mode_hdr->blk_desc_len = 0; in sasetparams()
4513 * If the compression algorithm is non-zero, enable in sasetparams()
4518 * non-zero, we leave it as-is. If it is zero, and we have in sasetparams()
4523 switch (ccomp->hdr.pagecode & ~0x80) { in sasetparams()
4526 struct scsi_dev_conf_page *dcp = &cpage->dconf; in sasetparams()
4528 dcp->sel_comp_alg = SA_COMP_NONE; in sasetparams()
4532 dcp->sel_comp_alg = calg; in sasetparams()
4533 } else if (dcp->sel_comp_alg == SA_COMP_NONE && in sasetparams()
4534 softc->saved_comp_algorithm != 0) { in sasetparams()
4535 dcp->sel_comp_alg = softc->saved_comp_algorithm; in sasetparams()
4540 if (ccomp->dcomp.dce_and_dcc & SA_DCP_DCC) { in sasetparams()
4541 struct scsi_data_compression_page *dcp = &cpage->dcomp; in sasetparams()
4548 dcp->dce_and_dcc = SA_DCP_DCC; in sasetparams()
4549 dcp->dde_and_red |= SA_DCP_DDE; in sasetparams()
4553 dcp->dce_and_dcc = SA_DCP_DCE | SA_DCP_DCC; in sasetparams()
4554 dcp->dde_and_red |= SA_DCP_DDE; in sasetparams()
4563 scsi_ulto4b(calg, dcp->comp_algorithm); in sasetparams()
4564 scsi_ulto4b(calg, dcp->decomp_algorithm); in sasetparams()
4565 } else if (scsi_4btoul(dcp->comp_algorithm) == 0 && in sasetparams()
4566 softc->saved_comp_algorithm != 0) { in sasetparams()
4567 scsi_ulto4b(softc->saved_comp_algorithm, in sasetparams()
4568 dcp->comp_algorithm); in sasetparams()
4569 scsi_ulto4b(softc->saved_comp_algorithm, in sasetparams()
4570 dcp->decomp_algorithm); in sasetparams()
4575 * Compression does not appear to be supported- in sasetparams()
4590 xpt_print(periph->path, in sasetparams()
4609 mode_buffer_len -= sizeof(sa_comp_t); in sasetparams()
4614 scsi_mode_select(&ccb->csio, 5, NULL, MSG_SIMPLE_Q_TAG, in sasetparams()
4617 softc->timeout_info[SA_TIMEOUT_MODE_SELECT]); in sasetparams()
4620 sense_flags, softc->device_stats); in sasetparams()
4622 if (CAM_DEBUGGED(periph->path, CAM_DEBUG_INFO)) { in sasetparams()
4625 xpt_print_path(periph->path); in sasetparams()
4652 scsi_ulto3b(current_blocksize, mode_blk->blklen); in sasetparams()
4656 * SCSI_SAME_DENSITY only applies to SCSI-2 or better in sasetparams()
4660 mode_blk->density = current_density; in sasetparams()
4661 } else if (softc->scsi_rev > SCSI_REV_CCS) { in sasetparams()
4662 mode_blk->density = SCSI_SAME_DENSITY; in sasetparams()
4664 mode_blk->density = softc->media_density; in sasetparams()
4674 ccb->ccb_h.retry_count = 1; in sasetparams()
4676 softc->device_stats); in sasetparams()
4686 softc->flags &= ~SA_FLAG_COMP_ENABLED; in sasetparams()
4691 * softc->flags &= ~SA_FLAG_COMP_SUPP; 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()
4716 softc = (struct sa_softc *)periph->softc; in saextget()
4723 if (!SA_IS_CTRL(dev) && !softc->open_pending_mount) in saextget()
4731 SASBADDVARSTR(sb, indent, periph->periph_name, %s, periph_name, in saextget()
4732 strlen(periph->periph_name) + 1); in saextget()
4733 SASBADDUINT(sb, indent, periph->unit_number, %u, unit_number); in saextget()
4736 periph->path, in saextget()
4741 g->status = MT_EXT_GET_ERROR; in saextget()
4742 snprintf(g->error_str, sizeof(g->error_str), in saextget()
4808 SASBADDUINTDESC(sb, indent, softc->maxio, %u, maxio, in saextget()
4811 SASBADDUINTDESC(sb, indent, softc->cpi_maxio, %u, cpi_maxio, in saextget()
4814 SASBADDUINTDESC(sb, indent, softc->max_blk, %u, max_blk, in saextget()
4817 SASBADDUINTDESC(sb, indent, softc->min_blk, %u, min_blk, in saextget()
4820 SASBADDUINTDESC(sb, indent, softc->blk_gran, %u, blk_gran, in saextget()
4823 maxio_tmp = min(softc->max_blk, softc->maxio); in saextget()
4828 SASBADDINTDESC(sb, indent, softc->flags & SA_FLAG_FIXED ? 1 : 0, %d, in saextget()
4834 if (softc->flags & SA_FLAG_COMP_UNSUPP) in saextget()
4840 if (softc->flags & SA_FLAG_COMP_ENABLED) in saextget()
4846 SASBADDUINTDESC(sb, indent, softc->comp_algorithm, %u, in saextget()
4851 SASBADDUINTDESC(sb, indent, softc->media_blksize, %u, in saextget()
4853 SASBADDINTDESC(sb, indent, (intmax_t)softc->fileno, %jd, in saextget()
4854 calculated_fileno, "Calculated file number, -1 if unknown"); in saextget()
4855 SASBADDINTDESC(sb, indent, (intmax_t)softc->blkno, %jd, in saextget()
4857 "set to -1 if unknown"); in saextget()
4858 SASBADDINTDESC(sb, indent, (intmax_t)softc->rep_fileno, %jd, in saextget()
4859 reported_fileno, "File number reported by drive, -1 if unknown"); in saextget()
4860 SASBADDINTDESC(sb, indent, (intmax_t)softc->rep_blkno, %jd, in saextget()
4862 "drive, -1 if unknown"); in saextget()
4863 SASBADDINTDESC(sb, indent, (intmax_t)softc->partition, %jd, in saextget()
4865 SASBADDINTDESC(sb, indent, softc->bop, %d, bop, in saextget()
4867 "not, -1 if unknown"); in saextget()
4868 SASBADDINTDESC(sb, indent, softc->eop, %d, eop, in saextget()
4869 "Set to 1 if drive is past early warning, 0 if not, -1 if unknown"); in saextget()
4870 SASBADDINTDESC(sb, indent, softc->bpew, %d, bpew, in saextget()
4872 "-1 if unknown"); in saextget()
4873 SASBADDINTDESC(sb, indent, (intmax_t)softc->last_io_resid, %jd, in saextget()
4879 SASBADDINTDESC(sb, indent, softc->dsreg, %d, dsreg, in saextget()
4898 SASBADDINTDESC(sb, indent, softc->sili, %d, sili, in saparamget()
4900 SASBADDINTDESC(sb, indent, softc->eot_warn, %d, eot_warn, in saparamget()
4915 softc = (struct sa_softc *)periph->softc; in saprevent()
4917 if ((action == PR_ALLOW) && (softc->flags & SA_FLAG_TAPE_LOCKED) == 0) in saprevent()
4919 if ((action == PR_PREVENT) && (softc->flags & SA_FLAG_TAPE_LOCKED) != 0) in saprevent()
4925 if (CAM_DEBUGGED(periph->path, CAM_DEBUG_INFO)) { in saprevent()
4933 scsi_prevent(&ccb->csio, 5, NULL, MSG_SIMPLE_Q_TAG, action, in saprevent()
4934 SSD_FULL_SIZE, softc->timeout_info[SA_TIMEOUT_PREVENT]); in saprevent()
4936 error = cam_periph_runccb(ccb, saerror, 0, sf, softc->device_stats); in saprevent()
4939 softc->flags &= ~SA_FLAG_TAPE_LOCKED; in saprevent()
4941 softc->flags |= SA_FLAG_TAPE_LOCKED; in saprevent()
4954 softc = (struct sa_softc *)periph->softc; in sarewind()
4959 scsi_rewind(&ccb->csio, 2, NULL, MSG_SIMPLE_Q_TAG, FALSE, in sarewind()
4960 SSD_FULL_SIZE, softc->timeout_info[SA_TIMEOUT_REWIND]); in sarewind()
4962 softc->dsreg = MTIO_DSREG_REW; in sarewind()
4963 error = cam_periph_runccb(ccb, saerror, 0, 0, softc->device_stats); in sarewind()
4964 softc->dsreg = MTIO_DSREG_REST; in sarewind()
4968 softc->partition = softc->fileno = softc->blkno = (daddr_t) 0; in sarewind()
4969 softc->rep_fileno = softc->rep_blkno = (daddr_t) 0; in sarewind()
4971 softc->fileno = softc->blkno = (daddr_t) -1; in sarewind()
4972 softc->partition = (daddr_t) -1; in sarewind()
4973 softc->rep_fileno = softc->rep_blkno = (daddr_t) -1; in sarewind()
4985 softc = (struct sa_softc *)periph->softc; in saspace()
4991 scsi_space(&ccb->csio, 0, NULL, MSG_SIMPLE_Q_TAG, code, count, in saspace()
4992 SSD_FULL_SIZE, softc->timeout_info[SA_TIMEOUT_SPACE]); in saspace()
4997 softc->last_ctl_resid = 0; in saspace()
4999 softc->dsreg = (count < 0)? MTIO_DSREG_REV : MTIO_DSREG_FWD; in saspace()
5000 error = cam_periph_runccb(ccb, saerror, 0, 0, softc->device_stats); in saspace()
5001 softc->dsreg = MTIO_DSREG_REST; in saspace()
5014 * than zero- if we've gone negative, we must have hit BOT. in saspace()
5020 * record number is- we've stopped between the end of the last in saspace()
5025 softc->fileno = softc->blkno = (daddr_t) -1; in saspace()
5026 softc->rep_blkno = softc->partition = (daddr_t) -1; in saspace()
5027 softc->rep_fileno = (daddr_t) -1; in saspace()
5029 softc->fileno = softc->blkno = (daddr_t) -1; in saspace()
5030 } else if (code == SS_FILEMARKS && softc->fileno != (daddr_t) -1) { in saspace()
5031 softc->fileno += (count - softc->last_ctl_resid); in saspace()
5032 if (softc->fileno < 0) /* we must of hit BOT */ in saspace()
5033 softc->fileno = 0; in saspace()
5034 softc->blkno = 0; in saspace()
5035 } else if (code == SS_BLOCKS && softc->blkno != (daddr_t) -1) { in saspace()
5036 softc->blkno += (count - softc->last_ctl_resid); in saspace()
5038 if (softc->last_ctl_resid || softc->blkno < 0) { in saspace()
5039 if (softc->fileno == 0) { in saspace()
5040 softc->blkno = 0; in saspace()
5042 softc->blkno = (daddr_t) -1; in saspace()
5060 softc = (struct sa_softc *)periph->softc; in sawritefilemarks()
5061 if (softc->open_rdonly) in sawritefilemarks()
5068 softc->last_ctl_resid = 0; in sawritefilemarks()
5070 softc->dsreg = MTIO_DSREG_FMK; in sawritefilemarks()
5072 scsi_write_filemarks(&ccb->csio, 0, NULL, MSG_SIMPLE_Q_TAG, in sawritefilemarks()
5074 softc->timeout_info[SA_TIMEOUT_WRITE_FILEMARKS]); in sawritefilemarks()
5075 softc->dsreg = MTIO_DSREG_REST; in sawritefilemarks()
5077 error = cam_periph_runccb(ccb, saerror, 0, 0, softc->device_stats); in sawritefilemarks()
5080 struct sa_softc *softc = (struct sa_softc *)periph->softc; in sawritefilemarks()
5081 nwm = nmarks - softc->last_ctl_resid; in sawritefilemarks()
5082 softc->filemarks += nwm; in sawritefilemarks()
5091 softc->fileno = softc->blkno = softc->partition = (daddr_t) -1; in sawritefilemarks()
5092 } else if (softc->fileno != (daddr_t) -1) { in sawritefilemarks()
5093 softc->fileno += nwm; in sawritefilemarks()
5094 softc->blkno = 0; in sawritefilemarks()
5107 if (softc->rep_fileno != (daddr_t) -1) { in sawritefilemarks()
5108 softc->fileno = softc->rep_fileno; in sawritefilemarks()
5109 softc->blkno = 0; in sawritefilemarks()
5120 struct sa_softc *softc = (struct sa_softc *)periph->softc; in sagetpos()
5123 if (softc->quirks & SA_QUIRK_NO_LONG_POS) { in sagetpos()
5124 softc->rep_fileno = (daddr_t) -1; in sagetpos()
5125 softc->rep_blkno = (daddr_t) -1; in sagetpos()
5126 softc->bop = softc->eop = softc->bpew = -1; in sagetpos()
5133 scsi_read_position_10(&ccb->csio, in sagetpos()
5142 softc->timeout_info[SA_TIMEOUT_READ_POSITION]); in sagetpos()
5144 softc->dsreg = MTIO_DSREG_RBSY; in sagetpos()
5146 softc->device_stats); in sagetpos()
5147 softc->dsreg = MTIO_DSREG_REST; in sagetpos()
5156 softc->fileno = (daddr_t) -1; in sagetpos()
5157 softc->rep_fileno = (daddr_t) -1; in sagetpos()
5159 softc->fileno = softc->rep_fileno = in sagetpos()
5164 softc->partition = (daddr_t) -1; in sagetpos()
5165 softc->rep_blkno = (daddr_t) -1; in sagetpos()
5170 softc->blkno = (daddr_t) -1; in sagetpos()
5172 softc->partition = scsi_4btoul(long_pos.partition); in sagetpos()
5173 softc->rep_blkno = in sagetpos()
5177 softc->bop = 1; in sagetpos()
5179 softc->bop = 0; in sagetpos()
5182 softc->eop = 1; in sagetpos()
5184 softc->eop = 0; in sagetpos()
5187 || (softc->set_pews_status != 0)) { in sagetpos()
5188 softc->bpew = 1; in sagetpos()
5189 if (softc->set_pews_status > 0) in sagetpos()
5190 softc->set_pews_status--; in sagetpos()
5192 softc->bpew = 0; in sagetpos()
5195 * If this drive returned an invalid-request type error, in sagetpos()
5198 softc->quirks |= SA_QUIRK_NO_LONG_POS; in sagetpos()
5202 softc->rep_fileno = softc->rep_blkno = (daddr_t) -1; in sagetpos()
5203 softc->partition = (daddr_t) -1; in sagetpos()
5204 softc->bop = softc->eop = softc->bpew = -1; in sagetpos()
5217 struct sa_softc *softc = (struct sa_softc *)periph->softc; in sardpos()
5225 * I think that *logical* block position is probably okay- in sardpos()
5230 if (hard && (softc->flags & SA_FLAG_TAPE_WRITTEN)) { in sardpos()
5237 scsi_read_position(&ccb->csio, 1, NULL, MSG_SIMPLE_Q_TAG, in sardpos()
5239 softc->timeout_info[SA_TIMEOUT_READ_POSITION]); in sardpos()
5240 softc->dsreg = MTIO_DSREG_RBSY; in sardpos()
5241 error = cam_periph_runccb(ccb, saerror, 0, 0, softc->device_stats); in sardpos()
5242 softc->dsreg = MTIO_DSREG_REST; in sardpos()
5273 softc = (struct sa_softc *)periph->softc; in sasetpos()
5276 cp = locate_info->flags & MT_LOCATE_FLAG_CHANGE_PART ? 1 : 0; in sasetpos()
5277 immed = locate_info->flags & MT_LOCATE_FLAG_IMMED ? 1 : 0; in sasetpos()
5284 * 32-bits. in sasetpos()
5288 else if ((locate_info->dest_type != MT_LOCATE_DEST_OBJECT) in sasetpos()
5289 || (locate_info->block_address_mode != MT_LOCATE_BAM_IMPLICIT) in sasetpos()
5290 || (locate_info->logical_id > SA_SPOS_MAX_BLK)) in sasetpos()
5296 scsi_locate_16(&ccb->csio, in sasetpos()
5302 /*dest_type*/ locate_info->dest_type, in sasetpos()
5303 /*bam*/ locate_info->block_address_mode, in sasetpos()
5304 /*partition*/ locate_info->partition, in sasetpos()
5305 /*logical_id*/ locate_info->logical_id, in sasetpos()
5308 softc->timeout_info[SA_TIMEOUT_LOCATE]); in sasetpos()
5310 scsi_locate_10(&ccb->csio, in sasetpos()
5317 /*partition*/ locate_info->partition, in sasetpos()
5318 /*block_address*/ locate_info->logical_id, in sasetpos()
5321 softc->timeout_info[SA_TIMEOUT_LOCATE]); in sasetpos()
5324 softc->dsreg = MTIO_DSREG_POS; in sasetpos()
5325 error = cam_periph_runccb(ccb, saerror, 0, 0, softc->device_stats); in sasetpos()
5326 softc->dsreg = MTIO_DSREG_REST; in sasetpos()
5333 softc->fileno = softc->blkno = (daddr_t) -1; in sasetpos()
5341 softc->partition = locate_info->partition; in sasetpos()
5343 softc->partition = (daddr_t) -1; in sasetpos()
5346 switch (locate_info->dest_type) { in sasetpos()
5352 softc->fileno = locate_info->logical_id; in sasetpos()
5353 softc->blkno = 0; in sasetpos()
5378 softc = (struct sa_softc *)periph->softc; in saretension()
5383 scsi_load_unload(&ccb->csio, 5, NULL, MSG_SIMPLE_Q_TAG, FALSE, in saretension()
5385 softc->timeout_info[SA_TIMEOUT_LOAD]); in saretension()
5387 softc->dsreg = MTIO_DSREG_TEN; in saretension()
5388 error = cam_periph_runccb(ccb, saerror, 0, 0, softc->device_stats); in saretension()
5389 softc->dsreg = MTIO_DSREG_REST; in saretension()
5393 softc->partition = softc->fileno = softc->blkno = (daddr_t) 0; in saretension()
5396 softc->partition = softc->fileno = softc->blkno = (daddr_t) -1; in saretension()
5407 softc = (struct sa_softc *)periph->softc; in sareservereleaseunit()
5411 scsi_reserve_release_unit(&ccb->csio, 2, NULL, MSG_SIMPLE_Q_TAG, in sareservereleaseunit()
5412 FALSE, 0, SSD_FULL_SIZE, softc->timeout_info[SA_TIMEOUT_RESERVE], in sareservereleaseunit()
5414 softc->dsreg = MTIO_DSREG_RBSY; in sareservereleaseunit()
5416 SF_RETRY_UA | SF_NO_PRINT, softc->device_stats); in sareservereleaseunit()
5417 softc->dsreg = MTIO_DSREG_REST; in sareservereleaseunit()
5438 softc = (struct sa_softc *)periph->softc; in saloadunload()
5443 scsi_load_unload(&ccb->csio, 5, NULL, MSG_SIMPLE_Q_TAG, FALSE, in saloadunload()
5445 softc->timeout_info[SA_TIMEOUT_LOAD]); in saloadunload()
5447 softc->dsreg = (load)? MTIO_DSREG_LD : MTIO_DSREG_UNL; in saloadunload()
5448 error = cam_periph_runccb(ccb, saerror, 0, 0, softc->device_stats); in saloadunload()
5449 softc->dsreg = MTIO_DSREG_REST; in saloadunload()
5453 softc->partition = softc->fileno = softc->blkno = (daddr_t) -1; in saloadunload()
5454 softc->rep_fileno = softc->rep_blkno = (daddr_t) -1; in saloadunload()
5456 softc->partition = softc->fileno = softc->blkno = (daddr_t) 0; in saloadunload()
5470 softc = (struct sa_softc *)periph->softc; in saerase()
5471 if (softc->open_rdonly) in saerase()
5476 scsi_erase(&ccb->csio, 1, NULL, MSG_SIMPLE_Q_TAG, FALSE, longerase, in saerase()
5477 SSD_FULL_SIZE, softc->timeout_info[SA_TIMEOUT_ERASE]); in saerase()
5479 softc->dsreg = MTIO_DSREG_ZER; in saerase()
5480 error = cam_periph_runccb(ccb, saerror, 0, 0, softc->device_stats); in saerase()
5481 softc->dsreg = MTIO_DSREG_REST; in saerase()
5489 * works for multi-byte integer fields.
5493 * sizes are possible for a given field. So passing in a multi-byte
5502 cur_field_len = sizeof(dens_data->field); \
5504 len_to_go -= desc_remain; \
5508 len_to_go -= cur_field_len; \
5510 desc_remain -= cur_field_len; \
5512 switch (sizeof(dens_data->field)) { \
5519 scsi_2btoul(dens_data->field), %u, field, desc); \
5523 scsi_3btoul(dens_data->field), %u, field, desc); \
5527 scsi_4btoul(dens_data->field), %u, field, desc); \
5531 (uintmax_t)scsi_8btou64(dens_data->field), %ju, \
5547 cur_field_len = sizeof(dens_data->field); \
5549 len_to_go -= desc_remain; \
5553 len_to_go -= cur_field_len; \
5555 desc_remain -= cur_field_len; \
5557 cam_strvis(tmpstr, dens_data->field, \
5558 sizeof(dens_data->field), sizeof(tmpstr)); \
5584 hdr_len = scsi_2btoul(hdr->length); in safilldenstypesb()
5585 len_to_go = min(buf_len - sizeof(*hdr), hdr_len); in safilldenstypesb()
5609 if (dens_data->byte2 & SDD_DLV) in safilldenstypesb()
5610 desc_remain = scsi_2btoul(dens_data->length); in safilldenstypesb()
5612 desc_remain = SDD_DEFAULT_LENGTH - in safilldenstypesb()
5617 desc_remain = scsi_2btoul(type_data->length); in safilldenstypesb()
5620 len_to_go -= length_offset; in safilldenstypesb()
5634 dens_data->primary_density_code, %u, in safilldenstypesb()
5637 dens_data->secondary_density_code, %u, in safilldenstypesb()
5640 dens_data->byte2 & ~SDD_DLV, %#x, density_flags, in safilldenstypesb()
5665 SASBADDUINTDESC(sb, *indent, type_data->medium_type, in safilldenstypesb()
5670 media_width) - in safilldenstypesb()
5675 len_to_go -= desc_remain; in safilldenstypesb()
5679 len_to_go -= cur_field_len; in safilldenstypesb()
5681 desc_remain -= cur_field_len; in safilldenstypesb()
5684 type_data->num_density_codes, %d, in safilldenstypesb()
5687 for (i = 0; i < type_data->num_density_codes; in safilldenstypesb()
5690 type_data->primary_density_codes[i], %u, in safilldenstypesb()
5705 cur_field_len = sizeof(type_data->reserved2); in safilldenstypesb()
5707 len_to_go -= desc_remain; in safilldenstypesb()
5711 len_to_go -= cur_field_len; in safilldenstypesb()
5713 desc_remain -= cur_field_len; in safilldenstypesb()
5742 SASBADDUINTDESC(sb, *indent, softc->media_density, %u, media_density, in safilldensitysb()
5748 if (softc->density_info_valid[i] == 0) in safilldensitysb()
5752 if (softc->density_type_bits[i] & SRDS_MEDIUM_TYPE) { in safilldensitysb()
5762 if (softc->density_type_bits[i] & SRDS_MEDIA) in safilldensitysb()
5769 safilldenstypesb(sb, indent, softc->density_info[i], in safilldensitysb()
5770 softc->density_info_valid[i], is_density); in safilldensitysb()
5789 hdr = (struct scsi_report_supported_opcodes_all *)ccb->csio.data_ptr; in saloadtimeouts()
5790 valid_len = ccb->csio.dxfer_len - ccb->csio.resid; in saloadtimeouts()
5795 avail_len = scsi_4btoul(hdr->length) + sizeof(hdr->length); in saloadtimeouts()
5798 xpt_print(softc->periph->path, "WARNING: available timeout " in saloadtimeouts()
5802 used_len = sizeof(hdr->length); in saloadtimeouts()
5803 avail_len = MIN(avail_len, valid_len - sizeof(*hdr)); in saloadtimeouts()
5804 buf = ccb->csio.data_ptr; in saloadtimeouts()
5805 while ((avail_len - used_len) > sizeof(*desc)) { in saloadtimeouts()
5816 if ((desc->flags & RSO_CTDP) == 0) in saloadtimeouts()
5823 if ((avail_len - used_len) < sizeof(*td)) { in saloadtimeouts()
5830 td_len = scsi_2btoul(td->length); in saloadtimeouts()
5831 td_len += sizeof(td->length); in saloadtimeouts()
5841 rec_time = scsi_4btoul(td->recommended_time); in saloadtimeouts()
5848 switch(desc->opcode) { in saloadtimeouts()
5850 softc->timeout_info[SA_TIMEOUT_ERASE] = rec_time; in saloadtimeouts()
5853 softc->timeout_info[SA_TIMEOUT_LOAD] = rec_time; in saloadtimeouts()
5860 softc->timeout_info[SA_TIMEOUT_LOCATE] = rec_time; in saloadtimeouts()
5867 softc->timeout_info[SA_TIMEOUT_MODE_SELECT] = rec_time; in saloadtimeouts()
5874 softc->timeout_info[SA_TIMEOUT_MODE_SENSE] = rec_time; in saloadtimeouts()
5877 softc->timeout_info[SA_TIMEOUT_PREVENT] = rec_time; in saloadtimeouts()
5880 softc->timeout_info[SA_TIMEOUT_READ] = rec_time; in saloadtimeouts()
5883 softc->timeout_info[SA_TIMEOUT_READ_BLOCK_LIMITS] = in saloadtimeouts()
5893 softc->timeout_info[SA_TIMEOUT_READ_POSITION] =rec_time; in saloadtimeouts()
5896 softc->timeout_info[SA_TIMEOUT_REP_DENSITY] = rec_time; in saloadtimeouts()
5901 softc->timeout_info[SA_TIMEOUT_RESERVE] = rec_time; in saloadtimeouts()
5904 softc->timeout_info[SA_TIMEOUT_REWIND] = rec_time; in saloadtimeouts()
5907 softc->timeout_info[SA_TIMEOUT_SPACE] = rec_time; in saloadtimeouts()
5910 softc->timeout_info[SA_TIMEOUT_TUR] = rec_time; in saloadtimeouts()
5913 softc->timeout_info[SA_TIMEOUT_WRITE] = rec_time; in saloadtimeouts()
5916 softc->timeout_info[SA_TIMEOUT_WRITE_FILEMARKS] = in saloadtimeouts()
5947 scsi_cmd = (struct scsi_read_block_limits *)&csio->cdb_io.cdb_bytes; in scsi_read_block_limits()
5949 scsi_cmd->opcode = READ_BLOCK_LIMITS; in scsi_read_block_limits()
5964 scsi_cmd = (struct scsi_sa_rw *)&csio->cdb_io.cdb_bytes; in scsi_sa_read_write()
5965 scsi_cmd->opcode = read ? SA_READ : SA_WRITE; in scsi_sa_read_write()
5966 scsi_cmd->sli_fixed = 0; in scsi_sa_read_write()
5968 scsi_cmd->sli_fixed |= SAR_SLI; in scsi_sa_read_write()
5970 scsi_cmd->sli_fixed |= SARW_FIXED; in scsi_sa_read_write()
5971 scsi_ulto3b(length, scsi_cmd->length); in scsi_sa_read_write()
5972 scsi_cmd->control = 0; in scsi_sa_read_write()
5989 scsi_cmd = (struct scsi_load_unload *)&csio->cdb_io.cdb_bytes; in scsi_load_unload()
5991 scsi_cmd->opcode = LOAD_UNLOAD; in scsi_load_unload()
5993 scsi_cmd->immediate = SLU_IMMED; in scsi_load_unload()
5995 scsi_cmd->eot_reten_load |= SLU_EOT; in scsi_load_unload()
5997 scsi_cmd->eot_reten_load |= SLU_RETEN; in scsi_load_unload()
5999 scsi_cmd->eot_reten_load |= SLU_LOAD; in scsi_load_unload()
6013 scsi_cmd = (struct scsi_rewind *)&csio->cdb_io.cdb_bytes; in scsi_rewind()
6015 scsi_cmd->opcode = REWIND; in scsi_rewind()
6017 scsi_cmd->immediate = SREW_IMMED; in scsi_rewind()
6031 scsi_cmd = (struct scsi_space *)&csio->cdb_io.cdb_bytes; in scsi_space()
6032 scsi_cmd->opcode = SPACE; in scsi_space()
6033 scsi_cmd->code = code; in scsi_space()
6034 scsi_ulto3b(count, scsi_cmd->count); in scsi_space()
6035 scsi_cmd->control = 0; in scsi_space()
6050 scsi_cmd = (struct scsi_write_filemarks *)&csio->cdb_io.cdb_bytes; in scsi_write_filemarks()
6052 scsi_cmd->opcode = WRITE_FILEMARKS; in scsi_write_filemarks()
6054 scsi_cmd->byte2 |= SWFMRK_IMMED; in scsi_write_filemarks()
6056 scsi_cmd->byte2 |= SWFMRK_WSMK; in scsi_write_filemarks()
6058 scsi_ulto3b(num_marks, scsi_cmd->num_marks); in scsi_write_filemarks()
6076 scsi_cmd = (struct scsi_reserve_release_unit *)&csio->cdb_io.cdb_bytes; in scsi_reserve_release_unit()
6080 scsi_cmd->opcode = RESERVE_UNIT; in scsi_reserve_release_unit()
6082 scsi_cmd->opcode = RELEASE_UNIT; in scsi_reserve_release_unit()
6085 scsi_cmd->lun_thirdparty |= SRRU_3RD_PARTY; in scsi_reserve_release_unit()
6086 scsi_cmd->lun_thirdparty |= in scsi_reserve_release_unit()
6102 scsi_cmd = (struct scsi_erase *)&csio->cdb_io.cdb_bytes; in scsi_erase()
6105 scsi_cmd->opcode = ERASE; in scsi_erase()
6108 scsi_cmd->lun_imm_long |= SE_IMMED; in scsi_erase()
6111 scsi_cmd->lun_imm_long |= SE_LONG; in scsi_erase()
6131 scmd = (struct scsi_tape_read_position *)&csio->cdb_io.cdb_bytes; in scsi_read_position()
6133 scmd->opcode = READ_POSITION; in scsi_read_position()
6134 scmd->byte1 = hardsoft; in scsi_read_position()
6160 scmd = (struct scsi_tape_read_position *)&csio->cdb_io.cdb_bytes; in scsi_read_position_10()
6162 scmd->opcode = READ_POSITION; in scsi_read_position_10()
6163 scmd->byte1 = service_action; in scsi_read_position_10()
6169 scsi_ulto2b(length, scmd->length); in scsi_read_position_10()
6185 scmd = (struct scsi_tape_locate *)&csio->cdb_io.cdb_bytes; in scsi_set_position()
6187 scmd->opcode = LOCATE; in scsi_set_position()
6189 scmd->byte1 |= SA_SPOS_BT; in scsi_set_position()
6190 scsi_ulto4b(blkno, scmd->blkaddr); in scsi_set_position()
6215 scmd = (struct scsi_tape_locate *)&csio->cdb_io.cdb_bytes; in scsi_locate_10()
6217 scmd->opcode = LOCATE; in scsi_locate_10()
6219 scmd->byte1 |= SA_SPOS_IMMED; in scsi_locate_10()
6221 scmd->byte1 |= SA_SPOS_CP; in scsi_locate_10()
6223 scmd->byte1 |= SA_SPOS_BT; in scsi_locate_10()
6224 scsi_ulto4b(block_address, scmd->blkaddr); in scsi_locate_10()
6225 scmd->partition = partition; in scsi_locate_10()
6249 scsi_cmd = (struct scsi_locate_16 *)&csio->cdb_io.cdb_bytes; in scsi_locate_16()
6251 scsi_cmd->opcode = LOCATE_16; in scsi_locate_16()
6253 scsi_cmd->byte1 |= SA_LC_IMMEDIATE; in scsi_locate_16()
6255 scsi_cmd->byte1 |= SA_LC_CP; in scsi_locate_16()
6256 scsi_cmd->byte1 |= (dest_type << SA_LC_DEST_TYPE_SHIFT); in scsi_locate_16()
6258 scsi_cmd->byte2 |= bam; in scsi_locate_16()
6259 scsi_cmd->partition = partition; in scsi_locate_16()
6260 scsi_u64to8b(logical_id, scsi_cmd->logical_id); in scsi_locate_16()
6272 scsi_cmd =(struct scsi_report_density_support *)&csio->cdb_io.cdb_bytes; in scsi_report_density_support()
6275 scsi_cmd->opcode = REPORT_DENSITY_SUPPORT; in scsi_report_density_support()
6277 scsi_cmd->byte1 |= SRDS_MEDIA; in scsi_report_density_support()
6279 scsi_cmd->byte1 |= SRDS_MEDIUM_TYPE; in scsi_report_density_support()
6281 scsi_ulto2b(length, scsi_cmd->length); in scsi_report_density_support()
6303 scsi_cmd = (struct scsi_set_capacity *)&csio->cdb_io.cdb_bytes; in scsi_set_capacity()
6306 scsi_cmd->opcode = SET_CAPACITY; in scsi_set_capacity()
6308 scsi_cmd->byte1 = byte1; in scsi_set_capacity()
6309 scsi_ulto2b(proportion, scsi_cmd->cap_proportion); in scsi_set_capacity()
6332 scsi_cmd = (struct scsi_format_medium*)&csio->cdb_io.cdb_bytes; in scsi_format_medium()
6335 scsi_cmd->opcode = FORMAT_MEDIUM; in scsi_format_medium()
6337 scsi_cmd->byte1 = byte1; in scsi_format_medium()
6338 scsi_cmd->byte2 = byte2; in scsi_format_medium()
6340 scsi_ulto2b(dxfer_len, scsi_cmd->length); in scsi_format_medium()
6362 scsi_cmd = (struct scsi_allow_overwrite *)&csio->cdb_io.cdb_bytes; in scsi_allow_overwrite()
6365 scsi_cmd->opcode = ALLOW_OVERWRITE; in scsi_allow_overwrite()
6367 scsi_cmd->allow_overwrite = allow_overwrite; in scsi_allow_overwrite()
6368 scsi_cmd->partition = partition; in scsi_allow_overwrite()
6369 scsi_u64to8b(logical_id, scsi_cmd->logical_id); in scsi_allow_overwrite()