xref: /wlan-driver/qca-wifi-host-cmn/wmi/src/wmi_unified_wds_tlv.c (revision 5113495b16420b49004c444715d2daae2066e7dc)
1*5113495bSYour Name /*
2*5113495bSYour Name  * Copyright (c) 2021 The Linux Foundation. All rights reserved.
3*5113495bSYour Name  *
4*5113495bSYour Name  * Permission to use, copy, modify, and/or distribute this software for
5*5113495bSYour Name  * any purpose with or without fee is hereby granted, provided that the
6*5113495bSYour Name  * above copyright notice and this permission notice appear in all
7*5113495bSYour Name  * copies.
8*5113495bSYour Name  *
9*5113495bSYour Name  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
10*5113495bSYour Name  * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
11*5113495bSYour Name  * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
12*5113495bSYour Name  * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
13*5113495bSYour Name  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
14*5113495bSYour Name  * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
15*5113495bSYour Name  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
16*5113495bSYour Name  * PERFORMANCE OF THIS SOFTWARE.
17*5113495bSYour Name  */
18*5113495bSYour Name 
19*5113495bSYour Name #include <osdep.h>
20*5113495bSYour Name #include <wmi.h>
21*5113495bSYour Name #include <wmi_unified_priv.h>
22*5113495bSYour Name #include <wmi_unified_wds_api.h>
23*5113495bSYour Name 
24*5113495bSYour Name /**
25*5113495bSYour Name  * send_peer_add_wds_entry_cmd_tlv() - send peer add command to fw
26*5113495bSYour Name  * @wmi_handle: wmi handle
27*5113495bSYour Name  * @param: pointer holding peer details
28*5113495bSYour Name  *
29*5113495bSYour Name  * Return: QDF_STATUS_SUCCESS for success or error code
30*5113495bSYour Name  */
31*5113495bSYour Name static QDF_STATUS
send_peer_add_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,struct peer_add_wds_entry_params * param)32*5113495bSYour Name send_peer_add_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
33*5113495bSYour Name 				struct peer_add_wds_entry_params *param)
34*5113495bSYour Name {
35*5113495bSYour Name 	wmi_peer_add_wds_entry_cmd_fixed_param *cmd;
36*5113495bSYour Name 	wmi_buf_t buf;
37*5113495bSYour Name 	int len = sizeof(*cmd);
38*5113495bSYour Name 	QDF_STATUS ret;
39*5113495bSYour Name 
40*5113495bSYour Name 	buf = wmi_buf_alloc(wmi_handle, len);
41*5113495bSYour Name 	if (!buf)
42*5113495bSYour Name 		return QDF_STATUS_E_NOMEM;
43*5113495bSYour Name 
44*5113495bSYour Name 	cmd = (wmi_peer_add_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
45*5113495bSYour Name 	WMITLV_SET_HDR(&cmd->tlv_header,
46*5113495bSYour Name 		       WMITLV_TAG_STRUC_wmi_peer_add_wds_entry_cmd_fixed_param,
47*5113495bSYour Name 		       WMITLV_GET_STRUCT_TLVLEN
48*5113495bSYour Name 		       (wmi_peer_add_wds_entry_cmd_fixed_param));
49*5113495bSYour Name 	WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
50*5113495bSYour Name 	WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
51*5113495bSYour Name 
52*5113495bSYour Name 	cmd->flags = (param->flags & WMI_HOST_WDS_FLAG_STATIC) ?
53*5113495bSYour Name 					WMI_WDS_FLAG_STATIC : 0;
54*5113495bSYour Name 	cmd->vdev_id = param->vdev_id;
55*5113495bSYour Name 
56*5113495bSYour Name 	wmi_mtrace(WMI_PEER_ADD_WDS_ENTRY_CMDID, cmd->vdev_id, 0);
57*5113495bSYour Name 	ret = wmi_unified_cmd_send(wmi_handle, buf, len,
58*5113495bSYour Name 				   WMI_PEER_ADD_WDS_ENTRY_CMDID);
59*5113495bSYour Name 	if (QDF_IS_STATUS_ERROR(ret))
60*5113495bSYour Name 		wmi_buf_free(buf);
61*5113495bSYour Name 
62*5113495bSYour Name 	return ret;
63*5113495bSYour Name }
64*5113495bSYour Name 
65*5113495bSYour Name /**
66*5113495bSYour Name  * send_peer_del_wds_entry_cmd_tlv() - send peer delete command to fw
67*5113495bSYour Name  * @wmi_handle: wmi handle
68*5113495bSYour Name  * @param: pointer holding peer details
69*5113495bSYour Name  *
70*5113495bSYour Name  * Return: QDF_STATUS_SUCCESS for success or error code
71*5113495bSYour Name  */
72*5113495bSYour Name static QDF_STATUS
send_peer_del_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,struct peer_del_wds_entry_params * param)73*5113495bSYour Name send_peer_del_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
74*5113495bSYour Name 				struct peer_del_wds_entry_params *param)
75*5113495bSYour Name {
76*5113495bSYour Name 	wmi_peer_remove_wds_entry_cmd_fixed_param *cmd;
77*5113495bSYour Name 	wmi_buf_t buf;
78*5113495bSYour Name 	int len = sizeof(*cmd);
79*5113495bSYour Name 	QDF_STATUS ret;
80*5113495bSYour Name 
81*5113495bSYour Name 	buf = wmi_buf_alloc(wmi_handle, len);
82*5113495bSYour Name 	if (!buf)
83*5113495bSYour Name 		return QDF_STATUS_E_NOMEM;
84*5113495bSYour Name 
85*5113495bSYour Name 	cmd = (wmi_peer_remove_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
86*5113495bSYour Name 	WMITLV_SET_HDR(&cmd->tlv_header,
87*5113495bSYour Name 		       WMITLV_TAG_STRUC_wmi_peer_remove_wds_entry_cmd_fixed_param,
88*5113495bSYour Name 		       WMITLV_GET_STRUCT_TLVLEN
89*5113495bSYour Name 		       (wmi_peer_remove_wds_entry_cmd_fixed_param));
90*5113495bSYour Name 	WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
91*5113495bSYour Name 
92*5113495bSYour Name 	cmd->vdev_id = param->vdev_id;
93*5113495bSYour Name 
94*5113495bSYour Name 	wmi_mtrace(WMI_PEER_REMOVE_WDS_ENTRY_CMDID, cmd->vdev_id, 0);
95*5113495bSYour Name 	ret = wmi_unified_cmd_send(wmi_handle, buf, len,
96*5113495bSYour Name 				   WMI_PEER_REMOVE_WDS_ENTRY_CMDID);
97*5113495bSYour Name 	if (QDF_IS_STATUS_ERROR(ret))
98*5113495bSYour Name 		wmi_buf_free(buf);
99*5113495bSYour Name 
100*5113495bSYour Name 	return ret;
101*5113495bSYour Name }
102*5113495bSYour Name 
103*5113495bSYour Name /**
104*5113495bSYour Name  * send_peer_update_wds_entry_cmd_tlv() - send peer update command to fw
105*5113495bSYour Name  * @wmi_handle: wmi handle
106*5113495bSYour Name  * @param: pointer holding peer details
107*5113495bSYour Name  *
108*5113495bSYour Name  * Return: QDF_STATUS_SUCCESS for success or error code
109*5113495bSYour Name  */
110*5113495bSYour Name static QDF_STATUS
send_peer_update_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,struct peer_update_wds_entry_params * param)111*5113495bSYour Name send_peer_update_wds_entry_cmd_tlv(wmi_unified_t wmi_handle,
112*5113495bSYour Name 				   struct peer_update_wds_entry_params *param)
113*5113495bSYour Name {
114*5113495bSYour Name 	wmi_peer_update_wds_entry_cmd_fixed_param *cmd;
115*5113495bSYour Name 	wmi_buf_t buf;
116*5113495bSYour Name 	int len = sizeof(*cmd);
117*5113495bSYour Name 	QDF_STATUS ret;
118*5113495bSYour Name 
119*5113495bSYour Name 	buf = wmi_buf_alloc(wmi_handle, len);
120*5113495bSYour Name 	if (!buf)
121*5113495bSYour Name 		return QDF_STATUS_E_NOMEM;
122*5113495bSYour Name 
123*5113495bSYour Name 	cmd = (wmi_peer_update_wds_entry_cmd_fixed_param *)wmi_buf_data(buf);
124*5113495bSYour Name 	WMITLV_SET_HDR(&cmd->tlv_header,
125*5113495bSYour Name 		       WMITLV_TAG_STRUC_wmi_peer_update_wds_entry_cmd_fixed_param,
126*5113495bSYour Name 		       WMITLV_GET_STRUCT_TLVLEN
127*5113495bSYour Name 		       (wmi_peer_update_wds_entry_cmd_fixed_param));
128*5113495bSYour Name 	WMI_CHAR_ARRAY_TO_MAC_ADDR(param->dest_addr, &cmd->wds_macaddr);
129*5113495bSYour Name 	WMI_CHAR_ARRAY_TO_MAC_ADDR(param->peer_addr, &cmd->peer_macaddr);
130*5113495bSYour Name 
131*5113495bSYour Name 	cmd->flags = (param->flags & WMI_HOST_WDS_FLAG_STATIC) ?
132*5113495bSYour Name 						WMI_WDS_FLAG_STATIC : 0;
133*5113495bSYour Name 	cmd->vdev_id = param->vdev_id;
134*5113495bSYour Name 
135*5113495bSYour Name 	wmi_mtrace(WMI_PEER_UPDATE_WDS_ENTRY_CMDID, cmd->vdev_id, 0);
136*5113495bSYour Name 	ret = wmi_unified_cmd_send(wmi_handle, buf, len,
137*5113495bSYour Name 				   WMI_PEER_UPDATE_WDS_ENTRY_CMDID);
138*5113495bSYour Name 	if (QDF_IS_STATUS_ERROR(ret))
139*5113495bSYour Name 		wmi_buf_free(buf);
140*5113495bSYour Name 
141*5113495bSYour Name 	return ret;
142*5113495bSYour Name }
143*5113495bSYour Name 
wmi_wds_attach_tlv(wmi_unified_t wmi_handle)144*5113495bSYour Name void wmi_wds_attach_tlv(wmi_unified_t wmi_handle)
145*5113495bSYour Name {
146*5113495bSYour Name 	struct wmi_ops *ops = wmi_handle->ops;
147*5113495bSYour Name 
148*5113495bSYour Name 	ops->send_peer_add_wds_entry_cmd = send_peer_add_wds_entry_cmd_tlv;
149*5113495bSYour Name 	ops->send_peer_del_wds_entry_cmd = send_peer_del_wds_entry_cmd_tlv;
150*5113495bSYour Name 	ops->send_peer_update_wds_entry_cmd =
151*5113495bSYour Name 		send_peer_update_wds_entry_cmd_tlv;
152*5113495bSYour Name }
153