Blame osmtest/osmt_slvl_vl_arb.c

Packit 13e616
/*
Packit 13e616
 * Copyright (c) 2006-2008 Voltaire, Inc. All rights reserved.
Packit 13e616
 * Copyright (c) 2002-2005 Mellanox Technologies LTD. All rights reserved.
Packit 13e616
 * Copyright (c) 1996-2003 Intel Corporation. All rights reserved.
Packit 13e616
 *
Packit 13e616
 * This software is available to you under a choice of one of two
Packit 13e616
 * licenses.  You may choose to be licensed under the terms of the GNU
Packit 13e616
 * General Public License (GPL) Version 2, available from the file
Packit 13e616
 * COPYING in the main directory of this source tree, or the
Packit 13e616
 * OpenIB.org BSD license below:
Packit 13e616
 *
Packit 13e616
 *     Redistribution and use in source and binary forms, with or
Packit 13e616
 *     without modification, are permitted provided that the following
Packit 13e616
 *     conditions are met:
Packit 13e616
 *
Packit 13e616
 *      - Redistributions of source code must retain the above
Packit 13e616
 *        copyright notice, this list of conditions and the following
Packit 13e616
 *        disclaimer.
Packit 13e616
 *
Packit 13e616
 *      - Redistributions in binary form must reproduce the above
Packit 13e616
 *        copyright notice, this list of conditions and the following
Packit 13e616
 *        disclaimer in the documentation and/or other materials
Packit 13e616
 *        provided with the distribution.
Packit 13e616
 *
Packit 13e616
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
Packit 13e616
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
Packit 13e616
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
Packit 13e616
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
Packit 13e616
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
Packit 13e616
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
Packit 13e616
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
Packit 13e616
 * SOFTWARE.
Packit 13e616
 *
Packit 13e616
 */
Packit 13e616
Packit 13e616
/*
Packit 13e616
 * Abstract:
Packit 13e616
 *    Implementation of SLtoVL and VL Arbitration testing flow..
Packit 13e616
 *    Top level is osmt_run_slvl_and_vlarb_records_flow:
Packit 13e616
 *     osmt_query_all_ports_vl_arb
Packit 13e616
 *     osmt_query_all_ports_slvl_map
Packit 13e616
 *
Packit 13e616
 */
Packit 13e616
Packit 13e616
#ifndef __WIN__
Packit 13e616
#include <unistd.h>
Packit 13e616
#endif
Packit 13e616
#include <stdio.h>
Packit 13e616
#include <stdlib.h>
Packit 13e616
#include <string.h>
Packit 13e616
#include <complib/cl_debug.h>
Packit 13e616
#include "osmtest.h"
Packit 13e616
Packit 13e616
static ib_api_status_t
Packit 13e616
osmtest_write_vl_arb_table(IN osmtest_t * const p_osmt,
Packit 13e616
			   IN FILE * fh,
Packit 13e616
			   IN const ib_vl_arb_table_record_t * const p_rec)
Packit 13e616
{
Packit 13e616
	int i;
Packit 13e616
	cl_status_t status = IB_SUCCESS;
Packit 13e616
Packit 13e616
	OSM_LOG_ENTER(&p_osmt->log);
Packit 13e616
Packit 13e616
	fprintf(fh,
Packit 13e616
		"VL_ARBITRATION_TABLE\n"
Packit 13e616
		"lid                     0x%X\n"
Packit 13e616
		"port_num                0x%X\n"
Packit 13e616
		"block                   0x%X\n",
Packit 13e616
		cl_ntoh16(p_rec->lid),
Packit 13e616
		p_rec->port_num, p_rec->block_num);
Packit 13e616
Packit 13e616
	fprintf(fh, "       ");
Packit 13e616
	for (i = 0; i < 32; i++)
Packit 13e616
		fprintf(fh, "| %-2u ", i);
Packit 13e616
	fprintf(fh, "|\nVL:    ");
Packit 13e616
Packit 13e616
	for (i = 0; i < 32; i++)
Packit 13e616
		fprintf(fh, "|0x%02X", p_rec->vl_arb_tbl.vl_entry[i].vl);
Packit 13e616
	fprintf(fh, "|\nWEIGHT:");
Packit 13e616
Packit 13e616
	for (i = 0; i < 32; i++)
Packit 13e616
		fprintf(fh, "|0x%02X", p_rec->vl_arb_tbl.vl_entry[i].weight);
Packit 13e616
	fprintf(fh, "|\nEND\n\n");
Packit 13e616
Packit 13e616
	/*  Exit: */
Packit 13e616
	OSM_LOG_EXIT(&p_osmt->log);
Packit 13e616
	return (status);
Packit 13e616
}
Packit 13e616
Packit 13e616
/**********************************************************************
Packit 13e616
 * GET A SINGLE PORT INFO BY NODE LID AND PORT NUMBER
Packit 13e616
 **********************************************************************/
