diff --git a/Makefile.am b/Makefile.am index e8600a3..07472ff 100644 --- a/Makefile.am +++ b/Makefile.am @@ -13,10 +13,8 @@ AM_CFLAGS = -std=c99 -Wno-override-init \ -DFM_SUPPORT_FM10000 \ -DINSTRUMENT_LOG_LEVEL=0 \ - -DPLATFORM_FIRST_FOCALPOINT=0 \ - -DPLATFORM_NUM_FOCALPOINTS=1 \ -D_GNU_SOURCE \ - -Lsrc/.libs/ -lFocalpointSDK -lm -lpthread -ldl -lrt \ + -Lsrc/.libs/ -lFocalpointSDK -lm -lpthread -lrt \ -I$(top_srcdir)/include \ -I$(top_srcdir)/include/alos/linux \ -I$(top_srcdir)/include/std/intel \ diff --git a/include/api/internal/fm10000/fm10000_api_port_int.h b/include/api/internal/fm10000/fm10000_api_port_int.h index 8547a1b..67e88dd 100644 --- a/include/api/internal/fm10000/fm10000_api_port_int.h +++ b/include/api/internal/fm10000/fm10000_api_port_int.h @@ -161,7 +161,7 @@ typedef enum #define FM10000_ETHERNET_MODE_CONFIG_PAUSE 100000000 /* From EAS MAC_CFG.TxFcsMode */ -enum +typedef enum { FM10000_FCS_PASSTHRU = 0, FM10000_FCS_PASSTHRU_CHECK, diff --git a/include/platforms/libertyTrail/platform_lib_api.h b/include/platforms/libertyTrail/platform_lib_api.h index 9824022..bae9317 100644 --- a/include/platforms/libertyTrail/platform_lib_api.h +++ b/include/platforms/libertyTrail/platform_lib_api.h @@ -50,6 +50,12 @@ typedef enum /** Bus to transceiver state */ FM_PLAT_BUS_XCVR_STATE, + FM_PLAT_BUS_UNKNOWN_4, + FM_PLAT_BUS_UNKNOWN_5, + FM_PLAT_BUS_UNKNOWN_6, + FM_PLAT_BUS_UNKNOWN_7, + FM_PLAT_BUS_UNKNOWN_8, + /** Bus to transceiver eeprom */ FM_PLAT_BUS_PHY, diff --git a/src/Makefile.am b/src/Makefile.am index 8f2cad3..840b0c9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -13,8 +13,6 @@ AM_CFLAGS = -std=c99 -Wno-override-init \ -DFM_SUPPORT_FM10000 \ -DINSTRUMENT_LOG_LEVEL=0 \ - -DPLATFORM_FIRST_FOCALPOINT=0 \ - -DPLATFORM_NUM_FOCALPOINTS=1 \ -D_GNU_SOURCE \ -I$(top_srcdir)/include \ -I$(top_srcdir)/include/alos \ @@ -26,8 +24,8 @@ AM_CFLAGS = -std=c99 lib_LTLIBRARIES = libFocalpointSDK.la -libFocalpointSDK_la_LDFLAGS = -release `cd $(top_srcdir) ; ./version.sh` -libFocalpointSDK_la_LIBADD = -ldl +libFocalpointSDK_la_LDFLAGS = -avoid-version +libFocalpointSDK_la_LIBADD = -lrt libFocalpointSDK_la_LDFLAGS += -Wl,-Ttext-segment=0x08000000 -shared -fPIC libFocalpointSDK_la_SOURCES = \ @@ -233,7 +231,7 @@ platforms/util/retimer/fm_util_gn2412.c lib_LTLIBRARIES += libLTStdPlatform.la -libLTStdPlatform_la_LDFLAGS = -release `cd $(top_srcdir) ; ./version.sh` +libLTStdPlatform_la_LDFLAGS = -avoid-version libLTStdPlatform_la_LDFLAGS += -Wl,-Ttext-segment=0x09600000 -shared -fPIC libLTStdPlatform_la_LIBADD = libFocalpointSDK.la diff --git a/src/api/fm10000/fm10000_api_i2c.c b/src/api/fm10000/fm10000_api_i2c.c index eac2cfa..6c8f542 100644 --- a/src/api/fm10000/fm10000_api_i2c.c +++ b/src/api/fm10000/fm10000_api_i2c.c @@ -129,7 +129,7 @@ static fm_status I2cWriteRead(fm_int sw, status = switchPtr->WriteUINT32(sw, FM10000_I2C_DATA(i), regValue); FM_LOG_EXIT_ON_ERR(FM_LOG_CAT_SWITCH, status); - FM_LOG_DEBUG_VERBOSE(FM_LOG_CAT_SWITCH, "WRITEDATA#%d : 0x%08x\n",i, regValue); + FM_LOG_DEBUG_VERBOSE(FM_LOG_CAT_SWITCH, "WRITEDATA#%d : 0x%08x\n",i, regValue); } regValue = 0; diff --git a/src/api/fm10000/fm10000_api_port.c b/src/api/fm10000/fm10000_api_port.c index 4dbceeb..81c03df 100644 --- a/src/api/fm10000/fm10000_api_port.c +++ b/src/api/fm10000/fm10000_api_port.c @@ -12232,7 +12232,7 @@ fm_status fm10000SetPortState( fm_int sw, portExt->eventInfo.info.admin.submode = submode; eventInfo.smType = portExt->smType; - eventInfo.srcSmType = 0; + eventInfo.srcSmType = 0; /* map the desired mode to the port-level state machine event ID */ switch ( mode ) diff --git a/src/api/fm10000/fm10000_api_sched.c b/src/api/fm10000/fm10000_api_sched.c index f843fda..d9448a7 100644 --- a/src/api/fm10000/fm10000_api_sched.c +++ b/src/api/fm10000/fm10000_api_sched.c @@ -2549,10 +2549,10 @@ ABORT: *****************************************************************************/ static void FreeStatEntry(void *ptr) { - if (ptr != NULL) - { - fmFree(ptr); - } + if (ptr != NULL) + { + fmFree(ptr); + } } /* end FreeStatEntry */ @@ -2572,10 +2572,10 @@ static void FreeStatEntry(void *ptr) *****************************************************************************/ static void FreeSchedEntryInfo(void *ptr) { - if (ptr != NULL) - { - fmFree(ptr); - } + if (ptr != NULL) + { + fmFree(ptr); + } } /* end FreeSchedEntryInfo */ diff --git a/src/api/fm10000/fm10000_api_serdes_actions.c b/src/api/fm10000/fm10000_api_serdes_actions.c index dba4e67..85278fa 100644 --- a/src/api/fm10000/fm10000_api_serdes_actions.c +++ b/src/api/fm10000/fm10000_api_serdes_actions.c @@ -578,17 +578,17 @@ fm_status fm10000SerDesStopErrorValidationTimer(fm_smEventInfo *eventInfo, void *userInfo) { fm10000_lane *pLaneExt; - fm_int serDes; + fm_int serDes; FM_NOT_USED(eventInfo); pLaneExt = ((fm10000_serDesSmEventInfo *)userInfo)->laneExt; - serDes = pLaneExt->serDes; + serDes = pLaneExt->serDes; - FM_LOG_DEBUG(FM_LOG_CAT_SERDES, - "SerDes %d Stop Error Validation Timer\n", - serDes); + FM_LOG_DEBUG(FM_LOG_CAT_SERDES, + "SerDes %d Stop Error Validation Timer\n", + serDes); return fmStopTimer( pLaneExt->timerHandleErrorValidation ); } diff --git a/src/api/fm10000/fm10000_api_vn.c b/src/api/fm10000/fm10000_api_vn.c index a923e99..4378d15 100644 --- a/src/api/fm10000/fm10000_api_vn.c +++ b/src/api/fm10000/fm10000_api_vn.c @@ -6004,7 +6004,7 @@ fm_status fm10000GetVNRemoteAddressList(fm_int sw, fm_customTreeIterator iter; fm10000_vnRemoteAddress *addrKey; fm10000_vnRemoteAddress *addrRec; - fm_int i; + fm_int i; FM_LOG_ENTRY( FM_LOG_CAT_VN, "sw = %d, vn = %p, maxAddresses = %d, numAddresses = %p, " @@ -6253,7 +6253,7 @@ fm_status fm10000GetVNRemoteAddressMaskList(fm_int sw, fm_customTreeIterator iter; fm10000_vnRemoteAddressMask *ruleKey; fm10000_vnRemoteAddressMask *addressMask; - fm_int i; + fm_int i; FM_LOG_ENTRY( FM_LOG_CAT_VN, "sw = %d, vn = %p, maxAddrMasks = %d, numAddrMasks = %p, " @@ -6724,7 +6724,7 @@ fm_status fm10000GetVNConfiguration(fm_int sw, fm_vnConfiguration *config) FM_LOG_ENTRY(FM_LOG_CAT_VN, "sw = %d, config = %p\n", sw, (void *) config); switchExt = GET_SWITCH_EXT(sw); - config->outerTTL = switchExt->vnOuterTTL; + config->outerTTL = switchExt->vnOuterTTL; config->deepInspectionCfgIndex = switchExt->vnDeepInspectionCfgIndex; FM_CLEAR(chksumCfg); @@ -7194,7 +7194,7 @@ fm_status fm10000GetVNLocalPortList(fm_int sw, fm10000_virtualNetwork *vnExt; fm_mcastGroupListener listener; fm_mcastGroupListener prevListener; - fm_int i; + fm_int i; FM_LOG_ENTRY( FM_LOG_CAT_VN, "sw = %d, vn = %p, maxPorts = %d, numPorts = %p, " @@ -7215,11 +7215,11 @@ fm_status fm10000GetVNLocalPortList(fm_int sw, { if (listener.listenerType == FM_MCAST_GROUP_LISTENER_PORT_VLAN) { - if (i >= maxPorts) - { + if (i >= maxPorts) + { status = FM_ERR_BUFFER_FULL; break; - } + } portList[i++] = listener.info.portVlanListener.port; } @@ -7297,7 +7297,7 @@ fm_status fm10000GetVNLocalPortFirst(fm_int sw, if (listener.listenerType == FM_MCAST_GROUP_LISTENER_PORT_VLAN) { *port = listener.info.portVlanListener.port; - break; + break; } status = fmGetMcastGroupListenerNextV2(sw, @@ -7370,7 +7370,7 @@ fm_status fm10000GetVNLocalPortNext(fm_int sw, if (listener.listenerType == FM_MCAST_GROUP_LISTENER_PORT_VLAN) { *port = listener.info.portVlanListener.port; - break; + break; } } @@ -7635,7 +7635,7 @@ fm_status fm10000GetVNVsiList(fm_int sw, { fm_status status; fm10000_switch *switchExt; - fm_int vsi; + fm_int vsi; fm_int i; FM_LOG_ENTRY( FM_LOG_CAT_VN, @@ -7644,18 +7644,18 @@ fm_status fm10000GetVNVsiList(fm_int sw, status = FM_OK; switchExt = GET_SWITCH_EXT(sw); - i = 0; + i = 0; for (vsi = 0; vsi < FM10000_TE_VNI_ENTRIES_0; vsi++) { if ( (switchExt->vnVsi[vsi] != NULL) && (switchExt->vnVsi[vsi]->vsId == vni) ) { - if (i >= maxVsis) - { + if (i >= maxVsis) + { status = FM_ERR_BUFFER_FULL; break; - } + } vsiList[i++] = vsi; } @@ -7714,7 +7714,7 @@ fm_status fm10000GetVNVsiFirst(fm_int sw, { *vsi = i; status = FM_OK; - break; + break; } } @@ -7773,10 +7773,10 @@ fm_status fm10000GetVNVsiNext(fm_int sw, status = FM_ERR_NO_MORE; - if (*searchToken == (FM10000_TE_VNI_ENTRIES_0 - 1)) - { + if (*searchToken == (FM10000_TE_VNI_ENTRIES_0 - 1)) + { FM_LOG_EXIT(FM_LOG_CAT_VN, status); - } + } for (i = (*searchToken + 1); i < FM10000_TE_VNI_ENTRIES_0; i++) { @@ -7785,7 +7785,7 @@ fm_status fm10000GetVNVsiNext(fm_int sw, { *vsi = i; status = FM_OK; - break; + break; } } @@ -8096,7 +8096,7 @@ fm_status fm10000DbgDumpVN(fm_int sw) (void *) aclRule->vn, aclRule->vn->vsId); FM_LOG_PRINT(" tunnel: %p (tunnelId: %d)\n", (void *) aclRule->tunnel, aclRule->tunnel->tunnelId); - cnt++; + cnt++; } if (cnt == 0) { @@ -8111,10 +8111,10 @@ fm_status fm10000DbgDumpVN(fm_int sw) FM_LOG_PRINT("\n VSI %d: vn %p (vsId %d)\n", i, (void *) switchExt->vnVsi[i], switchExt->vnVsi[i]->vsId); - cnt++; + cnt++; } } - if (cnt == 0) + if (cnt == 0) { FM_LOG_PRINT(" [none]\n"); } @@ -8246,14 +8246,14 @@ fm_status fm10000DbgDumpVirtualNetwork(fm_int sw, fm_uint32 vni) } FM_LOG_PRINT(" Address: %s, Address Mask: ", tempString1); - if (addrRec->addrMask == NULL) - { + if (addrRec->addrMask == NULL) + { FM_LOG_PRINT("NULL\n"); - } - else - { + } + else + { FM_LOG_PRINT("%s / %s\n", tempString2, tempString3); - } + } FM_LOG_PRINT(" tunnelId: %d (tunnel: %p)\n", addrRec->tunnel->tunnelId, (void *) addrRec->tunnel); @@ -8294,7 +8294,7 @@ fm_status fm10000DbgDumpVirtualNetwork(fm_int sw, fm_uint32 vni) { FM_LOG_PRINT(" vsi %d: %d\n", i, addrRec->encapTunnelRules[i]); - cnt2++; + cnt2++; } } if (cnt2 == 0) @@ -8303,7 +8303,7 @@ fm_status fm10000DbgDumpVirtualNetwork(fm_int sw, fm_uint32 vni) } } - cnt++; + cnt++; } if (cnt == 0) { @@ -8372,7 +8372,7 @@ fm_status fm10000DbgDumpVirtualNetwork(fm_int sw, fm_uint32 vni) addrMaskRule->encapTep->encapTunnelRule); } - cnt++; + cnt++; } if (cnt == 0) { @@ -8405,7 +8405,7 @@ fm_status fm10000DbgDumpVirtualNetwork(fm_int sw, fm_uint32 vni) (void *) tunnelUseCount->tunnel, tunnelUseCount->useCount); - cnt++; + cnt++; } if (cnt == 0) { @@ -8568,7 +8568,7 @@ fm_status fm10000DbgDumpVNTunnel(fm_int sw, fm_int tunnelId) tepRule->encapTunnelRule, tepRule->useCount, (void *) tepRule->vn, tepRule->vn->vsId); - cnt++; + cnt++; } if (cnt == 0) { diff --git a/src/api/fm_api_routing.c b/src/api/fm_api_routing.c index 4ffd941..25c2f10 100644 --- a/src/api/fm_api_routing.c +++ b/src/api/fm_api_routing.c @@ -1419,12 +1419,12 @@ fm_status fmRouterCleanup(fm_int sw) **************************************************/ if ( fmCustomTreeIsInitialized(&switchPtr->routeTree) ) { - fmCustomTreeDestroy(&switchPtr->routeTree, DestroyRecord); + fmCustomTreeDestroy(&switchPtr->routeTree, DestroyRecord); } if ( fmCustomTreeIsInitialized(&switchPtr->ecmpRouteTree) ) { - fmCustomTreeDestroy(&switchPtr->ecmpRouteTree, NULL); + fmCustomTreeDestroy(&switchPtr->ecmpRouteTree, NULL); } FM_LOG_EXIT(FM_LOG_CAT_ROUTING, FM_OK); diff --git a/src/debug/fm10000/fm10000_debug_regs.c b/src/debug/fm10000/fm10000_debug_regs.c index 18d5073..17fad68 100644 --- a/src/debug/fm10000/fm10000_debug_regs.c +++ b/src/debug/fm10000/fm10000_debug_regs.c @@ -3060,12 +3060,12 @@ void fm10000DbgWriteRegister(fm_int sw, fm_int port, fm_text regName, fm_int val val); fm10000DbgWriteRegisterV3(sw, - 0, - port, - 0, - 0, - regName, - val); + 0, + port, + 0, + 0, + regName, + val); FM_LOG_EXIT_VOID(FM_LOG_CAT_DEBUG); @@ -3117,12 +3117,12 @@ void fm10000DbgWriteRegister(fm_int sw, fm_int port, fm_text regName, fm_int val * *****************************************************************************/ fm_status fm10000DbgWriteRegisterField(fm_int sw, - fm_int indexA, - fm_int indexB, - fm_int indexC, - fm_text regName, - fm_text fieldName, - fm_uint64 value) + fm_int indexA, + fm_int indexB, + fm_int indexC, + fm_text regName, + fm_text fieldName, + fm_uint64 value) { const fm10000DbgFulcrumRegister *pReg; fm_status err = FM_ERR_UNKNOWN_REGISTER; @@ -3190,8 +3190,8 @@ fm_status fm10000DbgWriteRegisterField(fm_int sw, else if (matchCnt > 1) { FM_LOG_PRINT("Multiple (%d) registers matches to the given name: %s\n", - matchCnt, - regName); + matchCnt, + regName); FM_LOG_EXIT(FM_LOG_CAT_DEBUG, FM_ERR_UNKNOWN_REGISTER); } else if (IS_REG_PCIE_VF(regName)) diff --git a/src/platforms/libertyTrail/platform.c b/src/platforms/libertyTrail/platform.c index bfb392b..4e82dde 100644 --- a/src/platforms/libertyTrail/platform.c +++ b/src/platforms/libertyTrail/platform.c @@ -2324,7 +2324,9 @@ fm_status fmPlatformSwitchInserted(fm_int sw) libFunc = FM_PLAT_GET_LIB_FUNCS_PTR(sw); if ( libFunc->InitSwitch ) { + TAKE_PLAT_I2C_BUS_LOCK(sw); status = libFunc->InitSwitch(swCfg->swNum); + DROP_PLAT_I2C_BUS_LOCK(sw); FM_LOG_EXIT_ON_ERR(FM_LOG_CAT_PLATFORM, status); } @@ -3976,7 +3978,7 @@ fm_status fmPlatformSendCableMismatchEvent(fm_int sw, fm_event * event; fm_eventCableMismatch *mismatchEvent; fm_platXcvrInfo *xcvrInfo; - fm_int portIdx; + fm_int portIdx; portIdx = fmPlatformCfgPortGetIndex(sw, port); xcvrInfo = &GET_PLAT_STATE(sw)->xcvrInfo[portIdx]; diff --git a/src/platforms/libertyTrail/shared-libs/standard/fm_platform_standard_lib.c b/src/platforms/libertyTrail/shared-libs/standard/fm_platform_standard_lib.c index 176b6f7..8f446fb 100644 --- a/src/platforms/libertyTrail/shared-libs/standard/fm_platform_standard_lib.c +++ b/src/platforms/libertyTrail/shared-libs/standard/fm_platform_standard_lib.c @@ -1320,7 +1320,7 @@ static fm_status SwitchI2cWriteRead(fm_uintptr handle, i2c = &hwCfg.i2c[sw]; /* Read chip version: FM10000_CHIP_VERSION => register: 0x452 */ - status = fmReadUINT32(sw, 0x452, &rv); + status = fmReadUINT32(sw, FM10000_CHIP_VERSION(), &rv); if (status == FM_OK) { i2c->chipVersion = rv & 0x7F; @@ -1361,7 +1361,7 @@ static fm_status SwitchI2cWriteRead(fm_uintptr handle, } } - else + else if (device != 0x8) // specifically VRM_IR device from Silicom patch { FM_LOG_ERROR(FM_LOG_CAT_PLATFORM, "I2C error accessing device 0x%x via switch %d: %s\n", @@ -2145,7 +2145,7 @@ static fm_status LoadTlv(fm_byte *tlv) if (!(hwCfg.pcaIo[idx].loadFlags & LF_IO_MODEL)) { CfgOrderErrorMsg(tlv, idx, - "must be before PCA IO %d model config"); + "must be after PCA IO %d model config"); return FM_ERR_INVALID_ARGUMENT; } @@ -2163,7 +2163,7 @@ static fm_status LoadTlv(fm_byte *tlv) if (!(hwCfg.pcaIo[idx].loadFlags & LF_IO_MODEL)) { CfgOrderErrorMsg(tlv, idx, - "must be before PCA IO %d model config"); + "must be after PCA IO %d model config"); return FM_ERR_INVALID_ARGUMENT; } @@ -2221,8 +2221,10 @@ static fm_status LoadTlv(fm_byte *tlv) FM_LOG_EXIT(FM_LOG_CAT_PLATFORM, FM_ERR_NO_MEM); } for (idx = 0; idx < hwCfg.numResId; idx++) { + hwCfg.hwResId[idx].xcvrI2cBusSel.ioIdx = UINT_NOT_USED; hwCfg.hwResId[idx].xcvrI2cBusSel.parentMuxIdx = UINT_NOT_USED; + hwCfg.hwResId[idx].xcvrStateIo.ioIdx = UINT_NOT_USED; hwCfg.hwResId[idx].xcvrStateIo.basePin = UINT_NOT_USED; hwCfg.hwResId[idx].phy.parentMuxIdx = UINT_NOT_USED; hwCfg.hwResId[idx].vrm.parentMuxIdx = UINT_NOT_USED; @@ -2304,21 +2306,37 @@ static fm_status LoadTlv(fm_byte *tlv) xcvrIo->u.qsfpPin.modPresN = xcvrIo->basePin + hwCfg.defQsfpPat.modPresN; } + else + { + xcvrIo->u.qsfpPin.modPresN = UINT_NOT_USED; + } if (hwCfg.defQsfpPat.intrN != UINT_NOT_USED) { xcvrIo->u.qsfpPin.intrN = xcvrIo->basePin + hwCfg.defQsfpPat.intrN; } + else + { + xcvrIo->u.qsfpPin.intrN = UINT_NOT_USED; + } if (hwCfg.defQsfpPat.lpMode != UINT_NOT_USED) { xcvrIo->u.qsfpPin.lpMode = xcvrIo->basePin + hwCfg.defQsfpPat.lpMode; } + else + { + xcvrIo->u.qsfpPin.lpMode = UINT_NOT_USED; + } if (hwCfg.defQsfpPat.resetN != UINT_NOT_USED) { xcvrIo->u.qsfpPin.resetN = xcvrIo->basePin + hwCfg.defQsfpPat.resetN; } + else + { + xcvrIo->u.qsfpPin.resetN = UINT_NOT_USED; + } } break; case FM_TLV_PLAT_LIB_XCVR_MODABS_PIN: @@ -2453,7 +2471,7 @@ static fm_status LoadTlv(fm_byte *tlv) if (hwCfg.numResId != 0) { CfgOrderErrorMsg(tlv, 0, - "must must be before hwResourceId.count config"); + "must be before hwResourceId.count config"); return FM_ERR_INVALID_ARGUMENT; } hwCfg.defBusSelType = GetTlvInt(tlv + 3, 1); @@ -2823,8 +2841,7 @@ static fm_status LoadConfig(void) } - /* Release lib config to free memory */ - fmPlatformReleaseLibTlvCfg(swIdx); + fflush(stdout); return FM_OK; @@ -3066,6 +3083,60 @@ static void DumpConfig(void) +static fm_status VerifyConfig(void) +{ + fm_uint32 idx; + fm_uint32 subLed; + fm_status status; + + status = FM_OK; + + if (hwCfg.numResId > 0) + { + for(idx = 0; idx < hwCfg.numResId; ++idx) + { + if ( + hwCfg.hwResId[idx].xcvrI2cBusSel.busSelType == BUS_SEL_TYPE_PCA_IO && + hwCfg.hwResId[idx].xcvrStateIo.ioIdx >= hwCfg.numPcaIo + ) + { + FM_LOG_ERROR(FM_LOG_CAT_PLATFORM, + "hwResourceId %d xcvrI2C.pcaIo.index is out of range.\n", + idx); + status = FM_ERR_INVALID_ARGUMENT; + } + if ( + (hwCfg.hwResId[idx].xcvrStateIo.intfType == INTF_TYPE_SFPP || hwCfg.hwResId[idx].xcvrStateIo.intfType == INTF_TYPE_QSFP) && + hwCfg.hwResId[idx].xcvrStateIo.ioIdx >= hwCfg.numPcaIo + ) + { + FM_LOG_ERROR(FM_LOG_CAT_PLATFORM, + "hwResourceId %d xcvrState.pcaIo.index is out of range.\n", + idx); + status = FM_ERR_INVALID_ARGUMENT; + } + + { + for(subLed = 0; subLed < NUM_SUB_LED; ++subLed){ + if ( + hwCfg.hwResId[idx].portLed[0].subLed[subLed].usage == LED_USAGE_LINK && + hwCfg.hwResId[idx].portLed[0].subLed[subLed].pin >= hwCfg.numPcaIo + ) + { + FM_LOG_ERROR(FM_LOG_CAT_PLATFORM, + "hwResourceId %d LED pcaIo.index is out of range.\n", + idx); + status = FM_ERR_INVALID_ARGUMENT; + } + } + + } + } + } + + FM_LOG_EXIT(FM_LOG_CAT_PLATFORM, status); +} + /*****************************************************************************/ /* SetupMuxPathRcrsv @@ -3802,10 +3873,11 @@ fm_status GetVrmVoltageInt(fm_int sw, { /* Select Page */ data[0] = 0x18; - data[1] = 0x00; status = i2c->writeReadFunc(i2c->handle, vrmI2c->addr, data, 1, 1); - FM_LOG_ABORT_ON_ERR(FM_LOG_CAT_PLATFORM, status); + if (status != FM_OK){ + return status; + } *mVolt = (data[0] * 5000 + 245000) / 1000; @@ -3827,7 +3899,6 @@ ABORT: * Public Functions *****************************************************************************/ - /*****************************************************************************/ /* fmPlatformLibInit * \ingroup platformLib @@ -3906,6 +3977,12 @@ fm_status fmPlatformLibInit(void) DumpConfig(); } + status = VerifyConfig(); + if(status != FM_OK) + { + goto ABORT; + } + if (strlen(hwCfg.fileLockName) > 0) { hwCfg.fileLock = @@ -4219,6 +4296,7 @@ fm_status fmPlatformLibSelectBus(fm_int sw, fm_uint bitIdx; fm_uint cnt; fm_busSel *xcvrI2cBus; + fm_pcaMux *pcaMuxPtr; fm_uint lastId; fm_uint id; @@ -4277,7 +4355,78 @@ fm_status fmPlatformLibSelectBus(fm_int sw, muxIdx = UINT_NOT_USED; - if (busType == FM_PLAT_BUS_XCVR_STATE) + if (busType == FM_PLAT_BUS_UNKNOWN_4) + { + if (hwCfg.numPcaMux > 0) + { + for (muxValue = 0; muxValue < hwCfg.numPcaMux; ++muxValue) + { + if (hwCfg.pcaMux[muxValue].bus == sw) + { + status = SetupMuxPath(muxValue, 2); + break; + } + } + } + } + else if (busType == FM_PLAT_BUS_UNKNOWN_5) + { + if (hwCfg.numPcaMux > 0) + { + for (muxValue = 0; muxValue < hwCfg.numPcaMux; ++muxValue) + { + if (hwCfg.pcaMux[muxValue].bus == sw) + { + status = SetupMuxPath(muxValue, 4); + break; + } + } + } + + } + else if (busType == FM_PLAT_BUS_UNKNOWN_6) + { + if (hwCfg.numPcaMux > 0) + { + for (muxValue = 0; muxValue < hwCfg.numPcaMux; ++muxValue) + { + if (hwCfg.pcaMux[muxValue].bus == sw) + { + status = SetupMuxPath(muxValue + 1, 1); + break; + } + } + } + } + else if (busType == FM_PLAT_BUS_UNKNOWN_7) + { + if (hwCfg.numPcaMux > 0) + { + for (muxValue = 0; muxValue < hwCfg.numPcaMux; ++muxValue) + { + if (hwCfg.pcaMux[muxValue].bus == sw) + { + status = SetupMuxPath(muxValue, 4); + break; + } + } + } + } + else if (busType == FM_PLAT_BUS_UNKNOWN_8) + { + if (hwCfg.numPcaMux > 0) + { + for (muxValue = 0; muxValue < hwCfg.numPcaMux; ++muxValue) + { + if (hwCfg.pcaMux[muxValue].bus == sw) + { + status = SetupMuxPath(muxValue, 8); + break; + } + } + } + } + else if (busType == FM_PLAT_BUS_XCVR_STATE) { idx = hwResId->xcvrStateIo.ioIdx; muxIdx = hwCfg.pcaIo[idx].parentMuxIdx; @@ -4683,6 +4832,11 @@ fm_status fmPlatformLibGetPortXcvrState(fm_int sw, else if (xcvrIo->intfType == INTF_TYPE_QSFP) { offset = xcvrIo->u.qsfpPin.modPresN; + if (offset == UINT_NOT_USED) + { + xcvrState[cnt] |= FM_PLAT_XCVR_PRESENT; + } + if ((offset != UINT_NOT_USED) && (offset < NUM_PCA_PINS)) { byteIdx = offset / 8; @@ -4710,6 +4864,11 @@ fm_status fmPlatformLibGetPortXcvrState(fm_int sw, input/output mismatch seen with specific cables (Vendor : TE Connectivity : PN 2231368-1).*/ offset = xcvrIo->u.qsfpPin.lpMode; + if (offset == UINT_NOT_USED) + { + xcvrState[cnt] |= FM_PLAT_XCVR_LPMODE; + } + if ((offset != UINT_NOT_USED) && (offset < NUM_PCA_PINS)) { byteIdx = offset / 8; @@ -5282,6 +5441,7 @@ fm_status fmPlatformLibSetVrmVoltage(fm_int sw, fm_i2cCfg * i2c; fm_hwResId * hwResId; fm_vrmI2C * vrmI2c; + uint voltageCalc; fm_byte data[4]; fm_uint channel; fm_uint regVidSet; @@ -5531,30 +5691,26 @@ fm_status fmPlatformLibSetVrmVoltage(fm_int sw, else if (hwResId->vrm.model && (hwResId->vrm.model == VRM_IR)) { printf("vrm mVolt %d delta %d\n", mVolt, hwResId->vrm.delta); - uint voltageCalc = (mVolt + hwResId->vrm.delta) / 5 - 49; - data[1] = (char) voltageCalc; - printf("vrm channel %d data 0x%x\n", channel, voltageCalc & 0xff); + voltageCalc = (mVolt + hwResId->vrm.delta) / 5 - 49; + data[1] = voltageCalc; + printf("vrm channel %d data 0x%x\n", channel, voltageCalc); fflush(stdout); - if(channel == 0){ + if(status == 0){ data[0] = 0x26; } else if (channel == 1){ data[0] = 0x27; } - for(uint i; i < 0x32; ++i){ + for(uint i = 0; i < 50; ++i){ status = i2c->writeReadFunc(i2c->handle, vrmI2c->addr, data, 2, 0); if(status == FM_OK){ - status = i2c->writeReadFunc(i2c->handle, vrmI2c->addr, data, 0, 1); break; } - - fmDelay(0, 1); - } - if(status != FM_OK){ - i2c->writeReadFunc(i2c->handle, vrmI2c->addr, data, 0, 1); - FM_LOG_ABORT_ON_ERR(FM_LOG_CAT_PLATFORM, status); + fmDelayBy(1, 0); } + i2c->writeReadFunc(i2c->handle, vrmI2c->addr, data, 0, 1); + FM_LOG_ABORT_ON_ERR(FM_LOG_CAT_PLATFORM, status); } else { diff --git a/src/platforms/util/fm_util_pca.c b/src/platforms/util/fm_util_pca.c index 13ab8dd..ac854da 100644 --- a/src/platforms/util/fm_util_pca.c +++ b/src/platforms/util/fm_util_pca.c @@ -1677,7 +1677,7 @@ fm_status fmUtilPcaIoUpdateInputRegs(fm_pcaIoDevice *dev) PCA_IO_REG_TYPE_INPUT, 0, dev->devCap.numBytes); - + break; default: status = FM_ERR_INVALID_ARGUMENT; break; @@ -1717,6 +1717,7 @@ fm_status fmUtilPcaIoWriteRegs(fm_pcaIoDevice *dev, { fm_status status; + fflush(stdout); switch (dev->model) { case PCA_IO_9505: