iPXE
mlx_utils.c
Go to the documentation of this file.
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 <stddef.h>
23 
24 #include "../../include/private/mlx_utils_priv.h"
25 #include "../../include/public/mlx_pci.h"
26 #include "../../include/public/mlx_utils.h"
29  IN mlx_utils *utils,
30  IN mlx_pci *pci
31  )
32 {
34  if( pci == NULL || utils == NULL ){
36  goto bail;
37  }
38  utils->pci = pci;
39  status = mlx_pci_init(utils);
40  status = mlx_utils_init_lock(utils);
41 bail:
42  return status;
43 }
44 
47  IN mlx_utils *utils
48  )
49 {
51  mlx_utils_free_lock(utils);
52  mlx_pci_teardown(utils);
53  return status;
54 }
55 
58  IN mlx_uint32 msecs
59  )
60 {
62  return MLX_SUCCESS;
63 }
66  IN mlx_uint32 usecs
67  )
68 {
70  return MLX_SUCCESS;
71 }
74  IN mlx_uint32 i,
75  OUT mlx_uint32 *log
76  )
77 {
78  mlx_utils_ilog2_priv(i, log);
79  return MLX_SUCCESS;
80 }
81 
84  IN OUT mlx_utils *utils
85  )
86 {
87  return mlx_utils_init_lock_priv(&(utils->lock));
88 
89 }
90 
93  IN OUT mlx_utils *utils
94  )
95 {
96  return mlx_utils_free_lock_priv(utils->lock);
97 }
98 
101  IN OUT mlx_utils *utils
102  )
103 {
104  return mlx_utils_acquire_lock_priv(utils->lock);
105 }
106 
109  IN OUT mlx_utils *utils
110  )
111 {
112  return mlx_utils_release_lock_priv(utils->lock);
113 }
114 
117  IN mlx_utils *utils,
118  OUT mlx_uint32 *rand_num
119  )
120 {
121  return mlx_utils_rand_priv(utils, rand_num);
122 }
mlx_status mlx_utils_init_lock(IN OUT mlx_utils *utils)
Definition: mlx_utils.c:83
mlx_status mlx_utils_delay_in_us(IN mlx_uint32 usecs)
Definition: mlx_utils.c:65
mlx_status mlx_utils_rand_priv(IN mlx_utils *utils, OUT mlx_uint32 *rand_num)
FILE_LICENCE(GPL2_OR_LATER)
#define MLX_INVALID_PARAMETER
mlx_status mlx_utils_rand(IN mlx_utils *utils, OUT mlx_uint32 *rand_num)
Definition: mlx_utils.c:116
mlx_status mlx_utils_teardown(IN mlx_utils *utils)
Definition: mlx_utils.c:46
mlx_status mlx_pci_teardown(IN mlx_utils *utils)
Definition: mlx_pci.c:43
uint32_t mlx_uint32
mlx_status mlx_pci_init(IN mlx_utils *utils)
Definition: mlx_pci.c:28
#define OUT
Definition: mlx_utils.h:29
mlx_status mlx_utils_init_lock_priv(OUT void **lock)
#define MLX_SUCCESS
mlx_status mlx_utils_acquire_lock(IN OUT mlx_utils *utils)
Definition: mlx_utils.c:100
mlx_status mlx_utils_delay_in_ms_priv(IN mlx_uint32 msecs)
mlx_status mlx_utils_acquire_lock_priv(IN void *lock)
mlx_status mlx_utils_ilog2_priv(IN mlx_uint32 i, OUT mlx_uint32 *log)
A PCI device.
Definition: pci.h:206
mlx_status mlx_utils_release_lock_priv(IN void *lock)
mlx_status mlx_utils_ilog2(IN mlx_uint32 i, OUT mlx_uint32 *log)
Definition: mlx_utils.c:73
mlx_status mlx_utils_release_lock(IN OUT mlx_utils *utils)
Definition: mlx_utils.c:108
mlx_status mlx_utils_free_lock(IN OUT mlx_utils *utils)
Definition: mlx_utils.c:92
uint8_t status
Status.
Definition: ena.h:16
#define IN
Definition: mlx_utils.h:28
mlx_status mlx_utils_free_lock_priv(IN void *lock)
mlx_status mlx_utils_init(IN mlx_utils *utils, IN mlx_pci *pci)
Definition: mlx_utils.c:28
int mlx_status
mlx_status mlx_utils_delay_in_us_priv(IN mlx_uint32 usecs)
#define NULL
NULL pointer (VOID *)
Definition: Base.h:321
mlx_status mlx_utils_delay_in_ms(IN mlx_uint32 msecs)
Definition: mlx_utils.c:57