ctl_frontend_internal.c (237726) | ctl_frontend_internal.c (249009) |
---|---|
1/*- 2 * Copyright (c) 2004, 2005 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 --- 34 unchanged lines hidden (view full) --- 43 * To be able to fulfill the role of a full initiator layer, it would need 44 * a whole lot more functionality. 45 * 46 * Author: Ken Merry <ken@FreeBSD.org> 47 * 48 */ 49 50#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2004, 2005 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 --- 34 unchanged lines hidden (view full) --- 43 * To be able to fulfill the role of a full initiator layer, it would need 44 * a whole lot more functionality. 45 * 46 * Author: Ken Merry <ken@FreeBSD.org> 47 * 48 */ 49 50#include <sys/cdefs.h> |
51__FBSDID("$FreeBSD: head/sys/cam/ctl/ctl_frontend_internal.c 237726 2012-06-28 19:39:30Z ken $"); | 51__FBSDID("$FreeBSD: head/sys/cam/ctl/ctl_frontend_internal.c 249009 2013-04-02 09:42:42Z trasz $"); |
52 53#include <sys/param.h> 54#include <sys/systm.h> 55#include <sys/kernel.h> 56#include <sys/types.h> 57#include <sys/malloc.h> | 52 53#include <sys/param.h> 54#include <sys/systm.h> 55#include <sys/kernel.h> 56#include <sys/types.h> 57#include <sys/malloc.h> |
58#include <sys/module.h> |
|
58#include <sys/lock.h> 59#include <sys/mutex.h> 60#include <sys/condvar.h> 61#include <sys/queue.h> 62#include <sys/sbuf.h> 63#include <sys/sysctl.h> 64#include <cam/scsi/scsi_all.h> 65#include <cam/scsi/scsi_da.h> --- 118 unchanged lines hidden (view full) --- 184 struct ctl_mem_pool metatask_pool; 185}; 186 187MALLOC_DEFINE(M_CTL_CFI, "ctlcfi", "CTL CFI"); 188 189static struct cfi_softc fetd_internal_softc; 190extern int ctl_disable; 191 | 59#include <sys/lock.h> 60#include <sys/mutex.h> 61#include <sys/condvar.h> 62#include <sys/queue.h> 63#include <sys/sbuf.h> 64#include <sys/sysctl.h> 65#include <cam/scsi/scsi_all.h> 66#include <cam/scsi/scsi_da.h> --- 118 unchanged lines hidden (view full) --- 185 struct ctl_mem_pool metatask_pool; 186}; 187 188MALLOC_DEFINE(M_CTL_CFI, "ctlcfi", "CTL CFI"); 189 190static struct cfi_softc fetd_internal_softc; 191extern int ctl_disable; 192 |
192void cfi_init(void); | 193int cfi_init(void); |
193void cfi_shutdown(void) __unused; 194static void cfi_online(void *arg); 195static void cfi_offline(void *arg); 196static int cfi_targ_enable(void *arg, struct ctl_id targ_id); 197static int cfi_targ_disable(void *arg, struct ctl_id targ_id); 198static int cfi_lun_enable(void *arg, struct ctl_id target_id, int lun_id); 199static int cfi_lun_disable(void *arg, struct ctl_id target_id, int lun_id); 200static void cfi_datamove(union ctl_io *io); --- 11 unchanged lines hidden (view full) --- 212static void cfi_metatask_done(struct cfi_softc *softc, 213 struct cfi_metatask *metatask); 214static void cfi_metatask_bbr_errorparse(struct cfi_metatask *metatask, 215 union ctl_io *io); 216static void cfi_metatask_io_done(union ctl_io *io); 217static void cfi_err_recovery_done(union ctl_io *io); 218static void cfi_lun_io_done(union ctl_io *io); 219 | 194void cfi_shutdown(void) __unused; 195static void cfi_online(void *arg); 196static void cfi_offline(void *arg); 197static int cfi_targ_enable(void *arg, struct ctl_id targ_id); 198static int cfi_targ_disable(void *arg, struct ctl_id targ_id); 199static int cfi_lun_enable(void *arg, struct ctl_id target_id, int lun_id); 200static int cfi_lun_disable(void *arg, struct ctl_id target_id, int lun_id); 201static void cfi_datamove(union ctl_io *io); --- 11 unchanged lines hidden (view full) --- 213static void cfi_metatask_done(struct cfi_softc *softc, 214 struct cfi_metatask *metatask); 215static void cfi_metatask_bbr_errorparse(struct cfi_metatask *metatask, 216 union ctl_io *io); 217static void cfi_metatask_io_done(union ctl_io *io); 218static void cfi_err_recovery_done(union ctl_io *io); 219static void cfi_lun_io_done(union ctl_io *io); 220 |
220SYSINIT(cfi_init, SI_SUB_CONFIGURE, SI_ORDER_FOURTH, cfi_init, NULL); | 221static int cfi_module_event_handler(module_t, int /*modeventtype_t*/, void *); |
221 | 222 |
222void | 223static moduledata_t cfi_moduledata = { 224 "ctlcfi", 225 cfi_module_event_handler, 226 NULL 227}; 228 229DECLARE_MODULE(ctlcfi, cfi_moduledata, SI_SUB_CONFIGURE, SI_ORDER_FOURTH); 230MODULE_VERSION(ctlcfi, 1); 231MODULE_DEPEND(ctlcfi, ctl, 1, 1, 1); 232 233int |
223cfi_init(void) 224{ 225 struct cfi_softc *softc; 226 struct ctl_frontend *fe; 227 int retval; 228 229 softc = &fetd_internal_softc; 230 231 fe = &softc->fe; 232 233 retval = 0; 234 235 /* If we're disabled, don't initialize */ 236 if (ctl_disable != 0) | 234cfi_init(void) 235{ 236 struct cfi_softc *softc; 237 struct ctl_frontend *fe; 238 int retval; 239 240 softc = &fetd_internal_softc; 241 242 fe = &softc->fe; 243 244 retval = 0; 245 246 /* If we're disabled, don't initialize */ 247 if (ctl_disable != 0) |
237 return; | 248 return (0); |
238 239 if (sizeof(struct cfi_lun_io) > CTL_PORT_PRIV_SIZE) { 240 printf("%s: size of struct cfi_lun_io %zd > " 241 "CTL_PORT_PRIV_SIZE %d\n", __func__, 242 sizeof(struct cfi_lun_io), 243 CTL_PORT_PRIV_SIZE); 244 } 245 memset(softc, 0, sizeof(softc)); --- 41 unchanged lines hidden (view full) --- 287 CTL_MEM_POOL_PERM_GROW, /*grow_inc*/ 3, 288 /*initial_pool_size*/ 10) != 0) { 289 printf("%s: can't initialize metatask memory pool\n", __func__); 290 retval = 2; 291 goto bailout_error; 292 } 293bailout: 294 | 249 250 if (sizeof(struct cfi_lun_io) > CTL_PORT_PRIV_SIZE) { 251 printf("%s: size of struct cfi_lun_io %zd > " 252 "CTL_PORT_PRIV_SIZE %d\n", __func__, 253 sizeof(struct cfi_lun_io), 254 CTL_PORT_PRIV_SIZE); 255 } 256 memset(softc, 0, sizeof(softc)); --- 41 unchanged lines hidden (view full) --- 298 CTL_MEM_POOL_PERM_GROW, /*grow_inc*/ 3, 299 /*initial_pool_size*/ 10) != 0) { 300 printf("%s: can't initialize metatask memory pool\n", __func__); 301 retval = 2; 302 goto bailout_error; 303 } 304bailout: 305 |
295 return; | 306 return (0); |
296 297bailout_error: 298 299 switch (retval) { 300 case 3: 301 ctl_shrink_mem_pool(&softc->metatask_pool); 302 /* FALLTHROUGH */ 303 case 2: 304 ctl_shrink_mem_pool(&softc->lun_pool); 305 /* FALLTHROUGH */ 306 case 1: 307 ctl_frontend_deregister(fe); 308 break; 309 default: 310 break; 311 } | 307 308bailout_error: 309 310 switch (retval) { 311 case 3: 312 ctl_shrink_mem_pool(&softc->metatask_pool); 313 /* FALLTHROUGH */ 314 case 2: 315 ctl_shrink_mem_pool(&softc->lun_pool); 316 /* FALLTHROUGH */ 317 case 1: 318 ctl_frontend_deregister(fe); 319 break; 320 default: 321 break; 322 } |
323 324 return (ENOMEM); |
|
312} 313 314void 315cfi_shutdown(void) 316{ 317 struct cfi_softc *softc; 318 319 softc = &fetd_internal_softc; --- 6 unchanged lines hidden (view full) --- 326 327 if (ctl_shrink_mem_pool(&softc->lun_pool) != 0) 328 printf("%s: error shrinking LUN pool\n", __func__); 329 330 if (ctl_shrink_mem_pool(&softc->metatask_pool) != 0) 331 printf("%s: error shrinking LUN pool\n", __func__); 332} 333 | 325} 326 327void 328cfi_shutdown(void) 329{ 330 struct cfi_softc *softc; 331 332 softc = &fetd_internal_softc; --- 6 unchanged lines hidden (view full) --- 339 340 if (ctl_shrink_mem_pool(&softc->lun_pool) != 0) 341 printf("%s: error shrinking LUN pool\n", __func__); 342 343 if (ctl_shrink_mem_pool(&softc->metatask_pool) != 0) 344 printf("%s: error shrinking LUN pool\n", __func__); 345} 346 |
347static int 348cfi_module_event_handler(module_t mod, int what, void *arg) 349{ 350 351 switch (what) { 352 case MOD_LOAD: 353 return (cfi_init()); 354 case MOD_UNLOAD: 355 return (EBUSY); 356 default: 357 return (EOPNOTSUPP); 358 } 359} 360 |
|
334static void 335cfi_online(void *arg) 336{ 337 struct cfi_softc *softc; 338 struct cfi_lun *lun; 339 340 softc = (struct cfi_softc *)arg; 341 --- 1447 unchanged lines hidden --- | 361static void 362cfi_online(void *arg) 363{ 364 struct cfi_softc *softc; 365 struct cfi_lun *lun; 366 367 softc = (struct cfi_softc *)arg; 368 --- 1447 unchanged lines hidden --- |