Sravan Kumar Kairam | 4af61cf | 2018-02-22 17:53:44 +0530 | [diff] [blame^] | 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 | * DOC: public API related to the wlan ipa called by north bound HDD/OSIF |
| 20 | */ |
| 21 | |
| 22 | #include "wlan_ipa_obj_mgmt_api.h" |
| 23 | #include "wlan_ipa_main.h" |
| 24 | #include "wlan_objmgr_global_obj.h" |
| 25 | #include "target_if_ipa.h" |
| 26 | |
| 27 | /** |
| 28 | * ipa_pdev_obj_destroy_notification() - IPA pdev object destroy notification |
| 29 | * @pdev: pdev handle |
| 30 | * @arg_list: arguments list |
| 31 | * |
| 32 | * Return: QDF_STATUS_SUCCESS on success |
| 33 | */ |
| 34 | static QDF_STATUS |
| 35 | ipa_pdev_obj_destroy_notification(struct wlan_objmgr_pdev *pdev, |
| 36 | void *arg_list) |
| 37 | { |
| 38 | QDF_STATUS status; |
| 39 | struct wlan_ipa_priv *ipa_obj; |
| 40 | |
| 41 | ipa_obj = wlan_objmgr_pdev_get_comp_private_obj(pdev, |
| 42 | WLAN_UMAC_COMP_IPA); |
| 43 | if (!ipa_obj) { |
| 44 | ipa_err("Failed to get ipa pdev object"); |
| 45 | return QDF_STATUS_E_FAILURE; |
| 46 | } |
| 47 | |
| 48 | status = wlan_objmgr_pdev_component_obj_detach(pdev, |
| 49 | WLAN_UMAC_COMP_IPA, |
| 50 | ipa_obj); |
| 51 | if (QDF_IS_STATUS_ERROR(status)) |
| 52 | ipa_err("Failed to detatch ipa pdev object"); |
| 53 | |
| 54 | qdf_mem_free(ipa_obj); |
| 55 | |
| 56 | return status; |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * ipa_pdev_obj_create_notification() - IPA pdev object creation notification |
| 61 | * @pdev: pdev handle |
| 62 | * @arg_list: arguments list |
| 63 | * |
| 64 | * Return: QDF_STATUS_SUCCESS on success |
| 65 | */ |
| 66 | static QDF_STATUS |
| 67 | ipa_pdev_obj_create_notification(struct wlan_objmgr_pdev *pdev, |
| 68 | void *arg_list) |
| 69 | { |
| 70 | QDF_STATUS status; |
| 71 | struct wlan_ipa_priv *ipa_obj; |
| 72 | |
| 73 | ipa_info("ipa pdev created"); |
| 74 | |
| 75 | ipa_obj = qdf_mem_malloc(sizeof(*ipa_obj)); |
| 76 | if (!ipa_obj) { |
| 77 | ipa_err("Failed to allocate memory for ipa pdev object"); |
| 78 | return QDF_STATUS_E_FAILURE; |
| 79 | } |
| 80 | |
| 81 | status = wlan_objmgr_pdev_component_obj_attach(pdev, |
| 82 | WLAN_UMAC_COMP_IPA, |
| 83 | (void *)ipa_obj, |
| 84 | QDF_STATUS_SUCCESS); |
| 85 | if (QDF_IS_STATUS_ERROR(status)) { |
| 86 | ipa_err("Failed to attach pdev ipa component"); |
| 87 | qdf_mem_free(ipa_obj); |
| 88 | return status; |
| 89 | } |
| 90 | |
| 91 | target_if_ipa_register_tx_ops(ipa_obj->ipa_tx_op); |
| 92 | |
| 93 | ipa_info("ipa pdev attached"); |
| 94 | |
| 95 | return status; |
| 96 | } |
| 97 | |
| 98 | QDF_STATUS ipa_init(void) |
| 99 | { |
| 100 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
| 101 | |
| 102 | ipa_info("ipa module dispatcher init"); |
| 103 | |
| 104 | if (!wlan_ipa_is_present()) { |
| 105 | ipa_info("ipa hw not present"); |
| 106 | return status; |
| 107 | } |
| 108 | |
| 109 | status = wlan_objmgr_register_pdev_create_handler(WLAN_UMAC_COMP_IPA, |
| 110 | ipa_pdev_obj_create_notification, NULL); |
| 111 | |
| 112 | if (QDF_IS_STATUS_ERROR(status)) { |
| 113 | ipa_err("Failed to register pdev create handler for ipa"); |
| 114 | |
| 115 | return status; |
| 116 | } |
| 117 | |
| 118 | status = wlan_objmgr_register_pdev_destroy_handler(WLAN_UMAC_COMP_IPA, |
| 119 | ipa_pdev_obj_destroy_notification, NULL); |
| 120 | |
| 121 | if (QDF_IS_STATUS_ERROR(status)) { |
| 122 | ipa_err("Failed to register pdev destroy handler for ipa"); |
| 123 | goto fail_delete_pdev; |
| 124 | } |
| 125 | |
| 126 | return status; |
| 127 | |
| 128 | fail_delete_pdev: |
| 129 | wlan_objmgr_unregister_pdev_create_handler(WLAN_UMAC_COMP_IPA, |
| 130 | ipa_pdev_obj_create_notification, NULL); |
| 131 | |
| 132 | return status; |
| 133 | } |
| 134 | |
| 135 | QDF_STATUS ipa_deinit(void) |
| 136 | { |
| 137 | QDF_STATUS status = QDF_STATUS_SUCCESS; |
| 138 | |
| 139 | ipa_info("ipa module dispatcher deinit"); |
| 140 | |
| 141 | if (!wlan_ipa_is_present()) { |
| 142 | ipa_info("ipa hw not present"); |
| 143 | return status; |
| 144 | } |
| 145 | |
| 146 | status = wlan_objmgr_unregister_pdev_destroy_handler(WLAN_UMAC_COMP_IPA, |
| 147 | ipa_pdev_obj_destroy_notification, NULL); |
| 148 | if (QDF_IS_STATUS_ERROR(status)) |
| 149 | ipa_err("Failed to unregister pdev destroy handler"); |
| 150 | |
| 151 | status = wlan_objmgr_unregister_pdev_create_handler(WLAN_UMAC_COMP_IPA, |
| 152 | ipa_pdev_obj_create_notification, NULL); |
| 153 | if (QDF_IS_STATUS_ERROR(status)) |
| 154 | ipa_err("Failed to unregister pdev create handler"); |
| 155 | |
| 156 | return status; |
| 157 | } |