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 6f6ec36c9a9b..4fdad87bd43f 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 @@ -75,6 +75,11 @@ struct mgmt_offload_event_params { uint8_t tx_retry_cnt; }; +struct smu_event_params { + uint32_t vdev_id; + int32_t rx_avg_rssi; +}; + /** * struct pkt_capture_callbacks - callbacks to non-converged driver * @get_rmf_status: callback to get rmf status @@ -105,12 +110,18 @@ struct wlan_pkt_capture_tx_ops { * pointers for packet capture component * @pkt_capture_register_ev_handlers: register mgmt offload event * @pkt_capture_unregister_ev_handlers: unregister mgmt offload event + * @pkt_capture_register_smart_monitor_event: register smu event + * @pkt_capture_unregister_smart_monitor_event: unregister smu event */ struct wlan_pkt_capture_rx_ops { QDF_STATUS (*pkt_capture_register_ev_handlers) (struct wlan_objmgr_psoc *psoc); QDF_STATUS (*pkt_capture_unregister_ev_handlers) (struct wlan_objmgr_psoc *psoc); + QDF_STATUS (*pkt_capture_register_smart_monitor_event) + (struct wlan_objmgr_psoc *psoc); + QDF_STATUS (*pkt_capture_unregister_smart_monitor_event) + (struct wlan_objmgr_psoc *psoc); }; #endif /* _WLAN_PKT_CAPTURE_PUBLIC_STRUCTS_H_ */ diff --git a/components/pkt_capture/dispatcher/src/wlan_pkt_capture_tgt_api.c b/components/pkt_capture/dispatcher/src/wlan_pkt_capture_tgt_api.c index 69c1e95e9b6c..ee09bd3afb78 100644 --- a/components/pkt_capture/dispatcher/src/wlan_pkt_capture_tgt_api.c +++ b/components/pkt_capture/dispatcher/src/wlan_pkt_capture_tgt_api.c @@ -49,6 +49,10 @@ tgt_pkt_capture_register_ev_handler(struct wlan_objmgr_vdev *vdev) if (QDF_IS_STATUS_ERROR(status)) pkt_capture_err("Unable to register mgmt offload handler"); + status = rx_ops->pkt_capture_register_smart_monitor_event(psoc); + if (QDF_IS_STATUS_ERROR(status)) + pkt_capture_err("Unable to register smart monitor handler"); + return status; } @@ -81,6 +85,10 @@ tgt_pkt_capture_unregister_ev_handler(struct wlan_objmgr_vdev *vdev) if (QDF_IS_STATUS_ERROR(status)) pkt_capture_err("Unable to register mgmt offload handler"); + status = rx_ops->pkt_capture_unregister_smart_monitor_event(psoc); + if (QDF_IS_STATUS_ERROR(status)) + pkt_capture_err("Unable to unregister smart monitor handler"); + return status; } diff --git a/components/target_if/pkt_capture/src/target_if_pkt_capture.c b/components/target_if/pkt_capture/src/target_if_pkt_capture.c index 86567f7e8105..d74cbb33d4ff 100644 --- a/components/target_if/pkt_capture/src/target_if_pkt_capture.c +++ b/components/target_if/pkt_capture/src/target_if_pkt_capture.c @@ -23,6 +23,7 @@ */ #include +#include #include #include #include @@ -276,6 +277,121 @@ target_if_unregister_mgmt_data_offload_event(struct wlan_objmgr_psoc *psoc) return status; } +#ifdef WLAN_FEATURE_PKT_CAPTURE_V2 +static int +target_if_smart_monitor_event_handler(void *handle, uint8_t *data, + uint32_t len) +{ + struct smu_event_params params; + struct wmi_unified *wmi_handle; + struct wlan_objmgr_psoc *psoc; + QDF_STATUS status; + + psoc = target_if_get_psoc_from_scn_hdl(handle); + if (!psoc) { + pkt_capture_err("psoc is NULL"); + return -EINVAL; + } + + wmi_handle = get_wmi_unified_hdl_from_psoc(psoc); + if (!wmi_handle) { + target_if_err("Invalid WMI handle"); + return -EINVAL; + } + + if (!(ucfg_pkt_capture_get_pktcap_mode(psoc) & + PKT_CAPTURE_MODE_MGMT_ONLY)) + return -EINVAL; + + status = wmi_unified_extract_smart_monitor_event(wmi_handle, data, + ¶ms); + if (QDF_IS_STATUS_ERROR(status)) { + pkt_capture_err("Extract smart monitor event failed"); + return -EINVAL; + } + + return 0; +} + +/** + * target_if_register_smart_monitor_event() - Register smu event + * @psoc: wlan psoc object + * + * Return: QDF_STATUS + */ +static QDF_STATUS +target_if_register_smart_monitor_event(struct wlan_objmgr_psoc *psoc) +{ + wmi_unified_t wmi_handle; + + if (!psoc) { + pkt_capture_err("psoc got NULL"); + return QDF_STATUS_E_FAILURE; + } + wmi_handle = get_wmi_unified_hdl_from_psoc(psoc); + + if (!wmi_handle) { + pkt_capture_err("wmi_handle is NULL"); + return QDF_STATUS_E_FAILURE; + } + + if ((ucfg_pkt_capture_get_mode(psoc) != PACKET_CAPTURE_MODE_DISABLE) && + wmi_service_enabled(wmi_handle, + wmi_service_packet_capture_support)) { + uint8_t status; + + status = wmi_unified_register_event_handler( + wmi_handle, + wmi_vdev_smart_monitor_event_id, + target_if_smart_monitor_event_handler, + WMI_RX_WORK_CTX); + if (status) { + pkt_capture_err("Failed to register smart monitor handler"); + return QDF_STATUS_E_FAILURE; + } + } + + return QDF_STATUS_SUCCESS; +} + +/** + * target_if_unregister_smart_monitor_event() - Unregister smu event + * @psoc: wlan psoc object + * + * Return: QDF_STATUS + */ +static QDF_STATUS +target_if_unregister_smart_monitor_event(struct wlan_objmgr_psoc *psoc) +{ + wmi_unified_t wmi_handle; + QDF_STATUS status; + + wmi_handle = get_wmi_unified_hdl_from_psoc(psoc); + if (!wmi_handle) { + pkt_capture_err("Invalid wmi handle"); + return QDF_STATUS_E_INVAL; + } + + status = wmi_unified_unregister_event(wmi_handle, + wmi_vdev_smart_monitor_event_id); + if (status) + pkt_capture_err("unregister smart monitor event handler failed"); + + return status; +} +#else +static QDF_STATUS +target_if_register_smart_monitor_event(struct wlan_objmgr_psoc *psoc) +{ + return QDF_STATUS_SUCCESS; +} + +static QDF_STATUS +target_if_unregister_smart_monitor_event(struct wlan_objmgr_psoc *psoc) +{ + return QDF_STATUS_SUCCESS; +} +#endif void target_if_pkt_capture_register_rx_ops(struct wlan_pkt_capture_rx_ops *rx_ops) { @@ -289,6 +405,12 @@ target_if_pkt_capture_register_rx_ops(struct wlan_pkt_capture_rx_ops *rx_ops) rx_ops->pkt_capture_unregister_ev_handlers = target_if_unregister_mgmt_data_offload_event; + + rx_ops->pkt_capture_register_smart_monitor_event = + target_if_register_smart_monitor_event; + + rx_ops->pkt_capture_unregister_smart_monitor_event = + target_if_unregister_smart_monitor_event; } void