2 * Copyright (c) 2004-2008 Voltaire, Inc. All rights reserved.
3 * Copyright (c) 2002-2011 Mellanox Technologies LTD. All rights reserved.
4 * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
5 * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved.
7 * This software is available to you under a choice of one of two
8 * licenses. You may choose to be licensed under the terms of the GNU
9 * General Public License (GPL) Version 2, available from the file
10 * COPYING in the main directory of this source tree, or the
11 * OpenIB.org BSD license below:
13 * Redistribution and use in source and binary forms, with or
14 * without modification, are permitted provided that the following
17 * - Redistributions of source code must retain the above
18 * copyright notice, this list of conditions and the following
21 * - Redistributions in binary form must reproduce the above
22 * copyright notice, this list of conditions and the following
23 * disclaimer in the documentation and/or other materials
24 * provided with the distribution.
26 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
27 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
28 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
29 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
30 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
31 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
32 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
39 * Implementation of osm_cpi_rcv_t.
40 * This object represents the ClassPortInfo Receiver object.
41 * This object is part of the opensm family of objects.
46 #endif /* HAVE_CONFIG_H */
49 #include <iba/ib_types.h>
50 #include <complib/cl_qmap.h>
51 #include <complib/cl_passivelock.h>
52 #include <complib/cl_debug.h>
53 #include <complib/cl_qlist.h>
54 #include <opensm/osm_file_ids.h>
55 #define FILE_ID OSM_FILE_SA_CLASS_PORT_INFO_C
56 #include <vendor/osm_vendor_api.h>
57 #include <opensm/osm_helper.h>
58 #include <opensm/osm_sa.h>
60 #define MAX_MSECS_TO_RTV 24
61 /* Precalculated table in msec (index is related to encoded value) */
62 /* 4.096 usec * 2 ** n (where n = 8 - 31) */
63 const static uint32_t msecs_to_rtv_table[MAX_MSECS_TO_RTV] = {
67 4294, 8589, 17179, 34359,
68 68719, 137438, 274877, 549755,
69 1099511, 2199023, 4398046, 8796093
72 static void cpi_rcv_respond(IN osm_sa_t * sa, IN const osm_madw_t * p_madw)
74 osm_madw_t *p_resp_madw;
75 const ib_sa_mad_t *p_sa_mad;
76 ib_sa_mad_t *p_resp_sa_mad;
77 ib_class_port_info_t *p_resp_cpi;
82 OSM_LOG_ENTER(sa->p_log);
84 memset(&zero_gid, 0, sizeof(ib_gid_t));
87 Get a MAD to reply. Address of Mad is in the received mad_wrapper
89 p_resp_madw = osm_mad_pool_get(sa->p_mad_pool, p_madw->h_bind,
90 MAD_BLOCK_SIZE, &p_madw->mad_addr);
92 OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1408: "
93 "Unable to allocate MAD\n");
97 p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
98 p_resp_sa_mad = osm_madw_get_sa_mad_ptr(p_resp_madw);
100 memcpy(p_resp_sa_mad, p_sa_mad, IB_SA_MAD_HDR_SIZE);
101 p_resp_sa_mad->method |= IB_MAD_METHOD_RESP_MASK;
102 /* C15-0.1.5 - always return SM_Key = 0 (table 185 p 884) */
103 p_resp_sa_mad->sm_key = 0;
106 (ib_class_port_info_t *) ib_sa_mad_get_payload_ptr(p_resp_sa_mad);
108 /* finally do it (the job) man ! */
109 p_resp_cpi->base_ver = 1;
110 p_resp_cpi->class_ver = 2;
111 /* Calculate encoded response time value */
112 /* transaction timeout is in msec */
113 if (sa->p_subn->opt.transaction_timeout >
114 msecs_to_rtv_table[MAX_MSECS_TO_RTV - 1])
115 rtv = MAX_MSECS_TO_RTV - 1;
117 for (rtv = 0; rtv < MAX_MSECS_TO_RTV; rtv++) {
118 if (sa->p_subn->opt.transaction_timeout <=
119 msecs_to_rtv_table[rtv])
124 ib_class_set_resp_time_val(p_resp_cpi, rtv);
125 p_resp_cpi->redir_gid = zero_gid;
126 p_resp_cpi->redir_tc_sl_fl = 0;
127 p_resp_cpi->redir_lid = 0;
128 p_resp_cpi->redir_pkey = 0;
129 p_resp_cpi->redir_qp = CL_NTOH32(1);
130 p_resp_cpi->redir_qkey = IB_QP1_WELL_KNOWN_Q_KEY;
131 p_resp_cpi->trap_gid = zero_gid;
132 p_resp_cpi->trap_tc_sl_fl = 0;
133 p_resp_cpi->trap_lid = 0;
134 p_resp_cpi->trap_pkey = 0;
135 p_resp_cpi->trap_hop_qp = 0;
136 p_resp_cpi->trap_qkey = IB_QP1_WELL_KNOWN_Q_KEY;
138 /* set specific capability mask bits */
139 /* we do not support the following options/optional records:
140 OSM_CAP_IS_SUBN_OPT_RECS_SUP :
141 RandomForwardingTableRecord,
142 ServiceAssociationRecord
143 other optional records supported "under the table"
145 OSM_CAP_IS_MULTIPATH_SUP:
148 OSM_CAP_IS_REINIT_SUP:
149 For reinitialization functionality.
151 So not sending traps, but supporting Get(Notice) and Set(Notice).
154 /* Note host notation replaced later */
155 #if defined (VENDOR_RMPP_SUPPORT) && defined (DUAL_SIDED_RMPP)
156 p_resp_cpi->cap_mask = OSM_CAP_IS_SUBN_GET_SET_NOTICE_SUP |
157 OSM_CAP_IS_PORT_INFO_CAPMASK_MATCH_SUPPORTED |
158 OSM_CAP_IS_MULTIPATH_SUP;
160 p_resp_cpi->cap_mask = OSM_CAP_IS_SUBN_GET_SET_NOTICE_SUP |
161 OSM_CAP_IS_PORT_INFO_CAPMASK_MATCH_SUPPORTED;
163 cap_mask2 = OSM_CAP2_IS_FULL_PORTINFO_REC_SUPPORTED |
164 OSM_CAP2_IS_EXTENDED_SPEEDS_SUPPORTED |
165 OSM_CAP2_IS_ALIAS_GUIDS_SUPPORTED |
166 OSM_CAP2_IS_MULTICAST_SERVICE_RECS_SUPPORTED |
167 OSM_CAP2_IS_PORT_INFO_CAPMASK2_MATCH_SUPPORTED |
168 OSM_CAP2_IS_LINK_WIDTH_2X_SUPPORTED;
169 if (sa->p_subn->opt.use_mfttop)
170 cap_mask2 |= OSM_CAP2_IS_MCAST_TOP_SUPPORTED;
171 if (sa->p_subn->opt.qos)
172 cap_mask2 |= OSM_CAP2_IS_QOS_SUPPORTED;
173 ib_class_set_cap_mask2(p_resp_cpi, cap_mask2);
175 if (!sa->p_subn->opt.disable_multicast)
176 p_resp_cpi->cap_mask |= OSM_CAP_IS_UD_MCAST_SUP;
177 p_resp_cpi->cap_mask = cl_hton16(p_resp_cpi->cap_mask);
179 if (OSM_LOG_IS_ACTIVE_V2(sa->p_log, OSM_LOG_FRAMES))
180 osm_dump_sa_mad_v2(sa->p_log, p_resp_sa_mad, FILE_ID, OSM_LOG_FRAMES);
182 osm_sa_send(sa, p_resp_madw, FALSE);
185 OSM_LOG_EXIT(sa->p_log);
188 /**********************************************************************
189 * This code actually handles the call
190 **********************************************************************/
191 void osm_cpi_rcv_process(IN void *context, IN void *data)
193 osm_sa_t *sa = context;
194 osm_madw_t *p_madw = data;
195 const ib_sa_mad_t *p_sa_mad;
197 OSM_LOG_ENTER(sa->p_log);
201 p_sa_mad = osm_madw_get_sa_mad_ptr(p_madw);
203 /* we only support GET */
204 if (p_sa_mad->method != IB_MAD_METHOD_GET) {
205 OSM_LOG(sa->p_log, OSM_LOG_ERROR, "ERR 1403: "
206 "Unsupported Method (%s) for ClassPortInfo request\n",
207 ib_get_sa_method_str(p_sa_mad->method));
208 osm_sa_send_error(sa, p_madw, IB_SA_MAD_STATUS_REQ_INVALID);
212 CL_ASSERT(p_sa_mad->attr_id == IB_MAD_ATTR_CLASS_PORT_INFO);
214 /* CLASS PORT INFO does not really look at the SMDB - no lock required. */
216 cpi_rcv_respond(sa, p_madw);
219 OSM_LOG_EXIT(sa->p_log);