1/* 2 * Copyright (c) 2004-2009 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. 5 * 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: 11 * 12 * Redistribution and use in source and binary forms, with or 13 * without modification, are permitted provided that the following 14 * conditions are met: 15 * 16 * - Redistributions of source code must retain the above 17 * copyright notice, this list of conditions and the following 18 * disclaimer. 19 * 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. 24 * 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 32 * SOFTWARE. 33 * 34 */ 35 36/* 37 * Abstract: 38 * Declaration of osm_sa_t. 39 * This object represents an IBA subnet. 40 * This object is part of the OpenSM family of objects. 41 */ 42 43#ifndef _OSM_SA_H_ 44#define _OSM_SA_H_ 45 46#include <iba/ib_types.h> 47#include <complib/cl_passivelock.h> 48#include <complib/cl_event.h> 49#include <complib/cl_thread.h> 50#include <complib/cl_timer.h> 51#include <complib/cl_dispatcher.h> 52#include <opensm/osm_stats.h> 53#include <opensm/osm_subnet.h> 54#include <vendor/osm_vendor_api.h> 55#include <opensm/osm_mad_pool.h> 56#include <opensm/osm_log.h> 57#include <opensm/osm_sa_mad_ctrl.h> 58#include <opensm/osm_sm.h> 59#include <opensm/osm_multicast.h> 60 61#ifdef __cplusplus 62# define BEGIN_C_DECLS extern "C" { 63# define END_C_DECLS } 64#else /* !__cplusplus */ 65# define BEGIN_C_DECLS 66# define END_C_DECLS 67#endif /* __cplusplus */ 68 69BEGIN_C_DECLS 70/****h* OpenSM/SA 71* NAME 72* SA 73* 74* DESCRIPTION 75* The SA object encapsulates the information needed by the 76* OpenSM to instantiate subnet administration. The OpenSM 77* allocates one SA object per subnet manager. 78* 79* The SA object is thread safe. 80* 81* This object should be treated as opaque and should 82* be manipulated only through the provided functions. 83* 84* AUTHOR 85* Ranjit Pandit, Intel 86* Anil Keshavamurthy, Intel 87* 88*********/ 89 90/****d* OpenSM: SA/osm_sa_state_t 91* NAME 92* osm_sa_state_t 93* 94* DESCRIPTION 95* Enumerates the possible states of SA object. 96* 97* SYNOPSIS 98*/ 99typedef enum _osm_sa_state { 100 OSM_SA_STATE_INIT = 0, 101 OSM_SA_STATE_READY 102} osm_sa_state_t; 103/***********/ 104 105/****d* OpenSM: SA/osm_mpr_rec_t 106* NAME 107* osm_mpr_rec_t 108* 109* DESCRIPTION 110* SA MultiPathRecord response. 111* 112* SYNOPSIS 113*/ 114typedef struct osm_mpr_rec { 115 ib_path_rec_t path_rec; 116 const osm_port_t *p_src_port; 117 const osm_port_t *p_dest_port; 118 int hops; 119} osm_mpr_rec_t; 120/***********/ 121 122/****d* OpenSM: SA/osm_sa_item_t 123* NAME 124* osm_sa_item_t 125* 126* DESCRIPTION 127* SA response item. 128* 129* SYNOPSIS 130*/ 131typedef struct osm_sa_item { 132 cl_list_item_t list_item; 133 union { 134 char data[0]; 135 ib_guidinfo_record_t guid_rec; 136 ib_inform_info_t inform; 137 ib_inform_info_record_t inform_rec; 138 ib_lft_record_t lft_rec; 139 ib_link_record_t link_rec; 140 ib_member_rec_t mc_rec; 141 ib_mft_record_t mft_rec; 142 osm_mpr_rec_t mpr_rec; 143 ib_node_record_t node_rec; 144 ib_path_rec_t path_rec; 145 ib_pkey_table_record_t pkey_rec; 146 ib_portinfo_record_t port_rec; 147 ib_service_record_t service_rec; 148 ib_slvl_table_record_t slvl_rec; 149 ib_sminfo_record_t sminfo_rec; 150 ib_switch_info_record_t swinfo_rec; 151 ib_vl_arb_table_record_t vlarb_rec; 152 } resp; 153} osm_sa_item_t; 154/* 155* NOTES 156* Actual structure allocated is based on SA attribute 157* type. As such, it is variable sized. The allocation 158* occurs in the SA attribute handling code. 159* Note also that the size is specified external 160* to this structure (It's passed as a parameter to 161* osm_sa_respond). The SA_ITEM_RESP_SIZE macro 162* facilitates determining the size required. 163* 164***********/ 165 166#define SA_ITEM_RESP_SIZE(_m) offsetof(osm_sa_item_t, resp._m) + \ 167 sizeof(((osm_sa_item_t *)NULL)->resp._m) 168 169/****s* OpenSM: SM/osm_sa_t 170* NAME 171* osm_sa_t 172* 173* DESCRIPTION 174* Subnet Administration structure. 175* 176* This object should be treated as opaque and should 177* be manipulated only through the provided functions. 178* 179* SYNOPSIS 180*/ 181typedef struct osm_sa { 182 osm_sa_state_t state; 183 osm_sm_t *sm; 184 osm_subn_t *p_subn; 185 osm_vendor_t *p_vendor; 186 osm_log_t *p_log; 187 osm_mad_pool_t *p_mad_pool; 188 cl_dispatcher_t *p_disp; 189 cl_dispatcher_t *p_set_disp; 190 cl_plock_t *p_lock; 191 atomic32_t sa_trans_id; 192 osm_sa_mad_ctrl_t mad_ctrl; 193 cl_timer_t sr_timer; 194 boolean_t dirty; 195 cl_disp_reg_handle_t cpi_disp_h; 196 cl_disp_reg_handle_t nr_disp_h; 197 cl_disp_reg_handle_t pir_disp_h; 198 cl_disp_reg_handle_t gir_disp_h; 199 cl_disp_reg_handle_t lr_disp_h; 200 cl_disp_reg_handle_t pr_disp_h; 201 cl_disp_reg_handle_t smir_disp_h; 202 cl_disp_reg_handle_t mcmr_disp_h; 203 cl_disp_reg_handle_t sr_disp_h; 204#if defined (VENDOR_RMPP_SUPPORT) && defined (DUAL_SIDED_RMPP) 205 cl_disp_reg_handle_t mpr_disp_h; 206#endif 207 cl_disp_reg_handle_t infr_disp_h; 208 cl_disp_reg_handle_t infir_disp_h; 209 cl_disp_reg_handle_t vlarb_disp_h; 210 cl_disp_reg_handle_t slvl_disp_h; 211 cl_disp_reg_handle_t pkey_disp_h; 212 cl_disp_reg_handle_t lft_disp_h; 213 cl_disp_reg_handle_t sir_disp_h; 214 cl_disp_reg_handle_t mft_disp_h; 215 cl_disp_reg_handle_t infr_set_disp_h; 216 cl_disp_reg_handle_t gir_set_disp_h; 217 cl_disp_reg_handle_t mcmr_set_disp_h; 218 cl_disp_reg_handle_t sr_set_disp_h; 219} osm_sa_t; 220/* 221* FIELDS 222* state 223* State of this SA object 224* 225* sm 226* Pointer to the Subnet Manager object. 227* 228* p_subn 229* Pointer to the Subnet object for this subnet. 230* 231* p_vendor 232* Pointer to the vendor specific interfaces object. 233* 234* p_log 235* Pointer to the log object. 236* 237* p_mad_pool 238* Pointer to the MAD pool. 239* 240* p_disp 241* Pointer to dispatcher 242* 243* p_set_disp 244* Pointer to dispatcher for Set requests. 245* 246* p_lock 247* Pointer to Lock for serialization 248* 249* sa_trans_id 250* Transaction ID 251* 252* mad_ctrl 253* Mad Controller 254* 255* dirty 256* A flag that denotes that SA DB is dirty and needs 257* to be written to the dump file (if dumping is enabled) 258* 259* SEE ALSO 260* SM object 261*********/ 262 263/****f* OpenSM: SA/osm_sa_construct 264* NAME 265* osm_sa_construct 266* 267* DESCRIPTION 268* This function constructs an SA object. 269* 270* SYNOPSIS 271*/ 272void osm_sa_construct(IN osm_sa_t * p_sa); 273/* 274* PARAMETERS 275* p_sa 276* [in] Pointer to a SA object to construct. 277* 278* RETURN VALUE 279* This function does not return a value. 280* 281* NOTES 282* Allows calling osm_sa_destroy. 283* 284* Calling osm_sa_construct is a prerequisite to calling any other 285* method except osm_sa_init. 286* 287* SEE ALSO 288* SA object, osm_sa_init, osm_sa_destroy 289*********/ 290 291/****f* OpenSM: SA/osm_sa_shutdown 292* NAME 293* osm_sa_shutdown 294* 295* DESCRIPTION 296* The osm_sa_shutdown function shutdowns an SA, unregistering from all 297* dispatcher messages and unbinding the QP1 mad service 298* 299* SYNOPSIS 300*/ 301void osm_sa_shutdown(IN osm_sa_t * p_sa); 302/* 303* PARAMETERS 304* p_sa 305* [in] Pointer to a SA object to shutdown. 306* 307* RETURN VALUE 308* This function does not return a value. 309* 310* SEE ALSO 311* SA object, osm_sa_construct, osm_sa_init 312*********/ 313 314/****f* OpenSM: SA/osm_sa_destroy 315* NAME 316* osm_sa_destroy 317* 318* DESCRIPTION 319* The osm_sa_destroy function destroys an SA, releasing 320* all resources. 321* 322* SYNOPSIS 323*/ 324void osm_sa_destroy(IN osm_sa_t * p_sa); 325/* 326* PARAMETERS 327* p_sa 328* [in] Pointer to a SA object to destroy. 329* 330* RETURN VALUE 331* This function does not return a value. 332* 333* NOTES 334* Performs any necessary cleanup of the specified SA object. 335* Further operations should not be attempted on the destroyed object. 336* This function should only be called after a call to osm_sa_construct or 337* osm_sa_init. 338* 339* SEE ALSO 340* SA object, osm_sa_construct, osm_sa_init 341*********/ 342 343/****f* OpenSM: SA/osm_sa_init 344* NAME 345* osm_sa_init 346* 347* DESCRIPTION 348* The osm_sa_init function initializes a SA object for use. 349* 350* SYNOPSIS 351*/ 352ib_api_status_t osm_sa_init(IN osm_sm_t * p_sm, IN osm_sa_t * p_sa, 353 IN osm_subn_t * p_subn, IN osm_vendor_t * p_vendor, 354 IN osm_mad_pool_t * p_mad_pool, 355 IN osm_log_t * p_log, IN osm_stats_t * p_stats, 356 IN cl_dispatcher_t * p_disp, 357 IN cl_dispatcher_t * p_set_disp, 358 IN cl_plock_t * p_lock); 359/* 360* PARAMETERS 361* p_sa 362* [in] Pointer to an osm_sa_t object to initialize. 363* 364* p_subn 365* [in] Pointer to the Subnet object for this subnet. 366* 367* p_vendor 368* [in] Pointer to the vendor specific interfaces object. 369* 370* p_mad_pool 371* [in] Pointer to the MAD pool. 372* 373* p_log 374* [in] Pointer to the log object. 375* 376* p_stats 377* [in] Pointer to the statistics object. 378* 379* p_disp 380* [in] Pointer to the OpenSM central Dispatcher. 381* 382* p_set_disp 383* [in] Pointer to the OpenSM Dispatcher for Set requests. 384* 385* p_lock 386* [in] Pointer to the OpenSM serializing lock. 387* 388* RETURN VALUES 389* CL_SUCCESS if the SA object was initialized successfully. 390* 391* NOTES 392* Allows calling other SA methods. 393* 394* SEE ALSO 395* SA object, osm_sa_construct, osm_sa_destroy 396*********/ 397 398/****f* OpenSM: SA/osm_sa_bind 399* NAME 400* osm_sa_bind 401* 402* DESCRIPTION 403* Binds the SA object to a port guid. 404* 405* SYNOPSIS 406*/ 407ib_api_status_t osm_sa_bind(IN osm_sa_t * p_sa, IN ib_net64_t port_guid); 408/* 409* PARAMETERS 410* p_sa 411* [in] Pointer to an osm_sa_t object to bind. 412* 413* port_guid 414* [in] Local port GUID with which to bind. 415* 416* 417* RETURN VALUES 418* None 419* 420* NOTES 421* A given SA object can only be bound to one port at a time. 422* 423* SEE ALSO 424*********/ 425 426/****f* OpenSM: SA/osm_sa_send 427* NAME 428* osm_sa_send 429* 430* DESCRIPTION 431* Sends SA MAD via osm_vendor_send and maintains the QP1 sent statistic 432* 433* SYNOPSIS 434*/ 435ib_api_status_t osm_sa_send(osm_sa_t *sa, IN osm_madw_t * p_madw, 436 IN boolean_t resp_expected); 437 438/****f* IBA Base: Types/osm_sa_send_error 439* NAME 440* osm_sa_send_error 441* 442* DESCRIPTION 443* Sends a generic SA response with the specified error status. 444* The payload is simply replicated from the request MAD. 445* 446* SYNOPSIS 447*/ 448void osm_sa_send_error(IN osm_sa_t * sa, IN const osm_madw_t * p_madw, 449 IN ib_net16_t sa_status); 450/* 451* PARAMETERS 452* sa 453* [in] Pointer to an osm_sa_t object. 454* 455* p_madw 456* [in] Original MAD to which the response must be sent. 457* 458* sa_status 459* [in] Status to send in the response. 460* 461* RETURN VALUES 462* None. 463* 464* SEE ALSO 465* SA object 466*********/ 467 468/****f* OpenSM: SA/osm_sa_respond 469* NAME 470* osm_sa_respond 471* 472* DESCRIPTION 473* Sends SA MAD response 474*/ 475void osm_sa_respond(osm_sa_t *sa, osm_madw_t *madw, size_t attr_size, 476 cl_qlist_t *list); 477/* 478* PARAMETERS 479* sa 480* [in] Pointer to an osm_sa_t object. 481* 482* p_madw 483* [in] Original MAD to which the response must be sent. 484* 485* attr_size 486* [in] Size of this SA attribute. 487* 488* list 489* [in] List of attribute to respond - it will be freed after 490* sending. 491* 492* RETURN VALUES 493* None. 494* 495* SEE ALSO 496* SA object 497*********/ 498 499struct osm_opensm; 500/****f* OpenSM: SA/osm_sa_db_file_dump 501* NAME 502* osm_sa_db_file_dump 503* 504* DESCRIPTION 505* Dumps the SA DB to the dump file. 506* 507* SYNOPSIS 508*/ 509int osm_sa_db_file_dump(struct osm_opensm *p_osm); 510/* 511* PARAMETERS 512* p_osm 513* [in] Pointer to an osm_opensm_t object. 514* 515* RETURN VALUES 516* 0 if the SA DB was actually dumped 517* >0 if there was no need to dump the SA DB 518* <0 if some error occurred. 519* 520*********/ 521 522/****f* OpenSM: SA/osm_sa_db_file_load 523* NAME 524* osm_sa_db_file_load 525* 526* DESCRIPTION 527* Loads SA DB from the file. 528* 529* SYNOPSIS 530*/ 531int osm_sa_db_file_load(struct osm_opensm *p_osm); 532/* 533* PARAMETERS 534* p_osm 535* [in] Pointer to an osm_opensm_t object. 536* 537* RETURN VALUES 538* 0 on success, other value on failure. 539* 540*********/ 541 542/****f* OpenSM: MC Member Record Receiver/osm_mcmr_rcv_find_or_create_new_mgrp 543* NAME 544* osm_mcmr_rcv_find_or_create_new_mgrp 545* 546* DESCRIPTION 547* Create new Multicast group 548* 549* SYNOPSIS 550*/ 551 552osm_mgrp_t *osm_mcmr_rcv_find_or_create_new_mgrp(IN osm_sa_t * sa, 553 IN ib_net64_t comp_mask, 554 IN ib_member_rec_t * 555 p_recvd_mcmember_rec); 556/* 557* PARAMETERS 558* p_sa 559* [in] Pointer to an osm_sa_t object. 560* comp_mask 561* [in] SA query component mask 562* p_recvd_mcmember_rec 563* [in] Received Multicast member record 564* 565* RETURN VALUES 566* The pointer to MC group object found or created, NULL in case of errors 567* 568*********/ 569 570/** 571 * The following expose functionality of osm_sa_path_record.c for internal use 572 * by sub managers 573 */ 574typedef struct osm_path_parms { 575 ib_net16_t pkey; 576 uint8_t mtu; 577 uint8_t rate; 578 uint8_t sl; 579 uint8_t pkt_life; 580 boolean_t reversible; 581 int hops; 582} osm_path_parms_t; 583 584ib_api_status_t osm_get_path_params(IN osm_sa_t * sa, 585 IN const osm_port_t * p_src_port, 586 IN const uint16_t slid_ho, 587 IN const osm_port_t * p_dest_port, 588 IN const uint16_t dlid_ho, 589 OUT osm_path_parms_t * p_parms); 590 591ib_net16_t osm_pr_get_end_points(IN osm_sa_t * sa, 592 IN const ib_sa_mad_t *sa_mad, 593 OUT const osm_alias_guid_t ** pp_src_alias_guid, 594 OUT const osm_alias_guid_t ** pp_dest_alias_guid, 595 OUT const osm_port_t ** pp_src_port, 596 OUT const osm_port_t ** pp_dest_port, 597 OUT const ib_gid_t ** pp_sgid, 598 OUT const ib_gid_t ** pp_dgid); 599 600void osm_pr_process_pair(IN osm_sa_t * sa, IN const ib_sa_mad_t * sa_mad, 601 IN const osm_port_t * requester_port, 602 IN const osm_alias_guid_t * p_src_alias_guid, 603 IN const osm_alias_guid_t * p_dest_alias_guid, 604 IN const ib_gid_t * p_sgid, 605 IN const ib_gid_t * p_dgid, 606 IN cl_qlist_t * p_list); 607 608void osm_pr_process_half(IN osm_sa_t * sa, IN const ib_sa_mad_t * sa_mad, 609 IN const osm_port_t * requester_port, 610 IN const osm_alias_guid_t * p_src_alias_guid, 611 IN const osm_alias_guid_t * p_dest_alias_guid, 612 IN const ib_gid_t * p_sgid, 613 IN const ib_gid_t * p_dgid, 614 IN cl_qlist_t * p_list); 615 616END_C_DECLS 617#endif /* _OSM_SA_H_ */ 618