Rajeev Kumar Sirasanagandla | 4725ae4 | 2018-05-24 22:33:34 +0530 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2012-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: Public API implementation of action_oui called by north bound HDD/OSIF. |
| 21 | */ |
| 22 | |
| 23 | #include "wlan_action_oui_ucfg_api.h" |
| 24 | #include "wlan_action_oui_main.h" |
| 25 | #include "wlan_action_oui_main.h" |
| 26 | #include "target_if_action_oui.h" |
| 27 | #include "wlan_action_oui_tgt_api.h" |
| 28 | #include <qdf_str.h> |
| 29 | |
| 30 | QDF_STATUS ucfg_action_oui_init(void) |
| 31 | { |
| 32 | QDF_STATUS status; |
| 33 | |
| 34 | ACTION_OUI_ENTER(); |
| 35 | |
| 36 | status = wlan_objmgr_register_psoc_create_handler( |
| 37 | WLAN_UMAC_COMP_ACTION_OUI, |
| 38 | action_oui_psoc_create_notification, NULL); |
| 39 | if (!QDF_IS_STATUS_SUCCESS(status)) { |
| 40 | action_oui_err("Failed to register psoc create handler"); |
| 41 | goto exit; |
| 42 | } |
| 43 | |
| 44 | status = wlan_objmgr_register_psoc_destroy_handler( |
| 45 | WLAN_UMAC_COMP_ACTION_OUI, |
| 46 | action_oui_psoc_destroy_notification, NULL); |
| 47 | if (QDF_IS_STATUS_SUCCESS(status)) { |
| 48 | action_oui_debug("psoc create/delete notifications registered"); |
| 49 | goto exit; |
| 50 | } |
| 51 | |
| 52 | action_oui_err("Failed to register psoc delete handler"); |
| 53 | wlan_objmgr_unregister_psoc_create_handler(WLAN_UMAC_COMP_ACTION_OUI, |
| 54 | action_oui_psoc_create_notification, NULL); |
| 55 | |
| 56 | exit: |
| 57 | ACTION_OUI_EXIT(); |
| 58 | return status; |
| 59 | } |
| 60 | |
| 61 | void ucfg_action_oui_deinit(void) |
| 62 | { |
| 63 | QDF_STATUS status; |
| 64 | |
| 65 | ACTION_OUI_ENTER(); |
| 66 | |
| 67 | status = wlan_objmgr_unregister_psoc_create_handler( |
| 68 | WLAN_UMAC_COMP_ACTION_OUI, |
| 69 | action_oui_psoc_create_notification, NULL); |
| 70 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 71 | action_oui_err("Failed to unregister psoc create handler"); |
| 72 | |
| 73 | status = wlan_objmgr_unregister_psoc_destroy_handler( |
| 74 | WLAN_UMAC_COMP_ACTION_OUI, |
| 75 | action_oui_psoc_destroy_notification, |
| 76 | NULL); |
| 77 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 78 | action_oui_err("Failed to unregister psoc delete handler"); |
| 79 | |
| 80 | ACTION_OUI_EXIT(); |
| 81 | } |
| 82 | |
| 83 | QDF_STATUS |
| 84 | ucfg_action_oui_parse(struct wlan_objmgr_psoc *psoc, |
| 85 | const uint8_t *in_str, |
| 86 | enum action_oui_id action_id) |
| 87 | { |
| 88 | struct action_oui_psoc_priv *psoc_priv; |
| 89 | QDF_STATUS status = QDF_STATUS_E_INVAL; |
| 90 | uint8_t *oui_str; |
| 91 | int len; |
| 92 | |
| 93 | ACTION_OUI_ENTER(); |
| 94 | |
| 95 | if (!psoc) { |
| 96 | action_oui_err("psoc is NULL"); |
| 97 | goto exit; |
| 98 | } |
| 99 | |
| 100 | if (action_id >= ACTION_OUI_MAXIMUM_ID) { |
| 101 | action_oui_err("Invalid action_oui id: %u", action_id); |
| 102 | goto exit; |
| 103 | } |
| 104 | |
| 105 | psoc_priv = action_oui_psoc_get_priv(psoc); |
| 106 | if (!psoc_priv) { |
| 107 | action_oui_err("psoc priv is NULL"); |
| 108 | goto exit; |
| 109 | } |
| 110 | |
| 111 | len = qdf_str_len(in_str); |
| 112 | if (len <= 0 || len > ACTION_OUI_MAX_STR_LEN - 1) { |
| 113 | action_oui_err("Invalid string length: %u", action_id); |
| 114 | goto exit; |
| 115 | } |
| 116 | |
| 117 | oui_str = qdf_mem_malloc(len + 1); |
| 118 | if (!oui_str) { |
| 119 | action_oui_err("Mem alloc failed for string: %u", action_id); |
| 120 | status = QDF_STATUS_E_NOMEM; |
| 121 | goto exit; |
| 122 | } |
| 123 | |
| 124 | qdf_mem_copy(oui_str, in_str, len); |
| 125 | oui_str[len] = '\0'; |
| 126 | |
| 127 | status = action_oui_parse(psoc_priv, oui_str, action_id); |
| 128 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 129 | action_oui_err("Failed to parse: %u", action_id); |
| 130 | |
| 131 | qdf_mem_free(oui_str); |
| 132 | |
| 133 | exit: |
| 134 | ACTION_OUI_EXIT(); |
| 135 | return status; |
| 136 | } |
| 137 | |
| 138 | QDF_STATUS ucfg_action_oui_send(struct wlan_objmgr_psoc *psoc) |
| 139 | { |
| 140 | struct action_oui_psoc_priv *psoc_priv; |
| 141 | QDF_STATUS status = QDF_STATUS_E_INVAL; |
| 142 | uint32_t id; |
| 143 | |
| 144 | ACTION_OUI_ENTER(); |
| 145 | |
| 146 | if (!psoc) { |
| 147 | action_oui_err("psoc is NULL"); |
| 148 | goto exit; |
| 149 | } |
| 150 | |
| 151 | psoc_priv = action_oui_psoc_get_priv(psoc); |
| 152 | if (!psoc_priv) { |
| 153 | action_oui_err("psoc priv is NULL"); |
| 154 | goto exit; |
| 155 | } |
| 156 | |
| 157 | for (id = 0; id < ACTION_OUI_MAXIMUM_ID; id++) { |
| 158 | status = action_oui_send(psoc_priv, id); |
| 159 | if (!QDF_IS_STATUS_SUCCESS(status)) |
| 160 | action_oui_err("Failed to send: %u", id); |
| 161 | } |
| 162 | |
| 163 | exit: |
| 164 | ACTION_OUI_EXIT(); |
| 165 | return status; |
| 166 | } |
| 167 | |
| 168 | bool ucfg_action_oui_search(struct wlan_objmgr_psoc *psoc, |
| 169 | struct action_oui_search_attr *attr, |
| 170 | enum action_oui_id action_id) |
| 171 | { |
| 172 | struct action_oui_psoc_priv *psoc_priv; |
| 173 | bool found = false; |
| 174 | |
| 175 | ACTION_OUI_ENTER(); |
| 176 | |
| 177 | if (!psoc || !attr) { |
| 178 | action_oui_err("Invalid psoc or search attrs"); |
| 179 | goto exit; |
| 180 | } |
| 181 | |
| 182 | if (action_id >= ACTION_OUI_MAXIMUM_ID || |
| 183 | !attr->ie_data || !attr->ie_length) { |
| 184 | action_oui_err("Invalid action_oui id: %u", action_id); |
| 185 | goto exit; |
| 186 | } |
| 187 | |
| 188 | psoc_priv = action_oui_psoc_get_priv(psoc); |
| 189 | if (!psoc_priv) { |
| 190 | action_oui_err("psoc priv is NULL"); |
| 191 | goto exit; |
| 192 | } |
| 193 | |
| 194 | found = action_oui_search(psoc_priv, attr, action_id); |
| 195 | if (found) |
| 196 | action_oui_debug("Search Successful"); |
| 197 | |
| 198 | exit: |
| 199 | ACTION_OUI_EXIT(); |
| 200 | return found; |
| 201 | } |