Deleted Added
full compact
mlyvar.h (73050) mlyvar.h (79695)
1/*-
2 * Copyright (c) 2000, 2001 Michael Smith
3 * Copyright (c) 2000 BSDi
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 10 unchanged lines hidden (view full) ---

19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
1/*-
2 * Copyright (c) 2000, 2001 Michael Smith
3 * Copyright (c) 2000 BSDi
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:

--- 10 unchanged lines hidden (view full) ---

19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 *
27 * $FreeBSD: head/sys/dev/mly/mlyvar.h 73050 2001-02-25 22:48:34Z msmith $
27 * $FreeBSD: head/sys/dev/mly/mlyvar.h 79695 2001-07-14 00:12:23Z msmith $
28 */
29
30/********************************************************************************
31 ********************************************************************************
32 Driver Parameter Definitions
33 ********************************************************************************
34 ********************************************************************************/
35
36/*
37 * The firmware interface allows for a 16-bit command identifier. A lookup
38 * table this size (256k) would be too expensive, so we cap ourselves at a
39 * reasonable limit.
40 */
28 */
29
30/********************************************************************************
31 ********************************************************************************
32 Driver Parameter Definitions
33 ********************************************************************************
34 ********************************************************************************/
35
36/*
37 * The firmware interface allows for a 16-bit command identifier. A lookup
38 * table this size (256k) would be too expensive, so we cap ourselves at a
39 * reasonable limit.
40 */
41#define MLY_MAXCOMMANDS 256 /* max commands per controller */
41#define MLY_MAX_COMMANDS 256 /* max commands per controller */
42
43/*
44 * The firmware interface allows for a 16-bit s/g list length. We limit
45 * ourselves to a reasonable maximum and ensure alignment.
46 */
42
43/*
44 * The firmware interface allows for a 16-bit s/g list length. We limit
45 * ourselves to a reasonable maximum and ensure alignment.
46 */
47#define MLY_MAXSGENTRIES 64 /* max S/G entries, limit 65535 */
47#define MLY_MAX_SGENTRIES 64 /* max S/G entries, limit 65535 */
48
48
49/*
50 * The interval at which we poke the controller for status updates (in seconds).
51 */
52#define MLY_PERIODIC_INTERVAL 1
53
49/********************************************************************************
50 ********************************************************************************
51 Cross-version Compatibility
52 ********************************************************************************
53 ********************************************************************************/
54
55#if __FreeBSD_version >= 500005
56# include <sys/taskqueue.h>
57#endif
58
59#if __FreeBSD_version <= 500014
60# include <machine/clock.h>
61# undef offsetof
62# define offsetof(type, field) ((size_t)(&((type *)0)->field))
63#endif
64
54/********************************************************************************
55 ********************************************************************************
56 Cross-version Compatibility
57 ********************************************************************************
58 ********************************************************************************/
59
60#if __FreeBSD_version >= 500005
61# include <sys/taskqueue.h>
62#endif
63
64#if __FreeBSD_version <= 500014
65# include <machine/clock.h>
66# undef offsetof
67# define offsetof(type, field) ((size_t)(&((type *)0)->field))
68#endif
69
70#ifndef INTR_ENTROPY
71# define INTR_ENTROPY 0
72#endif
73
65/********************************************************************************
66 ********************************************************************************
67 Driver Variable Definitions
68 ********************************************************************************
69 ********************************************************************************/
70
71/*
72 * Debugging levels:

--- 69 unchanged lines hidden (view full) ---

142};
143
144/*
145 * Command slot regulation.
146 *
147 * We can't use slot 0 due to the memory mailbox implementation.
148 */
149#define MLY_SLOT_START 1
74/********************************************************************************
75 ********************************************************************************
76 Driver Variable Definitions
77 ********************************************************************************
78 ********************************************************************************/
79
80/*
81 * Debugging levels:

--- 69 unchanged lines hidden (view full) ---

151};
152
153/*
154 * Command slot regulation.
155 *
156 * We can't use slot 0 due to the memory mailbox implementation.
157 */
158#define MLY_SLOT_START 1
150#define MLY_SLOT_MAX (MLY_SLOT_START + MLY_MAXCOMMANDS)
159#define MLY_SLOT_MAX (MLY_SLOT_START + MLY_MAX_COMMANDS)
151
152/*
153 * Per-controller structure.
154 */
155struct mly_softc {
156 /* bus connections */
157 device_t mly_dev;
158 dev_t mly_dev_t;

--- 29 unchanged lines hidden (view full) ---

188 u_int64_t mly_mmbox_busaddr; /* bus-space address of memory mailbox */
189 bus_dma_tag_t mly_mmbox_dmat; /* memory mailbox DMA tag */
190 bus_dmamap_t mly_mmbox_dmamap; /* memory mailbox DMA map */
191 u_int32_t mly_mmbox_command_index; /* next index to use */
192 u_int32_t mly_mmbox_status_index; /* index we next expect status at */
193
194 /* controller features, limits and status */
195 int mly_state;
160
161/*
162 * Per-controller structure.
163 */
164struct mly_softc {
165 /* bus connections */
166 device_t mly_dev;
167 dev_t mly_dev_t;

--- 29 unchanged lines hidden (view full) ---

197 u_int64_t mly_mmbox_busaddr; /* bus-space address of memory mailbox */
198 bus_dma_tag_t mly_mmbox_dmat; /* memory mailbox DMA tag */
199 bus_dmamap_t mly_mmbox_dmamap; /* memory mailbox DMA map */
200 u_int32_t mly_mmbox_command_index; /* next index to use */
201 u_int32_t mly_mmbox_status_index; /* index we next expect status at */
202
203 /* controller features, limits and status */
204 int mly_state;
196#define MLY_STATE_SUSPEND (1<<0)
197#define MLY_STATE_OPEN (1<<1)
198#define MLY_STATE_INTERRUPTS_ON (1<<2)
199#define MLY_STATE_MMBOX_ACTIVE (1<<3)
205#define MLY_STATE_OPEN (1<<1)
206#define MLY_STATE_INTERRUPTS_ON (1<<2)
207#define MLY_STATE_MMBOX_ACTIVE (1<<3)
208#define MLY_STATE_CAM_FROZEN (1<<4)
200 struct mly_ioctl_getcontrollerinfo *mly_controllerinfo;
201 struct mly_param_controller *mly_controllerparam;
202 struct mly_btl mly_btl[MLY_MAX_CHANNELS][MLY_MAX_TARGETS];
203
204 /* command management */
209 struct mly_ioctl_getcontrollerinfo *mly_controllerinfo;
210 struct mly_param_controller *mly_controllerparam;
211 struct mly_btl mly_btl[MLY_MAX_CHANNELS][MLY_MAX_TARGETS];
212
213 /* command management */
205 struct mly_command mly_command[MLY_MAXCOMMANDS]; /* commands */
214 struct mly_command mly_command[MLY_MAX_COMMANDS]; /* commands */
206 union mly_command_packet *mly_packet; /* command packets */
207 bus_dma_tag_t mly_packet_dmat; /* packet DMA tag */
208 bus_dmamap_t mly_packetmap; /* packet DMA map */
209 u_int64_t mly_packetphys; /* packet array base address */
210 TAILQ_HEAD(,mly_command) mly_free; /* commands available for reuse */
215 union mly_command_packet *mly_packet; /* command packets */
216 bus_dma_tag_t mly_packet_dmat; /* packet DMA tag */
217 bus_dmamap_t mly_packetmap; /* packet DMA map */
218 u_int64_t mly_packetphys; /* packet array base address */
219 TAILQ_HEAD(,mly_command) mly_free; /* commands available for reuse */
211 TAILQ_HEAD(,mly_command) mly_ready; /* commands ready to be submitted */
212 TAILQ_HEAD(,mly_command) mly_busy;
213 TAILQ_HEAD(,mly_command) mly_complete; /* commands which have been returned by the controller */
214 struct mly_qstat mly_qstat[MLYQ_COUNT]; /* queue statistics */
215
216 /* health monitoring */
217 u_int32_t mly_event_change; /* event status change indicator */
218 u_int32_t mly_event_counter; /* next event for which we anticpiate status */
219 u_int32_t mly_event_waiting; /* next event the controller will post status for */
220 struct callout_handle mly_periodic; /* periodic event handling */
221
222 /* CAM connection */
220 TAILQ_HEAD(,mly_command) mly_busy;
221 TAILQ_HEAD(,mly_command) mly_complete; /* commands which have been returned by the controller */
222 struct mly_qstat mly_qstat[MLYQ_COUNT]; /* queue statistics */
223
224 /* health monitoring */
225 u_int32_t mly_event_change; /* event status change indicator */
226 u_int32_t mly_event_counter; /* next event for which we anticpiate status */
227 u_int32_t mly_event_waiting; /* next event the controller will post status for */
228 struct callout_handle mly_periodic; /* periodic event handling */
229
230 /* CAM connection */
223 TAILQ_HEAD(,ccb_hdr) mly_cam_ccbq; /* outstanding I/O from CAM */
224 struct cam_sim *mly_cam_sim[MLY_MAX_CHANNELS];
225 int mly_cam_lowbus;
231 struct cam_devq *mly_cam_devq; /* CAM device queue */
232 struct cam_sim *mly_cam_sim[MLY_MAX_CHANNELS]; /* CAM SIMs */
233 struct cam_path *mly_cam_path; /* rescan path */
234 int mly_cam_channels; /* total channel count */
226
227#if __FreeBSD_version >= 500005
228 /* command-completion task */
229 struct task mly_task_complete; /* deferred-completion task */
230#endif
231};
232
233/*

--- 33 unchanged lines hidden (view full) ---

267 } while(0);
268#define MLY_UNMASK_INTERRUPTS(sc) \
269 do { \
270 MLY_SET_REG((sc), (sc)->mly_interrupt_mask, MLY_INTERRUPT_MASK_ENABLE); \
271 sc->mly_state |= MLY_STATE_INTERRUPTS_ON; \
272 } while(0);
273
274/*
235
236#if __FreeBSD_version >= 500005
237 /* command-completion task */
238 struct task mly_task_complete; /* deferred-completion task */
239#endif
240};
241
242/*

--- 33 unchanged lines hidden (view full) ---

276 } while(0);
277#define MLY_UNMASK_INTERRUPTS(sc) \
278 do { \
279 MLY_SET_REG((sc), (sc)->mly_interrupt_mask, MLY_INTERRUPT_MASK_ENABLE); \
280 sc->mly_state |= MLY_STATE_INTERRUPTS_ON; \
281 } while(0);
282
283/*
275 * Logical device number -> bus/target translation
284 * Bus/target/logical ID-related macros.
276 */
285 */
277#define MLY_LOGDEV_BUS(sc, x) (((x) / MLY_MAX_TARGETS) + (sc)->mly_controllerinfo->physical_channels_present)
278#define MLY_LOGDEV_TARGET(x) ((x) % MLY_MAX_TARGETS)
286#define MLY_LOGDEV_ID(sc, bus, target) (((bus) - (sc)->mly_controllerinfo->physical_channels_present) * \
287 MLY_MAX_TARGETS + (target))
288#define MLY_LOGDEV_BUS(sc, logdev) (((logdev) / MLY_MAX_TARGETS) + \
289 (sc)->mly_controllerinfo->physical_channels_present)
290#define MLY_LOGDEV_TARGET(sc, logdev) ((logdev) % MLY_MAX_TARGETS)
291#define MLY_BUS_IS_VIRTUAL(sc, bus) ((bus) >= (sc)->mly_controllerinfo->physical_channels_present)
292#define MLY_BUS_IS_VALID(sc, bus) (((bus) < (sc)->mly_cam_channels) && ((sc)->mly_cam_sim[(bus)] != NULL))
279
293
280/*
281 * Public functions/variables
282 */
283/* mly.c */
284extern int mly_attach(struct mly_softc *sc);
285extern void mly_detach(struct mly_softc *sc);
286extern void mly_free(struct mly_softc *sc);
287extern void mly_startio(struct mly_softc *sc);
288extern void mly_done(struct mly_softc *sc);
289extern int mly_alloc_command(struct mly_softc *sc, struct mly_command **mcp);
290extern void mly_release_command(struct mly_command *mc);
291
292/* mly_cam.c */
293extern int mly_cam_attach(struct mly_softc *sc);
294extern void mly_cam_detach(struct mly_softc *sc);
295extern int mly_cam_command(struct mly_softc *sc, struct mly_command **mcp);
296extern int mly_name_device(struct mly_softc *sc, int bus, int target);
297
298/********************************************************************************
299 * Queue primitives
300 */
301
302#define MLYQ_ADD(sc, qname) \
303 do { \
304 struct mly_qstat *qs = &(sc)->mly_qstat[qname]; \
305 \

--- 59 unchanged lines hidden (view full) ---

365 s = splcam(); \
366 TAILQ_REMOVE(&mc->mc_sc->mly_ ## name, mc, mc_link); \
367 MLYQ_REMOVE(mc->mc_sc, index); \
368 splx(s); \
369} \
370struct hack
371
372MLYQ_COMMAND_QUEUE(free, MLYQ_FREE);
294/********************************************************************************
295 * Queue primitives
296 */
297
298#define MLYQ_ADD(sc, qname) \
299 do { \
300 struct mly_qstat *qs = &(sc)->mly_qstat[qname]; \
301 \

--- 59 unchanged lines hidden (view full) ---

361 s = splcam(); \
362 TAILQ_REMOVE(&mc->mc_sc->mly_ ## name, mc, mc_link); \
363 MLYQ_REMOVE(mc->mc_sc, index); \
364 splx(s); \
365} \
366struct hack
367
368MLYQ_COMMAND_QUEUE(free, MLYQ_FREE);
373MLYQ_COMMAND_QUEUE(ready, MLYQ_READY);
374MLYQ_COMMAND_QUEUE(busy, MLYQ_BUSY);
375MLYQ_COMMAND_QUEUE(complete, MLYQ_COMPLETE);
376
369MLYQ_COMMAND_QUEUE(busy, MLYQ_BUSY);
370MLYQ_COMMAND_QUEUE(complete, MLYQ_COMPLETE);
371
372/********************************************************************************
373 * space-fill a character string
374 */
375static __inline void
376padstr(char *targ, char *src, int len)
377{
378 while (len-- > 0) {
379 if (*src != 0) {
380 *targ++ = *src++;
381 } else {
382 *targ++ = ' ';
383 }
384 }
385}