2 * Copyright (c) 2006-2009 Voltaire, Inc. All rights reserved.
3 * Copyright (c) 2002-2012 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 * Implementation of osm_guid_mgr_t.
39 * This object implements the GUID manager object.
40 * This object is part of the opensm family of objects.
45 #endif /* HAVE_CONFIG_H */
48 #include <iba/ib_types.h>
49 #include <complib/cl_debug.h>
50 #include <complib/cl_qlist.h>
51 #include <opensm/osm_file_ids.h>
52 #define FILE_ID OSM_FILE_GUID_MGR_C
53 #include <opensm/osm_port.h>
54 #include <opensm/osm_node.h>
55 #include <opensm/osm_guid.h>
56 #include <opensm/osm_opensm.h>
58 static void guidinfo_set(IN osm_sa_t *sa, IN osm_port_t *p_port,
61 uint8_t payload[IB_SMP_DATA_SIZE];
62 osm_madw_context_t context;
63 ib_api_status_t status;
66 &((*p_port->p_physp->p_guids)[block_num * GUID_TABLE_MAX_ENTRIES]),
67 sizeof(ib_guid_info_t));
69 context.gi_context.node_guid = osm_node_get_node_guid(p_port->p_node);
70 context.gi_context.port_guid = osm_physp_get_port_guid(p_port->p_physp);
71 context.gi_context.set_method = TRUE;
72 context.gi_context.port_num = osm_physp_get_port_num(p_port->p_physp);
74 status = osm_req_set(sa->sm, osm_physp_get_dr_path_ptr(p_port->p_physp),
75 payload, sizeof(payload), IB_MAD_ATTR_GUID_INFO,
76 cl_hton32((uint32_t)block_num), FALSE,
77 ib_port_info_get_m_key(&p_port->p_physp->port_info),
78 CL_DISP_MSGID_NONE, &context);
79 if (status != IB_SUCCESS)
80 OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 5109: "
81 "Failure initiating GUIDInfo request (%s)\n",
82 ib_get_err_str(status));
85 osm_guidinfo_work_obj_t *osm_guid_work_obj_new(IN osm_port_t * p_port,
88 osm_guidinfo_work_obj_t *p_obj;
91 clean allocated memory to avoid assertion when trying to insert to
93 see cl_qlist_insert_tail(): CL_ASSERT(p_list_item->p_list != p_list)
95 p_obj = calloc(1, sizeof(*p_obj));
97 p_obj->p_port = p_port;
98 p_obj->block_num = block_num;
104 void osm_guid_work_obj_delete(IN osm_guidinfo_work_obj_t * p_wobj)
109 int osm_queue_guidinfo(IN osm_sa_t *sa, IN osm_port_t *p_port,
110 IN uint8_t block_num)
112 osm_guidinfo_work_obj_t *p_obj;
115 p_obj = osm_guid_work_obj_new(p_port, block_num);
117 cl_qlist_insert_tail(&sa->p_subn->alias_guid_list,
120 OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 510F: "
121 "Memory allocation of guid work object failed\n");
128 void osm_guid_mgr_process(IN osm_sm_t * sm) {
129 osm_guidinfo_work_obj_t *p_obj;
131 OSM_LOG_ENTER(sm->p_log);
133 OSM_LOG(sm->p_log, OSM_LOG_DEBUG, "Processing alias guid list\n");
135 CL_PLOCK_EXCL_ACQUIRE(sm->p_lock);
136 while (cl_qlist_count(&sm->p_subn->alias_guid_list)) {
137 p_obj = (osm_guidinfo_work_obj_t *) cl_qlist_remove_head(&sm->p_subn->alias_guid_list);
138 guidinfo_set(&sm->p_subn->p_osm->sa, p_obj->p_port,
140 osm_guid_work_obj_delete(p_obj);
143 CL_PLOCK_RELEASE(sm->p_lock);
144 OSM_LOG_EXIT(sm->p_log);