1 /*
2  * Copyright (c) 2022-2023 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: wlan_hdd_wds.c
21  *
22  * WLAN Host Device Driver file for wds (4 address frame header when
23  * SA and TA are different) support.
24  *
25  */
26 
27 /* Include Files */
28 #include <cdp_txrx_ctrl.h>
29 #include <wlan_hdd_main.h>
30 #include "wlan_hdd_wds.h"
31 
hdd_wds_config_dp_repeater_mode(struct wlan_objmgr_vdev * vdev)32 void hdd_wds_config_dp_repeater_mode(struct wlan_objmgr_vdev *vdev)
33 {
34 	struct wlan_objmgr_pdev *pdev;
35 	struct wlan_objmgr_psoc *psoc;
36 	ol_txrx_soc_handle soc;
37 	cdp_config_param_type vdev_param;
38 
39 	pdev = wlan_vdev_get_pdev(vdev);
40 	if (!pdev)
41 		return;
42 
43 	psoc = wlan_pdev_get_psoc(pdev);
44 	if (!psoc)
45 		return;
46 
47 	if (!wlan_mlme_get_wds_mode(psoc))
48 		return;
49 
50 	soc = wlan_psoc_get_dp_handle(psoc);
51 
52 	vdev_param.cdp_vdev_param_wds = true;
53 	if (cdp_txrx_set_vdev_param(soc, vdev->vdev_objmgr.vdev_id,
54 				    CDP_ENABLE_WDS,
55 				    vdev_param))
56 		hdd_debug("Failed to set WDS param on DP vdev");
57 }
58 
59 void
hdd_wds_replace_peer_mac(void * soc,struct hdd_adapter * adapter,uint8_t * mac_addr)60 hdd_wds_replace_peer_mac(void *soc, struct hdd_adapter *adapter,
61 			 uint8_t *mac_addr)
62 {
63 	struct cdp_ast_entry_info ast_entry_info = {0};
64 	cdp_config_param_type val;
65 	QDF_STATUS status;
66 
67 	if (!cdp_find_peer_exist(soc, OL_TXRX_PDEV_ID, mac_addr)) {
68 		status = cdp_txrx_get_vdev_param(soc, adapter->deflink->vdev_id,
69 						 CDP_ENABLE_WDS, &val);
70 		if (!QDF_IS_STATUS_SUCCESS(status))
71 			return;
72 
73 		if (!val.cdp_vdev_param_wds)
74 			return;
75 
76 		if (!cdp_peer_get_ast_info_by_soc(soc,  mac_addr,
77 						  &ast_entry_info))
78 			return;
79 
80 		qdf_mem_copy(mac_addr, ast_entry_info.peer_mac_addr,
81 			     QDF_MAC_ADDR_SIZE);
82 	}
83 }
84