From d7b5a8acac12c668c98e9b45dd90c2b448277ce5 Mon Sep 17 00:00:00 2001 From: WeebDataHoarder <57538841+weebdatahoarder@users.noreply.github.com> Date: Sun, 27 Dec 2020 03:55:23 +0100 Subject: [PATCH 01/12] change loop start --- .../shared-libs/standard/fm_platform_standard_lib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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..7c7864c 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 @@ -5532,8 +5532,8 @@ fm_status fmPlatformLibSetVrmVoltage(fm_int sw, { 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); + data[1] = voltageCalc; + printf("vrm channel %d data 0x%x\n", channel, voltageCalc); fflush(stdout); if(channel == 0){ @@ -5542,7 +5542,7 @@ fm_status fmPlatformLibSetVrmVoltage(fm_int sw, data[0] = 0x27; } - for(uint i; i < 0x32; ++i){ + for(uint i = 0; i < 0x32; ++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); -- 2.43.4 From 0905863285a7bba1d01c659eeb3848b60b497435 Mon Sep 17 00:00:00 2001 From: WeebDataHoarder <57538841+weebdatahoarder@users.noreply.github.com> Date: Tue, 26 Oct 2021 08:10:56 +0200 Subject: [PATCH 02/12] patches from new version diff * missing break; on fmUtilPcaIoUpdateInputRegs * missing fflush --- .../shared-libs/standard/fm_platform_standard_lib.c | 7 ++++--- src/platforms/util/fm_util_pca.c | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) 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 7c7864c..01003e8 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 @@ -3802,10 +3802,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; @@ -5545,7 +5546,7 @@ fm_status fmPlatformLibSetVrmVoltage(fm_int sw, for(uint i = 0; i < 0x32; ++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); + i2c->writeReadFunc(i2c->handle, vrmI2c->addr, data, 0, 1); break; } diff --git a/src/platforms/util/fm_util_pca.c b/src/platforms/util/fm_util_pca.c index 13ab8dd..1ae5ee6 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: -- 2.43.4 From 89abf99daff95a38c29a2082b315bb7789360f3a Mon Sep 17 00:00:00 2001 From: WeebDataHoarder <57538841+weebdatahoarder@users.noreply.github.com> Date: Tue, 26 Oct 2021 11:38:50 +0200 Subject: [PATCH 03/12] Remove default -DPLATFORM_NUM_FOCALPOINTS=1 --- Makefile.am | 2 -- src/Makefile.am | 2 -- 2 files changed, 4 deletions(-) diff --git a/Makefile.am b/Makefile.am index e8600a3..e3f3faa 100644 --- a/Makefile.am +++ b/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 \ -Lsrc/.libs/ -lFocalpointSDK -lm -lpthread -ldl -lrt \ -I$(top_srcdir)/include \ diff --git a/src/Makefile.am b/src/Makefile.am index 8f2cad3..3c413d8 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 \ -- 2.43.4 From 596a181e24173a26035e7012ec9d16387352eb0c Mon Sep 17 00:00:00 2001 From: WeebDataHoarder <57538841+weebdatahoarder@users.noreply.github.com> Date: Tue, 26 Oct 2021 23:10:25 +0200 Subject: [PATCH 04/12] Apply LoadTlv changes observed on diff for 4.3.2 --- .../standard/fm_platform_standard_lib.c | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) 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 01003e8..43b4f44 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 @@ -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: @@ -2825,6 +2843,7 @@ static fm_status LoadConfig(void) /* Release lib config to free memory */ fmPlatformReleaseLibTlvCfg(swIdx); + fflush(stdout); return FM_OK; -- 2.43.4 From 8e575c6274b1d8d8fc08bcb0a9382fbb4c414b04 Mon Sep 17 00:00:00 2001 From: WeebDataHoarder <57538841+weebdatahoarder@users.noreply.github.com> Date: Tue, 26 Oct 2021 23:42:13 +0200 Subject: [PATCH 05/12] Apply fmPlatformLibGetPortXcvrState changes observed on diff for 4.3.2 --- .../shared-libs/standard/fm_platform_standard_lib.c | 8 ++++++++ 1 file changed, 8 insertions(+) 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 43b4f44..210a7ef 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 @@ -4713,6 +4713,10 @@ fm_status fmPlatformLibGetPortXcvrState(fm_int sw, xcvrState[cnt] |= FM_PLAT_XCVR_PRESENT; } } + else if (offset == UINT_NOT_USED) + { + xcvrState[cnt] |= FM_PLAT_XCVR_PRESENT; + } offset = xcvrIo->u.qsfpPin.intrN; if ((offset != UINT_NOT_USED) && (offset < NUM_PCA_PINS)) @@ -4740,6 +4744,10 @@ fm_status fmPlatformLibGetPortXcvrState(fm_int sw, xcvrState[cnt] |= FM_PLAT_XCVR_LPMODE; } } + else if (offset == UINT_NOT_USED) + { + xcvrState[cnt] |= FM_PLAT_XCVR_LPMODE; + } offset = xcvrIo->u.qsfpPin.resetN; if ((offset != UINT_NOT_USED) && (offset < NUM_PCA_PINS)) -- 2.43.4 From 561bf142aaff03e4542d51932de651d6c4a9b91e Mon Sep 17 00:00:00 2001 From: WeebDataHoarder <57538841+weebdatahoarder@users.noreply.github.com> Date: Wed, 27 Oct 2021 00:08:38 +0200 Subject: [PATCH 06/12] Fix indentation on several files/patches to be consistent aross project --- src/api/fm10000/fm10000_api_port.c | 2 +- src/api/fm10000/fm10000_api_sched.c | 16 ++--- src/api/fm10000/fm10000_api_serdes_actions.c | 10 +-- src/api/fm10000/fm10000_api_vn.c | 66 +++++++++---------- src/api/fm_api_routing.c | 4 +- src/debug/fm10000/fm10000_debug_regs.c | 28 ++++---- src/platforms/libertyTrail/platform.c | 2 +- .../standard/fm_platform_standard_lib.c | 6 +- src/platforms/util/fm_util_pca.c | 4 +- 9 files changed, 69 insertions(+), 69 deletions(-) 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..e5d799c 100644 --- a/src/platforms/libertyTrail/platform.c +++ b/src/platforms/libertyTrail/platform.c @@ -3976,7 +3976,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 210a7ef..3e6eb58 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 @@ -3823,9 +3823,9 @@ fm_status GetVrmVoltageInt(fm_int sw, data[0] = 0x18; status = i2c->writeReadFunc(i2c->handle, vrmI2c->addr, data, 1, 1); - if (status != FM_OK){ - return status; - } + if (status != FM_OK){ + return status; + } *mVolt = (data[0] * 5000 + 245000) / 1000; diff --git a/src/platforms/util/fm_util_pca.c b/src/platforms/util/fm_util_pca.c index 1ae5ee6..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; + break; default: status = FM_ERR_INVALID_ARGUMENT; break; @@ -1717,7 +1717,7 @@ fm_status fmUtilPcaIoWriteRegs(fm_pcaIoDevice *dev, { fm_status status; - fflush(stdout); + fflush(stdout); switch (dev->model) { case PCA_IO_9505: -- 2.43.4 From 838a619fa24457378dbc1a1a802f424fbd3f1c1d Mon Sep 17 00:00:00 2001 From: WeebDataHoarder <57538841+weebdatahoarder@users.noreply.github.com> Date: Wed, 27 Oct 2021 19:26:17 +0200 Subject: [PATCH 07/12] Remove -ldl, add -lrt Remove version.sh from LDFLAGS --- Makefile.am | 2 +- src/Makefile.am | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile.am b/Makefile.am index e3f3faa..07472ff 100644 --- a/Makefile.am +++ b/Makefile.am @@ -14,7 +14,7 @@ AM_CFLAGS = -std=c99 -DFM_SUPPORT_FM10000 \ -DINSTRUMENT_LOG_LEVEL=0 \ -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/src/Makefile.am b/src/Makefile.am index 3c413d8..840b0c9 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -24,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 = \ @@ -231,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 -- 2.43.4 From 46cb10f2a44d29fb2d17c6f4789aeacff22f6a09 Mon Sep 17 00:00:00 2001 From: WeebDataHoarder <57538841+weebdatahoarder@users.noreply.github.com> Date: Thu, 28 Oct 2021 00:28:28 +0200 Subject: [PATCH 08/12] Added new bus values on fmPlatformLibSelectBus --- .../platforms/libertyTrail/platform_lib_api.h | 6 ++ .../standard/fm_platform_standard_lib.c | 96 ++++++++++++++++--- 2 files changed, 90 insertions(+), 12 deletions(-) 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/platforms/libertyTrail/shared-libs/standard/fm_platform_standard_lib.c b/src/platforms/libertyTrail/shared-libs/standard/fm_platform_standard_lib.c index 3e6eb58..4cdb67c 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 @@ -2471,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); @@ -2841,8 +2841,6 @@ static fm_status LoadConfig(void) } - /* Release lib config to free memory */ - fmPlatformReleaseLibTlvCfg(swIdx); fflush(stdout); return FM_OK; @@ -4239,6 +4237,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; @@ -4297,7 +4296,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; @@ -4703,6 +4773,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; @@ -4713,10 +4788,6 @@ fm_status fmPlatformLibGetPortXcvrState(fm_int sw, xcvrState[cnt] |= FM_PLAT_XCVR_PRESENT; } } - else if (offset == UINT_NOT_USED) - { - xcvrState[cnt] |= FM_PLAT_XCVR_PRESENT; - } offset = xcvrIo->u.qsfpPin.intrN; if ((offset != UINT_NOT_USED) && (offset < NUM_PCA_PINS)) @@ -4734,6 +4805,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; @@ -4744,10 +4820,6 @@ fm_status fmPlatformLibGetPortXcvrState(fm_int sw, xcvrState[cnt] |= FM_PLAT_XCVR_LPMODE; } } - else if (offset == UINT_NOT_USED) - { - xcvrState[cnt] |= FM_PLAT_XCVR_LPMODE; - } offset = xcvrIo->u.qsfpPin.resetN; if ((offset != UINT_NOT_USED) && (offset < NUM_PCA_PINS)) -- 2.43.4 From eb8ed6d1659c30db5d27f1ddd380c591b8680d58 Mon Sep 17 00:00:00 2001 From: WeebDataHoarder <57538841+weebdatahoarder@users.noreply.github.com> Date: Thu, 28 Oct 2021 01:21:14 +0200 Subject: [PATCH 09/12] Implemented VerifyConfig() for fmPlatformLibInit() --- .../standard/fm_platform_standard_lib.c | 61 ++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) 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 4cdb67c..13869e4 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 @@ -3083,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 @@ -3845,7 +3899,6 @@ ABORT: * Public Functions *****************************************************************************/ - /*****************************************************************************/ /* fmPlatformLibInit * \ingroup platformLib @@ -3924,6 +3977,12 @@ fm_status fmPlatformLibInit(void) DumpConfig(); } + status = VerifyConfig(); + if(status != FM_OK) + { + goto ABORT; + } + if (strlen(hwCfg.fileLockName) > 0) { hwCfg.fileLock = -- 2.43.4 From cec10e649e40af7697ea8501f75aea2d4db91c71 Mon Sep 17 00:00:00 2001 From: WeebDataHoarder <57538841+weebdatahoarder@users.noreply.github.com> Date: Thu, 28 Oct 2021 03:46:04 +0200 Subject: [PATCH 10/12] Fix compilation under GCC 10 due to -fno-common --- include/api/internal/fm10000/fm10000_api_port_int.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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, -- 2.43.4 From 2568379d1c528bf28cec42be040e0c19120dde92 Mon Sep 17 00:00:00 2001 From: WeebDataHoarder <57538841+weebdatahoarder@users.noreply.github.com> Date: Thu, 28 Oct 2021 04:43:12 +0200 Subject: [PATCH 11/12] Fix VRM_IR write on fmPlatformLibSetVrmVoltage() --- src/api/fm10000/fm10000_api_i2c.c | 2 +- .../standard/fm_platform_standard_lib.c | 17 +++++++---------- 2 files changed, 8 insertions(+), 11 deletions(-) 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/platforms/libertyTrail/shared-libs/standard/fm_platform_standard_lib.c b/src/platforms/libertyTrail/shared-libs/standard/fm_platform_standard_lib.c index 13869e4..d71b9a3 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 @@ -5441,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; @@ -5690,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; + 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 = 0; i < 0x32; ++i){ + for(uint i = 0; i < 50; ++i){ status = i2c->writeReadFunc(i2c->handle, vrmI2c->addr, data, 2, 0); if(status == FM_OK){ - 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 { -- 2.43.4 From 811f413afe5fda9ae6c9e647768fab2d91afb8ee Mon Sep 17 00:00:00 2001 From: WeebDataHoarder <57538841+weebdatahoarder@users.noreply.github.com> Date: Thu, 28 Oct 2021 07:00:59 +0200 Subject: [PATCH 12/12] Add special case on SwitchI2cWriteRead based on diff, add lock take/drop on SwitchInserted --- src/platforms/libertyTrail/platform.c | 2 ++ .../shared-libs/standard/fm_platform_standard_lib.c | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/platforms/libertyTrail/platform.c b/src/platforms/libertyTrail/platform.c index e5d799c..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); } 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 d71b9a3..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", -- 2.43.4