2013-05-19 04:28:07 +00:00
|
|
|
/******************************************************************************
|
|
|
|
*
|
|
|
|
* Copyright(c) 2007 - 2012 Realtek Corporation. All rights reserved.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of version 2 of the GNU General Public License as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
* more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
|
|
|
|
*
|
2013-08-12 02:47:28 +00:00
|
|
|
******************************************************************************/
|
2013-05-19 04:28:07 +00:00
|
|
|
#define _USB_OPS_LINUX_C_
|
|
|
|
|
|
|
|
#include <drv_types.h>
|
|
|
|
#include <usb_ops_linux.h>
|
|
|
|
#include <rtw_sreset.h>
|
|
|
|
|
|
|
|
unsigned int ffaddr2pipehdl(struct dvobj_priv *pdvobj, u32 addr)
|
|
|
|
{
|
2013-08-12 02:47:28 +00:00
|
|
|
unsigned int pipe = 0, ep_num = 0;
|
2013-05-19 04:28:07 +00:00
|
|
|
struct usb_device *pusbd = pdvobj->pusbdev;
|
|
|
|
|
|
|
|
if (addr == RECV_BULK_IN_ADDR) {
|
2013-08-12 02:47:28 +00:00
|
|
|
pipe = usb_rcvbulkpipe(pusbd, pdvobj->RtInPipe[0]);
|
2013-05-19 04:28:07 +00:00
|
|
|
} else if (addr == RECV_INT_IN_ADDR) {
|
2013-08-12 02:47:28 +00:00
|
|
|
pipe = usb_rcvbulkpipe(pusbd, pdvobj->RtInPipe[1]);
|
2013-05-19 04:28:07 +00:00
|
|
|
} else if (addr < HW_QUEUE_ENTRY) {
|
|
|
|
ep_num = pdvobj->Queue2Pipe[addr];
|
|
|
|
pipe = usb_sndbulkpipe(pusbd, ep_num);
|
|
|
|
}
|
|
|
|
|
|
|
|
return pipe;
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:47:28 +00:00
|
|
|
struct zero_bulkout_context {
|
2013-05-19 04:28:07 +00:00
|
|
|
void *pbuf;
|
|
|
|
void *purb;
|
|
|
|
void *pirp;
|
|
|
|
void *padapter;
|
|
|
|
};
|
|
|
|
|
|
|
|
void usb_read_mem(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *rmem)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void usb_write_mem(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void usb_read_port_cancel(struct intf_hdl *pintfhdl)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
struct recv_buf *precvbuf;
|
2013-07-27 01:08:39 +00:00
|
|
|
struct adapter *padapter = pintfhdl->padapter;
|
2013-05-19 04:28:07 +00:00
|
|
|
precvbuf = (struct recv_buf *)padapter->recvpriv.precv_buf;
|
|
|
|
|
2013-05-25 23:35:42 +00:00
|
|
|
DBG_88E("%s\n", __func__);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-26 03:02:10 +00:00
|
|
|
padapter->bReadPortCancel = true;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-08-12 02:47:28 +00:00
|
|
|
for (i = 0; i < NR_RECVBUFF; i++) {
|
2013-05-26 03:02:10 +00:00
|
|
|
precvbuf->reuse = true;
|
2013-08-12 02:47:28 +00:00
|
|
|
if (precvbuf->purb)
|
2013-05-19 04:28:07 +00:00
|
|
|
usb_kill_urb(precvbuf->purb);
|
|
|
|
precvbuf++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void usb_write_port_complete(struct urb *purb, struct pt_regs *regs)
|
|
|
|
{
|
|
|
|
struct xmit_buf *pxmitbuf = (struct xmit_buf *)purb->context;
|
2013-07-27 01:08:39 +00:00
|
|
|
struct adapter *padapter = pxmitbuf->padapter;
|
2013-07-20 22:33:31 +00:00
|
|
|
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
|
2013-08-12 02:47:28 +00:00
|
|
|
struct hal_data_8188e *haldata;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
|
|
|
_func_enter_;
|
|
|
|
|
2013-07-20 22:33:31 +00:00
|
|
|
switch (pxmitbuf->flags) {
|
|
|
|
case VO_QUEUE_INX:
|
|
|
|
pxmitpriv->voq_cnt--;
|
|
|
|
break;
|
|
|
|
case VI_QUEUE_INX:
|
|
|
|
pxmitpriv->viq_cnt--;
|
|
|
|
break;
|
|
|
|
case BE_QUEUE_INX:
|
|
|
|
pxmitpriv->beq_cnt--;
|
|
|
|
break;
|
|
|
|
case BK_QUEUE_INX:
|
|
|
|
pxmitpriv->bkq_cnt--;
|
|
|
|
break;
|
|
|
|
case HIGH_QUEUE_INX:
|
2013-10-19 17:45:47 +00:00
|
|
|
#ifdef CONFIG_88EU_AP_MODE
|
2013-07-20 22:33:31 +00:00
|
|
|
rtw_chk_hi_queue_cmd(padapter);
|
2013-05-19 04:28:07 +00:00
|
|
|
#endif
|
2013-07-20 22:33:31 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
|
|
|
|
2013-08-12 02:47:28 +00:00
|
|
|
if (padapter->bSurpriseRemoved || padapter->bDriverStopped ||
|
|
|
|
padapter->bWritePortCancel) {
|
2013-07-20 22:33:31 +00:00
|
|
|
RT_TRACE(_module_hci_ops_os_c_, _drv_err_,
|
|
|
|
("usb_write_port_complete:bDriverStopped(%d) OR bSurpriseRemoved(%d)",
|
|
|
|
padapter->bDriverStopped, padapter->bSurpriseRemoved));
|
2013-05-25 23:35:42 +00:00
|
|
|
DBG_88E("%s(): TX Warning! bDriverStopped(%d) OR bSurpriseRemoved(%d) bWritePortCancel(%d) pxmitbuf->ext_tag(%x)\n",
|
2013-08-12 02:47:28 +00:00
|
|
|
__func__, padapter->bDriverStopped,
|
|
|
|
padapter->bSurpriseRemoved, padapter->bReadPortCancel,
|
|
|
|
pxmitbuf->ext_tag);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
|
|
|
goto check_completion;
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:47:28 +00:00
|
|
|
if (purb->status) {
|
|
|
|
RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_write_port_complete : purb->status(%d) != 0\n", purb->status));
|
|
|
|
DBG_88E("###=> urb_write_port_complete status(%d)\n", purb->status);
|
|
|
|
if ((purb->status == -EPIPE) || (purb->status == -EPROTO)) {
|
2013-05-19 04:28:07 +00:00
|
|
|
sreset_set_wifi_error_status(padapter, USB_WRITE_PORT_FAIL);
|
|
|
|
} else if (purb->status == -EINPROGRESS) {
|
2013-08-12 02:47:28 +00:00
|
|
|
RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_write_port_complete: EINPROGESS\n"));
|
2013-05-19 04:28:07 +00:00
|
|
|
goto check_completion;
|
|
|
|
} else if (purb->status == -ENOENT) {
|
2013-05-25 23:35:42 +00:00
|
|
|
DBG_88E("%s: -ENOENT\n", __func__);
|
2013-05-19 04:28:07 +00:00
|
|
|
goto check_completion;
|
|
|
|
} else if (purb->status == -ECONNRESET) {
|
2013-05-25 23:35:42 +00:00
|
|
|
DBG_88E("%s: -ECONNRESET\n", __func__);
|
2013-05-19 04:28:07 +00:00
|
|
|
goto check_completion;
|
|
|
|
} else if (purb->status == -ESHUTDOWN) {
|
2013-08-12 02:47:28 +00:00
|
|
|
RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_write_port_complete: ESHUTDOWN\n"));
|
|
|
|
padapter->bDriverStopped = true;
|
|
|
|
RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_write_port_complete:bDriverStopped = true\n"));
|
2013-05-19 04:28:07 +00:00
|
|
|
goto check_completion;
|
2013-08-12 02:47:28 +00:00
|
|
|
} else {
|
|
|
|
padapter->bSurpriseRemoved = true;
|
|
|
|
DBG_88E("bSurpriseRemoved = true\n");
|
|
|
|
RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_write_port_complete:bSurpriseRemoved = true\n"));
|
2013-05-19 04:28:07 +00:00
|
|
|
|
|
|
|
goto check_completion;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:47:28 +00:00
|
|
|
haldata = GET_HAL_DATA(padapter);
|
|
|
|
haldata->srestpriv.last_tx_complete_time = rtw_get_current_time();
|
2013-05-19 04:28:07 +00:00
|
|
|
|
|
|
|
check_completion:
|
|
|
|
rtw_sctx_done_err(&pxmitbuf->sctx,
|
2013-08-12 02:47:28 +00:00
|
|
|
purb->status ? RTW_SCTX_DONE_WRITE_PORT_ERR :
|
|
|
|
RTW_SCTX_DONE_SUCCESS);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
|
|
|
rtw_free_xmitbuf(pxmitpriv, pxmitbuf);
|
|
|
|
|
2013-08-12 02:47:28 +00:00
|
|
|
tasklet_hi_schedule(&pxmitpriv->xmit_tasklet);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
|
|
|
_func_exit_;
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 usb_write_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem)
|
|
|
|
{
|
2013-07-24 03:39:20 +00:00
|
|
|
unsigned long irqL;
|
2013-05-19 04:28:07 +00:00
|
|
|
unsigned int pipe;
|
|
|
|
int status;
|
2013-10-19 17:45:47 +00:00
|
|
|
u32 ret = _FAIL;
|
2013-08-12 02:47:28 +00:00
|
|
|
struct urb *purb = NULL;
|
2013-07-27 01:08:39 +00:00
|
|
|
struct adapter *padapter = (struct adapter *)pintfhdl->padapter;
|
2013-05-19 04:28:07 +00:00
|
|
|
struct dvobj_priv *pdvobj = adapter_to_dvobj(padapter);
|
|
|
|
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
|
|
|
|
struct xmit_buf *pxmitbuf = (struct xmit_buf *)wmem;
|
|
|
|
struct xmit_frame *pxmitframe = (struct xmit_frame *)pxmitbuf->priv_data;
|
|
|
|
struct usb_device *pusbd = pdvobj->pusbdev;
|
|
|
|
|
|
|
|
_func_enter_;
|
|
|
|
|
2013-08-12 02:47:28 +00:00
|
|
|
RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("+usb_write_port\n"));
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-08-12 02:47:28 +00:00
|
|
|
if ((padapter->bDriverStopped) || (padapter->bSurpriseRemoved) ||
|
|
|
|
(padapter->pwrctrlpriv.pnp_bstop_trx)) {
|
|
|
|
RT_TRACE(_module_hci_ops_os_c_, _drv_err_,
|
|
|
|
("usb_write_port:( padapter->bDriverStopped ||padapter->bSurpriseRemoved ||adapter->pwrctrlpriv.pnp_bstop_trx)!!!\n"));
|
2013-05-19 04:28:07 +00:00
|
|
|
rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_TX_DENY);
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
_enter_critical(&pxmitpriv->lock, &irqL);
|
|
|
|
|
2013-08-12 02:47:28 +00:00
|
|
|
switch (addr) {
|
|
|
|
case VO_QUEUE_INX:
|
|
|
|
pxmitpriv->voq_cnt++;
|
|
|
|
pxmitbuf->flags = VO_QUEUE_INX;
|
|
|
|
break;
|
|
|
|
case VI_QUEUE_INX:
|
|
|
|
pxmitpriv->viq_cnt++;
|
|
|
|
pxmitbuf->flags = VI_QUEUE_INX;
|
|
|
|
break;
|
|
|
|
case BE_QUEUE_INX:
|
|
|
|
pxmitpriv->beq_cnt++;
|
|
|
|
pxmitbuf->flags = BE_QUEUE_INX;
|
|
|
|
break;
|
|
|
|
case BK_QUEUE_INX:
|
|
|
|
pxmitpriv->bkq_cnt++;
|
|
|
|
pxmitbuf->flags = BK_QUEUE_INX;
|
|
|
|
break;
|
|
|
|
case HIGH_QUEUE_INX:
|
|
|
|
pxmitbuf->flags = HIGH_QUEUE_INX;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
pxmitbuf->flags = MGT_QUEUE_INX;
|
|
|
|
break;
|
2013-05-19 04:28:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_exit_critical(&pxmitpriv->lock, &irqL);
|
|
|
|
|
|
|
|
purb = pxmitbuf->pxmit_urb[0];
|
|
|
|
|
2013-08-12 02:47:28 +00:00
|
|
|
/* translate DMA FIFO addr to pipehandle */
|
2013-05-19 04:28:07 +00:00
|
|
|
pipe = ffaddr2pipehdl(pdvobj, addr);
|
|
|
|
|
|
|
|
usb_fill_bulk_urb(purb, pusbd, pipe,
|
2013-08-12 02:47:28 +00:00
|
|
|
pxmitframe->buf_addr, /* pxmitbuf->pbuf */
|
|
|
|
cnt,
|
|
|
|
usb_write_port_complete,
|
|
|
|
pxmitbuf);/* context is pxmitbuf */
|
2013-05-19 04:28:07 +00:00
|
|
|
|
|
|
|
status = usb_submit_urb(purb, GFP_ATOMIC);
|
|
|
|
if (!status) {
|
2013-08-12 02:47:28 +00:00
|
|
|
struct hal_data_8188e *haldata = GET_HAL_DATA(padapter);
|
|
|
|
|
|
|
|
haldata->srestpriv.last_tx_time = rtw_get_current_time();
|
2013-05-19 04:28:07 +00:00
|
|
|
} else {
|
|
|
|
rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_WRITE_PORT_ERR);
|
2013-08-12 02:47:28 +00:00
|
|
|
DBG_88E("usb_write_port, status =%d\n", status);
|
|
|
|
RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_write_port(): usb_submit_urb, status =%x\n", status));
|
2013-05-19 04:28:07 +00:00
|
|
|
|
|
|
|
switch (status) {
|
|
|
|
case -ENODEV:
|
2013-08-12 02:47:28 +00:00
|
|
|
padapter->bDriverStopped = true;
|
2013-05-19 04:28:07 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
goto exit;
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:47:28 +00:00
|
|
|
ret = _SUCCESS;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-08-12 02:47:28 +00:00
|
|
|
/* We add the URB_ZERO_PACKET flag to urb so that the host will send the zero packet automatically. */
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-08-12 02:47:28 +00:00
|
|
|
RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("-usb_write_port\n"));
|
2013-05-19 04:28:07 +00:00
|
|
|
|
|
|
|
exit:
|
|
|
|
if (ret != _SUCCESS)
|
|
|
|
rtw_free_xmitbuf(pxmitpriv, pxmitbuf);
|
|
|
|
_func_exit_;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
void usb_write_port_cancel(struct intf_hdl *pintfhdl)
|
|
|
|
{
|
|
|
|
int i, j;
|
2013-07-27 01:08:39 +00:00
|
|
|
struct adapter *padapter = pintfhdl->padapter;
|
2013-05-19 04:28:07 +00:00
|
|
|
struct xmit_buf *pxmitbuf = (struct xmit_buf *)padapter->xmitpriv.pxmitbuf;
|
|
|
|
|
2013-05-25 23:35:42 +00:00
|
|
|
DBG_88E("%s\n", __func__);
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-05-26 03:02:10 +00:00
|
|
|
padapter->bWritePortCancel = true;
|
2013-05-19 04:28:07 +00:00
|
|
|
|
2013-08-12 02:47:28 +00:00
|
|
|
for (i = 0; i < NR_XMITBUFF; i++) {
|
|
|
|
for (j = 0; j < 8; j++) {
|
|
|
|
if (pxmitbuf->pxmit_urb[j])
|
2013-05-19 04:28:07 +00:00
|
|
|
usb_kill_urb(pxmitbuf->pxmit_urb[j]);
|
|
|
|
}
|
|
|
|
pxmitbuf++;
|
|
|
|
}
|
|
|
|
|
2013-08-12 02:47:28 +00:00
|
|
|
pxmitbuf = (struct xmit_buf *)padapter->xmitpriv.pxmit_extbuf;
|
2013-05-19 04:28:07 +00:00
|
|
|
for (i = 0; i < NR_XMIT_EXTBUFF; i++) {
|
2013-08-12 02:47:28 +00:00
|
|
|
for (j = 0; j < 8; j++) {
|
|
|
|
if (pxmitbuf->pxmit_urb[j])
|
2013-05-19 04:28:07 +00:00
|
|
|
usb_kill_urb(pxmitbuf->pxmit_urb[j]);
|
|
|
|
}
|
|
|
|
pxmitbuf++;
|
|
|
|
}
|
|
|
|
}
|