osm_vendor_mlx_sim.c revision 219820
1254885Sdumbbell/* 2254885Sdumbbell * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved. 3254885Sdumbbell * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved. 4254885Sdumbbell * Copyright (c) 1996-2003 Intel Corporation. All rights reserved. 5254885Sdumbbell * 6254885Sdumbbell * This software is available to you under a choice of one of two 7254885Sdumbbell * licenses. You may choose to be licensed under the terms of the GNU 8254885Sdumbbell * General Public License (GPL) Version 2, available from the file 9254885Sdumbbell * COPYING in the main directory of this source tree, or the 10254885Sdumbbell * OpenIB.org BSD license below: 11254885Sdumbbell * 12254885Sdumbbell * Redistribution and use in source and binary forms, with or 13254885Sdumbbell * without modification, are permitted provided that the following 14254885Sdumbbell * conditions are met: 15254885Sdumbbell * 16254885Sdumbbell * - Redistributions of source code must retain the above 17254885Sdumbbell * copyright notice, this list of conditions and the following 18254885Sdumbbell * disclaimer. 19254885Sdumbbell * 20254885Sdumbbell * - Redistributions in binary form must reproduce the above 21254885Sdumbbell * copyright notice, this list of conditions and the following 22254885Sdumbbell * disclaimer in the documentation and/or other materials 23254885Sdumbbell * provided with the distribution. 24254885Sdumbbell * 25254885Sdumbbell * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 26254885Sdumbbell * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 27254885Sdumbbell * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 28254885Sdumbbell * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 29254885Sdumbbell * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 30254885Sdumbbell * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 31254885Sdumbbell * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 32254885Sdumbbell * SOFTWARE. 33254885Sdumbbell * 34254885Sdumbbell */ 35254885Sdumbbell 36254885Sdumbbell/* AUTHOR Eitan Zahavi 37254885Sdumbbell * 38254885Sdumbbell * DESCRIPTION 39254885Sdumbbell * The lower-level MAD transport interface implementation 40254885Sdumbbell * that allows sending a single MAD/receiving a callback 41254885Sdumbbell * when a single MAD is received. 42254885Sdumbbell */ 43254885Sdumbbell 44254885Sdumbbell#if HAVE_CONFIG_H 45254885Sdumbbell# include <config.h> 46254885Sdumbbell#endif /* HAVE_CONFIG_H */ 47254885Sdumbbell 48254885Sdumbbell#include <sys/types.h> 49254885Sdumbbell#include <sys/stat.h> 50254885Sdumbbell#include <sys/ioctl.h> 51254885Sdumbbell#include <fcntl.h> 52254885Sdumbbell#include <errno.h> 53254885Sdumbbell#include <stdlib.h> 54254885Sdumbbell#include <string.h> 55254885Sdumbbell 56254885Sdumbbell#include <vendor/osm_vendor_api.h> 57254885Sdumbbell#include <vendor/osm_vendor_mlx_transport.h> 58254885Sdumbbell#include <vendor/osm_vendor_mlx_dispatcher.h> 59254885Sdumbbell#include <vendor/osm_vendor_mlx_svc.h> 60254885Sdumbbell#include <complib/cl_thread.h> 61254885Sdumbbell 62254885Sdumbbell/* the simulator messages definition */ 63254885Sdumbbell#include <ibmgtsim/ibms_client_api.h> 64254885Sdumbbell 65254885Sdumbbelltypedef struct _osmv_ibms_transport_mgr { 66254885Sdumbbell ibms_conn_handle_t conHdl; /* the connection handle we talk to */ 67254885Sdumbbell ibms_bind_msg_t filter; /* the bind message defining the filtering */ 68254885Sdumbbell cl_thread_t receiver; /* the thread waiting for incomming messages */ 69254885Sdumbbell} osmv_ibms_transport_mgr_t; 70254885Sdumbbell 71254885Sdumbbellstatic void 72254885Sdumbbell__osmv_ibms_mad_addr_to_osm_addr(IN osm_vendor_t const *p_vend, 73254885Sdumbbell IN struct _ibms_mad_addr *p_ibms_addr, 74254885Sdumbbell IN uint8_t is_smi, 75254885Sdumbbell OUT osm_mad_addr_t * p_osm_addr); 76254885Sdumbbell 77254885Sdumbbellstatic void 78254885Sdumbbell__osmv_ibms_osm_addr_to_mad_addr(IN const osm_mad_addr_t * p_osm_addr, 79254885Sdumbbell IN uint8_t is_smi, 80254885Sdumbbell OUT struct _ibms_mad_addr *p_ibms_addr); 81254885Sdumbbell 82254885Sdumbbell/* this is the callback function the "server" will call on incoming 83254885Sdumbbell messages */ 84254885Sdumbbellvoid __osmv_ibms_receiver_callback(void *p_ctx, ibms_mad_msg_t * p_mad) 85254885Sdumbbell{ 86254885Sdumbbell osm_mad_addr_t mad_addr; 87254885Sdumbbell osmv_bind_obj_t *const p_bo = (osmv_bind_obj_t *) p_ctx; 88254885Sdumbbell ib_api_status_t status = IB_SUCCESS; 89254885Sdumbbell 90254885Sdumbbell /* Make sure the p_bo object is still relevant */ 91254885Sdumbbell if ((p_bo->magic_ptr != p_bo) || p_bo->is_closing) 92254885Sdumbbell return; 93254885Sdumbbell 94254885Sdumbbell { 95254885Sdumbbell OSM_LOG_ENTER(p_bo->p_vendor->p_log); 96254885Sdumbbell 97254885Sdumbbell /* some logging */ 98254885Sdumbbell osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG, 99254885Sdumbbell "__osmv_ibms_receiver_callback: " 100254885Sdumbbell "MAD QPN:%d SLID:0x%04x class:0x%02x " 101254885Sdumbbell "method:0x%02x attr:0x%04x status:0x%04x " 102254885Sdumbbell "tid:0x%016" PRIx64 "\n", 103254885Sdumbbell p_mad->addr.dqpn, 104254885Sdumbbell cl_ntoh16(p_mad->addr.slid), 105254885Sdumbbell p_mad->header.mgmt_class, 106254885Sdumbbell p_mad->header.method, 107254885Sdumbbell cl_ntoh16(p_mad->header.attr_id), 108254885Sdumbbell cl_ntoh16(p_mad->header.status), 109254885Sdumbbell cl_ntoh64(p_mad->header.trans_id)); 110254885Sdumbbell 111254885Sdumbbell /* first arrange an address */ 112254885Sdumbbell __osmv_ibms_mad_addr_to_osm_addr(p_bo->p_vendor, 113254885Sdumbbell &p_mad->addr, 114254885Sdumbbell (((ib_mad_t *) & p_mad-> 115254885Sdumbbell header)->mgmt_class == 116254885Sdumbbell IB_MCLASS_SUBN_LID) 117254885Sdumbbell || 118254885Sdumbbell (((ib_mad_t *) & p_mad-> 119254885Sdumbbell header)->mgmt_class == 120254885Sdumbbell IB_MCLASS_SUBN_DIR), 121254885Sdumbbell &mad_addr); 122254885Sdumbbell 123254885Sdumbbell /* call the receiver callback */ 124254885Sdumbbell 125254885Sdumbbell status = 126254885Sdumbbell osmv_dispatch_mad((osm_bind_handle_t) p_bo, 127254885Sdumbbell (void *)&p_mad->header, &mad_addr); 128254885Sdumbbell 129254885Sdumbbell OSM_LOG_EXIT(p_bo->p_vendor->p_log); 130254885Sdumbbell } 131254885Sdumbbell} 132254885Sdumbbell 133254885Sdumbbellib_api_status_t 134254885Sdumbbellosm_vendor_get_guid_by_ca_and_port(IN osm_vendor_t * const p_vend, 135254885Sdumbbell IN char *hca_id, 136254885Sdumbbell IN uint32_t port_num, 137254885Sdumbbell OUT uint64_t * p_port_guid); 138254885Sdumbbell 139254885Sdumbbell/* 140254885Sdumbbell * NAME 141254885Sdumbbell * osmv_transport_init 142254885Sdumbbell * 143282199Sdumbbell * DESCRIPTION 144254885Sdumbbell * Setup the MAD transport infrastructure (filters, callbacks etc). 145254885Sdumbbell */ 146254885Sdumbbell 147254885Sdumbbellib_api_status_t 148254885Sdumbbellosmv_transport_init(IN osm_bind_info_t * p_info, 149254885Sdumbbell IN char hca_id[VENDOR_HCA_MAXNAMES], 150254885Sdumbbell IN uint8_t hca_idx, IN osmv_bind_obj_t * p_bo) 151254885Sdumbbell{ 152254885Sdumbbell ibms_conn_handle_t conHdl; /* the connection we talk to the simulator through */ 153254885Sdumbbell osmv_ibms_transport_mgr_t *p_mgr = 154254885Sdumbbell malloc(sizeof(osmv_ibms_transport_mgr_t)); 155254885Sdumbbell int qpn; 156254885Sdumbbell int ibms_status; 157254885Sdumbbell uint64_t port_guid; 158254885Sdumbbell 159254885Sdumbbell if (!p_mgr) { 160254885Sdumbbell return IB_INSUFFICIENT_MEMORY; 161254885Sdumbbell } 162254885Sdumbbell 163254885Sdumbbell memset(p_mgr, 0, sizeof(osmv_ibms_transport_mgr_t)); 164254885Sdumbbell 165254885Sdumbbell /* create the client socket connected to the simulator */ 166254885Sdumbbell /* also perform the "connect" message - such that we 167254885Sdumbbell validate the target guid */ 168254885Sdumbbell if (osm_vendor_get_guid_by_ca_and_port 169254885Sdumbbell (p_bo->p_vendor, hca_id, p_bo->port_num, &port_guid)) { 170254885Sdumbbell return IB_INVALID_GUID; 171254885Sdumbbell } 172254885Sdumbbell 173254885Sdumbbell conHdl = 174254885Sdumbbell ibms_connect(port_guid, __osmv_ibms_receiver_callback, 175254885Sdumbbell (void *)p_bo); 176282199Sdumbbell if (!conHdl) { 177254885Sdumbbell printf("fail to connect to the server.\n"); 178254885Sdumbbell exit(1); 179254885Sdumbbell } 180254885Sdumbbell 181254885Sdumbbell /* 182254885Sdumbbell * Create the MAD filter on this file handle. 183254885Sdumbbell */ 184254885Sdumbbell 185254885Sdumbbell p_mgr->filter.port = p_bo->port_num; 186254885Sdumbbell p_mgr->filter.only_input = 1; 187254885Sdumbbell p_mgr->filter.mask = 188254885Sdumbbell IBMS_BIND_MASK_PORT | 189254885Sdumbbell IBMS_BIND_MASK_INPUT | IBMS_BIND_MASK_QP | IBMS_BIND_MASK_CLASS; 190254885Sdumbbell 191254885Sdumbbell switch (p_info->mad_class) { 192254885Sdumbbell case IB_MCLASS_SUBN_LID: 193254885Sdumbbell case IB_MCLASS_SUBN_DIR: 194254885Sdumbbell qpn = 0; 195254885Sdumbbell p_mgr->filter.qpn = qpn; 196254885Sdumbbell p_mgr->filter.mgt_class = IB_MCLASS_SUBN_LID; 197254885Sdumbbell ibms_status = ibms_bind(conHdl, &p_mgr->filter); 198254885Sdumbbell if (ibms_status) { 199254885Sdumbbell return IB_ERROR; 200254885Sdumbbell } 201254885Sdumbbell 202254885Sdumbbell p_mgr->filter.mgt_class = IB_MCLASS_SUBN_DIR; 203254885Sdumbbell ibms_status = ibms_bind(conHdl, &p_mgr->filter); 204254885Sdumbbell if (ibms_status) { 205254885Sdumbbell return IB_ERROR; 206254885Sdumbbell } 207254885Sdumbbell 208254885Sdumbbell break; 209254885Sdumbbell 210254885Sdumbbell case IB_MCLASS_SUBN_ADM: 211254885Sdumbbell default: 212254885Sdumbbell qpn = 1; 213254885Sdumbbell p_mgr->filter.qpn = qpn; 214254885Sdumbbell p_mgr->filter.mgt_class = p_info->mad_class; 215254885Sdumbbell ibms_status = ibms_bind(conHdl, &p_mgr->filter); 216254885Sdumbbell if (ibms_status) { 217254885Sdumbbell return IB_ERROR; 218254885Sdumbbell } 219254885Sdumbbell break; 220254885Sdumbbell } 221254885Sdumbbell 222254885Sdumbbell p_mgr->conHdl = conHdl; 223254885Sdumbbell 224254885Sdumbbell p_bo->p_transp_mgr = p_mgr; 225254885Sdumbbell 226254885Sdumbbell /* Initialize the magic_ptr to the pointer of the p_bo info. 227254885Sdumbbell This will be used to signal when the object is being destroyed, so no 228254885Sdumbbell real action will be done then. */ 229254885Sdumbbell p_bo->magic_ptr = p_bo; 230254885Sdumbbell 231254885Sdumbbell return IB_SUCCESS; 232254885Sdumbbell} 233254885Sdumbbell 234254885Sdumbbell/* 235254885Sdumbbell * NAME 236254885Sdumbbell * osmv_transport_send_mad 237254885Sdumbbell * 238254885Sdumbbell * DESCRIPTION 239254885Sdumbbell * Send a single MAD (256 byte) 240254885Sdumbbell */ 241254885Sdumbbell 242254885Sdumbbellib_api_status_t 243254885Sdumbbellosmv_transport_mad_send(IN const osm_bind_handle_t h_bind, 244254885Sdumbbell IN void *p_mad, IN const osm_mad_addr_t * p_mad_addr) 245254885Sdumbbell{ 246254885Sdumbbell 247254885Sdumbbell osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind; 248254885Sdumbbell osm_vendor_t const *p_vend = p_bo->p_vendor; 249254885Sdumbbell int ret; 250254885Sdumbbell ibms_mad_msg_t mad_msg; 251254885Sdumbbell ib_api_status_t status; 252254885Sdumbbell 253254885Sdumbbell const ib_mad_t *p_mad_hdr = p_mad; 254254885Sdumbbell 255254885Sdumbbell OSM_LOG_ENTER(p_vend->p_log); 256254885Sdumbbell 257254885Sdumbbell memset(&mad_msg, 0, sizeof(mad_msg)); 258254885Sdumbbell 259254885Sdumbbell /* Make sure the p_bo object is still relevant */ 260254885Sdumbbell if ((p_bo->magic_ptr != p_bo) || p_bo->is_closing) 261254885Sdumbbell return IB_INVALID_CALLBACK; 262254885Sdumbbell 263254885Sdumbbell /* 264282199Sdumbbell * Copy the MAD over to the sent mad 265254885Sdumbbell */ 266254885Sdumbbell memcpy(&mad_msg.header, p_mad_hdr, MAD_BLOCK_SIZE); 267254885Sdumbbell 268254885Sdumbbell /* 269254885Sdumbbell * For all sends other than directed route SM MADs, 270254885Sdumbbell * acquire an address vector for the destination. 271254885Sdumbbell */ 272254885Sdumbbell if (p_mad_hdr->mgmt_class != IB_MCLASS_SUBN_DIR) { 273254885Sdumbbell 274254885Sdumbbell __osmv_ibms_osm_addr_to_mad_addr(p_mad_addr, 275282199Sdumbbell p_mad_hdr->mgmt_class == 276254885Sdumbbell IB_MCLASS_SUBN_LID, 277254885Sdumbbell &mad_msg.addr); 278254885Sdumbbell } else { 279254885Sdumbbell /* is a directed route - we need to construct a permissive address */ 280254885Sdumbbell /* we do not need port number since it is part of the mad_hndl */ 281282199Sdumbbell mad_msg.addr.dlid = IB_LID_PERMISSIVE; 282254885Sdumbbell mad_msg.addr.slid = IB_LID_PERMISSIVE; 283254885Sdumbbell mad_msg.addr.sqpn = 0; 284254885Sdumbbell mad_msg.addr.dqpn = 0; 285254885Sdumbbell } 286254885Sdumbbell 287254885Sdumbbell osm_log(p_bo->p_vendor->p_log, OSM_LOG_DEBUG, 288254885Sdumbbell "osmv_transport_mad_send: " 289254885Sdumbbell "Sending QPN:%d DLID:0x%04x class:0x%02x " 290254885Sdumbbell "method:0x%02x attr:0x%04x status:0x%04x " 291254885Sdumbbell "tid:0x%016" PRIx64 "\n", 292254885Sdumbbell mad_msg.addr.dqpn, 293254885Sdumbbell cl_ntoh16(mad_msg.addr.dlid), 294254885Sdumbbell mad_msg.header.mgmt_class, 295254885Sdumbbell mad_msg.header.method, 296254885Sdumbbell cl_ntoh16(mad_msg.header.attr_id), 297254885Sdumbbell cl_ntoh16(mad_msg.header.status), 298254885Sdumbbell cl_ntoh64(mad_msg.header.trans_id) 299254885Sdumbbell ); 300254885Sdumbbell 301254885Sdumbbell /* send it */ 302254885Sdumbbell ret = 303254885Sdumbbell ibms_send(((osmv_ibms_transport_mgr_t *) (p_bo->p_transp_mgr))-> 304254885Sdumbbell conHdl, &mad_msg); 305254885Sdumbbell if (ret) { 306254885Sdumbbell osm_log(p_vend->p_log, OSM_LOG_ERROR, 307254885Sdumbbell "osmv_transport_mad_send: ERR 5304: " 308254885Sdumbbell "Error sending mad (%d).\n", ret); 309254885Sdumbbell status = IB_ERROR; 310254885Sdumbbell goto Exit; 311254885Sdumbbell } 312254885Sdumbbell 313254885Sdumbbell status = IB_SUCCESS; 314254885Sdumbbell 315254885SdumbbellExit: 316254885Sdumbbell OSM_LOG_EXIT(p_vend->p_log); 317254885Sdumbbell return (status); 318254885Sdumbbell} 319254885Sdumbbell 320254885Sdumbbellvoid osmv_transport_done(IN const osm_bind_handle_t h_bind) 321254885Sdumbbell{ 322254885Sdumbbell osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind; 323254885Sdumbbell osmv_ibms_transport_mgr_t *p_tpot_mgr = 324254885Sdumbbell (osmv_ibms_transport_mgr_t *) (p_bo->p_transp_mgr); 325254885Sdumbbell 326254885Sdumbbell CL_ASSERT(p_bo); 327254885Sdumbbell 328254885Sdumbbell /* First of all - zero out the magic_ptr, so if a callback is called - 329254885Sdumbbell it'll know that we are currently closing down, and will not handle the 330254885Sdumbbell mad. */ 331254885Sdumbbell p_bo->magic_ptr = 0; 332254885Sdumbbell /* usleep(3000000); */ 333254885Sdumbbell 334254885Sdumbbell ibms_disconnect(p_tpot_mgr->conHdl); 335254885Sdumbbell 336254885Sdumbbell /* seems the only way to abort a blocking read is to make it read something */ 337254885Sdumbbell free(p_tpot_mgr); 338254885Sdumbbell} 339254885Sdumbbell 340254885Sdumbbellstatic void 341254885Sdumbbell__osmv_ibms_osm_addr_to_mad_addr(IN const osm_mad_addr_t * p_osm_addr, 342254885Sdumbbell IN uint8_t is_smi, 343254885Sdumbbell OUT struct _ibms_mad_addr *p_ibms_addr) 344254885Sdumbbell{ 345254885Sdumbbell 346254885Sdumbbell /* For global destination or Multicast address: */ 347254885Sdumbbell p_ibms_addr->dlid = cl_ntoh16(p_osm_addr->dest_lid); 348254885Sdumbbell p_ibms_addr->sl = p_osm_addr->addr_type.gsi.service_level; 349254885Sdumbbell if (is_smi) { 350254885Sdumbbell p_ibms_addr->sqpn = 0; 351254885Sdumbbell p_ibms_addr->dqpn = 0; 352254885Sdumbbell } else { 353254885Sdumbbell p_ibms_addr->sqpn = 1; 354254885Sdumbbell p_ibms_addr->dqpn = 355254885Sdumbbell cl_ntoh32(p_osm_addr->addr_type.gsi.remote_qp); 356254885Sdumbbell } 357254885Sdumbbell /* 358254885Sdumbbell HACK we limit to the first PKey Index assuming it will 359254885Sdumbbell always be the default PKey 360254885Sdumbbell */ 361254885Sdumbbell p_ibms_addr->pkey_index = 0; 362254885Sdumbbell} 363254885Sdumbbell 364254885Sdumbbellstatic void 365254885Sdumbbell__osmv_ibms_mad_addr_to_osm_addr(IN osm_vendor_t const *p_vend, 366254885Sdumbbell IN struct _ibms_mad_addr *p_ibms_addr, 367254885Sdumbbell IN uint8_t is_smi, 368254885Sdumbbell OUT osm_mad_addr_t * p_osm_addr) 369254885Sdumbbell{ 370254885Sdumbbell memset(p_osm_addr, 0, sizeof(osm_mad_addr_t)); 371254885Sdumbbell p_osm_addr->dest_lid = cl_hton16(p_ibms_addr->slid); 372254885Sdumbbell p_osm_addr->static_rate = 0; 373254885Sdumbbell p_osm_addr->path_bits = 0; 374254885Sdumbbell if (is_smi) { 375254885Sdumbbell /* SMI */ 376254885Sdumbbell p_osm_addr->addr_type.smi.source_lid = 377254885Sdumbbell cl_hton16(p_ibms_addr->slid); 378254885Sdumbbell p_osm_addr->addr_type.smi.port_num = 1; /* TODO add if required p_ibms_addr->port; */ 379254885Sdumbbell } else { 380254885Sdumbbell /* GSI */ 381254885Sdumbbell p_osm_addr->addr_type.gsi.remote_qp = 382254885Sdumbbell cl_ntoh32(p_ibms_addr->sqpn); 383254885Sdumbbell p_osm_addr->addr_type.gsi.remote_qkey = IB_QP1_WELL_KNOWN_Q_KEY; 384254885Sdumbbell p_osm_addr->addr_type.gsi.pkey_ix = p_ibms_addr->pkey_index; 385254885Sdumbbell p_osm_addr->addr_type.gsi.service_level = p_ibms_addr->sl; 386254885Sdumbbell 387254885Sdumbbell p_osm_addr->addr_type.gsi.global_route = FALSE; 388254885Sdumbbell /* copy the GRH data if relevant - TopSpin imp doesnt relate to GRH!!! */ 389254885Sdumbbell /* 390254885Sdumbbell if (p_osm_addr->addr_type.gsi.global_route) 391254885Sdumbbell { 392254885Sdumbbell p_osm_addr->addr_type.gsi.grh_info.ver_class_flow = 393254885Sdumbbell ib_grh_set_ver_class_flow(p_rcv_desc->grh.IP_version, 394254885Sdumbbell p_rcv_desc->grh.traffic_class, 395254885Sdumbbell p_rcv_desc->grh.flow_label); 396254885Sdumbbell p_osm_addr->addr_type.gsi.grh_info.hop_limit = p_rcv_desc->grh.hop_limit; 397254885Sdumbbell memcpy(&p_osm_addr->addr_type.gsi.grh_info.src_gid.raw, 398254885Sdumbbell &p_rcv_desc->grh.sgid, sizeof(ib_net64_t)); 399254885Sdumbbell memcpy(&p_osm_addr->addr_type.gsi.grh_info.dest_gid.raw, 400254885Sdumbbell p_rcv_desc->grh.dgid, sizeof(ib_net64_t)); 401254885Sdumbbell } 402254885Sdumbbell */ 403254885Sdumbbell } 404254885Sdumbbell} 405254885Sdumbbell 406254885Sdumbbell/* 407254885Sdumbbell * NAME osm_vendor_set_sm 408254885Sdumbbell * 409254885Sdumbbell * DESCRIPTION Modifies the port info for the bound port to set the "IS_SM" bit 410254885Sdumbbell * according to the value given (TRUE or FALSE). 411254885Sdumbbell */ 412254885Sdumbbell 413254885Sdumbbellvoid osm_vendor_set_sm(IN osm_bind_handle_t h_bind, IN boolean_t is_sm_val) 414254885Sdumbbell{ 415254885Sdumbbell osmv_bind_obj_t *p_bo = (osmv_bind_obj_t *) h_bind; 416254885Sdumbbell osm_vendor_t const *p_vend = p_bo->p_vendor; 417254885Sdumbbell int ret; 418254885Sdumbbell ibms_cap_msg_t cap_msg; 419254885Sdumbbell 420254885Sdumbbell OSM_LOG_ENTER(p_vend->p_log); 421254885Sdumbbell 422254885Sdumbbell cap_msg.mask = IB_PORT_CAP_IS_SM; 423254885Sdumbbell if (is_sm_val) 424254885Sdumbbell cap_msg.capabilities = IB_PORT_CAP_IS_SM; 425254885Sdumbbell else 426254885Sdumbbell cap_msg.capabilities = 0; 427254885Sdumbbell 428254885Sdumbbell ret = ibms_set_cap(((osmv_ibms_transport_mgr_t *) (p_bo-> 429254885Sdumbbell p_transp_mgr))-> 430254885Sdumbbell conHdl, &cap_msg); 431254885Sdumbbell 432254885Sdumbbell if (ret) { 433254885Sdumbbell osm_log(p_vend->p_log, OSM_LOG_ERROR, 434254885Sdumbbell "osm_vendor_set_sm: ERR 5312: " 435254885Sdumbbell "Unable set 'IS_SM' bit to:%u in port attributes.\n", 436254885Sdumbbell is_sm_val); 437254885Sdumbbell } 438254885Sdumbbell OSM_LOG_EXIT(p_vend->p_log); 439254885Sdumbbell} 440254885Sdumbbell