DWORD usb_read_port_complete( PVOID context ) { struct recv_buf *precvbuf = (struct recv_buf *)context; _adapter *adapter = (_adapter *)precvbuf->adapter; struct recv_priv *precvpriv = &adapter->recvpriv; struct intf_hdl *pintfhdl = &adapter->pio_queue->intf; struct intf_priv *pintfpriv = pintfhdl->pintfpriv; struct dvobj_priv *pdvobj_priv = (struct dvobj_priv*)pintfpriv->intf_dev; LPCUSB_FUNCS usb_funcs_vp = pdvobj_priv->usb_extension._lpUsbFuncs; DWORD dwBytesTransferred = 0; DWORD dwErr = USB_CANCELED_ERROR; uint isevt, *pbuf; int fComplete =_FALSE; RT_TRACE( _module_hci_ops_os_c_, _drv_info_, ("usb_read_port_complete(%u)\n", __LINE__)); _func_enter_; _rtw_spinlock_ex(&precvpriv->lock); precvbuf->irp_pending=_FALSE; precvpriv->rx_pending_cnt --; _rtw_spinunlock_ex(&precvpriv->lock); #if 1 (*usb_funcs_vp->lpGetTransferStatus)(precvbuf->usb_transfer_read_port, &dwBytesTransferred, &dwErr); fComplete = (*usb_funcs_vp->lpIsTransferComplete)(precvbuf->usb_transfer_read_port); if(fComplete!=_TRUE) { RT_TRACE( _module_hci_ops_os_c_, _drv_err_, ("usb_read_port_complete CloseTransfer before complete\n")); } (*usb_funcs_vp->lpCloseTransfer)(precvbuf->usb_transfer_read_port); #endif if(USB_NO_ERROR != dwErr) RT_TRACE( _module_hci_ops_os_c_, _drv_err_, ("usb_read_port_complete Fail :%d\n",dwErr)); { if ( dwBytesTransferred > MAX_RECVBUF_SZ || dwBytesTransferred < RXDESC_SIZE ) { RT_TRACE(_module_hci_ops_os_c_,_drv_err_, ("\n usb_read_port_complete: (pbulkurb->TransferBufferLength > MAX_RECVBUF_SZ) || (pbulkurb->TransferBufferLength < RXDESC_SIZE): %d\n",dwBytesTransferred)); rtw_read_port(adapter, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf); //usb_read_port(pintfhdl, 0, 0, (unsigned char *)precvframe); } else { precvbuf->transfer_len = dwBytesTransferred; pbuf = (uint*)precvbuf->pbuf; if((isevt = *(pbuf+1)&0x1ff) == 0x1ff) { RT_TRACE(_module_hci_ops_os_c_,_drv_info_, ("\n usb_read_port_complete: get a event\n")); rxcmd_event_hdl(adapter, pbuf);//rx c2h events rtw_read_port(adapter, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf); } else { if(recvbuf2recvframe(adapter, precvbuf)==_FAIL)//rx packets { //precvbuf->reuse = _TRUE; rtw_read_port(adapter, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf); } } } } RT_TRACE( _module_hci_ops_os_c_, _drv_info_, ("-usb_read_port_complete(%u)\n", __LINE__)); _func_exit_; return ERROR_SUCCESS; // return STATUS_MORE_PROCESSING_REQUIRED; }
void sd_c2h_hdl(PADAPTER padapter) { u8 cmd_seq, pkt_num = 0; u16 tmp16, sz, cmd_len = 0; u32 rd_sz=0, cmd_sz = 0;//,ptr; struct evt_priv *pevtpriv = &padapter->evtpriv; pkt_num = rtw_read8(padapter, 0x102500BF); // RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("@ sd_c2h_hdl:pkt_num=%d",pkt_num)); get_next: // ptr=rtw_read32(padapter,0x102500e8); // RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("@ sd_c2h_hdl:C2H fifo RDPTR=0x%x",ptr)); // ptr=rtw_read32(padapter,0x102500ec); // RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("@ sd_c2h_hdl:C2H fifo WTPTR=0x%x",ptr)); // if(pkt_num==0x0 ){ // RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("@ sd_c2h_hdl:cmd_pkt num=0x%x!",pkt_num)); // return; // } RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("@ sd_c2h_hdl:pkt_num=%d",pkt_num)); //memset(pevtpriv->c2h_mem,0,512); rtw_read_port(padapter, RTL8712_DMA_C2HCMD, 512, pevtpriv->c2h_mem); cmd_sz = *(u16 *)&pevtpriv->c2h_mem[0]; cmd_sz &= 0x3fff; RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("sd_c2h_hdl: cmd_sz=%d[0x%x]!",cmd_sz,cmd_sz)); tmp16 = *(u16 *)&pevtpriv->c2h_mem[4]; tmp16 &= 0x01ff; if (tmp16 !=0x1ff) { RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("sd_c2h_hdl: 0x1ff error[0x%x]!",pevtpriv->c2h_mem[4])); goto exit; } if((cmd_sz+24) >512){ rtw_read_port(padapter, RTL8712_DMA_C2HCMD, (cmd_sz+24-512), pevtpriv->c2h_mem+512); RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("sd_c2h_hdl: read the second part of c2h event!")); } cmd_seq = pevtpriv->c2h_mem[27]; cmd_seq &= 0x7f; if (pevtpriv->event_seq != cmd_seq) { RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("sd_c2h_hdl: pevtpriv->event_seq (%d) != c2hbuf seq(%d)",pevtpriv->event_seq,cmd_seq)); } else { RT_TRACE(_module_hci_intfs_c_, _drv_notice_, ("sd_c2h_hdl: pevtpriv->event_seq (%d) == c2hbuf seq(%d)",pevtpriv->event_seq,cmd_seq)); } cmd_len = *(u16 *)&pevtpriv->c2h_mem[0]; cmd_len &= 0x3ff; RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("@sd_c2h_hdl: cmd_len=%d",cmd_len)); // if(cmd_len){ // memset(pevtpriv->c2h_mem+cmd_len,0,cmd_len); // rtw_read_port(padapter, RTL8712_DMA_C2HCMD, cmd_len, pevtpriv->c2h_mem+cmd_len); // } // pevtpriv->event_seq=pevtpriv->event_seq++; // if(pevtpriv->event_seq>127) // pevtpriv->event_seq=0; RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("sd_c2h_hdl:!")); rxcmd_event_hdl(padapter,pevtpriv->c2h_mem); if (pkt_num > 1) { pkt_num--; RT_TRACE(_module_hci_intfs_c_, _drv_err_, ("sd_c2h_hdl: pkt_num=%d",pkt_num)); goto get_next; } exit: return; }
static void usb_read_port_complete(struct urb *purb, struct pt_regs *regs) #endif { _irqL irqL; uint isevt, *pbuf; struct recv_buf *precvbuf = (struct recv_buf *)purb->context; _adapter *padapter =(_adapter *)precvbuf->adapter; struct recv_priv *precvpriv = &padapter->recvpriv; RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_read_port_complete!!!\n")); //Useless for linux usb driver. //2010-03-10 by Thomas //_enter_critical(&precvpriv->lock, &irqL); //precvbuf->irp_pending=_FALSE; //precvpriv->rx_pending_cnt --; //_exit_critical(&precvpriv->lock, &irqL); //if(precvpriv->rx_pending_cnt== 0) //{ // RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_read_port_complete: rx_pending_cnt== 0, set allrxreturnevt!\n")); // _up_sema(&precvpriv->allrxreturnevt); //} if(padapter->bSurpriseRemoved ||padapter->bDriverStopped) { RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_read_port_complete:bDriverStopped(%d) OR bSurpriseRemoved(%d)\n", padapter->bDriverStopped, padapter->bSurpriseRemoved)); goto exit; } if(purb->status==0)//SUCCESS { if((purb->actual_length>(MAX_RECVBUF_SZ)) || (purb->actual_length < RXDESC_SIZE)) { RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_read_port_complete: (purb->actual_length > MAX_RECVBUF_SZ) || (purb->actual_length < RXDESC_SIZE)\n")); precvbuf->reuse = _TRUE; read_port(padapter, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf); } else { precvbuf->transfer_len = purb->actual_length; pbuf = (uint*)precvbuf->pbuf; if((isevt = le32_to_cpu(*(pbuf+1))&0x1ff) == 0x1ff) { //_irqL irqL; //_enter_critical( &padapter->lockRxFF0Filter, &irqL ); //if ( padapter->blnEnableRxFF0Filter ) //{ // padapter->blnEnableRxFF0Filter = 0; //} //_exit_critical( &padapter->lockRxFF0Filter, &irqL ); //MSG_8712("usb_read_port_complete():rxcmd_event_hdl\n"); rxcmd_event_hdl(padapter, pbuf);//rx c2h events precvbuf->reuse = _TRUE; read_port(padapter, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf); } else { #ifdef CONFIG_RECV_TASKLET _pkt *pskb = precvbuf->pskb; skb_put(pskb, purb->actual_length); skb_queue_tail(&precvpriv->rx_skb_queue, pskb); tasklet_hi_schedule(&precvpriv->recv_tasklet); precvbuf->pskb = NULL; precvbuf->reuse = _FALSE; read_port(padapter, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf); #else if(recvbuf2recvframe(padapter, precvbuf)==_FAIL)//rx packets { precvbuf->reuse = _TRUE; read_port(padapter, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf); } #endif } } } else { RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_read_port_complete : purb->status(%d) != 0 \n", purb->status)); printk( "[%s] purb->status(%d) != 0\n", __FUNCTION__, purb->status ); switch(purb->status) { case -EINVAL: case -EPIPE: case -ENODEV: case -ESHUTDOWN: //padapter->bSurpriseRemoved=_TRUE; RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_read_port_complete:bSurpriseRemoved=TRUE\n")); case -ENOENT: padapter->bDriverStopped=_TRUE; RT_TRACE(_module_hci_ops_os_c_,_drv_err_,("usb_read_port_complete:bDriverStopped=TRUE\n")); break; case -EPROTO: precvbuf->reuse = _TRUE; read_port(padapter, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf); break; case -EINPROGRESS: printk("ERROR: URB IS IN PROGRESS!/n"); break; default: break; } } exit: _func_exit_; }