xref: /openbsd/sys/scsi/mpathvar.h (revision 898184e3)
1 /*	$OpenBSD: mpathvar.h,v 1.3 2011/07/11 01:02:48 dlg Exp $ */
2 
3 /*
4  * Copyright (c) 2010 David Gwynne <dlg@openbsd.org>
5  *
6  * Permission to use, copy, modify, and distribute this software for any
7  * purpose with or without fee is hereby granted, provided that the above
8  * copyright notice and this permission notice appear in all copies.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 #ifndef _SYS_SCSI_MPATH_H_
20 #define _SYS_SCSI_MPATH_H_
21 
22 struct mpath_dev;
23 struct mpath_group;
24 
25 struct mpath_ops {
26 	char	op_name[16];
27 	int	(*op_checksense)(struct scsi_xfer *);
28 	int	(*op_online)(struct scsi_link *);
29 	int	(*op_offline)(struct scsi_link *);
30 	int	op_schedule;
31 };
32 
33 #define MPATH_ROUNDROBIN	0 /* use all active paths */
34 #define MPATH_NEXT		MPATH_ROUNDROBIN
35 #define MPATH_MRU		1 /* use most recently used path */
36 
37 struct mpath_path {
38 	/* the path driver must set these */
39 	struct scsi_xshandler	 p_xsh;
40 	struct scsi_link	*p_link;
41 	int			 p_gid;
42 
43 	/* the follwoing are private to mpath.c */
44 	TAILQ_ENTRY(mpath_path)	 p_entry;
45 	struct mpath_dev	*p_dev;
46 	int			 p_state;
47 };
48 
49 int			 mpath_path_probe(struct scsi_link *);
50 int			 mpath_path_attach(struct mpath_path *,
51 			    const struct mpath_ops *);
52 void			 mpath_path_state(struct mpath_path *, int);
53 int			 mpath_path_detach(struct mpath_path *);
54 
55 void			 mpath_start(struct mpath_path *, struct scsi_xfer *);
56 
57 struct device		*mpath_bootdv(struct device *);
58 
59 #endif /* _SYS_SCSI_MPATH_H_ */
60