mpt_raid.h revision 158934
1147883Sscottl/* $FreeBSD: head/sys/dev/mpt/mpt_raid.h 158934 2006-05-26 05:43:14Z 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 */
35147883Sscottl#ifndef  _MPT_RAID_H_
36147883Sscottl#define  _MPT_RAID_H_
37147883Sscottl
38147883Sscottl#include <cam/cam.h>
39147883Sscottlunion ccb;
40147883Sscottl
41147883Sscottltypedef enum {
42147883Sscottl	MPT_RAID_MWCE_ON,
43147883Sscottl	MPT_RAID_MWCE_OFF,
44147883Sscottl	MPT_RAID_MWCE_REBUILD_ONLY,
45147883Sscottl	MPT_RAID_MWCE_NC
46147883Sscottl} mpt_raid_mwce_t;
47147883Sscottl
48158934Smjacobconst char *mpt_vol_type(struct mpt_raid_volume *);
49158934Smjacobconst char *mpt_vol_state(struct mpt_raid_volume *);
50158934Smjacobconst char *mpt_disk_state(struct mpt_raid_disk *);
51158934Smjacobvoid
52158934Smjacobmpt_vol_prt(struct mpt_softc *, struct mpt_raid_volume *, const char *fmt, ...);
53158934Smjacobvoid
54158934Smjacobmpt_disk_prt(struct mpt_softc *, struct mpt_raid_disk *, const char *, ...);
55147883Sscottl
56158934Smjacobint
57158934Smjacobmpt_issue_raid_req(struct mpt_softc *, struct mpt_raid_volume *,
58158934Smjacob    struct mpt_raid_disk *, request_t *, u_int, uint32_t, bus_addr_t,
59158934Smjacob    bus_size_t, int, int);
60158934Smjacob
61147883Sscottlcam_status
62158934Smjacobmpt_map_physdisk(struct mpt_softc *, union ccb *, u_int *);
63147883Sscottlcam_status
64158934Smjacobmpt_raid_quiesce_disk(struct mpt_softc *, struct mpt_raid_disk *, request_t *);
65147883Sscottl
66158934Smjacobint	mpt_refresh_raid_data(struct mpt_softc *);
67158934Smjacobvoid	mpt_schedule_raid_refresh(struct mpt_softc *);
68158934Smjacob
69147883Sscottlstatic __inline void
70147883Sscottlmpt_raid_wakeup(struct mpt_softc *mpt)
71147883Sscottl{
72147883Sscottl	mpt->raid_wakeup++;
73147883Sscottl	wakeup(&mpt->raid_volumes);
74147883Sscottl}
75147883Sscottl
76147883Sscottl#define MPT_RAID_SYNC_REPORT_INTERVAL (15 * 60 * hz)
77147883Sscottl#define MPT_RAID_RESYNC_RATE_MAX (255)
78147883Sscottl#define MPT_RAID_RESYNC_RATE_MIN (1)
79147883Sscottl#define MPT_RAID_RESYNC_RATE_NC (0)
80147883Sscottl#define MPT_RAID_RESYNC_RATE_DEFAULT MPT_RAID_RESYNC_RATE_NC
81147883Sscottl
82147883Sscottl#define MPT_RAID_QUEUE_DEPTH_DEFAULT (128)
83147883Sscottl
84147883Sscottl#define MPT_RAID_MWCE_DEFAULT MPT_RAID_MWCE_NC
85147883Sscottl
86147883Sscottl#define RAID_VOL_FOREACH(mpt, mpt_vol)					\
87147883Sscottl	for (mpt_vol = (mpt)->raid_volumes;				\
88147883Sscottl	     mpt_vol != (mpt)->raid_volumes + (mpt)->raid_max_volumes;	\
89147883Sscottl	     mpt_vol++)
90147883Sscottl
91147883Sscottl#endif /*_MPT_RAID_H_ */
92