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 /*
23  * Copyright 2009 QLogic Corporation.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*
28  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
29  * Use is subject to license terms.
30  */
31 
32 #ifndef	_QLT_DMA_H
33 #define	_QLT_DMA_H
34 
35 #include <stmf.h>
36 
37 #ifdef	__cplusplus
38 extern "C" {
39 #endif
40 
41 struct qlt_dmem_bucket;
42 
43 typedef struct qlt_dmem_bctl {
44 	struct qlt_dmem_bucket	*bctl_bucket;
45 	struct qlt_dmem_bctl	*bctl_next;
46 	uint64_t		bctl_dev_addr;
47 	uint8_t			bctl_task_ndx;
48 	stmf_data_buf_t		*bctl_buf;
49 } qlt_dmem_bctl_t;
50 
51 typedef struct qlt_dmem_bucket {
52 	uint32_t		dmem_buf_size;
53 	uint32_t		dmem_nbufs;
54 	uint32_t		dmem_nbufs_free;
55 	uint8_t			*dmem_host_addr;
56 	uint64_t		dmem_dev_addr;
57 	ddi_dma_handle_t	dmem_dma_handle;
58 	ddi_acc_handle_t	dmem_acc_handle;
59 	kmutex_t		dmem_lock;
60 	qlt_dmem_bctl_t		*dmem_bctl_free_list;
61 	void			*dmem_bctls_mem;
62 } qlt_dmem_bucket_t;
63 
64 fct_status_t qlt_dmem_init(qlt_state_t *qlt);
65 void qlt_dmem_fini(qlt_state_t *qlt);
66 stmf_data_buf_t *qlt_dmem_alloc(fct_local_port_t *port, uint32_t size,
67     uint32_t *pminsize, uint32_t flags);
68 stmf_data_buf_t *qlt_i_dmem_alloc(qlt_state_t *qlt, uint32_t size,
69     uint32_t *pminsize, uint32_t flags);
70 void qlt_dmem_free(fct_dbuf_store_t *fds, stmf_data_buf_t *dbuf);
71 void qlt_i_dmem_free(qlt_state_t *qlt, stmf_data_buf_t *dbuf);
72 void qlt_dmem_dma_sync(stmf_data_buf_t *dbuf, uint_t sync_type);
73 
74 #ifdef	__cplusplus
75 }
76 #endif
77 
78 #endif /* _QLT_DMA_H */
79