Jelajahi Sumber

qcacld-3.0: Process MCC quota target event

Add and Register target if API to process MCC
quota wmi event. Deliver the event to existing
interfaces.

Change-Id: Ib044a336af2f5093dffbb053e65a52a174b85154
CRs-Fixed: 3101870
Liangwei Dong 3 tahun lalu
induk
melakukan
ea23c5f897

+ 4 - 2
components/p2p/core/src/wlan_p2p_main.c

@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2017-2020 The Linux Foundation. All rights reserved.
- * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2021-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
@@ -31,6 +31,7 @@
 #include "wlan_p2p_public_struct.h"
 #include "wlan_p2p_ucfg_api.h"
 #include "wlan_p2p_tgt_api.h"
+#include "wlan_p2p_mcc_quota_tgt_api.h"
 #include "wlan_p2p_main.h"
 #include "wlan_p2p_roc.h"
 #include "wlan_p2p_off_chan_tx.h"
@@ -844,7 +845,7 @@ QDF_STATUS p2p_psoc_start(struct wlan_objmgr_psoc *soc,
 	tgt_p2p_register_lo_ev_handler(soc);
 	tgt_p2p_register_noa_ev_handler(soc);
 	tgt_p2p_register_macaddr_rx_filter_evt_handler(soc, true);
-
+	tgt_p2p_register_mcc_quota_ev_handler(soc, true);
 	/* register scan request id */
 	p2p_soc_obj->scan_req_id = ucfg_scan_register_requester(
 		soc, P2P_MODULE_NAME, tgt_p2p_scan_event_cb,
@@ -893,6 +894,7 @@ QDF_STATUS p2p_psoc_stop(struct wlan_objmgr_psoc *soc)
 	/* unrgister scan request id*/
 	ucfg_scan_unregister_requester(soc, p2p_soc_obj->scan_req_id);
 
+	tgt_p2p_register_mcc_quota_ev_handler(soc, false);
 	/* unregister p2p lo stop and noa event */
 	tgt_p2p_register_macaddr_rx_filter_evt_handler(soc, false);
 	tgt_p2p_unregister_lo_ev_handler(soc);

+ 6 - 1
components/p2p/core/src/wlan_p2p_main.h

@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2017-2020 The Linux Foundation. All rights reserved.
- * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2021-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
@@ -32,6 +32,7 @@
 #include <qdf_idr.h>
 #include <qdf_mc_timer.h>
 #include <wlan_scan_public_structs.h>
+#include "wlan_p2p_ucfg_api.h"
 
 #define MAX_QUEUE_LENGTH 20
 #define P2P_NOA_ATTR_IND 0x1090
@@ -237,6 +238,7 @@ struct p2p_param {
  * @p2p_idr:          p2p idr
  * @param:            p2p parameters to be used
  * @connection_status:Global P2P connection status
+ * @mcc_quota_ev_os_if_cb:  callback to OS IF to indicate mcc quota event
  */
 struct p2p_soc_priv_obj {
 	struct wlan_objmgr_psoc *soc;
@@ -255,6 +257,9 @@ struct p2p_soc_priv_obj {
 #ifdef WLAN_FEATURE_P2P_DEBUG
 	enum p2p_connection_status connection_status;
 #endif
+#ifdef WLAN_FEATURE_MCC_QUOTA
+	mcc_quota_event_callback mcc_quota_ev_os_if_cb;
+#endif
 };
 
 /**

+ 116 - 0
components/p2p/core/src/wlan_p2p_mcc_quota.c

@@ -0,0 +1,116 @@
+/*
+ * 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
+ * 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.
+ */
+
+/**
+ * DOC: This file contains main P2P mcc quota event process core function
+ * implementation
+ */
+
+#include <wlan_objmgr_psoc_obj.h>
+#include <wlan_objmgr_pdev_obj.h>
+#include <wlan_objmgr_vdev_obj.h>
+#include "wlan_p2p_mcc_quota_public_struct.h"
+#include "wlan_p2p_public_struct.h"
+#include "wlan_p2p_ucfg_api.h"
+#include "wlan_p2p_main.h"
+#include "wlan_p2p_mcc_quota.h"
+
+/**
+ * struct wlan_mcc_quota_context - context for vdev iterate handler
+ * @indicated: mcc quota info indicated to os
+ * @quota_info: mcc quota information
+ * @p2p_soc_obj: p2p soc object
+ */
+struct wlan_mcc_quota_context {
+	bool indicated;
+	struct mcc_quota_info *quota_info;
+	struct p2p_soc_priv_obj *p2p_soc_obj;
+};
+
+/**
+ * wlan_indicate_quota_vdev_handler() - Vdev iterate handler to indicate
+ * mcc quota event to vdev object
+ * @psoc: psoc object
+ * @obj: vdev object
+ * @args: handler context
+ *
+ * Return: void
+ */
+static void wlan_indicate_quota_vdev_handler(struct wlan_objmgr_psoc *psoc,
+					     void *obj, void *args)
+{
+	struct wlan_objmgr_vdev *vdev = obj;
+	struct wlan_mcc_quota_context *context = args;
+	struct p2p_soc_priv_obj *p2p_soc_obj = context->p2p_soc_obj;
+	enum QDF_OPMODE op_mode;
+	QDF_STATUS status;
+
+	op_mode = wlan_vdev_mlme_get_opmode(vdev);
+	if (op_mode != QDF_STA_MODE &&
+	    op_mode != QDF_SAP_MODE &&
+	    op_mode != QDF_P2P_CLIENT_MODE &&
+	    op_mode != QDF_P2P_GO_MODE)
+		return;
+
+	status = p2p_soc_obj->mcc_quota_ev_os_if_cb(psoc, vdev,
+						    context->quota_info);
+	if (status != QDF_STATUS_SUCCESS)
+		return;
+
+	context->indicated = true;
+}
+
+QDF_STATUS p2p_mcc_quota_event_process(struct wlan_objmgr_psoc *psoc,
+				       struct mcc_quota_info *event_info)
+{
+	struct p2p_soc_priv_obj *p2p_soc_obj;
+	struct wlan_mcc_quota_context context;
+
+	if (!event_info) {
+		p2p_err("invalid mcc quota event information");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	if (!psoc) {
+		p2p_err("psoc context passed is NULL");
+		return QDF_STATUS_E_INVAL;
+	}
+	p2p_soc_obj = wlan_objmgr_psoc_get_comp_private_obj(psoc,
+							    WLAN_UMAC_COMP_P2P);
+	if (!p2p_soc_obj) {
+		p2p_err("p2p soc object is NULL");
+		return QDF_STATUS_E_INVAL;
+	}
+	if (!p2p_soc_obj->mcc_quota_ev_os_if_cb) {
+		p2p_err("mcc_quota_ev_os_if_cb is NULL");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	qdf_mem_zero(&context, sizeof(struct wlan_mcc_quota_context));
+	context.quota_info = event_info;
+	context.p2p_soc_obj = p2p_soc_obj;
+	wlan_objmgr_iterate_obj_list(psoc, WLAN_VDEV_OP,
+				     wlan_indicate_quota_vdev_handler,
+				     &context, true, WLAN_P2P_ID);
+
+	if (context.indicated)
+		return QDF_STATUS_SUCCESS;
+	else
+		return p2p_soc_obj->mcc_quota_ev_os_if_cb(psoc, NULL,
+							  event_info);
+}

+ 40 - 0
components/p2p/core/src/wlan_p2p_mcc_quota.h

@@ -0,0 +1,40 @@
+/*
+ * 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
+ * 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.
+ */
+
+/**
+ * DOC: Defines main MCC Quota core functions
+ */
+
+#ifndef _WLAN_P2P_MCC_QUOTA_H_
+#define _WLAN_P2P_MCC_QUOTA_H_
+
+struct wlan_objmgr_psoc;
+struct mcc_quota_info;
+/**
+ * p2p_mcc_quota_event_process() - Process mcc quota event
+ * @psoc: psoc object
+ * @event_info: mcc quota info
+ *
+ * This function handles the target mcc quota event to indicate
+ * the quota information to existing vdev's interface.
+ *
+ * Return: QDF_STATUS_SUCCESS - in case of success
+ */
+QDF_STATUS p2p_mcc_quota_event_process(struct wlan_objmgr_psoc *psoc,
+				       struct mcc_quota_info *event_info);
+#endif

+ 74 - 0
components/p2p/dispatcher/inc/wlan_p2p_mcc_quota_public_struct.h

@@ -0,0 +1,74 @@
+/*
+ * 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
+ * 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.
+ */
+
+/**
+ * DOC: Contains mcc quota event public data structure definations
+ */
+
+#ifndef _WLAN_P2P_MCC_QUOTA_PUBLIC_STRUCT_H_
+#define _WLAN_P2P_MCC_QUOTA_PUBLIC_STRUCT_H_
+
+#include <qdf_types.h>
+
+struct wlan_objmgr_psoc;
+struct wlan_objmgr_vdev;
+
+/*
+ * Max possible unique home channel numbers that host can receive to
+ * struct mcc_quota_info from FW event. In real case, for two MACs DBS,
+ * each MAC has two unique home channels, max home channel can't exceed 4.
+ */
+#define MAX_MCC_QUOTA_CH_NUM 4
+
+/**
+ * enum mcc_quota_type - mcc channel quota type
+ * @QUOTA_TYPE_CLEAR: target exits MCC state and clear mcc quota inforamtion
+ * @QUOTA_TYPE_FIXED: channel time quota is fixed and will not be changed
+ * @QUOTA_TYPE_DYNAMIC: channel time quota is dynamic and targe may change
+ *   the quota based on the data activity
+ * @QUOTA_TYPE_UNKNOWN: unknown type
+ */
+enum mcc_quota_type {
+	QUOTA_TYPE_CLEAR,
+	QUOTA_TYPE_FIXED,
+	QUOTA_TYPE_DYNAMIC,
+	QUOTA_TYPE_UNKNOWN = 0xff
+};
+
+/**
+ * struct chan_quota - mcc channel quota
+ * @chan_mhz: frequency of the channel for which the quota is set
+ * @channel_time_quota: channel time quota expressed as percentage
+ */
+struct channel_quota {
+	uint32_t chan_mhz;
+	uint32_t channel_time_quota;
+};
+
+/**
+ * struct mcc_quota_info - mcc quota information
+ * @type: mcc quota type
+ * @num_chan_quota: number of channel quota in chan_quota
+ * @chan_quota: channel quota array
+ */
+struct mcc_quota_info {
+	enum mcc_quota_type type;
+	uint32_t num_chan_quota;
+	struct channel_quota chan_quota[MAX_MCC_QUOTA_CH_NUM];
+};
+#endif /* _WLAN_P2P_MCC_QUOTA_PUBLIC_STRUCT_H_ */

+ 65 - 0
components/p2p/dispatcher/inc/wlan_p2p_mcc_quota_tgt_api.h

@@ -0,0 +1,65 @@
+/*
+ * 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
+ * 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.
+ */
+
+/**
+ * DOC: Contains p2p mcc quota event south bound interface definitions
+ */
+
+#ifndef _WLAN_P2P_MCC_QUOTA_TGT_API_H_
+#define _WLAN_P2P_MCC_QUOTA_TGT_API_H_
+
+#include <qdf_types.h>
+
+struct wlan_objmgr_psoc;
+
+#ifdef WLAN_FEATURE_MCC_QUOTA
+/**
+ * tgt_p2p_register_mcc_quota_ev_handler() - register/unregister mcc quota
+ * wmi event handler
+ * @psoc: psoc object
+ * @reg: true for register, false for unregister
+ *
+ * This function will register or unregister mcc quota event handler
+ * in target if.
+ *
+ * Return: QDF_STATUS_SUCCESS - in case of success
+ */
+QDF_STATUS tgt_p2p_register_mcc_quota_ev_handler(struct wlan_objmgr_psoc *psoc,
+						 bool reg);
+
+/**
+ * tgt_p2p_mcc_quota_event_cb() - mcc quota event callback handler
+ * @psoc: psoc object
+ * @event_info: mcc quota event
+ *
+ * This function will be called by target if to indicate mcc quota event
+ * to stack.
+ *
+ * Return: QDF_STATUS_SUCCESS - in case of success
+ */
+QDF_STATUS  tgt_p2p_mcc_quota_event_cb(struct wlan_objmgr_psoc *psoc,
+				       struct mcc_quota_info *event_info);
+#else
+static inline
+QDF_STATUS tgt_p2p_register_mcc_quota_ev_handler(struct wlan_objmgr_psoc *psoc,
+						 bool reg)
+{
+	return QDF_STATUS_SUCCESS;
+}
+#endif
+#endif /* _WLAN_P2P_MCC_QUOTA_TGT_API_H_ */

+ 37 - 0
components/p2p/dispatcher/inc/wlan_p2p_ucfg_api.h

@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2017-2018, 2020-2021 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,7 @@ struct p2p_ps_config;
 struct p2p_lo_start;
 struct p2p_lo_event;
 struct p2p_protocol_callbacks;
+struct mcc_quota_info;
 
 /**
  * p2p_rx_callback() - Callback for rx mgmt frame
@@ -86,6 +88,20 @@ typedef void (*p2p_lo_event_callback)(void *user_data,
 typedef void (*p2p_event_callback)(void *user_data,
 	struct p2p_event *p2p_event);
 
+/**
+ * mcc_quota_event_callback() - Callback for mcc quota
+ * @psoc: psoc object
+ * @vdev: vdev object
+ * @mcc_quota: mcc quota event information
+ *
+ * Callback to notify mcc quota event.
+ *
+ * Return: None
+ */
+typedef QDF_STATUS (*mcc_quota_event_callback)(struct wlan_objmgr_psoc *psoc,
+					       struct wlan_objmgr_vdev *vdev,
+					       struct mcc_quota_info *mcc_quota);
+
 /**
  * struct p2p_start_param - p2p soc start parameters. Below callbacks
  *                          will be registered by the HDD
@@ -363,6 +379,27 @@ bool ucfg_p2p_check_random_mac(struct wlan_objmgr_psoc *soc, uint32_t vdev_id,
 QDF_STATUS ucfg_p2p_register_callbacks(struct wlan_objmgr_psoc *soc,
 	    struct p2p_protocol_callbacks *cb_obj);
 
+#ifdef WLAN_FEATURE_MCC_QUOTA
+/**
+ * ucfg_p2p_register_mcc_quota_event_os_if_cb() - Register OS IF mcc quota
+ * event callback
+ * @psoc: soc object
+ * @cb: os if callback for mcc quota event
+ *
+ * Return: QDF_STATUS_SUCCESS for success
+ */
+QDF_STATUS
+ucfg_p2p_register_mcc_quota_event_os_if_cb(struct wlan_objmgr_psoc *psoc,
+					   mcc_quota_event_callback cb);
+#else
+static inline QDF_STATUS
+ucfg_p2p_register_mcc_quota_event_os_if_cb(struct wlan_objmgr_psoc *psoc,
+					   mcc_quota_event_callback cb)
+{
+	return QDF_STATUS_SUCCESS;
+}
+#endif
+
 /**
  * ucfg_p2p_status_scan() - Show P2P connection status when scanning
  * @vdev: vdev context

+ 68 - 0
components/p2p/dispatcher/src/wlan_p2p_mcc_quota_tgt_api.c

@@ -0,0 +1,68 @@
+/*
+ * 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
+ * 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.
+ */
+
+/**
+ * DOC: This file contains mcc quota event processing south bound interface
+ * API implementation
+ */
+
+#include <wlan_objmgr_psoc_obj.h>
+#include <wlan_lmac_if_def.h>
+#include "wlan_p2p_public_struct.h"
+#include "../../core/src/wlan_p2p_main.h"
+#include "../../core/src/wlan_p2p_mcc_quota.h"
+#include "wlan_p2p_mcc_quota_tgt_api.h"
+
+QDF_STATUS tgt_p2p_mcc_quota_event_cb(struct wlan_objmgr_psoc *psoc,
+				      struct mcc_quota_info *event_info)
+{
+	if (!event_info) {
+		p2p_err("invalid mcc quota event information");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	if (!psoc) {
+		p2p_err("psoc context passed is NULL");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	return p2p_mcc_quota_event_process(psoc, event_info);
+}
+
+QDF_STATUS
+tgt_p2p_register_mcc_quota_ev_handler(struct wlan_objmgr_psoc *psoc,
+				      bool reg)
+{
+	struct wlan_lmac_if_tx_ops *tx_ops;
+	struct wlan_lmac_if_p2p_tx_ops *p2p_tx_ops;
+	QDF_STATUS status = QDF_STATUS_E_FAILURE;
+
+	tx_ops = wlan_psoc_get_lmac_if_txops(psoc);
+	if (!tx_ops) {
+		p2p_err("invalid lmac if tx ops");
+		return QDF_STATUS_E_FAILURE;
+	}
+	p2p_tx_ops = &tx_ops->p2p;
+	if (p2p_tx_ops->reg_mcc_quota_ev_handler)
+		status = p2p_tx_ops->reg_mcc_quota_ev_handler(psoc, reg);
+
+	p2p_debug("register %d mcc quota event, status:%d",
+		  reg, status);
+
+	return status;
+}

+ 25 - 0
components/p2p/dispatcher/src/wlan_p2p_ucfg_api.c

@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2017-2021 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
@@ -575,6 +576,30 @@ QDF_STATUS ucfg_p2p_register_callbacks(struct wlan_objmgr_psoc *soc,
 	return QDF_STATUS_SUCCESS;
 }
 
+#ifdef WLAN_FEATURE_MCC_QUOTA
+QDF_STATUS
+ucfg_p2p_register_mcc_quota_event_os_if_cb(struct wlan_objmgr_psoc *psoc,
+					   mcc_quota_event_callback cb)
+{
+	struct p2p_soc_priv_obj *p2p_soc_obj;
+
+	if (!psoc) {
+		p2p_err("invalid psoc");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	p2p_soc_obj = wlan_objmgr_psoc_get_comp_private_obj(psoc,
+							    WLAN_UMAC_COMP_P2P);
+	if (!p2p_soc_obj) {
+		p2p_err("p2p soc private object is NULL");
+		return QDF_STATUS_E_FAILURE;
+	}
+	p2p_soc_obj->mcc_quota_ev_os_if_cb = cb;
+
+	return QDF_STATUS_SUCCESS;
+}
+#endif
+
 QDF_STATUS ucfg_p2p_status_scan(struct wlan_objmgr_vdev *vdev)
 {
 	if (!vdev) {

+ 43 - 0
components/target_if/p2p/inc/target_if_p2p_mcc_quota.h

@@ -0,0 +1,43 @@
+/*
+ * 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
+ * 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.
+ */
+
+/**
+ * DOC: offload lmac interface APIs for P2P MCC quota event processing
+ */
+
+#ifndef _TARGET_IF_P2P_MCC_QUOTA_H_
+#define _TARGET_IF_P2P_MCC_QUOTA_H_
+
+struct wlan_lmac_if_tx_ops;
+
+#ifdef WLAN_FEATURE_MCC_QUOTA
+/**
+ * target_if_mcc_quota_register_tx_ops() - Register mcc quota TX OPS
+ * @tx_ops: lmac if transmit ops
+ *
+ * Return: None
+ */
+void
+target_if_mcc_quota_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops);
+#else
+static inline void
+target_if_mcc_quota_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
+{
+}
+#endif
+#endif /* _TARGET_IF_P2P_MCC_QUOTA_H_ */

+ 4 - 0
components/target_if/p2p/src/target_if_p2p.c

@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2017-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
@@ -24,6 +25,7 @@
 #include <wlan_p2p_public_struct.h>
 #include "target_if.h"
 #include "target_if_p2p.h"
+#include "target_if_p2p_mcc_quota.h"
 #include "init_deinit_lmac.h"
 
 static inline struct wlan_lmac_if_p2p_rx_ops *
@@ -474,6 +476,8 @@ void target_if_p2p_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
 		target_if_p2p_register_macaddr_rx_filter_evt_handler;
 	p2p_tx_ops->set_mac_addr_rx_filter_cmd =
 		target_if_p2p_set_mac_addr_rx_filter_cmd;
+	target_if_mcc_quota_register_tx_ops(tx_ops);
+
 	/* register P2P listen offload callbacks */
 	target_if_p2p_lo_register_tx_ops(p2p_tx_ops);
 }

+ 143 - 0
components/target_if/p2p/src/target_if_p2p_mcc_quota.c

@@ -0,0 +1,143 @@
+/*
+ * 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
+ * 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.
+ */
+
+/**
+ * DOC: offload lmac interface APIs implementation for P2P mcc quota event
+ * processing
+ */
+
+#include <wmi_unified_api.h>
+#include "wlan_p2p_mcc_quota_public_struct.h"
+#include "target_if.h"
+#include "target_if_p2p_mcc_quota.h"
+
+/**
+ * target_if_mcc_quota_event_handler() - WMI callback for mcc_quota
+ * @scn:       pointer to scn
+ * @event_buf: event buffer
+ * @len:       buffer length
+ *
+ * This function gets called from WMI when triggered WMI event
+ * WMI_RESMGR_CHAN_TIME_QUOTA_CHANGED_EVENTID
+ *
+ * Return: 0 - success, others - failure
+ */
+static int target_if_mcc_quota_event_handler(ol_scn_t scn, uint8_t *data,
+					     uint32_t datalen)
+{
+	struct wlan_objmgr_psoc *psoc;
+	struct wmi_unified *wmi_handle;
+	struct mcc_quota_info *event_info;
+	struct wlan_lmac_if_rx_ops *rx_ops;
+	struct wlan_lmac_if_p2p_rx_ops *p2p_rx_ops;
+	QDF_STATUS status = QDF_STATUS_E_FAILURE;
+
+	target_if_debug("scn:%pK, data:%pK, datalen:%d", scn, data, datalen);
+
+	if (!scn || !data) {
+		target_if_err("scn: 0x%pK, data: 0x%pK", scn, data);
+		return -EINVAL;
+	}
+
+	psoc = target_if_get_psoc_from_scn_hdl(scn);
+	if (!psoc) {
+		target_if_err("null psoc");
+		return -EINVAL;
+	}
+
+	wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+	if (!wmi_handle) {
+		target_if_err("null wmi handle");
+		return -EINVAL;
+	}
+
+	event_info = qdf_mem_malloc(sizeof(*event_info));
+	if (!event_info)
+		return -ENOMEM;
+
+	if (wmi_extract_mcc_quota_ev_param(wmi_handle, data,
+					   event_info)) {
+		target_if_err("failed to extract mcc quota event");
+		qdf_mem_free(event_info);
+		return -EINVAL;
+	}
+	rx_ops = wlan_psoc_get_lmac_if_rxops(psoc);
+	if (!rx_ops) {
+		target_if_err("failed to get soc rx ops");
+		qdf_mem_free(event_info);
+		return -EINVAL;
+	}
+	p2p_rx_ops = &rx_ops->p2p;
+	if (p2p_rx_ops->mcc_quota_ev_handler) {
+		status = p2p_rx_ops->mcc_quota_ev_handler(psoc, event_info);
+		if (QDF_IS_STATUS_ERROR(status))
+			target_if_debug("quota event handler, status:%d",
+					status);
+	} else {
+		target_if_debug("no valid mcc quota event handler");
+	}
+	qdf_mem_free(event_info);
+
+	return qdf_status_to_os_return(status);
+}
+
+/**
+ * target_if_register_mcc_quota_event_handler() - Register or unregister
+ * mcc quota wmi event handler
+ * @psoc: psoc object
+ * @reg: register or unregister flag
+ *
+ * Return: QDF_STATUS_SUCCESS - in case of success
+ */
+static QDF_STATUS
+target_if_register_mcc_quota_event_handler(struct wlan_objmgr_psoc *psoc,
+					   bool reg)
+{
+	QDF_STATUS status;
+	wmi_unified_t wmi_handle = get_wmi_unified_hdl_from_psoc(psoc);
+
+	if (!wmi_handle) {
+		target_if_err("Invalid wmi handle");
+		return QDF_STATUS_E_INVAL;
+	}
+	if (reg) {
+		status = wmi_unified_register_event_handler(wmi_handle,
+							    wmi_resmgr_chan_time_quota_changed_eventid,
+							    target_if_mcc_quota_event_handler,
+							    WMI_RX_SERIALIZER_CTX);
+
+		target_if_debug("wmi register mcc_quota event handle, status:%d",
+				status);
+	} else {
+		status = wmi_unified_unregister_event_handler(wmi_handle,
+							      wmi_resmgr_chan_time_quota_changed_eventid);
+
+		target_if_debug("wmi unregister mcc_quota event handle, status:%d",
+				status);
+	}
+
+	return status;
+}
+
+void target_if_mcc_quota_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops)
+{
+	struct wlan_lmac_if_p2p_tx_ops *p2p_tx_ops = &tx_ops->p2p;
+
+	p2p_tx_ops->reg_mcc_quota_ev_handler =
+			target_if_register_mcc_quota_event_handler;
+}