iPXE
mlx_cmd.c
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2015 Mellanox Technologies Ltd.
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License as
00006  * published by the Free Software Foundation; either version 2 of the
00007  * License, or any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017  * 02110-1301, USA.
00018  */
00019 
00020 FILE_LICENCE ( GPL2_OR_LATER );
00021 
00022 #include "../include/mlx_cmd.h"
00023 #include "../../mlx_utils/include/public/mlx_pci_gw.h"
00024 #include "../../mlx_utils/include/public/mlx_bail.h"
00025 #include "../../mlx_utils/include/public/mlx_pci.h"
00026 #include "../../mlx_utils/include/public/mlx_logging.h"
00027 
00028 mlx_status
00029 nodnic_cmd_read(
00030                                 IN nodnic_device_priv *device_priv,
00031                                 IN mlx_uint32 address,
00032                                 OUT mlx_pci_gw_buffer *buffer
00033                                 )
00034 {
00035         mlx_status              status = MLX_SUCCESS;
00036         mlx_utils               *utils = NULL;
00037 
00038         if ( device_priv == NULL || buffer == NULL ) {
00039                 status = MLX_INVALID_PARAMETER;
00040                 goto bad_param;
00041         }
00042 
00043         utils = device_priv->utils;
00044 
00045         status = mlx_pci_gw_read(utils, PCI_GW_SPACE_NODNIC, address, buffer);
00046         MLX_CHECK_STATUS(device_priv, status, read_error,"mlx_pci_gw_read failed");
00047 
00048 read_error:
00049 bad_param:
00050         return status;
00051 }
00052 
00053 mlx_status
00054 nodnic_cmd_write(
00055                                 IN nodnic_device_priv *device_priv,
00056                                 IN mlx_uint32 address,
00057                                 IN mlx_pci_gw_buffer buffer
00058                                 )
00059 {
00060         mlx_status              status = MLX_SUCCESS;
00061         mlx_utils               *utils = NULL;
00062 
00063 
00064         if ( device_priv == NULL ) {
00065                 status = MLX_INVALID_PARAMETER;
00066                 goto bad_param;
00067         }
00068 
00069         utils = device_priv->utils;
00070 
00071 
00072         status = mlx_pci_gw_write(utils, PCI_GW_SPACE_NODNIC, address, buffer);
00073         MLX_CHECK_STATUS(device_priv, status, write_error,"mlx_pci_gw_write failed");
00074 write_error:
00075 bad_param:
00076         return status;
00077 }