xref: /freebsd/usr.sbin/mlxcontrol/mlxcontrol.h (revision b1f9167f94059fd55c630891d359bcff987bd7eb)
1 /*-
2  * Copyright (c) 1999 Michael Smith
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24  * SUCH DAMAGE.
25  *
26  *	$FreeBSD$
27  */
28 
29 #include <sys/queue.h>
30 
31 #define debug(fmt, args...)	printf("%s: " fmt "\n", __func__ , ##args)
32 
33 struct mlxd_foreach_action
34 {
35     void	(*func)(int unit, void *arg);
36     void	*arg;
37 };
38 
39 extern void			mlx_foreach(void (*func)(int unit, void *arg), void *arg);
40 void				mlxd_foreach_ctrlr(int unit, void *arg);
41 extern void			mlxd_foreach(void (*func)(int unit, void *arg), void *arg);
42 extern int			mlxd_find_ctrlr(int unit, int *ctrlr, int *sysdrive);
43 extern void			mlx_perform(int unit, void (*func)(int fd, void *arg), void *arg);
44 extern void			mlx_command(int fd, void *arg);
45 extern int			mlx_enquiry(int unit, struct mlx_enquiry2 *enq);
46 extern int			mlx_read_configuration(int unit, struct mlx_core_cfg *cfg);
47 extern int			mlx_scsi_inquiry(int unit, int bus, int target, char **vendor, char **device, char **revision);
48 extern int			mlx_get_device_state(int fd, int channel, int target, struct mlx_phys_drv *drv);
49 
50 extern char 	*ctrlrpath(int unit);
51 extern char	*ctrlrname(int unit);
52 extern char	*drivepath(int unit);
53 extern char	*drivename(int unit);
54 extern int	ctrlrunit(char *str);
55 extern int	driveunit(char *str);
56 
57 extern void	mlx_print_phys_drv(struct mlx_phys_drv *drv, int channel, int target, char *prefix, int verbose);
58 
59 struct conf_phys_drv
60 {
61     TAILQ_ENTRY(conf_phys_drv)	pd_link;
62     int				pd_bus;
63     int				pd_target;
64     struct mlx_phys_drv		pd_drv;
65 };
66 
67 struct conf_span
68 {
69     TAILQ_ENTRY(conf_span)	s_link;
70     struct conf_phys_drv	*s_drvs[8];
71     struct mlx_sys_drv_span	s_span;
72 };
73 
74 struct conf_sys_drv
75 {
76     TAILQ_ENTRY(conf_sys_drv)	sd_link;
77     struct conf_span		*sd_spans[4];
78     struct mlx_sys_drv		sd_drv;
79 };
80 
81 struct conf_config
82 {
83     TAILQ_HEAD(,conf_phys_drv)	cc_phys_drvs;
84     TAILQ_HEAD(,conf_span)	cc_spans;
85     TAILQ_HEAD(,conf_sys_drv)	cc_sys_drvs;
86     struct conf_sys_drv		*cc_drives[32];
87     struct mlx_core_cfg		cc_cfg;
88 };
89 
90