Packit 13e616
ib_api_status_t
Packit 13e616
osmt_query_vl_arb(IN osmtest_t * const p_osmt,
Packit 13e616
		  IN ib_net16_t const lid,
Packit 13e616
		  IN uint8_t const port_num,
Packit 13e616
		  IN uint8_t const block_num, IN FILE * fh)
Packit 13e616
{
Packit 13e616
	osmtest_req_context_t context;
Packit 13e616
	ib_api_status_t status = IB_SUCCESS;
Packit 13e616
	osmv_user_query_t user;
Packit 13e616
	osmv_query_req_t req;
Packit 13e616
	ib_vl_arb_table_record_t record, *p_rec;
Packit 13e616
Packit 13e616
	OSM_LOG_ENTER(&p_osmt->log);
Packit 13e616
Packit 13e616
	OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
Packit 13e616
		"Getting VL_Arbitration Table for port with LID 0x%X Num:0x%X\n",
Packit 13e616
		cl_ntoh16(lid), port_num);
Packit 13e616
Packit 13e616
	/*
Packit 13e616
	 * Do a blocking query for this record in the subnet.
Packit 13e616
	 * The result is returned in the result field of the caller's
Packit 13e616
	 * context structure.
Packit 13e616
	 *
Packit 13e616
	 * The query structures are locals.
Packit 13e616
	 */
Packit 13e616
	memset(&req, 0, sizeof(req));
Packit 13e616
	memset(&user, 0, sizeof(user));
Packit 13e616
	memset(&context, 0, sizeof(context));
Packit 13e616
Packit 13e616
	context.p_osmt = p_osmt;
Packit 13e616
Packit 13e616
	record.lid = lid;
Packit 13e616
	record.port_num = port_num;
Packit 13e616
	record.block_num = block_num;
Packit 13e616
	user.p_attr = &record;
Packit 13e616
Packit 13e616
	req.query_type = OSMV_QUERY_VLARB_BY_LID_PORT_BLOCK;
Packit 13e616
	req.timeout_ms = p_osmt->opt.transaction_timeout;
Packit 13e616
	req.retry_cnt = p_osmt->opt.retry_count;
Packit 13e616
	req.flags = OSM_SA_FLAGS_SYNC;
Packit 13e616
	req.query_context = &context;
Packit 13e616
	req.pfn_query_cb = osmtest_query_res_cb;
Packit 13e616
	req.p_query_input = &use;;
Packit 13e616
	req.sm_key = 0;
Packit 13e616
Packit 13e616
	if (p_osmt->opt.with_grh) {
Packit 13e616
		req.with_grh = 1;
Packit 13e616
		memcpy(&req.gid, &p_osmt->sm_port_gid, 16);
Packit 13e616
	}
Packit 13e616
Packit 13e616
	status = osmv_query_sa(p_osmt->h_bind, &req;;
Packit 13e616
Packit 13e616
	if (status != IB_SUCCESS) {
Packit 13e616
		OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0405: "
Packit 13e616
			"ib_query failed (%s)\n", ib_get_err_str(status));
Packit 13e616
		goto Exit;
Packit 13e616
	}
Packit 13e616
Packit 13e616
	status = context.result.status;
Packit 13e616
Packit 13e616
	if (status != IB_SUCCESS) {
Packit 13e616
		OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0466: "
Packit 13e616
			"ib_query failed (%s)\n", ib_get_err_str(status));
