1 /*
2 * Copyright (c) 2016 Intel Corporation
3 * Copyright (c) 2023 Nordic Semiconductor ASA
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
8 #include <zephyr/logging/log.h>
9 #include <zephyr/pm/device.h>
10 LOG_MODULE_DECLARE(net_shell);
11
12 #include "net_shell_private.h"
13
cmd_net_resume(const struct shell * sh,size_t argc,char * argv[])14 static int cmd_net_resume(const struct shell *sh, size_t argc, char *argv[])
15 {
16 #if defined(CONFIG_NET_POWER_MANAGEMENT)
17 if (argv[1]) {
18 struct net_if *iface = NULL;
19 const struct device *dev;
20 int idx;
21 int ret;
22
23 idx = get_iface_idx(sh, argv[1]);
24 if (idx < 0) {
25 return -ENOEXEC;
26 }
27
28 iface = net_if_get_by_index(idx);
29 if (!iface) {
30 PR_WARNING("No such interface in index %d\n", idx);
31 return -ENOEXEC;
32 }
33
34 dev = net_if_get_device(iface);
35
36 ret = pm_device_action_run(dev, PM_DEVICE_ACTION_RESUME);
37 if (ret != 0) {
38 PR_INFO("Iface could not be resumed\n");
39 }
40
41 } else {
42 PR("Usage:\n");
43 PR("\tresume <iface index>\n");
44 }
45 #else
46 PR_INFO("You need a network driver supporting Power Management.\n");
47 #endif /* CONFIG_NET_POWER_MANAGEMENT */
48
49 return 0;
50 }
51
52 SHELL_SUBCMD_ADD((net), resume, NULL,
53 "Resume a network interface",
54 cmd_net_resume, 1, 0);
55