Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 17 | #include <android-base/logging.h> |
| 18 | |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 19 | #include "hidl_return_util.h" |
Roshan Pius | e2d0ab5 | 2016-12-05 15:24:20 -0800 | [diff] [blame] | 20 | #include "hidl_struct_util.h" |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 21 | #include "wifi_chip.h" |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 22 | #include "wifi_status_util.h" |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 23 | |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 24 | namespace { |
| 25 | using android::sp; |
| 26 | using android::hardware::hidl_vec; |
| 27 | using android::hardware::hidl_string; |
Roshan Pius | 52947fb | 2016-11-18 11:38:07 -0800 | [diff] [blame] | 28 | using android::hardware::wifi::V1_0::IWifiChip; |
| 29 | using android::hardware::wifi::V1_0::IfaceType; |
| 30 | |
| 31 | constexpr uint32_t kStaChipModeId = 0; |
| 32 | constexpr uint32_t kApChipModeId = 1; |
| 33 | constexpr uint32_t kInvalidModeId = UINT32_MAX; |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 34 | |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 35 | template <typename Iface> |
| 36 | void invalidateAndClear(sp<Iface>& iface) { |
| 37 | if (iface.get()) { |
| 38 | iface->invalidate(); |
| 39 | iface.clear(); |
| 40 | } |
| 41 | } |
| 42 | } // namepsace |
| 43 | |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 44 | namespace android { |
| 45 | namespace hardware { |
| 46 | namespace wifi { |
Roshan Pius | 79a9975 | 2016-10-04 13:03:58 -0700 | [diff] [blame] | 47 | namespace V1_0 { |
| 48 | namespace implementation { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 49 | using hidl_return_util::validateAndCall; |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 50 | |
Roshan Pius | 52947fb | 2016-11-18 11:38:07 -0800 | [diff] [blame] | 51 | WifiChip::WifiChip( |
| 52 | ChipId chip_id, |
| 53 | const std::weak_ptr<legacy_hal::WifiLegacyHal> legacy_hal, |
| 54 | const std::weak_ptr<mode_controller::WifiModeController> mode_controller) |
| 55 | : chip_id_(chip_id), |
| 56 | legacy_hal_(legacy_hal), |
| 57 | mode_controller_(mode_controller), |
| 58 | is_valid_(true), |
| 59 | current_mode_id_(kInvalidModeId) {} |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 60 | |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 61 | void WifiChip::invalidate() { |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 62 | invalidateAndRemoveAllIfaces(); |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 63 | legacy_hal_.reset(); |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 64 | event_callbacks_.clear(); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 65 | is_valid_ = false; |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 66 | } |
| 67 | |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 68 | bool WifiChip::isValid() { |
| 69 | return is_valid_; |
| 70 | } |
| 71 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 72 | Return<void> WifiChip::getId(getId_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 73 | return validateAndCall(this, |
| 74 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 75 | &WifiChip::getIdInternal, |
| 76 | hidl_status_cb); |
Roshan Pius | cd566bd | 2016-10-10 08:03:42 -0700 | [diff] [blame] | 77 | } |
| 78 | |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 79 | Return<void> WifiChip::registerEventCallback( |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 80 | const sp<IWifiChipEventCallback>& event_callback, |
| 81 | registerEventCallback_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 82 | return validateAndCall(this, |
| 83 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 84 | &WifiChip::registerEventCallbackInternal, |
| 85 | hidl_status_cb, |
| 86 | event_callback); |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 87 | } |
| 88 | |
Roshan Pius | 7d08d7a | 2016-10-27 14:35:05 -0700 | [diff] [blame] | 89 | Return<void> WifiChip::getCapabilities(getCapabilities_cb hidl_status_cb) { |
| 90 | return validateAndCall(this, |
| 91 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 92 | &WifiChip::getCapabilitiesInternal, |
| 93 | hidl_status_cb); |
| 94 | } |
| 95 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 96 | Return<void> WifiChip::getAvailableModes(getAvailableModes_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 97 | return validateAndCall(this, |
| 98 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 99 | &WifiChip::getAvailableModesInternal, |
| 100 | hidl_status_cb); |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 101 | } |
| 102 | |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 103 | Return<void> WifiChip::configureChip(uint32_t mode_id, |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 104 | configureChip_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 105 | return validateAndCall(this, |
| 106 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 107 | &WifiChip::configureChipInternal, |
| 108 | hidl_status_cb, |
| 109 | mode_id); |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 110 | } |
| 111 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 112 | Return<void> WifiChip::getMode(getMode_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 113 | return validateAndCall(this, |
| 114 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 115 | &WifiChip::getModeInternal, |
| 116 | hidl_status_cb); |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 117 | } |
| 118 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 119 | Return<void> WifiChip::requestChipDebugInfo( |
| 120 | requestChipDebugInfo_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 121 | return validateAndCall(this, |
| 122 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 123 | &WifiChip::requestChipDebugInfoInternal, |
| 124 | hidl_status_cb); |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | Return<void> WifiChip::requestDriverDebugDump( |
| 128 | requestDriverDebugDump_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 129 | return validateAndCall(this, |
| 130 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 131 | &WifiChip::requestDriverDebugDumpInternal, |
| 132 | hidl_status_cb); |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 133 | } |
| 134 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 135 | Return<void> WifiChip::requestFirmwareDebugDump( |
| 136 | requestFirmwareDebugDump_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 137 | return validateAndCall(this, |
| 138 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 139 | &WifiChip::requestFirmwareDebugDumpInternal, |
| 140 | hidl_status_cb); |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 141 | } |
| 142 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 143 | Return<void> WifiChip::createApIface(createApIface_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 144 | return validateAndCall(this, |
| 145 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 146 | &WifiChip::createApIfaceInternal, |
| 147 | hidl_status_cb); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 148 | } |
| 149 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 150 | Return<void> WifiChip::getApIfaceNames(getApIfaceNames_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 151 | return validateAndCall(this, |
| 152 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 153 | &WifiChip::getApIfaceNamesInternal, |
| 154 | hidl_status_cb); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 155 | } |
| 156 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 157 | Return<void> WifiChip::getApIface(const hidl_string& ifname, |
| 158 | getApIface_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 159 | return validateAndCall(this, |
| 160 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 161 | &WifiChip::getApIfaceInternal, |
| 162 | hidl_status_cb, |
| 163 | ifname); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 164 | } |
| 165 | |
Roshan Pius | 8b55e6f | 2016-12-09 12:05:12 -0800 | [diff] [blame^] | 166 | Return<void> WifiChip::removeApIface(const hidl_string& ifname, |
| 167 | removeApIface_cb hidl_status_cb) { |
| 168 | return validateAndCall(this, |
| 169 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 170 | &WifiChip::removeApIfaceInternal, |
| 171 | hidl_status_cb, |
| 172 | ifname); |
| 173 | } |
| 174 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 175 | Return<void> WifiChip::createNanIface(createNanIface_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 176 | return validateAndCall(this, |
| 177 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 178 | &WifiChip::createNanIfaceInternal, |
| 179 | hidl_status_cb); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 180 | } |
| 181 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 182 | Return<void> WifiChip::getNanIfaceNames(getNanIfaceNames_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 183 | return validateAndCall(this, |
| 184 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 185 | &WifiChip::getNanIfaceNamesInternal, |
| 186 | hidl_status_cb); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | Return<void> WifiChip::getNanIface(const hidl_string& ifname, |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 190 | getNanIface_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 191 | return validateAndCall(this, |
| 192 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 193 | &WifiChip::getNanIfaceInternal, |
| 194 | hidl_status_cb, |
| 195 | ifname); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 196 | } |
| 197 | |
Roshan Pius | 8b55e6f | 2016-12-09 12:05:12 -0800 | [diff] [blame^] | 198 | Return<void> WifiChip::removeNanIface(const hidl_string& ifname, |
| 199 | removeNanIface_cb hidl_status_cb) { |
| 200 | return validateAndCall(this, |
| 201 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 202 | &WifiChip::removeNanIfaceInternal, |
| 203 | hidl_status_cb, |
| 204 | ifname); |
| 205 | } |
| 206 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 207 | Return<void> WifiChip::createP2pIface(createP2pIface_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 208 | return validateAndCall(this, |
| 209 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 210 | &WifiChip::createP2pIfaceInternal, |
| 211 | hidl_status_cb); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 212 | } |
| 213 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 214 | Return<void> WifiChip::getP2pIfaceNames(getP2pIfaceNames_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 215 | return validateAndCall(this, |
| 216 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 217 | &WifiChip::getP2pIfaceNamesInternal, |
| 218 | hidl_status_cb); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 219 | } |
| 220 | |
| 221 | Return<void> WifiChip::getP2pIface(const hidl_string& ifname, |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 222 | getP2pIface_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 223 | return validateAndCall(this, |
| 224 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 225 | &WifiChip::getP2pIfaceInternal, |
| 226 | hidl_status_cb, |
| 227 | ifname); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 228 | } |
| 229 | |
Roshan Pius | 8b55e6f | 2016-12-09 12:05:12 -0800 | [diff] [blame^] | 230 | Return<void> WifiChip::removeP2pIface(const hidl_string& ifname, |
| 231 | removeP2pIface_cb hidl_status_cb) { |
| 232 | return validateAndCall(this, |
| 233 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 234 | &WifiChip::removeP2pIfaceInternal, |
| 235 | hidl_status_cb, |
| 236 | ifname); |
| 237 | } |
| 238 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 239 | Return<void> WifiChip::createStaIface(createStaIface_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 240 | return validateAndCall(this, |
| 241 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 242 | &WifiChip::createStaIfaceInternal, |
| 243 | hidl_status_cb); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 244 | } |
| 245 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 246 | Return<void> WifiChip::getStaIfaceNames(getStaIfaceNames_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 247 | return validateAndCall(this, |
| 248 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 249 | &WifiChip::getStaIfaceNamesInternal, |
| 250 | hidl_status_cb); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 251 | } |
| 252 | |
| 253 | Return<void> WifiChip::getStaIface(const hidl_string& ifname, |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 254 | getStaIface_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 255 | return validateAndCall(this, |
| 256 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 257 | &WifiChip::getStaIfaceInternal, |
| 258 | hidl_status_cb, |
| 259 | ifname); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 260 | } |
| 261 | |
Roshan Pius | 8b55e6f | 2016-12-09 12:05:12 -0800 | [diff] [blame^] | 262 | Return<void> WifiChip::removeStaIface(const hidl_string& ifname, |
| 263 | removeStaIface_cb hidl_status_cb) { |
| 264 | return validateAndCall(this, |
| 265 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 266 | &WifiChip::removeStaIfaceInternal, |
| 267 | hidl_status_cb, |
| 268 | ifname); |
| 269 | } |
| 270 | |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame] | 271 | Return<void> WifiChip::createRttController( |
| 272 | const sp<IWifiIface>& bound_iface, createRttController_cb hidl_status_cb) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 273 | return validateAndCall(this, |
| 274 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 275 | &WifiChip::createRttControllerInternal, |
| 276 | hidl_status_cb, |
| 277 | bound_iface); |
Roshan Pius | 5926828 | 2016-10-06 20:23:47 -0700 | [diff] [blame] | 278 | } |
| 279 | |
Roshan Pius | 7d08d7a | 2016-10-27 14:35:05 -0700 | [diff] [blame] | 280 | Return<void> WifiChip::getDebugRingBuffersStatus( |
| 281 | getDebugRingBuffersStatus_cb hidl_status_cb) { |
| 282 | return validateAndCall(this, |
| 283 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 284 | &WifiChip::getDebugRingBuffersStatusInternal, |
| 285 | hidl_status_cb); |
| 286 | } |
| 287 | |
| 288 | Return<void> WifiChip::startLoggingToDebugRingBuffer( |
| 289 | const hidl_string& ring_name, |
| 290 | WifiDebugRingBufferVerboseLevel verbose_level, |
| 291 | uint32_t max_interval_in_sec, |
| 292 | uint32_t min_data_size_in_bytes, |
| 293 | startLoggingToDebugRingBuffer_cb hidl_status_cb) { |
| 294 | return validateAndCall(this, |
| 295 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 296 | &WifiChip::startLoggingToDebugRingBufferInternal, |
| 297 | hidl_status_cb, |
| 298 | ring_name, |
| 299 | verbose_level, |
| 300 | max_interval_in_sec, |
| 301 | min_data_size_in_bytes); |
| 302 | } |
| 303 | |
| 304 | Return<void> WifiChip::forceDumpToDebugRingBuffer( |
| 305 | const hidl_string& ring_name, |
| 306 | forceDumpToDebugRingBuffer_cb hidl_status_cb) { |
| 307 | return validateAndCall(this, |
| 308 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 309 | &WifiChip::forceDumpToDebugRingBufferInternal, |
| 310 | hidl_status_cb, |
| 311 | ring_name); |
| 312 | } |
| 313 | |
| 314 | Return<void> WifiChip::getDebugHostWakeReasonStats( |
| 315 | getDebugHostWakeReasonStats_cb hidl_status_cb) { |
| 316 | return validateAndCall(this, |
| 317 | WifiStatusCode::ERROR_WIFI_CHIP_INVALID, |
| 318 | &WifiChip::getDebugHostWakeReasonStatsInternal, |
| 319 | hidl_status_cb); |
| 320 | } |
| 321 | |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 322 | void WifiChip::invalidateAndRemoveAllIfaces() { |
| 323 | invalidateAndClear(ap_iface_); |
| 324 | invalidateAndClear(nan_iface_); |
| 325 | invalidateAndClear(p2p_iface_); |
| 326 | invalidateAndClear(sta_iface_); |
Roshan Pius | 5926828 | 2016-10-06 20:23:47 -0700 | [diff] [blame] | 327 | // Since all the ifaces are invalid now, all RTT controller objects |
| 328 | // using those ifaces also need to be invalidated. |
| 329 | for (const auto& rtt : rtt_controllers_) { |
| 330 | rtt->invalidate(); |
| 331 | } |
| 332 | rtt_controllers_.clear(); |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 333 | } |
| 334 | |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 335 | std::pair<WifiStatus, ChipId> WifiChip::getIdInternal() { |
| 336 | return {createWifiStatus(WifiStatusCode::SUCCESS), chip_id_}; |
| 337 | } |
| 338 | |
| 339 | WifiStatus WifiChip::registerEventCallbackInternal( |
| 340 | const sp<IWifiChipEventCallback>& event_callback) { |
| 341 | // TODO(b/31632518): remove the callback when the client is destroyed |
| 342 | event_callbacks_.emplace_back(event_callback); |
| 343 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 344 | } |
| 345 | |
Roshan Pius | 7d08d7a | 2016-10-27 14:35:05 -0700 | [diff] [blame] | 346 | std::pair<WifiStatus, uint32_t> WifiChip::getCapabilitiesInternal() { |
Roshan Pius | e2d0ab5 | 2016-12-05 15:24:20 -0800 | [diff] [blame] | 347 | legacy_hal::wifi_error legacy_status; |
| 348 | uint32_t legacy_logger_feature_set; |
| 349 | std::tie(legacy_status, legacy_logger_feature_set) = |
| 350 | legacy_hal_.lock()->getLoggerSupportedFeatureSet(); |
| 351 | if (legacy_status != legacy_hal::WIFI_SUCCESS) { |
| 352 | return {createWifiStatusFromLegacyError(legacy_status), 0}; |
| 353 | } |
| 354 | uint32_t hidl_caps; |
| 355 | if (!hidl_struct_util::convertLegacyFeaturesToHidlChipCapabilities( |
| 356 | legacy_logger_feature_set, &hidl_caps)) { |
| 357 | return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), 0}; |
| 358 | } |
| 359 | return {createWifiStatus(WifiStatusCode::SUCCESS), hidl_caps}; |
Roshan Pius | 7d08d7a | 2016-10-27 14:35:05 -0700 | [diff] [blame] | 360 | } |
| 361 | |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 362 | std::pair<WifiStatus, std::vector<IWifiChip::ChipMode>> |
| 363 | WifiChip::getAvailableModesInternal() { |
Roshan Pius | 52947fb | 2016-11-18 11:38:07 -0800 | [diff] [blame] | 364 | // The chip combination supported for current devices is fixed for now with |
| 365 | // 2 separate modes of operation: |
| 366 | // Mode 1 (STA mode): Will support 1 STA and 1 P2P or NAN iface operations |
| 367 | // concurrently. |
| 368 | // Mode 2 (AP mode): Will support 1 AP iface operations. |
| 369 | // TODO (b/32997844): Read this from some device specific flags in the |
| 370 | // makefile. |
| 371 | // STA mode iface combinations. |
| 372 | const IWifiChip::ChipIfaceCombinationLimit |
| 373 | sta_chip_iface_combination_limit_1 = {{IfaceType::STA}, 1}; |
| 374 | const IWifiChip::ChipIfaceCombinationLimit |
| 375 | sta_chip_iface_combination_limit_2 = {{IfaceType::P2P, IfaceType::NAN}, |
| 376 | 1}; |
| 377 | const IWifiChip::ChipIfaceCombination sta_chip_iface_combination = { |
| 378 | {sta_chip_iface_combination_limit_1, sta_chip_iface_combination_limit_2}}; |
| 379 | const IWifiChip::ChipMode sta_chip_mode = {kStaChipModeId, |
| 380 | {sta_chip_iface_combination}}; |
| 381 | // AP mode iface combinations. |
| 382 | const IWifiChip::ChipIfaceCombinationLimit ap_chip_iface_combination_limit = { |
| 383 | {IfaceType::AP}, 1}; |
| 384 | const IWifiChip::ChipIfaceCombination ap_chip_iface_combination = { |
| 385 | {ap_chip_iface_combination_limit}}; |
| 386 | const IWifiChip::ChipMode ap_chip_mode = {kApChipModeId, |
| 387 | {ap_chip_iface_combination}}; |
| 388 | return {createWifiStatus(WifiStatusCode::SUCCESS), |
| 389 | {sta_chip_mode, ap_chip_mode}}; |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 390 | } |
| 391 | |
Roshan Pius | 52947fb | 2016-11-18 11:38:07 -0800 | [diff] [blame] | 392 | WifiStatus WifiChip::configureChipInternal(uint32_t mode_id) { |
| 393 | if (mode_id != kStaChipModeId && mode_id != kApChipModeId) { |
| 394 | return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS); |
| 395 | } |
| 396 | if (mode_id == current_mode_id_) { |
| 397 | LOG(DEBUG) << "Already in the specified mode " << mode_id; |
| 398 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 399 | } |
| 400 | // If the chip is already configured in a different mode, stop |
| 401 | // the legacy HAL and then start it after firmware mode change. |
| 402 | if (current_mode_id_ != kInvalidModeId) { |
| 403 | invalidateAndRemoveAllIfaces(); |
| 404 | legacy_hal::wifi_error legacy_status = legacy_hal_.lock()->stop([]() {}); |
| 405 | if (legacy_status != legacy_hal::WIFI_SUCCESS) { |
| 406 | LOG(ERROR) << "Failed to stop legacy HAL: " |
| 407 | << legacyErrorToString(legacy_status); |
| 408 | // TODO(b/33038823): Need to invoke onChipReconfigureFailure() |
| 409 | return createWifiStatusFromLegacyError(legacy_status); |
| 410 | } |
| 411 | } |
| 412 | bool success; |
| 413 | if (mode_id == kStaChipModeId) { |
| 414 | success = mode_controller_.lock()->changeFirmwareMode(IfaceType::STA); |
| 415 | } else { |
| 416 | success = mode_controller_.lock()->changeFirmwareMode(IfaceType::AP); |
| 417 | } |
| 418 | if (!success) { |
| 419 | // TODO(b/33038823): Need to invoke onChipReconfigureFailure() |
| 420 | return createWifiStatus(WifiStatusCode::ERROR_UNKNOWN); |
| 421 | } |
| 422 | legacy_hal::wifi_error legacy_status = legacy_hal_.lock()->start(); |
| 423 | if (legacy_status != legacy_hal::WIFI_SUCCESS) { |
| 424 | LOG(ERROR) << "Failed to start legacy HAL: " |
| 425 | << legacyErrorToString(legacy_status); |
| 426 | // TODO(b/33038823): Need to invoke onChipReconfigureFailure() |
| 427 | return createWifiStatusFromLegacyError(legacy_status); |
| 428 | } |
| 429 | for (const auto& callback : event_callbacks_) { |
| 430 | callback->onChipReconfigured(mode_id); |
| 431 | } |
| 432 | current_mode_id_ = mode_id; |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 433 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 434 | } |
| 435 | |
| 436 | std::pair<WifiStatus, uint32_t> WifiChip::getModeInternal() { |
Roshan Pius | 52947fb | 2016-11-18 11:38:07 -0800 | [diff] [blame] | 437 | if (current_mode_id_ == kInvalidModeId) { |
| 438 | return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), |
| 439 | current_mode_id_}; |
| 440 | } |
| 441 | return {createWifiStatus(WifiStatusCode::SUCCESS), current_mode_id_}; |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 442 | } |
| 443 | |
| 444 | std::pair<WifiStatus, IWifiChip::ChipDebugInfo> |
| 445 | WifiChip::requestChipDebugInfoInternal() { |
| 446 | IWifiChip::ChipDebugInfo result; |
Roshan Pius | a4854ff | 2016-12-01 13:47:41 -0800 | [diff] [blame] | 447 | legacy_hal::wifi_error legacy_status; |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 448 | std::string driver_desc; |
| 449 | std::tie(legacy_status, driver_desc) = legacy_hal_.lock()->getDriverVersion(); |
Roshan Pius | a4854ff | 2016-12-01 13:47:41 -0800 | [diff] [blame] | 450 | if (legacy_status != legacy_hal::WIFI_SUCCESS) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 451 | LOG(ERROR) << "Failed to get driver version: " |
| 452 | << legacyErrorToString(legacy_status); |
| 453 | WifiStatus status = createWifiStatusFromLegacyError( |
| 454 | legacy_status, "failed to get driver version"); |
| 455 | return {status, result}; |
| 456 | } |
| 457 | result.driverDescription = driver_desc.c_str(); |
| 458 | |
| 459 | std::string firmware_desc; |
| 460 | std::tie(legacy_status, firmware_desc) = |
| 461 | legacy_hal_.lock()->getFirmwareVersion(); |
Roshan Pius | a4854ff | 2016-12-01 13:47:41 -0800 | [diff] [blame] | 462 | if (legacy_status != legacy_hal::WIFI_SUCCESS) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 463 | LOG(ERROR) << "Failed to get firmware version: " |
| 464 | << legacyErrorToString(legacy_status); |
| 465 | WifiStatus status = createWifiStatusFromLegacyError( |
| 466 | legacy_status, "failed to get firmware version"); |
| 467 | return {status, result}; |
| 468 | } |
| 469 | result.firmwareDescription = firmware_desc.c_str(); |
| 470 | |
| 471 | return {createWifiStatus(WifiStatusCode::SUCCESS), result}; |
| 472 | } |
| 473 | |
| 474 | std::pair<WifiStatus, std::vector<uint8_t>> |
| 475 | WifiChip::requestDriverDebugDumpInternal() { |
Roshan Pius | a4854ff | 2016-12-01 13:47:41 -0800 | [diff] [blame] | 476 | legacy_hal::wifi_error legacy_status; |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 477 | std::vector<uint8_t> driver_dump; |
| 478 | std::tie(legacy_status, driver_dump) = |
| 479 | legacy_hal_.lock()->requestDriverMemoryDump(); |
Roshan Pius | a4854ff | 2016-12-01 13:47:41 -0800 | [diff] [blame] | 480 | if (legacy_status != legacy_hal::WIFI_SUCCESS) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 481 | LOG(ERROR) << "Failed to get driver debug dump: " |
| 482 | << legacyErrorToString(legacy_status); |
| 483 | return {createWifiStatusFromLegacyError(legacy_status), |
| 484 | std::vector<uint8_t>()}; |
| 485 | } |
| 486 | return {createWifiStatus(WifiStatusCode::SUCCESS), driver_dump}; |
| 487 | } |
| 488 | |
| 489 | std::pair<WifiStatus, std::vector<uint8_t>> |
| 490 | WifiChip::requestFirmwareDebugDumpInternal() { |
Roshan Pius | a4854ff | 2016-12-01 13:47:41 -0800 | [diff] [blame] | 491 | legacy_hal::wifi_error legacy_status; |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 492 | std::vector<uint8_t> firmware_dump; |
| 493 | std::tie(legacy_status, firmware_dump) = |
| 494 | legacy_hal_.lock()->requestFirmwareMemoryDump(); |
Roshan Pius | a4854ff | 2016-12-01 13:47:41 -0800 | [diff] [blame] | 495 | if (legacy_status != legacy_hal::WIFI_SUCCESS) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 496 | LOG(ERROR) << "Failed to get firmware debug dump: " |
| 497 | << legacyErrorToString(legacy_status); |
Roshan Pius | 7d08d7a | 2016-10-27 14:35:05 -0700 | [diff] [blame] | 498 | return {createWifiStatusFromLegacyError(legacy_status), {}}; |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 499 | } |
| 500 | return {createWifiStatus(WifiStatusCode::SUCCESS), firmware_dump}; |
| 501 | } |
| 502 | |
| 503 | std::pair<WifiStatus, sp<IWifiApIface>> WifiChip::createApIfaceInternal() { |
Roshan Pius | 073d5b9 | 2016-12-08 19:10:06 -0800 | [diff] [blame] | 504 | if (current_mode_id_ != kApChipModeId || ap_iface_.get()) { |
| 505 | return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}}; |
| 506 | } |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 507 | std::string ifname = legacy_hal_.lock()->getApIfaceName(); |
| 508 | ap_iface_ = new WifiApIface(ifname, legacy_hal_); |
| 509 | return {createWifiStatus(WifiStatusCode::SUCCESS), ap_iface_}; |
| 510 | } |
| 511 | |
| 512 | std::pair<WifiStatus, std::vector<hidl_string>> |
| 513 | WifiChip::getApIfaceNamesInternal() { |
| 514 | if (!ap_iface_.get()) { |
| 515 | return {createWifiStatus(WifiStatusCode::SUCCESS), {}}; |
| 516 | } |
| 517 | return {createWifiStatus(WifiStatusCode::SUCCESS), |
| 518 | {legacy_hal_.lock()->getApIfaceName()}}; |
| 519 | } |
| 520 | |
| 521 | std::pair<WifiStatus, sp<IWifiApIface>> WifiChip::getApIfaceInternal( |
Roshan Pius | 8b55e6f | 2016-12-09 12:05:12 -0800 | [diff] [blame^] | 522 | const std::string& ifname) { |
| 523 | if (!ap_iface_.get() || (ifname != legacy_hal_.lock()->getApIfaceName())) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 524 | return {createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS), nullptr}; |
| 525 | } |
| 526 | return {createWifiStatus(WifiStatusCode::SUCCESS), ap_iface_}; |
| 527 | } |
| 528 | |
Roshan Pius | 8b55e6f | 2016-12-09 12:05:12 -0800 | [diff] [blame^] | 529 | WifiStatus WifiChip::removeApIfaceInternal(const std::string& ifname) { |
| 530 | if (!ap_iface_.get() || (ifname != legacy_hal_.lock()->getApIfaceName())) { |
| 531 | return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS); |
| 532 | } |
| 533 | invalidateAndClear(ap_iface_); |
| 534 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 535 | } |
| 536 | |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 537 | std::pair<WifiStatus, sp<IWifiNanIface>> WifiChip::createNanIfaceInternal() { |
Roshan Pius | 073d5b9 | 2016-12-08 19:10:06 -0800 | [diff] [blame] | 538 | // Only 1 of NAN or P2P iface can be active at a time. |
| 539 | if (current_mode_id_ != kStaChipModeId || nan_iface_.get() || |
| 540 | p2p_iface_.get()) { |
| 541 | return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}}; |
| 542 | } |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 543 | std::string ifname = legacy_hal_.lock()->getNanIfaceName(); |
| 544 | nan_iface_ = new WifiNanIface(ifname, legacy_hal_); |
| 545 | return {createWifiStatus(WifiStatusCode::SUCCESS), nan_iface_}; |
| 546 | } |
| 547 | |
| 548 | std::pair<WifiStatus, std::vector<hidl_string>> |
| 549 | WifiChip::getNanIfaceNamesInternal() { |
| 550 | if (!nan_iface_.get()) { |
| 551 | return {createWifiStatus(WifiStatusCode::SUCCESS), {}}; |
| 552 | } |
| 553 | return {createWifiStatus(WifiStatusCode::SUCCESS), |
| 554 | {legacy_hal_.lock()->getNanIfaceName()}}; |
| 555 | } |
| 556 | |
| 557 | std::pair<WifiStatus, sp<IWifiNanIface>> WifiChip::getNanIfaceInternal( |
Roshan Pius | 8b55e6f | 2016-12-09 12:05:12 -0800 | [diff] [blame^] | 558 | const std::string& ifname) { |
| 559 | if (!nan_iface_.get() || (ifname != legacy_hal_.lock()->getNanIfaceName())) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 560 | return {createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS), nullptr}; |
| 561 | } |
| 562 | return {createWifiStatus(WifiStatusCode::SUCCESS), nan_iface_}; |
| 563 | } |
| 564 | |
Roshan Pius | 8b55e6f | 2016-12-09 12:05:12 -0800 | [diff] [blame^] | 565 | WifiStatus WifiChip::removeNanIfaceInternal(const std::string& ifname) { |
| 566 | if (!nan_iface_.get() || (ifname != legacy_hal_.lock()->getNanIfaceName())) { |
| 567 | return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS); |
| 568 | } |
| 569 | invalidateAndClear(nan_iface_); |
| 570 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 571 | } |
| 572 | |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 573 | std::pair<WifiStatus, sp<IWifiP2pIface>> WifiChip::createP2pIfaceInternal() { |
Roshan Pius | 073d5b9 | 2016-12-08 19:10:06 -0800 | [diff] [blame] | 574 | // Only 1 of NAN or P2P iface can be active at a time. |
| 575 | if (current_mode_id_ != kStaChipModeId || p2p_iface_.get() || |
| 576 | nan_iface_.get()) { |
| 577 | return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}}; |
| 578 | } |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 579 | std::string ifname = legacy_hal_.lock()->getP2pIfaceName(); |
| 580 | p2p_iface_ = new WifiP2pIface(ifname, legacy_hal_); |
| 581 | return {createWifiStatus(WifiStatusCode::SUCCESS), p2p_iface_}; |
| 582 | } |
| 583 | |
| 584 | std::pair<WifiStatus, std::vector<hidl_string>> |
| 585 | WifiChip::getP2pIfaceNamesInternal() { |
| 586 | if (!p2p_iface_.get()) { |
| 587 | return {createWifiStatus(WifiStatusCode::SUCCESS), {}}; |
| 588 | } |
| 589 | return {createWifiStatus(WifiStatusCode::SUCCESS), |
| 590 | {legacy_hal_.lock()->getP2pIfaceName()}}; |
| 591 | } |
| 592 | |
| 593 | std::pair<WifiStatus, sp<IWifiP2pIface>> WifiChip::getP2pIfaceInternal( |
Roshan Pius | 8b55e6f | 2016-12-09 12:05:12 -0800 | [diff] [blame^] | 594 | const std::string& ifname) { |
| 595 | if (!p2p_iface_.get() || (ifname != legacy_hal_.lock()->getP2pIfaceName())) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 596 | return {createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS), nullptr}; |
| 597 | } |
| 598 | return {createWifiStatus(WifiStatusCode::SUCCESS), p2p_iface_}; |
| 599 | } |
| 600 | |
Roshan Pius | 8b55e6f | 2016-12-09 12:05:12 -0800 | [diff] [blame^] | 601 | WifiStatus WifiChip::removeP2pIfaceInternal(const std::string& ifname) { |
| 602 | if (!p2p_iface_.get() || (ifname != legacy_hal_.lock()->getP2pIfaceName())) { |
| 603 | return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS); |
| 604 | } |
| 605 | invalidateAndClear(p2p_iface_); |
| 606 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 607 | } |
| 608 | |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 609 | std::pair<WifiStatus, sp<IWifiStaIface>> WifiChip::createStaIfaceInternal() { |
Roshan Pius | 073d5b9 | 2016-12-08 19:10:06 -0800 | [diff] [blame] | 610 | if (current_mode_id_ != kStaChipModeId || sta_iface_.get()) { |
| 611 | return {createWifiStatus(WifiStatusCode::ERROR_NOT_AVAILABLE), {}}; |
| 612 | } |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 613 | std::string ifname = legacy_hal_.lock()->getStaIfaceName(); |
| 614 | sta_iface_ = new WifiStaIface(ifname, legacy_hal_); |
| 615 | return {createWifiStatus(WifiStatusCode::SUCCESS), sta_iface_}; |
| 616 | } |
| 617 | |
| 618 | std::pair<WifiStatus, std::vector<hidl_string>> |
| 619 | WifiChip::getStaIfaceNamesInternal() { |
| 620 | if (!sta_iface_.get()) { |
| 621 | return {createWifiStatus(WifiStatusCode::SUCCESS), {}}; |
| 622 | } |
| 623 | return {createWifiStatus(WifiStatusCode::SUCCESS), |
| 624 | {legacy_hal_.lock()->getStaIfaceName()}}; |
| 625 | } |
| 626 | |
| 627 | std::pair<WifiStatus, sp<IWifiStaIface>> WifiChip::getStaIfaceInternal( |
Roshan Pius | 8b55e6f | 2016-12-09 12:05:12 -0800 | [diff] [blame^] | 628 | const std::string& ifname) { |
| 629 | if (!sta_iface_.get() || (ifname != legacy_hal_.lock()->getStaIfaceName())) { |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 630 | return {createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS), nullptr}; |
| 631 | } |
| 632 | return {createWifiStatus(WifiStatusCode::SUCCESS), sta_iface_}; |
| 633 | } |
| 634 | |
Roshan Pius | 8b55e6f | 2016-12-09 12:05:12 -0800 | [diff] [blame^] | 635 | WifiStatus WifiChip::removeStaIfaceInternal(const std::string& ifname) { |
| 636 | if (!sta_iface_.get() || (ifname != legacy_hal_.lock()->getStaIfaceName())) { |
| 637 | return createWifiStatus(WifiStatusCode::ERROR_INVALID_ARGS); |
| 638 | } |
| 639 | invalidateAndClear(sta_iface_); |
| 640 | return createWifiStatus(WifiStatusCode::SUCCESS); |
| 641 | } |
| 642 | |
Roshan Pius | 3c86852 | 2016-10-27 12:43:49 -0700 | [diff] [blame] | 643 | std::pair<WifiStatus, sp<IWifiRttController>> |
| 644 | WifiChip::createRttControllerInternal(const sp<IWifiIface>& bound_iface) { |
| 645 | sp<WifiRttController> rtt = new WifiRttController(bound_iface, legacy_hal_); |
| 646 | rtt_controllers_.emplace_back(rtt); |
| 647 | return {createWifiStatus(WifiStatusCode::SUCCESS), rtt}; |
| 648 | } |
Roshan Pius | 7d08d7a | 2016-10-27 14:35:05 -0700 | [diff] [blame] | 649 | |
| 650 | std::pair<WifiStatus, std::vector<WifiDebugRingBufferStatus>> |
| 651 | WifiChip::getDebugRingBuffersStatusInternal() { |
Roshan Pius | e2d0ab5 | 2016-12-05 15:24:20 -0800 | [diff] [blame] | 652 | legacy_hal::wifi_error legacy_status; |
| 653 | std::vector<legacy_hal::wifi_ring_buffer_status> |
| 654 | legacy_ring_buffer_status_vec; |
| 655 | std::tie(legacy_status, legacy_ring_buffer_status_vec) = |
| 656 | legacy_hal_.lock()->getRingBuffersStatus(); |
| 657 | if (legacy_status != legacy_hal::WIFI_SUCCESS) { |
| 658 | return {createWifiStatusFromLegacyError(legacy_status), {}}; |
| 659 | } |
| 660 | std::vector<WifiDebugRingBufferStatus> hidl_ring_buffer_status_vec; |
| 661 | if (!hidl_struct_util::convertLegacyVectorOfDebugRingBufferStatusToHidl( |
| 662 | legacy_ring_buffer_status_vec, &hidl_ring_buffer_status_vec)) { |
| 663 | return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), {}}; |
| 664 | } |
| 665 | return {createWifiStatus(WifiStatusCode::SUCCESS), |
| 666 | hidl_ring_buffer_status_vec}; |
Roshan Pius | 7d08d7a | 2016-10-27 14:35:05 -0700 | [diff] [blame] | 667 | } |
| 668 | |
| 669 | WifiStatus WifiChip::startLoggingToDebugRingBufferInternal( |
Roshan Pius | e2d0ab5 | 2016-12-05 15:24:20 -0800 | [diff] [blame] | 670 | const hidl_string& ring_name, |
| 671 | WifiDebugRingBufferVerboseLevel verbose_level, |
| 672 | uint32_t max_interval_in_sec, |
| 673 | uint32_t min_data_size_in_bytes) { |
| 674 | legacy_hal::wifi_error legacy_status = |
| 675 | legacy_hal_.lock()->startRingBufferLogging( |
| 676 | ring_name, |
| 677 | static_cast< |
| 678 | std::underlying_type<WifiDebugRingBufferVerboseLevel>::type>( |
| 679 | verbose_level), |
| 680 | max_interval_in_sec, |
| 681 | min_data_size_in_bytes); |
| 682 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | 7d08d7a | 2016-10-27 14:35:05 -0700 | [diff] [blame] | 683 | } |
| 684 | |
| 685 | WifiStatus WifiChip::forceDumpToDebugRingBufferInternal( |
Roshan Pius | e2d0ab5 | 2016-12-05 15:24:20 -0800 | [diff] [blame] | 686 | const hidl_string& ring_name) { |
| 687 | legacy_hal::wifi_error legacy_status = |
| 688 | legacy_hal_.lock()->getRingBufferData(ring_name); |
| 689 | return createWifiStatusFromLegacyError(legacy_status); |
Roshan Pius | 7d08d7a | 2016-10-27 14:35:05 -0700 | [diff] [blame] | 690 | } |
| 691 | |
| 692 | std::pair<WifiStatus, WifiDebugHostWakeReasonStats> |
| 693 | WifiChip::getDebugHostWakeReasonStatsInternal() { |
Roshan Pius | e2d0ab5 | 2016-12-05 15:24:20 -0800 | [diff] [blame] | 694 | legacy_hal::wifi_error legacy_status; |
| 695 | legacy_hal::WakeReasonStats legacy_stats; |
| 696 | std::tie(legacy_status, legacy_stats) = |
| 697 | legacy_hal_.lock()->getWakeReasonStats(); |
| 698 | if (legacy_status != legacy_hal::WIFI_SUCCESS) { |
| 699 | return {createWifiStatusFromLegacyError(legacy_status), {}}; |
| 700 | } |
| 701 | WifiDebugHostWakeReasonStats hidl_stats; |
| 702 | if (!hidl_struct_util::convertLegacyWakeReasonStatsToHidl(legacy_stats, |
| 703 | &hidl_stats)) { |
| 704 | return {createWifiStatus(WifiStatusCode::ERROR_UNKNOWN), {}}; |
| 705 | } |
| 706 | return {createWifiStatus(WifiStatusCode::SUCCESS), hidl_stats}; |
Roshan Pius | 7d08d7a | 2016-10-27 14:35:05 -0700 | [diff] [blame] | 707 | } |
| 708 | |
Roshan Pius | 79a9975 | 2016-10-04 13:03:58 -0700 | [diff] [blame] | 709 | } // namespace implementation |
| 710 | } // namespace V1_0 |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 711 | } // namespace wifi |
| 712 | } // namespace hardware |
| 713 | } // namespace android |