Packit 13e616
Packit 13e616
		if (status == IB_REMOTE_ERROR) {
Packit 13e616
			OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
Packit 13e616
				"Remote error = %s\n",
Packit 13e616
				ib_get_mad_status_str(osm_madw_get_mad_ptr
Packit 13e616
						      (context.result.
Packit 13e616
						       p_result_madw)));
Packit 13e616
		}
Packit 13e616
		goto Exit;
Packit 13e616
	}
Packit 13e616
Packit 13e616
	/* ok it worked */
Packit 13e616
	p_rec = osmv_get_query_result(context.result.p_result_madw, 0);
Packit 13e616
	if (fh) {
Packit 13e616
		osmtest_write_vl_arb_table(p_osmt, fh, p_rec);
Packit 13e616
	}
Packit 13e616
Packit 13e616
Exit:
Packit 13e616
	/*
Packit 13e616
	 * Return the IB query MAD to the pool as necessary.
Packit 13e616
	 */
Packit 13e616
	if (context.result.p_result_madw != NULL) {
Packit 13e616
		osm_mad_pool_put(&p_osmt->mad_pool,
Packit 13e616
				 context.result.p_result_madw);
Packit 13e616
		context.result.p_result_madw = NULL;
Packit 13e616
	}
Packit 13e616
Packit 13e616
	OSM_LOG_EXIT(&p_osmt->log);
Packit 13e616
	return (status);
Packit 13e616
}
Packit 13e616
Packit 13e616
static ib_api_status_t
Packit 13e616
osmt_query_all_ports_vl_arb(IN osmtest_t * const p_osmt, IN FILE * fh)
Packit 13e616
{
Packit 13e616
	cl_status_t status = CL_SUCCESS;
Packit 13e616
	cl_qmap_t *p_tbl;
Packit 13e616
	port_t *p_src_port;
Packit 13e616
	uint8_t block, anyErr = 0;
Packit 13e616
Packit 13e616
	OSM_LOG_ENTER(&p_osmt->log);
Packit 13e616
Packit 13e616
	OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
Packit 13e616
		"Obtaining ALL Ports VL Arbitration Tables\n");
Packit 13e616
Packit 13e616
	/*
Packit 13e616
	 * Go over all ports that exist in the subnet
Packit 13e616
	 * get the relevant VLarbs
Packit 13e616
	 */
Packit 13e616
Packit 13e616
	p_tbl = &p_osmt->exp_subn.port_key_tbl;
Packit 13e616
Packit 13e616
	p_src_port = (port_t *) cl_qmap_head(p_tbl);
Packit 13e616
Packit 13e616
	while (p_src_port != (port_t *) cl_qmap_end(p_tbl)) {
Packit 13e616
Packit 13e616
		/* HACK we use capability_mask to know diff a CA port from switch port */
Packit 13e616
		if (p_src_port->rec.port_info.capability_mask) {
Packit 13e616
			/* this is an hca port */
Packit 13e616
			for (block = 1; block <= 4; block++) {
Packit 13e616
				/*  NOTE to comply we must set port number to 0 and the SA should figure it out */
Packit 13e616
				/*  since it is a CA port */
Packit 13e616
				status =
Packit 13e616
				    osmt_query_vl_arb(p_osmt,
Packit 13e616
						      p_src_port->rec.lid, 0,
Packit 13e616
						      block, fh);
Packit 13e616
				if (status != IB_SUCCESS) {
Packit 13e616
					OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
Packit 13e616
						"ERR 0467: "
Packit 13e616
						"Failed to get Lid:0x%X Port:0x%X (%s)\n",
Packit 13e616
						cl_ntoh16(p_src_port->rec.lid),
Packit 13e616
						0, ib_get_err_str(status));
Packit 13e616
					anyErr = 1;
Packit 13e616
				}
Packit 13e616
			}
Packit 13e616
		} else {
Packit 13e616
			/* this is a switch port */
Packit 13e616
			for (block = 1; block <= 4; block++) {
Packit 13e616
				status =
Packit 13e616
				    osmt_query_vl_arb(p_osmt,
Packit 13e616
						      p_src_port->rec.lid,
Packit 13e616
						      p_src_port->rec.port_num,
Packit 13e616
						      block, fh);
Packit 13e616
				if (status != IB_SUCCESS) {
Packit 13e616
					OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
Packit 13e616
						"ERR 0468: "
Packit 13e616
						"Failed to get Lid:0x%X Port:0x%X (%s)\n",
Packit 13e616
						cl_ntoh16(p_src_port->rec.lid),
Packit 13e616
						p_src_port->rec.port_num,
Packit 13e616
						ib_get_err_str(status));
Packit 13e616
					anyErr = 1;
Packit 13e616
				}
Packit 13e616
			}
