1*5113495bSYour Name /*
2*5113495bSYour Name * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
3*5113495bSYour Name *
4*5113495bSYour Name * Permission to use, copy, modify, and/or distribute this software for any
5*5113495bSYour Name * purpose with or without fee is hereby granted, provided that the above
6*5113495bSYour Name * copyright notice and this permission notice appear in all copies.
7*5113495bSYour Name *
8*5113495bSYour Name * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9*5113495bSYour Name * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10*5113495bSYour Name * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11*5113495bSYour Name * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12*5113495bSYour Name * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13*5113495bSYour Name * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14*5113495bSYour Name * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15*5113495bSYour Name */
16*5113495bSYour Name
17*5113495bSYour Name /*
18*5113495bSYour Name * DOC: contains CoAP south bound interface definitions
19*5113495bSYour Name */
20*5113495bSYour Name
21*5113495bSYour Name #include <wlan_coap_main.h>
22*5113495bSYour Name #include <wlan_coap_tgt_api.h>
23*5113495bSYour Name #include <wlan_lmac_if_def.h>
24*5113495bSYour Name #include "wlan_objmgr_pdev_obj.h"
25*5113495bSYour Name
26*5113495bSYour Name static inline struct wlan_lmac_if_coap_tx_ops *
wlan_psoc_get_coap_txops(struct wlan_objmgr_psoc * psoc)27*5113495bSYour Name wlan_psoc_get_coap_txops(struct wlan_objmgr_psoc *psoc)
28*5113495bSYour Name {
29*5113495bSYour Name struct wlan_lmac_if_tx_ops *tx_ops;
30*5113495bSYour Name
31*5113495bSYour Name tx_ops = wlan_psoc_get_lmac_if_txops(psoc);
32*5113495bSYour Name if (!tx_ops) {
33*5113495bSYour Name coap_err("tx_ops is NULL");
34*5113495bSYour Name return NULL;
35*5113495bSYour Name }
36*5113495bSYour Name
37*5113495bSYour Name return &tx_ops->coap_ops;
38*5113495bSYour Name }
39*5113495bSYour Name
40*5113495bSYour Name static inline struct wlan_lmac_if_coap_tx_ops *
wlan_vdev_get_coap_txops(struct wlan_objmgr_vdev * vdev)41*5113495bSYour Name wlan_vdev_get_coap_txops(struct wlan_objmgr_vdev *vdev)
42*5113495bSYour Name {
43*5113495bSYour Name struct wlan_objmgr_psoc *psoc;
44*5113495bSYour Name
45*5113495bSYour Name psoc = wlan_vdev_get_psoc(vdev);
46*5113495bSYour Name if (!psoc) {
47*5113495bSYour Name coap_err("NULL psoc");
48*5113495bSYour Name return NULL;
49*5113495bSYour Name }
50*5113495bSYour Name
51*5113495bSYour Name return wlan_psoc_get_coap_txops(psoc);
52*5113495bSYour Name }
53*5113495bSYour Name
tgt_coap_attach(struct wlan_objmgr_psoc * psoc)54*5113495bSYour Name QDF_STATUS tgt_coap_attach(struct wlan_objmgr_psoc *psoc)
55*5113495bSYour Name {
56*5113495bSYour Name struct wlan_lmac_if_coap_tx_ops *coap_tx_ops;
57*5113495bSYour Name
58*5113495bSYour Name if (!psoc) {
59*5113495bSYour Name coap_err("psoc is null");
60*5113495bSYour Name return QDF_STATUS_E_NULL_VALUE;
61*5113495bSYour Name }
62*5113495bSYour Name
63*5113495bSYour Name coap_tx_ops = wlan_psoc_get_coap_txops(psoc);
64*5113495bSYour Name if (!coap_tx_ops) {
65*5113495bSYour Name coap_err("tx_ops is null!");
66*5113495bSYour Name return QDF_STATUS_E_NULL_VALUE;
67*5113495bSYour Name }
68*5113495bSYour Name
69*5113495bSYour Name if (!coap_tx_ops->attach) {
70*5113495bSYour Name coap_err("attach function is null!");
71*5113495bSYour Name return QDF_STATUS_E_NULL_VALUE;
72*5113495bSYour Name }
73*5113495bSYour Name
74*5113495bSYour Name return coap_tx_ops->attach(psoc);
75*5113495bSYour Name }
76*5113495bSYour Name
tgt_coap_detach(struct wlan_objmgr_psoc * psoc)77*5113495bSYour Name QDF_STATUS tgt_coap_detach(struct wlan_objmgr_psoc *psoc)
78*5113495bSYour Name {
79*5113495bSYour Name struct wlan_lmac_if_coap_tx_ops *coap_tx_ops;
80*5113495bSYour Name
81*5113495bSYour Name if (!psoc) {
82*5113495bSYour Name coap_err("psoc is null");
83*5113495bSYour Name return QDF_STATUS_E_NULL_VALUE;
84*5113495bSYour Name }
85*5113495bSYour Name
86*5113495bSYour Name coap_tx_ops = wlan_psoc_get_coap_txops(psoc);
87*5113495bSYour Name if (!coap_tx_ops) {
88*5113495bSYour Name coap_err("tx_ops is null!");
89*5113495bSYour Name return QDF_STATUS_E_NULL_VALUE;
90*5113495bSYour Name }
91*5113495bSYour Name
92*5113495bSYour Name if (!coap_tx_ops->detach) {
93*5113495bSYour Name coap_err("coap_detach function is null!");
94*5113495bSYour Name return QDF_STATUS_E_NULL_VALUE;
95*5113495bSYour Name }
96*5113495bSYour Name
97*5113495bSYour Name return coap_tx_ops->detach(psoc);
98*5113495bSYour Name }
99*5113495bSYour Name
100*5113495bSYour Name QDF_STATUS
tgt_send_coap_offload_reply_enable(struct wlan_objmgr_vdev * vdev,struct coap_offload_reply_param * param)101*5113495bSYour Name tgt_send_coap_offload_reply_enable(struct wlan_objmgr_vdev *vdev,
102*5113495bSYour Name struct coap_offload_reply_param *param)
103*5113495bSYour Name {
104*5113495bSYour Name struct wlan_lmac_if_coap_tx_ops *coap_ops;
105*5113495bSYour Name
106*5113495bSYour Name if (!vdev) {
107*5113495bSYour Name coap_err("NULL vdev");
108*5113495bSYour Name return QDF_STATUS_E_NULL_VALUE;
109*5113495bSYour Name }
110*5113495bSYour Name
111*5113495bSYour Name coap_ops = wlan_vdev_get_coap_txops(vdev);
112*5113495bSYour Name if (coap_ops && coap_ops->offload_reply_enable)
113*5113495bSYour Name return coap_ops->offload_reply_enable(vdev, param);
114*5113495bSYour Name
115*5113495bSYour Name return QDF_STATUS_SUCCESS;
116*5113495bSYour Name }
117*5113495bSYour Name
118*5113495bSYour Name QDF_STATUS
tgt_send_coap_offload_reply_disable(struct wlan_objmgr_vdev * vdev,uint32_t req_id)119*5113495bSYour Name tgt_send_coap_offload_reply_disable(struct wlan_objmgr_vdev *vdev,
120*5113495bSYour Name uint32_t req_id)
121*5113495bSYour Name {
122*5113495bSYour Name struct wlan_lmac_if_coap_tx_ops *coap_ops;
123*5113495bSYour Name
124*5113495bSYour Name if (!vdev) {
125*5113495bSYour Name coap_err("NULL vdev");
126*5113495bSYour Name return QDF_STATUS_E_NULL_VALUE;
127*5113495bSYour Name }
128*5113495bSYour Name
129*5113495bSYour Name coap_ops = wlan_vdev_get_coap_txops(vdev);
130*5113495bSYour Name if (coap_ops && coap_ops->offload_reply_disable)
131*5113495bSYour Name return coap_ops->offload_reply_disable(vdev, req_id);
132*5113495bSYour Name
133*5113495bSYour Name return QDF_STATUS_SUCCESS;
134*5113495bSYour Name }
135*5113495bSYour Name
136*5113495bSYour Name QDF_STATUS
tgt_send_coap_offload_periodic_tx_enable(struct wlan_objmgr_vdev * vdev,struct coap_offload_periodic_tx_param * param)137*5113495bSYour Name tgt_send_coap_offload_periodic_tx_enable(struct wlan_objmgr_vdev *vdev,
138*5113495bSYour Name struct coap_offload_periodic_tx_param *param)
139*5113495bSYour Name {
140*5113495bSYour Name struct wlan_lmac_if_coap_tx_ops *coap_ops;
141*5113495bSYour Name
142*5113495bSYour Name if (!vdev) {
143*5113495bSYour Name coap_err("NULL vdev");
144*5113495bSYour Name return QDF_STATUS_E_NULL_VALUE;
145*5113495bSYour Name }
146*5113495bSYour Name
147*5113495bSYour Name coap_ops = wlan_vdev_get_coap_txops(vdev);
148*5113495bSYour Name if (coap_ops && coap_ops->offload_periodic_tx_enable)
149*5113495bSYour Name return coap_ops->offload_periodic_tx_enable(vdev, param);
150*5113495bSYour Name
151*5113495bSYour Name return QDF_STATUS_SUCCESS;
152*5113495bSYour Name }
153*5113495bSYour Name
154*5113495bSYour Name QDF_STATUS
tgt_send_coap_offload_periodic_tx_disable(struct wlan_objmgr_vdev * vdev,uint32_t req_id)155*5113495bSYour Name tgt_send_coap_offload_periodic_tx_disable(struct wlan_objmgr_vdev *vdev,
156*5113495bSYour Name uint32_t req_id)
157*5113495bSYour Name {
158*5113495bSYour Name struct wlan_lmac_if_coap_tx_ops *coap_ops;
159*5113495bSYour Name
160*5113495bSYour Name if (!vdev) {
161*5113495bSYour Name coap_err("NULL vdev");
162*5113495bSYour Name return QDF_STATUS_E_NULL_VALUE;
163*5113495bSYour Name }
164*5113495bSYour Name
165*5113495bSYour Name coap_ops = wlan_vdev_get_coap_txops(vdev);
166*5113495bSYour Name if (coap_ops && coap_ops->offload_periodic_tx_disable)
167*5113495bSYour Name return coap_ops->offload_periodic_tx_disable(vdev, req_id);
168*5113495bSYour Name
169*5113495bSYour Name return QDF_STATUS_SUCCESS;
170*5113495bSYour Name }
171*5113495bSYour Name
172*5113495bSYour Name QDF_STATUS
tgt_send_coap_offload_cache_get(struct wlan_objmgr_vdev * vdev,uint32_t req_id)173*5113495bSYour Name tgt_send_coap_offload_cache_get(struct wlan_objmgr_vdev *vdev, uint32_t req_id)
174*5113495bSYour Name {
175*5113495bSYour Name struct wlan_lmac_if_coap_tx_ops *coap_ops;
176*5113495bSYour Name
177*5113495bSYour Name if (!vdev) {
178*5113495bSYour Name coap_err("NULL vdev");
179*5113495bSYour Name return QDF_STATUS_E_NULL_VALUE;
180*5113495bSYour Name }
181*5113495bSYour Name
182*5113495bSYour Name coap_ops = wlan_vdev_get_coap_txops(vdev);
183*5113495bSYour Name if (coap_ops && coap_ops->offload_cache_get)
184*5113495bSYour Name return coap_ops->offload_cache_get(vdev, req_id);
185*5113495bSYour Name
186*5113495bSYour Name return QDF_STATUS_SUCCESS;
187*5113495bSYour Name }
188