2 * Copyright (c) 2006-2008 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
36 /* TODO : Check why we dont free the cl_qmap_items we store when reading DB */
40 * Implementation of osmtest_t.
41 * This object represents the OSMTest Test object.
46 #pragma warning(disable : 4996)
53 #include <complib/cl_timer.h>
58 #include <complib/cl_debug.h>
62 #define strnicmp strncasecmp
65 #define POOL_MIN_ITEMS 64
66 #define GUID_ARRAY_SIZE 64
68 typedef struct _osmtest_sm_info_rec {
73 } osmtest_sm_info_rec_t;
75 typedef struct _osmtest_inform_info {
79 } osmtest_inform_info_t;
81 typedef struct _osmtest_inform_info_rec {
82 ib_gid_t subscriber_gid;
83 ib_net16_t subscriber_enum;
84 } osmtest_inform_info_rec_t;
86 typedef enum _osmtest_token_val {
87 OSMTEST_TOKEN_COMMENT = 0,
89 OSMTEST_TOKEN_DEFINE_NODE,
90 OSMTEST_TOKEN_DEFINE_PORT,
91 OSMTEST_TOKEN_DEFINE_PATH,
92 OSMTEST_TOKEN_DEFINE_LINK,
94 OSMTEST_TOKEN_BASE_VERSION,
95 OSMTEST_TOKEN_CLASS_VERSION,
96 OSMTEST_TOKEN_NODE_TYPE,
97 OSMTEST_TOKEN_NUM_PORTS,
98 OSMTEST_TOKEN_SYS_GUID,
99 OSMTEST_TOKEN_NODE_GUID,
100 OSMTEST_TOKEN_PORT_GUID,
101 OSMTEST_TOKEN_PARTITION_CAP,
102 OSMTEST_TOKEN_DEVICE_ID,
103 OSMTEST_TOKEN_REVISION,
104 OSMTEST_TOKEN_PORT_NUM,
105 OSMTEST_TOKEN_VENDOR_ID,
110 OSMTEST_TOKEN_HOP_FLOW_RAW,
111 OSMTEST_TOKEN_TCLASS,
112 OSMTEST_TOKEN_NUM_PATH,
116 OSMTEST_TOKEN_PKT_LIFE,
117 OSMTEST_TOKEN_PREFERENCE,
119 OSMTEST_TOKEN_SUBN_PREF,
120 OSMTEST_TOKEN_BASE_LID,
121 OSMTEST_TOKEN_SM_BASE_LID,
122 OSMTEST_TOKEN_CAP_MASK,
123 OSMTEST_TOKEN_DIAG_CODE,
124 OSMTEST_TOKEN_MKEY_LEASE_PER,
125 OSMTEST_TOKEN_LOC_PORT_NUM,
126 OSMTEST_TOKEN_LINK_WID_EN,
127 OSMTEST_TOKEN_LINK_WID_SUP,
128 OSMTEST_TOKEN_LINK_WID_ACT,
129 OSMTEST_TOKEN_LINK_SPEED_SUP,
130 OSMTEST_TOKEN_PORT_STATE,
131 OSMTEST_TOKEN_STATE_INFO2,
132 OSMTEST_TOKEN_MKEY_PROT_BITS,
134 OSMTEST_TOKEN_LINK_SPEED,
135 OSMTEST_TOKEN_MTU_SMSL,
136 OSMTEST_TOKEN_VL_CAP,
137 OSMTEST_TOKEN_VL_HIGH_LIMIT,
138 OSMTEST_TOKEN_VL_ARB_HIGH_CAP,
139 OSMTEST_TOKEN_VL_ARB_LOW_CAP,
140 OSMTEST_TOKEN_MTU_CAP,
141 OSMTEST_TOKEN_VL_STALL_LIFE,
142 OSMTEST_TOKEN_VL_ENFORCE,
143 OSMTEST_TOKEN_MKEY_VIOL,
144 OSMTEST_TOKEN_PKEY_VIOL,
145 OSMTEST_TOKEN_QKEY_VIOL,
146 OSMTEST_TOKEN_GUID_CAP,
147 OSMTEST_TOKEN_SUBN_TIMEOUT,
148 OSMTEST_TOKEN_RESP_TIME_VAL,
149 OSMTEST_TOKEN_ERR_THRESHOLD,
151 OSMTEST_TOKEN_FROMLID,
152 OSMTEST_TOKEN_FROMPORTNUM,
153 OSMTEST_TOKEN_TOPORTNUM,
155 OSMTEST_TOKEN_UNKNOWN
156 } osmtest_token_val_t;
158 typedef struct _osmtest_token {
159 osmtest_token_val_t val;
164 const osmtest_token_t token_array[] = {
165 {OSMTEST_TOKEN_COMMENT, 1, "#"},
166 {OSMTEST_TOKEN_END, 3, "END"},
167 {OSMTEST_TOKEN_DEFINE_NODE, 11, "DEFINE_NODE"},
168 {OSMTEST_TOKEN_DEFINE_PORT, 11, "DEFINE_PORT"},
169 {OSMTEST_TOKEN_DEFINE_PATH, 11, "DEFINE_PATH"},
170 {OSMTEST_TOKEN_DEFINE_LINK, 11, "DEFINE_LINK"},
171 {OSMTEST_TOKEN_LID, 3, "LID"},
172 {OSMTEST_TOKEN_BASE_VERSION, 12, "BASE_VERSION"},
173 {OSMTEST_TOKEN_CLASS_VERSION, 13, "CLASS_VERSION"},
174 {OSMTEST_TOKEN_NODE_TYPE, 9, "NODE_TYPE"},
175 {OSMTEST_TOKEN_NUM_PORTS, 9, "NUM_PORTS"},
176 {OSMTEST_TOKEN_SYS_GUID, 8, "SYS_GUID"},
177 {OSMTEST_TOKEN_NODE_GUID, 9, "NODE_GUID"},
178 {OSMTEST_TOKEN_PORT_GUID, 9, "PORT_GUID"},
179 {OSMTEST_TOKEN_PARTITION_CAP, 13, "PARTITION_CAP"},
180 {OSMTEST_TOKEN_DEVICE_ID, 9, "DEVICE_ID"},
181 {OSMTEST_TOKEN_REVISION, 8, "REVISION"},
182 {OSMTEST_TOKEN_PORT_NUM, 8, "PORT_NUM"},
183 {OSMTEST_TOKEN_VENDOR_ID, 9, "VENDOR_ID"},
184 {OSMTEST_TOKEN_DGID, 4, "DGID"},
185 {OSMTEST_TOKEN_SGID, 4, "SGID"},
186 {OSMTEST_TOKEN_DLID, 4, "DLID"},
187 {OSMTEST_TOKEN_SLID, 4, "SLID"},
188 {OSMTEST_TOKEN_HOP_FLOW_RAW, 12, "HOP_FLOW_RAW"},
189 {OSMTEST_TOKEN_TCLASS, 6, "TCLASS"},
190 {OSMTEST_TOKEN_NUM_PATH, 8, "NUM_PATH"},
191 {OSMTEST_TOKEN_PKEY, 4, "PKEY"},
192 {OSMTEST_TOKEN_SL, 2, "SL"},
193 {OSMTEST_TOKEN_RATE, 4, "RATE"},
194 {OSMTEST_TOKEN_PKT_LIFE, 8, "PKT_LIFE"},
195 {OSMTEST_TOKEN_PREFERENCE, 10, "PREFERENCE"},
196 {OSMTEST_TOKEN_MKEY, 4, "M_KEY"},
197 {OSMTEST_TOKEN_SUBN_PREF, 13, "SUBNET_PREFIX"},
198 {OSMTEST_TOKEN_BASE_LID, 8, "BASE_LID"},
199 {OSMTEST_TOKEN_SM_BASE_LID, 18, "MASTER_SM_BASE_LID"},
200 {OSMTEST_TOKEN_CAP_MASK, 15, "CAPABILITY_MASK"},
201 {OSMTEST_TOKEN_DIAG_CODE, 9, "DIAG_CODE"},
202 {OSMTEST_TOKEN_MKEY_LEASE_PER, 18, "m_key_lease_period"},
203 {OSMTEST_TOKEN_LOC_PORT_NUM, 14, "local_port_num"},
204 {OSMTEST_TOKEN_LINK_WID_EN, 18, "link_width_enabled"},
205 {OSMTEST_TOKEN_LINK_WID_SUP, 20, "link_width_supported"},
206 {OSMTEST_TOKEN_LINK_WID_ACT, 17, "link_width_active"},
207 {OSMTEST_TOKEN_LINK_SPEED_SUP, 20, "link_speed_supported"},
208 {OSMTEST_TOKEN_PORT_STATE, 10, "port_state"},
209 {OSMTEST_TOKEN_STATE_INFO2, 10, "state_info2"},
210 {OSMTEST_TOKEN_MKEY_PROT_BITS, 3, "mpb"},
211 {OSMTEST_TOKEN_LMC, 3, "lmc"},
212 {OSMTEST_TOKEN_LINK_SPEED, 10, "link_speed"},
213 {OSMTEST_TOKEN_MTU_SMSL, 8, "mtu_smsl"},
214 {OSMTEST_TOKEN_VL_CAP, 6, "vl_cap"},
215 {OSMTEST_TOKEN_VL_HIGH_LIMIT, 13, "vl_high_limit"},
216 {OSMTEST_TOKEN_VL_ARB_HIGH_CAP, 15, "vl_arb_high_cap"},
217 {OSMTEST_TOKEN_VL_ARB_LOW_CAP, 14, "vl_arb_low_cap"},
218 {OSMTEST_TOKEN_MTU_CAP, 7, "mtu_cap"},
219 {OSMTEST_TOKEN_VL_STALL_LIFE, 13, "vl_stall_life"},
220 {OSMTEST_TOKEN_VL_ENFORCE, 10, "vl_enforce"},
221 {OSMTEST_TOKEN_MKEY_VIOL, 16, "m_key_violations"},
222 {OSMTEST_TOKEN_PKEY_VIOL, 16, "p_key_violations"},
223 {OSMTEST_TOKEN_QKEY_VIOL, 16, "q_key_violations"},
224 {OSMTEST_TOKEN_GUID_CAP, 8, "guid_cap"},
225 {OSMTEST_TOKEN_SUBN_TIMEOUT, 14, "subnet_timeout"},
226 {OSMTEST_TOKEN_RESP_TIME_VAL, 15, "resp_time_value"},
227 {OSMTEST_TOKEN_ERR_THRESHOLD, 15, "error_threshold"},
228 {OSMTEST_TOKEN_MTU, 3, "MTU"}, /* must be after the other mtu... tokens. */
229 {OSMTEST_TOKEN_FROMLID, 8, "from_lid"},
230 {OSMTEST_TOKEN_FROMPORTNUM, 13, "from_port_num"},
231 {OSMTEST_TOKEN_TOPORTNUM, 11, "to_port_num"},
232 {OSMTEST_TOKEN_TOLID, 6, "to_lid"},
233 {OSMTEST_TOKEN_UNKNOWN, 0, ""} /* must be last entry */
236 #define IB_MAD_STATUS_CLASS_MASK (CL_HTON16(0xFF00))
238 static const char ib_mad_status_str_busy[] = "IB_MAD_STATUS_BUSY";
239 static const char ib_mad_status_str_redirect[] = "IB_MAD_STATUS_REDIRECT";
240 static const char ib_mad_status_str_unsup_class_ver[] =
241 "IB_MAD_STATUS_UNSUP_CLASS_VER";
242 static const char ib_mad_status_str_unsup_method[] =
243 "IB_MAD_STATUS_UNSUP_METHOD";
244 static const char ib_mad_status_str_unsup_method_attr[] =
245 "IB_MAD_STATUS_UNSUP_METHOD_ATTR";
246 static const char ib_mad_status_str_invalid_field[] =
247 "IB_MAD_STATUS_INVALID_FIELD";
248 static const char ib_mad_status_str_no_resources[] =
249 "IB_SA_MAD_STATUS_NO_RESOURCES";
250 static const char ib_mad_status_str_req_invalid[] =
251 "IB_SA_MAD_STATUS_REQ_INVALID";
252 static const char ib_mad_status_str_no_records[] =
253 "IB_SA_MAD_STATUS_NO_RECORDS";
254 static const char ib_mad_status_str_too_many_records[] =
255 "IB_SA_MAD_STATUS_TOO_MANY_RECORDS";
256 static const char ib_mad_status_str_invalid_gid[] =
257 "IB_SA_MAD_STATUS_INVALID_GID";
258 static const char ib_mad_status_str_insuf_comps[] =
259 "IB_SA_MAD_STATUS_INSUF_COMPS";
260 static const char generic_or_str[] = " | ";
262 /**********************************************************************
263 **********************************************************************/
264 const char *ib_get_mad_status_str(IN const ib_mad_t * const p_mad)
266 static char line[512];
269 boolean_t first = TRUE;
273 status = (ib_net16_t) (p_mad->status & IB_SMP_STATUS_MASK);
276 strcat(&line[offset], "IB_SUCCESS");
280 if (status & IB_MAD_STATUS_BUSY) {
281 strcat(&line[offset], ib_mad_status_str_busy);
282 offset += sizeof(ib_mad_status_str_busy);
284 if (status & IB_MAD_STATUS_REDIRECT) {
286 strcat(&line[offset], generic_or_str);
287 offset += sizeof(generic_or_str) - 1;
290 strcat(&line[offset], ib_mad_status_str_redirect);
291 offset += sizeof(ib_mad_status_str_redirect) - 1;
293 if ((status & IB_MAD_STATUS_INVALID_FIELD) ==
294 IB_MAD_STATUS_UNSUP_CLASS_VER) {
296 strcat(&line[offset], generic_or_str);
297 offset += sizeof(generic_or_str) - 1;
300 strcat(&line[offset], ib_mad_status_str_unsup_class_ver);
301 offset += sizeof(ib_mad_status_str_unsup_class_ver) - 1;
303 if ((status & IB_MAD_STATUS_INVALID_FIELD) ==
304 IB_MAD_STATUS_UNSUP_METHOD) {
306 strcat(&line[offset], generic_or_str);
307 offset += sizeof(generic_or_str) - 1;
310 strcat(&line[offset], ib_mad_status_str_unsup_method);
311 offset += sizeof(ib_mad_status_str_unsup_method) - 1;
313 if ((status & IB_MAD_STATUS_INVALID_FIELD) ==
314 IB_MAD_STATUS_UNSUP_METHOD_ATTR) {
316 strcat(&line[offset], generic_or_str);
317 offset += sizeof(generic_or_str) - 1;
320 strcat(&line[offset], ib_mad_status_str_unsup_method_attr);
321 offset += sizeof(ib_mad_status_str_unsup_method_attr) - 1;
323 if ((status & IB_MAD_STATUS_INVALID_FIELD) ==
324 IB_MAD_STATUS_INVALID_FIELD) {
326 strcat(&line[offset], generic_or_str);
327 offset += sizeof(generic_or_str) - 1;
330 strcat(&line[offset], ib_mad_status_str_invalid_field);
331 offset += sizeof(ib_mad_status_str_invalid_field) - 1;
333 if ((status & IB_MAD_STATUS_CLASS_MASK) ==
334 IB_SA_MAD_STATUS_NO_RESOURCES) {
336 strcat(&line[offset], generic_or_str);
337 offset += sizeof(generic_or_str) - 1;
340 strcat(&line[offset], ib_mad_status_str_no_resources);
341 offset += sizeof(ib_mad_status_str_no_resources) - 1;
343 if ((status & IB_MAD_STATUS_CLASS_MASK) == IB_SA_MAD_STATUS_REQ_INVALID) {
345 strcat(&line[offset], generic_or_str);
346 offset += sizeof(generic_or_str) - 1;
349 strcat(&line[offset], ib_mad_status_str_req_invalid);
350 offset += sizeof(ib_mad_status_str_req_invalid) - 1;
352 if ((status & IB_MAD_STATUS_CLASS_MASK) == IB_SA_MAD_STATUS_NO_RECORDS) {
354 strcat(&line[offset], generic_or_str);
355 offset += sizeof(generic_or_str) - 1;
358 strcat(&line[offset], ib_mad_status_str_no_records);
359 offset += sizeof(ib_mad_status_str_no_records) - 1;
361 if ((status & IB_MAD_STATUS_CLASS_MASK) ==
362 IB_SA_MAD_STATUS_TOO_MANY_RECORDS) {
364 strcat(&line[offset], generic_or_str);
365 offset += sizeof(generic_or_str) - 1;
368 strcat(&line[offset], ib_mad_status_str_too_many_records);
369 offset += sizeof(ib_mad_status_str_too_many_records) - 1;
371 if ((status & IB_MAD_STATUS_CLASS_MASK) == IB_SA_MAD_STATUS_INVALID_GID) {
373 strcat(&line[offset], generic_or_str);
374 offset += sizeof(generic_or_str) - 1;
377 strcat(&line[offset], ib_mad_status_str_invalid_gid);
378 offset += sizeof(ib_mad_status_str_invalid_gid) - 1;
380 if ((status & IB_MAD_STATUS_CLASS_MASK) == IB_SA_MAD_STATUS_INSUF_COMPS) {
382 strcat(&line[offset], generic_or_str);
383 offset += sizeof(generic_or_str) - 1;
386 strcat(&line[offset], ib_mad_status_str_insuf_comps);
387 offset += sizeof(ib_mad_status_str_insuf_comps) - 1;
393 /**********************************************************************
394 **********************************************************************/
395 void subnet_construct(IN subnet_t * const p_subn)
397 cl_qmap_init(&p_subn->link_tbl);
398 cl_qmap_init(&p_subn->node_lid_tbl);
399 cl_qmap_init(&p_subn->node_guid_tbl);
400 cl_qmap_init(&p_subn->mgrp_mlid_tbl);
402 /* NO WAY TO HAVE UNIQUE PORT BY LID OR GUID */
403 /* cl_qmap_init( &p_subn->port_lid_tbl ); */
404 /* cl_qmap_init( &p_subn->port_guid_tbl ); */
406 /* port key is a lid and num pair */
407 cl_qmap_init(&p_subn->port_key_tbl);
408 cl_qmap_init(&p_subn->path_tbl);
411 /**********************************************************************
412 **********************************************************************/
413 cl_status_t subnet_init(IN subnet_t * const p_subn)
415 cl_status_t status = IB_SUCCESS;
417 subnet_construct(p_subn);
422 /**********************************************************************
423 **********************************************************************/
424 void osmtest_construct(IN osmtest_t * const p_osmt)
426 memset(p_osmt, 0, sizeof(*p_osmt));
427 osm_log_construct(&p_osmt->log);
428 subnet_construct(&p_osmt->exp_subn);
431 /**********************************************************************
432 **********************************************************************/
433 void osmtest_destroy(IN osmtest_t * const p_osmt)
435 cl_map_item_t *p_item, *p_next_item;
437 /* Currently there is a problem with IBAL exit flow - memory overrun,
438 so bypass vendor deletion - it will be cleaned by the Windows OS */
440 if (p_osmt->p_vendor)
441 osm_vendor_delete(&p_osmt->p_vendor);
444 cl_qpool_destroy(&p_osmt->port_pool);
445 cl_qpool_destroy(&p_osmt->node_pool);
447 /* destroy the qmap tables */
448 p_next_item = cl_qmap_head(&p_osmt->exp_subn.link_tbl);
449 while (p_next_item != cl_qmap_end(&p_osmt->exp_subn.link_tbl)) {
450 p_item = p_next_item;
451 p_next_item = cl_qmap_next(p_item);
454 p_next_item = cl_qmap_head(&p_osmt->exp_subn.mgrp_mlid_tbl);
455 while (p_next_item != cl_qmap_end(&p_osmt->exp_subn.mgrp_mlid_tbl)) {
456 p_item = p_next_item;
457 p_next_item = cl_qmap_next(p_item);
460 p_next_item = cl_qmap_head(&p_osmt->exp_subn.node_guid_tbl);
461 while (p_next_item != cl_qmap_end(&p_osmt->exp_subn.node_guid_tbl)) {
462 p_item = p_next_item;
463 p_next_item = cl_qmap_next(p_item);
467 p_next_item = cl_qmap_head(&p_osmt->exp_subn.node_lid_tbl);
468 while (p_next_item != cl_qmap_end(&p_osmt->exp_subn.node_lid_tbl)) {
469 p_item = p_next_item;
470 p_next_item = cl_qmap_next(p_item);
474 p_next_item = cl_qmap_head(&p_osmt->exp_subn.path_tbl);
475 while (p_next_item != cl_qmap_end(&p_osmt->exp_subn.path_tbl)) {
476 p_item = p_next_item;
477 p_next_item = cl_qmap_next(p_item);
480 p_next_item = cl_qmap_head(&p_osmt->exp_subn.port_key_tbl);
481 while (p_next_item != cl_qmap_end(&p_osmt->exp_subn.port_key_tbl)) {
482 p_item = p_next_item;
483 p_next_item = cl_qmap_next(p_item);
487 osm_log_destroy(&p_osmt->log);
490 /**********************************************************************
491 **********************************************************************/
493 osmtest_init(IN osmtest_t * const p_osmt,
494 IN const osmtest_opt_t * const p_opt,
495 IN const osm_log_level_t log_flags)
497 ib_api_status_t status;
499 /* Can't use log macros here, since we're initializing the log. */
500 osmtest_construct(p_osmt);
502 status = osm_log_init_v2(&p_osmt->log, p_opt->force_log_flush,
503 0x0001, p_opt->log_file, 0, TRUE);
504 if (status != IB_SUCCESS)
507 /* but we do not want any extra stuff here */
508 osm_log_set_level(&p_osmt->log, log_flags);
510 OSM_LOG(&p_osmt->log, OSM_LOG_FUNCS, "[\n");
512 p_osmt->opt = *p_opt;
514 status = cl_qpool_init(&p_osmt->node_pool, POOL_MIN_ITEMS, 0,
515 POOL_MIN_ITEMS, sizeof(node_t), NULL, NULL,
517 CL_ASSERT(status == CL_SUCCESS);
519 status = cl_qpool_init(&p_osmt->port_pool, POOL_MIN_ITEMS, 0,
520 POOL_MIN_ITEMS, sizeof(port_t), NULL, NULL,
522 CL_ASSERT(status == CL_SUCCESS);
524 p_osmt->p_vendor = osm_vendor_new(&p_osmt->log,
525 p_opt->transaction_timeout);
527 if (p_osmt->p_vendor == NULL) {
528 status = IB_INSUFFICIENT_RESOURCES;
529 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0001: "
530 "Unable to allocate vendor object");
535 osm_mad_pool_construct(&p_osmt->mad_pool);
536 status = osm_mad_pool_init(&p_osmt->mad_pool);
537 if (status != IB_SUCCESS)
541 OSM_LOG(&p_osmt->log, OSM_LOG_FUNCS, "]\n");
545 /**********************************************************************
546 **********************************************************************/
547 void osmtest_query_res_cb(IN osmv_query_res_t * p_rec)
549 osmtest_req_context_t *const p_ctxt =
550 (osmtest_req_context_t *) p_rec->query_context;
551 osmtest_t *const p_osmt = p_ctxt->p_osmt;
553 OSM_LOG_ENTER(&p_osmt->log);
555 p_ctxt->result = *p_rec;
557 if (p_rec->status != IB_SUCCESS) {
558 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0003: "
559 "Error on query (%s)\n", ib_get_err_str(p_rec->status));
562 OSM_LOG_EXIT(&p_osmt->log);
565 /**********************************************************************
566 **********************************************************************/
568 osmtest_get_all_recs(IN osmtest_t * const p_osmt,
569 IN ib_net16_t const attr_id,
570 IN size_t const attr_size,
571 IN OUT osmtest_req_context_t * const p_context)
573 ib_api_status_t status = IB_SUCCESS;
574 osmv_user_query_t user;
575 osmv_query_req_t req;
577 OSM_LOG_ENTER(&p_osmt->log);
579 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "Getting all %s records\n",
580 ib_get_sa_attr_str(attr_id));
583 * Do a blocking query for all <attr_id> records in the subnet.
584 * The result is returned in the result field of the caller's
587 * The query structures are locals.
589 memset(&req, 0, sizeof(req));
590 memset(&user, 0, sizeof(user));
592 p_context->p_osmt = p_osmt;
593 user.attr_id = attr_id;
594 user.attr_offset = cl_ntoh16((uint16_t) (attr_size >> 3));
596 req.query_type = OSMV_QUERY_USER_DEFINED;
597 req.timeout_ms = p_osmt->opt.transaction_timeout;
598 req.retry_cnt = p_osmt->opt.retry_count;
599 req.flags = OSM_SA_FLAGS_SYNC;
600 req.query_context = p_context;
601 req.pfn_query_cb = osmtest_query_res_cb;
602 req.p_query_input = &user;
605 status = osmv_query_sa(p_osmt->h_bind, &req);
606 if (status != IB_SUCCESS) {
607 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0004: "
608 "ib_query failed (%s)\n", ib_get_err_str(status));
612 status = p_context->result.status;
614 if (status != IB_SUCCESS) {
615 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0064: "
616 "ib_query failed (%s)\n", ib_get_err_str(status));
618 if (status == IB_REMOTE_ERROR) {
619 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
620 "Remote error = %s\n",
621 ib_get_mad_status_str(osm_madw_get_mad_ptr
629 OSM_LOG_EXIT(&p_osmt->log);
633 /**********************************************************************
634 **********************************************************************/
635 ib_api_status_t osmtest_validate_sa_class_port_info(IN osmtest_t * const p_osmt)
637 ib_api_status_t status = IB_SUCCESS;
638 osmv_query_req_t req;
639 ib_class_port_info_t *p_cpi;
640 osmtest_req_context_t context;
641 osmtest_req_context_t *p_context = &context;
642 ib_sa_mad_t *p_resp_sa_madp;
644 OSM_LOG_ENTER(&p_osmt->log);
646 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Getting ClassPortInfo\n");
649 * Do a blocking query for this record in the subnet.
650 * The result is returned in the result field of the caller's
653 * The query structures are locals.
655 memset(&req, 0, sizeof(req));
657 p_context->p_osmt = p_osmt;
658 req.query_type = OSMV_QUERY_CLASS_PORT_INFO;
659 req.timeout_ms = p_osmt->opt.transaction_timeout;
660 req.retry_cnt = p_osmt->opt.retry_count;
661 req.flags = OSM_SA_FLAGS_SYNC;
662 req.query_context = p_context;
663 req.pfn_query_cb = osmtest_query_res_cb;
664 req.p_query_input = 0;
667 status = osmv_query_sa(p_osmt->h_bind, &req);
668 if (status != IB_SUCCESS) {
669 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0065: "
670 "ib_query failed (%s)\n", ib_get_err_str(status));
674 status = p_context->result.status;
676 if (status != IB_SUCCESS) {
677 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0070: "
678 "ib_query failed (%s)\n", ib_get_err_str(status));
679 if (status == IB_REMOTE_ERROR) {
680 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
681 "Remote error = %s\n",
682 ib_get_mad_status_str(osm_madw_get_mad_ptr
689 /* ok we got it so please print it out */
691 (ib_sa_mad_t *) osm_madw_get_mad_ptr(context.result.p_result_madw);
693 (ib_class_port_info_t *) ib_sa_mad_get_payload_ptr(p_resp_sa_madp);
695 OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
696 "\n-----------------------------\n"
697 "SA Class Port Info:\n"
702 " resp_time_val:0x%X\n"
703 "-----------------------------\n",
704 p_cpi->base_ver, p_cpi->class_ver, cl_ntoh16(p_cpi->cap_mask),
705 ib_class_cap_mask2(p_cpi), ib_class_resp_time_val(p_cpi));
709 if (context.result.p_result_madw != NULL) {
710 osm_mad_pool_put(&p_osmt->mad_pool,
711 context.result.p_result_madw);
712 context.result.p_result_madw = NULL;
716 OSM_LOG_EXIT(&p_osmt->log);
720 /**********************************************************************
721 **********************************************************************/
723 osmtest_get_node_rec(IN osmtest_t * const p_osmt,
724 IN ib_net64_t const node_guid,
725 IN OUT osmtest_req_context_t * const p_context)
727 ib_api_status_t status = IB_SUCCESS;
728 osmv_user_query_t user;
729 osmv_query_req_t req;
730 ib_node_record_t record;
732 OSM_LOG_ENTER(&p_osmt->log);
734 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
735 "Getting node record for 0x%016" PRIx64 "\n",
736 cl_ntoh64(node_guid));
739 * Do a blocking query for this record in the subnet.
740 * The result is returned in the result field of the caller's
743 * The query structures are locals.
745 memset(&req, 0, sizeof(req));
746 memset(&user, 0, sizeof(user));
747 memset(&record, 0, sizeof(record));
749 record.node_info.node_guid = node_guid;
751 p_context->p_osmt = p_osmt;
752 user.comp_mask = IB_NR_COMPMASK_NODEGUID;
753 user.attr_id = IB_MAD_ATTR_NODE_RECORD;
754 user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3));
755 user.p_attr = &record;
757 req.query_type = OSMV_QUERY_USER_DEFINED;
758 req.timeout_ms = p_osmt->opt.transaction_timeout;
759 req.retry_cnt = p_osmt->opt.retry_count;
760 req.flags = OSM_SA_FLAGS_SYNC;
761 req.query_context = p_context;
762 req.pfn_query_cb = osmtest_query_res_cb;
763 req.p_query_input = &user;
766 status = osmv_query_sa(p_osmt->h_bind, &req);
767 if (status != IB_SUCCESS) {
768 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0071: "
769 "ib_query failed (%s)\n", ib_get_err_str(status));
773 status = p_context->result.status;
775 if (status != IB_SUCCESS) {
776 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0072: "
777 "ib_query failed (%s)\n", ib_get_err_str(status));
778 if (status == IB_REMOTE_ERROR) {
779 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
780 "Remote error = %s\n",
781 ib_get_mad_status_str(osm_madw_get_mad_ptr
789 OSM_LOG_EXIT(&p_osmt->log);
793 /**********************************************************************
794 * Get a node record by node LID
795 **********************************************************************/
797 osmtest_get_node_rec_by_lid(IN osmtest_t * const p_osmt,
798 IN ib_net16_t const lid,
799 IN OUT osmtest_req_context_t * const p_context)
801 ib_api_status_t status = IB_SUCCESS;
802 osmv_user_query_t user;
803 osmv_query_req_t req;
804 ib_node_record_t record;
807 OSM_LOG_ENTER(&p_osmt->log);
809 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
810 "Getting node record for LID 0x%02X\n", cl_ntoh16(lid));
813 * Do a blocking query for this record in the subnet.
814 * The result is returned in the result field of the caller's
817 * The query structures are locals.
819 memset(&req, 0, sizeof(req));
820 memset(&user, 0, sizeof(user));
821 memset(&record, 0, sizeof(record));
825 p_context->p_osmt = p_osmt;
826 user.comp_mask = IB_NR_COMPMASK_LID;
827 user.attr_id = IB_MAD_ATTR_NODE_RECORD;
828 user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3));
829 user.p_attr = &record;
831 req.query_type = OSMV_QUERY_USER_DEFINED;
832 req.timeout_ms = p_osmt->opt.transaction_timeout;
833 req.retry_cnt = p_osmt->opt.retry_count;
834 req.flags = OSM_SA_FLAGS_SYNC;
835 req.query_context = p_context;
836 req.pfn_query_cb = osmtest_query_res_cb;
837 req.p_query_input = &user;
840 status = osmv_query_sa(p_osmt->h_bind, &req);
841 if (status != IB_SUCCESS) {
842 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0073: "
843 "ib_query failed (%s)\n", ib_get_err_str(status));
847 status = p_context->result.status;
849 if (status != IB_SUCCESS) {
850 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0074: "
851 "ib_query failed (%s)\n", ib_get_err_str(status));
852 if (status == IB_REMOTE_ERROR) {
854 osm_madw_get_mad_ptr(p_context->result.
856 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
857 "Remote error = %s\n",
858 ib_get_mad_status_str(p_mad));
861 (ib_net16_t) (p_mad->status & IB_SMP_STATUS_MASK);
867 OSM_LOG_EXIT(&p_osmt->log);
871 /**********************************************************************
872 **********************************************************************/
873 static ib_api_status_t
874 osmtest_get_path_rec_by_guid_pair(IN osmtest_t * const p_osmt,
877 IN osmtest_req_context_t * p_context)
879 cl_status_t status = IB_SUCCESS;
880 osmv_query_req_t req;
881 osmv_guid_pair_t guid_pair;
883 OSM_LOG_ENTER(&p_osmt->log);
885 memset(&req, 0, sizeof(req));
886 memset(p_context, 0, sizeof(*p_context));
888 p_context->p_osmt = p_osmt;
889 req.timeout_ms = p_osmt->opt.transaction_timeout;
890 req.retry_cnt = p_osmt->opt.retry_count;
891 req.flags = OSM_SA_FLAGS_SYNC;
892 req.query_context = p_context;
893 req.pfn_query_cb = osmtest_query_res_cb;
895 req.query_type = OSMV_QUERY_PATH_REC_BY_PORT_GUIDS;
897 guid_pair.dest_guid = dguid;
898 guid_pair.src_guid = sguid;
900 req.p_query_input = &guid_pair;
903 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
904 "Query for path from 0x%" PRIx64 " to 0x%" PRIx64 "\n",
907 status = osmv_query_sa(p_osmt->h_bind, &req);
908 if (status != IB_SUCCESS) {
909 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0063: "
910 "ib_query failed (%s)\n", ib_get_err_str(status));
914 status = (*p_context).result.status;
916 if (status != IB_SUCCESS) {
917 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0066: "
918 "ib_query failed (%s)\n", ib_get_err_str(status));
920 if (status == IB_REMOTE_ERROR) {
921 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
922 "Remote error = %s\n",
923 ib_get_mad_status_str(osm_madw_get_mad_ptr
924 ((*p_context).result.
932 OSM_LOG_EXIT(&p_osmt->log);
936 /**********************************************************************
937 **********************************************************************/
938 static ib_api_status_t
939 osmtest_get_path_rec_by_gid_pair(IN osmtest_t * const p_osmt,
942 IN osmtest_req_context_t * p_context)
944 cl_status_t status = IB_SUCCESS;
945 osmv_query_req_t req;
946 osmv_gid_pair_t gid_pair;
948 OSM_LOG_ENTER(&p_osmt->log);
950 memset(&req, 0, sizeof(req));
951 memset(p_context, 0, sizeof(*p_context));
953 p_context->p_osmt = p_osmt;
954 req.timeout_ms = p_osmt->opt.transaction_timeout;
955 req.retry_cnt = p_osmt->opt.retry_count;
956 req.flags = OSM_SA_FLAGS_SYNC;
957 req.query_context = p_context;
958 req.pfn_query_cb = osmtest_query_res_cb;
960 req.query_type = OSMV_QUERY_PATH_REC_BY_GIDS;
962 gid_pair.dest_gid = dgid;
963 gid_pair.src_gid = sgid;
965 req.p_query_input = &gid_pair;
968 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
969 "Query for path from 0x%016" PRIx64 " 0x%016" PRIx64
970 " to 0x%016" PRIx64 " 0x%016" PRIx64 "\n", sgid.unicast.prefix,
971 sgid.unicast.interface_id, dgid.unicast.prefix,
972 dgid.unicast.interface_id);
974 status = osmv_query_sa(p_osmt->h_bind, &req);
975 if (status != IB_SUCCESS) {
976 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 006A: "
977 "ib_query failed (%s)\n", ib_get_err_str(status));
981 status = (*p_context).result.status;
983 if (status != IB_SUCCESS) {
984 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 006B: "
985 "ib_query failed (%s)\n", ib_get_err_str(status));
987 if (status == IB_REMOTE_ERROR) {
988 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
989 "Remote error = %s\n",
990 ib_get_mad_status_str(osm_madw_get_mad_ptr
991 ((*p_context).result.
999 OSM_LOG_EXIT(&p_osmt->log);
1003 #if defined (VENDOR_RMPP_SUPPORT) && defined (DUAL_SIDED_RMPP)
1004 /**********************************************************************
1005 **********************************************************************/
1006 static ib_api_status_t
1007 osmtest_get_multipath_rec(IN osmtest_t * const p_osmt,
1008 IN osmv_multipath_req_t * p_request,
1009 IN osmtest_req_context_t * p_context)
1011 cl_status_t status = IB_SUCCESS;
1012 osmv_query_req_t req;
1014 OSM_LOG_ENTER(&p_osmt->log);
1017 * Do a blocking query for this record in the subnet.
1018 * The result is returned in the result field of the caller's
1019 * context structure.
1021 * The query structures are locals.
1023 memset(&req, 0, sizeof(req));
1025 p_context->p_osmt = p_osmt;
1026 req.timeout_ms = p_osmt->opt.transaction_timeout;
1027 req.retry_cnt = p_osmt->opt.retry_count;
1028 req.flags = OSM_SA_FLAGS_SYNC;
1029 req.query_context = p_context;
1030 req.pfn_query_cb = osmtest_query_res_cb;
1032 req.query_type = OSMV_QUERY_MULTIPATH_REC;
1034 req.p_query_input = p_request;
1037 status = osmv_query_sa(p_osmt->h_bind, &req);
1038 if (status != IB_SUCCESS) {
1039 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0068: "
1040 "ib_query failed (%s)\n", ib_get_err_str(status));
1044 status = p_context->result.status;
1046 if (status != IB_SUCCESS) {
1047 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0069: "
1048 "ib_query failed (%s)\n", ib_get_err_str(status));
1050 if (status == IB_REMOTE_ERROR) {
1051 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
1052 "Remote error = %s\n",
1053 ib_get_mad_status_str(osm_madw_get_mad_ptr
1061 OSM_LOG_EXIT(&p_osmt->log);
1066 /**********************************************************************
1067 **********************************************************************/
1069 osmtest_get_port_rec(IN osmtest_t * const p_osmt,
1070 IN ib_net16_t const lid,
1071 IN OUT osmtest_req_context_t * const p_context)
1073 ib_api_status_t status = IB_SUCCESS;
1074 osmv_user_query_t user;
1075 osmv_query_req_t req;
1076 ib_portinfo_record_t record;
1078 OSM_LOG_ENTER(&p_osmt->log);
1080 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
1081 "Getting PortInfoRecord for port with LID 0x%X\n",
1085 * Do a blocking query for this record in the subnet.
1086 * The result is returned in the result field of the caller's
1087 * context structure.
1089 * The query structures are locals.
1091 memset(&req, 0, sizeof(req));
1092 memset(&user, 0, sizeof(user));
1093 memset(&record, 0, sizeof(record));
1097 p_context->p_osmt = p_osmt;
1098 user.comp_mask = IB_PIR_COMPMASK_LID;
1099 user.attr_id = IB_MAD_ATTR_PORTINFO_RECORD;
1100 user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3));
1101 user.p_attr = &record;
1103 req.query_type = OSMV_QUERY_USER_DEFINED;
1104 req.timeout_ms = p_osmt->opt.transaction_timeout;
1105 req.retry_cnt = p_osmt->opt.retry_count;
1106 req.flags = OSM_SA_FLAGS_SYNC;
1107 req.query_context = p_context;
1108 req.pfn_query_cb = osmtest_query_res_cb;
1109 req.p_query_input = &user;
1112 status = osmv_query_sa(p_osmt->h_bind, &req);
1113 if (status != IB_SUCCESS) {
1114 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0075: "
1115 "ib_query failed (%s)\n", ib_get_err_str(status));
1119 status = p_context->result.status;
1121 if (status != IB_SUCCESS) {
1122 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0076: "
1123 "ib_query failed (%s)\n", ib_get_err_str(status));
1125 if (status == IB_REMOTE_ERROR) {
1126 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
1127 "Remote error = %s\n",
1128 ib_get_mad_status_str(osm_madw_get_mad_ptr
1136 OSM_LOG_EXIT(&p_osmt->log);
1140 /**********************************************************************
1141 **********************************************************************/
1143 osmtest_get_port_rec_by_num(IN osmtest_t * const p_osmt,
1144 IN ib_net16_t const lid,
1145 IN uint8_t const port_num,
1146 IN OUT osmtest_req_context_t * const p_context)
1148 ib_api_status_t status = IB_SUCCESS;
1149 osmv_user_query_t user;
1150 osmv_query_req_t req;
1151 ib_portinfo_record_t record;
1154 OSM_LOG_ENTER(&p_osmt->log);
1156 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
1157 "Getting PortInfoRecord for port with LID 0x%X Num:0x%X\n",
1158 cl_ntoh16(lid), port_num);
1161 * Do a blocking query for this record in the subnet.
1162 * The result is returned in the result field of the caller's
1163 * context structure.
1165 * The query structures are locals.
1167 memset(&req, 0, sizeof(req));
1168 memset(&user, 0, sizeof(user));
1169 memset(&record, 0, sizeof(record));
1172 record.port_num = port_num;
1173 user.p_attr = &record;
1175 p_context->p_osmt = p_osmt;
1177 req.query_type = OSMV_QUERY_PORT_REC_BY_LID_AND_NUM;
1178 req.timeout_ms = p_osmt->opt.transaction_timeout;
1179 req.retry_cnt = p_osmt->opt.retry_count;
1180 req.flags = OSM_SA_FLAGS_SYNC;
1181 req.query_context = p_context;
1182 req.pfn_query_cb = osmtest_query_res_cb;
1183 req.p_query_input = &user;
1186 status = osmv_query_sa(p_osmt->h_bind, &req);
1187 if (status != IB_SUCCESS) {
1188 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0077: "
1189 "ib_query failed (%s)\n", ib_get_err_str(status));
1193 status = p_context->result.status;
1195 if (status != IB_SUCCESS) {
1196 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0078: "
1197 "ib_query failed (%s)\n", ib_get_err_str(status));
1199 if (status == IB_REMOTE_ERROR) {
1201 osm_madw_get_mad_ptr(p_context->result.
1203 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
1204 "Remote error = %s\n",
1205 ib_get_mad_status_str(p_mad));
1207 (ib_net16_t) (p_mad->status & IB_SMP_STATUS_MASK);
1213 OSM_LOG_EXIT(&p_osmt->log);
1217 /**********************************************************************
1218 **********************************************************************/
1220 osmtest_stress_port_recs_large(IN osmtest_t * const p_osmt,
1221 OUT uint32_t * const p_num_recs,
1222 OUT uint32_t * const p_num_queries)
1224 osmtest_req_context_t context;
1225 ib_portinfo_record_t *p_rec;
1228 uint32_t num_recs = 0;
1230 OSM_LOG_ENTER(&p_osmt->log);
1232 memset(&context, 0, sizeof(context));
1234 * Do a blocking query for all PortInfoRecords in the subnet.
1236 status = osmtest_get_all_recs(p_osmt, IB_MAD_ATTR_PORTINFO_RECORD,
1237 sizeof(*p_rec), &context);
1239 if (status != IB_SUCCESS) {
1240 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0006: "
1241 "osmtest_get_all_recs failed (%s)\n",
1242 ib_get_err_str(status));
1247 * Populate the database with the received records.
1249 num_recs = context.result.result_cnt;
1250 *p_num_recs += num_recs;
1253 if (osm_log_is_active(&p_osmt->log, OSM_LOG_VERBOSE)) {
1254 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
1255 "Received %u records\n", num_recs);
1257 for (i = 0; i < num_recs; i++) {
1259 osmv_get_query_portinfo_rec(context.result.
1261 osm_dump_portinfo_record(&p_osmt->log, p_rec,
1268 * Return the IB query MAD to the pool as necessary.
1270 if (context.result.p_result_madw != NULL) {
1271 osm_mad_pool_put(&p_osmt->mad_pool,
1272 context.result.p_result_madw);
1273 context.result.p_result_madw = NULL;
1276 OSM_LOG_EXIT(&p_osmt->log);
1280 /**********************************************************************
1281 **********************************************************************/
1283 osmtest_stress_node_recs_large(IN osmtest_t * const p_osmt,
1284 OUT uint32_t * const p_num_recs,
1285 OUT uint32_t * const p_num_queries)
1287 osmtest_req_context_t context;
1288 ib_node_record_t *p_rec;
1291 uint32_t num_recs = 0;
1293 OSM_LOG_ENTER(&p_osmt->log);
1295 memset(&context, 0, sizeof(context));
1298 * Do a blocking query for all NodeRecords in the subnet.
1300 status = osmtest_get_all_recs(p_osmt, IB_MAD_ATTR_NODE_RECORD,
1301 sizeof(*p_rec), &context);
1303 if (status != IB_SUCCESS) {
1304 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0007: "
1305 "osmtest_get_all_recs failed (%s)\n",
1306 ib_get_err_str(status));
1311 * Populate the database with the received records.
1313 num_recs = context.result.result_cnt;
1314 *p_num_recs += num_recs;
1317 if (osm_log_is_active(&p_osmt->log, OSM_LOG_VERBOSE)) {
1318 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
1319 "Received %u records\n", num_recs);
1321 for (i = 0; i < num_recs; i++) {
1323 osmv_get_query_node_rec(context.result.
1325 osm_dump_node_record(&p_osmt->log, p_rec,
1332 * Return the IB query MAD to the pool as necessary.
1334 if (context.result.p_result_madw != NULL) {
1335 osm_mad_pool_put(&p_osmt->mad_pool,
1336 context.result.p_result_madw);
1337 context.result.p_result_madw = NULL;
1340 OSM_LOG_EXIT(&p_osmt->log);
1344 /**********************************************************************
1345 **********************************************************************/
1347 osmtest_stress_path_recs_large(IN osmtest_t * const p_osmt,
1348 OUT uint32_t * const p_num_recs,
1349 OUT uint32_t * const p_num_queries)
1351 osmtest_req_context_t context;
1352 ib_path_rec_t *p_rec;
1355 uint32_t num_recs = 0;
1357 OSM_LOG_ENTER(&p_osmt->log);
1359 memset(&context, 0, sizeof(context));
1362 * Do a blocking query for all PathRecords in the subnet.
1364 status = osmtest_get_all_recs(p_osmt, IB_MAD_ATTR_PATH_RECORD,
1365 sizeof(*p_rec), &context);
1366 if (status != IB_SUCCESS) {
1367 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0008: "
1368 "osmtest_get_all_recs failed (%s)\n",
1369 ib_get_err_str(status));
1374 * Populate the database with the received records.
1376 num_recs = context.result.result_cnt;
1377 *p_num_recs += num_recs;
1380 if (osm_log_is_active(&p_osmt->log, OSM_LOG_VERBOSE)) {
1381 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
1382 "Received %u records\n", num_recs);
1384 for (i = 0; i < num_recs; i++) {
1386 osmv_get_query_path_rec(context.result.
1388 osm_dump_path_record(&p_osmt->log, p_rec,
1395 * Return the IB query MAD to the pool as necessary.
1397 if (context.result.p_result_madw != NULL) {
1398 osm_mad_pool_put(&p_osmt->mad_pool,
1399 context.result.p_result_madw);
1400 context.result.p_result_madw = NULL;
1403 OSM_LOG_EXIT(&p_osmt->log);
1407 /**********************************************************************
1408 **********************************************************************/
1410 osmtest_stress_path_recs_by_guid(IN osmtest_t * const p_osmt,
1411 OUT uint32_t * const p_num_recs,
1412 OUT uint32_t * const p_num_queries)
1414 osmtest_req_context_t context;
1415 ib_path_rec_t *p_rec;
1417 cl_status_t status = IB_SUCCESS;
1418 uint32_t num_recs = 0;
1419 node_t *p_src_node, *p_dst_node;
1422 OSM_LOG_ENTER(&p_osmt->log);
1424 memset(&context, 0, sizeof(context));
1426 context.p_osmt = p_osmt;
1428 p_tbl = &p_osmt->exp_subn.node_guid_tbl;
1430 p_src_node = (node_t *) cl_qmap_head(p_tbl);
1433 * Go over all nodes that exist in the subnet
1434 * for each pair that are not switch nodes get the path record
1436 while (p_src_node != (node_t *) cl_qmap_end(p_tbl)) {
1437 p_dst_node = (node_t *) cl_qmap_head(p_tbl);
1439 while (p_dst_node != (node_t *) cl_qmap_end(p_tbl)) {
1441 * Do a blocking query for CA to CA Path Record
1443 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
1444 "Source : guid = 0x%" PRIx64 " type = %d"
1445 "Target : guid = 0x%" PRIx64 " type = %d\n",
1446 cl_ntoh64(p_src_node->rec.node_info.port_guid),
1447 p_src_node->rec.node_info.node_type,
1448 cl_ntoh64(p_dst_node->rec.node_info.port_guid),
1449 p_dst_node->rec.node_info.node_type);
1451 if (p_src_node->rec.node_info.node_type ==
1453 && p_dst_node->rec.node_info.node_type ==
1456 osmtest_get_path_rec_by_guid_pair(p_osmt,
1467 /* In a case of TIMEOUT you still can try sending but cant count, maybe its a temporary issue */
1468 if (status != IB_SUCCESS) {
1469 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
1471 "osmtest_get_path_rec_by_guid_pair failed (%s)\n",
1472 ib_get_err_str(status));
1473 if (status != IB_TIMEOUT)
1476 /* we might have received several records */
1477 num_recs = context.result.result_cnt;
1479 * Populate the database with the received records.
1481 *p_num_recs += num_recs;
1483 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
1484 "Received %u records\n", num_recs);
1485 /* Dont waste time if not VERBOSE and above */
1486 if (p_osmt->log.level & OSM_LOG_VERBOSE) {
1487 for (i = 0; i < num_recs; i++) {
1489 osmv_get_query_path_rec
1492 osm_dump_path_record
1499 if (context.result.p_result_madw != NULL) {
1500 osm_mad_pool_put(&p_osmt->mad_pool,
1503 context.result.p_result_madw = NULL;
1506 /* next one please */
1508 (node_t *) cl_qmap_next(&p_dst_node->map_item);
1511 p_src_node = (node_t *) cl_qmap_next(&p_src_node->map_item);
1515 OSM_LOG_EXIT(&p_osmt->log);
1519 /**********************************************************************
1520 **********************************************************************/
1522 osmtest_stress_port_recs_small(IN osmtest_t * const p_osmt,
1523 OUT uint32_t * const p_num_recs,
1524 OUT uint32_t * const p_num_queries)
1526 osmtest_req_context_t context;
1527 ib_portinfo_record_t *p_rec;
1530 uint32_t num_recs = 0;
1532 OSM_LOG_ENTER(&p_osmt->log);
1534 memset(&context, 0, sizeof(context));
1537 * Do a blocking query for our own PortInfoRecord in the subnet.
1539 status = osmtest_get_port_rec(p_osmt,
1540 cl_ntoh16(p_osmt->local_port.lid),
1543 if (status != IB_SUCCESS) {
1544 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0010: "
1545 "osmtest_get_port_rec failed (%s)\n",
1546 ib_get_err_str(status));
1551 * Populate the database with the received records.
1553 num_recs = context.result.result_cnt;
1554 *p_num_recs += num_recs;
1557 if (osm_log_is_active(&p_osmt->log, OSM_LOG_VERBOSE)) {
1558 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
1559 "Received %u records\n", num_recs);
1561 for (i = 0; i < num_recs; i++) {
1563 osmv_get_query_portinfo_rec(context.result.
1565 osm_dump_portinfo_record(&p_osmt->log, p_rec,
1572 * Return the IB query MAD to the pool as necessary.
1574 if (context.result.p_result_madw != NULL) {
1575 osm_mad_pool_put(&p_osmt->mad_pool,
1576 context.result.p_result_madw);
1577 context.result.p_result_madw = NULL;
1580 OSM_LOG_EXIT(&p_osmt->log);
1584 /**********************************************************************
1585 **********************************************************************/
1587 osmtest_get_local_port_lmc(IN osmtest_t * const p_osmt,
1588 IN ib_net16_t lid, OUT uint8_t * const p_lmc)
1590 osmtest_req_context_t context;
1591 ib_portinfo_record_t *p_rec;
1594 uint32_t num_recs = 0;
1596 OSM_LOG_ENTER(&p_osmt->log);
1598 memset(&context, 0, sizeof(context));
1601 * Do a blocking query for our own PortInfoRecord in the subnet.
1603 status = osmtest_get_port_rec(p_osmt, cl_ntoh16(lid), &context);
1605 if (status != IB_SUCCESS) {
1606 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 001A: "
1607 "osmtest_get_port_rec failed (%s)\n",
1608 ib_get_err_str(status));
1612 num_recs = context.result.result_cnt;
1614 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Received %u records\n", num_recs);
1616 for (i = 0; i < num_recs; i++) {
1618 osmv_get_query_portinfo_rec(context.result.p_result_madw,
1620 osm_dump_portinfo_record(&p_osmt->log, p_rec, OSM_LOG_VERBOSE);
1622 *p_lmc = ib_port_info_get_lmc(&p_rec->port_info);
1623 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "LMC %d\n", *p_lmc);
1629 * Return the IB query MAD to the pool as necessary.
1631 if (context.result.p_result_madw != NULL) {
1632 osm_mad_pool_put(&p_osmt->mad_pool,
1633 context.result.p_result_madw);
1634 context.result.p_result_madw = NULL;
1637 OSM_LOG_EXIT(&p_osmt->log);
1641 /**********************************************************************
1642 * Use a wrong SM_Key in a simple port query and report success if
1644 **********************************************************************/
1645 ib_api_status_t osmtest_wrong_sm_key_ignored(IN osmtest_t * const p_osmt)
1647 ib_api_status_t status = IB_SUCCESS;
1648 osmv_user_query_t user;
1649 osmv_query_req_t req;
1650 ib_portinfo_record_t record;
1651 osmtest_req_context_t context;
1652 osmtest_req_context_t *p_context = &context;
1653 uint8_t port_num = 1;
1655 OSM_LOG_ENTER(&p_osmt->log);
1657 OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
1658 "Trying PortInfoRecord for port with LID 0x%X Num:0x%X\n",
1659 p_osmt->local_port.sm_lid, port_num);
1662 * Do a blocking query for this record in the subnet.
1663 * The result is returned in the result field of the caller's
1664 * context structure.
1666 * The query structures are locals.
1668 memset(&req, 0, sizeof(req));
1669 memset(&user, 0, sizeof(user));
1670 memset(&record, 0, sizeof(record));
1672 record.lid = p_osmt->local_port.sm_lid;
1673 record.port_num = port_num;
1674 user.p_attr = &record;
1676 p_context->p_osmt = p_osmt;
1678 req.query_type = OSMV_QUERY_PORT_REC_BY_LID_AND_NUM;
1679 req.timeout_ms = p_osmt->opt.transaction_timeout;
1680 req.retry_cnt = p_osmt->opt.retry_count;
1681 req.flags = OSM_SA_FLAGS_SYNC;
1682 req.query_context = p_context;
1683 req.pfn_query_cb = osmtest_query_res_cb;
1684 req.p_query_input = &user;
1686 context.result.p_result_madw = NULL;
1688 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
1689 status = osmv_query_sa(p_osmt->h_bind, &req);
1690 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
1692 /* since we use a wrong sm_key we should get a timeout */
1693 if (status != IB_TIMEOUT) {
1694 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0011: "
1695 "Did not get a timeout but got (%s)\n",
1696 ib_get_err_str(status));
1697 if (status == IB_SUCCESS) {
1698 /* assign some error value to status, since IB_SUCCESS is a bad rc */
1703 status = IB_SUCCESS;
1707 if (context.result.p_result_madw != NULL) {
1708 osm_mad_pool_put(&p_osmt->mad_pool,
1709 context.result.p_result_madw);
1710 context.result.p_result_madw = NULL;
1713 OSM_LOG_EXIT(&p_osmt->log);
1717 /**********************************************************************
1718 **********************************************************************/
1719 static ib_api_status_t
1720 osmtest_write_port_info(IN osmtest_t * const p_osmt,
1722 IN const ib_portinfo_record_t * const p_rec)
1725 cl_status_t status = IB_SUCCESS;
1727 OSM_LOG_ENTER(&p_osmt->log);
1729 result = fprintf(fh,
1733 "m_key 0x%016" PRIx64 "\n"
1734 "subnet_prefix 0x%016" PRIx64 "\n"
1736 "master_sm_base_lid 0x%X\n"
1737 "capability_mask 0x%X\n"
1739 "m_key_lease_period 0x%X\n"
1740 "local_port_num 0x%X\n"
1741 "link_width_enabled 0x%X\n"
1742 "link_width_supported 0x%X\n"
1743 "link_width_active 0x%X\n"
1744 "link_speed_supported 0x%X\n"
1746 "state_info2 0x%X\n"
1752 "vl_high_limit 0x%X\n"
1753 "vl_arb_high_cap 0x%X\n"
1754 "vl_arb_low_cap 0x%X\n"
1756 "vl_stall_life 0x%X\n"
1758 "m_key_violations 0x%X\n"
1759 "p_key_violations 0x%X\n"
1760 "q_key_violations 0x%X\n"
1762 "subnet_timeout 0x%X\n"
1763 "resp_time_value 0x%X\n"
1764 "error_threshold 0x%X\n"
1766 cl_ntoh16(p_rec->lid),
1768 cl_ntoh64(p_rec->port_info.m_key),
1769 cl_ntoh64(p_rec->port_info.subnet_prefix),
1770 cl_ntoh16(p_rec->port_info.base_lid),
1771 cl_ntoh16(p_rec->port_info.master_sm_base_lid),
1772 cl_ntoh32(p_rec->port_info.capability_mask),
1773 cl_ntoh16(p_rec->port_info.diag_code),
1774 cl_ntoh16(p_rec->port_info.m_key_lease_period),
1775 p_rec->port_info.local_port_num,
1776 p_rec->port_info.link_width_enabled,
1777 p_rec->port_info.link_width_supported,
1778 p_rec->port_info.link_width_active,
1779 ib_port_info_get_link_speed_sup(&p_rec->port_info),
1780 ib_get_port_state_str(ib_port_info_get_port_state
1781 (&p_rec->port_info)),
1782 p_rec->port_info.state_info2,
1783 ib_port_info_get_mpb(&p_rec->port_info),
1784 ib_port_info_get_lmc(&p_rec->port_info),
1785 p_rec->port_info.link_speed, p_rec->port_info.mtu_smsl,
1786 p_rec->port_info.vl_cap,
1787 p_rec->port_info.vl_high_limit,
1788 p_rec->port_info.vl_arb_high_cap,
1789 p_rec->port_info.vl_arb_low_cap,
1790 p_rec->port_info.mtu_cap,
1791 p_rec->port_info.vl_stall_life,
1792 p_rec->port_info.vl_enforce,
1793 cl_ntoh16(p_rec->port_info.m_key_violations),
1794 cl_ntoh16(p_rec->port_info.p_key_violations),
1795 cl_ntoh16(p_rec->port_info.q_key_violations),
1796 p_rec->port_info.guid_cap,
1797 ib_port_info_get_timeout(&p_rec->port_info),
1798 p_rec->port_info.resp_time_value,
1799 p_rec->port_info.error_threshold);
1802 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0161: "
1809 OSM_LOG_EXIT(&p_osmt->log);
1813 /**********************************************************************
1814 **********************************************************************/
1815 static ib_api_status_t
1816 osmtest_write_path_info(IN osmtest_t * const p_osmt,
1817 IN FILE * fh, IN const ib_path_rec_t * const p_rec)
1820 cl_status_t status = IB_SUCCESS;
1822 OSM_LOG_ENTER(&p_osmt->log);
1824 result = fprintf(fh,
1826 "dgid 0x%016" PRIx64 " 0x%016"
1827 PRIx64 "\nsgid 0x%016" PRIx64
1828 " 0x%016" PRIx64 "\ndlid 0x%X\n"
1830 "# hop_flow_raw 0x%X\n"
1835 "# qos_class 0x%X\n"
1839 "# preference 0x%X\n" "END\n\n",
1840 cl_ntoh64(p_rec->dgid.unicast.prefix),
1841 cl_ntoh64(p_rec->dgid.unicast.interface_id),
1842 cl_ntoh64(p_rec->sgid.unicast.prefix),
1843 cl_ntoh64(p_rec->sgid.unicast.interface_id),
1844 cl_ntoh16(p_rec->dlid), cl_ntoh16(p_rec->slid),
1845 cl_ntoh32(p_rec->hop_flow_raw), p_rec->tclass,
1846 p_rec->num_path, cl_ntoh16(p_rec->pkey),
1847 ib_path_rec_sl(p_rec), ib_path_rec_qos_class(p_rec),
1848 p_rec->mtu, p_rec->rate, p_rec->pkt_life,
1852 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0162: "
1859 OSM_LOG_EXIT(&p_osmt->log);
1863 /**********************************************************************
1864 **********************************************************************/
1865 static ib_api_status_t
1866 osmtest_write_node_info(IN osmtest_t * const p_osmt,
1867 IN FILE * fh, IN const ib_node_record_t * const p_rec)
1870 cl_status_t status = IB_SUCCESS;
1871 char desc[IB_NODE_DESCRIPTION_SIZE + 1];
1873 OSM_LOG_ENTER(&p_osmt->log);
1875 memcpy(desc, p_rec->node_desc.description, IB_NODE_DESCRIPTION_SIZE);
1876 desc[IB_NODE_DESCRIPTION_SIZE] = '\0';
1878 result = fprintf(fh,
1881 "base_version 0x%X\n"
1882 "class_version 0x%X\n"
1883 "node_type 0x%X # (%s)\n"
1885 "sys_guid 0x%016" PRIx64 "\n"
1886 "node_guid 0x%016" PRIx64 "\n"
1887 "port_guid 0x%016" PRIx64 "\n"
1888 "partition_cap 0x%X\n"
1892 "# vendor_id 0x%X\n"
1895 cl_ntoh16(p_rec->lid),
1896 p_rec->node_info.base_version,
1897 p_rec->node_info.class_version,
1898 p_rec->node_info.node_type,
1899 ib_get_node_type_str(p_rec->node_info.node_type),
1900 p_rec->node_info.num_ports,
1901 cl_ntoh64(p_rec->node_info.sys_guid),
1902 cl_ntoh64(p_rec->node_info.node_guid),
1903 cl_ntoh64(p_rec->node_info.port_guid),
1904 cl_ntoh16(p_rec->node_info.partition_cap),
1905 cl_ntoh16(p_rec->node_info.device_id),
1906 cl_ntoh32(p_rec->node_info.revision),
1907 ib_node_info_get_local_port_num(&p_rec->node_info),
1908 cl_ntoh32(ib_node_info_get_vendor_id
1909 (&p_rec->node_info)), desc);
1912 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0163: "
1919 OSM_LOG_EXIT(&p_osmt->log);
1923 /**********************************************************************
1924 **********************************************************************/
1925 static ib_api_status_t
1926 osmtest_write_link(IN osmtest_t * const p_osmt,
1927 IN FILE * fh, IN const ib_link_record_t * const p_rec)
1930 cl_status_t status = IB_SUCCESS;
1932 OSM_LOG_ENTER(&p_osmt->log);
1934 result = fprintf(fh,
1937 "from_port_num 0x%X\n"
1938 "to_port_num 0x%X\n"
1941 cl_ntoh16(p_rec->from_lid),
1942 p_rec->from_port_num,
1943 p_rec->to_port_num, cl_ntoh16(p_rec->to_lid));
1946 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0164: "
1953 OSM_LOG_EXIT(&p_osmt->log);
1957 /**********************************************************************
1958 **********************************************************************/
1959 static ib_api_status_t
1960 osmtest_write_all_link_recs(IN osmtest_t * const p_osmt, IN FILE * fh)
1962 osmtest_req_context_t context;
1963 const ib_link_record_t *p_rec;
1969 OSM_LOG_ENTER(&p_osmt->log);
1971 memset(&context, 0, sizeof(context));
1974 * Do a blocking query for all NodeRecords in the subnet.
1976 status = osmtest_get_all_recs(p_osmt, IB_MAD_ATTR_LINK_RECORD,
1977 sizeof(*p_rec), &context);
1979 if (status != IB_SUCCESS) {
1980 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0165: "
1981 "osmtest_get_all_recs failed (%s)\n",
1982 ib_get_err_str(status));
1987 * Write the received records out to the file.
1989 num_recs = context.result.result_cnt;
1991 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
1992 "Received %zu records\n", num_recs);
1994 result = fprintf(fh, "#\n" "# Link Records\n" "#\n");
1996 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0166: "
2002 for (i = 0; i < num_recs; i++) {
2004 (ib_link_record_t *) osmv_get_query_result(context.result.
2008 osmtest_write_link(p_osmt, fh, p_rec);
2013 * Return the IB query MAD to the pool as necessary.
2015 if (context.result.p_result_madw != NULL) {
2016 osm_mad_pool_put(&p_osmt->mad_pool,
2017 context.result.p_result_madw);
2018 context.result.p_result_madw = NULL;
2021 OSM_LOG_EXIT(&p_osmt->log);
2025 /**********************************************************************
2026 **********************************************************************/
2027 static ib_api_status_t
2028 osmtest_get_path_rec_by_lid_pair(IN osmtest_t * const p_osmt,
2031 IN osmtest_req_context_t * p_context)
2033 cl_status_t status = IB_SUCCESS;
2034 osmv_query_req_t req;
2035 osmv_lid_pair_t lid_pair;
2037 OSM_LOG_ENTER(&p_osmt->log);
2039 memset(&req, 0, sizeof(req));
2040 memset(p_context, 0, sizeof(*p_context));
2042 p_context->p_osmt = p_osmt;
2043 req.timeout_ms = p_osmt->opt.transaction_timeout;
2044 req.retry_cnt = p_osmt->opt.retry_count;
2045 req.flags = OSM_SA_FLAGS_SYNC;
2046 req.query_context = p_context;
2047 req.pfn_query_cb = osmtest_query_res_cb;
2049 req.query_type = OSMV_QUERY_PATH_REC_BY_LIDS;
2051 lid_pair.dest_lid = dlid;
2052 lid_pair.src_lid = slid;
2054 req.p_query_input = &lid_pair;
2057 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
2058 "Query for path from 0x%X to 0x%X\n", slid, dlid);
2059 status = osmv_query_sa(p_osmt->h_bind, &req);
2060 if (status != IB_SUCCESS) {
2061 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0053: "
2062 "ib_query failed (%s)\n", ib_get_err_str(status));
2066 status = (*p_context).result.status;
2068 if (status != IB_SUCCESS) {
2069 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0067: "
2070 "ib_query failed (%s)\n", ib_get_err_str(status));
2072 if (status == IB_REMOTE_ERROR) {
2073 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
2074 "Remote error = %s\n",
2075 ib_get_mad_status_str(osm_madw_get_mad_ptr
2076 ((*p_context).result.
2083 OSM_LOG_EXIT(&p_osmt->log);
2087 #ifdef VENDOR_RMPP_SUPPORT
2088 /**********************************************************************
2090 **********************************************************************/
2091 static ib_api_status_t
2092 osmtest_write_all_node_recs(IN osmtest_t * const p_osmt, IN FILE * fh)
2094 osmtest_req_context_t context;
2095 const ib_node_record_t *p_rec;
2101 OSM_LOG_ENTER(&p_osmt->log);
2103 memset(&context, 0, sizeof(context));
2106 * Do a blocking query for all NodeRecords in the subnet.
2108 status = osmtest_get_all_recs(p_osmt, IB_MAD_ATTR_NODE_RECORD,
2109 sizeof(*p_rec), &context);
2111 if (status != IB_SUCCESS) {
2112 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0022: "
2113 "osmtest_get_all_recs failed (%s)\n",
2114 ib_get_err_str(status));
2119 * Write the received records out to the file.
2121 num_recs = context.result.result_cnt;
2123 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Received %zu records\n", num_recs);
2125 result = fprintf(fh, "#\n" "# Node Records\n" "#\n");
2127 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0023: "
2133 for (i = 0; i < num_recs; i++) {
2135 osmv_get_query_node_rec(context.result.p_result_madw, i);
2136 osmtest_write_node_info(p_osmt, fh, p_rec);
2141 * Return the IB query MAD to the pool as necessary.
2143 if (context.result.p_result_madw != NULL) {
2144 osm_mad_pool_put(&p_osmt->mad_pool,
2145 context.result.p_result_madw);
2146 context.result.p_result_madw = NULL;
2149 OSM_LOG_EXIT(&p_osmt->log);
2153 /**********************************************************************
2155 **********************************************************************/
2156 static ib_api_status_t
2157 osmtest_write_all_port_recs(IN osmtest_t * const p_osmt, IN FILE * fh)
2159 osmtest_req_context_t context;
2160 const ib_portinfo_record_t *p_rec;
2166 OSM_LOG_ENTER(&p_osmt->log);
2168 memset(&context, 0, sizeof(context));
2171 * Do a blocking query for all NodeRecords in the subnet.
2173 status = osmtest_get_all_recs(p_osmt, IB_MAD_ATTR_PORTINFO_RECORD,
2174 sizeof(*p_rec), &context);
2176 if (status != IB_SUCCESS) {
2177 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0167: "
2178 "osmtest_get_all_recs failed (%s)\n",
2179 ib_get_err_str(status));
2184 * Write the received records out to the file.
2186 num_recs = context.result.result_cnt;
2188 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Received %zu records\n", num_recs);
2190 result = fprintf(fh, "#\n" "# PortInfo Records\n" "#\n");
2192 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0024: "
2198 for (i = 0; i < num_recs; i++) {
2200 osmv_get_query_portinfo_rec(context.result.p_result_madw,
2202 osmtest_write_port_info(p_osmt, fh, p_rec);
2207 * Return the IB query MAD to the pool as necessary.
2209 if (context.result.p_result_madw != NULL) {
2210 osm_mad_pool_put(&p_osmt->mad_pool,
2211 context.result.p_result_madw);
2212 context.result.p_result_madw = NULL;
2215 OSM_LOG_EXIT(&p_osmt->log);
2219 /**********************************************************************
2221 **********************************************************************/
2222 static ib_api_status_t
2223 osmtest_write_all_path_recs(IN osmtest_t * const p_osmt, IN FILE * fh)
2225 osmtest_req_context_t context;
2226 const ib_path_rec_t *p_rec;
2232 OSM_LOG_ENTER(&p_osmt->log);
2234 memset(&context, 0, sizeof(context));
2237 * Do a blocking query for all PathRecords in the subnet.
2239 status = osmtest_get_all_recs(p_osmt, IB_MAD_ATTR_PATH_RECORD,
2240 sizeof(*p_rec), &context);
2242 if (status != IB_SUCCESS) {
2243 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0025: "
2244 "osmtest_get_all_recs failed (%s)\n",
2245 ib_get_err_str(status));
2250 * Write the received records out to the file.
2252 num_recs = context.result.result_cnt;
2254 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Received %zu records\n", num_recs);
2256 result = fprintf(fh, "#\n" "# Path Records\n" "#\n");
2258 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0026: "
2264 for (i = 0; i < num_recs; i++) {
2266 osmv_get_query_path_rec(context.result.p_result_madw, i);
2267 osmtest_write_path_info(p_osmt, fh, p_rec);
2272 * Return the IB query MAD to the pool as necessary.
2274 if (context.result.p_result_madw != NULL) {
2275 osm_mad_pool_put(&p_osmt->mad_pool,
2276 context.result.p_result_madw);
2277 context.result.p_result_madw = NULL;
2280 OSM_LOG_EXIT(&p_osmt->log);
2286 * NON RMPP BASED QUERY FOR ALL NODES: BASED ON THE MAX LID GIVEN BY THE USER
2288 static ib_api_status_t
2289 osmtest_write_all_node_recs(IN osmtest_t * const p_osmt, IN FILE * fh)
2291 osmtest_req_context_t context;
2293 node_t *p_guid_node;
2294 const ib_node_record_t *p_rec;
2295 cl_status_t status = CL_SUCCESS;
2299 OSM_LOG_ENTER(&p_osmt->log);
2301 result = fprintf(fh, "#\n" "# Node Records\n" "#\n");
2303 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0027: "
2310 * Go over all LIDs in the range 1 to max_lid and do a
2311 * NodeRecord query by that lid.
2313 for (lid = 1; lid <= p_osmt->max_lid; lid++) {
2314 /* prepare the query context */
2315 memset(&context, 0, sizeof(context));
2318 osmtest_get_node_rec_by_lid(p_osmt, cl_ntoh16(lid),
2320 if (status != IB_SUCCESS) {
2321 if (status != IB_SA_MAD_STATUS_NO_RECORDS) {
2322 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "ERR 0028: "
2323 "failed to get node info for LID:0x%02X (%s)\n",
2324 cl_ntoh16(lid), ib_get_err_str(status));
2327 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "WRN 0121: "
2328 "failed to get node info for LID:0x%02X (%s)\n",
2329 cl_ntoh16(lid), ib_get_err_str(status));
2330 status = IB_SUCCESS;
2333 /* OK we got something */
2335 osmv_get_query_node_rec(context.result.
2337 osmtest_write_node_info(p_osmt, fh, p_rec);
2339 /* create a subnet object */
2340 p_node = node_new();
2341 CL_ASSERT(p_node != NULL);
2343 /* copy the info to the subnet node object */
2344 p_node->rec = *p_rec;
2346 cl_qmap_insert(&p_osmt->exp_subn.node_lid_tbl,
2347 p_node->rec.lid, &p_node->map_item);
2349 p_guid_node = node_new();
2350 CL_ASSERT(p_guid_node != NULL);
2352 *p_guid_node = *p_node;
2354 cl_qmap_insert(&p_osmt->exp_subn.node_guid_tbl,
2355 p_guid_node->rec.node_info.node_guid,
2356 &p_guid_node->map_item);
2360 if (context.result.p_result_madw != NULL) {
2361 osm_mad_pool_put(&p_osmt->mad_pool,
2362 context.result.p_result_madw);
2363 context.result.p_result_madw = NULL;
2368 if (context.result.p_result_madw != NULL) {
2369 osm_mad_pool_put(&p_osmt->mad_pool,
2370 context.result.p_result_madw);
2371 context.result.p_result_madw = NULL;
2374 OSM_LOG_EXIT(&p_osmt->log);
2379 * GET ALL PORT RECORDS IN THE FABRIC -
2380 * one by one by using the node info received
2382 static ib_api_status_t
2383 osmtest_write_all_port_recs(IN osmtest_t * const p_osmt, IN FILE * fh)
2385 osmtest_req_context_t context;
2386 const ib_node_record_t *p_node_rec;
2387 const ib_portinfo_record_t *p_rec;
2389 cl_status_t status = CL_SUCCESS;
2395 OSM_LOG_ENTER(&p_osmt->log);
2397 memset(&context, 0, sizeof(context));
2400 result = fprintf(fh, "#\n" "# PortInfo Records\n" "#\n");
2402 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0029: "
2408 /* use the pre-explored set of nodes */
2409 p_tbl = &p_osmt->exp_subn.node_lid_tbl;
2410 p_node = (node_t *) cl_qmap_head(p_tbl);
2413 * Go over all LIDs in the range 1 to max_lid and do a
2414 * NodeRecord query by that lid.
2416 while (p_node != (node_t *) cl_qmap_end(p_tbl)) {
2418 p_node_rec = &(p_node->rec);
2420 /* go through all ports of the node: */
2421 for (port_num = 0; port_num <= p_node_rec->node_info.num_ports;
2423 /* prepare the query context */
2424 memset(&context, 0, sizeof(context));
2426 status = osmtest_get_port_rec_by_num(p_osmt,
2430 if (status != IB_SUCCESS) {
2431 if (status != IB_SA_MAD_STATUS_NO_RECORDS) {
2432 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
2434 "Error encountered getting port info for LID:0x%04X Num:0x%02X (%s)\n",
2435 p_node_rec->lid, port_num,
2436 ib_get_err_str(status));
2439 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
2441 "failed to get port info for LID:0x%04X Num:0x%02X (%s)\n",
2442 p_node_rec->lid, port_num,
2443 ib_get_err_str(status));
2444 status = IB_SUCCESS;
2447 /* OK we got something */
2449 osmv_get_query_portinfo_rec(context.result.
2452 osmtest_write_port_info(p_osmt, fh, p_rec);
2454 /* create a subnet object */
2455 p_port = port_new();
2456 CL_ASSERT(p_port != NULL);
2458 /* copy the info to the subnet node object */
2459 p_port->rec = *p_rec;
2461 cl_qmap_insert(&p_osmt->exp_subn.port_key_tbl,
2462 port_gen_id(p_node_rec->lid,
2467 if (context.result.p_result_madw != NULL) {
2468 osm_mad_pool_put(&p_osmt->mad_pool,
2469 context.result.p_result_madw);
2470 context.result.p_result_madw = NULL;
2473 p_node = (node_t *) cl_qmap_next(&p_node->map_item);
2476 /* we must set the exist status to avoid abort of the over all algorith */
2480 * Return the IB query MAD to the pool as necessary.
2483 if (context.result.p_result_madw != NULL) {
2484 osm_mad_pool_put(&p_osmt->mad_pool,
2485 context.result.p_result_madw);
2486 context.result.p_result_madw = NULL;
2489 OSM_LOG_EXIT(&p_osmt->log);
2493 /**********************************************************************
2495 **********************************************************************/
2496 static ib_api_status_t
2497 osmtest_write_all_path_recs(IN osmtest_t * const p_osmt, IN FILE * fh)
2499 osmtest_req_context_t context;
2500 const ib_path_rec_t *p_rec;
2501 cl_status_t status = CL_SUCCESS;
2504 node_t *p_src_node, *p_dst_node;
2505 ib_api_status_t got_status = IB_SUCCESS;
2507 OSM_LOG_ENTER(&p_osmt->log);
2509 memset(&context, 0, sizeof(context));
2512 * Go over all nodes that exist in the subnet
2513 * for each pair that are not switch nodes get the path record
2516 context.p_osmt = p_osmt;
2518 p_tbl = &p_osmt->exp_subn.node_lid_tbl;
2520 p_src_node = (node_t *) cl_qmap_head(p_tbl);
2522 while (p_src_node != (node_t *) cl_qmap_end(p_tbl)) {
2523 /* HACK we use capability_mask to know diff a CA node from switch node */
2524 /* if(p_src_node->rec.node_info.capability_mask ) { */
2525 p_dst_node = (node_t *) cl_qmap_head(p_tbl);
2527 while (p_dst_node != (node_t *) cl_qmap_end(p_tbl)) {
2528 /* HACK we use capability_mask to know diff a CA node from switch node */
2529 /* if (p_dst_node->rec.node_info.capability_mask) { */
2532 status = osmtest_get_path_rec_by_lid_pair(p_osmt,
2539 if (status != IB_SUCCESS) {
2540 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 012D: "
2541 "failed to get path info from LID:0x%X To LID:0x%X (%s)\n",
2542 p_src_node->rec.lid,
2543 p_dst_node->rec.lid,
2544 ib_get_err_str(status));
2545 /* remember the first error status */
2548 IB_SUCCESS) ? status : got_status;
2550 /* we might have received several records */
2551 num_recs = context.result.result_cnt;
2552 for (i = 0; i < num_recs; i++) {
2554 osmv_get_query_path_rec(context.
2558 osmtest_write_path_info(p_osmt, fh,
2564 if (context.result.p_result_madw != NULL) {
2565 osm_mad_pool_put(&p_osmt->mad_pool,
2566 context.result.p_result_madw);
2567 context.result.p_result_madw = NULL;
2570 /* next one please */
2572 (node_t *) cl_qmap_next(&p_dst_node->map_item);
2576 p_src_node = (node_t *) cl_qmap_next(&p_src_node->map_item);
2579 if (got_status != IB_SUCCESS)
2580 status = got_status;
2583 * Return the IB query MAD to the pool as necessary.
2585 if (context.result.p_result_madw != NULL) {
2586 osm_mad_pool_put(&p_osmt->mad_pool,
2587 context.result.p_result_madw);
2588 context.result.p_result_madw = NULL;
2591 OSM_LOG_EXIT(&p_osmt->log);
2597 /**********************************************************************
2598 **********************************************************************/
2599 static ib_api_status_t
2600 osmtest_create_inventory_file(IN osmtest_t * const p_osmt)
2603 ib_api_status_t status = IB_SUCCESS;
2605 OSM_LOG_ENTER(&p_osmt->log);
2607 fh = fopen(p_osmt->opt.file_name, "w");
2609 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0079: "
2610 "Unable to open inventory file (%s)\n",
2611 p_osmt->opt.file_name);
2616 /* HACK: the order is important: nodes ports paths */
2617 status = osmtest_write_all_node_recs(p_osmt, fh);
2618 if (status != IB_SUCCESS)
2621 status = osmtest_write_all_port_recs(p_osmt, fh);
2622 if (status != IB_SUCCESS)
2625 if (!p_osmt->opt.ignore_path_records) {
2626 status = osmtest_write_all_path_recs(p_osmt, fh);
2627 if (status != IB_SUCCESS)
2631 status = osmtest_write_all_link_recs(p_osmt, fh);
2632 if (status != IB_SUCCESS)
2638 OSM_LOG_EXIT(&p_osmt->log);
2642 /**********************************************************************
2643 **********************************************************************/
2644 static ib_api_status_t osmtest_stress_large_rmpp_pr(IN osmtest_t * const p_osmt)
2646 ib_api_status_t status = IB_SUCCESS;
2647 uint64_t num_recs = 0;
2648 uint64_t num_queries = 0;
2649 uint32_t delta_recs;
2650 uint32_t delta_queries;
2651 uint32_t print_freq = 0;
2652 struct timeval start_tv, end_tv;
2653 long sec_diff, usec_diff;
2656 OSM_LOG_ENTER(&p_osmt->log);
2657 gettimeofday(&start_tv, NULL);
2658 printf("-I- Start time is : %09ld:%06ld [sec:usec]\n", start_tv.tv_sec,
2659 (long)start_tv.tv_usec);
2661 while (num_queries < STRESS_LARGE_PR_RMPP_THR) {
2665 status = osmtest_stress_path_recs_by_guid(p_osmt, &delta_recs,
2667 if (status != IB_SUCCESS)
2670 num_recs += delta_recs;
2671 num_queries += delta_queries;
2673 print_freq += delta_recs;
2674 if (print_freq > 10000) {
2675 gettimeofday(&end_tv, NULL);
2676 if (end_tv.tv_usec > start_tv.tv_usec) {
2677 sec_diff = end_tv.tv_sec - start_tv.tv_sec;
2678 usec_diff = end_tv.tv_usec - start_tv.tv_usec;
2680 sec_diff = end_tv.tv_sec - start_tv.tv_sec - 1;
2682 1000000 - (start_tv.tv_usec -
2685 printf("-I- End time is : %09ld:%06ld [sec:usec]\n",
2686 end_tv.tv_sec, (long)end_tv.tv_usec);
2687 printf("-I- Querying %" PRId64
2688 " Path Record queries CA to CA (rmpp)\n\ttook %04ld:%06ld [sec:usec]\n",
2689 num_queries, sec_diff, usec_diff);
2693 ratio = ((float)num_queries / (float)num_recs);
2694 printf("-I- Queries to Record Ratio is %" PRIu64
2695 " records, %" PRIu64 " queries : %.2f \n",
2696 num_recs, num_queries, ratio);
2702 gettimeofday(&end_tv, NULL);
2703 printf("-I- End time is : %09ld:%06ld [sec:usec]\n",
2704 end_tv.tv_sec, (long)end_tv.tv_usec);
2705 if (end_tv.tv_usec > start_tv.tv_usec) {
2706 sec_diff = end_tv.tv_sec - start_tv.tv_sec;
2707 usec_diff = end_tv.tv_usec - start_tv.tv_usec;
2709 sec_diff = end_tv.tv_sec - start_tv.tv_sec - 1;
2710 usec_diff = 1000000 - (start_tv.tv_usec - end_tv.tv_usec);
2713 printf("-I- Querying %" PRId64
2714 " Path Record queries (rmpp) took %04ld:%06ld [sec:usec]\n",
2715 num_queries, sec_diff, usec_diff);
2717 OSM_LOG_EXIT(&p_osmt->log);
2721 /**********************************************************************
2722 **********************************************************************/
2723 static ib_api_status_t osmtest_stress_large_rmpp(IN osmtest_t * const p_osmt)
2725 ib_api_status_t status = IB_SUCCESS;
2726 uint64_t num_recs = 0;
2727 uint64_t num_queries = 0;
2728 uint32_t delta_recs;
2729 uint32_t delta_queries;
2730 uint32_t print_freq = 0;
2731 struct timeval start_tv, end_tv;
2732 long sec_diff, usec_diff;
2734 OSM_LOG_ENTER(&p_osmt->log);
2735 gettimeofday(&start_tv, NULL);
2736 printf("-I- Start time is : %09ld:%06ld [sec:usec]\n", start_tv.tv_sec,
2737 (long)start_tv.tv_usec);
2739 while (num_queries < STRESS_LARGE_RMPP_THR) {
2743 status = osmtest_stress_node_recs_large(p_osmt, &delta_recs,
2745 if (status != IB_SUCCESS)
2748 status = osmtest_stress_path_recs_large(p_osmt, &delta_recs,
2750 if (status != IB_SUCCESS)
2753 status = osmtest_stress_port_recs_large(p_osmt, &delta_recs,
2755 if (status != IB_SUCCESS)
2758 num_recs += delta_recs;
2759 num_queries += delta_queries;
2761 print_freq += delta_recs;
2763 if (print_freq > 100000) {
2764 gettimeofday(&end_tv, NULL);
2765 if (end_tv.tv_usec > start_tv.tv_usec) {
2766 sec_diff = end_tv.tv_sec - start_tv.tv_sec;
2767 usec_diff = end_tv.tv_usec - start_tv.tv_usec;
2769 sec_diff = end_tv.tv_sec - start_tv.tv_sec - 1;
2771 1000000 - (start_tv.tv_usec -
2774 printf("-I- End time is : %09ld:%06ld [sec:usec]\n",
2775 end_tv.tv_sec, (long)end_tv.tv_usec);
2776 printf("-I- Querying %" PRId64
2777 " large mixed queries (rmpp) took %04ld:%06ld [sec:usec]\n",
2778 num_queries, sec_diff, usec_diff);
2779 printf("%" PRIu64 " records, %" PRIu64 " queries\n",
2780 num_recs, num_queries);
2786 gettimeofday(&end_tv, NULL);
2787 printf("-I- End time is : %09ld:%06ld [sec:usec]\n",
2788 end_tv.tv_sec, (long)end_tv.tv_usec);
2789 if (end_tv.tv_usec > start_tv.tv_usec) {
2790 sec_diff = end_tv.tv_sec - start_tv.tv_sec;
2791 usec_diff = end_tv.tv_usec - start_tv.tv_usec;
2793 sec_diff = end_tv.tv_sec - start_tv.tv_sec - 1;
2794 usec_diff = 1000000 - (start_tv.tv_usec - end_tv.tv_usec);
2797 printf("-I- Querying %" PRId64
2798 " large mixed queries (rmpp) took %04ld:%06ld [sec:usec]\n",
2799 num_queries, sec_diff, usec_diff);
2801 OSM_LOG_EXIT(&p_osmt->log);
2805 /**********************************************************************
2806 **********************************************************************/
2807 static ib_api_status_t osmtest_stress_small_rmpp(IN osmtest_t * const p_osmt)
2809 ib_api_status_t status = IB_SUCCESS;
2810 uint64_t num_recs = 0;
2811 uint64_t num_queries = 0;
2812 uint32_t delta_recs;
2813 uint32_t delta_queries;
2814 uint32_t print_freq = 0;
2815 int num_timeouts = 0;
2816 struct timeval start_tv, end_tv;
2817 long sec_diff, usec_diff;
2819 OSM_LOG_ENTER(&p_osmt->log);
2820 gettimeofday(&start_tv, NULL);
2821 printf("-I- Start time is : %09ld:%06ld [sec:usec]\n",
2822 start_tv.tv_sec, (long)start_tv.tv_usec);
2824 while ((num_queries < STRESS_SMALL_RMPP_THR) && (num_timeouts < 100)) {
2828 status = osmtest_stress_port_recs_small(p_osmt, &delta_recs,
2830 if (status != IB_SUCCESS)
2833 num_recs += delta_recs;
2834 num_queries += delta_queries;
2836 print_freq += delta_recs;
2837 if (print_freq > 5000) {
2838 gettimeofday(&end_tv, NULL);
2839 printf("%" PRIu64 " records, %" PRIu64 " queries\n",
2840 num_recs, num_queries);
2841 if (end_tv.tv_usec > start_tv.tv_usec) {
2842 sec_diff = end_tv.tv_sec - start_tv.tv_sec;
2843 usec_diff = end_tv.tv_usec - start_tv.tv_usec;
2845 sec_diff = end_tv.tv_sec - start_tv.tv_sec - 1;
2847 1000000 - (start_tv.tv_usec -
2850 printf("-I- End time is : %09ld:%06ld [sec:usec]\n",
2851 end_tv.tv_sec, (long)end_tv.tv_usec);
2852 printf("-I- Querying %" PRId64
2853 " port_info queries (single mad) took %04ld:%06ld [sec:usec]\n",
2854 num_queries, sec_diff, usec_diff);
2860 gettimeofday(&end_tv, NULL);
2861 printf("-I- End time is : %09ld:%06ld [sec:usec]\n",
2862 end_tv.tv_sec, (long)end_tv.tv_usec);
2863 if (end_tv.tv_usec > start_tv.tv_usec) {
2864 sec_diff = end_tv.tv_sec - start_tv.tv_sec;
2865 usec_diff = end_tv.tv_usec - start_tv.tv_usec;
2867 sec_diff = end_tv.tv_sec - start_tv.tv_sec - 1;
2868 usec_diff = 1000000 - (start_tv.tv_usec - end_tv.tv_usec);
2871 printf("-I- Querying %" PRId64
2872 " port_info queries (single mad) took %04ld:%06ld [sec:usec]\n",
2873 num_queries, sec_diff, usec_diff);
2874 if (num_timeouts > 50) {
2875 status = IB_TIMEOUT;
2878 OSM_LOG_EXIT(&p_osmt->log);
2882 /**********************************************************************
2883 **********************************************************************/
2885 osmtest_prepare_db_generic(IN osmtest_t * const p_osmt,
2886 IN cl_qmap_t * const p_tbl)
2888 generic_t *p_generic;
2890 OSM_LOG_ENTER(&p_osmt->log);
2892 p_generic = (generic_t *) cl_qmap_head(p_tbl);
2894 while (p_generic != (generic_t *) cl_qmap_end(p_tbl)) {
2895 p_generic->count = 0;
2896 p_generic = (generic_t *) cl_qmap_next(&p_generic->map_item);
2899 OSM_LOG_EXIT(&p_osmt->log);
2902 /**********************************************************************
2903 **********************************************************************/
2904 static void osmtest_prepare_db(IN osmtest_t * const p_osmt)
2906 OSM_LOG_ENTER(&p_osmt->log);
2908 osmtest_prepare_db_generic(p_osmt, &p_osmt->exp_subn.node_lid_tbl);
2909 osmtest_prepare_db_generic(p_osmt, &p_osmt->exp_subn.path_tbl);
2911 OSM_LOG_EXIT(&p_osmt->log);
2914 /**********************************************************************
2915 **********************************************************************/
2916 static ib_api_status_t osmtest_check_missing_nodes(IN osmtest_t * const p_osmt)
2918 const node_t *p_node;
2919 cl_status_t status = IB_SUCCESS;
2922 OSM_LOG_ENTER(&p_osmt->log);
2924 p_tbl = &p_osmt->exp_subn.node_lid_tbl;
2926 p_node = (node_t *) cl_qmap_head(p_tbl);
2928 while (p_node != (node_t *) cl_qmap_end(p_tbl)) {
2929 if (p_node->count == 0) {
2931 * This node was not reported by the SA
2933 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0080: "
2934 "Missing node 0x%016" PRIx64 "\n",
2935 cl_ntoh64(p_node->rec.node_info.node_guid));
2939 p_node = (node_t *) cl_qmap_next(&p_node->map_item);
2942 OSM_LOG_EXIT(&p_osmt->log);
2946 /**********************************************************************
2947 **********************************************************************/
2948 static ib_api_status_t osmtest_check_missing_ports(IN osmtest_t * const p_osmt)
2950 const port_t *p_port;
2951 cl_status_t status = IB_SUCCESS;
2954 OSM_LOG_ENTER(&p_osmt->log);
2956 p_tbl = &p_osmt->exp_subn.port_key_tbl;
2958 p_port = (port_t *) cl_qmap_head(p_tbl);
2960 while (p_port != (port_t *) cl_qmap_end(p_tbl)) {
2961 if (p_port->count == 0) {
2963 * This port was not reported by the SA
2965 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0081: "
2966 "Missing port LID:0x%X Num:0x%X\n",
2967 cl_ntoh16(p_port->rec.lid),
2968 p_port->rec.port_num);
2972 p_port = (port_t *) cl_qmap_next(&p_port->map_item);
2975 OSM_LOG_EXIT(&p_osmt->log);
2979 /**********************************************************************
2980 **********************************************************************/
2981 static ib_api_status_t osmtest_check_missing_paths(IN osmtest_t * const p_osmt)
2983 const path_t *p_path;
2984 cl_status_t status = IB_SUCCESS;
2987 OSM_LOG_ENTER(&p_osmt->log);
2989 p_tbl = &p_osmt->exp_subn.path_tbl;
2991 p_path = (path_t *) cl_qmap_head(p_tbl);
2993 while (p_path != (path_t *) cl_qmap_end(p_tbl)) {
2994 if (p_path->count == 0) {
2996 * This path was not reported by the SA
2998 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0051: "
2999 "SA did not return path SLID 0x%X to DLID 0x%X\n",
3000 cl_ntoh16(p_path->rec.slid),
3001 cl_ntoh16(p_path->rec.dlid));
3006 p_path = (path_t *) cl_qmap_next(&p_path->map_item);
3010 OSM_LOG_EXIT(&p_osmt->log);
3014 /**********************************************************************
3015 **********************************************************************/
3016 inline uint32_t osmtest_path_rec_key_get(IN const ib_path_rec_t * const p_rec)
3018 return (p_rec->dlid << 16 | p_rec->slid);
3021 /**********************************************************************
3022 **********************************************************************/
3024 osmtest_path_rec_kay_is_valid(IN osmtest_t * const p_osmt,
3025 IN const path_t * const p_path)
3027 if ((p_path->comp.dlid == 0) || (p_path->comp.slid == 0)) {
3028 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0168: "
3029 "SLID and DLID must be specified for defined paths\n");
3036 /**********************************************************************
3037 **********************************************************************/
3038 static ib_api_status_t
3039 osmtest_validate_path_data(IN osmtest_t * const p_osmt,
3040 IN path_t * const p_path,
3041 IN const ib_path_rec_t * const p_rec)
3043 cl_status_t status = IB_SUCCESS;
3046 OSM_LOG_ENTER(&p_osmt->log);
3048 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
3049 "Checking path SLID 0x%X to DLID 0x%X\n",
3050 cl_ntoh16(p_rec->slid), cl_ntoh16(p_rec->dlid));
3053 osmtest_get_local_port_lmc(p_osmt, p_osmt->local_port.lid, &lmc);
3054 if (status != IB_SUCCESS)
3057 /* HACK: Assume uniform LMC across endports in the subnet */
3058 /* This is the only LMC mode which OpenSM currently supports */
3059 /* In absence of this assumption, validation of this is much more complicated */
3062 * Has this record already been returned?
3064 if (p_path->count != 0) {
3065 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0056: "
3066 "Already received path SLID 0x%X to DLID 0x%X\n",
3067 cl_ntoh16(p_rec->slid), cl_ntoh16(p_rec->dlid));
3072 /* Also, this doesn't detect fewer than the correct number of paths being returned */
3073 if (p_path->count >= (uint32_t) (1 << (2 * lmc))) {
3074 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0052: "
3075 "Already received path SLID 0x%X to DLID 0x%X count %d LMC %d\n",
3076 cl_ntoh16(p_rec->slid), cl_ntoh16(p_rec->dlid),
3077 p_path->count, lmc);
3086 * Check the fields the user wants checked.
3088 if ((p_path->comp.dgid.unicast.interface_id &
3089 p_path->rec.dgid.unicast.interface_id) !=
3090 (p_path->comp.dgid.unicast.interface_id &
3091 p_rec->dgid.unicast.interface_id)) {
3092 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0169: "
3093 "DGID mismatch on path SLID 0x%X to DLID 0x%X\n"
3094 "\t\t\t\tExpected 0x%016" PRIx64 " 0x%016" PRIx64 "\n"
3095 "\t\t\t\tReceived 0x%016" PRIx64 " 0x%016" PRIx64 "\n",
3096 cl_ntoh16(p_path->rec.slid),
3097 cl_ntoh16(p_path->rec.dlid),
3098 cl_ntoh64(p_path->rec.dgid.unicast.prefix),
3099 cl_ntoh64(p_path->rec.dgid.unicast.interface_id),
3100 cl_ntoh64(p_rec->dgid.unicast.prefix),
3101 cl_ntoh64(p_rec->dgid.unicast.interface_id));
3107 * Check the fields the user wants checked.
3109 if ((p_path->comp.sgid.unicast.interface_id &
3110 p_path->rec.sgid.unicast.interface_id) !=
3111 (p_path->comp.sgid.unicast.interface_id &
3112 p_rec->sgid.unicast.interface_id)) {
3113 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0057: "
3114 "SGID mismatch on path SLID 0x%X to DLID 0x%X\n"
3115 "\t\t\t\tExpected 0x%016" PRIx64 " 0x%016" PRIx64 ",\n"
3116 "\t\t\t\tReceived 0x%016" PRIx64 " 0x%016" PRIx64 ".\n",
3117 cl_ntoh16(p_path->rec.slid),
3118 cl_ntoh16(p_path->rec.dlid),
3119 cl_ntoh64(p_path->rec.sgid.unicast.prefix),
3120 cl_ntoh64(p_path->rec.sgid.unicast.interface_id),
3121 cl_ntoh64(p_rec->sgid.unicast.prefix),
3122 cl_ntoh64(p_rec->sgid.unicast.interface_id));
3128 * Compare the fields the user wishes to validate.
3130 if ((p_path->comp.pkey & p_path->rec.pkey) !=
3131 (p_path->comp.pkey & p_rec->pkey)) {
3132 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0012: "
3133 "PKEY mismatch on path SLID 0x%X to DLID 0x%X\n"
3134 "\t\t\t\tExpected 0x%X, received 0x%X\n",
3135 cl_ntoh16(p_path->rec.slid),
3136 cl_ntoh16(p_path->rec.dlid),
3137 cl_ntoh16(p_path->rec.pkey), cl_ntoh16(p_rec->pkey));
3143 OSM_LOG_EXIT(&p_osmt->log);
3147 /**********************************************************************
3148 **********************************************************************/
3149 static ib_api_status_t
3150 osmtest_validate_node_data(IN osmtest_t * const p_osmt,
3151 IN node_t * const p_node,
3152 IN const ib_node_record_t * const p_rec)
3154 cl_status_t status = IB_SUCCESS;
3156 OSM_LOG_ENTER(&p_osmt->log);
3158 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
3159 "Checking node 0x%016" PRIx64 ", LID 0x%X\n",
3160 cl_ntoh64(p_rec->node_info.node_guid), cl_ntoh16(p_rec->lid));
3163 * Has this record already been returned?
3165 if (p_node->count != 0) {
3166 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0013: "
3167 "Already received node 0x%016" PRIx64 "\n",
3168 cl_ntoh64(p_node->rec.node_info.node_guid));
3176 * Compare the fields the user wishes to validate.
3178 if ((p_node->comp.lid & p_node->rec.lid) !=
3179 (p_node->comp.lid & p_rec->lid)) {
3180 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0014: "
3181 "Field mismatch node 0x%016" PRIx64 ", LID 0x%X\n"
3182 "\t\t\t\tExpected LID 0x%X, received 0x%X\n",
3183 cl_ntoh64(p_rec->node_info.node_guid),
3184 cl_ntoh16(p_rec->lid), p_node->rec.lid, p_rec->lid);
3189 if ((p_node->comp.node_info.base_version &
3190 p_node->rec.node_info.base_version) !=
3191 (p_node->comp.node_info.base_version &
3192 p_rec->node_info.base_version)) {
3193 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0015: "
3194 "Field mismatch node 0x%016" PRIx64 ", LID 0x%X\n"
3195 "\t\t\t\tExpected base_version 0x%X, received 0x%X\n",
3196 cl_ntoh64(p_rec->node_info.node_guid),
3197 cl_ntoh16(p_rec->lid),
3198 p_node->rec.node_info.base_version,
3199 p_rec->node_info.base_version);
3204 if ((p_node->comp.node_info.class_version &
3205 p_node->rec.node_info.class_version) !=
3206 (p_node->comp.node_info.class_version &
3207 p_rec->node_info.class_version)) {
3208 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0016: "
3209 "Field mismatch node 0x%016" PRIx64 ", LID 0x%X\n"
3210 "\t\t\t\tExpected class_version 0x%X, received 0x%X\n",
3211 cl_ntoh64(p_rec->node_info.node_guid),
3212 cl_ntoh16(p_rec->lid),
3213 p_node->rec.node_info.class_version,
3214 p_rec->node_info.class_version);
3219 if ((p_node->comp.node_info.node_type &
3220 p_node->rec.node_info.node_type) !=
3221 (p_node->comp.node_info.node_type & p_rec->node_info.node_type)) {
3222 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0017: "
3223 "Field mismatch node 0x%016" PRIx64 ", LID 0x%X\n"
3224 "\t\t\t\tExpected node_type 0x%X, received 0x%X\n",
3225 cl_ntoh64(p_rec->node_info.node_guid),
3226 cl_ntoh16(p_rec->lid),
3227 p_node->rec.node_info.node_type,
3228 p_rec->node_info.node_type);
3233 if ((p_node->comp.node_info.sys_guid &
3234 p_node->rec.node_info.sys_guid) !=
3235 (p_node->comp.node_info.sys_guid & p_rec->node_info.sys_guid)) {
3236 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0018: "
3237 "Field mismatch node 0x%016" PRIx64 ", LID 0x%X\n"
3238 "\t\t\t\tExpected sys_guid 0x%016" PRIx64
3239 ", received 0x%016" PRIx64 "\n",
3240 cl_ntoh64(p_rec->node_info.node_guid),
3241 cl_ntoh16(p_rec->lid),
3242 cl_ntoh64(p_node->rec.node_info.sys_guid),
3243 cl_ntoh64(p_rec->node_info.sys_guid));
3248 if ((p_node->comp.node_info.node_guid &
3249 p_node->rec.node_info.node_guid) !=
3250 (p_node->comp.node_info.node_guid & p_rec->node_info.node_guid)) {
3251 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0019: "
3252 "Field mismatch node 0x%016" PRIx64 ", LID 0x%X\n"
3253 "\t\t\t\tExpected node_guid 0x%016" PRIx64
3254 ", received 0x%016" PRIx64 "\n",
3255 cl_ntoh64(p_rec->node_info.node_guid),
3256 cl_ntoh16(p_rec->lid),
3257 cl_ntoh64(p_node->rec.node_info.node_guid),
3258 cl_ntoh64(p_rec->node_info.node_guid));
3263 if ((p_node->comp.node_info.port_guid &
3264 p_node->rec.node_info.port_guid) !=
3265 (p_node->comp.node_info.port_guid & p_rec->node_info.port_guid)) {
3266 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0031: "
3267 "Field mismatch node 0x%016" PRIx64 ", LID 0x%X\n"
3268 "\t\t\t\tExpected port_guid 0x%016" PRIx64
3269 ", received 0x%016" PRIx64 "\n",
3270 cl_ntoh64(p_rec->node_info.node_guid),
3271 cl_ntoh16(p_rec->lid),
3272 cl_ntoh64(p_node->rec.node_info.port_guid),
3273 cl_ntoh64(p_rec->node_info.port_guid));
3278 if ((p_node->comp.node_info.partition_cap &
3279 p_node->rec.node_info.partition_cap) !=
3280 (p_node->comp.node_info.partition_cap &
3281 p_rec->node_info.partition_cap)) {
3282 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0032: "
3283 "Field mismatch node 0x%016" PRIx64 ", LID 0x%X\n"
3284 "\t\t\t\tExpected partition_cap 0x%X, received 0x%X\n",
3285 cl_ntoh64(p_rec->node_info.node_guid),
3286 cl_ntoh16(p_rec->lid),
3287 cl_ntoh16(p_node->rec.node_info.partition_cap),
3288 cl_ntoh16(p_rec->node_info.partition_cap));
3293 if ((p_node->comp.node_info.device_id &
3294 p_node->rec.node_info.device_id) !=
3295 (p_node->comp.node_info.device_id & p_rec->node_info.device_id)) {
3296 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0033: "
3297 "Field mismatch node 0x%016" PRIx64 ", LID 0x%X\n"
3298 "\t\t\t\tExpected device_id 0x%X, received 0x%X\n",
3299 cl_ntoh64(p_rec->node_info.node_guid),
3300 cl_ntoh16(p_rec->lid),
3301 cl_ntoh16(p_node->rec.node_info.device_id),
3302 cl_ntoh16(p_rec->node_info.device_id));
3307 if ((p_node->comp.node_info.revision &
3308 p_node->rec.node_info.revision) !=
3309 (p_node->comp.node_info.revision & p_rec->node_info.revision)) {
3310 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0034: "
3311 "Field mismatch node 0x%016" PRIx64 ", LID 0x%X\n"
3312 "\t\t\t\tExpected revision 0x%X, received 0x%X\n",
3313 cl_ntoh64(p_rec->node_info.node_guid),
3314 cl_ntoh16(p_rec->lid),
3315 cl_ntoh32(p_node->rec.node_info.revision),
3316 cl_ntoh32(p_rec->node_info.revision));
3322 OSM_LOG_EXIT(&p_osmt->log);
3326 /**********************************************************************
3327 **********************************************************************/
3328 static ib_api_status_t
3329 osmtest_validate_node_rec(IN osmtest_t * const p_osmt,
3330 IN const ib_node_record_t * const p_rec)
3332 cl_status_t status = IB_SUCCESS;
3334 const cl_qmap_t *p_tbl;
3336 OSM_LOG_ENTER(&p_osmt->log);
3339 * Find proper node record in the database.
3341 p_tbl = &p_osmt->exp_subn.node_lid_tbl;
3342 p_node = (node_t *) cl_qmap_get(p_tbl, p_rec->lid);
3343 if (p_node == (node_t *) cl_qmap_end(p_tbl)) {
3344 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0035: "
3345 "Unexpected node 0x%016" PRIx64 ", LID 0x%X\n",
3346 cl_ntoh64(p_rec->node_info.node_guid),
3347 cl_ntoh16(p_rec->lid));
3352 status = osmtest_validate_node_data(p_osmt, p_node, p_rec);
3355 OSM_LOG_EXIT(&p_osmt->log);
3359 /**********************************************************************
3360 **********************************************************************/
3361 static ib_api_status_t
3362 osmtest_validate_port_data(IN osmtest_t * const p_osmt,
3363 IN port_t * const p_port,
3364 IN const ib_portinfo_record_t * const p_rec)
3366 cl_status_t status = IB_SUCCESS;
3368 OSM_LOG_ENTER(&p_osmt->log);
3370 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
3371 "Checking port LID 0x%X, Num 0x%X\n",
3372 cl_ntoh16(p_rec->lid), p_rec->port_num);
3375 * Has this record already been returned?
3377 if (p_port->count != 0) {
3378 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0036: "
3379 "Already received port LID 0x%X, Num 0x%X\n",
3380 cl_ntoh16(p_rec->lid), p_rec->port_num);
3388 * Compare the fields the user wishes to validate.
3390 if ((p_port->comp.lid & p_port->rec.lid) !=
3391 (p_port->comp.lid & p_rec->lid)) {
3392 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0037: "
3393 "Field mismatch port LID 0x%X Num:0x%X\n"
3394 "\t\t\t\tExpected LID 0x%X, received 0x%X\n",
3395 cl_ntoh16(p_rec->lid), p_rec->port_num,
3396 p_port->rec.lid, p_rec->lid);
3401 if ((p_port->comp.port_num & p_port->rec.port_num) !=
3402 (p_port->comp.port_num & p_rec->port_num)) {
3403 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0038: "
3404 "Field mismatch port LID 0x%X Num:0x%X\n"
3405 "\t\t\t\tExpected port_num 0x%X, received 0x%X\n",
3406 cl_ntoh16(p_rec->lid), p_rec->port_num,
3407 p_port->rec.port_num, p_rec->port_num);
3412 if ((p_port->comp.port_info.m_key & p_port->rec.port_info.m_key) !=
3413 (p_port->comp.port_info.m_key & p_rec->port_info.m_key)) {
3414 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0039: "
3415 "Field mismatch port LID 0x%X Num:0x%X\n"
3416 "\t\t\t\tExpected m_key 0x%016" PRIx64
3417 ", received 0x%016" PRIx64 "\n", cl_ntoh16(p_rec->lid),
3418 p_rec->port_num, p_port->rec.port_info.m_key,
3419 p_rec->port_info.m_key);
3424 if ((p_port->comp.port_info.subnet_prefix & p_port->rec.port_info.
3426 (p_port->comp.port_info.subnet_prefix & p_rec->port_info.
3428 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0040: "
3429 "Field mismatch port LID 0x%X Num:0x%X\n"
3430 "\t\t\t\tExpected subnet_prefix 0x%016" PRIx64
3431 ", received 0x%016" PRIx64 "\n", cl_ntoh16(p_rec->lid),
3432 p_rec->port_num, p_port->rec.port_info.subnet_prefix,
3433 p_rec->port_info.subnet_prefix);
3438 if ((p_port->comp.port_info.base_lid & p_port->rec.port_info.
3440 (p_port->comp.port_info.base_lid & p_rec->port_info.base_lid)) {
3441 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0041: "
3442 "Field mismatch port LID 0x%X Num:0x%X\n"
3443 "\t\t\t\tExpected base_lid 0x%X, received 0x%X\n",
3444 cl_ntoh16(p_rec->lid), p_rec->port_num,
3445 p_port->rec.port_info.base_lid,
3446 p_rec->port_info.base_lid);
3451 if ((p_port->comp.port_info.master_sm_base_lid & p_port->rec.port_info.
3452 master_sm_base_lid) !=
3453 (p_port->comp.port_info.master_sm_base_lid & p_rec->port_info.
3454 master_sm_base_lid)) {
3455 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0042: "
3456 "Field mismatch port LID 0x%X Num:0x%X\n"
3457 "\t\t\t\tExpected master_sm_base_lid 0x%X, received 0x%X\n",
3458 cl_ntoh16(p_rec->lid), p_rec->port_num,
3459 p_port->rec.port_info.master_sm_base_lid,
3460 p_rec->port_info.master_sm_base_lid);
3465 if ((p_port->comp.port_info.capability_mask & p_port->rec.port_info.
3467 (p_port->comp.port_info.capability_mask & p_rec->port_info.
3469 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0043: "
3470 "Field mismatch port LID 0x%X Num:0x%X\n"
3471 "\t\t\t\tExpected capability_mask 0x%X, received 0x%X\n",
3472 cl_ntoh16(p_rec->lid), p_rec->port_num,
3473 cl_ntoh32(p_port->rec.port_info.capability_mask),
3474 cl_ntoh32(p_rec->port_info.capability_mask));
3479 if ((p_port->comp.port_info.diag_code & p_port->rec.port_info.
3481 (p_port->comp.port_info.diag_code & p_rec->port_info.diag_code)) {
3482 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0044: "
3483 "Field mismatch port LID 0x%X Num:0x%X\n"
3484 "\t\t\t\tExpected diag_code 0x%X, received 0x%X\n",
3485 cl_ntoh16(p_rec->lid), p_rec->port_num,
3486 p_port->rec.port_info.diag_code,
3487 p_rec->port_info.diag_code);
3492 if ((p_port->comp.port_info.m_key_lease_period & p_port->rec.port_info.
3493 m_key_lease_period) !=
3494 (p_port->comp.port_info.m_key_lease_period & p_rec->port_info.
3495 m_key_lease_period)) {
3496 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0045: "
3497 "Field mismatch port LID 0x%X Num:0x%X\n"
3498 "\t\t\t\tExpected m_key_lease_period 0x%X, received 0x%X\n",
3499 cl_ntoh16(p_rec->lid), p_rec->port_num,
3500 p_port->rec.port_info.m_key_lease_period,
3501 p_rec->port_info.m_key_lease_period);
3506 if ((p_port->comp.port_info.local_port_num & p_port->rec.port_info.
3508 (p_port->comp.port_info.local_port_num & p_rec->port_info.
3510 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0046: "
3511 "Field mismatch port LID 0x%X Num:0x%X\n"
3512 "\t\t\t\tExpected local_port_num 0x%X, received 0x%X\n",
3513 cl_ntoh16(p_rec->lid), p_rec->port_num,
3514 p_port->rec.port_info.local_port_num,
3515 p_rec->port_info.local_port_num);
3520 if ((p_port->comp.port_info.link_width_enabled & p_port->rec.port_info.
3521 link_width_enabled) !=
3522 (p_port->comp.port_info.link_width_enabled & p_rec->port_info.
3523 link_width_enabled)) {
3524 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0047: "
3525 "Field mismatch port LID 0x%X Num:0x%X\n"
3526 "\t\t\t\tExpected link_width_enabled 0x%X, received 0x%X\n",
3527 cl_ntoh16(p_rec->lid), p_rec->port_num,
3528 p_port->rec.port_info.link_width_enabled,
3529 p_rec->port_info.link_width_enabled);
3534 if ((p_port->comp.port_info.link_width_supported & p_port->rec.
3535 port_info.link_width_supported) !=
3536 (p_port->comp.port_info.link_width_supported & p_rec->port_info.
3537 link_width_supported)) {
3538 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0048: "
3539 "Field mismatch port LID 0x%X Num:0x%X\n"
3540 "\t\t\t\tExpected link_width_supported 0x%X, received 0x%X\n",
3541 cl_ntoh16(p_rec->lid), p_rec->port_num,
3542 p_port->rec.port_info.link_width_supported,
3543 p_rec->port_info.link_width_supported);
3548 if ((p_port->comp.port_info.link_width_active & p_port->rec.port_info.
3549 link_width_active) !=
3550 (p_port->comp.port_info.link_width_active & p_rec->port_info.
3551 link_width_active)) {
3552 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0049: "
3553 "Field mismatch port LID 0x%X Num:0x%X\n"
3554 "\t\t\t\tExpected link_width_active 0x%X, received 0x%X\n",
3555 cl_ntoh16(p_rec->lid), p_rec->port_num,
3556 p_port->rec.port_info.link_width_active,
3557 p_rec->port_info.link_width_active);
3562 if ((p_port->comp.port_info.link_speed & p_port->rec.port_info.
3564 (p_port->comp.port_info.link_speed & p_rec->port_info.link_speed)) {
3565 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0054: "
3566 "Field mismatch port LID 0x%X Num:0x%X\n"
3567 "\t\t\t\tExpected link_speed 0x%X, received 0x%X\n",
3568 cl_ntoh16(p_rec->lid), p_rec->port_num,
3569 p_port->rec.port_info.link_speed,
3570 p_rec->port_info.link_speed);
3575 if ((p_port->comp.port_info.state_info1 & p_port->rec.port_info.
3577 (p_port->comp.port_info.state_info1 & p_rec->port_info.
3579 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0055: "
3580 "Field mismatch port LID 0x%X Num:0x%X\n"
3581 "\t\t\t\tExpected state_info1 0x%X, received 0x%X\n",
3582 cl_ntoh16(p_rec->lid), p_rec->port_num,
3583 p_port->rec.port_info.state_info1,
3584 p_rec->port_info.state_info1);
3589 if ((p_port->comp.port_info.state_info2 & p_port->rec.port_info.
3591 (p_port->comp.port_info.state_info2 & p_rec->port_info.
3593 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0058: "
3594 "Field mismatch port LID 0x%X Num:0x%X\n"
3595 "\t\t\t\tExpected state_info2 0x%X, received 0x%X\n",
3596 cl_ntoh16(p_rec->lid), p_rec->port_num,
3597 p_port->rec.port_info.state_info2,
3598 p_rec->port_info.state_info2);
3603 if ((p_port->comp.port_info.mkey_lmc & p_port->rec.port_info.
3605 (p_port->comp.port_info.mkey_lmc & p_rec->port_info.mkey_lmc)) {
3606 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0059: "
3607 "Field mismatch port LID 0x%X Num:0x%X\n"
3608 "\t\t\t\tExpected mkey_lmc 0x%X, received 0x%X\n",
3609 cl_ntoh16(p_rec->lid), p_rec->port_num,
3610 p_port->rec.port_info.mkey_lmc,
3611 p_rec->port_info.mkey_lmc);
3616 if ((p_port->comp.port_info.link_speed & p_port->rec.port_info.
3618 (p_port->comp.port_info.link_speed & p_rec->port_info.link_speed)) {
3619 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0060: "
3620 "Field mismatch port LID 0x%X Num:0x%X\n"
3621 "\t\t\t\tExpected link_speed 0x%X, received 0x%X\n",
3622 cl_ntoh16(p_rec->lid), p_rec->port_num,
3623 p_port->rec.port_info.link_speed,
3624 p_rec->port_info.link_speed);
3629 if ((p_port->comp.port_info.mtu_smsl & p_port->rec.port_info.
3631 (p_port->comp.port_info.mtu_smsl & p_rec->port_info.mtu_smsl)) {
3632 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0061: "
3633 "Field mismatch port LID 0x%X Num:0x%X\n"
3634 "\t\t\t\tExpected mtu_smsl 0x%X, received 0x%X\n",
3635 cl_ntoh16(p_rec->lid), p_rec->port_num,
3636 p_port->rec.port_info.mtu_smsl,
3637 p_rec->port_info.mtu_smsl);
3642 if ((p_port->comp.port_info.vl_cap & p_port->rec.port_info.vl_cap) !=
3643 (p_port->comp.port_info.vl_cap & p_rec->port_info.vl_cap)) {
3644 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0062: "
3645 "Field mismatch port LID 0x%X Num:0x%X\n"
3646 "\t\t\t\tExpected vl_cap 0x%X, received 0x%X\n",
3647 cl_ntoh16(p_rec->lid), p_rec->port_num,
3648 p_port->rec.port_info.vl_cap, p_rec->port_info.vl_cap);
3653 if ((p_port->comp.port_info.vl_high_limit & p_port->rec.port_info.
3655 (p_port->comp.port_info.vl_high_limit & p_rec->port_info.
3657 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0082: "
3658 "Field mismatch port LID 0x%X Num:0x%X\n"
3659 "\t\t\t\tExpected vl_high_limit 0x%X, received 0x%X\n",
3660 cl_ntoh16(p_rec->lid), p_rec->port_num,
3661 p_port->rec.port_info.vl_high_limit,
3662 p_rec->port_info.vl_high_limit);
3667 if ((p_port->comp.port_info.vl_arb_high_cap & p_port->rec.port_info.
3669 (p_port->comp.port_info.vl_arb_high_cap & p_rec->port_info.
3671 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0083: "
3672 "Field mismatch port LID 0x%X Num:0x%X\n"
3673 "\t\t\t\tExpected vl_arb_high_cap 0x%X, received 0x%X\n",
3674 cl_ntoh16(p_rec->lid), p_rec->port_num,
3675 p_port->rec.port_info.vl_arb_high_cap,
3676 p_rec->port_info.vl_arb_high_cap);
3681 if ((p_port->comp.port_info.vl_arb_low_cap & p_port->rec.port_info.
3683 (p_port->comp.port_info.vl_arb_low_cap & p_rec->port_info.
3685 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0084: "
3686 "Field mismatch port LID 0x%X Num:0x%X\n"
3687 "\t\t\t\tExpected vl_arb_low_cap 0x%X, received 0x%X\n",
3688 cl_ntoh16(p_rec->lid), p_rec->port_num,
3689 p_port->rec.port_info.vl_arb_low_cap,
3690 p_rec->port_info.vl_arb_low_cap);
3695 if ((p_port->comp.port_info.mtu_cap & p_port->rec.port_info.mtu_cap) !=
3696 (p_port->comp.port_info.mtu_cap & p_rec->port_info.mtu_cap)) {
3697 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0085: "
3698 "Field mismatch port LID 0x%X Num:0x%X\n"
3699 "\t\t\t\tExpected mtu_cap 0x%X, received 0x%X\n",
3700 cl_ntoh16(p_rec->lid), p_rec->port_num,
3701 p_port->rec.port_info.mtu_cap,
3702 p_rec->port_info.mtu_cap);
3707 /* this is a dynamic attribute */
3708 if ((p_port->comp.port_info.vl_stall_life & p_port->rec.port_info.
3710 (p_port->comp.port_info.vl_stall_life & p_rec->port_info.
3712 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 012F: "
3713 "Field mismatch port LID 0x%X Num:0x%X\n"
3714 "\t\t\t\tExpected vl_stall_life 0x%X, received 0x%X\n",
3715 cl_ntoh16(p_rec->lid), p_rec->port_num,
3716 p_port->rec.port_info.vl_stall_life,
3717 p_rec->port_info.vl_stall_life);
3723 if ((p_port->comp.port_info.vl_enforce & p_port->rec.port_info.
3725 (p_port->comp.port_info.vl_enforce & p_rec->port_info.vl_enforce)) {
3726 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0086: "
3727 "Field mismatch port LID 0x%X Num:0x%X\n"
3728 "\t\t\t\tExpected vl_enforce 0x%X, received 0x%X\n",
3729 cl_ntoh16(p_rec->lid), p_rec->port_num,
3730 p_port->rec.port_info.vl_enforce,
3731 p_rec->port_info.vl_enforce);
3736 if ((p_port->comp.port_info.m_key_violations & p_port->rec.port_info.
3737 m_key_violations) !=
3738 (p_port->comp.port_info.m_key_violations & p_rec->port_info.
3739 m_key_violations)) {
3740 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0087: "
3741 "Field mismatch port LID 0x%X Num:0x%X\n"
3742 "\t\t\t\tExpected m_key_violations 0x%X, received 0x%X\n",
3743 cl_ntoh16(p_rec->lid), p_rec->port_num,
3744 cl_ntoh16(p_port->rec.port_info.m_key_violations),
3745 cl_ntoh16(p_rec->port_info.m_key_violations));
3750 if ((p_port->comp.port_info.p_key_violations & p_port->rec.port_info.
3751 p_key_violations) !=
3752 (p_port->comp.port_info.p_key_violations & p_rec->port_info.
3753 p_key_violations)) {
3754 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0088: "
3755 "Field mismatch port LID 0x%X Num:0x%X\n"
3756 "\t\t\t\tExpected p_key_violations 0x%X, received 0x%X\n",
3757 cl_ntoh16(p_rec->lid), p_rec->port_num,
3758 cl_ntoh16(p_port->rec.port_info.p_key_violations),
3759 cl_ntoh16(p_rec->port_info.p_key_violations));
3764 if ((p_port->comp.port_info.q_key_violations & p_port->rec.port_info.
3765 q_key_violations) !=
3766 (p_port->comp.port_info.q_key_violations & p_rec->port_info.
3767 q_key_violations)) {
3768 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0089: "
3769 "Field mismatch port LID 0x%X Num:0x%X\n"
3770 "\t\t\t\tExpected q_key_violations 0x%X, received 0x%X\n",
3771 cl_ntoh16(p_rec->lid), p_rec->port_num,
3772 cl_ntoh16(p_port->rec.port_info.q_key_violations),
3773 cl_ntoh16(p_rec->port_info.q_key_violations));
3778 if ((p_port->comp.port_info.guid_cap & p_port->rec.port_info.
3780 (p_port->comp.port_info.guid_cap & p_rec->port_info.guid_cap)) {
3781 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0090: "
3782 "Field mismatch port LID 0x%X Num:0x%X\n"
3783 "\t\t\t\tExpected guid_cap 0x%X, received 0x%X\n",
3784 cl_ntoh16(p_rec->lid), p_rec->port_num,
3785 p_port->rec.port_info.guid_cap,
3786 p_rec->port_info.guid_cap);
3791 if ((p_port->comp.port_info.subnet_timeout & p_port->rec.port_info.
3793 (p_port->comp.port_info.subnet_timeout & p_rec->port_info.
3795 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0091: "
3796 "Field mismatch port LID 0x%X Num:0x%X\n"
3797 "\t\t\t\tExpected subnet_timeout 0x%X, received 0x%X\n",
3798 cl_ntoh16(p_rec->lid), p_rec->port_num,
3799 ib_port_info_get_timeout(&p_port->rec.port_info),
3800 ib_port_info_get_timeout(&p_rec->port_info));
3805 if ((p_port->comp.port_info.resp_time_value & p_port->rec.port_info.
3807 (p_port->comp.port_info.resp_time_value & p_rec->port_info.
3809 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0092: "
3810 "Field mismatch port LID 0x%X Num:0x%X\n"
3811 "\t\t\t\tExpected resp_time_value 0x%X, received 0x%X\n",
3812 cl_ntoh16(p_rec->lid), p_rec->port_num,
3813 p_port->rec.port_info.resp_time_value,
3814 p_rec->port_info.resp_time_value);
3819 if ((p_port->comp.port_info.error_threshold & p_port->rec.port_info.
3821 (p_port->comp.port_info.error_threshold & p_rec->port_info.
3823 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0093: "
3824 "Field mismatch port LID 0x%X Num:0x%X\n"
3825 "\t\t\t\tExpected error_threshold 0x%X, received 0x%X\n",
3826 cl_ntoh16(p_rec->lid), p_rec->port_num,
3827 p_port->rec.port_info.error_threshold,
3828 p_rec->port_info.error_threshold);
3834 OSM_LOG_EXIT(&p_osmt->log);
3838 /**********************************************************************
3839 **********************************************************************/
3840 static ib_api_status_t
3841 osmtest_validate_port_rec(IN osmtest_t * const p_osmt,
3842 IN const ib_portinfo_record_t * const p_rec)
3844 cl_status_t status = IB_SUCCESS;
3846 const cl_qmap_t *p_tbl;
3848 OSM_LOG_ENTER(&p_osmt->log);
3851 * Find proper port record in the database.
3852 * (we use by guid - since lid is not unique)
3854 p_tbl = &p_osmt->exp_subn.port_key_tbl;
3856 (port_t *) cl_qmap_get(p_tbl,
3857 port_gen_id(p_rec->lid, p_rec->port_num));
3858 if (p_port == (port_t *) cl_qmap_end(p_tbl)) {
3859 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0094: "
3860 "Unexpected port LID 0x%X, Num:0x%X\n",
3861 cl_ntoh16(p_rec->lid), p_rec->port_num);
3866 status = osmtest_validate_port_data(p_osmt, p_port, p_rec);
3869 OSM_LOG_EXIT(&p_osmt->log);
3873 /**********************************************************************
3874 **********************************************************************/
3875 static ib_api_status_t
3876 osmtest_validate_path_rec(IN osmtest_t * const p_osmt,
3877 IN const ib_path_rec_t * const p_rec)
3879 cl_status_t status = IB_SUCCESS;
3881 const cl_qmap_t *p_tbl;
3883 OSM_LOG_ENTER(&p_osmt->log);
3886 * Find proper path record in the database.
3888 p_tbl = &p_osmt->exp_subn.path_tbl;
3889 p_path = (path_t *) cl_qmap_get(p_tbl, osmtest_path_rec_key_get(p_rec));
3890 if (p_path == (path_t *) cl_qmap_end(p_tbl)) {
3891 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0095: "
3892 "Unexpected path SLID 0x%X to DLID 0x%X\n",
3893 cl_ntoh16(p_rec->slid), cl_ntoh16(p_rec->dlid));
3898 status = osmtest_validate_path_data(p_osmt, p_path, p_rec);
3901 OSM_LOG_EXIT(&p_osmt->log);
3905 #ifdef VENDOR_RMPP_SUPPORT
3906 ib_net64_t portguid = 0;
3908 /**********************************************************************
3909 **********************************************************************/
3910 static ib_api_status_t
3911 osmtest_validate_all_node_recs(IN osmtest_t * const p_osmt)
3913 osmtest_req_context_t context;
3914 const ib_node_record_t *p_rec;
3919 OSM_LOG_ENTER(&p_osmt->log);
3921 memset(&context, 0, sizeof(context));
3924 * Do a blocking query for all NodeRecords in the subnet.
3926 status = osmtest_get_all_recs(p_osmt, IB_MAD_ATTR_NODE_RECORD,
3927 sizeof(*p_rec), &context);
3929 if (status != IB_SUCCESS) {
3930 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0096: "
3931 "osmtest_get_all_recs failed (%s)\n",
3932 ib_get_err_str(status));
3936 num_recs = context.result.result_cnt;
3938 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Received %zu records\n",
3942 * Compare the received records to the database.
3944 osmtest_prepare_db(p_osmt);
3946 for (i = 0; i < num_recs; i++) {
3948 osmv_get_query_node_rec(context.result.p_result_madw, i);
3950 status = osmtest_validate_node_rec(p_osmt, p_rec);
3951 if (status != IB_SUCCESS) {
3952 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0097: "
3953 "osmtest_valid_node_rec failed (%s)\n",
3954 ib_get_err_str(status));
3958 portguid = p_rec->node_info.port_guid;
3961 status = osmtest_check_missing_nodes(p_osmt);
3962 if (status != IB_SUCCESS) {
3963 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0098: "
3964 "osmtest_check_missing_nodes failed (%s)\n",
3965 ib_get_err_str(status));
3971 * Return the IB query MAD to the pool as necessary.
3973 if (context.result.p_result_madw != NULL) {
3974 osm_mad_pool_put(&p_osmt->mad_pool,
3975 context.result.p_result_madw);
3976 context.result.p_result_madw = NULL;
3979 OSM_LOG_EXIT(&p_osmt->log);
3983 /**********************************************************************
3984 **********************************************************************/
3985 static ib_api_status_t
3986 osmtest_validate_all_guidinfo_recs(IN osmtest_t * const p_osmt)
3988 osmtest_req_context_t context;
3989 const ib_guidinfo_record_t *p_rec;
3993 OSM_LOG_ENTER(&p_osmt->log);
3995 memset(&context, 0, sizeof(context));
3998 * Do a blocking query for all GuidInfoRecords in the subnet.
4000 status = osmtest_get_all_recs(p_osmt, IB_MAD_ATTR_GUIDINFO_RECORD,
4001 sizeof(*p_rec), &context);
4003 if (status != IB_SUCCESS) {
4004 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0099: "
4005 "osmtest_get_all_recs failed (%s)\n",
4006 ib_get_err_str(status));
4010 num_recs = context.result.result_cnt;
4012 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Received %zu records\n",
4015 /* No validation as yet */
4019 * Return the IB query MAD to the pool as necessary.
4021 if (context.result.p_result_madw != NULL) {
4022 osm_mad_pool_put(&p_osmt->mad_pool,
4023 context.result.p_result_madw);
4024 context.result.p_result_madw = NULL;
4027 OSM_LOG_EXIT(&p_osmt->log);
4031 /**********************************************************************
4032 **********************************************************************/
4033 static ib_api_status_t
4034 osmtest_validate_all_path_recs(IN osmtest_t * const p_osmt)
4036 osmtest_req_context_t context;
4037 const ib_path_rec_t *p_rec;
4042 OSM_LOG_ENTER(&p_osmt->log);
4044 memset(&context, 0, sizeof(context));
4047 * Do a blocking query for all PathRecords in the subnet.
4049 status = osmtest_get_all_recs(p_osmt, IB_MAD_ATTR_PATH_RECORD,
4050 sizeof(*p_rec), &context);
4052 if (status != IB_SUCCESS) {
4053 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 009A: "
4054 "osmtest_get_all_recs failed (%s)\n",
4055 ib_get_err_str(status));
4059 num_recs = context.result.result_cnt;
4061 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Received %zu records\n",
4065 * Compare the received records to the database.
4067 osmtest_prepare_db(p_osmt);
4069 for (i = 0; i < num_recs; i++) {
4071 osmv_get_query_path_rec(context.result.p_result_madw, i);
4073 status = osmtest_validate_path_rec(p_osmt, p_rec);
4074 if (status != IB_SUCCESS) {
4075 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0100: "
4076 "osmtest_validate_path_rec failed (%s)\n",
4077 ib_get_err_str(status));
4082 status = osmtest_check_missing_paths(p_osmt);
4083 if (status != IB_SUCCESS) {
4084 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0101: "
4085 "osmtest_check_missing_paths failed (%s)\n",
4086 ib_get_err_str(status));
4092 * Return the IB query MAD to the pool as necessary.
4094 if (context.result.p_result_madw != NULL) {
4095 osm_mad_pool_put(&p_osmt->mad_pool,
4096 context.result.p_result_madw);
4097 context.result.p_result_madw = NULL;
4100 OSM_LOG_EXIT(&p_osmt->log);
4104 /**********************************************************************
4105 * Get link record by LID
4106 **********************************************************************/
4108 osmtest_get_link_rec_by_lid(IN osmtest_t * const p_osmt,
4109 IN ib_net16_t const from_lid,
4110 IN ib_net16_t const to_lid,
4111 IN OUT osmtest_req_context_t * const p_context)
4113 ib_api_status_t status = IB_SUCCESS;
4114 osmv_user_query_t user;
4115 osmv_query_req_t req;
4116 ib_link_record_t record;
4119 OSM_LOG_ENTER(&p_osmt->log);
4121 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
4122 "Getting link record from LID 0x%02X to LID 0x%02X\n",
4123 cl_ntoh16(from_lid), cl_ntoh16(to_lid));
4126 * Do a blocking query for this record in the subnet.
4127 * The result is returned in the result field of the caller's
4128 * context structure.
4130 * The query structures are locals.
4132 memset(&req, 0, sizeof(req));
4133 memset(&user, 0, sizeof(user));
4134 memset(&record, 0, sizeof(record));
4136 record.from_lid = from_lid;
4137 record.to_lid = to_lid;
4138 p_context->p_osmt = p_osmt;
4140 user.comp_mask |= IB_LR_COMPMASK_FROM_LID;
4142 user.comp_mask |= IB_LR_COMPMASK_TO_LID;
4143 user.attr_id = IB_MAD_ATTR_LINK_RECORD;
4144 user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3));
4145 user.p_attr = &record;
4147 req.query_type = OSMV_QUERY_USER_DEFINED;
4148 req.timeout_ms = p_osmt->opt.transaction_timeout;
4149 req.retry_cnt = p_osmt->opt.retry_count;
4150 req.flags = OSM_SA_FLAGS_SYNC;
4151 req.query_context = p_context;
4152 req.pfn_query_cb = osmtest_query_res_cb;
4153 req.p_query_input = &user;
4156 status = osmv_query_sa(p_osmt->h_bind, &req);
4157 if (status != IB_SUCCESS) {
4158 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 007A: "
4159 "ib_query failed (%s)\n", ib_get_err_str(status));
4163 status = p_context->result.status;
4165 if (status != IB_SUCCESS) {
4166 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 007B: "
4167 "ib_query failed (%s)\n", ib_get_err_str(status));
4168 if (status == IB_REMOTE_ERROR) {
4170 osm_madw_get_mad_ptr(p_context->result.
4172 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
4173 "osmtest_get_link_rec_by_lid: "
4174 "Remote error = %s\n",
4175 ib_get_mad_status_str(p_mad));
4178 (ib_net16_t) (p_mad->status & IB_SMP_STATUS_MASK);
4184 OSM_LOG_EXIT(&p_osmt->log);
4188 /**********************************************************************
4189 * Get GUIDInfo record by LID
4190 **********************************************************************/
4192 osmtest_get_guidinfo_rec_by_lid(IN osmtest_t * const p_osmt,
4193 IN ib_net16_t const lid,
4194 IN OUT osmtest_req_context_t * const p_context)
4196 ib_api_status_t status = IB_SUCCESS;
4197 osmv_user_query_t user;
4198 osmv_query_req_t req;
4199 ib_guidinfo_record_t record;
4202 OSM_LOG_ENTER(&p_osmt->log);
4204 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
4205 "Getting GUIDInfo record for LID 0x%02X\n", cl_ntoh16(lid));
4208 * Do a blocking query for this record in the subnet.
4209 * The result is returned in the result field of the caller's
4210 * context structure.
4212 * The query structures are locals.
4214 memset(&req, 0, sizeof(req));
4215 memset(&user, 0, sizeof(user));
4216 memset(&record, 0, sizeof(record));
4219 p_context->p_osmt = p_osmt;
4220 user.comp_mask = IB_GIR_COMPMASK_LID;
4221 user.attr_id = IB_MAD_ATTR_GUIDINFO_RECORD;
4222 user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3));
4223 user.p_attr = &record;
4225 req.query_type = OSMV_QUERY_USER_DEFINED;
4226 req.timeout_ms = p_osmt->opt.transaction_timeout;
4227 req.retry_cnt = p_osmt->opt.retry_count;
4229 req.flags = OSM_SA_FLAGS_SYNC;
4230 req.query_context = p_context;
4231 req.pfn_query_cb = osmtest_query_res_cb;
4232 req.p_query_input = &user;
4235 status = osmv_query_sa(p_osmt->h_bind, &req);
4236 if (status != IB_SUCCESS) {
4237 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 007C: "
4238 "ib_query failed (%s)\n", ib_get_err_str(status));
4242 status = p_context->result.status;
4244 if (status != IB_SUCCESS) {
4245 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 007D: "
4246 "ib_query failed (%s)\n", ib_get_err_str(status));
4247 if (status == IB_REMOTE_ERROR) {
4249 osm_madw_get_mad_ptr(p_context->result.
4251 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
4252 "Remote error = %s\n",
4253 ib_get_mad_status_str(p_mad));
4256 (ib_net16_t) (p_mad->status & IB_SMP_STATUS_MASK);
4262 OSM_LOG_EXIT(&p_osmt->log);
4266 /**********************************************************************
4267 * Get PKeyTable record by LID
4268 **********************************************************************/
4270 osmtest_get_pkeytbl_rec_by_lid(IN osmtest_t * const p_osmt,
4271 IN ib_net16_t const lid,
4272 IN ib_net64_t const sm_key,
4273 IN OUT osmtest_req_context_t * const p_context)
4275 ib_api_status_t status = IB_SUCCESS;
4276 osmv_user_query_t user;
4277 osmv_query_req_t req;
4278 ib_pkey_table_record_t record;
4281 OSM_LOG_ENTER(&p_osmt->log);
4283 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
4284 "Getting PKeyTable record for LID 0x%02X\n", cl_ntoh16(lid));
4287 * Do a blocking query for this record in the subnet.
4288 * The result is returned in the result field of the caller's
4289 * context structure.
4291 * The query structures are locals.
4293 memset(&req, 0, sizeof(req));
4294 memset(&user, 0, sizeof(user));
4295 memset(&record, 0, sizeof(record));
4298 p_context->p_osmt = p_osmt;
4299 user.comp_mask = IB_PKEY_COMPMASK_LID;
4300 user.attr_id = IB_MAD_ATTR_PKEY_TBL_RECORD;
4301 user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3));
4302 user.p_attr = &record;
4304 req.query_type = OSMV_QUERY_USER_DEFINED;
4305 req.timeout_ms = p_osmt->opt.transaction_timeout;
4306 req.retry_cnt = p_osmt->opt.retry_count;
4308 req.flags = OSM_SA_FLAGS_SYNC;
4309 req.query_context = p_context;
4310 req.pfn_query_cb = osmtest_query_res_cb;
4311 req.p_query_input = &user;
4312 req.sm_key = sm_key;
4314 status = osmv_query_sa(p_osmt->h_bind, &req);
4315 if (status != IB_SUCCESS) {
4316 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 007E: "
4317 "ib_query failed (%s)\n", ib_get_err_str(status));
4321 status = p_context->result.status;
4323 if (status != IB_SUCCESS) {
4324 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 007F: "
4325 "ib_query failed (%s)\n", ib_get_err_str(status));
4326 if (status == IB_REMOTE_ERROR) {
4328 osm_madw_get_mad_ptr(p_context->result.
4330 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
4331 "Remote error = %s\n",
4332 ib_get_mad_status_str(p_mad));
4335 (ib_net16_t) (p_mad->status & IB_SMP_STATUS_MASK);
4341 OSM_LOG_EXIT(&p_osmt->log);
4345 /**********************************************************************
4346 * Get SwitchInfo record by LID
4347 **********************************************************************/
4349 osmtest_get_sw_info_rec_by_lid(IN osmtest_t * const p_osmt,
4350 IN ib_net16_t const lid,
4351 IN OUT osmtest_req_context_t * const p_context)
4353 ib_api_status_t status = IB_SUCCESS;
4354 osmv_user_query_t user;
4355 osmv_query_req_t req;
4356 ib_switch_info_record_t record;
4359 OSM_LOG_ENTER(&p_osmt->log);
4361 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
4362 "Getting SwitchInfo record for LID 0x%02X\n", cl_ntoh16(lid));
4365 * Do a blocking query for this record in the subnet.
4366 * The result is returned in the result field of the caller's
4367 * context structure.
4369 * The query structures are locals.
4371 memset(&req, 0, sizeof(req));
4372 memset(&user, 0, sizeof(user));
4373 memset(&record, 0, sizeof(record));
4376 p_context->p_osmt = p_osmt;
4378 user.comp_mask = IB_SWIR_COMPMASK_LID;
4379 user.attr_id = IB_MAD_ATTR_SWITCH_INFO_RECORD;
4380 user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3));
4381 user.p_attr = &record;
4383 req.query_type = OSMV_QUERY_USER_DEFINED;
4384 req.timeout_ms = p_osmt->opt.transaction_timeout;
4385 req.retry_cnt = p_osmt->opt.retry_count;
4387 req.flags = OSM_SA_FLAGS_SYNC;
4388 req.query_context = p_context;
4389 req.pfn_query_cb = osmtest_query_res_cb;
4390 req.p_query_input = &user;
4393 status = osmv_query_sa(p_osmt->h_bind, &req);
4394 if (status != IB_SUCCESS) {
4395 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 006C: "
4396 "ib_query failed (%s)\n", ib_get_err_str(status));
4400 status = p_context->result.status;
4402 if (status != IB_SUCCESS) {
4403 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 006D: "
4404 "ib_query failed (%s)\n", ib_get_err_str(status));
4405 if (status == IB_REMOTE_ERROR) {
4407 osm_madw_get_mad_ptr(p_context->result.
4409 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
4410 "Remote error = %s\n",
4411 ib_get_mad_status_str(p_mad));
4414 (ib_net16_t) (p_mad->status & IB_SMP_STATUS_MASK);
4420 OSM_LOG_EXIT(&p_osmt->log);
4424 /**********************************************************************
4425 * Get LFT record by LID
4426 **********************************************************************/
4428 osmtest_get_lft_rec_by_lid(IN osmtest_t * const p_osmt,
4429 IN ib_net16_t const lid,
4430 IN OUT osmtest_req_context_t * const p_context)
4432 ib_api_status_t status = IB_SUCCESS;
4433 osmv_user_query_t user;
4434 osmv_query_req_t req;
4435 ib_lft_record_t record;
4438 OSM_LOG_ENTER(&p_osmt->log);
4440 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
4441 "Getting LFT record for LID 0x%02X\n", cl_ntoh16(lid));
4444 * Do a blocking query for this record in the subnet.
4445 * The result is returned in the result field of the caller's
4446 * context structure.
4448 * The query structures are locals.
4450 memset(&req, 0, sizeof(req));
4451 memset(&user, 0, sizeof(user));
4452 memset(&record, 0, sizeof(record));
4455 p_context->p_osmt = p_osmt;
4457 user.comp_mask = IB_LFTR_COMPMASK_LID;
4458 user.attr_id = IB_MAD_ATTR_LFT_RECORD;
4459 user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3));
4460 user.p_attr = &record;
4462 req.query_type = OSMV_QUERY_USER_DEFINED;
4463 req.timeout_ms = p_osmt->opt.transaction_timeout;
4464 req.retry_cnt = p_osmt->opt.retry_count;
4466 req.flags = OSM_SA_FLAGS_SYNC;
4467 req.query_context = p_context;
4468 req.pfn_query_cb = osmtest_query_res_cb;
4469 req.p_query_input = &user;
4472 status = osmv_query_sa(p_osmt->h_bind, &req);
4473 if (status != IB_SUCCESS) {
4474 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 008A: "
4475 "ib_query failed (%s)\n", ib_get_err_str(status));
4479 status = p_context->result.status;
4481 if (status != IB_SUCCESS) {
4482 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 008B: "
4483 "ib_query failed (%s)\n", ib_get_err_str(status));
4484 if (status == IB_REMOTE_ERROR) {
4486 osm_madw_get_mad_ptr(p_context->result.
4488 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
4489 "Remote error = %s\n",
4490 ib_get_mad_status_str(p_mad));
4493 (ib_net16_t) (p_mad->status & IB_SMP_STATUS_MASK);
4499 OSM_LOG_EXIT(&p_osmt->log);
4503 /**********************************************************************
4504 * Get MFT record by LID
4505 **********************************************************************/
4507 osmtest_get_mft_rec_by_lid(IN osmtest_t * const p_osmt,
4508 IN ib_net16_t const lid,
4509 IN OUT osmtest_req_context_t * const p_context)
4511 ib_api_status_t status = IB_SUCCESS;
4512 osmv_user_query_t user;
4513 osmv_query_req_t req;
4514 ib_mft_record_t record;
4517 OSM_LOG_ENTER(&p_osmt->log);
4519 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
4520 "Getting MFT record for LID 0x%02X\n", cl_ntoh16(lid));
4523 * Do a blocking query for this record in the subnet.
4524 * The result is returned in the result field of the caller's
4525 * context structure.
4527 * The query structures are locals.
4529 memset(&req, 0, sizeof(req));
4530 memset(&user, 0, sizeof(user));
4531 memset(&record, 0, sizeof(record));
4534 p_context->p_osmt = p_osmt;
4536 user.comp_mask = IB_MFTR_COMPMASK_LID;
4537 user.attr_id = IB_MAD_ATTR_MFT_RECORD;
4538 user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3));
4539 user.p_attr = &record;
4541 req.query_type = OSMV_QUERY_USER_DEFINED;
4542 req.timeout_ms = p_osmt->opt.transaction_timeout;
4543 req.retry_cnt = p_osmt->opt.retry_count;
4545 req.flags = OSM_SA_FLAGS_SYNC;
4546 req.query_context = p_context;
4547 req.pfn_query_cb = osmtest_query_res_cb;
4548 req.p_query_input = &user;
4551 status = osmv_query_sa(p_osmt->h_bind, &req);
4552 if (status != IB_SUCCESS) {
4553 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 009B: "
4554 "ib_query failed (%s)\n", ib_get_err_str(status));
4558 status = p_context->result.status;
4560 if (status != IB_SUCCESS) {
4561 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 009C: "
4562 "ib_query failed (%s)\n", ib_get_err_str(status));
4563 if (status == IB_REMOTE_ERROR) {
4565 osm_madw_get_mad_ptr(p_context->result.
4567 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
4568 "Remote error = %s\n",
4569 ib_get_mad_status_str(p_mad));
4572 (ib_net16_t) (p_mad->status & IB_SMP_STATUS_MASK);
4578 OSM_LOG_EXIT(&p_osmt->log);
4582 /**********************************************************************
4583 **********************************************************************/
4584 static ib_api_status_t
4585 osmtest_sminfo_record_request(IN osmtest_t * const p_osmt,
4588 IN OUT osmtest_req_context_t * const p_context)
4590 ib_api_status_t status = IB_SUCCESS;
4591 osmv_user_query_t user;
4592 osmv_query_req_t req;
4593 ib_sminfo_record_t record;
4595 osmtest_sm_info_rec_t *p_sm_info_opt;
4597 OSM_LOG_ENTER(&p_osmt->log);
4600 * Do a blocking query for these records in the subnet.
4601 * The result is returned in the result field of the caller's
4602 * context structure.
4604 * The query structures are locals.
4606 memset(&req, 0, sizeof(req));
4607 memset(&user, 0, sizeof(user));
4608 memset(&record, 0, sizeof(record));
4610 p_context->p_osmt = p_osmt;
4611 user.attr_id = IB_MAD_ATTR_SMINFO_RECORD;
4612 user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3));
4613 p_sm_info_opt = p_options;
4614 if (p_sm_info_opt->sm_guid != 0) {
4615 record.sm_info.guid = p_sm_info_opt->sm_guid;
4616 user.comp_mask |= IB_SMIR_COMPMASK_GUID;
4618 if (p_sm_info_opt->lid != 0) {
4619 record.lid = p_sm_info_opt->lid;
4620 user.comp_mask |= IB_SMIR_COMPMASK_LID;
4622 if (p_sm_info_opt->priority != 0) {
4623 record.sm_info.pri_state =
4624 (p_sm_info_opt->priority & 0x0F) << 4;
4625 user.comp_mask |= IB_SMIR_COMPMASK_PRIORITY;
4627 if (p_sm_info_opt->sm_state != 0) {
4628 record.sm_info.pri_state |= p_sm_info_opt->sm_state & 0x0F;
4629 user.comp_mask |= IB_SMIR_COMPMASK_SMSTATE;
4632 user.method = method;
4633 user.p_attr = &record;
4635 req.query_type = OSMV_QUERY_USER_DEFINED;
4636 req.timeout_ms = p_osmt->opt.transaction_timeout;
4637 req.retry_cnt = p_osmt->opt.retry_count;
4639 req.flags = OSM_SA_FLAGS_SYNC;
4640 req.query_context = p_context;
4641 req.pfn_query_cb = osmtest_query_res_cb;
4642 req.p_query_input = &user;
4645 status = osmv_query_sa(p_osmt->h_bind, &req);
4646 if (status != IB_SUCCESS) {
4647 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 008C: "
4648 "ib_query failed (%s)\n", ib_get_err_str(status));
4652 status = p_context->result.status;
4654 if (status != IB_SUCCESS) {
4655 if (status != IB_INVALID_PARAMETER) {
4656 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 008D: "
4657 "ib_query failed (%s)\n",
4658 ib_get_err_str(status));
4660 if (status == IB_REMOTE_ERROR) {
4662 osm_madw_get_mad_ptr(p_context->result.
4664 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
4665 "Remote error = %s\n",
4666 ib_get_mad_status_str(p_mad));
4669 (ib_net16_t) (p_mad->status & IB_SMP_STATUS_MASK);
4675 OSM_LOG_EXIT(&p_osmt->log);
4679 /**********************************************************************
4680 **********************************************************************/
4681 static ib_api_status_t
4682 osmtest_informinfo_request(IN osmtest_t * const p_osmt,
4683 IN ib_net16_t attr_id,
4686 IN OUT osmtest_req_context_t * const p_context)
4688 ib_api_status_t status = IB_SUCCESS;
4689 osmv_user_query_t user;
4690 osmv_query_req_t req;
4691 ib_inform_info_t rec;
4692 ib_inform_info_record_t record;
4694 osmtest_inform_info_t *p_inform_info_opt;
4695 osmtest_inform_info_rec_t *p_inform_info_rec_opt;
4697 OSM_LOG_ENTER(&p_osmt->log);
4700 * Do a blocking query for these records in the subnet.
4701 * The result is returned in the result field of the caller's
4702 * context structure.
4704 * The query structures are locals.
4706 memset(&req, 0, sizeof(req));
4707 memset(&user, 0, sizeof(user));
4708 memset(&rec, 0, sizeof(rec));
4709 memset(&record, 0, sizeof(record));
4711 p_context->p_osmt = p_osmt;
4712 user.attr_id = attr_id;
4713 if (attr_id == IB_MAD_ATTR_INFORM_INFO_RECORD) {
4714 user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3));
4715 p_inform_info_rec_opt = p_options;
4716 if (p_inform_info_rec_opt->subscriber_gid.unicast.prefix != 0 &&
4717 p_inform_info_rec_opt->subscriber_gid.unicast.
4718 interface_id != 0) {
4719 record.subscriber_gid =
4720 p_inform_info_rec_opt->subscriber_gid;
4721 user.comp_mask = IB_IIR_COMPMASK_SUBSCRIBERGID;
4723 record.subscriber_enum =
4724 cl_hton16(p_inform_info_rec_opt->subscriber_enum);
4725 user.comp_mask |= IB_IIR_COMPMASK_ENUM;
4726 user.p_attr = &record;
4728 user.attr_offset = cl_ntoh16((uint16_t) (sizeof(rec) >> 3));
4729 /* comp mask bits below are for InformInfoRecord rather than InformInfo */
4730 /* as currently no comp mask bits defined for InformInfo!!! */
4731 user.comp_mask = IB_IIR_COMPMASK_SUBSCRIBE;
4732 p_inform_info_opt = p_options;
4733 rec.subscribe = (uint8_t) p_inform_info_opt->subscribe;
4734 if (p_inform_info_opt->qpn) {
4735 rec.g_or_v.generic.qpn_resp_time_val =
4736 cl_hton32(p_inform_info_opt->qpn << 8);
4737 user.comp_mask |= IB_IIR_COMPMASK_QPN;
4739 if (p_inform_info_opt->trap) {
4740 rec.g_or_v.generic.trap_num =
4741 cl_hton16(p_inform_info_opt->trap);
4742 user.comp_mask |= IB_IIR_COMPMASK_TRAPNUMB;
4746 user.method = method;
4748 req.query_type = OSMV_QUERY_USER_DEFINED;
4749 req.timeout_ms = p_osmt->opt.transaction_timeout;
4750 req.retry_cnt = p_osmt->opt.retry_count;
4752 req.flags = OSM_SA_FLAGS_SYNC;
4753 req.query_context = p_context;
4754 req.pfn_query_cb = osmtest_query_res_cb;
4755 req.p_query_input = &user;
4758 status = osmv_query_sa(p_osmt->h_bind, &req);
4759 if (status != IB_SUCCESS) {
4760 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 008E: "
4761 "ib_query failed (%s)\n", ib_get_err_str(status));
4765 status = p_context->result.status;
4767 if (status != IB_SUCCESS) {
4768 if (status != IB_INVALID_PARAMETER) {
4769 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 008F: "
4770 "ib_query failed (%s)\n",
4771 ib_get_err_str(status));
4773 if (status == IB_REMOTE_ERROR) {
4775 osm_madw_get_mad_ptr(p_context->result.
4777 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
4778 "Remote error = %s\n",
4779 ib_get_mad_status_str(p_mad));
4782 (ib_net16_t) (p_mad->status & IB_SMP_STATUS_MASK);
4788 OSM_LOG_EXIT(&p_osmt->log);
4793 /**********************************************************************
4794 **********************************************************************/
4795 static ib_api_status_t
4796 osmtest_validate_single_path_rec_lid_pair(IN osmtest_t * const p_osmt,
4797 IN path_t * const p_path)
4799 osmtest_req_context_t context;
4800 const ib_path_rec_t *p_rec;
4801 cl_status_t status = IB_SUCCESS;
4804 OSM_LOG_ENTER(&p_osmt->log);
4806 memset(&context, 0, sizeof(context));
4808 status = osmtest_get_path_rec_by_lid_pair(p_osmt,
4810 p_path->rec.dlid, &context);
4811 if (status != IB_SUCCESS) {
4812 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0102: "
4813 "ib_query failed (%s)\n", ib_get_err_str(status));
4817 num_recs = context.result.result_cnt;
4818 if (num_recs != 1) {
4819 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0103: "
4820 "Too many records. Expected 1, received %zu\n",
4826 osmv_get_query_path_rec(context.result.p_result_madw, 0);
4828 status = osmtest_validate_path_data(p_osmt, p_path, p_rec);
4829 if (status != IB_SUCCESS) {
4830 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0104: "
4831 "osmtest_validate_path_data failed (%s)\n",
4832 ib_get_err_str(status));
4838 * Return the IB query MAD to the pool as necessary.
4840 if (context.result.p_result_madw != NULL) {
4841 osm_mad_pool_put(&p_osmt->mad_pool,
4842 context.result.p_result_madw);
4843 context.result.p_result_madw = NULL;
4846 OSM_LOG_EXIT(&p_osmt->log);
4850 /**********************************************************************
4851 **********************************************************************/
4852 static ib_api_status_t
4853 osmtest_validate_single_node_rec_lid(IN osmtest_t * const p_osmt,
4854 IN ib_net16_t const lid,
4855 IN node_t * const p_node)
4857 cl_status_t status = IB_SUCCESS;
4858 osmv_user_query_t user;
4859 osmv_query_req_t req;
4860 ib_node_record_t record;
4862 osmtest_req_context_t context;
4863 const ib_node_record_t *p_rec;
4866 OSM_LOG_ENTER(&p_osmt->log);
4868 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
4869 "Getting NodeRecord for node with LID 0x%X\n", cl_ntoh16(lid));
4871 memset(&context, 0, sizeof(context));
4872 memset(&req, 0, sizeof(req));
4873 memset(&user, 0, sizeof(user));
4874 memset(&record, 0, sizeof(record));
4878 context.p_osmt = p_osmt;
4879 user.comp_mask = IB_NR_COMPMASK_LID;
4880 user.attr_id = IB_MAD_ATTR_NODE_RECORD;
4881 user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3));
4882 user.p_attr = &record;
4884 req.query_type = OSMV_QUERY_USER_DEFINED;
4885 req.timeout_ms = p_osmt->opt.transaction_timeout;
4886 req.retry_cnt = p_osmt->opt.retry_count;
4887 req.flags = OSM_SA_FLAGS_SYNC;
4888 req.query_context = &context;
4889 req.pfn_query_cb = osmtest_query_res_cb;
4890 req.p_query_input = &user;
4893 status = osmv_query_sa(p_osmt->h_bind, &req);
4895 if (status != IB_SUCCESS) {
4896 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0105: "
4897 "ib_query failed (%s)\n", ib_get_err_str(status));
4901 status = context.result.status;
4903 if (status != IB_SUCCESS) {
4904 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0106: "
4905 "ib_query failed (%s)\n", ib_get_err_str(status));
4907 if (status == IB_REMOTE_ERROR) {
4908 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
4909 "Remote error = %s\n",
4910 ib_get_mad_status_str(osm_madw_get_mad_ptr
4917 num_recs = context.result.result_cnt;
4918 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
4919 "Received %d nodes\n", num_recs);
4921 for (i = 0; i < num_recs; i++) {
4923 osmv_get_query_node_rec(context.result.p_result_madw, i);
4925 status = osmtest_validate_node_rec(p_osmt, p_rec);
4926 if (status != IB_SUCCESS) {
4927 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0107: "
4928 "osmtest_validate_node_data failed (%s)\n",
4929 ib_get_err_str(status));
4936 * Return the IB query MAD to the pool as necessary.
4938 if (context.result.p_result_madw != NULL) {
4939 osm_mad_pool_put(&p_osmt->mad_pool,
4940 context.result.p_result_madw);
4941 context.result.p_result_madw = NULL;
4944 OSM_LOG_EXIT(&p_osmt->log);
4948 /**********************************************************************
4949 **********************************************************************/
4950 static ib_api_status_t
4951 osmtest_validate_single_port_rec_lid(IN osmtest_t * const p_osmt,
4952 IN port_t * const p_port)
4954 osmtest_req_context_t context;
4956 const ib_portinfo_record_t *p_rec;
4957 cl_status_t status = IB_SUCCESS;
4959 OSM_LOG_ENTER(&p_osmt->log);
4961 memset(&context, 0, sizeof(context));
4963 context.p_osmt = p_osmt;
4964 osmtest_get_port_rec_by_num(p_osmt,
4966 p_port->rec.port_num, &context);
4967 if (status != IB_SUCCESS) {
4968 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0108: "
4969 "ib_query failed (%s)\n", ib_get_err_str(status));
4974 /* we should have got exactly one port */
4975 p_rec = osmv_get_query_portinfo_rec(context.result.p_result_madw, 0);
4976 status = osmtest_validate_port_rec(p_osmt, p_rec);
4977 if (status != IB_SUCCESS) {
4978 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0109: "
4979 "osmtest_validate_port_data failed (%s)\n",
4980 ib_get_err_str(status));
4985 * Return the IB query MAD to the pool as necessary.
4987 if (context.result.p_result_madw != NULL) {
4988 osm_mad_pool_put(&p_osmt->mad_pool,
4989 context.result.p_result_madw);
4990 context.result.p_result_madw = NULL;
4993 OSM_LOG_EXIT(&p_osmt->log);
4997 /**********************************************************************
4998 **********************************************************************/
4999 static ib_api_status_t
5000 osmtest_validate_single_path_rec_guid_pair(IN osmtest_t * const p_osmt,
5001 IN const osmv_guid_pair_t *
5004 osmtest_req_context_t context;
5005 const ib_path_rec_t *p_rec;
5006 cl_status_t status = IB_SUCCESS;
5008 osmv_query_req_t req;
5010 boolean_t got_error = FALSE;
5012 OSM_LOG_ENTER(&p_osmt->log);
5014 memset(&req, 0, sizeof(req));
5015 memset(&context, 0, sizeof(context));
5017 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
5018 "\n\t\t\t\tChecking src 0x%016" PRIx64
5019 " to dest 0x%016" PRIx64 "\n",
5020 cl_ntoh64(p_pair->src_guid), cl_ntoh64(p_pair->dest_guid));
5022 context.p_osmt = p_osmt;
5024 req.timeout_ms = p_osmt->opt.transaction_timeout;
5025 req.retry_cnt = p_osmt->opt.retry_count;
5026 req.flags = OSM_SA_FLAGS_SYNC;
5027 req.query_context = &context;
5028 req.pfn_query_cb = osmtest_query_res_cb;
5030 req.query_type = OSMV_QUERY_PATH_REC_BY_PORT_GUIDS;
5031 req.p_query_input = p_pair;
5034 status = osmv_query_sa(p_osmt->h_bind, &req);
5035 if (status != IB_SUCCESS) {
5036 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0110: "
5037 "ib_query failed (%s)\n", ib_get_err_str(status));
5041 status = context.result.status;
5043 if (status != IB_SUCCESS) {
5044 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0111: "
5045 "ib_query failed (%s)\n", ib_get_err_str(status));
5047 if (status == IB_REMOTE_ERROR) {
5048 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
5049 "Remote error = %s\n",
5050 ib_get_mad_status_str(osm_madw_get_mad_ptr
5057 num_recs = context.result.result_cnt;
5058 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "%zu records\n", num_recs);
5060 for (i = 0; i < num_recs; i++) {
5062 osmv_get_query_path_rec(context.result.p_result_madw, i);
5065 * Make sure the GUID values are correct
5067 if (p_rec->dgid.unicast.interface_id != p_pair->dest_guid) {
5068 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0112: "
5069 "Destination GUID mismatch\n"
5070 "\t\t\t\texpected 0x%016" PRIx64
5071 ", received 0x%016" PRIx64 "\n",
5072 cl_ntoh64(p_pair->dest_guid),
5073 cl_ntoh64(p_rec->dgid.unicast.interface_id));
5077 if (p_rec->sgid.unicast.interface_id != p_pair->src_guid) {
5078 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0113: "
5079 "Source GUID mismatch\n"
5080 "\t\t\t\texpected 0x%016" PRIx64
5081 ", received 0x%016" PRIx64 ".\n",
5082 cl_ntoh64(p_pair->src_guid),
5083 cl_ntoh64(p_rec->sgid.unicast.interface_id));
5087 status = osmtest_validate_path_rec(p_osmt, p_rec);
5088 if (status != IB_SUCCESS) {
5089 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0114: "
5090 "osmtest_validate_path_rec failed (%s)\n",
5091 ib_get_err_str(status));
5094 if (got_error || (status != IB_SUCCESS)) {
5095 osm_dump_path_record(&p_osmt->log, p_rec,
5097 if (status == IB_SUCCESS)
5105 * Return the IB query MAD to the pool as necessary.
5107 if (context.result.p_result_madw != NULL) {
5108 osm_mad_pool_put(&p_osmt->mad_pool,
5109 context.result.p_result_madw);
5110 context.result.p_result_madw = NULL;
5113 OSM_LOG_EXIT(&p_osmt->log);
5117 /**********************************************************************
5118 **********************************************************************/
5119 static ib_api_status_t
5120 osmtest_validate_single_path_recs(IN osmtest_t * const p_osmt)
5123 cl_status_t status = IB_SUCCESS;
5124 const cl_qmap_t *p_path_tbl;
5125 /* We skip node to node path record validation since it might contains
5126 NONEXISTENT PATHS, i.e. when using UPDN */
5127 osmv_guid_pair_t guid_pair;
5130 OSM_LOG_ENTER(&p_osmt->log);
5132 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
5133 "Validating individual path record queries\n");
5134 p_path_tbl = &p_osmt->exp_subn.path_tbl;
5136 osmtest_prepare_db(p_osmt);
5139 * Walk the list of all path records, and ask for each one
5140 * specifically. Make sure we get it.
5143 p_path = (path_t *) cl_qmap_head(p_path_tbl);
5144 while (p_path != (path_t *) cl_qmap_end(p_path_tbl)) {
5146 osmtest_validate_single_path_rec_lid_pair(p_osmt, p_path);
5147 if (status != IB_SUCCESS)
5150 p_path = (path_t *) cl_qmap_next(&p_path->map_item);
5153 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
5154 "Total of %u path records validated using LID based query\n",
5157 status = osmtest_check_missing_paths(p_osmt);
5158 if (status != IB_SUCCESS) {
5159 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0115: "
5160 "osmtest_check_missing_paths failed (%s)\n",
5161 ib_get_err_str(status));
5166 * Do the whole thing again with port GUID pairs.
5167 * Note that multiple path records may be returned
5168 * for each guid pair if LMC > 0.
5170 osmtest_prepare_db(p_osmt);
5172 p_path = (path_t *) cl_qmap_head(p_path_tbl);
5173 while (p_path != (path_t *) cl_qmap_end(p_path_tbl)) {
5174 guid_pair.src_guid = p_path->rec.sgid.unicast.interface_id;
5175 guid_pair.dest_guid = p_path->rec.dgid.unicast.interface_id;
5176 status = osmtest_validate_single_path_rec_guid_pair(p_osmt,
5178 if (status != IB_SUCCESS)
5181 p_path = (path_t *) cl_qmap_next(&p_path->map_item);
5184 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
5185 "Total of %u path records validated using GUID based query\n",
5188 status = osmtest_check_missing_paths(p_osmt);
5189 if (status != IB_SUCCESS) {
5190 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0116: "
5191 "osmtest_check_missing_paths failed (%s)\n",
5192 ib_get_err_str(status));
5197 OSM_LOG_EXIT(&p_osmt->log);
5201 /**********************************************************************
5202 **********************************************************************/
5203 static ib_api_status_t
5204 osmtest_validate_single_node_recs(IN osmtest_t * const p_osmt)
5207 cl_status_t status = IB_SUCCESS;
5208 const cl_qmap_t *p_node_lid_tbl;
5211 OSM_LOG_ENTER(&p_osmt->log);
5213 p_node_lid_tbl = &p_osmt->exp_subn.node_lid_tbl;
5215 osmtest_prepare_db(p_osmt);
5217 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
5218 "Validating individual node record queries\n");
5221 * Walk the list of all node records, and ask for each one
5222 * specifically. Make sure we get it.
5224 p_node = (node_t *) cl_qmap_head(p_node_lid_tbl);
5225 while (p_node != (node_t *) cl_qmap_end(p_node_lid_tbl)) {
5226 status = osmtest_validate_single_node_rec_lid(p_osmt,
5228 cl_qmap_key((cl_map_item_t *) p_node), p_node);
5229 if (status != IB_SUCCESS) {
5230 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 011A: "
5231 "osmtest_validate_single_node_rec_lid (%s)\n",
5232 ib_get_err_str(status));
5236 p_node = (node_t *) cl_qmap_next(&p_node->map_item);
5239 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
5240 "Total of %u node records validated\n", cnt);
5242 status = osmtest_check_missing_nodes(p_osmt);
5243 if (status != IB_SUCCESS) {
5244 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0117: "
5245 "osmtest_check_missing_nodes (%s)\n",
5246 ib_get_err_str(status));
5251 OSM_LOG_EXIT(&p_osmt->log);
5255 /**********************************************************************
5256 **********************************************************************/
5257 static ib_api_status_t
5258 osmtest_validate_single_port_recs(IN osmtest_t * const p_osmt)
5261 cl_status_t status = IB_SUCCESS;
5262 const cl_qmap_t *p_port_key_tbl;
5265 OSM_LOG_ENTER(&p_osmt->log);
5267 p_port_key_tbl = &p_osmt->exp_subn.port_key_tbl;
5269 osmtest_prepare_db(p_osmt);
5271 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
5272 "Validating individual port record queries\n");
5275 * Walk the list of all port records, and ask for each one
5276 * specifically. Make sure we get it.
5278 p_port = (port_t *) cl_qmap_head(p_port_key_tbl);
5279 while (p_port != (port_t *) cl_qmap_end(p_port_key_tbl)) {
5280 status = osmtest_validate_single_port_rec_lid(p_osmt, p_port);
5281 if (status != IB_SUCCESS) {
5282 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 011B: "
5283 "osmtest_validate_single_port_rec_lid (%s)\n",
5284 ib_get_err_str(status));
5288 p_port = (port_t *) cl_qmap_next(&p_port->map_item);
5291 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
5292 "Total of %u port records validated\n", cnt);
5294 status = osmtest_check_missing_ports(p_osmt);
5295 if (status != IB_SUCCESS) {
5296 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0118: "
5297 "osmtest_check_missing_paths failed (%s)\n",
5298 ib_get_err_str(status));
5303 OSM_LOG_EXIT(&p_osmt->log);
5307 /**********************************************************************
5308 **********************************************************************/
5309 static ib_api_status_t osmtest_validate_against_db(IN osmtest_t * const p_osmt)
5311 ib_api_status_t status = IB_SUCCESS;
5312 ib_gid_t portgid, mgid;
5313 osmtest_sm_info_rec_t sm_info_rec_opt;
5314 osmtest_inform_info_t inform_info_opt;
5315 osmtest_inform_info_rec_t inform_info_rec_opt;
5316 #ifdef VENDOR_RMPP_SUPPORT
5318 ib_net16_t test_lid;
5320 osmtest_req_context_t context;
5321 #ifdef DUAL_SIDED_RMPP
5322 osmv_multipath_req_t request;
5327 OSM_LOG_ENTER(&p_osmt->log);
5329 #ifdef VENDOR_RMPP_SUPPORT
5330 status = osmtest_validate_all_node_recs(p_osmt);
5331 if (status != IB_SUCCESS)
5335 status = osmtest_validate_single_node_recs(p_osmt);
5336 if (status != IB_SUCCESS)
5339 /* Exercise SA PathRecord multicast destination code */
5340 memset(&context, 0, sizeof(context));
5341 ib_gid_set_default(&portgid, portguid);
5342 /* Set IPoIB broadcast MGID */
5343 mgid.unicast.prefix = CL_HTON64(0xff12401bffff0000ULL);
5344 mgid.unicast.interface_id = CL_HTON64(0x00000000ffffffffULL);
5345 /* Can't check status as don't know whether port is running IPoIB */
5346 osmtest_get_path_rec_by_gid_pair(p_osmt, portgid, mgid, &context);
5348 /* Other link local unicast PathRecord */
5349 memset(&context, 0, sizeof(context));
5350 ib_gid_set_default(&portgid, portguid);
5351 ib_gid_set_default(&mgid, portguid);
5352 mgid.raw[7] = 0xff; /* not default GID prefix */
5353 /* Can't check status as don't know whether ??? */
5354 osmtest_get_path_rec_by_gid_pair(p_osmt, portgid, mgid, &context);
5356 /* Off subnet (site local) unicast PathRecord */
5357 memset(&context, 0, sizeof(context));
5358 ib_gid_set_default(&portgid, portguid);
5359 ib_gid_set_default(&mgid, portguid);
5360 mgid.raw[1] = 0xc0; /* site local */
5361 /* Can't check status as don't know whether ??? */
5362 osmtest_get_path_rec_by_gid_pair(p_osmt, portgid, mgid, &context);
5364 /* More than link local scope multicast PathRecord */
5365 memset(&context, 0, sizeof(context));
5366 ib_gid_set_default(&portgid, portguid);
5367 /* Set IPoIB broadcast MGID */
5368 mgid.unicast.prefix = CL_HTON64(0xff15401bffff0000ULL); /* site local */
5369 mgid.unicast.interface_id = CL_HTON64(0x00000000ffffffffULL);
5370 /* Can't check status as don't know whether port is running IPoIB */
5371 osmtest_get_path_rec_by_gid_pair(p_osmt, portgid, mgid, &context);
5373 #if defined (VENDOR_RMPP_SUPPORT) && defined (DUAL_SIDED_RMPP)
5374 memset(&context, 0, sizeof(context));
5375 memset(&request, 0, sizeof(request));
5377 IB_MPR_COMPMASK_SGIDCOUNT | IB_MPR_COMPMASK_DGIDCOUNT;
5378 request.sgid_count = 1;
5379 request.dgid_count = 1;
5380 ib_gid_set_default(&request.gids[0], portguid);
5381 ib_gid_set_default(&request.gids[1], portguid);
5382 status = osmtest_get_multipath_rec(p_osmt, &request, &context);
5383 if (status != IB_SUCCESS)
5386 memset(&context, 0, sizeof(context));
5387 memset(&request, 0, sizeof(request));
5389 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
5390 status = osmtest_get_multipath_rec(p_osmt, &request, &context);
5391 if (status != IB_SUCCESS) {
5392 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
5393 "Got error %s\n", ib_get_err_str(status));
5395 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
5397 if (status == IB_SUCCESS) {
5402 memset(&context, 0, sizeof(context));
5403 memset(&request, 0, sizeof(request));
5404 request.comp_mask = IB_MPR_COMPMASK_SGIDCOUNT;
5405 request.sgid_count = 1;
5406 ib_gid_set_default(&request.gids[0], portguid);
5408 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
5409 status = osmtest_get_multipath_rec(p_osmt, &request, &context);
5410 if (status != IB_SUCCESS) {
5411 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
5412 "Got error %s\n", ib_get_err_str(status));
5414 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
5416 if (status == IB_SUCCESS) {
5421 memset(&context, 0, sizeof(context));
5422 memset(&request, 0, sizeof(request));
5424 IB_MPR_COMPMASK_SGIDCOUNT | IB_MPR_COMPMASK_DGIDCOUNT;
5425 request.sgid_count = 1;
5426 request.dgid_count = 1;
5427 ib_gid_set_default(&request.gids[0], portguid);
5428 /* Set IPoIB broadcast MGID as DGID */
5429 request.gids[1].unicast.prefix = CL_HTON64(0xff12401bffff0000ULL);
5430 request.gids[1].unicast.interface_id = CL_HTON64(0x00000000ffffffffULL);
5432 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
5433 status = osmtest_get_multipath_rec(p_osmt, &request, &context);
5434 if (status != IB_SUCCESS) {
5435 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
5436 "Got error %s\n", ib_get_err_str(status));
5438 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
5440 if (status == IB_SUCCESS) {
5445 memset(&context, 0, sizeof(context));
5447 IB_MPR_COMPMASK_SGIDCOUNT | IB_MPR_COMPMASK_DGIDCOUNT;
5448 request.sgid_count = 1;
5449 request.dgid_count = 1;
5450 /* Set IPoIB broadcast MGID as SGID */
5451 request.gids[0].unicast.prefix = CL_HTON64(0xff12401bffff0000ULL);
5452 request.gids[0].unicast.interface_id = CL_HTON64(0x00000000ffffffffULL);
5453 ib_gid_set_default(&request.gids[1], portguid);
5455 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
5456 status = osmtest_get_multipath_rec(p_osmt, &request, &context);
5457 if (status != IB_SUCCESS) {
5458 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
5459 "Got error %s\n", ib_get_err_str(status));
5461 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
5463 if (status == IB_SUCCESS) {
5468 memset(&context, 0, sizeof(context));
5469 memset(&request, 0, sizeof(request));
5471 IB_MPR_COMPMASK_SGIDCOUNT | IB_MPR_COMPMASK_DGIDCOUNT |
5472 IB_MPR_COMPMASK_NUMBPATH;
5473 request.sgid_count = 2;
5474 request.dgid_count = 2;
5475 request.num_path = 2;
5476 ib_gid_set_default(&request.gids[0], portguid);
5477 ib_gid_set_default(&request.gids[1], portguid);
5478 ib_gid_set_default(&request.gids[2], portguid);
5479 ib_gid_set_default(&request.gids[3], portguid);
5480 status = osmtest_get_multipath_rec(p_osmt, &request, &context);
5481 if (status != IB_SUCCESS)
5485 #ifdef VENDOR_RMPP_SUPPORT
5486 /* GUIDInfoRecords */
5487 status = osmtest_validate_all_guidinfo_recs(p_osmt);
5488 if (status != IB_SUCCESS)
5491 /* If LMC > 0, test non base LID SA PortInfoRecord request */
5493 osmtest_get_local_port_lmc(p_osmt, p_osmt->local_port.lid, &lmc);
5494 if (status != IB_SUCCESS)
5499 osmtest_get_local_port_lmc(p_osmt,
5500 p_osmt->local_port.lid + 1,
5502 if (status != IB_SUCCESS)
5506 status = osmtest_get_local_port_lmc(p_osmt, 0xffff, NULL);
5507 if (status != IB_SUCCESS)
5510 test_lid = cl_ntoh16(p_osmt->local_port.lid);
5512 /* More GUIDInfo Record tests */
5513 memset(&context, 0, sizeof(context));
5514 status = osmtest_get_guidinfo_rec_by_lid(p_osmt, test_lid, &context);
5515 if (status != IB_SUCCESS)
5518 memset(&context, 0, sizeof(context));
5519 status = osmtest_get_guidinfo_rec_by_lid(p_osmt, 0xffff, &context);
5520 if (status != IB_SUCCESS)
5523 /* Some PKeyTable Record tests */
5524 sm_key = OSM_DEFAULT_SM_KEY;
5525 memset(&context, 0, sizeof(context));
5527 osmtest_get_pkeytbl_rec_by_lid(p_osmt, test_lid, sm_key, &context);
5528 if (status != IB_SUCCESS)
5531 memset(&context, 0, sizeof(context));
5533 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n");
5534 status = osmtest_get_pkeytbl_rec_by_lid(p_osmt, test_lid, 0, &context);
5535 if (status != IB_SUCCESS) {
5536 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
5537 "Got error %s\n", ib_get_err_str(status));
5539 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n");
5541 if (status == IB_SUCCESS) {
5546 memset(&context, 0, sizeof(context));
5548 osmtest_get_pkeytbl_rec_by_lid(p_osmt, 0xffff, sm_key, &context);
5549 if (status != IB_SUCCESS)
5552 /* SwitchInfo Record tests */
5553 memset(&context, 0, sizeof(context));
5554 status = osmtest_get_sw_info_rec_by_lid(p_osmt, 0, &context);
5555 if (status != IB_SUCCESS)
5558 memset(&context, 0, sizeof(context));
5559 status = osmtest_get_sw_info_rec_by_lid(p_osmt, test_lid, &context);
5560 if (status != IB_SUCCESS)
5563 /* LFT Record tests */
5564 memset(&context, 0, sizeof(context));
5565 status = osmtest_get_lft_rec_by_lid(p_osmt, 0, &context);
5566 if (status != IB_SUCCESS)
5569 memset(&context, 0, sizeof(context));
5570 status = osmtest_get_lft_rec_by_lid(p_osmt, test_lid, &context);
5571 if (status != IB_SUCCESS)
5574 /* MFT Record tests */
5575 memset(&context, 0, sizeof(context));
5576 status = osmtest_get_mft_rec_by_lid(p_osmt, 0, &context);
5577 if (status != IB_SUCCESS)
5580 memset(&context, 0, sizeof(context));
5581 status = osmtest_get_mft_rec_by_lid(p_osmt, test_lid, &context);
5582 if (status != IB_SUCCESS)
5585 /* Some LinkRecord tests */
5587 memset(&context, 0, sizeof(context));
5588 status = osmtest_get_link_rec_by_lid(p_osmt, test_lid, 0, &context);
5589 if (status != IB_SUCCESS)
5593 memset(&context, 0, sizeof(context));
5594 status = osmtest_get_link_rec_by_lid(p_osmt, 0, test_lid, &context);
5595 if (status != IB_SUCCESS)
5598 /* FromLID & ToLID */
5599 memset(&context, 0, sizeof(context));
5601 osmtest_get_link_rec_by_lid(p_osmt, test_lid, test_lid, &context);
5602 if (status != IB_SUCCESS)
5605 /* NodeRecord test */
5606 memset(&context, 0, sizeof(context));
5607 status = osmtest_get_node_rec_by_lid(p_osmt, 0xffff, &context);
5608 if (status != IB_SUCCESS)
5611 /* SMInfoRecord tests */
5612 memset(&sm_info_rec_opt, 0, sizeof(sm_info_rec_opt));
5613 memset(&context, 0, sizeof(context));
5614 status = osmtest_sminfo_record_request(p_osmt, IB_MAD_METHOD_SET,
5615 &sm_info_rec_opt, &context);
5616 if (status == IB_SUCCESS) {
5620 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "IS EXPECTED ERROR ^^^^\n");
5623 memset(&sm_info_rec_opt, 0, sizeof(sm_info_rec_opt));
5624 memset(&context, 0, sizeof(context));
5625 status = osmtest_sminfo_record_request(p_osmt, IB_MAD_METHOD_GETTABLE,
5626 &sm_info_rec_opt, &context);
5627 if (status != IB_SUCCESS)
5630 memset(&sm_info_rec_opt, 0, sizeof(sm_info_rec_opt));
5631 sm_info_rec_opt.lid = test_lid; /* local LID */
5632 memset(&context, 0, sizeof(context));
5633 status = osmtest_sminfo_record_request(p_osmt, IB_MAD_METHOD_GETTABLE,
5634 &sm_info_rec_opt, &context);
5635 if (status != IB_SUCCESS)
5638 if (portguid != 0) {
5639 memset(&sm_info_rec_opt, 0, sizeof(sm_info_rec_opt));
5640 sm_info_rec_opt.sm_guid = portguid; /* local GUID */
5641 memset(&context, 0, sizeof(context));
5643 osmtest_sminfo_record_request(p_osmt,
5644 IB_MAD_METHOD_GETTABLE,
5645 &sm_info_rec_opt, &context);
5646 if (status != IB_SUCCESS)
5650 for (i = 1; i < 16; i++) {
5651 memset(&sm_info_rec_opt, 0, sizeof(sm_info_rec_opt));
5652 sm_info_rec_opt.priority = i;
5653 memset(&context, 0, sizeof(context));
5655 osmtest_sminfo_record_request(p_osmt,
5656 IB_MAD_METHOD_GETTABLE,
5657 &sm_info_rec_opt, &context);
5658 if (status != IB_SUCCESS)
5662 for (i = 1; i < 4; i++) {
5663 memset(&sm_info_rec_opt, 0, sizeof(sm_info_rec_opt));
5664 sm_info_rec_opt.sm_state = i;
5665 memset(&context, 0, sizeof(context));
5667 osmtest_sminfo_record_request(p_osmt,
5668 IB_MAD_METHOD_GETTABLE,
5669 &sm_info_rec_opt, &context);
5670 if (status != IB_SUCCESS)
5674 /* InformInfoRecord tests */
5675 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfoRecord "
5676 "Sending a BAD - Set Unsubscribe request\n");
5677 memset(&inform_info_opt, 0, sizeof(inform_info_opt));
5678 memset(&inform_info_rec_opt, 0, sizeof(inform_info_rec_opt));
5679 memset(&context, 0, sizeof(context));
5681 osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO_RECORD,
5682 IB_MAD_METHOD_SET, &inform_info_rec_opt,
5684 if (status == IB_SUCCESS) {
5688 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "InformInfoRecord "
5689 "IS EXPECTED ERROR ^^^^\n");
5692 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfoRecord "
5693 "Sending a Good - Empty GetTable request\n");
5694 memset(&context, 0, sizeof(context));
5696 osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO_RECORD,
5697 IB_MAD_METHOD_GETTABLE,
5698 &inform_info_rec_opt, &context);
5699 if (status != IB_SUCCESS)
5702 /* InformInfo tests */
5703 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfo "
5704 "Sending a BAD - Empty Get request "
5705 "(should fail with NO_RECORDS)\n");
5706 memset(&context, 0, sizeof(context));
5707 status = osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO,
5708 IB_MAD_METHOD_GET, &inform_info_opt,
5710 if (status == IB_SUCCESS) {
5714 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "InformInfo "
5715 "IS EXPECTED ERROR ^^^^\n");
5718 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfo "
5719 "Sending a BAD - Set Unsubscribe request\n");
5720 memset(&context, 0, sizeof(context));
5721 status = osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO,
5722 IB_MAD_METHOD_SET, &inform_info_opt,
5724 if (status == IB_SUCCESS) {
5728 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "InformInfo UnSubscribe "
5729 "IS EXPECTED ERROR ^^^^\n");
5733 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfo "
5734 "Sending a Good - Set Subscribe request\n");
5735 inform_info_opt.subscribe = TRUE;
5736 memset(&context, 0, sizeof(context));
5737 status = osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO,
5738 IB_MAD_METHOD_SET, &inform_info_opt,
5740 if (status != IB_SUCCESS)
5743 /* Now unsubscribe (QPN needs to be 1 to work) */
5744 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfo "
5745 "Sending a Good - Set Unsubscribe request\n");
5746 inform_info_opt.subscribe = FALSE;
5747 inform_info_opt.qpn = 1;
5748 memset(&context, 0, sizeof(context));
5749 status = osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO,
5750 IB_MAD_METHOD_SET, &inform_info_opt,
5752 if (status != IB_SUCCESS)
5755 /* Now subscribe again */
5756 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfo "
5757 "Sending a Good - Set Subscribe request\n");
5758 inform_info_opt.subscribe = TRUE;
5759 inform_info_opt.qpn = 1;
5760 memset(&context, 0, sizeof(context));
5761 status = osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO,
5762 IB_MAD_METHOD_SET, &inform_info_opt,
5764 if (status != IB_SUCCESS)
5767 /* Subscribe over existing subscription */
5768 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfo "
5769 "Sending a Good - Set Subscribe (again) request\n");
5770 inform_info_opt.qpn = 0;
5771 memset(&context, 0, sizeof(context));
5772 status = osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO,
5773 IB_MAD_METHOD_SET, &inform_info_opt,
5775 if (status != IB_SUCCESS)
5778 /* More InformInfoRecord tests */
5779 /* RID lookup (with currently invalid enum) */
5780 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfoRecord "
5781 "Sending a Good - GetTable by GID\n");
5782 ib_gid_set_default(&inform_info_rec_opt.subscriber_gid,
5783 p_osmt->local_port.port_guid);
5784 inform_info_rec_opt.subscriber_enum = 1;
5785 memset(&context, 0, sizeof(context));
5787 osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO_RECORD,
5788 IB_MAD_METHOD_GETTABLE,
5789 &inform_info_rec_opt, &context);
5790 if (status != IB_SUCCESS)
5794 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfoRecord "
5795 "Sending a Good - GetTable (subscriber_enum == 0) request\n");
5796 inform_info_rec_opt.subscriber_enum = 0;
5797 memset(&context, 0, sizeof(context));
5799 osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO_RECORD,
5800 IB_MAD_METHOD_GETTABLE,
5801 &inform_info_rec_opt, &context);
5802 if (status != IB_SUCCESS)
5805 /* Get all InformInfoRecords */
5806 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfoRecord "
5807 "Sending a Good - GetTable (ALL records) request\n");
5808 memset(&inform_info_rec_opt, 0, sizeof(inform_info_rec_opt));
5809 memset(&context, 0, sizeof(context));
5811 osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO_RECORD,
5812 IB_MAD_METHOD_GETTABLE,
5813 &inform_info_rec_opt, &context);
5814 if (status != IB_SUCCESS)
5817 /* Another subscription */
5818 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfo "
5819 "Sending another Good - Set Subscribe (again) request\n");
5820 inform_info_opt.qpn = 0;
5821 inform_info_opt.trap = 0x1234;
5822 memset(&context, 0, sizeof(context));
5823 status = osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO,
5824 IB_MAD_METHOD_SET, &inform_info_opt,
5826 if (status != IB_SUCCESS)
5829 /* Get all InformInfoRecords again */
5830 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfoRecord "
5831 "Sending a Good - GetTable (ALL records) request\n");
5832 memset(&inform_info_rec_opt, 0, sizeof(inform_info_rec_opt));
5833 memset(&context, 0, sizeof(context));
5835 osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO_RECORD,
5836 IB_MAD_METHOD_GETTABLE,
5837 &inform_info_rec_opt, &context);
5838 if (status != IB_SUCCESS)
5841 /* Cleanup subscriptions before further testing */
5842 /* Does order of deletion matter ? Test this !!! */
5843 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfo "
5844 "Sending a Good - Set (cleanup) request\n");
5845 inform_info_opt.subscribe = FALSE;
5846 inform_info_opt.qpn = 1;
5847 memset(&context, 0, sizeof(context));
5848 status = osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO,
5850 &inform_info_opt, &context);
5851 if (status != IB_SUCCESS)
5854 /* Get all InformInfoRecords again */
5855 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfoRecord "
5856 "Sending a Good - GetTable (ALL records) request\n");
5857 memset(&inform_info_rec_opt, 0, sizeof(inform_info_rec_opt));
5858 memset(&context, 0, sizeof(context));
5860 osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO_RECORD,
5861 IB_MAD_METHOD_GETTABLE,
5862 &inform_info_rec_opt, &context);
5863 if (status != IB_SUCCESS)
5866 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfo"
5867 "Sending a Good - Set (cleanup) request\n");
5868 inform_info_opt.subscribe = FALSE;
5869 inform_info_opt.qpn = 1;
5870 inform_info_opt.trap = 0;
5871 memset(&context, 0, sizeof(context));
5872 status = osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO,
5874 &inform_info_opt, &context);
5875 if (status != IB_SUCCESS)
5878 /* Get all InformInfoRecords a final time */
5879 OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfoRecord "
5880 "Sending a Good - GetTable (ALL records) request\n");
5881 memset(&inform_info_rec_opt, 0, sizeof(inform_info_rec_opt));
5882 memset(&context, 0, sizeof(context));
5884 osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO_RECORD,
5885 IB_MAD_METHOD_GETTABLE,
5886 &inform_info_rec_opt, &context);
5887 if (status != IB_SUCCESS)
5891 test_lid = cl_ntoh16(p_osmt->local_port.lid + 1);
5893 /* Another GUIDInfo Record test */
5894 memset(&context, 0, sizeof(context));
5896 osmtest_get_guidinfo_rec_by_lid(p_osmt, test_lid, &context);
5897 if (status != IB_SUCCESS)
5900 /* Another PKeyTable Record test */
5901 memset(&context, 0, sizeof(context));
5903 osmtest_get_pkeytbl_rec_by_lid(p_osmt, test_lid, sm_key,
5905 if (status != IB_SUCCESS)
5908 /* Another SwitchInfo Record test */
5909 memset(&context, 0, sizeof(context));
5911 osmtest_get_sw_info_rec_by_lid(p_osmt, test_lid, &context);
5912 if (status != IB_SUCCESS)
5915 /* Another LFT Record test */
5916 memset(&context, 0, sizeof(context));
5917 status = osmtest_get_lft_rec_by_lid(p_osmt, test_lid, &context);
5918 if (status != IB_SUCCESS)
5921 /* Another MFT Record test */
5922 memset(&context, 0, sizeof(context));
5923 status = osmtest_get_mft_rec_by_lid(p_osmt, test_lid, &context);
5924 if (status != IB_SUCCESS)
5927 /* More LinkRecord tests */
5929 memset(&context, 0, sizeof(context));
5931 osmtest_get_link_rec_by_lid(p_osmt, test_lid, 0, &context);
5932 if (status != IB_SUCCESS)
5936 memset(&context, 0, sizeof(context));
5938 osmtest_get_link_rec_by_lid(p_osmt, 0, test_lid, &context);
5939 if (status != IB_SUCCESS)
5942 /* Another NodeRecord test */
5943 memset(&context, 0, sizeof(context));
5945 osmtest_get_node_rec_by_lid(p_osmt, test_lid, &context);
5946 if (status != IB_SUCCESS)
5951 if (!p_osmt->opt.ignore_path_records) {
5952 status = osmtest_validate_all_path_recs(p_osmt);
5953 if (status != IB_SUCCESS)
5957 memset(&context, 0, sizeof(context));
5959 osmtest_get_path_rec_by_lid_pair(p_osmt, test_lid,
5962 if (status != IB_SUCCESS)
5965 memset(&context, 0, sizeof(context));
5966 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
5967 EXPECTING_ERRORS_START "\n");
5969 osmtest_get_path_rec_by_lid_pair(p_osmt, 0xffff,
5971 if (status != IB_SUCCESS) {
5972 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
5974 ib_get_err_str(status));
5976 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
5977 EXPECTING_ERRORS_END "\n");
5979 if (status == IB_SUCCESS) {
5984 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
5985 EXPECTING_ERRORS_START "\n");
5988 osmtest_get_path_rec_by_lid_pair(p_osmt, test_lid,
5990 if (status != IB_SUCCESS) {
5991 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
5993 ib_get_err_str(status));
5995 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
5996 EXPECTING_ERRORS_END "\n");
5998 if (status == IB_SUCCESS) {
6006 status = osmtest_validate_single_port_recs(p_osmt);
6007 if (status != IB_SUCCESS)
6010 if (!p_osmt->opt.ignore_path_records) {
6011 status = osmtest_validate_single_path_recs(p_osmt);
6012 if (status != IB_SUCCESS)
6017 OSM_LOG_EXIT(&p_osmt->log);
6021 /**********************************************************************
6022 **********************************************************************/
6023 static const osmtest_token_t *str_get_token(IN char *const p_str)
6025 const osmtest_token_t *p_tok;
6028 p_tok = &token_array[index];
6030 while (p_tok->val != OSMTEST_TOKEN_UNKNOWN) {
6031 if (strnicmp(p_str, p_tok->str, p_tok->str_size) == 0)
6034 p_tok = &token_array[++index];
6040 /**********************************************************************
6041 Returns true if not whitespace character encountered before EOL.
6042 **********************************************************************/
6044 str_skip_white(IN char line[], IN OUT uint32_t * const p_offset)
6046 while (((line[*p_offset] == '\t') ||
6047 (line[*p_offset] == ' ')) &&
6048 (line[*p_offset] != '\n') && (line[*p_offset] != '\0')) {
6052 if ((line[*p_offset] == '\n') || (line[*p_offset] == '\0'))
6058 /**********************************************************************
6059 Returns true if not whitespace character encountered before EOL.
6060 **********************************************************************/
6061 static void str_skip_token(IN char line[], IN OUT uint32_t * const p_offset)
6063 while ((line[*p_offset] != '\t') &&
6064 (line[*p_offset] != ' ') && (line[*p_offset] != '\0')) {
6069 /**********************************************************************
6070 **********************************************************************/
6071 static ib_api_status_t
6072 osmtest_parse_node(IN osmtest_t * const p_osmt,
6073 IN FILE * const fh, IN OUT uint32_t * const p_line_num)
6075 ib_api_status_t status = IB_SUCCESS;
6077 char line[OSMTEST_MAX_LINE_LEN];
6078 boolean_t done = FALSE;
6080 node_t *p_guid_node;
6081 const osmtest_token_t *p_tok;
6083 OSM_LOG_ENTER(&p_osmt->log);
6085 p_node = node_new();
6086 CL_ASSERT(p_node != NULL);
6089 * Parse the inventory file and create the database.
6092 if (fgets(line, OSMTEST_MAX_LINE_LEN, fh) == NULL) {
6094 * End of file in the middle of a definition.
6096 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0119: "
6097 "Unexpected end of file\n");
6108 if (!str_skip_white(line, &offset))
6109 continue; /* whole line was whitespace */
6111 p_tok = str_get_token(&line[offset]);
6112 if (p_tok == NULL) {
6113 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0120: "
6114 "Ignoring line %u with unknown token: %s\n",
6115 *p_line_num, &line[offset]);
6119 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6120 "Found '%s' (line %u)\n", p_tok->str, *p_line_num);
6122 str_skip_token(line, &offset);
6124 switch (p_tok->val) {
6125 case OSMTEST_TOKEN_COMMENT:
6128 case OSMTEST_TOKEN_LID:
6129 p_node->comp.lid = 0xFFFF;
6131 cl_hton16((uint16_t)
6132 strtoul(&line[offset], NULL, 0));
6133 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "lid = 0x%X\n",
6134 cl_ntoh16(p_node->rec.lid));
6137 case OSMTEST_TOKEN_BASE_VERSION:
6138 p_node->comp.node_info.base_version = 0xFF;
6139 p_node->rec.node_info.base_version =
6140 (uint8_t) strtoul(&line[offset], NULL, 0);
6141 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6142 "base_version = 0x%X\n",
6143 p_node->rec.node_info.base_version);
6146 case OSMTEST_TOKEN_CLASS_VERSION:
6147 p_node->comp.node_info.class_version = 0xFF;
6148 p_node->rec.node_info.class_version =
6149 (uint8_t) strtoul(&line[offset], NULL, 0);
6150 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6151 "class_version = 0x%X\n",
6152 p_node->rec.node_info.class_version);
6155 case OSMTEST_TOKEN_NODE_TYPE:
6156 p_node->comp.node_info.node_type = 0xFF;
6157 p_node->rec.node_info.node_type =
6158 (uint8_t) strtoul(&line[offset], NULL, 0);
6159 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6160 "node_type = 0x%X\n",
6161 p_node->rec.node_info.node_type);
6164 case OSMTEST_TOKEN_NUM_PORTS:
6165 p_node->comp.node_info.num_ports = 0xFF;
6166 p_node->rec.node_info.num_ports =
6167 (uint8_t) strtoul(&line[offset], NULL, 0);
6168 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6169 "num_ports = 0x%X\n",
6170 p_node->rec.node_info.num_ports);
6173 case OSMTEST_TOKEN_SYS_GUID:
6174 p_node->comp.node_info.sys_guid = 0xFFFFFFFFFFFFFFFFULL;
6175 p_node->rec.node_info.sys_guid =
6176 cl_hton64(strtoull(&line[offset], NULL, 0));
6177 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6178 "sys_guid = 0x%016" PRIx64 "\n",
6179 cl_ntoh64(p_node->rec.node_info.sys_guid));
6182 case OSMTEST_TOKEN_NODE_GUID:
6183 p_node->comp.node_info.node_guid =
6184 0xFFFFFFFFFFFFFFFFULL;
6185 p_node->rec.node_info.node_guid =
6186 cl_hton64(strtoull(&line[offset], NULL, 0));
6187 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6188 "node_guid = 0x%016" PRIx64 "\n",
6189 cl_ntoh64(p_node->rec.node_info.node_guid));
6192 case OSMTEST_TOKEN_PORT_GUID:
6193 p_node->comp.node_info.port_guid =
6194 0xFFFFFFFFFFFFFFFFULL;
6195 p_node->rec.node_info.port_guid =
6196 cl_hton64(strtoull(&line[offset], NULL, 0));
6197 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6198 "port_guid = 0x%016" PRIx64 "\n",
6199 cl_ntoh64(p_node->rec.node_info.port_guid));
6202 case OSMTEST_TOKEN_PARTITION_CAP:
6203 p_node->comp.node_info.partition_cap = 0xFFFF;
6204 p_node->rec.node_info.partition_cap =
6205 cl_hton16((uint16_t)
6206 strtoul(&line[offset], NULL, 0));
6207 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6208 "partition_cap = 0x%X\n",
6209 cl_ntoh16(p_node->rec.node_info.partition_cap));
6212 case OSMTEST_TOKEN_DEVICE_ID:
6213 p_node->comp.node_info.device_id = 0xFFFF;
6214 p_node->rec.node_info.device_id = cl_hton16((uint16_t)
6219 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6220 "device_id = 0x%X\n",
6221 cl_ntoh16(p_node->rec.node_info.device_id));
6224 case OSMTEST_TOKEN_REVISION:
6225 p_node->comp.node_info.revision = 0xFFFFFFFF;
6226 p_node->rec.node_info.revision =
6227 cl_hton32(strtoul(&line[offset], NULL, 0));
6228 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6229 "revision = 0x%X\n",
6230 cl_ntoh32(p_node->rec.node_info.revision));
6233 case OSMTEST_TOKEN_PORT_NUM:
6234 p_node->comp.node_info.port_num_vendor_id |=
6235 IB_NODE_INFO_PORT_NUM_MASK;
6236 p_node->rec.node_info.port_num_vendor_id |=
6237 (uint8_t) strtoul(&line[offset], NULL, 0);
6238 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6239 "local_port_num = 0x%X\n",
6240 ib_node_info_get_local_port_num
6241 (&p_node->rec.node_info));
6244 case OSMTEST_TOKEN_VENDOR_ID:
6245 p_node->comp.node_info.port_num_vendor_id |=
6246 IB_NODE_INFO_VEND_ID_MASK;
6247 p_node->rec.node_info.port_num_vendor_id |=
6248 cl_hton32(strtoul(&line[offset], NULL, 0));
6249 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6250 "vendor_id = 0x%X\n",
6251 cl_ntoh32(ib_node_info_get_vendor_id
6252 (&p_node->rec.node_info)));
6255 case OSMTEST_TOKEN_END:
6260 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0121: "
6261 "Ignoring line %u with unknown token: %s\n",
6262 *p_line_num, &line[offset]);
6269 * Make sure the user specified enough information, then
6270 * add this object to the database.
6272 if (p_node->comp.lid == 0) {
6273 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0122: "
6274 "LID must be specified for defined nodes\n");
6275 node_delete(p_node);
6279 cl_qmap_insert(&p_osmt->exp_subn.node_lid_tbl,
6280 p_node->rec.lid, &p_node->map_item);
6282 p_guid_node = node_new();
6283 CL_ASSERT(p_node != NULL);
6285 *p_guid_node = *p_node;
6287 cl_qmap_insert(&p_osmt->exp_subn.node_guid_tbl,
6288 p_guid_node->rec.node_info.node_guid,
6289 &p_guid_node->map_item);
6292 OSM_LOG_EXIT(&p_osmt->log);
6296 /**********************************************************************
6297 **********************************************************************/
6298 static ib_api_status_t
6299 osmtest_parse_port(IN osmtest_t * const p_osmt,
6300 IN FILE * const fh, IN OUT uint32_t * const p_line_num)
6302 ib_api_status_t status = IB_SUCCESS;
6304 char line[OSMTEST_MAX_LINE_LEN];
6305 boolean_t done = FALSE;
6307 const osmtest_token_t *p_tok;
6309 OSM_LOG_ENTER(&p_osmt->log);
6311 p_port = port_new();
6312 CL_ASSERT(p_port != NULL);
6315 * Parse the inventory file and create the database.
6318 if (fgets(line, OSMTEST_MAX_LINE_LEN, fh) == NULL) {
6320 * End of file in the middle of a definition.
6322 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0123: "
6323 "Unexpected end of file\n");
6334 if (!str_skip_white(line, &offset))
6335 continue; /* whole line was whitespace */
6337 p_tok = str_get_token(&line[offset]);
6338 if (p_tok == NULL) {
6339 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0124: "
6340 "Ignoring line %u with unknown token: %s\n",
6341 *p_line_num, &line[offset]);
6345 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6346 "Found '%s' (line %u)\n", p_tok->str, *p_line_num);
6348 str_skip_token(line, &offset);
6350 switch (p_tok->val) {
6351 case OSMTEST_TOKEN_COMMENT:
6354 case OSMTEST_TOKEN_LID:
6355 p_port->comp.lid = 0xFFFF;
6357 cl_hton16((uint16_t)
6358 strtoul(&line[offset], NULL, 0));
6359 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "lid = 0x%X\n",
6360 cl_ntoh16(p_port->rec.lid));
6363 case OSMTEST_TOKEN_PORT_NUM:
6364 p_port->comp.port_num = 0xFF;
6365 p_port->rec.port_num =
6366 (uint8_t) strtoul(&line[offset], NULL, 0);
6367 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6368 "port_num = 0x%u\n", p_port->rec.port_num);
6371 case OSMTEST_TOKEN_MKEY:
6372 p_port->comp.port_info.m_key = 0xFFFFFFFFFFFFFFFFULL;
6373 p_port->rec.port_info.m_key =
6374 cl_hton64(strtoull(&line[offset], NULL, 0));
6375 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6376 "m_key = 0x%016" PRIx64 "\n",
6377 cl_ntoh64(p_port->rec.port_info.m_key));
6380 case OSMTEST_TOKEN_SUBN_PREF:
6381 p_port->comp.port_info.subnet_prefix =
6382 0xFFFFFFFFFFFFFFFFULL;
6383 p_port->rec.port_info.subnet_prefix =
6384 cl_hton64(strtoull(&line[offset], NULL, 0));
6385 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6386 "subnet_prefix = 0x%016" PRIx64 "\n",
6387 cl_ntoh64(p_port->rec.port_info.subnet_prefix));
6390 case OSMTEST_TOKEN_BASE_LID:
6391 p_port->comp.port_info.base_lid = 0xFFFF;
6392 p_port->rec.port_info.base_lid =
6393 cl_hton16((uint16_t)
6394 strtoul(&line[offset], NULL, 0));
6395 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6396 "base_lid = 0x%X\n",
6397 cl_ntoh16(p_port->rec.port_info.base_lid));
6400 case OSMTEST_TOKEN_SM_BASE_LID:
6401 p_port->comp.port_info.master_sm_base_lid = 0xFFFF;
6402 p_port->rec.port_info.master_sm_base_lid =
6403 cl_hton16((uint16_t)
6404 strtoul(&line[offset], NULL, 0));
6405 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6406 "master_sm_base_lid = 0x%X\n",
6407 cl_ntoh16(p_port->rec.port_info.master_sm_base_lid));
6410 case OSMTEST_TOKEN_CAP_MASK:
6411 p_port->comp.port_info.capability_mask = 0xFFFFFFFF;
6412 p_port->rec.port_info.capability_mask =
6413 cl_hton32((uint32_t)
6414 strtoul(&line[offset], NULL, 0));
6415 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6416 "capability_mask = 0x%X\n",
6417 cl_ntoh32(p_port->rec.port_info.capability_mask));
6420 case OSMTEST_TOKEN_DIAG_CODE:
6421 p_port->comp.port_info.diag_code = 0xFFFF;
6422 p_port->rec.port_info.diag_code =
6423 cl_hton16((uint16_t)
6424 strtoul(&line[offset], NULL, 0));
6425 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6426 "diag_code = 0x%X\n",
6427 cl_ntoh16(p_port->rec.port_info.diag_code));
6430 case OSMTEST_TOKEN_MKEY_LEASE_PER:
6431 p_port->comp.port_info.m_key_lease_period = 0xFFFF;
6432 p_port->rec.port_info.m_key_lease_period =
6433 cl_hton16((uint16_t)
6434 strtoul(&line[offset], NULL, 0));
6435 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6436 "m_key_lease_period = 0x%X\n",
6437 cl_ntoh16(p_port->rec.port_info.m_key_lease_period));
6440 case OSMTEST_TOKEN_LOC_PORT_NUM:
6441 p_port->comp.port_info.local_port_num = 0xFF;
6442 p_port->rec.port_info.local_port_num =
6443 (uint8_t) strtoul(&line[offset], NULL, 0);
6444 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6445 "local_port_num = 0x%u\n",
6446 p_port->rec.port_info.local_port_num);
6449 case OSMTEST_TOKEN_LINK_WID_EN:
6450 p_port->comp.port_info.link_width_enabled = 0xFF;
6451 p_port->rec.port_info.link_width_enabled =
6452 (uint8_t) strtoul(&line[offset], NULL, 0);
6453 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6454 "link_width_enabled = 0x%u\n",
6455 p_port->rec.port_info.link_width_enabled);
6458 case OSMTEST_TOKEN_LINK_WID_SUP:
6459 p_port->comp.port_info.link_width_supported = 0xFF;
6460 p_port->rec.port_info.link_width_supported =
6461 (uint8_t) strtoul(&line[offset], NULL, 0);
6462 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6463 "link_width_supported = 0x%u\n",
6464 p_port->rec.port_info.link_width_supported);
6467 case OSMTEST_TOKEN_LINK_WID_ACT:
6468 p_port->comp.port_info.link_width_active = 0xFF;
6469 p_port->rec.port_info.link_width_active =
6470 (uint8_t) strtoul(&line[offset], NULL, 0);
6471 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6472 "link_width_active = 0x%u\n",
6473 p_port->rec.port_info.link_width_active);
6476 case OSMTEST_TOKEN_LINK_SPEED_SUP:
6477 p_port->comp.port_info.state_info1 = 0xFF;
6478 ib_port_info_set_link_speed_sup((uint8_t)
6479 strtoul(&line[offset],
6481 &p_port->rec.port_info);
6482 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6483 "link_speed_supported = 0x%u\n",
6484 ib_port_info_get_link_speed_sup(&p_port->rec.port_info));
6487 case OSMTEST_TOKEN_PORT_STATE:
6488 str_skip_white(line, &offset);
6489 p_port->comp.port_info.state_info1 = 0xFF;
6490 ib_port_info_set_port_state(&p_port->rec.port_info,
6491 ib_get_port_state_from_str
6493 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6494 "port_state = 0x%u\n",
6495 ib_port_info_get_port_state(&p_port->rec.port_info));
6498 case OSMTEST_TOKEN_STATE_INFO2:
6499 p_port->comp.port_info.state_info2 = 0xFF;
6500 p_port->rec.port_info.state_info2 =
6501 (uint8_t) strtoul(&line[offset], NULL, 0);
6502 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6503 "state_info2 = 0x%u\n",
6504 p_port->rec.port_info.state_info2);
6507 case OSMTEST_TOKEN_MKEY_PROT_BITS:
6508 p_port->comp.port_info.mkey_lmc = 0xFF;
6509 ib_port_info_set_mpb(&p_port->rec.port_info,
6510 (uint8_t) strtoul(&line[offset],
6512 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "mpb = 0x%u\n",
6513 ib_port_info_get_mpb(&p_port->rec.port_info));
6516 case OSMTEST_TOKEN_LMC:
6517 p_port->comp.port_info.mkey_lmc = 0xFF;
6518 ib_port_info_set_lmc(&p_port->rec.port_info,
6519 (uint8_t) strtoul(&line[offset],
6521 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "lmc = 0x%u\n",
6522 ib_port_info_get_lmc(&p_port->rec.port_info));
6525 case OSMTEST_TOKEN_LINK_SPEED:
6526 p_port->comp.port_info.link_speed = 0xFF;
6527 p_port->rec.port_info.link_speed =
6528 (uint8_t) strtoul(&line[offset], NULL, 0);
6529 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6530 "link_speed = 0x%u\n",
6531 p_port->rec.port_info.link_speed);
6534 case OSMTEST_TOKEN_MTU_SMSL:
6535 p_port->comp.port_info.mtu_smsl = 0xFF;
6536 p_port->rec.port_info.mtu_smsl =
6537 (uint8_t) strtoul(&line[offset], NULL, 0);
6538 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6539 "mtu_smsl = 0x%u\n",
6540 p_port->rec.port_info.mtu_smsl);
6543 case OSMTEST_TOKEN_VL_CAP:
6544 p_port->comp.port_info.vl_cap = 0xFF;
6545 p_port->rec.port_info.vl_cap =
6546 (uint8_t) strtoul(&line[offset], NULL, 0);
6547 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "vl_cap = 0x%u\n",
6548 p_port->rec.port_info.vl_cap);
6551 case OSMTEST_TOKEN_VL_HIGH_LIMIT:
6552 p_port->comp.port_info.vl_high_limit = 0xFF;
6553 p_port->rec.port_info.vl_high_limit =
6554 (uint8_t) strtoul(&line[offset], NULL, 0);
6555 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6556 "vl_high_limit = 0x%u\n",
6557 p_port->rec.port_info.vl_high_limit);
6560 case OSMTEST_TOKEN_VL_ARB_HIGH_CAP:
6561 p_port->comp.port_info.vl_arb_high_cap = 0xFF;
6562 p_port->rec.port_info.vl_arb_high_cap =
6563 (uint8_t) strtoul(&line[offset], NULL, 0);
6564 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6565 "vl_arb_high_cap = 0x%u\n",
6566 p_port->rec.port_info.vl_arb_high_cap);
6569 case OSMTEST_TOKEN_VL_ARB_LOW_CAP:
6570 p_port->comp.port_info.vl_arb_low_cap = 0xFF;
6571 p_port->rec.port_info.vl_arb_low_cap =
6572 (uint8_t) strtoul(&line[offset], NULL, 0);
6573 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6574 "vl_arb_low_cap = 0x%u\n",
6575 p_port->rec.port_info.vl_arb_low_cap);
6578 case OSMTEST_TOKEN_MTU_CAP:
6579 p_port->comp.port_info.mtu_cap = 0xFF;
6580 p_port->rec.port_info.mtu_cap =
6581 (uint8_t) strtoul(&line[offset], NULL, 0);
6582 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "mtu_cap = 0x%u\n",
6583 p_port->rec.port_info.mtu_cap);
6586 case OSMTEST_TOKEN_VL_STALL_LIFE:
6587 p_port->comp.port_info.vl_stall_life = 0xFF;
6588 p_port->rec.port_info.vl_stall_life =
6589 (uint8_t) strtoul(&line[offset], NULL, 0);
6590 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6591 "vl_stall_life = 0x%u\n",
6592 p_port->rec.port_info.vl_stall_life);
6595 case OSMTEST_TOKEN_VL_ENFORCE:
6596 p_port->comp.port_info.vl_enforce = 0xFF;
6597 p_port->rec.port_info.vl_enforce =
6598 (uint8_t) strtoul(&line[offset], NULL, 0);
6599 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6600 "vl_enforce = 0x%u\n",
6601 p_port->rec.port_info.vl_enforce);
6604 case OSMTEST_TOKEN_MKEY_VIOL:
6605 p_port->comp.port_info.m_key_violations = 0xFFFF;
6606 p_port->rec.port_info.m_key_violations =
6607 cl_hton16((uint16_t)
6608 strtoul(&line[offset], NULL, 0));
6609 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6610 "m_key_violations = 0x%X\n",
6611 cl_ntoh16(p_port->rec.port_info.m_key_violations));
6614 case OSMTEST_TOKEN_PKEY_VIOL:
6615 p_port->comp.port_info.p_key_violations = 0xFFFF;
6616 p_port->rec.port_info.p_key_violations =
6617 cl_hton16((uint16_t)
6618 strtoul(&line[offset], NULL, 0));
6619 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6620 "p_key_violations = 0x%X\n",
6621 cl_ntoh16(p_port->rec.port_info.p_key_violations));
6624 case OSMTEST_TOKEN_QKEY_VIOL:
6625 p_port->comp.port_info.q_key_violations = 0xFFFF;
6626 p_port->rec.port_info.q_key_violations =
6627 cl_hton16((uint16_t)
6628 strtoul(&line[offset], NULL, 0));
6629 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6630 "q_key_violations = 0x%X\n",
6631 cl_ntoh16(p_port->rec.port_info.q_key_violations));
6634 case OSMTEST_TOKEN_GUID_CAP:
6635 p_port->comp.port_info.guid_cap = 0xFF;
6636 p_port->rec.port_info.guid_cap =
6637 (uint8_t) strtoul(&line[offset], NULL, 0);
6638 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6639 "guid_cap = 0x%u\n",
6640 p_port->rec.port_info.guid_cap);
6643 case OSMTEST_TOKEN_SUBN_TIMEOUT:
6644 p_port->comp.port_info.subnet_timeout = 0x1F;
6645 p_port->rec.port_info.subnet_timeout =
6646 (uint8_t) strtoul(&line[offset], NULL, 0);
6647 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6648 "subnet_timeout = 0x%u\n",
6649 ib_port_info_get_timeout(&p_port->rec.port_info));
6652 case OSMTEST_TOKEN_RESP_TIME_VAL:
6653 p_port->comp.port_info.resp_time_value = 0xFF;
6654 p_port->rec.port_info.resp_time_value =
6655 (uint8_t) strtoul(&line[offset], NULL, 0);
6656 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6657 "resp_time_value = 0x%u\n",
6658 p_port->rec.port_info.resp_time_value);
6661 case OSMTEST_TOKEN_ERR_THRESHOLD:
6662 p_port->comp.port_info.error_threshold = 0xFF;
6663 p_port->rec.port_info.error_threshold =
6664 (uint8_t) strtoul(&line[offset], NULL, 0);
6665 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6666 "error_threshold = 0x%u\n",
6667 p_port->rec.port_info.error_threshold);
6670 case OSMTEST_TOKEN_END:
6675 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0125: "
6676 "Ignoring line %u with unknown token: %s\n",
6677 *p_line_num, &line[offset]);
6683 * Make sure the user specified enough information, then
6684 * add this object to the database.
6686 if (p_port->comp.lid == 0) {
6687 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0126: "
6688 "LID must be specified for defined ports\n");
6689 port_delete(p_port);
6694 cl_qmap_insert(&p_osmt->exp_subn.port_key_tbl,
6695 port_gen_id(p_port->rec.lid, p_port->rec.port_num),
6699 OSM_LOG_EXIT(&p_osmt->log);
6703 /**********************************************************************
6704 **********************************************************************/
6705 static ib_api_status_t
6706 osmtest_parse_path(IN osmtest_t * const p_osmt,
6707 IN FILE * const fh, IN OUT uint32_t * const p_line_num)
6709 ib_api_status_t status = IB_SUCCESS;
6711 char line[OSMTEST_MAX_LINE_LEN];
6712 boolean_t done = FALSE;
6714 const osmtest_token_t *p_tok;
6715 boolean_t got_error = FALSE;
6717 OSM_LOG_ENTER(&p_osmt->log);
6719 p_path = path_new();
6720 CL_ASSERT(p_path != NULL);
6723 * Parse the inventory file and create the database.
6726 if (fgets(line, OSMTEST_MAX_LINE_LEN, fh) == NULL) {
6728 * End of file in the middle of a definition.
6730 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0127: "
6731 "Unexpected end of file\n");
6742 if (!str_skip_white(line, &offset))
6743 continue; /* whole line was whitespace */
6745 p_tok = str_get_token(&line[offset]);
6746 if (p_tok == NULL) {
6747 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0128: "
6748 "Ignoring line %u with unknown token: %s\n",
6749 *p_line_num, &line[offset]);
6754 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6755 "Found '%s' (line %u)\n", p_tok->str, *p_line_num);
6757 str_skip_token(line, &offset);
6759 switch (p_tok->val) {
6760 case OSMTEST_TOKEN_COMMENT:
6763 case OSMTEST_TOKEN_DGID:
6764 p_path->comp.dgid.unicast.prefix =
6765 0xFFFFFFFFFFFFFFFFULL;
6766 p_path->comp.dgid.unicast.interface_id =
6767 0xFFFFFFFFFFFFFFFFULL;
6769 str_skip_white(line, &offset);
6770 p_path->rec.dgid.unicast.prefix =
6771 cl_hton64(strtoull(&line[offset], NULL, 0));
6772 str_skip_token(line, &offset);
6773 p_path->rec.dgid.unicast.interface_id =
6774 cl_hton64(strtoull(&line[offset], NULL, 0));
6776 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6777 "dgid = 0x%016" PRIx64 " 0x%016" PRIx64 "\n",
6778 cl_ntoh64(p_path->rec.dgid.unicast.prefix),
6779 cl_ntoh64(p_path->rec.dgid.unicast.interface_id));
6782 case OSMTEST_TOKEN_SGID:
6783 p_path->comp.sgid.unicast.prefix =
6784 0xFFFFFFFFFFFFFFFFULL;
6785 p_path->comp.sgid.unicast.interface_id =
6786 0xFFFFFFFFFFFFFFFFULL;
6788 str_skip_white(line, &offset);
6789 p_path->rec.sgid.unicast.prefix =
6790 cl_hton64(strtoull(&line[offset], NULL, 0));
6791 str_skip_token(line, &offset);
6792 p_path->rec.sgid.unicast.interface_id =
6793 cl_hton64(strtoull(&line[offset], NULL, 0));
6795 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6796 "sgid = 0x%016" PRIx64 " 0x%016" PRIx64 "\n",
6797 cl_ntoh64(p_path->rec.sgid.unicast.prefix),
6798 cl_ntoh64(p_path->rec.sgid.unicast.interface_id));
6801 case OSMTEST_TOKEN_DLID:
6802 p_path->comp.dlid = 0xFFFF;
6804 cl_hton16((uint16_t)
6805 strtoul(&line[offset], NULL, 0));
6806 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "dlid = 0x%X\n",
6807 cl_ntoh16(p_path->rec.dlid));
6810 case OSMTEST_TOKEN_SLID:
6811 p_path->comp.slid = 0xFFFF;
6813 cl_hton16((uint16_t)
6814 strtoul(&line[offset], NULL, 0));
6815 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "slid = 0x%X\n",
6816 cl_ntoh16(p_path->rec.slid));
6819 case OSMTEST_TOKEN_PKEY:
6820 p_path->comp.pkey = 0xFFFF;
6822 cl_hton16((uint16_t)
6823 strtoul(&line[offset], NULL, 0));
6824 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "pkey = 0x%X\n",
6825 cl_ntoh16(p_path->rec.pkey));
6828 case OSMTEST_TOKEN_END:
6833 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0129: "
6834 "Ignoring line %u with unknown token: %s\n",
6835 *p_line_num, &line[offset]);
6846 * Make sure the user specified enough information, then
6847 * add this object to the database.
6849 if (osmtest_path_rec_kay_is_valid(p_osmt, p_path) == FALSE) {
6850 path_delete(p_path);
6855 cl_qmap_insert(&p_osmt->exp_subn.path_tbl,
6856 osmtest_path_rec_key_get(&p_path->rec),
6860 OSM_LOG_EXIT(&p_osmt->log);
6864 /**********************************************************************
6865 **********************************************************************/
6866 static ib_api_status_t
6867 osmtest_parse_link(IN osmtest_t * const p_osmt,
6868 IN FILE * const fh, IN OUT uint32_t * const p_line_num)
6870 ib_api_status_t status = IB_SUCCESS;
6872 char line[OSMTEST_MAX_LINE_LEN];
6873 boolean_t done = FALSE;
6874 const osmtest_token_t *p_tok;
6875 boolean_t got_error = FALSE;
6877 OSM_LOG_ENTER(&p_osmt->log);
6880 * Parse the inventory file and create the database.
6883 if (fgets(line, OSMTEST_MAX_LINE_LEN, fh) == NULL) {
6885 * End of file in the middle of a definition.
6887 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 012A: "
6888 "Unexpected end of file\n");
6899 if (!str_skip_white(line, &offset))
6900 continue; /* whole line was whitespace */
6902 p_tok = str_get_token(&line[offset]);
6903 if (p_tok == NULL) {
6904 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 012B: "
6905 "Ignoring line %u with unknown token: %s\n",
6906 *p_line_num, &line[offset]);
6911 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6912 "Found '%s' (line %u)\n", p_tok->str, *p_line_num);
6914 str_skip_token(line, &offset);
6916 switch (p_tok->val) {
6917 case OSMTEST_TOKEN_FROMLID:
6918 case OSMTEST_TOKEN_FROMPORTNUM:
6919 case OSMTEST_TOKEN_TOPORTNUM:
6920 case OSMTEST_TOKEN_TOLID:
6924 case OSMTEST_TOKEN_END:
6929 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 012C: "
6930 "Ignoring line %u with unknown token: %s\n",
6931 *p_line_num, &line[offset]);
6941 OSM_LOG_EXIT(&p_osmt->log);
6945 /**********************************************************************
6946 **********************************************************************/
6947 static ib_api_status_t osmtest_create_db(IN osmtest_t * const p_osmt)
6950 ib_api_status_t status = IB_SUCCESS;
6952 char line[OSMTEST_MAX_LINE_LEN];
6953 uint32_t line_num = 0;
6954 const osmtest_token_t *p_tok;
6955 boolean_t got_error = FALSE;
6957 OSM_LOG_ENTER(&p_osmt->log);
6959 fh = fopen(p_osmt->opt.file_name, "r");
6961 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0130: "
6962 "Unable to open inventory file (%s)\n",
6963 p_osmt->opt.file_name);
6969 * Parse the inventory file and create the database.
6971 while (fgets(line, OSMTEST_MAX_LINE_LEN, fh) != NULL) {
6978 if (!str_skip_white(line, &offset))
6979 continue; /* whole line was whitespace */
6981 p_tok = str_get_token(&line[offset]);
6982 if (p_tok == NULL) {
6983 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0131: "
6984 "Ignoring line %u: %s\n", line_num,
6990 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
6991 "Found '%s' (line %u)\n", p_tok->str, line_num);
6993 switch (p_tok->val) {
6994 case OSMTEST_TOKEN_COMMENT:
6997 case OSMTEST_TOKEN_DEFINE_NODE:
6998 status = osmtest_parse_node(p_osmt, fh, &line_num);
7001 case OSMTEST_TOKEN_DEFINE_PORT:
7002 status = osmtest_parse_port(p_osmt, fh, &line_num);
7005 case OSMTEST_TOKEN_DEFINE_PATH:
7006 status = osmtest_parse_path(p_osmt, fh, &line_num);
7009 case OSMTEST_TOKEN_DEFINE_LINK:
7010 status = osmtest_parse_link(p_osmt, fh, &line_num);
7014 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0132: "
7015 "Ignoring line %u: %s\n", line_num,
7024 if (status != IB_SUCCESS) {
7025 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0133: "
7026 "Bad status received during parsing (%s)\n",
7027 ib_get_err_str(status));
7036 OSM_LOG_EXIT(&p_osmt->log);
7040 /**********************************************************************
7041 Returns the index in the local port attribute array for the
7043 **********************************************************************/
7045 osmtest_get_user_port(IN osmtest_t * const p_osmt,
7046 IN const ib_port_attr_t p_attr_array[],
7047 IN uint32_t const num_ports)
7050 uint32_t choice = 0;
7051 boolean_t done_flag = FALSE;
7053 OSM_LOG_ENTER(&p_osmt->log);
7056 * User needs prompting for the local port GUID with which
7060 while (done_flag == FALSE) {
7061 printf("\nChoose a local port number with which to bind:\n\n");
7062 for (i = 0; i < num_ports; i++) {
7064 * Print the index + 1 since by convention, port numbers
7065 * start with 1 on host channel adapters.
7068 printf("\t%u: GUID = 0x%8" PRIx64
7069 ", lid = 0x%04X, state = %s\n", i + 1,
7070 cl_ntoh64(p_attr_array[i].port_guid),
7071 p_attr_array[i].lid,
7072 ib_get_port_state_str(p_attr_array[i].
7076 printf("\nEnter choice (1-%u): ", i);
7077 scanf("%u", &choice);
7078 if (choice > num_ports)
7079 printf("\nError: Lame choice!\n");
7085 OSM_LOG_EXIT(&p_osmt->log);
7086 return (choice - 1);
7089 /**********************************************************************
7090 **********************************************************************/
7092 osmtest_bind(IN osmtest_t * p_osmt,
7093 IN uint16_t max_lid, IN ib_net64_t guid OPTIONAL)
7095 uint32_t port_index;
7096 ib_api_status_t status;
7097 uint32_t num_ports = GUID_ARRAY_SIZE;
7098 ib_port_attr_t attr_array[GUID_ARRAY_SIZE];
7100 OSM_LOG_ENTER(&p_osmt->log);
7103 * Call the transport layer for a list of local port
7106 status = osm_vendor_get_all_port_attr(p_osmt->p_vendor,
7107 attr_array, &num_ports);
7108 if (status != IB_SUCCESS) {
7109 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0134: "
7110 "Failure getting local port attributes (%s)\n",
7111 ib_get_err_str(status));
7117 * User needs prompting for the local port GUID with which
7121 osmtest_get_user_port(p_osmt, attr_array, num_ports);
7123 if (num_ports == 0) {
7124 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0135: "
7125 "No local ports. Unable to proceed\n");
7128 guid = attr_array[port_index].port_guid;
7130 for (port_index = 0; port_index < num_ports; port_index++) {
7131 if (attr_array[port_index].port_guid == guid)
7135 if (port_index == num_ports) {
7136 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0136: "
7137 "No local port with guid 0x%016" PRIx64 "\n",
7139 status = IB_NOT_FOUND;
7145 * Copy the port info for the selected port.
7147 memcpy(&p_osmt->local_port, &attr_array[port_index],
7148 sizeof(p_osmt->local_port));
7150 /* bind to the SA */
7151 OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
7152 "Using port with SM LID:0x%04X\n", p_osmt->local_port.sm_lid);
7153 p_osmt->max_lid = max_lid;
7156 osmv_bind_sa(p_osmt->p_vendor, &p_osmt->mad_pool, guid);
7158 if (p_osmt->h_bind == OSM_BIND_INVALID_HANDLE) {
7159 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0137: "
7160 "Unable to bind to SA\n");
7166 OSM_LOG_EXIT(&p_osmt->log);
7170 /**********************************************************************
7171 **********************************************************************/
7172 ib_api_status_t osmtest_run(IN osmtest_t * const p_osmt)
7174 ib_api_status_t status = IB_SUCCESS;
7176 OSM_LOG_ENTER(&p_osmt->log);
7178 status = osmtest_validate_sa_class_port_info(p_osmt);
7179 if (status != IB_SUCCESS) {
7180 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0138: "
7181 "Could not obtain SA ClassPortInfo (%s)\n",
7182 ib_get_err_str(status));
7186 if (p_osmt->opt.flow == OSMT_FLOW_CREATE_INVENTORY) {
7188 * Creating an inventory file with all nodes, ports and paths
7190 status = osmtest_create_inventory_file(p_osmt);
7191 if (status != IB_SUCCESS) {
7192 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0139: "
7193 "Inventory file create failed (%s)\n",
7194 ib_get_err_str(status));
7198 if (p_osmt->opt.flow == OSMT_FLOW_STRESS_SA) {
7200 * Stress SA - flood the SA with queries
7202 switch (p_osmt->opt.stress) {
7204 case 1: /* small response SA query stress */
7205 status = osmtest_stress_small_rmpp(p_osmt);
7206 if (status != IB_SUCCESS) {
7207 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
7209 "Small RMPP stress test failed (%s)\n",
7210 ib_get_err_str(status));
7214 case 2: /* large response SA query stress */
7215 status = osmtest_stress_large_rmpp(p_osmt);
7216 if (status != IB_SUCCESS) {
7217 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
7219 "Large RMPP stress test failed (%s)\n",
7220 ib_get_err_str(status));
7224 case 3: /* large response Path Record SA query stress */
7225 status = osmtest_create_db(p_osmt);
7226 if (status != IB_SUCCESS) {
7227 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
7229 "Database creation failed (%s)\n",
7230 ib_get_err_str(status));
7234 status = osmtest_stress_large_rmpp_pr(p_osmt);
7235 if (status != IB_SUCCESS) {
7236 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
7238 "Large RMPP stress test failed (%s)\n",
7239 ib_get_err_str(status));
7244 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
7246 "Unknown stress test value %u\n",
7247 p_osmt->opt.stress);
7253 * Run normal validation tests.
7255 if (p_osmt->opt.flow == OSMT_FLOW_ALL ||
7256 p_osmt->opt.flow == OSMT_FLOW_VALIDATE_INVENTORY) {
7258 * Only validate the given inventory file
7260 status = osmtest_create_db(p_osmt);
7261 if (status != IB_SUCCESS) {
7262 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
7264 "Database creation failed (%s)\n",
7265 ib_get_err_str(status));
7269 status = osmtest_validate_against_db(p_osmt);
7270 if (status != IB_SUCCESS) {
7271 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
7273 "SA validation database failure (%s)\n",
7274 ib_get_err_str(status));
7279 if (p_osmt->opt.flow == OSMT_FLOW_ALL) {
7280 status = osmtest_wrong_sm_key_ignored(p_osmt);
7281 if (status != IB_SUCCESS) {
7282 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
7284 "Try wrong SM_Key failed (%s)\n",
7285 ib_get_err_str(status));
7290 if (p_osmt->opt.flow == OSMT_FLOW_ALL ||
7291 p_osmt->opt.flow == OSMT_FLOW_SERVICE_REGISTRATION)
7294 * run service registration, deregistration, and lease test
7296 status = osmt_run_service_records_flow(p_osmt);
7297 if (status != IB_SUCCESS) {
7298 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
7300 "Service Flow failed (%s)\n",
7301 ib_get_err_str(status));
7306 if (p_osmt->opt.flow == OSMT_FLOW_ALL ||
7307 p_osmt->opt.flow == OSMT_FLOW_EVENT_FORWARDING) {
7309 * Run event forwarding test
7311 #ifdef OSM_VENDOR_INTF_MTL
7312 status = osmt_run_inform_info_flow(p_osmt);
7314 if (status != IB_SUCCESS) {
7315 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
7317 "Inform Info Flow failed: (%s)\n",
7318 ib_get_err_str(status));
7322 OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
7323 "The event forwarding flow "
7324 "is not implemented yet!\n");
7325 status = IB_SUCCESS;
7330 if (p_osmt->opt.flow == OSMT_FLOW_QOS) {
7332 * QoS info: dump VLArb and SLtoVL tables.
7333 * Since it generates a huge file, we run it only
7334 * if explicitly required to
7336 status = osmtest_create_db(p_osmt);
7337 if (status != IB_SUCCESS) {
7338 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
7340 "Database creation failed (%s)\n",
7341 ib_get_err_str(status));
7346 osmt_run_slvl_and_vlarb_records_flow
7348 if (status != IB_SUCCESS) {
7349 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
7351 "Failed to get SLtoVL and VL Arbitration Tables (%s)\n",
7352 ib_get_err_str(status));
7357 if (p_osmt->opt.flow == OSMT_FLOW_TRAP) {
7359 * Run trap 64/65 flow (this flow requires running of external tool)
7361 #ifdef OSM_VENDOR_INTF_MTL
7362 status = osmt_run_trap64_65_flow(p_osmt);
7363 if (status != IB_SUCCESS) {
7364 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
7366 "Trap 64/65 Flow failed: (%s)\n",
7367 ib_get_err_str(status));
7371 OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
7372 "The event forwarding flow "
7373 "is not implemented yet!\n");
7374 status = IB_SUCCESS;
7379 if (p_osmt->opt.flow == OSMT_FLOW_ALL ||
7380 p_osmt->opt.flow == OSMT_FLOW_MULTICAST) {
7384 status = osmt_run_mcast_flow(p_osmt);
7385 if (status != IB_SUCCESS) {
7386 OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
7388 "Multicast Flow failed: (%s)\n",
7389 ib_get_err_str(status));
7394 OSM_LOG(&p_osmt->log, OSM_LOG_INFO,
7395 "\n\n***************** ALL TESTS PASS *****************\n\n");
7401 OSM_LOG_EXIT(&p_osmt->log);