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