📄 vc.c
字号:
// DBGPRINT(DBG_COMP_VC, DBG_LEVEL_INFO,
DBGPRINT(DBG_COMP_VC, DBG_LEVEL_INFO,
("==>tbAtm155AllocateReceiveSegment\n"));
do
{
//
// Get a local copy of the receive buffer size.
//
MaxReceiveBufferSize =
pAdapter->RegistryParameters[TbAtm155BigReceiveBufferSize].Value;
//
// Verify PDU.
//
if ((0 == pRecvFlow->MaxSduSize) ||
(MAX_AAL5_PDU_SIZE < pRecvFlow->MaxSduSize))
{
DBGPRINT(DBG_COMP_VC, DBG_LEVEL_ERR,
("Invalid Sdu size in pRecvFlow->MaxSduSize (0x%lx)\n",
pRecvFlow->MaxSduSize));
Status = NDIS_STATUS_INVALID_DATA;
break;
}
//
// Allocate memory for the receive segment information.
//
ALLOCATE_MEMORY(&Status, &pRecvSegInfo, sizeof(RECV_SEG_INFO), '01DA');
if (NDIS_STATUS_SUCCESS != Status)
{
DBGPRINT(DBG_COMP_VC, DBG_LEVEL_ERR,
("Unable to allocate storage for the receive segment information\n"));
break;
}
//
// Initialize the receive segment information.
//
ZERO_MEMORY(pRecvSegInfo, sizeof(RECV_SEG_INFO));
NdisAllocateSpinLock(&pRecvSegInfo->lock);
//
// Save the receive segment information with the VC.
//
pVc->RecvSegInfo = pRecvSegInfo;
//
// Save the receive flow parameters.
//
pVc->Receive = *pRecvFlow;
//
// Align the receive segment size.
//
RcvSegmentSize = tbAtm155NextPowerOf2(pVc->Receive.MaxSduSize);
//
// Fill in the local VCI table entry but do not yet program/enable
// any hardware.
//
pRecvSegInfo->pAdapter = pAdapter;
pRecvSegInfo->SegmentSize = RcvSegmentSize;
//
// Poin to small and big free receive buffer queues.
//
pRecvSegInfo->FreeSmallBufQ = &pSar->FreeSmallBufferQ;
pRecvSegInfo->FreeBigBufQ = &pSar->FreeBigBufferQ;
//
// Allocate a receive buffer information structure.
//
Status = tbAtm155AllocateReceiveBufferInfo(
&pRecvSegInfo->pRecvBufferInfo,
pVc);
if (NDIS_STATUS_SUCCESS != Status)
{
DBGPRINT(DBG_COMP_VC, DBG_LEVEL_ERR,
("Failed to allocate RECV_BUFFER_INFO for a VC.\n"));
break;
}
//
// By setting this flag we know that we need to complete
// the VC activation once the receive pool has been allocated.
//
RECV_INFO_SET_FLAG(
pRecvSegInfo->pRecvBufferInfo,
fRECV_INFO_COMPLETE_VC_ACTIVATION);
//
// Get the starting address of the VC entry of Rx State table.
//
pRecvSegInfo->pEntryOfRecvState =
pHwInfo->pSramRxVcStateTbl +
(pVc->VpiVci.Vci * SIZEOF_RX_STATE_ENTRY);
pRecvState = &pRecvSegInfo->InitRecvState;
NdisZeroMemory (
(PVOID)(pRecvState),
sizeof(TBATM155_RX_STATE_ENTRY));
//
// Set Open in the init value to indicate the Vc has been
// opened by driver.
//
pRecvState->RxStateWord4.Rx_AAL5_CRC_Low = 0x0FFFF;
pRecvState->RxStateWord5.Rx_AAL5_CRC_High = 0x0FFFF;
//
// Set Open in the init value to indicate the Vc has been
// opened by driver later
//
pRecvState->RxStateWord0.Open = 1;
pRegistryParameters = pAdapter->RegistryParameters;
if (RcvSegmentSize > (pRegistryParameters[TbAtm155SmallReceiveBufferSize].Value))
{
DBGPRINT(DBG_COMP_VC, DBG_LEVEL_INFO,
("Allocate Big receive buffers\n"));
//
// uses big buffers for this VC.
//
pVc->RecvBufType = RECV_BIG_BUFFER;
//
// Initialize register values of Rx_State_Entry (in Off-Chip RAM)
//
pRecvState->RxStateWord0.Slot_Type = 1;
if (pSar->AllocatedBigRecvBuffers >= pSar->MaxRecvBufferCount)
{
DBGPRINT(DBG_COMP_VC, DBG_LEVEL_INFO,
("AllocatedBigRecvBuffers >= MaxRecvBufferCount\n"));
Status = NDIS_STATUS_SUCCESS;
break;
}
//
// Allocate the receive buffer pool.
//
Status = tbAtm155AllocateReceiveBufferPool(
pAdapter,
pRecvSegInfo->pRecvBufferInfo,
(ULONG)DEFAULT_RECEIVE_BUFFERS,
pRegistryParameters[TbAtm155BigReceiveBufferSize].Value);
}
else
{
DBGPRINT(DBG_COMP_VC, DBG_LEVEL_INFO,
("Allocate Small receive buffers\n"));
//
// uses small buffers for this VC.
//
pVc->RecvBufType = RECV_SMALL_BUFFER;
//
// The Rx_State_Entry in Off-Chip RAM has been set to init values.
//
// pRecvState->Slot_Type = 0;
//
if (pSar->AllocatedSmallRecvBuffers >= pSar->MaxRecvBufferCount)
{
DBGPRINT(DBG_COMP_VC, DBG_LEVEL_INFO,
("AllocatedSmallRecvBuffers >= MaxRecvBufferCount\n"));
Status = NDIS_STATUS_SUCCESS;
break;
}
//
// Allocate the receive buffer pool.
//
Status = tbAtm155AllocateReceiveBufferPool(
pAdapter,
pRecvSegInfo->pRecvBufferInfo,
(ULONG)DEFAULT_RECEIVE_BUFFERS,
pRegistryParameters[TbAtm155SmallReceiveBufferSize].Value);
}
if (NDIS_STATUS_PENDING != Status)
{
DBGPRINT(DBG_COMP_VC, DBG_LEVEL_ERR,
("Can't to allocate RECV_BUFFER_POOL for VC %u\n", pVc->VpiVci.Vci));
break;
}
} while (FALSE);
//
// If there was a failure then clean up.
//
if ((NDIS_STATUS_SUCCESS != Status) && (NDIS_STATUS_PENDING != Status))
{
tbAtm155FreeReceiveSegment(pVc);
}
DBGPRINT(DBG_COMP_VC, DBG_LEVEL_INFO,
("<==tbAtm155AllocateReceiveSegment (Status: 0x%lx)\n", Status));
return(Status);
}
VOID
tbAtm155FreeTransmitSegment(
IN PADAPTER_BLOCK pAdapter,
IN PVC_BLOCK pVc
)
/*++
Routine Description:
This routine will free up transmit resources for the VC.
Arguments:
Return Value:
--*/
{
PXMIT_SEG_INFO pXmitSegInfo;
PATM_FLOW_PARAMETERS pXmitFlow = &pVc->Transmit;
NDIS_STATUS Status;
//
// Did we get a transmit segment allocated?
//
if (NULL != pVc->XmitSegInfo)
{
pXmitSegInfo = pVc->XmitSegInfo;
#if DBG
if ((pXmitSegInfo->DmaCompleting.References) ||
(pXmitSegInfo->SegWait.References))
{
DBGPRINT(DBG_COMP_VC, DBG_LEVEL_INFO,
("There are still Tx buffer queued in the list.\n"));
DBGBREAK(DBG_COMP_VC, DBG_LEVEL_ERR);
}
#endif // end of DBG
//=================================
#if ABR_CODE
//=================================
if (NULL != pXmitFlow)
{
switch (pXmitFlow->ServiceCategory) {
case ATM_SERVICE_CATEGORY_CBR:
//
// Modify the CBR schedule table accordingly.
//
Status = tbAtm155SetCbrTblsInSRAM(pAdapter, pVc, FALSE);
//
// re-adjust Trasnmit remaining bandwidth.
//
pAdapter->RemainingTransmitBandwidth += pXmitFlow->PeakCellRate;
pAdapter->TotalEntriesUsedonCBRs -= pVc->CbrNumOfEntris;
pVc->CbrNumOfEntris = 0;
pVc->CbrPreScaleVal = 0;
#if AW_QOS
//
// The Number of available CBR VCs
// 9/17/97 - Please read the note where declares this
// variable (in SW.H).
//
pAdapter->NumOfAvailableCbrVc++;
#endif // end of AW_QOS
break;
case ATM_SERVICE_CATEGORY_ABR:
pAdapter->RemainingTransmitBandwidth += pXmitFlow->MinimumCellRate;
break;
}
}
//=================================
#else // not ABR_CODE
//=================================
if ((NULL != pXmitFlow) &&
(ATM_SERVICE_CATEGORY_CBR == pXmitFlow->ServiceCategory))
{
//
// Modify the CBR schedule table accordingly.
//
Status = tbAtm155SetCbrTblsInSRAM(pAdapter, pVc, FALSE);
//
// re-adjust Trasnmit remaining bandwidth.
//
pAdapter->RemainingTransmitBandwidth += pXmitFlow->PeakCellRate;
pAdapter->TotalEntriesUsedonCBRs -= pVc->CbrNumOfEntris;
pVc->CbrNumOfEntris = 0;
pVc->CbrPreScaleVal = 0;
#if AW_QOS
//
// The Number of available CBR VCs
// 9/17/97 - Please read the note where declares this
// variable (in SW.H).
//
pAdapter->NumOfAvailableCbrVc++;
#endif // end of AW_QOS
}
//=================================
#endif // end of ABR_CODE
//=================================
tbAtm155FreeTransmitBuffers(pAdapter, pVc);
NdisFreeSpinLock(&pXmitSegInfo->lock);
FREE_MEMORY(pXmitSegInfo, sizeof(XMIT_SEG_INFO));
pVc->XmitSegInfo = NULL;
}
//
// Just clear the flag.
//
VC_CLEAR_FLAG(pVc, fVC_TRANSMIT);
}
NDIS_STATUS
tbAtm155AllocateTransmitSegment(
IN PADAPTER_BLOCK pAdapter,
IN PVC_BLOCK pVc,
IN PCO_MEDIA_PARAMETERS pMediaParameters,
IN PATM_MEDIA_PARAMETERS pAtmMediaParms
)
/*++
Routine Description:
This routine will allocate transmit resources for the VC.
Arguments:
pAdapter - Pointer to the ADAPTER_BLOCK.
pVc - Pointer to the VC_BLOCK that we are allocating transmit
resources for.
pMediaParameters
Return Value:
--*/
{
NDIS_STATUS Status = NDIS_STATUS_SUCCESS;
PHARDWARE_INFO pHwInfo = pAdapter->HardwareInfo;
PATM_FLOW_PARAMETERS pXmitFlow = &pAtmMediaParms->Transmit;
ULONG PreScaleVal = 0;
ULONG NumOfEntries = 0;
PXMIT_SEG_INFO pXmitSegInfo = NULL;
PTBATM155_TX_STATE_ENTRY pXmitState;
ULONG RequestedSize;
do
{
//
// Verify PDU.
//
if ((0 == pXmitFlow->MaxSduSize) ||
(MAX_AAL5_PDU_SIZE < pXmitFlow->MaxSduSize))
{
DBGPRINT(DBG_COMP_VC, DBG_LEVEL_ERR,
("Invalid Sdu size in pXmitFlow->MaxSduSize (0x%lx)\n",
pXmitFlow->MaxSduSize));
return(NDIS_STATUS_INVALID_DATA);
}
//
// Allocate memory for the transmit segment information.
//
ALLOCATE_MEMORY(&Status, &pXmitSegInfo, sizeof(XMIT_SEG_INFO), '51DA');
if (NDIS_STATUS_SUCCESS != Status)
{
DBGPRINT(DBG_COMP_VC, DBG_LEVEL_ERR,
("Unable to allocate storage for the transmit segment information\n"));
break;
}
//
// Initialize the transmit segment information.
//
ZERO_MEMORY(pXmitSegInfo, sizeof(XMIT_SEG_INFO));
NdisAllocateSpinLock(&pXmitSegInfo->lock);
//
// Save the transmit segment information to the VC.
//
pVc->XmitSegInfo = pXmitSegInfo;
//
// Get the requested maximum service data unit size.
//
RequestedSize = pXmitFlow->MaxSduSize;
//
// If the VC is CBR then we need to adjust the traffic parameters.
//
if (ATM_SERVICE_CATEGORY_CBR == pXmitFlow->ServiceCategory)
{
//
// Determine bandwidth adjustments if any....
//
Status = tbAtm155AdjustTrafficParameters(
pAdapter,
pXmitFlow,
(BOOLEAN)((pMediaParameters->Flags & ROUND_UP_FLOW) == ROUND_UP_FLOW),
&PreScaleVal,
&NumOfEntries);
if (NDIS_STATUS_SUCCESS != Status)
{
DBGPRINT(DBG_COMP_VC, DBG_LEVEL_ERR,
("Unable to adjust the traffic paramters for VC: 0x%x\n", pVc->VpiVci.Vci));
Status = NDIS_STATUS_INVALID_DATA;
break;
}
//
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -