1 /*
2  * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
3  *
4  * Permission to use, copy, modify, and/or distribute this software for
5  * any purpose with or without fee is hereby granted, provided that the
6  * above copyright notice and this permission notice appear in all
7  * copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16  * PERFORMANCE OF THIS SOFTWARE.
17  */
18 
19 /**
20  * DOC: This file contains mcc quota event processing south bound interface
21  * API implementation
22  */
23 
24 #include <wlan_objmgr_psoc_obj.h>
25 #include <wlan_lmac_if_def.h>
26 #include "wlan_p2p_public_struct.h"
27 #include "../../core/src/wlan_p2p_main.h"
28 #include "../../core/src/wlan_p2p_mcc_quota.h"
29 #include "wlan_p2p_mcc_quota_tgt_api.h"
30 
tgt_p2p_mcc_quota_event_cb(struct wlan_objmgr_psoc * psoc,struct mcc_quota_info * event_info)31 QDF_STATUS tgt_p2p_mcc_quota_event_cb(struct wlan_objmgr_psoc *psoc,
32 				      struct mcc_quota_info *event_info)
33 {
34 	if (!event_info) {
35 		p2p_err("invalid mcc quota event information");
36 		return QDF_STATUS_E_INVAL;
37 	}
38 
39 	if (!psoc) {
40 		p2p_err("psoc context passed is NULL");
41 		return QDF_STATUS_E_INVAL;
42 	}
43 
44 	return p2p_mcc_quota_event_process(psoc, event_info);
45 }
46 
47 QDF_STATUS
tgt_p2p_register_mcc_quota_ev_handler(struct wlan_objmgr_psoc * psoc,bool reg)48 tgt_p2p_register_mcc_quota_ev_handler(struct wlan_objmgr_psoc *psoc,
49 				      bool reg)
50 {
51 	struct wlan_lmac_if_tx_ops *tx_ops;
52 	struct wlan_lmac_if_p2p_tx_ops *p2p_tx_ops;
53 	QDF_STATUS status = QDF_STATUS_E_FAILURE;
54 
55 	tx_ops = wlan_psoc_get_lmac_if_txops(psoc);
56 	if (!tx_ops) {
57 		p2p_err("invalid lmac if tx ops");
58 		return QDF_STATUS_E_FAILURE;
59 	}
60 	p2p_tx_ops = &tx_ops->p2p;
61 	if (p2p_tx_ops->reg_mcc_quota_ev_handler)
62 		status = p2p_tx_ops->reg_mcc_quota_ev_handler(psoc, reg);
63 
64 	p2p_debug("register %d mcc quota event, status:%d",
65 		  reg, status);
66 
67 	return status;
68 }
69