Packit 13e616
		}
Packit 13e616
Packit 13e616
		p_src_port = (port_t *) cl_qmap_next(&p_src_port->map_item);
Packit 13e616
	}
Packit 13e616
Packit 13e616
	OSM_LOG_EXIT(&p_osmt->log);
Packit 13e616
	if (anyErr) {
Packit 13e616
		status = IB_ERROR;
Packit 13e616
	}
Packit 13e616
	return (status);
Packit 13e616
}
Packit 13e616
Packit 13e616
/*******************************************************************************
Packit 13e616
 SLtoVL
Packit 13e616
*******************************************************************************/
Packit 13e616
static ib_api_status_t
Packit 13e616
osmtest_write_slvl_map_table(IN osmtest_t * const p_osmt,
Packit 13e616
			     IN FILE * fh,
Packit 13e616
			     IN const ib_slvl_table_record_t * const p_rec)
Packit 13e616
{
Packit 13e616
	int i;
Packit 13e616
	cl_status_t status = IB_SUCCESS;
Packit 13e616
Packit 13e616
	OSM_LOG_ENTER(&p_osmt->log);
Packit 13e616
Packit 13e616
	fprintf(fh,
Packit 13e616
		"SLtoVL_MAP_TABLE\n"
Packit 13e616
		"lid                     0x%X\n"
Packit 13e616
		"in_port_num             0x%X\n"
Packit 13e616
		"out_port_num            0x%X\n",
Packit 13e616
		cl_ntoh16(p_rec->lid),
Packit 13e616
		p_rec->in_port_num, p_rec->out_port_num);
Packit 13e616
Packit 13e616
	fprintf(fh, "SL:");
Packit 13e616
	for (i = 0; i < 16; i++)
Packit 13e616
		fprintf(fh, "| %-2u  ", i);
Packit 13e616
	fprintf(fh, "|\nVL:");
Packit 13e616
Packit 13e616
	for (i = 0; i < 16; i++)
Packit 13e616
		fprintf(fh, "| 0x%01X ",
Packit 13e616
			ib_slvl_table_get(&p_rec->slvl_tbl, (uint8_t) i));
Packit 13e616
	fprintf(fh, "|\nEND\n\n");
Packit 13e616
Packit 13e616
	/*  Exit: */
Packit 13e616
	OSM_LOG_EXIT(&p_osmt->log);
Packit 13e616
	return (status);
Packit 13e616
}
Packit 13e616
Packit 13e616
/**********************************************************************
Packit 13e616
 * GET A SINGLE PORT INFO BY NODE LID AND PORT NUMBER
Packit 13e616
 **********************************************************************/
Packit 13e616
ib_api_status_t
Packit 13e616
osmt_query_slvl_map(IN osmtest_t * const p_osmt,
Packit 13e616
		    IN ib_net16_t const lid,
Packit 13e616
		    IN uint8_t const out_port_num,
Packit 13e616
		    IN uint8_t const in_port_num, IN FILE * fh)
