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 <qdf_status.h> 20 #include <wmi_unified_api.h> 21 #include <target_if_direct_buf_rx_api.h> 22 #include <wlan_objmgr_cmn.h> 23 #include <wlan_objmgr_global_obj.h> 24 #include <wlan_objmgr_psoc_obj.h> 25 #include <wlan_objmgr_cmn.h> 26 #include "target_if_direct_buf_rx_main.h" 27 28 QDF_STATUS direct_buf_rx_init(void) 29 { 30 QDF_STATUS status; 31 32 status = wlan_objmgr_register_psoc_create_handler( 33 WLAN_TARGET_IF_COMP_DIRECT_BUF_RX, 34 target_if_direct_buf_rx_psoc_create_handler, 35 NULL); 36 37 if (QDF_IS_STATUS_ERROR(status)) { 38 direct_buf_rx_err("Failed to register psoc create handler"); 39 return status; 40 } 41 42 status = wlan_objmgr_register_psoc_destroy_handler( 43 WLAN_TARGET_IF_COMP_DIRECT_BUF_RX, 44 target_if_direct_buf_rx_psoc_destroy_handler, 45 NULL); 46 47 if (QDF_IS_STATUS_ERROR(status)) { 48 direct_buf_rx_err("Failed to register psoc destroy handler"); 49 goto dbr_unreg_psoc_create; 50 } 51 52 status = wlan_objmgr_register_pdev_create_handler( 53 WLAN_TARGET_IF_COMP_DIRECT_BUF_RX, 54 target_if_direct_buf_rx_pdev_create_handler, 55 NULL); 56 57 if (QDF_IS_STATUS_ERROR(status)) { 58 direct_buf_rx_err("Failed to register pdev create handler"); 59 goto dbr_unreg_psoc_destroy; 60 } 61 62 status = wlan_objmgr_register_pdev_destroy_handler( 63 WLAN_TARGET_IF_COMP_DIRECT_BUF_RX, 64 target_if_direct_buf_rx_pdev_destroy_handler, 65 NULL); 66 67 if (QDF_IS_STATUS_ERROR(status)) { 68 direct_buf_rx_err("Failed to register pdev destroy handler"); 69 goto dbr_unreg_pdev_create; 70 } 71 72 direct_buf_rx_info("Direct Buffer RX pdev,psoc create and destroy handlers registered"); 73 74 return QDF_STATUS_SUCCESS; 75 76 dbr_unreg_pdev_create: 77 status = wlan_objmgr_unregister_pdev_create_handler( 78 WLAN_TARGET_IF_COMP_DIRECT_BUF_RX, 79 target_if_direct_buf_rx_pdev_create_handler, 80 NULL); 81 82 dbr_unreg_psoc_destroy: 83 status = wlan_objmgr_unregister_psoc_destroy_handler( 84 WLAN_TARGET_IF_COMP_DIRECT_BUF_RX, 85 target_if_direct_buf_rx_psoc_destroy_handler, 86 NULL); 87 88 dbr_unreg_psoc_create: 89 status = wlan_objmgr_unregister_psoc_create_handler( 90 WLAN_TARGET_IF_COMP_DIRECT_BUF_RX, 91 target_if_direct_buf_rx_psoc_create_handler, 92 NULL); 93 94 return QDF_STATUS_E_FAILURE; 95 } 96 qdf_export_symbol(direct_buf_rx_init); 97 98 QDF_STATUS direct_buf_rx_deinit(void) 99 { 100 QDF_STATUS status; 101 102 status = wlan_objmgr_unregister_pdev_destroy_handler( 103 WLAN_TARGET_IF_COMP_DIRECT_BUF_RX, 104 target_if_direct_buf_rx_pdev_destroy_handler, 105 NULL); 106 107 if (QDF_IS_STATUS_ERROR(status)) 108 direct_buf_rx_err("Failed to unregister pdev destroy handler"); 109 110 status = wlan_objmgr_unregister_pdev_create_handler( 111 WLAN_TARGET_IF_COMP_DIRECT_BUF_RX, 112 target_if_direct_buf_rx_pdev_create_handler, 113 NULL); 114 115 if (QDF_IS_STATUS_ERROR(status)) 116 direct_buf_rx_err("Failed to unregister pdev create handler"); 117 118 status = wlan_objmgr_unregister_psoc_destroy_handler( 119 WLAN_TARGET_IF_COMP_DIRECT_BUF_RX, 120 target_if_direct_buf_rx_psoc_destroy_handler, 121 NULL); 122 123 if (QDF_IS_STATUS_ERROR(status)) 124 direct_buf_rx_err("Failed to unregister psoc destroy handler"); 125 126 status = wlan_objmgr_unregister_psoc_create_handler( 127 WLAN_TARGET_IF_COMP_DIRECT_BUF_RX, 128 target_if_direct_buf_rx_psoc_create_handler, 129 NULL); 130 131 if (QDF_IS_STATUS_ERROR(status)) 132 direct_buf_rx_err("Failed to unregister psoc create handler"); 133 134 direct_buf_rx_info("Direct Buffer RX pdev,psoc create and destroy handlers unregistered"); 135 136 return status; 137 } 138 qdf_export_symbol(direct_buf_rx_deinit); 139 140 QDF_STATUS direct_buf_rx_target_attach(struct wlan_objmgr_psoc *psoc, 141 void *hal_soc, qdf_device_t osdev) 142 { 143 struct direct_buf_rx_psoc_obj *dbr_psoc_obj; 144 145 if (hal_soc == NULL || osdev == NULL) { 146 direct_buf_rx_err("hal soc or osdev is null"); 147 return QDF_STATUS_E_INVAL; 148 } 149 150 dbr_psoc_obj = wlan_objmgr_psoc_get_comp_private_obj(psoc, 151 WLAN_TARGET_IF_COMP_DIRECT_BUF_RX); 152 153 direct_buf_rx_info("Dbr psoc obj %pK", dbr_psoc_obj); 154 155 if (dbr_psoc_obj == NULL) { 156 direct_buf_rx_err("dir buf rx psoc obj is null"); 157 return QDF_STATUS_E_FAILURE; 158 } 159 160 dbr_psoc_obj->hal_soc = hal_soc; 161 dbr_psoc_obj->osdev = osdev; 162 163 return QDF_STATUS_SUCCESS; 164 } 165 166 void target_if_direct_buf_rx_register_tx_ops(struct wlan_lmac_if_tx_ops *tx_ops) 167 { 168 tx_ops->dbr_tx_ops.direct_buf_rx_module_register = 169 target_if_direct_buf_rx_module_register; 170 tx_ops->dbr_tx_ops.direct_buf_rx_register_events = 171 target_if_direct_buf_rx_register_events; 172 tx_ops->dbr_tx_ops.direct_buf_rx_unregister_events = 173 target_if_direct_buf_rx_unregister_events; 174 } 175 qdf_export_symbol(target_if_direct_buf_rx_register_tx_ops); 176