[golan] Add Connect-IB, ConnectX-4 and ConnectX-4 Lx (Infiniband) support
[ipxe.git] / src / drivers / infiniband / mlx_utils / mlx_lib / mlx_wol_rol / mlx_wol_rol.c
1 /*
2 * Copyright (C) 2015 Mellanox Technologies Ltd.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License as
6 * published by the Free Software Foundation; either version 2 of the
7 * License, or any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17 * 02110-1301, USA.
18 */
19
20 FILE_LICENCE ( GPL2_OR_LATER );
21
22 #include "mlx_wol_rol.h"
23 #include "mlx_icmd.h"
24 #include "mlx_memory.h"
25 #include "mlx_bail.h"
26
27 mlx_status
28 mlx_set_wol (
29 IN mlx_utils *utils,
30 IN mlx_uint8 wol_mask
31 )
32 {
33 mlx_status status = MLX_SUCCESS;
34 struct mlx_wol_rol wol_rol;
35
36 if (utils == NULL) {
37 status = MLX_INVALID_PARAMETER;
38 goto bad_param;
39 }
40
41 mlx_memory_set(utils, &wol_rol, 0, sizeof(wol_rol));
42 wol_rol.wol_mode_valid = TRUE;
43 wol_rol.wol_mode = wol_mask;
44 status = mlx_icmd_send_command(
45 utils,
46 SET_WOL_ROL,
47 &wol_rol,
48 sizeof(wol_rol),
49 0
50 );
51 MLX_CHECK_STATUS(utils, status, icmd_err, "mlx_icmd_send_command failed");
52 icmd_err:
53 bad_param:
54 return status;
55 }
56
57 mlx_status
58 mlx_query_wol (
59 IN mlx_utils *utils,
60 OUT mlx_uint8 *wol_mask
61 )
62 {
63 mlx_status status = MLX_SUCCESS;
64 struct mlx_wol_rol wol_rol;
65
66 if (utils == NULL || wol_mask == NULL) {
67 status = MLX_INVALID_PARAMETER;
68 goto bad_param;
69 }
70
71 mlx_memory_set(utils, &wol_rol, 0, sizeof(wol_rol));
72 status = mlx_icmd_send_command(
73 utils,
74 QUERY_WOL_ROL,
75 &wol_rol,
76 0,
77 sizeof(wol_rol)
78 );
79 MLX_CHECK_STATUS(utils, status, icmd_err, "mlx_icmd_send_command failed");
80 *wol_mask = wol_rol.wol_mode;
81 icmd_err:
82 bad_param:
83 return status;
84 }