void QsfpModule::getCableInfo(Cable &cable) { cable.transmitterTech = getQsfpTransmitterTechnology(); cable.__isset.transmitterTech = true; cable.singleMode = getQsfpCableLength(SffField::LENGTH_SM_KM); cable.__isset.singleMode = (cable.singleMode != 0); cable.om3 = getQsfpCableLength(SffField::LENGTH_OM3); cable.__isset.om3 = (cable.om3 != 0); cable.om2 = getQsfpCableLength(SffField::LENGTH_OM2); cable.__isset.om2 = (cable.om2 != 0); cable.om1 = getQsfpCableLength(SffField::LENGTH_OM1); cable.__isset.om1 = (cable.om1 != 0); cable.copper = getQsfpCableLength(SffField::LENGTH_COPPER); cable.__isset.copper = (cable.copper != 0); if (!cable.__isset.copper) { // length and gauge fields currently only supported for copper // TODO: migrate all cable types return; } auto overrideDacCableInfo = getDACCableOverride(); if (overrideDacCableInfo) { cable.length = overrideDacCableInfo->first; cable.gauge = overrideDacCableInfo->second; } else { cable.length = getQsfpDACLength(); cable.gauge = getQsfpDACGauge(); } cable.__isset.length = (cable.length != 0); cable.__isset.gauge = (cable.gauge != 0); }
double QsfpModule::getQsfpDACLength() const { auto base = getQsfpCableLength(SffField::LENGTH_COPPER); auto fractional = getQsfpCableLength(SffField::LENGTH_COPPER_DECIMETERS); if (fractional < 0) { // fractional value not populated, fall back to integer value return base; } else if (fractional >= 1) { // some vendors misunderstood and expressed the full length in terms of dm return fractional; } else { return base + fractional; } }
bool QsfpModule::getCableInfo(Cable &cable) { cable.singleMode = getQsfpCableLength(SffField::LENGTH_SM_KM); cable.__isset.singleMode = (cable.singleMode != 0); cable.om3 = getQsfpCableLength(SffField::LENGTH_OM3); cable.__isset.om3 = (cable.om3 != 0); cable.om2 = getQsfpCableLength(SffField::LENGTH_OM2); cable.__isset.om2 = (cable.om2 != 0); cable.om1 = getQsfpCableLength(SffField::LENGTH_OM1); cable.__isset.om1 = (cable.om1 != 0); cable.copper = getQsfpCableLength(SffField::LENGTH_COPPER); cable.__isset.copper = (cable.copper != 0); return (cable.__isset.copper || cable.__isset.om1 || cable.__isset.om2 || cable.__isset.om3 || cable.__isset.singleMode); }