mpt_raid.h revision 148679
1147883Sscottl/* $FreeBSD: head/sys/dev/mpt/mpt_raid.h 148679 2005-08-03 14:08:41Z gibbs $ */
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
48147883Sscottlconst char *
49147883Sscottl	mpt_vol_type(struct mpt_raid_volume *);
50147883Sscottlconst char *
51147883Sscottl	mpt_vol_state(struct mpt_raid_volume *);
52147883Sscottlconst char *
53147883Sscottl	mpt_disk_state(struct mpt_raid_disk *);
54147883Sscottlvoid	mpt_vol_prt(struct mpt_softc *, struct mpt_raid_volume *,
55147883Sscottl		    const char *fmt, ...);
56147883Sscottlvoid	mpt_disk_prt(struct mpt_softc *mpt, struct mpt_raid_disk *disk,
57147883Sscottl		     const char *fmt, ...);
58147883Sscottl
59147883Sscottlint	mpt_issue_raid_req(struct mpt_softc *mpt, struct mpt_raid_volume *vol,
60147883Sscottl			   struct mpt_raid_disk *disk, request_t *req,
61147883Sscottl			   u_int Action, uint32_t ActionDataWord,
62147883Sscottl			   bus_addr_t addr, bus_size_t len, int write,
63147883Sscottl			   int wait);
64147883Sscottlcam_status
65147883Sscottl	mpt_map_physdisk(struct mpt_softc *mpt, union ccb *, u_int *tgt);
66147883Sscottlcam_status
67147883Sscottl	mpt_raid_quiesce_disk(struct mpt_softc *mpt,
68147883Sscottl			     struct mpt_raid_disk *mpt_disk,
69147883Sscottl			     request_t *req);
70147883Sscottlvoid	mpt_refresh_raid_data(struct mpt_softc *);
71147883Sscottlvoid	mpt_schedule_raid_refresh(struct mpt_softc *mpt);
72147883Sscottl
73147883Sscottlstatic __inline void
74147883Sscottlmpt_raid_wakeup(struct mpt_softc *mpt)
75147883Sscottl{
76147883Sscottl	mpt->raid_wakeup++;
77147883Sscottl	wakeup(&mpt->raid_volumes);
78147883Sscottl}
79147883Sscottl
80147883Sscottl#define MPT_RAID_SYNC_REPORT_INTERVAL (15 * 60 * hz)
81147883Sscottl#define MPT_RAID_RESYNC_RATE_MAX (255)
82147883Sscottl#define MPT_RAID_RESYNC_RATE_MIN (1)
83147883Sscottl#define MPT_RAID_RESYNC_RATE_NC (0)
84147883Sscottl#define MPT_RAID_RESYNC_RATE_DEFAULT MPT_RAID_RESYNC_RATE_NC
85147883Sscottl
86147883Sscottl#define MPT_RAID_QUEUE_DEPTH_DEFAULT (128)
87147883Sscottl
88147883Sscottl#define MPT_RAID_MWCE_DEFAULT MPT_RAID_MWCE_NC
89147883Sscottl
90147883Sscottl#define RAID_VOL_FOREACH(mpt, mpt_vol)					\
91147883Sscottl	for (mpt_vol = (mpt)->raid_volumes;				\
92147883Sscottl	     mpt_vol != (mpt)->raid_volumes + (mpt)->raid_max_volumes;	\
93147883Sscottl	     mpt_vol++)
94147883Sscottl
95147883Sscottl#endif /*_MPT_RAID_H_ */
96