2 * SPDX-License-Identifier: BSD-2-Clause
4 * Copyright (c) 2013 Yahoo!, Inc.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
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.
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
32 #include <sys/errno.h>
33 #include <sys/ioctl.h>
34 #include <sys/param.h>
35 #include <sys/sysctl.h>
46 #include <dev/mfi/mfi_ioctl.h>
48 MFI_TABLE(top, ctrlprop);
51 mfi_ctrl_get_properties(int fd, struct mfi_ctrl_props *info)
54 return (mfi_dcmd_command(fd, MFI_DCMD_CTRL_GET_PROPS, info,
55 sizeof(struct mfi_ctrl_props), NULL, 0, NULL));
59 mfi_ctrl_set_properties(int fd, struct mfi_ctrl_props *info)
62 return (mfi_dcmd_command(fd, MFI_DCMD_CTRL_SET_PROPS, info,
63 sizeof(struct mfi_ctrl_props), NULL, 0, NULL));
67 * Acquire the controller properties data structure, modify the
68 * rebuild rate if requested and then return
71 mfi_ctrl_rebuild_rate(int ac, char **av)
74 struct mfi_ctrl_props ctrl_props;
77 warn("mfi_ctrl_set_rebuild_rate");
81 fd = mfi_open(mfi_device, O_RDWR);
88 error = mfi_ctrl_get_properties(fd, &ctrl_props);
91 warn("Failed to get controller properties");
96 * User requested a change to the rebuild rate
99 ctrl_props.rebuild_rate = atoi(av[ac - 1]);
100 error = mfi_ctrl_set_properties(fd, &ctrl_props);
103 warn("Failed to set controller properties");
108 error = mfi_ctrl_get_properties(fd, &ctrl_props);
111 warn("Failed to get controller properties");
116 printf ("controller rebuild rate: %%%u \n",
117 ctrl_props.rebuild_rate);
120 MFI_COMMAND(ctrlprop, rebuild, mfi_ctrl_rebuild_rate);
123 mfi_ctrl_alarm_enable(int ac, char **av)
126 struct mfi_ctrl_props ctrl_props;
129 warn("mfi_ctrl_alarm_enable");
133 fd = mfi_open(mfi_device, O_RDWR);
140 error = mfi_ctrl_get_properties(fd, &ctrl_props);
143 warn("Failed to get controller properties");
147 printf ("controller alarm was : %s\n",
148 (ctrl_props.alarm_enable ? "enabled" : "disabled"));
151 ctrl_props.alarm_enable = atoi(av[ac - 1]);
152 error = mfi_ctrl_set_properties(fd, &ctrl_props);
155 warn("Failed to set controller properties");
160 error = mfi_ctrl_get_properties(fd, &ctrl_props);
163 warn("Failed to get controller properties");
168 printf ("controller alarm was : %s\n",
169 (ctrl_props.alarm_enable ? "enabled" : "disabled"));
173 MFI_COMMAND(ctrlprop, alarm, mfi_ctrl_alarm_enable);