2 * Copyright (c) 2013 Yahoo!, Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
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
30 #include <sys/errno.h>
31 #include <sys/ioctl.h>
32 #include <sys/param.h>
33 #include <sys/sysctl.h>
44 #include <dev/mfi/mfi_ioctl.h>
46 MFI_TABLE(top
, ctrlprop
);
49 mfi_ctrl_get_properties(int fd
, struct mfi_ctrl_props
*info
)
52 return (mfi_dcmd_command(fd
, MFI_DCMD_CTRL_GET_PROPS
, info
,
53 sizeof(struct mfi_ctrl_props
), NULL
, 0, NULL
));
57 mfi_ctrl_set_properties(int fd
, struct mfi_ctrl_props
*info
)
60 return (mfi_dcmd_command(fd
, MFI_DCMD_CTRL_SET_PROPS
, info
,
61 sizeof(struct mfi_ctrl_props
), NULL
, 0, NULL
));
65 * aquite the controller properties data structure modify the
66 * rebuild rate if requested and then retun
69 mfi_ctrl_rebuild_rate(int ac
, char **av
)
72 struct mfi_ctrl_props ctrl_props
;
75 warn("mfi_ctrl_set_rebuild_rate");
79 fd
= mfi_open(mfi_unit
, O_RDWR
);
86 error
= mfi_ctrl_get_properties(fd
, &ctrl_props
);
89 warn("Failed to get controller properties");
94 * User requested a change to the rebuild rate
97 ctrl_props
.rebuild_rate
= atoi(av
[ac
- 1]);
98 error
= mfi_ctrl_set_properties(fd
, &ctrl_props
);
101 warn("Failed to set controller properties");
106 error
= mfi_ctrl_get_properties(fd
, &ctrl_props
);
109 warn("Failed to get controller properties");
114 printf ("controller rebuild rate: %%%u \n",
115 ctrl_props
.rebuild_rate
);
118 MFI_COMMAND(ctrlprop
, rebuild
, mfi_ctrl_rebuild_rate
);
121 mfi_ctrl_alarm_enable(int ac
, char **av
)
124 struct mfi_ctrl_props ctrl_props
;
127 warn("mfi_ctrl_alarm_enable");
131 fd
= mfi_open(mfi_unit
, O_RDWR
);
138 error
= mfi_ctrl_get_properties(fd
, &ctrl_props
);
141 warn("Failed to get controller properties");
145 printf ("controller alarm was : %s\n",
146 (ctrl_props
.alarm_enable
? "enabled" : "disabled"));
149 ctrl_props
.alarm_enable
= atoi(av
[ac
- 1]);
150 error
= mfi_ctrl_set_properties(fd
, &ctrl_props
);
153 warn("Failed to set controller properties");
158 error
= mfi_ctrl_get_properties(fd
, &ctrl_props
);
161 warn("Failed to get controller properties");
166 printf ("controller alarm was : %s\n",
167 (ctrl_props
.alarm_enable
? "enabled" : "disabled"));
171 MFI_COMMAND(ctrlprop
, alarm
, mfi_ctrl_alarm_enable
);