root/drivers/staging/rtl8188eu/os_dep/recv_linux.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. rtw_os_recvbuf_resource_alloc
  2. rtw_handle_tkip_mic_err
  3. rtw_recv_indicatepkt
  4. rtw_init_recv_timer

   1 // SPDX-License-Identifier: GPL-2.0
   2 /******************************************************************************
   3  *
   4  * Copyright(c) 2007 - 2011 Realtek Corporation. All rights reserved.
   5  *
   6  ******************************************************************************/
   7 #include <osdep_service.h>
   8 #include <drv_types.h>
   9 
  10 #include <wifi.h>
  11 #include <recv_osdep.h>
  12 
  13 #include <osdep_intf.h>
  14 #include <usb_ops_linux.h>
  15 
  16 /* alloc os related resource in struct recv_buf */
  17 int rtw_os_recvbuf_resource_alloc(struct adapter *padapter,
  18                                   struct recv_buf *precvbuf)
  19 {
  20         precvbuf->pskb = NULL;
  21         precvbuf->reuse = false;
  22         precvbuf->purb = usb_alloc_urb(0, GFP_KERNEL);
  23         if (!precvbuf->purb)
  24                 return _FAIL;
  25         return _SUCCESS;
  26 }
  27 
  28 void rtw_handle_tkip_mic_err(struct adapter *padapter, u8 bgroup)
  29 {
  30         union iwreq_data wrqu;
  31         struct iw_michaelmicfailure ev;
  32         struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
  33         struct security_priv *psecuritypriv = &padapter->securitypriv;
  34         u32 cur_time = 0;
  35 
  36         if (psecuritypriv->last_mic_err_time == 0) {
  37                 psecuritypriv->last_mic_err_time = jiffies;
  38         } else {
  39                 cur_time = jiffies;
  40 
  41                 if (cur_time - psecuritypriv->last_mic_err_time < 60 * HZ) {
  42                         psecuritypriv->btkip_countermeasure = true;
  43                         psecuritypriv->last_mic_err_time = 0;
  44                         psecuritypriv->btkip_countermeasure_time = cur_time;
  45                 } else {
  46                         psecuritypriv->last_mic_err_time = jiffies;
  47                 }
  48         }
  49 
  50         memset(&ev, 0x00, sizeof(ev));
  51         if (bgroup)
  52                 ev.flags |= IW_MICFAILURE_GROUP;
  53         else
  54                 ev.flags |= IW_MICFAILURE_PAIRWISE;
  55 
  56         ev.src_addr.sa_family = ARPHRD_ETHER;
  57         memcpy(ev.src_addr.sa_data, &pmlmepriv->assoc_bssid[0], ETH_ALEN);
  58         memset(&wrqu, 0x00, sizeof(wrqu));
  59         wrqu.data.length = sizeof(ev);
  60         wireless_send_event(padapter->pnetdev, IWEVMICHAELMICFAILURE,
  61                             &wrqu, (char *)&ev);
  62 }
  63 
  64 int rtw_recv_indicatepkt(struct adapter *padapter,
  65                          struct recv_frame *precv_frame)
  66 {
  67         struct recv_priv *precvpriv;
  68         struct __queue *pfree_recv_queue;
  69         struct sk_buff *skb;
  70         struct mlme_priv *pmlmepriv = &padapter->mlmepriv;
  71 
  72         precvpriv = &padapter->recvpriv;
  73         pfree_recv_queue = &precvpriv->free_recv_queue;
  74 
  75         skb = precv_frame->pkt;
  76         if (!skb) {
  77                 RT_TRACE(_module_recv_osdep_c_, _drv_err_,
  78                          ("%s():skb == NULL something wrong!!!!\n", __func__));
  79                 goto _recv_indicatepkt_drop;
  80         }
  81 
  82         if (check_fwstate(pmlmepriv, WIFI_AP_STATE)) {
  83                 struct sk_buff *pskb2 = NULL;
  84                 struct sta_info *psta = NULL;
  85                 struct sta_priv *pstapriv = &padapter->stapriv;
  86                 struct rx_pkt_attrib *pattrib = &precv_frame->attrib;
  87                 bool mcast = is_multicast_ether_addr(pattrib->dst);
  88 
  89                 if (memcmp(pattrib->dst, myid(&padapter->eeprompriv),
  90                            ETH_ALEN)) {
  91                         if (mcast) {
  92                                 psta = rtw_get_bcmc_stainfo(padapter);
  93                                 pskb2 = skb_clone(skb, GFP_ATOMIC);
  94                         } else {
  95                                 psta = rtw_get_stainfo(pstapriv, pattrib->dst);
  96                         }
  97 
  98                         if (psta) {
  99                                 struct net_device *pnetdev;
 100 
 101                                 pnetdev = (struct net_device *)padapter->pnetdev;
 102                                 skb->dev = pnetdev;
 103                                 skb_set_queue_mapping(skb, rtw_recv_select_queue(skb));
 104 
 105                                 rtw_xmit_entry(skb, pnetdev);
 106 
 107                                 if (mcast)
 108                                         skb = pskb2;
 109                                 else
 110                                         goto _recv_indicatepkt_end;
 111                         }
 112                 }
 113         }
 114 
 115         skb->ip_summed = CHECKSUM_NONE;
 116         skb->dev = padapter->pnetdev;
 117         skb->protocol = eth_type_trans(skb, padapter->pnetdev);
 118 
 119         netif_rx(skb);
 120 
 121 _recv_indicatepkt_end:
 122 
 123         /*  pointers to NULL before rtw_free_recvframe() */
 124         precv_frame->pkt = NULL;
 125 
 126         rtw_free_recvframe(precv_frame, pfree_recv_queue);
 127 
 128         RT_TRACE(_module_recv_osdep_c_, _drv_info_,
 129                  ("\n %s :after netif_rx!!!!\n", __func__));
 130 
 131         return _SUCCESS;
 132 
 133 _recv_indicatepkt_drop:
 134 
 135          /* enqueue back to free_recv_queue */
 136         rtw_free_recvframe(precv_frame, pfree_recv_queue);
 137 
 138         return _FAIL;
 139 }
 140 
 141 void rtw_init_recv_timer(struct recv_reorder_ctrl *preorder_ctrl)
 142 {
 143         timer_setup(&preorder_ctrl->reordering_ctrl_timer,
 144                     rtw_reordering_ctrl_timeout_handler, 0);
 145 }

/* [<][>][^][v][top][bottom][index][help] */