Beispiel #1
0
HRESULT avcCreateResponsePacket(PB *packetBlock, PB **respPacket, BOOL bNewPayloadSize, uint32 payloadSize)
{
	HRESULT		hResult = NO_ERROR;	

	if (bNewPayloadSize)
	{
		hResult = pbCreateDuplicatePacketWithSize(packetBlock, respPacket, (uint16) payloadSize, NULL, PB_CREATE_AVC_SEND_RSP);
		if (hResult != NO_ERROR) return hResult;
	}
	else
	{
		hResult = pbCreateDuplicatePacket(packetBlock, respPacket, NULL, PB_CREATE_AVC_SEND_RSP);
		if (hResult != NO_ERROR) return hResult;
	}

#if 1 
	pbSwapSrcDstNodeAddr(*respPacket);
#endif

	return hResult;
}
Beispiel #2
0
 /*********************************************************
	The tx thread calls this when any transmit queue has one or more packets to transmit.
		
	the priority queue is always checked first and serviced until empty, the 
	general queue is ignored during bus reset.  this allows node handles to be 
	fixed up after a bus reset, making them transparent to the upper layers,
	unless a node has left the bus of course. this routine will call the appropriate
	send routine for request or response.
*/
static HRESULT lhlTxSndPacketPend(void)
{
	HRESULT		hResult = NO_ERROR;
	PB*			packetBlock = NULL;
	PB_HEADER 	*pHeader = NULL;
	uint32		tLabel = 0;
	uint32		tCode = 0;
	uint32		nodeAddr = 0;
	uint32 busGenCurrent = 0;
	uint32 busGenPacket = 0;

	DO_FOREVER 
	{
		// look for priority packets (non-blocking)
		hResult = lhlMsgQueueGetPacketBlock(LHL_QUEUE_PRIORITY, &packetBlock, TC_NO_WAIT);
		if (hResult != NO_ERROR) return hResult;

		if (pbIsValid(packetBlock))
		{	
			// if bus reset happened, queued requests must be thrown out
			briGetCurrentBusGeneration(&busGenCurrent);			
			pbGetBusGeneration (packetBlock, &busGenPacket);
			
			if (busGenCurrent != busGenPacket)
			{
				
				pbSwapSrcDstNodeAddr(packetBlock);

				pbSetFinalStatus(packetBlock, E_LHL_BUS_RESET_IN_PROGRESS);
				pbPacketDone(packetBlock, PB_DONE_LHL_ATX_SND_PEND_1);
				hResult = E_BRI_NEW_BUS_RESET;
				sysLogError(hResult, __LINE__, moduleName);
				return hResult;
			}
		}
		else
		{
			if (briInBusReset() == FALSE)
			{
				// if not in bus reset processing, look for general packets (non-blocking)
				hResult = lhlMsgQueueGetPacketBlock(LHL_QUEUE_GENERAL, &packetBlock, TC_NO_WAIT);
				if (hResult != NO_ERROR) return hResult;
			}
			else
			{
				DO_FOREVER
				{
					// if in bus reset processing, free for general packets (non-blocking)
					hResult = lhlMsgQueueGetPacketBlock(LHL_QUEUE_GENERAL, &packetBlock, TC_NO_WAIT);
					if (hResult != NO_ERROR) return hResult;

					if (pbIsValid(packetBlock))
					{
#if 1 
						pbSwapSrcDstNodeAddr(packetBlock);
#endif
						pbSetFinalStatus(packetBlock, E_LHL_BUS_RESET_IN_PROGRESS);
						pbPacketDone(packetBlock, PB_DONE_LHL_ATX_SND_PEND_2);
					}
					else
					{
						break; // no more packetBlocks to free
					}
				}
			}
		}

		if (pbIsValid(packetBlock))
		{
			briGetCurrentBusGeneration(&busGenCurrent);			
			pbGetBusGeneration (packetBlock, &busGenPacket);
			if (busGenCurrent != busGenPacket)
			{				
				pbSwapSrcDstNodeAddr(packetBlock);
				pbSetFinalStatus(packetBlock, E_LHL_BUS_RESET_IN_PROGRESS);
				pbPacketDone(packetBlock, PB_DONE_LHL_ATX_SND_PEND_1);
				hResult = E_BRI_NEW_BUS_RESET;
				sysLogError(hResult, __LINE__, moduleName);
				return hResult;
			}

			hResult = pbGetPacketHeader (packetBlock, &pHeader);
			if (hResult != NO_ERROR) return hResult;
			hResult = pbGetPacketTLabel (packetBlock, &tLabel);
			if (hResult != NO_ERROR) return hResult;
			hResult = pbGetPacketDstNodeAddr (packetBlock, &nodeAddr);
			if (hResult != NO_ERROR) return hResult;
			hResult = lhlPendingTxAdd(tLabel, nodeAddr, packetBlock);		// insert before send and remove if send error
			if (hResult != NO_ERROR) return hResult;    
			hResult = context1PostPacket(packetBlock,lhlTxDoneSemID);
			if (hResult != NO_ERROR)
			{
#if 1 
				pbSwapSrcDstNodeAddr(packetBlock);
#endif
				pbSetFinalStatus(packetBlock, hResult);
				pbPacketDone(packetBlock, PB_DONE_LHL_ATX_SND_PEND_3);
			}
			else
			{
				// We have now posted the write, the semaphore will be signaled
				uint8	matchResponse = FALSE; // error in sending req/rsp - match corresponding type in PendingTx
				pbIsResponsePacket(packetBlock, &matchResponse);

				hResult = TCSemaphoreWait(lhlTxDoneSemID);
				
				tCode = (pHeader->quadlets[0] & MASK_TCODE) >> SHIFT_TCODE;
				lhlTxPacketDoneLLC(tLabel, tCode, nodeAddr, matchResponse);
			}
		}
		else
		{
			break; // no more packets to send
		}
	}
Beispiel #3
0
/***************************************************************************
	Handling of the acknowledge transmitted packet request/response done
*/
static void lhlTxPacketDoneLLC(uint32 tLabel, uint16 tCode, uint32 nodeAddr, uint8 response)
{
	HRESULT		hResult = NO_ERROR;
	PB			*pMatchPB = NULL;
	uint16		conf;
	BOOL		bRemoveEntry = TRUE;
	uint8		pendingTxType; // ack for sending req/rsp/stm match corresponding type in PendingTx


	volatile POSTED_TX_CONTEXT * pContext = &postedTxState.contexts[1];
	
	if ((pContext->txStat & LLC_ASY_TX_CMPLT) == 0)
	{
		sysLogError(E_LLC_TX_NEVER_COMPLETED, __LINE__, moduleName);
	}

	conf = (pContext->txStat & LLC_ASY_TX_EVENT_MASK) >> LLC_ASY_TX_EVENT_SHIFT;

	// Handling of packet
	hResult = lhlPendingTxGetType((PB_PACKETTYPE) tCode, &pendingTxType);
	if (hResult != NO_ERROR) return;

	if (response)
	{
		// response acked by destination
		bRemoveEntry = TRUE;			
	}
	else
	{
		// OHCI_ACK_PENDING: succes, leave the packet in the pending list to be matched with the response packet
		// o.w. the transaction failed at the link layer, this status will be passed to the callback
		bRemoveEntry = (conf != ACK_1394_PENDING);
	}

	if (bRemoveEntry) 
	{
		hResult = lhlPendingTxMatch(tLabel, nodeAddr, pendingTxType, &pMatchPB, bRemoveEntry);
		if (hResult == NO_ERROR)
		{
			// either packet acked by destination, or error returned, or request expects no response  
			if (pbIsValid(pMatchPB))
			{
				HRESULT hResultFinal = NO_ERROR;

				if (conf != ACK_1394_COMPLETE && 
					conf != LLC_EVENT_INIT)			// Termination of async packet with no ack (e.g. bcast, phy, async stream)
				{
					hResultFinal = (HRESULT) (E_LHL_CONF_BASE + conf);
					SYS_DEBUG(SYSDEBUG_TRACE_PACKETS, "lhlATx SndPacketDone: ack error for %s call CB (conf: %i)\n\r", (response) ? "rsp" : "req", conf);
				}
				else
				{
					SYS_DEBUG(SYSDEBUG_TRACE_PACKETS, "lhlATx SndPacketDone: ack complete for %s call CB\n\r", (response) ? "rsp" : "req" );
				}

				pbSwapSrcDstNodeAddr(pMatchPB);
				pbSetFinalStatus(pMatchPB, hResultFinal);
				pbPacketDone(pMatchPB, PB_DONE_LHL_ATX_SND_DONE);
			}
			else
			{
				hResult = E_LHL_INVALID_PB;
				sysLogError(hResult, __LINE__, moduleName);
			}
		}
		else
		{
			SYS_DEBUG(SYSDEBUG_TRACE_PACKETS, "lhlATx SndPacketDone: match not found for %s\n\r", (response) ? "rsp" : "req" );
		}
	}
}