From af204caea610a564fdaeec3e529c54ab4dfbc320 Mon Sep 17 00:00:00 2001 From: Vulupala Shashank Reddy Date: Thu, 20 Feb 2020 14:47:03 +0530 Subject: [PATCH] qcacld-3.0: Add support to include ACK status and tx retry count Extend radiotap header to append ACK status and tx retry count for packets sent to virtual mon interface. Change-Id: If110a7de736c3efc0d477617089669104c6f1690 CRs-Fixed: 2627707 --- .../core/inc/wlan_pkt_capture_data_txrx.h | 21 +++++++- .../core/inc/wlan_pkt_capture_main.h | 14 +++++ .../core/inc/wlan_pkt_capture_mgmt_txrx.h | 10 ++++ .../core/inc/wlan_pkt_capture_mon_thread.h | 5 +- .../core/src/wlan_pkt_capture_data_txrx.c | 52 +++++++++++++++++-- .../core/src/wlan_pkt_capture_mgmt_txrx.c | 31 ++++++++++- .../core/src/wlan_pkt_capture_mon_thread.c | 3 +- .../inc/wlan_pkt_capture_public_structs.h | 2 + .../inc/wlan_pkt_capture_ucfg_api.h | 8 +-- .../src/wlan_pkt_capture_ucfg_api.c | 10 ++-- core/dp/txrx/ol_rx.c | 2 +- core/dp/txrx/ol_rx_defrag.c | 2 +- core/dp/txrx/ol_tx_send.c | 2 +- core/wma/src/wma_mgmt.c | 1 + 14 files changed, 143 insertions(+), 20 deletions(-) diff --git a/components/pkt_capture/core/inc/wlan_pkt_capture_data_txrx.h b/components/pkt_capture/core/inc/wlan_pkt_capture_data_txrx.h index 90ef8c2e1284..4f51854f4f16 100644 --- a/components/pkt_capture/core/inc/wlan_pkt_capture_data_txrx.h +++ b/components/pkt_capture/core/inc/wlan_pkt_capture_data_txrx.h @@ -61,6 +61,7 @@ enum pkt_capture_data_process_type { * @pkt_format: Frame format * @bssid: bssid * @pdev: pdev handle + * @tx_retry_cnt: tx retry count * * Return: none */ @@ -68,8 +69,9 @@ void pkt_capture_datapkt_process( uint8_t vdev_id, qdf_nbuf_t mon_buf_list, enum pkt_capture_data_process_type type, - uint8_t tid, uint8_t status, bool pkt_format, - uint8_t *bssid, htt_pdev_handle pdev); + uint8_t tid, uint8_t status, bool pktformat, + uint8_t *bssid, htt_pdev_handle pdev, + uint8_t tx_retry_cnt); /** * pkt_capture_msdu_process_pkts() - process data rx pkts * @bssid: bssid @@ -118,6 +120,20 @@ void pkt_capture_offload_deliver_indication_handler( /** * pkt_capture_tx_hdr_elem_t - tx packets header struture to * be used to update radiotap header for packet capture mode + * @timestamp: timestamp + * @preamble: preamble + * @mcs: MCS + * @rate: rate + * @rssi_comb: rssi in dBm + * @nss: if nss 1 means 1ss and 2 means 2ss + * @bw: BW (0=>20MHz, 1=>40MHz, 2=>80MHz, 3=>160MHz) + * @stbc: STBC + * @sgi: SGI + * @ldpc: LDPC + * @beamformed: beamformed + * @dir: direction rx: 0 and tx: 1 + * @status: tx status + * @tx_retry_cnt: tx retry count */ struct pkt_capture_tx_hdr_elem_t { uint32_t timestamp; @@ -133,6 +149,7 @@ struct pkt_capture_tx_hdr_elem_t { bool beamformed; bool dir; /* rx:0 , tx:1 */ uint8_t status; /* tx status */ + uint8_t tx_retry_cnt; }; /** 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 c38d239828c6..fc11cdac6af9 100644 --- a/components/pkt_capture/core/inc/wlan_pkt_capture_main.h +++ b/components/pkt_capture/core/inc/wlan_pkt_capture_main.h @@ -52,6 +52,20 @@ #define PKT_CAPTURE_ENTER() pkt_capture_debug("enter") #define PKT_CAPTURE_EXIT() pkt_capture_debug("exit") +/** + * enum pkt_capture_tx_status - packet capture tx status + * @pktcapture_tx_status_ok: successfully sent + acked + * @pktcapture_tx_status_discard: discard - not sent + * @pktcapture_tx_status_no_ack: no_ack - sent, but no ack + * + * This enum has tx status types for packet capture mode + */ +enum pkt_capture_tx_status { + pkt_capture_tx_status_ok, + pkt_capture_tx_status_discard, + pkt_capture_tx_status_no_ack, +}; + /** * pkt_capture_get_vdev() - Get pkt capture objmgr vdev. * diff --git a/components/pkt_capture/core/inc/wlan_pkt_capture_mgmt_txrx.h b/components/pkt_capture/core/inc/wlan_pkt_capture_mgmt_txrx.h index e2e80dc661f8..f456107b9f0c 100644 --- a/components/pkt_capture/core/inc/wlan_pkt_capture_mgmt_txrx.h +++ b/components/pkt_capture/core/inc/wlan_pkt_capture_mgmt_txrx.h @@ -91,4 +91,14 @@ pkt_capture_mgmt_tx_completion(struct wlan_objmgr_pdev *pdev, */ QDF_STATUS pkt_capture_mgmt_rx_ops(struct wlan_objmgr_psoc *psoc, bool is_register); + +/** + * pkt_capture_mgmt_status_map() - map Tx status for MGMT packets + * with packet capture Tx status + * @status: Tx status + * + * Return: pkt_capture_tx_status enum + */ +enum pkt_capture_tx_status +pkt_capture_mgmt_status_map(uint8_t status); #endif 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 08d96a6a4464..77221daf8b07 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 @@ -42,7 +42,8 @@ typedef void (*pkt_capture_mon_thread_cb)( void *context, void *ppdev, void *monpkt, uint8_t vdev_id, uint8_t tid, uint8_t status, bool pkt_format, - uint8_t *bssid); + uint8_t *bssid, + uint8_t tx_retry_cnt); /* * struct pkt_capture_mon_pkt - mon packet wrapper for mon data from TXRX @@ -55,6 +56,7 @@ typedef void (*pkt_capture_mon_thread_cb)( * @status: Tx packet status * @pkt_format: Mon packet format, 0 = 802.3 format , 1 = 802.11 format * @bssid: bssid + * @tx_retry_cnt: tx retry count * @callback: Mon callback */ struct pkt_capture_mon_pkt { @@ -67,6 +69,7 @@ struct pkt_capture_mon_pkt { uint8_t status; bool pkt_format; uint8_t bssid[QDF_MAC_ADDR_SIZE]; + uint8_t tx_retry_cnt; pkt_capture_mon_thread_cb callback; }; 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 f6871a977faf..a65ee5f6285a 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 @@ -26,9 +26,37 @@ #include #include #include +#include #define RESERVE_BYTES (100) +/** + * pkt_capture_txrx_status_map() - map Tx status for data packets + * with packet capture Tx status + * @status: Tx status + * + * Return: pkt_capture_tx_status enum + */ +static enum pkt_capture_tx_status +pkt_capture_txrx_status_map(uint8_t status) +{ + enum pkt_capture_tx_status tx_status; + + switch (status) { + case htt_tx_status_ok: + tx_status = pkt_capture_tx_status_ok; + break; + case htt_tx_status_no_ack: + tx_status = pkt_capture_tx_status_no_ack; + break; + default: + tx_status = pkt_capture_tx_status_discard; + break; + } + + return tx_status; +} + /** * pkt_capture_get_tx_rate() - get tx rate for tx packet * @preamble_type: preamble type @@ -211,6 +239,9 @@ pkt_capture_update_tx_status( tx_status->chan_flags = channel_flags; tx_status->ant_signal_db = pktcapture_hdr->rssi_comb; tx_status->rssi_comb = pktcapture_hdr->rssi_comb; + tx_status->tx_status = pktcapture_hdr->status; + tx_status->tx_retry_cnt = pktcapture_hdr->tx_retry_cnt; + tx_status->add_rtap_ext = true; } /** @@ -381,7 +412,7 @@ void pkt_capture_msdu_process_pkts( vdev_id, pktcapture_msdu, TXRX_PROCESS_TYPE_DATA_RX, 0, 0, TXRX_PKTCAPTURE_PKT_FORMAT_8023, - bssid, pdev); + bssid, pdev, 0); } /** @@ -395,6 +426,7 @@ void pkt_capture_msdu_process_pkts( * @status: Tx status * @pkt_format: Frame format * @bssid: bssid + * @tx_retry_cnt: tx retry count * * Return: none */ @@ -403,7 +435,7 @@ pkt_capture_rx_data_cb( void *context, void *ppdev, void *nbuf_list, uint8_t vdev_id, uint8_t tid, uint8_t status, bool pkt_format, - uint8_t *bssid) + uint8_t *bssid, uint8_t tx_retry_cnt) { struct pkt_capture_vdev_priv *vdev_priv; qdf_nbuf_t buf_list = (qdf_nbuf_t)nbuf_list; @@ -471,6 +503,9 @@ pkt_capture_rx_data_cb( /* need to update this to fill rx_status*/ htt_rx_mon_get_rx_status(pdev, rx_desc, &rx_status); rx_status.chan_noise_floor = NORMALIZED_TO_NOISE_FLOOR; + rx_status.tx_status = status; + rx_status.tx_retry_cnt = tx_retry_cnt; + rx_status.add_rtap_ext = true; /* clear IEEE80211_RADIOTAP_F_FCS flag*/ rx_status.rtap_flags &= ~(BIT(4)); @@ -519,6 +554,7 @@ free_buf: * @pktformat: Frame format * @bssid: bssid * @pdev: pdev handle + * @tx_retry_cnt: tx retry count * * Return: none */ @@ -526,7 +562,7 @@ static void pkt_capture_tx_data_cb( void *context, void *ppdev, void *nbuf_list, uint8_t vdev_id, uint8_t tid, uint8_t status, bool pkt_format, - uint8_t *bssid) + uint8_t *bssid, uint8_t tx_retry_cnt) { qdf_nbuf_t msdu, next_buf; struct pkt_capture_vdev_priv *vdev_priv; @@ -577,6 +613,8 @@ pkt_capture_tx_data_cb( pktcapture_hdr.sgi = cmpl_desc->sgi; pktcapture_hdr.ldpc = cmpl_desc->ldpc; pktcapture_hdr.beamformed = cmpl_desc->beamformed; + pktcapture_hdr.status = status; + pktcapture_hdr.tx_retry_cnt = tx_retry_cnt; qdf_nbuf_pull_head( msdu, @@ -688,13 +726,15 @@ void pkt_capture_datapkt_process( qdf_nbuf_t mon_buf_list, enum pkt_capture_data_process_type type, uint8_t tid, uint8_t status, bool pkt_format, - uint8_t *bssid, htt_pdev_handle pdev) + uint8_t *bssid, htt_pdev_handle pdev, + uint8_t tx_retry_cnt) { uint8_t drop_count; struct pkt_capture_mon_pkt *pkt; pkt_capture_mon_thread_cb callback = NULL; struct wlan_objmgr_vdev *vdev; + status = pkt_capture_txrx_status_map(status); vdev = pkt_capture_get_vdev(); if (!vdev) goto drop_rx_buf; @@ -724,6 +764,7 @@ void pkt_capture_datapkt_process( pkt->status = status; pkt->pkt_format = pkt_format; qdf_mem_copy(pkt->bssid, bssid, QDF_MAC_ADDR_SIZE); + pkt->tx_retry_cnt = tx_retry_cnt; pkt_capture_indicate_monpkt(vdev, pkt); return; @@ -834,5 +875,6 @@ void pkt_capture_offload_deliver_indication_handler( pkt_capture_datapkt_process( vdev_id, netbuf, TXRX_PROCESS_TYPE_DATA_TX, - tid, status, pkt_format, bssid, pdev); + tid, status, pkt_format, bssid, pdev, + offload_deliver_msg->tx_retry_cnt); } 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 dd3253bebaac..9da0130b4cbe 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 @@ -31,6 +31,26 @@ #include "wlan_utility.h" #include "cds_ieee80211_common.h" +enum pkt_capture_tx_status +pkt_capture_mgmt_status_map(uint8_t status) +{ + enum pkt_capture_tx_status tx_status; + + switch (status) { + case WMI_MGMT_TX_COMP_TYPE_COMPLETE_OK: + tx_status = pkt_capture_tx_status_ok; + break; + case WMI_MGMT_TX_COMP_TYPE_COMPLETE_NO_ACK: + tx_status = pkt_capture_tx_status_no_ack; + break; + default: + tx_status = pkt_capture_tx_status_discard; + break; + } + + return tx_status; +} + /** * pkt_capture_mgmtpkt_cb() - callback to process management packets * for pkt capture mode @@ -40,13 +60,14 @@ * @tid: tid number * @status: Tx status * @pkt_format: Frame format + * @tx_retry_cnt: tx retry count * * Return: none */ static void pkt_capture_mgmtpkt_cb(void *context, void *ppdev, void *nbuf_list, uint8_t vdev_id, uint8_t tid, uint8_t status, - bool pkt_format, uint8_t *bssid) + bool pkt_format, uint8_t *bssid, uint8_t tx_retry_cnt) { struct pkt_capture_vdev_priv *vdev_priv; struct wlan_objmgr_psoc *psoc = context; @@ -230,6 +251,9 @@ pkt_capture_process_mgmt_tx_data(struct wlan_objmgr_pdev *pdev, IEEE80211_CHAN_2GHZ : IEEE80211_CHAN_5GHZ); txrx_status.chan_flags = channel_flags; txrx_status.rate = ((txrx_status.rate == 6 /* Mbps */) ? 0x0c : 0x02); + txrx_status.tx_status = status; + txrx_status.tx_retry_cnt = params->tx_retry_cnt; + txrx_status.add_rtap_ext = true; wh = (struct ieee80211_frame *)qdf_nbuf_data(nbuf); wh->i_fc[1] &= ~IEEE80211_FC1_WEP; @@ -319,7 +343,9 @@ pkt_capture_mgmt_tx_completion(struct wlan_objmgr_pdev *pdev, qdf_mem_copy(qdf_nbuf_data(wbuf), qdf_nbuf_data(nbuf), nbuf_len); if (QDF_STATUS_SUCCESS != - pkt_capture_process_mgmt_tx_data(pdev, params, wbuf, status)) + pkt_capture_process_mgmt_tx_data( + pdev, params, wbuf, + pkt_capture_mgmt_status_map(status))) qdf_nbuf_free(wbuf); } @@ -375,6 +401,7 @@ pkt_capture_mgmt_rx_data_cb(struct wlan_objmgr_psoc *psoc, IEEE80211_CHAN_2GHZ : IEEE80211_CHAN_5GHZ); txrx_status.chan_flags = channel_flags; txrx_status.rate = ((txrx_status.rate == 6 /* Mbps */) ? 0x0c : 0x02); + txrx_status.add_rtap_ext = true; wh = (struct ieee80211_frame *)qdf_nbuf_data(nbuf); wh->i_fc[1] &= ~IEEE80211_FC1_WEP; 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 50056c7e8935..136fcf5f418e 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 @@ -210,7 +210,8 @@ pkt_capture_process_from_queue(struct pkt_capture_mon_context *mon_ctx) vdev_id = pkt->vdev_id; tid = pkt->tid; pkt->callback(pkt->context, pkt->pdev, pkt->monpkt, vdev_id, - tid, pkt->status, pkt->pkt_format, pkt->bssid); + tid, pkt->status, pkt->pkt_format, pkt->bssid, + pkt->tx_retry_cnt); pkt_capture_free_mon_pkt(mon_ctx, pkt); spin_lock_bh(&mon_ctx->mon_queue_lock); } diff --git a/components/pkt_capture/dispatcher/inc/wlan_pkt_capture_public_structs.h b/components/pkt_capture/dispatcher/inc/wlan_pkt_capture_public_structs.h index 3f16a670c302..a032b5da5c74 100644 --- a/components/pkt_capture/dispatcher/inc/wlan_pkt_capture_public_structs.h +++ b/components/pkt_capture/dispatcher/inc/wlan_pkt_capture_public_structs.h @@ -46,6 +46,7 @@ enum pkt_capture_mode { * 4: fifo underrun * 8: swabort * @buf: management frame buffer + * @tx_retry_cnt: tx retry count */ struct mgmt_offload_event_params { uint32_t tsf_l32; @@ -55,5 +56,6 @@ struct mgmt_offload_event_params { uint32_t buf_len; uint32_t tx_status; uint8_t *buf; + uint8_t tx_retry_cnt; }; #endif /* _WLAN_PKT_CAPTURE_PUBLIC_STRUCTS_H_ */ diff --git a/components/pkt_capture/dispatcher/inc/wlan_pkt_capture_ucfg_api.h b/components/pkt_capture/dispatcher/inc/wlan_pkt_capture_ucfg_api.h index c1cd376ca4d4..b1d018591211 100644 --- a/components/pkt_capture/dispatcher/inc/wlan_pkt_capture_ucfg_api.h +++ b/components/pkt_capture/dispatcher/inc/wlan_pkt_capture_ucfg_api.h @@ -243,6 +243,7 @@ struct htt_tx_data_hdr_information *ucfg_pkt_capture_tx_get_txcomplete_data_hdr( * @pktformat: Frame format * @bssid: bssid * @pdev: pdev handle + * @tx_retry_cnt: tx retry count * * Return: none */ @@ -251,7 +252,8 @@ void ucfg_pkt_capture_tx_completion_process( qdf_nbuf_t mon_buf_list, enum pkt_capture_data_process_type type, uint8_t tid, uint8_t status, bool pkt_format, - uint8_t *bssid, htt_pdev_handle pdev); + uint8_t *bssid, htt_pdev_handle pdev, + uint8_t tx_retry_cnt); /** * ucfg_pkt_capture_record_channel() - Update Channel Information @@ -381,8 +383,8 @@ ucfg_pkt_capture_tx_completion_process( qdf_nbuf_t mon_buf_list, enum pkt_capture_data_process_type type, uint8_t tid, uint8_t status, bool pkt_format, - uint8_t *bssid, htt_pdev_handle pdev) - + uint8_t *bssid, htt_pdev_handle pdev, + uint8_t tx_retry_cnt) { } diff --git a/components/pkt_capture/dispatcher/src/wlan_pkt_capture_ucfg_api.c b/components/pkt_capture/dispatcher/src/wlan_pkt_capture_ucfg_api.c index 7155a3c0f39f..569941ac8969 100644 --- a/components/pkt_capture/dispatcher/src/wlan_pkt_capture_ucfg_api.c +++ b/components/pkt_capture/dispatcher/src/wlan_pkt_capture_ucfg_api.c @@ -203,7 +203,9 @@ ucfg_pkt_capture_process_mgmt_tx_data(struct wlan_objmgr_pdev *pdev, qdf_nbuf_t nbuf, uint8_t status) { - return pkt_capture_process_mgmt_tx_data(pdev, params, nbuf, status); + return pkt_capture_process_mgmt_tx_data( + pdev, params, nbuf, + pkt_capture_mgmt_status_map(status)); } void @@ -323,12 +325,14 @@ ucfg_pkt_capture_tx_completion_process( qdf_nbuf_t mon_buf_list, enum pkt_capture_data_process_type type, uint8_t tid, uint8_t status, bool pkt_format, - uint8_t *bssid, htt_pdev_handle pdev) + uint8_t *bssid, htt_pdev_handle pdev, + uint8_t tx_retry_cnt) { pkt_capture_datapkt_process( vdev_id, mon_buf_list, TXRX_PROCESS_TYPE_DATA_TX_COMPL, - tid, status, pkt_format, bssid, pdev); + tid, status, pkt_format, bssid, pdev, + tx_retry_cnt); } void ucfg_pkt_capture_record_channel(struct wlan_objmgr_vdev *vdev) diff --git a/core/dp/txrx/ol_rx.c b/core/dp/txrx/ol_rx.c index 140e4a66159c..99d231db9530 100644 --- a/core/dp/txrx/ol_rx.c +++ b/core/dp/txrx/ol_rx.c @@ -1644,7 +1644,7 @@ ol_rx_in_order_indication_handler(ol_txrx_pdev_handle pdev, /* Packet Capture Mode */ - if ((ucfg_pkt_capture_get_mode((void *)soc->psoc) & + if ((ucfg_pkt_capture_get_pktcap_mode((void *)soc->psoc) & PKT_CAPTURE_MODE_DATA_ONLY)) { offloaded_pkt = ucfg_pkt_capture_rx_offloaded_pkt(rx_ind_msg); if (peer) { diff --git a/core/dp/txrx/ol_rx_defrag.c b/core/dp/txrx/ol_rx_defrag.c index af9b04b112b2..821df5d8568b 100644 --- a/core/dp/txrx/ol_rx_defrag.c +++ b/core/dp/txrx/ol_rx_defrag.c @@ -780,7 +780,7 @@ ol_rx_defrag(ol_txrx_pdev_handle pdev, /* Packet Capture Mode */ - if ((ucfg_pkt_capture_get_mode((void *)soc->psoc) & + if ((ucfg_pkt_capture_get_pktcap_mode((void *)soc->psoc) & PKT_CAPTURE_MODE_DATA_ONLY)) { if (peer) { if (peer->vdev) { diff --git a/core/dp/txrx/ol_tx_send.c b/core/dp/txrx/ol_tx_send.c index 0553054f7056..bd48b0480883 100644 --- a/core/dp/txrx/ol_tx_send.c +++ b/core/dp/txrx/ol_tx_send.c @@ -736,7 +736,7 @@ ol_tx_pkt_capture_tx_completion_process( netbuf, pkt_type, tid, status, TXRX_PKTCAPTURE_PKT_FORMAT_8023, bssid, - pdev->htt_pdev); + pdev->htt_pdev, payload_hdr->tx_retry_cnt); } #else static void diff --git a/core/wma/src/wma_mgmt.c b/core/wma/src/wma_mgmt.c index 3396c43847d2..6ff5b70aa97e 100644 --- a/core/wma/src/wma_mgmt.c +++ b/core/wma/src/wma_mgmt.c @@ -2656,6 +2656,7 @@ static void wma_extract_mgmt_offload_event_params( params->rssi = hdr->rssi; params->buf_len = hdr->buf_len; params->tx_status = hdr->tx_status; + params->tx_retry_cnt = hdr->tx_retry_cnt; } /**