linux-stable/drivers/staging/rtl8712/recv_linux.c

155 lines
4.5 KiB
C
Raw Normal View History

/******************************************************************************
* recv_linux.c
*
* Copyright(c) 2007 - 2010 Realtek Corporation. All rights reserved.
* Linux device driver for RTL8192SU
*
* 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
*
* Modifications for inclusion into the Linux staging tree are
* Copyright(c) 2010 Larry Finger. All rights reserved.
*
* Contact information:
* WLAN FAE <wlanfae@realtek.com>.
* Larry Finger <Larry.Finger@lwfinger.net>
*
******************************************************************************/
#define _RECV_OSDEP_C_
#include <linux/usb.h>
#include "osdep_service.h"
#include "drv_types.h"
#include "wifi.h"
#include "recv_osdep.h"
#include "osdep_intf.h"
#include "ethernet.h"
#include <linux/if_arp.h>
#include "usb_ops.h"
/*init os related resource in struct recv_priv*/
/*alloc os related resource in union recv_frame*/
int r8712_os_recv_resource_alloc(struct _adapter *padapter,
union recv_frame *precvframe)
{
precvframe->u.hdr.pkt_newalloc = NULL;
precvframe->u.hdr.pkt = NULL;
return _SUCCESS;
}
/*alloc os related resource in struct recv_buf*/
int r8712_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)
res = _FAIL;
precvbuf->pskb = NULL;
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 r8712_os_recvbuf_resource_free(struct _adapter *padapter,
struct recv_buf *precvbuf)
{
if (precvbuf->pskb)
dev_kfree_skb_any(precvbuf->pskb);
if (precvbuf->purb) {
usb_kill_urb(precvbuf->purb);
usb_free_urb(precvbuf->purb);
}
return _SUCCESS;
}
void r8712_handle_tkip_mic_err(struct _adapter *padapter, u8 bgroup)
{
union iwreq_data wrqu;
struct iw_michaelmicfailure ev;
struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
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;
Staging: rtl8712: replace memcpy() by ether_addr_copy() using coccinelle and pack variable This patch focuses on fixing the following warning generated by checkpatch.pl for the file rxtx.c Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2) @@ expression e1, e2; @@ - memcpy(e1, e2, ETH_ALEN); + ether_addr_copy(e1, e2); struct _adapter { struct dvobj_priv dvobjpriv; /* 0 40*/ struct mlme_priv mlmepriv; /* 40 1560*/ /* --- cacheline 25 boundary (1600 bytes) --- */ struct cmd_priv cmdpriv; /* 1600 136*/ /* --- cacheline 27 boundary (1728 bytes) was 8 bytes ago --- */ struct evt_priv evtpriv; /* 1736 96*/ /* --- cacheline 28 boundary (1792 bytes) was 40 bytes ago --- * */ struct io_queue * pio_queue; /* 1832 8*/ struct xmit_priv xmitpriv; /* 1840 912*/ /* --- cacheline 43 boundary (2752 bytes) --- */ struct recv_priv recvpriv; /* 2752 1088*/ /* --- cacheline 60 boundary (3840 bytes) --- */ struct sta_priv stapriv; /* 3840 672*/ /* --- cacheline 70 boundary (4480 bytes) was 32 bytes ago --- * */ struct security_priv securitypriv; /* 4512 4816*/ /* --- cacheline 145 boundary (9280 bytes) was 48 bytes ago --- * */ struct registry_priv registrypriv; /* 9328 968*/ /* --- cacheline 160 boundary (10240 bytes) was 56 bytes ago --- * */ struct wlan_acl_pool acl_list; /* 10296 1536*/ /* --- cacheline 184 boundary (11776 bytes) was 56 bytes ago --- * */ struct pwrctrl_priv pwrctrlpriv; /* 11832 224*/ /* --- cacheline 188 boundary (12032 bytes) was 24 bytes ago --- * */ struct eeprom_priv eeprompriv; /* 12056 508*/ /* XXX 4 bytes hole, try to pack */ /* --- cacheline 196 boundary (12544 bytes) was 24 bytes ago --- * */ struct hal_priv halpriv; /* 12568 88*/ /* --- cacheline 197 boundary (12608 bytes) was 48 bytes ago --- * */ struct led_priv ledpriv; /* 12656 304*/ /* --- cacheline 202 boundary (12928 bytes) was 32 bytes ago --- * */ struct mp_priv mppriv; /* 12960 1080*/ /* --- cacheline 219 boundary (14016 bytes) was 24 bytes ago --- * */ s32 bDriverStopped; /* 14040 4*/ s32 bSurpriseRemoved; /* 14044 4*/ u32 IsrContent; /* 14048 4*/ u32 ImrContent; /* 14052 4*/ u8 EepromAddressSize; /* 14056 1*/ u8 hw_init_completed; /* 14057 1*/ /* XXX 6 bytes hole, try to pack */ struct task_struct * cmdThread; /* 14064 8*/ pid_t evtThread; /* 14072 4*/ /* XXX 4 bytes hole, try to pack */ /* --- cacheline 220 boundary (14080 bytes) --- */ struct task_struct * xmitThread; /* 14080 8*/ pid_t recvThread; /* 14088 4*/ /* XXX 4 bytes hole, try to pack */ uint (*dvobj_init)(struct _adapter *); /*14096 8 */ void (*dvobj_deinit)(struct _adapter *);/* 14104 8 */ struct net_device * pnetdev; /* 14112 8*/ int bup; /* 14120 4*/ /* XXX 4 bytes hole, try to pack */ struct net_device_stats stats; /* 14128 184*/ /* --- cacheline 223 boundary (14272 bytes) was 40 bytes ago --- * */ struct iw_statistics iwstats; /* 14312 32*/ /* --- cacheline 224 boundary (14336 bytes) was 8 bytes ago --- * */ int pid; /* 14344 4*/ /* XXX 4 bytes hole, try to pack */ struct work_struct wkFilterRxFF0; /* 14352 32*/ u8 blnEnableRxFF0Filter; /* 14384 1*/ /* XXX 3 bytes hole, try to pack */ spinlock_t lockRxFF0Filter; /* 14388 4*/ const struct firmware * fw; /* 14392 8*/ u8 EepromAddressSize; /* 14056 1*/ u8 hw_init_completed; /* 14057 1*/ /* XXX 6 bytes hole, try to pack */ struct task_struct * cmdThread; /* 14064 8*/ pid_t evtThread; /* 14072 4*/ /* XXX 4 bytes hole, try to pack */ /* --- cacheline 220 boundary (14080 bytes) --- */ struct task_struct * xmitThread; /* 14080 8*/ pid_t recvThread; /* 14088 4*/ /* XXX 4 bytes hole, try to pack */ uint (*dvobj_init)(struct _adapter *); /*14096 8 */ void (*dvobj_deinit)(struct _adapter *);/* 14104 8 */ struct net_device * pnetdev; /* 14112 8*/ int bup; /* 14120 4*/ /* XXX 4 bytes hole, try to pack */ struct net_device_stats stats; /* 14128 184*/ /* --- cacheline 223 boundary (14272 bytes) was 40 bytes ago --- * */ struct iw_statistics iwstats; /* 14312 32*/ /* --- cacheline 224 boundary (14336 bytes) was 8 bytes ago --- * */ int pid; /* 14344 4*/ /* XXX 4 bytes hole, try to pack */ struct work_struct wkFilterRxFF0; /* 14352 32*/ u8 blnEnableRxFF0Filter; /* 14384 1*/ /* XXX 3 bytes hole, try to pack */ spinlock_t lockRxFF0Filter; /* 14388 4*/ const struct firmware * fw; /* 14392 8*/ /* --- cacheline 225 boundary (14400 bytes) --- */ struct usb_interface * pusb_intf; /* 14400 8*/ struct mutex mutex_start; /* 14408 40*/ /* XXX last struct has 4 bytes of padding */ struct completion rtl8712_fw_ready; /* 14448 32*/ /* --- cacheline 226 boundary (14464 bytes) was 16 bytes ago --- * */ /* size: 14480, cachelines: 227, members: 40 */ /* sum members: 14451, holes: 7, sum holes: 29 */ /* paddings: 1, sum paddings: 4 */ /* last cacheline: 16 bytes */ }; Signed-off-by: Melike Yurtoglu <aysemelikeyurtoglu@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2015-02-23 06:42:56 +00:00
ether_addr_copy(ev.src_addr.sa_data, &pmlmepriv->assoc_bssid[0]);
memset(&wrqu, 0x00, sizeof(wrqu));
wrqu.data.length = sizeof(ev);
wireless_send_event(padapter->pnetdev, IWEVMICHAELMICFAILURE, &wrqu,
(char *)&ev);
}
void r8712_recv_indicatepkt(struct _adapter *padapter,
union recv_frame *precv_frame)
{
struct recv_priv *precvpriv;
struct __queue *pfree_recv_queue;
_pkt *skb;
struct rx_pkt_attrib *pattrib = &precv_frame->u.hdr.attrib;
precvpriv = &(padapter->recvpriv);
pfree_recv_queue = &(precvpriv->free_recv_queue);
skb = precv_frame->u.hdr.pkt;
if (!skb)
goto _recv_indicatepkt_drop;
skb->data = precv_frame->u.hdr.rx_data;
skb->len = precv_frame->u.hdr.len;
skb_set_tail_pointer(skb, skb->len);
if ((pattrib->tcpchk_valid == 1) && (pattrib->tcp_chkrpt == 1))
skb->ip_summed = CHECKSUM_UNNECESSARY;
else
skb->ip_summed = CHECKSUM_NONE;
skb->dev = padapter->pnetdev;
skb->protocol = eth_type_trans(skb, padapter->pnetdev);
netif_rx(skb);
precv_frame->u.hdr.pkt = NULL; /* pointers to NULL before
* r8712_free_recvframe()
*/
r8712_free_recvframe(precv_frame, pfree_recv_queue);
return;
_recv_indicatepkt_drop:
/*enqueue back to free_recv_queue*/
if (precv_frame)
r8712_free_recvframe(precv_frame, pfree_recv_queue);
precvpriv->rx_drop++;
}
static void _r8712_reordering_ctrl_timeout_handler (unsigned long data)
{
struct recv_reorder_ctrl *preorder_ctrl =
(struct recv_reorder_ctrl *)data;
r8712_reordering_ctrl_timeout_handler(preorder_ctrl);
}
void r8712_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl)
{
setup_timer(&preorder_ctrl->reordering_ctrl_timer,
_r8712_reordering_ctrl_timeout_handler,
(unsigned long)preorder_ctrl);
}