xref: /freebsd/sys/dev/mpt/mpt_raid.h (revision ec3e6e77a14adfe0003269d39caa4cf1e221d3e5)
1b0a2fdeeSScott Long /* $FreeBSD$ */
2b0a2fdeeSScott Long /*-
3b0a2fdeeSScott Long  * Definitions for the integrated RAID features LSI MPT Fusion adapters.
4b0a2fdeeSScott Long  *
5b0a2fdeeSScott Long  * Copyright (c) 2005, WHEEL Sp. z o.o.
6b0a2fdeeSScott Long  * Copyright (c) 2004, 2005 Justin T. Gibbs
7b0a2fdeeSScott Long  * All rights reserved.
8b0a2fdeeSScott Long  *
9b0a2fdeeSScott Long  * Redistribution and use in source and binary forms, with or without
10b0a2fdeeSScott Long  * modification, are permitted provided that the following conditions are
11b0a2fdeeSScott Long  * met:
12b0a2fdeeSScott Long  * 1. Redistributions of source code must retain the above copyright
13b0a2fdeeSScott Long  *    notice, this list of conditions and the following disclaimer.
14b0a2fdeeSScott Long  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
15b0a2fdeeSScott Long  *    substantially similar to the "NO WARRANTY" disclaimer below
16b0a2fdeeSScott Long  *    ("Disclaimer") and any redistribution must be conditioned upon including
17b0a2fdeeSScott Long  *    a substantially similar Disclaimer requirement for further binary
18b0a2fdeeSScott Long  *    redistribution.
19286e947fSJustin T. Gibbs  * 3. Neither the names of the above listed copyright holders nor the names
20286e947fSJustin T. Gibbs  *    of any contributors may be used to endorse or promote products derived
21286e947fSJustin T. Gibbs  *    from this software without specific prior written permission.
22b0a2fdeeSScott Long  *
23b0a2fdeeSScott Long  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24b0a2fdeeSScott Long  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25b0a2fdeeSScott Long  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26b0a2fdeeSScott Long  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
27b0a2fdeeSScott Long  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28b0a2fdeeSScott Long  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29b0a2fdeeSScott Long  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30b0a2fdeeSScott Long  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31b0a2fdeeSScott Long  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32b0a2fdeeSScott Long  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF THE COPYRIGHT
33b0a2fdeeSScott Long  * OWNER OR CONTRIBUTOR IS ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34b0a2fdeeSScott Long  */
35ec5fe39dSMatt Jacob /*-
36ec5fe39dSMatt Jacob  * Some Breakage and Bug Fixing added later.
37ec5fe39dSMatt Jacob  * Copyright (c) 2006, by Matthew Jacob
38ec5fe39dSMatt Jacob  * All Rights Reserved
39ec5fe39dSMatt Jacob  *
40ec5fe39dSMatt Jacob  * Support from LSI-Logic has also gone a great deal toward making this a
41ec5fe39dSMatt Jacob  * workable subsystem and is gratefully acknowledged.
42ec5fe39dSMatt Jacob  */
43b0a2fdeeSScott Long #ifndef  _MPT_RAID_H_
44b0a2fdeeSScott Long #define  _MPT_RAID_H_
45b0a2fdeeSScott Long 
46b0a2fdeeSScott Long #include <cam/cam.h>
47b0a2fdeeSScott Long union ccb;
48b0a2fdeeSScott Long 
49b0a2fdeeSScott Long typedef enum {
50b0a2fdeeSScott Long 	MPT_RAID_MWCE_ON,
51b0a2fdeeSScott Long 	MPT_RAID_MWCE_OFF,
52b0a2fdeeSScott Long 	MPT_RAID_MWCE_REBUILD_ONLY,
53b0a2fdeeSScott Long 	MPT_RAID_MWCE_NC
54b0a2fdeeSScott Long } mpt_raid_mwce_t;
55b0a2fdeeSScott Long 
5687e255acSMarius Strobl cam_status mpt_map_physdisk(struct mpt_softc *, union ccb *, target_id_t *);
57*ec3e6e77SMarius Strobl int mpt_is_raid_member(struct mpt_softc *, target_id_t);
5887e255acSMarius Strobl int mpt_is_raid_volume(struct mpt_softc *, target_id_t);
59784880dbSMatt Jacob #if	0
60b0a2fdeeSScott Long cam_status
618bf91348SMatt Jacob mpt_raid_quiesce_disk(struct mpt_softc *, struct mpt_raid_disk *, request_t *);
62784880dbSMatt Jacob #endif
638bf91348SMatt Jacob 
641d79ca0eSMatt Jacob void	mpt_raid_free_mem(struct mpt_softc *);
65b0a2fdeeSScott Long 
66b0a2fdeeSScott Long static __inline void
67b0a2fdeeSScott Long mpt_raid_wakeup(struct mpt_softc *mpt)
68b0a2fdeeSScott Long {
69b0a2fdeeSScott Long 	mpt->raid_wakeup++;
70b0a2fdeeSScott Long 	wakeup(&mpt->raid_volumes);
71b0a2fdeeSScott Long }
72b0a2fdeeSScott Long 
73b0a2fdeeSScott Long #define MPT_RAID_SYNC_REPORT_INTERVAL (15 * 60 * hz)
74b0a2fdeeSScott Long #define MPT_RAID_RESYNC_RATE_MAX (255)
75b0a2fdeeSScott Long #define MPT_RAID_RESYNC_RATE_MIN (1)
76b0a2fdeeSScott Long #define MPT_RAID_RESYNC_RATE_NC (0)
77b0a2fdeeSScott Long #define MPT_RAID_RESYNC_RATE_DEFAULT MPT_RAID_RESYNC_RATE_NC
78b0a2fdeeSScott Long 
79b0a2fdeeSScott Long #define MPT_RAID_QUEUE_DEPTH_DEFAULT (128)
80b0a2fdeeSScott Long 
81b0a2fdeeSScott Long #define MPT_RAID_MWCE_DEFAULT MPT_RAID_MWCE_NC
82b0a2fdeeSScott Long 
83b0a2fdeeSScott Long #define RAID_VOL_FOREACH(mpt, mpt_vol)					\
84b0a2fdeeSScott Long 	for (mpt_vol = (mpt)->raid_volumes;				\
85b0a2fdeeSScott Long 	     mpt_vol != (mpt)->raid_volumes + (mpt)->raid_max_volumes;	\
86b0a2fdeeSScott Long 	     mpt_vol++)
87b0a2fdeeSScott Long 
88b0a2fdeeSScott Long #endif /*_MPT_RAID_H_ */
89