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 | |
| 17 | #ifndef WIFI_CHIP_H_ |
| 18 | #define WIFI_CHIP_H_ |
| 19 | |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 20 | #include <map> |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 21 | |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 22 | #include <android-base/macros.h> |
Roshan Pius | 79a9975 | 2016-10-04 13:03:58 -0700 | [diff] [blame] | 23 | #include <android/hardware/wifi/1.0/IWifiChip.h> |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 24 | |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 25 | #include "wifi_ap_iface.h" |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 26 | #include "wifi_legacy_hal.h" |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 27 | #include "wifi_nan_iface.h" |
| 28 | #include "wifi_p2p_iface.h" |
Roshan Pius | 5926828 | 2016-10-06 20:23:47 -0700 | [diff] [blame] | 29 | #include "wifi_rtt_controller.h" |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 30 | #include "wifi_sta_iface.h" |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 31 | |
| 32 | namespace android { |
| 33 | namespace hardware { |
| 34 | namespace wifi { |
Roshan Pius | 79a9975 | 2016-10-04 13:03:58 -0700 | [diff] [blame] | 35 | namespace V1_0 { |
| 36 | namespace implementation { |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 37 | |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 38 | /** |
| 39 | * HIDL interface object used to control a Wifi HAL chip instance. |
| 40 | * Since there is only a single chip instance used today, there is no |
| 41 | * identifying handle information stored here. |
| 42 | */ |
Roshan Pius | 79a9975 | 2016-10-04 13:03:58 -0700 | [diff] [blame] | 43 | class WifiChip : public IWifiChip { |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 44 | public: |
Roshan Pius | cd566bd | 2016-10-10 08:03:42 -0700 | [diff] [blame] | 45 | WifiChip(ChipId chip_id, const std::weak_ptr<WifiLegacyHal> legacy_hal); |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame] | 46 | // HIDL does not provide a built-in mechanism to let the server invalidate |
| 47 | // a HIDL interface object after creation. If any client process holds onto |
| 48 | // a reference to the object in their context, any method calls on that |
| 49 | // reference will continue to be directed to the server. |
| 50 | // |
| 51 | // However Wifi HAL needs to control the lifetime of these objects. So, add |
| 52 | // a public |invalidate| method to |WifiChip| and it's child objects. This |
| 53 | // will be used to mark an object invalid when either: |
| 54 | // a) Wifi HAL is stopped, or |
| 55 | // b) Wifi Chip is reconfigured. |
| 56 | // |
| 57 | // All HIDL method implementations should check if the object is still marked |
| 58 | // valid before processing them. |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 59 | void invalidate(); |
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 | // HIDL methods exposed. |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame^] | 62 | Return<void> getId(getId_cb hidl_status_cb) override; |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 63 | Return<void> registerEventCallback( |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame^] | 64 | const sp<IWifiChipEventCallback>& event_callback, |
| 65 | registerEventCallback_cb hidl_status_cb) override; |
| 66 | Return<void> getAvailableModes(getAvailableModes_cb hidl_status_cb) override; |
| 67 | Return<void> configureChip(uint32_t mode_id, |
| 68 | configureChip_cb hidl_status_cb) override; |
| 69 | Return<void> getMode(getMode_cb hidl_status_cb) override; |
| 70 | Return<void> requestChipDebugInfo( |
| 71 | requestChipDebugInfo_cb hidl_status_cb) override; |
| 72 | Return<void> requestDriverDebugDump( |
| 73 | requestDriverDebugDump_cb hidl_status_cb) override; |
| 74 | Return<void> requestFirmwareDebugDump( |
| 75 | requestFirmwareDebugDump_cb hidl_status_cb) override; |
| 76 | Return<void> createApIface(createApIface_cb hidl_status_cb) override; |
| 77 | Return<void> getApIfaceNames(getApIfaceNames_cb hidl_status_cb) override; |
| 78 | Return<void> getApIface(const hidl_string& ifname, |
| 79 | getApIface_cb hidl_status_cb) override; |
| 80 | Return<void> createNanIface(createNanIface_cb hidl_status_cb) override; |
| 81 | Return<void> getNanIfaceNames(getNanIfaceNames_cb hidl_status_cb) override; |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 82 | Return<void> getNanIface(const hidl_string& ifname, |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame^] | 83 | getNanIface_cb hidl_status_cb) override; |
| 84 | Return<void> createP2pIface(createP2pIface_cb hidl_status_cb) override; |
| 85 | Return<void> getP2pIfaceNames(getP2pIfaceNames_cb hidl_status_cb) override; |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 86 | Return<void> getP2pIface(const hidl_string& ifname, |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame^] | 87 | getP2pIface_cb hidl_status_cb) override; |
| 88 | Return<void> createStaIface(createStaIface_cb hidl_status_cb) override; |
| 89 | Return<void> getStaIfaceNames(getStaIfaceNames_cb hidl_status_cb) override; |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 90 | Return<void> getStaIface(const hidl_string& ifname, |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame^] | 91 | getStaIface_cb hidl_status_cb) override; |
| 92 | Return<void> createRttController( |
| 93 | const sp<IWifiIface>& bound_iface, |
| 94 | createRttController_cb hidl_status_cb) override; |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 95 | |
| 96 | private: |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 97 | void invalidateAndRemoveAllIfaces(); |
| 98 | |
Roshan Pius | cd566bd | 2016-10-10 08:03:42 -0700 | [diff] [blame] | 99 | ChipId chip_id_; |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 100 | std::weak_ptr<WifiLegacyHal> legacy_hal_; |
Roshan Pius | 5c05546 | 2016-10-11 08:27:27 -0700 | [diff] [blame^] | 101 | std::vector<sp<IWifiChipEventCallback>> event_callbacks_; |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 102 | sp<WifiApIface> ap_iface_; |
| 103 | sp<WifiNanIface> nan_iface_; |
| 104 | sp<WifiP2pIface> p2p_iface_; |
| 105 | sp<WifiStaIface> sta_iface_; |
Roshan Pius | 5926828 | 2016-10-06 20:23:47 -0700 | [diff] [blame] | 106 | std::vector<sp<WifiRttController>> rtt_controllers_; |
Roshan Pius | 35d958c | 2016-10-06 16:47:38 -0700 | [diff] [blame] | 107 | bool is_valid_; |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 108 | |
| 109 | DISALLOW_COPY_AND_ASSIGN(WifiChip); |
| 110 | }; |
| 111 | |
Roshan Pius | 79a9975 | 2016-10-04 13:03:58 -0700 | [diff] [blame] | 112 | } // namespace implementation |
| 113 | } // namespace V1_0 |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 114 | } // namespace wifi |
| 115 | } // namespace hardware |
| 116 | } // namespace android |
| 117 | |
| 118 | #endif // WIFI_CHIP_H_ |