Exemple #1
0
static void RPC_BufferDelivery(IPC_Buffer bufHandle)
{
	RPC_Result_t result = RPC_RESULT_ERROR;
	UInt8* pCid = (UInt8*)IPC_BufferHeaderPointer(bufHandle);
	IPC_EndpointId_T destId = IPC_BufferDestinationEndpointId(bufHandle);
	Int8 type = GetInterfaceType(destId);

	if(type != -1 && ipcInfoList[type].pktIndCb != NULL)
		result = ipcInfoList[type].pktIndCb((PACKET_InterfaceType_t)type, (UInt8)pCid[0], (PACKET_BufHandle_t)bufHandle);
	else
		_DBG_(RPC_TRACE("RPC_BufferDelivery(%c) FAIL destIP=%d handle=%x",(gRpcProcType == RPC_COMMS)?'C':'A',destId, bufHandle));


	if(result != RPC_RESULT_PENDING)
		IPC_FreeBuffer(bufHandle);
}
void IPC_SmSendBuffer(IPC_Buffer Buffer)
{
	IPC_EndpointId_T DestinationEpId;
	IPC_Endpoint DestinationEpPtr;
	IPC_CPU_ID_T DestinationCpu;

	DestinationEpId = IPC_BufferDestinationEndpointId(Buffer);

#ifdef IPC_DEBUG
	if (DestinationEpId == IPC_EP_None) {
		IPC_TRACE(IPC_Channel_Error,
			  "IPC_SmSendBuffer",
			  "Invalid Destination Endpoint %08X for Buffer %08X",
			  DestinationEpId, Buffer, 0, 0);
		return;
	}
#endif

#ifdef FUSE_IPC_CRASH_SUPPORT
	if (g_bCpCrashed == IPC_TRUE) {
		IPC_TRACE(IPC_Channel_Error,
			  "IPC_SmSendBuffer",
			  "Trying to send after CP has crashed for Buffer %08X",
			  Buffer, 0, 0, 0);
		return;
	}
#endif

	DestinationEpPtr = IPC_SmEndpointInfo(DestinationEpId);
	DestinationCpu = DestinationEpPtr->Cpu;

	IPC_TRACE(IPC_Channel_Sm,
		  "IPC_SmSendBuffer",
		  "DestinationCpu %02X, Buffer %08X",
		  DestinationCpu, Buffer, 0, 0);

	if (DestinationCpu == IPC_SM_CURRENT_CPU) {
		(*DestinationEpPtr->DeliveryFunction) (Buffer);
	} else {
		IPC_Fifo SendFifo =
		    &SmLocalControl.SmControl->
		    Fifos[IPC_CPU_ID_INDEX(DestinationCpu)].SendFifo;
		IPC_SmFifoWrite(SendFifo, Buffer);
	}
}
Exemple #3
0
static int rpcKthreadFn(MsgQueueHandle_t *mHandle, void *data)
{
	IPC_Buffer bufHandle = (IPC_Buffer) data;
	RPC_Result_t result = RPC_RESULT_ERROR;
	UInt8 *pCid = (UInt8 *)IPC_BufferHeaderPointer(bufHandle);
	IPC_EndpointId_T destId = IPC_BufferDestinationEndpointId(bufHandle);
	Int8 type = GetInterfaceType(destId);

/*	_DBG_(RPC_TRACE
	      ("RPC_BufferDelivery PROCESS mHandle=%x event=%d\n", (int)mHandle,
	       (int)data));*/

	if (ipcInfoList[(int)type].filterPktIndCb != NULL) {
		RpcDbgUpdatePktState((int)bufHandle, PKT_STATE_RPC_PROCESS);

		result =
		    ipcInfoList[(int)
				type].filterPktIndCb((PACKET_InterfaceType_t)
						     type, (UInt8)pCid[0],
						     (PACKET_BufHandle_t)
						     bufHandle);
	}

	if (result != RPC_RESULT_PENDING) {
		_DBG_(RPC_TRACE
		      ("IPC_FreeBuffer (No Handling) h=%d\r\n",
		       (int)bufHandle));

		RpcDbgUpdatePktState((int)bufHandle, PKT_STATE_PKT_FREE);
		IPC_FreeBuffer(bufHandle);
		freeRpcPkts++;
		rpc_wake_lock_remove((UInt32)bufHandle);
	}

	return 0;
}
Exemple #4
0
static void RPC_BufferDelivery(IPC_Buffer bufHandle)
{
	PACKET_InterfaceType_t ifType;
	RPC_IPCInfo_t *pInfo;
	Int32 isReservedPkt = 0;
	int ret;
	RPC_Result_t result = RPC_RESULT_ERROR;
	UInt8 *pCid = (UInt8 *)IPC_BufferHeaderPointer(bufHandle);
	IPC_EndpointId_T destId = IPC_BufferDestinationEndpointId(bufHandle);
	int type = GetInterfaceType(destId);
	PACKET_BufHandle_t pktBufHandle = (PACKET_BufHandle_t) bufHandle;

	if (type == -1 || pCid == NULL) {
		IPC_FreeBuffer(bufHandle);
		_DBG_(RPC_TRACE("RPC_BufferDelivery FAIL pkt=%d t=%d cid=%d",
				pktBufHandle, type, pCid));
		return;
	}
	pInfo = &ipcInfoList[type];
	ifType = (PACKET_InterfaceType_t)type;
	if (pInfo->pktIndCb == NULL && pInfo->filterPktIndCb == NULL) {
		IPC_FreeBuffer(bufHandle);
		_DBG_(RPC_TRACE("RPC_BufferDelivery FAIL No Cbk pkt=%d\r\n",
				pktBufHandle));
		return;
	}
	if (ifType != INTERFACE_PACKET) {
		IPC_U32 uParam;
		/*For bckward compatibility, remove in future release */

		uParam = IPC_BufferUserParameterGet(bufHandle);
		if (uParam == CAPI2_RESERVE_POOL_ID) {
			/* TBD: Add recovery mechanism */
			IPC_FreeBuffer(bufHandle);
			_DBG_(RPC_TRACE
			      ("RPC_BufferDelivery RESERVED (Drop) h=%d if=%d rcvPkts=%d freePkts=%d\r\n",
			       (int)bufHandle, (int)type,
			       (int)recvRpcPkts, (int)freeRpcPkts));
			return;
		}

		isReservedPkt = RPC_PACKET_IsReservedPkt(pktBufHandle);
		/* Log incoming packet */
		rpcLogNewPacket(pktBufHandle, ifType, pInfo, pCid,
				isReservedPkt);

	}

	if (pInfo->pktIndCb != NULL && isReservedPkt == 0)
		result = pInfo->pktIndCb((PACKET_InterfaceType_t)type,
					 (UInt8)pCid[0], pktBufHandle);

	if (result == RPC_RESULT_PENDING)
		return;		/* Sysrpc packet come here */
	if (pInfo->filterPktIndCb == NULL) {
		IPC_FreeBuffer(bufHandle);
		rpcLogFreePacket((PACKET_InterfaceType_t)type, pktBufHandle);
		return;		/* net or vt interface pkt come here */
	}
#ifdef USE_KTHREAD_HANDOVER
	if (isReservedPkt &&
	    MsgQueueCount(&rpcMQhandle) >= CFG_RPC_CMD_MAX_PACKETS) {
		IPC_FreeBuffer(bufHandle);
		rpcLogFreePacket((PACKET_InterfaceType_t)type, pktBufHandle);
		_DBG_(RPC_TRACE("RPC_BufferDelivery(rz) RpcQ FULL h=%d c=%d\n",
				(int)bufHandle, MsgQueueCount(&rpcMQhandle)));
		return;
	}

	/* Post it to RPC Thread */
	ret = MsgQueueAdd(&rpcMQhandle, (void *)bufHandle);

	if (ret != 0) {
		IPC_FreeBuffer(bufHandle);
		rpcLogFreePacket((PACKET_InterfaceType_t)type, pktBufHandle);
		_DBG_(RPC_TRACE("RPC_BufferDelivery Queue FAIL h=%d r=%d\n",
				(int)bufHandle, ret));
		return;
	}
	RpcDbgUpdatePktState((int)bufHandle, PKT_STATE_RPC_POST);

	result = RPC_RESULT_PENDING;
#else
	/* If using workerqueue instead of tasklet,
	   filterPktIndCb can be called directly */
	result = pInfo->filterPktIndCb((PACKET_InterfaceType_t)type,
				       (UInt8)pCid[0], (PACKET_BufHandle_t)
				       bufHandle);
#endif

	/* If Packet not consumed by secondary client then return */

	//Coverity [DEADCODE]
	if (result != RPC_RESULT_PENDING) {
		/* Packet was never consumed */
		/* coverity [dead_error_line] */
		IPC_FreeBuffer(bufHandle);
		rpcLogFreePacket((PACKET_InterfaceType_t)type, pktBufHandle);
		_DBG_(RPC_TRACE("RPC_BufferDelivery filterCb FAIL h=%d r=%d\n",
				(int)bufHandle, ret));
		return;
	}

	_DBG_(RPC_TRACE("RPC_BufferDelivery filterCb OK h=%d\n",
			(int)bufHandle));
	return;
}