1
0
mirror of https://github.com/aircrack-ng/rtl8812au.git synced 2024-11-25 14:44:09 +00:00

Ability to place rx descriptor into radiotap header

This commit is contained in:
Sergei Makarenkov 2017-03-12 12:41:59 +03:00
parent 568bd9eb3a
commit 7d44a9021d
5 changed files with 65 additions and 29 deletions

View File

@ -157,7 +157,7 @@ CONFIG_RTL8814A = y
endif endif
ifeq ($(DEBUG), 1) 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 else
EXTRA_CFLAGS += -DDBG=0 EXTRA_CFLAGS += -DDBG=0
endif endif

View File

@ -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)) #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; u16 tmp_16bit = 0;
u8 data_rate[] = { static u8 data_rate[] = {
2, 4, 11, 22, /* CCK */ 2, 4, 11, 22, /* CCK */
12, 18, 24, 36, 48, 72, 93, 108, /* OFDM */ 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 */ 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; struct ieee80211_radiotap_header *rtap_hdr = NULL;
u8 *ptr = NULL; u8 *ptr = NULL;
#ifdef CONFIG_RADIOTAP_WITH_RXDESC
u8 hdr_buf[128] = {0};
#else
u8 hdr_buf[64] = {0}; u8 hdr_buf[64] = {0};
#endif
u16 rt_len = 8; u16 rt_len = 8;
u32 tmp_32bit; u32 tmp_32bit;
int i; int i;
@ -4024,8 +4028,16 @@ static sint fill_radiotap_hdr(_adapter *padapter, union recv_frame *precvframe,
} }
tmp_32bit = (1<<IEEE80211_RADIOTAP_ANTENNA) | tmp_32bit = (1<<IEEE80211_RADIOTAP_ANTENNA) |
(1<<IEEE80211_RADIOTAP_DBM_ANTSIGNAL); (1<<IEEE80211_RADIOTAP_DBM_ANTSIGNAL);
#ifdef CONFIG_RADIOTAP_WITH_RXDESC
tmp_32bit |= (1 << IEEE80211_RADIOTAP_VENDOR_NAMESPACE);
#endif
memcpy(&hdr_buf[rt_len], &tmp_32bit, 4); memcpy(&hdr_buf[rt_len], &tmp_32bit, 4);
rt_len += 4; rt_len += 4;
} else {
#ifdef CONFIG_RADIOTAP_WITH_RXDESC
rtap_hdr->it_present |= (1 << IEEE80211_RADIOTAP_VENDOR_NAMESPACE);
#endif
} }
/* tsft */ /* tsft */
if (pattrib->tsfl) { if (pattrib->tsfl) {
@ -4251,21 +4263,52 @@ static sint fill_radiotap_hdr(_adapter *padapter, union recv_frame *precvframe,
rt_len ++; 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 */ /* 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) { if (skb_headroom(pskb) < rt_len) {
DBG_871X("%s:%d %s headroom is too small.\n", __FILE__, __LINE__, __func__); pskb = skb_realloc_headroom(pskb, rt_len);
ret = _FAIL; if(pskb == NULL) {
return ret; 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); ptr = skb_push(pskb, rt_len);
if (ptr) { if (ptr) {
rtap_hdr->it_len = cpu_to_le16(rt_len); rtap_hdr->it_len = cpu_to_le16(rt_len);
memcpy(ptr, rtap_hdr, rt_len); _rtw_memcpy(ptr, rtap_hdr, rt_len);
} else { } else {
ret = _FAIL; 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; 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; _queue *pfree_recv_queue = &padapter->recvpriv.free_recv_queue;
_pkt *pskb = NULL; _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 */ /* fill radiotap header */
if (fill_radiotap_hdr(padapter, rframe, (u8 *)pskb) == _FAIL) { if (fill_radiotap_hdr(padapter, rframe) == _FAIL) {
ret = _FAIL; ret = _FAIL;
rtw_free_recvframe(rframe, pfree_recv_queue); /* free this recv_frame */ rtw_free_recvframe(rframe, pfree_recv_queue); /* free this recv_frame */
goto exit; 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)) { if (!RTW_CANNOT_RUN(padapter)) {
/* indicate this recv_frame */ /* indicate this recv_frame */
ret = rtw_recv_monitor(padapter, rframe); ret = rtw_recv_monitor(padapter, rframe);

View File

@ -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)); _rtw_memset(pattrib, 0, sizeof(struct rx_pkt_attrib));
#ifdef CONFIG_RADIOTAP_WITH_RXDESC
_rtw_memcpy(pattrib->rxdesc, pdesc, RXDESC_SIZE);
#endif
//Offset 0 //Offset 0
pattrib->pkt_len = (u16)GET_RX_STATUS_DESC_PKT_LEN_8814A(pdesc);//(le32_to_cpu(pdesc->rxdw0)&0x00003fff) 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); 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)) if (GET_RX_STATUS_DESC_RPT_SEL_8814A(pdesc))
pattrib->pkt_rpt_type = C2H_PACKET; pattrib->pkt_rpt_type = C2H_PACKET;
else else
pattrib->pkt_rpt_type = NORMAL_RX;
pattrib->pkt_rpt_type = NORMAL_RX;
//Offset 12 //Offset 12
pattrib->data_rate=(u8)GET_RX_STATUS_DESC_RX_RATE_8814A(pdesc);//((le32_to_cpu(pdesc->rxdw3))&0x7f); pattrib->data_rate=(u8)GET_RX_STATUS_DESC_RX_RATE_8814A(pdesc);//((le32_to_cpu(pdesc->rxdw3))&0x7f);

View File

@ -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_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) #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_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_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) #define GET_RX_STATUS_DESC_STBC_8812(__pRxDesc) LE_BITS_TO_4BYTE( __pRxDesc+16, 2, 1)

View File

@ -177,6 +177,10 @@ typedef struct _ODM_Phy_Status_Info_
}ODM_PHY_INFO_T,*PODM_PHY_INFO_T; }ODM_PHY_INFO_T,*PODM_PHY_INFO_T;
*/ */
#define RXDESC_SIZE 24
#define RXDESC_OFFSET RXDESC_SIZE
struct phy_info struct phy_info
{ {
u8 RxPWDBAll; u8 RxPWDBAll;
@ -268,7 +272,9 @@ struct rx_pkt_attrib {
u8 pkt_rpt_type; u8 pkt_rpt_type;
u32 tsfl; u32 tsfl;
u32 MacIDValidEntry[2]; // 64 bits present 64 entry. u32 MacIDValidEntry[2]; // 64 bits present 64 entry.
#ifdef CONFIG_RADIOTAP_WITH_RXDESC
u8 rxdesc[RXDESC_SIZE];
#endif
/* /*
u8 signal_qual; u8 signal_qual;
s8 rx_mimo_signal_qual[2]; s8 rx_mimo_signal_qual[2];
@ -293,9 +299,6 @@ struct rx_pkt_attrib {
#define RXBD_SIZE sizeof(struct recv_stat) #define RXBD_SIZE sizeof(struct recv_stat)
#endif #endif
#define RXDESC_SIZE 24
#define RXDESC_OFFSET RXDESC_SIZE
struct recv_stat struct recv_stat
{ {
unsigned int rxdw0; unsigned int rxdw0;