xref: /freebsd/usr.sbin/mlxcontrol/mlxcontrol.h (revision 734e82fe33aa764367791a7d603b383996c6b40b)
1 /*-
2  * SPDX-License-Identifier: BSD-2-Clause
3  *
4  * Copyright (c) 1999 Michael Smith
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
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