void RPC_HandleEvent(void *eventHandle) { UInt8 clientId = 0; ResultDataBuffer_t *dataBuf; Result_t res = RESULT_OK; PACKET_BufHandle_t bufHandle = (PACKET_BufHandle_t) eventHandle; dataBuf = capi2_malloc(sizeof(ResultDataBuffer_t)); if (dataBuf) { dataBuf->refCount = 1; res = RPC_DeserializeMsg(RPC_PACKET_GetBufferData(bufHandle), RPC_PACKET_GetBufferLength(bufHandle), dataBuf); if (res == RESULT_OK) { Boolean isUnsolicited; UInt8 clientIndex = GetClientIndex(dataBuf, &isUnsolicited); clientId = RPC_SYS_GetClientID(clientIndex); RPC_USER_LOCK(gRpcLock); RPC_DispatchMsg(dataBuf); RPC_USER_UNLOCK(gRpcLock); } else { capi2_free(dataBuf); } } RPC_PACKET_FreeBufferEx(bufHandle, clientId); }
/** @fn RPC_Result_t bcm_fuse_net_bd_cb(PACKET_InterfaceType_t interfaceType, unsigned char cid, PACKET_BufHandle_t dataBufHandle); */ static RPC_Result_t bcm_fuse_net_bd_cb(PACKET_InterfaceType_t interfaceType, unsigned char cid, PACKET_BufHandle_t dataBufHandle) { unsigned long data_len = 0; struct sk_buff *skb = NULL; unsigned char *data_ptr = NULL; net_drvr_info_t *ndrvr_info_ptr = NULL; //BNET_DEBUG(DBG_INFO,"%s: receive packet \n", __FUNCTION__); data_len = RPC_PACKET_GetBufferLength(dataBufHandle); //BNET_DEBUG(DBG_INFO,"%s: RECVD Buffer Delivery on AP Packet channel, cid[%d] size[%d]!!\n", __FUNCTION__, cid, data_len); //ndrvr_info_ptr = &g_net_dev_tbl[0]; ndrvr_info_ptr = bcm_fuse_net_device_pdp_lookup(cid); if (ndrvr_info_ptr == NULL) { if (printk_ratelimit()) BNET_DEBUG(DBG_ERROR,"%s: bcm_fuse_net_device_pdp_lookup failed\n", __FUNCTION__); return RPC_RESULT_ERROR; } skb = dev_alloc_skb(data_len); if (skb == NULL) { if (printk_ratelimit()) BNET_DEBUG(DBG_ERROR,"%s: dev_alloc_skb() failed - packet dropped\n", __FUNCTION__); ndrvr_info_ptr->stats.rx_dropped++; return RPC_RESULT_ERROR; } data_ptr = (unsigned char*)RPC_PACKET_GetBufferData(dataBufHandle); memcpy(skb_put(skb, data_len), data_ptr, data_len); skb->dev = ndrvr_info_ptr->dev_ptr; skb->protocol=htons(ETH_P_IP); // skb->ip_summed = CHECKSUM_UNNECESSARY; /* don't check it */ skb->pkt_type = PACKET_HOST; ndrvr_info_ptr->dev_ptr->last_rx = jiffies; bcm_fuse_net_last_rx = ndrvr_info_ptr->dev_ptr->last_rx; ndrvr_info_ptr->stats.rx_packets++; ndrvr_info_ptr->stats.rx_bytes += data_len; netif_rx(skb); return RPC_RESULT_OK; }
void eemDispatchPacket(void* pkt, UInt8 cid) { Boolean handled = TRUE; int len = RPC_PACKET_GetBufferLength((PACKET_BufHandle_t)pkt); UInt8* buf = RPC_PACKET_GetBufferData((PACKET_BufHandle_t)pkt); if(sEemCb.recv) { handled = sEemCb.recv(buf, len, pkt); } Log_DebugPrintf(LOGID_SYSEEMRPC, "AP eemDispatchPacket recv len:%d buf:%x pkt:%x handled:%d cbk:%x", len, buf, pkt, handled,sEemCb.recv); if(handled) RPC_PACKET_FreeBuffer((PACKET_BufHandle_t)pkt); }
Result_t RPC_SendMsg(RPC_InternalMsg_t* rpcMsg) { char* stream; bool_t ret; UInt32 len; PACKET_InterfaceType_t rpcInterfaceType; PACKET_BufHandle_t bufHandle; //coverity[var_decl], "entry" will be inited in function rpc_fast_lookup() RPC_InternalXdrInfo_t entry; UInt32 maxPktSize =0; Result_t result = RESULT_OK; ret = rpc_fast_lookup((UInt16)rpcMsg->rootMsg.msgId, &entry); if(!ret || entry.xdrInfo == NULL) { _DBG_(RPC_TRACE("RPC_SerializeMsg: failed!")); return RESULT_ERROR; } if(rpcMsg->msgType == RPC_TYPE_REQUEST) { rpcMsg->clientIndex = entry.clientIndex; } rpcInterfaceType = RPC_GetInterfaceType((UInt8)entry.clientIndex); maxPktSize = RPC_GetMaxPktSize(rpcInterfaceType, entry.xdrInfo->maxMsgSize); maxPktSize = (maxPktSize==0) ? MAX_MSG_STREAM_SIZE : maxPktSize; bufHandle = RPC_PACKET_AllocateBuffer (rpcInterfaceType, maxPktSize, 0); if(!bufHandle) { xassert(0,rpcMsg->rootMsg.msgId); return RESULT_ERROR; } stream = RPC_PACKET_GetBufferData(bufHandle); if(stream == 0) return RESULT_ERROR; result = RPC_SerializeMsg(rpcMsg, stream, maxPktSize, &len); RPC_PACKET_SetBufferLength(bufHandle, len); RPC_PACKET_SendData(0, rpcInterfaceType, 0, bufHandle); return result; }
void RPC_HandleEvent(void* eventHandle) { ResultDataBuffer_t* dataBuf; Result_t res = RESULT_OK; PACKET_BufHandle_t bufHandle = (PACKET_BufHandle_t)eventHandle; dataBuf = capi2_malloc(sizeof(ResultDataBuffer_t)); if(dataBuf) { dataBuf->refCount = 1; res = RPC_DeserializeMsg(RPC_PACKET_GetBufferData(bufHandle), RPC_PACKET_GetBufferLength(bufHandle),dataBuf); if(res == RESULT_OK) { RPC_DispatchMsg(dataBuf); } } RPC_PACKET_FreeBuffer(bufHandle); }
void EEM_SendEx(void *buffer, UInt32 buflen, UInt8 hdr, UInt8 footer, UInt8 cacheAlign) { PACKET_BufHandle_t pkt; pkt = RPC_PACKET_AllocateBufferCacheAlign(INTERFACE_USB_EEM, (buflen + hdr + footer), 0, PKT_ALLOC_WAIT_FOREVER, cacheAlign); if(pkt) { UInt8* buf = RPC_PACKET_GetBufferData((PACKET_BufHandle_t)pkt); if(hdr) { buf+=hdr; //put the data after the header. Let the USB stack fill in the header and footer. } memcpy(buf, buffer, buflen); RPC_PACKET_SetBufferLength(pkt, (buflen + hdr + footer)); RPC_PACKET_SendData(0, INTERFACE_USB_EEM, 0, pkt ); Log_DebugPrintf(LOGID_SYSEEMRPC, "EEM_Send: pkt:0x%x buffer=0x%x len=%d", pkt, buf,buflen); } else Log_DebugPrintf(LOGID_SYSEEMRPC, "EEM_Send: Alloc fail size=%d", pkt, buflen); }
static int bcm_fuse_net_tx(struct sk_buff *skb, struct net_device *dev) { void *buff_data_ptr; uint8_t pdp_cid = BCM_NET_MAX_PDP_CNTXS; PACKET_BufHandle_t buffer; net_drvr_info_t *ndrvr_info_ptr = NULL; //consider for multiple case?? int i; for (i = 0; i < BCM_NET_MAX_PDP_CNTXS; i++) { if (g_net_dev_tbl[i].dev_ptr == dev) { ndrvr_info_ptr = &g_net_dev_tbl[i]; BNET_DEBUG(DBG_TRACE,"%s: g_net_dev_tbl[%d]=0x%x \n", __FUNCTION__, i, (unsigned int)(&g_net_dev_tbl[i])); break; } } if (NULL == ndrvr_info_ptr) { BNET_DEBUG(DBG_ERROR,"bcm_fuse_net_tx(), no device found\n"); return(-EINVAL); } if (BCM_NET_MAX_DATA_LEN < skb->len) { BNET_DEBUG(DBG_ERROR,"%s: len[%d] exceeds supported len[%d] failed\n", __FUNCTION__, skb->len, BCM_NET_MAX_DATA_LEN); ndrvr_info_ptr->stats.tx_errors++; return(-1); } if(0 == skb->len) { BNET_DEBUG(DBG_ERROR,"%s: len[%d] is zero size failed\n", __FUNCTION__, skb->len); return(-1); } //pdp_cid = 1; pdp_cid = bcm_fuse_net_pdp_id(ndrvr_info_ptr); if (BCM_NET_INVALID_PDP_CNTX == pdp_cid) { BNET_DEBUG(DBG_ERROR,"%s: net device to pdp context id mapping failed\n", __FUNCTION__); ndrvr_info_ptr->stats.tx_errors++; return(-1); } //Allocate a buffer buffer = RPC_PACKET_AllocateBuffer(INTERFACE_PACKET, skb->len, pdp_cid); if(!buffer) { BNET_DEBUG(DBG_ERROR,"%s: Error buffer Handle cid %d\n", __FUNCTION__, pdp_cid); ndrvr_info_ptr->stats.tx_errors++; return(-ENOBUFS); } //transfer data from skb to ipc_buffer buff_data_ptr = RPC_PACKET_GetBufferData(buffer); if (buff_data_ptr == NULL) { BNET_DEBUG(DBG_ERROR,"%s: RPC_PACKET_GetBufferData() failed\n", __FUNCTION__); ndrvr_info_ptr->stats.tx_errors++; return(-ENOBUFS); } memset(buff_data_ptr, 0, BCM_NET_MAX_DATA_LEN); memcpy(buff_data_ptr, skb->data, skb->len); RPC_PACKET_SetBufferLength(buffer, skb->len); dev->trans_start = jiffies; /* save the timestamp */ bcm_fuse_net_last_tx = dev->trans_start; RPC_PACKET_SendData(g_NetClientId, INTERFACE_PACKET, pdp_cid, buffer); /** The IPC buffer is freed by the receiving end point. */ ndrvr_info_ptr->stats.tx_packets++; ndrvr_info_ptr->stats.tx_bytes += skb->len; dev_kfree_skb(skb); return(0); }