Packit 13e616
{
Packit 13e616
	osmtest_req_context_t context;
Packit 13e616
	ib_api_status_t status = IB_SUCCESS;
Packit 13e616
	osmv_user_query_t user;
Packit 13e616
	osmv_query_req_t req;
Packit 13e616
	ib_slvl_table_record_t record, *p_rec;
Packit 13e616
Packit 13e616
	OSM_LOG_ENTER(&p_osmt->log);
Packit 13e616
Packit 13e616
	OSM_LOG(&p_osmt->log, OSM_LOG_DEBUG,
Packit 13e616
		"Getting SLtoVL Map Table for out-port with LID 0x%X Num:0x%X from In-Port:0x%X\n",
Packit 13e616
		cl_ntoh16(lid), out_port_num, in_port_num);
Packit 13e616
Packit 13e616
	/*
Packit 13e616
	 * Do a blocking query for this record in the subnet.
Packit 13e616
	 * The result is returned in the result field of the caller's
Packit 13e616
	 * context structure.
Packit 13e616
	 *
Packit 13e616
	 * The query structures are locals.
Packit 13e616
	 */
Packit 13e616
	memset(&req, 0, sizeof(req));
Packit 13e616
	memset(&user, 0, sizeof(user));
Packit 13e616
	memset(&context, 0, sizeof(context));
Packit 13e616
Packit 13e616
	context.p_osmt = p_osmt;
Packit 13e616
Packit 13e616
	record.lid = lid;
Packit 13e616
	record.in_port_num = in_port_num;
Packit 13e616
	record.out_port_num = out_port_num;
Packit 13e616
	user.p_attr = &record;
Packit 13e616
Packit 13e616
	req.query_type = OSMV_QUERY_SLVL_BY_LID_AND_PORTS;
Packit 13e616
	req.timeout_ms = p_osmt->opt.transaction_timeout;
Packit 13e616
	req.retry_cnt = p_osmt->opt.retry_count;
Packit 13e616
	req.flags = OSM_SA_FLAGS_SYNC;
Packit 13e616
	req.query_context = &context;
Packit 13e616
	req.pfn_query_cb = osmtest_query_res_cb;
Packit 13e616
	req.p_query_input = &use;;
Packit 13e616
	req.sm_key = 0;
Packit 13e616
Packit 13e616
	if (p_osmt->opt.with_grh) {
Packit 13e616
		req.with_grh = 1;
Packit 13e616
		memcpy(&req.gid, &p_osmt->sm_port_gid, 16);
Packit 13e616
	}
Packit 13e616
Packit 13e616
	status = osmv_query_sa(p_osmt->h_bind, &req;;
Packit 13e616
Packit 13e616
	if (status != IB_SUCCESS) {
Packit 13e616
		OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0469: "
Packit 13e616
			"ib_query failed (%s)\n", ib_get_err_str(status));
Packit 13e616
		goto Exit;
Packit 13e616
	}
Packit 13e616
Packit 13e616
	status = context.result.status;
Packit 13e616
Packit 13e616
	if (status != IB_SUCCESS) {
Packit 13e616
		OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0470: "
Packit 13e616
			"ib_query failed (%s)\n", ib_get_err_str(status));
Packit 13e616
Packit 13e616
		if (status == IB_REMOTE_ERROR) {
Packit 13e616
			OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
Packit 13e616
				"Remote error = %s\n",
Packit 13e616
				ib_get_mad_status_str(osm_madw_get_mad_ptr
Packit 13e616
						      (context.result.
Packit 13e616
						       p_result_madw)));
Packit 13e616
		}
Packit 13e616
		goto Exit;
Packit 13e616
	}
Packit 13e616
Packit 13e616
	/* ok it worked */
Packit 13e616
	p_rec = osmv_get_query_result(context.result.p_result_madw, 0);
Packit 13e616
	if (fh) {
Packit 13e616
		osmtest_write_slvl_map_table(p_osmt, fh, p_rec);
Packit 13e616
	}
Packit 13e616
Packit 13e616
Exit:
Packit 13e616
	/*
Packit 13e616
	 * Return the IB query MAD to the pool as necessary.
Packit 13e616
	 */
Packit 13e616
	if (context.result.p_result_madw != NULL) {
Packit 13e616
		osm_mad_pool_put(&p_osmt->mad_pool,
Packit 13e616
				 context.result.p_result_madw);
Packit 13e616
		context.result.p_result_madw = NULL;
Packit 13e616
	}
Packit 13e616
Packit 13e616
	OSM_LOG_EXIT(&p_osmt->log);
Packit 13e616
	return (status);
