Commit 2b42bd58 authored by Phillip Potter's avatar Phillip Potter Committed by Greg Kroah-Hartman

staging: r8188eu: introduce new os_dep dir for RTL8188eu driver

This patchset is split in order to keep the file sizes down. This os_dep
directory is part of the newer/better driver from GitHub modified by
Larry Finger. Import this as the basis for all future work going
forward.
Suggested-by: default avatarLarry Finger <Larry.Finger@lwfinger.net>
Signed-off-by: default avatarPhillip Potter <phil@philpotter.co.uk>
Link: https://lore.kernel.org/r/20210727232219.2948-4-phil@philpotter.co.ukSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8cd574e6
This diff is collapsed.
/******************************************************************************
*
* 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
*
*
******************************************************************************/
#define _MLME_OSDEP_C_
#include <osdep_service.h>
#include <drv_types.h>
#include <mlme_osdep.h>
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)
void rtw_join_timeout_handler (void *FunctionContext)
#else
void rtw_join_timeout_handler (struct timer_list *t)
#endif
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)
struct adapter *adapter = (struct adapter *)FunctionContext;
#else
struct adapter *adapter = from_timer(adapter, t, mlmepriv.assoc_timer);
#endif
_rtw_join_timeout_handler(adapter);
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)
void _rtw_scan_timeout_handler (void *FunctionContext)
#else
void _rtw_scan_timeout_handler (struct timer_list *t)
#endif
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)
struct adapter *adapter = (struct adapter *)FunctionContext;
#else
struct adapter *adapter = from_timer(adapter, t, mlmepriv.scan_to_timer);
#endif
rtw_scan_timeout_handler(adapter);
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)
static void _dynamic_check_timer_handlder(void *FunctionContext)
#else
static void _dynamic_check_timer_handlder(struct timer_list *t)
#endif
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)
struct adapter *adapter = (struct adapter *)FunctionContext;
#else
struct adapter *adapter = from_timer(adapter, t, mlmepriv.dynamic_chk_timer);
#endif
if (adapter->registrypriv.mp_mode == 1)
return;
rtw_dynamic_check_timer_handlder(adapter);
_set_timer(&adapter->mlmepriv.dynamic_chk_timer, 2000);
}
void rtw_init_mlme_timer(struct adapter *padapter)
{
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)
_init_timer(&(pmlmepriv->assoc_timer), padapter->pnetdev, rtw_join_timeout_handler, padapter);
_init_timer(&(pmlmepriv->scan_to_timer), padapter->pnetdev, _rtw_scan_timeout_handler, padapter);
_init_timer(&(pmlmepriv->dynamic_chk_timer), padapter->pnetdev, _dynamic_check_timer_handlder, padapter);
#else
timer_setup(&pmlmepriv->assoc_timer, rtw_join_timeout_handler, 0);
timer_setup(&pmlmepriv->scan_to_timer, _rtw_scan_timeout_handler, 0);
timer_setup(&pmlmepriv->dynamic_chk_timer, _dynamic_check_timer_handlder, 0);
#endif
}
void rtw_os_indicate_connect(struct adapter *adapter)
{
rtw_indicate_wx_assoc_event(adapter);
netif_carrier_on(adapter->pnetdev);
if (adapter->pid[2] != 0)
rtw_signal_process(adapter->pid[2], SIGALRM);
}
void rtw_os_indicate_scan_done(struct adapter *padapter, bool aborted)
{
indicate_wx_scan_complete_event(padapter);
}
static struct rt_pmkid_list backup_pmkid[NUM_PMKID_CACHE];
void rtw_reset_securitypriv(struct adapter *adapter)
{
u8 backup_index = 0;
u8 backup_counter = 0x00;
u32 backup_time = 0;
if (adapter->securitypriv.dot11AuthAlgrthm == dot11AuthAlgrthm_8021X) {
/* 802.1x */
/* We have to backup the PMK information for WiFi PMK Caching test item. */
/* Backup the btkip_countermeasure information. */
/* When the countermeasure is trigger, the driver have to disconnect with AP for 60 seconds. */
memset(&backup_pmkid[0], 0x00, sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
memcpy(&backup_pmkid[0], &adapter->securitypriv.PMKIDList[0], sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
backup_index = adapter->securitypriv.PMKIDIndex;
backup_counter = adapter->securitypriv.btkip_countermeasure;
backup_time = adapter->securitypriv.btkip_countermeasure_time;
memset((unsigned char *)&adapter->securitypriv, 0, sizeof(struct security_priv));
/* Restore the PMK information to securitypriv structure for the following connection. */
memcpy(&adapter->securitypriv.PMKIDList[0],
&backup_pmkid[0],
sizeof(struct rt_pmkid_list) * NUM_PMKID_CACHE);
adapter->securitypriv.PMKIDIndex = backup_index;
adapter->securitypriv.btkip_countermeasure = backup_counter;
adapter->securitypriv.btkip_countermeasure_time = backup_time;
adapter->securitypriv.ndisauthtype = Ndis802_11AuthModeOpen;
adapter->securitypriv.ndisencryptstatus = Ndis802_11WEPDisabled;
} else {
/* reset values in securitypriv */
struct security_priv *psec_priv = &adapter->securitypriv;
psec_priv->dot11AuthAlgrthm = dot11AuthAlgrthm_Open; /* open system */
psec_priv->dot11PrivacyAlgrthm = _NO_PRIVACY_;
psec_priv->dot11PrivacyKeyIndex = 0;
psec_priv->dot118021XGrpPrivacy = _NO_PRIVACY_;
psec_priv->dot118021XGrpKeyid = 1;
psec_priv->ndisauthtype = Ndis802_11AuthModeOpen;
psec_priv->ndisencryptstatus = Ndis802_11WEPDisabled;
}
}
void rtw_os_indicate_disconnect(struct adapter *adapter)
{
netif_carrier_off(adapter->pnetdev); /* Do it first for tx broadcast pkt after disconnection issue! */
rtw_indicate_wx_disassoc_event(adapter);
rtw_reset_securitypriv(adapter);
}
void rtw_report_sec_ie(struct adapter *adapter, u8 authmode, u8 *sec_ie)
{
uint len;
u8 *buff, *p, i;
union iwreq_data wrqu;
RT_TRACE(_module_mlme_osdep_c_, _drv_info_,
("+rtw_report_sec_ie, authmode=%d\n", authmode));
buff = NULL;
if (authmode == _WPA_IE_ID_) {
RT_TRACE(_module_mlme_osdep_c_, _drv_info_,
("rtw_report_sec_ie, authmode=%d\n", authmode));
buff = rtw_malloc(IW_CUSTOM_MAX);
if (!buff)
return;
memset(buff, 0, IW_CUSTOM_MAX);
p = buff;
p += sprintf(p, "ASSOCINFO(ReqIEs =");
len = sec_ie[1]+2;
len = (len < IW_CUSTOM_MAX) ? len : IW_CUSTOM_MAX;
for (i = 0; i < len; i++)
p += sprintf(p, "%02x", sec_ie[i]);
p += sprintf(p, ")");
memset(&wrqu, 0, sizeof(wrqu));
wrqu.data.length = p-buff;
wrqu.data.length = (wrqu.data.length < IW_CUSTOM_MAX) ?
wrqu.data.length : IW_CUSTOM_MAX;
wireless_send_event(adapter->pnetdev, IWEVCUSTOM, &wrqu, buff);
kfree(buff);
}
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)
static void _survey_timer_hdl(void *FunctionContext)
#else
static void _survey_timer_hdl(struct timer_list *t)
#endif
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)
struct adapter *padapter = (struct adapter *)FunctionContext;
#else
struct adapter *padapter = from_timer(padapter, t, mlmeextpriv.survey_timer);
#endif
survey_timer_hdl(padapter);
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)
static void _link_timer_hdl(void *FunctionContext)
#else
static void _link_timer_hdl(struct timer_list *t)
#endif
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)
struct adapter *padapter = (struct adapter *)FunctionContext;
#else
struct adapter *padapter = from_timer(padapter, t, mlmeextpriv.link_timer);
#endif
link_timer_hdl(padapter);
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)
static void _addba_timer_hdl(void *FunctionContext)
#else
static void _addba_timer_hdl(struct timer_list *t)
#endif
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)
struct sta_info *psta = (struct sta_info *)FunctionContext;
#else
struct sta_info *psta = from_timer(psta, t, addba_retry_timer);
#endif
addba_timer_hdl(psta);
}
void init_addba_retry_timer(struct adapter *padapter, struct sta_info *psta)
{
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)
_init_timer(&psta->addba_retry_timer, padapter->pnetdev, _addba_timer_hdl, psta);
#else
timer_setup(&psta->addba_retry_timer, _addba_timer_hdl, 0);
#endif
}
void init_mlme_ext_timer(struct adapter *padapter)
{
struct mlme_ext_priv *pmlmeext = &padapter->mlmeextpriv;
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)
_init_timer(&pmlmeext->survey_timer, padapter->pnetdev, _survey_timer_hdl, padapter);
_init_timer(&pmlmeext->link_timer, padapter->pnetdev, _link_timer_hdl, padapter);
#else
timer_setup(&pmlmeext->survey_timer, _survey_timer_hdl, 0);
timer_setup(&pmlmeext->link_timer, _link_timer_hdl, 0);
#endif
}
#ifdef CONFIG_88EU_AP_MODE
void rtw_indicate_sta_assoc_event(struct adapter *padapter, struct sta_info *psta)
{
union iwreq_data wrqu;
struct sta_priv *pstapriv = &padapter->stapriv;
if (psta == NULL)
return;
if (psta->aid > NUM_STA)
return;
if (pstapriv->sta_aid[psta->aid - 1] != psta)
return;
wrqu.addr.sa_family = ARPHRD_ETHER;
memcpy(wrqu.addr.sa_data, psta->hwaddr, ETH_ALEN);
DBG_88E("+rtw_indicate_sta_assoc_event\n");
wireless_send_event(padapter->pnetdev, IWEVREGISTERED, &wrqu, NULL);
}
void rtw_indicate_sta_disassoc_event(struct adapter *padapter, struct sta_info *psta)
{
union iwreq_data wrqu;
struct sta_priv *pstapriv = &padapter->stapriv;
if (psta == NULL)
return;
if (psta->aid > NUM_STA)
return;
if (pstapriv->sta_aid[psta->aid - 1] != psta)
return;
wrqu.addr.sa_family = ARPHRD_ETHER;
memcpy(wrqu.addr.sa_data, psta->hwaddr, ETH_ALEN);
DBG_88E("+rtw_indicate_sta_disassoc_event\n");
wireless_send_event(padapter->pnetdev, IWEVEXPIRED, &wrqu, NULL);
}
#endif
This diff is collapsed.
This diff is collapsed.
/******************************************************************************
*
* 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
*
*
******************************************************************************/
#define _RECV_OSDEP_C_
#include <osdep_service.h>
#include <drv_types.h>
#include <wifi.h>
#include <recv_osdep.h>
#include <osdep_intf.h>
#include <ethernet.h>
#include <usb_ops.h>
/* init os related resource in struct recv_priv */
int rtw_os_recv_resource_init(struct recv_priv *precvpriv,
struct adapter *padapter)
{
return _SUCCESS;
}
/* alloc os related resource in struct recv_frame */
int rtw_os_recv_resource_alloc(struct adapter *padapter,
struct recv_frame *precvframe)
{
precvframe->pkt_newalloc = NULL;
precvframe->pkt = NULL;
return _SUCCESS;
}
/* free os related resource in struct recv_frame */
void rtw_os_recv_resource_free(struct recv_priv *precvpriv)
{
}
/* alloc os related resource in struct recv_buf */
int rtw_os_recvbuf_resource_alloc(struct adapter *padapter,
struct recv_buf *precvbuf)
{
int res = _SUCCESS;
precvbuf->irp_pending = false;
precvbuf->purb = usb_alloc_urb(0, GFP_KERNEL);
if (precvbuf->purb == NULL)
res = _FAIL;
precvbuf->pskb = NULL;
precvbuf->reuse = false;
precvbuf->pallocated_buf = NULL;
precvbuf->pbuf = NULL;
precvbuf->pdata = NULL;
precvbuf->phead = NULL;
precvbuf->ptail = NULL;
precvbuf->pend = NULL;
precvbuf->transfer_len = 0;
precvbuf->len = 0;
return res;
}
/* free os related resource in struct recv_buf */
int rtw_os_recvbuf_resource_free(struct adapter *padapter,
struct recv_buf *precvbuf)
{
usb_free_urb(precvbuf->purb);
return _SUCCESS;
}
void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 bgroup)
{
union iwreq_data wrqu;
struct iw_michaelmicfailure ev;
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
struct security_priv *psecuritypriv = &padapter->securitypriv;
u32 cur_time = 0;
if (psecuritypriv->last_mic_err_time == 0) {
psecuritypriv->last_mic_err_time = jiffies;
} else {
cur_time = jiffies;
if (cur_time - psecuritypriv->last_mic_err_time < 60*HZ) {
psecuritypriv->btkip_countermeasure = true;
psecuritypriv->last_mic_err_time = 0;
psecuritypriv->btkip_countermeasure_time = cur_time;
} else {
psecuritypriv->last_mic_err_time = jiffies;
}
}
memset(&ev, 0x00, sizeof(ev));
if (bgroup)
ev.flags |= IW_MICFAILURE_GROUP;
else
ev.flags |= IW_MICFAILURE_PAIRWISE;
ev.src_addr.sa_family = ARPHRD_ETHER;
memcpy(ev.src_addr.sa_data, &pmlmepriv->assoc_bssid[0], ETH_ALEN);
memset(&wrqu, 0x00, sizeof(wrqu));
wrqu.data.length = sizeof(ev);
wireless_send_event(padapter->pnetdev, IWEVMICHAELMICFAILURE,
&wrqu, (char *)&ev);
}
void rtw_hostapd_mlme_rx(struct adapter *padapter,
struct recv_frame *precv_frame)
{
}
int rtw_recv_indicatepkt(struct adapter *padapter,
struct recv_frame *precv_frame)
{
struct recv_priv *precvpriv;
struct __queue *pfree_recv_queue;
struct sk_buff *skb;
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
precvpriv = &(padapter->recvpriv);
pfree_recv_queue = &(precvpriv->free_recv_queue);
skb = precv_frame->pkt;
if (skb == NULL) {
RT_TRACE(_module_recv_osdep_c_, _drv_err_,
("rtw_recv_indicatepkt():skb == NULL something wrong!!!!\n"));
goto _recv_indicatepkt_drop;
}
RT_TRACE(_module_recv_osdep_c_, _drv_info_,
("rtw_recv_indicatepkt():skb != NULL !!!\n"));
RT_TRACE(_module_recv_osdep_c_, _drv_info_,
("rtw_recv_indicatepkt():precv_frame->rx_head =%p precv_frame->hdr.rx_data =%p\n",
precv_frame->rx_head, precv_frame->rx_data));
RT_TRACE(_module_recv_osdep_c_, _drv_info_,
("precv_frame->hdr.rx_tail =%p precv_frame->rx_end =%p precv_frame->hdr.len =%d\n",
precv_frame->rx_tail, precv_frame->rx_end,
precv_frame->len));
skb->data = precv_frame->rx_data;
skb_set_tail_pointer(skb, precv_frame->len);
skb->len = precv_frame->len;
RT_TRACE(_module_recv_osdep_c_, _drv_info_,
("skb->head =%p skb->data =%p skb->tail =%p skb->end =%p skb->len =%d\n",
skb->head, skb->data, skb_tail_pointer(skb),
skb_end_pointer(skb), skb->len));
if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
struct sk_buff *pskb2 = NULL;
struct sta_info *psta = NULL;
struct sta_priv *pstapriv = &padapter->stapriv;
struct rx_pkt_attrib *pattrib = &precv_frame->attrib;
int bmcast = IS_MCAST(pattrib->dst);
if (memcmp(pattrib->dst, myid(&padapter->eeprompriv),
ETH_ALEN)) {
if (bmcast) {
psta = rtw_get_bcmc_stainfo(padapter);
pskb2 = skb_clone(skb, GFP_ATOMIC);
} else {
psta = rtw_get_stainfo(pstapriv, pattrib->dst);
}
if (psta) {
struct net_device *pnetdev;
pnetdev = (struct net_device *)padapter->pnetdev;
skb->dev = pnetdev;
skb_set_queue_mapping(skb, rtw_recv_select_queue(skb));
rtw_xmit_entry(skb, pnetdev);
if (bmcast)
skb = pskb2;
else
goto _recv_indicatepkt_end;
}
}
}
rcu_read_lock();
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)
rcu_dereference(padapter->pnetdev->rx_handler_data);
#else
rcu_dereference(padapter->pnetdev->br_port);
#endif
rcu_read_unlock();
skb->ip_summed = CHECKSUM_NONE;
skb->dev = padapter->pnetdev;
skb->protocol = eth_type_trans(skb, padapter->pnetdev);
netif_rx(skb);
_recv_indicatepkt_end:
/* pointers to NULL before rtw_free_recvframe() */
precv_frame->pkt = NULL;
rtw_free_recvframe(precv_frame, pfree_recv_queue);
RT_TRACE(_module_recv_osdep_c_, _drv_info_,
("\n rtw_recv_indicatepkt :after netif_rx!!!!\n"));
return _SUCCESS;
_recv_indicatepkt_drop:
/* enqueue back to free_recv_queue */
rtw_free_recvframe(precv_frame, pfree_recv_queue);
return _FAIL;
}
void rtw_os_read_port(struct adapter *padapter, struct recv_buf *precvbuf)
{
struct recv_priv *precvpriv = &padapter->recvpriv;
precvbuf->ref_cnt--;
/* free skb in recv_buf */
dev_kfree_skb_any(precvbuf->pskb);
precvbuf->pskb = NULL;
precvbuf->reuse = false;
if (!precvbuf->irp_pending)
rtw_read_port(padapter, precvpriv->ff_hwaddr, 0,
(unsigned char *)precvbuf);
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)
static void _rtw_reordering_ctrl_timeout_handler(void *func_context)
#else
static void _rtw_reordering_ctrl_timeout_handler(struct timer_list *t)
#endif
{
struct recv_reorder_ctrl *preorder_ctrl;
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)
preorder_ctrl = (struct recv_reorder_ctrl *)func_context;
#else
preorder_ctrl = from_timer(preorder_ctrl, t, reordering_ctrl_timer);
#endif
rtw_reordering_ctrl_timeout_handler(preorder_ctrl);
}
void rtw_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl)
{
struct adapter *padapter = preorder_ctrl->padapter;
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 15, 0)
_init_timer(&(preorder_ctrl->reordering_ctrl_timer), padapter->pnetdev, _rtw_reordering_ctrl_timeout_handler, preorder_ctrl);
#else
timer_setup(&preorder_ctrl->reordering_ctrl_timer, _rtw_reordering_ctrl_timeout_handler, 0);
#endif
}
/******************************************************************************
*
* 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 <linux/module.h>
#include <linux/netdevice.h>
#include <linux/version.h>
#include <rtw_android.h>
#include <osdep_service.h>
#include <rtw_debug.h>
#include <ioctl_cfg80211.h>
#include <rtw_ioctl_set.h>
static const char *android_wifi_cmd_str[ANDROID_WIFI_CMD_MAX] = {
"START",
"STOP",
"SCAN-ACTIVE",
"SCAN-PASSIVE",
"RSSI",
"LINKSPEED",
"RXFILTER-START",
"RXFILTER-STOP",
"RXFILTER-ADD",
"RXFILTER-REMOVE",
"BTCOEXSCAN-START",
"BTCOEXSCAN-STOP",
"BTCOEXMODE",
"SETSUSPENDOPT",
"P2P_DEV_ADDR",
"SETFWPATH",
"SETBAND",
"GETBAND",
"COUNTRY",
"P2P_SET_NOA",
"P2P_GET_NOA",
"P2P_SET_PS",
"SET_AP_WPS_P2P_IE",
"MACADDR",
"BLOCK",
"WFD-ENABLE",
"WFD-DISABLE",
"WFD-SET-TCPPORT",
"WFD-SET-MAXTPUT",
"WFD-SET-DEVTYPE",
};
struct android_wifi_priv_cmd {
const char __user *buf;
int used_len;
int total_len;
};
/**
* Local (static) functions and variables
*/
/* Initialize g_wifi_on to 1 so dhd_bus_start will be called for the first
* time (only) in dhd_open, subsequential wifi on will be handled by
* wl_android_wifi_on
*/
static int g_wifi_on = true;
int rtw_android_cmdstr_to_num(char *cmdstr)
{
int cmd_num;
for(cmd_num=0; cmd_num < ANDROID_WIFI_CMD_MAX; cmd_num++)
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 0, 0))
if (!strncasecmp(cmdstr, android_wifi_cmd_str[cmd_num],
strlen(android_wifi_cmd_str[cmd_num])))
#else
if(0 == strnicmp(cmdstr, android_wifi_cmd_str[cmd_num],
strlen(android_wifi_cmd_str[cmd_num])))
#endif
break;
return cmd_num;
}
static int rtw_android_get_rssi(struct net_device *net, char *command,
int total_len)
{
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(net);
struct mlme_priv *pmlmepriv = &(padapter->mlmepriv);
struct wlan_network *pcur_network = &pmlmepriv->cur_network;
int bytes_written = 0;
if (check_fwstate(pmlmepriv, _FW_LINKED)) {
bytes_written += snprintf(&command[bytes_written], total_len,
"%s rssi %d",
pcur_network->network.Ssid.Ssid,
padapter->recvpriv.rssi);
}
return bytes_written;
}
static int rtw_android_get_link_speed(struct net_device *net, char *command,
int total_len)
{
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(net);
int bytes_written;
u16 link_speed;
link_speed = rtw_get_cur_max_rate(padapter) / 10;
bytes_written = snprintf(command, total_len, "LinkSpeed %d",
link_speed);
return bytes_written;
}
static int rtw_android_get_macaddr(struct net_device *net, char *command,
int total_len)
{
int bytes_written;
bytes_written = snprintf(command, total_len, "Macaddr = %pM",
net->dev_addr);
return bytes_written;
}
static int android_set_cntry(struct net_device *net, char *command,
int total_len)
{
struct adapter *adapter = (struct adapter *)rtw_netdev_priv(net);
char *country_code = command + strlen(android_wifi_cmd_str[ANDROID_WIFI_CMD_COUNTRY]) + 1;
int ret;
ret = rtw_set_country(adapter, country_code);
return (ret == _SUCCESS) ? 0 : -1;
}
static int android_get_p2p_addr(struct net_device *net, char *command,
int total_len)
{
/* We use the same address as our HW MAC address */
memcpy(command, net->dev_addr, ETH_ALEN);
return ETH_ALEN;
}
static int rtw_android_set_block(struct net_device *net, char *command,
int total_len)
{
return 0;
}
int rtw_android_priv_cmd(struct net_device *net, struct ifreq *ifr, int cmd)
{
int ret = 0;
char *command = NULL;
int cmd_num;
int bytes_written = 0;
struct android_wifi_priv_cmd priv_cmd;
rtw_lock_suspend();
if (!ifr->ifr_data) {
ret = -EINVAL;
goto exit;
}
if (copy_from_user(&priv_cmd, ifr->ifr_data,
sizeof(struct android_wifi_priv_cmd))) {
ret = -EFAULT;
goto exit;
}
command = kmalloc(priv_cmd.total_len, GFP_KERNEL);
if (!command) {
DBG_88E("%s: failed to allocate memory\n", __func__);
ret = -ENOMEM;
goto exit;
}
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0))
if (!access_ok(priv_cmd.buf, priv_cmd.total_len)) {
#else
if (!access_ok(VERIFY_READ, priv_cmd.buf, priv_cmd.total_len)) {
#endif
DBG_88E("%s: failed to access memory\n", __func__);
ret = -EFAULT;
goto exit;
}
if (copy_from_user(command, (char __user *)priv_cmd.buf,
priv_cmd.total_len)) {
ret = -EFAULT;
goto exit;
}
DBG_88E("%s: Android private cmd \"%s\" on %s\n",
__func__, command, ifr->ifr_name);
cmd_num = rtw_android_cmdstr_to_num(command);
switch (cmd_num) {
case ANDROID_WIFI_CMD_START:
goto response;
case ANDROID_WIFI_CMD_SETFWPATH:
goto response;
}
if (!g_wifi_on) {
DBG_88E("%s: Ignore private cmd \"%s\" - iface %s is down\n",
__func__, command, ifr->ifr_name);
ret = 0;
goto exit;
}
switch (cmd_num) {
case ANDROID_WIFI_CMD_STOP:
break;
case ANDROID_WIFI_CMD_SCAN_ACTIVE:
break;
case ANDROID_WIFI_CMD_SCAN_PASSIVE:
break;
case ANDROID_WIFI_CMD_RSSI:
bytes_written = rtw_android_get_rssi(net, command,
priv_cmd.total_len);
break;
case ANDROID_WIFI_CMD_LINKSPEED:
bytes_written = rtw_android_get_link_speed(net, command,
priv_cmd.total_len);
break;
case ANDROID_WIFI_CMD_MACADDR:
bytes_written = rtw_android_get_macaddr(net, command,
priv_cmd.total_len);
break;
case ANDROID_WIFI_CMD_BLOCK:
bytes_written = rtw_android_set_block(net, command,
priv_cmd.total_len);
break;
case ANDROID_WIFI_CMD_RXFILTER_START:
break;
case ANDROID_WIFI_CMD_RXFILTER_STOP:
break;
case ANDROID_WIFI_CMD_RXFILTER_ADD:
break;
case ANDROID_WIFI_CMD_RXFILTER_REMOVE:
break;
case ANDROID_WIFI_CMD_BTCOEXSCAN_START:
/* TBD: BTCOEXSCAN-START */
break;
case ANDROID_WIFI_CMD_BTCOEXSCAN_STOP:
/* TBD: BTCOEXSCAN-STOP */
break;
case ANDROID_WIFI_CMD_BTCOEXMODE:
break;
case ANDROID_WIFI_CMD_SETSUSPENDOPT:
break;
case ANDROID_WIFI_CMD_SETBAND:
break;
case ANDROID_WIFI_CMD_GETBAND:
break;
case ANDROID_WIFI_CMD_COUNTRY:
bytes_written = android_set_cntry(net, command,
priv_cmd.total_len);
break;
case ANDROID_WIFI_CMD_P2P_DEV_ADDR:
bytes_written = android_get_p2p_addr(net, command,
priv_cmd.total_len);
break;
case ANDROID_WIFI_CMD_P2P_SET_NOA:
break;
case ANDROID_WIFI_CMD_P2P_GET_NOA:
break;
case ANDROID_WIFI_CMD_P2P_SET_PS:
break;
default:
DBG_88E("Unknown PRIVATE command %s - ignored\n", command);
snprintf(command, 3, "OK");
bytes_written = strlen("OK");
}
response:
if (bytes_written >= 0) {
if ((bytes_written == 0) && (priv_cmd.total_len > 0))
command[0] = '\0';
if (bytes_written >= priv_cmd.total_len) {
DBG_88E("%s: bytes_written = %d\n", __func__,
bytes_written);
bytes_written = priv_cmd.total_len;
} else {
bytes_written++;
}
priv_cmd.used_len = bytes_written;
if (copy_to_user((char __user *)priv_cmd.buf, command,
bytes_written)) {
DBG_88E("%s: failed to copy data to user buffer\n",
__func__);
ret = -EFAULT;
}
} else {
ret = bytes_written;
}
exit:
rtw_unlock_suspend();
kfree(command);
return ret;
}
This diff is collapsed.
/******************************************************************************
*
* 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 _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)
{
unsigned int pipe = 0, ep_num = 0;
struct usb_device *pusbd = pdvobj->pusbdev;
if (addr == RECV_BULK_IN_ADDR) {
pipe = usb_rcvbulkpipe(pusbd, pdvobj->RtInPipe[0]);
} else if (addr == RECV_INT_IN_ADDR) {
pipe = usb_rcvbulkpipe(pusbd, pdvobj->RtInPipe[1]);
} else if (addr < HW_QUEUE_ENTRY) {
ep_num = pdvobj->Queue2Pipe[addr];
pipe = usb_sndbulkpipe(pusbd, ep_num);
}
return pipe;
}
struct zero_bulkout_context {
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;
struct adapter *padapter = pintfhdl->padapter;
precvbuf = (struct recv_buf *)padapter->recvpriv.precv_buf;
DBG_88E("%s\n", __func__);
padapter->bReadPortCancel = true;
for (i = 0; i < NR_RECVBUFF; i++) {
precvbuf->reuse = true;
if (precvbuf->purb)
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;
struct adapter *padapter = pxmitbuf->padapter;
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
struct hal_data_8188e *haldata;
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:
#ifdef CONFIG_88EU_AP_MODE
rtw_chk_hi_queue_cmd(padapter);
#endif
break;
default:
break;
}
if (padapter->bSurpriseRemoved || padapter->bDriverStopped ||
padapter->bWritePortCancel) {
RT_TRACE(_module_hci_ops_os_c_, _drv_err_,
("usb_write_port_complete:bDriverStopped(%d) OR bSurpriseRemoved(%d)",
padapter->bDriverStopped, padapter->bSurpriseRemoved));
DBG_88E("%s(): TX Warning! bDriverStopped(%d) OR bSurpriseRemoved(%d) bWritePortCancel(%d) pxmitbuf->ext_tag(%x)\n",
__func__, padapter->bDriverStopped,
padapter->bSurpriseRemoved, padapter->bReadPortCancel,
pxmitbuf->ext_tag);
goto check_completion;
}
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)) {
sreset_set_wifi_error_status(padapter, USB_WRITE_PORT_FAIL);
} else if (purb->status == -EINPROGRESS) {
RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("usb_write_port_complete: EINPROGESS\n"));
goto check_completion;
} else if (purb->status == -ENOENT) {
DBG_88E("%s: -ENOENT\n", __func__);
goto check_completion;
} else if (purb->status == -ECONNRESET) {
DBG_88E("%s: -ECONNRESET\n", __func__);
goto check_completion;
} else if (purb->status == -ESHUTDOWN) {
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"));
goto check_completion;
} 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"));
goto check_completion;
}
}
haldata = GET_HAL_DATA(padapter);
haldata->srestpriv.last_tx_complete_time = jiffies;
check_completion:
rtw_sctx_done_err(&pxmitbuf->sctx,
purb->status ? RTW_SCTX_DONE_WRITE_PORT_ERR :
RTW_SCTX_DONE_SUCCESS);
rtw_free_xmitbuf(pxmitpriv, pxmitbuf);
tasklet_hi_schedule(&pxmitpriv->xmit_tasklet);
}
u32 usb_write_port(struct intf_hdl *pintfhdl, u32 addr, u32 cnt, u8 *wmem)
{
unsigned long irqL;
unsigned int pipe;
int status;
u32 ret = _FAIL;
struct urb *purb = NULL;
struct adapter *padapter = (struct adapter *)pintfhdl->padapter;
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;
RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("+usb_write_port\n"));
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"));
rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_TX_DENY);
goto exit;
}
spin_lock_irqsave(&pxmitpriv->lock, irqL);
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;
}
spin_unlock_irqrestore(&pxmitpriv->lock, irqL);
purb = pxmitbuf->pxmit_urb[0];
/* translate DMA FIFO addr to pipehandle */
pipe = ffaddr2pipehdl(pdvobj, addr);
usb_fill_bulk_urb(purb, pusbd, pipe,
pxmitframe->buf_addr, /* pxmitbuf->pbuf */
cnt,
usb_write_port_complete,
pxmitbuf);/* context is pxmitbuf */
status = usb_submit_urb(purb, GFP_ATOMIC);
if (!status) {
struct hal_data_8188e *haldata = GET_HAL_DATA(padapter);
haldata->srestpriv.last_tx_time = jiffies;
} else {
rtw_sctx_done_err(&pxmitbuf->sctx, RTW_SCTX_DONE_WRITE_PORT_ERR);
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));
switch (status) {
case -ENODEV:
padapter->bDriverStopped = true;
break;
default:
break;
}
goto exit;
}
ret = _SUCCESS;
/* We add the URB_ZERO_PACKET flag to urb so that the host will send the zero packet automatically. */
RT_TRACE(_module_hci_ops_os_c_, _drv_err_, ("-usb_write_port\n"));
exit:
if (ret != _SUCCESS)
rtw_free_xmitbuf(pxmitpriv, pxmitbuf);
return ret;
}
void usb_write_port_cancel(struct intf_hdl *pintfhdl)
{
int i, j;
struct adapter *padapter = pintfhdl->padapter;
struct xmit_buf *pxmitbuf = (struct xmit_buf *)padapter->xmitpriv.pxmitbuf;
DBG_88E("%s\n", __func__);
padapter->bWritePortCancel = true;
for (i = 0; i < NR_XMITBUFF; i++) {
for (j = 0; j < 8; j++) {
if (pxmitbuf->pxmit_urb[j])
usb_kill_urb(pxmitbuf->pxmit_urb[j]);
}
pxmitbuf++;
}
pxmitbuf = (struct xmit_buf *)padapter->xmitpriv.pxmit_extbuf;
for (i = 0; i < NR_XMIT_EXTBUFF; i++) {
for (j = 0; j < 8; j++) {
if (pxmitbuf->pxmit_urb[j])
usb_kill_urb(pxmitbuf->pxmit_urb[j]);
}
pxmitbuf++;
}
}
/******************************************************************************
*
* 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 <linux/version.h>
#include <osdep_service.h>
#include <drv_types.h>
#include <if_ether.h>
#include <ip.h>
#include <wifi.h>
#include <mlme_osdep.h>
#include <xmit_osdep.h>
#include <osdep_intf.h>
#include <usb_osintf.h>
uint rtw_remainder_len(struct pkt_file *pfile)
{
return pfile->buf_len - ((size_t)(pfile->cur_addr) -
(size_t)(pfile->buf_start));
}
void _rtw_open_pktfile(struct sk_buff *pktptr, struct pkt_file *pfile)
{
if (!pktptr) {
pr_err("8188eu: pktptr is NULL\n");
return;
}
if (!pfile) {
pr_err("8188eu: pfile is NULL\n");
return;
}
pfile->pkt = pktptr;
pfile->cur_addr = pktptr->data;
pfile->buf_start = pktptr->data;
pfile->pkt_len = pktptr->len;
pfile->buf_len = pktptr->len;
pfile->cur_buffer = pfile->buf_start;
}
uint _rtw_pktfile_read (struct pkt_file *pfile, u8 *rmem, uint rlen)
{
uint len = 0;
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;
return len;
}
int rtw_endofpktfile(struct pkt_file *pfile)
{
if (pfile->pkt_len == 0) {
return true;
}
return false;
}
void rtw_set_tx_chksum_offload(struct sk_buff *pkt, struct pkt_attrib *pattrib)
{
}
int rtw_os_xmit_resource_alloc(struct adapter *padapter, struct xmit_buf *pxmitbuf, u32 alloc_sz)
{
int i;
pxmitbuf->pallocated_buf = rtw_zmalloc(alloc_sz);
if (pxmitbuf->pallocated_buf == NULL)
return _FAIL;
pxmitbuf->pbuf = (u8 *)N_BYTE_ALIGMENT((size_t)(pxmitbuf->pallocated_buf), XMITBUF_ALIGN_SZ);
pxmitbuf->dma_transfer_addr = 0;
for (i = 0; i < 8; i++) {
pxmitbuf->pxmit_urb[i] = usb_alloc_urb(0, GFP_KERNEL);
if (pxmitbuf->pxmit_urb[i] == NULL) {
DBG_88E("pxmitbuf->pxmit_urb[i]==NULL");
return _FAIL;
}
}
return _SUCCESS;
}
void rtw_os_xmit_resource_free(struct adapter *padapter,
struct xmit_buf *pxmitbuf, u32 free_sz)
{
int i;
for (i = 0; i < 8; i++)
usb_free_urb(pxmitbuf->pxmit_urb[i]);
kfree(pxmitbuf->pallocated_buf);
}
#define WMM_XMIT_THRESHOLD (NR_XMITFRAME*2/5)
void rtw_os_pkt_complete(struct adapter *padapter, struct sk_buff *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
dev_kfree_skb_any(pkt);
}
void rtw_os_xmit_complete(struct adapter *padapter, struct xmit_frame *pxframe)
{
if (pxframe->pkt)
rtw_os_pkt_complete(padapter, pxframe->pkt);
pxframe->pkt = NULL;
}
void rtw_os_xmit_schedule(struct adapter *padapter)
{
struct xmit_priv *pxmitpriv;
if (!padapter)
return;
pxmitpriv = &padapter->xmitpriv;
spin_lock_bh(&pxmitpriv->lock);
if (rtw_txframes_pending(padapter))
tasklet_hi_schedule(&pxmitpriv->xmit_tasklet);
spin_unlock_bh(&pxmitpriv->lock);
}
static void rtw_check_xmit_resource(struct adapter *padapter, struct sk_buff *pkt)
{
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
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)
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);
}
}
}
static int rtw_mlcst2unicst(struct adapter *padapter, struct sk_buff *skb)
{
struct sta_priv *pstapriv = &padapter->stapriv;
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
struct list_head *phead, *plist;
struct sk_buff *newskb;
struct sta_info *psta = NULL;
s32 res;
spin_lock_bh(&pstapriv->asoc_list_lock);
phead = &pstapriv->asoc_list;
plist = phead->next;
/* free sta asoc_queue */
while (phead != plist) {
psta = container_of(plist, struct sta_info, asoc_list);
plist = plist->next;
/* avoid come from STA1 and send back STA1 */
if (!memcmp(psta->hwaddr, &skb->data[6], 6))
continue;
newskb = skb_copy(skb, GFP_ATOMIC);
if (newskb) {
memcpy(newskb->data, psta->hwaddr, 6);
res = rtw_xmit(padapter, &newskb);
if (res < 0) {
DBG_88E("%s()-%d: rtw_xmit() return error!\n", __func__, __LINE__);
pxmitpriv->tx_drop++;
dev_kfree_skb_any(newskb);
} else {
pxmitpriv->tx_pkts++;
}
} else {
DBG_88E("%s-%d: skb_copy() failed!\n", __func__, __LINE__);
pxmitpriv->tx_drop++;
spin_unlock_bh(&pstapriv->asoc_list_lock);
return false; /* Caller shall tx this multicast frame via normal way. */
}
}
spin_unlock_bh(&pstapriv->asoc_list_lock);
dev_kfree_skb_any(skb);
return true;
}
int rtw_xmit_entry(struct sk_buff *pkt, struct net_device *pnetdev)
{
struct adapter *padapter = (struct adapter *)rtw_netdev_priv(pnetdev);
struct xmit_priv *pxmitpriv = &padapter->xmitpriv;
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
s32 res = 0;
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"));
goto drop_packet;
}
rtw_check_xmit_resource(padapter, pkt);
if (!rtw_mc2u_disable && check_fwstate(pmlmepriv, WIFI_AP_STATE) &&
(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)
goto exit;
}
}
res = rtw_xmit(padapter, &pkt);
if (res < 0)
goto drop_packet;
pxmitpriv->tx_pkts++;
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++;
dev_kfree_skb_any(pkt);
RT_TRACE(_module_xmit_osdep_c_, _drv_notice_, ("rtw_xmit_entry: drop, tx_drop=%d\n", (u32)pxmitpriv->tx_drop));
exit:
return 0;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment