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.
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.
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]
23 * Copyright 2009 QLogic Corporation. All rights reserved.
24 * Use is subject to license terms.
28 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
43 #define QLT_DMA_SG_LIST_LENGTH 1270
44 #define CMD7_2400_DATA_SEGMENTS 1
45 #define CONT_A64_DATA_SEGMENTS 5
49 * Container for ddi_dma_handle
51 * These elements are either linked to an active dbuf or in the free list.
53 struct qlt_dma_handle
{
54 struct qlt_dma_handle
*next
;
55 ddi_dma_handle_t dma_handle
;
56 ddi_dma_cookie_t first_cookie
;
58 uint_t num_cookies_fetched
;
61 typedef struct qlt_dma_handle qlt_dma_handle_t
;
64 * The dbuf private data when using a scatter/gather list.
67 uint16_t handle_count
;
68 uint16_t cookie_count
;
69 uint16_t cookie_next_fetch
;
70 uint16_t cookie_prefetched
;
71 qlt_dma_handle_t
*handle_list
;
72 qlt_dma_handle_t
*handle_next_fetch
;
74 ddi_dma_cookie_t cookie
[1];
77 typedef struct qlt_dma_sgl qlt_dma_sgl_t
;
80 * Structure to maintain ddi_dma_handle free pool.
82 struct qlt_dma_handle_pool
{
83 kmutex_t pool_lock
; /* protects all fields */
84 qlt_dma_handle_t
*free_list
;
89 typedef struct qlt_dma_handle_pool qlt_dma_handle_pool_t
;
91 struct qlt_dmem_bucket
;
93 typedef struct qlt_dmem_bctl
{
94 struct qlt_dmem_bucket
*bctl_bucket
;
95 struct qlt_dmem_bctl
*bctl_next
;
96 uint64_t bctl_dev_addr
;
97 uint8_t bctl_task_ndx
; /* notused */
98 stmf_data_buf_t
*bctl_buf
;
101 typedef struct qlt_dmem_bucket
{
102 uint32_t dmem_buf_size
;
104 uint32_t dmem_nbufs_free
;
105 uint8_t *dmem_host_addr
;
106 uint64_t dmem_dev_addr
;
107 ddi_dma_handle_t dmem_dma_handle
;
108 ddi_acc_handle_t dmem_acc_handle
;
110 qlt_dmem_bctl_t
*dmem_bctl_free_list
;
111 void *dmem_bctls_mem
;
114 fct_status_t
qlt_dmem_init(qlt_state_t
*qlt
);
115 void qlt_dmem_fini(qlt_state_t
*qlt
);
116 void qlt_dma_handle_pool_init(qlt_state_t
*qlt
);
117 void qlt_dma_handle_pool_fini(qlt_state_t
*qlt
);
118 stmf_data_buf_t
*qlt_dmem_alloc(fct_local_port_t
*port
, uint32_t size
,
119 uint32_t *pminsize
, uint32_t flags
);
120 stmf_data_buf_t
*qlt_i_dmem_alloc(qlt_state_t
*qlt
, uint32_t size
,
121 uint32_t *pminsize
, uint32_t flags
);
122 void qlt_dmem_free(fct_dbuf_store_t
*fds
, stmf_data_buf_t
*dbuf
);
123 void qlt_i_dmem_free(qlt_state_t
*qlt
, stmf_data_buf_t
*dbuf
);
124 stmf_status_t
qlt_dma_setup_dbuf(fct_local_port_t
*port
,
125 stmf_data_buf_t
*dbuf
, uint32_t flags
);
126 void qlt_dma_teardown_dbuf(fct_dbuf_store_t
*fds
, stmf_data_buf_t
*dbuf
);
127 void qlt_dmem_dma_sync(stmf_data_buf_t
*dbuf
, uint_t sync_type
);
128 uint8_t qlt_get_iocb_count(uint32_t cookie_cnt
);
129 uint64_t qlt_ddi_vtop(caddr_t vaddr
);
131 * XXX move the following into the fct layer
133 uint16_t qlt_get_cookie_count(stmf_data_buf_t
*dbuf
);
134 void qlt_ddi_dma_nextcookie(stmf_data_buf_t
*dbuf
, ddi_dma_cookie_t
*cookie_p
);
135 ddi_dma_cookie_t
*qlt_get_cookie_array(stmf_data_buf_t
*dbuf
);
142 #endif /* _QLT_DMA_H */