xref: /titanic_44/usr/src/uts/common/sys/scsi/adapters/pmcs/pmcs_sgl.h (revision 4c06356b0f0fffb4fc1b6eccc8e5d8e2254a84d6)
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 #ifndef	_PMCS_SGL_H
26 #define	_PMCS_SGL_H
27 #ifdef	__cplusplus
28 extern "C" {
29 #endif
30 
31 /*
32  * This is the strict physical representation of an external
33  * S/G list entry that the PMCS hardware uses. We manage them
34  * in chunks.
35  */
36 typedef struct {
37 	uint32_t	sglal;	/* Low 32 bit DMA address */
38 	uint32_t	sglah;	/* High 32 bit DMA address */
39 	uint32_t	sglen;	/* Length */
40 	uint32_t	flags;
41 } pmcs_dmasgl_t;
42 
43 /*
44  * If this is bit is set in flags, then the address
45  * described by this structure is an array of SGLs,
46  * the last of which may contain *another* flag
47  * to continue the list.
48  */
49 #define	PMCS_DMASGL_EXTENSION	(1U << 31)
50 
51 #define	PMCS_SGL_CHUNKSZ	(PMCS_SGL_NCHUNKS * (sizeof (pmcs_dmasgl_t)))
52 
53 /*
54  * This is how we keep track of chunks- we have a linked list of
55  * chunk pointers that are either on the free list or are tagged
56  * off of a SCSA command. We used to maintain offsets indices
57  * within the sglen area of the lest element of a chunk, but this
58  * is marked reserved and may not be reliably used future firmware
59  * revisions.
60  */
61 typedef struct pmcs_dmachunk pmcs_dmachunk_t;
62 struct pmcs_dmachunk {
63 	pmcs_dmachunk_t	*nxt;
64 	pmcs_dmasgl_t	*chunks;
65 	unsigned long	addr;
66 	ddi_acc_handle_t	acc_handle;
67 	ddi_dma_handle_t	dma_handle;
68 };
69 
70 /*
71  * DMA related functions
72  */
73 int pmcs_dma_load(pmcs_hw_t *, pmcs_cmd_t *, uint32_t *);
74 void pmcs_dma_unload(pmcs_hw_t *, pmcs_cmd_t *);
75 
76 /*
77  * After allocating some DMA chunks, insert them
78  * into the free list and set them up for use.
79  */
80 void pmcs_idma_chunks(pmcs_hw_t *, pmcs_dmachunk_t *,
81     pmcs_chunk_t *, unsigned long);
82 
83 #ifdef	__cplusplus
84 }
85 #endif
86 #endif	/* _PMCS_SGL_H */
87