?? zl5011xinit.c
字號:
{
gotDevice = ZL5011X_TRUE;
}
}
/* main function code starts */
if (status == ZL5011X_OK)
{
ZL5011X_TRACE(ZL5011X_INIT_FN_ID,
"zl5011xWanInit: if type %d",
par->ifType, 0, 0, 0, 0, 0);
/* the memory must be initialised before the WAN is configured */
if (zl5011xParams->memoryInitialised == ZL5011X_FALSE)
{
status = ZL5011X_MEMORY_NOT_INIT;
}
}
if (status == ZL5011X_OK)
{
if (zl5011xParams->wanInitialised == ZL5011X_TRUE)
{
status = ZL5011X_MULTIPLE_INIT_ATTEMPT;
}
}
/* initialise the WAN blocks - note that the memory must be active before
initialising the PLA */
if (status == ZL5011X_OK)
{
status = zl5011xInitBlocks(zl5011xParams, ZL5011X_ADM_TIF_BIT | ZL5011X_ADM_TFM_BIT |
ZL5011X_ADM_TFQ_BIT | ZL5011X_ADM_PAC_BIT | ZL5011X_ADM_PLA_BIT);
}
/* initialise the TIF block, and set the interface type. This sets the number of
streams etc. and must be done before the TFM, TFQ. */
if (status == ZL5011X_OK)
{
status = zl5011xTifInit(zl5011xParams);
}
if (status == ZL5011X_OK)
{
status = zl5011xTifSetInterfaceType(zl5011xParams, par->ifType, par->liuFreq, par->liuFreqHz);
}
/* initialise the other WAN blocks */
if (status == ZL5011X_OK)
{
status = zl5011xTfmInit(zl5011xParams);
}
if (status == ZL5011X_OK)
{
status = zl5011xTfqInit(zl5011xParams);
}
if (status == ZL5011X_OK)
{
status = zl5011xTfqSetGranuleUsage(zl5011xParams, par->txQueueMaxNumberOfGranules);
}
if (status == ZL5011X_OK)
{
status = zl5011xPacInit(zl5011xParams);
}
if (status == ZL5011X_OK)
{
status = zl5011xPlaInit(zl5011xParams);
}
if (status == ZL5011X_OK)
{
zl5011xParams->wanInitialised = ZL5011X_TRUE;
for (loop = 0; loop < ZL5011X_MAX_NUMBER_CONTEXTS; loop++)
{
zl5011xParams->wanIf.txQueue[loop].queueInitialised = ZL5011X_FALSE;
}
}
if (gotDevice == ZL5011X_TRUE)
{
if (status == ZL5011X_OK)
{
status = zl5011xReleaseDevice(zl5011xParams);
}
else
{
/* already have an error code, so don't overwrite it */
(void)zl5011xReleaseDevice(zl5011xParams);
}
}
return status;
}
/*******************************************************************************
Function:
zl5011xLanInitStructInit
Description:
Initialises structure used by zl5011xLanInit function.
Inputs:
zl5011xParams Pointer to the structure for this device instance
par Pointer to the structure for configuration items.
See main function
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xLanInitStructInit(zl5011xParamsS *zl5011xParams, zl5011xLanInitS *par)
{
zlStatusE status = ZL5011X_OK;
if (status == ZL5011X_OK)
{
ZL5011X_TRACE(ZL5011X_INIT_FN_ID, "zl5011xLanInitStructInit: ", 0, 0, 0, 0, 0, 0);
par->maxPacketQueueGranules = (Uint32T)ZL5011X_INVALID;
par->rtpInterruptPeriodMs = 5;
par->osExclusionEnable = ZL5011X_TRUE;
par->unmatchedProtocolLoopback = ZL5011X_FALSE;
par->packetLoopbackConfig.protocolType = ZL5011X_LOOPBACK_ETHERNET;
par->packetLoopbackConfig.header = NULL;
par->packetLoopbackConfig.portNum = (Uint8T)ZL5011X_INVALID;
par->packetLoopbackConfig.queueNum = (Uint8T)ZL5011X_INVALID;
par->packetLoopbackConfig.enableVlan = ZL5011X_FALSE;
par->packetLoopbackConfig.ethernetSrcAddressFromMac = ZL5011X_TRUE;
}
return status;
}
/*******************************************************************************
Function:
zl5011xLanInit
Description:
This function initialises the LAN interface blocks. The Tx low headers are
setup and the queues initialised. Sets the frequency of the RTP interrupt.
This function does not configure the actual Lan ports. The ports can be
configured after this function has been run.
There are several functions used to configure the device from reset. They
are shown below, and must be called in this sequence, in order to enable the
device.
zl5011xInit
zl5011xConfigureMemory
zl5011xWanInit
zl5011xLanInit
zl5011xRun
Inputs:
zl5011xParams Pointer to the structure for this device instance
par Pointer to the structure for configuration items. See below:
Structure inputs:
maxPacketQueueGranules maximum number of granules to use for the packet
queues
rtpInterruptPeriodMs the minimum time between RTP interrupts in
milli-seconds
unmatchedProtocolLoopback set to ZL5011X_TRUE to configure loopback for
any packets that fail the packet Rx protocol
match.
packetLoopbackConfig configuration for the header to be attached to the
loopback packets. The three types of header are :-
ETHERNET - replaces the src and dest MAC addresses
IP_UDP - adds an extra ethernet->IPv4->UDP header
MPLS - adds an extra ethernet->MPLS header
osExclusionEnable ZL5011X_TRUE to enable OS exclusion
Structure outputs:
None
Returns:
zlStatusE
Remarks:
The RTP interrupt is enabled from the block, but not from the device (the
interrupt needs to be enabled at the top level).
It is probably not desirable to have all packets looped back before the
active contexts etc. have been programmed, so this function only configures
the loopback and does NOT enable it. The loopback can be enabled / disabled
by calling zl5011xPacketLoopbackControl.
*******************************************************************************/
zlStatusE zl5011xLanInit(zl5011xParamsS *zl5011xParams, zl5011xLanInitS *par)
{
zlStatusE status = ZL5011X_OK;
zl5011xBooleanE gotDevice = ZL5011X_FALSE;
/* do some parameter checking */
status = ZL5011X_CHECK_POINTERS(zl5011xParams, par);
if ((status == ZL5011X_OK) && (par->osExclusionEnable == ZL5011X_TRUE))
{
/* get access to the device */
status = zl5011xGetDevice(zl5011xParams, ZL5011X_GET_DEVICE_TIMEOUT_MODE);
if (status == ZL5011X_OK)
{
gotDevice = ZL5011X_TRUE;
}
}
/* main function code starts */
if (status == ZL5011X_OK)
{
ZL5011X_TRACE(ZL5011X_INIT_FN_ID,
"zl5011xLanInit: ",
0, 0, 0, 0, 0, 0);
/* the WAN must be initialised before the LAN is configured */
if (zl5011xParams->wanInitialised == ZL5011X_FALSE)
{
status = ZL5011X_WAN_NOT_INIT;
}
}
if (status == ZL5011X_OK)
{
if (zl5011xParams->lanInitialised == ZL5011X_TRUE)
{
status = ZL5011X_MULTIPLE_INIT_ATTEMPT;
}
}
/* initialise the LAN blocks - PKQ and PTX do not have initialisation bits */
if (status == ZL5011X_OK)
{
status = zl5011xInitBlocks(zl5011xParams, ZL5011X_ADM_PKI_BIT | ZL5011X_ADM_PRX_BIT |
ZL5011X_ADM_PKC_BIT | ZL5011X_ADM_RTP_BIT);
}
/* enable the PTX block, this does not have an init, and needs to be run
before it can be accessed */
if (status == ZL5011X_OK)
{
status = zl5011xAdmEnableBlocks(zl5011xParams, ZL5011X_ADM_PTX_BIT);
}
if (status == ZL5011X_OK)
{
status = zl5011xPkiInit(zl5011xParams);
}
if (status == ZL5011X_OK)
{
status = zl5011xPkcInit(zl5011xParams);
}
if (status == ZL5011X_OK)
{
status = zl5011xPrxInit(zl5011xParams);
}
if (status == ZL5011X_OK)
{
status = zl5011xPtxInit(zl5011xParams);
}
/* configure the PTX - ethernet and IP header generation */
if (status == ZL5011X_OK)
{
status = zl5011xPtxConfigure(zl5011xParams);
}
/* PKQ initialisation */
if (status == ZL5011X_OK)
{
status = zl5011xPkqInit(zl5011xParams);
}
if (status == ZL5011X_OK)
{
/* if the value has been set by the calling function then make the call */
if (par->maxPacketQueueGranules != (Uint32T)ZL5011X_INVALID)
{
status = zl5011xPkqSetTotalGranuleThreshold(zl5011xParams,
par->maxPacketQueueGranules);
}
}
if (status == ZL5011X_OK)
{
status = zl5011xRtpInit(zl5011xParams);
}
if (status == ZL5011X_OK)
{
status = zl5011xRtpSetInterruptPeriod(zl5011xParams, par->rtpInterruptPeriodMs);
}
if (status == ZL5011X_OK)
{
status = zl5011xRtpConfigure(zl5011xParams,
ZL5011X_RTP_STATS_BASE, ZL5011X_RTP_HEADER_BASE);
}
if (par->unmatchedProtocolLoopback == ZL5011X_TRUE)
{
/* set up the packet Tx header first */
if (status == ZL5011X_OK)
{
if (par->packetLoopbackConfig.header == NULL)
{
status = ZL5011X_PARAMETER_INVALID;
}
else
{
status = zl5011xPacketTxLoopback(zl5011xParams, &(par->packetLoopbackConfig));
}
}
/* set up the packet Rx for unmatched packets */
if (status == ZL5011X_OK)
{
status = zl5011xPacketRxLoopback(zl5011xParams, &(par->packetLoopbackConfig),
par->unmatchedProtocolLoopback);
}
if (status == ZL5011X_OK)
{
zl5011xParams->packetIf.unmatchedProtocolLoopback = par->unmatchedProtocolLoopback;
}
}
if (status == ZL5011X_OK)
{
zl5011xParams->lanInitialised = ZL5011X_TRUE;
}
if (gotDevice == ZL5011X_TRUE)
{
if (status == ZL5011X_OK)
{
status = zl5011xReleaseDevice(zl5011xParams);
}
else
{
/* already have an error code, so don't overwrite it */
(void)zl5011xReleaseDevice(zl5011xParams);
}
}
return status;
}
/*******************************************************************************
Function:
zl5011xRunStructInit
Description:
Initialises structure used by zl5011xRun function.
Inputs:
zl5011xParams Pointer to the structure for this device instance
par Pointer to the structure for configuration items.
See main function
Returns:
zlStatusE
Remarks:
None
*******************************************************************************/
zlStatusE zl5011xRunStructInit(zl5011xParamsS *zl5011xParams, zl5011xRunS *par)
{
zlStatusE status = ZL5011X_OK;
if (status == ZL5011X_OK)
{
ZL5011X_TRACE(ZL5011X_INIT_FN_ID, "zl5011xRunStructInit: ", 0, 0, 0, 0, 0, 0);
par->osExclusionEnable = ZL5011X_TRUE;
}
return status;
}
/*******************************************************************************
Function:
zl5011xRun
Description:
This function is the last stage of the initialisation sequence. If all of the
other initialisation functions has completed successfully, then the blocks are
put into run mode.
There are several functions used to configure the device from reset. They
are shown below, and must be called in this sequence, in order to enable the
device.
zl5011xInit
zl5011xConfigureMemory
zl5011xWanInit
zl5011xLanInit
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -