?? zl5011xpla.c
字號:
if ((zl5011xParams->wanIf.plaCurrent.channel[loop].context == context) ||
(zl5011xParams->wanIf.plaActive.channel[loop].context == context))
{
zl5011xParams->wanIf.plaCurrent.channel[loop].context = (Uint32T)ZL5011X_INVALID_CONTEXT;
zl5011xParams->wanIf.plaActive.channel[loop].context = (Uint32T)ZL5011X_INVALID_CONTEXT;
}
}
zl5011xParams->wanIf.plaCurrent.context[context].numChannels = 0;
zl5011xParams->wanIf.plaCurrent.context[context].firstChannelIndex = (Uint32T)ZL5011X_INVALID_CHANNEL;
zl5011xParams->wanIf.plaActive.context[context].numChannels = 0;
zl5011xParams->wanIf.plaActive.context[context].firstChannelIndex = (Uint32T)ZL5011X_INVALID_CHANNEL;
/* the context now has no channels associated, but we have to wait for the
queue to flush before we can reuse the context */
zl5011xParams->wanIf.plaCurrent.context[context].state = ZL5011X_STATE_NOT_IN_USE;
return(status);
}
/*****************************************************************************
Function:
zl5011xPlaUpdateActiveContext
Description:
Copies the context setup from the current structures to the active
structures. This frees up any channels that were used in the active channel
but are no longer used.
Sets the state for the context to be active.
Inputs:
zl5011xParams Pointer to the structure for this device instance
context which context to update
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*****************************************************************************/
zlStatusE zl5011xPlaUpdateActiveContext(zl5011xParamsS *zl5011xParams, Uint32T context)
{
zlStatusE status = ZL5011X_OK;
Uint32T loop;
ZL5011X_TRACE(ZL5011X_PLA_FN_ID, "zl5011xPlaUpdateActiveContext: ctxt %3d",
context, 0, 0, 0, 0, 0);
/* copy the channel information from current to active structure */
for (loop = 0; loop < ZL5011X_MAX_NUMBER_CHANNELS; loop++)
{
if ((zl5011xParams->wanIf.plaCurrent.channel[loop].context == context) ||
(zl5011xParams->wanIf.plaActive.channel[loop].context == context))
{
zl5011xParams->wanIf.plaActive.channel[loop].context =
zl5011xParams->wanIf.plaCurrent.channel[loop].context;
}
}
/* copy the context information from current to active structure */
memcpy(zl5011xParams->wanIf.plaActive.context + context,
zl5011xParams->wanIf.plaCurrent.context + context,
sizeof(zl5011xWanTxContextS));
zl5011xParams->wanIf.plaCurrent.context[context].state = ZL5011X_STATE_ACTIVE;
return(status);
}
/*****************************************************************************
Function:
zl5011xPlaTeardownContext
Description:
Sets the teardown bit for the context. If an update has been requested, then
clear that and set the teardown bit.
Inputs:
zl5011xParams Pointer to the structure for this device instance
context which context
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*****************************************************************************/
zlStatusE zl5011xPlaTeardownContext(zl5011xParamsS *zl5011xParams, Uint32T context)
{
zlStatusE status = ZL5011X_OK;
Uint32T temp;
ZL5011X_TRACE(ZL5011X_PLA_FN_ID, "zl5011xPlaTeardownContext: ctxt %3d",
context, 0, 0, 0, 0, 0);
if (zl5011xParams->wanIf.plaCurrent.context[context].state != ZL5011X_STATE_TAKEN)
{
status = ZL5011X_CONTEXT_NOT_TAKEN;
}
if (status == ZL5011X_OK)
{
status = zl5011xRead(zl5011xParams,
ZL5011X_PLA_CONTEXT_MEMORY1 + (context * ZL5011X_PLA_CTXT_MEM1_SIZE),
&temp);
}
if (status == ZL5011X_OK)
{
/* if a teardown is requested, then cancel the update bit if it were
set, since teardown is a higher priority */
temp |= ZL5011X_1BIT_MASK << ZL5011X_PLA_TEARDOWN_BIT;
temp &= ~(ZL5011X_1BIT_MASK << ZL5011X_PLA_UPDATE_BIT);
status = zl5011xWrite(zl5011xParams,
ZL5011X_PLA_CONTEXT_MEMORY1 + (context * ZL5011X_PLA_CTXT_MEM1_SIZE),
temp);
zl5011xParams->wanIf.plaCurrent.context[context].state = ZL5011X_STATE_TEARING_DOWN;
}
return(status);
}
/*****************************************************************************
Function:
zl5011xPlaUpdateContext
Description:
Sets the update bit for the context.
Inputs:
zl5011xParams Pointer to the structure for this device instance
context which context
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*****************************************************************************/
zlStatusE zl5011xPlaUpdateContext(zl5011xParamsS *zl5011xParams, Uint32T context)
{
zlStatusE status = ZL5011X_OK;
Uint32T temp;
ZL5011X_TRACE(ZL5011X_PLA_FN_ID, "zl5011xPlaUpdateContext: ctxt %3d",
context, 0, 0, 0, 0, 0);
/* the context can be updated from the INIT or TAKEN state. The error code is
to show that the context needs to be taken before it can be updated */
if ((zl5011xParams->wanIf.plaCurrent.context[context].state != ZL5011X_STATE_TAKEN) &&
(zl5011xParams->wanIf.plaCurrent.context[context].state != ZL5011X_STATE_INIT))
{
status = ZL5011X_CONTEXT_NOT_TAKEN;
}
if (status == ZL5011X_OK)
{
status = zl5011xRead(zl5011xParams,
ZL5011X_PLA_CONTEXT_MEMORY1 + (context * ZL5011X_PLA_CTXT_MEM1_SIZE),
&temp);
}
if (status == ZL5011X_OK)
{
/* cannot request an update and a teardown at the same time */
if ((temp & (ZL5011X_1BIT_MASK << ZL5011X_PLA_TEARDOWN_BIT)) != 0)
{
status = ZL5011X_CONTEXT_IN_UPDATE;
}
}
if (status == ZL5011X_OK)
{
/* set the update bit */
temp |= ZL5011X_1BIT_MASK << ZL5011X_PLA_UPDATE_BIT;
status = zl5011xWrite(zl5011xParams,
ZL5011X_PLA_CONTEXT_MEMORY1 + (context * ZL5011X_PLA_CTXT_MEM1_SIZE),
temp);
zl5011xParams->wanIf.plaCurrent.context[context].state = ZL5011X_STATE_UPDATING;
}
return(status);
}
/*****************************************************************************
Function:
zl5011xPlaSetPayloadLength
Description:
Sets the payload length in bytes for the context.
Inputs:
zl5011xParams Pointer to the structure for this device instance
context which context to get the length for.
length number of bytes per packet for the context
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*****************************************************************************/
zlStatusE zl5011xPlaSetPayloadLength(zl5011xParamsS *zl5011xParams, Uint32T context,
Uint32T length)
{
Uint32T bit, bitMask;
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE_CONTEXT(ZL5011X_PLA_FN_ID, context,
"zl5011xPlaSetPayloadLength: ctxt %3d, length %d",
context, length, 0, 0, 0, 0);
if ((length & ~ZL5011X_PLA_PKT_LENGTH_MASK) != 0)
{
status = ZL5011X_PARAMETER_INVALID;
}
if (status == ZL5011X_OK)
{
bit = length << ZL5011X_PLA_PKT_LENGTH_BITS;
bitMask = ZL5011X_PLA_PKT_LENGTH_MASK << ZL5011X_PLA_PKT_LENGTH_BITS;
status = zl5011xReadModWrite(zl5011xParams,
ZL5011X_PLA_CONTEXT_MEMORY1 + (context * ZL5011X_PLA_CTXT_MEM1_SIZE),
bit, bitMask);
}
return(status);
}
/*****************************************************************************
Function:
zl5011xPlaSetFlowType
Description:
Sets the flow type for the context, and adds the MPID.
Inputs:
zl5011xParams Pointer to the structure for this device instance
context which context to operate on
flow flow type to program
mpid value to set in the MPID field for this context
Outputs:
none
Returns:
zlStatusE
Remarks:
None
*****************************************************************************/
zlStatusE zl5011xPlaSetFlowType(zl5011xParamsS *zl5011xParams, Uint32T context,
zl5011xFlowTypeE flow, Uint32T mpid)
{
Uint32T bits, bitMask;
zlStatusE status = ZL5011X_OK;
ZL5011X_TRACE_CONTEXT(ZL5011X_PLA_FN_ID, context,
"zl5011xPlaSetFlowType: ctxt %3d, flow %d, mpid %3d",
context, flow, mpid, 0, 0, 0);
status = ZL5011X_CHECK_FLOW_TYPE(flow);
if (status == ZL5011X_OK)
{
if ((mpid & ~ZL5011X_PLA_CONTEXT_MASK) != 0)
{
status = ZL5011X_PARAMETER_INVALID;
}
}
if (status == ZL5011X_OK)
{
bits = (flow << ZL5011X_PLA_FLOW_TYPE_BITS) |
(mpid << ZL5011X_PLA_MPID_BITS);
bitMask = (ZL5011X_PLA_FLOW_TYPE_MASK << ZL5011X_PLA_FLOW_TYPE_BITS) |
(ZL5011X_PLA_MPID_MASK << ZL5011X_PLA_MPID_BITS);
status = zl5011xReadModWrite(zl5011xParams,
ZL5011X_PLA_CONTEXT_MEMORY2 + (context * ZL5011X_PLA_CTXT_MEM2_SIZE),
bits, bitMask);
}
return(status);
}
/*****************************************************************************
Function:
zl5011xPlaSetInterruptMask
Description:
Sets the interrupt mask bits in the device.
Inputs:
zl5011xParams Pointer to the structure for this device instance
context which context to get the length for.
intBits interrupt mask bits
Outputs:
None
Returns:
zlStatusE
Remarks:
None
*****************************************************************************/
zlStatusE zl5011xPlaSetInterruptMask(zl5011xParamsS *zl5011xParams, Uint32T context,
Uint32T intBits)
{
zlStatusE status = ZL5011X_OK;
Uint32T bitMask;
ZL5011X_TRACE(ZL5011X_PLA_FN_ID, "zl5011xPlaSetInterruptMask: ctxt %3d, mask %08X",
context, intBits, 0, 0, 0, 0);
bitMask = (ZL5011X_1BIT_MASK << ZL5011X_PLA_QUEUE_ERR_INT) |
(ZL5011X_1BIT_MASK << ZL5011X_PLA_QUEUE_WARN_INT) |
(ZL5011X_1BIT_MASK << ZL5011X_PLA_CACHE_ERR_INT) |
(ZL5011X_1BIT_MASK << ZL5011X_PLA_GRANULE_ERR_INT) |
(ZL5011X_1BIT_MASK << ZL5011X_PLA_FRAME_INT);
status = zl5011xReadModWrite(zl5011xParams,
ZL5011X_PLA_CONTEXT_MEMORY1 + (context * ZL5011X_PLA_CTXT_MEM1_SIZE),
intBits, bitMask);
return(status);
}
/*****************************************************************************
Function:
zl5011xPlaGetCurrentHeader
Description:
This function is called to get the state of the current ctxt_sw bit.
This bit is used to select the header to attach in the packet formation
blocks.
Inputs:
zl5011xParams Pointer to the structure for this device instance
context which context to get the ctct sw for
Outputs:
ctxtSw which header is currently in use.
Returns:
zlStatusE
Remarks:
None
*****************************************************************************/
zlStatusE zl5011xPlaGetCurrentHeader(zl5011xParamsS *zl5011xParams,
Uint32T context, zl5011xContextHeaderSwitchE *ctxtSw)
{
zlStatusE status = ZL5011X_OK;
Uint32T readValue;
status = zl5011xRead(zl5011xParams,
ZL5011X_PLA_STATE_MEMORY1 + (context * ZL5011X_PLA_CTXT_MEM1_SIZE),
&readValue);
if ((readValue & (ZL5011X_1BIT_MASK >> ZL5011X_PLA_CTXT_SW_BIT)) == 0)
{
*ctxtSw = ZL5011X_PRIMARY_HEADER;
}
else
{
*ctxtSw = ZL5011X_SECONDARY_HEADER;
}
ZL5011X_TRACE_CONTEXT(ZL5011X_PLA_FN_ID, context,
"zl5011xPlaGetCurrentHeader: ctxt %3d, ctxt sw %d",
context, *ctxtSw, 0, 0, 0, 0);
return(status);
}
/*****************************************************************************
Function:
zl5011xPlaGetErroredContext
Description:
This function is called to get a context ID from the interrupt queue.
Inputs:
zl5011xParams Pointer to the structure for this device instance
Outputs:
context ID from the interrupt queue
Returns:
zlStatusE
Remarks:
None
*****************************************************************************/
zlStatusE zl5011xPlaGetErroredContext(zl5011xParamsS *zl5011xParams,
Uint32T *context)
{
zlStatusE status = ZL5011X_OK;
Uint32T readValue;
status = zl5011xRead(zl5011xParams, ZL5011X_PLA_INTERRUPT_QUEUE,
&readValue);
*context = (readValue >> ZL5011X_PLA_INT_QUEUE_CTXT_BITS) & ZL5011X_PLA_CONTEXT_MASK;
ZL5011X_TRACE(ZL5011X_PLA_FN_ID, "zl5011xPlaGetErroredContext: ctxt %3d",
*context, 0, 0, 0, 0, 0);
return(status);
}
/*****************************************************************************
Function:
zl5011xPlaGetError
Description:
Collects the error flags for a context, and resets them.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -