ctl_frontend_cam_sim.c (246713) | ctl_frontend_cam_sim.c (249009) |
---|---|
1/*- 2 * Copyright (c) 2009 Silicon Graphics International Corp. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 23 unchanged lines hidden (view full) --- 32/* 33 * CTL frontend to CAM SIM interface. This allows access to CTL LUNs via 34 * the da(4) and pass(4) drivers from inside the system. 35 * 36 * Author: Ken Merry <ken@FreeBSD.org> 37 */ 38 39#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2009 Silicon Graphics International Corp. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 23 unchanged lines hidden (view full) --- 32/* 33 * CTL frontend to CAM SIM interface. This allows access to CTL LUNs via 34 * the da(4) and pass(4) drivers from inside the system. 35 * 36 * Author: Ken Merry <ken@FreeBSD.org> 37 */ 38 39#include <sys/cdefs.h> |
40__FBSDID("$FreeBSD: head/sys/cam/ctl/ctl_frontend_cam_sim.c 246713 2013-02-12 16:57:20Z kib $"); | 40__FBSDID("$FreeBSD: head/sys/cam/ctl/ctl_frontend_cam_sim.c 249009 2013-04-02 09:42:42Z trasz $"); |
41 42#include <sys/param.h> 43#include <sys/systm.h> 44#include <sys/kernel.h> 45#include <sys/types.h> 46#include <sys/malloc.h> 47#include <sys/lock.h> 48#include <sys/mutex.h> --- 67 unchanged lines hidden (view full) --- 116/* 117 * This is primarly intended to allow for error injection to test the CAM 118 * sense data and sense residual handling code. This sets the maximum 119 * amount of SCSI sense data that we will report to CAM. 120 */ 121static int cfcs_max_sense = sizeof(struct scsi_sense_data); 122extern int ctl_disable; 123 | 41 42#include <sys/param.h> 43#include <sys/systm.h> 44#include <sys/kernel.h> 45#include <sys/types.h> 46#include <sys/malloc.h> 47#include <sys/lock.h> 48#include <sys/mutex.h> --- 67 unchanged lines hidden (view full) --- 116/* 117 * This is primarly intended to allow for error injection to test the CAM 118 * sense data and sense residual handling code. This sets the maximum 119 * amount of SCSI sense data that we will report to CAM. 120 */ 121static int cfcs_max_sense = sizeof(struct scsi_sense_data); 122extern int ctl_disable; 123 |
124SYSINIT(cfcs_init, SI_SUB_CONFIGURE, SI_ORDER_FOURTH, cfcs_init, NULL); | |
125SYSCTL_NODE(_kern_cam, OID_AUTO, ctl2cam, CTLFLAG_RD, 0, 126 "CAM Target Layer SIM frontend"); 127SYSCTL_INT(_kern_cam_ctl2cam, OID_AUTO, max_sense, CTLFLAG_RW, 128 &cfcs_max_sense, 0, "Maximum sense data size"); 129 | 124SYSCTL_NODE(_kern_cam, OID_AUTO, ctl2cam, CTLFLAG_RD, 0, 125 "CAM Target Layer SIM frontend"); 126SYSCTL_INT(_kern_cam_ctl2cam, OID_AUTO, max_sense, CTLFLAG_RW, 127 &cfcs_max_sense, 0, "Maximum sense data size"); 128 |
129static int cfcs_module_event_handler(module_t, int /*modeventtype_t*/, void *); |
|
130 | 130 |
131static moduledata_t cfcs_moduledata = { 132 "ctlcfcs", 133 cfcs_module_event_handler, 134 NULL 135}; 136 137DECLARE_MODULE(ctlcfcs, cfcs_moduledata, SI_SUB_CONFIGURE, SI_ORDER_FOURTH); 138MODULE_VERSION(ctlcfcs, 1); 139MODULE_DEPEND(ctlcfi, ctl, 1, 1, 1); 140MODULE_DEPEND(ctlcfi, cam, 1, 1, 1); 141 |
|
131int 132cfcs_init(void) 133{ 134 struct cfcs_softc *softc; 135 struct ccb_setasync csa; 136 struct ctl_frontend *fe; 137#ifdef NEEDTOPORT 138 char wwnn[8]; --- 32 unchanged lines hidden (view full) --- 171 fe->max_targets = 1; 172 fe->max_target_id = 15; 173 174 retval = ctl_frontend_register(fe, /*master_SC*/ 1); 175 if (retval != 0) { 176 printf("%s: ctl_frontend_register() failed with error %d!\n", 177 __func__, retval); 178 mtx_destroy(&softc->lock); | 142int 143cfcs_init(void) 144{ 145 struct cfcs_softc *softc; 146 struct ccb_setasync csa; 147 struct ctl_frontend *fe; 148#ifdef NEEDTOPORT 149 char wwnn[8]; --- 32 unchanged lines hidden (view full) --- 182 fe->max_targets = 1; 183 fe->max_target_id = 15; 184 185 retval = ctl_frontend_register(fe, /*master_SC*/ 1); 186 if (retval != 0) { 187 printf("%s: ctl_frontend_register() failed with error %d!\n", 188 __func__, retval); 189 mtx_destroy(&softc->lock); |
179 return (1); | 190 return (retval); |
180 } 181 182 /* 183 * Get the WWNN out of the database, and create a WWPN as well. 184 */ 185#ifdef NEEDTOPORT 186 ddb_GetWWNN((char *)wwnn); 187 softc->wwnn = be64dec(wwnn); --- 43 unchanged lines hidden (view full) --- 231 } 232 233 if (xpt_create_path(&softc->path, /*periph*/NULL, 234 cam_sim_path(softc->sim), 235 CAM_TARGET_WILDCARD, 236 CAM_LUN_WILDCARD) != CAM_REQ_CMP) { 237 printf("%s: error creating path\n", __func__); 238 xpt_bus_deregister(cam_sim_path(softc->sim)); | 191 } 192 193 /* 194 * Get the WWNN out of the database, and create a WWPN as well. 195 */ 196#ifdef NEEDTOPORT 197 ddb_GetWWNN((char *)wwnn); 198 softc->wwnn = be64dec(wwnn); --- 43 unchanged lines hidden (view full) --- 242 } 243 244 if (xpt_create_path(&softc->path, /*periph*/NULL, 245 cam_sim_path(softc->sim), 246 CAM_TARGET_WILDCARD, 247 CAM_LUN_WILDCARD) != CAM_REQ_CMP) { 248 printf("%s: error creating path\n", __func__); 249 xpt_bus_deregister(cam_sim_path(softc->sim)); |
239 retval = 1; | 250 retval = EINVAL; |
240 goto bailout; 241 } 242 243 xpt_setup_ccb(&csa.ccb_h, softc->path, CAM_PRIORITY_NONE); 244 csa.ccb_h.func_code = XPT_SASYNC_CB; 245 csa.event_enable = AC_LOST_DEVICE; 246 csa.callback = cfcs_async; 247 csa.callback_arg = softc->sim; --- 21 unchanged lines hidden (view full) --- 269} 270 271void 272cfcs_shutdown(void) 273{ 274 275} 276 | 251 goto bailout; 252 } 253 254 xpt_setup_ccb(&csa.ccb_h, softc->path, CAM_PRIORITY_NONE); 255 csa.ccb_h.func_code = XPT_SASYNC_CB; 256 csa.event_enable = AC_LOST_DEVICE; 257 csa.callback = cfcs_async; 258 csa.callback_arg = softc->sim; --- 21 unchanged lines hidden (view full) --- 280} 281 282void 283cfcs_shutdown(void) 284{ 285 286} 287 |
288static int 289cfcs_module_event_handler(module_t mod, int what, void *arg) 290{ 291 292 switch (what) { 293 case MOD_LOAD: 294 return (cfcs_init()); 295 case MOD_UNLOAD: 296 return (EBUSY); 297 default: 298 return (EOPNOTSUPP); 299 } 300} 301 |
|
277static void 278cfcs_onoffline(void *arg, int online) 279{ 280 struct cfcs_softc *softc; 281 union ccb *ccb; 282 283 softc = (struct cfcs_softc *)arg; 284 --- 571 unchanged lines hidden --- | 302static void 303cfcs_onoffline(void *arg, int online) 304{ 305 struct cfcs_softc *softc; 306 union ccb *ccb; 307 308 softc = (struct cfcs_softc *)arg; 309 --- 571 unchanged lines hidden --- |