diff --git a/components/pkt_capture/core/inc/wlan_pkt_capture_main.h b/components/pkt_capture/core/inc/wlan_pkt_capture_main.h index fc11cdac6af9..3d3ee30f11e4 100644 --- a/components/pkt_capture/core/inc/wlan_pkt_capture_main.h +++ b/components/pkt_capture/core/inc/wlan_pkt_capture_main.h @@ -185,4 +185,15 @@ uint32_t pkt_capture_drop_nbuf_list(qdf_nbuf_t buf_list); * Return: None */ void pkt_capture_record_channel(struct wlan_objmgr_vdev *vdev); + +/** + * pkt_capture_mon() - Wrapper function to invoke mon cb + * @cb_ctx: packet capture callback context + * @msdu: packet + * + * Return: None + */ +void pkt_capture_mon(struct pkt_capture_cb_context *cb_ctx, + qdf_nbuf_t msdu); + #endif /* end of _WLAN_PKT_CAPTURE_MAIN_H_ */ diff --git a/components/pkt_capture/core/inc/wlan_pkt_capture_mon_thread.h b/components/pkt_capture/core/inc/wlan_pkt_capture_mon_thread.h index 77221daf8b07..006fa0a0854e 100644 --- a/components/pkt_capture/core/inc/wlan_pkt_capture_mon_thread.h +++ b/components/pkt_capture/core/inc/wlan_pkt_capture_mon_thread.h @@ -111,6 +111,20 @@ struct pkt_capture_mon_context { bool is_mon_thread_suspended; }; +/** + * struct radiotap_header - base radiotap header + * @it_version: radiotap version, always 0 + * @it_pad: padding (or alignment) + * @it_len: overall radiotap header length + * @it_present: (first) present word + */ +struct radiotap_header { + uint8_t it_version; + uint8_t it_pad; + __le16 it_len; + __le32 it_present; +} __packed; + /** * pkt_capture_suspend_mon_thread() - suspend packet capture mon thread * vdev: pointer to vdev object manager diff --git a/components/pkt_capture/core/src/wlan_pkt_capture_data_txrx.c b/components/pkt_capture/core/src/wlan_pkt_capture_data_txrx.c index a65ee5f6285a..59fdef0aa992 100644 --- a/components/pkt_capture/core/src/wlan_pkt_capture_data_txrx.c +++ b/components/pkt_capture/core/src/wlan_pkt_capture_data_txrx.c @@ -528,12 +528,7 @@ pkt_capture_rx_data_cb( */ headroom = qdf_nbuf_headroom(msdu); qdf_nbuf_update_radiotap(&rx_status, msdu, headroom); - - if (QDF_STATUS_SUCCESS != - cb_ctx->mon_cb(cb_ctx->mon_ctx, msdu)) { - pkt_capture_err("Frame Rx to HDD failed"); - qdf_nbuf_free(msdu); - } + pkt_capture_mon(cb_ctx, msdu); msdu = next_buf; } @@ -706,13 +701,7 @@ pkt_capture_tx_data_cb( */ headroom = qdf_nbuf_headroom(msdu); qdf_nbuf_update_radiotap(&tx_status, msdu, headroom); - - if (QDF_STATUS_SUCCESS != - cb_ctx->mon_cb(cb_ctx->mon_ctx, msdu)) { - pkt_capture_err("Frame Tx to HDD failed"); - qdf_nbuf_free(msdu); - } - + pkt_capture_mon(cb_ctx, msdu); msdu = next_buf; } return; diff --git a/components/pkt_capture/core/src/wlan_pkt_capture_mgmt_txrx.c b/components/pkt_capture/core/src/wlan_pkt_capture_mgmt_txrx.c index 9bbdeb4673fc..71295bacc5a7 100644 --- a/components/pkt_capture/core/src/wlan_pkt_capture_mgmt_txrx.c +++ b/components/pkt_capture/core/src/wlan_pkt_capture_mgmt_txrx.c @@ -100,11 +100,7 @@ pkt_capture_mgmtpkt_cb(void *context, void *ppdev, void *nbuf_list, while (msdu) { next_buf = qdf_nbuf_queue_next(msdu); qdf_nbuf_set_next(msdu, NULL); /* Add NULL terminator */ - if (QDF_STATUS_SUCCESS != - cb_ctx->mon_cb(cb_ctx->mon_ctx, msdu)) { - pkt_capture_err("Frame Rx to HDD failed"); - qdf_nbuf_free(msdu); - } + pkt_capture_mon(cb_ctx, msdu); msdu = next_buf; } diff --git a/components/pkt_capture/core/src/wlan_pkt_capture_mon_thread.c b/components/pkt_capture/core/src/wlan_pkt_capture_mon_thread.c index 136fcf5f418e..8773e0d63c4f 100644 --- a/components/pkt_capture/core/src/wlan_pkt_capture_mon_thread.c +++ b/components/pkt_capture/core/src/wlan_pkt_capture_mon_thread.c @@ -20,8 +20,33 @@ * DOC: Define internal APIs related to the packet capture component */ -#include "wlan_pkt_capture_priv.h" +#include "wlan_pkt_capture_mon_thread.h" #include +#include "cds_ieee80211_common.h" + +void pkt_capture_mon(struct pkt_capture_cb_context *cb_ctx, + qdf_nbuf_t msdu) +{ + struct radiotap_header *rthdr; + uint8_t rtlen, type, sub_type; + struct ieee80211_frame *wh; + + rthdr = (struct radiotap_header *)qdf_nbuf_data(msdu); + rtlen = rthdr->it_len; + wh = (struct ieee80211_frame *)(qdf_nbuf_data(msdu) + rtlen); + type = (wh)->i_fc[0] & IEEE80211_FC0_TYPE_MASK; + sub_type = (wh)->i_fc[0] & IEEE80211_FC0_SUBTYPE_MASK; + + if ((type == QDF_IEEE80211_FC0_TYPE_DATA) && + (sub_type == QDF_IEEE80211_FC0_SUBTYPE_QOS_NULL)) { + qdf_nbuf_free(msdu); + return; + } + if (cb_ctx->mon_cb(cb_ctx->mon_ctx, msdu) != QDF_STATUS_SUCCESS) { + pkt_capture_err("Frame Rx to HDD failed"); + qdf_nbuf_free(msdu); + } +} void pkt_capture_free_mon_pkt_freeq(struct pkt_capture_mon_context *mon_ctx) {