/**
* @internal appDemoDxChDbReset function
* @endinternal
*
* @brief DxCh DB reset. (part of 'System reset')
*
* @param[in] devNum - device number
* @param[in] needHwReset - indication to do HW reset
* @param[in] needFullDbCleanUp - indication to do full DB reset (or skip it to minimal)
*
* @retval GT_OK - on success,
* @retval GT_FAIL - otherwise.
*/
GT_STATUS appDemoDxChDbReset
(
IN GT_U8 devNum,
IN GT_BOOL needHwReset,
IN GT_BOOL needFullDbCleanUp
)
{
GT_STATUS rc; /* To hold funcion return code */
static GT_CHAR devMustNotResetPort_str[100];
CPSS_PORTS_BMP_STC portBmp;/* bmp for port */
GT_U32 port;/* port iterator */
struct {
GT_U32 regAddr;
GT_U32 value;
} regsToRestore[] = {
/* Unit Default ID (UDID) Register */
{ 0x00000204, 0 },
/* Window n registers (n=0..5)
* Base Address,
* Size,
* High Address Remap,
* Window Control
*/
{ 0x020c, 0 }, { 0x0210, 0 }, { 0x23c, 0}, { 0x0254, 0 },
{ 0x0214, 0 }, { 0x0218, 0 }, { 0x240, 0}, { 0x0258, 0 },
{ 0x021c, 0 }, { 0x0220, 0 }, { 0x244, 0}, { 0x025c, 0 },
{ 0x0224, 0 }, { 0x0228, 0 }, { 0x248, 0}, { 0x0260, 0 },
{ 0x022c, 0 }, { 0x0230, 0 }, { 0x24c, 0}, { 0x0264, 0 },
{ 0x0234, 0 }, { 0x0248, 0 }, { 0x250, 0}, { 0x0258, 0 },
/* address completion are used by LSP of MSYS for
eth port PHY managment */
{ 0x0124, 0 }, { 0x0128, 0 }, { 0x012c, 0}, { 0x0130, 0 },
{ 0x0134, 0 }, { 0x0138, 0 }, { 0x013c, 0},
/* SMI Master controller configuration is used for BobK systems
for MSYS eth port PHY managment */
{ SMI_MNG_ADDRESS_MARK_CNS, 0 }, /* must be last before {0,0} */
{ 0, 0 }/* END */
};
GT_U32 ii;
GT_UINTPTR deviceBaseAddrOnPex;
GT_U32 doMgDecodingRestore;
CPSS_PP_INTERFACE_CHANNEL_ENT ifChannel; /* DIAG device channel access type */
GT_U32 value;
GT_BOOL doByteSwap;
GT_U32 supportMgWindowsRegisters = 1;
GT_U32 mgOffset;
GT_U32 *unitBasePtr;
if(PRV_CPSS_IS_DEV_EXISTS_MAC(devNum) == 0)
{
return (GT_STATUS)GT_ERROR;
}
if (PRV_CPSS_SIP_5_CHECK_MAC(devNum))
{
/* all SIP5 devices should use PEX_MBUS driver with 8 regions address completion. */
ifChannel = CPSS_CHANNEL_PEX_MBUS_E;
}
else
{
ifChannel = CPSS_CHANNEL_PEX_E;
}
#ifdef ASIC_SIMULATION
doMgDecodingRestore = 0;
if (!PRV_CPSS_SIP_5_CHECK_MAC(devNum) &&
!PRV_CPSS_DXCH_IS_AC3_BASED_DEVICE_MAC(devNum))
{
/* the memory space was not implemented ... and not really needed */
supportMgWindowsRegisters = 0;
}
#else
doMgDecodingRestore = 1;
#endif
if(PRV_CPSS_SIP_6_CHECK_MAC(devNum) || (PRV_CPSS_PP_MAC(devNum)->devFamily == CPSS_PP_FAMILY_DXCH_AC5_E))
{
supportMgWindowsRegisters = 0;
/* we skip the MG 'save' and 'restore' because the 'init phase' in the appDemo
is calling to :
extern GT_STATUS prvNoKmDrv_configure_dma_per_devNum(IN GT_U8 devNum , IN GT_U32 portGroupId);
that initialize the MG[0] of the device.
and the 'cpss init phase2' will copy it from MG[0] to all other MGs
*/
}
if (PRV_CPSS_SIP_7_CHECK_MAC(devNum))
{
/* NO MG unit(s) */
supportMgWindowsRegisters = 0;
doMgDecodingRestore = 0;
mgOffset = 0;/* not used , but for compiler warning only */
}
else
{
unitBasePtr = NULL;
rc = prvCpssDxChUnitBaseTableGet(devNum, &unitBasePtr);
if ((GT_NOT_APPLICABLE_DEVICE != rc) && (rc != GT_OK))
{
return rc;
}
mgOffset = (NULL == unitBasePtr)?0:unitBasePtr[PRV_CPSS_DXCH_UNIT_MG_E];
for(ii = 0; ii < sizeof(regsToRestore)/sizeof(regsToRestore[0]); ii++)
{
if(0 == regsToRestore[ii].regAddr)
{
break;
}
regsToRestore[ii].regAddr += mgOffset;
}
}
if(needHwReset == GT_FALSE)
{
doMgDecodingRestore = 0;
}
/*osPrintf("appDemoDxChDbReset - start \n");*/
if(GT_TRUE == needFullDbCleanUp)
{
/* IP LPM DB Clear - main LBM DB deleted, all prefixes removed, all VR removed */
rc = prvIpLpmLibReset();
CPSS_ENABLER_DBG_TRACE_RC_MAC("prvIpLpmLibReset", rc);
if (rc != GT_OK)
{
return rc;
}
#ifdef IMPL_TM
if(PRV_CPSS_PP_MAC(devNum)->tmInfo.tmHandle != NULL)
{
/* TM DB Clear */
rc = cpssTmClose(devNum);
CPSS_ENABLER_DBG_TRACE_RC_MAC("cpssTmClose", rc);
if (rc != GT_OK)
{
return rc;
}
}
#endif /*IMPL_TM*/
/* reset TCAM related DBs */
appDemoDxChTcamDbReset();
/* Reset FDB Manager SW Db */
rc = prvCpssDxChFdbManagerAllDbDelete();
CPSS_ENABLER_DBG_TRACE_RC_MAC("prvCpssDxChFdbManagerAllDbDelete", rc);
if(rc != GT_OK)
{
return rc;
}
/* Reset Exact Match Manager SW Db */
rc = prvCpssDxChExactMatchManagerAllDbDelete();
CPSS_ENABLER_DBG_TRACE_RC_MAC("prvCpssDxChExactMatchManagerAllDbDelete", rc);
if(rc != GT_OK)
{
return rc;
}
}
else
{
BYPASS_DB_CLEANUP_MAC(prvIpLpmLibReset);
BYPASS_DB_CLEANUP_MAC(cpssTmClose);
BYPASS_DB_CLEANUP_MAC(appDemoDxChTcamDbReset);
}
if(supportMgWindowsRegisters)
{
/* fill-in registers restore DB by run time values */
for(ii = 0 ; regsToRestore[ii].regAddr != 0; ii++)
{
if(SMI_MNG_ADDRESS_MARK_CNS == regsToRestore[ii].regAddr)
{
if(PRV_CPSS_DXCH_PP_MAC(devNum)->hwInfo.gop_lms.notSupported == GT_TRUE)
{
regsToRestore[ii].regAddr = PRV_CPSS_DXCH_DEV_REGS_VER1_MAC(devNum)->GOP.SMI[0].SMIMiscConfiguration;
}
else
{
/* BC2 A0 - MSYS does not use this register.
mark as last one and not used */
regsToRestore[ii].regAddr = 0;
}
}
}
}
CPSS_PORTS_BMP_PORT_CLEAR_ALL_MAC(&portBmp);
cpssOsBzero(devMustNotResetPort_str, sizeof(devMustNotResetPort_str));
/* power down all ports */
for(port = 0 ; port < CPSS_MAX_PORTS_NUM_CNS /*support 256 ports in bc2*/; port++)
{
if(prvCpssDxChPortRemotePortCheck(devNum,port))
{
/* we allow remote ports ... see logic below */
}
else
if(GT_FALSE == appDemoDxChIsPhysicalPortHoldMac(devNum,port))
{
/* skip ports without MAC */
continue;
}
cpssOsSprintf(devMustNotResetPort_str,"devMustNotResetPort_str_d[%d]p[%d]",devNum,port);
if(appDemoStaticDbEntryGet(devMustNotResetPort_str,&value)== GT_OK)
{
if(value)
{
/* port 90 is used for MAC 62 in BobK.
Power down of SERDES for this port kills OOB port. Skip this ports. */
osPrintf("appDemoDxChDbReset : SKIP reset of port [%d] because 'MUST NOT RESET' flag \n",
port);
continue;
}
}
if(portMgr)
{
/* support port manager operation */
(void)appDemoPortInitSeqDeletePortStage(devNum, port);
}
else
{
/* set the port in bmp */
CPSS_PORTS_BMP_PORT_SET_MAC(&portBmp,port);
rc = cpssDxChPortModeSpeedSet(devNum, &portBmp, GT_FALSE,
/*don't care*/CPSS_PORT_INTERFACE_MODE_SGMII_E,
/*don't care*/CPSS_PORT_SPEED_1000_E);
if (rc != GT_OK)
{
/* do not break .. maybe port not exists but we not have here knowledge about it */
if(port < PRV_CPSS_PP_MAC(devNum)->numOfPorts)
{
/* give indication about ports that are supposed to be in 'valid range'
note that for BC2 ports 60..63 could give 'false alarm' indication */
/*osPrintf("cpssDxChPortModeSpeedSet : failed on port[%d] \n",
port);*/
}
}
}
/* Remote ports are not HW reset: Restore HW defaults */
if (needHwReset &&
prvCpssDxChPortRemotePortCheck(devNum,port))
{
cpssDxChPortForceLinkPassEnableSet(devNum,port,GT_FALSE);
cpssDxChPortForceLinkDownEnableSet(devNum,port,GT_FALSE);
}
/* remove the port from bmp */
CPSS_PORTS_BMP_PORT_CLEAR_MAC(&portBmp,port);
}
if(needHwReset == GT_TRUE)
{
CPSS_HW_INFO_STC *hwInfoPtr;
hwInfoPtr = cpssDrvHwPpHwInfoStcPtrGet(devNum, 0);
if (hwInfoPtr == NULL)
return GT_FAIL;
deviceBaseAddrOnPex = hwInfoPtr->resource.switching.start;
osPrintf("deviceBaseAddrOnPex = 0x %p \n",deviceBaseAddrOnPex);
doByteSwap = GT_FALSE;
if(supportMgWindowsRegisters)
{
/* read the registers */
for(ii = 0 ; regsToRestore[ii].regAddr != 0; ii++)
{
rc = prvCpssDrvHwPpReadRegister(devNum,regsToRestore[ii].regAddr,&(regsToRestore[ii].value));
CPSS_ENABLER_DBG_TRACE_RC_MAC("prvCpssDrvHwPpReadRegister", rc);
if (rc != GT_OK)
{
return rc;
}
}
rc = cpssDxChDiagRegRead(deviceBaseAddrOnPex,
ifChannel,
CPSS_DIAG_PP_REG_INTERNAL_E, mgOffset + 0x50,
&value, doByteSwap);
CPSS_ENABLER_DBG_TRACE_RC_MAC("cpssDxChDiagRegRead", rc);
if (rc != GT_OK)
{
return rc;
}
if(value == 0xAB110000)
{
doByteSwap = GT_TRUE;
}
}
}
else
{
deviceBaseAddrOnPex = 0;/* dummy.. will not be used */
doByteSwap = GT_FALSE; /* dummy.. will not be used */
}
if(appDemoDbEntryGet("mgcamEnable", &value) == GT_OK)
{
/* disable MGCAM before remove device */
appDemoMgCamEnableSet(devNum, GT_FALSE);
}
if(needHwReset == GT_TRUE)
{
/* logic above generates interrupts. Provide time for CPU to take care of them. */
cpssOsTimerWkAfter(100);
/* do 'atomic' device remove after device reset */
rc = doAtomicDeviceResetAndRemove(devNum);
CPSS_ENABLER_DBG_TRACE_RC_MAC("doAtomicDeviceResetAndRemove", rc);
if (rc != GT_OK)
{
return rc;
}
}
else
{
if(skipRemoveDeviceFromCpss_get())
{
osPrintf("appDemoDxChDbReset : DO NOT 'remove device from cpss' --- SKIP the remove device operation \n");
}
else
{
/* do device remove without device reset */
osPrintf("appDemoDxChDbReset : 'remove device from cpss' \n");
rc = cpssDxChCfgDevRemove(devNum);
CPSS_ENABLER_DBG_TRACE_RC_MAC("cpssDxChCfgDevRemove", rc);
if (rc != GT_OK)
{
return rc;
}
}
}
/* let the device minimal time for reset before we restore next registers */
osTimerWkAfter(1);
if(doMgDecodingRestore && supportMgWindowsRegisters)
{
osPrintf("appDemoDxChDbReset : (after soft reset) restore 'MG Registers/Address Decoding' configurations \n");
rc = cpssDxChDiagRegRead(deviceBaseAddrOnPex,
ifChannel,
CPSS_DIAG_PP_REG_INTERNAL_E, mgOffset + 0x50,
&value, doByteSwap);
CPSS_ENABLER_DBG_TRACE_RC_MAC("cpssDxChDiagRegRead", rc);
if (rc != GT_OK)
{
return rc;
}
/*osPrintf("cpssDxChDiagRegRead:deviceBaseAddrOnPex[0x%x] reg[0x50] with value[%d] doByteSwap[%d] \n",
deviceBaseAddrOnPex,value,doByteSwap);*/
/* restore the registers of :
<MG_IP> MG_IP/MG Registers/Address Decoding/Base Address %n
0x0000020C + n*8: where n (0-5) represents BA
and:
<MG_IP> MG_IP/MG Registers/Address Decoding/Size (S) %n
0x00000210 + n*0x8: where n (0-5) represents SR
and:
<MG_IP> MG_IP/MG Registers/Address Decoding/High Address Remap %n
0x0000023c + n*0x4: where n (0-5) represents HA
and :
<MG_IP> MG_IP/MG Registers/Address Decoding/Window Control Register%n
0x00000254 + n*4: where n (0-5) represents n
*/
if(supportMgWindowsRegisters)
{
/* write the saved registers */
/* since the device was removed from cpss ...
we must use the 'diag' functions to write to the device ... */
/* restore the registers */
for(ii = 0 ; regsToRestore[ii].regAddr != 0; ii++)
{
rc = cpssDxChDiagRegWrite(deviceBaseAddrOnPex,
ifChannel,
CPSS_DIAG_PP_REG_INTERNAL_E,
regsToRestore[ii].regAddr,
regsToRestore[ii].value,
doByteSwap);
CPSS_ENABLER_DBG_TRACE_RC_MAC("cpssDxChDiagRegWrite", rc);
if (rc != GT_OK)
{
return rc;
}
}
}
}
osPrintf("appDemoDxChDbReset - ended \n");
return GT_OK; 貌似是/* do device remove without device reset */
osPrintf("appDemoDxChDbReset : 'remove device from cpss' \n");
rc = cpssDxChCfgDevRemove(devNum);这里报错,分析下原因
最新发布