Print this page
*** NO COMMENTS ***
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/uts/common/sys/blkdev.h
+++ new/usr/src/uts/common/sys/blkdev.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
23 23 * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
24 24 */
25 25
26 26 #ifndef _SYS_BLKDEV_H
27 27 #define _SYS_BLKDEV_H
28 28
29 29 #include <sys/types.h>
30 30 #include <sys/ksynch.h>
31 31 #include <sys/ddi.h>
32 32 #include <sys/sunddi.h>
33 33
34 34 #ifdef __cplusplus
35 35 extern "C" {
36 36 #endif
37 37
38 38 /*
39 39 * This describes a fairly simple block device. The idea here is that
40 40 * these things want to take advantage of the common labelling support,
41 41 * but do not need all the capabilities of SCSA. So we make quite a few
42 42 * simplifications:
43 43 *
44 44 * 1) Device block size is a multiple of 512 bytes.
45 45 *
46 46 * 2) Non-rotating media. We assume a simple linear layout.
47 47 *
48 48 * 3) Fixed queue depth, for each device. The adapter driver reports
49 49 * the queue depth at registration. We don't have any form of
50 50 * dynamic flow control.
51 51 *
52 52 * 4) Negligible power management support. The framework does not support
53 53 * fine grained power management. If the adapter driver wants to use
54 54 * such, it will need to manage power on its own.
55 55 *
56 56 * 5) Suspend/resume support managed by the adapter driver. We don't
57 57 * support suspend/resume directly. The adapter device driver will
58 58 * need to manage this on its own behalf.
59 59 *
60 60 * 6) No request priorities. Transfers are assumed to execute in
61 61 * roughly FIFO order. The adapter driver may reorder them, but the
62 62 * submitter has no control over that.
63 63 *
64 64 * 7) No request cancellation. Once submitted, the job completes or
65 65 * fails. It cannot be canceled.
66 66 *
67 67 * 8) Limited support for removable media. There is no support for
68 68 * locking bay doors or mechanised media bays. This could be
69 69 * added, but at present the only such interesting devices are
70 70 * covered by the SCSI disk driver.
71 71 */
72 72
73 73 typedef struct bd_handle *bd_handle_t;
74 74 typedef struct bd_xfer bd_xfer_t;
75 75 typedef struct bd_drive bd_drive_t;
76 76 typedef struct bd_media bd_media_t;
77 77 typedef struct bd_ops bd_ops_t;
78 78
79 79
80 80 struct bd_xfer {
81 81 /*
82 82 * NB: If using DMA the br_ndmac will be non-zero. Otherwise
83 83 * the br_kaddr will be non-NULL.
84 84 */
85 85 diskaddr_t x_blkno;
86 86 size_t x_nblks;
87 87 ddi_dma_handle_t x_dmah;
88 88 ddi_dma_cookie_t x_dmac;
89 89 unsigned x_ndmac;
90 90 caddr_t x_kaddr;
91 91 unsigned x_flags;
92 92 };
93 93
94 94 #define BD_XFER_POLL (1U << 0) /* no interrupts (dump) */
95 95
96 96 struct bd_drive {
97 97 uint32_t d_qsize;
98 98 uint32_t d_maxxfer;
99 99 boolean_t d_removable;
100 100 boolean_t d_hotpluggable;
101 101 int d_target;
102 102 int d_lun;
103 103 };
104 104
105 105 struct bd_media {
106 106 /*
107 107 * NB: The block size must be a power of two not less than
108 108 * DEV_BSIZE (512). Other values of the block size will
109 109 * simply not function and the media will be rejected.
110 110 *
111 111 * The block size must also divide evenly into the device's
112 112 * d_maxxfer field. If the maxxfer is a power of two larger
113 113 * than the block size, then this will automatically be
114 114 * satisfied.
115 115 */
116 116 uint64_t m_nblks;
117 117 uint32_t m_blksize;
118 118 boolean_t m_readonly;
119 119 };
120 120
121 121 #define BD_INFO_FLAG_REMOVABLE (1U << 0)
122 122 #define BD_INFO_FLAG_HOTPLUGGABLE (1U << 1)
|
↓ open down ↓ |
122 lines elided |
↑ open up ↑ |
123 123 #define BD_INFO_FLAG_READ_ONLY (1U << 2)
124 124
125 125 struct bd_ops {
126 126 int o_version;
127 127 void (*o_drive_info)(void *, bd_drive_t *);
128 128 int (*o_media_info)(void *, bd_media_t *);
129 129 int (*o_devid_init)(void *, dev_info_t *, ddi_devid_t *);
130 130 int (*o_sync_cache)(void *, bd_xfer_t *);
131 131 int (*o_read)(void *, bd_xfer_t *);
132 132 int (*o_write)(void *, bd_xfer_t *);
133 + int (*o_ioctl)(dev_t, int, intptr_t, int, cred_t *, int *);
133 134 };
134 135
135 136 #define BD_OPS_VERSION_0 0
137 +#define BD_OPS_VERSION_1 1
138 +#define BD_OPS_VERSION 1 /* Should be latest! */
136 139
137 140 /*
138 141 * Note, one handler *per* address. Drivers with multiple targets at
139 142 * different addresses must use separate handles.
140 143 */
141 144 bd_handle_t bd_alloc_handle(void *, bd_ops_t *, ddi_dma_attr_t *, int);
142 145 void bd_free_handle(bd_handle_t);
143 146 int bd_attach_handle(dev_info_t *, bd_handle_t);
144 147 int bd_detach_handle(bd_handle_t);
145 148 void bd_state_change(bd_handle_t);
146 149 void bd_xfer_done(bd_xfer_t *, int);
147 150 void bd_mod_init(struct dev_ops *);
148 151 void bd_mod_fini(struct dev_ops *);
149 152
150 153 #ifdef __cplusplus
151 154 }
152 155 #endif
153 156
154 157 #endif /* _SYS_BLKDEV_H */
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX