Changeset View
Changeset View
Standalone View
Standalone View
sys/cam/cam_xpt.c
Show First 20 Lines • Show All 493 Lines • ▼ Show 20 Lines | #endif | ||||
case XPT_DEBUG: { | case XPT_DEBUG: { | ||||
union ccb ccb; | union ccb ccb; | ||||
/* | /* | ||||
* This is an immediate CCB, so it's okay to | * This is an immediate CCB, so it's okay to | ||||
* allocate it on the stack. | * allocate it on the stack. | ||||
*/ | */ | ||||
memset(&ccb, 0, sizeof(ccb)); | xpt_setup_stack_ccb(&ccb.ccb_h, sizeof(ccb), | ||||
imp: this is a bug, but we dump the path into into this ccb, and then dump the path into it, then… | |||||
ccb.ccb_h.path, | |||||
inccb->ccb_h.pinfo.priority); | |||||
/* | /* | ||||
* Create a path using the bus, target, and lun the | * Create a path using the bus, target, and lun the | ||||
* user passed in. | * user passed in. | ||||
*/ | */ | ||||
if (xpt_create_path(&ccb.ccb_h.path, NULL, | if (xpt_create_path(&ccb.ccb_h.path, NULL, | ||||
inccb->ccb_h.path_id, | inccb->ccb_h.path_id, | ||||
inccb->ccb_h.target_id, | inccb->ccb_h.target_id, | ||||
inccb->ccb_h.target_lun) != | inccb->ccb_h.target_lun) != | ||||
CAM_REQ_CMP){ | CAM_REQ_CMP){ | ||||
error = EINVAL; | error = EINVAL; | ||||
break; | break; | ||||
} | } | ||||
/* Ensure all of our fields are correct */ | /* Ensure all of our fields are correct */ | ||||
xpt_setup_ccb(&ccb.ccb_h, ccb.ccb_h.path, | |||||
inccb->ccb_h.pinfo.priority); | |||||
xpt_merge_ccb(&ccb, inccb); | xpt_merge_ccb(&ccb, inccb); | ||||
xpt_action(&ccb); | xpt_action(&ccb); | ||||
bcopy(&ccb, inccb, sizeof(union ccb)); | bcopy(&ccb, inccb, sizeof(union ccb)); | ||||
xpt_free_path(ccb.ccb_h.path); | xpt_free_path(ccb.ccb_h.path); | ||||
break; | break; | ||||
} | } | ||||
case XPT_DEV_MATCH: { | case XPT_DEV_MATCH: { | ||||
struct cam_periph_map_info mapinfo; | struct cam_periph_map_info mapinfo; | ||||
▲ Show 20 Lines • Show All 717 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
int ret = -1, l, o; | int ret = -1, l, o; | ||||
struct ccb_dev_advinfo cdai; | struct ccb_dev_advinfo cdai; | ||||
struct scsi_vpd_device_id *did; | struct scsi_vpd_device_id *did; | ||||
struct scsi_vpd_id_descriptor *idd; | struct scsi_vpd_id_descriptor *idd; | ||||
xpt_path_assert(path, MA_OWNED); | xpt_path_assert(path, MA_OWNED); | ||||
memset(&cdai, 0, sizeof(cdai)); | xpt_setup_stack_ccb(&cdai.ccb_h, sizeof(cdai), path, | ||||
xpt_setup_ccb(&cdai.ccb_h, path, CAM_PRIORITY_NORMAL); | CAM_PRIORITY_NORMAL); | ||||
cdai.ccb_h.func_code = XPT_DEV_ADVINFO; | cdai.ccb_h.func_code = XPT_DEV_ADVINFO; | ||||
cdai.flags = CDAI_FLAG_NONE; | cdai.flags = CDAI_FLAG_NONE; | ||||
cdai.bufsiz = len; | cdai.bufsiz = len; | ||||
cdai.buf = buf; | cdai.buf = buf; | ||||
if (!strcmp(attr, "GEOM::ident")) | if (!strcmp(attr, "GEOM::ident")) | ||||
cdai.buftype = CDAI_TYPE_SERIAL_NUM; | cdai.buftype = CDAI_TYPE_SERIAL_NUM; | ||||
else if (!strcmp(attr, "GEOM::physpath")) | else if (!strcmp(attr, "GEOM::physpath")) | ||||
▲ Show 20 Lines • Show All 1,329 Lines • ▼ Show 20 Lines | xptsetasyncfunc(struct cam_ed *device, void *arg) | ||||
* Don't report unconfigured devices (Wildcard devs, | * Don't report unconfigured devices (Wildcard devs, | ||||
* devices only for target mode, device instances | * devices only for target mode, device instances | ||||
* that have been invalidated but are waiting for | * that have been invalidated but are waiting for | ||||
* their last reference count to be released). | * their last reference count to be released). | ||||
*/ | */ | ||||
if ((device->flags & CAM_DEV_UNCONFIGURED) != 0) | if ((device->flags & CAM_DEV_UNCONFIGURED) != 0) | ||||
return (1); | return (1); | ||||
memset(&cgd, 0, sizeof(cgd)); | xpt_setup_stack_ccb(&cgd.ccb_h, sizeof(cgd), &path, | ||||
CAM_PRIORITY_NORMAL); | |||||
xpt_compile_path(&path, | xpt_compile_path(&path, | ||||
NULL, | NULL, | ||||
device->target->bus->path_id, | device->target->bus->path_id, | ||||
device->target->target_id, | device->target->target_id, | ||||
device->lun_id); | device->lun_id); | ||||
xpt_setup_ccb(&cgd.ccb_h, &path, CAM_PRIORITY_NORMAL); | |||||
cgd.ccb_h.func_code = XPT_GDEV_TYPE; | cgd.ccb_h.func_code = XPT_GDEV_TYPE; | ||||
xpt_action((union ccb *)&cgd); | xpt_action((union ccb *)&cgd); | ||||
csa->callback(csa->callback_arg, | csa->callback(csa->callback_arg, | ||||
AC_FOUND_DEVICE, | AC_FOUND_DEVICE, | ||||
&path, &cgd); | &path, &cgd); | ||||
xpt_release_path(&path); | xpt_release_path(&path); | ||||
return(1); | return(1); | ||||
▲ Show 20 Lines • Show All 2,501 Lines • ▼ Show 20 Lines | xpt_start_tags(struct cam_path *path) | ||||
device->inq_flags |= SID_CmdQue; | device->inq_flags |= SID_CmdQue; | ||||
if (device->tag_saved_openings != 0) | if (device->tag_saved_openings != 0) | ||||
newopenings = device->tag_saved_openings; | newopenings = device->tag_saved_openings; | ||||
else | else | ||||
newopenings = min(device->maxtags, | newopenings = min(device->maxtags, | ||||
sim->max_tagged_dev_openings); | sim->max_tagged_dev_openings); | ||||
xpt_dev_ccbq_resize(path, newopenings); | xpt_dev_ccbq_resize(path, newopenings); | ||||
xpt_async(AC_GETDEV_CHANGED, path, NULL); | xpt_async(AC_GETDEV_CHANGED, path, NULL); | ||||
memset(&crs, 0, sizeof(crs)); | xpt_setup_stack_ccb(&crs.ccb_h, sizeof(crs), path, | ||||
xpt_setup_ccb(&crs.ccb_h, path, CAM_PRIORITY_NORMAL); | CAM_PRIORITY_NORMAL); | ||||
crs.ccb_h.func_code = XPT_REL_SIMQ; | crs.ccb_h.func_code = XPT_REL_SIMQ; | ||||
crs.release_flags = RELSIM_RELEASE_AFTER_QEMPTY; | crs.release_flags = RELSIM_RELEASE_AFTER_QEMPTY; | ||||
crs.openings | crs.openings | ||||
= crs.release_timeout | = crs.release_timeout | ||||
= crs.qfrozen_cnt | = crs.qfrozen_cnt | ||||
= 0; | = 0; | ||||
xpt_action((union ccb *)&crs); | xpt_action((union ccb *)&crs); | ||||
} | } | ||||
void | void | ||||
xpt_stop_tags(struct cam_path *path) | xpt_stop_tags(struct cam_path *path) | ||||
{ | { | ||||
struct ccb_relsim crs; | struct ccb_relsim crs; | ||||
struct cam_ed *device; | struct cam_ed *device; | ||||
struct cam_sim *sim; | struct cam_sim *sim; | ||||
device = path->device; | device = path->device; | ||||
sim = path->bus->sim; | sim = path->bus->sim; | ||||
device->flags &= ~CAM_DEV_TAG_AFTER_COUNT; | device->flags &= ~CAM_DEV_TAG_AFTER_COUNT; | ||||
device->tag_delay_count = 0; | device->tag_delay_count = 0; | ||||
xpt_freeze_devq(path, /*count*/1); | xpt_freeze_devq(path, /*count*/1); | ||||
device->inq_flags &= ~SID_CmdQue; | device->inq_flags &= ~SID_CmdQue; | ||||
xpt_dev_ccbq_resize(path, sim->max_dev_openings); | xpt_dev_ccbq_resize(path, sim->max_dev_openings); | ||||
xpt_async(AC_GETDEV_CHANGED, path, NULL); | xpt_async(AC_GETDEV_CHANGED, path, NULL); | ||||
memset(&crs, 0, sizeof(crs)); | xpt_setup_stack_ccb(&crs.ccb_h, sizeof(crs), path, | ||||
xpt_setup_ccb(&crs.ccb_h, path, CAM_PRIORITY_NORMAL); | CAM_PRIORITY_NORMAL); | ||||
crs.ccb_h.func_code = XPT_REL_SIMQ; | crs.ccb_h.func_code = XPT_REL_SIMQ; | ||||
crs.release_flags = RELSIM_RELEASE_AFTER_QEMPTY; | crs.release_flags = RELSIM_RELEASE_AFTER_QEMPTY; | ||||
crs.openings | crs.openings | ||||
= crs.release_timeout | = crs.release_timeout | ||||
= crs.qfrozen_cnt | = crs.qfrozen_cnt | ||||
= 0; | = 0; | ||||
xpt_action((union ccb *)&crs); | xpt_action((union ccb *)&crs); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 140 Lines • ▼ Show 20 Lines | if (path == NULL) { | ||||
status = xpt_create_path(&path, /*periph*/NULL, CAM_XPT_PATH_ID, | status = xpt_create_path(&path, /*periph*/NULL, CAM_XPT_PATH_ID, | ||||
CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD); | CAM_TARGET_WILDCARD, CAM_LUN_WILDCARD); | ||||
if (status != CAM_REQ_CMP) | if (status != CAM_REQ_CMP) | ||||
return (status); | return (status); | ||||
xpt_path_lock(path); | xpt_path_lock(path); | ||||
xptpath = 1; | xptpath = 1; | ||||
} | } | ||||
memset(&csa, 0, sizeof(csa)); | xpt_setup_stack_ccb(&csa.ccb_h, sizeof(csa), path, | ||||
xpt_setup_ccb(&csa.ccb_h, path, CAM_PRIORITY_NORMAL); | CAM_PRIORITY_NORMAL); | ||||
csa.ccb_h.func_code = XPT_SASYNC_CB; | csa.ccb_h.func_code = XPT_SASYNC_CB; | ||||
csa.event_enable = event; | csa.event_enable = event; | ||||
csa.callback = cbfunc; | csa.callback = cbfunc; | ||||
csa.callback_arg = cbarg; | csa.callback_arg = cbarg; | ||||
xpt_action((union ccb *)&csa); | xpt_action((union ccb *)&csa); | ||||
status = csa.ccb_h.status; | status = csa.ccb_h.status; | ||||
CAM_DEBUG(csa.ccb_h.path, CAM_DEBUG_TRACE, | CAM_DEBUG(csa.ccb_h.path, CAM_DEBUG_TRACE, | ||||
▲ Show 20 Lines • Show All 367 Lines • Show Last 20 Lines |
this is a bug, but we dump the path into into this ccb, and then dump the path into it, then setup things, which is a pattern not otherwise done.