mpt_raid.h revision 160395
1147883Sscottl/* $FreeBSD: head/sys/dev/mpt/mpt_raid.h 160395 2006-07-16 03:31:01Z mjacob $ */
2147883Sscottl/*-
3147883Sscottl * Definitions for the integrated RAID features LSI MPT Fusion adapters.
4147883Sscottl *
5147883Sscottl * Copyright (c) 2005, WHEEL Sp. z o.o.
6147883Sscottl * Copyright (c) 2004, 2005 Justin T. Gibbs
7147883Sscottl * All rights reserved.
8147883Sscottl *
9147883Sscottl * Redistribution and use in source and binary forms, with or without
10147883Sscottl * modification, are permitted provided that the following conditions are
11147883Sscottl * met:
12147883Sscottl * 1. Redistributions of source code must retain the above copyright
13147883Sscottl *    notice, this list of conditions and the following disclaimer.
14147883Sscottl * 2. Redistributions in binary form must reproduce at minimum a disclaimer
15147883Sscottl *    substantially similar to the "NO WARRANTY" disclaimer below
16147883Sscottl *    ("Disclaimer") and any redistribution must be conditioned upon including
17147883Sscottl *    a substantially similar Disclaimer requirement for further binary
18147883Sscottl *    redistribution.
19148679Sgibbs * 3. Neither the names of the above listed copyright holders nor the names
20148679Sgibbs *    of any contributors may be used to endorse or promote products derived
21148679Sgibbs *    from this software without specific prior written permission.
22147883Sscottl *
23147883Sscottl * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24147883Sscottl * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25147883Sscottl * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26147883Sscottl * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27147883Sscottl * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28147883Sscottl * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29147883Sscottl * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30147883Sscottl * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31147883Sscottl * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32147883Sscottl * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF THE COPYRIGHT
33147883Sscottl * OWNER OR CONTRIBUTOR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34147883Sscottl */
35159052Smjacob/*-
36159052Smjacob * Some Breakage and Bug Fixing added later.
37159052Smjacob * Copyright (c) 2006, by Matthew Jacob
38159052Smjacob * All Rights Reserved
39159052Smjacob *
40159052Smjacob * Support from LSI-Logic has also gone a great deal toward making this a
41159052Smjacob * workable subsystem and is gratefully acknowledged.
42159052Smjacob */
43147883Sscottl#ifndef  _MPT_RAID_H_
44147883Sscottl#define  _MPT_RAID_H_
45147883Sscottl
46147883Sscottl#include <cam/cam.h>
47147883Sscottlunion ccb;
48147883Sscottl
49147883Sscottltypedef enum {
50147883Sscottl	MPT_RAID_MWCE_ON,
51147883Sscottl	MPT_RAID_MWCE_OFF,
52147883Sscottl	MPT_RAID_MWCE_REBUILD_ONLY,
53147883Sscottl	MPT_RAID_MWCE_NC
54147883Sscottl} mpt_raid_mwce_t;
55147883Sscottl
56158934Smjacobconst char *mpt_vol_type(struct mpt_raid_volume *);
57158934Smjacobconst char *mpt_vol_state(struct mpt_raid_volume *);
58158934Smjacobconst char *mpt_disk_state(struct mpt_raid_disk *);
59158934Smjacobvoid
60158934Smjacobmpt_vol_prt(struct mpt_softc *, struct mpt_raid_volume *, const char *fmt, ...);
61158934Smjacobvoid
62158934Smjacobmpt_disk_prt(struct mpt_softc *, struct mpt_raid_disk *, const char *, ...);
63147883Sscottl
64158934Smjacobint
65158934Smjacobmpt_issue_raid_req(struct mpt_softc *, struct mpt_raid_volume *,
66158934Smjacob    struct mpt_raid_disk *, request_t *, u_int, uint32_t, bus_addr_t,
67158934Smjacob    bus_size_t, int, int);
68158934Smjacob
69147883Sscottlcam_status
70158982Smjacobmpt_map_physdisk(struct mpt_softc *, union ccb *, target_id_t *);
71159050Smjacobint mpt_is_raid_volume(struct mpt_softc *, int);
72160395Smjacob#if	0
73147883Sscottlcam_status
74158934Smjacobmpt_raid_quiesce_disk(struct mpt_softc *, struct mpt_raid_disk *, request_t *);
75160395Smjacob#endif
76147883Sscottl
77158934Smjacobint	mpt_refresh_raid_data(struct mpt_softc *);
78158934Smjacobvoid	mpt_schedule_raid_refresh(struct mpt_softc *);
79158982Smjacobvoid	mpt_raid_free_mem(struct mpt_softc *);
80158934Smjacob
81147883Sscottlstatic __inline void
82147883Sscottlmpt_raid_wakeup(struct mpt_softc *mpt)
83147883Sscottl{
84147883Sscottl	mpt->raid_wakeup++;
85147883Sscottl	wakeup(&mpt->raid_volumes);
86147883Sscottl}
87147883Sscottl
88147883Sscottl#define MPT_RAID_SYNC_REPORT_INTERVAL (15 * 60 * hz)
89147883Sscottl#define MPT_RAID_RESYNC_RATE_MAX (255)
90147883Sscottl#define MPT_RAID_RESYNC_RATE_MIN (1)
91147883Sscottl#define MPT_RAID_RESYNC_RATE_NC (0)
92147883Sscottl#define MPT_RAID_RESYNC_RATE_DEFAULT MPT_RAID_RESYNC_RATE_NC
93147883Sscottl
94147883Sscottl#define MPT_RAID_QUEUE_DEPTH_DEFAULT (128)
95147883Sscottl
96147883Sscottl#define MPT_RAID_MWCE_DEFAULT MPT_RAID_MWCE_NC
97147883Sscottl
98147883Sscottl#define RAID_VOL_FOREACH(mpt, mpt_vol)					\
99147883Sscottl	for (mpt_vol = (mpt)->raid_volumes;				\
100147883Sscottl	     mpt_vol != (mpt)->raid_volumes + (mpt)->raid_max_volumes;	\
101147883Sscottl	     mpt_vol++)
102147883Sscottl
103147883Sscottl#endif /*_MPT_RAID_H_ */
104