mirror of
https://github.com/Mange/rtl8192eu-linux-driver
synced 2026-04-02 07:29:56 +00:00
The official RTL8192EU linux driver from D-Link Australia
Version information: 20140812_rtl8192EU_linux_v4.3.1.1_11320 2014-08-12 version 4.3.1.1_11320 Source: ftp://files.dlink.com.au/products/DWA-131/REV_E/Drivers/DWA-131_Linux_driver_v4.3.1.1.zip This version does not currently work on newer kernels, but it does contain USB ID 2001:3319, which a lot of other repos in GitHub does not.
This commit is contained in:
290
os_dep/linux/custom_gpio_linux.c
Normal file
290
os_dep/linux/custom_gpio_linux.c
Normal file
@@ -0,0 +1,290 @@
|
||||
/******************************************************************************
|
||||
* Customer code to add GPIO control during WLAN start/stop
|
||||
*
|
||||
* Copyright(c) 2007 - 2011 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
|
||||
*
|
||||
*
|
||||
******************************************************************************/
|
||||
#include "drv_types.h"
|
||||
|
||||
#ifdef CONFIG_PLATFORM_SPRD
|
||||
|
||||
//gspi func & GPIO define
|
||||
#include <mach/gpio.h>//0915
|
||||
#include <mach/board.h>
|
||||
|
||||
#if !(defined ANDROID_2X)
|
||||
|
||||
#ifdef CONFIG_RTL8188E
|
||||
#include <mach/regulator.h>
|
||||
#include <linux/regulator/consumer.h>
|
||||
#endif // CONFIG_RTL8188E
|
||||
|
||||
#ifndef GPIO_WIFI_POWER
|
||||
#define GPIO_WIFI_POWER -1
|
||||
#endif // !GPIO_WIFI_POWER
|
||||
|
||||
#ifndef GPIO_WIFI_RESET
|
||||
#define GPIO_WIFI_RESET -1
|
||||
#endif // !GPIO_WIFI_RESET
|
||||
|
||||
#ifndef GPIO_WIFI_PWDN
|
||||
#define GPIO_WIFI_PWDN -1
|
||||
#endif // !GPIO_WIFI_RESET
|
||||
#ifdef CONFIG_GSPI_HCI
|
||||
extern unsigned int oob_irq;
|
||||
#endif // CONFIG_GSPI_HCI
|
||||
|
||||
#ifdef CONFIG_SDIO_HCI
|
||||
extern int rtw_mp_mode;
|
||||
#else // !CONFIG_SDIO_HCI
|
||||
#endif // !CONFIG_SDIO_HCI
|
||||
|
||||
int rtw_wifi_gpio_init(void)
|
||||
{
|
||||
#ifdef CONFIG_GSPI_HCI
|
||||
if (GPIO_WIFI_IRQ > 0) {
|
||||
gpio_request(GPIO_WIFI_IRQ, "oob_irq");
|
||||
gpio_direction_input(GPIO_WIFI_IRQ);
|
||||
|
||||
oob_irq = gpio_to_irq(GPIO_WIFI_IRQ);
|
||||
|
||||
DBG_8192C("%s oob_irq:%d\n", __func__, oob_irq);
|
||||
}
|
||||
#endif
|
||||
if (GPIO_WIFI_RESET > 0)
|
||||
gpio_request(GPIO_WIFI_RESET , "wifi_rst");
|
||||
if (GPIO_WIFI_POWER > 0)
|
||||
gpio_request(GPIO_WIFI_POWER, "wifi_power");
|
||||
|
||||
#ifdef CONFIG_SDIO_HCI
|
||||
#if (defined(CONFIG_RTL8723A) || defined(CONFIG_RTL8723B)) && (MP_DRIVER == 1)
|
||||
if(rtw_mp_mode==1){
|
||||
DBG_871X("%s GPIO_BT_RESET pin special for mp_test\n", __func__);
|
||||
if (GPIO_BT_RESET > 0)
|
||||
gpio_request(GPIO_BT_RESET , "bt_rst");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rtw_wifi_gpio_deinit(void)
|
||||
{
|
||||
#ifdef CONFIG_GSPI_HCI
|
||||
if (GPIO_WIFI_IRQ > 0)
|
||||
gpio_free(GPIO_WIFI_IRQ);
|
||||
#endif
|
||||
if (GPIO_WIFI_RESET > 0)
|
||||
gpio_free(GPIO_WIFI_RESET );
|
||||
if (GPIO_WIFI_POWER > 0)
|
||||
gpio_free(GPIO_WIFI_POWER);
|
||||
|
||||
#ifdef CONFIG_SDIO_HCI
|
||||
#if (defined(CONFIG_RTL8723A) || defined(CONFIG_RTL8723B)) && (MP_DRIVER == 1)
|
||||
if(rtw_mp_mode==1){
|
||||
DBG_871X("%s GPIO_BT_RESET pin special for mp_test\n", __func__);
|
||||
if (GPIO_BT_RESET > 0)
|
||||
gpio_free(GPIO_BT_RESET);
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Customer function to control hw specific wlan gpios */
|
||||
void rtw_wifi_gpio_wlan_ctrl(int onoff)
|
||||
{
|
||||
switch (onoff)
|
||||
{
|
||||
case WLAN_PWDN_OFF:
|
||||
DBG_8192C("%s: call customer specific GPIO(%d) to set wifi power down pin to 0\n",
|
||||
__FUNCTION__, GPIO_WIFI_RESET);
|
||||
|
||||
#ifndef CONFIG_DONT_BUS_SCAN
|
||||
if (GPIO_WIFI_RESET > 0)
|
||||
gpio_direction_output(GPIO_WIFI_RESET , 0);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case WLAN_PWDN_ON:
|
||||
DBG_8192C("%s: callc customer specific GPIO(%d) to set wifi power down pin to 1\n",
|
||||
__FUNCTION__, GPIO_WIFI_RESET);
|
||||
|
||||
if (GPIO_WIFI_RESET > 0)
|
||||
gpio_direction_output(GPIO_WIFI_RESET , 1);
|
||||
break;
|
||||
|
||||
case WLAN_POWER_OFF:
|
||||
break;
|
||||
|
||||
case WLAN_POWER_ON:
|
||||
break;
|
||||
#ifdef CONFIG_SDIO_HCI
|
||||
#if (defined(CONFIG_RTL8723A) || defined(CONFIG_RTL8723B)) && (MP_DRIVER == 1)
|
||||
case WLAN_BT_PWDN_OFF:
|
||||
if(rtw_mp_mode==1)
|
||||
{
|
||||
DBG_871X("%s: call customer specific GPIO to set wifi power down pin to 0\n",
|
||||
__FUNCTION__);
|
||||
if (GPIO_BT_RESET > 0)
|
||||
gpio_direction_output(GPIO_BT_RESET , 0);
|
||||
}
|
||||
break;
|
||||
|
||||
case WLAN_BT_PWDN_ON:
|
||||
if(rtw_mp_mode==1)
|
||||
{
|
||||
DBG_871X("%s: callc customer specific GPIO to set wifi power down pin to 1 %x\n",
|
||||
__FUNCTION__, GPIO_BT_RESET);
|
||||
|
||||
if (GPIO_BT_RESET > 0)
|
||||
gpio_direction_output(GPIO_BT_RESET , 1);
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
#else //ANDROID_2X
|
||||
|
||||
#include <mach/ldo.h>
|
||||
|
||||
#ifdef CONFIG_RTL8188E
|
||||
extern int sprd_3rdparty_gpio_wifi_power;
|
||||
#endif
|
||||
extern int sprd_3rdparty_gpio_wifi_pwd;
|
||||
#if (defined(CONFIG_RTL8723A) || defined(CONFIG_RTL8723B))
|
||||
extern int sprd_3rdparty_gpio_bt_reset;
|
||||
#endif
|
||||
|
||||
int rtw_wifi_gpio_init(void)
|
||||
{
|
||||
#if (defined(CONFIG_RTL8723A) || defined(CONFIG_RTL8723B))
|
||||
if (sprd_3rdparty_gpio_bt_reset > 0)
|
||||
gpio_direction_output(sprd_3rdparty_gpio_bt_reset, 1);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rtw_wifi_gpio_deinit(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Customer function to control hw specific wlan gpios */
|
||||
void rtw_wifi_gpio_wlan_ctrl(int onoff)
|
||||
{
|
||||
switch (onoff)
|
||||
{
|
||||
case WLAN_PWDN_OFF:
|
||||
DBG_8192C("%s: call customer specific GPIO to set wifi power down pin to 0\n",
|
||||
__FUNCTION__);
|
||||
if (sprd_3rdparty_gpio_wifi_pwd > 0)
|
||||
{
|
||||
gpio_set_value(sprd_3rdparty_gpio_wifi_pwd, 0);
|
||||
}
|
||||
|
||||
if (sprd_3rdparty_gpio_wifi_pwd == 60) {
|
||||
DBG_8192C("%s: turn off VSIM2 2.8V\n", __func__);
|
||||
LDO_TurnOffLDO(LDO_LDO_SIM2);
|
||||
}
|
||||
break;
|
||||
|
||||
case WLAN_PWDN_ON:
|
||||
DBG_8192C("%s: callc customer specific GPIO to set wifi power down pin to 1\n",
|
||||
__FUNCTION__);
|
||||
if (sprd_3rdparty_gpio_wifi_pwd == 60) {
|
||||
DBG_8192C("%s: turn on VSIM2 2.8V\n", __func__);
|
||||
LDO_SetVoltLevel(LDO_LDO_SIM2, LDO_VOLT_LEVEL0);
|
||||
LDO_TurnOnLDO(LDO_LDO_SIM2);
|
||||
}
|
||||
if (sprd_3rdparty_gpio_wifi_pwd > 0)
|
||||
{
|
||||
gpio_set_value(sprd_3rdparty_gpio_wifi_pwd, 1);
|
||||
}
|
||||
break;
|
||||
|
||||
case WLAN_POWER_OFF:
|
||||
#ifdef CONFIG_RTL8188E
|
||||
#ifdef CONFIG_WIF1_LDO
|
||||
DBG_8192C("%s: turn off VDD-WIFI0 1.2V\n", __FUNCTION__);
|
||||
LDO_TurnOffLDO(LDO_LDO_WIF1);
|
||||
#endif //CONFIG_WIF1_LDO
|
||||
|
||||
DBG_8192C("%s: turn off VDD-WIFI0 3.3V\n", __FUNCTION__);
|
||||
LDO_TurnOffLDO(LDO_LDO_WIF0);
|
||||
|
||||
DBG_8192C("%s: call customer specific GPIO(%d) to turn off wifi power\n",
|
||||
__FUNCTION__, sprd_3rdparty_gpio_wifi_power);
|
||||
if (sprd_3rdparty_gpio_wifi_power != 65535)
|
||||
gpio_set_value(sprd_3rdparty_gpio_wifi_power, 0);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case WLAN_POWER_ON:
|
||||
#ifdef CONFIG_RTL8188E
|
||||
DBG_8192C("%s: call customer specific GPIO(%d) to turn on wifi power\n",
|
||||
__FUNCTION__, sprd_3rdparty_gpio_wifi_power);
|
||||
if (sprd_3rdparty_gpio_wifi_power != 65535)
|
||||
gpio_set_value(sprd_3rdparty_gpio_wifi_power, 1);
|
||||
|
||||
DBG_8192C("%s: turn on VDD-WIFI0 3.3V\n", __FUNCTION__);
|
||||
LDO_TurnOnLDO(LDO_LDO_WIF0);
|
||||
LDO_SetVoltLevel(LDO_LDO_WIF0,LDO_VOLT_LEVEL1);
|
||||
|
||||
#ifdef CONFIG_WIF1_LDO
|
||||
DBG_8192C("%s: turn on VDD-WIFI1 1.2V\n", __func__);
|
||||
LDO_TurnOnLDO(LDO_LDO_WIF1);
|
||||
LDO_SetVoltLevel(LDO_LDO_WIF1,LDO_VOLT_LEVEL3);
|
||||
#endif //CONFIG_WIF1_LDO
|
||||
#endif
|
||||
break;
|
||||
|
||||
case WLAN_BT_PWDN_OFF:
|
||||
DBG_8192C("%s: call customer specific GPIO to set bt power down pin to 0\n",
|
||||
__FUNCTION__);
|
||||
#if (defined(CONFIG_RTL8723A) || defined(CONFIG_RTL8723B))
|
||||
if (sprd_3rdparty_gpio_bt_reset > 0)
|
||||
gpio_set_value(sprd_3rdparty_gpio_bt_reset, 0);
|
||||
#endif
|
||||
break;
|
||||
|
||||
case WLAN_BT_PWDN_ON:
|
||||
DBG_8192C("%s: callc customer specific GPIO to set bt power down pin to 1\n",
|
||||
__FUNCTION__);
|
||||
#if (defined(CONFIG_RTL8723A) || defined(CONFIG_RTL8723B))
|
||||
if (sprd_3rdparty_gpio_bt_reset > 0)
|
||||
gpio_set_value(sprd_3rdparty_gpio_bt_reset, 1);
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif //ANDROID_2X
|
||||
|
||||
#else // !CONFIG_PLATFORM_SPRD
|
||||
|
||||
int rtw_wifi_gpio_init(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void rtw_wifi_gpio_wlan_ctrl(int onoff)
|
||||
{
|
||||
}
|
||||
#endif //CONFIG_PLATFORM_SPRD
|
||||
6110
os_dep/linux/ioctl_cfg80211.c
Normal file
6110
os_dep/linux/ioctl_cfg80211.c
Normal file
File diff suppressed because it is too large
Load Diff
14463
os_dep/linux/ioctl_linux.c
Normal file
14463
os_dep/linux/ioctl_linux.c
Normal file
File diff suppressed because it is too large
Load Diff
609
os_dep/linux/mlme_linux.c
Normal file
609
os_dep/linux/mlme_linux.c
Normal file
File diff suppressed because it is too large
Load Diff
3776
os_dep/linux/os_intfs.c
Normal file
3776
os_dep/linux/os_intfs.c
Normal file
File diff suppressed because it is too large
Load Diff
688
os_dep/linux/recv_linux.c
Normal file
688
os_dep/linux/recv_linux.c
Normal file
File diff suppressed because it is too large
Load Diff
1181
os_dep/linux/rtw_android.c
Normal file
1181
os_dep/linux/rtw_android.c
Normal file
File diff suppressed because it is too large
Load Diff
860
os_dep/linux/rtw_proc.c
Normal file
860
os_dep/linux/rtw_proc.c
Normal file
File diff suppressed because it is too large
Load Diff
52
os_dep/linux/rtw_proc.h
Normal file
52
os_dep/linux/rtw_proc.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright(c) 2007 - 2013 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
|
||||
*
|
||||
*
|
||||
******************************************************************************/
|
||||
#ifndef __RTW_PROC_H__
|
||||
#define __RTW_PROC_H__
|
||||
|
||||
#include <linux/proc_fs.h>
|
||||
#include <linux/seq_file.h>
|
||||
|
||||
struct rtw_proc_hdl {
|
||||
char *name;
|
||||
int (*show)(struct seq_file *, void *);
|
||||
ssize_t (*write)(struct file *file, const char __user *buffer, size_t count, loff_t *pos, void *data);
|
||||
};
|
||||
|
||||
#ifdef CONFIG_PROC_DEBUG
|
||||
|
||||
struct proc_dir_entry *get_rtw_drv_proc(void);
|
||||
int rtw_drv_proc_init(void);
|
||||
void rtw_drv_proc_deinit(void);
|
||||
struct proc_dir_entry *rtw_adapter_proc_init(struct net_device *dev);
|
||||
void rtw_adapter_proc_deinit(struct net_device *dev);
|
||||
void rtw_adapter_proc_replace(struct net_device *dev);
|
||||
|
||||
#else //!CONFIG_PROC_DEBUG
|
||||
|
||||
struct proc_dir_entry *get_rtw_drv_proc(void) {return NULL;}
|
||||
int rtw_drv_proc_init(void) {return 0;}
|
||||
void rtw_drv_proc_deinit(void) {}
|
||||
struct proc_dir_entry *rtw_adapter_proc_init(struct net_device *dev){return NULL;}
|
||||
void rtw_adapter_proc_deinit(struct net_device *dev){}
|
||||
void rtw_adapter_proc_replace(struct net_device *dev){}
|
||||
|
||||
#endif //!CONFIG_PROC_DEBUG
|
||||
|
||||
#endif //__RTW_PROC_H__
|
||||
1848
os_dep/linux/usb_intf.c
Normal file
1848
os_dep/linux/usb_intf.c
Normal file
File diff suppressed because it is too large
Load Diff
788
os_dep/linux/usb_ops_linux.c
Normal file
788
os_dep/linux/usb_ops_linux.c
Normal file
File diff suppressed because it is too large
Load Diff
547
os_dep/linux/wifi_regd.c
Normal file
547
os_dep/linux/wifi_regd.c
Normal file
File diff suppressed because it is too large
Load Diff
441
os_dep/linux/xmit_linux.c
Normal file
441
os_dep/linux/xmit_linux.c
Normal file
@@ -0,0 +1,441 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* 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
|
||||
*
|
||||
*
|
||||
******************************************************************************/
|
||||
#define _XMIT_OSDEP_C_
|
||||
|
||||
#include <drv_types.h>
|
||||
|
||||
|
||||
uint rtw_remainder_len(struct pkt_file *pfile)
|
||||
{
|
||||
return (pfile->buf_len - ((SIZE_PTR)(pfile->cur_addr) - (SIZE_PTR)(pfile->buf_start)));
|
||||
}
|
||||
|
||||
void _rtw_open_pktfile (_pkt *pktptr, struct pkt_file *pfile)
|
||||
{
|
||||
_func_enter_;
|
||||
|
||||
pfile->pkt = pktptr;
|
||||
pfile->cur_addr = pfile->buf_start = pktptr->data;
|
||||
pfile->pkt_len = pfile->buf_len = pktptr->len;
|
||||
|
||||
pfile->cur_buffer = pfile->buf_start ;
|
||||
|
||||
_func_exit_;
|
||||
}
|
||||
|
||||
uint _rtw_pktfile_read (struct pkt_file *pfile, u8 *rmem, uint rlen)
|
||||
{
|
||||
uint len = 0;
|
||||
|
||||
_func_enter_;
|
||||
|
||||
len = rtw_remainder_len(pfile);
|
||||
len = (rlen > len)? len: rlen;
|
||||
|
||||
if(rmem)
|
||||
skb_copy_bits(pfile->pkt, pfile->buf_len-pfile->pkt_len, rmem, len);
|
||||
|
||||
pfile->cur_addr += len;
|
||||
pfile->pkt_len -= len;
|
||||
|
||||
_func_exit_;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
||||
sint rtw_endofpktfile(struct pkt_file *pfile)
|
||||
{
|
||||
_func_enter_;
|
||||
|
||||
if (pfile->pkt_len == 0) {
|
||||
_func_exit_;
|
||||
return _TRUE;
|
||||
}
|
||||
|
||||
_func_exit_;
|
||||
|
||||
return _FALSE;
|
||||
}
|
||||
|
||||
void rtw_set_tx_chksum_offload(_pkt *pkt, struct pkt_attrib *pattrib)
|
||||
{
|
||||
|
||||
#ifdef CONFIG_TCP_CSUM_OFFLOAD_TX
|
||||
struct sk_buff *skb = (struct sk_buff *)pkt;
|
||||
pattrib->hw_tcp_csum = 0;
|
||||
|
||||
if (skb->ip_summed == CHECKSUM_PARTIAL) {
|
||||
if (skb_shinfo(skb)->nr_frags == 0)
|
||||
{
|
||||
const struct iphdr *ip = ip_hdr(skb);
|
||||
if (ip->protocol == IPPROTO_TCP) {
|
||||
// TCP checksum offload by HW
|
||||
DBG_871X("CHECKSUM_PARTIAL TCP\n");
|
||||
pattrib->hw_tcp_csum = 1;
|
||||
//skb_checksum_help(skb);
|
||||
} else if (ip->protocol == IPPROTO_UDP) {
|
||||
//DBG_871X("CHECKSUM_PARTIAL UDP\n");
|
||||
#if 1
|
||||
skb_checksum_help(skb);
|
||||
#else
|
||||
// Set UDP checksum = 0 to skip checksum check
|
||||
struct udphdr *udp = skb_transport_header(skb);
|
||||
udp->check = 0;
|
||||
#endif
|
||||
} else {
|
||||
DBG_871X("%s-%d TCP CSUM offload Error!!\n", __FUNCTION__, __LINE__);
|
||||
WARN_ON(1); /* we need a WARN() */
|
||||
}
|
||||
}
|
||||
else { // IP fragmentation case
|
||||
DBG_871X("%s-%d nr_frags != 0, using skb_checksum_help(skb);!!\n", __FUNCTION__, __LINE__);
|
||||
skb_checksum_help(skb);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
int rtw_os_xmit_resource_alloc(_adapter *padapter, struct xmit_buf *pxmitbuf, u32 alloc_sz, u8 flag)
|
||||
{
|
||||
if (alloc_sz > 0) {
|
||||
#ifdef CONFIG_USE_USB_BUFFER_ALLOC_TX
|
||||
struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter);
|
||||
struct usb_device *pusbd = pdvobjpriv->pusbdev;
|
||||
|
||||
pxmitbuf->pallocated_buf = rtw_usb_buffer_alloc(pusbd, (size_t)alloc_sz, &pxmitbuf->dma_transfer_addr);
|
||||
pxmitbuf->pbuf = pxmitbuf->pallocated_buf;
|
||||
if(pxmitbuf->pallocated_buf == NULL)
|
||||
return _FAIL;
|
||||
#else // CONFIG_USE_USB_BUFFER_ALLOC_TX
|
||||
|
||||
pxmitbuf->pallocated_buf = rtw_zmalloc(alloc_sz);
|
||||
if (pxmitbuf->pallocated_buf == NULL)
|
||||
{
|
||||
return _FAIL;
|
||||
}
|
||||
|
||||
pxmitbuf->pbuf = (u8 *)N_BYTE_ALIGMENT((SIZE_PTR)(pxmitbuf->pallocated_buf), XMITBUF_ALIGN_SZ);
|
||||
|
||||
#endif // CONFIG_USE_USB_BUFFER_ALLOC_TX
|
||||
}
|
||||
|
||||
if (flag) {
|
||||
#ifdef CONFIG_USB_HCI
|
||||
int i;
|
||||
for(i=0; i<8; i++)
|
||||
{
|
||||
pxmitbuf->pxmit_urb[i] = usb_alloc_urb(0, GFP_KERNEL);
|
||||
if(pxmitbuf->pxmit_urb[i] == NULL)
|
||||
{
|
||||
DBG_871X("pxmitbuf->pxmit_urb[i]==NULL");
|
||||
return _FAIL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return _SUCCESS;
|
||||
}
|
||||
|
||||
void rtw_os_xmit_resource_free(_adapter *padapter, struct xmit_buf *pxmitbuf,u32 free_sz, u8 flag)
|
||||
{
|
||||
if (flag) {
|
||||
#ifdef CONFIG_USB_HCI
|
||||
int i;
|
||||
|
||||
for(i=0; i<8; i++)
|
||||
{
|
||||
if(pxmitbuf->pxmit_urb[i])
|
||||
{
|
||||
//usb_kill_urb(pxmitbuf->pxmit_urb[i]);
|
||||
usb_free_urb(pxmitbuf->pxmit_urb[i]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
if (free_sz > 0 ) {
|
||||
#ifdef CONFIG_USE_USB_BUFFER_ALLOC_TX
|
||||
struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter);
|
||||
struct usb_device *pusbd = pdvobjpriv->pusbdev;
|
||||
|
||||
rtw_usb_buffer_free(pusbd, (size_t)free_sz, pxmitbuf->pallocated_buf, pxmitbuf->dma_transfer_addr);
|
||||
pxmitbuf->pallocated_buf = NULL;
|
||||
pxmitbuf->dma_transfer_addr = 0;
|
||||
#else // CONFIG_USE_USB_BUFFER_ALLOC_TX
|
||||
if(pxmitbuf->pallocated_buf)
|
||||
rtw_mfree(pxmitbuf->pallocated_buf, free_sz);
|
||||
#endif // CONFIG_USE_USB_BUFFER_ALLOC_TX
|
||||
}
|
||||
}
|
||||
|
||||
#define WMM_XMIT_THRESHOLD (NR_XMITFRAME*2/5)
|
||||
|
||||
void rtw_os_pkt_complete(_adapter *padapter, _pkt *pkt)
|
||||
{
|
||||
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,35))
|
||||
u16 queue;
|
||||
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
|
||||
|
||||
queue = skb_get_queue_mapping(pkt);
|
||||
if (padapter->registrypriv.wifi_spec) {
|
||||
if(__netif_subqueue_stopped(padapter->pnetdev, queue) &&
|
||||
(pxmitpriv->hwxmits[queue].accnt < WMM_XMIT_THRESHOLD))
|
||||
{
|
||||
netif_wake_subqueue(padapter->pnetdev, queue);
|
||||
}
|
||||
} else {
|
||||
if(__netif_subqueue_stopped(padapter->pnetdev, queue))
|
||||
netif_wake_subqueue(padapter->pnetdev, queue);
|
||||
}
|
||||
#else
|
||||
if (netif_queue_stopped(padapter->pnetdev))
|
||||
netif_wake_queue(padapter->pnetdev);
|
||||
#endif
|
||||
|
||||
rtw_skb_free(pkt);
|
||||
}
|
||||
|
||||
void rtw_os_xmit_complete(_adapter *padapter, struct xmit_frame *pxframe)
|
||||
{
|
||||
if(pxframe->pkt)
|
||||
rtw_os_pkt_complete(padapter, pxframe->pkt);
|
||||
|
||||
pxframe->pkt = NULL;
|
||||
}
|
||||
|
||||
void rtw_os_xmit_schedule(_adapter *padapter)
|
||||
{
|
||||
_adapter *pri_adapter = padapter;
|
||||
|
||||
#if defined(CONFIG_SDIO_HCI) || defined(CONFIG_GSPI_HCI)
|
||||
if(!padapter)
|
||||
return;
|
||||
|
||||
#ifdef CONFIG_CONCURRENT_MODE
|
||||
if(padapter->adapter_type > PRIMARY_ADAPTER)
|
||||
pri_adapter = padapter->pbuddy_adapter;
|
||||
#endif
|
||||
|
||||
if (_rtw_queue_empty(&padapter->xmitpriv.pending_xmitbuf_queue) == _FALSE)
|
||||
_rtw_up_sema(&pri_adapter->xmitpriv.xmit_sema);
|
||||
|
||||
|
||||
#else
|
||||
_irqL irqL;
|
||||
struct xmit_priv *pxmitpriv;
|
||||
|
||||
if(!padapter)
|
||||
return;
|
||||
|
||||
pxmitpriv = &padapter->xmitpriv;
|
||||
|
||||
_enter_critical_bh(&pxmitpriv->lock, &irqL);
|
||||
|
||||
if(rtw_txframes_pending(padapter))
|
||||
{
|
||||
tasklet_hi_schedule(&pxmitpriv->xmit_tasklet);
|
||||
}
|
||||
|
||||
_exit_critical_bh(&pxmitpriv->lock, &irqL);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void rtw_check_xmit_resource(_adapter *padapter, _pkt *pkt)
|
||||
{
|
||||
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
|
||||
#if (LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,35))
|
||||
u16 queue;
|
||||
|
||||
queue = skb_get_queue_mapping(pkt);
|
||||
if (padapter->registrypriv.wifi_spec) {
|
||||
/* No free space for Tx, tx_worker is too slow */
|
||||
if (pxmitpriv->hwxmits[queue].accnt > WMM_XMIT_THRESHOLD) {
|
||||
//DBG_871X("%s(): stop netif_subqueue[%d]\n", __FUNCTION__, queue);
|
||||
netif_stop_subqueue(padapter->pnetdev, queue);
|
||||
}
|
||||
} else {
|
||||
if(pxmitpriv->free_xmitframe_cnt<=4) {
|
||||
if (!netif_tx_queue_stopped(netdev_get_tx_queue(padapter->pnetdev, queue)))
|
||||
netif_stop_subqueue(padapter->pnetdev, queue);
|
||||
}
|
||||
}
|
||||
#else
|
||||
if(pxmitpriv->free_xmitframe_cnt<=4)
|
||||
{
|
||||
if (!rtw_netif_queue_stopped(padapter->pnetdev))
|
||||
rtw_netif_stop_queue(padapter->pnetdev);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef CONFIG_TX_MCAST2UNI
|
||||
int rtw_mlcst2unicst(_adapter *padapter, struct sk_buff *skb)
|
||||
{
|
||||
struct sta_priv *pstapriv = &padapter->stapriv;
|
||||
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
|
||||
_irqL irqL;
|
||||
_list *phead, *plist;
|
||||
struct sk_buff *newskb;
|
||||
struct sta_info *psta = NULL;
|
||||
u8 chk_alive_num = 0;
|
||||
char chk_alive_list[NUM_STA];
|
||||
u8 bc_addr[6]={0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
|
||||
u8 null_addr[6]={0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
|
||||
int i;
|
||||
s32 res;
|
||||
|
||||
_enter_critical_bh(&pstapriv->asoc_list_lock, &irqL);
|
||||
phead = &pstapriv->asoc_list;
|
||||
plist = get_next(phead);
|
||||
|
||||
//free sta asoc_queue
|
||||
while ((rtw_end_of_queue_search(phead, plist)) == _FALSE) {
|
||||
int stainfo_offset;
|
||||
psta = LIST_CONTAINOR(plist, struct sta_info, asoc_list);
|
||||
plist = get_next(plist);
|
||||
|
||||
stainfo_offset = rtw_stainfo_offset(pstapriv, psta);
|
||||
if (stainfo_offset_valid(stainfo_offset)) {
|
||||
chk_alive_list[chk_alive_num++] = stainfo_offset;
|
||||
}
|
||||
}
|
||||
_exit_critical_bh(&pstapriv->asoc_list_lock, &irqL);
|
||||
|
||||
for (i = 0; i < chk_alive_num; i++) {
|
||||
psta = rtw_get_stainfo_by_offset(pstapriv, chk_alive_list[i]);
|
||||
if(!(psta->state &_FW_LINKED))
|
||||
continue;
|
||||
|
||||
/* avoid come from STA1 and send back STA1 */
|
||||
if (_rtw_memcmp(psta->hwaddr, &skb->data[6], 6) == _TRUE
|
||||
|| _rtw_memcmp(psta->hwaddr, null_addr, 6) == _TRUE
|
||||
|| _rtw_memcmp(psta->hwaddr, bc_addr, 6) == _TRUE
|
||||
)
|
||||
continue;
|
||||
|
||||
newskb = rtw_skb_copy(skb);
|
||||
|
||||
if (newskb) {
|
||||
_rtw_memcpy(newskb->data, psta->hwaddr, 6);
|
||||
res = rtw_xmit(padapter, &newskb);
|
||||
if (res < 0) {
|
||||
DBG_871X("%s()-%d: rtw_xmit() return error!\n", __FUNCTION__, __LINE__);
|
||||
pxmitpriv->tx_drop++;
|
||||
rtw_skb_free(newskb);
|
||||
}
|
||||
} else {
|
||||
DBG_871X("%s-%d: rtw_skb_copy() failed!\n", __FUNCTION__, __LINE__);
|
||||
pxmitpriv->tx_drop++;
|
||||
//rtw_skb_free(skb);
|
||||
return _FALSE; // Caller shall tx this multicast frame via normal way.
|
||||
}
|
||||
}
|
||||
|
||||
rtw_skb_free(skb);
|
||||
return _TRUE;
|
||||
}
|
||||
#endif // CONFIG_TX_MCAST2UNI
|
||||
|
||||
|
||||
int _rtw_xmit_entry(_pkt *pkt, _nic_hdl pnetdev)
|
||||
{
|
||||
_adapter *padapter = (_adapter *)rtw_netdev_priv(pnetdev);
|
||||
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
|
||||
#ifdef CONFIG_TX_MCAST2UNI
|
||||
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
|
||||
extern int rtw_mc2u_disable;
|
||||
#endif // CONFIG_TX_MCAST2UNI
|
||||
s32 res = 0;
|
||||
#if (LINUX_VERSION_CODE>=KERNEL_VERSION(2,6,35))
|
||||
u16 queue;
|
||||
#endif
|
||||
|
||||
_func_enter_;
|
||||
|
||||
RT_TRACE(_module_rtl871x_mlme_c_, _drv_info_, ("+xmit_enry\n"));
|
||||
|
||||
if (rtw_if_up(padapter) == _FALSE) {
|
||||
RT_TRACE(_module_xmit_osdep_c_, _drv_err_, ("rtw_xmit_entry: rtw_if_up fail\n"));
|
||||
#ifdef DBG_TX_DROP_FRAME
|
||||
DBG_871X("DBG_TX_DROP_FRAME %s if_up fail\n", __FUNCTION__);
|
||||
#endif
|
||||
goto drop_packet;
|
||||
}
|
||||
|
||||
rtw_check_xmit_resource(padapter, pkt);
|
||||
|
||||
#ifdef CONFIG_TX_MCAST2UNI
|
||||
if ( !rtw_mc2u_disable
|
||||
&& check_fwstate(pmlmepriv, WIFI_AP_STATE) == _TRUE
|
||||
&& ( IP_MCAST_MAC(pkt->data)
|
||||
|| ICMPV6_MCAST_MAC(pkt->data) )
|
||||
&& (padapter->registrypriv.wifi_spec == 0)
|
||||
)
|
||||
{
|
||||
if ( pxmitpriv->free_xmitframe_cnt > (NR_XMITFRAME/4) ) {
|
||||
res = rtw_mlcst2unicst(padapter, pkt);
|
||||
if (res == _TRUE) {
|
||||
goto exit;
|
||||
}
|
||||
} else {
|
||||
//DBG_871X("Stop M2U(%d, %d)! ", pxmitpriv->free_xmitframe_cnt, pxmitpriv->free_xmitbuf_cnt);
|
||||
//DBG_871X("!m2u );
|
||||
}
|
||||
}
|
||||
#endif // CONFIG_TX_MCAST2UNI
|
||||
|
||||
res = rtw_xmit(padapter, &pkt);
|
||||
if (res < 0) {
|
||||
#ifdef DBG_TX_DROP_FRAME
|
||||
DBG_871X("DBG_TX_DROP_FRAME %s rtw_xmit fail\n", __FUNCTION__);
|
||||
#endif
|
||||
goto drop_packet;
|
||||
}
|
||||
|
||||
RT_TRACE(_module_xmit_osdep_c_, _drv_info_, ("rtw_xmit_entry: tx_pkts=%d\n", (u32)pxmitpriv->tx_pkts));
|
||||
goto exit;
|
||||
|
||||
drop_packet:
|
||||
pxmitpriv->tx_drop++;
|
||||
rtw_skb_free(pkt);
|
||||
RT_TRACE(_module_xmit_osdep_c_, _drv_notice_, ("rtw_xmit_entry: drop, tx_drop=%d\n", (u32)pxmitpriv->tx_drop));
|
||||
|
||||
exit:
|
||||
|
||||
_func_exit_;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int rtw_xmit_entry(_pkt *pkt, _nic_hdl pnetdev)
|
||||
{
|
||||
int ret = 0;
|
||||
|
||||
if (pkt) {
|
||||
rtw_mstat_update(MSTAT_TYPE_SKB, MSTAT_ALLOC_SUCCESS, pkt->truesize);
|
||||
ret = _rtw_xmit_entry(pkt, pnetdev);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
2466
os_dep/osdep_service.c
Normal file
2466
os_dep/osdep_service.c
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user