Mohit Khanna | 7032200 | 2018-05-15 19:21:32 -0700 | [diff] [blame^] | 1 | /* |
| 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 | |
| 23 | QDF_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) { |
| 31 | dp_err("failed to alloc dp_txrx_handle"); |
| 32 | QDF_ASSERT(0); |
| 33 | return QDF_STATUS_E_NOMEM; |
| 34 | } |
| 35 | |
| 36 | dp_debug("dp_txrx_handle allocated"); |
| 37 | dp_ext_hdl->soc = soc; |
| 38 | dp_ext_hdl->pdev = pdev; |
| 39 | cdp_soc_set_dp_txrx_handle(soc, dp_ext_hdl); |
| 40 | qdf_mem_copy(&dp_ext_hdl->config, config, sizeof(*config)); |
| 41 | dp_ext_hdl->rx_tm_hdl.txrx_handle_cmn = |
| 42 | dp_txrx_get_cmn_hdl_frm_ext_hdl(dp_ext_hdl); |
| 43 | |
| 44 | if (dp_ext_hdl->config.enable_rx_threads) { |
| 45 | qdf_status = dp_rx_tm_init(&dp_ext_hdl->rx_tm_hdl, |
| 46 | dp_ext_hdl->config.num_rx_threads); |
| 47 | } |
| 48 | |
| 49 | return qdf_status; |
| 50 | } |
| 51 | |
| 52 | QDF_STATUS dp_txrx_deinit(ol_txrx_soc_handle soc) |
| 53 | { |
| 54 | struct dp_txrx_handle *dp_ext_hdl; |
| 55 | |
| 56 | if (!soc) |
| 57 | return QDF_STATUS_E_INVAL; |
| 58 | |
| 59 | dp_ext_hdl = cdp_soc_get_dp_txrx_handle(soc); |
| 60 | if (!dp_ext_hdl) |
| 61 | return QDF_STATUS_E_FAULT; |
| 62 | |
| 63 | dp_rx_tm_deinit(&dp_ext_hdl->rx_tm_hdl); |
| 64 | qdf_mem_free(dp_ext_hdl); |
| 65 | dp_info("dp_txrx_handle_t de-allocated"); |
| 66 | |
| 67 | cdp_soc_set_dp_txrx_handle(soc, NULL); |
| 68 | |
| 69 | return QDF_STATUS_SUCCESS; |
| 70 | } |