cam_xpt.c (236605) | cam_xpt.c (236712) |
---|---|
1/*- 2 * Implementation of the Common Access Method Transport (XPT) layer. 3 * 4 * Copyright (c) 1997, 1998, 1999 Justin T. Gibbs. 5 * Copyright (c) 1997, 1998, 1999 Kenneth D. Merry. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> | 1/*- 2 * Implementation of the Common Access Method Transport (XPT) layer. 3 * 4 * Copyright (c) 1997, 1998, 1999 Justin T. Gibbs. 5 * Copyright (c) 1997, 1998, 1999 Kenneth D. Merry. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 14 unchanged lines hidden (view full) --- 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 */ 29 30#include <sys/cdefs.h> |
31__FBSDID("$FreeBSD: head/sys/cam/cam_xpt.c 236605 2012-06-05 10:23:41Z mav $"); | 31__FBSDID("$FreeBSD: head/sys/cam/cam_xpt.c 236712 2012-06-07 10:05:51Z mav $"); |
32 33#include <sys/param.h> 34#include <sys/bus.h> 35#include <sys/systm.h> 36#include <sys/types.h> 37#include <sys/malloc.h> 38#include <sys/kernel.h> 39#include <sys/time.h> --- 143 unchanged lines hidden (view full) --- 183 .d_flags = 0, 184 .d_open = xptopen, 185 .d_close = xptclose, 186 .d_ioctl = xptioctl, 187 .d_name = "xpt", 188}; 189 190/* Storage for debugging datastructures */ | 32 33#include <sys/param.h> 34#include <sys/bus.h> 35#include <sys/systm.h> 36#include <sys/types.h> 37#include <sys/malloc.h> 38#include <sys/kernel.h> 39#include <sys/time.h> --- 143 unchanged lines hidden (view full) --- 183 .d_flags = 0, 184 .d_open = xptopen, 185 .d_close = xptclose, 186 .d_ioctl = xptioctl, 187 .d_name = "xpt", 188}; 189 190/* Storage for debugging datastructures */ |
191#ifdef CAMDEBUG | |
192struct cam_path *cam_dpath; | 191struct cam_path *cam_dpath; |
193#ifdef CAM_DEBUG_FLAGS | |
194u_int32_t cam_dflags = CAM_DEBUG_FLAGS; | 192u_int32_t cam_dflags = CAM_DEBUG_FLAGS; |
195#else 196u_int32_t cam_dflags = CAM_DEBUG_NONE; 197#endif | |
198TUNABLE_INT("kern.cam.dflags", &cam_dflags); 199SYSCTL_UINT(_kern_cam, OID_AUTO, dflags, CTLFLAG_RW, | 193TUNABLE_INT("kern.cam.dflags", &cam_dflags); 194SYSCTL_UINT(_kern_cam, OID_AUTO, dflags, CTLFLAG_RW, |
200 &cam_dflags, 0, "Cam Debug Flags"); 201u_int32_t cam_debug_delay; | 195 &cam_dflags, 0, "Enabled debug flags"); 196u_int32_t cam_debug_delay = CAM_DEBUG_DELAY; |
202TUNABLE_INT("kern.cam.debug_delay", &cam_debug_delay); 203SYSCTL_UINT(_kern_cam, OID_AUTO, debug_delay, CTLFLAG_RW, | 197TUNABLE_INT("kern.cam.debug_delay", &cam_debug_delay); 198SYSCTL_UINT(_kern_cam, OID_AUTO, debug_delay, CTLFLAG_RW, |
204 &cam_debug_delay, 0, "Cam Debug Flags"); 205#endif | 199 &cam_debug_delay, 0, "Delay in us after each debug message"); |
206 207/* Our boot-time initialization hook */ 208static int cam_module_event_handler(module_t, int /*modeventtype_t*/, void *); 209 210static moduledata_t cam_moduledata = { 211 "cam", 212 cam_module_event_handler, 213 NULL --- 2253 unchanged lines hidden (view full) --- 2467 if (CAM_PRIORITY_TO_RL(start_ccb->ccb_h.pinfo.priority) == 0) 2468 start_ccb->ccb_h.pinfo.priority += CAM_PRIORITY_NORMAL - 1; 2469 (*(start_ccb->ccb_h.path->bus->xport->action))(start_ccb); 2470} 2471 2472void 2473xpt_action_default(union ccb *start_ccb) 2474{ | 200 201/* Our boot-time initialization hook */ 202static int cam_module_event_handler(module_t, int /*modeventtype_t*/, void *); 203 204static moduledata_t cam_moduledata = { 205 "cam", 206 cam_module_event_handler, 207 NULL --- 2253 unchanged lines hidden (view full) --- 2461 if (CAM_PRIORITY_TO_RL(start_ccb->ccb_h.pinfo.priority) == 0) 2462 start_ccb->ccb_h.pinfo.priority += CAM_PRIORITY_NORMAL - 1; 2463 (*(start_ccb->ccb_h.path->bus->xport->action))(start_ccb); 2464} 2465 2466void 2467xpt_action_default(union ccb *start_ccb) 2468{ |
2475#ifdef CAMDEBUG | |
2476 char cdb_str[(SCSI_MAX_CDBLEN * 3) + 1]; | 2469 char cdb_str[(SCSI_MAX_CDBLEN * 3) + 1]; |
2477#endif | |
2478 struct cam_path *path; 2479 2480 path = start_ccb->ccb_h.path; 2481 CAM_DEBUG(path, CAM_DEBUG_TRACE, ("xpt_action_default\n")); 2482 2483 switch (start_ccb->ccb_h.func_code) { 2484 case XPT_SCSI_IO: 2485 { --- 489 unchanged lines hidden (view full) --- 2975 crs->release_timeout : 0, 2976 /*count*/1, /*run_queue*/TRUE); 2977 } 2978 start_ccb->crs.qfrozen_cnt = dev->ccbq.queue.qfrozen_cnt[0]; 2979 start_ccb->ccb_h.status = CAM_REQ_CMP; 2980 break; 2981 } 2982 case XPT_DEBUG: { | 2470 struct cam_path *path; 2471 2472 path = start_ccb->ccb_h.path; 2473 CAM_DEBUG(path, CAM_DEBUG_TRACE, ("xpt_action_default\n")); 2474 2475 switch (start_ccb->ccb_h.func_code) { 2476 case XPT_SCSI_IO: 2477 { --- 489 unchanged lines hidden (view full) --- 2967 crs->release_timeout : 0, 2968 /*count*/1, /*run_queue*/TRUE); 2969 } 2970 start_ccb->crs.qfrozen_cnt = dev->ccbq.queue.qfrozen_cnt[0]; 2971 start_ccb->ccb_h.status = CAM_REQ_CMP; 2972 break; 2973 } 2974 case XPT_DEBUG: { |
2983#ifdef CAMDEBUG 2984#ifdef CAM_DEBUG_DELAY 2985 cam_debug_delay = CAM_DEBUG_DELAY; 2986#endif | 2975 /* Check that all request bits are supported. */ 2976 if (start_ccb->cdbg.flags & ~CAM_DEBUG_COMPILE) { 2977 start_ccb->ccb_h.status = CAM_FUNC_NOTAVAIL; 2978 break; 2979 } 2980 |
2987 cam_dflags = start_ccb->cdbg.flags; 2988 if (cam_dpath != NULL) { 2989 xpt_free_path(cam_dpath); 2990 cam_dpath = NULL; 2991 } | 2981 cam_dflags = start_ccb->cdbg.flags; 2982 if (cam_dpath != NULL) { 2983 xpt_free_path(cam_dpath); 2984 cam_dpath = NULL; 2985 } |
2992 | |
2993 if (cam_dflags != CAM_DEBUG_NONE) { 2994 if (xpt_create_path(&cam_dpath, xpt_periph, 2995 start_ccb->ccb_h.path_id, 2996 start_ccb->ccb_h.target_id, 2997 start_ccb->ccb_h.target_lun) != 2998 CAM_REQ_CMP) { 2999 start_ccb->ccb_h.status = CAM_RESRC_UNAVAIL; 3000 cam_dflags = CAM_DEBUG_NONE; 3001 } else { 3002 start_ccb->ccb_h.status = CAM_REQ_CMP; 3003 xpt_print(cam_dpath, "debugging flags now %x\n", 3004 cam_dflags); 3005 } 3006 } else { 3007 cam_dpath = NULL; 3008 start_ccb->ccb_h.status = CAM_REQ_CMP; 3009 } | 2986 if (cam_dflags != CAM_DEBUG_NONE) { 2987 if (xpt_create_path(&cam_dpath, xpt_periph, 2988 start_ccb->ccb_h.path_id, 2989 start_ccb->ccb_h.target_id, 2990 start_ccb->ccb_h.target_lun) != 2991 CAM_REQ_CMP) { 2992 start_ccb->ccb_h.status = CAM_RESRC_UNAVAIL; 2993 cam_dflags = CAM_DEBUG_NONE; 2994 } else { 2995 start_ccb->ccb_h.status = CAM_REQ_CMP; 2996 xpt_print(cam_dpath, "debugging flags now %x\n", 2997 cam_dflags); 2998 } 2999 } else { 3000 cam_dpath = NULL; 3001 start_ccb->ccb_h.status = CAM_REQ_CMP; 3002 } |
3010#else /* !CAMDEBUG */ 3011 start_ccb->ccb_h.status = CAM_FUNC_NOTAVAIL; 3012#endif /* CAMDEBUG */ | |
3013 break; 3014 } 3015 case XPT_FREEZE_QUEUE: 3016 { 3017 struct ccb_relsim *crs = &start_ccb->crs; 3018 3019 xpt_freeze_devq_rl(path, /*runlevel*/ 3020 (crs->release_flags & RELSIM_RELEASE_RUNLEVEL) ? --- 1734 unchanged lines hidden (view full) --- 4755 4756static void 4757xpt_config(void *arg) 4758{ 4759 /* 4760 * Now that interrupts are enabled, go find our devices 4761 */ 4762 | 3003 break; 3004 } 3005 case XPT_FREEZE_QUEUE: 3006 { 3007 struct ccb_relsim *crs = &start_ccb->crs; 3008 3009 xpt_freeze_devq_rl(path, /*runlevel*/ 3010 (crs->release_flags & RELSIM_RELEASE_RUNLEVEL) ? --- 1734 unchanged lines hidden (view full) --- 4745 4746static void 4747xpt_config(void *arg) 4748{ 4749 /* 4750 * Now that interrupts are enabled, go find our devices 4751 */ 4752 |
4763#ifdef CAMDEBUG 4764 /* Setup debugging flags and path */ 4765#ifdef CAM_DEBUG_BUS | 4753 /* Setup debugging path */ |
4766 if (cam_dflags != CAM_DEBUG_NONE) { 4767 /* 4768 * Locking is specifically omitted here. No SIMs have 4769 * registered yet, so xpt_create_path will only be searching 4770 * empty lists of targets and devices. 4771 */ 4772 if (xpt_create_path(&cam_dpath, xpt_periph, 4773 CAM_DEBUG_BUS, CAM_DEBUG_TARGET, 4774 CAM_DEBUG_LUN) != CAM_REQ_CMP) { 4775 printf("xpt_config: xpt_create_path() failed for debug" 4776 " target %d:%d:%d, debugging disabled\n", 4777 CAM_DEBUG_BUS, CAM_DEBUG_TARGET, CAM_DEBUG_LUN); 4778 cam_dflags = CAM_DEBUG_NONE; 4779 } 4780 } else 4781 cam_dpath = NULL; | 4754 if (cam_dflags != CAM_DEBUG_NONE) { 4755 /* 4756 * Locking is specifically omitted here. No SIMs have 4757 * registered yet, so xpt_create_path will only be searching 4758 * empty lists of targets and devices. 4759 */ 4760 if (xpt_create_path(&cam_dpath, xpt_periph, 4761 CAM_DEBUG_BUS, CAM_DEBUG_TARGET, 4762 CAM_DEBUG_LUN) != CAM_REQ_CMP) { 4763 printf("xpt_config: xpt_create_path() failed for debug" 4764 " target %d:%d:%d, debugging disabled\n", 4765 CAM_DEBUG_BUS, CAM_DEBUG_TARGET, CAM_DEBUG_LUN); 4766 cam_dflags = CAM_DEBUG_NONE; 4767 } 4768 } else 4769 cam_dpath = NULL; |
4782#else /* !CAM_DEBUG_BUS */ 4783 cam_dpath = NULL; 4784#endif /* CAM_DEBUG_BUS */ 4785#endif /* CAMDEBUG */ | |
4786 4787 periphdriver_init(1); 4788 xpt_hold_boot(); 4789 callout_init(&xsoftc.boot_callout, 1); 4790 callout_reset(&xsoftc.boot_callout, hz * xsoftc.boot_delay / 1000, 4791 xpt_boot_delay, NULL); 4792 /* Fire up rescan thread. */ 4793 if (kproc_create(xpt_scanner_thread, NULL, NULL, 0, 0, "xpt_thrd")) { --- 311 unchanged lines hidden --- | 4770 4771 periphdriver_init(1); 4772 xpt_hold_boot(); 4773 callout_init(&xsoftc.boot_callout, 1); 4774 callout_reset(&xsoftc.boot_callout, hz * xsoftc.boot_delay / 1000, 4775 xpt_boot_delay, NULL); 4776 /* Fire up rescan thread. */ 4777 if (kproc_create(xpt_scanner_thread, NULL, NULL, 0, 0, "xpt_thrd")) { --- 311 unchanged lines hidden --- |