From 7d44a9021d15d7a2b3679af2834725583534ca66 Mon Sep 17 00:00:00 2001 From: Sergei Makarenkov Date: Sun, 12 Mar 2017 12:41:59 +0300 Subject: [PATCH] Ability to place rx descriptor into radiotap header --- Makefile | 2 +- core/rtw_recv.c | 72 ++++++++++++++++++++++++---------- hal/rtl8814a/rtl8814a_rxdesc.c | 7 +++- include/rtl8812a_recv.h | 2 +- include/rtw_recv.h | 11 ++++-- 5 files changed, 65 insertions(+), 29 deletions(-) diff --git a/Makefile b/Makefile index 2f5a55f..e2b9832 100755 --- a/Makefile +++ b/Makefile @@ -157,7 +157,7 @@ CONFIG_RTL8814A = y endif ifeq ($(DEBUG), 1) -EXTRA_CFLAGS += -DDBG=1 -DCONFIG_DEBUG -DCONFIG_DBG_COUNTER +EXTRA_CFLAGS += -DDBG=1 -DCONFIG_DEBUG -DCONFIG_DBG_COUNTER -DCONFIG_RADIOTAP_WITH_RXDESC else EXTRA_CFLAGS += -DDBG=0 endif diff --git a/core/rtw_recv.c b/core/rtw_recv.c index dad0a28..6c12b04 100644 --- a/core/rtw_recv.c +++ b/core/rtw_recv.c @@ -3929,7 +3929,7 @@ exit: } -static sint fill_radiotap_hdr(_adapter *padapter, union recv_frame *precvframe, u8 *buf) +static sint fill_radiotap_hdr(_adapter *padapter, union recv_frame *precvframe) { #define CHAN2FREQ(a) ((a < 14)?(2407+5*a):(5000+5*a)) @@ -3982,7 +3982,7 @@ static sint fill_radiotap_hdr(_adapter *padapter, union recv_frame *precvframe, u16 tmp_16bit = 0; - u8 data_rate[] = { + static u8 data_rate[] = { 2, 4, 11, 22, /* CCK */ 12, 18, 24, 36, 48, 72, 93, 108, /* OFDM */ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, /* HT MCS index */ @@ -3998,7 +3998,11 @@ static sint fill_radiotap_hdr(_adapter *padapter, union recv_frame *precvframe, struct ieee80211_radiotap_header *rtap_hdr = NULL; u8 *ptr = NULL; +#ifdef CONFIG_RADIOTAP_WITH_RXDESC + u8 hdr_buf[128] = {0}; +#else u8 hdr_buf[64] = {0}; +#endif u16 rt_len = 8; u32 tmp_32bit; int i; @@ -4024,8 +4028,16 @@ static sint fill_radiotap_hdr(_adapter *padapter, union recv_frame *precvframe, } tmp_32bit = (1<it_present |= (1 << IEEE80211_RADIOTAP_VENDOR_NAMESPACE); +#endif } /* tsft */ if (pattrib->tsfl) { @@ -4251,21 +4263,52 @@ static sint fill_radiotap_hdr(_adapter *padapter, union recv_frame *precvframe, rt_len ++; } } + +#ifdef CONFIG_RADIOTAP_WITH_RXDESC + rt_len += rt_len&1; + hdr_buf[rt_len++] = 0xde; + hdr_buf[rt_len++] = 0xab; + hdr_buf[rt_len++] = 0xbe; + hdr_buf[rt_len++] = 0xaf; + hdr_buf[rt_len++] = 24; + hdr_buf[rt_len++] = 0; + _rtw_memcpy(hdr_buf + rt_len, pattrib->rxdesc, RXDESC_SIZE); + rt_len += RXDESC_SIZE; +#endif + /* push to skb */ - pskb = (_pkt *)buf; + /* read skb information from recv frame */ + pskb = precvframe->u.hdr.pkt; + pskb->len = precvframe->u.hdr.len; + pskb->data = precvframe->u.hdr.rx_data; + skb_set_tail_pointer(pskb, precvframe->u.hdr.len); + if (skb_headroom(pskb) < rt_len) { - DBG_871X("%s:%d %s headroom is too small.\n", __FILE__, __LINE__, __func__); - ret = _FAIL; - return ret; + pskb = skb_realloc_headroom(pskb, rt_len); + if(pskb == NULL) { + DBG_871X("%s:%d %s headroom is too small.\n", __FILE__, __LINE__, __func__); + ret = _FAIL; + return ret; + } + precvframe->u.hdr.pkt = pskb; } ptr = skb_push(pskb, rt_len); if (ptr) { rtap_hdr->it_len = cpu_to_le16(rt_len); - memcpy(ptr, rtap_hdr, rt_len); + _rtw_memcpy(ptr, rtap_hdr, rt_len); } else { ret = _FAIL; + return ret; } +out: + /* write skb information to recv frame */ + skb_reset_mac_header(pskb); + precvframe->u.hdr.len = pskb->len; + precvframe->u.hdr.rx_data = pskb->data; + precvframe->u.hdr.rx_head = pskb->head; + precvframe->u.hdr.rx_tail = skb_tail_pointer(pskb); + precvframe->u.hdr.rx_end = skb_end_pointer(pskb); return ret; @@ -4279,27 +4322,14 @@ int recv_frame_monitor(_adapter *padapter, union recv_frame *rframe) _queue *pfree_recv_queue = &padapter->recvpriv.free_recv_queue; _pkt *pskb = NULL; - /* read skb information from recv frame */ - pskb = rframe->u.hdr.pkt; - pskb->len = rframe->u.hdr.len; - pskb->data = rframe->u.hdr.rx_data; - skb_set_tail_pointer(pskb, rframe->u.hdr.len); /* fill radiotap header */ - if (fill_radiotap_hdr(padapter, rframe, (u8 *)pskb) == _FAIL) { + if (fill_radiotap_hdr(padapter, rframe) == _FAIL) { ret = _FAIL; rtw_free_recvframe(rframe, pfree_recv_queue); /* free this recv_frame */ goto exit; } - /* write skb information to recv frame */ - skb_reset_mac_header(pskb); - rframe->u.hdr.len = pskb->len; - rframe->u.hdr.rx_data = pskb->data; - rframe->u.hdr.rx_head = pskb->head; - rframe->u.hdr.rx_tail = skb_tail_pointer(pskb); - rframe->u.hdr.rx_end = skb_end_pointer(pskb); - if (!RTW_CANNOT_RUN(padapter)) { /* indicate this recv_frame */ ret = rtw_recv_monitor(padapter, rframe); diff --git a/hal/rtl8814a/rtl8814a_rxdesc.c b/hal/rtl8814a/rtl8814a_rxdesc.c index cd360b9..7de802c 100644 --- a/hal/rtl8814a/rtl8814a_rxdesc.c +++ b/hal/rtl8814a/rtl8814a_rxdesc.c @@ -28,6 +28,10 @@ void rtl8814_query_rx_desc_status(union recv_frame *precvframe, u8 *pdesc) _rtw_memset(pattrib, 0, sizeof(struct rx_pkt_attrib)); +#ifdef CONFIG_RADIOTAP_WITH_RXDESC + _rtw_memcpy(pattrib->rxdesc, pdesc, RXDESC_SIZE); +#endif + //Offset 0 pattrib->pkt_len = (u16)GET_RX_STATUS_DESC_PKT_LEN_8814A(pdesc);//(le32_to_cpu(pdesc->rxdw0)&0x00003fff) pattrib->crc_err = (u8)GET_RX_STATUS_DESC_CRC32_8814A(pdesc);//((le32_to_cpu(pdesc->rxdw0) >> 14) & 0x1); @@ -52,8 +56,7 @@ void rtl8814_query_rx_desc_status(union recv_frame *precvframe, u8 *pdesc) if (GET_RX_STATUS_DESC_RPT_SEL_8814A(pdesc)) pattrib->pkt_rpt_type = C2H_PACKET; else - - pattrib->pkt_rpt_type = NORMAL_RX; + pattrib->pkt_rpt_type = NORMAL_RX; //Offset 12 pattrib->data_rate=(u8)GET_RX_STATUS_DESC_RX_RATE_8814A(pdesc);//((le32_to_cpu(pdesc->rxdw3))&0x7f); diff --git a/include/rtl8812a_recv.h b/include/rtl8812a_recv.h index 7729d42..e8657f5 100644 --- a/include/rtl8812a_recv.h +++ b/include/rtl8812a_recv.h @@ -122,7 +122,7 @@ #define GET_RX_STATUS_DESC_UNICAST_MATCH_8812(__pRxDesc) LE_BITS_TO_4BYTE( __pRxDesc+12, 30, 1) #define GET_RX_STATUS_DESC_MAGIC_MATCH_8812(__pRxDesc) LE_BITS_TO_4BYTE( __pRxDesc+12, 31, 1) -//DWORD 6 +//DWORD 4 #define GET_RX_STATUS_DESC_SPLCP_8812(__pRxDesc) LE_BITS_TO_4BYTE( __pRxDesc+16, 0, 1) #define GET_RX_STATUS_DESC_LDPC_8812(__pRxDesc) LE_BITS_TO_4BYTE( __pRxDesc+16, 1, 1) #define GET_RX_STATUS_DESC_STBC_8812(__pRxDesc) LE_BITS_TO_4BYTE( __pRxDesc+16, 2, 1) diff --git a/include/rtw_recv.h b/include/rtw_recv.h index 92ad648..ff05af6 100644 --- a/include/rtw_recv.h +++ b/include/rtw_recv.h @@ -177,6 +177,10 @@ typedef struct _ODM_Phy_Status_Info_ }ODM_PHY_INFO_T,*PODM_PHY_INFO_T; */ + +#define RXDESC_SIZE 24 +#define RXDESC_OFFSET RXDESC_SIZE + struct phy_info { u8 RxPWDBAll; @@ -268,7 +272,9 @@ struct rx_pkt_attrib { u8 pkt_rpt_type; u32 tsfl; u32 MacIDValidEntry[2]; // 64 bits present 64 entry. - +#ifdef CONFIG_RADIOTAP_WITH_RXDESC + u8 rxdesc[RXDESC_SIZE]; +#endif /* u8 signal_qual; s8 rx_mimo_signal_qual[2]; @@ -293,9 +299,6 @@ struct rx_pkt_attrib { #define RXBD_SIZE sizeof(struct recv_stat) #endif -#define RXDESC_SIZE 24 -#define RXDESC_OFFSET RXDESC_SIZE - struct recv_stat { unsigned int rxdw0;