Path: blob/master/ALFA-W1F1/RTL8814AU/os_dep/linux/recv_linux.c
1307 views
/******************************************************************************1*2* Copyright(c) 2007 - 2017 Realtek Corporation.3*4* This program is free software; you can redistribute it and/or modify it5* under the terms of version 2 of the GNU General Public License as6* published by the Free Software Foundation.7*8* This program is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for11* more details.12*13*****************************************************************************/14#define _RECV_OSDEP_C_1516#include <drv_types.h>1718int rtw_os_recvframe_duplicate_skb(_adapter *padapter, union recv_frame *pcloneframe, _pkt *pskb)19{20int res = _SUCCESS;21_pkt *pkt_copy = NULL;2223if (pskb == NULL) {24RTW_INFO("%s [WARN] skb == NULL, drop frag frame\n", __func__);25return _FAIL;26}27#if 128pkt_copy = rtw_skb_copy(pskb);2930if (pkt_copy == NULL) {31RTW_INFO("%s [WARN] rtw_skb_copy fail , drop frag frame\n", __func__);32return _FAIL;33}34#else35pkt_copy = rtw_skb_clone(pskb);3637if (pkt_copy == NULL) {38RTW_INFO("%s [WARN] rtw_skb_clone fail , drop frag frame\n", __func__);39return _FAIL;40}41#endif42pkt_copy->dev = padapter->pnetdev;4344pcloneframe->u.hdr.pkt = pkt_copy;45pcloneframe->u.hdr.rx_head = pkt_copy->head;46pcloneframe->u.hdr.rx_data = pkt_copy->data;47pcloneframe->u.hdr.rx_end = skb_end_pointer(pkt_copy);48pcloneframe->u.hdr.rx_tail = skb_tail_pointer(pkt_copy);49pcloneframe->u.hdr.len = pkt_copy->len;5051return res;52}5354int rtw_os_alloc_recvframe(_adapter *padapter, union recv_frame *precvframe, u8 *pdata, _pkt *pskb)55{56int res = _SUCCESS;57u8 shift_sz = 0;58u32 skb_len, alloc_sz;59_pkt *pkt_copy = NULL;60struct rx_pkt_attrib *pattrib = &precvframe->u.hdr.attrib;616263if (pdata == NULL) {64precvframe->u.hdr.pkt = NULL;65res = _FAIL;66return res;67}686970/* Modified by Albert 20101213 */71/* For 8 bytes IP header alignment. */72shift_sz = pattrib->qos ? 6 : 0; /* Qos data, wireless lan header length is 26 */7374skb_len = pattrib->pkt_len;7576/* for first fragment packet, driver need allocate 1536+drvinfo_sz+RXDESC_SIZE to defrag packet. */77/* modify alloc_sz for recvive crc error packet by thomas 2011-06-02 */78if ((pattrib->mfrag == 1) && (pattrib->frag_num == 0)) {79/* alloc_sz = 1664; */ /* 1664 is 128 alignment. */80alloc_sz = (skb_len <= 1650) ? 1664 : (skb_len + 14);81} else {82alloc_sz = skb_len;83/* 6 is for IP header 8 bytes alignment in QoS packet case. */84/* 8 is for skb->data 4 bytes alignment. */85alloc_sz += 14;86}8788pkt_copy = rtw_skb_alloc(alloc_sz);8990if (pkt_copy) {91pkt_copy->dev = padapter->pnetdev;92pkt_copy->len = skb_len;93precvframe->u.hdr.pkt = pkt_copy;94precvframe->u.hdr.rx_head = pkt_copy->head;95precvframe->u.hdr.rx_end = pkt_copy->data + alloc_sz;96skb_reserve(pkt_copy, 8 - ((SIZE_PTR)(pkt_copy->data) & 7)); /* force pkt_copy->data at 8-byte alignment address */97skb_reserve(pkt_copy, shift_sz);/* force ip_hdr at 8-byte alignment address according to shift_sz. */98_rtw_memcpy(pkt_copy->data, pdata, skb_len);99precvframe->u.hdr.rx_data = precvframe->u.hdr.rx_tail = pkt_copy->data;100} else {101#if 0102{103rtw_free_recvframe(precvframe_if2, &precvpriv->free_recv_queue);104rtw_enqueue_recvbuf_to_head(precvbuf, &precvpriv->recv_buf_pending_queue);105106/* The case of can't allocate skb is serious and may never be recovered,107once bDriverStopped is enable, this task should be stopped.*/108if (!rtw_is_drv_stopped(secondary_padapter))109#ifdef PLATFORM_LINUX110tasklet_schedule(&precvpriv->recv_tasklet);111#endif112return ret;113}114115#endif116117#ifdef CONFIG_USE_USB_BUFFER_ALLOC_RX118RTW_INFO("%s:can not allocate memory for skb copy\n", __func__);119120precvframe->u.hdr.pkt = NULL;121122/* rtw_free_recvframe(precvframe, pfree_recv_queue); */123/*exit_rtw_os_recv_resource_alloc;*/124125res = _FAIL;126#else127if ((pattrib->mfrag == 1) && (pattrib->frag_num == 0)) {128RTW_INFO("%s: alloc_skb fail , drop frag frame\n", __FUNCTION__);129/* rtw_free_recvframe(precvframe, pfree_recv_queue); */130res = _FAIL;131goto exit_rtw_os_recv_resource_alloc;132}133134if (pskb == NULL) {135res = _FAIL;136goto exit_rtw_os_recv_resource_alloc;137}138139precvframe->u.hdr.pkt = rtw_skb_clone(pskb);140if (precvframe->u.hdr.pkt) {141precvframe->u.hdr.pkt->dev = padapter->pnetdev;142precvframe->u.hdr.rx_head = precvframe->u.hdr.rx_data = precvframe->u.hdr.rx_tail = pdata;143precvframe->u.hdr.rx_end = pdata + alloc_sz;144} else {145RTW_INFO("%s: rtw_skb_clone fail\n", __FUNCTION__);146/* rtw_free_recvframe(precvframe, pfree_recv_queue); */147/*exit_rtw_os_recv_resource_alloc;*/148res = _FAIL;149}150#endif151}152153exit_rtw_os_recv_resource_alloc:154155return res;156157}158159void rtw_os_free_recvframe(union recv_frame *precvframe)160{161if (precvframe->u.hdr.pkt) {162rtw_os_pkt_free(precvframe->u.hdr.pkt);163precvframe->u.hdr.pkt = NULL;164}165}166167/* init os related resource in struct recv_priv */168int rtw_os_recv_resource_init(struct recv_priv *precvpriv, _adapter *padapter)169{170int res = _SUCCESS;171172173#ifdef CONFIG_RTW_NAPI174skb_queue_head_init(&precvpriv->rx_napi_skb_queue);175#endif /* CONFIG_RTW_NAPI */176177return res;178}179180/* alloc os related resource in union recv_frame */181int rtw_os_recv_resource_alloc(_adapter *padapter, union recv_frame *precvframe)182{183int res = _SUCCESS;184185precvframe->u.hdr.pkt = NULL;186187return res;188}189190/* free os related resource in union recv_frame */191void rtw_os_recv_resource_free(struct recv_priv *precvpriv)192{193sint i;194union recv_frame *precvframe;195precvframe = (union recv_frame *) precvpriv->precv_frame_buf;196197198#ifdef CONFIG_RTW_NAPI199if (skb_queue_len(&precvpriv->rx_napi_skb_queue))200RTW_WARN("rx_napi_skb_queue not empty\n");201rtw_skb_queue_purge(&precvpriv->rx_napi_skb_queue);202#endif /* CONFIG_RTW_NAPI */203204for (i = 0; i < NR_RECVFRAME; i++) {205rtw_os_free_recvframe(precvframe);206precvframe++;207}208}209210/* alloc os related resource in struct recv_buf */211int rtw_os_recvbuf_resource_alloc(_adapter *padapter, struct recv_buf *precvbuf)212{213int res = _SUCCESS;214215#ifdef CONFIG_USB_HCI216#ifdef CONFIG_USE_USB_BUFFER_ALLOC_RX217struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter);218struct usb_device *pusbd = pdvobjpriv->pusbdev;219#endif220221precvbuf->irp_pending = _FALSE;222precvbuf->purb = usb_alloc_urb(0, GFP_KERNEL);223if (precvbuf->purb == NULL)224res = _FAIL;225226precvbuf->pskb = NULL;227228precvbuf->pallocated_buf = precvbuf->pbuf = NULL;229230precvbuf->pdata = precvbuf->phead = precvbuf->ptail = precvbuf->pend = NULL;231232precvbuf->transfer_len = 0;233234precvbuf->len = 0;235236#ifdef CONFIG_USE_USB_BUFFER_ALLOC_RX237precvbuf->pallocated_buf = rtw_usb_buffer_alloc(pusbd, (size_t)precvbuf->alloc_sz, &precvbuf->dma_transfer_addr);238precvbuf->pbuf = precvbuf->pallocated_buf;239if (precvbuf->pallocated_buf == NULL)240return _FAIL;241#endif /* CONFIG_USE_USB_BUFFER_ALLOC_RX */242243#endif /* CONFIG_USB_HCI */244245return res;246}247248/* free os related resource in struct recv_buf */249int rtw_os_recvbuf_resource_free(_adapter *padapter, struct recv_buf *precvbuf)250{251int ret = _SUCCESS;252253#ifdef CONFIG_USB_HCI254255#ifdef CONFIG_USE_USB_BUFFER_ALLOC_RX256257struct dvobj_priv *pdvobjpriv = adapter_to_dvobj(padapter);258struct usb_device *pusbd = pdvobjpriv->pusbdev;259260rtw_usb_buffer_free(pusbd, (size_t)precvbuf->alloc_sz, precvbuf->pallocated_buf, precvbuf->dma_transfer_addr);261precvbuf->pallocated_buf = NULL;262precvbuf->dma_transfer_addr = 0;263264#endif /* CONFIG_USE_USB_BUFFER_ALLOC_RX */265266if (precvbuf->purb) {267/* usb_kill_urb(precvbuf->purb); */268usb_free_urb(precvbuf->purb);269}270271#endif /* CONFIG_USB_HCI */272273274if (precvbuf->pskb) {275#ifdef CONFIG_PREALLOC_RX_SKB_BUFFER276if (rtw_free_skb_premem(precvbuf->pskb) != 0)277#endif278rtw_skb_free(precvbuf->pskb);279}280return ret;281282}283284_pkt *rtw_os_alloc_msdu_pkt(union recv_frame *prframe, const u8 *da, const u8 *sa, u8 *msdu ,u16 msdu_len)285{286u16 eth_type;287u8 *data_ptr;288_pkt *sub_skb;289struct rx_pkt_attrib *pattrib;290291pattrib = &prframe->u.hdr.attrib;292293#ifdef CONFIG_SKB_COPY294sub_skb = rtw_skb_alloc(msdu_len + 14);295if (sub_skb) {296skb_reserve(sub_skb, 14);297data_ptr = (u8 *)skb_put(sub_skb, msdu_len);298_rtw_memcpy(data_ptr, msdu, msdu_len);299} else300#endif /* CONFIG_SKB_COPY */301{302sub_skb = rtw_skb_clone(prframe->u.hdr.pkt);303if (sub_skb) {304sub_skb->data = msdu;305sub_skb->len = msdu_len;306skb_set_tail_pointer(sub_skb, msdu_len);307} else {308RTW_INFO("%s(): rtw_skb_clone() Fail!!!\n", __FUNCTION__);309return NULL;310}311}312313eth_type = RTW_GET_BE16(&sub_skb->data[6]);314315if (sub_skb->len >= 8316&& ((_rtw_memcmp(sub_skb->data, rtw_rfc1042_header, SNAP_SIZE)317&& eth_type != ETH_P_AARP && eth_type != ETH_P_IPX)318|| _rtw_memcmp(sub_skb->data, rtw_bridge_tunnel_header, SNAP_SIZE))319) {320/* remove RFC1042 or Bridge-Tunnel encapsulation and replace EtherType */321skb_pull(sub_skb, SNAP_SIZE);322_rtw_memcpy(skb_push(sub_skb, ETH_ALEN), sa, ETH_ALEN);323_rtw_memcpy(skb_push(sub_skb, ETH_ALEN), da, ETH_ALEN);324} else {325/* Leave Ethernet header part of hdr and full payload */326u16 len;327328len = htons(sub_skb->len);329_rtw_memcpy(skb_push(sub_skb, 2), &len, 2);330_rtw_memcpy(skb_push(sub_skb, ETH_ALEN), sa, ETH_ALEN);331_rtw_memcpy(skb_push(sub_skb, ETH_ALEN), da, ETH_ALEN);332}333334return sub_skb;335}336337#ifdef CONFIG_RTW_NAPI338static int napi_recv(_adapter *padapter, int budget)339{340_pkt *pskb;341struct recv_priv *precvpriv = &padapter->recvpriv;342int work_done = 0;343struct registry_priv *pregistrypriv = &padapter->registrypriv;344u8 rx_ok;345346347while ((work_done < budget) &&348(!skb_queue_empty(&precvpriv->rx_napi_skb_queue))) {349pskb = skb_dequeue(&precvpriv->rx_napi_skb_queue);350if (!pskb)351break;352353rx_ok = _FALSE;354355#ifdef CONFIG_RTW_GRO356if (pregistrypriv->en_gro) {357#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 12, 0))358if (rtw_napi_gro_receive(&padapter->napi, pskb) != GRO_DROP)359rx_ok = _TRUE;360#else361rtw_napi_gro_receive(&padapter->napi, pskb);362rx_ok = _TRUE;363#endif364goto next;365}366#endif /* CONFIG_RTW_GRO */367368if (rtw_netif_receive_skb(padapter->pnetdev, pskb) == NET_RX_SUCCESS)369rx_ok = _TRUE;370371next:372if (rx_ok == _TRUE) {373work_done++;374DBG_COUNTER(padapter->rx_logs.os_netif_ok);375} else {376DBG_COUNTER(padapter->rx_logs.os_netif_err);377}378}379380return work_done;381}382383int rtw_recv_napi_poll(struct napi_struct *napi, int budget)384{385_adapter *padapter = container_of(napi, _adapter, napi);386int work_done = 0;387struct recv_priv *precvpriv = &padapter->recvpriv;388389390work_done = napi_recv(padapter, budget);391if (work_done < budget) {392#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)) && defined(CONFIG_PCI_HCI)393napi_complete_done(napi, work_done);394#else395napi_complete(napi);396#endif397if (!skb_queue_empty(&precvpriv->rx_napi_skb_queue))398napi_schedule(napi);399}400401return work_done;402}403404#ifdef CONFIG_RTW_NAPI_DYNAMIC405void dynamic_napi_th_chk (_adapter *adapter)406{407408if (adapter->registrypriv.en_napi) {409struct dvobj_priv *dvobj;410struct registry_priv *registry;411412dvobj = adapter_to_dvobj(adapter);413registry = &adapter->registrypriv;414if (dvobj->traffic_stat.cur_rx_tp > registry->napi_threshold)415dvobj->en_napi_dynamic = 1;416else417dvobj->en_napi_dynamic = 0;418}419420}421#endif /* CONFIG_RTW_NAPI_DYNAMIC */422#endif /* CONFIG_RTW_NAPI */423424void rtw_os_recv_indicate_pkt(_adapter *padapter, _pkt *pkt, union recv_frame *rframe)425{426struct mlme_priv *pmlmepriv = &padapter->mlmepriv;427struct recv_priv *precvpriv = &(padapter->recvpriv);428struct registry_priv *pregistrypriv = &padapter->registrypriv;429#ifdef CONFIG_BR_EXT430void *br_port = NULL;431#endif432int ret;433434/* Indicat the packets to upper layer */435if (pkt) {436struct ethhdr *ehdr = (struct ethhdr *)pkt->data;437438DBG_COUNTER(padapter->rx_logs.os_indicate);439440if (MLME_IS_AP(padapter)) {441_pkt *pskb2 = NULL;442struct sta_info *psta = NULL;443struct sta_priv *pstapriv = &padapter->stapriv;444int bmcast = IS_MCAST(ehdr->h_dest);445446/* RTW_INFO("bmcast=%d\n", bmcast); */447448if (_rtw_memcmp(ehdr->h_dest, adapter_mac_addr(padapter), ETH_ALEN) == _FALSE) {449/* RTW_INFO("not ap psta=%p, addr=%pM\n", psta, ehdr->h_dest); */450451if (bmcast) {452psta = rtw_get_bcmc_stainfo(padapter);453pskb2 = rtw_skb_clone(pkt);454} else455psta = rtw_get_stainfo(pstapriv, ehdr->h_dest);456457if (psta) {458struct net_device *pnetdev = (struct net_device *)padapter->pnetdev;459460/* RTW_INFO("directly forwarding to the rtw_xmit_entry\n"); */461462/* skb->ip_summed = CHECKSUM_NONE; */463pkt->dev = pnetdev;464#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35))465skb_set_queue_mapping(pkt, rtw_recv_select_queue(pkt));466#endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35) */467468_rtw_xmit_entry(pkt, pnetdev);469470if (bmcast && (pskb2 != NULL)) {471pkt = pskb2;472DBG_COUNTER(padapter->rx_logs.os_indicate_ap_mcast);473} else {474DBG_COUNTER(padapter->rx_logs.os_indicate_ap_forward);475return;476}477}478} else { /* to APself */479/* RTW_INFO("to APSelf\n"); */480DBG_COUNTER(padapter->rx_logs.os_indicate_ap_self);481}482}483484#ifdef CONFIG_BR_EXT485if (check_fwstate(pmlmepriv, WIFI_STATION_STATE | WIFI_ADHOC_STATE) == _TRUE) {486/* Insert NAT2.5 RX here! */487#if (LINUX_VERSION_CODE <= KERNEL_VERSION(2, 6, 35))488br_port = padapter->pnetdev->br_port;489#else490rcu_read_lock();491br_port = rcu_dereference(padapter->pnetdev->rx_handler_data);492rcu_read_unlock();493#endif494495if (br_port) {496int nat25_handle_frame(_adapter *priv, struct sk_buff *skb);497498if (nat25_handle_frame(padapter, pkt) == -1) {499/* priv->ext_stats.rx_data_drops++; */500/* DEBUG_ERR("RX DROP: nat25_handle_frame fail!\n"); */501/* return FAIL; */502503#if 1504/* bypass this frame to upper layer!! */505#else506rtw_skb_free(sub_skb);507continue;508#endif509}510}511}512#endif /* CONFIG_BR_EXT */513514/* After eth_type_trans process , pkt->data pointer will move from ethrnet header to ip header */515pkt->protocol = eth_type_trans(pkt, padapter->pnetdev);516pkt->dev = padapter->pnetdev;517pkt->ip_summed = CHECKSUM_NONE; /* CONFIG_TCP_CSUM_OFFLOAD_RX */518#ifdef CONFIG_TCP_CSUM_OFFLOAD_RX519if ((rframe->u.hdr.attrib.csum_valid == 1)520&& (rframe->u.hdr.attrib.csum_err == 0))521pkt->ip_summed = CHECKSUM_UNNECESSARY;522#endif /* CONFIG_TCP_CSUM_OFFLOAD_RX */523524#ifdef CONFIG_RTW_NAPI525#ifdef CONFIG_RTW_NAPI_DYNAMIC526if (!skb_queue_empty(&precvpriv->rx_napi_skb_queue)527&& !adapter_to_dvobj(padapter)->en_napi_dynamic528)529napi_recv(padapter, RTL_NAPI_WEIGHT);530#endif531532if (pregistrypriv->en_napi533#ifdef CONFIG_RTW_NAPI_DYNAMIC534&& adapter_to_dvobj(padapter)->en_napi_dynamic535#endif536) {537skb_queue_tail(&precvpriv->rx_napi_skb_queue, pkt);538#ifndef CONFIG_RTW_NAPI_V2539napi_schedule(&padapter->napi);540#endif541return;542}543#endif /* CONFIG_RTW_NAPI */544545ret = rtw_netif_rx(padapter->pnetdev, pkt);546if (ret == NET_RX_SUCCESS)547DBG_COUNTER(padapter->rx_logs.os_netif_ok);548else549DBG_COUNTER(padapter->rx_logs.os_netif_err);550}551}552553void rtw_handle_tkip_mic_err(_adapter *padapter, struct sta_info *sta, u8 bgroup)554{555#ifdef CONFIG_IOCTL_CFG80211556enum nl80211_key_type key_type = 0;557#endif558union iwreq_data wrqu;559struct iw_michaelmicfailure ev;560struct security_priv *psecuritypriv = &padapter->securitypriv;561systime cur_time = 0;562563if (psecuritypriv->last_mic_err_time == 0)564psecuritypriv->last_mic_err_time = rtw_get_current_time();565else {566cur_time = rtw_get_current_time();567568if (cur_time - psecuritypriv->last_mic_err_time < 60 * HZ) {569psecuritypriv->btkip_countermeasure = _TRUE;570psecuritypriv->last_mic_err_time = 0;571psecuritypriv->btkip_countermeasure_time = cur_time;572} else573psecuritypriv->last_mic_err_time = rtw_get_current_time();574}575576#ifdef CONFIG_IOCTL_CFG80211577if (bgroup)578key_type |= NL80211_KEYTYPE_GROUP;579else580key_type |= NL80211_KEYTYPE_PAIRWISE;581582cfg80211_michael_mic_failure(padapter->pnetdev, sta->cmn.mac_addr, key_type, -1, NULL, GFP_ATOMIC);583#endif584585_rtw_memset(&ev, 0x00, sizeof(ev));586if (bgroup)587ev.flags |= IW_MICFAILURE_GROUP;588else589ev.flags |= IW_MICFAILURE_PAIRWISE;590591ev.src_addr.sa_family = ARPHRD_ETHER;592_rtw_memcpy(ev.src_addr.sa_data, sta->cmn.mac_addr, ETH_ALEN);593594_rtw_memset(&wrqu, 0x00, sizeof(wrqu));595wrqu.data.length = sizeof(ev);596597#ifndef CONFIG_IOCTL_CFG80211598wireless_send_event(padapter->pnetdev, IWEVMICHAELMICFAILURE, &wrqu, (char *) &ev);599#endif600}601602#ifdef CONFIG_HOSTAPD_MLME603void rtw_hostapd_mlme_rx(_adapter *padapter, union recv_frame *precv_frame)604{605_pkt *skb;606struct hostapd_priv *phostapdpriv = padapter->phostapdpriv;607struct net_device *pmgnt_netdev = phostapdpriv->pmgnt_netdev;608609610skb = precv_frame->u.hdr.pkt;611612if (skb == NULL)613return;614615skb->data = precv_frame->u.hdr.rx_data;616skb->tail = precv_frame->u.hdr.rx_tail;617skb->len = precv_frame->u.hdr.len;618619/* pskb_copy = rtw_skb_copy(skb);620* if(skb == NULL) goto _exit; */621622skb->dev = pmgnt_netdev;623skb->ip_summed = CHECKSUM_NONE;624skb->pkt_type = PACKET_OTHERHOST;625/* skb->protocol = __constant_htons(0x0019); ETH_P_80211_RAW */626skb->protocol = __constant_htons(0x0003); /*ETH_P_80211_RAW*/627628/* RTW_INFO("(1)data=0x%x, head=0x%x, tail=0x%x, mac_header=0x%x, len=%d\n", skb->data, skb->head, skb->tail, skb->mac_header, skb->len); */629630/* skb->mac.raw = skb->data; */631skb_reset_mac_header(skb);632633/* skb_pull(skb, 24); */634_rtw_memset(skb->cb, 0, sizeof(skb->cb));635636rtw_netif_rx(pmgnt_netdev, skb);637638precv_frame->u.hdr.pkt = NULL; /* set pointer to NULL before rtw_free_recvframe() if call rtw_netif_rx() */639}640#endif /* CONFIG_HOSTAPD_MLME */641642int rtw_recv_monitor(_adapter *padapter, union recv_frame *precv_frame)643{644int ret = _FAIL;645struct recv_priv *precvpriv;646_queue *pfree_recv_queue;647_pkt *skb;648struct rx_pkt_attrib *pattrib;649650if (NULL == precv_frame)651goto _recv_drop;652653pattrib = &precv_frame->u.hdr.attrib;654precvpriv = &(padapter->recvpriv);655pfree_recv_queue = &(precvpriv->free_recv_queue);656657skb = precv_frame->u.hdr.pkt;658if (skb == NULL) {659RTW_INFO("%s :skb==NULL something wrong!!!!\n", __func__);660goto _recv_drop;661}662663skb->data = precv_frame->u.hdr.rx_data;664skb_set_tail_pointer(skb, precv_frame->u.hdr.len);665skb->len = precv_frame->u.hdr.len;666skb->ip_summed = CHECKSUM_NONE;667skb->pkt_type = PACKET_OTHERHOST;668skb->protocol = htons(0x0019); /* ETH_P_80211_RAW */669670rtw_netif_rx(padapter->pnetdev, skb);671672/* pointers to NULL before rtw_free_recvframe() */673precv_frame->u.hdr.pkt = NULL;674675ret = _SUCCESS;676677_recv_drop:678679/* enqueue back to free_recv_queue */680if (precv_frame)681rtw_free_recvframe(precv_frame, pfree_recv_queue);682683return ret;684685}686687inline void rtw_rframe_set_os_pkt(union recv_frame *rframe)688{689_pkt *skb = rframe->u.hdr.pkt;690691skb->data = rframe->u.hdr.rx_data;692skb_set_tail_pointer(skb, rframe->u.hdr.len);693skb->len = rframe->u.hdr.len;694}695696int rtw_recv_indicatepkt(_adapter *padapter, union recv_frame *precv_frame)697{698struct recv_priv *precvpriv;699_queue *pfree_recv_queue;700701precvpriv = &(padapter->recvpriv);702pfree_recv_queue = &(precvpriv->free_recv_queue);703704if (precv_frame->u.hdr.pkt == NULL)705goto _recv_indicatepkt_drop;706707rtw_os_recv_indicate_pkt(padapter, precv_frame->u.hdr.pkt, precv_frame);708709precv_frame->u.hdr.pkt = NULL;710rtw_free_recvframe(precv_frame, pfree_recv_queue);711return _SUCCESS;712713_recv_indicatepkt_drop:714rtw_free_recvframe(precv_frame, pfree_recv_queue);715DBG_COUNTER(padapter->rx_logs.os_indicate_err);716return _FAIL;717}718719void rtw_os_read_port(_adapter *padapter, struct recv_buf *precvbuf)720{721#ifdef CONFIG_USB_HCI722struct recv_priv *precvpriv = &padapter->recvpriv;723724precvbuf->ref_cnt--;725726/* free skb in recv_buf */727rtw_skb_free(precvbuf->pskb);728729precvbuf->pskb = NULL;730731if (precvbuf->irp_pending == _FALSE)732rtw_read_port(padapter, precvpriv->ff_hwaddr, 0, (unsigned char *)precvbuf);733734735#endif736#if defined(CONFIG_SDIO_HCI) || defined(CONFIG_GSPI_HCI)737precvbuf->pskb = NULL;738#endif739740}741742743744