123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863 |
- /*
- * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
- * Permission to use, copy, modify, and/or distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
- #include <dp_types.h>
- #include "dp_rx.h"
- #include "dp_peer.h"
- #include <dp_htt.h>
- #include <dp_rx_mon.h>
- #include <dp_mon_filter.h>
- #include <dp_mon.h>
- #include "htt_ppdu_stats.h"
- #define RNG_ERR "SRNG setup failed for"
- #define mon_init_err(params...) QDF_TRACE_ERROR(QDF_MODULE_ID_DP_INIT, params)
- QDF_STATUS dp_srng_alloc(struct dp_soc *soc, struct dp_srng *srng,
- int ring_type, uint32_t num_entries,
- bool cached);
- void dp_srng_free(struct dp_soc *soc, struct dp_srng *srng);
- QDF_STATUS dp_srng_init(struct dp_soc *soc, struct dp_srng *srng,
- int ring_type, int ring_num, int mac_id);
- void dp_srng_deinit(struct dp_soc *soc, struct dp_srng *srng,
- int ring_type, int ring_num);
- QDF_STATUS dp_htt_ppdu_stats_attach(struct dp_pdev *pdev);
- void dp_htt_ppdu_stats_detach(struct dp_pdev *pdev);
- void dp_neighbour_peers_detach(struct dp_pdev *pdev);
- void dp_pktlogmod_exit(struct dp_pdev *handle);
- QDF_STATUS dp_vdev_set_monitor_mode_rings(struct dp_pdev *pdev,
- uint8_t delayed_replenish);
- #if !defined(DISABLE_MON_CONFIG)
- /**
- * dp_mon_rings_deinit() - Deinitialize monitor rings
- * @pdev: DP pdev handle
- *
- * Return: None
- *
- */
- static void dp_mon_rings_deinit(struct dp_pdev *pdev)
- {
- int mac_id = 0;
- struct wlan_cfg_dp_pdev_ctxt *pdev_cfg_ctx;
- struct dp_soc *soc = pdev->soc;
- pdev_cfg_ctx = pdev->wlan_cfg_ctx;
- for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
- int lmac_id = dp_get_lmac_id_for_pdev_id(soc, mac_id,
- pdev->pdev_id);
- dp_srng_deinit(soc, &soc->rxdma_mon_status_ring[lmac_id],
- RXDMA_MONITOR_STATUS, 0);
- if (!soc->wlan_cfg_ctx->rxdma1_enable)
- continue;
- dp_srng_deinit(soc, &soc->rxdma_mon_buf_ring[lmac_id],
- RXDMA_MONITOR_BUF, 0);
- dp_srng_deinit(soc, &soc->rxdma_mon_dst_ring[lmac_id],
- RXDMA_MONITOR_DST, 0);
- dp_srng_deinit(soc, &soc->rxdma_mon_desc_ring[lmac_id],
- RXDMA_MONITOR_DESC, 0);
- }
- }
- /**
- * dp_mon_rings_free() - free monitor rings
- * @pdev: Datapath pdev handle
- *
- * Return: None
- *
- */
- static void dp_mon_rings_free(struct dp_pdev *pdev)
- {
- int mac_id = 0;
- struct wlan_cfg_dp_pdev_ctxt *pdev_cfg_ctx;
- struct dp_soc *soc = pdev->soc;
- pdev_cfg_ctx = pdev->wlan_cfg_ctx;
- for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
- int lmac_id = dp_get_lmac_id_for_pdev_id(soc, mac_id,
- pdev->pdev_id);
- dp_srng_free(soc, &soc->rxdma_mon_status_ring[lmac_id]);
- if (!soc->wlan_cfg_ctx->rxdma1_enable)
- continue;
- dp_srng_free(soc, &soc->rxdma_mon_buf_ring[lmac_id]);
- dp_srng_free(soc, &soc->rxdma_mon_dst_ring[lmac_id]);
- dp_srng_free(soc, &soc->rxdma_mon_desc_ring[lmac_id]);
- }
- }
- /**
- * dp_mon_rings_init() - Initialize monitor srng rings
- * @pdev: Datapath pdev handle
- *
- * return: QDF_STATUS_SUCCESS on success
- * QDF_STATUS_E_NOMEM on failure
- */
- static
- QDF_STATUS dp_mon_rings_init(struct dp_soc *soc, struct dp_pdev *pdev)
- {
- int mac_id = 0;
- struct wlan_cfg_dp_pdev_ctxt *pdev_cfg_ctx;
- pdev_cfg_ctx = pdev->wlan_cfg_ctx;
- for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
- int lmac_id = dp_get_lmac_id_for_pdev_id(soc, mac_id,
- pdev->pdev_id);
- if (dp_srng_init(soc, &soc->rxdma_mon_status_ring[lmac_id],
- RXDMA_MONITOR_STATUS, 0, lmac_id)) {
- mon_init_err("%pK: " RNG_ERR "rxdma_mon_status_ring",
- soc);
- goto fail1;
- }
- if (!soc->wlan_cfg_ctx->rxdma1_enable)
- continue;
- if (dp_srng_init(soc, &soc->rxdma_mon_buf_ring[lmac_id],
- RXDMA_MONITOR_BUF, 0, lmac_id)) {
- mon_init_err("%pK: " RNG_ERR "rxdma_mon_buf_ring ",
- soc);
- goto fail1;
- }
- if (dp_srng_init(soc, &soc->rxdma_mon_dst_ring[lmac_id],
- RXDMA_MONITOR_DST, 0, lmac_id)) {
- mon_init_err("%pK: " RNG_ERR "rxdma_mon_dst_ring", soc);
- goto fail1;
- }
- if (dp_srng_init(soc, &soc->rxdma_mon_desc_ring[lmac_id],
- RXDMA_MONITOR_DESC, 0, lmac_id)) {
- mon_init_err("%pK: " RNG_ERR "rxdma_mon_desc_ring",
- soc);
- goto fail1;
- }
- }
- return QDF_STATUS_SUCCESS;
- fail1:
- dp_mon_rings_deinit(pdev);
- return QDF_STATUS_E_NOMEM;
- }
- /**
- * dp_mon_rings_alloc() - Allocate memory for monitor srng rings
- * @soc: Datapath soc handle
- * @pdev: Datapath pdev handle
- *
- * return: QDF_STATUS_SUCCESS on success
- * QDF_STATUS_E_NOMEM on failure
- */
- static
- QDF_STATUS dp_mon_rings_alloc(struct dp_soc *soc, struct dp_pdev *pdev)
- {
- int mac_id = 0;
- int entries;
- struct wlan_cfg_dp_pdev_ctxt *pdev_cfg_ctx;
- pdev_cfg_ctx = pdev->wlan_cfg_ctx;
- for (mac_id = 0; mac_id < NUM_RXDMA_RINGS_PER_PDEV; mac_id++) {
- int lmac_id =
- dp_get_lmac_id_for_pdev_id(soc, mac_id, pdev->pdev_id);
- entries = wlan_cfg_get_dma_mon_stat_ring_size(pdev_cfg_ctx);
- if (dp_srng_alloc(soc, &soc->rxdma_mon_status_ring[lmac_id],
- RXDMA_MONITOR_STATUS, entries, 0)) {
- mon_init_err("%pK: " RNG_ERR "rxdma_mon_status_ring",
- soc);
- goto fail1;
- }
- if (!soc->wlan_cfg_ctx->rxdma1_enable)
- continue;
- entries = wlan_cfg_get_dma_mon_buf_ring_size(pdev_cfg_ctx);
- if (dp_srng_alloc(soc, &soc->rxdma_mon_buf_ring[lmac_id],
- RXDMA_MONITOR_BUF, entries, 0)) {
- mon_init_err("%pK: " RNG_ERR "rxdma_mon_buf_ring ",
- soc);
- goto fail1;
- }
- entries = wlan_cfg_get_dma_mon_dest_ring_size(pdev_cfg_ctx);
- if (dp_srng_alloc(soc, &soc->rxdma_mon_dst_ring[lmac_id],
- RXDMA_MONITOR_DST, entries, 0)) {
- mon_init_err("%pK: " RNG_ERR "rxdma_mon_dst_ring", soc);
- goto fail1;
- }
- entries = wlan_cfg_get_dma_mon_desc_ring_size(pdev_cfg_ctx);
- if (dp_srng_alloc(soc, &soc->rxdma_mon_desc_ring[lmac_id],
- RXDMA_MONITOR_DESC, entries, 0)) {
- mon_init_err("%pK: " RNG_ERR "rxdma_mon_desc_ring",
- soc);
- goto fail1;
- }
- }
- return QDF_STATUS_SUCCESS;
- fail1:
- dp_mon_rings_free(pdev);
- return QDF_STATUS_E_NOMEM;
- }
- #else
- static void dp_mon_rings_free(struct dp_pdev *pdev)
- {
- }
- static void dp_mon_rings_deinit(struct dp_pdev *pdev)
- {
- }
- static
- QDF_STATUS dp_mon_rings_init(struct dp_soc *soc, struct dp_pdev *pdev)
- {
- return QDF_STATUS_SUCCESS;
- }
- static
- QDF_STATUS dp_mon_rings_alloc(struct dp_soc *soc, struct dp_pdev *pdev)
- {
- return QDF_STATUS_SUCCESS;
- }
- #endif
- #ifdef QCA_SUPPORT_FULL_MON
- static inline QDF_STATUS
- dp_config_full_mon_mode(struct cdp_soc_t *soc_handle,
- uint8_t val)
- {
- struct dp_soc *soc = (struct dp_soc *)soc_handle;
- soc->full_mon_mode = val;
- dp_cdp_err("Configure full monitor mode val: %d ", val);
- return QDF_STATUS_SUCCESS;
- }
- #else
- static inline QDF_STATUS
- dp_config_full_mon_mode(struct cdp_soc_t *soc_handle,
- uint8_t val)
- {
- return 0;
- }
- #endif
- static inline void
- dp_pdev_disable_mcopy_code(struct dp_pdev *pdev)
- {
- pdev->mcopy_mode = M_COPY_DISABLED;
- pdev->monitor_configured = false;
- pdev->monitor_vdev = NULL;
- }
- #ifdef QCA_SUPPORT_FULL_MON
- static inline QDF_STATUS
- dp_soc_config_full_mon_mode(struct dp_pdev *pdev, enum dp_full_mon_config val)
- {
- struct dp_soc *soc = pdev->soc;
- QDF_STATUS status = QDF_STATUS_SUCCESS;
- if (!soc->full_mon_mode)
- return QDF_STATUS_SUCCESS;
- if ((htt_h2t_full_mon_cfg(soc->htt_handle,
- pdev->pdev_id,
- val)) != QDF_STATUS_SUCCESS) {
- status = QDF_STATUS_E_FAILURE;
- }
- return status;
- }
- #else
- static inline QDF_STATUS
- dp_soc_config_full_mon_mode(struct dp_pdev *pdev, enum dp_full_mon_config val)
- {
- return 0;
- }
- #endif
- /**
- * dp_reset_monitor_mode() - Disable monitor mode
- * @soc_hdl: Datapath soc handle
- * @pdev_id: id of datapath PDEV handle
- *
- * Return: QDF_STATUS
- */
- QDF_STATUS dp_reset_monitor_mode(struct cdp_soc_t *soc_hdl,
- uint8_t pdev_id,
- uint8_t special_monitor)
- {
- struct dp_soc *soc = (struct dp_soc *)soc_hdl;
- struct dp_pdev *pdev =
- dp_get_pdev_from_soc_pdev_id_wifi3((struct dp_soc *)soc,
- pdev_id);
- QDF_STATUS status = QDF_STATUS_SUCCESS;
- if (!pdev)
- return QDF_STATUS_E_FAILURE;
- qdf_spin_lock_bh(&pdev->mon_lock);
- dp_soc_config_full_mon_mode(pdev, DP_FULL_MON_DISABLE);
- pdev->monitor_vdev = NULL;
- pdev->monitor_configured = false;
- /*
- * Lite monitor mode, smart monitor mode and monitor
- * mode uses this APIs to filter reset and mode disable
- */
- if (pdev->mcopy_mode) {
- #if defined(FEATURE_PERPKT_INFO)
- dp_pdev_disable_mcopy_code(pdev);
- dp_mon_filter_reset_mcopy_mode(pdev);
- #endif /* FEATURE_PERPKT_INFO */
- } else if (special_monitor) {
- #if defined(ATH_SUPPORT_NAC)
- dp_mon_filter_reset_smart_monitor(pdev);
- #endif /* ATH_SUPPORT_NAC */
- } else {
- dp_mon_filter_reset_mon_mode(pdev);
- }
- status = dp_mon_filter_update(pdev);
- if (status != QDF_STATUS_SUCCESS) {
- dp_rx_mon_dest_err("%pK: Failed to reset monitor filters",
- soc);
- }
- qdf_spin_unlock_bh(&pdev->mon_lock);
- return QDF_STATUS_SUCCESS;
- }
- /**
- * dp_pdev_set_advance_monitor_filter() - Set DP PDEV monitor filter
- * @soc: soc handle
- * @pdev_id: id of Datapath PDEV handle
- * @filter_val: Flag to select Filter for monitor mode
- * Return: 0 on success, not 0 on failure
- */
- static QDF_STATUS
- dp_pdev_set_advance_monitor_filter(struct cdp_soc_t *soc_hdl, uint8_t pdev_id,
- struct cdp_monitor_filter *filter_val)
- {
- /* Many monitor VAPs can exists in a system but only one can be up at
- * anytime
- */
- struct dp_soc *soc = (struct dp_soc *)soc_hdl;
- struct dp_vdev *vdev;
- struct dp_pdev *pdev =
- dp_get_pdev_from_soc_pdev_id_wifi3((struct dp_soc *)soc,
- pdev_id);
- QDF_STATUS status = QDF_STATUS_SUCCESS;
- if (!pdev)
- return QDF_STATUS_E_FAILURE;
- vdev = pdev->monitor_vdev;
- if (!vdev)
- return QDF_STATUS_E_FAILURE;
- QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_WARN,
- "pdev=%pK, pdev_id=%d, soc=%pK vdev=%pK",
- pdev, pdev_id, soc, vdev);
- /*Check if current pdev's monitor_vdev exists */
- if (!pdev->monitor_vdev) {
- QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_ERROR,
- "vdev=%pK", vdev);
- qdf_assert(vdev);
- }
- /* update filter mode, type in pdev structure */
- pdev->mon_filter_mode = filter_val->mode;
- pdev->fp_mgmt_filter = filter_val->fp_mgmt;
- pdev->fp_ctrl_filter = filter_val->fp_ctrl;
- pdev->fp_data_filter = filter_val->fp_data;
- pdev->mo_mgmt_filter = filter_val->mo_mgmt;
- pdev->mo_ctrl_filter = filter_val->mo_ctrl;
- pdev->mo_data_filter = filter_val->mo_data;
- dp_mon_filter_setup_mon_mode(pdev);
- status = dp_mon_filter_update(pdev);
- if (status != QDF_STATUS_SUCCESS) {
- dp_rx_mon_dest_err("%pK: Failed to set filter for adv mon mode",
- soc);
- dp_mon_filter_reset_mon_mode(pdev);
- }
- return status;
- }
- /**
- * dp_deliver_tx_mgmt() - Deliver mgmt frame for tx capture
- * @cdp_soc : data path soc handle
- * @pdev_id : pdev_id
- * @nbuf: Management frame buffer
- */
- static QDF_STATUS
- dp_deliver_tx_mgmt(struct cdp_soc_t *cdp_soc, uint8_t pdev_id, qdf_nbuf_t nbuf)
- {
- struct dp_pdev *pdev =
- dp_get_pdev_from_soc_pdev_id_wifi3((struct dp_soc *)cdp_soc,
- pdev_id);
- if (!pdev)
- return QDF_STATUS_E_FAILURE;
- dp_deliver_mgmt_frm(pdev, nbuf);
- return QDF_STATUS_SUCCESS;
- }
- /**
- * dp_vdev_set_monitor_mode() - Set DP VDEV to monitor mode
- * @vdev_handle: Datapath VDEV handle
- * @smart_monitor: Flag to denote if its smart monitor mode
- *
- * Return: 0 on success, not 0 on failure
- */
- static QDF_STATUS dp_vdev_set_monitor_mode(struct cdp_soc_t *dp_soc,
- uint8_t vdev_id,
- uint8_t special_monitor)
- {
- struct dp_soc *soc = (struct dp_soc *)dp_soc;
- struct dp_pdev *pdev;
- struct dp_vdev *vdev = dp_vdev_get_ref_by_id(soc, vdev_id,
- DP_MOD_ID_CDP);
- QDF_STATUS status = QDF_STATUS_SUCCESS;
- if (!vdev)
- return QDF_STATUS_E_FAILURE;
- pdev = vdev->pdev;
- pdev->monitor_vdev = vdev;
- QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_WARN,
- "pdev=%pK, pdev_id=%d, soc=%pK vdev=%pK\n",
- pdev, pdev->pdev_id, pdev->soc, vdev);
- /*
- * do not configure monitor buf ring and filter for smart and
- * lite monitor
- * for smart monitor filters are added along with first NAC
- * for lite monitor required configuration done through
- * dp_set_pdev_param
- */
- if (special_monitor) {
- status = QDF_STATUS_SUCCESS;
- goto fail;
- }
- /*Check if current pdev's monitor_vdev exists */
- if (pdev->monitor_configured) {
- QDF_TRACE(QDF_MODULE_ID_TXRX, QDF_TRACE_LEVEL_DEBUG,
- "monitor vap already created vdev=%pK\n", vdev);
- status = QDF_STATUS_E_RESOURCES;
- goto fail;
- }
- pdev->monitor_configured = true;
- dp_soc_config_full_mon_mode(pdev, DP_FULL_MON_ENABLE);
- dp_mon_filter_setup_mon_mode(pdev);
- status = dp_mon_filter_update(pdev);
- if (status != QDF_STATUS_SUCCESS) {
- dp_cdp_err("%pK: Failed to reset monitor filters", soc);
- dp_mon_filter_reset_mon_mode(pdev);
- pdev->monitor_configured = false;
- pdev->monitor_vdev = NULL;
- }
- fail:
- dp_vdev_unref_delete(soc, vdev, DP_MOD_ID_CDP);
- return status;
- }
- /*
- * dp_config_debug_sniffer()- API to enable/disable debug sniffer
- * @pdev: DP_PDEV handle
- * @val: user provided value
- *
- * Return: 0 for success. nonzero for failure.
- */
- static QDF_STATUS
- dp_config_debug_sniffer(struct dp_pdev *pdev, int val)
- {
- QDF_STATUS status = QDF_STATUS_SUCCESS;
- /*
- * Note: The mirror copy mode cannot co-exist with any other
- * monitor modes. Hence disabling the filter for this mode will
- * reset the monitor destination ring filters.
- */
- if (pdev->mcopy_mode) {
- #ifdef FEATURE_PERPKT_INFO
- dp_soc_config_full_mon_mode(pdev, DP_FULL_MON_DISABLE);
- dp_pdev_disable_mcopy_code(pdev);
- dp_mon_filter_reset_mcopy_mode(pdev);
- status = dp_mon_filter_update(pdev);
- if (status != QDF_STATUS_SUCCESS) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL("Failed to reset AM copy mode filters"));
- }
- #endif /* FEATURE_PERPKT_INFO */
- }
- switch (val) {
- case 0:
- pdev->tx_sniffer_enable = 0;
- pdev->monitor_configured = false;
- /*
- * We don't need to reset the Rx monitor status ring or call
- * the API dp_ppdu_ring_reset() if all debug sniffer mode is
- * disabled. The Rx monitor status ring will be disabled when
- * the last mode using the monitor status ring get disabled.
- */
- if (!pdev->pktlog_ppdu_stats && !pdev->enhanced_stats_en &&
- !pdev->bpr_enable) {
- dp_h2t_cfg_stats_msg_send(pdev, 0, pdev->pdev_id);
- } else if (pdev->enhanced_stats_en && !pdev->bpr_enable) {
- dp_h2t_cfg_stats_msg_send(pdev,
- DP_PPDU_STATS_CFG_ENH_STATS,
- pdev->pdev_id);
- } else if (!pdev->enhanced_stats_en && pdev->bpr_enable) {
- dp_h2t_cfg_stats_msg_send(pdev,
- DP_PPDU_STATS_CFG_BPR_ENH,
- pdev->pdev_id);
- } else {
- dp_h2t_cfg_stats_msg_send(pdev,
- DP_PPDU_STATS_CFG_BPR,
- pdev->pdev_id);
- }
- break;
- case 1:
- pdev->tx_sniffer_enable = 1;
- pdev->monitor_configured = false;
- if (!pdev->pktlog_ppdu_stats)
- dp_h2t_cfg_stats_msg_send(pdev,
- DP_PPDU_STATS_CFG_SNIFFER,
- pdev->pdev_id);
- break;
- case 2:
- case 4:
- if (pdev->monitor_vdev) {
- status = QDF_STATUS_E_RESOURCES;
- break;
- }
- #ifdef FEATURE_PERPKT_INFO
- pdev->mcopy_mode = val;
- pdev->tx_sniffer_enable = 0;
- pdev->monitor_configured = true;
- if (!wlan_cfg_is_delay_mon_replenish(pdev->soc->wlan_cfg_ctx))
- dp_vdev_set_monitor_mode_rings(pdev, true);
- /*
- * Setup the M copy mode filter.
- */
- dp_soc_config_full_mon_mode(pdev, DP_FULL_MON_ENABLE);
- dp_mon_filter_setup_mcopy_mode(pdev);
- status = dp_mon_filter_update(pdev);
- if (status != QDF_STATUS_SUCCESS) {
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- FL("Failed to set M_copy mode filters"));
- dp_mon_filter_reset_mcopy_mode(pdev);
- dp_pdev_disable_mcopy_code(pdev);
- return status;
- }
- if (!pdev->pktlog_ppdu_stats)
- dp_h2t_cfg_stats_msg_send(pdev,
- DP_PPDU_STATS_CFG_SNIFFER,
- pdev->pdev_id);
- #endif /* FEATURE_PERPKT_INFO */
- break;
- default:
- QDF_TRACE(QDF_MODULE_ID_DP, QDF_TRACE_LEVEL_ERROR,
- "Invalid value");
- break;
- }
- return status;
- }
- QDF_STATUS dp_mon_soc_cfg_init(struct dp_soc *soc)
- {
- int target_type;
- target_type = hal_get_target_type(soc->hal_soc);
- switch (target_type) {
- case TARGET_TYPE_QCA6290:
- case TARGET_TYPE_QCA6390:
- case TARGET_TYPE_QCA6490:
- case TARGET_TYPE_QCA6750:
- break;
- case TARGET_TYPE_QCA8074:
- wlan_cfg_set_mon_delayed_replenish_entries(soc->wlan_cfg_ctx,
- MON_BUF_MIN_ENTRIES);
- break;
- case TARGET_TYPE_QCA8074V2:
- case TARGET_TYPE_QCA6018:
- case TARGET_TYPE_QCA9574:
- wlan_cfg_set_mon_delayed_replenish_entries(soc->wlan_cfg_ctx,
- MON_BUF_MIN_ENTRIES);
- soc->hw_nac_monitor_support = 1;
- break;
- case TARGET_TYPE_QCN9000:
- wlan_cfg_set_mon_delayed_replenish_entries(soc->wlan_cfg_ctx,
- MON_BUF_MIN_ENTRIES);
- soc->hw_nac_monitor_support = 1;
- if (cfg_get(soc->ctrl_psoc, CFG_DP_FULL_MON_MODE))
- dp_config_full_mon_mode((struct cdp_soc_t *)soc, 1);
- break;
- case TARGET_TYPE_QCA5018:
- case TARGET_TYPE_QCN6122:
- wlan_cfg_set_mon_delayed_replenish_entries(soc->wlan_cfg_ctx,
- MON_BUF_MIN_ENTRIES);
- soc->hw_nac_monitor_support = 1;
- break;
- case TARGET_TYPE_QCN9224:
- wlan_cfg_set_mon_delayed_replenish_entries(soc->wlan_cfg_ctx,
- MON_BUF_MIN_ENTRIES);
- soc->hw_nac_monitor_support = 1;
- break;
- default:
- qdf_print("%s: Unknown tgt type %d\n", __func__, target_type);
- qdf_assert_always(0);
- break;
- }
- return QDF_STATUS_SUCCESS;
- }
- QDF_STATUS dp_mon_pdev_attach(struct dp_pdev *pdev)
- {
- struct dp_soc *soc;
- struct dp_mon_pdev *mon_pdev;
- if (!pdev) {
- mon_init_err("pdev is NULL");
- goto fail0;
- }
- soc = pdev->soc;
- mon_pdev = (struct dp_mon_pdev *)qdf_mem_malloc(sizeof(*mon_pdev));
- if (!mon_pdev) {
- mon_init_err("%pK: MONITOR pdev allocation failed", pdev);
- goto fail0;
- }
- if (dp_mon_rings_alloc(soc, pdev)) {
- mon_init_err("%pK: MONITOR rings setup failed", pdev);
- goto fail1;
- }
- /* Rx monitor mode specific init */
- if (dp_rx_pdev_mon_desc_pool_alloc(pdev)) {
- mon_init_err("%pK: dp_rx_pdev_mon_attach failed", pdev);
- goto fail2;
- }
- pdev->monitor_pdev = mon_pdev;
- return QDF_STATUS_SUCCESS;
- fail2:
- dp_mon_rings_free(pdev);
- fail1:
- pdev->monitor_pdev = NULL;
- qdf_mem_free(mon_pdev);
- fail0:
- return QDF_STATUS_E_NOMEM;
- }
- QDF_STATUS dp_mon_pdev_detach(struct dp_pdev *pdev)
- {
- struct dp_mon_pdev *mon_pdev;
- if (!pdev) {
- mon_init_err("pdev is NULL");
- return QDF_STATUS_E_FAILURE;
- }
- mon_pdev = pdev->monitor_pdev;
- dp_rx_pdev_mon_desc_pool_free(pdev);
- dp_mon_rings_free(pdev);
- pdev->monitor_pdev = NULL;
- qdf_mem_free(mon_pdev);
- return QDF_STATUS_SUCCESS;
- }
- QDF_STATUS dp_mon_pdev_init(struct dp_pdev *pdev)
- {
- struct dp_soc *soc;
- if (!pdev) {
- mon_init_err("pdev is NULL");
- return QDF_STATUS_E_FAILURE;
- }
- soc = pdev->soc;
- pdev->filter = dp_mon_filter_alloc(pdev);
- if (!pdev->filter) {
- mon_init_err("%pK: Memory allocation failed for monitor filter",
- pdev);
- return QDF_STATUS_E_NOMEM;
- }
- qdf_spinlock_create(&pdev->ppdu_stats_lock);
- qdf_spinlock_create(&pdev->neighbour_peer_mutex);
- pdev->monitor_configured = false;
- pdev->mon_chan_band = REG_BAND_UNKNOWN;
- /* Monitor filter init */
- pdev->mon_filter_mode = MON_FILTER_ALL;
- TAILQ_INIT(&pdev->neighbour_peers_list);
- pdev->neighbour_peers_added = false;
- pdev->monitor_configured = false;
- /* Monitor filter init */
- pdev->mon_filter_mode = MON_FILTER_ALL;
- pdev->fp_mgmt_filter = FILTER_MGMT_ALL;
- pdev->fp_ctrl_filter = FILTER_CTRL_ALL;
- pdev->fp_data_filter = FILTER_DATA_ALL;
- pdev->mo_mgmt_filter = FILTER_MGMT_ALL;
- pdev->mo_ctrl_filter = FILTER_CTRL_ALL;
- pdev->mo_data_filter = FILTER_DATA_ALL;
- if (dp_htt_ppdu_stats_attach(pdev) != QDF_STATUS_SUCCESS)
- goto fail0;
- if (dp_mon_rings_init(soc, pdev)) {
- mon_init_err("%pK: MONITOR rings setup failed", pdev);
- goto fail1;
- }
- /* initialize sw monitor rx descriptors */
- dp_rx_pdev_mon_desc_pool_init(pdev);
- /* allocate buffers and replenish the monitor RxDMA ring */
- dp_rx_pdev_mon_buffers_alloc(pdev);
- dp_tx_ppdu_stats_attach(pdev);
- return QDF_STATUS_SUCCESS;
- fail1:
- dp_htt_ppdu_stats_detach(pdev);
- fail0:
- qdf_spinlock_destroy(&pdev->neighbour_peer_mutex);
- qdf_spinlock_destroy(&pdev->ppdu_stats_lock);
- dp_mon_filter_dealloc(pdev);
- return QDF_STATUS_E_FAILURE;
- }
- QDF_STATUS dp_mon_pdev_deinit(struct dp_pdev *pdev)
- {
- dp_tx_ppdu_stats_detach(pdev);
- dp_rx_pdev_mon_buffers_free(pdev);
- dp_rx_pdev_mon_desc_pool_deinit(pdev);
- dp_mon_rings_deinit(pdev);
- dp_htt_ppdu_stats_detach(pdev);
- qdf_spinlock_destroy(&pdev->ppdu_stats_lock);
- dp_neighbour_peers_detach(pdev);
- dp_pktlogmod_exit(pdev);
- if (pdev->filter)
- dp_mon_filter_dealloc(pdev);
- return QDF_STATUS_SUCCESS;
- }
- static struct dp_mon_ops monitor_ops = {
- .mon_soc_cfg_init = dp_mon_soc_cfg_init,
- .mon_pdev_attach = dp_mon_pdev_attach,
- .mon_pdev_detach = dp_mon_pdev_detach,
- .mon_pdev_init = dp_mon_pdev_init,
- .mon_pdev_deinit = dp_mon_pdev_deinit,
- .mon_config_debug_sniffer = dp_config_debug_sniffer,
- };
- static struct cdp_mon_ops dp_ops_mon = {
- .txrx_reset_monitor_mode = dp_reset_monitor_mode,
- /* Added support for HK advance filter */
- .txrx_set_advance_monitor_filter = dp_pdev_set_advance_monitor_filter,
- .txrx_deliver_tx_mgmt = dp_deliver_tx_mgmt,
- .config_full_mon_mode = dp_config_full_mon_mode,
- };
- static inline void dp_mon_ops_register(struct dp_mon_soc *mon_soc)
- {
- mon_soc->mon_ops = &monitor_ops;
- }
- static inline void dp_mon_cdp_ops_register(struct dp_soc *soc)
- {
- struct cdp_ops *ops = soc->cdp_soc.ops;
- if (!ops) {
- mon_init_err("cdp_ops is NULL");
- return;
- }
- ops->mon_ops = &dp_ops_mon;
- ops->cmn_drv_ops->txrx_set_monitor_mode = dp_vdev_set_monitor_mode;
- }
- QDF_STATUS dp_mon_soc_attach(struct dp_soc *soc)
- {
- struct dp_mon_soc *mon_soc;
- if (!soc) {
- mon_init_err("dp_soc is NULL");
- return QDF_STATUS_E_FAILURE;
- }
- mon_soc = (struct dp_mon_soc *)qdf_mem_malloc(sizeof(*mon_soc));
- if (!mon_soc) {
- mon_init_err("%pK: mem allocation failed", soc);
- return QDF_STATUS_E_NOMEM;
- }
- /* register monitor ops */
- dp_mon_ops_register(mon_soc);
- soc->monitor_soc = mon_soc;
- dp_mon_cdp_ops_register(soc);
- return QDF_STATUS_SUCCESS;
- }
- QDF_STATUS dp_mon_soc_detach(struct dp_soc *soc)
- {
- struct dp_mon_soc *mon_soc;
- if (!soc) {
- mon_init_err("dp_soc is NULL");
- return QDF_STATUS_E_FAILURE;
- }
- mon_soc = soc->monitor_soc;
- soc->monitor_soc = NULL;
- qdf_mem_free(mon_soc);
- return QDF_STATUS_SUCCESS;
- }
|