From a71b36fc0ad407cecb54da946c883828de67c960 Mon Sep 17 00:00:00 2001 From: Alok Kumar Date: Sun, 8 Sep 2019 20:16:19 +0530 Subject: [PATCH] qcacld-3.0: Register callbacks for packet capture Add callbacks to register pktcapture Rx Ops and pktcapture adapter context in pdev for packet capture mode. Change-Id: Iefbb24c364dfb460788f7512dee1a6ec4d2b29c1 CRs-Fixed: 2528553 --- core/hdd/inc/wlan_hdd_tx_rx.h | 32 +++++++++++++++++++++++++++++++- core/hdd/src/wlan_hdd_main.c | 27 ++++++++++++++++++++++----- core/hdd/src/wlan_hdd_p2p.c | 1 + core/hdd/src/wlan_hdd_tx_rx.c | 32 ++++++++++++++++++++++++++++++++ 4 files changed, 86 insertions(+), 6 deletions(-) diff --git a/core/hdd/inc/wlan_hdd_tx_rx.h b/core/hdd/inc/wlan_hdd_tx_rx.h index 7c1a50383ec7..3c704a6466cd 100644 --- a/core/hdd/inc/wlan_hdd_tx_rx.h +++ b/core/hdd/inc/wlan_hdd_tx_rx.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2019 The Linux Foundation. All rights reserved. + * Copyright (c) 2013-2020 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 @@ -326,6 +326,36 @@ int hdd_set_mon_rx_cb(struct net_device *dev) } #endif +#ifdef WLAN_FEATURE_PKT_CAPTURE +/** + * hdd_set_pktcapture_cb() - Set pkt capture mode callback + * @dev: Pointer to net_device structure + * @pdev_id: pdev id + * + * Return: 0 on success; non-zero for failure + */ +int hdd_set_pktcapture_cb(struct net_device *dev, uint8_t pdev_id); + +/** + * hdd_reset_pktcapture_cb() - Reset pkt capture mode callback + * @pdev_id: pdev id + * + * Return: None + */ +void hdd_reset_pktcapture_cb(uint8_t pdev_id); +#else +static inline +int hdd_set_pktcapture_cb(struct net_device *dev, uint8_t pdev_id) +{ + return -ENOTSUPP; +} + +static inline +void hdd_reset_pktcapture_cb(uint8_t pdev_id) +{ +} +#endif /* WLAN_FEATURE_PKT_CAPTURE */ + void hdd_send_rps_ind(struct hdd_adapter *adapter); void hdd_send_rps_disable_ind(struct hdd_adapter *adapter); void wlan_hdd_classify_pkt(struct sk_buff *skb); diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index e3e4e5e2cf78..d1d9892439e5 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -2564,6 +2564,8 @@ static int __hdd_pktcapture_open(struct net_device *dev) hdd_mon_mode_ether_setup(dev); + ret = hdd_set_pktcapture_cb(dev, OL_TXRX_PDEV_ID); + if (!ret) set_bit(DEVICE_IFACE_OPENED, &adapter->event_flags); @@ -2571,7 +2573,7 @@ static int __hdd_pktcapture_open(struct net_device *dev) } /** - * hdd_pktcapture_open() - Wrapper function for __hdd_mon_open to + * hdd_pktcapture_open() - Wrapper function for hdd_pktcapture_open to * protect it from SSR * @dev: Pointer to net_device structure * @@ -3771,10 +3773,12 @@ static int __hdd_stop(struct net_device *dev) mac_handle = hdd_ctx->mac_handle; - hdd_debug("Disabling Auto Power save timer"); - sme_ps_disable_auto_ps_timer( - mac_handle, - adapter->vdev_id); + if (!wlan_hdd_is_session_type_monitor(adapter->device_mode)) { + hdd_debug("Disabling Auto Power save timer"); + sme_ps_disable_auto_ps_timer( + mac_handle, + adapter->vdev_id); + } /* * Disable TX on the interface, after this hard_start_xmit() will not @@ -3790,6 +3794,9 @@ static int __hdd_stop(struct net_device *dev) if (adapter->device_mode == QDF_STA_MODE) hdd_lpass_notify_stop(hdd_ctx); + if (wlan_hdd_is_session_type_monitor(adapter->device_mode)) + hdd_reset_pktcapture_cb(OL_TXRX_PDEV_ID); + /* * NAN data interface is different in some sense. The traffic on NDI is * bursty in nature and depends on the need to transfer. The service @@ -7148,6 +7155,12 @@ QDF_STATUS hdd_start_all_adapters(struct hdd_context *hdd_ctx) hdd_delete_sta(adapter); break; case QDF_MONITOR_MODE: + if (wlan_hdd_is_session_type_monitor( + QDF_MONITOR_MODE)) { + hdd_set_pktcapture_cb(adapter->dev, + OL_TXRX_PDEV_ID); + break; + } chan = wlan_reg_freq_to_chan(hdd_ctx->pdev, adapter->mon_chan_freq); hdd_start_station_adapter(adapter); @@ -7921,6 +7934,10 @@ void hdd_wlan_exit(struct hdd_context *hdd_ctx) */ hdd_abort_mac_scan_all_adapters(hdd_ctx); hdd_abort_sched_scan_all_adapters(hdd_ctx); + + if (wlan_hdd_is_session_type_monitor(QDF_MONITOR_MODE)) + hdd_reset_pktcapture_cb(OL_TXRX_PDEV_ID); + hdd_stop_all_adapters(hdd_ctx); hdd_deinit_all_adapters(hdd_ctx, false); } diff --git a/core/hdd/src/wlan_hdd_p2p.c b/core/hdd/src/wlan_hdd_p2p.c index b3a3984a52e1..f0f254d2bd40 100644 --- a/core/hdd/src/wlan_hdd_p2p.c +++ b/core/hdd/src/wlan_hdd_p2p.c @@ -899,6 +899,7 @@ int __wlan_hdd_del_virtual_intf(struct wiphy *wiphy, struct wireless_dev *wdev) } else if (wlan_hdd_is_session_type_monitor( adapter->device_mode)) { wlan_hdd_del_monitor(hdd_ctx, adapter, TRUE); + hdd_reset_pktcapture_cb(OL_TXRX_PDEV_ID); } else { wlan_hdd_release_intf_addr(hdd_ctx, adapter->mac_addr.bytes); diff --git a/core/hdd/src/wlan_hdd_tx_rx.c b/core/hdd/src/wlan_hdd_tx_rx.c index c81dc6d606e6..c3d6959ccc9e 100644 --- a/core/hdd/src/wlan_hdd_tx_rx.c +++ b/core/hdd/src/wlan_hdd_tx_rx.c @@ -48,6 +48,7 @@ #include #include #include +#include #include "wlan_hdd_nan_datapath.h" #include "pld_common.h" #include @@ -2710,6 +2711,37 @@ void hdd_print_netdev_txq_status(struct net_device *dev) } } +#ifdef WLAN_FEATURE_PKT_CAPTURE +/** + * hdd_set_pktcapture_cb() - Set pkt capture mode callback + * @dev: Pointer to net_device structure + * @pdev_id: pdev id + * + * Return: 0 on success; non-zero for failure + */ +int hdd_set_pktcapture_cb(struct net_device *dev, uint8_t pdev_id) +{ + struct hdd_adapter *adapter = WLAN_HDD_GET_PRIV_PTR(dev); + void *soc = cds_get_context(QDF_MODULE_ID_SOC); + + return cdp_register_pktcapture_cb(soc, pdev_id, adapter, + hdd_mon_rx_packet_cbk); +} + +/** + * hdd_reset_pktcapture_cb() - Reset pkt capture mode callback + * @pdev_id: pdev id + * + * Return: None + */ +void hdd_reset_pktcapture_cb(uint8_t pdev_id) +{ + void *soc = cds_get_context(QDF_MODULE_ID_SOC); + + cdp_deregister_pktcapture_cb(soc, pdev_id); +} +#endif /* WLAN_FEATURE_PKT_CAPTURE */ + #ifdef FEATURE_MONITOR_MODE_SUPPORT /** * hdd_set_mon_rx_cb() - Set Monitor mode Rx callback