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 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); }