xref: /wlan-dirver/qca-wifi-host-cmn/target_if/dp/src/target_if_dp.c (revision a175314c51a4ce5cec2835cc8a8c7dc0c1810915)
1 /*
2  * Copyright (c) 2018 The Linux Foundation. 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: defines DP interaction with FW using WMI
21  */
22 
23 #include <qdf_status.h>
24 #include "target_if_dp.h"
25 #include <init_deinit_lmac.h>
26 
27 void
28 target_if_peer_set_default_routing(struct cdp_ctrl_objmgr_pdev *pdev,
29 				   uint8_t *peer_macaddr, uint8_t vdev_id,
30 				   bool hash_based, uint8_t ring_num)
31 {
32 	uint32_t value;
33 	struct peer_set_params param;
34 	struct common_wmi_handle *pdev_wmi_handle;
35 
36 	pdev_wmi_handle =
37 		lmac_get_pdev_wmi_handle((struct wlan_objmgr_pdev *)pdev);
38 	if (!pdev_wmi_handle) {
39 		target_if_err("pdev wmi handle NULL");
40 		return;
41 	}
42 
43 	qdf_mem_set(&param, sizeof(param), 0);
44 
45 	/* TODO: Need bit definitions for ring number and hash based routing
46 	 * fields in common wmi header file
47 	 */
48 	value = ((hash_based) ? 1 : 0) | (ring_num << 1);
49 
50 	param.param_id = WMI_HOST_PEER_SET_DEFAULT_ROUTING;
51 	param.vdev_id = vdev_id;
52 	param.param_value = value;
53 
54 	if (wmi_set_peer_param_send(pdev_wmi_handle, peer_macaddr, &param)) {
55 		target_if_err("Unable to set default routing for peer "
56 				QDF_MAC_ADDR_STR,
57 				QDF_MAC_ADDR_ARRAY(peer_macaddr));
58 	}
59 }
60 
61 QDF_STATUS
62 target_if_peer_rx_reorder_queue_setup(struct cdp_ctrl_objmgr_pdev *pdev,
63 				      uint8_t vdev_id, uint8_t *peer_macaddr,
64 				      qdf_dma_addr_t hw_qdesc, int tid,
65 				      uint16_t queue_no)
66 {
67 	struct rx_reorder_queue_setup_params param;
68 	struct common_wmi_handle *pdev_wmi_handle;
69 
70 	pdev_wmi_handle =
71 		lmac_get_pdev_wmi_handle((struct wlan_objmgr_pdev *)pdev);
72 	if (!pdev_wmi_handle) {
73 		target_if_err("pdev wmi handle NULL");
74 		return QDF_STATUS_E_FAILURE;
75 	}
76 	param.tid = tid;
77 	param.vdev_id = vdev_id;
78 	param.peer_macaddr = peer_macaddr;
79 	param.hw_qdesc_paddr_lo = hw_qdesc & 0xffffffff;
80 	param.hw_qdesc_paddr_hi = (uint64_t)hw_qdesc >> 32;
81 	param.queue_no = queue_no;
82 	return wmi_unified_peer_rx_reorder_queue_setup_send(pdev_wmi_handle,
83 							    &param);
84 }
85 
86 QDF_STATUS
87 target_if_peer_rx_reorder_queue_remove(struct cdp_ctrl_objmgr_pdev *pdev,
88 				       uint8_t vdev_id, uint8_t *peer_macaddr,
89 				       uint32_t peer_tid_bitmap)
90 {
91 	struct rx_reorder_queue_remove_params param;
92 	struct common_wmi_handle *pdev_wmi_handle;
93 
94 	pdev_wmi_handle =
95 		lmac_get_pdev_wmi_handle((struct wlan_objmgr_pdev *)pdev);
96 	if (!pdev_wmi_handle) {
97 		target_if_err("pdev wmi handle NULL");
98 		return QDF_STATUS_E_FAILURE;
99 	}
100 	param.vdev_id = vdev_id;
101 	param.peer_macaddr = peer_macaddr;
102 	param.peer_tid_bitmap = peer_tid_bitmap;
103 	return wmi_unified_peer_rx_reorder_queue_remove_send(pdev_wmi_handle,
104 							     &param);
105 }
106 
107 QDF_STATUS
108 target_if_lro_hash_config(struct wlan_objmgr_psoc *psoc_handle,
109 			  struct cdp_lro_hash_config *lro_hash_cfg)
110 {
111 	struct wmi_lro_config_cmd_t wmi_lro_cmd = {0};
112 	struct common_wmi_handle *wmi_handle;
113 
114 	wmi_handle = lmac_get_wmi_hdl(psoc_handle);
115 	if (!lro_hash_cfg || !wmi_handle) {
116 		target_if_err("wmi_handle: 0x%pK, lro_hash_cfg: 0x%pK",
117 			      wmi_handle, lro_hash_cfg);
118 		return QDF_STATUS_E_FAILURE;
119 	}
120 
121 	wmi_lro_cmd.lro_enable = lro_hash_cfg->lro_enable;
122 	wmi_lro_cmd.tcp_flag = lro_hash_cfg->tcp_flag;
123 	wmi_lro_cmd.tcp_flag_mask = lro_hash_cfg->tcp_flag_mask;
124 
125 	qdf_mem_copy(wmi_lro_cmd.toeplitz_hash_ipv4,
126 		     lro_hash_cfg->toeplitz_hash_ipv4,
127 		     LRO_IPV4_SEED_ARR_SZ * sizeof(uint32_t));
128 
129 	qdf_mem_copy(wmi_lro_cmd.toeplitz_hash_ipv6,
130 		     lro_hash_cfg->toeplitz_hash_ipv6,
131 		     LRO_IPV6_SEED_ARR_SZ * sizeof(uint32_t));
132 
133 	return wmi_unified_lro_config_cmd(wmi_handle,
134 					  &wmi_lro_cmd);
135 }
136