2 * Copyright (c) 2004-2008 Voltaire Inc. All rights reserved.
4 * This software is available to you under a choice of one of two
5 * licenses. You may choose to be licensed under the terms of the GNU
6 * General Public License (GPL) Version 2, available from the file
7 * COPYING in the main directory of this source tree, or the
8 * OpenIB.org BSD license below:
10 * Redistribution and use in source and binary forms, with or
11 * without modification, are permitted provided that the following
14 * - Redistributions of source code must retain the above
15 * copyright notice, this list of conditions and the following
18 * - Redistributions in binary form must reproduce the above
19 * copyright notice, this list of conditions and the following
20 * disclaimer in the documentation and/or other materials
21 * provided with the distribution.
23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
27 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
28 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
37 #include <infiniband/common.h>
40 # define BEGIN_C_DECLS extern "C" {
41 # define END_C_DECLS }
42 #else /* !__cplusplus */
43 # define BEGIN_C_DECLS
45 #endif /* __cplusplus */
49 #define UMAD_MAX_DEVICES 20
50 #define UMAD_ANY_PORT 0
52 typedef struct ib_mad_addr {
61 uint8_t traffic_class;
68 typedef struct ib_user_mad {
78 #define IB_UMAD_ABI_VERSION 5
79 #define IB_UMAD_ABI_DIR "/sys/class/infiniband_mad"
80 #define IB_UMAD_ABI_FILE "abi_version"
82 #define IB_IOCTL_MAGIC 0x1b
84 #define IB_USER_MAD_REGISTER_AGENT _IO(IB_IOCTL_MAGIC, 1)
85 #define IB_USER_MAD_UNREGISTER_AGENT _IO(IB_IOCTL_MAGIC, 2)
86 #define IB_USER_MAD_ENABLE_PKEY _IO(IB_IOCTL_MAGIC, 3)
88 #define UMAD_CA_NAME_LEN 20
89 #define UMAD_CA_MAX_PORTS 10 /* 0 - 9 */
90 #define UMAD_CA_MAX_AGENTS 32
92 #define SYS_INFINIBAND "/sys/class/infiniband"
94 #define SYS_INFINIBAND_MAD "/sys/class/infiniband_mad"
95 #define SYS_IB_MAD_PORT "port"
96 #define SYS_IB_MAD_DEV "ibdev"
98 #define UMAD_MAX_PORTS 64
100 #define UMAD_DEV_DIR "/dev"
102 #define SYS_CA_PORTS_DIR "ports"
104 #define SYS_NODE_TYPE "node_type"
105 #define SYS_CA_FW_VERS "fw_ver"
106 #define SYS_CA_HW_VERS "hw_rev"
107 #define SYS_CA_TYPE "hca_type"
108 #define SYS_CA_NODE_GUID "node_guid"
109 #define SYS_CA_SYS_GUID "sys_image_guid"
111 #define SYS_PORT_LMC "lid_mask_count"
112 #define SYS_PORT_SMLID "sm_lid"
113 #define SYS_PORT_SMSL "sm_sl"
114 #define SYS_PORT_LID "lid"
115 #define SYS_PORT_STATE "state"
116 #define SYS_PORT_PHY_STATE "phys_state"
117 #define SYS_PORT_CAPMASK "cap_mask"
118 #define SYS_PORT_RATE "rate"
119 #define SYS_PORT_GUID "port_guid"
120 #define SYS_PORT_GID "gids/0"
122 typedef struct umad_port {
123 char ca_name[UMAD_CA_NAME_LEN];
139 typedef struct umad_ca {
140 char ca_name[UMAD_CA_NAME_LEN];
147 uint64_t system_guid;
148 umad_port_t *ports[UMAD_CA_MAX_PORTS];
154 int umad_get_cas_names(char cas[][UMAD_CA_NAME_LEN], int max);
155 int umad_get_ca_portguids(char *ca_name, uint64_t *portguids, int max);
157 int umad_get_ca(char *ca_name, umad_ca_t *ca);
158 int umad_release_ca(umad_ca_t *ca);
159 int umad_get_port(char *ca_name, int portnum, umad_port_t *port);
160 int umad_release_port(umad_port_t *port);
162 int umad_get_issm_path(char *ca_name, int portnum, char path[], int max);
164 int umad_open_port(char *ca_name, int portnum);
165 int umad_close_port(int portid);
167 void * umad_get_mad(void *umad);
168 size_t umad_size(void);
169 int umad_status(void *umad);
171 ib_mad_addr_t *umad_get_mad_addr(void *umad);
172 int umad_set_grh_net(void *umad, void *mad_addr);
173 int umad_set_grh(void *umad, void *mad_addr);
174 int umad_set_addr_net(void *umad, int dlid, int dqp, int sl, int qkey);
175 int umad_set_addr(void *umad, int dlid, int dqp, int sl, int qkey);
176 int umad_set_pkey(void *umad, int pkey_index);
177 int umad_get_pkey(void *umad);
179 int umad_send(int portid, int agentid, void *umad, int length,
180 int timeout_ms, int retries);
181 int umad_recv(int portid, void *umad, int *length, int timeout_ms);
182 int umad_poll(int portid, int timeout_ms);
183 int umad_get_fd(int portid);
185 int umad_register(int portid, int mgmt_class, int mgmt_version,
186 uint8_t rmpp_version, long method_mask[16/sizeof(long)]);
187 int umad_register_oui(int portid, int mgmt_class, uint8_t rmpp_version,
188 uint8_t oui[3], long method_mask[16/sizeof(long)]);
189 int umad_unregister(int portid, int agentid);
191 int umad_debug(int level);
192 void umad_addr_dump(ib_mad_addr_t *addr);
193 void umad_dump(void *umad);
198 umad_alloc(int num, size_t size) /* alloc array of umad buffers */
200 return calloc(num, size);
204 umad_free(void *umad)