2 * Copyright (c) 2004-2006 Voltaire, Inc. All rights reserved.
3 * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
4 * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
6 * This software is available to you under a choice of one of two
7 * licenses. You may choose to be licensed under the terms of the GNU
8 * General Public License (GPL) Version 2, available from the file
9 * COPYING in the main directory of this source tree, or the
10 * OpenIB.org BSD license below:
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
20 * - Redistributions in binary form must reproduce the above
21 * copyright notice, this list of conditions and the following
22 * disclaimer in the documentation and/or other materials
23 * provided with the distribution.
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
38 #endif /* HAVE_CONFIG_H */
40 #if defined(OSM_VENDOR_INTF_ANAFA)
48 #include <vendor/osm_vendor_api.h>
49 #include <opensm/osm_log.h>
50 #include <sys/ioctl.h>
52 #include <vendor/osm_vendor_mlx_transport_anafa.h>
53 #include <vendor/osm_ts_useraccess.h>
55 /********************************************************************************
57 * Provide the functionality for selecting an HCA Port and Obtaining it's guid.
59 ********************************************************************************/
61 typedef struct _osm_ca_info {
62 /* ib_net64_t guid; ?? */
63 /* size_t attr_size; ?? */
67 /**********************************************************************
68 * Convert the given GID to GUID by copy of it's upper 8 bytes
69 **********************************************************************/
71 __osm_vendor_gid_to_guid(IN tTS_IB_GID gid, OUT ib_net64_t * p_guid)
73 memcpy(p_guid, gid + 8, 8);
77 /**********************************************************************
78 * Initialize an Info Struct for the Given HCA by its Id
79 **********************************************************************/
80 static ib_api_status_t
81 __osm_ca_info_init(IN osm_vendor_t * const p_vend,
82 OUT osm_ca_info_t * const p_ca_info)
84 ib_api_status_t status = IB_ERROR;
86 osmv_TOPSPIN_ANAFA_transport_info_t *p_tpot_info =
87 p_vend->p_transport_info;
88 osm_ts_gid_entry_ioctl gid_ioctl;
89 osm_ts_get_port_info_ioctl port_info;
90 struct ib_get_dev_info_ioctl dev_info;
92 OSM_LOG_ENTER(p_vend->p_log);
95 ioctl_ret = ioctl(p_tpot_info->device_fd, TS_IB_IOCGDEVINFO, &dev_info);
97 osm_log(p_vend->p_log, OSM_LOG_ERROR,
98 "__osm_ca_info_init: ERR 7001: "
99 "Fail to get HCA Capabilities (%d).\n", ioctl_ret);
103 memcpy(&(p_ca_info->attr.ca_guid), dev_info.dev_info.node_guid,
104 8 * sizeof(uint8_t));
106 /* now obtain the attributes of the ports - on our case port 1*/
108 p_ca_info->attr.num_ports = 1;
109 p_ca_info->attr.p_port_attr =
110 (ib_port_attr_t *) malloc(1 * sizeof(ib_port_attr_t));
114 ioctl(p_tpot_info->device_fd, TS_IB_IOCGPORTINFO, &port_info);
116 osm_log(p_vend->p_log, OSM_LOG_ERROR,
117 "__osm_ca_info_init: ERR 7002: "
118 "Fail to get HCA Port Attributes (%d).\n", ioctl_ret);
125 ioctl(p_tpot_info->device_fd, TS_IB_IOCGGIDENTRY, &gid_ioctl);
127 osm_log(p_vend->p_log, OSM_LOG_ERROR,
128 "__osm_ca_info_init: ERR 7003: "
129 "Fail to get HCA Port GID (%d).\n", ioctl_ret);
133 __osm_vendor_gid_to_guid(gid_ioctl.gid_entry,
134 &(p_ca_info->attr.p_port_attr[0].port_guid));
135 p_ca_info->attr.p_port_attr[0].lid = port_info.port_info.lid;
136 p_ca_info->attr.p_port_attr[0].link_state =
137 port_info.port_info.port_state;
138 p_ca_info->attr.p_port_attr[0].sm_lid = port_info.port_info.sm_lid;
142 OSM_LOG_EXIT(p_vend->p_log);
146 /**********************************************************************
147 **********************************************************************/
148 /**********************************************************************
151 * Update the vendor object list of ca_info structs
152 **********************************************************************/
154 osm_vendor_get_all_port_attr(IN osm_vendor_t * const p_vend,
155 IN ib_port_attr_t * const p_attr_array,
156 IN uint32_t * const p_num_ports)
158 ib_api_status_t status;
159 osm_ca_info_t ca_info;
160 uint32_t attr_array_sz = *p_num_ports;
162 OSM_LOG_ENTER(p_vend->p_log);
165 /* anafa has one port - the user didnt supply enough storage space */
166 if (attr_array_sz < 1) {
167 status = IB_INSUFFICIENT_MEMORY;
172 * retrieve the CA info attributes
174 status = __osm_ca_info_init(p_vend, &ca_info);
175 if (status != IB_SUCCESS) {
176 osm_log(p_vend->p_log, OSM_LOG_ERROR,
177 "osm_vendor_get_all_port_attr: ERR 7004: "
178 "Unable to initialize CA Info object (%s).\n",
179 ib_get_err_str(status));
185 p_attr_array[0] = ca_info.attr.p_port_attr[0]; /* anafa has only one port */
190 OSM_LOG_EXIT(p_vend->p_log);