1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9 * or http://www.opensolaris.org/os/licensing. 10 * See the License for the specific language governing permissions 11 * and limitations under the License. 12 * 13 * When distributing Covered Code, include this CDDL HEADER in each 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15 * If applicable, add the following below this CDDL HEADER, with the 16 * fields enclosed by brackets "[]" replaced with your own identifying 17 * information: Portions Copyright [yyyy] [name of copyright owner] 18 * 19 * CDDL HEADER END 20 * 21 * 22 * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 23 * Use is subject to license terms. 24 */ 25 /* 26 * SCSI (SCSA) midlayer interface for PMC drier. 27 */ 28 #ifndef _PMCS_SCSA_H 29 #define _PMCS_SCSA_H 30 #ifdef __cplusplus 31 extern "C" { 32 #endif 33 34 #include <sys/scsi/scsi_types.h> 35 36 #define ADDR2TRAN(ap) ((ap)->a_hba_tran) 37 #define ADDR2PMC(ap) (ITRAN2PMC(ADDR2TRAN(ap))) 38 39 #define CMD2TRAN(cmd) (CMD2PKT(cmd)->pkt_address.a_hba_tran) 40 #define CMD2PMC(cmd) (ITRAN2PMC(CMD2TRAN(cmd))) 41 42 #define PKT2ADDR(pkt) (&((pkt)->pkt_address)) 43 #define PKT2CMD(pkt) ((pmcs_cmd_t *)(pkt->pkt_ha_private)) 44 #define CMD2PKT(sp) (sp->cmd_pkt) 45 #define PMCS_STATUS_LEN 264 46 47 #define TRAN2PMC(tran) ((pmcs_hw_t *)(tran)->tran_hba_private) 48 #define ITRAN2PMC(tran) \ 49 (((pmcs_iport_t *)(tran)->tran_hba_private)->pwp) 50 #define ITRAN2IPORT(tran) \ 51 ((pmcs_iport_t *)(tran)->tran_hba_private) 52 53 /* 54 * Wrapper around scsi_pkt. 55 */ 56 struct pmcs_cmd { 57 struct scsi_pkt *cmd_pkt; /* actual SCSI Packet */ 58 STAILQ_ENTRY(pmcs_cmd) cmd_next; /* linked list */ 59 pmcs_dmachunk_t *cmd_clist; /* list of dma chunks */ 60 pmcs_xscsi_t *cmd_target; /* Pointer to target */ 61 pmcs_lun_t *cmd_lun; /* Pointer to LU */ 62 uint32_t cmd_tag; /* PMC htag */ 63 uint8_t cmd_satltag; /* SATL tag */ 64 }; 65 66 #define SCSA_CDBLEN(sp) sp->cmd_pkt->pkt_cdblen 67 #define SCSA_STSLEN(sp) sp->cmd_pkt->pkt_scblen 68 #define SCSA_TGTLEN(sp) sp->cmd_pkt->pkt_tgtlen 69 70 #define PMCS_WQ_RUN_SUCCESS 0 71 #define PMCS_WQ_RUN_FAIL_RES 1 /* Failed to alloc rsrcs (e.g. DMA chunks) */ 72 #define PMCS_WQ_RUN_FAIL_OTHER 2 /* Any other failure */ 73 74 int pmcs_scsa_init(pmcs_hw_t *, const ddi_dma_attr_t *); 75 76 void pmcs_latch_status(pmcs_hw_t *, pmcs_cmd_t *, uint8_t, uint8_t *, 77 size_t, char *); 78 size_t pmcs_set_resid(struct scsi_pkt *, size_t, uint32_t); 79 boolean_t pmcs_scsa_wq_run_one(pmcs_hw_t *, pmcs_xscsi_t *); 80 void pmcs_scsa_wq_run(pmcs_hw_t *); 81 void pmcs_scsa_cq_run(void *); 82 83 int pmcs_config_one(pmcs_hw_t *, uint64_t, int, long, dev_info_t **); 84 85 dev_info_t *pmcs_find_child_smp(pmcs_hw_t *, char *); 86 int pmcs_config_one_smp(pmcs_hw_t *, uint64_t, dev_info_t **); 87 88 int pmcs_run_sata_special(pmcs_hw_t *, pmcs_xscsi_t *); 89 #ifdef __cplusplus 90 } 91 #endif 92 #endif /* _PMCS_SCSA_H */ 93