scsa2usb.c revision 96603521bb3ca55315c6b6c579f1d4a5559832e2
906N/A * The contents of this file are subject to the terms of the 906N/A * Common Development and Distribution License, Version 1.0 only 906N/A * (the "License"). You may not use this file except in compliance 906N/A * See the License for the specific language governing permissions 906N/A * and limitations under the License. 906N/A * When distributing Covered Code, include this CDDL HEADER in each 906N/A * If applicable, add the following below this CDDL HEADER, with the 906N/A * fields enclosed by brackets "[]" replaced with your own identifying 906N/A * information: Portions Copyright [yyyy] [name of copyright owner] 906N/A * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 906N/A * Use is subject to license terms. 906N/A#
pragma ident "%Z%%M% %I% %E% SMI" 906N/A * scsa2usb bridge nexus driver: 906N/A * This driver supports the following wire transports: 906N/A * It handles the following command sets: 906N/A * b. ATAPI command set (subset of SCSI command set) 906N/A * For details on USB Mass Storage Class overview: 906N/A/* override property handling */ 906N/A/* PANIC callback handling */ 906N/A/* functions for command and transport support */ 906N/A/* auto request sense handling */ 906N/A/* utility functions for any transport */ 906N/A/* external functions for Bulk only (BO) support */ 906N/A * Mass-Storage devices masquerade as "sd" disks. 906N/A * These devices may not support all SCSI CDBs in their 906N/A * entirety due to their hardware implementation limitations. 906N/A * As such, following is a list of some of the black-listed 906N/A * devices w/ the attributes that they do not support. 906N/A /* Iomega Zip100 drive (prototype) with flaky bridge */ 906N/A /* Iomega Zip100 drive (newer model) with flaky bridge */ 906N/A /* Iomega Zip100 drive (newer model) with flaky bridge */ 906N/A /* Iomega Zip250 drive */ 906N/A /* Iomega Clik! drive */ 906N/A /* SMSC floppy Device - and its clones */ 906N/A /* Hagiwara SmartMedia Device */ 906N/A /* Hagiwara CompactFlash Device */ 906N/A /* Hagiwara new SM Device */ 906N/A /* Hagiwara new CF Device */ 906N/A /* Mitsumi CD-RW Device(s) */ 906N/A /* dumb flash devices */ 906N/A /* SimpleTech UCF-100 CF Device */ 906N/A * Attribute values can be overridden by values 906N/A * These arrays define possible user input values. 906N/A/* for debug messages */ 906N/A * Some devices have problems with big bulk transfers, 906N/A * transfers >= 128kbytes hang the device. This tunable allows to 906N/A * limit the maximum bulk transfers rate. 906N/A * Test BO 13 cases. (See USB Mass Storage Class - Bulk Only Transport). 906N/A * We are not covering test cases 1, 6, and 12 as these are the "good" 906N/A * test cases and are tested as part of the normal drive access operations. 906N/A * NOTE: This is for testing only. It will be replaced by a uscsi test. 906N/A#
endif /* SCSA2USB_BULK_ONLY_TEST */ 906N/A/* modloading support */ 906N/A "SCSA to USB Driver %I%",
/* Name of the module. */ 906N/A * Get minor number, soft state structure etc. 906N/A * Allocate a "scsi_hba_tran" - call scsi_hba_tran_alloc() 906N/A * Invoke scsi_hba_attach_setup 906N/A * Get the serialno of the device 906N/A * Create disk child(ren) 906N/A * Create and register panic callback 906N/A * NOTE: Replaced CBW_DIR_OUT with USB_EP_DIR_OUT and CBW_DIR_IN with 906N/A * USB_EP_DIR_IN as they are the same #defines. 906N/A "scsa2usb_attach: failed");
906N/A /* Allocate softc information */ 906N/A /* get soft state space and initialize */ 906N/A "usb_client_attach failed");
906N/A "usb_get_dev_data failed");
906N/A /* initialize the mutex with the right cookie */ 906N/A /* save the default pipe handle */ 906N/A /* basic inits are done */ 906N/A "curr_cfg=%d, curr_if=%d",
906N/A /* now find out relevant descriptors for alternate 0 */ 906N/A /* All CB/CBI, BO devices should have this value set */ 906N/A "invalid interface class (0x%x)",
906N/A /* figure out the endpoints and copy the descr */ 906N/A * check here for protocol and subclass supported by this driver 906N/A * first check if conf file has override values 906N/A * Note: override values are not used if supplied values are legal 906N/A "protocol=0x%x override=0x%x subclass=0x%x override=0x%x",
906N/A "overriding protocol %x",
906N/A "unsupported protocol = %x",
906N/A "overriding subclass %x",
906N/A "unsupported subclass = %x",
906N/A /* check that we have the right set of endpoint descriptors */ 906N/A "scsa2usb%d doesn't support minimum required endpoints",
906N/A * Validate the black-listed attributes 906N/A /* Print the serial number from the registration data */ 906N/A * Allocate a SCSA transport structure 906N/A * initialize transport structure 906N/A * register with SCSA as an HBA 906N/A * Note that the dma attributes are from parent nexus 906N/A "scsi_hba_attach_setup failed");
906N/A /* create minor node */ 906N/A "scsi_attach: ddi_create_minor_node failed");
906N/A /* open pipes and set scsa2usb_flags */ 906N/A "error opening pipes");
906N/A /* set default block size. updated after read cap cmd */ 906N/A /* initialize PANIC callback */ 906N/A /* finally we are all done 'initializing' the device */ 906N/A /* enable PM, mutex needs to be held across this */ 906N/A "error cb registering");
906N/A /* free the dev_data tree, we no longer need it */ 906N/A /* log the conf file override string if there is one */ 906N/A /* get a ugen handle */ 906N/A "usb_ugen_attach failed");
906N/A * detach or suspend driver instance 906N/A * (all ugen opens and pipe opens are by definition exclusive so it is OK 906N/A /* if this is the first ugen open, check on transport busy */ 906N/A * scsa2usb_ugen_close() 906N/A "scsa2usb_ugen_close: dev_t=0x%lx",
dev);
906N/A "scsa2usb_ugen_read: dev_t=0x%lx",
dev);
906N/A "scsa2usb_ugen_write: dev_t=0x%lx",
dev);
906N/A "scsa2usb_ugen_poll: dev_t=0x%lx",
dev);
906N/A * cleanup whatever attach has setup 906N/A /* wait till the work thread is done */ 906N/A * Disable the event callbacks first, after this point, event 906N/A * callbacks will never get called. Note we shouldn't hold 906N/A * mutex while unregistering events because there may be a 906N/A * competing event callback thread. Event callbacks are done 906N/A * with ndi mutex held and this can cause a potential deadlock. 906N/A * if a waitQ exists, get rid of it before destroying it 906N/A "disable remote wakeup failed " 906N/A /* remove the minor nodes */ 906N/A /* Cancel the registered panic callback */ 906N/A * some devices may be attached even though their subclass or 906N/A * protocol info is not according to spec. 906N/A * these can be determined by the 'subclass-protocol-override' 906N/A * property set in the conf file. 906N/A /* parse each string in the subclass-protocol-override property */ 906N/A * save a copy of the override string for possible 906N/A * inclusion in soft state later 906N/A * or if device should not be power managed 906N/A * if there'a a match, save the override string in soft state 906N/A "vid=0x%x pid=0x%x rev=0x%x subclass=0x%x " 906N/A "pmoff=%d not_removable=%d modesense=%d " 906N/A "reduced-cmd-support=%d",
906N/A * scsa2usb_parse_input_str: 906N/A * parse one conf file subclass-protocol-override string 906N/A * return vendor id, product id, revision, subclass, protocol 906N/A * function return is success or failure 906N/A /* parse all the input pairs in the string */ /* if input value is a 'don't care', skip to the next pair */ "reduced-cmd-support") == 0) {
* scsa2usb_override_error: * print an error message if conf file string is bad format "invalid %s in scsa2usb conf file entry",
input_field);
* scsa2usb_validate_attrs: * many devices have BO/CB/CBI protocol support issues. * individual erroneous attributes * NOTE: we look at only device at a time (at attach time) /* determine if this device is on the blacklist */ * Mitsumi's CD-RW drives subclass isn't UFI. * But they support UFI command-set (this code ensures that) * NOTE: This is a special case, and is being called out so. "scsa2usb attributes modified: 0x%x",
* check the number of luns but continue if the check fails, * create child nodes for each lun "scsa2usb_create_luns:");
/* Set n_luns to 1 by default (for floppies and other devices) */ * Check if there are any device out there which don't * support the GET_MAX_LUN command. If so, don't issue * control request to them. "get_max_lun cmd not supported");
* create disk child for each lun /* do an inquiry to get the dtype of this lun */ /* attach target & lun properties */ "ndi_prop_update_int target failed %d",
rval);
"ndi_prop_update_int lun failed %d",
rval);
"ndi_prop_update_string_array failed %d",
* add property "usb" so we always verify that it is our child "ndi_prop_create_boolean failed %d",
rval);
* scsa2usb gets called for all possible sd children. * we can only accept usb children * scsa2usb_panic_callb_init: * initialize PANIC callb and free allocated resources * In case the system panics, the sync command flushes * dirty FS pages or buffers. This would cause a hang * The reason for the failure is that we enter * polled mode (interrupts disabled) and HCD gets stuck * trying to execute bulk requests * The panic_callback registered below provides a warning * that a panic has occurred and from that point onwards, we * complete each request successfully and immediately. This * will fake successful syncing so at least the rest of the * filesystems complete syncing. * scsa2usb_panic_callb_fini: * cancel out PANIC callb and free allocated resources * This routine is called when there is a system panic. "scsa2usb_panic_callb: code=%d",
code);
* If we return error here, "sd" prints lots of error * messages and could retry the same pkt over and over again. * The sync recovery isn't "smooth" in that case. By faking * a success return, instead, we force sync to complete. * Do not print the "no sync" warning here. it will then be * displayed before we actually start syncing. Also we don't * replace this code with a call to scsa2usb_pkt_completion(). * NOTE: mutexes are disabled during panic. * determine if the device's state can be changed to SUSPENDED * close pipes if there is no activity "scsa2usb_cpr_suspend:");
* If the device is busy, we cannot suspend "scsa2usb_cpr_suspend: I/O active");
/* fall back to previous state */ "scsa2usb_cpr_suspend: Illegal dev state: %d",
"scsa2usb_cpr_resume: dip = 0x%p",
dip);
* scsa2usb_restore_device_state: * - raise the device's power "scsa2usb_restore_device_state:");
/* Check for the same device */ /* change the flags to active */ "Reinserted device is accessible again.");
* if the device had remote wakeup earlier, * scsa2usb_scsi_tgt_probe: * scsa functions are exported by means of the transport table * Issue a probe to get the inquiry data. "scsa2usb_scsi_tgt_probe:");
/* if device is disconnected (ie. pipes closed), fail immediately */ "scsa2usb_scsi_tgt_probe: scsi_device = 0x%p",
sd);
* fake the removable bit on all USB storage devices * scsa2usb_scsi_tgt_init: * check whether we created this child ourselves /* is this a child we created? */ "scsa2usb_scsi_tgt_init: new child %s%d",
* add property "usb" so we can always verify that it "ndi_prop_create_boolean failed");
* we don't store this dip in scsa2usb_lun_dip, there * might be multiple dips for the same device * scsa2usb_scsi_tgt_free: * bus enumeration entry points "scsa2usb_scsi_bus_config: op=%d",
op);
/* create children if necessary */ "scsa2usb_scsi_bus_unconfig: op=%d",
op);
* first offline and if offlining successful, then * If unconfig is successful and not part of modunload * daemon, attempt to remove children. "Disconnected device was busy, " "scsa2usb_scsi_bus_unconfig: rval=%d",
rval);
* scsa2usb_scsi_init_pkt: * Set up the scsi_pkt for transport. Also initialize * scsa2usb_cmd struct for the transport. * NOTE: We do not do any DMA setup here as USBA framework /* continue so caller will not hang or complain */ /* allocate a pkt, if none already allocated */ "scsa2usb: pkt != NULL");
"scsa2usb_scsi_init_pkt: mapped in 0x%p, addr=0x%p",
"scsa2usb_scsi_init_pkt: ap = 0x%p pkt: 0x%p\n\t" "bp = 0x%p cmdlen = %x stlen = 0x%x tlen = 0x%x flags = 0x%x",
* scsa2usb_scsi_destroy_pkt: * We are done with the packet. Get rid of it. "scsa2usb_scsi_destroy_pkt: pkt=0x%p",
pkt);
* For each command being issued, build up the CDB * and call scsi_transport to issue the command. This * function is based on the assumption that USB allows * a subset of SCSI commands. Other SCSI commands we fail. "scsa2usb_scsi_start:\n\t" "bp: 0x%p ap: 0x%p pkt: 0x%p flag: 0x%x time: 0x%x\n\tcdb0: 0x%x " "dev_state: 0x%x pkt_state: 0x%x flags: 0x%x pipe_state: 0x%x",
"pkt submitted with 0 timeout which may cause indefinite " * if we are in panic, we are in polled mode, so we can just * accept the request, drop it and return * if we fail this request, the rest of the file systems do not /* we cannot do polling, this should not happen */ /* is there a ugen open? */ "ugen access in progress (count=%d)",
/* just queue up the requests in the waitQ if below max */ "scsa2usb_scsi_start: limit (%d) exceeded",
/* fire up a thread to start executing the protocol */ "no work thread started");
* Issue SCSI abort command. This function is a NOP. "scsa2usb_scsi_abort: pkt = %p",
pkt);
/* if device is disconnected (ie. pipes closed), fail immediately */ /* flush waitQ if target and lun match */ * device reset may turn the device into a brick and bus reset * We return success, always. "scsa2usb_scsi_reset: ap = 0x%p, level = %d",
ap,
level);
"scsa2usb_scsi_getcap: invalid arg, " "cap = 0x%p whom = %d",
cap,
whom);
"scsa2usb_scsi_getcap: cap = %s",
cap);
/* if device is disconnected (ie. pipes closed), fail immediately */ /* unlabeled floppy, 18k per cylinder */ rval = ((
64 <<
16) |
32);
rval = ((
255 <<
16) |
63);
rval = ((
512 <<
16) |
256);
"scsa2usb_scsi_getcap: unsupported cap = %s",
cap);
"scsa2usb_scsi_getcap: cap = %s, returned = %d",
cap,
rval);
int rval = -
1;
/* default is cap undefined */ "scsa2usb_scsi_setcap: invalid arg");
/* if device is disconnected (ie. pipes closed), fail immediately */ "scsa2usb_scsi_setcap: ap = 0x%p value = 0x%x whom = 0x%x " /* supported but not settable */ "scsa2usb_scsi_setcap: unsupported cap = %s",
cap);
* scsa2usb - cmd and transport stuff * initialize some fields of the pkt and cmd "scsa2usb_prepare_pkt: pkt=0x%p cdb: 0x%x (%s)",
* scsa2usb_force_invalid_request "scsa2usb_force_invalid_request: pkt = 0x%p",
cmd->
cmd_pkt);
"%x %x %x %x %x %x %x %x %x %x " "%x %x %x %x %x %x %x %x %x %x",
p[0], p[
1], p[
2], p[
3], p[
4],
p[
5], p[
6], p[
7], p[
8], p[
9],
p[
10], p[
11], p[
12], p[
13], p[
14],
p[
15], p[
16], p[
17], p[
18], p[
19]);
* scsa2usb_cmd_transport: "scsa2usb_cmd_transport: pkt: 0x%p, cur_pkt = 0x%p",
/* check black-listed attrs first */ /* just accept the command */ /* check command set next */ * scsa2usb_check_bulkonly_blacklist_attrs: * validate "scsa2usb_blacklist_attrs" (see scsa2usb.h) * if blacklisted attrs match accept the request * attributes checked are:- * SCSA2USB_ATTRS_START_STOP "scsa2usb_check_bulkonly_blacklist_attrs: opcode = %s",
* decode and convert the packet * for most cmds, we can bcopy the cdb * these devices don't have mechanics that spin the * media up and down. So, it doesn't make much sense * Furthermore, Hagiwara devices do not handle these * cmds well. just accept this command as success. * if the device is really a removable then * pass it on to the device, else just accept * if we have not received a NOT READY condition, * just accept since some device choke on this too. * we do have to let EJECT get through though * Some devices do not handle the inquiry cmd well * so build an inquiry and accept this command as * Fake accepting the following two Opcodes * (as the drive doesn't support it.) * These are needed by format command. * scsa2usb_handle_scsi_cmd_sub_class: * returns SCSA2USB_TRANSPORT, SCSA2USB_REJECT, SCSA2USB_JUST_ACCEPT "scsa2usb_handle_scsi_cmd_sub_class: cmd = 0x%p pkt = 0x%p",
* decode and convert the packet * for most cmds, we can bcopy the cdb * SCMD_FORMAT used to limit cmd->cmd_xfercount * to 4 bytes, but this hangs * formatting dvd media using cdrecord (that is, * a SCSI FORMAT UNIT command with a parameter list > 4 bytes) * (bit 4 in cdb1 is the Fmtdata bit) * (as ATAPI devices don't recognize G0 commands) * scsa2usb_rw_transport() along with other commands. * USB Host Controllers cannot handle large (read/write) * xfers. We split the large request to chunks of * smaller ones to meet the HCD limitations. * the mode header is different as well * Needed by zip protocol to reset the device * Next command does not have a SCSI equivalent as * It was listed in the vendor's ATAPI Zip specs. * an unknown command may be a uscsi cmd which we * should let go thru without mapping "scsa2usb_handle_scsi_cmd_sub_class: opcode = 0x%x count = 0x%lx",
* scsa2usb_check_ufi_blacklist_attrs: * validate "scsa2usb_blacklist_attrs" (see scsa2usb.h) * if blacklisted attrs match accept the request * attributes checked are:- * SCSA2USB_ATTRS_GET_CONF * SCSA2USB_ATTRS_GET_PERF * SCSA2USB_ATTRS_GET_START_STOP * some CB/CBI devices don't have mechanics that spin the * media up and down. So, it doesn't make much sense * to issue this cmd to those devices. * scsa2usb_handle_ufi_subclass_cmd: * returns SCSA2USB_TRANSPORT, SCSA2USB_REJECT "scsa2usb_handle_ufi_subclass_cmd: cmd = 0x%p pkt = 0x%p",
* decode and convert the packet if necessary * for most cmds, we can bcopy the cdb /* if parameter list is specified */ * mode header is different as well * Some CB/CBI devices may not support TUR. /* A larger timeout is needed for 'flaky' CD-RW devices */ * all other commands don't need special mapping "scsa2usb_handle_ufi_subclass_cmd: opcode = 0x%x count = 0x%lx",
* Handle splitting READ and WRITE requests to the * device to a size that the host controller allows. * variety of block sizes for the different types of CD * data (audio, data, video, CD-XA, yellowbook, redbook etc.) * Some of the block sizes used are:- 512, 1k, 2k, 2056, 2336 * 2340, 2352, 2368, 2448, 2646, 2647 etc. * NOTE: the driver could be entertaining a SCSI CDB that uses * any of the above listed block sizes at a given time, and a * totally different block size at any other given time for a * We need to compute block size every time and figure out * matching LBA and LEN accordingly. * Also UHCI has a limitation that it can only xfer 32k at a * given time. So, with "odd" sized blocks and a limitation of * how much we can xfer per shot, we need to compute xfer_count * The same computation is also done in the function * scsa2usb_setup_next_xfer(). To save computing block_size in * this function, I am saving block_size in "cmd" now. "scsa2usb_rw_transport:");
* Note that READ/WRITE(6) are not supported by the drive. /* Figure out the block size */ /* reduce xfer count if necessary */ * For CD-RW devices reduce the xfer count based * on the block size used by these devices. The * block size could change for READ_CD and WRITE * Also as UHCI allows a max xfer of 32k at a time; * compute the xfer_count based on the new block_size. * The len part of the cdb changes as a result of that. * Having figure out the 'partial' xfer len based on he * block size; fill it in to the cmd->cmd_cdb "bcount=0x%lx lba=0x%x len=0x%lx xfercount=0x%lx total=0x%lx",
/* Set the timeout value as per command request */ * We increase the time as CD-RW writes have two things * to do. After writing out the data to the media, a * TOC needs to be filled up at the beginning of the media * This is when the write gets "finalized". * Hence the actual write could take longer than the * value specified in cmd->cmd_timeout. "lba 0x%x len 0x%lx xfercount 0x%lx total 0x%lx",
* scsa2usb_setup_next_xfer: * For READs and WRITEs we split up the transfer in terms of * HCD understood units. This function handles the split transfers. * See comments in the previous function scsa2usb_rw_transport * The lba computation was being done based on scsa2usb_max_bulk_xfer_size * earlier. With CD-RW devices, the xfer_count and the block_size may * no longer be a multiple of scsa2usb_max_bulk_xfer_size. So compute * xfer_count all over again. Adjust lba, based on the previous requests' * len. Find out the len and add it to cmd->cmd_lba to get the new lba "scsa2usb_setup_next_xfer: opcode = 0x%x lba = 0x%x " * For CD-RW devices reduce the xfer count based on the * block_size used by these devices. See changes below * where xfer_count is being adjusted. * Also adjust len/lba based on the block_size and xfer_count. * NOTE: Always calculate lba first, as it based on previous /* calculate lba = current_lba + len_of_prev_cmd */ /* re-adjust xfer count */ /* calculate lba = current_lba + len_of_prev_cmd */ /* calculate lba = current_lba + len_of_prev_cmd */ /* re-adjust xfer count */ "scsa2usb_setup_next_xfer:\n\tlba = 0x%x xfer_len = 0x%x " * take one request from the lun's waitQ and transport it * if device has been disconnected, just complete it "device not accessible");
"scsa2usb_transport_request: cmd=0x%p bp=0x%p addr=0x%p",
"scsa2usb_transport_request: transport rval = %d",
* start an auto-request sense iff * there was a check condition, we have enough * space in the status block, and we have not * faked an auto request sense * copy the timeout from the * for lack of a better value /* finish w/ this packet */ * we have valid request sense * data so clear the pkt_reason * The taskq thread that kicks off the transport (BO and CB/CBI) "scsa2usb_work_thread:");
/* exclude ugen accesses */ /* reopen the pipes if necessary */ "scsa2usb_work_thread: exit");
* empties the entire waitQ with errors asap. * It is called from scsa2usb_scsi_reset and scsa2usb_panic_callb. * If the device is reset; we should empty the waitQ right away. * If the system has paniced; we should empty the waitQ right away. * CPR suspend will only succeed if device is idle. No need to call * this function for CPR suspend case. * scsa2usb_do_inquiry is performed before INIT CHILD and we have * to fake a few things normally done by SCSA "scsa2usb_do_inquiry: %d bytes",
len);
/* is it inquiry-challenged? */ /* limit inquiry to 36 bytes */ "scsa2usb_do_inquiry: failed");
"scsa2usb_do_inquiry:INQUIRY");
"INQUIRY failed, cannot determine device type, " /* not much hope for other cmds, reduce */ * build an inquiry for a given device that doesnt like inquiry "scsa2usb_fake_inquiry:");
/* Fill in the Vendor id/Product id strings */ /* Set the Revision to the Device */ /* Copy inquiry data in to soft state */ * scsa2usb_create_arq_pkt: * Create and ARQ packet to get request sense data "scsa2usb_create_arq_pkt: scsa2usbp: %p, ap: %p",
scsa2usbp,
ap);
* scsa2usb_delete_arq_pkt: * scsa2usb_complete_arq_pkt: * finish processing the arq packet /* is this meaningful sense data */ /* we will not sense start cmd until we receive a NOT READY */ * scsa2usb_open_usb_pipes: * open usb bulk pipes (BO and CB/CBI) * open usb interrupt pipe (CBI) "scsa2usb_open_usb_pipes: dip = 0x%p flag = 0x%x",
* one pipe policy for all bulk pipes /* at least 2, for the normal and exceptional callbacks */ "scsa2usb_open_usb_pipes: opening bulk pipes");
/* Open the USB bulk-in pipe */ "scsa2usb_open_usb_pipes: bulk/in pipe open " " failed rval = %d",
rval);
/* Open the bulk-out pipe using the same policy */ "scsa2usb_open_usb_pipes: bulk/out pipe open" " failed rval = %d",
rval);
/* open interrupt pipe for CBI protocol */ "scsa2usb_open_usb_pipes: intr pipe open" " failed rval = %d",
rval);
/* get the max transfer size of the bulk pipe */ /* limit the xfer size */ "scsa2usb_open_usb_pipes: max bulk transfer size = %lx",
/* Set the pipes opened flag */ /* Set the state to NONE */ * scsa2usb_close_usb_pipes: * close all pipes synchronously "scsa2usb_close_usb_pipes: scsa2usb_state = 0x%p",
scsa2usbp);
/* to avoid races, reset the flag first */ * scsa2usb_fill_up_cdb_lba: * fill up command CDBs' LBA part /* zero cdb1, lba bits so they won't get copied in the new cdb */ * scsa2usb_fill_up_ReadCD_cdb_len: * fill up READ_CD command CDBs' len part * scsa2usb_fill_up_12byte_cdb_len: * fill up generic 12-byte command CDBs' len part * scsa2usb_fill_up_cdb_len: * fill up generic 10-byte command CDBs' len part * scsa2usb_read_cd_blk_size: * For SCMD_READ_CD opcode (0xbe). Figure out the * block size based on expected sector type field * definition. See MMC SCSI Specs section 6.1.15 * Based on the value of the "expected_sector_type" * field, the block size could be different. /* needed for esballoc_wait() */ * Convert a bp to mblk_t. USBA framework understands mblk_t. "scsa2usb_bp_to_mblk: ");
"mp=0x%p bp=0x%p pkt=0x%p off=0x%lx sz=%lu add=0x%p",
mp,
* scsa2usb_handle_data_start: * Initiate the data xfer. It could be IN/OUT direction. * Send out the bulk-xfer request * clear endpoint stall and reset bulk-in pipe * handle data read in so far; set cmd->cmd_done * also adjust data xfer length accordingly * report back to transport * typically transport will call reset recovery * Send out the bulk-xfer request * clear endpoint stall and reset bulk-in pipe * adjust data xfer length * report back to transport * typically transport will call reset recovery * NOTE: We call this function only if there is xfercount. "scsa2usb_handle_data_start: BEGIN cmd = %p, req = %p",
cmd,
req);
* This case occurs when the host expects to receive * more data than the device actually transfers. Hi > Di "TEST 5: Hi > Di: rval = 0x%x",
rval);
* This happens when the host expects to send data to the * device while the device intends to send data to the host. "TEST 8: Hi <> Do: Step 2");
#
endif /* SCSA2USB_BULK_ONLY_TEST */ * This happens when the host expects to receive data * from the device while the device intends to receive "TEST 10: Ho <> Di: done rval = 0x%x",
rval);
#
endif /* SCSA2USB_BULK_ONLY_TEST */ * Host expects to send data to the device and * device doesn't expect to receive any data #
endif /* SCSA2USB_BULK_ONLY_TEST */ "scsa2usb_handle_data_start: rval=%d cr=%d",
rval,
/* no more data to transfer after this */ "scsa2usb_handle_data_start: END %s data rval = %d",
* scsa2usb_handle_data_done: * This function handles the completion of the data xfer. * It also massages the inquiry data. This function may * also be called after a stall. "scsa2usb_handle_data_done:\n\tcmd = 0x%p data = 0x%p len = 0x%x",
* cache a copy of the inquiry data for our own use * but ensure that we have at least up to * inq_revision, inq_serial is not required. * ignore inquiry data returned for inquiry commands * with SCSI-3 EVPD, CmdDt bits set. "scsi inquiry type = 0x%x",
/* Figure out the logical block size */ "%x %x %x %x %x %x %x %x %x %x\n\t" "%x %x %x %x %x %x %x %x %x %x",
p[0], p[
1], p[
2], p[
3], p[
4],
p[
5], p[
6], p[
7], p[
8], p[
9],
p[
10], p[
11], p[
12], p[
13], p[
14],
p[
15], p[
16], p[
17], p[
18], p[
19]);
* we don't have to copy the data, the * data pointers for the mblk_t for * the bulk-in xfer points to the "len = 0x%x total = 0x%lx",
* update total_xfercount now but it may be * adjusted after receiving the residue /* set pkt_resid to total to be sure */ * scsa2usb_init_bulk_req: * Allocate (synchronously) and fill in a bulk-request * ensure that bulk requests do not have infinite timeout values * scsa2usb_clear_ept_stall: * clear endpoint stall and reset pipes "scsa2usb_clear_ept_stall: on %s: ept = 0x%x rval = %d",
* scsa2usb_pkt_completion: "scsa2usb_pkt_completion:\n\tscsa2usbp = 0x%p " "reason=%d, status=%d state=0x%x stats=0x%x resid=0x%lx",
* don't zap the current state when in panic as this will /* save the last command */ * set pkt state to NONE *before* calling back as the target * driver will immediately submit the next packet * Even handling functions: * scsa2usb_reconnect_event_cb: "scsa2usb_reconnect_event_cb: dip = 0x%p",
dip);
/* stop suppressing warnings */ * scsa2usb_all_waitQs_empty: * check if all waitQs empty * scsa2usb_disconnect_event_cb: * callback for disconnect events "scsa2usb_disconnect_event_cb: dip = 0x%p",
dip);
* wait till the work thread is done, carry on regardless * scsa2usb_create_pm_components: * create the pm components required for power management * no mutex is need when calling USBA interfaces "scsa2usb_create_pm_components: dip = 0x%p, scsa2usbp = 0x%p",
* determine if this device is on the blacklist * or if a conf file entry has disabled PM "device cannot be power managed");
/* Allocate the PM state structure */ * check if the device is using full power or not "scsa2usb_raise_power:");
* functions to handle power transition for OS levels 0 -> 3 /* Deny the powerdown request if the device is busy */ * stop polling on interrupt pipe /* Issue USB D3 command to the device here */ /* Issue USB D2 command to the device here */ /* Issue USB D1 command to the device here */ * PM framework tries to put us in full power * during system shutdown. If we are disconnected /* Issue USB D0 command to the device here */ "scsa2usb_power: Begin scsa2usbp (%p): level = %d",
"scsa2usb_power: pm NULL");
/* check if we are transitioning to a legal power level */ "scsa2usb_power: illegal power level = %d " * scsa2usb_pm_idle_component: "cdb: %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x %x",
c[0], c[
1], c[
2], c[
3], c[
4], c[
5], c[
6], c[
7], c[
8],
c[
9], c[
10], c[
11], c[
12], c[
13], c[
14], c[
15]);
* This function sends a dummy data mblk_t to simulate * the following test cases: 5 and 11. /* should we create a larger mblk? */ /* fill up the data mblk */ for (i = 0; i <
len; i++) {
"scsa2usb_test_mblk: Sent Data Out rval = 0x%x",
rval);
#
endif /* SCSA2USB_BULK_ONLY_TEST */