[golan] Add Connect-IB, ConnectX-4 and ConnectX-4 Lx (Infiniband) support
[ipxe.git] / src / drivers / infiniband / mlx_utils / include / public / mlx_utils.h
1 #ifndef MLXUTILS_INCLUDE_PUBLIC_MLXUTILS_H_
2 #define MLXUTILS_INCLUDE_PUBLIC_MLXUTILS_H_
3
4 /*
5 * Copyright (C) 2015 Mellanox Technologies Ltd.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License as
9 * published by the Free Software Foundation; either version 2 of the
10 * License, or any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
20 * 02110-1301, USA.
21 */
22
23 FILE_LICENCE ( GPL2_OR_LATER );
24
25 #include "mlx_logging.h"
26 #include "mlx_types.h"
27
28 #define IN
29 #define OUT
30
31 typedef mlx_uint16 mlx_pci_gw_space;
32
33 typedef struct{
34 mlx_uint32 pci_cmd_offset;
35 mlx_pci_gw_space space;
36 } __attribute__ (( packed )) mlx_pci_gw;
37
38 typedef struct {
39 mlx_boolean icmd_opened;
40 mlx_boolean took_semaphore;
41 mlx_uint32 max_cmd_size;
42 } __attribute__ (( packed )) mlx_icmd ;
43
44 typedef struct{
45 mlx_pci *pci;
46 mlx_pci_gw pci_gw;
47 mlx_icmd icmd;
48 void *lock;
49 #ifdef DEVICE_CX3
50 /* ACCESS to BAR0 */
51 void *config;
52 #endif
53 } __attribute__ (( packed )) mlx_utils;
54
55 mlx_status
56 mlx_utils_init(
57 IN mlx_utils *utils,
58 IN mlx_pci *pci
59 );
60
61 mlx_status
62 mlx_utils_teardown(
63 IN mlx_utils *utils
64 );
65 mlx_status
66 mlx_utils_delay_in_ms(
67 IN mlx_uint32 msecs
68 );
69
70 mlx_status
71 mlx_utils_delay_in_us(
72 IN mlx_uint32 usecs
73 );
74
75 mlx_status
76 mlx_utils_ilog2(
77 IN mlx_uint32 i,
78 OUT mlx_uint32 *log
79 );
80
81 mlx_status
82 mlx_utils_init_lock(
83 IN OUT mlx_utils *utils
84 );
85
86 mlx_status
87 mlx_utils_free_lock(
88 IN OUT mlx_utils *utils
89 );
90
91 mlx_status
92 mlx_utils_acquire_lock (
93 IN OUT mlx_utils *utils
94 );
95
96 mlx_status
97 mlx_utils_release_lock (
98 IN OUT mlx_utils *utils
99 );
100
101 mlx_status
102 mlx_utils_rand (
103 IN mlx_utils *utils,
104 OUT mlx_uint32 *rand_num
105 );
106 #endif /* STUB_MLXUTILS_INCLUDE_PUBLIC_MLXUTILS_H_ */