@@ -8,6 +8,7 @@ int cmd_list(int argc, const char **argv, struct daxctl_ctx *ctx);
int cmd_migrate(int argc, const char **argv, struct daxctl_ctx *ctx);
int cmd_reconfig_device(int argc, const char **argv, struct daxctl_ctx *ctx);
int cmd_disable_device(int argc, const char **argv, struct daxctl_ctx *ctx);
+int cmd_enable_device(int argc, const char **argv, struct daxctl_ctx *ctx);
int cmd_online_memory(int argc, const char **argv, struct daxctl_ctx *ctx);
int cmd_offline_memory(int argc, const char **argv, struct daxctl_ctx *ctx);
#endif /* _DAXCTL_BUILTIN_H_ */
@@ -75,6 +75,7 @@ static struct cmd_struct commands[] = {
{ "online-memory", .d_fn = cmd_online_memory },
{ "offline-memory", .d_fn = cmd_offline_memory },
{ "disable-device", .d_fn = cmd_disable_device },
+ { "enable-device", .d_fn = cmd_enable_device },
};
int main(int argc, const char **argv)
@@ -48,6 +48,7 @@ enum device_action {
ACTION_ONLINE,
ACTION_OFFLINE,
ACTION_DISABLE,
+ ACTION_ENABLE,
};
#define BASE_OPTIONS() \
@@ -90,6 +91,11 @@ static const struct option disable_options[] = {
OPT_END(),
};
+static const struct option enable_options[] = {
+ BASE_OPTIONS(),
+ OPT_END(),
+};
+
static const char *parse_device_options(int argc, const char **argv,
enum device_action action, const struct option *options,
const char *usage, struct daxctl_ctx *ctx)
@@ -119,6 +125,9 @@ static const char *parse_device_options(int argc, const char **argv,
case ACTION_DISABLE:
action_string = "disable";
break;
+ case ACTION_ENABLE:
+ action_string = "enable";
+ break;
default:
action_string = "<>";
break;
@@ -172,6 +181,7 @@ static const char *parse_device_options(int argc, const char **argv,
/* fall through */
case ACTION_OFFLINE:
case ACTION_DISABLE:
+ case ACTION_ENABLE:
/* nothing special */
break;
}
@@ -515,6 +525,14 @@ static int do_xble(struct daxctl_dev *dev, enum device_action action)
}
switch (action) {
+ case ACTION_ENABLE:
+ rc = daxctl_dev_enable_devdax(dev);
+ if (rc) {
+ fprintf(stderr, "%s: enable failed: %s\n",
+ daxctl_dev_get_devname(dev), strerror(-rc));
+ return rc;
+ }
+ break;
case ACTION_DISABLE:
rc = daxctl_dev_disable(dev);
if (rc) {
@@ -564,6 +582,11 @@ static int do_xaction_device(const char *device, enum device_action action,
if (rc == 0)
(*processed)++;
break;
+ case ACTION_ENABLE:
+ rc = do_xble(dev, action);
+ if (rc == 0)
+ (*processed)++;
+ break;
case ACTION_DISABLE:
rc = do_xble(dev, action);
if (rc == 0)
@@ -621,6 +644,23 @@ int cmd_disable_device(int argc, const char **argv, struct daxctl_ctx *ctx)
return rc;
}
+int cmd_enable_device(int argc, const char **argv, struct daxctl_ctx *ctx)
+{
+ char *usage = "daxctl enable-device <device>";
+ const char *device = parse_device_options(argc, argv, ACTION_DISABLE,
+ enable_options, usage, ctx);
+ int processed, rc;
+
+ rc = do_xaction_device(device, ACTION_ENABLE, ctx, &processed);
+ if (rc < 0)
+ fprintf(stderr, "error enabling device: %s\n",
+ strerror(-rc));
+
+ fprintf(stderr, "enabled %d device%s\n", processed,
+ processed == 1 ? "" : "s");
+ return rc;
+}
+
int cmd_online_memory(int argc, const char **argv, struct daxctl_ctx *ctx)
{
char *usage = "daxctl online-memory <device> [<options>]";