void _HTC_ResumeRecv(HTC_ENDPOINT_ID EndpointID);
LOCAL void HTCProcessConnectMsg(HTC_CONTEXT *pHTC, HTC_CONNECT_SERVICE_MSG *pMsg);
LOCAL void HTCProcessConfigPipeMsg(HTC_CONTEXT *pHTC, HTC_CONFIG_PIPE_MSG *pMsg);
void _HTC_ResumeRecv(HTC_ENDPOINT_ID EndpointID);
LOCAL void HTCProcessConnectMsg(HTC_CONTEXT *pHTC, HTC_CONNECT_SERVICE_MSG *pMsg);
LOCAL void HTCProcessConfigPipeMsg(HTC_CONTEXT *pHTC, HTC_CONFIG_PIPE_MSG *pMsg);
a dynamic threshold */
#define CHECK_AND_ADJUST_CREDIT_THRESHOLD(pEndpoint) \
if ((pEndpoint)->ConnectionFlags & HTC_CONNECT_FLAGS_REDUCE_CREDIT_DRIBBLE) { \
AdjustCreditThreshold((pEndpoint)); \
a dynamic threshold */
#define CHECK_AND_ADJUST_CREDIT_THRESHOLD(pEndpoint) \
if ((pEndpoint)->ConnectionFlags & HTC_CONNECT_FLAGS_REDUCE_CREDIT_DRIBBLE) { \
AdjustCreditThreshold((pEndpoint)); \
- BUF_Pool_create_pool(pHTC->PoolHandle, POOL_ID_HTC_CONTROL, Count, Size);
+ BUF_Pool_create_pool(pHTC->PoolHandle, POOL_ID_HTC_CONTROL, Count, Size);
}
LOCAL htc_handle_t _HTC_Init(HTC_SETUP_COMPLETE_CB SetupComplete,
HTC_CONFIG *pConfig)
{
HIF_CALLBACK hifCBConfig;
}
LOCAL htc_handle_t _HTC_Init(HTC_SETUP_COMPLETE_CB SetupComplete,
HTC_CONFIG *pConfig)
{
HIF_CALLBACK hifCBConfig;
adf_os_mem_zero(pHTC, sizeof(HTC_CONTEXT));
pHTC->OSHandle = pConfig->OSHandle;
pHTC->PoolHandle = pConfig->PoolHandle;
pHTC->hifHandle = pConfig->HIFHandle;
adf_os_mem_zero(pHTC, sizeof(HTC_CONTEXT));
pHTC->OSHandle = pConfig->OSHandle;
pHTC->PoolHandle = pConfig->PoolHandle;
pHTC->hifHandle = pConfig->HIFHandle;
hifCBConfig.send_buf_done = A_INDIR(htc._HTC_SendDoneHandler);
hifCBConfig.recv_buf = A_INDIR(htc._HTC_MsgRecvHandler);
hifCBConfig.context = pHTC;
hifCBConfig.send_buf_done = A_INDIR(htc._HTC_SendDoneHandler);
hifCBConfig.recv_buf = A_INDIR(htc._HTC_MsgRecvHandler);
hifCBConfig.context = pHTC;
/* initialize hardware layer */
HIF_register_callback(pConfig->HIFHandle, &hifCBConfig);
/* initialize hardware layer */
HIF_register_callback(pConfig->HIFHandle, &hifCBConfig);
/* see if the host wants us to override the number of ctrl buffers */
pHTC->NumBuffersForCreditRpts = 0;
/* see if the host wants us to override the number of ctrl buffers */
pHTC->NumBuffersForCreditRpts = 0;
if (0 == pHTC->NumBuffersForCreditRpts) {
/* nothing to override, simply set default */
if (0 == pHTC->NumBuffersForCreditRpts) {
/* nothing to override, simply set default */
}
/* calculate the total allocation size based on the number of credit report buffers */
pHTC->CtrlBufferAllocSize = MIN_CREDIT_BUFFER_ALLOC_SIZE * pHTC->NumBuffersForCreditRpts;
/* we need at least enough buffer space for 1 ctrl message */
pHTC->CtrlBufferAllocSize = A_MAX(pHTC->CtrlBufferAllocSize,MAX_HTC_SETUP_MSG_SIZE);
}
/* calculate the total allocation size based on the number of credit report buffers */
pHTC->CtrlBufferAllocSize = MIN_CREDIT_BUFFER_ALLOC_SIZE * pHTC->NumBuffersForCreditRpts;
/* we need at least enough buffer space for 1 ctrl message */
pHTC->CtrlBufferAllocSize = A_MAX(pHTC->CtrlBufferAllocSize,MAX_HTC_SETUP_MSG_SIZE);
/* save the size of each buffer/credit we will receive */
pHTC->RecvBufferSize = pConfig->CreditSize; //RecvBufferSize;
pHTC->TotalCredits = pConfig->CreditNumber;
pHTC->TotalCreditsAssigned = 0;
/* save the size of each buffer/credit we will receive */
pHTC->RecvBufferSize = pConfig->CreditSize; //RecvBufferSize;
pHTC->TotalCredits = pConfig->CreditNumber;
pHTC->TotalCreditsAssigned = 0;
/* setup the pseudo service that handles HTC control messages */
pHTC->HTCControlService.ProcessRecvMsg = A_INDIR(htc._HTC_ControlSvcProcessMsg);
pHTC->HTCControlService.ProcessSendBufferComplete = A_INDIR(htc._HTC_ControlSvcProcessSendComplete);
pHTC->HTCControlService.TrailerSpcCheckLimit = HTC_CTRL_BUFFER_CHECK_SIZE;
pHTC->HTCControlService.MaxSvcMsgSize = MAX_HTC_SETUP_MSG_SIZE;
pHTC->HTCControlService.ServiceCtx = pHTC;
/* setup the pseudo service that handles HTC control messages */
pHTC->HTCControlService.ProcessRecvMsg = A_INDIR(htc._HTC_ControlSvcProcessMsg);
pHTC->HTCControlService.ProcessSendBufferComplete = A_INDIR(htc._HTC_ControlSvcProcessSendComplete);
pHTC->HTCControlService.TrailerSpcCheckLimit = HTC_CTRL_BUFFER_CHECK_SIZE;
pHTC->HTCControlService.MaxSvcMsgSize = MAX_HTC_SETUP_MSG_SIZE;
pHTC->HTCControlService.ServiceCtx = pHTC;
/* automatically register this pseudo service to endpoint 1 */
pHTC->Endpoints[ENDPOINT0].pService = &pHTC->HTCControlService;
/* automatically register this pseudo service to endpoint 1 */
pHTC->Endpoints[ENDPOINT0].pService = &pHTC->HTCControlService;
/* set the first free endpoint */
pHTC->CurrentEpIndex = ENDPOINT1;
pHTC->SetupCompleteCb = SetupComplete;
/* set the first free endpoint */
pHTC->CurrentEpIndex = ENDPOINT1;
pHTC->SetupCompleteCb = SetupComplete;
/* setup buffers for just the setup phase, we only need 1 buffer to handle
* setup */
HTC_AssembleBuffers(pHTC, 4, MAX_HTC_SETUP_MSG_SIZE);
/* setup buffers for just the setup phase, we only need 1 buffer to handle
* setup */
HTC_AssembleBuffers(pHTC, 4, MAX_HTC_SETUP_MSG_SIZE);
adf_os_mem_free(pHTC);
}
LOCAL void _HTC_RegisterService(htc_handle_t htcHandle, HTC_SERVICE *pService)
{
HTC_CONTEXT *pHTC = (HTC_CONTEXT *)htcHandle;
adf_os_mem_free(pHTC);
}
LOCAL void _HTC_RegisterService(htc_handle_t htcHandle, HTC_SERVICE *pService)
{
HTC_CONTEXT *pHTC = (HTC_CONTEXT *)htcHandle;
/* an optimization... the header length is chosen to
* be aligned on a 16 bit bounday, the fields in the message are designed to
* be aligned */
/* an optimization... the header length is chosen to
* be aligned on a 16 bit bounday, the fields in the message are designed to
* be aligned */
- addr = adf_nbuf_put_tail(pBuffer, sizeof(HTC_READY_MSG));
- pReady = (HTC_READY_MSG *)addr;
- A_MEMZERO(pReady,sizeof(HTC_READY_MSG));
+ addr = adf_nbuf_put_tail(pBuffer, sizeof(HTC_READY_MSG));
+ pReady = (HTC_READY_MSG *)addr;
+ A_MEMZERO(pReady,sizeof(HTC_READY_MSG));
pReady->MessageID = adf_os_htons(HTC_MSG_READY_ID);
pReady->CreditSize = adf_os_htons((A_UINT16)pHTC->RecvBufferSize);
pReady->CreditCount = adf_os_htons((A_UINT16)pHTC->TotalCredits);
pReady->MaxEndpoints = ENDPOINT_MAX;
pReady->MessageID = adf_os_htons(HTC_MSG_READY_ID);
pReady->CreditSize = adf_os_htons((A_UINT16)pHTC->RecvBufferSize);
pReady->CreditCount = adf_os_htons((A_UINT16)pHTC->TotalCredits);
pReady->MaxEndpoints = ENDPOINT_MAX;
/* send out the message */
HTC_SendMsg(pHTC, ENDPOINT0, pBuffer);
/* now we need to wait for service connection requests */
/* send out the message */
HTC_SendMsg(pHTC, ENDPOINT0, pBuffer);
/* now we need to wait for service connection requests */
LOCAL void ReturnBuffers(htc_handle_t htcHandle, HTC_ENDPOINT_ID EndpointID,
adf_nbuf_t pBuffers, A_BOOL sendCreditFlag)
LOCAL void ReturnBuffers(htc_handle_t htcHandle, HTC_ENDPOINT_ID EndpointID,
adf_nbuf_t pBuffers, A_BOOL sendCreditFlag)
/* supply some head-room again */
adf_nbuf_push_head(pBuffers, HTC_HDR_LENGTH);
/* supply some head-room again */
adf_nbuf_push_head(pBuffers, HTC_HDR_LENGTH);
- HIF_return_recv_buf(pHTC->hifHandle, pHTC->Endpoints[EndpointID].UpLinkPipeID, pBuffers);
-
- if (pHTC->StateFlags & HTC_STATE_SETUP_COMPLETE) {
+ HIF_return_recv_buf(pHTC->hifHandle, pHTC->Endpoints[EndpointID].UpLinkPipeID, pBuffers);
+
+ if (pHTC->StateFlags & HTC_STATE_SETUP_COMPLETE) {
A_UINT32 epCreditMask = (1 << EndpointID);
/* we are running normally */
/* update pending credit counts with the number of buffers that were added */
pHTC->Endpoints[EndpointID].CreditsToReturn += (A_INT16)nbufs;
A_UINT32 epCreditMask = (1 << EndpointID);
/* we are running normally */
/* update pending credit counts with the number of buffers that were added */
pHTC->Endpoints[EndpointID].CreditsToReturn += (A_INT16)nbufs;
if (sendCreditFlag) {
HTCCheckAndSendCreditReport(pHTC, epCreditMask,&pHTC->Endpoints[EndpointID],EndpointID);
if (sendCreditFlag) {
HTCCheckAndSendCreditReport(pHTC, epCreditMask,&pHTC->Endpoints[EndpointID],EndpointID);
{
ReturnBuffers(htcHandle, EndpointID, pBuffers, TRUE);
}
{
ReturnBuffers(htcHandle, EndpointID, pBuffers, TRUE);
}
/* init total size (this does not include the space we will put in for the HTC header) */
totsz = adf_nbuf_len(pBuffers);
/* init total size (this does not include the space we will put in for the HTC header) */
totsz = adf_nbuf_len(pBuffers);
/* the first buffer stores the header */
/* back up buffer by a header size when we pass it down, by agreed upon convention the caller
/* the first buffer stores the header */
/* back up buffer by a header size when we pass it down, by agreed upon convention the caller
/* the header start is ALWAYS aligned since we DMA it directly */
/* set some fields, the rest of them will be filled below when we check for
* trailer space */
pHTCHdr->Flags = 0;
/* the header start is ALWAYS aligned since we DMA it directly */
/* set some fields, the rest of them will be filled below when we check for
* trailer space */
pHTCHdr->Flags = 0;
/* check opportunistically if we can return any reports via a trailer */
do {
int room,i,totalReportBytes;
/* check opportunistically if we can return any reports via a trailer */
do {
int room,i,totalReportBytes;
/* figure out how much room the last buffer can spare */
pipeMaxLen = HIF_get_max_msg_len(pHTC->hifHandle,
pHTC->Endpoints[EndpointID].DownLinkPipeID);
/* figure out how much room the last buffer can spare */
pipeMaxLen = HIF_get_max_msg_len(pHTC->hifHandle,
pHTC->Endpoints[EndpointID].DownLinkPipeID);
room = adf_os_min( adf_nbuf_tailroom(pBuffers), roomForPipeMaxLen);
if (room < (int)(sizeof(HTC_CREDIT_REPORT) + sizeof(HTC_RECORD_HDR))) {
/* no room for any reports */
room = adf_os_min( adf_nbuf_tailroom(pBuffers), roomForPipeMaxLen);
if (room < (int)(sizeof(HTC_CREDIT_REPORT) + sizeof(HTC_RECORD_HDR))) {
/* no room for any reports */
/* set the ID, the length will be updated with the number of credit reports we
* can fit (see below) */
pRecHdr->RecordID = HTC_RECORD_CREDITS;
pRecHdr->Length = 0;
/* set the ID, the length will be updated with the number of credit reports we
* can fit (see below) */
pRecHdr->RecordID = HTC_RECORD_CREDITS;
pRecHdr->Length = 0;
pCreditRpt = (HTC_CREDIT_REPORT *)adf_nbuf_put_tail(pBuffers,
sizeof(HTC_CREDIT_REPORT));
pCreditRpt = (HTC_CREDIT_REPORT *)adf_nbuf_put_tail(pBuffers,
sizeof(HTC_CREDIT_REPORT));
/* clear pending mask, we are going to return all these credits */
creditsPendingMap &= ~(compareMask);
/* add this record */
pCreditRpt->EndpointID = i;
pCreditRpt->Credits = (A_UINT8)pHTC->Endpoints[i].CreditsToReturn;
/* remove pending credits, we always send deltas */
/* clear pending mask, we are going to return all these credits */
creditsPendingMap &= ~(compareMask);
/* add this record */
pCreditRpt->EndpointID = i;
pCreditRpt->Credits = (A_UINT8)pHTC->Endpoints[i].CreditsToReturn;
/* remove pending credits, we always send deltas */
/* adjust new threshold for this endpoint if needed */
CHECK_AND_ADJUST_CREDIT_THRESHOLD(&pHTC->Endpoints[i]);
/* update this record length */
/* adjust new threshold for this endpoint if needed */
CHECK_AND_ADJUST_CREDIT_THRESHOLD(&pHTC->Endpoints[i]);
/* update this record length */
* The trailer can have at most 1 credit record with up to 32 reports in the record.
* The trailer can have at most 1 lookahead record with only 1 lookahead report in the record.
*/
* The trailer can have at most 1 credit record with up to 32 reports in the record.
* The trailer can have at most 1 lookahead record with only 1 lookahead report in the record.
*/
pHTCHdr->ControlBytes[0] = totalReportBytes;
/* HTC frame contains a trailer */
pHTCHdr->Flags |= HTC_FLAGS_RECV_TRAILER;
/* increment total size by the reports we added */
totsz += totalReportBytes;
pHTCHdr->ControlBytes[0] = totalReportBytes;
/* HTC frame contains a trailer */
pHTCHdr->Flags |= HTC_FLAGS_RECV_TRAILER;
/* increment total size by the reports we added */
totsz += totalReportBytes;
- pHTCHdr->PayloadLen = adf_os_htons(totsz);
- HIF_send_buffer(pHTC->hifHandle, pHTC->Endpoints[EndpointID].DownLinkPipeID, pBuffers);
+ pHTCHdr->PayloadLen = adf_os_htons(totsz);
+ HIF_send_buffer(pHTC->hifHandle, pHTC->Endpoints[EndpointID].DownLinkPipeID, pBuffers);
return HTC_HDR_LENGTH + HIF_get_reserved_headroom(pHTC->hifHandle);
}
void htc_module_install(struct htc_apis *pAPIs)
return HTC_HDR_LENGTH + HIF_get_reserved_headroom(pHTC->hifHandle);
}
void htc_module_install(struct htc_apis *pAPIs)
pAPIs->_HTC_Init = _HTC_Init;
pAPIs->_HTC_ReturnBuffers = _HTC_ReturnBuffers;
pAPIs->_HTC_ReturnBuffersList = _HTC_ReturnBuffersList;
pAPIs->_HTC_Ready = _HTC_Ready;
pAPIs->_HTC_RegisterService = _HTC_RegisterService;
pAPIs->_HTC_Init = _HTC_Init;
pAPIs->_HTC_ReturnBuffers = _HTC_ReturnBuffers;
pAPIs->_HTC_ReturnBuffersList = _HTC_ReturnBuffersList;
pAPIs->_HTC_Ready = _HTC_Ready;
pAPIs->_HTC_RegisterService = _HTC_RegisterService;
pAPIs->_HTC_Shutdown = _HTC_Shutdown;
pAPIs->_HTC_GetReservedHeadroom = _HTC_GetReservedHeadroom;
pAPIs->_HTC_MsgRecvHandler = HTCMsgRecvHandler;
pAPIs->_HTC_Shutdown = _HTC_Shutdown;
pAPIs->_HTC_GetReservedHeadroom = _HTC_GetReservedHeadroom;
pAPIs->_HTC_MsgRecvHandler = HTCMsgRecvHandler;
}
LOCAL void HTCCheckAndSendCreditReport(HTC_CONTEXT *pHTC, A_UINT32 EpMask,
HTC_ENDPOINT *pEndpoint, HTC_ENDPOINT_ID Eid)
{
adf_nbuf_t pCredBuffer;
}
LOCAL void HTCCheckAndSendCreditReport(HTC_CONTEXT *pHTC, A_UINT32 EpMask,
HTC_ENDPOINT *pEndpoint, HTC_ENDPOINT_ID Eid)
{
adf_nbuf_t pCredBuffer;
do {
/* check if host needs credits */
if (!(pHTC->EpHostNeedsCreditMap & EpMask)) {
/* host does not need any credits for this set */
do {
/* check if host needs credits */
if (!(pHTC->EpHostNeedsCreditMap & EpMask)) {
/* host does not need any credits for this set */
if (pEndpoint->PendingCreditReports >= pHTC->MaxEpPendingCreditRpts) {
/* this endpoint already has some reports outstanding */
/* flag that as soon as a buffer is reaped, we issue a credit update to
* pick up this credit that is being held up because the endpoint has already
if (pEndpoint->PendingCreditReports >= pHTC->MaxEpPendingCreditRpts) {
/* this endpoint already has some reports outstanding */
/* flag that as soon as a buffer is reaped, we issue a credit update to
* pick up this credit that is being held up because the endpoint has already
/* allocate a message buffer for the trailer */
pCredBuffer = HTCAllocMsgBuffer(pHTC);
if (NULL == pCredBuffer) {
/* allocate a message buffer for the trailer */
pCredBuffer = HTCAllocMsgBuffer(pHTC);
if (NULL == pCredBuffer) {
* have to wait until we get our endpoint 0 messages back.. */
/* mark that we need to send an update as soon as we can get a buffer back */
pHTC->StateFlags |= HTC_SEND_CREDIT_UPDATE_SOON;
* have to wait until we get our endpoint 0 messages back.. */
/* mark that we need to send an update as soon as we can get a buffer back */
pHTC->StateFlags |= HTC_SEND_CREDIT_UPDATE_SOON;
/* save the endpoint in order to decrement the count when the send completes */
ctx->htc_flags = Eid | HTC_FLAGS_CREDIT_RPT;
/* save the endpoint in order to decrement the count when the send completes */
ctx->htc_flags = Eid | HTC_FLAGS_CREDIT_RPT;
/* this is an empty message, the HTC_SendMsg will tack on a trailer in the remaining
* space, NOTE: no need to flush the cache, the header and trailers are assembled
* using uncached addresses */
/* this is an empty message, the HTC_SendMsg will tack on a trailer in the remaining
* space, NOTE: no need to flush the cache, the header and trailers are assembled
* using uncached addresses */
/* called in response to the arrival of a service connection message */
LOCAL void HTCProcessConnectMsg(HTC_CONTEXT *pHTC, HTC_CONNECT_SERVICE_MSG *pMsg)
{
/* called in response to the arrival of a service connection message */
LOCAL void HTCProcessConnectMsg(HTC_CONTEXT *pHTC, HTC_CONNECT_SERVICE_MSG *pMsg)
{
pBuffer = HTCAllocMsgBuffer(pHTC);
/* note : this will be aligned */
pRspMsg = (HTC_CONNECT_SERVICE_RESPONSE_MSG *)
adf_nbuf_put_tail(pBuffer, sizeof(HTC_CONNECT_SERVICE_RESPONSE_MSG));
pBuffer = HTCAllocMsgBuffer(pHTC);
/* note : this will be aligned */
pRspMsg = (HTC_CONNECT_SERVICE_RESPONSE_MSG *)
adf_nbuf_put_tail(pBuffer, sizeof(HTC_CONNECT_SERVICE_RESPONSE_MSG));
A_MEMZERO(pRspMsg,sizeof(HTC_CONNECT_SERVICE_RESPONSE_MSG));
pRspMsg->MessageID = adf_os_htons(HTC_MSG_CONNECT_SERVICE_RESPONSE_ID);
/* reflect the service ID for this connect attempt */
pRspMsg->ServiceID = adf_os_htons(serviceId);
while (pService) {
A_MEMZERO(pRspMsg,sizeof(HTC_CONNECT_SERVICE_RESPONSE_MSG));
pRspMsg->MessageID = adf_os_htons(HTC_MSG_CONNECT_SERVICE_RESPONSE_ID);
/* reflect the service ID for this connect attempt */
pRspMsg->ServiceID = adf_os_htons(serviceId);
while (pService) {
/* outgoing meta data resides in the space after the response message */
pMetaDataOut = ((A_UINT8 *)pRspMsg) + sizeof(HTC_CONNECT_SERVICE_RESPONSE_MSG);
/* outgoing meta data resides in the space after the response message */
pMetaDataOut = ((A_UINT8 *)pRspMsg) + sizeof(HTC_CONNECT_SERVICE_RESPONSE_MSG);
if (pMsg->ServiceMetaLength != 0) {
/* the meta data follows the connect service message */
pMetaDataIN = ((A_UINT8 *)pMsg) + sizeof(HTC_CONNECT_SERVICE_MSG);
if (pMsg->ServiceMetaLength != 0) {
/* the meta data follows the connect service message */
pMetaDataIN = ((A_UINT8 *)pMsg) + sizeof(HTC_CONNECT_SERVICE_MSG);
/* check if the service accepted this connection request */
if (HTC_SERVICE_SUCCESS == connectStatus) {
/* set the length of the response meta data going back to the host */
/* check if the service accepted this connection request */
if (HTC_SERVICE_SUCCESS == connectStatus) {
/* set the length of the response meta data going back to the host */
pHTC->Endpoints[pHTC->CurrentEpIndex].pService = pService;
/* set connection flags */
pHTC->Endpoints[pHTC->CurrentEpIndex].ConnectionFlags = pMsg->ConnectionFlags;
pHTC->Endpoints[pHTC->CurrentEpIndex].pService = pService;
/* set connection flags */
pHTC->Endpoints[pHTC->CurrentEpIndex].ConnectionFlags = pMsg->ConnectionFlags;
pHTC->Endpoints[pHTC->CurrentEpIndex].DownLinkPipeID = pMsg->DownLinkPipeID;
pHTC->Endpoints[pHTC->CurrentEpIndex].UpLinkPipeID = pMsg->UpLinkPipeID;
pHTC->Endpoints[pHTC->CurrentEpIndex].DownLinkPipeID = pMsg->DownLinkPipeID;
pHTC->Endpoints[pHTC->CurrentEpIndex].UpLinkPipeID = pMsg->UpLinkPipeID;
/* mark that we are now connected */
pService->ServiceFlags |= HTC_SERVICE_FLAGS_CONNECTED;
/* bump up our index, this EP is now in use */
/* mark that we are now connected */
pService->ServiceFlags |= HTC_SERVICE_FLAGS_CONNECTED;
/* bump up our index, this EP is now in use */
}
LOCAL void HTCProcessConfigPipeMsg(HTC_CONTEXT *pHTC, HTC_CONFIG_PIPE_MSG *pMsg)
{
adf_nbuf_t pBuffer;
HTC_CONFIG_PIPE_RESPONSE_MSG *pRspMsg;
}
LOCAL void HTCProcessConfigPipeMsg(HTC_CONTEXT *pHTC, HTC_CONFIG_PIPE_MSG *pMsg)
{
adf_nbuf_t pBuffer;
HTC_CONFIG_PIPE_RESPONSE_MSG *pRspMsg;
pRspMsg->MessageID = adf_os_htons(HTC_MSG_CONFIG_PIPE_RESPONSE_ID);
/* reflect the service ID for this connect attempt */
pRspMsg->PipeID = pMsg->PipeID;
if ( HIF_is_pipe_supported(pHTC->hifHandle, pMsg->PipeID) ) {
pRspMsg->MessageID = adf_os_htons(HTC_MSG_CONFIG_PIPE_RESPONSE_ID);
/* reflect the service ID for this connect attempt */
pRspMsg->PipeID = pMsg->PipeID;
if ( HIF_is_pipe_supported(pHTC->hifHandle, pMsg->PipeID) ) {
}
/* process an incomming control message from the host */
LOCAL void HTCControlSvcProcessMsg(HTC_ENDPOINT_ID EndpointID, adf_nbuf_t hdr_buf,
adf_nbuf_t pBuffers, void *arg)
}
/* process an incomming control message from the host */
LOCAL void HTCControlSvcProcessMsg(HTC_ENDPOINT_ID EndpointID, adf_nbuf_t hdr_buf,
adf_nbuf_t pBuffers, void *arg)
adf_os_assert(hdr_buf == ADF_NBUF_NULL);
/* we assume buffers are aligned such that we can access the message
* parameters directly*/
adf_nbuf_peek_header(pBuffers, &anbdata, &anblen);
pMsg = (HTC_UNKNOWN_MSG *)anbdata;
adf_os_assert(hdr_buf == ADF_NBUF_NULL);
/* we assume buffers are aligned such that we can access the message
* parameters directly*/
adf_nbuf_peek_header(pBuffers, &anbdata, &anblen);
pMsg = (HTC_UNKNOWN_MSG *)anbdata;
case HTC_MSG_SETUP_COMPLETE_ID:
/* the host has indicated that it has completed all
setup tasks and we can now let the services take over to
run the rest of the application */
case HTC_MSG_SETUP_COMPLETE_ID:
/* the host has indicated that it has completed all
setup tasks and we can now let the services take over to
run the rest of the application */
if (pHTC->StateFlags & HTC_STATE_SETUP_COMPLETE) {
/* recycle buffer only if we are fully running */
HTC_ReturnBuffers(pHTC, ENDPOINT0,pBuffers);
} else {
/* supply some head-room again */
adf_nbuf_push_head(pBuffers, HTC_HDR_LENGTH);
if (pHTC->StateFlags & HTC_STATE_SETUP_COMPLETE) {
/* recycle buffer only if we are fully running */
HTC_ReturnBuffers(pHTC, ENDPOINT0,pBuffers);
} else {
/* supply some head-room again */
adf_nbuf_push_head(pBuffers, HTC_HDR_LENGTH);
- if ( ctx->htc_flags & HTC_FLAGS_CREDIT_RPT ) {
- /* extract the endpoint number that requested this credit report */
- creditRptEndpoint = ctx->htc_flags & HTC_FLAGS_CRPT_EP_MASK;
- pHTC->Endpoints[creditRptEndpoint].PendingCreditReports--;
+ if ( ctx->htc_flags & HTC_FLAGS_CREDIT_RPT ) {
+ /* extract the endpoint number that requested this credit report */
+ creditRptEndpoint = ctx->htc_flags & HTC_FLAGS_CRPT_EP_MASK;
+ pHTC->Endpoints[creditRptEndpoint].PendingCreditReports--;
if (pHTC->StateFlags & HTC_SEND_CREDIT_UPDATE_SOON) {
/* this flag is set when the host could not send a credit report
* because we ran out of HTC control buffers */
pHTC->StateFlags &= ~HTC_SEND_CREDIT_UPDATE_SOON;
/* send out a report if anything is pending */
HTCCheckAndSendCreditReport(pHTC, HTC_ANY_ENDPOINT_MASK,NULL,ENDPOINT_MAX);
if (pHTC->StateFlags & HTC_SEND_CREDIT_UPDATE_SOON) {
/* this flag is set when the host could not send a credit report
* because we ran out of HTC control buffers */
pHTC->StateFlags &= ~HTC_SEND_CREDIT_UPDATE_SOON;
/* send out a report if anything is pending */
HTCCheckAndSendCreditReport(pHTC, HTC_ANY_ENDPOINT_MASK,NULL,ENDPOINT_MAX);
/* Walk through the buffers and fixup the ones we used for HTC headers.
* The buffer list may contain more than one string of HTC buffers comprising of an
/* Walk through the buffers and fixup the ones we used for HTC headers.
* The buffer list may contain more than one string of HTC buffers comprising of an
A_INT16 creditsOutstanding = pEndpoint->CreditsToReturn + pEndpoint->CreditsConsumed;
/* set the new threshold based on the number of credits that have been consumed
* and which have not been returned by the app.
A_INT16 creditsOutstanding = pEndpoint->CreditsToReturn + pEndpoint->CreditsConsumed;
/* set the new threshold based on the number of credits that have been consumed
* and which have not been returned by the app.
switch (pEndpoint->ConnectionFlags & HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_MASK) {
case HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_ONE_FOURTH :
creditsOutstanding >>= 2;
switch (pEndpoint->ConnectionFlags & HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_MASK) {
case HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_ONE_FOURTH :
creditsOutstanding >>= 2;
- case HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_THREE_FOURTHS :
- creditsOutstanding = (creditsOutstanding * 3) >> 2;
+ case HTC_CONNECT_FLAGS_THRESHOLD_LEVEL_THREE_FOURTHS :
+ creditsOutstanding = (creditsOutstanding * 3) >> 2;
/* callback from the mailbox hardware layer when a full message arrives */
LOCAL void HTCMsgRecvHandler(adf_nbuf_t hdr_buf, adf_nbuf_t buffer, void *context)
{
/* callback from the mailbox hardware layer when a full message arrives */
LOCAL void HTCMsgRecvHandler(adf_nbuf_t hdr_buf, adf_nbuf_t buffer, void *context)
{
-
- adf_nbuf_peek_header(tmp_nbuf, &anbdata, &anblen);
- pHTCHdr = (HTC_FRAME_HDR *)anbdata;
-
- totsz = adf_os_ntohs(pHTCHdr->PayloadLen);
-
- eid = pHTCHdr->EndpointID;
-
+
+ adf_nbuf_peek_header(tmp_nbuf, &anbdata, &anblen);
+ pHTCHdr = (HTC_FRAME_HDR *)anbdata;
+
+ eid = pHTCHdr->EndpointID;
+
if (pHTC->StateFlags & HTC_STATE_SETUP_COMPLETE) {
/* after setup we keep track of credit consumption to allow us to
if (pHTC->StateFlags & HTC_STATE_SETUP_COMPLETE) {
/* after setup we keep track of credit consumption to allow us to
* when we receive a frame with the NEED_CREDIT_UPDATE flag set .
* if the host received credits through an opportunistic path, then it can
* issue a another frame with this bit cleared, this signals the target to clear
* when we receive a frame with the NEED_CREDIT_UPDATE flag set .
* if the host received credits through an opportunistic path, then it can
* issue a another frame with this bit cleared, this signals the target to clear
if (pHTCHdr->Flags & HTC_FLAGS_NEED_CREDIT_UPDATE) {
/* the host is running low (or is out) of credits on this
* endpoint, update mask */
if (pHTCHdr->Flags & HTC_FLAGS_NEED_CREDIT_UPDATE) {
/* the host is running low (or is out) of credits on this
* endpoint, update mask */
payload, the first buffer contains the header */
adf_nbuf_pull_head(tmp_nbuf, HTC_HDR_LENGTH);
payload, the first buffer contains the header */
adf_nbuf_pull_head(tmp_nbuf, HTC_HDR_LENGTH);
/* NOTE : This callback could re-queue the recv buffers within this calling context.
* The callback could also send a response message within the context of this callback
* as the result of parsing this message. In either case, if there are
/* NOTE : This callback could re-queue the recv buffers within this calling context.
* The callback could also send a response message within the context of this callback
* as the result of parsing this message. In either case, if there are
pEndpoint->pService->ProcessRecvMsg(eid, hdr_buf, buffer, pEndpoint->pService->ServiceCtx);
pEndpoint->pService->ProcessRecvMsg(eid, hdr_buf, buffer, pEndpoint->pService->ServiceCtx);
- /* Calls to HTC_ReturnBuffers drives the endpoint credit reporting state machine.
- * We do not want to delay credits for too long in the event that the application is
+ /* Calls to HTC_ReturnBuffers drives the endpoint credit reporting state machine.
+ * We do not want to delay credits for too long in the event that the application is
* holding onto buffers for excessive periods of time. This gives us "some" better
* opportunities to send up credits. */
* holding onto buffers for excessive periods of time. This gives us "some" better
* opportunities to send up credits. */
- HTCCheckAndSendCreditReport(pHTC, eidMask, pEndpoint, eid);
+ HTCCheckAndSendCreditReport(pHTC, eidMask, pEndpoint, eid);