Index: stable/9/contrib/ofed/management/opensm/osmtest/osmt_multicast.c =================================================================== --- stable/9/contrib/ofed/management/opensm/osmtest/osmt_multicast.c (revision 276976) +++ stable/9/contrib/ofed/management/opensm/osmtest/osmt_multicast.c (revision 276977) @@ -1,2707 +1,2708 @@ /* * Copyright (c) 2006-2008 Voltaire, Inc. All rights reserved. * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved. * Copyright (c) 1996-2003 Intel Corporation. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU * General Public License (GPL) Version 2, available from the file * COPYING in the main directory of this source tree, or the * OpenIB.org BSD license below: * * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following * conditions are met: * * - Redistributions of source code must retain the above * copyright notice, this list of conditions and the following * disclaimer. * * - Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials * provided with the distribution. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * */ /* * Abstract: * Implementation of Multicast Member testing flow.. * */ #ifndef __WIN__ #include #endif +#include #include #include #include #include #include #include #include #include "osmtest.h" /********************************************************************** **********************************************************************/ static void __osmt_print_all_multicast_records(IN osmtest_t * const p_osmt) { uint32_t i; ib_api_status_t status; osmv_query_req_t req; osmv_user_query_t user; osmtest_req_context_t context; ib_member_rec_t *mcast_record; memset(&context, 0, sizeof(context)); memset(&req, 0, sizeof(req)); memset(&user, 0, sizeof(user)); user.attr_id = IB_MAD_ATTR_MCMEMBER_RECORD; user.attr_offset = ib_get_attr_offset(sizeof(*mcast_record)); req.query_type = OSMV_QUERY_USER_DEFINED; req.timeout_ms = p_osmt->opt.transaction_timeout; req.retry_cnt = 1; req.flags = OSM_SA_FLAGS_SYNC; context.p_osmt = p_osmt; req.query_context = &context; req.pfn_query_cb = osmtest_query_res_cb; req.p_query_input = &user; /* UnTrusted (SMKey of 0) - get the multicast groups */ status = osmv_query_sa(p_osmt->h_bind, &req); if (status != IB_SUCCESS || context.result.status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02B5: " "Failed getting the multicast groups records - %s/%s\n", ib_get_err_str(status), ib_get_err_str(context.result.status)); return; } osm_log(&p_osmt->log, OSM_LOG_INFO, "\n |------------------------------------------|" "\n | Remaining Multicast Groups |" "\n |------------------------------------------|\n"); for (i = 0; i < context.result.result_cnt; i++) { mcast_record = osmv_get_query_mc_rec(context.result.p_result_madw, i); osm_dump_mc_record(&p_osmt->log, mcast_record, OSM_LOG_INFO); } /* Trusted - now get the multicast group members */ req.sm_key = OSM_DEFAULT_SM_KEY; status = osmv_query_sa(p_osmt->h_bind, &req); if (status != IB_SUCCESS || context.result.status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02B6: " "Failed getting the multicast group members records - %s/%s\n", ib_get_err_str(status), ib_get_err_str(context.result.status)); return; } osm_log(&p_osmt->log, OSM_LOG_INFO, "\n |--------------------------------------------------|" "\n | Remaining Multicast Group Members |" "\n |--------------------------------------------------|\n"); for (i = 0; i < context.result.result_cnt; i++) { mcast_record = osmv_get_query_mc_rec(context.result.p_result_madw, i); osm_dump_mc_record(&p_osmt->log, mcast_record, OSM_LOG_INFO); } } /********************************************************************** **********************************************************************/ static cl_status_t __match_mgids(IN const void *const p_object, IN void *context) { ib_gid_t *p_mgid_context = (ib_gid_t *) context; ib_gid_t *p_mgid_list_item = (ib_gid_t *) p_object; int32_t count; count = memcmp(p_mgid_context, p_mgid_list_item, sizeof(ib_gid_t)); if (count == 0) return CL_SUCCESS; else return CL_NOT_FOUND; } /********************************************************************** **********************************************************************/ ib_api_status_t osmt_query_mcast(IN osmtest_t * const p_osmt) { ib_api_status_t status = IB_SUCCESS; osmv_user_query_t user; osmv_query_req_t req; osmtest_req_context_t context; ib_member_rec_t *p_rec; uint32_t i, num_recs = 0; cl_list_t mgids_list; cl_list_t *p_mgids_list; cl_list_iterator_t p_mgids_res; cl_status_t cl_status; cl_map_item_t *p_item, *p_next_item; osmtest_mgrp_t *p_mgrp; OSM_LOG_ENTER(&p_osmt->log); /* * Do a blocking query for all Multicast Records in the subnet. * The result is returned in the result field of the caller's * context structure. * * The query structures are locals. */ memset(&req, 0, sizeof(req)); memset(&user, 0, sizeof(user)); context.p_osmt = p_osmt; user.attr_id = IB_MAD_ATTR_MCMEMBER_RECORD; user.attr_offset = ib_get_attr_offset(sizeof(ib_member_rec_t)); req.query_type = OSMV_QUERY_USER_DEFINED; req.timeout_ms = p_osmt->opt.transaction_timeout; req.retry_cnt = p_osmt->opt.retry_count; req.flags = OSM_SA_FLAGS_SYNC; req.query_context = &context; req.pfn_query_cb = osmtest_query_res_cb; req.p_query_input = &user; status = osmv_query_sa(p_osmt->h_bind, &req); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0203: " "ib_query failed (%s)\n", ib_get_err_str(status)); goto Exit; } status = context.result.status; if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0264: " "ib_query failed (%s)\n", ib_get_err_str(status)); if (status == IB_REMOTE_ERROR) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "Remote error = %s.\n", ib_get_mad_status_str(osm_madw_get_mad_ptr (context.result. p_result_madw))); } goto Exit; } /* ok we have got something */ /* First Delete the old MGID Table */ p_next_item = cl_qmap_head(&p_osmt->exp_subn.mgrp_mlid_tbl); while (p_next_item != cl_qmap_end(&p_osmt->exp_subn.mgrp_mlid_tbl)) { p_item = p_next_item; p_next_item = cl_qmap_next(p_item); cl_qmap_remove_item(&p_osmt->exp_subn.mgrp_mlid_tbl, p_item); free(p_item); } cl_list_construct(&mgids_list); cl_list_init(&mgids_list, num_recs); p_mgids_list = &mgids_list; num_recs = context.result.result_cnt; OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Received %u records\n", num_recs); for (i = 0; i < num_recs; i++) { p_rec = osmv_get_query_result(context.result.p_result_madw, i); p_mgids_res = cl_list_find_from_head(p_mgids_list, __match_mgids, &(p_rec->mgid)); /* If returns iterator other than end of list, same mgid exists already */ if (p_mgids_res != cl_list_end(p_mgids_list)) { char gid_str[INET6_ADDRSTRLEN]; OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0265: " "MCG MGIDs are the same - invalid MGID : %s\n", inet_ntop(AF_INET6, p_rec->mgid.raw, gid_str, sizeof gid_str)); status = IB_ERROR; goto Exit; } osm_dump_mc_record(&p_osmt->log, p_rec, OSM_LOG_VERBOSE); cl_status = cl_list_insert_head(p_mgids_list, &(p_rec->mgid)); if (cl_status) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0205: " "Could not add MGID to cl_list\n"); status = IB_ERROR; goto Exit; } p_mgrp = (osmtest_mgrp_t *) malloc(sizeof(*p_mgrp)); if (!p_mgrp) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0204: " "Could not allocate new MCG\n"); status = IB_ERROR; goto Exit; } memcpy(&p_mgrp->mcmember_rec, p_rec, sizeof(p_mgrp->mcmember_rec)); cl_qmap_insert(&p_osmt->exp_subn.mgrp_mlid_tbl, cl_ntoh16(p_rec->mlid), &p_mgrp->map_item); } Exit: if (context.result.p_result_madw != NULL) { osm_mad_pool_put(&p_osmt->mad_pool, context.result.p_result_madw); context.result.p_result_madw = NULL; } OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ /* given a multicast request send and wait for response. */ ib_api_status_t osmt_send_mcast_request(IN osmtest_t * const p_osmt, IN uint8_t is_set, IN ib_member_rec_t * p_mc_req, IN uint64_t comp_mask, OUT ib_sa_mad_t * p_res) { osmtest_req_context_t context; ib_api_status_t status = IB_SUCCESS; osmv_user_query_t user; osmv_query_req_t req; OSM_LOG_ENTER(&p_osmt->log); /* * Do a blocking query for this record in the subnet. * * The query structures are locals. */ memset(&req, 0, sizeof(req)); memset(&user, 0, sizeof(user)); memset(&context, 0, sizeof(context)); memset(p_res, 0, sizeof(ib_sa_mad_t)); context.p_osmt = p_osmt; user.p_attr = p_mc_req; user.comp_mask = comp_mask; if (is_set == 1) { req.query_type = OSMV_QUERY_UD_MULTICAST_SET; } else if (is_set == 0) { req.query_type = OSMV_QUERY_UD_MULTICAST_DELETE; } else if (is_set == 0xee) { OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Set USER DEFINED QUERY\n"); req.query_type = OSMV_QUERY_USER_DEFINED; user.method = IB_MAD_METHOD_GET; user.attr_id = IB_MAD_ATTR_MCMEMBER_RECORD; user.attr_offset = ib_get_attr_offset(sizeof(ib_member_rec_t)); } else if (is_set == 0xff) { OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Set USER DEFINED QUERY\n"); req.query_type = OSMV_QUERY_USER_DEFINED; user.method = IB_MAD_METHOD_SET; user.attr_id = IB_MAD_ATTR_MCMEMBER_RECORD; user.attr_offset = ib_get_attr_offset(sizeof(ib_member_rec_t)); } /* TODO : Check the validity of all user fields in order to use OSMV_QUERY_USER_DEFINED p_user_query = ( osmv_user_query_t * ) p_query_req->p_query_input; if (p_user_query->method) sa_mad_data.method = p_user_query->method; sa_mad_data.attr_offset = p_user_query->attr_offset; sa_mad_data.attr_id = p_user_query->attr_id; sa_mad_data.comp_mask = p_user_query->comp_mask; sa_mad_data.p_attr = p_user_query->p_attr; */ req.timeout_ms = p_osmt->opt.transaction_timeout; req.retry_cnt = p_osmt->opt.retry_count; req.flags = OSM_SA_FLAGS_SYNC; req.query_context = &context; req.pfn_query_cb = osmtest_query_res_cb; req.p_query_input = &user; status = osmv_query_sa(p_osmt->h_bind, &req); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0206: " "ib_query failed (%s)\n", ib_get_err_str(status)); goto Exit; } /* ok it worked */ memcpy(p_res, osm_madw_get_mad_ptr(context.result.p_result_madw), sizeof(ib_sa_mad_t)); status = context.result.status; if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0224: " "ib_query failed (%s)\n", ib_get_err_str(status)); if (status == IB_REMOTE_ERROR) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "Remote error = %s\n", ib_get_mad_status_str(osm_madw_get_mad_ptr (context.result. p_result_madw))); } } Exit: /* * Return the IB query MAD to the pool as necessary. */ if (context.result.p_result_madw != NULL) { osm_mad_pool_put(&p_osmt->mad_pool, context.result.p_result_madw); context.result.p_result_madw = NULL; } OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ void osmt_init_mc_query_rec(IN osmtest_t * const p_osmt, IN OUT ib_member_rec_t * p_mc_req) { /* use default values so we can change only what we want later */ memset(p_mc_req, 0, sizeof(ib_member_rec_t)); /* we leave the MGID to the user */ memcpy(&p_mc_req->port_gid.unicast.interface_id, &p_osmt->local_port.port_guid, sizeof(p_osmt->local_port.port_guid) ); /* use our own subnet prefix: */ p_mc_req->port_gid.unicast.prefix = CL_HTON64(0xFE80000000000000ULL); /* ib_net32_t qkey; */ /* ib_net16_t mlid; - we keep it zero for upper level to decide. */ /* uint8_t mtu; - keep it zero means - anything you have please. */ /* uint8_t tclass; can leave as zero for now (between subnets) */ /* ib_net16_t pkey; leave as zero */ p_mc_req->rate = IB_LINK_WIDTH_ACTIVE_4X; /* uint8_t pkt_life; zero means greater than zero ... */ /* ib_net32_t sl_flow_hop; keep it all zeros */ /* we want to use a link local scope: 0x02 */ p_mc_req->scope_state = ib_member_set_scope_state(0x02, 0); } /*********************************************************************** * UD Multicast testing flow: * o15.0.1.3: * - Request new MCG with not enough components in comp_mask : * ERR_INSUFFICIENT_COMPONENTS * o15.0.1.8: * - Request a join with irrelevant RATE and get a ERR_INVALID_REQ * o15.0.1.4: * - Create an MGID by asking for a join with MGID = 0 * providing P_Key, Q_Key, SL, FlowLabel, Tclass. * o15.0.1.5: * - Check the returned MGID is valid. (p 804) * o15.0.1.6: * - Create a new MCG with valid requested MGID. * - Try to create a new MCG with invalid MGID : get back ERR_REQ_INVALID * - Try again with MGID prefix = 0xA01B (maybe 0x1BA0 little or big ?) * - Try to create again the already created group: ERR_REQ_INVALID * o15.0.1.7 - implicitlly checked during the prev steps. * o15.0.1.9 * - Create MCG with Invalid JoinState.FullMember != 1 : get ERR_REQ_INVALID * o15.0.1.10 - can't check on a single client . * o15.0.1.11: * - Try to join into a MGID that exists with JoinState=SendOnlyMember - * see that it updates JoinState. What is the routing change? * - We can not check simple join since we have only one tester (for now) * o15.0.1.12: * - The last join should have a special treatment in the SA (sender only) * but what is it ? * o15.0.1.13: * - Try joining with wrong rate - ERR_REQ_INVALID * o15.0.1.14: * - Try partial delete - actually updating the join state. check it. * - Register by InformInfo flow to receive trap 67 on MCG delete. * - Try full delete (JoinState and should be 0) * - Wait for trap 67. * - Try joining (not full mem) again to see the group was deleted. * (should fail - o15.0.1.13) * o15.0.1.15: * - Try deletion of the IPoIB MCG and get: ERR_REQ_INVALID * o15.0.1.16: * - Try GetTable with PortGUID wildcarded and get back some groups. ***********************************************************************/ /* The following macro can be used only within the osmt_run_mcast_flow() function */ #define IS_IPOIB_MGID(p_mgid) \ ( !memcmp(&osm_ipoib_good_mgid, (p_mgid), sizeof(osm_ipoib_good_mgid)) || \ !memcmp(&osm_ts_ipoib_good_mgid, (p_mgid), sizeof(osm_ts_ipoib_good_mgid)) ) ib_api_status_t osmt_run_mcast_flow(IN osmtest_t * const p_osmt) { char gid_str[INET6_ADDRSTRLEN]; char gid_str2[INET6_ADDRSTRLEN]; ib_api_status_t status; ib_member_rec_t mc_req_rec; ib_member_rec_t *p_mc_res; ib_sa_mad_t res_sa_mad; uint64_t comp_mask = 0; ib_net64_t remote_port_guid = 0x0; cl_qmap_t *p_mgrp_mlid_tbl; osmtest_mgrp_t *p_mgrp; ib_gid_t special_mgid, tmp_mgid, proxy_mgid; ib_net16_t invalid_mlid = 0x0; ib_net16_t max_mlid = cl_hton16(0xFFFE), tmp_mlid; boolean_t ReachedMlidLimit = FALSE; int start_cnt = 0, cnt, middle_cnt = 0, end_cnt = 0; int start_ipoib_cnt = 0, end_ipoib_cnt = 0; int mcg_outside_test_cnt = 0, fail_to_delete_mcg = 0; osmtest_req_context_t context; ib_node_record_t *p_rec; uint32_t num_recs = 0, i; uint8_t mtu_phys = 0, rate_phys = 0; cl_map_t test_created_mlids; /* List of all mlids created in this test */ ib_member_rec_t *p_recvd_rec; boolean_t got_error = FALSE; static ib_gid_t good_mgid = { { 0xFF, 0x12, 0xA0, 0x1C, 0xFE, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12, 0x34, 0x56, 0x78} }; static ib_gid_t osm_ipoib_mgid = { { 0xff, /* multicast field */ 0x12, /* scope */ 0x40, 0x1b, /* IPv4 signature */ 0xff, 0xff, /* 16 bits of P_Key (to be filled in) */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 48 bits of zeros */ 0xff, 0xff, 0xff, 0xee, /* 32 bit IPv4 broadcast address */ }, }; static ib_gid_t osm_ts_ipoib_good_mgid = { { 0xff, /* multicast field */ 0x12, /* non-permanent bit,scope */ 0x40, 0x1b, /* IPv4 signature */ 0xff, 0xff, /* 16 bits of P_Key (to be filled in) */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 48 bits of zeros */ 0x00, 0x00, 0x00, 0x01, /* 32 bit IPv4 broadcast address */ }, }; static ib_gid_t osm_ipoib_good_mgid = { { 0xff, /* multicast field */ 0x12, /* non-permanent bit,scope */ 0x40, 0x1b, /* IPv4 signature */ 0xff, 0xff, /* 16 bits of P_Key (to be filled in) */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 48 bits of zeros */ 0xff, 0xff, 0xff, 0xff, /* 32 bit IPv4 broadcast address */ }, }; static ib_gid_t osm_link_local_mgid = { { 0xFF, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}, }; OSM_LOG_ENTER(&p_osmt->log); OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "GetTable of all current MCGs...\n"); status = osmt_query_mcast(p_osmt); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 2FF " "GetTable of all records has failed!\n"); goto Exit; } /* Initialize the test_created_mgrps map */ cl_map_construct(&test_created_mlids); cl_map_init(&test_created_mlids, 1000); p_mgrp_mlid_tbl = &p_osmt->exp_subn.mgrp_mlid_tbl; osmt_init_mc_query_rec(p_osmt, &mc_req_rec); p_mc_res = ib_sa_mad_get_payload_ptr(&res_sa_mad); /* Only when we are on single mode check flow - do the count comparison, otherwise skip */ if (p_osmt->opt.mmode == 1 || p_osmt->opt.mmode == 3) { start_cnt = cl_qmap_count(p_mgrp_mlid_tbl); OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "(start): " "Number of MC Records found in SA DB is %d\n", start_cnt); } /* This flow is being added due to bug discovered using SilverStorm stack - The bug was initializing MCast with MTU & RATE min values that do not match the subnet capability, even though that OpenSM reponds with the correct value it does not store it in the MCG. We want the check a join request to already existing group (ipoib) without using MTU or RATE then getting response from OpenSM with the correct values then join again with them and get IB_SUCCESS all the way */ /* First validate IPoIB exist in the SA DB */ p_mgrp = (osmtest_mgrp_t *) cl_qmap_head(p_mgrp_mlid_tbl); /* scan all available multicast groups in the DB and fill in the table */ while (p_mgrp != (osmtest_mgrp_t *) cl_qmap_end(p_mgrp_mlid_tbl)) { /* search for ipoib mgid */ if (IS_IPOIB_MGID(&p_mgrp->mcmember_rec.mgid)) { start_ipoib_cnt++; } else { OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Non-IPoIB MC Groups exist: mgid=%s\n", inet_ntop(AF_INET6, p_mgrp->mcmember_rec.mgid.raw, gid_str, sizeof gid_str)); mcg_outside_test_cnt++; } p_mgrp = (osmtest_mgrp_t *) cl_qmap_next(&p_mgrp->map_item); } OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Found %d non-IPoIB MC Groups\n", mcg_outside_test_cnt); if (start_ipoib_cnt) { /* o15-0.2.4 - Check a join request to already created MCG */ OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Found IPoIB MC Group, so we run SilverStorm Bug Flow...\n"); /* Try to join first like IPoIB of SilverStorm */ memcpy(&mc_req_rec.mgid, &osm_ipoib_good_mgid, sizeof(ib_gid_t)); /* Request Join */ ib_member_set_join_state(&mc_req_rec, IB_MC_REC_STATE_FULL_MEMBER); comp_mask = IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_JOIN_STATE; status = osmt_send_mcast_request(p_osmt, 0xff, /* User Defined query Set */ &mc_req_rec, comp_mask, &res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Joining an existing IPoIB multicast group\n"); OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Sent Join request with :\n\t\tport_gid=%s, mgid=%s\n" "\t\tjoin state= 0x%x, response is : %s\n", inet_ntop(AF_INET6, mc_req_rec.port_gid.raw, gid_str, sizeof gid_str), inet_ntop(AF_INET6, mc_req_rec.mgid.raw, gid_str2, sizeof gid_str2), (mc_req_rec.scope_state & 0x0F), ib_get_err_str(status)); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02B3: " "Failed joining existing IPoIB MCGroup - got %s\n", ib_get_err_str(status)); goto Exit; } /* Check MTU & Rate Value and resend with SA suggested values */ p_mc_res = ib_sa_mad_get_payload_ptr(&res_sa_mad); /* Prepare the mc_req_rec for the rest of the flow */ osmt_init_mc_query_rec(p_osmt, &mc_req_rec); /* We simulate the same situation as in SilverStorm - a response with the exact RATE & MTU as the SA responded with. Actually the query has included some more fields but we know that problem was genereated by the RATE */ OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Received attributes of MCG : \n\t\tMTU=0x%02X, RATE=0x%02X\n", p_mc_res->mtu, p_mc_res->rate); mc_req_rec.mtu = p_mc_res->mtu; mc_req_rec.rate = p_mc_res->rate; /* Set feasible mtu & rate that will allow check the exact statement of OpenSM */ mtu_phys = p_mc_res->mtu; rate_phys = p_mc_res->rate; memcpy(&mc_req_rec.mgid, &osm_ipoib_good_mgid, sizeof(ib_gid_t)); /* Request Join */ ib_member_set_join_state(&mc_req_rec, IB_MC_REC_STATE_FULL_MEMBER); comp_mask = IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_MTU_SEL | IB_MCR_COMPMASK_MTU | IB_MCR_COMPMASK_RATE_SEL | IB_MCR_COMPMASK_RATE; OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Sending attributes of MCG : \n\t\tMTU=0x%02X, RATE=0x%02X\n", mc_req_rec.mtu, mc_req_rec.rate); status = osmt_send_mcast_request(p_osmt, 0xff, /* User Defined query */ &mc_req_rec, comp_mask, &res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Sent Join request using response values, response is : %s\n", ib_get_err_str(status)); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02EF: " "Query as Full Member of already existing " "ipoib group gid %s has failed\n", inet_ntop(AF_INET6, mc_req_rec.mgid.raw, gid_str, sizeof gid_str)); goto Exit; } /* We do not want to leave the MCG since its IPoIB */ } /**************************************************************************/ /* Check Get with invalid mlid */ OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking Get with invalid mlid...\n"); /* Request Get */ ib_member_set_join_state(&mc_req_rec, IB_MC_REC_STATE_FULL_MEMBER); mc_req_rec.mlid = invalid_mlid; comp_mask = IB_MCR_COMPMASK_MLID; OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); status = osmt_send_mcast_request(p_osmt, 0xee, /* User Defined query Get */ &mc_req_rec, comp_mask, &res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); if (status == IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 2E0 " "SubnAdmGet with invalid mlid 0x%x succeeded\n", cl_ntoh16(mc_req_rec.mlid)); status = IB_ERROR; goto Exit; } /* Prepare the mc_req_rec for the rest of the flow */ osmt_init_mc_query_rec(p_osmt, &mc_req_rec); /**************************************************************************/ /* Check Get with invalid port guid */ OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking Get with invalid port guid (0x0) but valid interface ID : 0x%" PRIx64 "...\n", cl_ntoh64(mc_req_rec.port_gid.unicast.interface_id)); /* Request Get */ ib_member_set_join_state(&mc_req_rec, IB_MC_REC_STATE_FULL_MEMBER); memset(&mc_req_rec.port_gid.unicast.interface_id, 0, sizeof(ib_net64_t)); comp_mask = IB_MCR_COMPMASK_GID; OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); status = osmt_send_mcast_request(p_osmt, 0xee, /* User Defined query Get */ &mc_req_rec, comp_mask, &res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); if (status == IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 2E4 " "SubnAdmGet with invalid port guid succeeded\n"); status = IB_ERROR; goto Exit; } /* Prepare the mc_req_rec for the rest of the flow */ osmt_init_mc_query_rec(p_osmt, &mc_req_rec); /**************************************************************************/ /* o15.0.1.3: */ /* - Request Join with insufficient comp_mask */ OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking Join with insufficient comp mask qkey & pkey (o15.0.1.3)...\n"); /* no MGID */ memset(&mc_req_rec.mgid, 0, sizeof(ib_gid_t)); /* Request Join */ ib_member_set_join_state(&mc_req_rec, IB_MC_REC_STATE_FULL_MEMBER); comp_mask = IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID | /* IB_MCR_COMPMASK_QKEY | */ /* IB_MCR_COMPMASK_PKEY | intentionaly missed to raise the error */ IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */ IB_MCR_COMPMASK_RATE_SEL | IB_MCR_COMPMASK_RATE; OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); if (status != IB_REMOTE_ERROR || ((ib_net16_t) (res_sa_mad.status & IB_SMP_STATUS_MASK)) != IB_SA_MAD_STATUS_INSUF_COMPS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02EE: " "Expectedd REMOTE ERROR IB_SA_MAD_STATUS_INSUF_COMPS got:%s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); status = IB_ERROR; goto Exit; } OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking Join with insufficient comp mask - sl (15.0.1.3)...\n"); /* no MGID */ memset(&mc_req_rec.mgid, 0, sizeof(ib_gid_t)); /* Request Join */ ib_member_set_join_state(&mc_req_rec, IB_MC_REC_STATE_FULL_MEMBER); comp_mask = IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | /* IB_MCR_COMPMASK_SL | */ IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */ IB_MCR_COMPMASK_RATE_SEL | IB_MCR_COMPMASK_RATE; OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); if (status != IB_REMOTE_ERROR || ((ib_net16_t) (res_sa_mad.status & IB_SMP_STATUS_MASK)) != IB_SA_MAD_STATUS_INSUF_COMPS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02ED: " "Expectedd REMOTE ERROR IB_SA_MAD_STATUS_INSUF_COMPS got:%s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); status = IB_ERROR; goto Exit; } osmt_init_mc_query_rec(p_osmt, &mc_req_rec); /* no MGID */ memset(&mc_req_rec.mgid, 0, sizeof(ib_gid_t)); mc_req_rec.mgid.raw[15] = 0x01; p_mc_res = ib_sa_mad_get_payload_ptr(&res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking Join with insufficient comp mask - flow label (o15.0.1.3)...\n"); /* Request Join */ ib_member_set_join_state(&mc_req_rec, IB_MC_REC_STATE_FULL_MEMBER); comp_mask = IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | /* IB_MCR_COMPMASK_FLOW | intentionaly missed to raise the error */ IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */ IB_MCR_COMPMASK_RATE_SEL | IB_MCR_COMPMASK_RATE; OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); if (status != IB_REMOTE_ERROR || ((ib_net16_t) (res_sa_mad.status & IB_SMP_STATUS_MASK)) != IB_SA_MAD_STATUS_INSUF_COMPS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02EC: " "Expected REMOTE ERROR IB_SA_MAD_STATUS_INSUF_COMPS got:%s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); status = IB_ERROR; goto Exit; } osmt_init_mc_query_rec(p_osmt, &mc_req_rec); p_mc_res = ib_sa_mad_get_payload_ptr(&res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking Join with insufficient comp mask - tclass (o15.0.1.3)...\n"); /* Request Join */ ib_member_set_join_state(&mc_req_rec, IB_MC_REC_STATE_FULL_MEMBER); comp_mask = IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | /* IB_MCR_COMPMASK_TCLASS | Intentionally missed to raise an error */ IB_MCR_COMPMASK_RATE_SEL | IB_MCR_COMPMASK_RATE; OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); if (status != IB_REMOTE_ERROR || ((ib_net16_t) (res_sa_mad.status & IB_SMP_STATUS_MASK)) != IB_SA_MAD_STATUS_INSUF_COMPS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02EA: " "Expected REMOTE ERROR IB_SA_MAD_STATUS_INSUF_COMPS got:%s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); status = IB_ERROR; goto Exit; } osmt_init_mc_query_rec(p_osmt, &mc_req_rec); p_mc_res = ib_sa_mad_get_payload_ptr(&res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking Join with insufficient comp mask - tclass qkey (o15.0.1.3)...\n"); /* no MGID */ /* memset(&mc_req_rec.mgid, 0, sizeof(ib_gid_t)); */ /* Request Join */ ib_member_set_join_state(&mc_req_rec, IB_MC_REC_STATE_FULL_MEMBER); comp_mask = IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID | /* IB_MCR_COMPMASK_QKEY | intentionaly missed to raise the error */ IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | /* IB_MCR_COMPMASK_TCLASS | intentionaly missed to raise the error */ IB_MCR_COMPMASK_RATE_SEL | IB_MCR_COMPMASK_RATE; OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); if (status != IB_REMOTE_ERROR || ((ib_net16_t) (res_sa_mad.status & IB_SMP_STATUS_MASK)) != IB_SA_MAD_STATUS_INSUF_COMPS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02E9: " "Expected REMOTE ERROR IB_SA_MAD_STATUS_INSUF_COMPS got:%s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); status = IB_ERROR; goto Exit; } /* o15.0.1.8: */ /* - Request join with irrelevant RATE : get a ERR_INSUFFICIENT_COMPONENTS */ OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking Join with unrealistic rate (o15.0.1.8)...\n"); /* impossible requested rate */ mc_req_rec.rate = IB_LINK_WIDTH_ACTIVE_12X | IB_PATH_SELECTOR_GREATER_THAN << 6; comp_mask = IB_MCR_COMPMASK_GID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */ IB_MCR_COMPMASK_RATE_SEL | IB_MCR_COMPMASK_RATE; OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); if (status != IB_REMOTE_ERROR || res_sa_mad.status != IB_SA_MAD_STATUS_REQ_INVALID) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0207: " "Expected REMOTE ERROR IB_SA_MAD_STATUS_REQ_INVALID got:%s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); status = IB_ERROR; goto Exit; } /* Check Valid value which is unreasonable now */ OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking Join with unrealistic rate 120GB (o15.0.1.8)...\n"); /* impossible requested rate */ mc_req_rec.rate = IB_PATH_RECORD_RATE_120_GBS | IB_PATH_SELECTOR_GREATER_THAN << 6; comp_mask = IB_MCR_COMPMASK_GID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */ IB_MCR_COMPMASK_RATE_SEL | IB_MCR_COMPMASK_RATE; OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); if (status != IB_REMOTE_ERROR || res_sa_mad.status != IB_SA_MAD_STATUS_REQ_INVALID) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0208: " "Expected REMOTE ERROR IB_SA_MAD_STATUS_REQ_INVALID got:%s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); status = IB_ERROR; goto Exit; } /* Check Valid value which is unreasonable now */ OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking Join with less than min rate 2.5GB (o15.0.1.8)...\n"); /* impossible requested rate */ mc_req_rec.rate = IB_PATH_RECORD_RATE_2_5_GBS | IB_PATH_SELECTOR_LESS_THAN << 6; comp_mask = IB_MCR_COMPMASK_GID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */ IB_MCR_COMPMASK_RATE_SEL | IB_MCR_COMPMASK_RATE; OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); if (status != IB_REMOTE_ERROR || res_sa_mad.status != IB_SA_MAD_STATUS_REQ_INVALID) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02AB: " "Expected REMOTE ERROR IB_SA_MAD_STATUS_REQ_INVALID got:%s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); status = IB_ERROR; goto Exit; } /* Checking above max value of MTU which is impossible */ OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking Join with unrealistic mtu : \n\t\tmore than 4096 -" " max (o15.0.1.8)...\n"); /* impossible requested mtu */ mc_req_rec.mtu = IB_MTU_LEN_4096 | IB_PATH_SELECTOR_GREATER_THAN << 6; comp_mask = IB_MCR_COMPMASK_GID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */ IB_MCR_COMPMASK_MTU_SEL | IB_MCR_COMPMASK_MTU; OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); if (status != IB_REMOTE_ERROR || res_sa_mad.status != IB_SA_MAD_STATUS_REQ_INVALID) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02AC: " "Expected REMOTE ERROR IB_SA_MAD_STATUS_REQ_INVALID got:%s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad)) ); status = IB_ERROR; goto Exit; } /* Checking below min value of MTU which is impossible */ OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking Join with unrealistic mtu : \n\t\tless than 256 -" " min (o15.0.1.8)...\n"); /* impossible requested mtu */ mc_req_rec.mtu = IB_MTU_LEN_256 | IB_PATH_SELECTOR_LESS_THAN << 6; comp_mask = IB_MCR_COMPMASK_GID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */ IB_MCR_COMPMASK_MTU_SEL | IB_MCR_COMPMASK_MTU; OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); if (status != IB_REMOTE_ERROR || res_sa_mad.status != IB_SA_MAD_STATUS_REQ_INVALID) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02AD: " "Expected REMOTE ERROR IB_SA_MAD_STATUS_REQ_INVALID got:%s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); status = IB_ERROR; goto Exit; } OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking Join with unrealistic mtu (o15.0.1.8)...\n"); /* impossible requested mtu */ mc_req_rec.mtu = 0x6 | IB_PATH_SELECTOR_GREATER_THAN << 6; comp_mask = IB_MCR_COMPMASK_GID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */ IB_MCR_COMPMASK_MTU_SEL | IB_MCR_COMPMASK_MTU; OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); if (status != IB_REMOTE_ERROR || res_sa_mad.status != IB_SA_MAD_STATUS_REQ_INVALID) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02AE: " "Expected REMOTE ERROR IB_SA_MAD_STATUS_REQ_INVALID got:%s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); status = IB_ERROR; goto Exit; } #if 0 /* Currently PacketLifeTime isn't checked in opensm */ /* Check PacketLifeTime as 0 */ OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking Create with unrealistic packet life value less than 0 (o15.0.1.8)...\n"); /* impossible requested packet life */ mc_req_rec.pkt_life = 0 | IB_PATH_SELECTOR_LESS_THAN << 6; comp_mask = IB_MCR_COMPMASK_GID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */ IB_MCR_COMPMASK_LIFE | IB_MCR_COMPMASK_LIFE_SEL; OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); if (status != IB_REMOTE_ERROR || res_sa_mad.status != IB_SA_MAD_STATUS_REQ_INVALID) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02AF: " "Expected REMOTE ERROR IB_SA_MAD_STATUS_REQ_INVALID got:%s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); status = IB_ERROR; goto Exit; } #endif /* o15.0.1.4: */ /* - Create an MGID by asking for a join with MGID = 0 */ /* providing P_Key, Q_Key, SL, FlowLabel, Tclass. */ OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking Create given MGID=0 skip service level (o15.0.1.4)...\n"); osmt_init_mc_query_rec(p_osmt, &mc_req_rec); p_mc_res = ib_sa_mad_get_payload_ptr(&res_sa_mad); /* no MGID */ memset(&mc_req_rec.mgid, 0, sizeof(ib_gid_t)); /* Request Join */ ib_member_set_join_state(&mc_req_rec, IB_MC_REC_STATE_FULL_MEMBER); comp_mask = IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | /* IB_MCR_COMPMASK_SL | Intentionally missed */ IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */ IB_MCR_COMPMASK_RATE_SEL | IB_MCR_COMPMASK_RATE; OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); if (status != IB_REMOTE_ERROR || ((ib_net16_t) (res_sa_mad.status & IB_SMP_STATUS_MASK)) != IB_SA_MAD_STATUS_INSUF_COMPS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02A8: " "Expected REMOTE ERROR IB_SA_MAD_STATUS_INSUF_COMPS got:%s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); status = IB_ERROR; goto Exit; } /* Check that no same MCG in the SMDB */ status = osmt_query_mcast(p_osmt); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02AA: " "Could not get all MC Records in subnet, got:%s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); goto Exit; } /* Only when we are on single mode check flow - do the count comparison, otherwise skip */ if (p_osmt->opt.mmode == 1 || p_osmt->opt.mmode == 3) { middle_cnt = cl_qmap_count(&p_osmt->exp_subn.mgrp_mlid_tbl); OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "(post false create): " "Number of MC Records found in SA DB is %d\n", middle_cnt); if (middle_cnt != start_cnt) { OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Got different number of records stored in SA DB (before any creation)\n" "Instead of %d got %d\n", start_cnt, middle_cnt); } } OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking Create given MGID=0 skip Qkey and Pkey (o15.0.1.4)...\n"); osmt_init_mc_query_rec(p_osmt, &mc_req_rec); p_mc_res = ib_sa_mad_get_payload_ptr(&res_sa_mad); /* no MGID */ memset(&mc_req_rec.mgid, 0, sizeof(ib_gid_t)); /* Request Join */ ib_member_set_join_state(&mc_req_rec, IB_MC_REC_STATE_FULL_MEMBER); comp_mask = IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID | /* IB_MCR_COMPMASK_QKEY | */ /* IB_MCR_COMPMASK_PKEY | Intentionally missed */ IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */ IB_MCR_COMPMASK_RATE_SEL | IB_MCR_COMPMASK_RATE; OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); if (status != IB_REMOTE_ERROR || ((ib_net16_t) (res_sa_mad.status & IB_SMP_STATUS_MASK)) != IB_SA_MAD_STATUS_INSUF_COMPS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02A7: " "Expected REMOTE ERROR IB_SA_MAD_STATUS_INSUF_COMPS got:%s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); status = IB_ERROR; goto Exit; } /* Bad Query o15.0.1.4 */ status = osmt_query_mcast(p_osmt); OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking Create given MGID=0 skip TClass (o15.0.1.4)...\n"); osmt_init_mc_query_rec(p_osmt, &mc_req_rec); p_mc_res = ib_sa_mad_get_payload_ptr(&res_sa_mad); /* no MGID */ memset(&mc_req_rec.mgid, 0, sizeof(ib_gid_t)); /* Request Join */ ib_member_set_join_state(&mc_req_rec, IB_MC_REC_STATE_FULL_MEMBER); comp_mask = IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | /* IB_MCR_COMPMASK_TCLASS | Intentionally missed */ /* all above are required */ IB_MCR_COMPMASK_RATE_SEL | IB_MCR_COMPMASK_RATE; OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); if (status != IB_REMOTE_ERROR || ((ib_net16_t) (res_sa_mad.status & IB_SMP_STATUS_MASK)) != IB_SA_MAD_STATUS_INSUF_COMPS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02A6: " "Expected REMOTE ERROR IB_SA_MAD_STATUS_INSUF_COMPS got:%s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); status = IB_ERROR; goto Exit; } OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking Create given MGID=0 valid Set several options :\n\t\t" "First above min RATE, Second less than max RATE\n\t\t" "Third above min MTU, Second less than max MTU\n\t\t" "Fifth exact MTU & RATE feasible, Sixth exact RATE feasible\n\t\t" "Seventh exact MTU feasible (o15.0.1.4)...\n"); /* Good Flow - mgid is 0 while giving all required fields for join : P_Key, Q_Key, SL, FlowLabel, Tclass */ mc_req_rec.rate = IB_LINK_WIDTH_ACTIVE_1X | IB_PATH_SELECTOR_GREATER_THAN << 6; comp_mask = IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */ IB_MCR_COMPMASK_RATE_SEL | IB_MCR_COMPMASK_RATE; status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02A5: " "Failed to create MCG for MGID=0 with higher than minimum RATE - got %s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); goto Exit; } /* Save the mlid created in test_created_mlids map */ p_recvd_rec = (ib_member_rec_t *) ib_sa_mad_get_payload_ptr(&res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "created MGID:%s MLID:0x%04X\n", inet_ntop(AF_INET6, p_recvd_rec->mgid.raw, gid_str, sizeof gid_str), cl_ntoh16(p_recvd_rec->mlid)); cl_map_insert(&test_created_mlids, cl_ntoh16(p_recvd_rec->mlid), p_recvd_rec); /* Good Flow - mgid is 0 while giving all required fields for join : P_Key, Q_Key, SL, FlowLabel, Tclass */ mc_req_rec.rate = IB_LINK_WIDTH_ACTIVE_12X | IB_PATH_SELECTOR_LESS_THAN << 6; comp_mask = IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */ IB_MCR_COMPMASK_RATE_SEL | IB_MCR_COMPMASK_RATE; status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0211: " "Failed to create MCG for MGID=0 with less than highest RATE - got %s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); goto Exit; } /* Save the mlid created in test_created_mlids map */ p_recvd_rec = (ib_member_rec_t *) ib_sa_mad_get_payload_ptr(&res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Created MGID:%s MLID:0x%04X\n", inet_ntop(AF_INET6, p_recvd_rec->mgid.raw, gid_str, sizeof gid_str), cl_ntoh16(p_recvd_rec->mlid)); cl_map_insert(&test_created_mlids, cl_ntoh16(p_recvd_rec->mlid), p_recvd_rec); /* Good Flow - mgid is 0 while giving all required fields for join : P_Key, Q_Key, SL, FlowLabel, Tclass */ mc_req_rec.mtu = IB_MTU_LEN_4096 | IB_PATH_SELECTOR_LESS_THAN << 6; comp_mask = IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */ IB_MCR_COMPMASK_MTU_SEL | IB_MCR_COMPMASK_MTU; status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0238: " "Failed to create MCG for MGID=0 with less than highest MTU - got %s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); goto Exit; } /* Save the mlid created in test_created_mlids map */ p_recvd_rec = (ib_member_rec_t *) ib_sa_mad_get_payload_ptr(&res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Created MGID:%s MLID:0x%04X\n", inet_ntop(AF_INET6, p_recvd_rec->mgid.raw, gid_str, sizeof gid_str), cl_ntoh16(p_recvd_rec->mlid)); cl_map_insert(&test_created_mlids, cl_ntoh16(p_recvd_rec->mlid), p_recvd_rec); /* Good Flow - mgid is 0 while giving all required fields for join : P_Key, Q_Key, SL, FlowLabel, Tclass */ mc_req_rec.mtu = IB_MTU_LEN_256 | IB_PATH_SELECTOR_GREATER_THAN << 6; comp_mask = IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */ IB_MCR_COMPMASK_MTU_SEL | IB_MCR_COMPMASK_MTU; status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0239: " "Failed to create MCG for MGID=0 with higher than lowest MTU - got %s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); goto Exit; } /* Save the mlid created in test_created_mlids map */ p_recvd_rec = (ib_member_rec_t *) ib_sa_mad_get_payload_ptr(&res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Created MGID:%s MLID:0x%04X\n", inet_ntop(AF_INET6, p_recvd_rec->mgid.raw, gid_str, sizeof gid_str), cl_ntoh16(p_recvd_rec->mlid)); cl_map_insert(&test_created_mlids, cl_ntoh16(p_recvd_rec->mlid), p_recvd_rec); /* Good Flow - mgid is 0 while giving all required fields for join : P_Key, Q_Key, SL, FlowLabel, Tclass */ /* Using Exact feasible MTU & RATE */ OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Using Exact feasible MTU & RATE: " "MTU = 0x%02X, RATE = 0x%02X\n", mtu_phys, rate_phys); mc_req_rec.mtu = mtu_phys; mc_req_rec.rate = rate_phys; comp_mask = IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */ IB_MCR_COMPMASK_MTU_SEL | IB_MCR_COMPMASK_MTU | IB_MCR_COMPMASK_RATE_SEL | IB_MCR_COMPMASK_RATE; status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0240: " "Failed to create MCG for MGID=0 with exact MTU & RATE - got %s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); goto Exit; } /* Save the mlid created in test_created_mlids map */ p_recvd_rec = (ib_member_rec_t *) ib_sa_mad_get_payload_ptr(&res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Created MGID:%s MLID:0x%04X\n", inet_ntop(AF_INET6, p_recvd_rec->mgid.raw, gid_str, sizeof gid_str), cl_ntoh16(p_recvd_rec->mlid)); cl_map_insert(&test_created_mlids, cl_ntoh16(p_recvd_rec->mlid), p_recvd_rec); /* Good Flow - mgid is 0 while giving all required fields for join : P_Key, Q_Key, SL, FlowLabel, Tclass */ /* Using Exact feasible RATE */ OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Using Exact feasible RATE: 0x%02X\n", rate_phys); mc_req_rec.rate = rate_phys; comp_mask = IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */ IB_MCR_COMPMASK_RATE_SEL | IB_MCR_COMPMASK_RATE; status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0241: " "Failed to create MCG for MGID=0 with exact RATE - got %s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); goto Exit; } /* Save the mlid created in test_created_mlids map */ p_recvd_rec = (ib_member_rec_t *) ib_sa_mad_get_payload_ptr(&res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Created MGID:%s MLID:0x%04X\n", inet_ntop(AF_INET6, p_recvd_rec->mgid.raw, gid_str, sizeof gid_str), cl_ntoh16(p_recvd_rec->mlid)); cl_map_insert(&test_created_mlids, cl_ntoh16(p_recvd_rec->mlid), p_recvd_rec); /* Good Flow - mgid is 0 while giving all required fields for join : P_Key, Q_Key, SL, FlowLabel, Tclass */ /* Using Exact feasible MTU */ OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Using Exact feasible MTU: 0x%02X\n", mtu_phys); mc_req_rec.mtu = mtu_phys; comp_mask = IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */ IB_MCR_COMPMASK_MTU_SEL | IB_MCR_COMPMASK_MTU; status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0242: " "Failed to create MCG for MGID=0 with exact MTU - got %s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); goto Exit; } /* Save the mlid created in test_created_mlids map */ p_recvd_rec = (ib_member_rec_t *) ib_sa_mad_get_payload_ptr(&res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Created MGID:%s MLID:0x%04X\n", inet_ntop(AF_INET6, p_recvd_rec->mgid.raw, gid_str, sizeof gid_str), cl_ntoh16(p_recvd_rec->mlid)); cl_map_insert(&test_created_mlids, cl_ntoh16(p_recvd_rec->mlid), p_recvd_rec); /* o15.0.1.5: */ /* - Check the returned MGID is valid. (p 804) */ OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Validating resulting MGID (o15.0.1.5)...\n"); /* prefix 0xFF1 Scope 0xA01B */ /* Since we did not directly specified SCOPE in comp mask we should get the comp mask that is link-local scope */ if ((p_mc_res->mgid.multicast.header[0] != 0xFF) || (p_mc_res->mgid.multicast.header[1] != 0x12) || (p_mc_res->mgid.multicast.raw_group_id[0] != 0xA0) || (p_mc_res->mgid.multicast.raw_group_id[1] != 0x1B)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0209: " "Validating MGID failed. MGID:%s\n", inet_ntop(AF_INET6, p_mc_res->mgid.raw, gid_str, sizeof gid_str)); status = IB_ERROR; goto Exit; } /* Good Flow - mgid is 0 while giving all required fields for join : P_Key, Q_Key, SL, FlowLabel, Tclass */ /* Using feasible GREATER_THAN 0 packet lifitime */ OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking Create given MGID=0 (o15.0.1.4)...\n"); status = osmt_query_mcast(p_osmt); osmt_init_mc_query_rec(p_osmt, &mc_req_rec); p_mc_res = ib_sa_mad_get_payload_ptr(&res_sa_mad); /* no MGID */ memset(&mc_req_rec.mgid, 0, sizeof(ib_gid_t)); /* Request Join */ ib_member_set_join_state(&mc_req_rec, IB_MC_REC_STATE_FULL_MEMBER); mc_req_rec.pkt_life = 0 | IB_PATH_SELECTOR_GREATER_THAN << 6; comp_mask = IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */ IB_MCR_COMPMASK_LIFE | IB_MCR_COMPMASK_LIFE_SEL; status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0210: " "Failed to create MCG for MGID=0 - got %s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); goto Exit; } /* Save the mlid created in test_created_mlids map */ p_recvd_rec = (ib_member_rec_t *) ib_sa_mad_get_payload_ptr(&res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Created MGID:%s MLID:0x%04X\n", inet_ntop(AF_INET6, p_recvd_rec->mgid.raw, gid_str, sizeof gid_str), cl_ntoh16(p_recvd_rec->mlid)); cl_map_insert(&test_created_mlids, cl_ntoh16(p_recvd_rec->mlid), p_recvd_rec); /* o15.0.1.6: */ /* - Create a new MCG with valid requested MGID. */ osmt_init_mc_query_rec(p_osmt, &mc_req_rec); mc_req_rec.mgid = good_mgid; OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking Create given valid MGID=%s (o15.0.1.6)...\n", inet_ntop(AF_INET6, mc_req_rec.mgid.raw, gid_str, sizeof gid_str)); /* Before creation, need to check that this group doesn't exist */ OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Verifying that MCGroup with this MGID doesn't exist by trying to Join it (o15.0.1.13)...\n"); ib_member_set_join_state(&mc_req_rec, IB_MC_REC_STATE_NON_MEMBER); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); status = osmt_send_mcast_request(p_osmt, 1, /* join */ &mc_req_rec, comp_mask, &res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); if ((status != IB_REMOTE_ERROR) || (res_sa_mad.status != IB_SA_MAD_STATUS_REQ_INVALID)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0301: " "Tried joining group that shouldn't have existed - got %s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); status = IB_ERROR; goto Exit; } /* Set State to full member to allow group creation */ ib_member_set_join_state(&mc_req_rec, IB_MC_REC_STATE_FULL_MEMBER); OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Now creating group with given valid MGID=%s (o15.0.1.6)...\n", inet_ntop(AF_INET6, mc_req_rec.mgid.raw, gid_str, sizeof gid_str)); status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0211: " "Failed to create MCG for MGID=%s (o15.0.1.6) - got %s/%s\n", inet_ntop(AF_INET6, good_mgid.raw, gid_str, sizeof gid_str), ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); goto Exit; } /* Save the mlid created in test_created_mlids map */ p_recvd_rec = (ib_member_rec_t *) ib_sa_mad_get_payload_ptr(&res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Created MGID:%s MLID:0x%04X\n", inet_ntop(AF_INET6, p_recvd_rec->mgid.raw, gid_str, sizeof gid_str), cl_ntoh16(p_recvd_rec->mlid)); cl_map_insert(&test_created_mlids, cl_ntoh16(p_recvd_rec->mlid), p_recvd_rec); OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Validating resulting MGID (o15.0.1.6)...\n"); /* prefix 0xFF1 Scope 0xA01B */ if ((p_mc_res->mgid.multicast.header[0] != 0xFF) || (p_mc_res->mgid.multicast.header[1] != 0x12) || /* HACK hardcoded scope = 0x02 */ (p_mc_res->mgid.multicast.raw_group_id[0] != 0xA0) || (p_mc_res->mgid.multicast.raw_group_id[1] != 0x1C)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0212: " "Validating MGID failed. MGID:%s\n", inet_ntop(AF_INET6, p_mc_res->mgid.raw, gid_str, sizeof gid_str)); status = IB_ERROR; goto Exit; } /* - Try to create a new MCG with invalid MGID : get back ERR_REQ_INVALID */ OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking BAD MGID=0xFA..... (o15.0.1.6)...\n"); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); mc_req_rec.mgid.raw[0] = 0xFA; status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); if ((status != IB_REMOTE_ERROR) || (res_sa_mad.status != IB_SA_MAD_STATUS_REQ_INVALID)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0213: " "Failed to recognize MGID error for MGID=0xFA - got %s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); status = IB_ERROR; goto Exit; } /* - Try again with MGID prefix = 0xA01B (maybe 0x1BA0 little or big ?) */ OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking BAD MGID=0xFF12A01B..... with link-local scope (o15.0.1.6)...\n"); mc_req_rec.mgid.raw[0] = 0xFF; mc_req_rec.mgid.raw[3] = 0x1B; comp_mask = comp_mask | IB_MCR_COMPMASK_SCOPE; mc_req_rec.scope_state = mc_req_rec.scope_state & 0x2F; /* local scope */ OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); if ((status != IB_REMOTE_ERROR) || (res_sa_mad.status != IB_SA_MAD_STATUS_REQ_INVALID)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0214: " "Failed to recognize MGID error for A01B with link-local bit (status %s) (rem status %s)\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); status = IB_ERROR; goto Exit; } /* Change the mgid prefix - get back ERR_REQ_INVALID */ OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking BAD MGID PREFIX=0xEF... (o15.0.1.6)...\n"); mc_req_rec.mgid = good_mgid; mc_req_rec.mgid.raw[0] = 0xEF; OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); if ((status != IB_REMOTE_ERROR) || (res_sa_mad.status != IB_SA_MAD_STATUS_REQ_INVALID)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0215: " "Failed to recognize MGID PREFIX error for MGID=0xEF - got %s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); status = IB_ERROR; goto Exit; } /* Change the scope to reserved - get back VALID REQ */ OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking local scope with full member \n\t\tand valid mgid %s" " ... (o15.0.1.6)...\n", inet_ntop(AF_INET6, mc_req_rec.mgid.raw, gid_str, sizeof gid_str)); mc_req_rec.mgid = good_mgid; mc_req_rec.mgid.raw[1] = 0x1F; status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0216: " "Failed to create MCG for MGID=%s - got %s/%s\n", inet_ntop(AF_INET6, good_mgid.raw, gid_str, sizeof gid_str), ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); goto Exit; } /* Save the mlid created in test_created_mlids map */ p_recvd_rec = (ib_member_rec_t *) ib_sa_mad_get_payload_ptr(&res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Created MGID:%s MLID:0x%04X\n", inet_ntop(AF_INET6, p_recvd_rec->mgid.raw, gid_str, sizeof gid_str), cl_ntoh16(p_recvd_rec->mlid)); cl_map_insert(&test_created_mlids, cl_ntoh16(p_recvd_rec->mlid), p_recvd_rec); /* Change the flags to invalid value 0x2 - get back INVALID REQ */ OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking invalid flags=0xFF 22 ... (o15.0.1.6)...\n"); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); mc_req_rec.mgid = good_mgid; mc_req_rec.mgid.raw[1] = 0x22; status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); if ((status != IB_REMOTE_ERROR) || (res_sa_mad.status != IB_SA_MAD_STATUS_REQ_INVALID)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0217: " "Failed to recognize create with invalid flags value 0x2 - got %s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); status = IB_ERROR; goto Exit; } /* Change the MGID to link local MGID - get back VALID REQ */ OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking link local MGID 0xFF02:0:0:0:0:0:0:1 (o15.0.1.6)...\n"); mc_req_rec.mgid = osm_link_local_mgid; status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0218: " "Failed to create MCG for MGID=0xFF02:0:0:0:0:0:0:1 - got %s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); goto Exit; } /* Save the mlid created in test_created_mlids map */ p_recvd_rec = (ib_member_rec_t *) ib_sa_mad_get_payload_ptr(&res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Created MGID:%s MLID:0x%04X\n", inet_ntop(AF_INET6, p_recvd_rec->mgid.raw, gid_str, sizeof gid_str), cl_ntoh16(p_recvd_rec->mlid)); cl_map_insert(&test_created_mlids, cl_ntoh16(p_recvd_rec->mlid), p_recvd_rec); /* o15.0.1.7 - implicitlly checked during the prev steps. */ /* o15.0.1.8 - implicitlly checked during the prev steps. */ /* o15.0.1.9 */ /* - Create MCG with Invalid JoinState.FullMember != 1 : get ERR_REQ_INVALID */ OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking new MGID with invalid join state (o15.0.1.9)...\n"); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); mc_req_rec.mgid = good_mgid; mc_req_rec.mgid.raw[12] = 0xFF; mc_req_rec.scope_state = 0x22; /* link-local scope, non-member state */ status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); if ((status != IB_REMOTE_ERROR) || (res_sa_mad.status != IB_SA_MAD_STATUS_REQ_INVALID)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0219: " "Failed to recognize create with JoinState != FullMember - got %s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); status = IB_ERROR; goto Exit; } /* Lets try a valid join scope state */ OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking new MGID with valid join state (o15.0.1.9)...\n"); mc_req_rec.mgid = good_mgid; mc_req_rec.scope_state = 0x23; /* link-local scope, non member and full member */ status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0220: " "Failed to create MCG with valid join state 0x3 - got %s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); goto Exit; } /* Save the mlid created in test_created_mlids map */ p_recvd_rec = (ib_member_rec_t *) ib_sa_mad_get_payload_ptr(&res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Created MGID:%s MLID:0x%04X\n", inet_ntop(AF_INET6, p_recvd_rec->mgid.raw, gid_str, sizeof gid_str), cl_ntoh16(p_recvd_rec->mlid)); cl_map_insert(&test_created_mlids, cl_ntoh16(p_recvd_rec->mlid), p_recvd_rec); /* Lets try another invalid join scope state */ OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking new MGID with invalid join state (o15.0.1.9)...\n"); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); /* We have created a new MCG so now we need different mgid when cresting group otherwise it will be counted as join request . */ mc_req_rec.mgid = good_mgid; mc_req_rec.mgid.raw[12] = 0xFC; mc_req_rec.scope_state = 0x24; /* link-local scope, send only member */ status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); if ((status != IB_REMOTE_ERROR) || (res_sa_mad.status != IB_SA_MAD_STATUS_REQ_INVALID)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0221: " "Failed to recognize create with JoinState != FullMember - got %s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); status = IB_ERROR; goto Exit; } /* Lets try another valid join scope state */ OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking new MGID creation with valid join state (o15.0.2.3)...\n"); mc_req_rec.mgid = good_mgid; mc_req_rec.mgid.raw[12] = 0xFB; memcpy(&special_mgid, &mc_req_rec.mgid, sizeof(ib_gid_t)); mc_req_rec.scope_state = 0x2F; /* link-local scope, Full member with all other bits turned on */ status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0222: " "Failed to create MCG with valid join state 0xF - got %s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); goto Exit; } /* Save the mlid created in test_created_mlids map */ p_recvd_rec = (ib_member_rec_t *) ib_sa_mad_get_payload_ptr(&res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Created MGID:%s MLID:0x%04X\n", inet_ntop(AF_INET6, p_recvd_rec->mgid.raw, gid_str, sizeof gid_str), cl_ntoh16(p_recvd_rec->mlid)); cl_map_insert(&test_created_mlids, cl_ntoh16(p_recvd_rec->mlid), p_recvd_rec); /* o15.0.1.10 - can't check on a single client .-- obsolete - checked by SilverStorm bug o15-0.2.4, never the less recheck */ /* o15-0.2.4 - Check a join request to already created MCG */ p_mc_res = ib_sa_mad_get_payload_ptr(&res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Check o15-0.2.4 statement...\n"); /* Try to join */ memcpy(&mc_req_rec.mgid, &p_mc_res->mgid, sizeof(ib_gid_t)); /* Request Join */ ib_member_set_join_state(&mc_req_rec, IB_MC_REC_STATE_NON_MEMBER); comp_mask = IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_JOIN_STATE; status = osmt_send_mcast_request(p_osmt, 0x1, /* SubnAdmSet */ &mc_req_rec, comp_mask, &res_sa_mad); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02CC: " "Failed to join MCG with valid req, returned status = %s\n", ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); goto Exit; } p_mc_res = ib_sa_mad_get_payload_ptr(&res_sa_mad); if ((p_mc_res->scope_state & 0x7) != 0x7) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02D0: " "Validating JoinState update failed. " "Expected 0x27 got 0x%02X\n", p_mc_res->scope_state); status = IB_ERROR; goto Exit; } /* o15.0.1.11: */ /* - Try to join into a MGID that exists with JoinState=SendOnlyMember - */ /* see that it updates JoinState. What is the routing change? */ OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking Retry of existing MGID - See JoinState update (o15.0.1.11)...\n"); mc_req_rec.mgid = good_mgid; /* first, make sure that the group exists */ mc_req_rec.scope_state = 0x21; status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02CD: " "Failed to create/join as full member - got %s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); goto Exit; } mc_req_rec.scope_state = 0x22; /* link-local scope, non-member */ status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02D1: " "Failed to update existing MGID - got %s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); goto Exit; } OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Validating Join State update with NonMember (o15.0.1.11)...\n"); if (p_mc_res->scope_state != 0x23) { /* scope is LSB */ OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02CE: " "Validating JoinState update failed. Expected 0x23 got: 0x%02X\n", p_mc_res->scope_state); status = IB_ERROR; goto Exit; } /* Try delete current join state then update it with another value */ OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking JoinState update request should return 0x22 (o15.0.1.11)...\n"); mc_req_rec.rate = IB_LINK_WIDTH_ACTIVE_1X | IB_PATH_SELECTOR_GREATER_THAN << 6; mc_req_rec.mgid = good_mgid; OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking Partially delete JoinState (o15.0.1.14)...\n"); /* link-local scope, both non-member bits, so we should not be able to delete) */ mc_req_rec.scope_state = 0x26; OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); status = osmt_send_mcast_request(p_osmt, 0, &mc_req_rec, comp_mask, &res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); if (status != IB_REMOTE_ERROR) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02CF: " "Expected to fail partially update JoinState, " "but got %s\n", ib_get_err_str(status)); status = IB_ERROR; goto Exit; } /* link-local scope, NonMember bit, the FullMember bit should stay */ mc_req_rec.scope_state = 0x22; status = osmt_send_mcast_request(p_osmt, 0, &mc_req_rec, comp_mask, &res_sa_mad); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02D3: " "Failed to partially update JoinState : %s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); status = IB_ERROR; goto Exit; } p_mc_res = ib_sa_mad_get_payload_ptr(&res_sa_mad); if (p_mc_res->scope_state != 0x21) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02D4: " "Failed to partially update JoinState : " "JoinState = 0x%02X, expected 0x%02X\n", p_mc_res->scope_state, 0x21); status = IB_ERROR; goto Exit; } /* So far successfully delete state - Now change it */ mc_req_rec.mgid = good_mgid; mc_req_rec.scope_state = 0x24; /* link-local scope, send only member */ status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02C0: " "Failed to update existing MCG - got %s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); goto Exit; } OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Validating Join State update with Send Only Member (o15.0.1.11)...\n"); if (p_mc_res->scope_state != 0x25) { /* scope is MSB */ OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02C1: " "Validating JoinState update failed. Expected 0x25 got: 0x%02X\n", p_mc_res->scope_state); status = IB_ERROR; goto Exit; } /* Now try to update value of join state */ mc_req_rec.scope_state = 0x21; /* link-local scope, full member */ status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02C2: " "Failed to update existing MGID - got %s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); goto Exit; } OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Validating Join State update with Full Member\n\t\t" "to an existing 0x5 state MCG (o15.0.1.11)...\n"); if (p_mc_res->scope_state != 0x25) { /* scope is LSB */ OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02C3: " "Validating JoinState update failed. Expected 0x25 got: 0x%02X\n", p_mc_res->scope_state); status = IB_ERROR; goto Exit; } /* Now try to update value of join state */ mc_req_rec.scope_state = 0x22; /* link-local scope,non member */ status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02C4: " "Failed to update existing MGID - got %s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); goto Exit; } OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Validating Join State update with Non Member\n\t\t" "to an existing 0x5 state MCG (o15.0.1.11)...\n"); if (p_mc_res->scope_state != 0x27) { /* scope is LSB */ OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02C5: " "Validating JoinState update failed. Expected 0x27 got: 0x%02X\n", p_mc_res->scope_state); status = IB_ERROR; goto Exit; } OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "DEBUG - Current scope_state value : 0x%02X...\n", p_mc_res->scope_state); /* - We can not check simple join since we have only one tester (for now) */ /* o15.0.1.12: Not Supported */ /* - The SendOnlyNonMem join should have a special treatment in the SA but what is it ? */ /* o15.0.1.13: */ /* - Try joining with rate that does not exist in any MCG - ERR_REQ_INVALID */ OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking BAD RATE when connecting to existing MGID (o15.0.1.13)...\n"); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); mc_req_rec.mgid = good_mgid; mc_req_rec.rate = IB_LINK_WIDTH_ACTIVE_1X | IB_PATH_SELECTOR_LESS_THAN << 6; comp_mask = IB_MCR_COMPMASK_GID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */ IB_MCR_COMPMASK_RATE_SEL | IB_MCR_COMPMASK_RATE; status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); if ((status != IB_REMOTE_ERROR) || (res_sa_mad.status != IB_SA_MAD_STATUS_REQ_INVALID)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02C6: " "Failed to catch BAD RATE joining an exiting MGID: %s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); status = IB_ERROR; goto Exit; } /* Try MTU that does not exist in any MCG */ OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking BAD MTU (higher them max) when connecting to " "existing MGID (o15.0.1.13)...\n"); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); mc_req_rec.mgid = osm_ipoib_mgid; mc_req_rec.mtu = IB_MTU_LEN_4096 | IB_PATH_SELECTOR_GREATER_THAN << 6; comp_mask = IB_MCR_COMPMASK_GID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */ IB_MCR_COMPMASK_MTU_SEL | IB_MCR_COMPMASK_MTU; status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); if ((status != IB_REMOTE_ERROR) || (res_sa_mad.status != IB_SA_MAD_STATUS_REQ_INVALID)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02C7: " "Failed to catch BAD RATE (higher them max) joining an exiting MGID: %s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); status = IB_ERROR; goto Exit; } /* Try another MTU that does not exist in any MCG */ OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking BAD MTU (less than min) when connecting " "to existing MGID (o15.0.1.13)...\n"); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); mc_req_rec.mgid = osm_ipoib_mgid; mc_req_rec.mtu = IB_MTU_LEN_256 | IB_PATH_SELECTOR_LESS_THAN << 6; comp_mask = IB_MCR_COMPMASK_GID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */ IB_MCR_COMPMASK_MTU_SEL | IB_MCR_COMPMASK_MTU; status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); if ((status != IB_REMOTE_ERROR) || (res_sa_mad.status != IB_SA_MAD_STATUS_REQ_INVALID)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02C8: " "Failed to catch BAD RATE (less them min) joining an exiting MGID: %s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); status = IB_ERROR; goto Exit; } /* o15.0.1.14: */ /* - Try partial delete - actually updating the join state. check it. */ OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking partial JoinState delete request - removing NonMember (o15.0.1.14)...\n"); mc_req_rec.rate = IB_LINK_WIDTH_ACTIVE_1X | IB_PATH_SELECTOR_GREATER_THAN << 6; mc_req_rec.mgid = good_mgid; comp_mask = IB_MCR_COMPMASK_GID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */ IB_MCR_COMPMASK_RATE_SEL | IB_MCR_COMPMASK_RATE; /* link-local scope, non member (so we should not be able to delete) */ /* but the NonMember bit should be gone */ mc_req_rec.scope_state = 0x22; status = osmt_send_mcast_request(p_osmt, 0, &mc_req_rec, comp_mask, &res_sa_mad); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02C9: " "Fail to partially update JoinState during delete: %s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); status = IB_ERROR; goto Exit; } OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Validating Join State removal of Non Member bit (o15.0.1.14)...\n"); if (p_mc_res->scope_state != 0x25) { /* scope is MSB - now only the full member & send only member have left */ OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02CA: " "Validating JoinState update failed. Expected 0x25 got: 0x%02X\n", p_mc_res->scope_state); status = IB_ERROR; goto Exit; } /* Now use the same scope_state and delete all JoinState - leave multicast group since state is 0x0 */ mc_req_rec.scope_state = 0x25; status = osmt_send_mcast_request(p_osmt, 0, &mc_req_rec, comp_mask, &res_sa_mad); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02CB: " "Failed to update JoinState during delete: %s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); status = IB_ERROR; goto Exit; } OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Validating Join State update remove (o15.0.1.14)...\n"); if (p_mc_res->scope_state != 0x25) { /* scope is MSB - now only 0x0 so port is removed from MCG */ OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02BF: " "Validating JoinState update failed. Expected 0x25 got: 0x%02X\n", p_mc_res->scope_state); status = IB_ERROR; goto Exit; } /* - Try joining (not full mem) again to see the group was deleted. (should fail) */ OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking Delete by trying to Join deleted group (o15.0.1.13)...\n"); mc_req_rec.scope_state = 0x22; /* use non member - so if no group fail */ OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); status = osmt_send_mcast_request(p_osmt, 1, /* join */ &mc_req_rec, comp_mask, &res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); if (status != IB_REMOTE_ERROR) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02BC: " "Succeeded Joining Deleted Group: %s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); status = IB_ERROR; goto Exit; } /* - Try deletion of the IPoIB MCG and get: ERR_REQ_INVALID */ OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking BAD Delete of Mgid membership (no prev join) (o15.0.1.15)...\n"); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); mc_req_rec.mgid = osm_ipoib_mgid; mc_req_rec.rate = IB_LINK_WIDTH_ACTIVE_1X | IB_PATH_SELECTOR_GREATER_THAN << 6; mc_req_rec.scope_state = 0x21; /* delete full member */ status = osmt_send_mcast_request(p_osmt, 0, /* delete flag */ &mc_req_rec, comp_mask, &res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); if ((status != IB_REMOTE_ERROR) || (res_sa_mad.status != IB_SA_MAD_STATUS_REQ_INVALID)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02BD: " "Failed to catch BAD delete from IPoIB: %s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); status = IB_ERROR; goto Exit; } /* Prepare another MCG for the following tests : */ OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking Create given MGID=%s\n\t\t(o15.0.1.4)...\n", inet_ntop(AF_INET6, osm_ipoib_mgid.raw, gid_str, sizeof gid_str)); mc_req_rec.mgid = good_mgid; mc_req_rec.mgid.raw[12] = 0xAA; mc_req_rec.pkt_life = 0 | IB_PATH_SELECTOR_GREATER_THAN << 6; mc_req_rec.scope_state = 0x21; /* Full memeber */ comp_mask = IB_MCR_COMPMASK_GID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */ IB_MCR_COMPMASK_LIFE | IB_MCR_COMPMASK_LIFE_SEL; status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02BE: " "Failed to create MCG for %s - got %s/%s\n", inet_ntop(AF_INET6, good_mgid.raw, gid_str, sizeof gid_str), ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); goto Exit; } /* - Try delete with valid join state */ OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking Full Delete of a group (o15.0.1.14)...\n"); mc_req_rec.scope_state = 0x21; /* the FullMember is the current JoinState */ status = osmt_send_mcast_request(p_osmt, 0, &mc_req_rec, comp_mask, &res_sa_mad); if (status != IB_SUCCESS) { goto Exit; } /* o15.0.1.15: */ /* - Try deletion of the IPoIB MCG and get: ERR_REQ_INVALID */ OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking BAD Delete of IPoIB membership (no prev join) (o15.0.1.15)...\n"); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); mc_req_rec.mgid = osm_ipoib_mgid; mc_req_rec.rate = IB_LINK_WIDTH_ACTIVE_1X | IB_PATH_SELECTOR_GREATER_THAN << 6; mc_req_rec.scope_state = 0x21; /* delete full member */ status = osmt_send_mcast_request(p_osmt, 0, /* delete flag */ &mc_req_rec, comp_mask, &res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); if ((status != IB_REMOTE_ERROR) || (res_sa_mad.status != IB_SA_MAD_STATUS_REQ_INVALID)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0223: " "Failed to catch BAD delete from IPoIB: %s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); status = IB_ERROR; goto Exit; } /**************************************************************************/ /* Checking join with invalid MTU */ osmt_init_mc_query_rec(p_osmt, &mc_req_rec); OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking Join with unrealistic mtu : \n" "\t\tFirst create new MCG than try to join it \n" "\t\twith unrealistic MTU greater than 4096 (o15.0.1.8)...\n"); /* First create new mgrp */ ib_member_set_join_state(&mc_req_rec, IB_MC_REC_STATE_FULL_MEMBER); mc_req_rec.mtu = IB_MTU_LEN_1024 | IB_PATH_SELECTOR_EXACTLY << 6; memset(&mc_req_rec.mgid, 0, sizeof(ib_gid_t)); comp_mask = IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */ IB_MCR_COMPMASK_MTU_SEL | IB_MCR_COMPMASK_MTU; status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); p_mc_res = ib_sa_mad_get_payload_ptr(&res_sa_mad); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02EB: " "Failed to create new mgrp\n"); goto Exit; } memcpy(&tmp_mgid, &p_mc_res->mgid, sizeof(ib_gid_t)); osm_dump_mc_record(&p_osmt->log, p_mc_res, OSM_LOG_INFO); /* tmp_mtu = p_mc_res->mtu & 0x3F; */ /* impossible requested mtu always greater than exist in MCG */ mc_req_rec.mtu = IB_MTU_LEN_4096 | IB_PATH_SELECTOR_GREATER_THAN << 6; memcpy(&mc_req_rec.mgid, &tmp_mgid, sizeof(ib_gid_t)); ib_member_set_join_state(&mc_req_rec, IB_MC_REC_STATE_FULL_MEMBER); comp_mask = IB_MCR_COMPMASK_GID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_MTU_SEL | IB_MCR_COMPMASK_MTU; OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); if (status == IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02E4: " "Expected REMOTE ERROR got:%s/%s\n", ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); status = IB_ERROR; goto Exit; } /* - Try GetTable with PortGUID wildcarded and get back some groups. */ status = osmt_query_mcast(p_osmt); cnt = cl_qmap_count(&p_osmt->exp_subn.mgrp_mlid_tbl); OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "(Before checking Max MCG creation): " "Number of MC Records found in SA DB is %d\n", cnt); /**************************************************************************/ /* Checking join on behalf of remote port gid */ OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking Proxy Join...\n"); osmt_init_mc_query_rec(p_osmt, &mc_req_rec); memset(&context, 0, sizeof(context)); /* * Do a blocking query for all NodeRecords in the subnet. */ status = osmtest_get_all_recs(p_osmt, IB_MAD_ATTR_NODE_RECORD, sizeof(*p_rec), &context); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02E5: " "osmtest_get_all_recs failed on getting all node records(%s)\n", ib_get_err_str(status)); goto Exit; } /* * Populate the database with the received records. */ num_recs = context.result.result_cnt; OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Received %u records\n", num_recs); for (i = 0; i < num_recs; i++) { p_rec = osmv_get_query_node_rec(context.result.p_result_madw, i); if (p_rec->node_info.port_guid != p_osmt->local_port.port_guid && p_rec->node_info.node_type == IB_NODE_TYPE_CA) { OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "remote port_guid = 0x%" PRIx64 "\n", cl_ntoh64(p_rec->node_info.port_guid)); remote_port_guid = p_rec->node_info.port_guid; i = num_recs; break; } } if (remote_port_guid != 0x0) { ib_member_set_join_state(&mc_req_rec, IB_MC_REC_STATE_FULL_MEMBER); memset(&mc_req_rec.mgid, 0, sizeof(ib_gid_t)); mc_req_rec.port_gid.unicast.interface_id = remote_port_guid; comp_mask = IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS; /* all above are required */ status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02B4: " "Could not join on behalf of remote port 0x%016" PRIx64 " remote status: %s\n", cl_ntoh64(remote_port_guid), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); status = IB_ERROR; goto Exit; } p_mc_res = ib_sa_mad_get_payload_ptr(&res_sa_mad); memcpy(&proxy_mgid, &p_mc_res->mgid, sizeof(ib_gid_t)); /* First try a bad deletion then good one */ OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Trying deletion of remote port with local port guid\n"); osmt_init_mc_query_rec(p_osmt, &mc_req_rec); ib_member_set_join_state(&mc_req_rec, IB_MC_REC_STATE_FULL_MEMBER); comp_mask = IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_JOIN_STATE; OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); status = osmt_send_mcast_request(p_osmt, 0, /* delete flag */ &mc_req_rec, comp_mask, &res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); if (status == IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02A9: " "Successful deletion of remote port guid with local one MGID : " "%s, Got : %s/%s\n", inet_ntop(AF_INET6, p_mgrp->mcmember_rec.mgid.raw, gid_str, sizeof gid_str), ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); status = IB_ERROR; goto Exit; } OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Trying deletion of remote port with the right port guid\n"); osmt_init_mc_query_rec(p_osmt, &mc_req_rec); ib_member_set_join_state(&mc_req_rec, IB_MC_REC_STATE_FULL_MEMBER); mc_req_rec.mgid = proxy_mgid; mc_req_rec.port_gid.unicast.interface_id = remote_port_guid; comp_mask = IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_JOIN_STATE; status = osmt_send_mcast_request(p_osmt, 0, /* delete flag */ &mc_req_rec, comp_mask, &res_sa_mad); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02B0: " "Failed to delete mgid with remote port guid MGID : " "%s, Got : %s/%s\n", inet_ntop(AF_INET6, p_mgrp->mcmember_rec.mgid.raw, gid_str, sizeof gid_str), ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); goto Exit; } } else { OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Could not check proxy join since could not found remote port, different from local port\n"); } /* prepare init for next check */ osmt_init_mc_query_rec(p_osmt, &mc_req_rec); /**************************************************************************/ if (p_osmt->opt.mmode > 2) { /* Check invalid Join with max mlid which is more than the Mellanox switches support 0xC000+0x1000 = 0xd000 */ OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Checking Creation of Maximum avaliable Groups (MulticastFDBCap)...\n"); tmp_mlid = cl_ntoh16(max_mlid) - cnt; while (tmp_mlid > 0 && !ReachedMlidLimit) { uint16_t cur_mlid = 0; /* Request Set */ ib_member_set_join_state(&mc_req_rec, IB_MC_REC_STATE_FULL_MEMBER); /* Good Flow - mgid is 0 while giving all required fields for join : P_Key, Q_Key, SL, FlowLabel, Tclass */ mc_req_rec.rate = IB_LINK_WIDTH_ACTIVE_1X | IB_PATH_SELECTOR_GREATER_THAN << 6; mc_req_rec.mlid = max_mlid; memset(&mc_req_rec.mgid, 0, sizeof(ib_gid_t)); comp_mask = IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_QKEY | IB_MCR_COMPMASK_PKEY | IB_MCR_COMPMASK_SL | IB_MCR_COMPMASK_FLOW | IB_MCR_COMPMASK_JOIN_STATE | IB_MCR_COMPMASK_TCLASS | /* all above are required */ IB_MCR_COMPMASK_MLID; status = osmt_send_mcast_request(p_osmt, 1, &mc_req_rec, comp_mask, &res_sa_mad); p_mc_res = ib_sa_mad_get_payload_ptr(&res_sa_mad); if (status != IB_SUCCESS) { if (cur_mlid > cl_ntoh16(max_mlid)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 2E1 " "Successful Join with greater mlid than switches support (MulticastFDBCap) 0x%04X\n", cur_mlid); status = IB_ERROR; osm_dump_mc_record(&p_osmt->log, p_mc_res, OSM_LOG_VERBOSE); goto Exit; } else if ((res_sa_mad. status & IB_SMP_STATUS_MASK) == IB_SA_MAD_STATUS_NO_RESOURCES) { /* You can quitly exit the loop since no available mlid in SA DB i.e. reached the maximum valiad avalable mlid */ ReachedMlidLimit = TRUE; } } else { cur_mlid = cl_ntoh16(p_mc_res->mlid); /* Save the mlid created in test_created_mlids map */ p_recvd_rec = (ib_member_rec_t *) ib_sa_mad_get_payload_ptr(&res_sa_mad); OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Created MGID:%s MLID:0x%04X\n", inet_ntop(AF_INET6, p_recvd_rec->mgid.raw, gid_str, sizeof gid_str), cl_ntoh16(p_recvd_rec->mlid)); cl_map_insert(&test_created_mlids, cl_ntoh16(p_recvd_rec->mlid), p_recvd_rec); } tmp_mlid--; } } /* Prepare the mc_req_rec for the rest of the flow */ osmt_init_mc_query_rec(p_osmt, &mc_req_rec); /**************************************************************************/ /* o15.0.1.16: */ /* - Try GetTable with PortGUID wildcarded and get back some groups. */ status = osmt_query_mcast(p_osmt); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02B1: " "Failed to query multicast groups: %s\n", ib_get_err_str(status)); goto Exit; } cnt = cl_qmap_count(&p_osmt->exp_subn.mgrp_mlid_tbl); OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "(Before Deletion of all MCG): " "Number of MC Records found in SA DB is %d\n", cnt); /* Delete all MCG that are not of IPoIB */ OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Cleanup all MCG that are not IPoIB...\n"); p_mgrp_mlid_tbl = &p_osmt->exp_subn.mgrp_mlid_tbl; p_mgrp = (osmtest_mgrp_t *) cl_qmap_head(p_mgrp_mlid_tbl); /* scan all available multicast groups in the DB and fill in the table */ while (p_mgrp != (osmtest_mgrp_t *) cl_qmap_end(p_mgrp_mlid_tbl)) { /* Only if different from IPoIB Mgid try to delete */ if (!IS_IPOIB_MGID(&p_mgrp->mcmember_rec.mgid)) { osmt_init_mc_query_rec(p_osmt, &mc_req_rec); mc_req_rec.mgid = p_mgrp->mcmember_rec.mgid; /* o15-0.1.4 - need to specify the oppsite state for a valid delete */ if (!memcmp (&special_mgid, &p_mgrp->mcmember_rec.mgid, sizeof(special_mgid))) { mc_req_rec.scope_state = 0x2F; } else { mc_req_rec.scope_state = 0x21; } comp_mask = IB_MCR_COMPMASK_MGID | IB_MCR_COMPMASK_PORT_GID | IB_MCR_COMPMASK_JOIN_STATE; OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Sending request to delete MGID : %s" ", scope_state : 0x%02X\n", inet_ntop(AF_INET6, mc_req_rec.mgid.raw, gid_str, sizeof gid_str), mc_req_rec.scope_state); status = osmt_send_mcast_request(p_osmt, 0, /* delete flag */ &mc_req_rec, comp_mask, &res_sa_mad); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02FF: Failed to delete MGID : %s" " ,\n\t\t it is not our MCG, Status : %s/%s\n", inet_ntop(AF_INET6, p_mgrp->mcmember_rec.mgid.raw, gid_str, sizeof gid_str), ib_get_err_str(status), ib_get_mad_status_str((ib_mad_t *) (&res_sa_mad))); fail_to_delete_mcg++; } } else { end_ipoib_cnt++; } p_mgrp = (osmtest_mgrp_t *) cl_qmap_next(&p_mgrp->map_item); } status = osmt_query_mcast(p_osmt); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02B2 " "GetTable of all records has failed - got %s\n", ib_get_err_str(status)); goto Exit; } /* If we are in single mode check flow - need to make sure all the multicast groups that are left are not ones created during the flow. */ if (p_osmt->opt.mmode == 1 || p_osmt->opt.mmode == 3) { end_cnt = cl_qmap_count(&p_osmt->exp_subn.mgrp_mlid_tbl); OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Status of MC Records in SA DB during the test flow:\n" " Beginning of test\n" " Unrelated to the test: %d\n" " IPoIB MC Records : %d\n" " Total : %d\n" " End of test\n" " Failed to delete : %d\n" " IPoIB MC Records : %d\n" " Total : %d\n", mcg_outside_test_cnt, /* Non-IPoIB that existed at the beginning */ start_ipoib_cnt, /* IPoIB records */ start_cnt, /* Total: IPoIB and MC Records unrelated to the test */ fail_to_delete_mcg, /* Failed to delete at the end */ end_ipoib_cnt, /* IPoIB records */ end_cnt); /* Total MC Records at the end */ /* when we compare num of MCG we should consider an outside source which create other MCGs */ if ((end_cnt - fail_to_delete_mcg - end_ipoib_cnt) != (start_cnt - mcg_outside_test_cnt - start_ipoib_cnt)) { OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Got different number of non-IPoIB records stored in SA DB\n\t\t" "at Start got %d, at End got %d (IPoIB groups only)\n", (start_cnt - mcg_outside_test_cnt - start_ipoib_cnt), (end_cnt - fail_to_delete_mcg - end_ipoib_cnt)); } p_mgrp_mlid_tbl = &p_osmt->exp_subn.mgrp_mlid_tbl; p_mgrp = (osmtest_mgrp_t *) cl_qmap_head(p_mgrp_mlid_tbl); while (p_mgrp != (osmtest_mgrp_t *) cl_qmap_end(p_mgrp_mlid_tbl)) { uint16_t mlid = (uint16_t) cl_qmap_key((cl_map_item_t *) p_mgrp); OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Found MLID:0x%04X\n", mlid); /* Check if the mlid is in the test_created_mlids. If TRUE, then we didn't delete a MCgroup that was created in this flow. */ if (cl_map_get(&test_created_mlids, mlid) != NULL) { /* This means that we still have an mgrp that we created!! */ OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 02FE: " "Wasn't able to erase mgrp with MGID:%s" " MLID:0x%04X\n", inet_ntop(AF_INET6, p_mgrp->mcmember_rec.mgid.raw, gid_str, sizeof gid_str), mlid); got_error = TRUE; } else { OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Still exists %s MGID:%s\n", (IS_IPOIB_MGID (&p_mgrp->mcmember_rec. mgid)) ? "IPoIB" : "non-IPoIB", inet_ntop(AF_INET6, p_mgrp->mcmember_rec.mgid.raw, gid_str, sizeof gid_str)); } p_mgrp = (osmtest_mgrp_t *) cl_qmap_next(&p_mgrp->map_item); } if (got_error) { __osmt_print_all_multicast_records(p_osmt); status = IB_ERROR; } } Exit: OSM_LOG_EXIT(&p_osmt->log); return status; } Index: stable/9/contrib/ofed/management/opensm/osmtest/osmtest.c =================================================================== --- stable/9/contrib/ofed/management/opensm/osmtest/osmtest.c (revision 276976) +++ stable/9/contrib/ofed/management/opensm/osmtest/osmtest.c (revision 276977) @@ -1,7403 +1,7403 @@ /* * Copyright (c) 2006-2008 Voltaire, Inc. All rights reserved. * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved. * Copyright (c) 1996-2003 Intel Corporation. All rights reserved. * * This software is available to you under a choice of one of two * licenses. You may choose to be licensed under the terms of the GNU * General Public License (GPL) Version 2, available from the file * COPYING in the main directory of this source tree, or the * OpenIB.org BSD license below: * * Redistribution and use in source and binary forms, with or * without modification, are permitted provided that the following * conditions are met: * * - Redistributions of source code must retain the above * copyright notice, this list of conditions and the following * disclaimer. * * - Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials * provided with the distribution. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * */ /* TODO : Check why we dont free the cl_qmap_items we store when reading DB */ /* * Abstract: * Implementation of osmtest_t. * This object represents the OSMTest Test object. * */ #ifdef __WIN__ #pragma warning(disable : 4996) #endif #include #include #include #ifdef __WIN__ #include #else #include #include #endif #include #include "osmtest.h" #ifndef __WIN__ #define strnicmp strncasecmp #endif #define POOL_MIN_ITEMS 64 #define GUID_ARRAY_SIZE 64 typedef struct _osmtest_sm_info_rec { ib_net64_t sm_guid; ib_net16_t lid; uint8_t priority; uint8_t sm_state; } osmtest_sm_info_rec_t; typedef struct _osmtest_inform_info { boolean_t subscribe; ib_net32_t qpn; ib_net16_t trap; } osmtest_inform_info_t; typedef struct _osmtest_inform_info_rec { ib_gid_t subscriber_gid; ib_net16_t subscriber_enum; } osmtest_inform_info_rec_t; typedef enum _osmtest_token_val { OSMTEST_TOKEN_COMMENT = 0, OSMTEST_TOKEN_END, OSMTEST_TOKEN_DEFINE_NODE, OSMTEST_TOKEN_DEFINE_PORT, OSMTEST_TOKEN_DEFINE_PATH, OSMTEST_TOKEN_DEFINE_LINK, OSMTEST_TOKEN_LID, OSMTEST_TOKEN_BASE_VERSION, OSMTEST_TOKEN_CLASS_VERSION, OSMTEST_TOKEN_NODE_TYPE, OSMTEST_TOKEN_NUM_PORTS, OSMTEST_TOKEN_SYS_GUID, OSMTEST_TOKEN_NODE_GUID, OSMTEST_TOKEN_PORT_GUID, OSMTEST_TOKEN_PARTITION_CAP, OSMTEST_TOKEN_DEVICE_ID, OSMTEST_TOKEN_REVISION, OSMTEST_TOKEN_PORT_NUM, OSMTEST_TOKEN_VENDOR_ID, OSMTEST_TOKEN_DGID, OSMTEST_TOKEN_SGID, OSMTEST_TOKEN_DLID, OSMTEST_TOKEN_SLID, OSMTEST_TOKEN_HOP_FLOW_RAW, OSMTEST_TOKEN_TCLASS, OSMTEST_TOKEN_NUM_PATH, OSMTEST_TOKEN_PKEY, OSMTEST_TOKEN_SL, OSMTEST_TOKEN_RATE, OSMTEST_TOKEN_PKT_LIFE, OSMTEST_TOKEN_PREFERENCE, OSMTEST_TOKEN_MKEY, OSMTEST_TOKEN_SUBN_PREF, OSMTEST_TOKEN_BASE_LID, OSMTEST_TOKEN_SM_BASE_LID, OSMTEST_TOKEN_CAP_MASK, OSMTEST_TOKEN_DIAG_CODE, OSMTEST_TOKEN_MKEY_LEASE_PER, OSMTEST_TOKEN_LOC_PORT_NUM, OSMTEST_TOKEN_LINK_WID_EN, OSMTEST_TOKEN_LINK_WID_SUP, OSMTEST_TOKEN_LINK_WID_ACT, OSMTEST_TOKEN_LINK_SPEED_SUP, OSMTEST_TOKEN_PORT_STATE, OSMTEST_TOKEN_STATE_INFO2, OSMTEST_TOKEN_MKEY_PROT_BITS, OSMTEST_TOKEN_LMC, OSMTEST_TOKEN_LINK_SPEED, OSMTEST_TOKEN_MTU_SMSL, OSMTEST_TOKEN_VL_CAP, OSMTEST_TOKEN_VL_HIGH_LIMIT, OSMTEST_TOKEN_VL_ARB_HIGH_CAP, OSMTEST_TOKEN_VL_ARB_LOW_CAP, OSMTEST_TOKEN_MTU_CAP, OSMTEST_TOKEN_VL_STALL_LIFE, OSMTEST_TOKEN_VL_ENFORCE, OSMTEST_TOKEN_MKEY_VIOL, OSMTEST_TOKEN_PKEY_VIOL, OSMTEST_TOKEN_QKEY_VIOL, OSMTEST_TOKEN_GUID_CAP, OSMTEST_TOKEN_SUBN_TIMEOUT, OSMTEST_TOKEN_RESP_TIME_VAL, OSMTEST_TOKEN_ERR_THRESHOLD, OSMTEST_TOKEN_MTU, OSMTEST_TOKEN_FROMLID, OSMTEST_TOKEN_FROMPORTNUM, OSMTEST_TOKEN_TOPORTNUM, OSMTEST_TOKEN_TOLID, OSMTEST_TOKEN_UNKNOWN } osmtest_token_val_t; typedef struct _osmtest_token { osmtest_token_val_t val; size_t str_size; const char *str; } osmtest_token_t; const osmtest_token_t token_array[] = { {OSMTEST_TOKEN_COMMENT, 1, "#"}, {OSMTEST_TOKEN_END, 3, "END"}, {OSMTEST_TOKEN_DEFINE_NODE, 11, "DEFINE_NODE"}, {OSMTEST_TOKEN_DEFINE_PORT, 11, "DEFINE_PORT"}, {OSMTEST_TOKEN_DEFINE_PATH, 11, "DEFINE_PATH"}, {OSMTEST_TOKEN_DEFINE_LINK, 11, "DEFINE_LINK"}, {OSMTEST_TOKEN_LID, 3, "LID"}, {OSMTEST_TOKEN_BASE_VERSION, 12, "BASE_VERSION"}, {OSMTEST_TOKEN_CLASS_VERSION, 13, "CLASS_VERSION"}, {OSMTEST_TOKEN_NODE_TYPE, 9, "NODE_TYPE"}, {OSMTEST_TOKEN_NUM_PORTS, 9, "NUM_PORTS"}, {OSMTEST_TOKEN_SYS_GUID, 8, "SYS_GUID"}, {OSMTEST_TOKEN_NODE_GUID, 9, "NODE_GUID"}, {OSMTEST_TOKEN_PORT_GUID, 9, "PORT_GUID"}, {OSMTEST_TOKEN_PARTITION_CAP, 13, "PARTITION_CAP"}, {OSMTEST_TOKEN_DEVICE_ID, 9, "DEVICE_ID"}, {OSMTEST_TOKEN_REVISION, 8, "REVISION"}, {OSMTEST_TOKEN_PORT_NUM, 8, "PORT_NUM"}, {OSMTEST_TOKEN_VENDOR_ID, 9, "VENDOR_ID"}, {OSMTEST_TOKEN_DGID, 4, "DGID"}, {OSMTEST_TOKEN_SGID, 4, "SGID"}, {OSMTEST_TOKEN_DLID, 4, "DLID"}, {OSMTEST_TOKEN_SLID, 4, "SLID"}, {OSMTEST_TOKEN_HOP_FLOW_RAW, 12, "HOP_FLOW_RAW"}, {OSMTEST_TOKEN_TCLASS, 6, "TCLASS"}, {OSMTEST_TOKEN_NUM_PATH, 8, "NUM_PATH"}, {OSMTEST_TOKEN_PKEY, 4, "PKEY"}, {OSMTEST_TOKEN_SL, 2, "SL"}, {OSMTEST_TOKEN_RATE, 4, "RATE"}, {OSMTEST_TOKEN_PKT_LIFE, 8, "PKT_LIFE"}, {OSMTEST_TOKEN_PREFERENCE, 10, "PREFERENCE"}, {OSMTEST_TOKEN_MKEY, 4, "M_KEY"}, {OSMTEST_TOKEN_SUBN_PREF, 13, "SUBNET_PREFIX"}, {OSMTEST_TOKEN_BASE_LID, 8, "BASE_LID"}, {OSMTEST_TOKEN_SM_BASE_LID, 18, "MASTER_SM_BASE_LID"}, {OSMTEST_TOKEN_CAP_MASK, 15, "CAPABILITY_MASK"}, {OSMTEST_TOKEN_DIAG_CODE, 9, "DIAG_CODE"}, {OSMTEST_TOKEN_MKEY_LEASE_PER, 18, "m_key_lease_period"}, {OSMTEST_TOKEN_LOC_PORT_NUM, 14, "local_port_num"}, {OSMTEST_TOKEN_LINK_WID_EN, 18, "link_width_enabled"}, {OSMTEST_TOKEN_LINK_WID_SUP, 20, "link_width_supported"}, {OSMTEST_TOKEN_LINK_WID_ACT, 17, "link_width_active"}, {OSMTEST_TOKEN_LINK_SPEED_SUP, 20, "link_speed_supported"}, {OSMTEST_TOKEN_PORT_STATE, 10, "port_state"}, {OSMTEST_TOKEN_STATE_INFO2, 10, "state_info2"}, {OSMTEST_TOKEN_MKEY_PROT_BITS, 3, "mpb"}, {OSMTEST_TOKEN_LMC, 3, "lmc"}, {OSMTEST_TOKEN_LINK_SPEED, 10, "link_speed"}, {OSMTEST_TOKEN_MTU_SMSL, 8, "mtu_smsl"}, {OSMTEST_TOKEN_VL_CAP, 6, "vl_cap"}, {OSMTEST_TOKEN_VL_HIGH_LIMIT, 13, "vl_high_limit"}, {OSMTEST_TOKEN_VL_ARB_HIGH_CAP, 15, "vl_arb_high_cap"}, {OSMTEST_TOKEN_VL_ARB_LOW_CAP, 14, "vl_arb_low_cap"}, {OSMTEST_TOKEN_MTU_CAP, 7, "mtu_cap"}, {OSMTEST_TOKEN_VL_STALL_LIFE, 13, "vl_stall_life"}, {OSMTEST_TOKEN_VL_ENFORCE, 10, "vl_enforce"}, {OSMTEST_TOKEN_MKEY_VIOL, 16, "m_key_violations"}, {OSMTEST_TOKEN_PKEY_VIOL, 16, "p_key_violations"}, {OSMTEST_TOKEN_QKEY_VIOL, 16, "q_key_violations"}, {OSMTEST_TOKEN_GUID_CAP, 8, "guid_cap"}, {OSMTEST_TOKEN_SUBN_TIMEOUT, 14, "subnet_timeout"}, {OSMTEST_TOKEN_RESP_TIME_VAL, 15, "resp_time_value"}, {OSMTEST_TOKEN_ERR_THRESHOLD, 15, "error_threshold"}, {OSMTEST_TOKEN_MTU, 3, "MTU"}, /* must be after the other mtu... tokens. */ {OSMTEST_TOKEN_FROMLID, 8, "from_lid"}, {OSMTEST_TOKEN_FROMPORTNUM, 13, "from_port_num"}, {OSMTEST_TOKEN_TOPORTNUM, 11, "to_port_num"}, {OSMTEST_TOKEN_TOLID, 6, "to_lid"}, {OSMTEST_TOKEN_UNKNOWN, 0, ""} /* must be last entry */ }; #define IB_MAD_STATUS_CLASS_MASK (CL_HTON16(0xFF00)) static const char ib_mad_status_str_busy[] = "IB_MAD_STATUS_BUSY"; static const char ib_mad_status_str_redirect[] = "IB_MAD_STATUS_REDIRECT"; static const char ib_mad_status_str_unsup_class_ver[] = "IB_MAD_STATUS_UNSUP_CLASS_VER"; static const char ib_mad_status_str_unsup_method[] = "IB_MAD_STATUS_UNSUP_METHOD"; static const char ib_mad_status_str_unsup_method_attr[] = "IB_MAD_STATUS_UNSUP_METHOD_ATTR"; static const char ib_mad_status_str_invalid_field[] = "IB_MAD_STATUS_INVALID_FIELD"; static const char ib_mad_status_str_no_resources[] = "IB_SA_MAD_STATUS_NO_RESOURCES"; static const char ib_mad_status_str_req_invalid[] = "IB_SA_MAD_STATUS_REQ_INVALID"; static const char ib_mad_status_str_no_records[] = "IB_SA_MAD_STATUS_NO_RECORDS"; static const char ib_mad_status_str_too_many_records[] = "IB_SA_MAD_STATUS_TOO_MANY_RECORDS"; static const char ib_mad_status_str_invalid_gid[] = "IB_SA_MAD_STATUS_INVALID_GID"; static const char ib_mad_status_str_insuf_comps[] = "IB_SA_MAD_STATUS_INSUF_COMPS"; static const char generic_or_str[] = " | "; /********************************************************************** **********************************************************************/ const char *ib_get_mad_status_str(IN const ib_mad_t * const p_mad) { static char line[512]; uint32_t offset = 0; ib_net16_t status; boolean_t first = TRUE; line[offset] = '\0'; status = (ib_net16_t) (p_mad->status & IB_SMP_STATUS_MASK); if (status == 0) { strcat(&line[offset], "IB_SUCCESS"); return (line); } if (status & IB_MAD_STATUS_BUSY) { strcat(&line[offset], ib_mad_status_str_busy); offset += sizeof(ib_mad_status_str_busy); } if (status & IB_MAD_STATUS_REDIRECT) { if (!first) { strcat(&line[offset], generic_or_str); offset += sizeof(generic_or_str) - 1; } first = FALSE; strcat(&line[offset], ib_mad_status_str_redirect); offset += sizeof(ib_mad_status_str_redirect) - 1; } if ((status & IB_MAD_STATUS_INVALID_FIELD) == IB_MAD_STATUS_UNSUP_CLASS_VER) { if (!first) { strcat(&line[offset], generic_or_str); offset += sizeof(generic_or_str) - 1; } first = FALSE; strcat(&line[offset], ib_mad_status_str_unsup_class_ver); offset += sizeof(ib_mad_status_str_unsup_class_ver) - 1; } if ((status & IB_MAD_STATUS_INVALID_FIELD) == IB_MAD_STATUS_UNSUP_METHOD) { if (!first) { strcat(&line[offset], generic_or_str); offset += sizeof(generic_or_str) - 1; } first = FALSE; strcat(&line[offset], ib_mad_status_str_unsup_method); offset += sizeof(ib_mad_status_str_unsup_method) - 1; } if ((status & IB_MAD_STATUS_INVALID_FIELD) == IB_MAD_STATUS_UNSUP_METHOD_ATTR) { if (!first) { strcat(&line[offset], generic_or_str); offset += sizeof(generic_or_str) - 1; } first = FALSE; strcat(&line[offset], ib_mad_status_str_unsup_method_attr); offset += sizeof(ib_mad_status_str_unsup_method_attr) - 1; } if ((status & IB_MAD_STATUS_INVALID_FIELD) == IB_MAD_STATUS_INVALID_FIELD) { if (!first) { strcat(&line[offset], generic_or_str); offset += sizeof(generic_or_str) - 1; } first = FALSE; strcat(&line[offset], ib_mad_status_str_invalid_field); offset += sizeof(ib_mad_status_str_invalid_field) - 1; } if ((status & IB_MAD_STATUS_CLASS_MASK) == IB_SA_MAD_STATUS_NO_RESOURCES) { if (!first) { strcat(&line[offset], generic_or_str); offset += sizeof(generic_or_str) - 1; } first = FALSE; strcat(&line[offset], ib_mad_status_str_no_resources); offset += sizeof(ib_mad_status_str_no_resources) - 1; } if ((status & IB_MAD_STATUS_CLASS_MASK) == IB_SA_MAD_STATUS_REQ_INVALID) { if (!first) { strcat(&line[offset], generic_or_str); offset += sizeof(generic_or_str) - 1; } first = FALSE; strcat(&line[offset], ib_mad_status_str_req_invalid); offset += sizeof(ib_mad_status_str_req_invalid) - 1; } if ((status & IB_MAD_STATUS_CLASS_MASK) == IB_SA_MAD_STATUS_NO_RECORDS) { if (!first) { strcat(&line[offset], generic_or_str); offset += sizeof(generic_or_str) - 1; } first = FALSE; strcat(&line[offset], ib_mad_status_str_no_records); offset += sizeof(ib_mad_status_str_no_records) - 1; } if ((status & IB_MAD_STATUS_CLASS_MASK) == IB_SA_MAD_STATUS_TOO_MANY_RECORDS) { if (!first) { strcat(&line[offset], generic_or_str); offset += sizeof(generic_or_str) - 1; } first = FALSE; strcat(&line[offset], ib_mad_status_str_too_many_records); offset += sizeof(ib_mad_status_str_too_many_records) - 1; } if ((status & IB_MAD_STATUS_CLASS_MASK) == IB_SA_MAD_STATUS_INVALID_GID) { if (!first) { strcat(&line[offset], generic_or_str); offset += sizeof(generic_or_str) - 1; } first = FALSE; strcat(&line[offset], ib_mad_status_str_invalid_gid); offset += sizeof(ib_mad_status_str_invalid_gid) - 1; } if ((status & IB_MAD_STATUS_CLASS_MASK) == IB_SA_MAD_STATUS_INSUF_COMPS) { if (!first) { strcat(&line[offset], generic_or_str); offset += sizeof(generic_or_str) - 1; } first = FALSE; strcat(&line[offset], ib_mad_status_str_insuf_comps); offset += sizeof(ib_mad_status_str_insuf_comps) - 1; } return (line); } /********************************************************************** **********************************************************************/ void subnet_construct(IN subnet_t * const p_subn) { cl_qmap_init(&p_subn->link_tbl); cl_qmap_init(&p_subn->node_lid_tbl); cl_qmap_init(&p_subn->node_guid_tbl); cl_qmap_init(&p_subn->mgrp_mlid_tbl); /* NO WAY TO HAVE UNIQUE PORT BY LID OR GUID */ /* cl_qmap_init( &p_subn->port_lid_tbl ); */ /* cl_qmap_init( &p_subn->port_guid_tbl ); */ /* port key is a lid and num pair */ cl_qmap_init(&p_subn->port_key_tbl); cl_qmap_init(&p_subn->path_tbl); } /********************************************************************** **********************************************************************/ cl_status_t subnet_init(IN subnet_t * const p_subn) { cl_status_t status = IB_SUCCESS; subnet_construct(p_subn); return (status); } /********************************************************************** **********************************************************************/ void osmtest_construct(IN osmtest_t * const p_osmt) { memset(p_osmt, 0, sizeof(*p_osmt)); osm_log_construct(&p_osmt->log); subnet_construct(&p_osmt->exp_subn); } /********************************************************************** **********************************************************************/ void osmtest_destroy(IN osmtest_t * const p_osmt) { cl_map_item_t *p_item, *p_next_item; /* Currently there is a problem with IBAL exit flow - memory overrun, so bypass vendor deletion - it will be cleaned by the Windows OS */ #ifndef __WIN__ if (p_osmt->p_vendor) osm_vendor_delete(&p_osmt->p_vendor); #endif cl_qpool_destroy(&p_osmt->port_pool); cl_qpool_destroy(&p_osmt->node_pool); /* destroy the qmap tables */ p_next_item = cl_qmap_head(&p_osmt->exp_subn.link_tbl); while (p_next_item != cl_qmap_end(&p_osmt->exp_subn.link_tbl)) { p_item = p_next_item; p_next_item = cl_qmap_next(p_item); free(p_item); } p_next_item = cl_qmap_head(&p_osmt->exp_subn.mgrp_mlid_tbl); while (p_next_item != cl_qmap_end(&p_osmt->exp_subn.mgrp_mlid_tbl)) { p_item = p_next_item; p_next_item = cl_qmap_next(p_item); free(p_item); } p_next_item = cl_qmap_head(&p_osmt->exp_subn.node_guid_tbl); while (p_next_item != cl_qmap_end(&p_osmt->exp_subn.node_guid_tbl)) { p_item = p_next_item; p_next_item = cl_qmap_next(p_item); free(p_item); } p_next_item = cl_qmap_head(&p_osmt->exp_subn.node_lid_tbl); while (p_next_item != cl_qmap_end(&p_osmt->exp_subn.node_lid_tbl)) { p_item = p_next_item; p_next_item = cl_qmap_next(p_item); free(p_item); } p_next_item = cl_qmap_head(&p_osmt->exp_subn.path_tbl); while (p_next_item != cl_qmap_end(&p_osmt->exp_subn.path_tbl)) { p_item = p_next_item; p_next_item = cl_qmap_next(p_item); free(p_item); } p_next_item = cl_qmap_head(&p_osmt->exp_subn.port_key_tbl); while (p_next_item != cl_qmap_end(&p_osmt->exp_subn.port_key_tbl)) { p_item = p_next_item; p_next_item = cl_qmap_next(p_item); free(p_item); } osm_log_destroy(&p_osmt->log); } /********************************************************************** **********************************************************************/ ib_api_status_t osmtest_init(IN osmtest_t * const p_osmt, IN const osmtest_opt_t * const p_opt, IN const osm_log_level_t log_flags) { ib_api_status_t status; /* Can't use log macros here, since we're initializing the log. */ osmtest_construct(p_osmt); status = osm_log_init_v2(&p_osmt->log, p_opt->force_log_flush, 0x0001, p_opt->log_file, 0, TRUE); if (status != IB_SUCCESS) return (status); /* but we do not want any extra stuff here */ osm_log_set_level(&p_osmt->log, log_flags); OSM_LOG(&p_osmt->log, OSM_LOG_FUNCS, "[\n"); p_osmt->opt = *p_opt; status = cl_qpool_init(&p_osmt->node_pool, POOL_MIN_ITEMS, 0, POOL_MIN_ITEMS, sizeof(node_t), NULL, NULL, NULL); CL_ASSERT(status == CL_SUCCESS); status = cl_qpool_init(&p_osmt->port_pool, POOL_MIN_ITEMS, 0, POOL_MIN_ITEMS, sizeof(port_t), NULL, NULL, NULL); CL_ASSERT(status == CL_SUCCESS); p_osmt->p_vendor = osm_vendor_new(&p_osmt->log, p_opt->transaction_timeout); if (p_osmt->p_vendor == NULL) { status = IB_INSUFFICIENT_RESOURCES; OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0001: " "Unable to allocate vendor object"); status = IB_ERROR; goto Exit; } osm_mad_pool_construct(&p_osmt->mad_pool); status = osm_mad_pool_init(&p_osmt->mad_pool); if (status != IB_SUCCESS) goto Exit; Exit: OSM_LOG(&p_osmt->log, OSM_LOG_FUNCS, "]\n"); return (status); } /********************************************************************** **********************************************************************/ void osmtest_query_res_cb(IN osmv_query_res_t * p_rec) { osmtest_req_context_t *const p_ctxt = (osmtest_req_context_t *) p_rec->query_context; osmtest_t *const p_osmt = p_ctxt->p_osmt; OSM_LOG_ENTER(&p_osmt->log); p_ctxt->result = *p_rec; if (p_rec->status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0003: " "Error on query (%s)\n", ib_get_err_str(p_rec->status)); } OSM_LOG_EXIT(&p_osmt->log); } /********************************************************************** **********************************************************************/ ib_api_status_t osmtest_get_all_recs(IN osmtest_t * const p_osmt, IN ib_net16_t const attr_id, IN size_t const attr_size, IN OUT osmtest_req_context_t * const p_context) { ib_api_status_t status = IB_SUCCESS; osmv_user_query_t user; osmv_query_req_t req; OSM_LOG_ENTER(&p_osmt->log); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "Getting all %s records\n", ib_get_sa_attr_str(attr_id)); /* * Do a blocking query for all records in the subnet. * The result is returned in the result field of the caller's * context structure. * * The query structures are locals. */ memset(&req, 0, sizeof(req)); memset(&user, 0, sizeof(user)); p_context->p_osmt = p_osmt; user.attr_id = attr_id; user.attr_offset = cl_ntoh16((uint16_t) (attr_size >> 3)); req.query_type = OSMV_QUERY_USER_DEFINED; req.timeout_ms = p_osmt->opt.transaction_timeout; req.retry_cnt = p_osmt->opt.retry_count; req.flags = OSM_SA_FLAGS_SYNC; req.query_context = p_context; req.pfn_query_cb = osmtest_query_res_cb; req.p_query_input = &user; req.sm_key = 0; status = osmv_query_sa(p_osmt->h_bind, &req); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0004: " "ib_query failed (%s)\n", ib_get_err_str(status)); goto Exit; } status = p_context->result.status; if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0064: " "ib_query failed (%s)\n", ib_get_err_str(status)); if (status == IB_REMOTE_ERROR) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "Remote error = %s\n", ib_get_mad_status_str(osm_madw_get_mad_ptr (p_context->result. p_result_madw))); } goto Exit; } Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ ib_api_status_t osmtest_validate_sa_class_port_info(IN osmtest_t * const p_osmt) { ib_api_status_t status = IB_SUCCESS; osmv_query_req_t req; ib_class_port_info_t *p_cpi; osmtest_req_context_t context; osmtest_req_context_t *p_context = &context; ib_sa_mad_t *p_resp_sa_madp; OSM_LOG_ENTER(&p_osmt->log); OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Getting ClassPortInfo\n"); /* * Do a blocking query for this record in the subnet. * The result is returned in the result field of the caller's * context structure. * * The query structures are locals. */ memset(&req, 0, sizeof(req)); p_context->p_osmt = p_osmt; req.query_type = OSMV_QUERY_CLASS_PORT_INFO; req.timeout_ms = p_osmt->opt.transaction_timeout; req.retry_cnt = p_osmt->opt.retry_count; req.flags = OSM_SA_FLAGS_SYNC; req.query_context = p_context; req.pfn_query_cb = osmtest_query_res_cb; req.p_query_input = 0; req.sm_key = 0; status = osmv_query_sa(p_osmt->h_bind, &req); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0065: " "ib_query failed (%s)\n", ib_get_err_str(status)); goto Exit; } status = p_context->result.status; if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0070: " "ib_query failed (%s)\n", ib_get_err_str(status)); if (status == IB_REMOTE_ERROR) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "Remote error = %s\n", ib_get_mad_status_str(osm_madw_get_mad_ptr (p_context->result. p_result_madw))); } goto Exit; } /* ok we got it so please print it out */ p_resp_sa_madp = (ib_sa_mad_t *) osm_madw_get_mad_ptr(context.result.p_result_madw); p_cpi = (ib_class_port_info_t *) ib_sa_mad_get_payload_ptr(p_resp_sa_madp); OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "\n-----------------------------\n" "SA Class Port Info:\n" " base_ver:%u\n" " class_ver:%u\n" " cap_mask:0x%X\n" " cap_mask2:0x%X\n" " resp_time_val:0x%X\n" "-----------------------------\n", p_cpi->base_ver, p_cpi->class_ver, cl_ntoh16(p_cpi->cap_mask), ib_class_cap_mask2(p_cpi), ib_class_resp_time_val(p_cpi)); Exit: #if 0 if (context.result.p_result_madw != NULL) { osm_mad_pool_put(&p_osmt->mad_pool, context.result.p_result_madw); context.result.p_result_madw = NULL; } #endif OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ ib_api_status_t osmtest_get_node_rec(IN osmtest_t * const p_osmt, IN ib_net64_t const node_guid, IN OUT osmtest_req_context_t * const p_context) { ib_api_status_t status = IB_SUCCESS; osmv_user_query_t user; osmv_query_req_t req; ib_node_record_t record; OSM_LOG_ENTER(&p_osmt->log); OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Getting node record for 0x%016" PRIx64 "\n", cl_ntoh64(node_guid)); /* * Do a blocking query for this record in the subnet. * The result is returned in the result field of the caller's * context structure. * * The query structures are locals. */ memset(&req, 0, sizeof(req)); memset(&user, 0, sizeof(user)); memset(&record, 0, sizeof(record)); record.node_info.node_guid = node_guid; p_context->p_osmt = p_osmt; user.comp_mask = IB_NR_COMPMASK_NODEGUID; user.attr_id = IB_MAD_ATTR_NODE_RECORD; user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3)); user.p_attr = &record; req.query_type = OSMV_QUERY_USER_DEFINED; req.timeout_ms = p_osmt->opt.transaction_timeout; req.retry_cnt = p_osmt->opt.retry_count; req.flags = OSM_SA_FLAGS_SYNC; req.query_context = p_context; req.pfn_query_cb = osmtest_query_res_cb; req.p_query_input = &user; req.sm_key = 0; status = osmv_query_sa(p_osmt->h_bind, &req); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0071: " "ib_query failed (%s)\n", ib_get_err_str(status)); goto Exit; } status = p_context->result.status; if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0072: " "ib_query failed (%s)\n", ib_get_err_str(status)); if (status == IB_REMOTE_ERROR) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "Remote error = %s\n", ib_get_mad_status_str(osm_madw_get_mad_ptr (p_context->result. p_result_madw))); } goto Exit; } Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** * Get a node record by node LID **********************************************************************/ ib_api_status_t osmtest_get_node_rec_by_lid(IN osmtest_t * const p_osmt, IN ib_net16_t const lid, IN OUT osmtest_req_context_t * const p_context) { ib_api_status_t status = IB_SUCCESS; osmv_user_query_t user; osmv_query_req_t req; ib_node_record_t record; ib_mad_t *p_mad; OSM_LOG_ENTER(&p_osmt->log); OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Getting node record for LID 0x%02X\n", cl_ntoh16(lid)); /* * Do a blocking query for this record in the subnet. * The result is returned in the result field of the caller's * context structure. * * The query structures are locals. */ memset(&req, 0, sizeof(req)); memset(&user, 0, sizeof(user)); memset(&record, 0, sizeof(record)); record.lid = lid; p_context->p_osmt = p_osmt; user.comp_mask = IB_NR_COMPMASK_LID; user.attr_id = IB_MAD_ATTR_NODE_RECORD; user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3)); user.p_attr = &record; req.query_type = OSMV_QUERY_USER_DEFINED; req.timeout_ms = p_osmt->opt.transaction_timeout; req.retry_cnt = p_osmt->opt.retry_count; req.flags = OSM_SA_FLAGS_SYNC; req.query_context = p_context; req.pfn_query_cb = osmtest_query_res_cb; req.p_query_input = &user; req.sm_key = 0; status = osmv_query_sa(p_osmt->h_bind, &req); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0073: " "ib_query failed (%s)\n", ib_get_err_str(status)); goto Exit; } status = p_context->result.status; if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0074: " "ib_query failed (%s)\n", ib_get_err_str(status)); if (status == IB_REMOTE_ERROR) { p_mad = osm_madw_get_mad_ptr(p_context->result. p_result_madw); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "Remote error = %s\n", ib_get_mad_status_str(p_mad)); status = (ib_net16_t) (p_mad->status & IB_SMP_STATUS_MASK); } goto Exit; } Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ static ib_api_status_t osmtest_get_path_rec_by_guid_pair(IN osmtest_t * const p_osmt, IN ib_net64_t sguid, IN ib_net64_t dguid, IN osmtest_req_context_t * p_context) { cl_status_t status = IB_SUCCESS; osmv_query_req_t req; osmv_guid_pair_t guid_pair; OSM_LOG_ENTER(&p_osmt->log); memset(&req, 0, sizeof(req)); memset(p_context, 0, sizeof(*p_context)); p_context->p_osmt = p_osmt; req.timeout_ms = p_osmt->opt.transaction_timeout; req.retry_cnt = p_osmt->opt.retry_count; req.flags = OSM_SA_FLAGS_SYNC; req.query_context = p_context; req.pfn_query_cb = osmtest_query_res_cb; req.query_type = OSMV_QUERY_PATH_REC_BY_PORT_GUIDS; guid_pair.dest_guid = dguid; guid_pair.src_guid = sguid; req.p_query_input = &guid_pair; req.sm_key = 0; OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Query for path from 0x%" PRIx64 " to 0x%" PRIx64 "\n", sguid, dguid); status = osmv_query_sa(p_osmt->h_bind, &req); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0063: " "ib_query failed (%s)\n", ib_get_err_str(status)); goto Exit; } status = (*p_context).result.status; if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0066: " "ib_query failed (%s)\n", ib_get_err_str(status)); if (status == IB_REMOTE_ERROR) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "Remote error = %s\n", ib_get_mad_status_str(osm_madw_get_mad_ptr ((*p_context).result. p_result_madw))); } goto Exit; } Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ static ib_api_status_t osmtest_get_path_rec_by_gid_pair(IN osmtest_t * const p_osmt, IN ib_gid_t sgid, IN ib_gid_t dgid, IN osmtest_req_context_t * p_context) { cl_status_t status = IB_SUCCESS; osmv_query_req_t req; osmv_gid_pair_t gid_pair; OSM_LOG_ENTER(&p_osmt->log); memset(&req, 0, sizeof(req)); memset(p_context, 0, sizeof(*p_context)); p_context->p_osmt = p_osmt; req.timeout_ms = p_osmt->opt.transaction_timeout; req.retry_cnt = p_osmt->opt.retry_count; req.flags = OSM_SA_FLAGS_SYNC; req.query_context = p_context; req.pfn_query_cb = osmtest_query_res_cb; req.query_type = OSMV_QUERY_PATH_REC_BY_GIDS; gid_pair.dest_gid = dgid; gid_pair.src_gid = sgid; req.p_query_input = &gid_pair; req.sm_key = 0; OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Query for path from 0x%016" PRIx64 " 0x%016" PRIx64 " to 0x%016" PRIx64 " 0x%016" PRIx64 "\n", sgid.unicast.prefix, sgid.unicast.interface_id, dgid.unicast.prefix, dgid.unicast.interface_id); status = osmv_query_sa(p_osmt->h_bind, &req); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 006A: " "ib_query failed (%s)\n", ib_get_err_str(status)); goto Exit; } status = (*p_context).result.status; if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 006B: " "ib_query failed (%s)\n", ib_get_err_str(status)); if (status == IB_REMOTE_ERROR) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "Remote error = %s\n", ib_get_mad_status_str(osm_madw_get_mad_ptr ((*p_context).result. p_result_madw))); } goto Exit; } Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } #if defined (VENDOR_RMPP_SUPPORT) && defined (DUAL_SIDED_RMPP) /********************************************************************** **********************************************************************/ static ib_api_status_t osmtest_get_multipath_rec(IN osmtest_t * const p_osmt, IN osmv_multipath_req_t * p_request, IN osmtest_req_context_t * p_context) { cl_status_t status = IB_SUCCESS; osmv_query_req_t req; OSM_LOG_ENTER(&p_osmt->log); /* * Do a blocking query for this record in the subnet. * The result is returned in the result field of the caller's * context structure. * * The query structures are locals. */ memset(&req, 0, sizeof(req)); p_context->p_osmt = p_osmt; req.timeout_ms = p_osmt->opt.transaction_timeout; req.retry_cnt = p_osmt->opt.retry_count; req.flags = OSM_SA_FLAGS_SYNC; req.query_context = p_context; req.pfn_query_cb = osmtest_query_res_cb; req.query_type = OSMV_QUERY_MULTIPATH_REC; req.p_query_input = p_request; req.sm_key = 0; status = osmv_query_sa(p_osmt->h_bind, &req); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0068: " "ib_query failed (%s)\n", ib_get_err_str(status)); goto Exit; } status = p_context->result.status; if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0069: " "ib_query failed (%s)\n", ib_get_err_str(status)); if (status == IB_REMOTE_ERROR) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "Remote error = %s\n", ib_get_mad_status_str(osm_madw_get_mad_ptr (p_context->result. p_result_madw))); } goto Exit; } Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } #endif /********************************************************************** **********************************************************************/ ib_api_status_t osmtest_get_port_rec(IN osmtest_t * const p_osmt, IN ib_net16_t const lid, IN OUT osmtest_req_context_t * const p_context) { ib_api_status_t status = IB_SUCCESS; osmv_user_query_t user; osmv_query_req_t req; ib_portinfo_record_t record; OSM_LOG_ENTER(&p_osmt->log); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "Getting PortInfoRecord for port with LID 0x%X\n", cl_ntoh16(lid)); /* * Do a blocking query for this record in the subnet. * The result is returned in the result field of the caller's * context structure. * * The query structures are locals. */ memset(&req, 0, sizeof(req)); memset(&user, 0, sizeof(user)); memset(&record, 0, sizeof(record)); record.lid = lid; p_context->p_osmt = p_osmt; user.comp_mask = IB_PIR_COMPMASK_LID; user.attr_id = IB_MAD_ATTR_PORTINFO_RECORD; user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3)); user.p_attr = &record; req.query_type = OSMV_QUERY_USER_DEFINED; req.timeout_ms = p_osmt->opt.transaction_timeout; req.retry_cnt = p_osmt->opt.retry_count; req.flags = OSM_SA_FLAGS_SYNC; req.query_context = p_context; req.pfn_query_cb = osmtest_query_res_cb; req.p_query_input = &user; req.sm_key = 0; status = osmv_query_sa(p_osmt->h_bind, &req); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0075: " "ib_query failed (%s)\n", ib_get_err_str(status)); goto Exit; } status = p_context->result.status; if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0076: " "ib_query failed (%s)\n", ib_get_err_str(status)); if (status == IB_REMOTE_ERROR) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "Remote error = %s\n", ib_get_mad_status_str(osm_madw_get_mad_ptr (p_context->result. p_result_madw))); } goto Exit; } Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ ib_api_status_t osmtest_get_port_rec_by_num(IN osmtest_t * const p_osmt, IN ib_net16_t const lid, IN uint8_t const port_num, IN OUT osmtest_req_context_t * const p_context) { ib_api_status_t status = IB_SUCCESS; osmv_user_query_t user; osmv_query_req_t req; ib_portinfo_record_t record; ib_mad_t *p_mad; OSM_LOG_ENTER(&p_osmt->log); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "Getting PortInfoRecord for port with LID 0x%X Num:0x%X\n", cl_ntoh16(lid), port_num); /* * Do a blocking query for this record in the subnet. * The result is returned in the result field of the caller's * context structure. * * The query structures are locals. */ memset(&req, 0, sizeof(req)); memset(&user, 0, sizeof(user)); memset(&record, 0, sizeof(record)); record.lid = lid; record.port_num = port_num; user.p_attr = &record; p_context->p_osmt = p_osmt; req.query_type = OSMV_QUERY_PORT_REC_BY_LID_AND_NUM; req.timeout_ms = p_osmt->opt.transaction_timeout; req.retry_cnt = p_osmt->opt.retry_count; req.flags = OSM_SA_FLAGS_SYNC; req.query_context = p_context; req.pfn_query_cb = osmtest_query_res_cb; req.p_query_input = &user; req.sm_key = 0; status = osmv_query_sa(p_osmt->h_bind, &req); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0077: " "ib_query failed (%s)\n", ib_get_err_str(status)); goto Exit; } status = p_context->result.status; if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0078: " "ib_query failed (%s)\n", ib_get_err_str(status)); if (status == IB_REMOTE_ERROR) { p_mad = osm_madw_get_mad_ptr(p_context->result. p_result_madw); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "Remote error = %s\n", ib_get_mad_status_str(p_mad)); status = (ib_net16_t) (p_mad->status & IB_SMP_STATUS_MASK); } goto Exit; } Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ ib_api_status_t osmtest_stress_port_recs_large(IN osmtest_t * const p_osmt, OUT uint32_t * const p_num_recs, OUT uint32_t * const p_num_queries) { osmtest_req_context_t context; ib_portinfo_record_t *p_rec; uint32_t i; cl_status_t status; uint32_t num_recs = 0; OSM_LOG_ENTER(&p_osmt->log); memset(&context, 0, sizeof(context)); /* * Do a blocking query for all PortInfoRecords in the subnet. */ status = osmtest_get_all_recs(p_osmt, IB_MAD_ATTR_PORTINFO_RECORD, sizeof(*p_rec), &context); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0006: " "osmtest_get_all_recs failed (%s)\n", ib_get_err_str(status)); goto Exit; } /* * Populate the database with the received records. */ num_recs = context.result.result_cnt; *p_num_recs += num_recs; ++*p_num_queries; if (osm_log_is_active(&p_osmt->log, OSM_LOG_VERBOSE)) { OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Received %u records\n", num_recs); for (i = 0; i < num_recs; i++) { p_rec = osmv_get_query_portinfo_rec(context.result. p_result_madw, i); osm_dump_portinfo_record(&p_osmt->log, p_rec, OSM_LOG_VERBOSE); } } Exit: /* * Return the IB query MAD to the pool as necessary. */ if (context.result.p_result_madw != NULL) { osm_mad_pool_put(&p_osmt->mad_pool, context.result.p_result_madw); context.result.p_result_madw = NULL; } OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ ib_api_status_t osmtest_stress_node_recs_large(IN osmtest_t * const p_osmt, OUT uint32_t * const p_num_recs, OUT uint32_t * const p_num_queries) { osmtest_req_context_t context; ib_node_record_t *p_rec; uint32_t i; cl_status_t status; uint32_t num_recs = 0; OSM_LOG_ENTER(&p_osmt->log); memset(&context, 0, sizeof(context)); /* * Do a blocking query for all NodeRecords in the subnet. */ status = osmtest_get_all_recs(p_osmt, IB_MAD_ATTR_NODE_RECORD, sizeof(*p_rec), &context); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0007: " "osmtest_get_all_recs failed (%s)\n", ib_get_err_str(status)); goto Exit; } /* * Populate the database with the received records. */ num_recs = context.result.result_cnt; *p_num_recs += num_recs; ++*p_num_queries; if (osm_log_is_active(&p_osmt->log, OSM_LOG_VERBOSE)) { OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Received %u records\n", num_recs); for (i = 0; i < num_recs; i++) { p_rec = osmv_get_query_node_rec(context.result. p_result_madw, i); osm_dump_node_record(&p_osmt->log, p_rec, OSM_LOG_VERBOSE); } } Exit: /* * Return the IB query MAD to the pool as necessary. */ if (context.result.p_result_madw != NULL) { osm_mad_pool_put(&p_osmt->mad_pool, context.result.p_result_madw); context.result.p_result_madw = NULL; } OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ ib_api_status_t osmtest_stress_path_recs_large(IN osmtest_t * const p_osmt, OUT uint32_t * const p_num_recs, OUT uint32_t * const p_num_queries) { osmtest_req_context_t context; ib_path_rec_t *p_rec; uint32_t i; cl_status_t status; uint32_t num_recs = 0; OSM_LOG_ENTER(&p_osmt->log); memset(&context, 0, sizeof(context)); /* * Do a blocking query for all PathRecords in the subnet. */ status = osmtest_get_all_recs(p_osmt, IB_MAD_ATTR_PATH_RECORD, sizeof(*p_rec), &context); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0008: " "osmtest_get_all_recs failed (%s)\n", ib_get_err_str(status)); goto Exit; } /* * Populate the database with the received records. */ num_recs = context.result.result_cnt; *p_num_recs += num_recs; ++*p_num_queries; if (osm_log_is_active(&p_osmt->log, OSM_LOG_VERBOSE)) { OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Received %u records\n", num_recs); for (i = 0; i < num_recs; i++) { p_rec = osmv_get_query_path_rec(context.result. p_result_madw, i); osm_dump_path_record(&p_osmt->log, p_rec, OSM_LOG_VERBOSE); } } Exit: /* * Return the IB query MAD to the pool as necessary. */ if (context.result.p_result_madw != NULL) { osm_mad_pool_put(&p_osmt->mad_pool, context.result.p_result_madw); context.result.p_result_madw = NULL; } OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ ib_api_status_t osmtest_stress_path_recs_by_guid(IN osmtest_t * const p_osmt, OUT uint32_t * const p_num_recs, OUT uint32_t * const p_num_queries) { osmtest_req_context_t context; ib_path_rec_t *p_rec; uint32_t i; cl_status_t status = IB_SUCCESS; uint32_t num_recs = 0; node_t *p_src_node, *p_dst_node; cl_qmap_t *p_tbl; OSM_LOG_ENTER(&p_osmt->log); memset(&context, 0, sizeof(context)); context.p_osmt = p_osmt; p_tbl = &p_osmt->exp_subn.node_guid_tbl; p_src_node = (node_t *) cl_qmap_head(p_tbl); /* * Go over all nodes that exist in the subnet * for each pair that are not switch nodes get the path record */ while (p_src_node != (node_t *) cl_qmap_end(p_tbl)) { p_dst_node = (node_t *) cl_qmap_head(p_tbl); while (p_dst_node != (node_t *) cl_qmap_end(p_tbl)) { /* * Do a blocking query for CA to CA Path Record */ OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Source : guid = 0x%" PRIx64 " type = %d" "Target : guid = 0x%" PRIx64 " type = %d\n", cl_ntoh64(p_src_node->rec.node_info.port_guid), p_src_node->rec.node_info.node_type, cl_ntoh64(p_dst_node->rec.node_info.port_guid), p_dst_node->rec.node_info.node_type); if (p_src_node->rec.node_info.node_type == IB_NODE_TYPE_CA && p_dst_node->rec.node_info.node_type == IB_NODE_TYPE_CA) { status = osmtest_get_path_rec_by_guid_pair(p_osmt, p_src_node-> rec. node_info. port_guid, p_dst_node-> rec. node_info. port_guid, &context); /* In a case of TIMEOUT you still can try sending but cant count, maybe its a temporary issue */ if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0009: " "osmtest_get_path_rec_by_guid_pair failed (%s)\n", ib_get_err_str(status)); if (status != IB_TIMEOUT) goto Exit; } else { /* we might have received several records */ num_recs = context.result.result_cnt; /* * Populate the database with the received records. */ *p_num_recs += num_recs; ++*p_num_queries; OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Received %u records\n", num_recs); /* Dont waste time if not VERBOSE and above */ if (p_osmt->log.level & OSM_LOG_VERBOSE) { for (i = 0; i < num_recs; i++) { p_rec = osmv_get_query_path_rec (context.result. p_result_madw, i); osm_dump_path_record (&p_osmt->log, p_rec, OSM_LOG_VERBOSE); } } } if (context.result.p_result_madw != NULL) { osm_mad_pool_put(&p_osmt->mad_pool, context.result. p_result_madw); context.result.p_result_madw = NULL; } } /* next one please */ p_dst_node = (node_t *) cl_qmap_next(&p_dst_node->map_item); } p_src_node = (node_t *) cl_qmap_next(&p_src_node->map_item); } Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ ib_api_status_t osmtest_stress_port_recs_small(IN osmtest_t * const p_osmt, OUT uint32_t * const p_num_recs, OUT uint32_t * const p_num_queries) { osmtest_req_context_t context; ib_portinfo_record_t *p_rec; uint32_t i; cl_status_t status; uint32_t num_recs = 0; OSM_LOG_ENTER(&p_osmt->log); memset(&context, 0, sizeof(context)); /* * Do a blocking query for our own PortInfoRecord in the subnet. */ status = osmtest_get_port_rec(p_osmt, cl_ntoh16(p_osmt->local_port.lid), &context); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0010: " "osmtest_get_port_rec failed (%s)\n", ib_get_err_str(status)); goto Exit; } /* * Populate the database with the received records. */ num_recs = context.result.result_cnt; *p_num_recs += num_recs; ++*p_num_queries; if (osm_log_is_active(&p_osmt->log, OSM_LOG_VERBOSE)) { OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Received %u records\n", num_recs); for (i = 0; i < num_recs; i++) { p_rec = osmv_get_query_portinfo_rec(context.result. p_result_madw, i); osm_dump_portinfo_record(&p_osmt->log, p_rec, OSM_LOG_VERBOSE); } } Exit: /* * Return the IB query MAD to the pool as necessary. */ if (context.result.p_result_madw != NULL) { osm_mad_pool_put(&p_osmt->mad_pool, context.result.p_result_madw); context.result.p_result_madw = NULL; } OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ ib_api_status_t osmtest_get_local_port_lmc(IN osmtest_t * const p_osmt, IN ib_net16_t lid, OUT uint8_t * const p_lmc) { osmtest_req_context_t context; ib_portinfo_record_t *p_rec; uint32_t i; cl_status_t status; uint32_t num_recs = 0; OSM_LOG_ENTER(&p_osmt->log); memset(&context, 0, sizeof(context)); /* * Do a blocking query for our own PortInfoRecord in the subnet. */ status = osmtest_get_port_rec(p_osmt, cl_ntoh16(lid), &context); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 001A: " "osmtest_get_port_rec failed (%s)\n", ib_get_err_str(status)); goto Exit; } num_recs = context.result.result_cnt; OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Received %u records\n", num_recs); for (i = 0; i < num_recs; i++) { p_rec = osmv_get_query_portinfo_rec(context.result.p_result_madw, i); osm_dump_portinfo_record(&p_osmt->log, p_rec, OSM_LOG_VERBOSE); if (p_lmc) { *p_lmc = ib_port_info_get_lmc(&p_rec->port_info); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "LMC %d\n", *p_lmc); } } Exit: /* * Return the IB query MAD to the pool as necessary. */ if (context.result.p_result_madw != NULL) { osm_mad_pool_put(&p_osmt->mad_pool, context.result.p_result_madw); context.result.p_result_madw = NULL; } OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** * Use a wrong SM_Key in a simple port query and report success if * failed. **********************************************************************/ ib_api_status_t osmtest_wrong_sm_key_ignored(IN osmtest_t * const p_osmt) { ib_api_status_t status = IB_SUCCESS; osmv_user_query_t user; osmv_query_req_t req; ib_portinfo_record_t record; osmtest_req_context_t context; osmtest_req_context_t *p_context = &context; uint8_t port_num = 1; OSM_LOG_ENTER(&p_osmt->log); OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "Trying PortInfoRecord for port with LID 0x%X Num:0x%X\n", p_osmt->local_port.sm_lid, port_num); /* * Do a blocking query for this record in the subnet. * The result is returned in the result field of the caller's * context structure. * * The query structures are locals. */ memset(&req, 0, sizeof(req)); memset(&user, 0, sizeof(user)); memset(&record, 0, sizeof(record)); record.lid = p_osmt->local_port.sm_lid; record.port_num = port_num; user.p_attr = &record; p_context->p_osmt = p_osmt; req.query_type = OSMV_QUERY_PORT_REC_BY_LID_AND_NUM; req.timeout_ms = p_osmt->opt.transaction_timeout; req.retry_cnt = p_osmt->opt.retry_count; req.flags = OSM_SA_FLAGS_SYNC; req.query_context = p_context; req.pfn_query_cb = osmtest_query_res_cb; req.p_query_input = &user; req.sm_key = 9999; context.result.p_result_madw = NULL; OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); status = osmv_query_sa(p_osmt->h_bind, &req); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); /* since we use a wrong sm_key we should get a timeout */ if (status != IB_TIMEOUT) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0011: " "Did not get a timeout but got (%s)\n", ib_get_err_str(status)); if (status == IB_SUCCESS) { /* assign some error value to status, since IB_SUCCESS is a bad rc */ status = IB_ERROR; } goto Exit; } else { status = IB_SUCCESS; } Exit: if (context.result.p_result_madw != NULL) { osm_mad_pool_put(&p_osmt->mad_pool, context.result.p_result_madw); context.result.p_result_madw = NULL; } OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ static ib_api_status_t osmtest_write_port_info(IN osmtest_t * const p_osmt, IN FILE * fh, IN const ib_portinfo_record_t * const p_rec) { int result; cl_status_t status = IB_SUCCESS; OSM_LOG_ENTER(&p_osmt->log); result = fprintf(fh, "DEFINE_PORT\n" "lid 0x%X\n" "port_num 0x%X\n" "m_key 0x%016" PRIx64 "\n" "subnet_prefix 0x%016" PRIx64 "\n" "base_lid 0x%X\n" "master_sm_base_lid 0x%X\n" "capability_mask 0x%X\n" "diag_code 0x%X\n" "m_key_lease_period 0x%X\n" "local_port_num 0x%X\n" "link_width_enabled 0x%X\n" "link_width_supported 0x%X\n" "link_width_active 0x%X\n" "link_speed_supported 0x%X\n" "port_state %s\n" "state_info2 0x%X\n" "mpb 0x%X\n" "lmc 0x%X\n" "link_speed 0x%X\n" "mtu_smsl 0x%X\n" "vl_cap 0x%X\n" "vl_high_limit 0x%X\n" "vl_arb_high_cap 0x%X\n" "vl_arb_low_cap 0x%X\n" "mtu_cap 0x%X\n" "vl_stall_life 0x%X\n" "vl_enforce 0x%X\n" "m_key_violations 0x%X\n" "p_key_violations 0x%X\n" "q_key_violations 0x%X\n" "guid_cap 0x%X\n" "subnet_timeout 0x%X\n" "resp_time_value 0x%X\n" "error_threshold 0x%X\n" "END\n\n", cl_ntoh16(p_rec->lid), p_rec->port_num, cl_ntoh64(p_rec->port_info.m_key), cl_ntoh64(p_rec->port_info.subnet_prefix), cl_ntoh16(p_rec->port_info.base_lid), cl_ntoh16(p_rec->port_info.master_sm_base_lid), cl_ntoh32(p_rec->port_info.capability_mask), cl_ntoh16(p_rec->port_info.diag_code), cl_ntoh16(p_rec->port_info.m_key_lease_period), p_rec->port_info.local_port_num, p_rec->port_info.link_width_enabled, p_rec->port_info.link_width_supported, p_rec->port_info.link_width_active, ib_port_info_get_link_speed_sup(&p_rec->port_info), ib_get_port_state_str(ib_port_info_get_port_state (&p_rec->port_info)), p_rec->port_info.state_info2, ib_port_info_get_mpb(&p_rec->port_info), ib_port_info_get_lmc(&p_rec->port_info), p_rec->port_info.link_speed, p_rec->port_info.mtu_smsl, p_rec->port_info.vl_cap, p_rec->port_info.vl_high_limit, p_rec->port_info.vl_arb_high_cap, p_rec->port_info.vl_arb_low_cap, p_rec->port_info.mtu_cap, p_rec->port_info.vl_stall_life, p_rec->port_info.vl_enforce, cl_ntoh16(p_rec->port_info.m_key_violations), cl_ntoh16(p_rec->port_info.p_key_violations), cl_ntoh16(p_rec->port_info.q_key_violations), p_rec->port_info.guid_cap, ib_port_info_get_timeout(&p_rec->port_info), p_rec->port_info.resp_time_value, p_rec->port_info.error_threshold); if (result < 0) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0161: " "Write failed\n"); status = IB_ERROR; goto Exit; } Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ static ib_api_status_t osmtest_write_path_info(IN osmtest_t * const p_osmt, IN FILE * fh, IN const ib_path_rec_t * const p_rec) { int result; cl_status_t status = IB_SUCCESS; OSM_LOG_ENTER(&p_osmt->log); result = fprintf(fh, "DEFINE_PATH\n" "dgid 0x%016" PRIx64 " 0x%016" PRIx64 "\nsgid 0x%016" PRIx64 " 0x%016" PRIx64 "\ndlid 0x%X\n" "slid 0x%X\n" "# hop_flow_raw 0x%X\n" "# tclass 0x%X\n" "# num_path 0x%X\n" "pkey 0x%X\n" "# sl 0x%X\n" "# qos_class 0x%X\n" "# mtu 0x%X\n" "# rate 0x%X\n" "# pkt_life 0x%X\n" "# preference 0x%X\n" "END\n\n", cl_ntoh64(p_rec->dgid.unicast.prefix), cl_ntoh64(p_rec->dgid.unicast.interface_id), cl_ntoh64(p_rec->sgid.unicast.prefix), cl_ntoh64(p_rec->sgid.unicast.interface_id), cl_ntoh16(p_rec->dlid), cl_ntoh16(p_rec->slid), cl_ntoh32(p_rec->hop_flow_raw), p_rec->tclass, p_rec->num_path, cl_ntoh16(p_rec->pkey), ib_path_rec_sl(p_rec), ib_path_rec_qos_class(p_rec), p_rec->mtu, p_rec->rate, p_rec->pkt_life, p_rec->preference); if (result < 0) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0162: " "Write failed\n"); status = IB_ERROR; goto Exit; } Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ static ib_api_status_t osmtest_write_node_info(IN osmtest_t * const p_osmt, IN FILE * fh, IN const ib_node_record_t * const p_rec) { int result; cl_status_t status = IB_SUCCESS; char desc[IB_NODE_DESCRIPTION_SIZE + 1]; OSM_LOG_ENTER(&p_osmt->log); memcpy(desc, p_rec->node_desc.description, IB_NODE_DESCRIPTION_SIZE); desc[IB_NODE_DESCRIPTION_SIZE] = '\0'; result = fprintf(fh, "DEFINE_NODE\n" "lid 0x%X\n" "base_version 0x%X\n" "class_version 0x%X\n" "node_type 0x%X # (%s)\n" "num_ports 0x%X\n" "sys_guid 0x%016" PRIx64 "\n" "node_guid 0x%016" PRIx64 "\n" "port_guid 0x%016" PRIx64 "\n" "partition_cap 0x%X\n" "device_id 0x%X\n" "revision 0x%X\n" "# port_num 0x%X\n" "# vendor_id 0x%X\n" "# node_desc %s\n" "END\n\n", cl_ntoh16(p_rec->lid), p_rec->node_info.base_version, p_rec->node_info.class_version, p_rec->node_info.node_type, ib_get_node_type_str(p_rec->node_info.node_type), p_rec->node_info.num_ports, cl_ntoh64(p_rec->node_info.sys_guid), cl_ntoh64(p_rec->node_info.node_guid), cl_ntoh64(p_rec->node_info.port_guid), cl_ntoh16(p_rec->node_info.partition_cap), cl_ntoh16(p_rec->node_info.device_id), cl_ntoh32(p_rec->node_info.revision), ib_node_info_get_local_port_num(&p_rec->node_info), cl_ntoh32(ib_node_info_get_vendor_id (&p_rec->node_info)), desc); if (result < 0) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0163: " "Write failed\n"); status = IB_ERROR; goto Exit; } Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ static ib_api_status_t osmtest_write_link(IN osmtest_t * const p_osmt, IN FILE * fh, IN const ib_link_record_t * const p_rec) { int result; cl_status_t status = IB_SUCCESS; OSM_LOG_ENTER(&p_osmt->log); result = fprintf(fh, "DEFINE_LINK\n" "from_lid 0x%X\n" "from_port_num 0x%X\n" "to_port_num 0x%X\n" "to_lid 0x%X\n" "END\n\n", cl_ntoh16(p_rec->from_lid), p_rec->from_port_num, p_rec->to_port_num, cl_ntoh16(p_rec->to_lid)); if (result < 0) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0164: " "Write failed\n"); status = IB_ERROR; goto Exit; } Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ static ib_api_status_t osmtest_write_all_link_recs(IN osmtest_t * const p_osmt, IN FILE * fh) { osmtest_req_context_t context; const ib_link_record_t *p_rec; uint32_t i; cl_status_t status; size_t num_recs; int result; OSM_LOG_ENTER(&p_osmt->log); memset(&context, 0, sizeof(context)); /* * Do a blocking query for all NodeRecords in the subnet. */ status = osmtest_get_all_recs(p_osmt, IB_MAD_ATTR_LINK_RECORD, sizeof(*p_rec), &context); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0165: " "osmtest_get_all_recs failed (%s)\n", ib_get_err_str(status)); goto Exit; } /* * Write the received records out to the file. */ num_recs = context.result.result_cnt; OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Received %zu records\n", num_recs); result = fprintf(fh, "#\n" "# Link Records\n" "#\n"); if (result < 0) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0166: " "Write failed\n"); status = IB_ERROR; goto Exit; } for (i = 0; i < num_recs; i++) { p_rec = (ib_link_record_t *) osmv_get_query_result(context.result. p_result_madw, i); osmtest_write_link(p_osmt, fh, p_rec); } Exit: /* * Return the IB query MAD to the pool as necessary. */ if (context.result.p_result_madw != NULL) { osm_mad_pool_put(&p_osmt->mad_pool, context.result.p_result_madw); context.result.p_result_madw = NULL; } OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ static ib_api_status_t osmtest_get_path_rec_by_lid_pair(IN osmtest_t * const p_osmt, IN ib_net16_t slid, IN ib_net16_t dlid, IN osmtest_req_context_t * p_context) { cl_status_t status = IB_SUCCESS; osmv_query_req_t req; osmv_lid_pair_t lid_pair; OSM_LOG_ENTER(&p_osmt->log); memset(&req, 0, sizeof(req)); memset(p_context, 0, sizeof(*p_context)); p_context->p_osmt = p_osmt; req.timeout_ms = p_osmt->opt.transaction_timeout; req.retry_cnt = p_osmt->opt.retry_count; req.flags = OSM_SA_FLAGS_SYNC; req.query_context = p_context; req.pfn_query_cb = osmtest_query_res_cb; req.query_type = OSMV_QUERY_PATH_REC_BY_LIDS; lid_pair.dest_lid = dlid; lid_pair.src_lid = slid; req.p_query_input = &lid_pair; req.sm_key = 0; OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Query for path from 0x%X to 0x%X\n", slid, dlid); status = osmv_query_sa(p_osmt->h_bind, &req); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0053: " "ib_query failed (%s)\n", ib_get_err_str(status)); goto Exit; } status = (*p_context).result.status; if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0067: " "ib_query failed (%s)\n", ib_get_err_str(status)); if (status == IB_REMOTE_ERROR) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "Remote error = %s\n", ib_get_mad_status_str(osm_madw_get_mad_ptr ((*p_context).result. p_result_madw))); } goto Exit; } Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } #ifdef VENDOR_RMPP_SUPPORT /********************************************************************** * ASSUMES RMPP **********************************************************************/ static ib_api_status_t osmtest_write_all_node_recs(IN osmtest_t * const p_osmt, IN FILE * fh) { osmtest_req_context_t context; const ib_node_record_t *p_rec; uint32_t i; cl_status_t status; size_t num_recs; int result; OSM_LOG_ENTER(&p_osmt->log); memset(&context, 0, sizeof(context)); /* * Do a blocking query for all NodeRecords in the subnet. */ status = osmtest_get_all_recs(p_osmt, IB_MAD_ATTR_NODE_RECORD, sizeof(*p_rec), &context); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0022: " "osmtest_get_all_recs failed (%s)\n", ib_get_err_str(status)); goto Exit; } /* * Write the received records out to the file. */ num_recs = context.result.result_cnt; OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Received %zu records\n", num_recs); result = fprintf(fh, "#\n" "# Node Records\n" "#\n"); if (result < 0) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0023: " "Write failed\n"); status = IB_ERROR; goto Exit; } for (i = 0; i < num_recs; i++) { p_rec = osmv_get_query_node_rec(context.result.p_result_madw, i); osmtest_write_node_info(p_osmt, fh, p_rec); } Exit: /* * Return the IB query MAD to the pool as necessary. */ if (context.result.p_result_madw != NULL) { osm_mad_pool_put(&p_osmt->mad_pool, context.result.p_result_madw); context.result.p_result_madw = NULL; } OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** * ASSUMES RMPP **********************************************************************/ static ib_api_status_t osmtest_write_all_port_recs(IN osmtest_t * const p_osmt, IN FILE * fh) { osmtest_req_context_t context; const ib_portinfo_record_t *p_rec; uint32_t i; cl_status_t status; size_t num_recs; int result; OSM_LOG_ENTER(&p_osmt->log); memset(&context, 0, sizeof(context)); /* * Do a blocking query for all NodeRecords in the subnet. */ status = osmtest_get_all_recs(p_osmt, IB_MAD_ATTR_PORTINFO_RECORD, sizeof(*p_rec), &context); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0167: " "osmtest_get_all_recs failed (%s)\n", ib_get_err_str(status)); goto Exit; } /* * Write the received records out to the file. */ num_recs = context.result.result_cnt; OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Received %zu records\n", num_recs); result = fprintf(fh, "#\n" "# PortInfo Records\n" "#\n"); if (result < 0) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0024: " "Write failed\n"); status = IB_ERROR; goto Exit; } for (i = 0; i < num_recs; i++) { p_rec = osmv_get_query_portinfo_rec(context.result.p_result_madw, i); osmtest_write_port_info(p_osmt, fh, p_rec); } Exit: /* * Return the IB query MAD to the pool as necessary. */ if (context.result.p_result_madw != NULL) { osm_mad_pool_put(&p_osmt->mad_pool, context.result.p_result_madw); context.result.p_result_madw = NULL; } OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** * ASSUMES RMPP **********************************************************************/ static ib_api_status_t osmtest_write_all_path_recs(IN osmtest_t * const p_osmt, IN FILE * fh) { osmtest_req_context_t context; const ib_path_rec_t *p_rec; uint32_t i; cl_status_t status; size_t num_recs; int result; OSM_LOG_ENTER(&p_osmt->log); memset(&context, 0, sizeof(context)); /* * Do a blocking query for all PathRecords in the subnet. */ status = osmtest_get_all_recs(p_osmt, IB_MAD_ATTR_PATH_RECORD, sizeof(*p_rec), &context); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0025: " "osmtest_get_all_recs failed (%s)\n", ib_get_err_str(status)); goto Exit; } /* * Write the received records out to the file. */ num_recs = context.result.result_cnt; OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Received %zu records\n", num_recs); result = fprintf(fh, "#\n" "# Path Records\n" "#\n"); if (result < 0) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0026: " "Write failed\n"); status = IB_ERROR; goto Exit; } for (i = 0; i < num_recs; i++) { p_rec = osmv_get_query_path_rec(context.result.p_result_madw, i); osmtest_write_path_info(p_osmt, fh, p_rec); } Exit: /* * Return the IB query MAD to the pool as necessary. */ if (context.result.p_result_madw != NULL) { osm_mad_pool_put(&p_osmt->mad_pool, context.result.p_result_madw); context.result.p_result_madw = NULL; } OSM_LOG_EXIT(&p_osmt->log); return (status); } #else /* * NON RMPP BASED QUERY FOR ALL NODES: BASED ON THE MAX LID GIVEN BY THE USER */ static ib_api_status_t osmtest_write_all_node_recs(IN osmtest_t * const p_osmt, IN FILE * fh) { osmtest_req_context_t context; node_t *p_node; node_t *p_guid_node; const ib_node_record_t *p_rec; cl_status_t status = CL_SUCCESS; int result; uint16_t lid; OSM_LOG_ENTER(&p_osmt->log); result = fprintf(fh, "#\n" "# Node Records\n" "#\n"); if (result < 0) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0027: " "Write failed\n"); status = IB_ERROR; goto Exit; } /* * Go over all LIDs in the range 1 to max_lid and do a * NodeRecord query by that lid. */ for (lid = 1; lid <= p_osmt->max_lid; lid++) { /* prepare the query context */ memset(&context, 0, sizeof(context)); status = osmtest_get_node_rec_by_lid(p_osmt, cl_ntoh16(lid), &context); if (status != IB_SUCCESS) { if (status != IB_SA_MAD_STATUS_NO_RECORDS) { OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "ERR 0028: " "failed to get node info for LID:0x%02X (%s)\n", cl_ntoh16(lid), ib_get_err_str(status)); goto Exit; } else { OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "WRN 0121: " "failed to get node info for LID:0x%02X (%s)\n", cl_ntoh16(lid), ib_get_err_str(status)); status = IB_SUCCESS; } } else { /* OK we got something */ p_rec = osmv_get_query_node_rec(context.result. p_result_madw, 0); osmtest_write_node_info(p_osmt, fh, p_rec); /* create a subnet object */ p_node = node_new(); CL_ASSERT(p_node != NULL); /* copy the info to the subnet node object */ p_node->rec = *p_rec; cl_qmap_insert(&p_osmt->exp_subn.node_lid_tbl, p_node->rec.lid, &p_node->map_item); p_guid_node = node_new(); CL_ASSERT(p_guid_node != NULL); *p_guid_node = *p_node; cl_qmap_insert(&p_osmt->exp_subn.node_guid_tbl, p_guid_node->rec.node_info.node_guid, &p_guid_node->map_item); } if (context.result.p_result_madw != NULL) { osm_mad_pool_put(&p_osmt->mad_pool, context.result.p_result_madw); context.result.p_result_madw = NULL; } } Exit: if (context.result.p_result_madw != NULL) { osm_mad_pool_put(&p_osmt->mad_pool, context.result.p_result_madw); context.result.p_result_madw = NULL; } OSM_LOG_EXIT(&p_osmt->log); return (status); } /* * GET ALL PORT RECORDS IN THE FABRIC - * one by one by using the node info received */ static ib_api_status_t osmtest_write_all_port_recs(IN osmtest_t * const p_osmt, IN FILE * fh) { osmtest_req_context_t context; const ib_node_record_t *p_node_rec; const ib_portinfo_record_t *p_rec; uint8_t port_num; cl_status_t status = CL_SUCCESS; cl_qmap_t *p_tbl; node_t *p_node; port_t *p_port; int result; OSM_LOG_ENTER(&p_osmt->log); memset(&context, 0, sizeof(context)); /* print header */ result = fprintf(fh, "#\n" "# PortInfo Records\n" "#\n"); if (result < 0) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0029: " "Write failed\n"); status = IB_ERROR; goto Exit; } /* use the pre-explored set of nodes */ p_tbl = &p_osmt->exp_subn.node_lid_tbl; p_node = (node_t *) cl_qmap_head(p_tbl); /* * Go over all LIDs in the range 1 to max_lid and do a * NodeRecord query by that lid. */ while (p_node != (node_t *) cl_qmap_end(p_tbl)) { p_node_rec = &(p_node->rec); /* go through all ports of the node: */ for (port_num = 0; port_num <= p_node_rec->node_info.num_ports; port_num++) { /* prepare the query context */ memset(&context, 0, sizeof(context)); status = osmtest_get_port_rec_by_num(p_osmt, p_node_rec->lid, port_num, &context); if (status != IB_SUCCESS) { if (status != IB_SA_MAD_STATUS_NO_RECORDS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "WRN 0122: " "Error encountered getting port info for LID:0x%04X Num:0x%02X (%s)\n", p_node_rec->lid, port_num, ib_get_err_str(status)); goto Exit; } else { OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "WRN 0123: " "failed to get port info for LID:0x%04X Num:0x%02X (%s)\n", p_node_rec->lid, port_num, ib_get_err_str(status)); status = IB_SUCCESS; } } else { /* OK we got something */ p_rec = osmv_get_query_portinfo_rec(context.result. p_result_madw, 0); osmtest_write_port_info(p_osmt, fh, p_rec); /* create a subnet object */ p_port = port_new(); CL_ASSERT(p_port != NULL); /* copy the info to the subnet node object */ p_port->rec = *p_rec; cl_qmap_insert(&p_osmt->exp_subn.port_key_tbl, port_gen_id(p_node_rec->lid, port_num), &p_port->map_item); } if (context.result.p_result_madw != NULL) { osm_mad_pool_put(&p_osmt->mad_pool, context.result.p_result_madw); context.result.p_result_madw = NULL; } } p_node = (node_t *) cl_qmap_next(&p_node->map_item); } /* we must set the exist status to avoid abort of the over all algorith */ Exit: /* * Return the IB query MAD to the pool as necessary. */ if (context.result.p_result_madw != NULL) { osm_mad_pool_put(&p_osmt->mad_pool, context.result.p_result_madw); context.result.p_result_madw = NULL; } OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** * ASSUMES NO RMPP **********************************************************************/ static ib_api_status_t osmtest_write_all_path_recs(IN osmtest_t * const p_osmt, IN FILE * fh) { osmtest_req_context_t context; const ib_path_rec_t *p_rec; cl_status_t status = CL_SUCCESS; int num_recs, i; cl_qmap_t *p_tbl; node_t *p_src_node, *p_dst_node; ib_api_status_t got_status = IB_SUCCESS; OSM_LOG_ENTER(&p_osmt->log); memset(&context, 0, sizeof(context)); /* * Go over all nodes that exist in the subnet * for each pair that are not switch nodes get the path record */ context.p_osmt = p_osmt; p_tbl = &p_osmt->exp_subn.node_lid_tbl; p_src_node = (node_t *) cl_qmap_head(p_tbl); while (p_src_node != (node_t *) cl_qmap_end(p_tbl)) { /* HACK we use capability_mask to know diff a CA node from switch node */ /* if(p_src_node->rec.node_info.capability_mask ) { */ p_dst_node = (node_t *) cl_qmap_head(p_tbl); while (p_dst_node != (node_t *) cl_qmap_end(p_tbl)) { /* HACK we use capability_mask to know diff a CA node from switch node */ /* if (p_dst_node->rec.node_info.capability_mask) { */ /* query for it: */ status = osmtest_get_path_rec_by_lid_pair(p_osmt, p_src_node-> rec.lid, p_dst_node-> rec.lid, &context); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 012D: " "failed to get path info from LID:0x%X To LID:0x%X (%s)\n", p_src_node->rec.lid, p_dst_node->rec.lid, ib_get_err_str(status)); /* remember the first error status */ got_status = (got_status == IB_SUCCESS) ? status : got_status; } else { /* we might have received several records */ num_recs = context.result.result_cnt; for (i = 0; i < num_recs; i++) { p_rec = osmv_get_query_path_rec(context. result. p_result_madw, i); osmtest_write_path_info(p_osmt, fh, p_rec); } } /* } */ if (context.result.p_result_madw != NULL) { osm_mad_pool_put(&p_osmt->mad_pool, context.result.p_result_madw); context.result.p_result_madw = NULL; } /* next one please */ p_dst_node = (node_t *) cl_qmap_next(&p_dst_node->map_item); } /* } */ p_src_node = (node_t *) cl_qmap_next(&p_src_node->map_item); } if (got_status != IB_SUCCESS) status = got_status; /* * Return the IB query MAD to the pool as necessary. */ if (context.result.p_result_madw != NULL) { osm_mad_pool_put(&p_osmt->mad_pool, context.result.p_result_madw); context.result.p_result_madw = NULL; } OSM_LOG_EXIT(&p_osmt->log); return (status); } #endif /********************************************************************** **********************************************************************/ static ib_api_status_t osmtest_create_inventory_file(IN osmtest_t * const p_osmt) { FILE *fh; ib_api_status_t status = IB_SUCCESS; OSM_LOG_ENTER(&p_osmt->log); fh = fopen(p_osmt->opt.file_name, "w"); if (fh == NULL) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0079: " "Unable to open inventory file (%s)\n", p_osmt->opt.file_name); status = IB_ERROR; goto Exit; } /* HACK: the order is important: nodes ports paths */ status = osmtest_write_all_node_recs(p_osmt, fh); if (status != IB_SUCCESS) goto Exit; status = osmtest_write_all_port_recs(p_osmt, fh); if (status != IB_SUCCESS) goto Exit; if (!p_osmt->opt.ignore_path_records) { status = osmtest_write_all_path_recs(p_osmt, fh); if (status != IB_SUCCESS) goto Exit; } status = osmtest_write_all_link_recs(p_osmt, fh); if (status != IB_SUCCESS) goto Exit; fclose(fh); Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ static ib_api_status_t osmtest_stress_large_rmpp_pr(IN osmtest_t * const p_osmt) { ib_api_status_t status = IB_SUCCESS; uint64_t num_recs = 0; uint64_t num_queries = 0; uint32_t delta_recs; uint32_t delta_queries; uint32_t print_freq = 0; struct timeval start_tv, end_tv; long sec_diff, usec_diff; float ratio; OSM_LOG_ENTER(&p_osmt->log); gettimeofday(&start_tv, NULL); printf("-I- Start time is : %09ld:%06ld [sec:usec]\n", start_tv.tv_sec, (long)start_tv.tv_usec); while (num_queries < STRESS_LARGE_PR_RMPP_THR) { delta_recs = 0; delta_queries = 0; status = osmtest_stress_path_recs_by_guid(p_osmt, &delta_recs, &delta_queries); if (status != IB_SUCCESS) goto Exit; num_recs += delta_recs; num_queries += delta_queries; print_freq += delta_recs; if (print_freq > 10000) { gettimeofday(&end_tv, NULL); if (end_tv.tv_usec > start_tv.tv_usec) { sec_diff = end_tv.tv_sec - start_tv.tv_sec; usec_diff = end_tv.tv_usec - start_tv.tv_usec; } else { sec_diff = end_tv.tv_sec - start_tv.tv_sec - 1; usec_diff = 1000000 - (start_tv.tv_usec - end_tv.tv_usec); } printf("-I- End time is : %09ld:%06ld [sec:usec]\n", end_tv.tv_sec, (long)end_tv.tv_usec); printf("-I- Querying %" PRId64 " Path Record queries CA to CA (rmpp)\n\ttook %04ld:%06ld [sec:usec]\n", num_queries, sec_diff, usec_diff); if (num_recs == 0) ratio = 0; else ratio = ((float)num_queries / (float)num_recs); printf("-I- Queries to Record Ratio is %" PRIu64 " records, %" PRIu64 " queries : %.2f \n", num_recs, num_queries, ratio); print_freq = 0; } } Exit: gettimeofday(&end_tv, NULL); printf("-I- End time is : %09ld:%06ld [sec:usec]\n", end_tv.tv_sec, (long)end_tv.tv_usec); if (end_tv.tv_usec > start_tv.tv_usec) { sec_diff = end_tv.tv_sec - start_tv.tv_sec; usec_diff = end_tv.tv_usec - start_tv.tv_usec; } else { sec_diff = end_tv.tv_sec - start_tv.tv_sec - 1; usec_diff = 1000000 - (start_tv.tv_usec - end_tv.tv_usec); } printf("-I- Querying %" PRId64 " Path Record queries (rmpp) took %04ld:%06ld [sec:usec]\n", num_queries, sec_diff, usec_diff); OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ static ib_api_status_t osmtest_stress_large_rmpp(IN osmtest_t * const p_osmt) { ib_api_status_t status = IB_SUCCESS; uint64_t num_recs = 0; uint64_t num_queries = 0; uint32_t delta_recs; uint32_t delta_queries; uint32_t print_freq = 0; struct timeval start_tv, end_tv; long sec_diff, usec_diff; OSM_LOG_ENTER(&p_osmt->log); gettimeofday(&start_tv, NULL); printf("-I- Start time is : %09ld:%06ld [sec:usec]\n", start_tv.tv_sec, (long)start_tv.tv_usec); while (num_queries < STRESS_LARGE_RMPP_THR) { delta_recs = 0; delta_queries = 0; status = osmtest_stress_node_recs_large(p_osmt, &delta_recs, &delta_queries); if (status != IB_SUCCESS) goto Exit; status = osmtest_stress_path_recs_large(p_osmt, &delta_recs, &delta_queries); if (status != IB_SUCCESS) goto Exit; status = osmtest_stress_port_recs_large(p_osmt, &delta_recs, &delta_queries); if (status != IB_SUCCESS) goto Exit; num_recs += delta_recs; num_queries += delta_queries; print_freq += delta_recs; if (print_freq > 100000) { gettimeofday(&end_tv, NULL); if (end_tv.tv_usec > start_tv.tv_usec) { sec_diff = end_tv.tv_sec - start_tv.tv_sec; usec_diff = end_tv.tv_usec - start_tv.tv_usec; } else { sec_diff = end_tv.tv_sec - start_tv.tv_sec - 1; usec_diff = 1000000 - (start_tv.tv_usec - end_tv.tv_usec); } printf("-I- End time is : %09ld:%06ld [sec:usec]\n", end_tv.tv_sec, (long)end_tv.tv_usec); printf("-I- Querying %" PRId64 " large mixed queries (rmpp) took %04ld:%06ld [sec:usec]\n", num_queries, sec_diff, usec_diff); printf("%" PRIu64 " records, %" PRIu64 " queries\n", num_recs, num_queries); print_freq = 0; } } Exit: gettimeofday(&end_tv, NULL); printf("-I- End time is : %09ld:%06ld [sec:usec]\n", end_tv.tv_sec, (long)end_tv.tv_usec); if (end_tv.tv_usec > start_tv.tv_usec) { sec_diff = end_tv.tv_sec - start_tv.tv_sec; usec_diff = end_tv.tv_usec - start_tv.tv_usec; } else { sec_diff = end_tv.tv_sec - start_tv.tv_sec - 1; usec_diff = 1000000 - (start_tv.tv_usec - end_tv.tv_usec); } printf("-I- Querying %" PRId64 " large mixed queries (rmpp) took %04ld:%06ld [sec:usec]\n", num_queries, sec_diff, usec_diff); OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ static ib_api_status_t osmtest_stress_small_rmpp(IN osmtest_t * const p_osmt) { ib_api_status_t status = IB_SUCCESS; uint64_t num_recs = 0; uint64_t num_queries = 0; uint32_t delta_recs; uint32_t delta_queries; uint32_t print_freq = 0; int num_timeouts = 0; struct timeval start_tv, end_tv; long sec_diff, usec_diff; OSM_LOG_ENTER(&p_osmt->log); gettimeofday(&start_tv, NULL); printf("-I- Start time is : %09ld:%06ld [sec:usec]\n", start_tv.tv_sec, (long)start_tv.tv_usec); while ((num_queries < STRESS_SMALL_RMPP_THR) && (num_timeouts < 100)) { delta_recs = 0; delta_queries = 0; status = osmtest_stress_port_recs_small(p_osmt, &delta_recs, &delta_queries); if (status != IB_SUCCESS) goto Exit; num_recs += delta_recs; num_queries += delta_queries; print_freq += delta_recs; if (print_freq > 5000) { gettimeofday(&end_tv, NULL); printf("%" PRIu64 " records, %" PRIu64 " queries\n", num_recs, num_queries); if (end_tv.tv_usec > start_tv.tv_usec) { sec_diff = end_tv.tv_sec - start_tv.tv_sec; usec_diff = end_tv.tv_usec - start_tv.tv_usec; } else { sec_diff = end_tv.tv_sec - start_tv.tv_sec - 1; usec_diff = 1000000 - (start_tv.tv_usec - end_tv.tv_usec); } printf("-I- End time is : %09ld:%06ld [sec:usec]\n", end_tv.tv_sec, (long)end_tv.tv_usec); printf("-I- Querying %" PRId64 " port_info queries (single mad) took %04ld:%06ld [sec:usec]\n", num_queries, sec_diff, usec_diff); print_freq = 0; } } Exit: gettimeofday(&end_tv, NULL); printf("-I- End time is : %09ld:%06ld [sec:usec]\n", end_tv.tv_sec, (long)end_tv.tv_usec); if (end_tv.tv_usec > start_tv.tv_usec) { sec_diff = end_tv.tv_sec - start_tv.tv_sec; usec_diff = end_tv.tv_usec - start_tv.tv_usec; } else { sec_diff = end_tv.tv_sec - start_tv.tv_sec - 1; usec_diff = 1000000 - (start_tv.tv_usec - end_tv.tv_usec); } printf("-I- Querying %" PRId64 " port_info queries (single mad) took %04ld:%06ld [sec:usec]\n", num_queries, sec_diff, usec_diff); if (num_timeouts > 50) { status = IB_TIMEOUT; } /* Exit: */ OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ static void osmtest_prepare_db_generic(IN osmtest_t * const p_osmt, IN cl_qmap_t * const p_tbl) { generic_t *p_generic; OSM_LOG_ENTER(&p_osmt->log); p_generic = (generic_t *) cl_qmap_head(p_tbl); while (p_generic != (generic_t *) cl_qmap_end(p_tbl)) { p_generic->count = 0; p_generic = (generic_t *) cl_qmap_next(&p_generic->map_item); } OSM_LOG_EXIT(&p_osmt->log); } /********************************************************************** **********************************************************************/ static void osmtest_prepare_db(IN osmtest_t * const p_osmt) { OSM_LOG_ENTER(&p_osmt->log); osmtest_prepare_db_generic(p_osmt, &p_osmt->exp_subn.node_lid_tbl); osmtest_prepare_db_generic(p_osmt, &p_osmt->exp_subn.path_tbl); OSM_LOG_EXIT(&p_osmt->log); } /********************************************************************** **********************************************************************/ static ib_api_status_t osmtest_check_missing_nodes(IN osmtest_t * const p_osmt) { const node_t *p_node; cl_status_t status = IB_SUCCESS; cl_qmap_t *p_tbl; OSM_LOG_ENTER(&p_osmt->log); p_tbl = &p_osmt->exp_subn.node_lid_tbl; p_node = (node_t *) cl_qmap_head(p_tbl); while (p_node != (node_t *) cl_qmap_end(p_tbl)) { if (p_node->count == 0) { /* * This node was not reported by the SA */ OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0080: " "Missing node 0x%016" PRIx64 "\n", cl_ntoh64(p_node->rec.node_info.node_guid)); status = IB_ERROR; } p_node = (node_t *) cl_qmap_next(&p_node->map_item); } OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ static ib_api_status_t osmtest_check_missing_ports(IN osmtest_t * const p_osmt) { const port_t *p_port; cl_status_t status = IB_SUCCESS; cl_qmap_t *p_tbl; OSM_LOG_ENTER(&p_osmt->log); p_tbl = &p_osmt->exp_subn.port_key_tbl; p_port = (port_t *) cl_qmap_head(p_tbl); while (p_port != (port_t *) cl_qmap_end(p_tbl)) { if (p_port->count == 0) { /* * This port was not reported by the SA */ OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0081: " "Missing port LID:0x%X Num:0x%X\n", cl_ntoh16(p_port->rec.lid), p_port->rec.port_num); status = IB_ERROR; } p_port = (port_t *) cl_qmap_next(&p_port->map_item); } OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ static ib_api_status_t osmtest_check_missing_paths(IN osmtest_t * const p_osmt) { const path_t *p_path; cl_status_t status = IB_SUCCESS; cl_qmap_t *p_tbl; OSM_LOG_ENTER(&p_osmt->log); p_tbl = &p_osmt->exp_subn.path_tbl; p_path = (path_t *) cl_qmap_head(p_tbl); while (p_path != (path_t *) cl_qmap_end(p_tbl)) { if (p_path->count == 0) { /* * This path was not reported by the SA */ OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0051: " "SA did not return path SLID 0x%X to DLID 0x%X\n", cl_ntoh16(p_path->rec.slid), cl_ntoh16(p_path->rec.dlid)); status = IB_ERROR; goto Exit; } p_path = (path_t *) cl_qmap_next(&p_path->map_item); } Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ -inline uint32_t osmtest_path_rec_key_get(IN const ib_path_rec_t * const p_rec) +static inline uint32_t osmtest_path_rec_key_get(IN const ib_path_rec_t * const p_rec) { return (p_rec->dlid << 16 | p_rec->slid); } /********************************************************************** **********************************************************************/ static boolean_t osmtest_path_rec_kay_is_valid(IN osmtest_t * const p_osmt, IN const path_t * const p_path) { if ((p_path->comp.dlid == 0) || (p_path->comp.slid == 0)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0168: " "SLID and DLID must be specified for defined paths\n"); return (FALSE); } return (TRUE); } /********************************************************************** **********************************************************************/ static ib_api_status_t osmtest_validate_path_data(IN osmtest_t * const p_osmt, IN path_t * const p_path, IN const ib_path_rec_t * const p_rec) { cl_status_t status = IB_SUCCESS; uint8_t lmc = 0; OSM_LOG_ENTER(&p_osmt->log); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "Checking path SLID 0x%X to DLID 0x%X\n", cl_ntoh16(p_rec->slid), cl_ntoh16(p_rec->dlid)); status = osmtest_get_local_port_lmc(p_osmt, p_osmt->local_port.lid, &lmc); if (status != IB_SUCCESS) goto Exit; /* HACK: Assume uniform LMC across endports in the subnet */ /* This is the only LMC mode which OpenSM currently supports */ /* In absence of this assumption, validation of this is much more complicated */ if (lmc == 0) { /* * Has this record already been returned? */ if (p_path->count != 0) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0056: " "Already received path SLID 0x%X to DLID 0x%X\n", cl_ntoh16(p_rec->slid), cl_ntoh16(p_rec->dlid)); status = IB_ERROR; goto Exit; } } else { /* Also, this doesn't detect fewer than the correct number of paths being returned */ if (p_path->count >= (uint32_t) (1 << (2 * lmc))) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0052: " "Already received path SLID 0x%X to DLID 0x%X count %d LMC %d\n", cl_ntoh16(p_rec->slid), cl_ntoh16(p_rec->dlid), p_path->count, lmc); status = IB_ERROR; goto Exit; } } ++p_path->count; /* * Check the fields the user wants checked. */ if ((p_path->comp.dgid.unicast.interface_id & p_path->rec.dgid.unicast.interface_id) != (p_path->comp.dgid.unicast.interface_id & p_rec->dgid.unicast.interface_id)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0169: " "DGID mismatch on path SLID 0x%X to DLID 0x%X\n" "\t\t\t\tExpected 0x%016" PRIx64 " 0x%016" PRIx64 "\n" "\t\t\t\tReceived 0x%016" PRIx64 " 0x%016" PRIx64 "\n", cl_ntoh16(p_path->rec.slid), cl_ntoh16(p_path->rec.dlid), cl_ntoh64(p_path->rec.dgid.unicast.prefix), cl_ntoh64(p_path->rec.dgid.unicast.interface_id), cl_ntoh64(p_rec->dgid.unicast.prefix), cl_ntoh64(p_rec->dgid.unicast.interface_id)); status = IB_ERROR; goto Exit; } /* * Check the fields the user wants checked. */ if ((p_path->comp.sgid.unicast.interface_id & p_path->rec.sgid.unicast.interface_id) != (p_path->comp.sgid.unicast.interface_id & p_rec->sgid.unicast.interface_id)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0057: " "SGID mismatch on path SLID 0x%X to DLID 0x%X\n" "\t\t\t\tExpected 0x%016" PRIx64 " 0x%016" PRIx64 ",\n" "\t\t\t\tReceived 0x%016" PRIx64 " 0x%016" PRIx64 ".\n", cl_ntoh16(p_path->rec.slid), cl_ntoh16(p_path->rec.dlid), cl_ntoh64(p_path->rec.sgid.unicast.prefix), cl_ntoh64(p_path->rec.sgid.unicast.interface_id), cl_ntoh64(p_rec->sgid.unicast.prefix), cl_ntoh64(p_rec->sgid.unicast.interface_id)); status = IB_ERROR; goto Exit; } /* * Compare the fields the user wishes to validate. */ if ((p_path->comp.pkey & p_path->rec.pkey) != (p_path->comp.pkey & p_rec->pkey)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0012: " "PKEY mismatch on path SLID 0x%X to DLID 0x%X\n" "\t\t\t\tExpected 0x%X, received 0x%X\n", cl_ntoh16(p_path->rec.slid), cl_ntoh16(p_path->rec.dlid), cl_ntoh16(p_path->rec.pkey), cl_ntoh16(p_rec->pkey)); status = IB_ERROR; goto Exit; } Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ static ib_api_status_t osmtest_validate_node_data(IN osmtest_t * const p_osmt, IN node_t * const p_node, IN const ib_node_record_t * const p_rec) { cl_status_t status = IB_SUCCESS; OSM_LOG_ENTER(&p_osmt->log); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "Checking node 0x%016" PRIx64 ", LID 0x%X\n", cl_ntoh64(p_rec->node_info.node_guid), cl_ntoh16(p_rec->lid)); /* * Has this record already been returned? */ if (p_node->count != 0) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0013: " "Already received node 0x%016" PRIx64 "\n", cl_ntoh64(p_node->rec.node_info.node_guid)); status = IB_ERROR; goto Exit; } ++p_node->count; /* * Compare the fields the user wishes to validate. */ if ((p_node->comp.lid & p_node->rec.lid) != (p_node->comp.lid & p_rec->lid)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0014: " "Field mismatch node 0x%016" PRIx64 ", LID 0x%X\n" "\t\t\t\tExpected LID 0x%X, received 0x%X\n", cl_ntoh64(p_rec->node_info.node_guid), cl_ntoh16(p_rec->lid), p_node->rec.lid, p_rec->lid); status = IB_ERROR; goto Exit; } if ((p_node->comp.node_info.base_version & p_node->rec.node_info.base_version) != (p_node->comp.node_info.base_version & p_rec->node_info.base_version)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0015: " "Field mismatch node 0x%016" PRIx64 ", LID 0x%X\n" "\t\t\t\tExpected base_version 0x%X, received 0x%X\n", cl_ntoh64(p_rec->node_info.node_guid), cl_ntoh16(p_rec->lid), p_node->rec.node_info.base_version, p_rec->node_info.base_version); status = IB_ERROR; goto Exit; } if ((p_node->comp.node_info.class_version & p_node->rec.node_info.class_version) != (p_node->comp.node_info.class_version & p_rec->node_info.class_version)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0016: " "Field mismatch node 0x%016" PRIx64 ", LID 0x%X\n" "\t\t\t\tExpected class_version 0x%X, received 0x%X\n", cl_ntoh64(p_rec->node_info.node_guid), cl_ntoh16(p_rec->lid), p_node->rec.node_info.class_version, p_rec->node_info.class_version); status = IB_ERROR; goto Exit; } if ((p_node->comp.node_info.node_type & p_node->rec.node_info.node_type) != (p_node->comp.node_info.node_type & p_rec->node_info.node_type)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0017: " "Field mismatch node 0x%016" PRIx64 ", LID 0x%X\n" "\t\t\t\tExpected node_type 0x%X, received 0x%X\n", cl_ntoh64(p_rec->node_info.node_guid), cl_ntoh16(p_rec->lid), p_node->rec.node_info.node_type, p_rec->node_info.node_type); status = IB_ERROR; goto Exit; } if ((p_node->comp.node_info.sys_guid & p_node->rec.node_info.sys_guid) != (p_node->comp.node_info.sys_guid & p_rec->node_info.sys_guid)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0018: " "Field mismatch node 0x%016" PRIx64 ", LID 0x%X\n" "\t\t\t\tExpected sys_guid 0x%016" PRIx64 ", received 0x%016" PRIx64 "\n", cl_ntoh64(p_rec->node_info.node_guid), cl_ntoh16(p_rec->lid), cl_ntoh64(p_node->rec.node_info.sys_guid), cl_ntoh64(p_rec->node_info.sys_guid)); status = IB_ERROR; goto Exit; } if ((p_node->comp.node_info.node_guid & p_node->rec.node_info.node_guid) != (p_node->comp.node_info.node_guid & p_rec->node_info.node_guid)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0019: " "Field mismatch node 0x%016" PRIx64 ", LID 0x%X\n" "\t\t\t\tExpected node_guid 0x%016" PRIx64 ", received 0x%016" PRIx64 "\n", cl_ntoh64(p_rec->node_info.node_guid), cl_ntoh16(p_rec->lid), cl_ntoh64(p_node->rec.node_info.node_guid), cl_ntoh64(p_rec->node_info.node_guid)); status = IB_ERROR; goto Exit; } if ((p_node->comp.node_info.port_guid & p_node->rec.node_info.port_guid) != (p_node->comp.node_info.port_guid & p_rec->node_info.port_guid)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0031: " "Field mismatch node 0x%016" PRIx64 ", LID 0x%X\n" "\t\t\t\tExpected port_guid 0x%016" PRIx64 ", received 0x%016" PRIx64 "\n", cl_ntoh64(p_rec->node_info.node_guid), cl_ntoh16(p_rec->lid), cl_ntoh64(p_node->rec.node_info.port_guid), cl_ntoh64(p_rec->node_info.port_guid)); status = IB_ERROR; goto Exit; } if ((p_node->comp.node_info.partition_cap & p_node->rec.node_info.partition_cap) != (p_node->comp.node_info.partition_cap & p_rec->node_info.partition_cap)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0032: " "Field mismatch node 0x%016" PRIx64 ", LID 0x%X\n" "\t\t\t\tExpected partition_cap 0x%X, received 0x%X\n", cl_ntoh64(p_rec->node_info.node_guid), cl_ntoh16(p_rec->lid), cl_ntoh16(p_node->rec.node_info.partition_cap), cl_ntoh16(p_rec->node_info.partition_cap)); status = IB_ERROR; goto Exit; } if ((p_node->comp.node_info.device_id & p_node->rec.node_info.device_id) != (p_node->comp.node_info.device_id & p_rec->node_info.device_id)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0033: " "Field mismatch node 0x%016" PRIx64 ", LID 0x%X\n" "\t\t\t\tExpected device_id 0x%X, received 0x%X\n", cl_ntoh64(p_rec->node_info.node_guid), cl_ntoh16(p_rec->lid), cl_ntoh16(p_node->rec.node_info.device_id), cl_ntoh16(p_rec->node_info.device_id)); status = IB_ERROR; goto Exit; } if ((p_node->comp.node_info.revision & p_node->rec.node_info.revision) != (p_node->comp.node_info.revision & p_rec->node_info.revision)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0034: " "Field mismatch node 0x%016" PRIx64 ", LID 0x%X\n" "\t\t\t\tExpected revision 0x%X, received 0x%X\n", cl_ntoh64(p_rec->node_info.node_guid), cl_ntoh16(p_rec->lid), cl_ntoh32(p_node->rec.node_info.revision), cl_ntoh32(p_rec->node_info.revision)); status = IB_ERROR; goto Exit; } Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ static ib_api_status_t osmtest_validate_node_rec(IN osmtest_t * const p_osmt, IN const ib_node_record_t * const p_rec) { cl_status_t status = IB_SUCCESS; node_t *p_node; const cl_qmap_t *p_tbl; OSM_LOG_ENTER(&p_osmt->log); /* * Find proper node record in the database. */ p_tbl = &p_osmt->exp_subn.node_lid_tbl; p_node = (node_t *) cl_qmap_get(p_tbl, p_rec->lid); if (p_node == (node_t *) cl_qmap_end(p_tbl)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0035: " "Unexpected node 0x%016" PRIx64 ", LID 0x%X\n", cl_ntoh64(p_rec->node_info.node_guid), cl_ntoh16(p_rec->lid)); status = IB_ERROR; goto Exit; } status = osmtest_validate_node_data(p_osmt, p_node, p_rec); Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ static ib_api_status_t osmtest_validate_port_data(IN osmtest_t * const p_osmt, IN port_t * const p_port, IN const ib_portinfo_record_t * const p_rec) { cl_status_t status = IB_SUCCESS; OSM_LOG_ENTER(&p_osmt->log); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "Checking port LID 0x%X, Num 0x%X\n", cl_ntoh16(p_rec->lid), p_rec->port_num); /* * Has this record already been returned? */ if (p_port->count != 0) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0036: " "Already received port LID 0x%X, Num 0x%X\n", cl_ntoh16(p_rec->lid), p_rec->port_num); status = IB_ERROR; goto Exit; } ++p_port->count; /* * Compare the fields the user wishes to validate. */ if ((p_port->comp.lid & p_port->rec.lid) != (p_port->comp.lid & p_rec->lid)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0037: " "Field mismatch port LID 0x%X Num:0x%X\n" "\t\t\t\tExpected LID 0x%X, received 0x%X\n", cl_ntoh16(p_rec->lid), p_rec->port_num, p_port->rec.lid, p_rec->lid); status = IB_ERROR; goto Exit; } if ((p_port->comp.port_num & p_port->rec.port_num) != (p_port->comp.port_num & p_rec->port_num)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0038: " "Field mismatch port LID 0x%X Num:0x%X\n" "\t\t\t\tExpected port_num 0x%X, received 0x%X\n", cl_ntoh16(p_rec->lid), p_rec->port_num, p_port->rec.port_num, p_rec->port_num); status = IB_ERROR; goto Exit; } if ((p_port->comp.port_info.m_key & p_port->rec.port_info.m_key) != (p_port->comp.port_info.m_key & p_rec->port_info.m_key)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0039: " "Field mismatch port LID 0x%X Num:0x%X\n" "\t\t\t\tExpected m_key 0x%016" PRIx64 ", received 0x%016" PRIx64 "\n", cl_ntoh16(p_rec->lid), p_rec->port_num, p_port->rec.port_info.m_key, p_rec->port_info.m_key); status = IB_ERROR; goto Exit; } if ((p_port->comp.port_info.subnet_prefix & p_port->rec.port_info. subnet_prefix) != (p_port->comp.port_info.subnet_prefix & p_rec->port_info. subnet_prefix)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0040: " "Field mismatch port LID 0x%X Num:0x%X\n" "\t\t\t\tExpected subnet_prefix 0x%016" PRIx64 ", received 0x%016" PRIx64 "\n", cl_ntoh16(p_rec->lid), p_rec->port_num, p_port->rec.port_info.subnet_prefix, p_rec->port_info.subnet_prefix); status = IB_ERROR; goto Exit; } if ((p_port->comp.port_info.base_lid & p_port->rec.port_info. base_lid) != (p_port->comp.port_info.base_lid & p_rec->port_info.base_lid)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0041: " "Field mismatch port LID 0x%X Num:0x%X\n" "\t\t\t\tExpected base_lid 0x%X, received 0x%X\n", cl_ntoh16(p_rec->lid), p_rec->port_num, p_port->rec.port_info.base_lid, p_rec->port_info.base_lid); status = IB_ERROR; goto Exit; } if ((p_port->comp.port_info.master_sm_base_lid & p_port->rec.port_info. master_sm_base_lid) != (p_port->comp.port_info.master_sm_base_lid & p_rec->port_info. master_sm_base_lid)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0042: " "Field mismatch port LID 0x%X Num:0x%X\n" "\t\t\t\tExpected master_sm_base_lid 0x%X, received 0x%X\n", cl_ntoh16(p_rec->lid), p_rec->port_num, p_port->rec.port_info.master_sm_base_lid, p_rec->port_info.master_sm_base_lid); status = IB_ERROR; goto Exit; } if ((p_port->comp.port_info.capability_mask & p_port->rec.port_info. capability_mask) != (p_port->comp.port_info.capability_mask & p_rec->port_info. capability_mask)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0043: " "Field mismatch port LID 0x%X Num:0x%X\n" "\t\t\t\tExpected capability_mask 0x%X, received 0x%X\n", cl_ntoh16(p_rec->lid), p_rec->port_num, cl_ntoh32(p_port->rec.port_info.capability_mask), cl_ntoh32(p_rec->port_info.capability_mask)); status = IB_ERROR; goto Exit; } if ((p_port->comp.port_info.diag_code & p_port->rec.port_info. diag_code) != (p_port->comp.port_info.diag_code & p_rec->port_info.diag_code)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0044: " "Field mismatch port LID 0x%X Num:0x%X\n" "\t\t\t\tExpected diag_code 0x%X, received 0x%X\n", cl_ntoh16(p_rec->lid), p_rec->port_num, p_port->rec.port_info.diag_code, p_rec->port_info.diag_code); status = IB_ERROR; goto Exit; } if ((p_port->comp.port_info.m_key_lease_period & p_port->rec.port_info. m_key_lease_period) != (p_port->comp.port_info.m_key_lease_period & p_rec->port_info. m_key_lease_period)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0045: " "Field mismatch port LID 0x%X Num:0x%X\n" "\t\t\t\tExpected m_key_lease_period 0x%X, received 0x%X\n", cl_ntoh16(p_rec->lid), p_rec->port_num, p_port->rec.port_info.m_key_lease_period, p_rec->port_info.m_key_lease_period); status = IB_ERROR; goto Exit; } if ((p_port->comp.port_info.local_port_num & p_port->rec.port_info. local_port_num) != (p_port->comp.port_info.local_port_num & p_rec->port_info. local_port_num)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0046: " "Field mismatch port LID 0x%X Num:0x%X\n" "\t\t\t\tExpected local_port_num 0x%X, received 0x%X\n", cl_ntoh16(p_rec->lid), p_rec->port_num, p_port->rec.port_info.local_port_num, p_rec->port_info.local_port_num); status = IB_ERROR; goto Exit; } if ((p_port->comp.port_info.link_width_enabled & p_port->rec.port_info. link_width_enabled) != (p_port->comp.port_info.link_width_enabled & p_rec->port_info. link_width_enabled)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0047: " "Field mismatch port LID 0x%X Num:0x%X\n" "\t\t\t\tExpected link_width_enabled 0x%X, received 0x%X\n", cl_ntoh16(p_rec->lid), p_rec->port_num, p_port->rec.port_info.link_width_enabled, p_rec->port_info.link_width_enabled); status = IB_ERROR; goto Exit; } if ((p_port->comp.port_info.link_width_supported & p_port->rec. port_info.link_width_supported) != (p_port->comp.port_info.link_width_supported & p_rec->port_info. link_width_supported)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0048: " "Field mismatch port LID 0x%X Num:0x%X\n" "\t\t\t\tExpected link_width_supported 0x%X, received 0x%X\n", cl_ntoh16(p_rec->lid), p_rec->port_num, p_port->rec.port_info.link_width_supported, p_rec->port_info.link_width_supported); status = IB_ERROR; goto Exit; } if ((p_port->comp.port_info.link_width_active & p_port->rec.port_info. link_width_active) != (p_port->comp.port_info.link_width_active & p_rec->port_info. link_width_active)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0049: " "Field mismatch port LID 0x%X Num:0x%X\n" "\t\t\t\tExpected link_width_active 0x%X, received 0x%X\n", cl_ntoh16(p_rec->lid), p_rec->port_num, p_port->rec.port_info.link_width_active, p_rec->port_info.link_width_active); status = IB_ERROR; goto Exit; } if ((p_port->comp.port_info.link_speed & p_port->rec.port_info. link_speed) != (p_port->comp.port_info.link_speed & p_rec->port_info.link_speed)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0054: " "Field mismatch port LID 0x%X Num:0x%X\n" "\t\t\t\tExpected link_speed 0x%X, received 0x%X\n", cl_ntoh16(p_rec->lid), p_rec->port_num, p_port->rec.port_info.link_speed, p_rec->port_info.link_speed); status = IB_ERROR; goto Exit; } if ((p_port->comp.port_info.state_info1 & p_port->rec.port_info. state_info1) != (p_port->comp.port_info.state_info1 & p_rec->port_info. state_info1)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0055: " "Field mismatch port LID 0x%X Num:0x%X\n" "\t\t\t\tExpected state_info1 0x%X, received 0x%X\n", cl_ntoh16(p_rec->lid), p_rec->port_num, p_port->rec.port_info.state_info1, p_rec->port_info.state_info1); status = IB_ERROR; goto Exit; } if ((p_port->comp.port_info.state_info2 & p_port->rec.port_info. state_info2) != (p_port->comp.port_info.state_info2 & p_rec->port_info. state_info2)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0058: " "Field mismatch port LID 0x%X Num:0x%X\n" "\t\t\t\tExpected state_info2 0x%X, received 0x%X\n", cl_ntoh16(p_rec->lid), p_rec->port_num, p_port->rec.port_info.state_info2, p_rec->port_info.state_info2); status = IB_ERROR; goto Exit; } if ((p_port->comp.port_info.mkey_lmc & p_port->rec.port_info. mkey_lmc) != (p_port->comp.port_info.mkey_lmc & p_rec->port_info.mkey_lmc)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0059: " "Field mismatch port LID 0x%X Num:0x%X\n" "\t\t\t\tExpected mkey_lmc 0x%X, received 0x%X\n", cl_ntoh16(p_rec->lid), p_rec->port_num, p_port->rec.port_info.mkey_lmc, p_rec->port_info.mkey_lmc); status = IB_ERROR; goto Exit; } if ((p_port->comp.port_info.link_speed & p_port->rec.port_info. link_speed) != (p_port->comp.port_info.link_speed & p_rec->port_info.link_speed)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0060: " "Field mismatch port LID 0x%X Num:0x%X\n" "\t\t\t\tExpected link_speed 0x%X, received 0x%X\n", cl_ntoh16(p_rec->lid), p_rec->port_num, p_port->rec.port_info.link_speed, p_rec->port_info.link_speed); status = IB_ERROR; goto Exit; } if ((p_port->comp.port_info.mtu_smsl & p_port->rec.port_info. mtu_smsl) != (p_port->comp.port_info.mtu_smsl & p_rec->port_info.mtu_smsl)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0061: " "Field mismatch port LID 0x%X Num:0x%X\n" "\t\t\t\tExpected mtu_smsl 0x%X, received 0x%X\n", cl_ntoh16(p_rec->lid), p_rec->port_num, p_port->rec.port_info.mtu_smsl, p_rec->port_info.mtu_smsl); status = IB_ERROR; goto Exit; } if ((p_port->comp.port_info.vl_cap & p_port->rec.port_info.vl_cap) != (p_port->comp.port_info.vl_cap & p_rec->port_info.vl_cap)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0062: " "Field mismatch port LID 0x%X Num:0x%X\n" "\t\t\t\tExpected vl_cap 0x%X, received 0x%X\n", cl_ntoh16(p_rec->lid), p_rec->port_num, p_port->rec.port_info.vl_cap, p_rec->port_info.vl_cap); status = IB_ERROR; goto Exit; } if ((p_port->comp.port_info.vl_high_limit & p_port->rec.port_info. vl_high_limit) != (p_port->comp.port_info.vl_high_limit & p_rec->port_info. vl_high_limit)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0082: " "Field mismatch port LID 0x%X Num:0x%X\n" "\t\t\t\tExpected vl_high_limit 0x%X, received 0x%X\n", cl_ntoh16(p_rec->lid), p_rec->port_num, p_port->rec.port_info.vl_high_limit, p_rec->port_info.vl_high_limit); status = IB_ERROR; goto Exit; } if ((p_port->comp.port_info.vl_arb_high_cap & p_port->rec.port_info. vl_arb_high_cap) != (p_port->comp.port_info.vl_arb_high_cap & p_rec->port_info. vl_arb_high_cap)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0083: " "Field mismatch port LID 0x%X Num:0x%X\n" "\t\t\t\tExpected vl_arb_high_cap 0x%X, received 0x%X\n", cl_ntoh16(p_rec->lid), p_rec->port_num, p_port->rec.port_info.vl_arb_high_cap, p_rec->port_info.vl_arb_high_cap); status = IB_ERROR; goto Exit; } if ((p_port->comp.port_info.vl_arb_low_cap & p_port->rec.port_info. vl_arb_low_cap) != (p_port->comp.port_info.vl_arb_low_cap & p_rec->port_info. vl_arb_low_cap)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0084: " "Field mismatch port LID 0x%X Num:0x%X\n" "\t\t\t\tExpected vl_arb_low_cap 0x%X, received 0x%X\n", cl_ntoh16(p_rec->lid), p_rec->port_num, p_port->rec.port_info.vl_arb_low_cap, p_rec->port_info.vl_arb_low_cap); status = IB_ERROR; goto Exit; } if ((p_port->comp.port_info.mtu_cap & p_port->rec.port_info.mtu_cap) != (p_port->comp.port_info.mtu_cap & p_rec->port_info.mtu_cap)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0085: " "Field mismatch port LID 0x%X Num:0x%X\n" "\t\t\t\tExpected mtu_cap 0x%X, received 0x%X\n", cl_ntoh16(p_rec->lid), p_rec->port_num, p_port->rec.port_info.mtu_cap, p_rec->port_info.mtu_cap); status = IB_ERROR; goto Exit; } #if 0 /* this is a dynamic attribute */ if ((p_port->comp.port_info.vl_stall_life & p_port->rec.port_info. vl_stall_life) != (p_port->comp.port_info.vl_stall_life & p_rec->port_info. vl_stall_life)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 012F: " "Field mismatch port LID 0x%X Num:0x%X\n" "\t\t\t\tExpected vl_stall_life 0x%X, received 0x%X\n", cl_ntoh16(p_rec->lid), p_rec->port_num, p_port->rec.port_info.vl_stall_life, p_rec->port_info.vl_stall_life); status = IB_ERROR; goto Exit; } #endif if ((p_port->comp.port_info.vl_enforce & p_port->rec.port_info. vl_enforce) != (p_port->comp.port_info.vl_enforce & p_rec->port_info.vl_enforce)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0086: " "Field mismatch port LID 0x%X Num:0x%X\n" "\t\t\t\tExpected vl_enforce 0x%X, received 0x%X\n", cl_ntoh16(p_rec->lid), p_rec->port_num, p_port->rec.port_info.vl_enforce, p_rec->port_info.vl_enforce); status = IB_ERROR; goto Exit; } if ((p_port->comp.port_info.m_key_violations & p_port->rec.port_info. m_key_violations) != (p_port->comp.port_info.m_key_violations & p_rec->port_info. m_key_violations)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0087: " "Field mismatch port LID 0x%X Num:0x%X\n" "\t\t\t\tExpected m_key_violations 0x%X, received 0x%X\n", cl_ntoh16(p_rec->lid), p_rec->port_num, cl_ntoh16(p_port->rec.port_info.m_key_violations), cl_ntoh16(p_rec->port_info.m_key_violations)); status = IB_ERROR; goto Exit; } if ((p_port->comp.port_info.p_key_violations & p_port->rec.port_info. p_key_violations) != (p_port->comp.port_info.p_key_violations & p_rec->port_info. p_key_violations)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0088: " "Field mismatch port LID 0x%X Num:0x%X\n" "\t\t\t\tExpected p_key_violations 0x%X, received 0x%X\n", cl_ntoh16(p_rec->lid), p_rec->port_num, cl_ntoh16(p_port->rec.port_info.p_key_violations), cl_ntoh16(p_rec->port_info.p_key_violations)); status = IB_ERROR; goto Exit; } if ((p_port->comp.port_info.q_key_violations & p_port->rec.port_info. q_key_violations) != (p_port->comp.port_info.q_key_violations & p_rec->port_info. q_key_violations)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0089: " "Field mismatch port LID 0x%X Num:0x%X\n" "\t\t\t\tExpected q_key_violations 0x%X, received 0x%X\n", cl_ntoh16(p_rec->lid), p_rec->port_num, cl_ntoh16(p_port->rec.port_info.q_key_violations), cl_ntoh16(p_rec->port_info.q_key_violations)); status = IB_ERROR; goto Exit; } if ((p_port->comp.port_info.guid_cap & p_port->rec.port_info. guid_cap) != (p_port->comp.port_info.guid_cap & p_rec->port_info.guid_cap)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0090: " "Field mismatch port LID 0x%X Num:0x%X\n" "\t\t\t\tExpected guid_cap 0x%X, received 0x%X\n", cl_ntoh16(p_rec->lid), p_rec->port_num, p_port->rec.port_info.guid_cap, p_rec->port_info.guid_cap); status = IB_ERROR; goto Exit; } if ((p_port->comp.port_info.subnet_timeout & p_port->rec.port_info. subnet_timeout) != (p_port->comp.port_info.subnet_timeout & p_rec->port_info. subnet_timeout)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0091: " "Field mismatch port LID 0x%X Num:0x%X\n" "\t\t\t\tExpected subnet_timeout 0x%X, received 0x%X\n", cl_ntoh16(p_rec->lid), p_rec->port_num, ib_port_info_get_timeout(&p_port->rec.port_info), ib_port_info_get_timeout(&p_rec->port_info)); status = IB_ERROR; goto Exit; } if ((p_port->comp.port_info.resp_time_value & p_port->rec.port_info. resp_time_value) != (p_port->comp.port_info.resp_time_value & p_rec->port_info. resp_time_value)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0092: " "Field mismatch port LID 0x%X Num:0x%X\n" "\t\t\t\tExpected resp_time_value 0x%X, received 0x%X\n", cl_ntoh16(p_rec->lid), p_rec->port_num, p_port->rec.port_info.resp_time_value, p_rec->port_info.resp_time_value); status = IB_ERROR; goto Exit; } if ((p_port->comp.port_info.error_threshold & p_port->rec.port_info. error_threshold) != (p_port->comp.port_info.error_threshold & p_rec->port_info. error_threshold)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0093: " "Field mismatch port LID 0x%X Num:0x%X\n" "\t\t\t\tExpected error_threshold 0x%X, received 0x%X\n", cl_ntoh16(p_rec->lid), p_rec->port_num, p_port->rec.port_info.error_threshold, p_rec->port_info.error_threshold); status = IB_ERROR; goto Exit; } Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ static ib_api_status_t osmtest_validate_port_rec(IN osmtest_t * const p_osmt, IN const ib_portinfo_record_t * const p_rec) { cl_status_t status = IB_SUCCESS; port_t *p_port; const cl_qmap_t *p_tbl; OSM_LOG_ENTER(&p_osmt->log); /* * Find proper port record in the database. * (we use by guid - since lid is not unique) */ p_tbl = &p_osmt->exp_subn.port_key_tbl; p_port = (port_t *) cl_qmap_get(p_tbl, port_gen_id(p_rec->lid, p_rec->port_num)); if (p_port == (port_t *) cl_qmap_end(p_tbl)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0094: " "Unexpected port LID 0x%X, Num:0x%X\n", cl_ntoh16(p_rec->lid), p_rec->port_num); status = IB_ERROR; goto Exit; } status = osmtest_validate_port_data(p_osmt, p_port, p_rec); Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ static ib_api_status_t osmtest_validate_path_rec(IN osmtest_t * const p_osmt, IN const ib_path_rec_t * const p_rec) { cl_status_t status = IB_SUCCESS; path_t *p_path; const cl_qmap_t *p_tbl; OSM_LOG_ENTER(&p_osmt->log); /* * Find proper path record in the database. */ p_tbl = &p_osmt->exp_subn.path_tbl; p_path = (path_t *) cl_qmap_get(p_tbl, osmtest_path_rec_key_get(p_rec)); if (p_path == (path_t *) cl_qmap_end(p_tbl)) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0095: " "Unexpected path SLID 0x%X to DLID 0x%X\n", cl_ntoh16(p_rec->slid), cl_ntoh16(p_rec->dlid)); status = IB_ERROR; goto Exit; } status = osmtest_validate_path_data(p_osmt, p_path, p_rec); Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } #ifdef VENDOR_RMPP_SUPPORT ib_net64_t portguid = 0; /********************************************************************** **********************************************************************/ static ib_api_status_t osmtest_validate_all_node_recs(IN osmtest_t * const p_osmt) { osmtest_req_context_t context; const ib_node_record_t *p_rec; uint32_t i; cl_status_t status; size_t num_recs; OSM_LOG_ENTER(&p_osmt->log); memset(&context, 0, sizeof(context)); /* * Do a blocking query for all NodeRecords in the subnet. */ status = osmtest_get_all_recs(p_osmt, IB_MAD_ATTR_NODE_RECORD, sizeof(*p_rec), &context); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0096: " "osmtest_get_all_recs failed (%s)\n", ib_get_err_str(status)); goto Exit; } num_recs = context.result.result_cnt; OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Received %zu records\n", num_recs); /* * Compare the received records to the database. */ osmtest_prepare_db(p_osmt); for (i = 0; i < num_recs; i++) { p_rec = osmv_get_query_node_rec(context.result.p_result_madw, i); status = osmtest_validate_node_rec(p_osmt, p_rec); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0097: " "osmtest_valid_node_rec failed (%s)\n", ib_get_err_str(status)); goto Exit; } if (!portguid) portguid = p_rec->node_info.port_guid; } status = osmtest_check_missing_nodes(p_osmt); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0098: " "osmtest_check_missing_nodes failed (%s)\n", ib_get_err_str(status)); goto Exit; } Exit: /* * Return the IB query MAD to the pool as necessary. */ if (context.result.p_result_madw != NULL) { osm_mad_pool_put(&p_osmt->mad_pool, context.result.p_result_madw); context.result.p_result_madw = NULL; } OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ static ib_api_status_t osmtest_validate_all_guidinfo_recs(IN osmtest_t * const p_osmt) { osmtest_req_context_t context; const ib_guidinfo_record_t *p_rec; cl_status_t status; size_t num_recs; OSM_LOG_ENTER(&p_osmt->log); memset(&context, 0, sizeof(context)); /* * Do a blocking query for all GuidInfoRecords in the subnet. */ status = osmtest_get_all_recs(p_osmt, IB_MAD_ATTR_GUIDINFO_RECORD, sizeof(*p_rec), &context); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0099: " "osmtest_get_all_recs failed (%s)\n", ib_get_err_str(status)); goto Exit; } num_recs = context.result.result_cnt; OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Received %zu records\n", num_recs); /* No validation as yet */ Exit: /* * Return the IB query MAD to the pool as necessary. */ if (context.result.p_result_madw != NULL) { osm_mad_pool_put(&p_osmt->mad_pool, context.result.p_result_madw); context.result.p_result_madw = NULL; } OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ static ib_api_status_t osmtest_validate_all_path_recs(IN osmtest_t * const p_osmt) { osmtest_req_context_t context; const ib_path_rec_t *p_rec; uint32_t i; cl_status_t status; size_t num_recs; OSM_LOG_ENTER(&p_osmt->log); memset(&context, 0, sizeof(context)); /* * Do a blocking query for all PathRecords in the subnet. */ status = osmtest_get_all_recs(p_osmt, IB_MAD_ATTR_PATH_RECORD, sizeof(*p_rec), &context); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 009A: " "osmtest_get_all_recs failed (%s)\n", ib_get_err_str(status)); goto Exit; } num_recs = context.result.result_cnt; OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Received %zu records\n", num_recs); /* * Compare the received records to the database. */ osmtest_prepare_db(p_osmt); for (i = 0; i < num_recs; i++) { p_rec = osmv_get_query_path_rec(context.result.p_result_madw, i); status = osmtest_validate_path_rec(p_osmt, p_rec); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0100: " "osmtest_validate_path_rec failed (%s)\n", ib_get_err_str(status)); goto Exit; } } status = osmtest_check_missing_paths(p_osmt); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0101: " "osmtest_check_missing_paths failed (%s)\n", ib_get_err_str(status)); goto Exit; } Exit: /* * Return the IB query MAD to the pool as necessary. */ if (context.result.p_result_madw != NULL) { osm_mad_pool_put(&p_osmt->mad_pool, context.result.p_result_madw); context.result.p_result_madw = NULL; } OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** * Get link record by LID **********************************************************************/ ib_api_status_t osmtest_get_link_rec_by_lid(IN osmtest_t * const p_osmt, IN ib_net16_t const from_lid, IN ib_net16_t const to_lid, IN OUT osmtest_req_context_t * const p_context) { ib_api_status_t status = IB_SUCCESS; osmv_user_query_t user; osmv_query_req_t req; ib_link_record_t record; ib_mad_t *p_mad; OSM_LOG_ENTER(&p_osmt->log); OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Getting link record from LID 0x%02X to LID 0x%02X\n", cl_ntoh16(from_lid), cl_ntoh16(to_lid)); /* * Do a blocking query for this record in the subnet. * The result is returned in the result field of the caller's * context structure. * * The query structures are locals. */ memset(&req, 0, sizeof(req)); memset(&user, 0, sizeof(user)); memset(&record, 0, sizeof(record)); record.from_lid = from_lid; record.to_lid = to_lid; p_context->p_osmt = p_osmt; if (from_lid) user.comp_mask |= IB_LR_COMPMASK_FROM_LID; if (to_lid) user.comp_mask |= IB_LR_COMPMASK_TO_LID; user.attr_id = IB_MAD_ATTR_LINK_RECORD; user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3)); user.p_attr = &record; req.query_type = OSMV_QUERY_USER_DEFINED; req.timeout_ms = p_osmt->opt.transaction_timeout; req.retry_cnt = p_osmt->opt.retry_count; req.flags = OSM_SA_FLAGS_SYNC; req.query_context = p_context; req.pfn_query_cb = osmtest_query_res_cb; req.p_query_input = &user; req.sm_key = 0; status = osmv_query_sa(p_osmt->h_bind, &req); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 007A: " "ib_query failed (%s)\n", ib_get_err_str(status)); goto Exit; } status = p_context->result.status; if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 007B: " "ib_query failed (%s)\n", ib_get_err_str(status)); if (status == IB_REMOTE_ERROR) { p_mad = osm_madw_get_mad_ptr(p_context->result. p_result_madw); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "osmtest_get_link_rec_by_lid: " "Remote error = %s\n", ib_get_mad_status_str(p_mad)); status = (ib_net16_t) (p_mad->status & IB_SMP_STATUS_MASK); } goto Exit; } Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** * Get GUIDInfo record by LID **********************************************************************/ ib_api_status_t osmtest_get_guidinfo_rec_by_lid(IN osmtest_t * const p_osmt, IN ib_net16_t const lid, IN OUT osmtest_req_context_t * const p_context) { ib_api_status_t status = IB_SUCCESS; osmv_user_query_t user; osmv_query_req_t req; ib_guidinfo_record_t record; ib_mad_t *p_mad; OSM_LOG_ENTER(&p_osmt->log); OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Getting GUIDInfo record for LID 0x%02X\n", cl_ntoh16(lid)); /* * Do a blocking query for this record in the subnet. * The result is returned in the result field of the caller's * context structure. * * The query structures are locals. */ memset(&req, 0, sizeof(req)); memset(&user, 0, sizeof(user)); memset(&record, 0, sizeof(record)); record.lid = lid; p_context->p_osmt = p_osmt; user.comp_mask = IB_GIR_COMPMASK_LID; user.attr_id = IB_MAD_ATTR_GUIDINFO_RECORD; user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3)); user.p_attr = &record; req.query_type = OSMV_QUERY_USER_DEFINED; req.timeout_ms = p_osmt->opt.transaction_timeout; req.retry_cnt = p_osmt->opt.retry_count; req.flags = OSM_SA_FLAGS_SYNC; req.query_context = p_context; req.pfn_query_cb = osmtest_query_res_cb; req.p_query_input = &user; req.sm_key = 0; status = osmv_query_sa(p_osmt->h_bind, &req); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 007C: " "ib_query failed (%s)\n", ib_get_err_str(status)); goto Exit; } status = p_context->result.status; if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 007D: " "ib_query failed (%s)\n", ib_get_err_str(status)); if (status == IB_REMOTE_ERROR) { p_mad = osm_madw_get_mad_ptr(p_context->result. p_result_madw); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "Remote error = %s\n", ib_get_mad_status_str(p_mad)); status = (ib_net16_t) (p_mad->status & IB_SMP_STATUS_MASK); } goto Exit; } Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** * Get PKeyTable record by LID **********************************************************************/ ib_api_status_t osmtest_get_pkeytbl_rec_by_lid(IN osmtest_t * const p_osmt, IN ib_net16_t const lid, IN ib_net64_t const sm_key, IN OUT osmtest_req_context_t * const p_context) { ib_api_status_t status = IB_SUCCESS; osmv_user_query_t user; osmv_query_req_t req; ib_pkey_table_record_t record; ib_mad_t *p_mad; OSM_LOG_ENTER(&p_osmt->log); OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Getting PKeyTable record for LID 0x%02X\n", cl_ntoh16(lid)); /* * Do a blocking query for this record in the subnet. * The result is returned in the result field of the caller's * context structure. * * The query structures are locals. */ memset(&req, 0, sizeof(req)); memset(&user, 0, sizeof(user)); memset(&record, 0, sizeof(record)); record.lid = lid; p_context->p_osmt = p_osmt; user.comp_mask = IB_PKEY_COMPMASK_LID; user.attr_id = IB_MAD_ATTR_PKEY_TBL_RECORD; user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3)); user.p_attr = &record; req.query_type = OSMV_QUERY_USER_DEFINED; req.timeout_ms = p_osmt->opt.transaction_timeout; req.retry_cnt = p_osmt->opt.retry_count; req.flags = OSM_SA_FLAGS_SYNC; req.query_context = p_context; req.pfn_query_cb = osmtest_query_res_cb; req.p_query_input = &user; req.sm_key = sm_key; status = osmv_query_sa(p_osmt->h_bind, &req); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 007E: " "ib_query failed (%s)\n", ib_get_err_str(status)); goto Exit; } status = p_context->result.status; if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 007F: " "ib_query failed (%s)\n", ib_get_err_str(status)); if (status == IB_REMOTE_ERROR) { p_mad = osm_madw_get_mad_ptr(p_context->result. p_result_madw); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "Remote error = %s\n", ib_get_mad_status_str(p_mad)); status = (ib_net16_t) (p_mad->status & IB_SMP_STATUS_MASK); } goto Exit; } Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** * Get SwitchInfo record by LID **********************************************************************/ ib_api_status_t osmtest_get_sw_info_rec_by_lid(IN osmtest_t * const p_osmt, IN ib_net16_t const lid, IN OUT osmtest_req_context_t * const p_context) { ib_api_status_t status = IB_SUCCESS; osmv_user_query_t user; osmv_query_req_t req; ib_switch_info_record_t record; ib_mad_t *p_mad; OSM_LOG_ENTER(&p_osmt->log); OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Getting SwitchInfo record for LID 0x%02X\n", cl_ntoh16(lid)); /* * Do a blocking query for this record in the subnet. * The result is returned in the result field of the caller's * context structure. * * The query structures are locals. */ memset(&req, 0, sizeof(req)); memset(&user, 0, sizeof(user)); memset(&record, 0, sizeof(record)); record.lid = lid; p_context->p_osmt = p_osmt; if (lid) user.comp_mask = IB_SWIR_COMPMASK_LID; user.attr_id = IB_MAD_ATTR_SWITCH_INFO_RECORD; user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3)); user.p_attr = &record; req.query_type = OSMV_QUERY_USER_DEFINED; req.timeout_ms = p_osmt->opt.transaction_timeout; req.retry_cnt = p_osmt->opt.retry_count; req.flags = OSM_SA_FLAGS_SYNC; req.query_context = p_context; req.pfn_query_cb = osmtest_query_res_cb; req.p_query_input = &user; req.sm_key = 0; status = osmv_query_sa(p_osmt->h_bind, &req); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 006C: " "ib_query failed (%s)\n", ib_get_err_str(status)); goto Exit; } status = p_context->result.status; if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 006D: " "ib_query failed (%s)\n", ib_get_err_str(status)); if (status == IB_REMOTE_ERROR) { p_mad = osm_madw_get_mad_ptr(p_context->result. p_result_madw); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "Remote error = %s\n", ib_get_mad_status_str(p_mad)); status = (ib_net16_t) (p_mad->status & IB_SMP_STATUS_MASK); } goto Exit; } Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** * Get LFT record by LID **********************************************************************/ ib_api_status_t osmtest_get_lft_rec_by_lid(IN osmtest_t * const p_osmt, IN ib_net16_t const lid, IN OUT osmtest_req_context_t * const p_context) { ib_api_status_t status = IB_SUCCESS; osmv_user_query_t user; osmv_query_req_t req; ib_lft_record_t record; ib_mad_t *p_mad; OSM_LOG_ENTER(&p_osmt->log); OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Getting LFT record for LID 0x%02X\n", cl_ntoh16(lid)); /* * Do a blocking query for this record in the subnet. * The result is returned in the result field of the caller's * context structure. * * The query structures are locals. */ memset(&req, 0, sizeof(req)); memset(&user, 0, sizeof(user)); memset(&record, 0, sizeof(record)); record.lid = lid; p_context->p_osmt = p_osmt; if (lid) user.comp_mask = IB_LFTR_COMPMASK_LID; user.attr_id = IB_MAD_ATTR_LFT_RECORD; user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3)); user.p_attr = &record; req.query_type = OSMV_QUERY_USER_DEFINED; req.timeout_ms = p_osmt->opt.transaction_timeout; req.retry_cnt = p_osmt->opt.retry_count; req.flags = OSM_SA_FLAGS_SYNC; req.query_context = p_context; req.pfn_query_cb = osmtest_query_res_cb; req.p_query_input = &user; req.sm_key = 0; status = osmv_query_sa(p_osmt->h_bind, &req); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 008A: " "ib_query failed (%s)\n", ib_get_err_str(status)); goto Exit; } status = p_context->result.status; if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 008B: " "ib_query failed (%s)\n", ib_get_err_str(status)); if (status == IB_REMOTE_ERROR) { p_mad = osm_madw_get_mad_ptr(p_context->result. p_result_madw); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "Remote error = %s\n", ib_get_mad_status_str(p_mad)); status = (ib_net16_t) (p_mad->status & IB_SMP_STATUS_MASK); } goto Exit; } Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** * Get MFT record by LID **********************************************************************/ ib_api_status_t osmtest_get_mft_rec_by_lid(IN osmtest_t * const p_osmt, IN ib_net16_t const lid, IN OUT osmtest_req_context_t * const p_context) { ib_api_status_t status = IB_SUCCESS; osmv_user_query_t user; osmv_query_req_t req; ib_mft_record_t record; ib_mad_t *p_mad; OSM_LOG_ENTER(&p_osmt->log); OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Getting MFT record for LID 0x%02X\n", cl_ntoh16(lid)); /* * Do a blocking query for this record in the subnet. * The result is returned in the result field of the caller's * context structure. * * The query structures are locals. */ memset(&req, 0, sizeof(req)); memset(&user, 0, sizeof(user)); memset(&record, 0, sizeof(record)); record.lid = lid; p_context->p_osmt = p_osmt; if (lid) user.comp_mask = IB_MFTR_COMPMASK_LID; user.attr_id = IB_MAD_ATTR_MFT_RECORD; user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3)); user.p_attr = &record; req.query_type = OSMV_QUERY_USER_DEFINED; req.timeout_ms = p_osmt->opt.transaction_timeout; req.retry_cnt = p_osmt->opt.retry_count; req.flags = OSM_SA_FLAGS_SYNC; req.query_context = p_context; req.pfn_query_cb = osmtest_query_res_cb; req.p_query_input = &user; req.sm_key = 0; status = osmv_query_sa(p_osmt->h_bind, &req); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 009B: " "ib_query failed (%s)\n", ib_get_err_str(status)); goto Exit; } status = p_context->result.status; if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 009C: " "ib_query failed (%s)\n", ib_get_err_str(status)); if (status == IB_REMOTE_ERROR) { p_mad = osm_madw_get_mad_ptr(p_context->result. p_result_madw); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "Remote error = %s\n", ib_get_mad_status_str(p_mad)); status = (ib_net16_t) (p_mad->status & IB_SMP_STATUS_MASK); } goto Exit; } Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ static ib_api_status_t osmtest_sminfo_record_request(IN osmtest_t * const p_osmt, IN uint8_t method, IN void *p_options, IN OUT osmtest_req_context_t * const p_context) { ib_api_status_t status = IB_SUCCESS; osmv_user_query_t user; osmv_query_req_t req; ib_sminfo_record_t record; ib_mad_t *p_mad; osmtest_sm_info_rec_t *p_sm_info_opt; OSM_LOG_ENTER(&p_osmt->log); /* * Do a blocking query for these records in the subnet. * The result is returned in the result field of the caller's * context structure. * * The query structures are locals. */ memset(&req, 0, sizeof(req)); memset(&user, 0, sizeof(user)); memset(&record, 0, sizeof(record)); p_context->p_osmt = p_osmt; user.attr_id = IB_MAD_ATTR_SMINFO_RECORD; user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3)); p_sm_info_opt = p_options; if (p_sm_info_opt->sm_guid != 0) { record.sm_info.guid = p_sm_info_opt->sm_guid; user.comp_mask |= IB_SMIR_COMPMASK_GUID; } if (p_sm_info_opt->lid != 0) { record.lid = p_sm_info_opt->lid; user.comp_mask |= IB_SMIR_COMPMASK_LID; } if (p_sm_info_opt->priority != 0) { record.sm_info.pri_state = (p_sm_info_opt->priority & 0x0F) << 4; user.comp_mask |= IB_SMIR_COMPMASK_PRIORITY; } if (p_sm_info_opt->sm_state != 0) { record.sm_info.pri_state |= p_sm_info_opt->sm_state & 0x0F; user.comp_mask |= IB_SMIR_COMPMASK_SMSTATE; } user.method = method; user.p_attr = &record; req.query_type = OSMV_QUERY_USER_DEFINED; req.timeout_ms = p_osmt->opt.transaction_timeout; req.retry_cnt = p_osmt->opt.retry_count; req.flags = OSM_SA_FLAGS_SYNC; req.query_context = p_context; req.pfn_query_cb = osmtest_query_res_cb; req.p_query_input = &user; req.sm_key = 0; status = osmv_query_sa(p_osmt->h_bind, &req); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 008C: " "ib_query failed (%s)\n", ib_get_err_str(status)); goto Exit; } status = p_context->result.status; if (status != IB_SUCCESS) { if (status != IB_INVALID_PARAMETER) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 008D: " "ib_query failed (%s)\n", ib_get_err_str(status)); } if (status == IB_REMOTE_ERROR) { p_mad = osm_madw_get_mad_ptr(p_context->result. p_result_madw); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "Remote error = %s\n", ib_get_mad_status_str(p_mad)); status = (ib_net16_t) (p_mad->status & IB_SMP_STATUS_MASK); } goto Exit; } Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ static ib_api_status_t osmtest_informinfo_request(IN osmtest_t * const p_osmt, IN ib_net16_t attr_id, IN uint8_t method, IN void *p_options, IN OUT osmtest_req_context_t * const p_context) { ib_api_status_t status = IB_SUCCESS; osmv_user_query_t user; osmv_query_req_t req; ib_inform_info_t rec; ib_inform_info_record_t record; ib_mad_t *p_mad; osmtest_inform_info_t *p_inform_info_opt; osmtest_inform_info_rec_t *p_inform_info_rec_opt; OSM_LOG_ENTER(&p_osmt->log); /* * Do a blocking query for these records in the subnet. * The result is returned in the result field of the caller's * context structure. * * The query structures are locals. */ memset(&req, 0, sizeof(req)); memset(&user, 0, sizeof(user)); memset(&rec, 0, sizeof(rec)); memset(&record, 0, sizeof(record)); p_context->p_osmt = p_osmt; user.attr_id = attr_id; if (attr_id == IB_MAD_ATTR_INFORM_INFO_RECORD) { user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3)); p_inform_info_rec_opt = p_options; if (p_inform_info_rec_opt->subscriber_gid.unicast.prefix != 0 && p_inform_info_rec_opt->subscriber_gid.unicast. interface_id != 0) { record.subscriber_gid = p_inform_info_rec_opt->subscriber_gid; user.comp_mask = IB_IIR_COMPMASK_SUBSCRIBERGID; } record.subscriber_enum = cl_hton16(p_inform_info_rec_opt->subscriber_enum); user.comp_mask |= IB_IIR_COMPMASK_ENUM; user.p_attr = &record; } else { user.attr_offset = cl_ntoh16((uint16_t) (sizeof(rec) >> 3)); /* comp mask bits below are for InformInfoRecord rather than InformInfo */ /* as currently no comp mask bits defined for InformInfo!!! */ user.comp_mask = IB_IIR_COMPMASK_SUBSCRIBE; p_inform_info_opt = p_options; rec.subscribe = (uint8_t) p_inform_info_opt->subscribe; if (p_inform_info_opt->qpn) { rec.g_or_v.generic.qpn_resp_time_val = cl_hton32(p_inform_info_opt->qpn << 8); user.comp_mask |= IB_IIR_COMPMASK_QPN; } if (p_inform_info_opt->trap) { rec.g_or_v.generic.trap_num = cl_hton16(p_inform_info_opt->trap); user.comp_mask |= IB_IIR_COMPMASK_TRAPNUMB; } user.p_attr = &rec; } user.method = method; req.query_type = OSMV_QUERY_USER_DEFINED; req.timeout_ms = p_osmt->opt.transaction_timeout; req.retry_cnt = p_osmt->opt.retry_count; req.flags = OSM_SA_FLAGS_SYNC; req.query_context = p_context; req.pfn_query_cb = osmtest_query_res_cb; req.p_query_input = &user; req.sm_key = 0; status = osmv_query_sa(p_osmt->h_bind, &req); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 008E: " "ib_query failed (%s)\n", ib_get_err_str(status)); goto Exit; } status = p_context->result.status; if (status != IB_SUCCESS) { if (status != IB_INVALID_PARAMETER) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 008F: " "ib_query failed (%s)\n", ib_get_err_str(status)); } if (status == IB_REMOTE_ERROR) { p_mad = osm_madw_get_mad_ptr(p_context->result. p_result_madw); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "Remote error = %s\n", ib_get_mad_status_str(p_mad)); status = (ib_net16_t) (p_mad->status & IB_SMP_STATUS_MASK); } goto Exit; } Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } #endif /********************************************************************** **********************************************************************/ static ib_api_status_t osmtest_validate_single_path_rec_lid_pair(IN osmtest_t * const p_osmt, IN path_t * const p_path) { osmtest_req_context_t context; const ib_path_rec_t *p_rec; cl_status_t status = IB_SUCCESS; size_t num_recs; OSM_LOG_ENTER(&p_osmt->log); memset(&context, 0, sizeof(context)); status = osmtest_get_path_rec_by_lid_pair(p_osmt, p_path->rec.slid, p_path->rec.dlid, &context); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0102: " "ib_query failed (%s)\n", ib_get_err_str(status)); goto Exit; } num_recs = context.result.result_cnt; if (num_recs != 1) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0103: " "Too many records. Expected 1, received %zu\n", num_recs); status = IB_ERROR; } else { p_rec = osmv_get_query_path_rec(context.result.p_result_madw, 0); status = osmtest_validate_path_data(p_osmt, p_path, p_rec); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0104: " "osmtest_validate_path_data failed (%s)\n", ib_get_err_str(status)); } } Exit: /* * Return the IB query MAD to the pool as necessary. */ if (context.result.p_result_madw != NULL) { osm_mad_pool_put(&p_osmt->mad_pool, context.result.p_result_madw); context.result.p_result_madw = NULL; } OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ static ib_api_status_t osmtest_validate_single_node_rec_lid(IN osmtest_t * const p_osmt, IN ib_net16_t const lid, IN node_t * const p_node) { cl_status_t status = IB_SUCCESS; osmv_user_query_t user; osmv_query_req_t req; ib_node_record_t record; osmtest_req_context_t context; const ib_node_record_t *p_rec; int num_recs, i; OSM_LOG_ENTER(&p_osmt->log); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "Getting NodeRecord for node with LID 0x%X\n", cl_ntoh16(lid)); memset(&context, 0, sizeof(context)); memset(&req, 0, sizeof(req)); memset(&user, 0, sizeof(user)); memset(&record, 0, sizeof(record)); record.lid = lid; context.p_osmt = p_osmt; user.comp_mask = IB_NR_COMPMASK_LID; user.attr_id = IB_MAD_ATTR_NODE_RECORD; user.attr_offset = cl_ntoh16((uint16_t) (sizeof(record) >> 3)); user.p_attr = &record; req.query_type = OSMV_QUERY_USER_DEFINED; req.timeout_ms = p_osmt->opt.transaction_timeout; req.retry_cnt = p_osmt->opt.retry_count; req.flags = OSM_SA_FLAGS_SYNC; req.query_context = &context; req.pfn_query_cb = osmtest_query_res_cb; req.p_query_input = &user; req.sm_key = 0; status = osmv_query_sa(p_osmt->h_bind, &req); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0105: " "ib_query failed (%s)\n", ib_get_err_str(status)); goto Exit; } status = context.result.status; if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0106: " "ib_query failed (%s)\n", ib_get_err_str(status)); if (status == IB_REMOTE_ERROR) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "Remote error = %s\n", ib_get_mad_status_str(osm_madw_get_mad_ptr (context.result. p_result_madw))); } goto Exit; } num_recs = context.result.result_cnt; OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Received %d nodes\n", num_recs); for (i = 0; i < num_recs; i++) { p_rec = osmv_get_query_node_rec(context.result.p_result_madw, i); status = osmtest_validate_node_rec(p_osmt, p_rec); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0107: " "osmtest_validate_node_data failed (%s)\n", ib_get_err_str(status)); goto Exit; } } Exit: /* * Return the IB query MAD to the pool as necessary. */ if (context.result.p_result_madw != NULL) { osm_mad_pool_put(&p_osmt->mad_pool, context.result.p_result_madw); context.result.p_result_madw = NULL; } OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ static ib_api_status_t osmtest_validate_single_port_rec_lid(IN osmtest_t * const p_osmt, IN port_t * const p_port) { osmtest_req_context_t context; const ib_portinfo_record_t *p_rec; cl_status_t status = IB_SUCCESS; OSM_LOG_ENTER(&p_osmt->log); memset(&context, 0, sizeof(context)); context.p_osmt = p_osmt; osmtest_get_port_rec_by_num(p_osmt, p_port->rec.lid, p_port->rec.port_num, &context); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0108: " "ib_query failed (%s)\n", ib_get_err_str(status)); goto Exit; } /* we should have got exactly one port */ p_rec = osmv_get_query_portinfo_rec(context.result.p_result_madw, 0); status = osmtest_validate_port_rec(p_osmt, p_rec); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0109: " "osmtest_validate_port_data failed (%s)\n", ib_get_err_str(status)); } Exit: /* * Return the IB query MAD to the pool as necessary. */ if (context.result.p_result_madw != NULL) { osm_mad_pool_put(&p_osmt->mad_pool, context.result.p_result_madw); context.result.p_result_madw = NULL; } OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ static ib_api_status_t osmtest_validate_single_path_rec_guid_pair(IN osmtest_t * const p_osmt, IN const osmv_guid_pair_t * const p_pair) { osmtest_req_context_t context; const ib_path_rec_t *p_rec; cl_status_t status = IB_SUCCESS; size_t num_recs; osmv_query_req_t req; uint32_t i; boolean_t got_error = FALSE; OSM_LOG_ENTER(&p_osmt->log); memset(&req, 0, sizeof(req)); memset(&context, 0, sizeof(context)); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "\n\t\t\t\tChecking src 0x%016" PRIx64 " to dest 0x%016" PRIx64 "\n", cl_ntoh64(p_pair->src_guid), cl_ntoh64(p_pair->dest_guid)); context.p_osmt = p_osmt; req.timeout_ms = p_osmt->opt.transaction_timeout; req.retry_cnt = p_osmt->opt.retry_count; req.flags = OSM_SA_FLAGS_SYNC; req.query_context = &context; req.pfn_query_cb = osmtest_query_res_cb; req.query_type = OSMV_QUERY_PATH_REC_BY_PORT_GUIDS; req.p_query_input = p_pair; req.sm_key = 0; status = osmv_query_sa(p_osmt->h_bind, &req); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0110: " "ib_query failed (%s)\n", ib_get_err_str(status)); goto Exit; } status = context.result.status; if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0111: " "ib_query failed (%s)\n", ib_get_err_str(status)); if (status == IB_REMOTE_ERROR) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "Remote error = %s\n", ib_get_mad_status_str(osm_madw_get_mad_ptr (context.result. p_result_madw))); } goto Exit; } num_recs = context.result.result_cnt; OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "%zu records\n", num_recs); for (i = 0; i < num_recs; i++) { p_rec = osmv_get_query_path_rec(context.result.p_result_madw, i); /* * Make sure the GUID values are correct */ if (p_rec->dgid.unicast.interface_id != p_pair->dest_guid) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0112: " "Destination GUID mismatch\n" "\t\t\t\texpected 0x%016" PRIx64 ", received 0x%016" PRIx64 "\n", cl_ntoh64(p_pair->dest_guid), cl_ntoh64(p_rec->dgid.unicast.interface_id)); got_error = TRUE; } if (p_rec->sgid.unicast.interface_id != p_pair->src_guid) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0113: " "Source GUID mismatch\n" "\t\t\t\texpected 0x%016" PRIx64 ", received 0x%016" PRIx64 ".\n", cl_ntoh64(p_pair->src_guid), cl_ntoh64(p_rec->sgid.unicast.interface_id)); got_error = TRUE; } status = osmtest_validate_path_rec(p_osmt, p_rec); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0114: " "osmtest_validate_path_rec failed (%s)\n", ib_get_err_str(status)); got_error = TRUE; } if (got_error || (status != IB_SUCCESS)) { osm_dump_path_record(&p_osmt->log, p_rec, OSM_LOG_VERBOSE); if (status == IB_SUCCESS) status = IB_ERROR; goto Exit; } } Exit: /* * Return the IB query MAD to the pool as necessary. */ if (context.result.p_result_madw != NULL) { osm_mad_pool_put(&p_osmt->mad_pool, context.result.p_result_madw); context.result.p_result_madw = NULL; } OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ static ib_api_status_t osmtest_validate_single_path_recs(IN osmtest_t * const p_osmt) { path_t *p_path; cl_status_t status = IB_SUCCESS; const cl_qmap_t *p_path_tbl; /* We skip node to node path record validation since it might contains NONEXISTENT PATHS, i.e. when using UPDN */ osmv_guid_pair_t guid_pair; uint16_t cnt; OSM_LOG_ENTER(&p_osmt->log); OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Validating individual path record queries\n"); p_path_tbl = &p_osmt->exp_subn.path_tbl; osmtest_prepare_db(p_osmt); /* * Walk the list of all path records, and ask for each one * specifically. Make sure we get it. */ cnt = 0; p_path = (path_t *) cl_qmap_head(p_path_tbl); while (p_path != (path_t *) cl_qmap_end(p_path_tbl)) { status = osmtest_validate_single_path_rec_lid_pair(p_osmt, p_path); if (status != IB_SUCCESS) goto Exit; cnt++; p_path = (path_t *) cl_qmap_next(&p_path->map_item); } OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Total of %u path records validated using LID based query\n", cnt); status = osmtest_check_missing_paths(p_osmt); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0115: " "osmtest_check_missing_paths failed (%s)\n", ib_get_err_str(status)); goto Exit; } /* * Do the whole thing again with port GUID pairs. * Note that multiple path records may be returned * for each guid pair if LMC > 0. */ osmtest_prepare_db(p_osmt); cnt = 0; p_path = (path_t *) cl_qmap_head(p_path_tbl); while (p_path != (path_t *) cl_qmap_end(p_path_tbl)) { guid_pair.src_guid = p_path->rec.sgid.unicast.interface_id; guid_pair.dest_guid = p_path->rec.dgid.unicast.interface_id; status = osmtest_validate_single_path_rec_guid_pair(p_osmt, &guid_pair); if (status != IB_SUCCESS) goto Exit; cnt++; p_path = (path_t *) cl_qmap_next(&p_path->map_item); } OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Total of %u path records validated using GUID based query\n", cnt); status = osmtest_check_missing_paths(p_osmt); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0116: " "osmtest_check_missing_paths failed (%s)\n", ib_get_err_str(status)); goto Exit; } Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ static ib_api_status_t osmtest_validate_single_node_recs(IN osmtest_t * const p_osmt) { node_t *p_node; cl_status_t status = IB_SUCCESS; const cl_qmap_t *p_node_lid_tbl; uint16_t cnt = 0; OSM_LOG_ENTER(&p_osmt->log); p_node_lid_tbl = &p_osmt->exp_subn.node_lid_tbl; osmtest_prepare_db(p_osmt); OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Validating individual node record queries\n"); /* * Walk the list of all node records, and ask for each one * specifically. Make sure we get it. */ p_node = (node_t *) cl_qmap_head(p_node_lid_tbl); while (p_node != (node_t *) cl_qmap_end(p_node_lid_tbl)) { status = osmtest_validate_single_node_rec_lid(p_osmt, (ib_net16_t) cl_qmap_key((cl_map_item_t *) p_node), p_node); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 011A: " "osmtest_validate_single_node_rec_lid (%s)\n", ib_get_err_str(status)); goto Exit; } cnt++; p_node = (node_t *) cl_qmap_next(&p_node->map_item); } OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Total of %u node records validated\n", cnt); status = osmtest_check_missing_nodes(p_osmt); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0117: " "osmtest_check_missing_nodes (%s)\n", ib_get_err_str(status)); goto Exit; } Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ static ib_api_status_t osmtest_validate_single_port_recs(IN osmtest_t * const p_osmt) { port_t *p_port; cl_status_t status = IB_SUCCESS; const cl_qmap_t *p_port_key_tbl; uint16_t cnt = 0; OSM_LOG_ENTER(&p_osmt->log); p_port_key_tbl = &p_osmt->exp_subn.port_key_tbl; osmtest_prepare_db(p_osmt); OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Validating individual port record queries\n"); /* * Walk the list of all port records, and ask for each one * specifically. Make sure we get it. */ p_port = (port_t *) cl_qmap_head(p_port_key_tbl); while (p_port != (port_t *) cl_qmap_end(p_port_key_tbl)) { status = osmtest_validate_single_port_rec_lid(p_osmt, p_port); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 011B: " "osmtest_validate_single_port_rec_lid (%s)\n", ib_get_err_str(status)); goto Exit; } cnt++; p_port = (port_t *) cl_qmap_next(&p_port->map_item); } OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "Total of %u port records validated\n", cnt); status = osmtest_check_missing_ports(p_osmt); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0118: " "osmtest_check_missing_paths failed (%s)\n", ib_get_err_str(status)); goto Exit; } Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ static ib_api_status_t osmtest_validate_against_db(IN osmtest_t * const p_osmt) { ib_api_status_t status = IB_SUCCESS; ib_gid_t portgid, mgid; osmtest_sm_info_rec_t sm_info_rec_opt; osmtest_inform_info_t inform_info_opt; osmtest_inform_info_rec_t inform_info_rec_opt; #ifdef VENDOR_RMPP_SUPPORT ib_net64_t sm_key; ib_net16_t test_lid; uint8_t lmc; osmtest_req_context_t context; #ifdef DUAL_SIDED_RMPP osmv_multipath_req_t request; #endif uint8_t i; #endif OSM_LOG_ENTER(&p_osmt->log); #ifdef VENDOR_RMPP_SUPPORT status = osmtest_validate_all_node_recs(p_osmt); if (status != IB_SUCCESS) goto Exit; #endif status = osmtest_validate_single_node_recs(p_osmt); if (status != IB_SUCCESS) goto Exit; /* Exercise SA PathRecord multicast destination code */ memset(&context, 0, sizeof(context)); ib_gid_set_default(&portgid, portguid); /* Set IPoIB broadcast MGID */ mgid.unicast.prefix = CL_HTON64(0xff12401bffff0000ULL); mgid.unicast.interface_id = CL_HTON64(0x00000000ffffffffULL); /* Can't check status as don't know whether port is running IPoIB */ osmtest_get_path_rec_by_gid_pair(p_osmt, portgid, mgid, &context); /* Other link local unicast PathRecord */ memset(&context, 0, sizeof(context)); ib_gid_set_default(&portgid, portguid); ib_gid_set_default(&mgid, portguid); mgid.raw[7] = 0xff; /* not default GID prefix */ /* Can't check status as don't know whether ??? */ osmtest_get_path_rec_by_gid_pair(p_osmt, portgid, mgid, &context); /* Off subnet (site local) unicast PathRecord */ memset(&context, 0, sizeof(context)); ib_gid_set_default(&portgid, portguid); ib_gid_set_default(&mgid, portguid); mgid.raw[1] = 0xc0; /* site local */ /* Can't check status as don't know whether ??? */ osmtest_get_path_rec_by_gid_pair(p_osmt, portgid, mgid, &context); /* More than link local scope multicast PathRecord */ memset(&context, 0, sizeof(context)); ib_gid_set_default(&portgid, portguid); /* Set IPoIB broadcast MGID */ mgid.unicast.prefix = CL_HTON64(0xff15401bffff0000ULL); /* site local */ mgid.unicast.interface_id = CL_HTON64(0x00000000ffffffffULL); /* Can't check status as don't know whether port is running IPoIB */ osmtest_get_path_rec_by_gid_pair(p_osmt, portgid, mgid, &context); #if defined (VENDOR_RMPP_SUPPORT) && defined (DUAL_SIDED_RMPP) memset(&context, 0, sizeof(context)); memset(&request, 0, sizeof(request)); request.comp_mask = IB_MPR_COMPMASK_SGIDCOUNT | IB_MPR_COMPMASK_DGIDCOUNT; request.sgid_count = 1; request.dgid_count = 1; ib_gid_set_default(&request.gids[0], portguid); ib_gid_set_default(&request.gids[1], portguid); status = osmtest_get_multipath_rec(p_osmt, &request, &context); if (status != IB_SUCCESS) goto Exit; memset(&context, 0, sizeof(context)); memset(&request, 0, sizeof(request)); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); status = osmtest_get_multipath_rec(p_osmt, &request, &context); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "Got error %s\n", ib_get_err_str(status)); } OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); if (status == IB_SUCCESS) { status = IB_ERROR; goto Exit; } memset(&context, 0, sizeof(context)); memset(&request, 0, sizeof(request)); request.comp_mask = IB_MPR_COMPMASK_SGIDCOUNT; request.sgid_count = 1; ib_gid_set_default(&request.gids[0], portguid); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); status = osmtest_get_multipath_rec(p_osmt, &request, &context); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "Got error %s\n", ib_get_err_str(status)); } OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); if (status == IB_SUCCESS) { status = IB_ERROR; goto Exit; } memset(&context, 0, sizeof(context)); memset(&request, 0, sizeof(request)); request.comp_mask = IB_MPR_COMPMASK_SGIDCOUNT | IB_MPR_COMPMASK_DGIDCOUNT; request.sgid_count = 1; request.dgid_count = 1; ib_gid_set_default(&request.gids[0], portguid); /* Set IPoIB broadcast MGID as DGID */ request.gids[1].unicast.prefix = CL_HTON64(0xff12401bffff0000ULL); request.gids[1].unicast.interface_id = CL_HTON64(0x00000000ffffffffULL); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); status = osmtest_get_multipath_rec(p_osmt, &request, &context); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "Got error %s\n", ib_get_err_str(status)); } OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); if (status == IB_SUCCESS) { status = IB_ERROR; goto Exit; } memset(&context, 0, sizeof(context)); request.comp_mask = IB_MPR_COMPMASK_SGIDCOUNT | IB_MPR_COMPMASK_DGIDCOUNT; request.sgid_count = 1; request.dgid_count = 1; /* Set IPoIB broadcast MGID as SGID */ request.gids[0].unicast.prefix = CL_HTON64(0xff12401bffff0000ULL); request.gids[0].unicast.interface_id = CL_HTON64(0x00000000ffffffffULL); ib_gid_set_default(&request.gids[1], portguid); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); status = osmtest_get_multipath_rec(p_osmt, &request, &context); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "Got error %s\n", ib_get_err_str(status)); } OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); if (status == IB_SUCCESS) { status = IB_ERROR; goto Exit; } memset(&context, 0, sizeof(context)); memset(&request, 0, sizeof(request)); request.comp_mask = IB_MPR_COMPMASK_SGIDCOUNT | IB_MPR_COMPMASK_DGIDCOUNT | IB_MPR_COMPMASK_NUMBPATH; request.sgid_count = 2; request.dgid_count = 2; request.num_path = 2; ib_gid_set_default(&request.gids[0], portguid); ib_gid_set_default(&request.gids[1], portguid); ib_gid_set_default(&request.gids[2], portguid); ib_gid_set_default(&request.gids[3], portguid); status = osmtest_get_multipath_rec(p_osmt, &request, &context); if (status != IB_SUCCESS) goto Exit; #endif #ifdef VENDOR_RMPP_SUPPORT /* GUIDInfoRecords */ status = osmtest_validate_all_guidinfo_recs(p_osmt); if (status != IB_SUCCESS) goto Exit; /* If LMC > 0, test non base LID SA PortInfoRecord request */ status = osmtest_get_local_port_lmc(p_osmt, p_osmt->local_port.lid, &lmc); if (status != IB_SUCCESS) goto Exit; if (lmc != 0) { status = osmtest_get_local_port_lmc(p_osmt, p_osmt->local_port.lid + 1, NULL); if (status != IB_SUCCESS) goto Exit; } status = osmtest_get_local_port_lmc(p_osmt, 0xffff, NULL); if (status != IB_SUCCESS) goto Exit; test_lid = cl_ntoh16(p_osmt->local_port.lid); /* More GUIDInfo Record tests */ memset(&context, 0, sizeof(context)); status = osmtest_get_guidinfo_rec_by_lid(p_osmt, test_lid, &context); if (status != IB_SUCCESS) goto Exit; memset(&context, 0, sizeof(context)); status = osmtest_get_guidinfo_rec_by_lid(p_osmt, 0xffff, &context); if (status != IB_SUCCESS) goto Exit; /* Some PKeyTable Record tests */ sm_key = OSM_DEFAULT_SM_KEY; memset(&context, 0, sizeof(context)); status = osmtest_get_pkeytbl_rec_by_lid(p_osmt, test_lid, sm_key, &context); if (status != IB_SUCCESS) goto Exit; memset(&context, 0, sizeof(context)); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); status = osmtest_get_pkeytbl_rec_by_lid(p_osmt, test_lid, 0, &context); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "Got error %s\n", ib_get_err_str(status)); } OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); if (status == IB_SUCCESS) { status = IB_ERROR; goto Exit; } memset(&context, 0, sizeof(context)); status = osmtest_get_pkeytbl_rec_by_lid(p_osmt, 0xffff, sm_key, &context); if (status != IB_SUCCESS) goto Exit; /* SwitchInfo Record tests */ memset(&context, 0, sizeof(context)); status = osmtest_get_sw_info_rec_by_lid(p_osmt, 0, &context); if (status != IB_SUCCESS) goto Exit; memset(&context, 0, sizeof(context)); status = osmtest_get_sw_info_rec_by_lid(p_osmt, test_lid, &context); if (status != IB_SUCCESS) goto Exit; /* LFT Record tests */ memset(&context, 0, sizeof(context)); status = osmtest_get_lft_rec_by_lid(p_osmt, 0, &context); if (status != IB_SUCCESS) goto Exit; memset(&context, 0, sizeof(context)); status = osmtest_get_lft_rec_by_lid(p_osmt, test_lid, &context); if (status != IB_SUCCESS) goto Exit; /* MFT Record tests */ memset(&context, 0, sizeof(context)); status = osmtest_get_mft_rec_by_lid(p_osmt, 0, &context); if (status != IB_SUCCESS) goto Exit; memset(&context, 0, sizeof(context)); status = osmtest_get_mft_rec_by_lid(p_osmt, test_lid, &context); if (status != IB_SUCCESS) goto Exit; /* Some LinkRecord tests */ /* FromLID */ memset(&context, 0, sizeof(context)); status = osmtest_get_link_rec_by_lid(p_osmt, test_lid, 0, &context); if (status != IB_SUCCESS) goto Exit; /* ToLID */ memset(&context, 0, sizeof(context)); status = osmtest_get_link_rec_by_lid(p_osmt, 0, test_lid, &context); if (status != IB_SUCCESS) goto Exit; /* FromLID & ToLID */ memset(&context, 0, sizeof(context)); status = osmtest_get_link_rec_by_lid(p_osmt, test_lid, test_lid, &context); if (status != IB_SUCCESS) goto Exit; /* NodeRecord test */ memset(&context, 0, sizeof(context)); status = osmtest_get_node_rec_by_lid(p_osmt, 0xffff, &context); if (status != IB_SUCCESS) goto Exit; /* SMInfoRecord tests */ memset(&sm_info_rec_opt, 0, sizeof(sm_info_rec_opt)); memset(&context, 0, sizeof(context)); status = osmtest_sminfo_record_request(p_osmt, IB_MAD_METHOD_SET, &sm_info_rec_opt, &context); if (status == IB_SUCCESS) { status = IB_ERROR; goto Exit; } else { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "IS EXPECTED ERROR ^^^^\n"); } memset(&sm_info_rec_opt, 0, sizeof(sm_info_rec_opt)); memset(&context, 0, sizeof(context)); status = osmtest_sminfo_record_request(p_osmt, IB_MAD_METHOD_GETTABLE, &sm_info_rec_opt, &context); if (status != IB_SUCCESS) goto Exit; memset(&sm_info_rec_opt, 0, sizeof(sm_info_rec_opt)); sm_info_rec_opt.lid = test_lid; /* local LID */ memset(&context, 0, sizeof(context)); status = osmtest_sminfo_record_request(p_osmt, IB_MAD_METHOD_GETTABLE, &sm_info_rec_opt, &context); if (status != IB_SUCCESS) goto Exit; if (portguid != 0) { memset(&sm_info_rec_opt, 0, sizeof(sm_info_rec_opt)); sm_info_rec_opt.sm_guid = portguid; /* local GUID */ memset(&context, 0, sizeof(context)); status = osmtest_sminfo_record_request(p_osmt, IB_MAD_METHOD_GETTABLE, &sm_info_rec_opt, &context); if (status != IB_SUCCESS) goto Exit; } for (i = 1; i < 16; i++) { memset(&sm_info_rec_opt, 0, sizeof(sm_info_rec_opt)); sm_info_rec_opt.priority = i; memset(&context, 0, sizeof(context)); status = osmtest_sminfo_record_request(p_osmt, IB_MAD_METHOD_GETTABLE, &sm_info_rec_opt, &context); if (status != IB_SUCCESS) goto Exit; } for (i = 1; i < 4; i++) { memset(&sm_info_rec_opt, 0, sizeof(sm_info_rec_opt)); sm_info_rec_opt.sm_state = i; memset(&context, 0, sizeof(context)); status = osmtest_sminfo_record_request(p_osmt, IB_MAD_METHOD_GETTABLE, &sm_info_rec_opt, &context); if (status != IB_SUCCESS) goto Exit; } /* InformInfoRecord tests */ OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfoRecord " "Sending a BAD - Set Unsubscribe request\n"); memset(&inform_info_opt, 0, sizeof(inform_info_opt)); memset(&inform_info_rec_opt, 0, sizeof(inform_info_rec_opt)); memset(&context, 0, sizeof(context)); status = osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO_RECORD, IB_MAD_METHOD_SET, &inform_info_rec_opt, &context); if (status == IB_SUCCESS) { status = IB_ERROR; goto Exit; } else { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "InformInfoRecord " "IS EXPECTED ERROR ^^^^\n"); } OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfoRecord " "Sending a Good - Empty GetTable request\n"); memset(&context, 0, sizeof(context)); status = osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO_RECORD, IB_MAD_METHOD_GETTABLE, &inform_info_rec_opt, &context); if (status != IB_SUCCESS) goto Exit; /* InformInfo tests */ OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfo " "Sending a BAD - Empty Get request " "(should fail with NO_RECORDS)\n"); memset(&context, 0, sizeof(context)); status = osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO, IB_MAD_METHOD_GET, &inform_info_opt, &context); if (status == IB_SUCCESS) { status = IB_ERROR; goto Exit; } else { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "InformInfo " "IS EXPECTED ERROR ^^^^\n"); } OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfo " "Sending a BAD - Set Unsubscribe request\n"); memset(&context, 0, sizeof(context)); status = osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO, IB_MAD_METHOD_SET, &inform_info_opt, &context); if (status == IB_SUCCESS) { status = IB_ERROR; goto Exit; } else { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "InformInfo UnSubscribe " "IS EXPECTED ERROR ^^^^\n"); } /* Now subscribe */ OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfo " "Sending a Good - Set Subscribe request\n"); inform_info_opt.subscribe = TRUE; memset(&context, 0, sizeof(context)); status = osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO, IB_MAD_METHOD_SET, &inform_info_opt, &context); if (status != IB_SUCCESS) goto Exit; /* Now unsubscribe (QPN needs to be 1 to work) */ OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfo " "Sending a Good - Set Unsubscribe request\n"); inform_info_opt.subscribe = FALSE; inform_info_opt.qpn = 1; memset(&context, 0, sizeof(context)); status = osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO, IB_MAD_METHOD_SET, &inform_info_opt, &context); if (status != IB_SUCCESS) goto Exit; /* Now subscribe again */ OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfo " "Sending a Good - Set Subscribe request\n"); inform_info_opt.subscribe = TRUE; inform_info_opt.qpn = 1; memset(&context, 0, sizeof(context)); status = osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO, IB_MAD_METHOD_SET, &inform_info_opt, &context); if (status != IB_SUCCESS) goto Exit; /* Subscribe over existing subscription */ OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfo " "Sending a Good - Set Subscribe (again) request\n"); inform_info_opt.qpn = 0; memset(&context, 0, sizeof(context)); status = osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO, IB_MAD_METHOD_SET, &inform_info_opt, &context); if (status != IB_SUCCESS) goto Exit; /* More InformInfoRecord tests */ /* RID lookup (with currently invalid enum) */ OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfoRecord " "Sending a Good - GetTable by GID\n"); ib_gid_set_default(&inform_info_rec_opt.subscriber_gid, p_osmt->local_port.port_guid); inform_info_rec_opt.subscriber_enum = 1; memset(&context, 0, sizeof(context)); status = osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO_RECORD, IB_MAD_METHOD_GETTABLE, &inform_info_rec_opt, &context); if (status != IB_SUCCESS) goto Exit; /* Enum lookup */ OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfoRecord " "Sending a Good - GetTable (subscriber_enum == 0) request\n"); inform_info_rec_opt.subscriber_enum = 0; memset(&context, 0, sizeof(context)); status = osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO_RECORD, IB_MAD_METHOD_GETTABLE, &inform_info_rec_opt, &context); if (status != IB_SUCCESS) goto Exit; /* Get all InformInfoRecords */ OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfoRecord " "Sending a Good - GetTable (ALL records) request\n"); memset(&inform_info_rec_opt, 0, sizeof(inform_info_rec_opt)); memset(&context, 0, sizeof(context)); status = osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO_RECORD, IB_MAD_METHOD_GETTABLE, &inform_info_rec_opt, &context); if (status != IB_SUCCESS) goto Exit; /* Another subscription */ OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfo " "Sending another Good - Set Subscribe (again) request\n"); inform_info_opt.qpn = 0; inform_info_opt.trap = 0x1234; memset(&context, 0, sizeof(context)); status = osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO, IB_MAD_METHOD_SET, &inform_info_opt, &context); if (status != IB_SUCCESS) goto Exit; /* Get all InformInfoRecords again */ OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfoRecord " "Sending a Good - GetTable (ALL records) request\n"); memset(&inform_info_rec_opt, 0, sizeof(inform_info_rec_opt)); memset(&context, 0, sizeof(context)); status = osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO_RECORD, IB_MAD_METHOD_GETTABLE, &inform_info_rec_opt, &context); if (status != IB_SUCCESS) goto Exit; /* Cleanup subscriptions before further testing */ /* Does order of deletion matter ? Test this !!! */ OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfo " "Sending a Good - Set (cleanup) request\n"); inform_info_opt.subscribe = FALSE; inform_info_opt.qpn = 1; memset(&context, 0, sizeof(context)); status = osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO, IB_MAD_METHOD_SET, &inform_info_opt, &context); if (status != IB_SUCCESS) goto Exit; /* Get all InformInfoRecords again */ OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfoRecord " "Sending a Good - GetTable (ALL records) request\n"); memset(&inform_info_rec_opt, 0, sizeof(inform_info_rec_opt)); memset(&context, 0, sizeof(context)); status = osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO_RECORD, IB_MAD_METHOD_GETTABLE, &inform_info_rec_opt, &context); if (status != IB_SUCCESS) goto Exit; OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfo" "Sending a Good - Set (cleanup) request\n"); inform_info_opt.subscribe = FALSE; inform_info_opt.qpn = 1; inform_info_opt.trap = 0; memset(&context, 0, sizeof(context)); status = osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO, IB_MAD_METHOD_SET, &inform_info_opt, &context); if (status != IB_SUCCESS) goto Exit; /* Get all InformInfoRecords a final time */ OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE, "InformInfoRecord " "Sending a Good - GetTable (ALL records) request\n"); memset(&inform_info_rec_opt, 0, sizeof(inform_info_rec_opt)); memset(&context, 0, sizeof(context)); status = osmtest_informinfo_request(p_osmt, IB_MAD_ATTR_INFORM_INFO_RECORD, IB_MAD_METHOD_GETTABLE, &inform_info_rec_opt, &context); if (status != IB_SUCCESS) goto Exit; if (lmc != 0) { test_lid = cl_ntoh16(p_osmt->local_port.lid + 1); /* Another GUIDInfo Record test */ memset(&context, 0, sizeof(context)); status = osmtest_get_guidinfo_rec_by_lid(p_osmt, test_lid, &context); if (status != IB_SUCCESS) goto Exit; /* Another PKeyTable Record test */ memset(&context, 0, sizeof(context)); status = osmtest_get_pkeytbl_rec_by_lid(p_osmt, test_lid, sm_key, &context); if (status != IB_SUCCESS) goto Exit; /* Another SwitchInfo Record test */ memset(&context, 0, sizeof(context)); status = osmtest_get_sw_info_rec_by_lid(p_osmt, test_lid, &context); if (status != IB_SUCCESS) goto Exit; /* Another LFT Record test */ memset(&context, 0, sizeof(context)); status = osmtest_get_lft_rec_by_lid(p_osmt, test_lid, &context); if (status != IB_SUCCESS) goto Exit; /* Another MFT Record test */ memset(&context, 0, sizeof(context)); status = osmtest_get_mft_rec_by_lid(p_osmt, test_lid, &context); if (status != IB_SUCCESS) goto Exit; /* More LinkRecord tests */ /* FromLID */ memset(&context, 0, sizeof(context)); status = osmtest_get_link_rec_by_lid(p_osmt, test_lid, 0, &context); if (status != IB_SUCCESS) goto Exit; /* ToLID */ memset(&context, 0, sizeof(context)); status = osmtest_get_link_rec_by_lid(p_osmt, 0, test_lid, &context); if (status != IB_SUCCESS) goto Exit; /* Another NodeRecord test */ memset(&context, 0, sizeof(context)); status = osmtest_get_node_rec_by_lid(p_osmt, test_lid, &context); if (status != IB_SUCCESS) goto Exit; } /* PathRecords */ if (!p_osmt->opt.ignore_path_records) { status = osmtest_validate_all_path_recs(p_osmt); if (status != IB_SUCCESS) goto Exit; if (lmc != 0) { memset(&context, 0, sizeof(context)); status = osmtest_get_path_rec_by_lid_pair(p_osmt, test_lid, test_lid, &context); if (status != IB_SUCCESS) goto Exit; memset(&context, 0, sizeof(context)); OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); status = osmtest_get_path_rec_by_lid_pair(p_osmt, 0xffff, 0xffff, &context); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "Got error %s\n", ib_get_err_str(status)); } OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); if (status == IB_SUCCESS) { status = IB_ERROR; goto Exit; } OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_START "\n"); status = osmtest_get_path_rec_by_lid_pair(p_osmt, test_lid, 0xffff, &context); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "Got error %s\n", ib_get_err_str(status)); } OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, EXPECTING_ERRORS_END "\n"); if (status == IB_SUCCESS) { status = IB_ERROR; goto Exit; } } } #endif status = osmtest_validate_single_port_recs(p_osmt); if (status != IB_SUCCESS) goto Exit; if (!p_osmt->opt.ignore_path_records) { status = osmtest_validate_single_path_recs(p_osmt); if (status != IB_SUCCESS) goto Exit; } Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ static const osmtest_token_t *str_get_token(IN char *const p_str) { const osmtest_token_t *p_tok; uint32_t index = 0; p_tok = &token_array[index]; while (p_tok->val != OSMTEST_TOKEN_UNKNOWN) { if (strnicmp(p_str, p_tok->str, p_tok->str_size) == 0) return (p_tok); p_tok = &token_array[++index]; } return (NULL); } /********************************************************************** Returns true if not whitespace character encountered before EOL. **********************************************************************/ static boolean_t str_skip_white(IN char line[], IN OUT uint32_t * const p_offset) { while (((line[*p_offset] == '\t') || (line[*p_offset] == ' ')) && (line[*p_offset] != '\n') && (line[*p_offset] != '\0')) { ++*p_offset; } if ((line[*p_offset] == '\n') || (line[*p_offset] == '\0')) return (FALSE); else return (TRUE); } /********************************************************************** Returns true if not whitespace character encountered before EOL. **********************************************************************/ static void str_skip_token(IN char line[], IN OUT uint32_t * const p_offset) { while ((line[*p_offset] != '\t') && (line[*p_offset] != ' ') && (line[*p_offset] != '\0')) { ++*p_offset; } } /********************************************************************** **********************************************************************/ static ib_api_status_t osmtest_parse_node(IN osmtest_t * const p_osmt, IN FILE * const fh, IN OUT uint32_t * const p_line_num) { ib_api_status_t status = IB_SUCCESS; uint32_t offset; char line[OSMTEST_MAX_LINE_LEN]; boolean_t done = FALSE; node_t *p_node; node_t *p_guid_node; const osmtest_token_t *p_tok; OSM_LOG_ENTER(&p_osmt->log); p_node = node_new(); CL_ASSERT(p_node != NULL); /* * Parse the inventory file and create the database. */ while (!done) { if (fgets(line, OSMTEST_MAX_LINE_LEN, fh) == NULL) { /* * End of file in the middle of a definition. */ OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0119: " "Unexpected end of file\n"); status = IB_ERROR; goto Exit; } ++*p_line_num; /* * Skip whitespace */ offset = 0; if (!str_skip_white(line, &offset)) continue; /* whole line was whitespace */ p_tok = str_get_token(&line[offset]); if (p_tok == NULL) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0120: " "Ignoring line %u with unknown token: %s\n", *p_line_num, &line[offset]); continue; } OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "Found '%s' (line %u)\n", p_tok->str, *p_line_num); str_skip_token(line, &offset); switch (p_tok->val) { case OSMTEST_TOKEN_COMMENT: break; case OSMTEST_TOKEN_LID: p_node->comp.lid = 0xFFFF; p_node->rec.lid = cl_hton16((uint16_t) strtoul(&line[offset], NULL, 0)); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "lid = 0x%X\n", cl_ntoh16(p_node->rec.lid)); break; case OSMTEST_TOKEN_BASE_VERSION: p_node->comp.node_info.base_version = 0xFF; p_node->rec.node_info.base_version = (uint8_t) strtoul(&line[offset], NULL, 0); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "base_version = 0x%X\n", p_node->rec.node_info.base_version); break; case OSMTEST_TOKEN_CLASS_VERSION: p_node->comp.node_info.class_version = 0xFF; p_node->rec.node_info.class_version = (uint8_t) strtoul(&line[offset], NULL, 0); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "class_version = 0x%X\n", p_node->rec.node_info.class_version); break; case OSMTEST_TOKEN_NODE_TYPE: p_node->comp.node_info.node_type = 0xFF; p_node->rec.node_info.node_type = (uint8_t) strtoul(&line[offset], NULL, 0); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "node_type = 0x%X\n", p_node->rec.node_info.node_type); break; case OSMTEST_TOKEN_NUM_PORTS: p_node->comp.node_info.num_ports = 0xFF; p_node->rec.node_info.num_ports = (uint8_t) strtoul(&line[offset], NULL, 0); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "num_ports = 0x%X\n", p_node->rec.node_info.num_ports); break; case OSMTEST_TOKEN_SYS_GUID: p_node->comp.node_info.sys_guid = 0xFFFFFFFFFFFFFFFFULL; p_node->rec.node_info.sys_guid = cl_hton64(strtoull(&line[offset], NULL, 0)); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "sys_guid = 0x%016" PRIx64 "\n", cl_ntoh64(p_node->rec.node_info.sys_guid)); break; case OSMTEST_TOKEN_NODE_GUID: p_node->comp.node_info.node_guid = 0xFFFFFFFFFFFFFFFFULL; p_node->rec.node_info.node_guid = cl_hton64(strtoull(&line[offset], NULL, 0)); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "node_guid = 0x%016" PRIx64 "\n", cl_ntoh64(p_node->rec.node_info.node_guid)); break; case OSMTEST_TOKEN_PORT_GUID: p_node->comp.node_info.port_guid = 0xFFFFFFFFFFFFFFFFULL; p_node->rec.node_info.port_guid = cl_hton64(strtoull(&line[offset], NULL, 0)); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "port_guid = 0x%016" PRIx64 "\n", cl_ntoh64(p_node->rec.node_info.port_guid)); break; case OSMTEST_TOKEN_PARTITION_CAP: p_node->comp.node_info.partition_cap = 0xFFFF; p_node->rec.node_info.partition_cap = cl_hton16((uint16_t) strtoul(&line[offset], NULL, 0)); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "partition_cap = 0x%X\n", cl_ntoh16(p_node->rec.node_info.partition_cap)); break; case OSMTEST_TOKEN_DEVICE_ID: p_node->comp.node_info.device_id = 0xFFFF; p_node->rec.node_info.device_id = cl_hton16((uint16_t) strtoul (&line [offset], NULL, 0)); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "device_id = 0x%X\n", cl_ntoh16(p_node->rec.node_info.device_id)); break; case OSMTEST_TOKEN_REVISION: p_node->comp.node_info.revision = 0xFFFFFFFF; p_node->rec.node_info.revision = cl_hton32(strtoul(&line[offset], NULL, 0)); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "revision = 0x%X\n", cl_ntoh32(p_node->rec.node_info.revision)); break; case OSMTEST_TOKEN_PORT_NUM: p_node->comp.node_info.port_num_vendor_id |= IB_NODE_INFO_PORT_NUM_MASK; p_node->rec.node_info.port_num_vendor_id |= (uint8_t) strtoul(&line[offset], NULL, 0); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "local_port_num = 0x%X\n", ib_node_info_get_local_port_num (&p_node->rec.node_info)); break; case OSMTEST_TOKEN_VENDOR_ID: p_node->comp.node_info.port_num_vendor_id |= IB_NODE_INFO_VEND_ID_MASK; p_node->rec.node_info.port_num_vendor_id |= cl_hton32(strtoul(&line[offset], NULL, 0)); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "vendor_id = 0x%X\n", cl_ntoh32(ib_node_info_get_vendor_id (&p_node->rec.node_info))); break; case OSMTEST_TOKEN_END: done = TRUE; break; default: OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0121: " "Ignoring line %u with unknown token: %s\n", *p_line_num, &line[offset]); break; } } /* * Make sure the user specified enough information, then * add this object to the database. */ if (p_node->comp.lid == 0) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0122: " "LID must be specified for defined nodes\n"); node_delete(p_node); goto Exit; } cl_qmap_insert(&p_osmt->exp_subn.node_lid_tbl, p_node->rec.lid, &p_node->map_item); p_guid_node = node_new(); CL_ASSERT(p_node != NULL); *p_guid_node = *p_node; cl_qmap_insert(&p_osmt->exp_subn.node_guid_tbl, p_guid_node->rec.node_info.node_guid, &p_guid_node->map_item); Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ static ib_api_status_t osmtest_parse_port(IN osmtest_t * const p_osmt, IN FILE * const fh, IN OUT uint32_t * const p_line_num) { ib_api_status_t status = IB_SUCCESS; uint32_t offset; char line[OSMTEST_MAX_LINE_LEN]; boolean_t done = FALSE; port_t *p_port; const osmtest_token_t *p_tok; OSM_LOG_ENTER(&p_osmt->log); p_port = port_new(); CL_ASSERT(p_port != NULL); /* * Parse the inventory file and create the database. */ while (!done) { if (fgets(line, OSMTEST_MAX_LINE_LEN, fh) == NULL) { /* * End of file in the middle of a definition. */ OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0123: " "Unexpected end of file\n"); status = IB_ERROR; goto Exit; } ++*p_line_num; /* * Skip whitespace */ offset = 0; if (!str_skip_white(line, &offset)) continue; /* whole line was whitespace */ p_tok = str_get_token(&line[offset]); if (p_tok == NULL) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0124: " "Ignoring line %u with unknown token: %s\n", *p_line_num, &line[offset]); continue; } OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "Found '%s' (line %u)\n", p_tok->str, *p_line_num); str_skip_token(line, &offset); switch (p_tok->val) { case OSMTEST_TOKEN_COMMENT: break; case OSMTEST_TOKEN_LID: p_port->comp.lid = 0xFFFF; p_port->rec.lid = cl_hton16((uint16_t) strtoul(&line[offset], NULL, 0)); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "lid = 0x%X\n", cl_ntoh16(p_port->rec.lid)); break; case OSMTEST_TOKEN_PORT_NUM: p_port->comp.port_num = 0xFF; p_port->rec.port_num = (uint8_t) strtoul(&line[offset], NULL, 0); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "port_num = 0x%u\n", p_port->rec.port_num); break; case OSMTEST_TOKEN_MKEY: p_port->comp.port_info.m_key = 0xFFFFFFFFFFFFFFFFULL; p_port->rec.port_info.m_key = cl_hton64(strtoull(&line[offset], NULL, 0)); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "m_key = 0x%016" PRIx64 "\n", cl_ntoh64(p_port->rec.port_info.m_key)); break; case OSMTEST_TOKEN_SUBN_PREF: p_port->comp.port_info.subnet_prefix = 0xFFFFFFFFFFFFFFFFULL; p_port->rec.port_info.subnet_prefix = cl_hton64(strtoull(&line[offset], NULL, 0)); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "subnet_prefix = 0x%016" PRIx64 "\n", cl_ntoh64(p_port->rec.port_info.subnet_prefix)); break; case OSMTEST_TOKEN_BASE_LID: p_port->comp.port_info.base_lid = 0xFFFF; p_port->rec.port_info.base_lid = cl_hton16((uint16_t) strtoul(&line[offset], NULL, 0)); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "base_lid = 0x%X\n", cl_ntoh16(p_port->rec.port_info.base_lid)); break; case OSMTEST_TOKEN_SM_BASE_LID: p_port->comp.port_info.master_sm_base_lid = 0xFFFF; p_port->rec.port_info.master_sm_base_lid = cl_hton16((uint16_t) strtoul(&line[offset], NULL, 0)); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "master_sm_base_lid = 0x%X\n", cl_ntoh16(p_port->rec.port_info.master_sm_base_lid)); break; case OSMTEST_TOKEN_CAP_MASK: p_port->comp.port_info.capability_mask = 0xFFFFFFFF; p_port->rec.port_info.capability_mask = cl_hton32((uint32_t) strtoul(&line[offset], NULL, 0)); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "capability_mask = 0x%X\n", cl_ntoh32(p_port->rec.port_info.capability_mask)); break; case OSMTEST_TOKEN_DIAG_CODE: p_port->comp.port_info.diag_code = 0xFFFF; p_port->rec.port_info.diag_code = cl_hton16((uint16_t) strtoul(&line[offset], NULL, 0)); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "diag_code = 0x%X\n", cl_ntoh16(p_port->rec.port_info.diag_code)); break; case OSMTEST_TOKEN_MKEY_LEASE_PER: p_port->comp.port_info.m_key_lease_period = 0xFFFF; p_port->rec.port_info.m_key_lease_period = cl_hton16((uint16_t) strtoul(&line[offset], NULL, 0)); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "m_key_lease_period = 0x%X\n", cl_ntoh16(p_port->rec.port_info.m_key_lease_period)); break; case OSMTEST_TOKEN_LOC_PORT_NUM: p_port->comp.port_info.local_port_num = 0xFF; p_port->rec.port_info.local_port_num = (uint8_t) strtoul(&line[offset], NULL, 0); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "local_port_num = 0x%u\n", p_port->rec.port_info.local_port_num); break; case OSMTEST_TOKEN_LINK_WID_EN: p_port->comp.port_info.link_width_enabled = 0xFF; p_port->rec.port_info.link_width_enabled = (uint8_t) strtoul(&line[offset], NULL, 0); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "link_width_enabled = 0x%u\n", p_port->rec.port_info.link_width_enabled); break; case OSMTEST_TOKEN_LINK_WID_SUP: p_port->comp.port_info.link_width_supported = 0xFF; p_port->rec.port_info.link_width_supported = (uint8_t) strtoul(&line[offset], NULL, 0); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "link_width_supported = 0x%u\n", p_port->rec.port_info.link_width_supported); break; case OSMTEST_TOKEN_LINK_WID_ACT: p_port->comp.port_info.link_width_active = 0xFF; p_port->rec.port_info.link_width_active = (uint8_t) strtoul(&line[offset], NULL, 0); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "link_width_active = 0x%u\n", p_port->rec.port_info.link_width_active); break; case OSMTEST_TOKEN_LINK_SPEED_SUP: p_port->comp.port_info.state_info1 = 0xFF; ib_port_info_set_link_speed_sup((uint8_t) strtoul(&line[offset], NULL, 0), &p_port->rec.port_info); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "link_speed_supported = 0x%u\n", ib_port_info_get_link_speed_sup(&p_port->rec.port_info)); break; case OSMTEST_TOKEN_PORT_STATE: str_skip_white(line, &offset); p_port->comp.port_info.state_info1 = 0xFF; ib_port_info_set_port_state(&p_port->rec.port_info, ib_get_port_state_from_str (&line[offset])); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "port_state = 0x%u\n", ib_port_info_get_port_state(&p_port->rec.port_info)); break; case OSMTEST_TOKEN_STATE_INFO2: p_port->comp.port_info.state_info2 = 0xFF; p_port->rec.port_info.state_info2 = (uint8_t) strtoul(&line[offset], NULL, 0); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "state_info2 = 0x%u\n", p_port->rec.port_info.state_info2); break; case OSMTEST_TOKEN_MKEY_PROT_BITS: p_port->comp.port_info.mkey_lmc = 0xFF; ib_port_info_set_mpb(&p_port->rec.port_info, (uint8_t) strtoul(&line[offset], NULL, 0)); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "mpb = 0x%u\n", ib_port_info_get_mpb(&p_port->rec.port_info)); break; case OSMTEST_TOKEN_LMC: p_port->comp.port_info.mkey_lmc = 0xFF; ib_port_info_set_lmc(&p_port->rec.port_info, (uint8_t) strtoul(&line[offset], NULL, 0)); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "lmc = 0x%u\n", ib_port_info_get_lmc(&p_port->rec.port_info)); break; case OSMTEST_TOKEN_LINK_SPEED: p_port->comp.port_info.link_speed = 0xFF; p_port->rec.port_info.link_speed = (uint8_t) strtoul(&line[offset], NULL, 0); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "link_speed = 0x%u\n", p_port->rec.port_info.link_speed); break; case OSMTEST_TOKEN_MTU_SMSL: p_port->comp.port_info.mtu_smsl = 0xFF; p_port->rec.port_info.mtu_smsl = (uint8_t) strtoul(&line[offset], NULL, 0); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "mtu_smsl = 0x%u\n", p_port->rec.port_info.mtu_smsl); break; case OSMTEST_TOKEN_VL_CAP: p_port->comp.port_info.vl_cap = 0xFF; p_port->rec.port_info.vl_cap = (uint8_t) strtoul(&line[offset], NULL, 0); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "vl_cap = 0x%u\n", p_port->rec.port_info.vl_cap); break; case OSMTEST_TOKEN_VL_HIGH_LIMIT: p_port->comp.port_info.vl_high_limit = 0xFF; p_port->rec.port_info.vl_high_limit = (uint8_t) strtoul(&line[offset], NULL, 0); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "vl_high_limit = 0x%u\n", p_port->rec.port_info.vl_high_limit); break; case OSMTEST_TOKEN_VL_ARB_HIGH_CAP: p_port->comp.port_info.vl_arb_high_cap = 0xFF; p_port->rec.port_info.vl_arb_high_cap = (uint8_t) strtoul(&line[offset], NULL, 0); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "vl_arb_high_cap = 0x%u\n", p_port->rec.port_info.vl_arb_high_cap); break; case OSMTEST_TOKEN_VL_ARB_LOW_CAP: p_port->comp.port_info.vl_arb_low_cap = 0xFF; p_port->rec.port_info.vl_arb_low_cap = (uint8_t) strtoul(&line[offset], NULL, 0); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "vl_arb_low_cap = 0x%u\n", p_port->rec.port_info.vl_arb_low_cap); break; case OSMTEST_TOKEN_MTU_CAP: p_port->comp.port_info.mtu_cap = 0xFF; p_port->rec.port_info.mtu_cap = (uint8_t) strtoul(&line[offset], NULL, 0); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "mtu_cap = 0x%u\n", p_port->rec.port_info.mtu_cap); break; case OSMTEST_TOKEN_VL_STALL_LIFE: p_port->comp.port_info.vl_stall_life = 0xFF; p_port->rec.port_info.vl_stall_life = (uint8_t) strtoul(&line[offset], NULL, 0); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "vl_stall_life = 0x%u\n", p_port->rec.port_info.vl_stall_life); break; case OSMTEST_TOKEN_VL_ENFORCE: p_port->comp.port_info.vl_enforce = 0xFF; p_port->rec.port_info.vl_enforce = (uint8_t) strtoul(&line[offset], NULL, 0); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "vl_enforce = 0x%u\n", p_port->rec.port_info.vl_enforce); break; case OSMTEST_TOKEN_MKEY_VIOL: p_port->comp.port_info.m_key_violations = 0xFFFF; p_port->rec.port_info.m_key_violations = cl_hton16((uint16_t) strtoul(&line[offset], NULL, 0)); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "m_key_violations = 0x%X\n", cl_ntoh16(p_port->rec.port_info.m_key_violations)); break; case OSMTEST_TOKEN_PKEY_VIOL: p_port->comp.port_info.p_key_violations = 0xFFFF; p_port->rec.port_info.p_key_violations = cl_hton16((uint16_t) strtoul(&line[offset], NULL, 0)); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "p_key_violations = 0x%X\n", cl_ntoh16(p_port->rec.port_info.p_key_violations)); break; case OSMTEST_TOKEN_QKEY_VIOL: p_port->comp.port_info.q_key_violations = 0xFFFF; p_port->rec.port_info.q_key_violations = cl_hton16((uint16_t) strtoul(&line[offset], NULL, 0)); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "q_key_violations = 0x%X\n", cl_ntoh16(p_port->rec.port_info.q_key_violations)); break; case OSMTEST_TOKEN_GUID_CAP: p_port->comp.port_info.guid_cap = 0xFF; p_port->rec.port_info.guid_cap = (uint8_t) strtoul(&line[offset], NULL, 0); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "guid_cap = 0x%u\n", p_port->rec.port_info.guid_cap); break; case OSMTEST_TOKEN_SUBN_TIMEOUT: p_port->comp.port_info.subnet_timeout = 0x1F; p_port->rec.port_info.subnet_timeout = (uint8_t) strtoul(&line[offset], NULL, 0); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "subnet_timeout = 0x%u\n", ib_port_info_get_timeout(&p_port->rec.port_info)); break; case OSMTEST_TOKEN_RESP_TIME_VAL: p_port->comp.port_info.resp_time_value = 0xFF; p_port->rec.port_info.resp_time_value = (uint8_t) strtoul(&line[offset], NULL, 0); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "resp_time_value = 0x%u\n", p_port->rec.port_info.resp_time_value); break; case OSMTEST_TOKEN_ERR_THRESHOLD: p_port->comp.port_info.error_threshold = 0xFF; p_port->rec.port_info.error_threshold = (uint8_t) strtoul(&line[offset], NULL, 0); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "error_threshold = 0x%u\n", p_port->rec.port_info.error_threshold); break; case OSMTEST_TOKEN_END: done = TRUE; break; default: OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0125: " "Ignoring line %u with unknown token: %s\n", *p_line_num, &line[offset]); break; } } /* * Make sure the user specified enough information, then * add this object to the database. */ if (p_port->comp.lid == 0) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0126: " "LID must be specified for defined ports\n"); port_delete(p_port); status = IB_ERROR; goto Exit; } cl_qmap_insert(&p_osmt->exp_subn.port_key_tbl, port_gen_id(p_port->rec.lid, p_port->rec.port_num), &p_port->map_item); Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ static ib_api_status_t osmtest_parse_path(IN osmtest_t * const p_osmt, IN FILE * const fh, IN OUT uint32_t * const p_line_num) { ib_api_status_t status = IB_SUCCESS; uint32_t offset; char line[OSMTEST_MAX_LINE_LEN]; boolean_t done = FALSE; path_t *p_path; const osmtest_token_t *p_tok; boolean_t got_error = FALSE; OSM_LOG_ENTER(&p_osmt->log); p_path = path_new(); CL_ASSERT(p_path != NULL); /* * Parse the inventory file and create the database. */ while (!done) { if (fgets(line, OSMTEST_MAX_LINE_LEN, fh) == NULL) { /* * End of file in the middle of a definition. */ OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0127: " "Unexpected end of file\n"); status = IB_ERROR; goto Exit; } ++*p_line_num; /* * Skip whitespace */ offset = 0; if (!str_skip_white(line, &offset)) continue; /* whole line was whitespace */ p_tok = str_get_token(&line[offset]); if (p_tok == NULL) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0128: " "Ignoring line %u with unknown token: %s\n", *p_line_num, &line[offset]); got_error = TRUE; continue; } OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "Found '%s' (line %u)\n", p_tok->str, *p_line_num); str_skip_token(line, &offset); switch (p_tok->val) { case OSMTEST_TOKEN_COMMENT: break; case OSMTEST_TOKEN_DGID: p_path->comp.dgid.unicast.prefix = 0xFFFFFFFFFFFFFFFFULL; p_path->comp.dgid.unicast.interface_id = 0xFFFFFFFFFFFFFFFFULL; str_skip_white(line, &offset); p_path->rec.dgid.unicast.prefix = cl_hton64(strtoull(&line[offset], NULL, 0)); str_skip_token(line, &offset); p_path->rec.dgid.unicast.interface_id = cl_hton64(strtoull(&line[offset], NULL, 0)); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "dgid = 0x%016" PRIx64 " 0x%016" PRIx64 "\n", cl_ntoh64(p_path->rec.dgid.unicast.prefix), cl_ntoh64(p_path->rec.dgid.unicast.interface_id)); break; case OSMTEST_TOKEN_SGID: p_path->comp.sgid.unicast.prefix = 0xFFFFFFFFFFFFFFFFULL; p_path->comp.sgid.unicast.interface_id = 0xFFFFFFFFFFFFFFFFULL; str_skip_white(line, &offset); p_path->rec.sgid.unicast.prefix = cl_hton64(strtoull(&line[offset], NULL, 0)); str_skip_token(line, &offset); p_path->rec.sgid.unicast.interface_id = cl_hton64(strtoull(&line[offset], NULL, 0)); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "sgid = 0x%016" PRIx64 " 0x%016" PRIx64 "\n", cl_ntoh64(p_path->rec.sgid.unicast.prefix), cl_ntoh64(p_path->rec.sgid.unicast.interface_id)); break; case OSMTEST_TOKEN_DLID: p_path->comp.dlid = 0xFFFF; p_path->rec.dlid = cl_hton16((uint16_t) strtoul(&line[offset], NULL, 0)); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "dlid = 0x%X\n", cl_ntoh16(p_path->rec.dlid)); break; case OSMTEST_TOKEN_SLID: p_path->comp.slid = 0xFFFF; p_path->rec.slid = cl_hton16((uint16_t) strtoul(&line[offset], NULL, 0)); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "slid = 0x%X\n", cl_ntoh16(p_path->rec.slid)); break; case OSMTEST_TOKEN_PKEY: p_path->comp.pkey = 0xFFFF; p_path->rec.pkey = cl_hton16((uint16_t) strtoul(&line[offset], NULL, 0)); OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "pkey = 0x%X\n", cl_ntoh16(p_path->rec.pkey)); break; case OSMTEST_TOKEN_END: done = TRUE; break; default: OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0129: " "Ignoring line %u with unknown token: %s\n", *p_line_num, &line[offset]); got_error = TRUE; break; } } if (got_error) { status = IB_ERROR; goto Exit; } /* * Make sure the user specified enough information, then * add this object to the database. */ if (osmtest_path_rec_kay_is_valid(p_osmt, p_path) == FALSE) { path_delete(p_path); status = IB_ERROR; goto Exit; } cl_qmap_insert(&p_osmt->exp_subn.path_tbl, osmtest_path_rec_key_get(&p_path->rec), &p_path->map_item); Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ static ib_api_status_t osmtest_parse_link(IN osmtest_t * const p_osmt, IN FILE * const fh, IN OUT uint32_t * const p_line_num) { ib_api_status_t status = IB_SUCCESS; uint32_t offset; char line[OSMTEST_MAX_LINE_LEN]; boolean_t done = FALSE; const osmtest_token_t *p_tok; boolean_t got_error = FALSE; OSM_LOG_ENTER(&p_osmt->log); /* * Parse the inventory file and create the database. */ while (!done) { if (fgets(line, OSMTEST_MAX_LINE_LEN, fh) == NULL) { /* * End of file in the middle of a definition. */ OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 012A: " "Unexpected end of file\n"); status = IB_ERROR; goto Exit; } ++*p_line_num; /* * Skip whitespace */ offset = 0; if (!str_skip_white(line, &offset)) continue; /* whole line was whitespace */ p_tok = str_get_token(&line[offset]); if (p_tok == NULL) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 012B: " "Ignoring line %u with unknown token: %s\n", *p_line_num, &line[offset]); got_error = TRUE; continue; } OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "Found '%s' (line %u)\n", p_tok->str, *p_line_num); str_skip_token(line, &offset); switch (p_tok->val) { case OSMTEST_TOKEN_FROMLID: case OSMTEST_TOKEN_FROMPORTNUM: case OSMTEST_TOKEN_TOPORTNUM: case OSMTEST_TOKEN_TOLID: /* For now */ break; case OSMTEST_TOKEN_END: done = TRUE; break; default: OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 012C: " "Ignoring line %u with unknown token: %s\n", *p_line_num, &line[offset]); got_error = TRUE; break; } } if (got_error) status = IB_ERROR; Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ static ib_api_status_t osmtest_create_db(IN osmtest_t * const p_osmt) { FILE *fh; ib_api_status_t status = IB_SUCCESS; uint32_t offset; char line[OSMTEST_MAX_LINE_LEN]; uint32_t line_num = 0; const osmtest_token_t *p_tok; boolean_t got_error = FALSE; OSM_LOG_ENTER(&p_osmt->log); fh = fopen(p_osmt->opt.file_name, "r"); if (fh == NULL) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0130: " "Unable to open inventory file (%s)\n", p_osmt->opt.file_name); status = IB_ERROR; goto Exit; } /* * Parse the inventory file and create the database. */ while (fgets(line, OSMTEST_MAX_LINE_LEN, fh) != NULL) { line_num++; /* * Skip whitespace */ offset = 0; if (!str_skip_white(line, &offset)) continue; /* whole line was whitespace */ p_tok = str_get_token(&line[offset]); if (p_tok == NULL) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0131: " "Ignoring line %u: %s\n", line_num, &line[offset]); got_error = TRUE; continue; } OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "Found '%s' (line %u)\n", p_tok->str, line_num); switch (p_tok->val) { case OSMTEST_TOKEN_COMMENT: break; case OSMTEST_TOKEN_DEFINE_NODE: status = osmtest_parse_node(p_osmt, fh, &line_num); break; case OSMTEST_TOKEN_DEFINE_PORT: status = osmtest_parse_port(p_osmt, fh, &line_num); break; case OSMTEST_TOKEN_DEFINE_PATH: status = osmtest_parse_path(p_osmt, fh, &line_num); break; case OSMTEST_TOKEN_DEFINE_LINK: status = osmtest_parse_link(p_osmt, fh, &line_num); break; default: OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0132: " "Ignoring line %u: %s\n", line_num, &line[offset]); got_error = TRUE; break; } if (got_error) status = IB_ERROR; if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0133: " "Bad status received during parsing (%s)\n", ib_get_err_str(status)); fclose(fh); goto Exit; } } fclose(fh); Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** Returns the index in the local port attribute array for the user's selection. **********************************************************************/ static uint32_t osmtest_get_user_port(IN osmtest_t * const p_osmt, IN const ib_port_attr_t p_attr_array[], IN uint32_t const num_ports) { uint32_t i; uint32_t choice = 0; boolean_t done_flag = FALSE; OSM_LOG_ENTER(&p_osmt->log); /* * User needs prompting for the local port GUID with which * to bind. */ while (done_flag == FALSE) { printf("\nChoose a local port number with which to bind:\n\n"); for (i = 0; i < num_ports; i++) { /* * Print the index + 1 since by convention, port numbers * start with 1 on host channel adapters. */ printf("\t%u: GUID = 0x%8" PRIx64 ", lid = 0x%04X, state = %s\n", i + 1, cl_ntoh64(p_attr_array[i].port_guid), p_attr_array[i].lid, ib_get_port_state_str(p_attr_array[i]. link_state)); } printf("\nEnter choice (1-%u): ", i); scanf("%u", &choice); if (choice > num_ports) printf("\nError: Lame choice!\n"); else done_flag = TRUE; } printf("\n"); OSM_LOG_EXIT(&p_osmt->log); return (choice - 1); } /********************************************************************** **********************************************************************/ ib_api_status_t osmtest_bind(IN osmtest_t * p_osmt, IN uint16_t max_lid, IN ib_net64_t guid OPTIONAL) { uint32_t port_index; ib_api_status_t status; uint32_t num_ports = GUID_ARRAY_SIZE; ib_port_attr_t attr_array[GUID_ARRAY_SIZE]; OSM_LOG_ENTER(&p_osmt->log); /* * Call the transport layer for a list of local port * GUID values. */ status = osm_vendor_get_all_port_attr(p_osmt->p_vendor, attr_array, &num_ports); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0134: " "Failure getting local port attributes (%s)\n", ib_get_err_str(status)); goto Exit; } if (guid == 0) { /* * User needs prompting for the local port GUID with which * to bind. */ port_index = osmtest_get_user_port(p_osmt, attr_array, num_ports); if (num_ports == 0) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0135: " "No local ports. Unable to proceed\n"); goto Exit; } guid = attr_array[port_index].port_guid; } else { for (port_index = 0; port_index < num_ports; port_index++) { if (attr_array[port_index].port_guid == guid) break; } if (port_index == num_ports) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0136: " "No local port with guid 0x%016" PRIx64 "\n", cl_ntoh64(guid)); status = IB_NOT_FOUND; goto Exit; } } /* * Copy the port info for the selected port. */ memcpy(&p_osmt->local_port, &attr_array[port_index], sizeof(p_osmt->local_port)); /* bind to the SA */ OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG, "Using port with SM LID:0x%04X\n", p_osmt->local_port.sm_lid); p_osmt->max_lid = max_lid; p_osmt->h_bind = osmv_bind_sa(p_osmt->p_vendor, &p_osmt->mad_pool, guid); if (p_osmt->h_bind == OSM_BIND_INVALID_HANDLE) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0137: " "Unable to bind to SA\n"); status = IB_ERROR; goto Exit; } Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } /********************************************************************** **********************************************************************/ ib_api_status_t osmtest_run(IN osmtest_t * const p_osmt) { ib_api_status_t status = IB_SUCCESS; OSM_LOG_ENTER(&p_osmt->log); status = osmtest_validate_sa_class_port_info(p_osmt); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0138: " "Could not obtain SA ClassPortInfo (%s)\n", ib_get_err_str(status)); goto Exit; } if (p_osmt->opt.flow == OSMT_FLOW_CREATE_INVENTORY) { /* * Creating an inventory file with all nodes, ports and paths */ status = osmtest_create_inventory_file(p_osmt); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0139: " "Inventory file create failed (%s)\n", ib_get_err_str(status)); goto Exit; } } else { if (p_osmt->opt.flow == OSMT_FLOW_STRESS_SA) { /* * Stress SA - flood the SA with queries */ switch (p_osmt->opt.stress) { case 0: case 1: /* small response SA query stress */ status = osmtest_stress_small_rmpp(p_osmt); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0140: " "Small RMPP stress test failed (%s)\n", ib_get_err_str(status)); goto Exit; } break; case 2: /* large response SA query stress */ status = osmtest_stress_large_rmpp(p_osmt); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0141: " "Large RMPP stress test failed (%s)\n", ib_get_err_str(status)); goto Exit; } break; case 3: /* large response Path Record SA query stress */ status = osmtest_create_db(p_osmt); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0142: " "Database creation failed (%s)\n", ib_get_err_str(status)); goto Exit; } status = osmtest_stress_large_rmpp_pr(p_osmt); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0143: " "Large RMPP stress test failed (%s)\n", ib_get_err_str(status)); goto Exit; } break; default: OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0144: " "Unknown stress test value %u\n", p_osmt->opt.stress); break; } } else { /* * Run normal validation tests. */ if (p_osmt->opt.flow == OSMT_FLOW_ALL || p_osmt->opt.flow == OSMT_FLOW_VALIDATE_INVENTORY) { /* * Only validate the given inventory file */ status = osmtest_create_db(p_osmt); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0145: " "Database creation failed (%s)\n", ib_get_err_str(status)); goto Exit; } status = osmtest_validate_against_db(p_osmt); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0146: " "SA validation database failure (%s)\n", ib_get_err_str(status)); goto Exit; } } if (p_osmt->opt.flow == OSMT_FLOW_ALL) { status = osmtest_wrong_sm_key_ignored(p_osmt); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0147: " "Try wrong SM_Key failed (%s)\n", ib_get_err_str(status)); goto Exit; } } if (p_osmt->opt.flow == OSMT_FLOW_ALL || p_osmt->opt.flow == OSMT_FLOW_SERVICE_REGISTRATION) { /* * run service registration, deregistration, and lease test */ status = osmt_run_service_records_flow(p_osmt); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0148: " "Service Flow failed (%s)\n", ib_get_err_str(status)); goto Exit; } } if (p_osmt->opt.flow == OSMT_FLOW_ALL || p_osmt->opt.flow == OSMT_FLOW_EVENT_FORWARDING) { /* * Run event forwarding test */ #ifdef OSM_VENDOR_INTF_MTL status = osmt_run_inform_info_flow(p_osmt); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0149: " "Inform Info Flow failed: (%s)\n", ib_get_err_str(status)); goto Exit; } #else OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "The event forwarding flow " "is not implemented yet!\n"); status = IB_SUCCESS; goto Exit; #endif } if (p_osmt->opt.flow == OSMT_FLOW_QOS) { /* * QoS info: dump VLArb and SLtoVL tables. * Since it generates a huge file, we run it only * if explicitly required to */ status = osmtest_create_db(p_osmt); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 014A: " "Database creation failed (%s)\n", ib_get_err_str(status)); goto Exit; } status = osmt_run_slvl_and_vlarb_records_flow (p_osmt); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0150: " "Failed to get SLtoVL and VL Arbitration Tables (%s)\n", ib_get_err_str(status)); goto Exit; } } if (p_osmt->opt.flow == OSMT_FLOW_TRAP) { /* * Run trap 64/65 flow (this flow requires running of external tool) */ #ifdef OSM_VENDOR_INTF_MTL status = osmt_run_trap64_65_flow(p_osmt); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0151: " "Trap 64/65 Flow failed: (%s)\n", ib_get_err_str(status)); goto Exit; } #else OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "The event forwarding flow " "is not implemented yet!\n"); status = IB_SUCCESS; goto Exit; #endif } if (p_osmt->opt.flow == OSMT_FLOW_ALL || p_osmt->opt.flow == OSMT_FLOW_MULTICAST) { /* * Multicast flow */ status = osmt_run_mcast_flow(p_osmt); if (status != IB_SUCCESS) { OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0152: " "Multicast Flow failed: (%s)\n", ib_get_err_str(status)); goto Exit; } } OSM_LOG(&p_osmt->log, OSM_LOG_INFO, "\n\n***************** ALL TESTS PASS *****************\n\n"); } } Exit: OSM_LOG_EXIT(&p_osmt->log); return (status); } Index: stable/9/contrib/ofed/usr.bin/Makefile =================================================================== --- stable/9/contrib/ofed/usr.bin/Makefile (revision 276976) +++ stable/9/contrib/ofed/usr.bin/Makefile (revision 276977) @@ -1,7 +1,7 @@ .include -SUBDIR = ibaddr ibnetdiscover ibping ibportstate ibroute ibsendtrap ibstat -SUBDIR += ibsysstat ibtracert opensm perfquery saquery -SUBDIR += sminfo smpdump smpquery vendstat +SUBDIR= ibaddr ibnetdiscover ibping ibportstate ibroute ibsendtrap ibstat \ + ibsysstat ibtracert opensm perfquery saquery \ + sminfo smpdump smpquery vendstat .include Index: stable/9/contrib/ofed/usr.bin/osmtest/Makefile =================================================================== --- stable/9/contrib/ofed/usr.bin/osmtest/Makefile (nonexistent) +++ stable/9/contrib/ofed/usr.bin/osmtest/Makefile (revision 276977) @@ -0,0 +1,34 @@ +# $FreeBSD$ + +.include "../Makefile.inc" + +OPENSM= ${.CURDIR}/../../management/opensm +.PATH: ${OPENSM}/osmtest ${OPENSM}/man + +BINDIR= ${TESTSBASE}/usr.bin/opensm +PROG= osmtest + +SRCS= main.c \ + osmt_inform.c \ + osmt_mtl_regular_qp.c \ + osmt_multicast.c \ + osmt_service.c \ + osmt_slvl_vl_arb.c \ + osmtest.c + +LDADD= -libcommon \ + -libmad \ + -libumad \ + -losmvendor \ + -losmcomp \ + -lopensm \ + -lpthread + +CFLAGS= -DVENDOR_RMPP_SUPPORT -DDUAL_SIDED_RMPP \ + -I${OPENSM}/osmtest/include + +MAN= osmtest.8 + +WARNS?= 1 + +.include Property changes on: stable/9/contrib/ofed/usr.bin/osmtest/Makefile ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property Index: stable/9/contrib/ofed/usr.lib/Makefile =================================================================== --- stable/9/contrib/ofed/usr.lib/Makefile (revision 276976) +++ stable/9/contrib/ofed/usr.lib/Makefile (revision 276977) @@ -1,6 +1,6 @@ .include -SUBDIR = libibcommon libibmad libibumad libibverbs libmlx4 libmthca -SUBDIR += libopensm libosmcomp libosmvendor libibcm librdmacm libsdp +SUBDIR= libibcommon libibmad libibumad libibverbs libmlx4 libmthca \ + libopensm libosmcomp libosmvendor libibcm librdmacm libsdp .include Index: stable/9/contrib =================================================================== --- stable/9/contrib (revision 276976) +++ stable/9/contrib (revision 276977) Property changes on: stable/9/contrib ___________________________________________________________________ Modified: svn:mergeinfo ## -0,0 +0,1 ## Merged /head/contrib:r276823