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_lib/mlx_vmac/mlx_vmac.h"
23 #include "../../include/public/mlx_icmd.h"
24 #include "../../include/public/mlx_bail.h"
25 
26 mlx_status
mlx_vmac_query_virt_mac(IN mlx_utils * utils,OUT struct mlx_vmac_query_virt_mac * virt_mac)27 mlx_vmac_query_virt_mac (
28 	IN mlx_utils *utils,
29 	OUT struct mlx_vmac_query_virt_mac *virt_mac
30 	)
31 {
32 	mlx_status status = MLX_SUCCESS;
33 	if (utils == NULL || virt_mac == NULL) {
34 		status = MLX_INVALID_PARAMETER;
35 		goto bad_param;
36 	}
37 
38 	status = mlx_icmd_send_command(
39 			utils,
40 			QUERY_VIRTUAL_MAC,
41 			virt_mac,
42 			0,
43 			sizeof(*virt_mac)
44 			);
45 	MLX_CHECK_STATUS(utils, status, icmd_err, "mlx_icmd_send_command failed");
46 icmd_err:
47 bad_param:
48 	return status;
49 }
50 
51 mlx_status
mlx_vmac_set_virt_mac(IN mlx_utils * utils,OUT struct mlx_vmac_set_virt_mac * virt_mac)52 mlx_vmac_set_virt_mac (
53 	IN mlx_utils *utils,
54 	OUT struct mlx_vmac_set_virt_mac *virt_mac
55 	)
56 {
57 	mlx_status status = MLX_SUCCESS;
58 	if (utils == NULL || virt_mac == NULL) {
59 		status = MLX_INVALID_PARAMETER;
60 		goto bad_param;
61 	}
62 
63 	status = mlx_icmd_send_command(
64 			utils,
65 			SET_VIRTUAL_MAC,
66 			virt_mac,
67 			sizeof(*virt_mac),
68 			0
69 			);
70 	MLX_CHECK_STATUS(utils, status, icmd_err, "mlx_icmd_send_command failed");
71 icmd_err:
72 bad_param:
73 	return status;
74 }
75