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 "../include/mlx_cmd.h"
23 #include "../../mlx_utils/include/public/mlx_pci_gw.h"
24 #include "../../mlx_utils/include/public/mlx_bail.h"
25 #include "../../mlx_utils/include/public/mlx_pci.h"
26 #include "../../mlx_utils/include/public/mlx_logging.h"
27
28 mlx_status
nodnic_cmd_read(IN nodnic_device_priv * device_priv,IN mlx_uint32 address,OUT mlx_pci_gw_buffer * buffer)29 nodnic_cmd_read(
30 IN nodnic_device_priv *device_priv,
31 IN mlx_uint32 address,
32 OUT mlx_pci_gw_buffer *buffer
33 )
34 {
35 mlx_status status = MLX_SUCCESS;
36 mlx_utils *utils = NULL;
37
38 if ( device_priv == NULL || buffer == NULL ) {
39 status = MLX_INVALID_PARAMETER;
40 goto bad_param;
41 }
42
43 utils = device_priv->utils;
44
45 status = mlx_pci_gw_read(utils, PCI_GW_SPACE_NODNIC, address, buffer);
46 MLX_CHECK_STATUS(device_priv, status, read_error,"mlx_pci_gw_read failed");
47
48 read_error:
49 bad_param:
50 return status;
51 }
52
53 mlx_status
nodnic_cmd_write(IN nodnic_device_priv * device_priv,IN mlx_uint32 address,IN mlx_pci_gw_buffer buffer)54 nodnic_cmd_write(
55 IN nodnic_device_priv *device_priv,
56 IN mlx_uint32 address,
57 IN mlx_pci_gw_buffer buffer
58 )
59 {
60 mlx_status status = MLX_SUCCESS;
61 mlx_utils *utils = NULL;
62
63
64 if ( device_priv == NULL ) {
65 status = MLX_INVALID_PARAMETER;
66 goto bad_param;
67 }
68
69 utils = device_priv->utils;
70
71
72 status = mlx_pci_gw_write(utils, PCI_GW_SPACE_NODNIC, address, buffer);
73 MLX_CHECK_STATUS(device_priv, status, write_error,"mlx_pci_gw_write failed");
74 write_error:
75 bad_param:
76 return status;
77 }
78