507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * CDDL HEADER START
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * The contents of this file are subject to the terms of the
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * Common Development and Distribution License (the "License").
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * You may not use this file except in compliance with the License.
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * See the License for the specific language governing permissions
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * and limitations under the License.
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * When distributing Covered Code, include this CDDL HEADER in each
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * If applicable, add the following below this CDDL HEADER, with the
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * fields enclosed by brackets "[]" replaced with your own identifying
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * information: Portions Copyright [yyyy] [name of copyright owner]
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * CDDL HEADER END
903a11ebdc8df157c4700150f41f1f262f4a8ae8rh * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * Use is subject to license terms.
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf#pragma ident "%Z%%M% %I% %E% SMI"
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * Local Function Prototypes
507c32411f3f101e90ca2120f042b5ee698ba1d5mlfstatic struct scsi_pkt *ghd_pktalloc(ccc_t *cccp, struct scsi_address *ap,
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * Round up all allocations so that we can guarantee
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * long-long alignment. This is the same alignment
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * provided by kmem_alloc().
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * Private wrapper for gcmd_t
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * round up the size so the HBA private area is on a 8 byte boundary
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf/*ARGSUSED*/
507c32411f3f101e90ca2120f042b5ee698ba1d5mlfghd_tran_sync_pkt(struct scsi_address *ap, struct scsi_pkt *pktp)
507c32411f3f101e90ca2120f042b5ee698ba1d5mlfstatic struct scsi_pkt *
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf /* allocate everything from kmem pool */
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf pktp = scsi_hba_pkt_alloc(cccp->ccc_hba_dip, ap, cmdlen, statuslen,
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf /* get the ptr to the HBA specific buffer */
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf /* get the ptr to the GHD specific buffer */
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * save the ptr to HBA private area and initialize the rest
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * of the gcmd_t members
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * save the the scsi_pkt ptr in gcmd_t.
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * callback to the HBA driver so it can initalize its
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * buffer and return the ptr to my cmd_t structure which is
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * probably embedded in its buffer.
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf if (!(*cccp->ccc_ccballoc)(gtgtp, gcmdp, cmdlen, statuslen, tgtlen,
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * packet free
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf/*ARGSUSED*/
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf /* free any extra resources allocated by the HBA */
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf /* free the scsi_pkt and the GHD and HBA private areas */
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf ASSERT(callback == NULL_FUNC || callback == SLEEP_FUNC);
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * Allocate a pkt
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf pktp = ghd_pktalloc(cccp, ap, cmdlen, statuslen, tgtlen,
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf GDBG_PKT(("ghd_tran_init_pkt_attr: gcmdp 0x%p dma_handle 0x%p\n",
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * free stale DMA window if necessary.
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf /* release the old DMA resources */
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * Set up dma info if there's any data and
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf * if the device supports DMA.
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf GDBG_PKT(("ghd_tran_init_pkt: gcmdp 0x%p bp 0x%p limp 0x%p\n",
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf /* check direction for data transfer */
507c32411f3f101e90ca2120f042b5ee698ba1d5mlf /* check dma option flags */