Packit 13e616
}
Packit 13e616
Packit 13e616
static ib_api_status_t
Packit 13e616
osmt_query_all_ports_slvl_map(IN osmtest_t * const p_osmt, IN FILE * fh)
Packit 13e616
{
Packit 13e616
	cl_status_t status = CL_SUCCESS;
Packit 13e616
	cl_qmap_t *p_tbl;
Packit 13e616
	port_t *p_src_port;
Packit 13e616
	uint8_t in_port, anyErr = 0, num_ports;
Packit 13e616
	node_t *p_node;
Packit 13e616
	const cl_qmap_t *p_node_tbl;
Packit 13e616
Packit 13e616
	OSM_LOG_ENTER(&p_osmt->log);
Packit 13e616
Packit 13e616
	/*
Packit 13e616
	 * Go over all ports that exist in the subnet
Packit 13e616
	 * get the relevant SLtoVLs
Packit 13e616
	 */
Packit 13e616
Packit 13e616
	OSM_LOG(&p_osmt->log, OSM_LOG_VERBOSE,
Packit 13e616
		"Obtaining ALL Ports (to other ports) SLtoVL Maps\n");
Packit 13e616
Packit 13e616
	p_tbl = &p_osmt->exp_subn.port_key_tbl;
Packit 13e616
	p_node_tbl = &p_osmt->exp_subn.node_lid_tbl;
Packit 13e616
Packit 13e616
	p_src_port = (port_t *) cl_qmap_head(p_tbl);
Packit 13e616
Packit 13e616
	while (p_src_port != (port_t *) cl_qmap_end(p_tbl)) {
Packit 13e616
Packit 13e616
		/* HACK we use capability_mask to know diff a CA port from switch port */
Packit 13e616
		if (p_src_port->rec.port_info.capability_mask) {
Packit 13e616
			/* this is an hca port */
Packit 13e616
			/*  NOTE to comply we must set port number to 0 and the SA should figure it out */
Packit 13e616
			/*  since it is a CA port */
Packit 13e616
			status =
Packit 13e616
			    osmt_query_slvl_map(p_osmt, p_src_port->rec.lid, 0,
Packit 13e616
						0, fh);
Packit 13e616
			if (status != IB_SUCCESS) {
Packit 13e616
				OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0471: "
Packit 13e616
					"Failed to get Lid:0x%X In-Port:0x%X Out-Port:0x%X(%s)\n",
Packit 13e616
					cl_ntoh16(p_src_port->rec.lid), 0, 0,
Packit 13e616
					ib_get_err_str(status));
Packit 13e616
				anyErr = 1;
Packit 13e616
			}
Packit 13e616
		} else {
Packit 13e616
			/* this is a switch port */
Packit 13e616
			/* get the node */
Packit 13e616
			p_node =
Packit 13e616
			    (node_t *) cl_qmap_get(p_node_tbl,
Packit 13e616
						   p_src_port->rec.lid);
Packit 13e616
			if (p_node == (node_t *) cl_qmap_end(p_node_tbl)) {
Packit 13e616
				OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0472: "
Packit 13e616
					"Failed to get Node by Lid:0x%X\n",
Packit 13e616
					p_src_port->rec.lid);
Packit 13e616
				goto Exit;
Packit 13e616
			}
Packit 13e616
Packit 13e616
			num_ports = p_node->rec.node_info.num_ports;
Packit 13e616
Packit 13e616
			for (in_port = 1; in_port <= num_ports; in_port++) {
Packit 13e616
				status =
Packit 13e616
				    osmt_query_slvl_map(p_osmt,
Packit 13e616
							p_src_port->rec.lid,
Packit 13e616
							p_src_port->rec.
Packit 13e616
							port_num, in_port, fh);
Packit 13e616
				if (status != IB_SUCCESS) {
Packit 13e616
					OSM_LOG(&p_osmt->log, OSM_LOG_ERROR,
Packit 13e616
						"ERR 0473: "
Packit 13e616
						"Failed to get Lid:0x%X In-Port:0x%X Out-Port:0x%X (%s)\n",
Packit 13e616
						cl_ntoh16(p_src_port->rec.lid),
Packit 13e616
						p_src_port->rec.port_num,
Packit 13e616
						in_port,
Packit 13e616
						ib_get_err_str(status));
Packit 13e616
					anyErr = 1;
Packit 13e616
				}
Packit 13e616
			}
Packit 13e616
		}
