[golan] Add Connect-IB, ConnectX-4 and ConnectX-4 Lx (Infiniband) support
[ipxe.git] / src / drivers / infiniband / mlx_utils / src / public / mlx_pci.c
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 #include "../../include/private/mlx_pci_priv.h"
24 #include "../../include/public/mlx_pci.h"
25
26 mlx_status
27 mlx_pci_init(
28 IN mlx_utils *utils
29 )
30 {
31 mlx_status status = MLX_SUCCESS;
32 if( utils == NULL){
33 status = MLX_INVALID_PARAMETER;
34 goto bail;
35 }
36 status = mlx_pci_init_priv(utils);
37 bail:
38 return status;
39 }
40
41 mlx_status
42 mlx_pci_read(
43 IN mlx_utils *utils,
44 IN mlx_pci_width width,
45 IN mlx_uint32 offset,
46 IN mlx_uintn count,
47 OUT mlx_void *buffer
48 )
49 {
50 mlx_status status = MLX_SUCCESS;
51 if( utils == NULL || count == 0){
52 status = MLX_INVALID_PARAMETER;
53 goto bail;
54 }
55 status = mlx_pci_read_priv(utils, width, offset, count, buffer);
56 bail:
57 return status;
58 }
59
60 mlx_status
61 mlx_pci_write(
62 IN mlx_utils *utils,
63 IN mlx_pci_width width,
64 IN mlx_uint32 offset,
65 IN mlx_uintn count,
66 IN mlx_void *buffer
67 )
68 {
69 mlx_status status = MLX_SUCCESS;
70 if( utils == NULL || count == 0){
71 status = MLX_INVALID_PARAMETER;
72 goto bail;
73 }
74 status = mlx_pci_write_priv(utils, width, offset, count, buffer);
75 bail:
76 return status;
77 }
78
79 mlx_status
80 mlx_pci_mem_read(
81 IN mlx_utils *utils,
82 IN mlx_pci_width width,
83 IN mlx_uint8 bar_index,
84 IN mlx_uint64 offset,
85 IN mlx_uintn count,
86 OUT mlx_void *buffer
87 )
88 {
89 mlx_status status = MLX_SUCCESS;
90 if( utils == NULL || count == 0){
91 status = MLX_INVALID_PARAMETER;
92 goto bail;
93 }
94 status = mlx_pci_mem_read_priv(utils, bar_index, width, offset, count, buffer);
95 bail:
96 return status;
97 }
98
99 mlx_status
100 mlx_pci_mem_write(
101 IN mlx_utils *utils,
102 IN mlx_pci_width width,
103 IN mlx_uint8 bar_index,
104 IN mlx_uint64 offset,
105 IN mlx_uintn count,
106 IN mlx_void *buffer
107 )
108 {
109 mlx_status status = MLX_SUCCESS;
110 if( utils == NULL || count == 0){
111 status = MLX_INVALID_PARAMETER;
112 goto bail;
113 }
114 status = mlx_pci_mem_write_priv(utils, width, bar_index, offset, count, buffer);
115 bail:
116 return status;
117 }