blob: 87bf50101918ba8238ad3ced1e507e9a0ede2171 [file] [log] [blame]
Mohit Khanna70322002018-05-15 19:21:32 -07001/*
2 * Copyright (c) 2017-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#include <wlan_objmgr_pdev_obj.h>
20#include <dp_txrx.h>
21#include <cdp_txrx_cmn.h>
22
23QDF_STATUS dp_txrx_init(ol_txrx_soc_handle soc, struct cdp_pdev *pdev,
24 struct dp_txrx_config *config)
25{
26 struct dp_txrx_handle *dp_ext_hdl;
27 QDF_STATUS qdf_status = QDF_STATUS_SUCCESS;
28
29 dp_ext_hdl = qdf_mem_malloc(sizeof(*dp_ext_hdl));
30 if (!dp_ext_hdl) {
Mohit Khanna70322002018-05-15 19:21:32 -070031 QDF_ASSERT(0);
32 return QDF_STATUS_E_NOMEM;
33 }
34
Mohit Khanna13ea5242018-08-28 18:00:34 -070035 dp_info("dp_txrx_handle allocated");
Mohit Khanna70322002018-05-15 19:21:32 -070036 dp_ext_hdl->soc = soc;
37 dp_ext_hdl->pdev = pdev;
38 cdp_soc_set_dp_txrx_handle(soc, dp_ext_hdl);
39 qdf_mem_copy(&dp_ext_hdl->config, config, sizeof(*config));
40 dp_ext_hdl->rx_tm_hdl.txrx_handle_cmn =
41 dp_txrx_get_cmn_hdl_frm_ext_hdl(dp_ext_hdl);
42
43 if (dp_ext_hdl->config.enable_rx_threads) {
44 qdf_status = dp_rx_tm_init(&dp_ext_hdl->rx_tm_hdl,
45 dp_ext_hdl->config.num_rx_threads);
46 }
47
48 return qdf_status;
49}
50
51QDF_STATUS dp_txrx_deinit(ol_txrx_soc_handle soc)
52{
53 struct dp_txrx_handle *dp_ext_hdl;
54
55 if (!soc)
56 return QDF_STATUS_E_INVAL;
57
58 dp_ext_hdl = cdp_soc_get_dp_txrx_handle(soc);
59 if (!dp_ext_hdl)
60 return QDF_STATUS_E_FAULT;
61
Mohit Khanna13ea5242018-08-28 18:00:34 -070062 if (dp_ext_hdl->config.enable_rx_threads)
63 dp_rx_tm_deinit(&dp_ext_hdl->rx_tm_hdl);
64
Mohit Khanna70322002018-05-15 19:21:32 -070065 qdf_mem_free(dp_ext_hdl);
66 dp_info("dp_txrx_handle_t de-allocated");
67
68 cdp_soc_set_dp_txrx_handle(soc, NULL);
69
70 return QDF_STATUS_SUCCESS;
71}