ctl.c (312582) | ctl.c (312834) |
---|---|
1/*- 2 * Copyright (c) 2003-2009 Silicon Graphics International Corp. 3 * Copyright (c) 2012 The FreeBSD Foundation 4 * Copyright (c) 2015 Alexander Motin <mav@FreeBSD.org> 5 * All rights reserved. 6 * 7 * Portions of this software were developed by Edward Tomasz Napierala 8 * under sponsorship from the FreeBSD Foundation. --- 29 unchanged lines hidden (view full) --- 38 * CAM Target Layer, a SCSI device emulation subsystem. 39 * 40 * Author: Ken Merry <ken@FreeBSD.org> 41 */ 42 43#define _CTL_C 44 45#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2003-2009 Silicon Graphics International Corp. 3 * Copyright (c) 2012 The FreeBSD Foundation 4 * Copyright (c) 2015 Alexander Motin <mav@FreeBSD.org> 5 * All rights reserved. 6 * 7 * Portions of this software were developed by Edward Tomasz Napierala 8 * under sponsorship from the FreeBSD Foundation. --- 29 unchanged lines hidden (view full) --- 38 * CAM Target Layer, a SCSI device emulation subsystem. 39 * 40 * Author: Ken Merry <ken@FreeBSD.org> 41 */ 42 43#define _CTL_C 44 45#include <sys/cdefs.h> |
46__FBSDID("$FreeBSD: stable/11/sys/cam/ctl/ctl.c 312582 2017-01-21 08:39:01Z mav $"); | 46__FBSDID("$FreeBSD: stable/11/sys/cam/ctl/ctl.c 312834 2017-01-26 20:49:19Z mav $"); |
47 48#include <sys/param.h> 49#include <sys/systm.h> 50#include <sys/ctype.h> 51#include <sys/kernel.h> 52#include <sys/types.h> 53#include <sys/kthread.h> 54#include <sys/bio.h> --- 377 unchanged lines hidden (view full) --- 432 struct ctl_ooa *ooa_hdr, 433 struct ctl_ooa_entry *kern_entries); 434static int ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, 435 struct thread *td); 436static int ctl_alloc_lun(struct ctl_softc *ctl_softc, struct ctl_lun *lun, 437 struct ctl_be_lun *be_lun); 438static int ctl_free_lun(struct ctl_lun *lun); 439static void ctl_create_lun(struct ctl_be_lun *be_lun); | 47 48#include <sys/param.h> 49#include <sys/systm.h> 50#include <sys/ctype.h> 51#include <sys/kernel.h> 52#include <sys/types.h> 53#include <sys/kthread.h> 54#include <sys/bio.h> --- 377 unchanged lines hidden (view full) --- 432 struct ctl_ooa *ooa_hdr, 433 struct ctl_ooa_entry *kern_entries); 434static int ctl_ioctl(struct cdev *dev, u_long cmd, caddr_t addr, int flag, 435 struct thread *td); 436static int ctl_alloc_lun(struct ctl_softc *ctl_softc, struct ctl_lun *lun, 437 struct ctl_be_lun *be_lun); 438static int ctl_free_lun(struct ctl_lun *lun); 439static void ctl_create_lun(struct ctl_be_lun *be_lun); |
440static struct ctl_port * ctl_io_port(struct ctl_io_hdr *io_hdr); | |
441 442static int ctl_do_mode_select(union ctl_io *io); 443static int ctl_pro_preempt(struct ctl_softc *softc, struct ctl_lun *lun, 444 uint64_t res_key, uint64_t sa_res_key, 445 uint8_t type, uint32_t residx, 446 struct ctl_scsiio *ctsio, 447 struct scsi_per_res_out *cdb, 448 struct scsi_per_res_out_parms* param); 449static void ctl_pro_preempt_other(struct ctl_lun *lun, 450 union ctl_ha_msg *msg); | 440 441static int ctl_do_mode_select(union ctl_io *io); 442static int ctl_pro_preempt(struct ctl_softc *softc, struct ctl_lun *lun, 443 uint64_t res_key, uint64_t sa_res_key, 444 uint8_t type, uint32_t residx, 445 struct ctl_scsiio *ctsio, 446 struct scsi_per_res_out *cdb, 447 struct scsi_per_res_out_parms* param); 448static void ctl_pro_preempt_other(struct ctl_lun *lun, 449 union ctl_ha_msg *msg); |
451static void ctl_hndl_per_res_out_on_other_sc(union ctl_ha_msg *msg); | 450static void ctl_hndl_per_res_out_on_other_sc(union ctl_io *io); |
452static int ctl_inquiry_evpd_supported(struct ctl_scsiio *ctsio, int alloc_len); 453static int ctl_inquiry_evpd_serial(struct ctl_scsiio *ctsio, int alloc_len); 454static int ctl_inquiry_evpd_devid(struct ctl_scsiio *ctsio, int alloc_len); 455static int ctl_inquiry_evpd_eid(struct ctl_scsiio *ctsio, int alloc_len); 456static int ctl_inquiry_evpd_mpp(struct ctl_scsiio *ctsio, int alloc_len); 457static int ctl_inquiry_evpd_scsi_ports(struct ctl_scsiio *ctsio, 458 int alloc_len); 459static int ctl_inquiry_evpd_block_limits(struct ctl_scsiio *ctsio, --- 102 unchanged lines hidden (view full) --- 562static struct ctl_frontend ha_frontend = 563{ 564 .name = "ha", 565}; 566 567static void 568ctl_ha_datamove(union ctl_io *io) 569{ | 451static int ctl_inquiry_evpd_supported(struct ctl_scsiio *ctsio, int alloc_len); 452static int ctl_inquiry_evpd_serial(struct ctl_scsiio *ctsio, int alloc_len); 453static int ctl_inquiry_evpd_devid(struct ctl_scsiio *ctsio, int alloc_len); 454static int ctl_inquiry_evpd_eid(struct ctl_scsiio *ctsio, int alloc_len); 455static int ctl_inquiry_evpd_mpp(struct ctl_scsiio *ctsio, int alloc_len); 456static int ctl_inquiry_evpd_scsi_ports(struct ctl_scsiio *ctsio, 457 int alloc_len); 458static int ctl_inquiry_evpd_block_limits(struct ctl_scsiio *ctsio, --- 102 unchanged lines hidden (view full) --- 561static struct ctl_frontend ha_frontend = 562{ 563 .name = "ha", 564}; 565 566static void 567ctl_ha_datamove(union ctl_io *io) 568{ |
570 struct ctl_lun *lun; | 569 struct ctl_lun *lun = CTL_LUN(io); |
571 struct ctl_sg_entry *sgl; 572 union ctl_ha_msg msg; 573 uint32_t sg_entries_sent; 574 int do_sg_copy, i, j; 575 | 570 struct ctl_sg_entry *sgl; 571 union ctl_ha_msg msg; 572 uint32_t sg_entries_sent; 573 int do_sg_copy, i, j; 574 |
576 lun = (struct ctl_lun *)io->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; | |
577 memset(&msg.dt, 0, sizeof(msg.dt)); 578 msg.hdr.msg_type = CTL_MSG_DATAMOVE; 579 msg.hdr.original_sc = io->io_hdr.original_sc; 580 msg.hdr.serializing_sc = io; 581 msg.hdr.nexus = io->io_hdr.nexus; 582 msg.hdr.status = io->io_hdr.status; 583 msg.dt.flags = io->io_hdr.flags; 584 --- 1213 unchanged lines hidden (view full) --- 1798 make_dev_args_init(&args); 1799 args.mda_devsw = &ctl_cdevsw; 1800 args.mda_uid = UID_ROOT; 1801 args.mda_gid = GID_OPERATOR; 1802 args.mda_mode = 0600; 1803 args.mda_si_drv1 = softc; 1804 error = make_dev_s(&args, &softc->dev, "cam/ctl"); 1805 if (error != 0) { | 575 memset(&msg.dt, 0, sizeof(msg.dt)); 576 msg.hdr.msg_type = CTL_MSG_DATAMOVE; 577 msg.hdr.original_sc = io->io_hdr.original_sc; 578 msg.hdr.serializing_sc = io; 579 msg.hdr.nexus = io->io_hdr.nexus; 580 msg.hdr.status = io->io_hdr.status; 581 msg.dt.flags = io->io_hdr.flags; 582 --- 1213 unchanged lines hidden (view full) --- 1796 make_dev_args_init(&args); 1797 args.mda_devsw = &ctl_cdevsw; 1798 args.mda_uid = UID_ROOT; 1799 args.mda_gid = GID_OPERATOR; 1800 args.mda_mode = 0600; 1801 args.mda_si_drv1 = softc; 1802 error = make_dev_s(&args, &softc->dev, "cam/ctl"); 1803 if (error != 0) { |
1806 free(control_softc, M_DEVBUF); | 1804 free(softc, M_DEVBUF); 1805 control_softc = NULL; |
1807 return (error); 1808 } 1809 1810 sysctl_ctx_init(&softc->sysctl_ctx); 1811 softc->sysctl_tree = SYSCTL_ADD_NODE(&softc->sysctl_ctx, 1812 SYSCTL_STATIC_CHILDREN(_kern_cam), OID_AUTO, "ctl", 1813 CTLFLAG_RD, 0, "CAM Target Layer"); 1814 1815 if (softc->sysctl_tree == NULL) { 1816 printf("%s: unable to allocate sysctl tree\n", __func__); 1817 destroy_dev(softc->dev); | 1806 return (error); 1807 } 1808 1809 sysctl_ctx_init(&softc->sysctl_ctx); 1810 softc->sysctl_tree = SYSCTL_ADD_NODE(&softc->sysctl_ctx, 1811 SYSCTL_STATIC_CHILDREN(_kern_cam), OID_AUTO, "ctl", 1812 CTLFLAG_RD, 0, "CAM Target Layer"); 1813 1814 if (softc->sysctl_tree == NULL) { 1815 printf("%s: unable to allocate sysctl tree\n", __func__); 1816 destroy_dev(softc->dev); |
1818 free(control_softc, M_DEVBUF); | 1817 free(softc, M_DEVBUF); |
1819 control_softc = NULL; 1820 return (ENOMEM); 1821 } 1822 1823 mtx_init(&softc->ctl_lock, "CTL mutex", NULL, MTX_DEF); 1824 softc->io_zone = uma_zcreate("CTL IO", sizeof(union ctl_io), 1825 NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0); 1826 softc->flags = 0; --- 131 unchanged lines hidden (view full) --- 1958 ctl_tpc_shutdown(softc); 1959 uma_zdestroy(softc->io_zone); 1960 mtx_destroy(&softc->ctl_lock); 1961 1962 destroy_dev(softc->dev); 1963 1964 sysctl_ctx_free(&softc->sysctl_ctx); 1965 | 1818 control_softc = NULL; 1819 return (ENOMEM); 1820 } 1821 1822 mtx_init(&softc->ctl_lock, "CTL mutex", NULL, MTX_DEF); 1823 softc->io_zone = uma_zcreate("CTL IO", sizeof(union ctl_io), 1824 NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0); 1825 softc->flags = 0; --- 131 unchanged lines hidden (view full) --- 1957 ctl_tpc_shutdown(softc); 1958 uma_zdestroy(softc->io_zone); 1959 mtx_destroy(&softc->ctl_lock); 1960 1961 destroy_dev(softc->dev); 1962 1963 sysctl_ctx_free(&softc->sysctl_ctx); 1964 |
1966 free(control_softc, M_DEVBUF); | 1965 free(softc, M_DEVBUF); |
1967 control_softc = NULL; 1968} 1969 1970static int 1971ctl_module_event_handler(module_t mod, int what, void *arg) 1972{ 1973 1974 switch (what) { --- 225 unchanged lines hidden (view full) --- 2200 * standard case in ctl_scsiio_precheck(). Errors in this case need to get 2201 * sent back to the other side, but in the success case, we execute the 2202 * command on this side (XFER mode) or tell the other side to execute it 2203 * (SER_ONLY mode). 2204 */ 2205static void 2206ctl_serialize_other_sc_cmd(struct ctl_scsiio *ctsio) 2207{ | 1966 control_softc = NULL; 1967} 1968 1969static int 1970ctl_module_event_handler(module_t mod, int what, void *arg) 1971{ 1972 1973 switch (what) { --- 225 unchanged lines hidden (view full) --- 2199 * standard case in ctl_scsiio_precheck(). Errors in this case need to get 2200 * sent back to the other side, but in the success case, we execute the 2201 * command on this side (XFER mode) or tell the other side to execute it 2202 * (SER_ONLY mode). 2203 */ 2204static void 2205ctl_serialize_other_sc_cmd(struct ctl_scsiio *ctsio) 2206{ |
2208 struct ctl_softc *softc = control_softc; | 2207 struct ctl_softc *softc = CTL_SOFTC(ctsio); 2208 struct ctl_port *port = CTL_PORT(ctsio); |
2209 union ctl_ha_msg msg_info; | 2209 union ctl_ha_msg msg_info; |
2210 struct ctl_port *port; | |
2211 struct ctl_lun *lun; 2212 const struct ctl_cmd_entry *entry; 2213 uint32_t targ_lun; 2214 2215 targ_lun = ctsio->io_hdr.nexus.targ_mapped_lun; | 2210 struct ctl_lun *lun; 2211 const struct ctl_cmd_entry *entry; 2212 uint32_t targ_lun; 2213 2214 targ_lun = ctsio->io_hdr.nexus.targ_mapped_lun; |
2216 mtx_lock(&softc->ctl_lock); | |
2217 2218 /* Make sure that we know about this port. */ | 2215 2216 /* Make sure that we know about this port. */ |
2219 port = ctl_io_port(&ctsio->io_hdr); | |
2220 if (port == NULL || (port->status & CTL_PORT_STATUS_ONLINE) == 0) { 2221 ctl_set_internal_failure(ctsio, /*sks_valid*/ 0, 2222 /*retry_count*/ 1); 2223 goto badjuju; 2224 } 2225 2226 /* Make sure that we know about this LUN. */ | 2217 if (port == NULL || (port->status & CTL_PORT_STATUS_ONLINE) == 0) { 2218 ctl_set_internal_failure(ctsio, /*sks_valid*/ 0, 2219 /*retry_count*/ 1); 2220 goto badjuju; 2221 } 2222 2223 /* Make sure that we know about this LUN. */ |
2224 mtx_lock(&softc->ctl_lock); |
|
2227 if (targ_lun >= CTL_MAX_LUNS || 2228 (lun = softc->ctl_luns[targ_lun]) == NULL) { 2229 mtx_unlock(&softc->ctl_lock); 2230 2231 /* 2232 * The other node would not send this request to us unless 2233 * received announce that we are primary node for this LUN. 2234 * If this LUN does not exist now, it is probably result of --- 16 unchanged lines hidden (view full) --- 2251 } 2252 2253 entry = ctl_get_cmd_entry(ctsio, NULL); 2254 if (ctl_scsiio_lun_check(lun, entry, ctsio) != 0) { 2255 mtx_unlock(&lun->lun_lock); 2256 goto badjuju; 2257 } 2258 | 2225 if (targ_lun >= CTL_MAX_LUNS || 2226 (lun = softc->ctl_luns[targ_lun]) == NULL) { 2227 mtx_unlock(&softc->ctl_lock); 2228 2229 /* 2230 * The other node would not send this request to us unless 2231 * received announce that we are primary node for this LUN. 2232 * If this LUN does not exist now, it is probably result of --- 16 unchanged lines hidden (view full) --- 2249 } 2250 2251 entry = ctl_get_cmd_entry(ctsio, NULL); 2252 if (ctl_scsiio_lun_check(lun, entry, ctsio) != 0) { 2253 mtx_unlock(&lun->lun_lock); 2254 goto badjuju; 2255 } 2256 |
2259 ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr = lun; 2260 ctsio->io_hdr.ctl_private[CTL_PRIV_BACKEND_LUN].ptr = lun->be_lun; | 2257 CTL_LUN(ctsio) = lun; 2258 CTL_BACKEND_LUN(ctsio) = lun->be_lun; |
2261 2262 /* 2263 * Every I/O goes into the OOA queue for a 2264 * particular LUN, and stays there until completion. 2265 */ 2266#ifdef CTL_TIME_IO 2267 if (TAILQ_EMPTY(&lun->ooa_queue)) 2268 lun->idle_time += getsbinuptime() - lun->last_busy; --- 1351 unchanged lines hidden (view full) --- 3620 if (l <= 0x3fff) 3621 return (((uint64_t)RPL_LUNDATA_ATYP_FLAT << 56) | (l << 48)); 3622 if (l <= 0xffffff) 3623 return (((uint64_t)(RPL_LUNDATA_ATYP_EXTLUN | 0x12) << 56) | 3624 (l << 32)); 3625 return ((((uint64_t)RPL_LUNDATA_ATYP_EXTLUN | 0x22) << 56) | (l << 16)); 3626} 3627 | 2259 2260 /* 2261 * Every I/O goes into the OOA queue for a 2262 * particular LUN, and stays there until completion. 2263 */ 2264#ifdef CTL_TIME_IO 2265 if (TAILQ_EMPTY(&lun->ooa_queue)) 2266 lun->idle_time += getsbinuptime() - lun->last_busy; --- 1351 unchanged lines hidden (view full) --- 3618 if (l <= 0x3fff) 3619 return (((uint64_t)RPL_LUNDATA_ATYP_FLAT << 56) | (l << 48)); 3620 if (l <= 0xffffff) 3621 return (((uint64_t)(RPL_LUNDATA_ATYP_EXTLUN | 0x12) << 56) | 3622 (l << 32)); 3623 return ((((uint64_t)RPL_LUNDATA_ATYP_EXTLUN | 0x22) << 56) | (l << 16)); 3624} 3625 |
3628static struct ctl_port * 3629ctl_io_port(struct ctl_io_hdr *io_hdr) 3630{ 3631 3632 return (control_softc->ctl_ports[io_hdr->nexus.targ_port]); 3633} 3634 | |
3635int 3636ctl_ffz(uint32_t *mask, uint32_t first, uint32_t last) 3637{ 3638 int i; 3639 3640 for (i = first; i < last; i++) { 3641 if ((mask[i / 32] & (1 << (i % 32))) == 0) 3642 return (i); --- 101 unchanged lines hidden (view full) --- 3744/* 3745 * ctl_softc, pool_name, total_ctl_io are passed in. 3746 * npool is passed out. 3747 */ 3748int 3749ctl_pool_create(struct ctl_softc *ctl_softc, const char *pool_name, 3750 uint32_t total_ctl_io, void **npool) 3751{ | 3626int 3627ctl_ffz(uint32_t *mask, uint32_t first, uint32_t last) 3628{ 3629 int i; 3630 3631 for (i = first; i < last; i++) { 3632 if ((mask[i / 32] & (1 << (i % 32))) == 0) 3633 return (i); --- 101 unchanged lines hidden (view full) --- 3735/* 3736 * ctl_softc, pool_name, total_ctl_io are passed in. 3737 * npool is passed out. 3738 */ 3739int 3740ctl_pool_create(struct ctl_softc *ctl_softc, const char *pool_name, 3741 uint32_t total_ctl_io, void **npool) 3742{ |
3752#ifdef IO_POOLS | |
3753 struct ctl_io_pool *pool; 3754 3755 pool = (struct ctl_io_pool *)malloc(sizeof(*pool), M_CTL, 3756 M_NOWAIT | M_ZERO); 3757 if (pool == NULL) 3758 return (ENOMEM); 3759 3760 snprintf(pool->name, sizeof(pool->name), "CTL IO %s", pool_name); 3761 pool->ctl_softc = ctl_softc; | 3743 struct ctl_io_pool *pool; 3744 3745 pool = (struct ctl_io_pool *)malloc(sizeof(*pool), M_CTL, 3746 M_NOWAIT | M_ZERO); 3747 if (pool == NULL) 3748 return (ENOMEM); 3749 3750 snprintf(pool->name, sizeof(pool->name), "CTL IO %s", pool_name); 3751 pool->ctl_softc = ctl_softc; |
3752#ifdef IO_POOLS |
|
3762 pool->zone = uma_zsecond_create(pool->name, NULL, 3763 NULL, NULL, NULL, ctl_softc->io_zone); 3764 /* uma_prealloc(pool->zone, total_ctl_io); */ | 3753 pool->zone = uma_zsecond_create(pool->name, NULL, 3754 NULL, NULL, NULL, ctl_softc->io_zone); 3755 /* uma_prealloc(pool->zone, total_ctl_io); */ |
3765 3766 *npool = pool; | |
3767#else | 3756#else |
3768 *npool = ctl_softc->io_zone; | 3757 pool->zone = ctl_softc->io_zone; |
3769#endif | 3758#endif |
3759 3760 *npool = pool; |
|
3770 return (0); 3771} 3772 3773void 3774ctl_pool_free(struct ctl_io_pool *pool) 3775{ 3776 3777 if (pool == NULL) 3778 return; 3779 3780#ifdef IO_POOLS 3781 uma_zdestroy(pool->zone); | 3761 return (0); 3762} 3763 3764void 3765ctl_pool_free(struct ctl_io_pool *pool) 3766{ 3767 3768 if (pool == NULL) 3769 return; 3770 3771#ifdef IO_POOLS 3772 uma_zdestroy(pool->zone); |
3782 free(pool, M_CTL); | |
3783#endif | 3773#endif |
3774 free(pool, M_CTL); |
|
3784} 3785 3786union ctl_io * 3787ctl_alloc_io(void *pool_ref) 3788{ | 3775} 3776 3777union ctl_io * 3778ctl_alloc_io(void *pool_ref) 3779{ |
3789 union ctl_io *io; 3790#ifdef IO_POOLS | |
3791 struct ctl_io_pool *pool = (struct ctl_io_pool *)pool_ref; | 3780 struct ctl_io_pool *pool = (struct ctl_io_pool *)pool_ref; |
3781 union ctl_io *io; |
|
3792 3793 io = uma_zalloc(pool->zone, M_WAITOK); | 3782 3783 io = uma_zalloc(pool->zone, M_WAITOK); |
3794#else 3795 io = uma_zalloc((uma_zone_t)pool_ref, M_WAITOK); 3796#endif 3797 if (io != NULL) | 3784 if (io != NULL) { |
3798 io->io_hdr.pool = pool_ref; | 3785 io->io_hdr.pool = pool_ref; |
3786 CTL_SOFTC(io) = pool->ctl_softc; 3787 } |
|
3799 return (io); 3800} 3801 3802union ctl_io * 3803ctl_alloc_io_nowait(void *pool_ref) 3804{ | 3788 return (io); 3789} 3790 3791union ctl_io * 3792ctl_alloc_io_nowait(void *pool_ref) 3793{ |
3805 union ctl_io *io; 3806#ifdef IO_POOLS | |
3807 struct ctl_io_pool *pool = (struct ctl_io_pool *)pool_ref; | 3794 struct ctl_io_pool *pool = (struct ctl_io_pool *)pool_ref; |
3795 union ctl_io *io; |
|
3808 3809 io = uma_zalloc(pool->zone, M_NOWAIT); | 3796 3797 io = uma_zalloc(pool->zone, M_NOWAIT); |
3810#else 3811 io = uma_zalloc((uma_zone_t)pool_ref, M_NOWAIT); 3812#endif 3813 if (io != NULL) | 3798 if (io != NULL) { |
3814 io->io_hdr.pool = pool_ref; | 3799 io->io_hdr.pool = pool_ref; |
3800 CTL_SOFTC(io) = pool->ctl_softc; 3801 } |
|
3815 return (io); 3816} 3817 3818void 3819ctl_free_io(union ctl_io *io) 3820{ | 3802 return (io); 3803} 3804 3805void 3806ctl_free_io(union ctl_io *io) 3807{ |
3821#ifdef IO_POOLS | |
3822 struct ctl_io_pool *pool; | 3808 struct ctl_io_pool *pool; |
3823#endif | |
3824 3825 if (io == NULL) 3826 return; 3827 | 3809 3810 if (io == NULL) 3811 return; 3812 |
3828#ifdef IO_POOLS | |
3829 pool = (struct ctl_io_pool *)io->io_hdr.pool; 3830 uma_zfree(pool->zone, io); | 3813 pool = (struct ctl_io_pool *)io->io_hdr.pool; 3814 uma_zfree(pool->zone, io); |
3831#else 3832 uma_zfree((uma_zone_t)io->io_hdr.pool, io); 3833#endif | |
3834} 3835 3836void 3837ctl_zero_io(union ctl_io *io) 3838{ | 3815} 3816 3817void 3818ctl_zero_io(union ctl_io *io) 3819{ |
3839 void *pool_ref; | 3820 struct ctl_io_pool *pool; |
3840 3841 if (io == NULL) 3842 return; 3843 3844 /* 3845 * May need to preserve linked list pointers at some point too. 3846 */ | 3821 3822 if (io == NULL) 3823 return; 3824 3825 /* 3826 * May need to preserve linked list pointers at some point too. 3827 */ |
3847 pool_ref = io->io_hdr.pool; | 3828 pool = io->io_hdr.pool; |
3848 memset(io, 0, sizeof(*io)); | 3829 memset(io, 0, sizeof(*io)); |
3849 io->io_hdr.pool = pool_ref; | 3830 io->io_hdr.pool = pool; 3831 CTL_SOFTC(io) = pool->ctl_softc; |
3850} 3851 3852int 3853ctl_expand_number(const char *buf, uint64_t *num) 3854{ 3855 char *endptr; 3856 uint64_t number; 3857 unsigned shift; --- 790 unchanged lines hidden (view full) --- 4648 * Delete a LUN. 4649 * Assumptions: 4650 * - LUN has already been marked invalid and any pending I/O has been taken 4651 * care of. 4652 */ 4653static int 4654ctl_free_lun(struct ctl_lun *lun) 4655{ | 3832} 3833 3834int 3835ctl_expand_number(const char *buf, uint64_t *num) 3836{ 3837 char *endptr; 3838 uint64_t number; 3839 unsigned shift; --- 790 unchanged lines hidden (view full) --- 4630 * Delete a LUN. 4631 * Assumptions: 4632 * - LUN has already been marked invalid and any pending I/O has been taken 4633 * care of. 4634 */ 4635static int 4636ctl_free_lun(struct ctl_lun *lun) 4637{ |
4656 struct ctl_softc *softc; | 4638 struct ctl_softc *softc = lun->ctl_softc; |
4657 struct ctl_lun *nlun; 4658 int i; 4659 | 4639 struct ctl_lun *nlun; 4640 int i; 4641 |
4660 softc = lun->ctl_softc; 4661 | |
4662 mtx_assert(&softc->ctl_lock, MA_OWNED); 4663 4664 STAILQ_REMOVE(&softc->lun_list, lun, ctl_lun, links); 4665 4666 ctl_clear_mask(softc->ctl_lun_mask, lun->lun); 4667 4668 softc->ctl_luns[lun->lun] = NULL; 4669 --- 484 unchanged lines hidden (view full) --- 5154} 5155 5156/* 5157 * SCSI release command. 5158 */ 5159int 5160ctl_scsi_release(struct ctl_scsiio *ctsio) 5161{ | 4642 mtx_assert(&softc->ctl_lock, MA_OWNED); 4643 4644 STAILQ_REMOVE(&softc->lun_list, lun, ctl_lun, links); 4645 4646 ctl_clear_mask(softc->ctl_lun_mask, lun->lun); 4647 4648 softc->ctl_luns[lun->lun] = NULL; 4649 --- 484 unchanged lines hidden (view full) --- 5134} 5135 5136/* 5137 * SCSI release command. 5138 */ 5139int 5140ctl_scsi_release(struct ctl_scsiio *ctsio) 5141{ |
5162 struct ctl_lun *lun; | 5142 struct ctl_lun *lun = CTL_LUN(ctsio); |
5163 uint32_t residx; 5164 5165 CTL_DEBUG_PRINT(("ctl_scsi_release\n")); 5166 5167 residx = ctl_get_initindex(&ctsio->io_hdr.nexus); | 5143 uint32_t residx; 5144 5145 CTL_DEBUG_PRINT(("ctl_scsi_release\n")); 5146 5147 residx = ctl_get_initindex(&ctsio->io_hdr.nexus); |
5168 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; | |
5169 5170 /* 5171 * XXX KDM right now, we only support LUN reservation. We don't 5172 * support 3rd party reservations, or extent reservations, which 5173 * might actually need the parameter list. If we've gotten this 5174 * far, we've got a LUN reservation. Anything else got kicked out 5175 * above. So, according to SPC, ignore the length. 5176 */ --- 15 unchanged lines hidden (view full) --- 5192 ctl_set_success(ctsio); 5193 ctl_done((union ctl_io *)ctsio); 5194 return (CTL_RETVAL_COMPLETE); 5195} 5196 5197int 5198ctl_scsi_reserve(struct ctl_scsiio *ctsio) 5199{ | 5148 5149 /* 5150 * XXX KDM right now, we only support LUN reservation. We don't 5151 * support 3rd party reservations, or extent reservations, which 5152 * might actually need the parameter list. If we've gotten this 5153 * far, we've got a LUN reservation. Anything else got kicked out 5154 * above. So, according to SPC, ignore the length. 5155 */ --- 15 unchanged lines hidden (view full) --- 5171 ctl_set_success(ctsio); 5172 ctl_done((union ctl_io *)ctsio); 5173 return (CTL_RETVAL_COMPLETE); 5174} 5175 5176int 5177ctl_scsi_reserve(struct ctl_scsiio *ctsio) 5178{ |
5200 struct ctl_lun *lun; | 5179 struct ctl_lun *lun = CTL_LUN(ctsio); |
5201 uint32_t residx; 5202 5203 CTL_DEBUG_PRINT(("ctl_reserve\n")); 5204 5205 residx = ctl_get_initindex(&ctsio->io_hdr.nexus); | 5180 uint32_t residx; 5181 5182 CTL_DEBUG_PRINT(("ctl_reserve\n")); 5183 5184 residx = ctl_get_initindex(&ctsio->io_hdr.nexus); |
5206 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; | |
5207 5208 /* 5209 * XXX KDM right now, we only support LUN reservation. We don't 5210 * support 3rd party reservations, or extent reservations, which 5211 * might actually need the parameter list. If we've gotten this 5212 * far, we've got a LUN reservation. Anything else got kicked out 5213 * above. So, according to SPC, ignore the length. 5214 */ --- 18 unchanged lines hidden (view full) --- 5233 mtx_unlock(&lun->lun_lock); 5234 ctl_done((union ctl_io *)ctsio); 5235 return (CTL_RETVAL_COMPLETE); 5236} 5237 5238int 5239ctl_start_stop(struct ctl_scsiio *ctsio) 5240{ | 5185 5186 /* 5187 * XXX KDM right now, we only support LUN reservation. We don't 5188 * support 3rd party reservations, or extent reservations, which 5189 * might actually need the parameter list. If we've gotten this 5190 * far, we've got a LUN reservation. Anything else got kicked out 5191 * above. So, according to SPC, ignore the length. 5192 */ --- 18 unchanged lines hidden (view full) --- 5211 mtx_unlock(&lun->lun_lock); 5212 ctl_done((union ctl_io *)ctsio); 5213 return (CTL_RETVAL_COMPLETE); 5214} 5215 5216int 5217ctl_start_stop(struct ctl_scsiio *ctsio) 5218{ |
5219 struct ctl_lun *lun = CTL_LUN(ctsio); |
|
5241 struct scsi_start_stop_unit *cdb; | 5220 struct scsi_start_stop_unit *cdb; |
5242 struct ctl_lun *lun; | |
5243 int retval; 5244 5245 CTL_DEBUG_PRINT(("ctl_start_stop\n")); 5246 | 5221 int retval; 5222 5223 CTL_DEBUG_PRINT(("ctl_start_stop\n")); 5224 |
5247 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; | |
5248 cdb = (struct scsi_start_stop_unit *)ctsio->cdb; 5249 5250 if ((cdb->how & SSS_PC_MASK) == 0) { 5251 if ((lun->flags & CTL_LUN_PR_RESERVED) && 5252 (cdb->how & SSS_START) == 0) { 5253 uint32_t residx; 5254 5255 residx = ctl_get_initindex(&ctsio->io_hdr.nexus); --- 32 unchanged lines hidden (view full) --- 5288 5289 retval = lun->backend->config_write((union ctl_io *)ctsio); 5290 return (retval); 5291} 5292 5293int 5294ctl_prevent_allow(struct ctl_scsiio *ctsio) 5295{ | 5225 cdb = (struct scsi_start_stop_unit *)ctsio->cdb; 5226 5227 if ((cdb->how & SSS_PC_MASK) == 0) { 5228 if ((lun->flags & CTL_LUN_PR_RESERVED) && 5229 (cdb->how & SSS_START) == 0) { 5230 uint32_t residx; 5231 5232 residx = ctl_get_initindex(&ctsio->io_hdr.nexus); --- 32 unchanged lines hidden (view full) --- 5265 5266 retval = lun->backend->config_write((union ctl_io *)ctsio); 5267 return (retval); 5268} 5269 5270int 5271ctl_prevent_allow(struct ctl_scsiio *ctsio) 5272{ |
5296 struct ctl_lun *lun; | 5273 struct ctl_lun *lun = CTL_LUN(ctsio); |
5297 struct scsi_prevent *cdb; 5298 int retval; 5299 uint32_t initidx; 5300 5301 CTL_DEBUG_PRINT(("ctl_prevent_allow\n")); 5302 | 5274 struct scsi_prevent *cdb; 5275 int retval; 5276 uint32_t initidx; 5277 5278 CTL_DEBUG_PRINT(("ctl_prevent_allow\n")); 5279 |
5303 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; | |
5304 cdb = (struct scsi_prevent *)ctsio->cdb; 5305 5306 if ((lun->flags & CTL_LUN_REMOVABLE) == 0) { 5307 ctl_set_invalid_opcode(ctsio); 5308 ctl_done((union ctl_io *)ctsio); 5309 return (CTL_RETVAL_COMPLETE); 5310 } 5311 --- 17 unchanged lines hidden (view full) --- 5329 * We support the SYNCHRONIZE CACHE command (10 and 16 byte versions), but 5330 * we don't really do anything with the LBA and length fields if the user 5331 * passes them in. Instead we'll just flush out the cache for the entire 5332 * LUN. 5333 */ 5334int 5335ctl_sync_cache(struct ctl_scsiio *ctsio) 5336{ | 5280 cdb = (struct scsi_prevent *)ctsio->cdb; 5281 5282 if ((lun->flags & CTL_LUN_REMOVABLE) == 0) { 5283 ctl_set_invalid_opcode(ctsio); 5284 ctl_done((union ctl_io *)ctsio); 5285 return (CTL_RETVAL_COMPLETE); 5286 } 5287 --- 17 unchanged lines hidden (view full) --- 5305 * We support the SYNCHRONIZE CACHE command (10 and 16 byte versions), but 5306 * we don't really do anything with the LBA and length fields if the user 5307 * passes them in. Instead we'll just flush out the cache for the entire 5308 * LUN. 5309 */ 5310int 5311ctl_sync_cache(struct ctl_scsiio *ctsio) 5312{ |
5337 struct ctl_lun *lun; 5338 struct ctl_softc *softc; | 5313 struct ctl_lun *lun = CTL_LUN(ctsio); |
5339 struct ctl_lba_len_flags *lbalen; 5340 uint64_t starting_lba; 5341 uint32_t block_count; 5342 int retval; 5343 uint8_t byte2; 5344 5345 CTL_DEBUG_PRINT(("ctl_sync_cache\n")); 5346 | 5314 struct ctl_lba_len_flags *lbalen; 5315 uint64_t starting_lba; 5316 uint32_t block_count; 5317 int retval; 5318 uint8_t byte2; 5319 5320 CTL_DEBUG_PRINT(("ctl_sync_cache\n")); 5321 |
5347 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; 5348 softc = lun->ctl_softc; | |
5349 retval = 0; 5350 5351 switch (ctsio->cdb[0]) { 5352 case SYNCHRONIZE_CACHE: { 5353 struct scsi_sync_cache *cdb; 5354 cdb = (struct scsi_sync_cache *)ctsio->cdb; 5355 5356 starting_lba = scsi_4btoul(cdb->begin_lba); --- 39 unchanged lines hidden (view full) --- 5396bailout: 5397 return (retval); 5398} 5399 5400int 5401ctl_format(struct ctl_scsiio *ctsio) 5402{ 5403 struct scsi_format *cdb; | 5322 retval = 0; 5323 5324 switch (ctsio->cdb[0]) { 5325 case SYNCHRONIZE_CACHE: { 5326 struct scsi_sync_cache *cdb; 5327 cdb = (struct scsi_sync_cache *)ctsio->cdb; 5328 5329 starting_lba = scsi_4btoul(cdb->begin_lba); --- 39 unchanged lines hidden (view full) --- 5369bailout: 5370 return (retval); 5371} 5372 5373int 5374ctl_format(struct ctl_scsiio *ctsio) 5375{ 5376 struct scsi_format *cdb; |
5404 struct ctl_lun *lun; | |
5405 int length, defect_list_len; 5406 5407 CTL_DEBUG_PRINT(("ctl_format\n")); 5408 | 5377 int length, defect_list_len; 5378 5379 CTL_DEBUG_PRINT(("ctl_format\n")); 5380 |
5409 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; 5410 | |
5411 cdb = (struct scsi_format *)ctsio->cdb; 5412 5413 length = 0; 5414 if (cdb->byte2 & SF_FMTDATA) { 5415 if (cdb->byte2 & SF_LONGLIST) 5416 length = sizeof(struct scsi_format_header_long); 5417 else 5418 length = sizeof(struct scsi_format_header_short); --- 62 unchanged lines hidden (view full) --- 5481 5482 ctl_done((union ctl_io *)ctsio); 5483 return (CTL_RETVAL_COMPLETE); 5484} 5485 5486int 5487ctl_read_buffer(struct ctl_scsiio *ctsio) 5488{ | 5381 cdb = (struct scsi_format *)ctsio->cdb; 5382 5383 length = 0; 5384 if (cdb->byte2 & SF_FMTDATA) { 5385 if (cdb->byte2 & SF_LONGLIST) 5386 length = sizeof(struct scsi_format_header_long); 5387 else 5388 length = sizeof(struct scsi_format_header_short); --- 62 unchanged lines hidden (view full) --- 5451 5452 ctl_done((union ctl_io *)ctsio); 5453 return (CTL_RETVAL_COMPLETE); 5454} 5455 5456int 5457ctl_read_buffer(struct ctl_scsiio *ctsio) 5458{ |
5489 struct ctl_lun *lun; | 5459 struct ctl_lun *lun = CTL_LUN(ctsio); |
5490 uint64_t buffer_offset; 5491 uint32_t len; 5492 uint8_t byte2; 5493 static uint8_t descr[4]; 5494 static uint8_t echo_descr[4] = { 0 }; 5495 5496 CTL_DEBUG_PRINT(("ctl_read_buffer\n")); | 5460 uint64_t buffer_offset; 5461 uint32_t len; 5462 uint8_t byte2; 5463 static uint8_t descr[4]; 5464 static uint8_t echo_descr[4] = { 0 }; 5465 5466 CTL_DEBUG_PRINT(("ctl_read_buffer\n")); |
5497 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; | 5467 |
5498 switch (ctsio->cdb[0]) { 5499 case READ_BUFFER: { 5500 struct scsi_read_buffer *cdb; 5501 5502 cdb = (struct scsi_read_buffer *)ctsio->cdb; 5503 buffer_offset = scsi_3btoul(cdb->offset); 5504 len = scsi_3btoul(cdb->length); 5505 byte2 = cdb->byte2; --- 50 unchanged lines hidden (view full) --- 5556 ctsio->be_move_done = ctl_config_move_done; 5557 ctl_datamove((union ctl_io *)ctsio); 5558 return (CTL_RETVAL_COMPLETE); 5559} 5560 5561int 5562ctl_write_buffer(struct ctl_scsiio *ctsio) 5563{ | 5468 switch (ctsio->cdb[0]) { 5469 case READ_BUFFER: { 5470 struct scsi_read_buffer *cdb; 5471 5472 cdb = (struct scsi_read_buffer *)ctsio->cdb; 5473 buffer_offset = scsi_3btoul(cdb->offset); 5474 len = scsi_3btoul(cdb->length); 5475 byte2 = cdb->byte2; --- 50 unchanged lines hidden (view full) --- 5526 ctsio->be_move_done = ctl_config_move_done; 5527 ctl_datamove((union ctl_io *)ctsio); 5528 return (CTL_RETVAL_COMPLETE); 5529} 5530 5531int 5532ctl_write_buffer(struct ctl_scsiio *ctsio) 5533{ |
5534 struct ctl_lun *lun = CTL_LUN(ctsio); |
|
5564 struct scsi_write_buffer *cdb; | 5535 struct scsi_write_buffer *cdb; |
5565 struct ctl_lun *lun; | |
5566 int buffer_offset, len; 5567 5568 CTL_DEBUG_PRINT(("ctl_write_buffer\n")); 5569 | 5536 int buffer_offset, len; 5537 5538 CTL_DEBUG_PRINT(("ctl_write_buffer\n")); 5539 |
5570 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; | |
5571 cdb = (struct scsi_write_buffer *)ctsio->cdb; 5572 5573 len = scsi_3btoul(cdb->length); 5574 buffer_offset = scsi_3btoul(cdb->offset); 5575 5576 if (buffer_offset + len > CTL_WRITE_BUFFER_SIZE) { 5577 ctl_set_invalid_field(ctsio, 5578 /*sks_valid*/ 1, --- 30 unchanged lines hidden (view full) --- 5609 ctl_set_success(ctsio); 5610 ctl_done((union ctl_io *)ctsio); 5611 return (CTL_RETVAL_COMPLETE); 5612} 5613 5614int 5615ctl_write_same(struct ctl_scsiio *ctsio) 5616{ | 5540 cdb = (struct scsi_write_buffer *)ctsio->cdb; 5541 5542 len = scsi_3btoul(cdb->length); 5543 buffer_offset = scsi_3btoul(cdb->offset); 5544 5545 if (buffer_offset + len > CTL_WRITE_BUFFER_SIZE) { 5546 ctl_set_invalid_field(ctsio, 5547 /*sks_valid*/ 1, --- 30 unchanged lines hidden (view full) --- 5578 ctl_set_success(ctsio); 5579 ctl_done((union ctl_io *)ctsio); 5580 return (CTL_RETVAL_COMPLETE); 5581} 5582 5583int 5584ctl_write_same(struct ctl_scsiio *ctsio) 5585{ |
5617 struct ctl_lun *lun; | 5586 struct ctl_lun *lun = CTL_LUN(ctsio); |
5618 struct ctl_lba_len_flags *lbalen; 5619 uint64_t lba; 5620 uint32_t num_blocks; 5621 int len, retval; 5622 uint8_t byte2; 5623 5624 CTL_DEBUG_PRINT(("ctl_write_same\n")); 5625 | 5587 struct ctl_lba_len_flags *lbalen; 5588 uint64_t lba; 5589 uint32_t num_blocks; 5590 int len, retval; 5591 uint8_t byte2; 5592 5593 CTL_DEBUG_PRINT(("ctl_write_same\n")); 5594 |
5626 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; 5627 | |
5628 switch (ctsio->cdb[0]) { 5629 case WRITE_SAME_10: { 5630 struct scsi_write_same_10 *cdb; 5631 5632 cdb = (struct scsi_write_same_10 *)ctsio->cdb; 5633 5634 lba = scsi_4btoul(cdb->addr); 5635 num_blocks = scsi_2btoul(cdb->length); --- 87 unchanged lines hidden (view full) --- 5723 retval = lun->backend->config_write((union ctl_io *)ctsio); 5724 5725 return (retval); 5726} 5727 5728int 5729ctl_unmap(struct ctl_scsiio *ctsio) 5730{ | 5595 switch (ctsio->cdb[0]) { 5596 case WRITE_SAME_10: { 5597 struct scsi_write_same_10 *cdb; 5598 5599 cdb = (struct scsi_write_same_10 *)ctsio->cdb; 5600 5601 lba = scsi_4btoul(cdb->addr); 5602 num_blocks = scsi_2btoul(cdb->length); --- 87 unchanged lines hidden (view full) --- 5690 retval = lun->backend->config_write((union ctl_io *)ctsio); 5691 5692 return (retval); 5693} 5694 5695int 5696ctl_unmap(struct ctl_scsiio *ctsio) 5697{ |
5731 struct ctl_lun *lun; | 5698 struct ctl_lun *lun = CTL_LUN(ctsio); |
5732 struct scsi_unmap *cdb; 5733 struct ctl_ptr_len_flags *ptrlen; 5734 struct scsi_unmap_header *hdr; 5735 struct scsi_unmap_desc *buf, *end, *endnz, *range; 5736 uint64_t lba; 5737 uint32_t num_blocks; 5738 int len, retval; 5739 uint8_t byte2; 5740 5741 CTL_DEBUG_PRINT(("ctl_unmap\n")); 5742 | 5699 struct scsi_unmap *cdb; 5700 struct ctl_ptr_len_flags *ptrlen; 5701 struct scsi_unmap_header *hdr; 5702 struct scsi_unmap_desc *buf, *end, *endnz, *range; 5703 uint64_t lba; 5704 uint32_t num_blocks; 5705 int len, retval; 5706 uint8_t byte2; 5707 5708 CTL_DEBUG_PRINT(("ctl_unmap\n")); 5709 |
5743 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; | |
5744 cdb = (struct scsi_unmap *)ctsio->cdb; | 5710 cdb = (struct scsi_unmap *)ctsio->cdb; |
5745 | |
5746 len = scsi_2btoul(cdb->length); 5747 byte2 = cdb->byte2; 5748 5749 /* 5750 * If we've got a kernel request that hasn't been malloced yet, 5751 * malloc it and tell the caller the data buffer is here. 5752 */ 5753 if ((ctsio->io_hdr.flags & CTL_FLAG_ALLOCATED) == 0) { --- 73 unchanged lines hidden (view full) --- 5827 ctl_done((union ctl_io *)ctsio); 5828 return (CTL_RETVAL_COMPLETE); 5829} 5830 5831int 5832ctl_default_page_handler(struct ctl_scsiio *ctsio, 5833 struct ctl_page_index *page_index, uint8_t *page_ptr) 5834{ | 5711 len = scsi_2btoul(cdb->length); 5712 byte2 = cdb->byte2; 5713 5714 /* 5715 * If we've got a kernel request that hasn't been malloced yet, 5716 * malloc it and tell the caller the data buffer is here. 5717 */ 5718 if ((ctsio->io_hdr.flags & CTL_FLAG_ALLOCATED) == 0) { --- 73 unchanged lines hidden (view full) --- 5792 ctl_done((union ctl_io *)ctsio); 5793 return (CTL_RETVAL_COMPLETE); 5794} 5795 5796int 5797ctl_default_page_handler(struct ctl_scsiio *ctsio, 5798 struct ctl_page_index *page_index, uint8_t *page_ptr) 5799{ |
5835 struct ctl_lun *lun; | 5800 struct ctl_lun *lun = CTL_LUN(ctsio); |
5836 uint8_t *current_cp; 5837 int set_ua; 5838 uint32_t initidx; 5839 | 5801 uint8_t *current_cp; 5802 int set_ua; 5803 uint32_t initidx; 5804 |
5840 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; | |
5841 initidx = ctl_get_initindex(&ctsio->io_hdr.nexus); 5842 set_ua = 0; 5843 5844 current_cp = (page_index->page_data + (page_index->page_len * 5845 CTL_PAGE_CURRENT)); 5846 5847 mtx_lock(&lun->lun_lock); 5848 if (memcmp(current_cp, page_ptr, page_index->page_len)) { --- 33 unchanged lines hidden (view full) --- 5882 callout_schedule(&lun->ie_callout, t * hz / 10); 5883 } 5884} 5885 5886int 5887ctl_ie_page_handler(struct ctl_scsiio *ctsio, 5888 struct ctl_page_index *page_index, uint8_t *page_ptr) 5889{ | 5805 initidx = ctl_get_initindex(&ctsio->io_hdr.nexus); 5806 set_ua = 0; 5807 5808 current_cp = (page_index->page_data + (page_index->page_len * 5809 CTL_PAGE_CURRENT)); 5810 5811 mtx_lock(&lun->lun_lock); 5812 if (memcmp(current_cp, page_ptr, page_index->page_len)) { --- 33 unchanged lines hidden (view full) --- 5846 callout_schedule(&lun->ie_callout, t * hz / 10); 5847 } 5848} 5849 5850int 5851ctl_ie_page_handler(struct ctl_scsiio *ctsio, 5852 struct ctl_page_index *page_index, uint8_t *page_ptr) 5853{ |
5854 struct ctl_lun *lun = CTL_LUN(ctsio); |
|
5890 struct scsi_info_exceptions_page *pg; | 5855 struct scsi_info_exceptions_page *pg; |
5891 struct ctl_lun *lun; | |
5892 uint64_t t; 5893 5894 (void)ctl_default_page_handler(ctsio, page_index, page_ptr); 5895 | 5856 uint64_t t; 5857 5858 (void)ctl_default_page_handler(ctsio, page_index, page_ptr); 5859 |
5896 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; | |
5897 pg = (struct scsi_info_exceptions_page *)page_ptr; 5898 mtx_lock(&lun->lun_lock); 5899 if (pg->info_flags & SIEP_FLAGS_TEST) { 5900 lun->ie_asc = 0x5d; 5901 lun->ie_ascq = 0xff; 5902 if (pg->mrie == SIEP_MRIE_UA) { 5903 ctl_est_ua_all(lun, -1, CTL_UA_IE); 5904 lun->ie_reported = 1; --- 20 unchanged lines hidden (view full) --- 5925 } 5926 mtx_unlock(&lun->lun_lock); 5927 return (CTL_RETVAL_COMPLETE); 5928} 5929 5930static int 5931ctl_do_mode_select(union ctl_io *io) 5932{ | 5860 pg = (struct scsi_info_exceptions_page *)page_ptr; 5861 mtx_lock(&lun->lun_lock); 5862 if (pg->info_flags & SIEP_FLAGS_TEST) { 5863 lun->ie_asc = 0x5d; 5864 lun->ie_ascq = 0xff; 5865 if (pg->mrie == SIEP_MRIE_UA) { 5866 ctl_est_ua_all(lun, -1, CTL_UA_IE); 5867 lun->ie_reported = 1; --- 20 unchanged lines hidden (view full) --- 5888 } 5889 mtx_unlock(&lun->lun_lock); 5890 return (CTL_RETVAL_COMPLETE); 5891} 5892 5893static int 5894ctl_do_mode_select(union ctl_io *io) 5895{ |
5896 struct ctl_lun *lun = CTL_LUN(io); |
|
5933 struct scsi_mode_page_header *page_header; 5934 struct ctl_page_index *page_index; 5935 struct ctl_scsiio *ctsio; 5936 int page_len, page_len_offset, page_len_size; 5937 union ctl_modepage_info *modepage_info; | 5897 struct scsi_mode_page_header *page_header; 5898 struct ctl_page_index *page_index; 5899 struct ctl_scsiio *ctsio; 5900 int page_len, page_len_offset, page_len_size; 5901 union ctl_modepage_info *modepage_info; |
5938 struct ctl_lun *lun; | |
5939 uint16_t *len_left, *len_used; 5940 int retval, i; 5941 5942 ctsio = &io->scsiio; 5943 page_index = NULL; 5944 page_len = 0; | 5902 uint16_t *len_left, *len_used; 5903 int retval, i; 5904 5905 ctsio = &io->scsiio; 5906 page_index = NULL; 5907 page_len = 0; |
5945 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; | |
5946 5947 modepage_info = (union ctl_modepage_info *) 5948 ctsio->io_hdr.ctl_private[CTL_PRIV_MODEPAGE].bytes; 5949 len_left = &modepage_info->header.len_left; 5950 len_used = &modepage_info->header.len_used; 5951 5952do_next_page: 5953 --- 196 unchanged lines hidden (view full) --- 6150 6151 return (CTL_RETVAL_COMPLETE); 6152 6153} 6154 6155int 6156ctl_mode_select(struct ctl_scsiio *ctsio) 6157{ | 5908 5909 modepage_info = (union ctl_modepage_info *) 5910 ctsio->io_hdr.ctl_private[CTL_PRIV_MODEPAGE].bytes; 5911 len_left = &modepage_info->header.len_left; 5912 len_used = &modepage_info->header.len_used; 5913 5914do_next_page: 5915 --- 196 unchanged lines hidden (view full) --- 6112 6113 return (CTL_RETVAL_COMPLETE); 6114 6115} 6116 6117int 6118ctl_mode_select(struct ctl_scsiio *ctsio) 6119{ |
6158 struct ctl_lun *lun; | 6120 struct ctl_lun *lun = CTL_LUN(ctsio); |
6159 union ctl_modepage_info *modepage_info; 6160 int bd_len, i, header_size, param_len, pf, rtd, sp; 6161 uint32_t initidx; 6162 | 6121 union ctl_modepage_info *modepage_info; 6122 int bd_len, i, header_size, param_len, pf, rtd, sp; 6123 uint32_t initidx; 6124 |
6163 lun = ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; | |
6164 initidx = ctl_get_initindex(&ctsio->io_hdr.nexus); 6165 switch (ctsio->cdb[0]) { 6166 case MODE_SELECT_6: { 6167 struct scsi_mode_select_6 *cdb; 6168 6169 cdb = (struct scsi_mode_select_6 *)ctsio->cdb; 6170 6171 pf = (cdb->byte2 & SMS_PF) ? 1 : 0; --- 128 unchanged lines hidden (view full) --- 6300 modepage_info->header.len_used = header_size + bd_len; 6301 6302 return (ctl_do_mode_select((union ctl_io *)ctsio)); 6303} 6304 6305int 6306ctl_mode_sense(struct ctl_scsiio *ctsio) 6307{ | 6125 initidx = ctl_get_initindex(&ctsio->io_hdr.nexus); 6126 switch (ctsio->cdb[0]) { 6127 case MODE_SELECT_6: { 6128 struct scsi_mode_select_6 *cdb; 6129 6130 cdb = (struct scsi_mode_select_6 *)ctsio->cdb; 6131 6132 pf = (cdb->byte2 & SMS_PF) ? 1 : 0; --- 128 unchanged lines hidden (view full) --- 6261 modepage_info->header.len_used = header_size + bd_len; 6262 6263 return (ctl_do_mode_select((union ctl_io *)ctsio)); 6264} 6265 6266int 6267ctl_mode_sense(struct ctl_scsiio *ctsio) 6268{ |
6308 struct ctl_lun *lun; | 6269 struct ctl_lun *lun = CTL_LUN(ctsio); |
6309 int pc, page_code, dbd, llba, subpage; 6310 int alloc_len, page_len, header_len, total_len; 6311 struct scsi_mode_block_descr *block_desc; 6312 struct ctl_page_index *page_index; 6313 6314 dbd = 0; 6315 llba = 0; 6316 block_desc = NULL; 6317 6318 CTL_DEBUG_PRINT(("ctl_mode_sense\n")); 6319 | 6270 int pc, page_code, dbd, llba, subpage; 6271 int alloc_len, page_len, header_len, total_len; 6272 struct scsi_mode_block_descr *block_desc; 6273 struct ctl_page_index *page_index; 6274 6275 dbd = 0; 6276 llba = 0; 6277 block_desc = NULL; 6278 6279 CTL_DEBUG_PRINT(("ctl_mode_sense\n")); 6280 |
6320 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; | |
6321 switch (ctsio->cdb[0]) { 6322 case MODE_SENSE_6: { 6323 struct scsi_mode_sense_6 *cdb; 6324 6325 cdb = (struct scsi_mode_sense_6 *)ctsio->cdb; 6326 6327 header_len = sizeof(struct scsi_mode_hdr_6); 6328 if (cdb->byte2 & SMS_DBD) --- 319 unchanged lines hidden (view full) --- 6648 return (CTL_RETVAL_COMPLETE); 6649} 6650 6651int 6652ctl_lbp_log_sense_handler(struct ctl_scsiio *ctsio, 6653 struct ctl_page_index *page_index, 6654 int pc) 6655{ | 6281 switch (ctsio->cdb[0]) { 6282 case MODE_SENSE_6: { 6283 struct scsi_mode_sense_6 *cdb; 6284 6285 cdb = (struct scsi_mode_sense_6 *)ctsio->cdb; 6286 6287 header_len = sizeof(struct scsi_mode_hdr_6); 6288 if (cdb->byte2 & SMS_DBD) --- 319 unchanged lines hidden (view full) --- 6608 return (CTL_RETVAL_COMPLETE); 6609} 6610 6611int 6612ctl_lbp_log_sense_handler(struct ctl_scsiio *ctsio, 6613 struct ctl_page_index *page_index, 6614 int pc) 6615{ |
6656 struct ctl_lun *lun; | 6616 struct ctl_lun *lun = CTL_LUN(ctsio); |
6657 struct scsi_log_param_header *phdr; 6658 uint8_t *data; 6659 uint64_t val; 6660 | 6617 struct scsi_log_param_header *phdr; 6618 uint8_t *data; 6619 uint64_t val; 6620 |
6661 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; | |
6662 data = page_index->page_data; 6663 6664 if (lun->backend->lun_attr != NULL && 6665 (val = lun->backend->lun_attr(lun->be_lun->be_lun, "blocksavail")) 6666 != UINT64_MAX) { 6667 phdr = (struct scsi_log_param_header *)data; 6668 scsi_ulto2b(0x0001, phdr->param_code); 6669 phdr->param_control = SLP_LBIN | SLP_LP; --- 47 unchanged lines hidden (view full) --- 6717 return (0); 6718} 6719 6720int 6721ctl_sap_log_sense_handler(struct ctl_scsiio *ctsio, 6722 struct ctl_page_index *page_index, 6723 int pc) 6724{ | 6621 data = page_index->page_data; 6622 6623 if (lun->backend->lun_attr != NULL && 6624 (val = lun->backend->lun_attr(lun->be_lun->be_lun, "blocksavail")) 6625 != UINT64_MAX) { 6626 phdr = (struct scsi_log_param_header *)data; 6627 scsi_ulto2b(0x0001, phdr->param_code); 6628 phdr->param_control = SLP_LBIN | SLP_LP; --- 47 unchanged lines hidden (view full) --- 6676 return (0); 6677} 6678 6679int 6680ctl_sap_log_sense_handler(struct ctl_scsiio *ctsio, 6681 struct ctl_page_index *page_index, 6682 int pc) 6683{ |
6725 struct ctl_lun *lun; | 6684 struct ctl_lun *lun = CTL_LUN(ctsio); |
6726 struct stat_page *data; 6727 uint64_t rn, wn, rb, wb; 6728 struct bintime rt, wt; 6729 int i; 6730 | 6685 struct stat_page *data; 6686 uint64_t rn, wn, rb, wb; 6687 struct bintime rt, wt; 6688 int i; 6689 |
6731 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; | |
6732 data = (struct stat_page *)page_index->page_data; 6733 6734 scsi_ulto2b(SLP_SAP, data->sap.hdr.param_code); 6735 data->sap.hdr.param_control = SLP_LBIN; 6736 data->sap.hdr.param_len = sizeof(struct scsi_log_stat_and_perf) - 6737 sizeof(struct scsi_log_param_header); 6738 rn = wn = rb = wb = 0; 6739 bintime_clear(&rt); --- 36 unchanged lines hidden (view full) --- 6776 return (0); 6777} 6778 6779int 6780ctl_ie_log_sense_handler(struct ctl_scsiio *ctsio, 6781 struct ctl_page_index *page_index, 6782 int pc) 6783{ | 6690 data = (struct stat_page *)page_index->page_data; 6691 6692 scsi_ulto2b(SLP_SAP, data->sap.hdr.param_code); 6693 data->sap.hdr.param_control = SLP_LBIN; 6694 data->sap.hdr.param_len = sizeof(struct scsi_log_stat_and_perf) - 6695 sizeof(struct scsi_log_param_header); 6696 rn = wn = rb = wb = 0; 6697 bintime_clear(&rt); --- 36 unchanged lines hidden (view full) --- 6734 return (0); 6735} 6736 6737int 6738ctl_ie_log_sense_handler(struct ctl_scsiio *ctsio, 6739 struct ctl_page_index *page_index, 6740 int pc) 6741{ |
6784 struct ctl_lun *lun; | 6742 struct ctl_lun *lun = CTL_LUN(ctsio); |
6785 struct scsi_log_informational_exceptions *data; 6786 | 6743 struct scsi_log_informational_exceptions *data; 6744 |
6787 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; | |
6788 data = (struct scsi_log_informational_exceptions *)page_index->page_data; 6789 6790 scsi_ulto2b(SLP_IE_GEN, data->hdr.param_code); 6791 data->hdr.param_control = SLP_LBIN; 6792 data->hdr.param_len = sizeof(struct scsi_log_informational_exceptions) - 6793 sizeof(struct scsi_log_param_header); 6794 data->ie_asc = lun->ie_asc; 6795 data->ie_ascq = lun->ie_ascq; 6796 data->temperature = 0xff; 6797 return (0); 6798} 6799 6800int 6801ctl_log_sense(struct ctl_scsiio *ctsio) 6802{ | 6745 data = (struct scsi_log_informational_exceptions *)page_index->page_data; 6746 6747 scsi_ulto2b(SLP_IE_GEN, data->hdr.param_code); 6748 data->hdr.param_control = SLP_LBIN; 6749 data->hdr.param_len = sizeof(struct scsi_log_informational_exceptions) - 6750 sizeof(struct scsi_log_param_header); 6751 data->ie_asc = lun->ie_asc; 6752 data->ie_ascq = lun->ie_ascq; 6753 data->temperature = 0xff; 6754 return (0); 6755} 6756 6757int 6758ctl_log_sense(struct ctl_scsiio *ctsio) 6759{ |
6803 struct ctl_lun *lun; | 6760 struct ctl_lun *lun = CTL_LUN(ctsio); |
6804 int i, pc, page_code, subpage; 6805 int alloc_len, total_len; 6806 struct ctl_page_index *page_index; 6807 struct scsi_log_sense *cdb; 6808 struct scsi_log_header *header; 6809 6810 CTL_DEBUG_PRINT(("ctl_log_sense\n")); 6811 | 6761 int i, pc, page_code, subpage; 6762 int alloc_len, total_len; 6763 struct ctl_page_index *page_index; 6764 struct scsi_log_sense *cdb; 6765 struct scsi_log_header *header; 6766 6767 CTL_DEBUG_PRINT(("ctl_log_sense\n")); 6768 |
6812 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; | |
6813 cdb = (struct scsi_log_sense *)ctsio->cdb; 6814 pc = (cdb->page & SLS_PAGE_CTRL_MASK) >> 6; 6815 page_code = cdb->page & SLS_PAGE_CODE; 6816 subpage = cdb->subpage; 6817 alloc_len = scsi_2btoul(cdb->length); 6818 6819 page_index = NULL; 6820 for (i = 0; i < CTL_NUM_LOG_PAGES; i++) { --- 60 unchanged lines hidden (view full) --- 6881 ctsio->be_move_done = ctl_config_move_done; 6882 ctl_datamove((union ctl_io *)ctsio); 6883 return (CTL_RETVAL_COMPLETE); 6884} 6885 6886int 6887ctl_read_capacity(struct ctl_scsiio *ctsio) 6888{ | 6769 cdb = (struct scsi_log_sense *)ctsio->cdb; 6770 pc = (cdb->page & SLS_PAGE_CTRL_MASK) >> 6; 6771 page_code = cdb->page & SLS_PAGE_CODE; 6772 subpage = cdb->subpage; 6773 alloc_len = scsi_2btoul(cdb->length); 6774 6775 page_index = NULL; 6776 for (i = 0; i < CTL_NUM_LOG_PAGES; i++) { --- 60 unchanged lines hidden (view full) --- 6837 ctsio->be_move_done = ctl_config_move_done; 6838 ctl_datamove((union ctl_io *)ctsio); 6839 return (CTL_RETVAL_COMPLETE); 6840} 6841 6842int 6843ctl_read_capacity(struct ctl_scsiio *ctsio) 6844{ |
6845 struct ctl_lun *lun = CTL_LUN(ctsio); |
|
6889 struct scsi_read_capacity *cdb; 6890 struct scsi_read_capacity_data *data; | 6846 struct scsi_read_capacity *cdb; 6847 struct scsi_read_capacity_data *data; |
6891 struct ctl_lun *lun; | |
6892 uint32_t lba; 6893 6894 CTL_DEBUG_PRINT(("ctl_read_capacity\n")); 6895 6896 cdb = (struct scsi_read_capacity *)ctsio->cdb; 6897 6898 lba = scsi_4btoul(cdb->addr); 6899 if (((cdb->pmi & SRC_PMI) == 0) 6900 && (lba != 0)) { 6901 ctl_set_invalid_field(/*ctsio*/ ctsio, 6902 /*sks_valid*/ 1, 6903 /*command*/ 1, 6904 /*field*/ 2, 6905 /*bit_valid*/ 0, 6906 /*bit*/ 0); 6907 ctl_done((union ctl_io *)ctsio); 6908 return (CTL_RETVAL_COMPLETE); 6909 } 6910 | 6848 uint32_t lba; 6849 6850 CTL_DEBUG_PRINT(("ctl_read_capacity\n")); 6851 6852 cdb = (struct scsi_read_capacity *)ctsio->cdb; 6853 6854 lba = scsi_4btoul(cdb->addr); 6855 if (((cdb->pmi & SRC_PMI) == 0) 6856 && (lba != 0)) { 6857 ctl_set_invalid_field(/*ctsio*/ ctsio, 6858 /*sks_valid*/ 1, 6859 /*command*/ 1, 6860 /*field*/ 2, 6861 /*bit_valid*/ 0, 6862 /*bit*/ 0); 6863 ctl_done((union ctl_io *)ctsio); 6864 return (CTL_RETVAL_COMPLETE); 6865 } 6866 |
6911 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; 6912 | |
6913 ctsio->kern_data_ptr = malloc(sizeof(*data), M_CTL, M_WAITOK | M_ZERO); 6914 data = (struct scsi_read_capacity_data *)ctsio->kern_data_ptr; 6915 ctsio->residual = 0; 6916 ctsio->kern_data_len = sizeof(*data); 6917 ctsio->kern_total_len = sizeof(*data); 6918 ctsio->kern_data_resid = 0; 6919 ctsio->kern_rel_offset = 0; 6920 ctsio->kern_sg_entries = 0; --- 18 unchanged lines hidden (view full) --- 6939 ctsio->be_move_done = ctl_config_move_done; 6940 ctl_datamove((union ctl_io *)ctsio); 6941 return (CTL_RETVAL_COMPLETE); 6942} 6943 6944int 6945ctl_read_capacity_16(struct ctl_scsiio *ctsio) 6946{ | 6867 ctsio->kern_data_ptr = malloc(sizeof(*data), M_CTL, M_WAITOK | M_ZERO); 6868 data = (struct scsi_read_capacity_data *)ctsio->kern_data_ptr; 6869 ctsio->residual = 0; 6870 ctsio->kern_data_len = sizeof(*data); 6871 ctsio->kern_total_len = sizeof(*data); 6872 ctsio->kern_data_resid = 0; 6873 ctsio->kern_rel_offset = 0; 6874 ctsio->kern_sg_entries = 0; --- 18 unchanged lines hidden (view full) --- 6893 ctsio->be_move_done = ctl_config_move_done; 6894 ctl_datamove((union ctl_io *)ctsio); 6895 return (CTL_RETVAL_COMPLETE); 6896} 6897 6898int 6899ctl_read_capacity_16(struct ctl_scsiio *ctsio) 6900{ |
6901 struct ctl_lun *lun = CTL_LUN(ctsio); |
|
6947 struct scsi_read_capacity_16 *cdb; 6948 struct scsi_read_capacity_data_long *data; | 6902 struct scsi_read_capacity_16 *cdb; 6903 struct scsi_read_capacity_data_long *data; |
6949 struct ctl_lun *lun; | |
6950 uint64_t lba; 6951 uint32_t alloc_len; 6952 6953 CTL_DEBUG_PRINT(("ctl_read_capacity_16\n")); 6954 6955 cdb = (struct scsi_read_capacity_16 *)ctsio->cdb; 6956 6957 alloc_len = scsi_4btoul(cdb->alloc_len); --- 6 unchanged lines hidden (view full) --- 6964 /*command*/ 1, 6965 /*field*/ 2, 6966 /*bit_valid*/ 0, 6967 /*bit*/ 0); 6968 ctl_done((union ctl_io *)ctsio); 6969 return (CTL_RETVAL_COMPLETE); 6970 } 6971 | 6904 uint64_t lba; 6905 uint32_t alloc_len; 6906 6907 CTL_DEBUG_PRINT(("ctl_read_capacity_16\n")); 6908 6909 cdb = (struct scsi_read_capacity_16 *)ctsio->cdb; 6910 6911 alloc_len = scsi_4btoul(cdb->alloc_len); --- 6 unchanged lines hidden (view full) --- 6918 /*command*/ 1, 6919 /*field*/ 2, 6920 /*bit_valid*/ 0, 6921 /*bit*/ 0); 6922 ctl_done((union ctl_io *)ctsio); 6923 return (CTL_RETVAL_COMPLETE); 6924 } 6925 |
6972 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; 6973 | |
6974 ctsio->kern_data_ptr = malloc(sizeof(*data), M_CTL, M_WAITOK | M_ZERO); 6975 data = (struct scsi_read_capacity_data_long *)ctsio->kern_data_ptr; 6976 6977 if (sizeof(*data) < alloc_len) { 6978 ctsio->residual = alloc_len - sizeof(*data); 6979 ctsio->kern_data_len = sizeof(*data); 6980 ctsio->kern_total_len = sizeof(*data); 6981 } else { --- 18 unchanged lines hidden (view full) --- 7000 ctsio->be_move_done = ctl_config_move_done; 7001 ctl_datamove((union ctl_io *)ctsio); 7002 return (CTL_RETVAL_COMPLETE); 7003} 7004 7005int 7006ctl_get_lba_status(struct ctl_scsiio *ctsio) 7007{ | 6926 ctsio->kern_data_ptr = malloc(sizeof(*data), M_CTL, M_WAITOK | M_ZERO); 6927 data = (struct scsi_read_capacity_data_long *)ctsio->kern_data_ptr; 6928 6929 if (sizeof(*data) < alloc_len) { 6930 ctsio->residual = alloc_len - sizeof(*data); 6931 ctsio->kern_data_len = sizeof(*data); 6932 ctsio->kern_total_len = sizeof(*data); 6933 } else { --- 18 unchanged lines hidden (view full) --- 6952 ctsio->be_move_done = ctl_config_move_done; 6953 ctl_datamove((union ctl_io *)ctsio); 6954 return (CTL_RETVAL_COMPLETE); 6955} 6956 6957int 6958ctl_get_lba_status(struct ctl_scsiio *ctsio) 6959{ |
6960 struct ctl_lun *lun = CTL_LUN(ctsio); |
|
7008 struct scsi_get_lba_status *cdb; 7009 struct scsi_get_lba_status_data *data; | 6961 struct scsi_get_lba_status *cdb; 6962 struct scsi_get_lba_status_data *data; |
7010 struct ctl_lun *lun; | |
7011 struct ctl_lba_len_flags *lbalen; 7012 uint64_t lba; 7013 uint32_t alloc_len, total_len; 7014 int retval; 7015 7016 CTL_DEBUG_PRINT(("ctl_get_lba_status\n")); 7017 | 6963 struct ctl_lba_len_flags *lbalen; 6964 uint64_t lba; 6965 uint32_t alloc_len, total_len; 6966 int retval; 6967 6968 CTL_DEBUG_PRINT(("ctl_get_lba_status\n")); 6969 |
7018 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; | |
7019 cdb = (struct scsi_get_lba_status *)ctsio->cdb; 7020 lba = scsi_8btou64(cdb->addr); 7021 alloc_len = scsi_4btoul(cdb->alloc_len); 7022 7023 if (lba > lun->be_lun->maxlba) { 7024 ctl_set_lba_out_of_range(ctsio, lba); 7025 ctl_done((union ctl_io *)ctsio); 7026 return (CTL_RETVAL_COMPLETE); --- 96 unchanged lines hidden (view full) --- 7123 ctsio->be_move_done = ctl_config_move_done; 7124 ctl_datamove((union ctl_io *)ctsio); 7125 return (CTL_RETVAL_COMPLETE); 7126} 7127 7128int 7129ctl_report_tagret_port_groups(struct ctl_scsiio *ctsio) 7130{ | 6970 cdb = (struct scsi_get_lba_status *)ctsio->cdb; 6971 lba = scsi_8btou64(cdb->addr); 6972 alloc_len = scsi_4btoul(cdb->alloc_len); 6973 6974 if (lba > lun->be_lun->maxlba) { 6975 ctl_set_lba_out_of_range(ctsio, lba); 6976 ctl_done((union ctl_io *)ctsio); 6977 return (CTL_RETVAL_COMPLETE); --- 96 unchanged lines hidden (view full) --- 7074 ctsio->be_move_done = ctl_config_move_done; 7075 ctl_datamove((union ctl_io *)ctsio); 7076 return (CTL_RETVAL_COMPLETE); 7077} 7078 7079int 7080ctl_report_tagret_port_groups(struct ctl_scsiio *ctsio) 7081{ |
7082 struct ctl_softc *softc = CTL_SOFTC(ctsio); 7083 struct ctl_lun *lun = CTL_LUN(ctsio); |
|
7131 struct scsi_maintenance_in *cdb; 7132 int retval; 7133 int alloc_len, ext, total_len = 0, g, pc, pg, ts, os; 7134 int num_ha_groups, num_target_ports, shared_group; | 7084 struct scsi_maintenance_in *cdb; 7085 int retval; 7086 int alloc_len, ext, total_len = 0, g, pc, pg, ts, os; 7087 int num_ha_groups, num_target_ports, shared_group; |
7135 struct ctl_lun *lun; 7136 struct ctl_softc *softc; | |
7137 struct ctl_port *port; 7138 struct scsi_target_group_data *rtg_ptr; 7139 struct scsi_target_group_data_extended *rtg_ext_ptr; 7140 struct scsi_target_port_group_descriptor *tpg_desc; 7141 7142 CTL_DEBUG_PRINT(("ctl_report_tagret_port_groups\n")); 7143 7144 cdb = (struct scsi_maintenance_in *)ctsio->cdb; | 7088 struct ctl_port *port; 7089 struct scsi_target_group_data *rtg_ptr; 7090 struct scsi_target_group_data_extended *rtg_ext_ptr; 7091 struct scsi_target_port_group_descriptor *tpg_desc; 7092 7093 CTL_DEBUG_PRINT(("ctl_report_tagret_port_groups\n")); 7094 7095 cdb = (struct scsi_maintenance_in *)ctsio->cdb; |
7145 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; 7146 softc = lun->ctl_softc; 7147 | |
7148 retval = CTL_RETVAL_COMPLETE; 7149 7150 switch (cdb->byte2 & STG_PDF_MASK) { 7151 case STG_PDF_LENGTH: 7152 ext = 0; 7153 break; 7154 case STG_PDF_EXTENDED: 7155 ext = 1; --- 149 unchanged lines hidden (view full) --- 7305 ctsio->be_move_done = ctl_config_move_done; 7306 ctl_datamove((union ctl_io *)ctsio); 7307 return(retval); 7308} 7309 7310int 7311ctl_report_supported_opcodes(struct ctl_scsiio *ctsio) 7312{ | 7096 retval = CTL_RETVAL_COMPLETE; 7097 7098 switch (cdb->byte2 & STG_PDF_MASK) { 7099 case STG_PDF_LENGTH: 7100 ext = 0; 7101 break; 7102 case STG_PDF_EXTENDED: 7103 ext = 1; --- 149 unchanged lines hidden (view full) --- 7253 ctsio->be_move_done = ctl_config_move_done; 7254 ctl_datamove((union ctl_io *)ctsio); 7255 return(retval); 7256} 7257 7258int 7259ctl_report_supported_opcodes(struct ctl_scsiio *ctsio) 7260{ |
7313 struct ctl_lun *lun; | 7261 struct ctl_lun *lun = CTL_LUN(ctsio); |
7314 struct scsi_report_supported_opcodes *cdb; 7315 const struct ctl_cmd_entry *entry, *sentry; 7316 struct scsi_report_supported_opcodes_all *all; 7317 struct scsi_report_supported_opcodes_descr *descr; 7318 struct scsi_report_supported_opcodes_one *one; 7319 int retval; 7320 int alloc_len, total_len; 7321 int opcode, service_action, i, j, num; 7322 7323 CTL_DEBUG_PRINT(("ctl_report_supported_opcodes\n")); 7324 7325 cdb = (struct scsi_report_supported_opcodes *)ctsio->cdb; | 7262 struct scsi_report_supported_opcodes *cdb; 7263 const struct ctl_cmd_entry *entry, *sentry; 7264 struct scsi_report_supported_opcodes_all *all; 7265 struct scsi_report_supported_opcodes_descr *descr; 7266 struct scsi_report_supported_opcodes_one *one; 7267 int retval; 7268 int alloc_len, total_len; 7269 int opcode, service_action, i, j, num; 7270 7271 CTL_DEBUG_PRINT(("ctl_report_supported_opcodes\n")); 7272 7273 cdb = (struct scsi_report_supported_opcodes *)ctsio->cdb; |
7326 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; 7327 | |
7328 retval = CTL_RETVAL_COMPLETE; 7329 7330 opcode = cdb->requested_opcode; 7331 service_action = scsi_2btoul(cdb->requested_service_action); 7332 switch (cdb->options & RSO_OPTIONS_MASK) { 7333 case RSO_OPTIONS_ALL: 7334 num = 0; 7335 for (i = 0; i < 256; i++) { --- 248 unchanged lines hidden (view full) --- 7584 ctsio->be_move_done = ctl_config_move_done; 7585 ctl_datamove((union ctl_io *)ctsio); 7586 return (retval); 7587} 7588 7589int 7590ctl_persistent_reserve_in(struct ctl_scsiio *ctsio) 7591{ | 7274 retval = CTL_RETVAL_COMPLETE; 7275 7276 opcode = cdb->requested_opcode; 7277 service_action = scsi_2btoul(cdb->requested_service_action); 7278 switch (cdb->options & RSO_OPTIONS_MASK) { 7279 case RSO_OPTIONS_ALL: 7280 num = 0; 7281 for (i = 0; i < 256; i++) { --- 248 unchanged lines hidden (view full) --- 7530 ctsio->be_move_done = ctl_config_move_done; 7531 ctl_datamove((union ctl_io *)ctsio); 7532 return (retval); 7533} 7534 7535int 7536ctl_persistent_reserve_in(struct ctl_scsiio *ctsio) 7537{ |
7538 struct ctl_softc *softc = CTL_SOFTC(ctsio); 7539 struct ctl_lun *lun = CTL_LUN(ctsio); |
|
7592 struct scsi_per_res_in *cdb; 7593 int alloc_len, total_len = 0; 7594 /* struct scsi_per_res_in_rsrv in_data; */ | 7540 struct scsi_per_res_in *cdb; 7541 int alloc_len, total_len = 0; 7542 /* struct scsi_per_res_in_rsrv in_data; */ |
7595 struct ctl_lun *lun; 7596 struct ctl_softc *softc; | |
7597 uint64_t key; 7598 7599 CTL_DEBUG_PRINT(("ctl_persistent_reserve_in\n")); 7600 7601 cdb = (struct scsi_per_res_in *)ctsio->cdb; 7602 7603 alloc_len = scsi_2btoul(cdb->length); 7604 | 7543 uint64_t key; 7544 7545 CTL_DEBUG_PRINT(("ctl_persistent_reserve_in\n")); 7546 7547 cdb = (struct scsi_per_res_in *)ctsio->cdb; 7548 7549 alloc_len = scsi_2btoul(cdb->length); 7550 |
7605 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; 7606 softc = lun->ctl_softc; 7607 | |
7608retry: 7609 mtx_lock(&lun->lun_lock); 7610 switch (cdb->action) { 7611 case SPRI_RK: /* read keys */ 7612 total_len = sizeof(struct scsi_per_res_in_keys) + 7613 lun->pr_key_count * 7614 sizeof(struct scsi_per_res_key); 7615 break; --- 546 unchanged lines hidden (view full) --- 8162 lun->pr_generation++; 8163 8164} 8165 8166 8167int 8168ctl_persistent_reserve_out(struct ctl_scsiio *ctsio) 8169{ | 7551retry: 7552 mtx_lock(&lun->lun_lock); 7553 switch (cdb->action) { 7554 case SPRI_RK: /* read keys */ 7555 total_len = sizeof(struct scsi_per_res_in_keys) + 7556 lun->pr_key_count * 7557 sizeof(struct scsi_per_res_key); 7558 break; --- 546 unchanged lines hidden (view full) --- 8105 lun->pr_generation++; 8106 8107} 8108 8109 8110int 8111ctl_persistent_reserve_out(struct ctl_scsiio *ctsio) 8112{ |
8113 struct ctl_softc *softc = CTL_SOFTC(ctsio); 8114 struct ctl_lun *lun = CTL_LUN(ctsio); |
|
8170 int retval; 8171 u_int32_t param_len; 8172 struct scsi_per_res_out *cdb; | 8115 int retval; 8116 u_int32_t param_len; 8117 struct scsi_per_res_out *cdb; |
8173 struct ctl_lun *lun; | |
8174 struct scsi_per_res_out_parms* param; | 8118 struct scsi_per_res_out_parms* param; |
8175 struct ctl_softc *softc; | |
8176 uint32_t residx; 8177 uint64_t res_key, sa_res_key, key; 8178 uint8_t type; 8179 union ctl_ha_msg persis_io; 8180 int i; 8181 8182 CTL_DEBUG_PRINT(("ctl_persistent_reserve_out\n")); 8183 | 8119 uint32_t residx; 8120 uint64_t res_key, sa_res_key, key; 8121 uint8_t type; 8122 union ctl_ha_msg persis_io; 8123 int i; 8124 8125 CTL_DEBUG_PRINT(("ctl_persistent_reserve_out\n")); 8126 |
8127 cdb = (struct scsi_per_res_out *)ctsio->cdb; |
|
8184 retval = CTL_RETVAL_COMPLETE; 8185 | 8128 retval = CTL_RETVAL_COMPLETE; 8129 |
8186 cdb = (struct scsi_per_res_out *)ctsio->cdb; 8187 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; 8188 softc = lun->ctl_softc; 8189 | |
8190 /* 8191 * We only support whole-LUN scope. The scope & type are ignored for 8192 * register, register and ignore existing key and clear. 8193 * We sometimes ignore scope and type on preempts too!! 8194 * Verify reservation type here as well. 8195 */ 8196 type = cdb->scope_type & SPR_TYPE_MASK; 8197 if ((cdb->action == SPRO_RESERVE) --- 356 unchanged lines hidden (view full) --- 8554 8555/* 8556 * This routine is for handling a message from the other SC pertaining to 8557 * persistent reserve out. All the error checking will have been done 8558 * so only perorming the action need be done here to keep the two 8559 * in sync. 8560 */ 8561static void | 8130 /* 8131 * We only support whole-LUN scope. The scope & type are ignored for 8132 * register, register and ignore existing key and clear. 8133 * We sometimes ignore scope and type on preempts too!! 8134 * Verify reservation type here as well. 8135 */ 8136 type = cdb->scope_type & SPR_TYPE_MASK; 8137 if ((cdb->action == SPRO_RESERVE) --- 356 unchanged lines hidden (view full) --- 8494 8495/* 8496 * This routine is for handling a message from the other SC pertaining to 8497 * persistent reserve out. All the error checking will have been done 8498 * so only perorming the action need be done here to keep the two 8499 * in sync. 8500 */ 8501static void |
8562ctl_hndl_per_res_out_on_other_sc(union ctl_ha_msg *msg) | 8502ctl_hndl_per_res_out_on_other_sc(union ctl_io *io) |
8563{ | 8503{ |
8564 struct ctl_softc *softc = control_softc; | 8504 struct ctl_softc *softc = CTL_SOFTC(io); 8505 union ctl_ha_msg *msg = (union ctl_ha_msg *)&io->presio.pr_msg; |
8565 struct ctl_lun *lun; 8566 int i; 8567 uint32_t residx, targ_lun; 8568 8569 targ_lun = msg->hdr.nexus.targ_mapped_lun; 8570 mtx_lock(&softc->ctl_lock); 8571 if (targ_lun >= CTL_MAX_LUNS || 8572 (lun = softc->ctl_luns[targ_lun]) == NULL) { --- 102 unchanged lines hidden (view full) --- 8675 } 8676 8677 mtx_unlock(&lun->lun_lock); 8678} 8679 8680int 8681ctl_read_write(struct ctl_scsiio *ctsio) 8682{ | 8506 struct ctl_lun *lun; 8507 int i; 8508 uint32_t residx, targ_lun; 8509 8510 targ_lun = msg->hdr.nexus.targ_mapped_lun; 8511 mtx_lock(&softc->ctl_lock); 8512 if (targ_lun >= CTL_MAX_LUNS || 8513 (lun = softc->ctl_luns[targ_lun]) == NULL) { --- 102 unchanged lines hidden (view full) --- 8616 } 8617 8618 mtx_unlock(&lun->lun_lock); 8619} 8620 8621int 8622ctl_read_write(struct ctl_scsiio *ctsio) 8623{ |
8683 struct ctl_lun *lun; | 8624 struct ctl_lun *lun = CTL_LUN(ctsio); |
8684 struct ctl_lba_len_flags *lbalen; 8685 uint64_t lba; 8686 uint32_t num_blocks; 8687 int flags, retval; 8688 int isread; 8689 | 8625 struct ctl_lba_len_flags *lbalen; 8626 uint64_t lba; 8627 uint32_t num_blocks; 8628 int flags, retval; 8629 int isread; 8630 |
8690 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; 8691 | |
8692 CTL_DEBUG_PRINT(("ctl_read_write: command: %#x\n", ctsio->cdb[0])); 8693 8694 flags = 0; 8695 isread = ctsio->cdb[0] == READ_6 || ctsio->cdb[0] == READ_10 8696 || ctsio->cdb[0] == READ_12 || ctsio->cdb[0] == READ_16; 8697 switch (ctsio->cdb[0]) { 8698 case READ_6: 8699 case WRITE_6: { --- 168 unchanged lines hidden (view full) --- 8868 8869 retval = lun->backend->data_submit((union ctl_io *)ctsio); 8870 return (retval); 8871} 8872 8873static int 8874ctl_cnw_cont(union ctl_io *io) 8875{ | 8631 CTL_DEBUG_PRINT(("ctl_read_write: command: %#x\n", ctsio->cdb[0])); 8632 8633 flags = 0; 8634 isread = ctsio->cdb[0] == READ_6 || ctsio->cdb[0] == READ_10 8635 || ctsio->cdb[0] == READ_12 || ctsio->cdb[0] == READ_16; 8636 switch (ctsio->cdb[0]) { 8637 case READ_6: 8638 case WRITE_6: { --- 168 unchanged lines hidden (view full) --- 8807 8808 retval = lun->backend->data_submit((union ctl_io *)ctsio); 8809 return (retval); 8810} 8811 8812static int 8813ctl_cnw_cont(union ctl_io *io) 8814{ |
8815 struct ctl_lun *lun = CTL_LUN(io); |
|
8876 struct ctl_scsiio *ctsio; | 8816 struct ctl_scsiio *ctsio; |
8877 struct ctl_lun *lun; | |
8878 struct ctl_lba_len_flags *lbalen; 8879 int retval; 8880 8881 ctsio = &io->scsiio; 8882 ctsio->io_hdr.status = CTL_STATUS_NONE; 8883 ctsio->io_hdr.flags &= ~CTL_FLAG_IO_CONT; | 8817 struct ctl_lba_len_flags *lbalen; 8818 int retval; 8819 8820 ctsio = &io->scsiio; 8821 ctsio->io_hdr.status = CTL_STATUS_NONE; 8822 ctsio->io_hdr.flags &= ~CTL_FLAG_IO_CONT; |
8884 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; | |
8885 lbalen = (struct ctl_lba_len_flags *) 8886 &ctsio->io_hdr.ctl_private[CTL_PRIV_LBA_LEN]; 8887 lbalen->flags &= ~CTL_LLF_COMPARE; 8888 lbalen->flags |= CTL_LLF_WRITE; 8889 8890 CTL_DEBUG_PRINT(("ctl_cnw_cont: calling data_submit()\n")); 8891 retval = lun->backend->data_submit((union ctl_io *)ctsio); 8892 return (retval); 8893} 8894 8895int 8896ctl_cnw(struct ctl_scsiio *ctsio) 8897{ | 8823 lbalen = (struct ctl_lba_len_flags *) 8824 &ctsio->io_hdr.ctl_private[CTL_PRIV_LBA_LEN]; 8825 lbalen->flags &= ~CTL_LLF_COMPARE; 8826 lbalen->flags |= CTL_LLF_WRITE; 8827 8828 CTL_DEBUG_PRINT(("ctl_cnw_cont: calling data_submit()\n")); 8829 retval = lun->backend->data_submit((union ctl_io *)ctsio); 8830 return (retval); 8831} 8832 8833int 8834ctl_cnw(struct ctl_scsiio *ctsio) 8835{ |
8898 struct ctl_lun *lun; | 8836 struct ctl_lun *lun = CTL_LUN(ctsio); |
8899 struct ctl_lba_len_flags *lbalen; 8900 uint64_t lba; 8901 uint32_t num_blocks; 8902 int flags, retval; 8903 | 8837 struct ctl_lba_len_flags *lbalen; 8838 uint64_t lba; 8839 uint32_t num_blocks; 8840 int flags, retval; 8841 |
8904 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; 8905 | |
8906 CTL_DEBUG_PRINT(("ctl_cnw: command: %#x\n", ctsio->cdb[0])); 8907 8908 flags = 0; 8909 switch (ctsio->cdb[0]) { 8910 case COMPARE_AND_WRITE: { 8911 struct scsi_compare_and_write *cdb; 8912 8913 cdb = (struct scsi_compare_and_write *)ctsio->cdb; --- 64 unchanged lines hidden (view full) --- 8978 CTL_DEBUG_PRINT(("ctl_cnw: calling data_submit()\n")); 8979 retval = lun->backend->data_submit((union ctl_io *)ctsio); 8980 return (retval); 8981} 8982 8983int 8984ctl_verify(struct ctl_scsiio *ctsio) 8985{ | 8842 CTL_DEBUG_PRINT(("ctl_cnw: command: %#x\n", ctsio->cdb[0])); 8843 8844 flags = 0; 8845 switch (ctsio->cdb[0]) { 8846 case COMPARE_AND_WRITE: { 8847 struct scsi_compare_and_write *cdb; 8848 8849 cdb = (struct scsi_compare_and_write *)ctsio->cdb; --- 64 unchanged lines hidden (view full) --- 8914 CTL_DEBUG_PRINT(("ctl_cnw: calling data_submit()\n")); 8915 retval = lun->backend->data_submit((union ctl_io *)ctsio); 8916 return (retval); 8917} 8918 8919int 8920ctl_verify(struct ctl_scsiio *ctsio) 8921{ |
8986 struct ctl_lun *lun; | 8922 struct ctl_lun *lun = CTL_LUN(ctsio); |
8987 struct ctl_lba_len_flags *lbalen; 8988 uint64_t lba; 8989 uint32_t num_blocks; 8990 int bytchk, flags; 8991 int retval; 8992 | 8923 struct ctl_lba_len_flags *lbalen; 8924 uint64_t lba; 8925 uint32_t num_blocks; 8926 int bytchk, flags; 8927 int retval; 8928 |
8993 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; 8994 | |
8995 CTL_DEBUG_PRINT(("ctl_verify: command: %#x\n", ctsio->cdb[0])); 8996 8997 bytchk = 0; 8998 flags = CTL_LLF_FUA; 8999 switch (ctsio->cdb[0]) { 9000 case VERIFY_10: { 9001 struct scsi_verify_10 *cdb; 9002 --- 79 unchanged lines hidden (view full) --- 9082 CTL_DEBUG_PRINT(("ctl_verify: calling data_submit()\n")); 9083 retval = lun->backend->data_submit((union ctl_io *)ctsio); 9084 return (retval); 9085} 9086 9087int 9088ctl_report_luns(struct ctl_scsiio *ctsio) 9089{ | 8929 CTL_DEBUG_PRINT(("ctl_verify: command: %#x\n", ctsio->cdb[0])); 8930 8931 bytchk = 0; 8932 flags = CTL_LLF_FUA; 8933 switch (ctsio->cdb[0]) { 8934 case VERIFY_10: { 8935 struct scsi_verify_10 *cdb; 8936 --- 79 unchanged lines hidden (view full) --- 9016 CTL_DEBUG_PRINT(("ctl_verify: calling data_submit()\n")); 9017 retval = lun->backend->data_submit((union ctl_io *)ctsio); 9018 return (retval); 9019} 9020 9021int 9022ctl_report_luns(struct ctl_scsiio *ctsio) 9023{ |
9090 struct ctl_softc *softc; | 9024 struct ctl_softc *softc = CTL_SOFTC(ctsio); 9025 struct ctl_port *port = CTL_PORT(ctsio); 9026 struct ctl_lun *lun, *request_lun = CTL_LUN(ctsio); |
9091 struct scsi_report_luns *cdb; 9092 struct scsi_report_luns_data *lun_data; | 9027 struct scsi_report_luns *cdb; 9028 struct scsi_report_luns_data *lun_data; |
9093 struct ctl_lun *lun, *request_lun; 9094 struct ctl_port *port; | |
9095 int num_filled, num_luns, num_port_luns, retval; 9096 uint32_t alloc_len, lun_datalen; 9097 uint32_t initidx, targ_lun_id, lun_id; 9098 9099 retval = CTL_RETVAL_COMPLETE; 9100 cdb = (struct scsi_report_luns *)ctsio->cdb; | 9029 int num_filled, num_luns, num_port_luns, retval; 9030 uint32_t alloc_len, lun_datalen; 9031 uint32_t initidx, targ_lun_id, lun_id; 9032 9033 retval = CTL_RETVAL_COMPLETE; 9034 cdb = (struct scsi_report_luns *)ctsio->cdb; |
9101 port = ctl_io_port(&ctsio->io_hdr); 9102 softc = port->ctl_softc; | |
9103 9104 CTL_DEBUG_PRINT(("ctl_report_luns\n")); 9105 9106 num_luns = 0; 9107 num_port_luns = port->lun_map ? port->lun_map_size : CTL_MAX_LUNS; 9108 mtx_lock(&softc->ctl_lock); 9109 for (targ_lun_id = 0; targ_lun_id < num_port_luns; targ_lun_id++) { 9110 if (ctl_lun_map_from_port(port, targ_lun_id) != UINT32_MAX) --- 36 unchanged lines hidden (view full) --- 9147 /*command*/ 1, 9148 /*field*/ 6, 9149 /*bit_valid*/ 0, 9150 /*bit*/ 0); 9151 ctl_done((union ctl_io *)ctsio); 9152 return (retval); 9153 } 9154 | 9035 9036 CTL_DEBUG_PRINT(("ctl_report_luns\n")); 9037 9038 num_luns = 0; 9039 num_port_luns = port->lun_map ? port->lun_map_size : CTL_MAX_LUNS; 9040 mtx_lock(&softc->ctl_lock); 9041 for (targ_lun_id = 0; targ_lun_id < num_port_luns; targ_lun_id++) { 9042 if (ctl_lun_map_from_port(port, targ_lun_id) != UINT32_MAX) --- 36 unchanged lines hidden (view full) --- 9079 /*command*/ 1, 9080 /*field*/ 6, 9081 /*bit_valid*/ 0, 9082 /*bit*/ 0); 9083 ctl_done((union ctl_io *)ctsio); 9084 return (retval); 9085 } 9086 |
9155 request_lun = (struct ctl_lun *) 9156 ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; 9157 | |
9158 lun_datalen = sizeof(*lun_data) + 9159 (num_luns * sizeof(struct scsi_report_luns_lundata)); 9160 9161 ctsio->kern_data_ptr = malloc(lun_datalen, M_CTL, M_WAITOK | M_ZERO); 9162 lun_data = (struct scsi_report_luns_data *)ctsio->kern_data_ptr; 9163 ctsio->kern_sg_entries = 0; 9164 9165 initidx = ctl_get_initindex(&ctsio->io_hdr.nexus); --- 74 unchanged lines hidden (view full) --- 9240 ctsio->be_move_done = ctl_config_move_done; 9241 ctl_datamove((union ctl_io *)ctsio); 9242 return (retval); 9243} 9244 9245int 9246ctl_request_sense(struct ctl_scsiio *ctsio) 9247{ | 9087 lun_datalen = sizeof(*lun_data) + 9088 (num_luns * sizeof(struct scsi_report_luns_lundata)); 9089 9090 ctsio->kern_data_ptr = malloc(lun_datalen, M_CTL, M_WAITOK | M_ZERO); 9091 lun_data = (struct scsi_report_luns_data *)ctsio->kern_data_ptr; 9092 ctsio->kern_sg_entries = 0; 9093 9094 initidx = ctl_get_initindex(&ctsio->io_hdr.nexus); --- 74 unchanged lines hidden (view full) --- 9169 ctsio->be_move_done = ctl_config_move_done; 9170 ctl_datamove((union ctl_io *)ctsio); 9171 return (retval); 9172} 9173 9174int 9175ctl_request_sense(struct ctl_scsiio *ctsio) 9176{ |
9177 struct ctl_softc *softc = CTL_SOFTC(ctsio); 9178 struct ctl_lun *lun = CTL_LUN(ctsio); |
|
9248 struct scsi_request_sense *cdb; 9249 struct scsi_sense_data *sense_ptr; | 9179 struct scsi_request_sense *cdb; 9180 struct scsi_sense_data *sense_ptr; |
9250 struct ctl_softc *softc; 9251 struct ctl_lun *lun; | |
9252 uint32_t initidx; 9253 int have_error; 9254 u_int sense_len = SSD_FULL_SIZE; 9255 scsi_sense_data_type sense_format; 9256 ctl_ua_type ua_type; 9257 uint8_t asc = 0, ascq = 0; 9258 9259 cdb = (struct scsi_request_sense *)ctsio->cdb; 9260 | 9181 uint32_t initidx; 9182 int have_error; 9183 u_int sense_len = SSD_FULL_SIZE; 9184 scsi_sense_data_type sense_format; 9185 ctl_ua_type ua_type; 9186 uint8_t asc = 0, ascq = 0; 9187 9188 cdb = (struct scsi_request_sense *)ctsio->cdb; 9189 |
9261 softc = control_softc; 9262 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; 9263 | |
9264 CTL_DEBUG_PRINT(("ctl_request_sense\n")); 9265 9266 /* 9267 * Determine which sense format the user wants. 9268 */ 9269 if (cdb->byte2 & SRS_DESC) 9270 sense_format = SSD_TYPE_DESC; 9271 else --- 126 unchanged lines hidden (view full) --- 9398} 9399 9400/* 9401 * SCSI VPD page 0x00, the Supported VPD Pages page. 9402 */ 9403static int 9404ctl_inquiry_evpd_supported(struct ctl_scsiio *ctsio, int alloc_len) 9405{ | 9190 CTL_DEBUG_PRINT(("ctl_request_sense\n")); 9191 9192 /* 9193 * Determine which sense format the user wants. 9194 */ 9195 if (cdb->byte2 & SRS_DESC) 9196 sense_format = SSD_TYPE_DESC; 9197 else --- 126 unchanged lines hidden (view full) --- 9324} 9325 9326/* 9327 * SCSI VPD page 0x00, the Supported VPD Pages page. 9328 */ 9329static int 9330ctl_inquiry_evpd_supported(struct ctl_scsiio *ctsio, int alloc_len) 9331{ |
9332 struct ctl_lun *lun = CTL_LUN(ctsio); |
|
9406 struct scsi_vpd_supported_pages *pages; 9407 int sup_page_size; | 9333 struct scsi_vpd_supported_pages *pages; 9334 int sup_page_size; |
9408 struct ctl_lun *lun; | |
9409 int p; 9410 | 9335 int p; 9336 |
9411 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; 9412 | |
9413 sup_page_size = sizeof(struct scsi_vpd_supported_pages) * 9414 SCSI_EVPD_NUM_SUPPORTED_PAGES; 9415 ctsio->kern_data_ptr = malloc(sup_page_size, M_CTL, M_WAITOK | M_ZERO); 9416 pages = (struct scsi_vpd_supported_pages *)ctsio->kern_data_ptr; 9417 ctsio->kern_sg_entries = 0; 9418 9419 if (sup_page_size < alloc_len) { 9420 ctsio->residual = alloc_len - sup_page_size; --- 52 unchanged lines hidden (view full) --- 9473} 9474 9475/* 9476 * SCSI VPD page 0x80, the Unit Serial Number page. 9477 */ 9478static int 9479ctl_inquiry_evpd_serial(struct ctl_scsiio *ctsio, int alloc_len) 9480{ | 9337 sup_page_size = sizeof(struct scsi_vpd_supported_pages) * 9338 SCSI_EVPD_NUM_SUPPORTED_PAGES; 9339 ctsio->kern_data_ptr = malloc(sup_page_size, M_CTL, M_WAITOK | M_ZERO); 9340 pages = (struct scsi_vpd_supported_pages *)ctsio->kern_data_ptr; 9341 ctsio->kern_sg_entries = 0; 9342 9343 if (sup_page_size < alloc_len) { 9344 ctsio->residual = alloc_len - sup_page_size; --- 52 unchanged lines hidden (view full) --- 9397} 9398 9399/* 9400 * SCSI VPD page 0x80, the Unit Serial Number page. 9401 */ 9402static int 9403ctl_inquiry_evpd_serial(struct ctl_scsiio *ctsio, int alloc_len) 9404{ |
9405 struct ctl_lun *lun = CTL_LUN(ctsio); |
|
9481 struct scsi_vpd_unit_serial_number *sn_ptr; | 9406 struct scsi_vpd_unit_serial_number *sn_ptr; |
9482 struct ctl_lun *lun; | |
9483 int data_len; 9484 | 9407 int data_len; 9408 |
9485 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; 9486 | |
9487 data_len = 4 + CTL_SN_LEN; 9488 ctsio->kern_data_ptr = malloc(data_len, M_CTL, M_WAITOK | M_ZERO); 9489 sn_ptr = (struct scsi_vpd_unit_serial_number *)ctsio->kern_data_ptr; 9490 if (data_len < alloc_len) { 9491 ctsio->residual = alloc_len - data_len; 9492 ctsio->kern_data_len = data_len; 9493 ctsio->kern_total_len = data_len; 9494 } else { --- 37 unchanged lines hidden (view full) --- 9532 9533 9534/* 9535 * SCSI VPD page 0x86, the Extended INQUIRY Data page. 9536 */ 9537static int 9538ctl_inquiry_evpd_eid(struct ctl_scsiio *ctsio, int alloc_len) 9539{ | 9409 data_len = 4 + CTL_SN_LEN; 9410 ctsio->kern_data_ptr = malloc(data_len, M_CTL, M_WAITOK | M_ZERO); 9411 sn_ptr = (struct scsi_vpd_unit_serial_number *)ctsio->kern_data_ptr; 9412 if (data_len < alloc_len) { 9413 ctsio->residual = alloc_len - data_len; 9414 ctsio->kern_data_len = data_len; 9415 ctsio->kern_total_len = data_len; 9416 } else { --- 37 unchanged lines hidden (view full) --- 9454 9455 9456/* 9457 * SCSI VPD page 0x86, the Extended INQUIRY Data page. 9458 */ 9459static int 9460ctl_inquiry_evpd_eid(struct ctl_scsiio *ctsio, int alloc_len) 9461{ |
9462 struct ctl_lun *lun = CTL_LUN(ctsio); |
|
9540 struct scsi_vpd_extended_inquiry_data *eid_ptr; | 9463 struct scsi_vpd_extended_inquiry_data *eid_ptr; |
9541 struct ctl_lun *lun; | |
9542 int data_len; 9543 | 9464 int data_len; 9465 |
9544 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; 9545 | |
9546 data_len = sizeof(struct scsi_vpd_extended_inquiry_data); 9547 ctsio->kern_data_ptr = malloc(data_len, M_CTL, M_WAITOK | M_ZERO); 9548 eid_ptr = (struct scsi_vpd_extended_inquiry_data *)ctsio->kern_data_ptr; 9549 ctsio->kern_sg_entries = 0; 9550 9551 if (data_len < alloc_len) { 9552 ctsio->residual = alloc_len - data_len; 9553 ctsio->kern_data_len = data_len; --- 54 unchanged lines hidden (view full) --- 9608 ctsio->be_move_done = ctl_config_move_done; 9609 ctl_datamove((union ctl_io *)ctsio); 9610 return (CTL_RETVAL_COMPLETE); 9611} 9612 9613static int 9614ctl_inquiry_evpd_mpp(struct ctl_scsiio *ctsio, int alloc_len) 9615{ | 9466 data_len = sizeof(struct scsi_vpd_extended_inquiry_data); 9467 ctsio->kern_data_ptr = malloc(data_len, M_CTL, M_WAITOK | M_ZERO); 9468 eid_ptr = (struct scsi_vpd_extended_inquiry_data *)ctsio->kern_data_ptr; 9469 ctsio->kern_sg_entries = 0; 9470 9471 if (data_len < alloc_len) { 9472 ctsio->residual = alloc_len - data_len; 9473 ctsio->kern_data_len = data_len; --- 54 unchanged lines hidden (view full) --- 9528 ctsio->be_move_done = ctl_config_move_done; 9529 ctl_datamove((union ctl_io *)ctsio); 9530 return (CTL_RETVAL_COMPLETE); 9531} 9532 9533static int 9534ctl_inquiry_evpd_mpp(struct ctl_scsiio *ctsio, int alloc_len) 9535{ |
9536 struct ctl_lun *lun = CTL_LUN(ctsio); |
|
9616 struct scsi_vpd_mode_page_policy *mpp_ptr; | 9537 struct scsi_vpd_mode_page_policy *mpp_ptr; |
9617 struct ctl_lun *lun; | |
9618 int data_len; 9619 | 9538 int data_len; 9539 |
9620 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; 9621 | |
9622 data_len = sizeof(struct scsi_vpd_mode_page_policy) + 9623 sizeof(struct scsi_vpd_mode_page_policy_descr); 9624 9625 ctsio->kern_data_ptr = malloc(data_len, M_CTL, M_WAITOK | M_ZERO); 9626 mpp_ptr = (struct scsi_vpd_mode_page_policy *)ctsio->kern_data_ptr; 9627 ctsio->kern_sg_entries = 0; 9628 9629 if (data_len < alloc_len) { --- 32 unchanged lines hidden (view full) --- 9662} 9663 9664/* 9665 * SCSI VPD page 0x83, the Device Identification page. 9666 */ 9667static int 9668ctl_inquiry_evpd_devid(struct ctl_scsiio *ctsio, int alloc_len) 9669{ | 9540 data_len = sizeof(struct scsi_vpd_mode_page_policy) + 9541 sizeof(struct scsi_vpd_mode_page_policy_descr); 9542 9543 ctsio->kern_data_ptr = malloc(data_len, M_CTL, M_WAITOK | M_ZERO); 9544 mpp_ptr = (struct scsi_vpd_mode_page_policy *)ctsio->kern_data_ptr; 9545 ctsio->kern_sg_entries = 0; 9546 9547 if (data_len < alloc_len) { --- 32 unchanged lines hidden (view full) --- 9580} 9581 9582/* 9583 * SCSI VPD page 0x83, the Device Identification page. 9584 */ 9585static int 9586ctl_inquiry_evpd_devid(struct ctl_scsiio *ctsio, int alloc_len) 9587{ |
9588 struct ctl_softc *softc = CTL_SOFTC(ctsio); 9589 struct ctl_port *port = CTL_PORT(ctsio); 9590 struct ctl_lun *lun = CTL_LUN(ctsio); |
|
9670 struct scsi_vpd_device_id *devid_ptr; 9671 struct scsi_vpd_id_descriptor *desc; | 9591 struct scsi_vpd_device_id *devid_ptr; 9592 struct scsi_vpd_id_descriptor *desc; |
9672 struct ctl_softc *softc; 9673 struct ctl_lun *lun; 9674 struct ctl_port *port; | |
9675 int data_len, g; 9676 uint8_t proto; 9677 | 9593 int data_len, g; 9594 uint8_t proto; 9595 |
9678 softc = control_softc; 9679 9680 port = ctl_io_port(&ctsio->io_hdr); 9681 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; 9682 | |
9683 data_len = sizeof(struct scsi_vpd_device_id) + 9684 sizeof(struct scsi_vpd_id_descriptor) + 9685 sizeof(struct scsi_vpd_id_rel_trgt_port_id) + 9686 sizeof(struct scsi_vpd_id_descriptor) + 9687 sizeof(struct scsi_vpd_id_trgt_port_grp_id); 9688 if (lun && lun->lun_devid) 9689 data_len += lun->lun_devid->len; 9690 if (port && port->port_devid) --- 96 unchanged lines hidden (view full) --- 9787 ctsio->be_move_done = ctl_config_move_done; 9788 ctl_datamove((union ctl_io *)ctsio); 9789 return (CTL_RETVAL_COMPLETE); 9790} 9791 9792static int 9793ctl_inquiry_evpd_scsi_ports(struct ctl_scsiio *ctsio, int alloc_len) 9794{ | 9596 data_len = sizeof(struct scsi_vpd_device_id) + 9597 sizeof(struct scsi_vpd_id_descriptor) + 9598 sizeof(struct scsi_vpd_id_rel_trgt_port_id) + 9599 sizeof(struct scsi_vpd_id_descriptor) + 9600 sizeof(struct scsi_vpd_id_trgt_port_grp_id); 9601 if (lun && lun->lun_devid) 9602 data_len += lun->lun_devid->len; 9603 if (port && port->port_devid) --- 96 unchanged lines hidden (view full) --- 9700 ctsio->be_move_done = ctl_config_move_done; 9701 ctl_datamove((union ctl_io *)ctsio); 9702 return (CTL_RETVAL_COMPLETE); 9703} 9704 9705static int 9706ctl_inquiry_evpd_scsi_ports(struct ctl_scsiio *ctsio, int alloc_len) 9707{ |
9795 struct ctl_softc *softc = control_softc; | 9708 struct ctl_softc *softc = CTL_SOFTC(ctsio); 9709 struct ctl_lun *lun = CTL_LUN(ctsio); |
9796 struct scsi_vpd_scsi_ports *sp; 9797 struct scsi_vpd_port_designation *pd; 9798 struct scsi_vpd_port_designation_cont *pdc; | 9710 struct scsi_vpd_scsi_ports *sp; 9711 struct scsi_vpd_port_designation *pd; 9712 struct scsi_vpd_port_designation_cont *pdc; |
9799 struct ctl_lun *lun; | |
9800 struct ctl_port *port; 9801 int data_len, num_target_ports, iid_len, id_len; 9802 | 9713 struct ctl_port *port; 9714 int data_len, num_target_ports, iid_len, id_len; 9715 |
9803 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; 9804 | |
9805 num_target_ports = 0; 9806 iid_len = 0; 9807 id_len = 0; 9808 mtx_lock(&softc->ctl_lock); 9809 STAILQ_FOREACH(port, &softc->port_list, links) { 9810 if ((port->status & CTL_PORT_STATUS_ONLINE) == 0) 9811 continue; 9812 if (lun != NULL && --- 77 unchanged lines hidden (view full) --- 9890 ctsio->be_move_done = ctl_config_move_done; 9891 ctl_datamove((union ctl_io *)ctsio); 9892 return (CTL_RETVAL_COMPLETE); 9893} 9894 9895static int 9896ctl_inquiry_evpd_block_limits(struct ctl_scsiio *ctsio, int alloc_len) 9897{ | 9716 num_target_ports = 0; 9717 iid_len = 0; 9718 id_len = 0; 9719 mtx_lock(&softc->ctl_lock); 9720 STAILQ_FOREACH(port, &softc->port_list, links) { 9721 if ((port->status & CTL_PORT_STATUS_ONLINE) == 0) 9722 continue; 9723 if (lun != NULL && --- 77 unchanged lines hidden (view full) --- 9801 ctsio->be_move_done = ctl_config_move_done; 9802 ctl_datamove((union ctl_io *)ctsio); 9803 return (CTL_RETVAL_COMPLETE); 9804} 9805 9806static int 9807ctl_inquiry_evpd_block_limits(struct ctl_scsiio *ctsio, int alloc_len) 9808{ |
9809 struct ctl_lun *lun = CTL_LUN(ctsio); |
|
9898 struct scsi_vpd_block_limits *bl_ptr; | 9810 struct scsi_vpd_block_limits *bl_ptr; |
9899 struct ctl_lun *lun; | |
9900 uint64_t ival; 9901 | 9811 uint64_t ival; 9812 |
9902 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; 9903 | |
9904 ctsio->kern_data_ptr = malloc(sizeof(*bl_ptr), M_CTL, M_WAITOK | M_ZERO); 9905 bl_ptr = (struct scsi_vpd_block_limits *)ctsio->kern_data_ptr; 9906 ctsio->kern_sg_entries = 0; 9907 9908 if (sizeof(*bl_ptr) < alloc_len) { 9909 ctsio->residual = alloc_len - sizeof(*bl_ptr); 9910 ctsio->kern_data_len = sizeof(*bl_ptr); 9911 ctsio->kern_total_len = sizeof(*bl_ptr); --- 55 unchanged lines hidden (view full) --- 9967 ctsio->be_move_done = ctl_config_move_done; 9968 ctl_datamove((union ctl_io *)ctsio); 9969 return (CTL_RETVAL_COMPLETE); 9970} 9971 9972static int 9973ctl_inquiry_evpd_bdc(struct ctl_scsiio *ctsio, int alloc_len) 9974{ | 9813 ctsio->kern_data_ptr = malloc(sizeof(*bl_ptr), M_CTL, M_WAITOK | M_ZERO); 9814 bl_ptr = (struct scsi_vpd_block_limits *)ctsio->kern_data_ptr; 9815 ctsio->kern_sg_entries = 0; 9816 9817 if (sizeof(*bl_ptr) < alloc_len) { 9818 ctsio->residual = alloc_len - sizeof(*bl_ptr); 9819 ctsio->kern_data_len = sizeof(*bl_ptr); 9820 ctsio->kern_total_len = sizeof(*bl_ptr); --- 55 unchanged lines hidden (view full) --- 9876 ctsio->be_move_done = ctl_config_move_done; 9877 ctl_datamove((union ctl_io *)ctsio); 9878 return (CTL_RETVAL_COMPLETE); 9879} 9880 9881static int 9882ctl_inquiry_evpd_bdc(struct ctl_scsiio *ctsio, int alloc_len) 9883{ |
9884 struct ctl_lun *lun = CTL_LUN(ctsio); |
|
9975 struct scsi_vpd_block_device_characteristics *bdc_ptr; | 9885 struct scsi_vpd_block_device_characteristics *bdc_ptr; |
9976 struct ctl_lun *lun; | |
9977 const char *value; 9978 u_int i; 9979 | 9886 const char *value; 9887 u_int i; 9888 |
9980 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; 9981 | |
9982 ctsio->kern_data_ptr = malloc(sizeof(*bdc_ptr), M_CTL, M_WAITOK | M_ZERO); 9983 bdc_ptr = (struct scsi_vpd_block_device_characteristics *)ctsio->kern_data_ptr; 9984 ctsio->kern_sg_entries = 0; 9985 9986 if (sizeof(*bdc_ptr) < alloc_len) { 9987 ctsio->residual = alloc_len - sizeof(*bdc_ptr); 9988 ctsio->kern_data_len = sizeof(*bdc_ptr); 9989 ctsio->kern_total_len = sizeof(*bdc_ptr); --- 37 unchanged lines hidden (view full) --- 10027 ctsio->be_move_done = ctl_config_move_done; 10028 ctl_datamove((union ctl_io *)ctsio); 10029 return (CTL_RETVAL_COMPLETE); 10030} 10031 10032static int 10033ctl_inquiry_evpd_lbp(struct ctl_scsiio *ctsio, int alloc_len) 10034{ | 9889 ctsio->kern_data_ptr = malloc(sizeof(*bdc_ptr), M_CTL, M_WAITOK | M_ZERO); 9890 bdc_ptr = (struct scsi_vpd_block_device_characteristics *)ctsio->kern_data_ptr; 9891 ctsio->kern_sg_entries = 0; 9892 9893 if (sizeof(*bdc_ptr) < alloc_len) { 9894 ctsio->residual = alloc_len - sizeof(*bdc_ptr); 9895 ctsio->kern_data_len = sizeof(*bdc_ptr); 9896 ctsio->kern_total_len = sizeof(*bdc_ptr); --- 37 unchanged lines hidden (view full) --- 9934 ctsio->be_move_done = ctl_config_move_done; 9935 ctl_datamove((union ctl_io *)ctsio); 9936 return (CTL_RETVAL_COMPLETE); 9937} 9938 9939static int 9940ctl_inquiry_evpd_lbp(struct ctl_scsiio *ctsio, int alloc_len) 9941{ |
9942 struct ctl_lun *lun = CTL_LUN(ctsio); |
|
10035 struct scsi_vpd_logical_block_prov *lbp_ptr; | 9943 struct scsi_vpd_logical_block_prov *lbp_ptr; |
10036 struct ctl_lun *lun; | |
10037 const char *value; 10038 | 9944 const char *value; 9945 |
10039 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; 10040 | |
10041 ctsio->kern_data_ptr = malloc(sizeof(*lbp_ptr), M_CTL, M_WAITOK | M_ZERO); 10042 lbp_ptr = (struct scsi_vpd_logical_block_prov *)ctsio->kern_data_ptr; 10043 ctsio->kern_sg_entries = 0; 10044 10045 if (sizeof(*lbp_ptr) < alloc_len) { 10046 ctsio->residual = alloc_len - sizeof(*lbp_ptr); 10047 ctsio->kern_data_len = sizeof(*lbp_ptr); 10048 ctsio->kern_total_len = sizeof(*lbp_ptr); --- 41 unchanged lines hidden (view full) --- 10090} 10091 10092/* 10093 * INQUIRY with the EVPD bit set. 10094 */ 10095static int 10096ctl_inquiry_evpd(struct ctl_scsiio *ctsio) 10097{ | 9946 ctsio->kern_data_ptr = malloc(sizeof(*lbp_ptr), M_CTL, M_WAITOK | M_ZERO); 9947 lbp_ptr = (struct scsi_vpd_logical_block_prov *)ctsio->kern_data_ptr; 9948 ctsio->kern_sg_entries = 0; 9949 9950 if (sizeof(*lbp_ptr) < alloc_len) { 9951 ctsio->residual = alloc_len - sizeof(*lbp_ptr); 9952 ctsio->kern_data_len = sizeof(*lbp_ptr); 9953 ctsio->kern_total_len = sizeof(*lbp_ptr); --- 41 unchanged lines hidden (view full) --- 9995} 9996 9997/* 9998 * INQUIRY with the EVPD bit set. 9999 */ 10000static int 10001ctl_inquiry_evpd(struct ctl_scsiio *ctsio) 10002{ |
10098 struct ctl_lun *lun; | 10003 struct ctl_lun *lun = CTL_LUN(ctsio); |
10099 struct scsi_inquiry *cdb; 10100 int alloc_len, retval; 10101 | 10004 struct scsi_inquiry *cdb; 10005 int alloc_len, retval; 10006 |
10102 lun = (struct ctl_lun *)ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; | |
10103 cdb = (struct scsi_inquiry *)ctsio->cdb; 10104 alloc_len = scsi_2btoul(cdb->length); 10105 10106 switch (cdb->page_code) { 10107 case SVPD_SUPPORTED_PAGES: 10108 retval = ctl_inquiry_evpd_supported(ctsio, alloc_len); 10109 break; 10110 case SVPD_UNIT_SERIAL_NUMBER: --- 46 unchanged lines hidden (view full) --- 10157} 10158 10159/* 10160 * Standard INQUIRY data. 10161 */ 10162static int 10163ctl_inquiry_std(struct ctl_scsiio *ctsio) 10164{ | 10007 cdb = (struct scsi_inquiry *)ctsio->cdb; 10008 alloc_len = scsi_2btoul(cdb->length); 10009 10010 switch (cdb->page_code) { 10011 case SVPD_SUPPORTED_PAGES: 10012 retval = ctl_inquiry_evpd_supported(ctsio, alloc_len); 10013 break; 10014 case SVPD_UNIT_SERIAL_NUMBER: --- 46 unchanged lines hidden (view full) --- 10061} 10062 10063/* 10064 * Standard INQUIRY data. 10065 */ 10066static int 10067ctl_inquiry_std(struct ctl_scsiio *ctsio) 10068{ |
10069 struct ctl_softc *softc = CTL_SOFTC(ctsio); 10070 struct ctl_port *port = CTL_PORT(ctsio); 10071 struct ctl_lun *lun = CTL_LUN(ctsio); |
|
10165 struct scsi_inquiry_data *inq_ptr; 10166 struct scsi_inquiry *cdb; | 10072 struct scsi_inquiry_data *inq_ptr; 10073 struct scsi_inquiry *cdb; |
10167 struct ctl_softc *softc = control_softc; 10168 struct ctl_port *port; 10169 struct ctl_lun *lun; | |
10170 char *val; 10171 uint32_t alloc_len, data_len; 10172 ctl_port_type port_type; 10173 | 10074 char *val; 10075 uint32_t alloc_len, data_len; 10076 ctl_port_type port_type; 10077 |
10174 port = ctl_io_port(&ctsio->io_hdr); | |
10175 port_type = port->port_type; 10176 if (port_type == CTL_PORT_IOCTL || port_type == CTL_PORT_INTERNAL) 10177 port_type = CTL_PORT_SCSI; 10178 | 10078 port_type = port->port_type; 10079 if (port_type == CTL_PORT_IOCTL || port_type == CTL_PORT_INTERNAL) 10080 port_type = CTL_PORT_SCSI; 10081 |
10179 lun = ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; | |
10180 cdb = (struct scsi_inquiry *)ctsio->cdb; 10181 alloc_len = scsi_2btoul(cdb->length); 10182 10183 /* 10184 * We malloc the full inquiry data size here and fill it 10185 * in. If the user only asks for less, we'll give him 10186 * that much. 10187 */ --- 197 unchanged lines hidden (view full) --- 10385 } 10386 10387 return (retval); 10388} 10389 10390int 10391ctl_get_config(struct ctl_scsiio *ctsio) 10392{ | 10082 cdb = (struct scsi_inquiry *)ctsio->cdb; 10083 alloc_len = scsi_2btoul(cdb->length); 10084 10085 /* 10086 * We malloc the full inquiry data size here and fill it 10087 * in. If the user only asks for less, we'll give him 10088 * that much. 10089 */ --- 197 unchanged lines hidden (view full) --- 10287 } 10288 10289 return (retval); 10290} 10291 10292int 10293ctl_get_config(struct ctl_scsiio *ctsio) 10294{ |
10295 struct ctl_lun *lun = CTL_LUN(ctsio); |
|
10393 struct scsi_get_config_header *hdr; 10394 struct scsi_get_config_feature *feature; 10395 struct scsi_get_config *cdb; | 10296 struct scsi_get_config_header *hdr; 10297 struct scsi_get_config_feature *feature; 10298 struct scsi_get_config *cdb; |
10396 struct ctl_lun *lun; | |
10397 uint32_t alloc_len, data_len; 10398 int rt, starting; 10399 | 10299 uint32_t alloc_len, data_len; 10300 int rt, starting; 10301 |
10400 lun = ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; | |
10401 cdb = (struct scsi_get_config *)ctsio->cdb; 10402 rt = (cdb->rt & SGC_RT_MASK); 10403 starting = scsi_2btoul(cdb->starting_feature); 10404 alloc_len = scsi_2btoul(cdb->length); 10405 10406 data_len = sizeof(struct scsi_get_config_header) + 10407 sizeof(struct scsi_get_config_feature) + 8 + 10408 sizeof(struct scsi_get_config_feature) + 8 + --- 194 unchanged lines hidden (view full) --- 10603 return (CTL_RETVAL_COMPLETE); 10604} 10605 10606int 10607ctl_get_event_status(struct ctl_scsiio *ctsio) 10608{ 10609 struct scsi_get_event_status_header *hdr; 10610 struct scsi_get_event_status *cdb; | 10302 cdb = (struct scsi_get_config *)ctsio->cdb; 10303 rt = (cdb->rt & SGC_RT_MASK); 10304 starting = scsi_2btoul(cdb->starting_feature); 10305 alloc_len = scsi_2btoul(cdb->length); 10306 10307 data_len = sizeof(struct scsi_get_config_header) + 10308 sizeof(struct scsi_get_config_feature) + 8 + 10309 sizeof(struct scsi_get_config_feature) + 8 + --- 194 unchanged lines hidden (view full) --- 10504 return (CTL_RETVAL_COMPLETE); 10505} 10506 10507int 10508ctl_get_event_status(struct ctl_scsiio *ctsio) 10509{ 10510 struct scsi_get_event_status_header *hdr; 10511 struct scsi_get_event_status *cdb; |
10611 struct ctl_lun *lun; | |
10612 uint32_t alloc_len, data_len; 10613 int notif_class; 10614 | 10512 uint32_t alloc_len, data_len; 10513 int notif_class; 10514 |
10615 lun = ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; | |
10616 cdb = (struct scsi_get_event_status *)ctsio->cdb; 10617 if ((cdb->byte2 & SGESN_POLLED) == 0) { 10618 ctl_set_invalid_field(ctsio, /*sks_valid*/ 1, /*command*/ 1, 10619 /*field*/ 1, /*bit_valid*/ 1, /*bit*/ 0); 10620 ctl_done((union ctl_io *)ctsio); 10621 return (CTL_RETVAL_COMPLETE); 10622 } 10623 notif_class = cdb->notif_class; --- 27 unchanged lines hidden (view full) --- 10651 return (CTL_RETVAL_COMPLETE); 10652} 10653 10654int 10655ctl_mechanism_status(struct ctl_scsiio *ctsio) 10656{ 10657 struct scsi_mechanism_status_header *hdr; 10658 struct scsi_mechanism_status *cdb; | 10515 cdb = (struct scsi_get_event_status *)ctsio->cdb; 10516 if ((cdb->byte2 & SGESN_POLLED) == 0) { 10517 ctl_set_invalid_field(ctsio, /*sks_valid*/ 1, /*command*/ 1, 10518 /*field*/ 1, /*bit_valid*/ 1, /*bit*/ 0); 10519 ctl_done((union ctl_io *)ctsio); 10520 return (CTL_RETVAL_COMPLETE); 10521 } 10522 notif_class = cdb->notif_class; --- 27 unchanged lines hidden (view full) --- 10550 return (CTL_RETVAL_COMPLETE); 10551} 10552 10553int 10554ctl_mechanism_status(struct ctl_scsiio *ctsio) 10555{ 10556 struct scsi_mechanism_status_header *hdr; 10557 struct scsi_mechanism_status *cdb; |
10659 struct ctl_lun *lun; | |
10660 uint32_t alloc_len, data_len; 10661 | 10558 uint32_t alloc_len, data_len; 10559 |
10662 lun = ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; | |
10663 cdb = (struct scsi_mechanism_status *)ctsio->cdb; 10664 alloc_len = scsi_2btoul(cdb->length); 10665 10666 data_len = sizeof(struct scsi_mechanism_status_header); 10667 ctsio->kern_data_ptr = malloc(data_len, M_CTL, M_WAITOK | M_ZERO); 10668 ctsio->kern_sg_entries = 0; 10669 ctsio->kern_data_resid = 0; 10670 ctsio->kern_rel_offset = 0; --- 31 unchanged lines hidden (view full) --- 10702 buf[1] = bin2bcd((lba / 75) / 60); 10703 buf[2] = bin2bcd((lba / 75) % 60); 10704 buf[3] = bin2bcd(lba % 75); 10705} 10706 10707int 10708ctl_read_toc(struct ctl_scsiio *ctsio) 10709{ | 10560 cdb = (struct scsi_mechanism_status *)ctsio->cdb; 10561 alloc_len = scsi_2btoul(cdb->length); 10562 10563 data_len = sizeof(struct scsi_mechanism_status_header); 10564 ctsio->kern_data_ptr = malloc(data_len, M_CTL, M_WAITOK | M_ZERO); 10565 ctsio->kern_sg_entries = 0; 10566 ctsio->kern_data_resid = 0; 10567 ctsio->kern_rel_offset = 0; --- 31 unchanged lines hidden (view full) --- 10599 buf[1] = bin2bcd((lba / 75) / 60); 10600 buf[2] = bin2bcd((lba / 75) % 60); 10601 buf[3] = bin2bcd(lba % 75); 10602} 10603 10604int 10605ctl_read_toc(struct ctl_scsiio *ctsio) 10606{ |
10607 struct ctl_lun *lun = CTL_LUN(ctsio); |
|
10710 struct scsi_read_toc_hdr *hdr; 10711 struct scsi_read_toc_type01_descr *descr; 10712 struct scsi_read_toc *cdb; | 10608 struct scsi_read_toc_hdr *hdr; 10609 struct scsi_read_toc_type01_descr *descr; 10610 struct scsi_read_toc *cdb; |
10713 struct ctl_lun *lun; | |
10714 uint32_t alloc_len, data_len; 10715 int format, msf; 10716 | 10611 uint32_t alloc_len, data_len; 10612 int format, msf; 10613 |
10717 lun = ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; | |
10718 cdb = (struct scsi_read_toc *)ctsio->cdb; 10719 msf = (cdb->byte2 & CD_MSF) != 0; 10720 format = cdb->format; 10721 alloc_len = scsi_2btoul(cdb->data_len); 10722 10723 data_len = sizeof(struct scsi_read_toc_hdr); 10724 if (format == 0) 10725 data_len += 2 * sizeof(struct scsi_read_toc_type01_descr); --- 730 unchanged lines hidden (view full) --- 11456{ 11457 ctl_set_busy(&io->scsiio); 11458 ctl_done(io); 11459} 11460 11461static void 11462ctl_failover_lun(union ctl_io *rio) 11463{ | 10614 cdb = (struct scsi_read_toc *)ctsio->cdb; 10615 msf = (cdb->byte2 & CD_MSF) != 0; 10616 format = cdb->format; 10617 alloc_len = scsi_2btoul(cdb->data_len); 10618 10619 data_len = sizeof(struct scsi_read_toc_hdr); 10620 if (format == 0) 10621 data_len += 2 * sizeof(struct scsi_read_toc_type01_descr); --- 730 unchanged lines hidden (view full) --- 11352{ 11353 ctl_set_busy(&io->scsiio); 11354 ctl_done(io); 11355} 11356 11357static void 11358ctl_failover_lun(union ctl_io *rio) 11359{ |
11464 struct ctl_softc *softc = control_softc; | 11360 struct ctl_softc *softc = CTL_SOFTC(rio); |
11465 struct ctl_lun *lun; 11466 struct ctl_io_hdr *io, *next_io; 11467 uint32_t targ_lun; 11468 11469 targ_lun = rio->io_hdr.nexus.targ_mapped_lun; 11470 CTL_DEBUG_PRINT(("FAILOVER for lun %ju\n", targ_lun)); 11471 11472 /* Find and lock the LUN. */ --- 89 unchanged lines hidden (view full) --- 11562 * completed. 11563 */ 11564 mtx_lock(&lun->lun_lock); 11565 if (lun->flags & CTL_LUN_DISABLED) { 11566 mtx_unlock(&lun->lun_lock); 11567 lun = NULL; 11568 } 11569 } | 11361 struct ctl_lun *lun; 11362 struct ctl_io_hdr *io, *next_io; 11363 uint32_t targ_lun; 11364 11365 targ_lun = rio->io_hdr.nexus.targ_mapped_lun; 11366 CTL_DEBUG_PRINT(("FAILOVER for lun %ju\n", targ_lun)); 11367 11368 /* Find and lock the LUN. */ --- 89 unchanged lines hidden (view full) --- 11458 * completed. 11459 */ 11460 mtx_lock(&lun->lun_lock); 11461 if (lun->flags & CTL_LUN_DISABLED) { 11462 mtx_unlock(&lun->lun_lock); 11463 lun = NULL; 11464 } 11465 } |
11570 ctsio->io_hdr.ctl_private[CTL_PRIV_LUN].ptr = lun; | 11466 CTL_LUN(ctsio) = lun; |
11571 if (lun) { | 11467 if (lun) { |
11572 ctsio->io_hdr.ctl_private[CTL_PRIV_BACKEND_LUN].ptr = 11573 lun->be_lun; | 11468 CTL_BACKEND_LUN(ctsio) = lun->be_lun; |
11574 11575 /* 11576 * Every I/O goes into the OOA queue for a particular LUN, 11577 * and stays there until completion. 11578 */ 11579#ifdef CTL_TIME_IO 11580 if (TAILQ_EMPTY(&lun->ooa_queue)) 11581 lun->idle_time += getsbinuptime() - lun->last_busy; --- 297 unchanged lines hidden (view full) --- 11879{ 11880 return(ctl_target_reset(softc, io, CTL_UA_BUS_RESET)); 11881} 11882 11883static int 11884ctl_target_reset(struct ctl_softc *softc, union ctl_io *io, 11885 ctl_ua_type ua_type) 11886{ | 11469 11470 /* 11471 * Every I/O goes into the OOA queue for a particular LUN, 11472 * and stays there until completion. 11473 */ 11474#ifdef CTL_TIME_IO 11475 if (TAILQ_EMPTY(&lun->ooa_queue)) 11476 lun->idle_time += getsbinuptime() - lun->last_busy; --- 297 unchanged lines hidden (view full) --- 11774{ 11775 return(ctl_target_reset(softc, io, CTL_UA_BUS_RESET)); 11776} 11777 11778static int 11779ctl_target_reset(struct ctl_softc *softc, union ctl_io *io, 11780 ctl_ua_type ua_type) 11781{ |
11887 struct ctl_port *port; | 11782 struct ctl_port *port = CTL_PORT(io); |
11888 struct ctl_lun *lun; 11889 int retval; 11890 11891 if (!(io->io_hdr.flags & CTL_FLAG_FROM_OTHER_SC)) { 11892 union ctl_ha_msg msg_info; 11893 11894 msg_info.hdr.nexus = io->io_hdr.nexus; 11895 if (ua_type==CTL_UA_TARG_RESET) --- 4 unchanged lines hidden (view full) --- 11900 msg_info.hdr.original_sc = NULL; 11901 msg_info.hdr.serializing_sc = NULL; 11902 ctl_ha_msg_send(CTL_HA_CHAN_CTL, &msg_info, 11903 sizeof(msg_info.task), M_WAITOK); 11904 } 11905 retval = 0; 11906 11907 mtx_lock(&softc->ctl_lock); | 11783 struct ctl_lun *lun; 11784 int retval; 11785 11786 if (!(io->io_hdr.flags & CTL_FLAG_FROM_OTHER_SC)) { 11787 union ctl_ha_msg msg_info; 11788 11789 msg_info.hdr.nexus = io->io_hdr.nexus; 11790 if (ua_type==CTL_UA_TARG_RESET) --- 4 unchanged lines hidden (view full) --- 11795 msg_info.hdr.original_sc = NULL; 11796 msg_info.hdr.serializing_sc = NULL; 11797 ctl_ha_msg_send(CTL_HA_CHAN_CTL, &msg_info, 11798 sizeof(msg_info.task), M_WAITOK); 11799 } 11800 retval = 0; 11801 11802 mtx_lock(&softc->ctl_lock); |
11908 port = ctl_io_port(&io->io_hdr); | |
11909 STAILQ_FOREACH(lun, &softc->lun_list, links) { 11910 if (port != NULL && 11911 ctl_lun_map_to_port(port, lun->lun) == UINT32_MAX) 11912 continue; 11913 retval += ctl_do_lun_reset(lun, io, ua_type); 11914 } 11915 mtx_unlock(&softc->ctl_lock); 11916 io->taskio.task_status = CTL_TASK_FUNCTION_COMPLETE; --- 145 unchanged lines hidden (view full) --- 12062 } 12063 } 12064 } 12065} 12066 12067static int 12068ctl_abort_task_set(union ctl_io *io) 12069{ | 11803 STAILQ_FOREACH(lun, &softc->lun_list, links) { 11804 if (port != NULL && 11805 ctl_lun_map_to_port(port, lun->lun) == UINT32_MAX) 11806 continue; 11807 retval += ctl_do_lun_reset(lun, io, ua_type); 11808 } 11809 mtx_unlock(&softc->ctl_lock); 11810 io->taskio.task_status = CTL_TASK_FUNCTION_COMPLETE; --- 145 unchanged lines hidden (view full) --- 11956 } 11957 } 11958 } 11959} 11960 11961static int 11962ctl_abort_task_set(union ctl_io *io) 11963{ |
12070 struct ctl_softc *softc = control_softc; | 11964 struct ctl_softc *softc = CTL_SOFTC(io); |
12071 struct ctl_lun *lun; 12072 uint32_t targ_lun; 12073 12074 /* 12075 * Look up the LUN. 12076 */ 12077 targ_lun = io->io_hdr.nexus.targ_mapped_lun; 12078 mtx_lock(&softc->ctl_lock); --- 17 unchanged lines hidden (view full) --- 12096 mtx_unlock(&lun->lun_lock); 12097 io->taskio.task_status = CTL_TASK_FUNCTION_COMPLETE; 12098 return (0); 12099} 12100 12101static int 12102ctl_i_t_nexus_reset(union ctl_io *io) 12103{ | 11965 struct ctl_lun *lun; 11966 uint32_t targ_lun; 11967 11968 /* 11969 * Look up the LUN. 11970 */ 11971 targ_lun = io->io_hdr.nexus.targ_mapped_lun; 11972 mtx_lock(&softc->ctl_lock); --- 17 unchanged lines hidden (view full) --- 11990 mtx_unlock(&lun->lun_lock); 11991 io->taskio.task_status = CTL_TASK_FUNCTION_COMPLETE; 11992 return (0); 11993} 11994 11995static int 11996ctl_i_t_nexus_reset(union ctl_io *io) 11997{ |
12104 struct ctl_softc *softc = control_softc; | 11998 struct ctl_softc *softc = CTL_SOFTC(io); |
12105 struct ctl_lun *lun; 12106 uint32_t initidx; 12107 12108 if (!(io->io_hdr.flags & CTL_FLAG_FROM_OTHER_SC)) { 12109 union ctl_ha_msg msg_info; 12110 12111 msg_info.hdr.nexus = io->io_hdr.nexus; 12112 msg_info.task.task_action = CTL_TASK_I_T_NEXUS_RESET; --- 25 unchanged lines hidden (view full) --- 12138 mtx_unlock(&softc->ctl_lock); 12139 io->taskio.task_status = CTL_TASK_FUNCTION_COMPLETE; 12140 return (0); 12141} 12142 12143static int 12144ctl_abort_task(union ctl_io *io) 12145{ | 11999 struct ctl_lun *lun; 12000 uint32_t initidx; 12001 12002 if (!(io->io_hdr.flags & CTL_FLAG_FROM_OTHER_SC)) { 12003 union ctl_ha_msg msg_info; 12004 12005 msg_info.hdr.nexus = io->io_hdr.nexus; 12006 msg_info.task.task_action = CTL_TASK_I_T_NEXUS_RESET; --- 25 unchanged lines hidden (view full) --- 12032 mtx_unlock(&softc->ctl_lock); 12033 io->taskio.task_status = CTL_TASK_FUNCTION_COMPLETE; 12034 return (0); 12035} 12036 12037static int 12038ctl_abort_task(union ctl_io *io) 12039{ |
12040 struct ctl_softc *softc = CTL_SOFTC(io); |
|
12146 union ctl_io *xio; 12147 struct ctl_lun *lun; | 12041 union ctl_io *xio; 12042 struct ctl_lun *lun; |
12148 struct ctl_softc *softc; | |
12149#if 0 12150 struct sbuf sb; 12151 char printbuf[128]; 12152#endif 12153 int found; 12154 uint32_t targ_lun; 12155 | 12043#if 0 12044 struct sbuf sb; 12045 char printbuf[128]; 12046#endif 12047 int found; 12048 uint32_t targ_lun; 12049 |
12156 softc = control_softc; | |
12157 found = 0; 12158 12159 /* 12160 * Look up the LUN. 12161 */ 12162 targ_lun = io->io_hdr.nexus.targ_mapped_lun; 12163 mtx_lock(&softc->ctl_lock); 12164 if (targ_lun >= CTL_MAX_LUNS || --- 107 unchanged lines hidden (view full) --- 12272 } 12273 io->taskio.task_status = CTL_TASK_FUNCTION_COMPLETE; 12274 return (0); 12275} 12276 12277static int 12278ctl_query_task(union ctl_io *io, int task_set) 12279{ | 12050 found = 0; 12051 12052 /* 12053 * Look up the LUN. 12054 */ 12055 targ_lun = io->io_hdr.nexus.targ_mapped_lun; 12056 mtx_lock(&softc->ctl_lock); 12057 if (targ_lun >= CTL_MAX_LUNS || --- 107 unchanged lines hidden (view full) --- 12165 } 12166 io->taskio.task_status = CTL_TASK_FUNCTION_COMPLETE; 12167 return (0); 12168} 12169 12170static int 12171ctl_query_task(union ctl_io *io, int task_set) 12172{ |
12173 struct ctl_softc *softc = CTL_SOFTC(io); |
|
12280 union ctl_io *xio; 12281 struct ctl_lun *lun; | 12174 union ctl_io *xio; 12175 struct ctl_lun *lun; |
12282 struct ctl_softc *softc; | |
12283 int found = 0; 12284 uint32_t targ_lun; 12285 | 12176 int found = 0; 12177 uint32_t targ_lun; 12178 |
12286 softc = control_softc; | |
12287 targ_lun = io->io_hdr.nexus.targ_mapped_lun; 12288 mtx_lock(&softc->ctl_lock); 12289 if (targ_lun >= CTL_MAX_LUNS || 12290 (lun = softc->ctl_luns[targ_lun]) == NULL) { 12291 mtx_unlock(&softc->ctl_lock); 12292 io->taskio.task_status = CTL_TASK_LUN_DOES_NOT_EXIST; 12293 return (1); 12294 } --- 18 unchanged lines hidden (view full) --- 12313 else 12314 io->taskio.task_status = CTL_TASK_FUNCTION_COMPLETE; 12315 return (0); 12316} 12317 12318static int 12319ctl_query_async_event(union ctl_io *io) 12320{ | 12179 targ_lun = io->io_hdr.nexus.targ_mapped_lun; 12180 mtx_lock(&softc->ctl_lock); 12181 if (targ_lun >= CTL_MAX_LUNS || 12182 (lun = softc->ctl_luns[targ_lun]) == NULL) { 12183 mtx_unlock(&softc->ctl_lock); 12184 io->taskio.task_status = CTL_TASK_LUN_DOES_NOT_EXIST; 12185 return (1); 12186 } --- 18 unchanged lines hidden (view full) --- 12205 else 12206 io->taskio.task_status = CTL_TASK_FUNCTION_COMPLETE; 12207 return (0); 12208} 12209 12210static int 12211ctl_query_async_event(union ctl_io *io) 12212{ |
12213 struct ctl_softc *softc = CTL_SOFTC(io); |
|
12321 struct ctl_lun *lun; | 12214 struct ctl_lun *lun; |
12322 struct ctl_softc *softc; | |
12323 ctl_ua_type ua; 12324 uint32_t targ_lun, initidx; 12325 | 12215 ctl_ua_type ua; 12216 uint32_t targ_lun, initidx; 12217 |
12326 softc = control_softc; | |
12327 targ_lun = io->io_hdr.nexus.targ_mapped_lun; 12328 mtx_lock(&softc->ctl_lock); 12329 if (targ_lun >= CTL_MAX_LUNS || 12330 (lun = softc->ctl_luns[targ_lun]) == NULL) { 12331 mtx_unlock(&softc->ctl_lock); 12332 io->taskio.task_status = CTL_TASK_LUN_DOES_NOT_EXIST; 12333 return (1); 12334 } --- 7 unchanged lines hidden (view full) --- 12342 else 12343 io->taskio.task_status = CTL_TASK_FUNCTION_COMPLETE; 12344 return (0); 12345} 12346 12347static void 12348ctl_run_task(union ctl_io *io) 12349{ | 12218 targ_lun = io->io_hdr.nexus.targ_mapped_lun; 12219 mtx_lock(&softc->ctl_lock); 12220 if (targ_lun >= CTL_MAX_LUNS || 12221 (lun = softc->ctl_luns[targ_lun]) == NULL) { 12222 mtx_unlock(&softc->ctl_lock); 12223 io->taskio.task_status = CTL_TASK_LUN_DOES_NOT_EXIST; 12224 return (1); 12225 } --- 7 unchanged lines hidden (view full) --- 12233 else 12234 io->taskio.task_status = CTL_TASK_FUNCTION_COMPLETE; 12235 return (0); 12236} 12237 12238static void 12239ctl_run_task(union ctl_io *io) 12240{ |
12350 struct ctl_softc *softc = control_softc; | 12241 struct ctl_softc *softc = CTL_SOFTC(io); |
12351 int retval = 1; 12352 12353 CTL_DEBUG_PRINT(("ctl_run_task\n")); 12354 KASSERT(io->io_hdr.io_type == CTL_IO_TASK, 12355 ("ctl_run_task: Unextected io_type %d\n", io->io_hdr.io_type)); 12356 io->taskio.task_status = CTL_TASK_FUNCTION_NOT_SUPPORTED; 12357 bzero(io->taskio.task_resp, sizeof(io->taskio.task_resp)); 12358 switch (io->taskio.task_action) { --- 45 unchanged lines hidden (view full) --- 12404 12405/* 12406 * For HA operation. Handle commands that come in from the other 12407 * controller. 12408 */ 12409static void 12410ctl_handle_isc(union ctl_io *io) 12411{ | 12242 int retval = 1; 12243 12244 CTL_DEBUG_PRINT(("ctl_run_task\n")); 12245 KASSERT(io->io_hdr.io_type == CTL_IO_TASK, 12246 ("ctl_run_task: Unextected io_type %d\n", io->io_hdr.io_type)); 12247 io->taskio.task_status = CTL_TASK_FUNCTION_NOT_SUPPORTED; 12248 bzero(io->taskio.task_resp, sizeof(io->taskio.task_resp)); 12249 switch (io->taskio.task_action) { --- 45 unchanged lines hidden (view full) --- 12295 12296/* 12297 * For HA operation. Handle commands that come in from the other 12298 * controller. 12299 */ 12300static void 12301ctl_handle_isc(union ctl_io *io) 12302{ |
12412 struct ctl_softc *softc = control_softc; | 12303 struct ctl_softc *softc = CTL_SOFTC(io); |
12413 struct ctl_lun *lun; 12414 const struct ctl_cmd_entry *entry; 12415 uint32_t targ_lun; 12416 12417 targ_lun = io->io_hdr.nexus.targ_mapped_lun; 12418 switch (io->io_hdr.msg_type) { 12419 case CTL_MSG_SERIALIZE: 12420 ctl_serialize_other_sc_cmd(&io->scsiio); --- 27 unchanged lines hidden (view full) --- 12448 } 12449 mtx_lock(&lun->lun_lock); 12450 TAILQ_REMOVE(&lun->ooa_queue, &io->io_hdr, ooa_links); 12451 ctl_check_blocked(lun); 12452 mtx_unlock(&lun->lun_lock); 12453 ctl_free_io(io); 12454 break; 12455 case CTL_MSG_PERS_ACTION: | 12304 struct ctl_lun *lun; 12305 const struct ctl_cmd_entry *entry; 12306 uint32_t targ_lun; 12307 12308 targ_lun = io->io_hdr.nexus.targ_mapped_lun; 12309 switch (io->io_hdr.msg_type) { 12310 case CTL_MSG_SERIALIZE: 12311 ctl_serialize_other_sc_cmd(&io->scsiio); --- 27 unchanged lines hidden (view full) --- 12339 } 12340 mtx_lock(&lun->lun_lock); 12341 TAILQ_REMOVE(&lun->ooa_queue, &io->io_hdr, ooa_links); 12342 ctl_check_blocked(lun); 12343 mtx_unlock(&lun->lun_lock); 12344 ctl_free_io(io); 12345 break; 12346 case CTL_MSG_PERS_ACTION: |
12456 ctl_hndl_per_res_out_on_other_sc( 12457 (union ctl_ha_msg *)&io->presio.pr_msg); | 12347 ctl_hndl_per_res_out_on_other_sc(io); |
12458 ctl_free_io(io); 12459 break; 12460 case CTL_MSG_BAD_JUJU: 12461 ctl_done(io); 12462 break; 12463 case CTL_MSG_DATAMOVE: /* Only used in XFER mode */ 12464 ctl_datamove_remote(io); 12465 break; --- 156 unchanged lines hidden (view full) --- 12622 12623 ctl_datamove(io); 12624} 12625#endif /* CTL_IO_DELAY */ 12626 12627void 12628ctl_datamove(union ctl_io *io) 12629{ | 12348 ctl_free_io(io); 12349 break; 12350 case CTL_MSG_BAD_JUJU: 12351 ctl_done(io); 12352 break; 12353 case CTL_MSG_DATAMOVE: /* Only used in XFER mode */ 12354 ctl_datamove_remote(io); 12355 break; --- 156 unchanged lines hidden (view full) --- 12512 12513 ctl_datamove(io); 12514} 12515#endif /* CTL_IO_DELAY */ 12516 12517void 12518ctl_datamove(union ctl_io *io) 12519{ |
12630 struct ctl_lun *lun; | |
12631 void (*fe_datamove)(union ctl_io *io); 12632 | 12520 void (*fe_datamove)(union ctl_io *io); 12521 |
12633 mtx_assert(&control_softc->ctl_lock, MA_NOTOWNED); | 12522 mtx_assert(&((struct ctl_softc *)CTL_SOFTC(io))->ctl_lock, MA_NOTOWNED); |
12634 12635 CTL_DEBUG_PRINT(("ctl_datamove\n")); 12636 | 12523 12524 CTL_DEBUG_PRINT(("ctl_datamove\n")); 12525 |
12637 lun = (struct ctl_lun *)io->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; | |
12638#ifdef CTL_TIME_IO 12639 if ((time_uptime - io->io_hdr.start_time) > ctl_time_io_secs) { 12640 char str[256]; 12641 char path_str[64]; 12642 struct sbuf sb; 12643 12644 ctl_scsi_path_string(io, path_str, sizeof(path_str)); 12645 sbuf_new(&sb, str, sizeof(str), SBUF_FIXEDLEN); --- 64 unchanged lines hidden (view full) --- 12710 } 12711 12712 /* Don't confuse frontend with zero length data move. */ 12713 if (io->scsiio.kern_data_len == 0) { 12714 io->scsiio.be_move_done(io); 12715 return; 12716 } 12717 | 12526#ifdef CTL_TIME_IO 12527 if ((time_uptime - io->io_hdr.start_time) > ctl_time_io_secs) { 12528 char str[256]; 12529 char path_str[64]; 12530 struct sbuf sb; 12531 12532 ctl_scsi_path_string(io, path_str, sizeof(path_str)); 12533 sbuf_new(&sb, str, sizeof(str), SBUF_FIXEDLEN); --- 64 unchanged lines hidden (view full) --- 12598 } 12599 12600 /* Don't confuse frontend with zero length data move. */ 12601 if (io->scsiio.kern_data_len == 0) { 12602 io->scsiio.be_move_done(io); 12603 return; 12604 } 12605 |
12718 fe_datamove = ctl_io_port(&io->io_hdr)->fe_datamove; | 12606 fe_datamove = CTL_PORT(io)->fe_datamove; |
12719 fe_datamove(io); 12720} 12721 12722static void 12723ctl_send_datamove_done(union ctl_io *io, int have_lock) 12724{ 12725 union ctl_ha_msg msg; 12726#ifdef CTL_TIME_IO --- 101 unchanged lines hidden (view full) --- 12828 io->scsiio.kern_data_ptr = (uint8_t *)io->io_hdr.local_sglist; 12829 12830 /* 12831 * Use a custom move done callback, since we need to send completion 12832 * back to the other controller, not to the backend on this side. 12833 */ 12834 io->scsiio.be_move_done = ctl_datamove_remote_dm_write_cb; 12835 | 12607 fe_datamove(io); 12608} 12609 12610static void 12611ctl_send_datamove_done(union ctl_io *io, int have_lock) 12612{ 12613 union ctl_ha_msg msg; 12614#ifdef CTL_TIME_IO --- 101 unchanged lines hidden (view full) --- 12716 io->scsiio.kern_data_ptr = (uint8_t *)io->io_hdr.local_sglist; 12717 12718 /* 12719 * Use a custom move done callback, since we need to send completion 12720 * back to the other controller, not to the backend on this side. 12721 */ 12722 io->scsiio.be_move_done = ctl_datamove_remote_dm_write_cb; 12723 |
12836 fe_datamove = ctl_io_port(&io->io_hdr)->fe_datamove; | 12724 fe_datamove = CTL_PORT(io)->fe_datamove; |
12837 fe_datamove(io); 12838} 12839 12840static int 12841ctl_datamove_remote_dm_read_cb(union ctl_io *io) 12842{ 12843#if 0 12844 char str[256]; --- 58 unchanged lines hidden (view full) --- 12903 /* 12904 * Use a custom move done callback, since we need to send completion 12905 * back to the other controller, not to the backend on this side. 12906 */ 12907 io->scsiio.be_move_done = ctl_datamove_remote_dm_read_cb; 12908 12909 /* XXX KDM add checks like the ones in ctl_datamove? */ 12910 | 12725 fe_datamove(io); 12726} 12727 12728static int 12729ctl_datamove_remote_dm_read_cb(union ctl_io *io) 12730{ 12731#if 0 12732 char str[256]; --- 58 unchanged lines hidden (view full) --- 12791 /* 12792 * Use a custom move done callback, since we need to send completion 12793 * back to the other controller, not to the backend on this side. 12794 */ 12795 io->scsiio.be_move_done = ctl_datamove_remote_dm_read_cb; 12796 12797 /* XXX KDM add checks like the ones in ctl_datamove? */ 12798 |
12911 fe_datamove = ctl_io_port(&io->io_hdr)->fe_datamove; | 12799 fe_datamove = CTL_PORT(io)->fe_datamove; |
12912 fe_datamove(io); 12913} 12914 12915static int 12916ctl_datamove_remote_sgl_setup(union ctl_io *io) 12917{ 12918 struct ctl_sg_entry *local_sglist; 12919 uint32_t len_to_go; --- 199 unchanged lines hidden (view full) --- 13119 * first. Once that is complete, the data gets DMAed into the remote 13120 * controller's memory. For reads, we DMA from the remote controller's 13121 * memory into our memory first, and then move it out to the FETD. 13122 */ 13123static void 13124ctl_datamove_remote(union ctl_io *io) 13125{ 13126 | 12800 fe_datamove(io); 12801} 12802 12803static int 12804ctl_datamove_remote_sgl_setup(union ctl_io *io) 12805{ 12806 struct ctl_sg_entry *local_sglist; 12807 uint32_t len_to_go; --- 199 unchanged lines hidden (view full) --- 13007 * first. Once that is complete, the data gets DMAed into the remote 13008 * controller's memory. For reads, we DMA from the remote controller's 13009 * memory into our memory first, and then move it out to the FETD. 13010 */ 13011static void 13012ctl_datamove_remote(union ctl_io *io) 13013{ 13014 |
13127 mtx_assert(&control_softc->ctl_lock, MA_NOTOWNED); | 13015 mtx_assert(&((struct ctl_softc *)CTL_SOFTC(io))->ctl_lock, MA_NOTOWNED); |
13128 13129 if (io->io_hdr.flags & CTL_FLAG_FAILOVER) { 13130 ctl_failover_io(io, /*have_lock*/ 0); 13131 return; 13132 } 13133 13134 /* 13135 * Note that we look for an aborted I/O here, but don't do some of --- 19 unchanged lines hidden (view full) --- 13155 io->io_hdr.port_status = 31339; 13156 ctl_send_datamove_done(io, /*have_lock*/ 0); 13157 } 13158} 13159 13160static void 13161ctl_process_done(union ctl_io *io) 13162{ | 13016 13017 if (io->io_hdr.flags & CTL_FLAG_FAILOVER) { 13018 ctl_failover_io(io, /*have_lock*/ 0); 13019 return; 13020 } 13021 13022 /* 13023 * Note that we look for an aborted I/O here, but don't do some of --- 19 unchanged lines hidden (view full) --- 13043 io->io_hdr.port_status = 31339; 13044 ctl_send_datamove_done(io, /*have_lock*/ 0); 13045 } 13046} 13047 13048static void 13049ctl_process_done(union ctl_io *io) 13050{ |
13163 struct ctl_lun *lun; 13164 struct ctl_softc *softc = control_softc; | 13051 struct ctl_softc *softc = CTL_SOFTC(io); 13052 struct ctl_lun *lun = CTL_LUN(io); |
13165 void (*fe_done)(union ctl_io *io); 13166 union ctl_ha_msg msg; 13167 uint32_t targ_port = io->io_hdr.nexus.targ_port; 13168 13169 CTL_DEBUG_PRINT(("ctl_process_done\n")); 13170 fe_done = softc->ctl_ports[targ_port]->fe_done; 13171 13172#ifdef CTL_TIME_IO --- 39 unchanged lines hidden (view full) --- 13212 ctl_io_error_print(io, NULL); 13213 fe_done(io); 13214 return; 13215 default: 13216 panic("%s: Invalid CTL I/O type %d\n", 13217 __func__, io->io_hdr.io_type); 13218 } 13219 | 13053 void (*fe_done)(union ctl_io *io); 13054 union ctl_ha_msg msg; 13055 uint32_t targ_port = io->io_hdr.nexus.targ_port; 13056 13057 CTL_DEBUG_PRINT(("ctl_process_done\n")); 13058 fe_done = softc->ctl_ports[targ_port]->fe_done; 13059 13060#ifdef CTL_TIME_IO --- 39 unchanged lines hidden (view full) --- 13100 ctl_io_error_print(io, NULL); 13101 fe_done(io); 13102 return; 13103 default: 13104 panic("%s: Invalid CTL I/O type %d\n", 13105 __func__, io->io_hdr.io_type); 13106 } 13107 |
13220 lun = (struct ctl_lun *)io->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; | |
13221 if (lun == NULL) { 13222 CTL_DEBUG_PRINT(("NULL LUN for lun %d\n", 13223 io->io_hdr.nexus.targ_mapped_lun)); 13224 goto bailout; 13225 } 13226 13227 mtx_lock(&lun->lun_lock); 13228 --- 137 unchanged lines hidden (view full) --- 13366#ifdef CTL_WITH_CA 13367/* 13368 * Front end should call this if it doesn't do autosense. When the request 13369 * sense comes back in from the initiator, we'll dequeue this and send it. 13370 */ 13371int 13372ctl_queue_sense(union ctl_io *io) 13373{ | 13108 if (lun == NULL) { 13109 CTL_DEBUG_PRINT(("NULL LUN for lun %d\n", 13110 io->io_hdr.nexus.targ_mapped_lun)); 13111 goto bailout; 13112 } 13113 13114 mtx_lock(&lun->lun_lock); 13115 --- 137 unchanged lines hidden (view full) --- 13253#ifdef CTL_WITH_CA 13254/* 13255 * Front end should call this if it doesn't do autosense. When the request 13256 * sense comes back in from the initiator, we'll dequeue this and send it. 13257 */ 13258int 13259ctl_queue_sense(union ctl_io *io) 13260{ |
13261 struct ctl_softc *softc = CTL_SOFTC(io); 13262 struct ctl_port *port = CTL_PORT(io); |
|
13374 struct ctl_lun *lun; | 13263 struct ctl_lun *lun; |
13375 struct ctl_port *port; 13376 struct ctl_softc *softc; | |
13377 uint32_t initidx, targ_lun; 13378 13379 CTL_DEBUG_PRINT(("ctl_queue_sense\n")); 13380 | 13264 uint32_t initidx, targ_lun; 13265 13266 CTL_DEBUG_PRINT(("ctl_queue_sense\n")); 13267 |
13381 softc = control_softc; 13382 port = ctl_io_port(&ctsio->io_hdr); | |
13383 targ_lun = ctl_lun_map_from_port(port, io->io_hdr.nexus.targ_lun); 13384 13385 /* 13386 * LUN lookup will likely move to the ctl_work_thread() once we 13387 * have our new queueing infrastructure (that doesn't put things on 13388 * a per-LUN queue initially). That is so that we can handle 13389 * things like an INQUIRY to a LUN that we don't have enabled. We 13390 * can't deal with that right now. --- 31 unchanged lines hidden (view full) --- 13422 13423/* 13424 * Primary command inlet from frontend ports. All SCSI and task I/O 13425 * requests must go through this function. 13426 */ 13427int 13428ctl_queue(union ctl_io *io) 13429{ | 13268 targ_lun = ctl_lun_map_from_port(port, io->io_hdr.nexus.targ_lun); 13269 13270 /* 13271 * LUN lookup will likely move to the ctl_work_thread() once we 13272 * have our new queueing infrastructure (that doesn't put things on 13273 * a per-LUN queue initially). That is so that we can handle 13274 * things like an INQUIRY to a LUN that we don't have enabled. We 13275 * can't deal with that right now. --- 31 unchanged lines hidden (view full) --- 13307 13308/* 13309 * Primary command inlet from frontend ports. All SCSI and task I/O 13310 * requests must go through this function. 13311 */ 13312int 13313ctl_queue(union ctl_io *io) 13314{ |
13430 struct ctl_port *port; | 13315 struct ctl_port *port = CTL_PORT(io); |
13431 13432 CTL_DEBUG_PRINT(("ctl_queue cdb[0]=%02X\n", io->scsiio.cdb[0])); 13433 13434#ifdef CTL_TIME_IO 13435 io->io_hdr.start_time = time_uptime; 13436 getbinuptime(&io->io_hdr.start_bt); 13437#endif /* CTL_TIME_IO */ 13438 13439 /* Map FE-specific LUN ID into global one. */ | 13316 13317 CTL_DEBUG_PRINT(("ctl_queue cdb[0]=%02X\n", io->scsiio.cdb[0])); 13318 13319#ifdef CTL_TIME_IO 13320 io->io_hdr.start_time = time_uptime; 13321 getbinuptime(&io->io_hdr.start_bt); 13322#endif /* CTL_TIME_IO */ 13323 13324 /* Map FE-specific LUN ID into global one. */ |
13440 port = ctl_io_port(&io->io_hdr); | |
13441 io->io_hdr.nexus.targ_mapped_lun = 13442 ctl_lun_map_from_port(port, io->io_hdr.nexus.targ_lun); 13443 13444 switch (io->io_hdr.io_type) { 13445 case CTL_IO_SCSI: 13446 case CTL_IO_TASK: 13447 if (ctl_debug & CTL_DEBUG_CDB) 13448 ctl_io_print(io); --- 16 unchanged lines hidden (view full) --- 13465 io = (union ctl_io *)arg; 13466 ctl_done(io); 13467} 13468#endif /* CTL_IO_DELAY */ 13469 13470void 13471ctl_serseq_done(union ctl_io *io) 13472{ | 13325 io->io_hdr.nexus.targ_mapped_lun = 13326 ctl_lun_map_from_port(port, io->io_hdr.nexus.targ_lun); 13327 13328 switch (io->io_hdr.io_type) { 13329 case CTL_IO_SCSI: 13330 case CTL_IO_TASK: 13331 if (ctl_debug & CTL_DEBUG_CDB) 13332 ctl_io_print(io); --- 16 unchanged lines hidden (view full) --- 13349 io = (union ctl_io *)arg; 13350 ctl_done(io); 13351} 13352#endif /* CTL_IO_DELAY */ 13353 13354void 13355ctl_serseq_done(union ctl_io *io) 13356{ |
13473 struct ctl_lun *lun; | 13357 struct ctl_lun *lun = CTL_LUN(io);; |
13474 | 13358 |
13475 lun = (struct ctl_lun *)io->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; | |
13476 if (lun->be_lun == NULL || 13477 lun->be_lun->serseq == CTL_LUN_SERSEQ_OFF) 13478 return; 13479 mtx_lock(&lun->lun_lock); 13480 io->io_hdr.flags |= CTL_FLAG_SERSEQ_DONE; 13481 ctl_check_blocked(lun); 13482 mtx_unlock(&lun->lun_lock); 13483} --- 33 unchanged lines hidden (view full) --- 13517 */ 13518 if (io->io_hdr.flags & CTL_FLAG_INT_COPY) 13519 return; 13520 13521#ifdef CTL_IO_DELAY 13522 if (io->io_hdr.flags & CTL_FLAG_DELAY_DONE) { 13523 io->io_hdr.flags &= ~CTL_FLAG_DELAY_DONE; 13524 } else { | 13359 if (lun->be_lun == NULL || 13360 lun->be_lun->serseq == CTL_LUN_SERSEQ_OFF) 13361 return; 13362 mtx_lock(&lun->lun_lock); 13363 io->io_hdr.flags |= CTL_FLAG_SERSEQ_DONE; 13364 ctl_check_blocked(lun); 13365 mtx_unlock(&lun->lun_lock); 13366} --- 33 unchanged lines hidden (view full) --- 13400 */ 13401 if (io->io_hdr.flags & CTL_FLAG_INT_COPY) 13402 return; 13403 13404#ifdef CTL_IO_DELAY 13405 if (io->io_hdr.flags & CTL_FLAG_DELAY_DONE) { 13406 io->io_hdr.flags &= ~CTL_FLAG_DELAY_DONE; 13407 } else { |
13525 struct ctl_lun *lun; | 13408 struct ctl_lun *lun = CTL_LUN(io); |
13526 | 13409 |
13527 lun =(struct ctl_lun *)io->io_hdr.ctl_private[CTL_PRIV_LUN].ptr; 13528 | |
13529 if ((lun != NULL) 13530 && (lun->delay_info.done_delay > 0)) { 13531 13532 callout_init(&io->io_hdr.delay_callout, /*mpsafe*/ 1); 13533 io->io_hdr.flags |= CTL_FLAG_DELAY_DONE; 13534 callout_reset(&io->io_hdr.delay_callout, 13535 lun->delay_info.done_delay * hz, 13536 ctl_done_timer_wakeup, io); --- 194 unchanged lines hidden (view full) --- 13731 mtx_unlock(&softc->ctl_lock); 13732 pause("-", CTL_LBP_PERIOD * hz); 13733 } 13734} 13735 13736static void 13737ctl_enqueue_incoming(union ctl_io *io) 13738{ | 13410 if ((lun != NULL) 13411 && (lun->delay_info.done_delay > 0)) { 13412 13413 callout_init(&io->io_hdr.delay_callout, /*mpsafe*/ 1); 13414 io->io_hdr.flags |= CTL_FLAG_DELAY_DONE; 13415 callout_reset(&io->io_hdr.delay_callout, 13416 lun->delay_info.done_delay * hz, 13417 ctl_done_timer_wakeup, io); --- 194 unchanged lines hidden (view full) --- 13612 mtx_unlock(&softc->ctl_lock); 13613 pause("-", CTL_LBP_PERIOD * hz); 13614 } 13615} 13616 13617static void 13618ctl_enqueue_incoming(union ctl_io *io) 13619{ |
13739 struct ctl_softc *softc = control_softc; | 13620 struct ctl_softc *softc = CTL_SOFTC(io); |
13740 struct ctl_thread *thr; 13741 u_int idx; 13742 13743 idx = (io->io_hdr.nexus.targ_port * 127 + 13744 io->io_hdr.nexus.initid) % worker_threads; 13745 thr = &softc->threads[idx]; 13746 mtx_lock(&thr->queue_lock); 13747 STAILQ_INSERT_TAIL(&thr->incoming_queue, &io->io_hdr, links); 13748 mtx_unlock(&thr->queue_lock); 13749 wakeup(thr); 13750} 13751 13752static void 13753ctl_enqueue_rtr(union ctl_io *io) 13754{ | 13621 struct ctl_thread *thr; 13622 u_int idx; 13623 13624 idx = (io->io_hdr.nexus.targ_port * 127 + 13625 io->io_hdr.nexus.initid) % worker_threads; 13626 thr = &softc->threads[idx]; 13627 mtx_lock(&thr->queue_lock); 13628 STAILQ_INSERT_TAIL(&thr->incoming_queue, &io->io_hdr, links); 13629 mtx_unlock(&thr->queue_lock); 13630 wakeup(thr); 13631} 13632 13633static void 13634ctl_enqueue_rtr(union ctl_io *io) 13635{ |
13755 struct ctl_softc *softc = control_softc; | 13636 struct ctl_softc *softc = CTL_SOFTC(io); |
13756 struct ctl_thread *thr; 13757 13758 thr = &softc->threads[io->io_hdr.nexus.targ_mapped_lun % worker_threads]; 13759 mtx_lock(&thr->queue_lock); 13760 STAILQ_INSERT_TAIL(&thr->rtr_queue, &io->io_hdr, links); 13761 mtx_unlock(&thr->queue_lock); 13762 wakeup(thr); 13763} 13764 13765static void 13766ctl_enqueue_done(union ctl_io *io) 13767{ | 13637 struct ctl_thread *thr; 13638 13639 thr = &softc->threads[io->io_hdr.nexus.targ_mapped_lun % worker_threads]; 13640 mtx_lock(&thr->queue_lock); 13641 STAILQ_INSERT_TAIL(&thr->rtr_queue, &io->io_hdr, links); 13642 mtx_unlock(&thr->queue_lock); 13643 wakeup(thr); 13644} 13645 13646static void 13647ctl_enqueue_done(union ctl_io *io) 13648{ |
13768 struct ctl_softc *softc = control_softc; | 13649 struct ctl_softc *softc = CTL_SOFTC(io); |
13769 struct ctl_thread *thr; 13770 13771 thr = &softc->threads[io->io_hdr.nexus.targ_mapped_lun % worker_threads]; 13772 mtx_lock(&thr->queue_lock); 13773 STAILQ_INSERT_TAIL(&thr->done_queue, &io->io_hdr, links); 13774 mtx_unlock(&thr->queue_lock); 13775 wakeup(thr); 13776} 13777 13778static void 13779ctl_enqueue_isc(union ctl_io *io) 13780{ | 13650 struct ctl_thread *thr; 13651 13652 thr = &softc->threads[io->io_hdr.nexus.targ_mapped_lun % worker_threads]; 13653 mtx_lock(&thr->queue_lock); 13654 STAILQ_INSERT_TAIL(&thr->done_queue, &io->io_hdr, links); 13655 mtx_unlock(&thr->queue_lock); 13656 wakeup(thr); 13657} 13658 13659static void 13660ctl_enqueue_isc(union ctl_io *io) 13661{ |
13781 struct ctl_softc *softc = control_softc; | 13662 struct ctl_softc *softc = CTL_SOFTC(io); |
13782 struct ctl_thread *thr; 13783 13784 thr = &softc->threads[io->io_hdr.nexus.targ_mapped_lun % worker_threads]; 13785 mtx_lock(&thr->queue_lock); 13786 STAILQ_INSERT_TAIL(&thr->isc_queue, &io->io_hdr, links); 13787 mtx_unlock(&thr->queue_lock); 13788 wakeup(thr); 13789} 13790 13791/* 13792 * vim: ts=8 13793 */ | 13663 struct ctl_thread *thr; 13664 13665 thr = &softc->threads[io->io_hdr.nexus.targ_mapped_lun % worker_threads]; 13666 mtx_lock(&thr->queue_lock); 13667 STAILQ_INSERT_TAIL(&thr->isc_queue, &io->io_hdr, links); 13668 mtx_unlock(&thr->queue_lock); 13669 wakeup(thr); 13670} 13671 13672/* 13673 * vim: ts=8 13674 */ |