Packit 13e616
Packit 13e616
		p_src_port = (port_t *) cl_qmap_next(&p_src_port->map_item);
Packit 13e616
	}
Packit 13e616
Packit 13e616
Exit:
Packit 13e616
	OSM_LOG_EXIT(&p_osmt->log);
Packit 13e616
	if (anyErr) {
Packit 13e616
		status = IB_ERROR;
Packit 13e616
	}
Packit 13e616
	return (status);
Packit 13e616
}
Packit 13e616
Packit 13e616
/*
Packit 13e616
 * Run a vl arbitration queries and sl2vl maps queries flow:
Packit 13e616
 * Good flow:
Packit 13e616
 * - for each physical port on the network - obtain the VL Arb
Packit 13e616
 * - for each CA physical port obtain its SLtoVL Map
Packit 13e616
 * - for each SW physical port (out) obtain the SLtoVL Map to each other port
Packit 13e616
 * BAD flow:
Packit 13e616
 * - Try get with multiple results
Packit 13e616
 * - Try gettable
Packit 13e616
 * - Try providing non existing port
Packit 13e616
 */
Packit 13e616
ib_api_status_t
Packit 13e616
osmt_run_slvl_and_vlarb_records_flow(IN osmtest_t * const p_osmt)
Packit 13e616
{
Packit 13e616
	ib_api_status_t status;
Packit 13e616
	FILE *fh;
Packit 13e616
	ib_net16_t test_lid;
Packit 13e616
	uint8_t lmc;
Packit 13e616
Packit 13e616
	OSM_LOG_ENTER(&p_osmt->log);
Packit 13e616
Packit 13e616
	fh = fopen("qos.txt", "w");
Packit 13e616
	if (!fh) {
Packit 13e616
		OSM_LOG(&p_osmt->log, OSM_LOG_ERROR, "ERR 0474: "
Packit 13e616
			"Failed to open file qos.txt for writing\n");
Packit 13e616
		status = IB_ERROR;
Packit 13e616
		goto Exit;
Packit 13e616
	}
Packit 13e616
Packit 13e616
	/* go over all ports in the subnet */
Packit 13e616
	status = osmt_query_all_ports_vl_arb(p_osmt, fh);
Packit 13e616
	if (status != IB_SUCCESS) {
Packit 13e616
		goto Exit;
Packit 13e616
	}
Packit 13e616
Packit 13e616
	status = osmt_query_all_ports_slvl_map(p_osmt, fh);
Packit 13e616
	if (status != IB_SUCCESS) {
Packit 13e616
		goto Exit;
Packit 13e616
	}
Packit 13e616
Packit 13e616
	/* If LMC > 0, test non base LID SA QoS Record requests */
Packit 13e616
	status =
Packit 13e616
	    osmtest_get_local_port_lmc(p_osmt, p_osmt->local_port.lid, &lmc;;
Packit 13e616
	if (status != IB_SUCCESS)
Packit 13e616
		goto Exit;
Packit 13e616
Packit 13e616
	if (lmc != 0) {
Packit 13e616
		test_lid = cl_ntoh16(p_osmt->local_port.lid + 1);
Packit 13e616
Packit 13e616
		status = osmt_query_vl_arb(p_osmt, test_lid, 0, 1, NULL);
Packit 13e616
		if (status != IB_SUCCESS)
Packit 13e616
			goto Exit;
Packit 13e616
Packit 13e616
		status = osmt_query_slvl_map(p_osmt, test_lid, 0, 0, NULL);
Packit 13e616
		if (status != IB_SUCCESS)
Packit 13e616
			goto Exit;
Packit 13e616
	}
Packit 13e616
Packit 13e616
Exit:
Packit 13e616
	if (fh)
Packit 13e616
		fclose(fh);
Packit 13e616
	OSM_LOG_EXIT(&p_osmt->log);
Packit 13e616
	return status;
Packit 13e616
}