diff --git a/umac/global_umac_dispatcher/lmac_if/inc/wlan_lmac_if_def.h b/umac/global_umac_dispatcher/lmac_if/inc/wlan_lmac_if_def.h index 3d2c113320..bcfa36c1b7 100644 --- a/umac/global_umac_dispatcher/lmac_if/inc/wlan_lmac_if_def.h +++ b/umac/global_umac_dispatcher/lmac_if/inc/wlan_lmac_if_def.h @@ -551,6 +551,7 @@ struct p2p_set_mac_filter; * @reg_mac_addr_rx_filter_handler: function pointer to register/unregister * set mac addr status event callback. * @set_mac_addr_rx_filter_cmd: function pointer to set mac addr rx filter + * @reg_mcc_quota_ev_handler: function to register mcc_quota event handler */ struct wlan_lmac_if_p2p_tx_ops { QDF_STATUS (*set_ps)(struct wlan_objmgr_psoc *psoc, @@ -576,6 +577,10 @@ struct wlan_lmac_if_p2p_tx_ops { QDF_STATUS (*set_mac_addr_rx_filter_cmd)( struct wlan_objmgr_psoc *psoc, struct p2p_set_mac_filter *param); +#ifdef WLAN_FEATURE_MCC_QUOTA + QDF_STATUS (*reg_mcc_quota_ev_handler)(struct wlan_objmgr_psoc *psoc, + bool reg); +#endif }; #endif @@ -1598,6 +1603,7 @@ struct wlan_lmac_if_reg_rx_ops { struct p2p_noa_info; struct p2p_lo_event; struct p2p_set_mac_filter_evt; +struct mcc_quota_info; /** * struct wlan_lmac_if_p2p_rx_ops - structure of rx function pointers @@ -1606,6 +1612,7 @@ struct p2p_set_mac_filter_evt; * @noa_ev_handler: function pointer to give noa event * @add_mac_addr_filter_evt_handler: function pointer to process add mac addr * rx filter event + * @mcc_quota_ev_handler: function pointer to receive mcc quota event */ struct wlan_lmac_if_p2p_rx_ops { #ifdef FEATURE_P2P_LISTEN_OFFLOAD @@ -1617,7 +1624,10 @@ struct wlan_lmac_if_p2p_rx_ops { QDF_STATUS (*add_mac_addr_filter_evt_handler)( struct wlan_objmgr_psoc *psoc, struct p2p_set_mac_filter_evt *event_info); - +#ifdef WLAN_FEATURE_MCC_QUOTA + QDF_STATUS (*mcc_quota_ev_handler)(struct wlan_objmgr_psoc *psoc, + struct mcc_quota_info *event_info); +#endif }; #endif diff --git a/umac/global_umac_dispatcher/lmac_if/src/wlan_lmac_if.c b/umac/global_umac_dispatcher/lmac_if/src/wlan_lmac_if.c index eb3ef3642e..7e5f700a86 100644 --- a/umac/global_umac_dispatcher/lmac_if/src/wlan_lmac_if.c +++ b/umac/global_umac_dispatcher/lmac_if/src/wlan_lmac_if.c @@ -459,24 +459,41 @@ static void wlan_lmac_if_umac_reg_rx_ops_register( } #ifdef CONVERGED_P2P_ENABLE -#ifdef FEATURE_P2P_LISTEN_OFFLOAD -static void wlan_lmac_if_umac_rx_ops_register_p2p( - struct wlan_lmac_if_rx_ops *rx_ops) +#ifdef WLAN_FEATURE_MCC_QUOTA +static inline void +wlan_lmac_if_umac_rx_ops_register_p2p_mcc_quota(struct wlan_lmac_if_rx_ops *rx_ops) { - rx_ops->p2p.lo_ev_handler = tgt_p2p_lo_event_cb; - rx_ops->p2p.noa_ev_handler = tgt_p2p_noa_event_cb; - rx_ops->p2p.add_mac_addr_filter_evt_handler = - tgt_p2p_add_mac_addr_status_event_cb; + rx_ops->p2p.mcc_quota_ev_handler = tgt_p2p_mcc_quota_event_cb; } #else +static inline void wlan_lmac_if_umac_rx_ops_register_p2p_mcc_quota( + struct wlan_lmac_if_rx_ops *rx_ops) +{ +} +#endif + +#ifdef FEATURE_P2P_LISTEN_OFFLOAD +static inline void +wlan_lmac_if_umac_rx_ops_register_p2p_listen_offload(struct wlan_lmac_if_rx_ops *rx_ops) +{ + rx_ops->p2p.lo_ev_handler = tgt_p2p_lo_event_cb; +} +#else +static inline void +wlan_lmac_if_umac_rx_ops_register_p2p_listen_offload(struct wlan_lmac_if_rx_ops *rx_ops) +{ +} +#endif + static void wlan_lmac_if_umac_rx_ops_register_p2p( struct wlan_lmac_if_rx_ops *rx_ops) { + wlan_lmac_if_umac_rx_ops_register_p2p_listen_offload(rx_ops); rx_ops->p2p.noa_ev_handler = tgt_p2p_noa_event_cb; rx_ops->p2p.add_mac_addr_filter_evt_handler = tgt_p2p_add_mac_addr_status_event_cb; + wlan_lmac_if_umac_rx_ops_register_p2p_mcc_quota(rx_ops); } -#endif #else static void wlan_lmac_if_umac_rx_ops_register_p2p( struct wlan_lmac_if_rx_ops *rx_ops) diff --git a/wmi/inc/wmi_unified_concurrency_api.h b/wmi/inc/wmi_unified_concurrency_api.h index 2f2e968ed4..cf30667053 100644 --- a/wmi/inc/wmi_unified_concurrency_api.h +++ b/wmi/inc/wmi_unified_concurrency_api.h @@ -1,5 +1,6 @@ /* * Copyright (c) 2013-2019 The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. 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 @@ -36,6 +37,20 @@ QDF_STATUS wmi_unified_set_mcc_channel_time_quota_cmd( uint32_t adapter_1_chan_freq, uint32_t adapter_1_quota, uint32_t adapter_2_chan_freq); +#ifdef WLAN_FEATURE_MCC_QUOTA +/** + * wmi_extract_mcc_quota_ev_param() - extract mcc_quota param from wmi event + * @wmi_handle: wmi handle + * @evt_buf: pointer to event buffer + * @param: Pointer to hold mcc_quota param + * + * Return: QDF_STATUS_SUCCESS on success or error code + */ +QDF_STATUS wmi_extract_mcc_quota_ev_param(wmi_unified_t wmi_handle, + void *evt_buf, + struct mcc_quota_info *param); +#endif + /** * wmi_unified_set_mcc_channel_time_latency_cmd() - set MCC channel time latency * @wmi_handle: wmi handle diff --git a/wmi/inc/wmi_unified_param.h b/wmi/inc/wmi_unified_param.h index 0f039ea220..ad7d06dee3 100644 --- a/wmi/inc/wmi_unified_param.h +++ b/wmi/inc/wmi_unified_param.h @@ -4894,6 +4894,9 @@ typedef enum { #endif #ifdef WLAN_FEATURE_11BE_MLO wmi_vdev_quiet_offload_eventid, +#endif +#ifdef WLAN_FEATURE_MCC_QUOTA + wmi_resmgr_chan_time_quota_changed_eventid, #endif wmi_events_max, } wmi_conv_event_id; diff --git a/wmi/inc/wmi_unified_priv.h b/wmi/inc/wmi_unified_priv.h index 90901ba623..118c6025db 100644 --- a/wmi/inc/wmi_unified_priv.h +++ b/wmi/inc/wmi_unified_priv.h @@ -720,6 +720,12 @@ QDF_STATUS (*send_set_mcc_channel_time_latency_cmd) QDF_STATUS (*send_set_enable_disable_mcc_adaptive_scheduler_cmd)( wmi_unified_t wmi_handle, uint32_t mcc_adaptive_scheduler, uint32_t pdev_id); + +#ifdef WLAN_FEATURE_MCC_QUOTA +QDF_STATUS (*extract_mcc_quota_ev_param)(wmi_unified_t wmi_handle, + void *evt_buf, + struct mcc_quota_info *param); +#endif #endif /* WMI_CONCURRENCY_SUPPORT */ QDF_STATUS (*send_p2p_go_set_beacon_ie_cmd)(wmi_unified_t wmi_handle, diff --git a/wmi/src/wmi_unified_concurrency_api.c b/wmi/src/wmi_unified_concurrency_api.c index b8dde1163b..49e9a7fb85 100644 --- a/wmi/src/wmi_unified_concurrency_api.c +++ b/wmi/src/wmi_unified_concurrency_api.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2013-2019 The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. 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 @@ -59,3 +60,20 @@ QDF_STATUS wmi_unified_set_mcc_channel_time_quota_cmd( return QDF_STATUS_E_FAILURE; } +#ifdef WLAN_FEATURE_MCC_QUOTA +QDF_STATUS wmi_extract_mcc_quota_ev_param(wmi_unified_t wmi_handle, + void *evt_buf, + struct mcc_quota_info *param) +{ + if (!wmi_handle) { + wmi_err("wmi handle is null"); + return QDF_STATUS_E_INVAL; + } + + if (wmi_handle->ops->extract_mcc_quota_ev_param) + return wmi_handle->ops->extract_mcc_quota_ev_param( + wmi_handle, evt_buf, param); + + return QDF_STATUS_E_FAILURE; +} +#endif diff --git a/wmi/src/wmi_unified_concurrency_tlv.c b/wmi/src/wmi_unified_concurrency_tlv.c index 9f7efb37bb..079824081e 100644 --- a/wmi/src/wmi_unified_concurrency_tlv.c +++ b/wmi/src/wmi_unified_concurrency_tlv.c @@ -1,5 +1,6 @@ /* * Copyright (c) 2013-2020 The Linux Foundation. All rights reserved. + * Copyright (c) 2022 Qualcomm Innovation Center, Inc. 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 @@ -228,6 +229,101 @@ static QDF_STATUS send_set_mcc_channel_time_quota_cmd_tlv( return ret; } +#ifdef WLAN_FEATURE_MCC_QUOTA +/** + * convert_to_host_quota_type() - convert wmi quota type to host quota type + * @quota_type: wmi target quota type + * + * Return: enum mcc_quota_type + */ +static enum mcc_quota_type convert_to_host_quota_type(uint32_t quota_type) +{ + switch (quota_type) { + case WMI_RESMGR_QUOTA_TYPE_CLEAR: + return QUOTA_TYPE_CLEAR; + case WMI_RESMGR_QUOTA_TYPE_FIXED: + return QUOTA_TYPE_FIXED; + case WMI_RESMGR_QUOTA_TYPE_DYNAMIC: + return QUOTA_TYPE_DYNAMIC; + default: + wmi_err("mcc quota unknown quota type %d", quota_type); + return QUOTA_TYPE_UNKNOWN; + } +} + +/** + * extract_mcc_quota_ev_param_tlv() - extract mcc quota information from wmi + * event + * @wmi_handle: wmi handle + * @param evt_buf: pointer to event buffer + * @param param: Pointer to hold mcc quota info + * + * Return: QDF_STATUS_SUCCESS for success or error code + */ +static QDF_STATUS +extract_mcc_quota_ev_param_tlv(wmi_unified_t wmi_handle, + void *evt_buf, struct mcc_quota_info *param) +{ + WMI_RESMGR_CHAN_TIME_QUOTA_CHANGED_EVENTID_param_tlvs *param_tlvs; + wmi_resmgr_chan_time_quota_changed_event_fixed_param *fixed_param; + uint8_t i; + wmi_resmgr_chan_time_quota_tlv *wmi_mcc_quota_info; + + if (!param) { + wmi_err("mcc quota information param is null"); + return QDF_STATUS_E_INVAL; + } + + param_tlvs = evt_buf; + if (!param_tlvs || !param_tlvs->fixed_param) { + wmi_err("Invalid mcc quota event buffer"); + return QDF_STATUS_E_INVAL; + } + fixed_param = param_tlvs->fixed_param; + + wmi_debug("mcc quota type %d, num %d", + fixed_param->quota_type, param_tlvs->num_chan_quota); + + param->type = convert_to_host_quota_type(fixed_param->quota_type); + if (param->type == QUOTA_TYPE_UNKNOWN) + return QDF_STATUS_E_INVAL; + + if (!param_tlvs->chan_quota) { + param->num_chan_quota = 0; + return QDF_STATUS_SUCCESS; + } + + if (param_tlvs->num_chan_quota > MAX_MCC_QUOTA_CH_NUM) + wmi_warn("mcc quota num %d unexpected", + param_tlvs->num_chan_quota); + param->num_chan_quota = qdf_min(param_tlvs->num_chan_quota, + (uint32_t)MAX_MCC_QUOTA_CH_NUM); + wmi_mcc_quota_info = param_tlvs->chan_quota; + for (i = 0; i < param->num_chan_quota; i++) { + param->chan_quota[i].chan_mhz = + wmi_mcc_quota_info[i].chan_time_quota.chan_mhz; + param->chan_quota[i].channel_time_quota = + wmi_mcc_quota_info[i].chan_time_quota.channel_time_quota; + wmi_debug("mcc quota [%d] chan %d, quota %d", + i, param->chan_quota[i].chan_mhz, + param->chan_quota[i].channel_time_quota); + } + + return QDF_STATUS_SUCCESS; +} + +static void wmi_mcc_quota_evt_attach_tlv(wmi_unified_t wmi_handle) +{ + struct wmi_ops *ops = wmi_handle->ops; + + ops->extract_mcc_quota_ev_param = extract_mcc_quota_ev_param_tlv; +} +#else +static inline void wmi_mcc_quota_evt_attach_tlv(wmi_unified_t wmi_handle) +{ +} +#endif + void wmi_concurrency_attach_tlv(wmi_unified_t wmi_handle) { struct wmi_ops *ops = wmi_handle->ops; @@ -238,4 +334,5 @@ void wmi_concurrency_attach_tlv(wmi_unified_t wmi_handle) send_set_mcc_channel_time_latency_cmd_tlv; ops->send_set_mcc_channel_time_quota_cmd = send_set_mcc_channel_time_quota_cmd_tlv; + wmi_mcc_quota_evt_attach_tlv(wmi_handle); } diff --git a/wmi/src/wmi_unified_tlv.c b/wmi/src/wmi_unified_tlv.c index 13f850bace..7fdc6225c7 100644 --- a/wmi/src/wmi_unified_tlv.c +++ b/wmi/src/wmi_unified_tlv.c @@ -17998,6 +17998,10 @@ event_ids[wmi_roam_scan_chan_list_id] = event_ids[wmi_vdev_quiet_offload_eventid] = WMI_QUIET_HANDLING_EVENTID; #endif +#ifdef WLAN_FEATURE_MCC_QUOTA + event_ids[wmi_resmgr_chan_time_quota_changed_eventid] = + WMI_RESMGR_CHAN_TIME_QUOTA_CHANGED_EVENTID; +#endif } #ifdef WLAN_FEATURE_LINK_LAYER_STATS