xref: /titanic_51/usr/src/uts/common/sys/scsi/adapters/pmcs/pmcs_scsa.h (revision 5a7797ce9bcfe70ce0ab366abc3051dce3cede6f)
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 (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
23  */
24 /*
25  * SCSI (SCSA) midlayer interface for PMC drier.
26  */
27 #ifndef _PMCS_SCSA_H
28 #define	_PMCS_SCSA_H
29 #ifdef	__cplusplus
30 extern "C" {
31 #endif
32 
33 #include <sys/scsi/scsi_types.h>
34 
35 #define	ADDR2TRAN(ap)		((ap)->a_hba_tran)
36 #define	ADDR2PMC(ap)		(ITRAN2PMC(ADDR2TRAN(ap)))
37 
38 #define	CMD2TRAN(cmd)		(CMD2PKT(cmd)->pkt_address.a_hba_tran)
39 #define	CMD2PMC(cmd)		(ITRAN2PMC(CMD2TRAN(cmd)))
40 
41 #define	PKT2ADDR(pkt)		(&((pkt)->pkt_address))
42 #define	PKT2CMD(pkt)		((pmcs_cmd_t *)(pkt->pkt_ha_private))
43 #define	CMD2PKT(sp)		(sp->cmd_pkt)
44 #define	PMCS_STATUS_LEN		264
45 
46 #define	TRAN2PMC(tran)		((pmcs_hw_t *)(tran)->tran_hba_private)
47 #define	ITRAN2PMC(tran) \
48 	(((pmcs_iport_t *)(tran)->tran_hba_private)->pwp)
49 #define	ITRAN2IPORT(tran) \
50 	((pmcs_iport_t *)(tran)->tran_hba_private)
51 
52 /*
53  * Wrapper around scsi_pkt.
54  */
55 struct pmcs_cmd {
56 	struct scsi_pkt		*cmd_pkt;	/* actual SCSI Packet */
57 	STAILQ_ENTRY(pmcs_cmd)	cmd_next;	/* linked list */
58 	pmcs_dmachunk_t		*cmd_clist;	/* list of dma chunks */
59 	pmcs_xscsi_t		*cmd_target;	/* Pointer to target */
60 	pmcs_lun_t		*cmd_lun;	/* Pointer to LU */
61 	uint32_t		cmd_tag;	/* PMC htag */
62 	uint8_t			cmd_satltag;	/* SATL tag */
63 };
64 
65 #define	SCSA_CDBLEN(sp)		sp->cmd_pkt->pkt_cdblen
66 #define	SCSA_STSLEN(sp)		sp->cmd_pkt->pkt_scblen
67 #define	SCSA_TGTLEN(sp)		sp->cmd_pkt->pkt_tgtlen
68 
69 #define	PMCS_WQ_RUN_SUCCESS		0
70 #define	PMCS_WQ_RUN_FAIL_RES		1 /* Failed to alloc rsrcs */
71 #define	PMCS_WQ_RUN_FAIL_RES_CMP	2 /* Failed rsrcs, but put on the CQ */
72 #define	PMCS_WQ_RUN_FAIL_OTHER		3 /* 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