xref: /wlan-driver/qcacld-3.0/core/wma/src/wma_nan_datapath.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1*5113495bSYour Name /*
2*5113495bSYour Name  * Copyright (c) 2016-2021 The Linux Foundation. All rights reserved.
3*5113495bSYour Name  * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved.
4*5113495bSYour Name  *
5*5113495bSYour Name  * Permission to use, copy, modify, and/or distribute this software for
6*5113495bSYour Name  * any purpose with or without fee is hereby granted, provided that the
7*5113495bSYour Name  * above copyright notice and this permission notice appear in all
8*5113495bSYour Name  * copies.
9*5113495bSYour Name  *
10*5113495bSYour Name  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
11*5113495bSYour Name  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
12*5113495bSYour Name  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
13*5113495bSYour Name  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
14*5113495bSYour Name  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
15*5113495bSYour Name  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
16*5113495bSYour Name  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
17*5113495bSYour Name  * PERFORMANCE OF THIS SOFTWARE.
18*5113495bSYour Name  */
19*5113495bSYour Name 
20*5113495bSYour Name /**
21*5113495bSYour Name  * DOC: wma_nan_datapath.c
22*5113495bSYour Name  *
23*5113495bSYour Name  * WMA NAN Data path API implementation
24*5113495bSYour Name  */
25*5113495bSYour Name 
26*5113495bSYour Name #include "wma.h"
27*5113495bSYour Name #include "wma_api.h"
28*5113495bSYour Name #include "wmi_unified_api.h"
29*5113495bSYour Name #include "wmi_unified.h"
30*5113495bSYour Name #include "wma_nan_datapath.h"
31*5113495bSYour Name #include "wma_internal.h"
32*5113495bSYour Name #include "cds_utils.h"
33*5113495bSYour Name #include "cdp_txrx_peer_ops.h"
34*5113495bSYour Name #include "cdp_txrx_tx_delay.h"
35*5113495bSYour Name #include "cdp_txrx_misc.h"
36*5113495bSYour Name #include <cdp_txrx_handle.h>
37*5113495bSYour Name 
wma_add_sta_ndi_mode(tp_wma_handle wma,tpAddStaParams add_sta)38*5113495bSYour Name QDF_STATUS wma_add_sta_ndi_mode(tp_wma_handle wma, tpAddStaParams add_sta)
39*5113495bSYour Name {
40*5113495bSYour Name 	enum ol_txrx_peer_state state = OL_TXRX_PEER_STATE_CONN;
41*5113495bSYour Name 	uint8_t pdev_id = WMI_PDEV_ID_SOC;
42*5113495bSYour Name 	void *soc = cds_get_context(QDF_MODULE_ID_SOC);
43*5113495bSYour Name 	QDF_STATUS status;
44*5113495bSYour Name 	struct wma_txrx_node *iface;
45*5113495bSYour Name 
46*5113495bSYour Name 	iface = &wma->interfaces[add_sta->smesessionId];
47*5113495bSYour Name 	wma_debug("vdev: %d, peer_mac_addr: "QDF_MAC_ADDR_FMT,
48*5113495bSYour Name 		add_sta->smesessionId, QDF_MAC_ADDR_REF(add_sta->staMac));
49*5113495bSYour Name 
50*5113495bSYour Name 	if (cdp_find_peer_exist_on_vdev(soc, add_sta->smesessionId,
51*5113495bSYour Name 					add_sta->staMac)) {
52*5113495bSYour Name 		wma_err("NDI peer already exists, peer_addr "QDF_MAC_ADDR_FMT,
53*5113495bSYour Name 			 QDF_MAC_ADDR_REF(add_sta->staMac));
54*5113495bSYour Name 		add_sta->status = QDF_STATUS_E_EXISTS;
55*5113495bSYour Name 		goto send_rsp;
56*5113495bSYour Name 	}
57*5113495bSYour Name 
58*5113495bSYour Name 	/*
59*5113495bSYour Name 	 * The code above only checks the peer existence on its own vdev.
60*5113495bSYour Name 	 * Need to check whether the peer exists on other vDevs because firmware
61*5113495bSYour Name 	 * can't create the peer if the peer with same MAC address already
62*5113495bSYour Name 	 * exists on the pDev. As this peer belongs to other vDevs, just return
63*5113495bSYour Name 	 * here.
64*5113495bSYour Name 	 */
65*5113495bSYour Name 	if (cdp_find_peer_exist(soc, pdev_id, add_sta->staMac)) {
66*5113495bSYour Name 		wma_err("peer exists on other vdev with peer_addr "QDF_MAC_ADDR_FMT,
67*5113495bSYour Name 			 QDF_MAC_ADDR_REF(add_sta->staMac));
68*5113495bSYour Name 		add_sta->status = QDF_STATUS_E_EXISTS;
69*5113495bSYour Name 		goto send_rsp;
70*5113495bSYour Name 	}
71*5113495bSYour Name 
72*5113495bSYour Name 	status = wma_create_peer(wma, add_sta->staMac,
73*5113495bSYour Name 				 WMI_PEER_TYPE_NAN_DATA, add_sta->smesessionId,
74*5113495bSYour Name 				 NULL, false);
75*5113495bSYour Name 	if (status != QDF_STATUS_SUCCESS) {
76*5113495bSYour Name 		wma_err("Failed to create peer for "QDF_MAC_ADDR_FMT,
77*5113495bSYour Name 			 QDF_MAC_ADDR_REF(add_sta->staMac));
78*5113495bSYour Name 		add_sta->status = status;
79*5113495bSYour Name 		goto send_rsp;
80*5113495bSYour Name 	}
81*5113495bSYour Name 
82*5113495bSYour Name 	if (!cdp_find_peer_exist_on_vdev(soc, add_sta->smesessionId,
83*5113495bSYour Name 					 add_sta->staMac)) {
84*5113495bSYour Name 		wma_err("Failed to find peer handle using peer mac "QDF_MAC_ADDR_FMT,
85*5113495bSYour Name 			 QDF_MAC_ADDR_REF(add_sta->staMac));
86*5113495bSYour Name 		add_sta->status = QDF_STATUS_E_FAILURE;
87*5113495bSYour Name 		wma_remove_peer(wma, add_sta->staMac, add_sta->smesessionId,
88*5113495bSYour Name 				false);
89*5113495bSYour Name 		goto send_rsp;
90*5113495bSYour Name 	}
91*5113495bSYour Name 
92*5113495bSYour Name 	wma_debug("Moving peer "QDF_MAC_ADDR_FMT" to state %d",
93*5113495bSYour Name 		  QDF_MAC_ADDR_REF(add_sta->staMac), state);
94*5113495bSYour Name 	cdp_peer_state_update(soc, add_sta->staMac, state);
95*5113495bSYour Name 
96*5113495bSYour Name 	add_sta->nss    = iface->nss;
97*5113495bSYour Name 	add_sta->status = QDF_STATUS_SUCCESS;
98*5113495bSYour Name send_rsp:
99*5113495bSYour Name 	status = add_sta->status;
100*5113495bSYour Name 	wma_debug("Sending add sta rsp to umac (mac:"QDF_MAC_ADDR_FMT", status:%d)",
101*5113495bSYour Name 		  QDF_MAC_ADDR_REF(add_sta->staMac), add_sta->status);
102*5113495bSYour Name 
103*5113495bSYour Name 	wma_send_msg_high_priority(wma, WMA_ADD_STA_RSP, (void *)add_sta, 0);
104*5113495bSYour Name 
105*5113495bSYour Name 	return status;
106*5113495bSYour Name }
107*5113495bSYour Name 
wma_delete_sta_req_ndi_mode(tp_wma_handle wma,tpDeleteStaParams del_sta)108*5113495bSYour Name QDF_STATUS wma_delete_sta_req_ndi_mode(tp_wma_handle wma,
109*5113495bSYour Name 				       tpDeleteStaParams del_sta)
110*5113495bSYour Name {
111*5113495bSYour Name 	QDF_STATUS status;
112*5113495bSYour Name 
113*5113495bSYour Name 	status = wma_remove_peer(wma, del_sta->staMac,
114*5113495bSYour Name 				 del_sta->smesessionId, false);
115*5113495bSYour Name 	del_sta->status = QDF_STATUS_SUCCESS;
116*5113495bSYour Name 
117*5113495bSYour Name 	if (del_sta->respReqd) {
118*5113495bSYour Name 		wma_debug("Sending del rsp to umac (status: %d)",
119*5113495bSYour Name 				del_sta->status);
120*5113495bSYour Name 		wma_send_msg_high_priority(wma, WMA_DELETE_STA_RSP, del_sta, 0);
121*5113495bSYour Name 	} else {
122*5113495bSYour Name 		wma_debug("NDI Del Sta resp not needed");
123*5113495bSYour Name 		qdf_mem_free(del_sta);
124*5113495bSYour Name 	}
125*5113495bSYour Name 
126*5113495bSYour Name 	return status;
127*5113495bSYour Name }
128