Ability to place rx descriptor into radiotap header

This commit is contained in:
kimocoder 2018-08-04 21:17:04 +02:00
parent f1dce475a4
commit 9b811a5614
3 changed files with 62 additions and 27 deletions

View File

@ -3593,7 +3593,7 @@ exit:
}
#endif
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))
@ -3651,7 +3651,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 */
@ -3667,7 +3667,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;
@ -3691,8 +3695,15 @@ static sint fill_radiotap_hdr(_adapter *padapter, union recv_frame *precvframe,
}
tmp_32bit = (1<<IEEE80211_RADIOTAP_ANTENNA) |
(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);
rt_len += 4;
} else {
#ifdef CONFIG_RADIOTAP_WITH_RXDESC
rtap_hdr->it_present |= (1 << IEEE80211_RADIOTAP_VENDOR_NAMESPACE);
#endif
}
/* tsft */
@ -3919,23 +3930,53 @@ static sint fill_radiotap_hdr(_adapter *padapter, union recv_frame *precvframe,
}
}
#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) {
RTW_INFO("%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) {
RTW_INFO("%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);
} else
_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;
}
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24))
int recv_frame_monitor(_adapter *padapter, union recv_frame *rframe)
@ -3946,27 +3987,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);

View File

@ -23,6 +23,10 @@ void rtl8812_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_8812(pdesc);/* (le32_to_cpu(pdesc->rxdw0)&0x00003fff) */
pattrib->crc_err = (u8)GET_RX_STATUS_DESC_CRC32_8812(pdesc);/* ((le32_to_cpu(pdesc->rxdw0) >> 14) & 0x1); */

View File

@ -160,6 +160,8 @@ struct rx_raw_rssi {
u8 ofdm_snr[4];
};
#define RXDESC_SIZE 24
#define RXDESC_OFFSET RXDESC_SIZE
#include "cmn_info/rtw_sta_info.h"
@ -208,11 +210,15 @@ 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 ppdu_cnt;
struct phydm_phyinfo_struct phy_info;
};
/* These definition is used for Rx packet reordering. */
#define SN_LESS(a, b) (((a-b) & 0x800) != 0)
#define SN_EQUAL(a, b) (a == b)
@ -228,9 +234,6 @@ struct rx_pkt_attrib {
#define RXBD_SIZE sizeof(struct recv_stat)
#endif
#define RXDESC_SIZE 24
#define RXDESC_OFFSET RXDESC_SIZE
#ifdef CONFIG_TRX_BD_ARCH
struct rx_buf_desc {
/* RX has exactly one segment */