iPXE
mlx_utils.h
Go to the documentation of this file.
00001 #ifndef MLXUTILS_INCLUDE_PUBLIC_MLXUTILS_H_
00002 #define MLXUTILS_INCLUDE_PUBLIC_MLXUTILS_H_
00003 
00004 /*
00005  * Copyright (C) 2015 Mellanox Technologies Ltd.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License as
00009  * published by the Free Software Foundation; either version 2 of the
00010  * License, or any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful, but
00013  * WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  * General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00020  * 02110-1301, USA.
00021  */
00022 
00023 FILE_LICENCE ( GPL2_OR_LATER );
00024 
00025 #include "mlx_logging.h"
00026 #include "mlx_types.h"
00027 
00028 #define IN
00029 #define OUT
00030 
00031 typedef mlx_uint16      mlx_pci_gw_space;
00032 
00033 typedef struct{
00034         mlx_uint32      pci_cmd_offset;
00035         mlx_pci_gw_space space;
00036 } __attribute__ (( packed )) mlx_pci_gw;
00037 
00038 typedef struct {
00039         mlx_boolean icmd_opened;
00040         mlx_boolean took_semaphore;
00041         mlx_uint32 max_cmd_size;
00042 } __attribute__ (( packed )) mlx_icmd ;
00043 
00044 typedef  struct{
00045         mlx_pci *pci;
00046         mlx_pci_gw pci_gw;
00047         mlx_icmd icmd;
00048         void *lock;
00049 #ifdef DEVICE_CX3
00050         /* ACCESS to BAR0 */
00051         void *config;
00052 #endif
00053 } __attribute__ (( packed )) mlx_utils;
00054 
00055 mlx_status
00056 mlx_utils_init(
00057                                 IN mlx_utils *utils,
00058                                 IN mlx_pci *pci
00059                                 );
00060 
00061 mlx_status
00062 mlx_utils_teardown(
00063                                 IN mlx_utils *utils
00064                                 );
00065 mlx_status
00066 mlx_utils_delay_in_ms(
00067                         IN mlx_uint32 msecs
00068                 );
00069 
00070 mlx_status
00071 mlx_utils_delay_in_us(
00072                         IN mlx_uint32 usecs
00073                 );
00074 
00075 mlx_status
00076 mlx_utils_ilog2(
00077                         IN mlx_uint32 i,
00078                         OUT mlx_uint32 *log
00079                 );
00080 
00081 mlx_status
00082 mlx_utils_init_lock(
00083                         IN OUT mlx_utils *utils
00084                 );
00085 
00086 mlx_status
00087 mlx_utils_free_lock(
00088                         IN OUT mlx_utils *utils
00089                 );
00090 
00091 mlx_status
00092 mlx_utils_acquire_lock (
00093                         IN OUT mlx_utils *utils
00094                 );
00095 
00096 mlx_status
00097 mlx_utils_release_lock (
00098                 IN OUT mlx_utils *utils
00099                 );
00100 
00101 mlx_status
00102 mlx_utils_rand (
00103                 IN mlx_utils *utils,
00104                 OUT mlx_uint32 *rand_num
00105                 );
00106 #endif /* STUB_MLXUTILS_INCLUDE_PUBLIC_MLXUTILS_H_ */