Blame IbPrint/sma.c

Packit 857059
/* BEGIN_ICS_COPYRIGHT7 ****************************************
Packit 857059
Packit 857059
Copyright (c) 2015-2017, Intel Corporation
Packit 857059
Packit 857059
Redistribution and use in source and binary forms, with or without
Packit 857059
modification, are permitted provided that the following conditions are met:
Packit 857059
Packit 857059
    * Redistributions of source code must retain the above copyright notice,
Packit 857059
      this list of conditions and the following disclaimer.
Packit 857059
    * Redistributions in binary form must reproduce the above copyright
Packit 857059
      notice, this list of conditions and the following disclaimer in the
Packit 857059
      documentation and/or other materials provided with the distribution.
Packit 857059
    * Neither the name of Intel Corporation nor the names of its contributors
Packit 857059
      may be used to endorse or promote products derived from this software
Packit 857059
      without specific prior written permission.
Packit 857059
Packit 857059
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
Packit 857059
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
Packit 857059
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
Packit 857059
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
Packit 857059
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
Packit 857059
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
Packit 857059
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
Packit 857059
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
Packit 857059
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
Packit 857059
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Packit 857059
Packit 857059
** END_ICS_COPYRIGHT7   ****************************************/
Packit 857059
Packit 857059
/* [ICS VERSION STRING: unknown] */
Packit 857059
Packit 857059
#include <stdio.h>
Packit 857059
#include <stdlib.h>
Packit 857059
#include <unistd.h>
Packit 857059
#include <errno.h>
Packit 857059
#include <iba/ibt.h>
Packit 857059
#include <stdarg.h>
Packit 857059
#include "ibprint.h"
Packit 857059
Packit 857059
void PrintNodeDesc(PrintDest_t *dest, int indent, const NODE_DESCRIPTION *pNodeDesc)
Packit 857059
{
Packit 857059
	PrintFunc(dest, "%*s%.*s\n",
Packit 857059
			indent, "",
Packit 857059
			NODE_DESCRIPTION_ARRAY_SIZE, pNodeDesc->NodeString);
Packit 857059
}
Packit 857059
Packit 857059
void PrintNodeInfo(PrintDest_t *dest, int indent, const NODE_INFO *pNodeInfo)
Packit 857059
{
Packit 857059
	PrintFunc(dest, "%*sType: %s Ports: %d PortNum: %d PartitionCap: %d\n",
Packit 857059
				indent, "",
Packit 857059
				StlNodeTypeToText(pNodeInfo->NodeType), pNodeInfo->NumPorts,
Packit 857059
				pNodeInfo->u1.s.LocalPortNum, pNodeInfo->PartitionCap);
Packit 857059
	PrintFunc(dest, "%*sNodeGuid: 0x%016"PRIx64" PortGuid: 0x%016"PRIx64"\n",
Packit 857059
				indent, "", pNodeInfo->NodeGUID, pNodeInfo->PortGUID);
Packit 857059
	PrintFunc(dest, "%*sSystemImageGuid: 0x%016"PRIx64"\n",
Packit 857059
				indent, "", pNodeInfo->SystemImageGUID);
Packit 857059
	PrintFunc(dest, "%*sBaseVersion: %d SmaVersion: %d VendorID: 0x%x DeviceId: 0x%x Revision: 0x%x\n",
Packit 857059
				indent, "", pNodeInfo->BaseVersion,
Packit 857059
				pNodeInfo->ClassVersion, pNodeInfo->u1.s.VendorID,
Packit 857059
				pNodeInfo->DeviceID, pNodeInfo->Revision);
Packit 857059
}
Packit 857059
Packit 857059
// style=0 or 1
Packit 857059
// TBD - key off portGuid!=0 to decide style instead?
Packit 857059
void PrintPortInfo(PrintDest_t *dest, int indent, const PORT_INFO *pPortInfo, EUI64 portGuid, int style)
Packit 857059
{
Packit 857059
	char tempBuf[9];
Packit 857059
	char tempBuf2[9];
Packit 857059
	char cbuf[80];
Packit 857059
Packit 857059
	PrintFunc(dest, "%*sPortState: %-6s           PhysState: %-8s  DownDefault: %-5s\n",
Packit 857059
		indent, "",
Packit 857059
		IbPortStateToText(pPortInfo->Link.PortState),
Packit 857059
		IbPortPhysStateToText(pPortInfo->Link.PortPhysicalState),
Packit 857059
		IbPortDownDefaultToText(pPortInfo->Link.DownDefaultState));
Packit 857059
	if (style == 0) {
Packit 857059
		PrintFunc(dest, "%*sLID:    0x%04x              LMC: %u               Subnet: 0x%016"PRIx64"\n",
Packit 857059
			indent, "",
Packit 857059
			pPortInfo->LID, pPortInfo->s1.LMC, pPortInfo->SubnetPrefix);
Packit 857059
	} else {
Packit 857059
		PrintFunc(dest, "%*sLID:    0x%04x              LMC: %u\n",
Packit 857059
			indent, "", pPortInfo->LID, pPortInfo->s1.LMC);
Packit 857059
		if (portGuid) {
Packit 857059
			PrintFunc(dest, "%*sSubnet: 0x%016"PRIx64"  GUID: 0x%016"PRIx64"  GUID Cap:  %4u\n",
Packit 857059
				indent, "", pPortInfo->SubnetPrefix, portGuid, pPortInfo->GUIDCap);
Packit 857059
		} else {
Packit 857059
			PrintFunc(dest, "%*sSubnet: 0x%016"PRIx64"                            GUID Cap:  %4u\n",
Packit 857059
				indent, "", pPortInfo->SubnetPrefix, pPortInfo->GUIDCap);
Packit 857059
		}
Packit 857059
	}
Packit 857059
	FormatTimeoutMult(tempBuf, pPortInfo->Resp.TimeValue);
Packit 857059
	FormatTimeoutMult(tempBuf2, pPortInfo->Subnet.Timeout);
Packit 857059
	PrintFunc(dest, "%*sSMLID:  0x%04x   SMSL: %2u   RespTimeout: %s  SubnetTimeout: %s\n",
Packit 857059
		indent, "",
Packit 857059
		pPortInfo->MasterSMLID, pPortInfo->s2.MasterSMSL, tempBuf, tempBuf2);
Packit 857059
	PrintFunc(dest, "%*sM_KEY:  0x%016"PRIx64"  Lease: %5u s          Protect: %s\n",
Packit 857059
		indent, "", pPortInfo->M_Key, pPortInfo->M_KeyLeasePeriod,
Packit 857059
		IbMKeyProtectToText(pPortInfo->s1.M_KeyProtectBits));
Packit 857059
	PrintFunc(dest, "%*sMTU:       Active:   %5s  Supported:      %5s  VL Stall: %u\n",
Packit 857059
		indent, "", IbMTUToText(pPortInfo->s2.NeighborMTU),
Packit 857059
		IbMTUToText(pPortInfo->MTU.Cap), pPortInfo->XmitQ.VLStallCount);
Packit 857059
	PrintFunc(dest, "%*sLinkWidth: Active:    %4s  Supported:    %7s  Enabled:    %7s\n",
Packit 857059
		indent, "",
Packit 857059
		IbLinkWidthToText(pPortInfo->LinkWidth.Active),
Packit 857059
		IbLinkWidthToText(pPortInfo->LinkWidth.Supported),
Packit 857059
		IbLinkWidthToText(pPortInfo->LinkWidth.Enabled));
Packit 857059
	PrintFunc( dest, "%*sLinkSpeed: Active: %7s  Supported: %10s  Enabled: %10s\n",
Packit 857059
		indent, "",
Packit 857059
		IbLinkSpeedToText(PortDataGetLinkSpeedActiveCombined((PORT_INFO *)pPortInfo)),
Packit 857059
		IbLinkSpeedToText(PortDataGetLinkSpeedSupportedCombined((PORT_INFO *)pPortInfo)), 
Packit 857059
		IbLinkSpeedToText(PortDataGetLinkSpeedEnabledCombined((PORT_INFO *)pPortInfo)) );
Packit 857059
	if (pPortInfo->XmitQ.HOQLife > IB_LIFETIME_MAX)
Packit 857059
	{
Packit 857059
		memcpy(tempBuf, "Infinite", 9);
Packit 857059
	} else {
Packit 857059
		FormatTimeoutMult(tempBuf, pPortInfo->XmitQ.HOQLife);
Packit 857059
	}
Packit 857059
	PrintFunc(dest, "%*sVLs:       Active:    %-2d  Supported:       %-2d  HOQLife: %s\n",
Packit 857059
		indent, "",
Packit 857059
		pPortInfo->s3.OperationalVL,
Packit 857059
		pPortInfo->VL.s.Cap, tempBuf);
Packit 857059
	PrintFunc(dest, "%*sVL Arb Cap:  High:    %4u        Low:       %4u  HiLimit: %4u\n",
Packit 857059
		indent, "", pPortInfo->VL.ArbitrationHighCap,
Packit 857059
		pPortInfo->VL.ArbitrationLowCap, pPortInfo->VL.HighLimit);
Packit 857059
#if ! GUID_CAP_ALWAYS_ALONE
Packit 857059
	if (style == 0)
Packit 857059
#endif
Packit 857059
		PrintFunc(dest, "%*sGUID Cap:  %4u\n", indent, "", pPortInfo->GUIDCap);
Packit 857059
Packit 857059
	FormatCapabilityMask(cbuf, pPortInfo->CapabilityMask);
Packit 857059
	PrintFunc(dest, "%*sCapability 0x%08x: %s\n",
Packit 857059
		indent, "",
Packit 857059
		pPortInfo->CapabilityMask.AsReg32, cbuf);
Packit 857059
	PrintFunc(dest, "%*sViolations: M_Key: %5u P_Key: %5u Q_Key: %5u\n",
Packit 857059
		indent, "",
Packit 857059
		pPortInfo->Violations.M_Key, pPortInfo->Violations.P_Key,
Packit 857059
		pPortInfo->Violations.Q_Key);
Packit 857059
	PrintFunc(dest, "%*sErrorLimits: Overrun: %2u LocalPhys: %2u  DiagCode: 0x%04x\n",
Packit 857059
		indent, "",
Packit 857059
		pPortInfo->Errors.Overrun, pPortInfo->Errors.LocalPhys,
Packit 857059
		pPortInfo->DiagCode);
Packit 857059
	PrintFunc(dest, "%*sP_Key Enforcement: In: %3s Out: %3s  FilterRaw: In: %3s Out: %3s\n",
Packit 857059
		indent, "",
Packit 857059
		pPortInfo->s3.PartitionEnforcementInbound?"On":"Off",
Packit 857059
		pPortInfo->s3.PartitionEnforcementOutbound?"On":"Off",
Packit 857059
		pPortInfo->s3.FilterRawInbound?"On":"Off",
Packit 857059
		pPortInfo->s3.FilterRawOutbound?"On":"Off");
Packit 857059
}
Packit 857059
Packit 857059
void PrintPortInfoSmp(PrintDest_t *dest, int indent, const SMP *smp, EUI64 portGuid)
Packit 857059
{
Packit 857059
	const PORT_INFO* pPortInfo = (PORT_INFO *)&(smp->SmpExt.DirectedRoute.SMPData);
Packit 857059
Packit 857059
	PrintFunc(dest, "%*sPort %u Info\n", indent, "",
Packit 857059
				smp->common.AttributeModifier & 0xff);
Packit 857059
	PrintPortInfo(dest, indent+4, pPortInfo, portGuid, 1);
Packit 857059
}
Packit 857059
Packit 857059
void PrintSMInfo(PrintDest_t *dest, int indent, const SM_INFO *pSMInfo, IB_LID lid)
Packit 857059
{
Packit 857059
	if (lid)
Packit 857059
		PrintFunc(dest, "%*sLID: 0x%04x PortGuid: 0x%016"PRIx64" State: %11s\n",
Packit 857059
				indent, "", lid, pSMInfo->GUID,
Packit 857059
				IbSMStateToText(pSMInfo->s.SMState));
Packit 857059
	else
Packit 857059
		PrintFunc(dest, "%*sPortGuid: 0x%016"PRIx64" State: %11s\n",
Packit 857059
				indent, "", pSMInfo->GUID,
Packit 857059
				IbSMStateToText(pSMInfo->s.SMState));
Packit 857059
	PrintFunc(dest, "%*sSM_Key: 0x%016"PRIx64" Priority: %3d ActCount: 0x%08x\n",
Packit 857059
				indent, "", pSMInfo->SM_Key,
Packit 857059
				pSMInfo->s.Priority, pSMInfo->ActCount);
Packit 857059
}
Packit 857059
Packit 857059
void PrintSwitchInfo(PrintDest_t *dest, int indent, const SWITCH_INFO *pSwitchInfo, IB_LID lid)
Packit 857059
{
Packit 857059
	char buf[8];
Packit 857059
Packit 857059
	if (lid)
Packit 857059
		PrintFunc(dest, "%*sLID: 0x%04x\n", indent, "", lid);
Packit 857059
Packit 857059
	PrintFunc(dest, "%*sLinearFDBCap: %5u LinearFDBTop: 0x%04x MCFDBCap: %5u MCFDBTop: 0x%04x\n",
Packit 857059
			indent, "",
Packit 857059
			pSwitchInfo->LinearFDBCap, pSwitchInfo->LinearFDBTop,
Packit 857059
			pSwitchInfo->MulticastFDBCap, pSwitchInfo->MulticastFDBTop);
Packit 857059
	FormatTimeoutMult(buf, pSwitchInfo->u1.s.LifeTimeValue);
Packit 857059
	PrintFunc(dest, "%*sRandomFDBCap: %5u LIDsPerPort: %5u LifeTime: %s\n",
Packit 857059
				indent, "",
Packit 857059
				pSwitchInfo->RandomFDBCap, pSwitchInfo->LIDsPerPort, buf);
Packit 857059
	PrintFunc(dest, "%*sDefaultPort: %3u DefaultMCPrimaryPort: %3u DefaultMCNotPrimaryPort: %3u\n",
Packit 857059
				indent, "",
Packit 857059
				pSwitchInfo->DefaultPort,
Packit 857059
				pSwitchInfo->DefaultMulticastPrimaryPort,
Packit 857059
				pSwitchInfo->DefaultMulticastNotPrimaryPort);
Packit 857059
	PrintFunc(dest, "%*sCapability: 0x%02x: %s%s%s%s%s%s PartEnfCap: %5u PortStateChange: %d\n",
Packit 857059
				indent, "",
Packit 857059
				pSwitchInfo->u2.AsReg8,
Packit 857059
				pSwitchInfo->u2.s.InboundEnforcementCapable?"IE ": "",
Packit 857059
				pSwitchInfo->u2.s.OutboundEnforcementCapable?"OE ": "",
Packit 857059
				pSwitchInfo->u2.s.FilterRawPacketInboundCapable?"FI ": "",
Packit 857059
				pSwitchInfo->u2.s.FilterRawPacketOutboundCapable?"FO ": "",
Packit 857059
				pSwitchInfo->u2.s.EnhancedPort0?"E0 ": "",
Packit 857059
				pSwitchInfo->u1.s.OptimizedSLVL?"SLVL ": "",
Packit 857059
				pSwitchInfo->PartitionEnforcementCap,
Packit 857059
				pSwitchInfo->u1.s.PortStateChange);
Packit 857059
}
Packit 857059
Packit 857059
void PrintLinearFDB(PrintDest_t *dest, int indent, const FORWARDING_TABLE *pLinearFDB, uint16 blockNum)
Packit 857059
{
Packit 857059
	int i;
Packit 857059
	IB_LID baselid = blockNum*LFT_BLOCK_SIZE;
Packit 857059
Packit 857059
	for (i=0; i
Packit 857059
	{
Packit 857059
		// LID is index into overall FDB table
Packit 857059
		// 255 is invalid port, indicates an unsed table entry
Packit 857059
		if (pLinearFDB->u.Linear.LftBlock[i] != 255)
Packit 857059
			PrintFunc(dest, "%*s  LID 0x%04x -> Port %5u\n",
Packit 857059
				indent, "", baselid + i,
Packit 857059
				pLinearFDB->u.Linear.LftBlock[i]);
Packit 857059
	}
Packit 857059
}
Packit 857059
Packit 857059
void PrintRandomFDB(PrintDest_t *dest, int indent, const FORWARDING_TABLE *pRandomFDB, uint16 blockNum)
Packit 857059
{
Packit 857059
	int i;
Packit 857059
Packit 857059
	for (i=0; i
Packit 857059
	{
Packit 857059
		// Valid = 0 indicates unused table entry
Packit 857059
		if (pRandomFDB->u.Random.RftBlock[i].s.Valid)
Packit 857059
		{
Packit 857059
			IB_LID lid = pRandomFDB->u.Random.RftBlock[i].LID;
Packit 857059
			uint8 lmc = pRandomFDB->u.Random.RftBlock[i].s.LMC;
Packit 857059
			if (lmc) {
Packit 857059
				PrintFunc(dest, "%*s  LID 0x%04x-0x%04x -> Port %5u\n",
Packit 857059
					indent, "", lid, lid + (1<
Packit 857059
					pRandomFDB->u.Random.RftBlock[i].Port);
Packit 857059
			} else {
Packit 857059
				PrintFunc(dest, "%*s  LID 0x%04x -> Port %5u\n",
Packit 857059
					indent, "", lid,
Packit 857059
					pRandomFDB->u.Random.RftBlock[i].Port);
Packit 857059
			}
Packit 857059
		}
Packit 857059
	}
Packit 857059
}
Packit 857059
Packit 857059
boolean isMCastFDBEmpty(const FORWARDING_TABLE *pMCastFDB)
Packit 857059
{
Packit 857059
	int i;
Packit 857059
Packit 857059
	for (i=0; i
Packit 857059
	{
Packit 857059
		// PortMask = 0 indicates unused table entry
Packit 857059
		if (pMCastFDB->u.Multicast.MftBlock[i])
Packit 857059
			return FALSE;
Packit 857059
	}
Packit 857059
	return TRUE;
Packit 857059
}
Packit 857059
Packit 857059
void PrintMCastFDB(PrintDest_t *dest, int indent, const FORWARDING_TABLE *pMCastFDB, uint16 blockNum)
Packit 857059
{
Packit 857059
	int i;
Packit 857059
	IB_LID baselid = blockNum*MFT_BLOCK_SIZE+LID_MCAST_START;
Packit 857059
Packit 857059
	for (i=0; i
Packit 857059
	{
Packit 857059
		// PortMask = 0 indicates unused table entry
Packit 857059
		if (pMCastFDB->u.Multicast.MftBlock[i])
Packit 857059
		{
Packit 857059
			PrintFunc(dest, "%*s  LID 0x%04x -> PortMask 0x%04x\n",
Packit 857059
				indent, "", baselid+i,
Packit 857059
				pMCastFDB->u.Multicast.MftBlock[i]);
Packit 857059
		}
Packit 857059
	}
Packit 857059
}
Packit 857059
Packit 857059
void PrintMCastFDBSmp(PrintDest_t *dest, int indent, const SMP *smp)
Packit 857059
{
Packit 857059
	const FORWARDING_TABLE *pMCastFDB = (FORWARDING_TABLE *)&(smp->SmpExt.DirectedRoute.SMPData);
Packit 857059
Packit 857059
	PrintFunc(dest, "%*sPosition: %2u\n", indent, "",
Packit 857059
				smp->common.AttributeModifier >> 28);
Packit 857059
Packit 857059
	PrintMCastFDB(dest, indent, pMCastFDB, smp->common.AttributeModifier & 0x1ff);
Packit 857059
}
Packit 857059
Packit 857059
boolean isMCastFDBEmptyRows(const FORWARDING_TABLE *pMCastFDB, uint8 numPositions)
Packit 857059
{
Packit 857059
	int i;
Packit 857059
	unsigned p;
Packit 857059
Packit 857059
	for (i=0; i
Packit 857059
	{
Packit 857059
		for (p=0; p
Packit 857059
			// PortMask = 0 indicates unused table entry
Packit 857059
			if (pMCastFDB[p].u.Multicast.MftBlock[i])
Packit 857059
				return FALSE;
Packit 857059
		}
Packit 857059
	}
Packit 857059
	return TRUE;
Packit 857059
}
Packit 857059
Packit 857059
// prints full rows in table
Packit 857059
// pMcastFDB expected to be FORWARDING_TABLE[1+endPosition-startPosition] entry
Packit 857059
void PrintMCastFDBRows(PrintDest_t *dest, int indent, const FORWARDING_TABLE *pMCastFDB, uint16 blockNum, uint8 startPosition, uint8 endPosition, boolean showHeading)
Packit 857059
{
Packit 857059
	int i;
Packit 857059
	unsigned p;
Packit 857059
	IB_LID baselid = blockNum*MFT_BLOCK_SIZE+LID_MCAST_START;
Packit 857059
Packit 857059
	if (showHeading)
Packit 857059
		PrintFunc(dest, "%*sPositions: %2u - %2u\n", indent, "",
Packit 857059
				startPosition, endPosition);
Packit 857059
	for (i=0; i
Packit 857059
	{
Packit 857059
		// see if given MLID has a non-zero mask
Packit 857059
		boolean empty = TRUE;
Packit 857059
		for (p=startPosition; p<=endPosition; ++p) {
Packit 857059
			// PortMask = 0 indicates unused table entry
Packit 857059
			if (pMCastFDB[p-startPosition].u.Multicast.MftBlock[i])
Packit 857059
			{
Packit 857059
				empty = FALSE;
Packit 857059
			}
Packit 857059
		}
Packit 857059
		if (! empty) {
Packit 857059
			char buf[80];
Packit 857059
			int offset;
Packit 857059
			offset = sprintf(buf, "  LID 0x%04x -> PortMask 0x", baselid+i);
Packit 857059
			// show the combined mask, MSb to LSb
Packit 857059
			p=endPosition;
Packit 857059
			do {
Packit 857059
				offset += sprintf(&buf[offset], "%04x", pMCastFDB[p-startPosition].u.Multicast.MftBlock[i]);
Packit 857059
			} while (p-- != startPosition);
Packit 857059
			PrintFunc(dest, "%*s%s\n", indent, "", buf);
Packit 857059
Packit 857059
			// show the list of ports that Mask corresponds to
Packit 857059
			offset = sprintf(buf, "                Ports:");
Packit 857059
			for (p=startPosition; p<=endPosition; ++p) {
Packit 857059
				PORTMASK mask = pMCastFDB[p-startPosition].u.Multicast.MftBlock[i];
Packit 857059
				if (mask) {
Packit 857059
					uint8 bit;
Packit 857059
					for (bit=0; bit
Packit 857059
						if (mask & (1<
Packit 857059
							if (offset > 70) {
Packit 857059
								PrintFunc(dest, "%*s%s\n", indent, "", buf);
Packit 857059
								offset = sprintf(buf, "                      ");
Packit 857059
							}
Packit 857059
							offset += sprintf(&buf[offset], " %3u", p*MFT_BLOCK_WIDTH+bit);
Packit 857059
						}
Packit 857059
					}
Packit 857059
				}
Packit 857059
			}
Packit 857059
			PrintFunc(dest, "%*s%s\n", indent, "", buf);
Packit 857059
		}
Packit 857059
	}
Packit 857059
}
Packit 857059
Packit 857059
void PrintVLArbTable(PrintDest_t *dest, int indent, const VLARBTABLE *pVLArbTable, uint8 blockNum)
Packit 857059
{
Packit 857059
	uint8 base_index = 0;
Packit 857059
	int i;
Packit 857059
Packit 857059
	if (blockNum == 2 || blockNum == 4)
Packit 857059
		base_index = IB_VLARBTABLE_SIZE;
Packit 857059
	PrintFunc(dest, "%*s  Indx VL Weight\n", indent, "");
Packit 857059
	for (i=0; i
Packit 857059
	{
Packit 857059
		// zero weight is a disabled entry
Packit 857059
		if (pVLArbTable->ArbTable[i].Weight)
Packit 857059
		{
Packit 857059
			PrintFunc(dest, "%*s   %2d  %2u  %3u\n",
Packit 857059
				indent, "", base_index+i,
Packit 857059
				pVLArbTable->ArbTable[i].s.VL,
Packit 857059
				pVLArbTable->ArbTable[i].Weight);
Packit 857059
		}
Packit 857059
	}
Packit 857059
}
Packit 857059
Packit 857059
void PrintVLArbTableSmp(PrintDest_t *dest, int indent, const SMP *smp, NODE_TYPE nodetype)
Packit 857059
{
Packit 857059
	VLARBTABLE *pVLArbTable = (VLARBTABLE *)&(smp->SmpExt.DirectedRoute.SMPData);
Packit 857059
	char buf[40] = "";
Packit 857059
	uint32 block = smp->common.AttributeModifier >> 16;
Packit 857059
Packit 857059
	if (nodetype == STL_NODE_SW) {
Packit 857059
Packit 857059
		sprintf(buf, "OutputPort: %3u ", smp->common.AttributeModifier  & 0xffff);
Packit 857059
	}
Packit 857059
	PrintFunc(dest, "%*s%sBlockNum: %2u (%s)\n", indent, "",
Packit 857059
					buf, block,
Packit 857059
					block == 1?"Low Pri lower":
Packit 857059
					block == 2?"Low Pri upper":
Packit 857059
					block == 3?"High Pri lower":
Packit 857059
					block == 4?"High Pri upper":
Packit 857059
					"Unknown"
Packit 857059
					);
Packit 857059
	PrintVLArbTable(dest, indent, pVLArbTable, block);
Packit 857059
}
Packit 857059
Packit 857059
void PrintPKeyTable(PrintDest_t *dest, int indent, const PARTITION_TABLE *pPKeyTable, uint16 blockNum)
Packit 857059
{
Packit 857059
	uint16 i;
Packit 857059
	char buf[81];
Packit 857059
	int offset=0;
Packit 857059
	uint16 index = blockNum*PARTITION_TABLE_BLOCK_SIZE;
Packit 857059
Packit 857059
	// 8 entries per line
Packit 857059
	for (i=0; i
Packit 857059
	{
Packit 857059
		if (i%8 == 0) {
Packit 857059
			if (i)
Packit 857059
				PrintFunc(dest, "%*s%s\n", indent, "", buf);
Packit 857059
			offset=sprintf(buf, "   %4u-%4u:", i+index, i+7+index);
Packit 857059
		}
Packit 857059
		offset+=sprintf(&buf[offset], "  0x%04x", pPKeyTable->PartitionTableBlock[i].AsInt16);
Packit 857059
	}
Packit 857059
	PrintFunc(dest, "%*s%s\n", indent, "", buf);
Packit 857059
}
Packit 857059
Packit 857059
void PrintPKeyTableSmp(PrintDest_t *dest, int indent, const SMP *smp, NODE_TYPE nodetype, boolean showHeading, boolean showBlock)
Packit 857059
{
Packit 857059
	PARTITION_TABLE *pPKeyTable = (PARTITION_TABLE *)&(smp->SmpExt.DirectedRoute.SMPData);
Packit 857059
	char buf[40] = "";
Packit 857059
	uint32 block = smp->common.AttributeModifier & 0xffff;
Packit 857059
Packit 857059
	if (showHeading) {
Packit 857059
		if (nodetype == STL_NODE_SW)
Packit 857059
			sprintf(buf, "OutputPort: %3u ", smp->common.AttributeModifier >> 16);
Packit 857059
		if (showBlock)
Packit 857059
			PrintFunc(dest, "%*s%sBlockNum: %2u\n", indent, "", buf, block);
Packit 857059
		else if (buf[0])
Packit 857059
			PrintFunc(dest, "%*s%s\n", indent, "", buf);
Packit 857059
	}
Packit 857059
	PrintPKeyTable(dest, indent, pPKeyTable, block);
Packit 857059
}
Packit 857059
Packit 857059
void PrintGuidInfo(PrintDest_t *dest, int indent, const GUID_INFO *pGuidInfo, uint8 blockNum)
Packit 857059
{
Packit 857059
	int i;
Packit 857059
	char buf[81];
Packit 857059
	int offset=0;
Packit 857059
	uint16 index = blockNum*GUID_INFO_BLOCK_SIZE;
Packit 857059
Packit 857059
	// 2 entries per line
Packit 857059
	for (i=0; i
Packit 857059
	{
Packit 857059
		if (i%2 == 0) {
Packit 857059
			if (i)
Packit 857059
				PrintFunc(dest, "%*s%s\n", indent, "", buf);
Packit 857059
			offset=sprintf(buf, "   %4u-%4u:", i+index, i+1+index);
Packit 857059
		}
Packit 857059
		offset+=sprintf(&buf[offset], "  0x%016"PRIx64"", pGuidInfo->Gid[i]);
Packit 857059
	}
Packit 857059
	PrintFunc(dest, "%*s%s\n", indent, "", buf);
Packit 857059
}
Packit 857059
Packit 857059
void PrintPortGroupTable(PrintDest_t *dest, int indent, const PORT_GROUP_TABLE *pPortGroup, uint16 tier, uint16 blockNum)
Packit 857059
{
Packit 857059
	int i;
Packit 857059
	uint baseport = (blockNum & 0xff)*PGTABLE_LIST_COUNT;
Packit 857059
Packit 857059
	PrintFunc(dest, "%*s Adaptive Routing Port Group (Tier= %d):\n", indent, "", tier);
Packit 857059
	for (i=0; i
Packit 857059
	{
Packit 857059
		// zero is invalid port group id, indicates an unused table entry
Packit 857059
		if (pPortGroup->PortGroup[i] != 0) {
Packit 857059
			PrintFunc(dest, "%*s  Port %5u -> PortGroup %5u\n",
Packit 857059
				indent, "", baseport + i,
Packit 857059
				pPortGroup->PortGroup[i]);
Packit 857059
		}
Packit 857059
	}
Packit 857059
}
Packit 857059
Packit 857059
void PrintAdaptiveRoutingLidmask(PrintDest_t *dest, int indent, const ADAPTIVE_ROUTING_LIDMASK *pLidmask, uint16 blockNum)
Packit 857059
{
Packit 857059
	char	string[256];
Packit 857059
	char	str[32];
Packit 857059
	int		i,j;
Packit 857059
	uint8_t	lidmask;
Packit 857059
 	IB_LID	curlid;
Packit 857059
 	IB_LID  baselid = blockNum*(LIDMASK_LEN*8);
Packit 857059
	int		firstdone = 0;
Packit 857059
	int		first = 0;
Packit 857059
	int		next = 0;
Packit 857059
Packit 857059
	string[0] = '\0';
Packit 857059
	for (i=LIDMASK_LEN-1; i>=0; i--)
Packit 857059
	{ 
Packit 857059
		if (pLidmask->lidmask[i]) {
Packit 857059
			lidmask = pLidmask->lidmask[i];
Packit 857059
			for (j=0; j<8; j++) {
Packit 857059
				if (lidmask & (1<
Packit 857059
					if (strlen(string) > 80) {
Packit 857059
						strcat(string, ",");
Packit 857059
						PrintFunc(dest, "%*s %s\n", indent, "", string);
Packit 857059
						string[0] = '\0';
Packit 857059
						firstdone = 0;
Packit 857059
					}
Packit 857059
					curlid = baselid+j;
Packit 857059
					if (!first) {
Packit 857059
						first = curlid;
Packit 857059
					} else if (!next) {
Packit 857059
						if (curlid - first > 1) {
Packit 857059
							if (!firstdone) {
Packit 857059
								sprintf(str, "0x%x", first);
Packit 857059
								firstdone = 1;
Packit 857059
							} else {
Packit 857059
                                sprintf(str, ",0x%x", first);
Packit 857059
							}
Packit 857059
							strcat(string, str);
Packit 857059
							first = curlid;
Packit 857059
						} else {
Packit 857059
							next = curlid;
Packit 857059
						}
Packit 857059
					} else {
Packit 857059
						if (curlid - next > 1) {
Packit 857059
							if (!firstdone) {
Packit 857059
								sprintf(str, "0x%x-0x%x", first, next);
Packit 857059
								firstdone = 1;
Packit 857059
							} else {
Packit 857059
								sprintf(str, ",0x%x-0x%x", first, next);
Packit 857059
							}
Packit 857059
							strcat(string, str);
Packit 857059
							first = curlid;
Packit 857059
							next = 0;
Packit 857059
						} else {
Packit 857059
							next = curlid;
Packit 857059
						}
Packit 857059
					}
Packit 857059
				}
Packit 857059
			}
Packit 857059
		}
Packit 857059
		baselid+=8;
Packit 857059
	}
Packit 857059
Packit 857059
	if (first) {
Packit 857059
		if (!firstdone) {
Packit 857059
			sprintf(str, "0x%x", first);
Packit 857059
			strcat(string, str);
Packit 857059
		} else {
Packit 857059
			sprintf(str, ",0x%x", first);
Packit 857059
			strcat(string, str);
Packit 857059
		}
Packit 857059
		if (next) {
Packit 857059
			sprintf(str, "-0x%x", next);
Packit 857059
			strcat(string, str);
Packit 857059
		}
Packit 857059
	}
Packit 857059
	if (strlen(string) > 0) {
Packit 857059
		PrintFunc(dest, "%*s %s\n", indent, "", string);
Packit 857059
	}
Packit 857059
}
Packit 857059
Packit 857059
void PrintSmp(PrintDest_t *dest, int indent, const SMP *smp)
Packit 857059
{
Packit 857059
	PrintSmpHeader(dest, indent, smp);
Packit 857059
	switch (smp->common.AttributeID) {
Packit 857059
	case MCLASS_ATTRIB_ID_NODE_DESCRIPTION:
Packit 857059
		PrintNodeDesc(dest, indent, (const NODE_DESCRIPTION *)&smp->SmpExt.DirectedRoute.SMPData);
Packit 857059
		break;
Packit 857059
	case MCLASS_ATTRIB_ID_NODE_INFO:
Packit 857059
		PrintNodeInfo(dest, indent, (const NODE_INFO *)&smp->SmpExt.DirectedRoute.SMPData);
Packit 857059
		break;
Packit 857059
	case MCLASS_ATTRIB_ID_SWITCH_INFO:
Packit 857059
		PrintSwitchInfo(dest, indent, (const SWITCH_INFO *)&smp->SmpExt.DirectedRoute.SMPData, 0);
Packit 857059
		break;
Packit 857059
	case MCLASS_ATTRIB_ID_GUID_INFO:
Packit 857059
		PrintGuidInfo(dest, indent, (const GUID_INFO *)&smp->SmpExt.DirectedRoute.SMPData, smp->common.AttributeModifier);
Packit 857059
		break;
Packit 857059
	case MCLASS_ATTRIB_ID_PORT_INFO:
Packit 857059
		PrintPortInfoSmp(dest, indent, smp, 0);
Packit 857059
		break;
Packit 857059
	case MCLASS_ATTRIB_ID_PART_TABLE:
Packit 857059
		PrintPKeyTableSmp(dest, indent, smp,
Packit 857059
			(smp->common.AttributeModifier >> 16)?STL_NODE_SW:0, TRUE, TRUE);
Packit 857059
		break;
Packit 857059
	case MCLASS_ATTRIB_ID_VL_ARBITRATION:
Packit 857059
		PrintVLArbTableSmp(dest, indent, smp, 
Packit 857059
			(smp->common.AttributeModifier &0xffff)?STL_NODE_SW:0);
Packit 857059
		break;
Packit 857059
	case MCLASS_ATTRIB_ID_LINEAR_FWD_TABLE:
Packit 857059
		PrintLinearFDB(dest, indent,
Packit 857059
				(const FORWARDING_TABLE *)&smp->SmpExt.DirectedRoute.SMPData,
Packit 857059
				smp->common.AttributeModifier & 0xffff);
Packit 857059
		break;
Packit 857059
	case MCLASS_ATTRIB_ID_RANDOM_FWD_TABLE:
Packit 857059
		PrintRandomFDB(dest, indent,
Packit 857059
				(const FORWARDING_TABLE *)&smp->SmpExt.DirectedRoute.SMPData,
Packit 857059
				smp->common.AttributeModifier);
Packit 857059
		break;
Packit 857059
	case MCLASS_ATTRIB_ID_MCAST_FWD_TABLE:
Packit 857059
		PrintMCastFDBSmp(dest, indent, smp);
Packit 857059
		break;
Packit 857059
	case MCLASS_ATTRIB_ID_SM_INFO:
Packit 857059
		PrintSMInfo(dest, indent, (const SM_INFO *)&smp->SmpExt.DirectedRoute.SMPData, 0);
Packit 857059
		break;
Packit 857059
	case MCLASS_ATTRIB_ID_VENDOR_DIAG:
Packit 857059
		// TBD Hex Dump
Packit 857059
		break;
Packit 857059
	case MCLASS_ATTRIB_ID_LED_INFO:
Packit 857059
		// TBD Hex Dump
Packit 857059
		break;
Packit 857059
	case MCLASS_ATTRIB_ID_PORT_LFT:
Packit 857059
		PrintLinearFDB(dest, indent,
Packit 857059
				(const FORWARDING_TABLE *)&smp->SmpExt.DirectedRoute.SMPData,
Packit 857059
				smp->common.AttributeModifier & 0xffff);
Packit 857059
		break;
Packit 857059
	case MCLASS_ATTRIB_ID_PORT_GROUP:
Packit 857059
		PrintPortGroupTable(dest, indent, 
Packit 857059
			(const PORT_GROUP_TABLE *)&smp->SmpExt.DirectedRoute.SMPData,
Packit 857059
			smp->common.AttributeModifier >>16,
Packit 857059
			smp->common.AttributeModifier & 0xffff);
Packit 857059
		break;
Packit 857059
	case MCLASS_ATTRIB_ID_AR_LIDMASK:
Packit 857059
		PrintAdaptiveRoutingLidmask(dest, indent, 
Packit 857059
			(const ADAPTIVE_ROUTING_LIDMASK *)&smp->SmpExt.DirectedRoute.SMPData,
Packit 857059
			//smp->common.AttributeModifier >>17,
Packit 857059
			smp->common.AttributeModifier & 0xffff);
Packit 857059
		break;
Packit 857059
	default:
Packit 857059
		// TBD Hex Dump
Packit 857059
		break;
Packit 857059
	}
Packit 857059
}