xref: /freebsd/sys/dev/mpt/mpt_raid.h (revision 8bf91348e58f1ce86723865cf78b9b4fc760908b)
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  */
35b0a2fdeeSScott Long #ifndef  _MPT_RAID_H_
36b0a2fdeeSScott Long #define  _MPT_RAID_H_
37b0a2fdeeSScott Long 
38b0a2fdeeSScott Long #include <cam/cam.h>
39b0a2fdeeSScott Long union ccb;
40b0a2fdeeSScott Long 
41b0a2fdeeSScott Long typedef enum {
42b0a2fdeeSScott Long 	MPT_RAID_MWCE_ON,
43b0a2fdeeSScott Long 	MPT_RAID_MWCE_OFF,
44b0a2fdeeSScott Long 	MPT_RAID_MWCE_REBUILD_ONLY,
45b0a2fdeeSScott Long 	MPT_RAID_MWCE_NC
46b0a2fdeeSScott Long } mpt_raid_mwce_t;
47b0a2fdeeSScott Long 
488bf91348SMatt Jacob const char *mpt_vol_type(struct mpt_raid_volume *);
498bf91348SMatt Jacob const char *mpt_vol_state(struct mpt_raid_volume *);
508bf91348SMatt Jacob const char *mpt_disk_state(struct mpt_raid_disk *);
518bf91348SMatt Jacob void
528bf91348SMatt Jacob mpt_vol_prt(struct mpt_softc *, struct mpt_raid_volume *, const char *fmt, ...);
538bf91348SMatt Jacob void
548bf91348SMatt Jacob mpt_disk_prt(struct mpt_softc *, struct mpt_raid_disk *, const char *, ...);
55b0a2fdeeSScott Long 
568bf91348SMatt Jacob int
578bf91348SMatt Jacob mpt_issue_raid_req(struct mpt_softc *, struct mpt_raid_volume *,
588bf91348SMatt Jacob     struct mpt_raid_disk *, request_t *, u_int, uint32_t, bus_addr_t,
598bf91348SMatt Jacob     bus_size_t, int, int);
608bf91348SMatt Jacob 
61b0a2fdeeSScott Long cam_status
628bf91348SMatt Jacob mpt_map_physdisk(struct mpt_softc *, union ccb *, u_int *);
63b0a2fdeeSScott Long cam_status
648bf91348SMatt Jacob mpt_raid_quiesce_disk(struct mpt_softc *, struct mpt_raid_disk *, request_t *);
658bf91348SMatt Jacob 
668bf91348SMatt Jacob int	mpt_refresh_raid_data(struct mpt_softc *);
678bf91348SMatt Jacob void	mpt_schedule_raid_refresh(struct mpt_softc *);
68b0a2fdeeSScott Long 
69b0a2fdeeSScott Long static __inline void
70b0a2fdeeSScott Long mpt_raid_wakeup(struct mpt_softc *mpt)
71b0a2fdeeSScott Long {
72b0a2fdeeSScott Long 	mpt->raid_wakeup++;
73b0a2fdeeSScott Long 	wakeup(&mpt->raid_volumes);
74b0a2fdeeSScott Long }
75b0a2fdeeSScott Long 
76b0a2fdeeSScott Long #define MPT_RAID_SYNC_REPORT_INTERVAL (15 * 60 * hz)
77b0a2fdeeSScott Long #define MPT_RAID_RESYNC_RATE_MAX (255)
78b0a2fdeeSScott Long #define MPT_RAID_RESYNC_RATE_MIN (1)
79b0a2fdeeSScott Long #define MPT_RAID_RESYNC_RATE_NC (0)
80b0a2fdeeSScott Long #define MPT_RAID_RESYNC_RATE_DEFAULT MPT_RAID_RESYNC_RATE_NC
81b0a2fdeeSScott Long 
82b0a2fdeeSScott Long #define MPT_RAID_QUEUE_DEPTH_DEFAULT (128)
83b0a2fdeeSScott Long 
84b0a2fdeeSScott Long #define MPT_RAID_MWCE_DEFAULT MPT_RAID_MWCE_NC
85b0a2fdeeSScott Long 
86b0a2fdeeSScott Long #define RAID_VOL_FOREACH(mpt, mpt_vol)					\
87b0a2fdeeSScott Long 	for (mpt_vol = (mpt)->raid_volumes;				\
88b0a2fdeeSScott Long 	     mpt_vol != (mpt)->raid_volumes + (mpt)->raid_max_volumes;	\
89b0a2fdeeSScott Long 	     mpt_vol++)
90b0a2fdeeSScott Long 
91b0a2fdeeSScott Long #endif /*_MPT_RAID_H_ */
92