1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_PX_MMU_H
#define _SYS_PX_MMU_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
#include <sys/vmem.h>
typedef uint64_t px_dvma_addr_t;
typedef uint64_t px_dma_bypass_addr_t;
typedef uint64_t px_dma_peer_addr_t;
typedef uint16_t px_dvma_context_t;
typedef uint64_t px_window_t;
/*
* boiler plate for tte (everything except the pfn)
*/
#define PX_GET_TTE_ATTR(flags, attr)\
(((flags & DDI_DMA_READ) ? PCI_MAP_ATTR_WRITE : 0) | \
((flags & DDI_DMA_WRITE) ? PCI_MAP_ATTR_READ : 0) | \
((attr & DDI_DMA_RELAXED_ORDERING) ? PCI_MAP_ATTR_RO : 0))
/*
* mmu block soft state structure:
*
* Each px node may share an mmu block structure with its peer
* node of have its own private mmu block structure.
*/
typedef struct px_mmu {
px_t *mmu_px_p; /* link back to px soft state */
int mmu_inst;
/*
* address ranges of dvma space:
*/
px_dvma_addr_t mmu_dvma_base;
px_dvma_addr_t mmu_dvma_end;
px_dvma_addr_t mmu_dvma_fast_end;
px_dvma_addr_t dvma_base_pg; /* = MMU_BTOP(mmu_dvma_base) */
px_dvma_addr_t dvma_end_pg; /* = MMU_BTOP(mmu_dvma_end) */
/*
* virtual memory map and callback id for dvma space:
*/
vmem_t *mmu_dvma_map;
uintptr_t mmu_dvma_clid;
/*
* fields for fast dvma interfaces:
*/
ulong_t mmu_dvma_reserve;
/*
* dvma fast track page cache byte map
*/
uint8_t *mmu_dvma_cache_locks;
uint_t mmu_dvma_addr_scan_start;
/* dvma debug */
kmutex_t dvma_debug_lock;
uint32_t dvma_alloc_rec_index;
uint32_t dvma_free_rec_index;
uint32_t dvma_active_count;
struct px_dvma_rec *dvma_alloc_rec;
struct px_dvma_rec *dvma_free_rec;
struct px_dvma_rec *dvma_active_list;
} px_mmu_t;
typedef struct px_dvma_range_prop {
uint32_t dvma_base;
uint32_t dvma_len;
} px_dvma_range_prop_t;
#define MMU_PAGE_INDEX(mmu_p, dvma_pg) ((dvma_pg) - (mmu_p)->dvma_base_pg)
/* dvma debug */
#define PX_DVMA_DBG_ON(mmu_p) \
((1ull << (mmu_p)->mmu_inst) & px_dvma_debug_on)
#define PX_DVMA_DBG_OFF(mmu_p) \
((1ull << (mmu_p)->mmu_inst) & px_dvma_debug_off)
extern void px_dvma_debug_fini(px_mmu_t *mmu_p);
extern void px_dvma_alloc_debug(px_mmu_t *mmu_p, char *address, uint_t len,
ddi_dma_impl_t *mp);
extern void px_dvma_free_debug(px_mmu_t *mmu_p, char *address, uint_t len,
ddi_dma_impl_t *mp);
/* DVMA routines */
extern int px_mmu_map_pages(px_mmu_t *mmu_p, ddi_dma_impl_t *mp,
px_dvma_addr_t dvma_pg, size_t npages, size_t pfn_index);
extern int px_mmu_map_window(px_mmu_t *mmu_p, ddi_dma_impl_t *mp,
px_window_t window);
extern void px_mmu_unmap_pages(px_mmu_t *mmu_p, ddi_dma_impl_t *mp,
px_dvma_addr_t dvma_pg, uint_t npages);
extern void px_mmu_unmap_window(px_mmu_t *mmu_p, ddi_dma_impl_t *mp);
/* MMU initialization routines */
extern int px_mmu_attach(px_t *px_p);
extern void px_mmu_detach(px_t *px_p);
#ifdef __cplusplus
}
#endif
#endif /* _SYS_PX_MMU_H */
|