blob: 94ffa63ec24d4c4b6d556802331823e559321018 [file] [log] [blame]
Roshan Pius3c4e8a32016-10-03 14:53:58 -07001/*
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 Pius35d958c2016-10-06 16:47:38 -070020#include <map>
Roshan Pius3c4e8a32016-10-03 14:53:58 -070021
Roshan Pius3c4e8a32016-10-03 14:53:58 -070022#include <android-base/macros.h>
Roshan Pius79a99752016-10-04 13:03:58 -070023#include <android/hardware/wifi/1.0/IWifiChip.h>
Roshan Pius3c4e8a32016-10-03 14:53:58 -070024
Roshan Pius35d958c2016-10-06 16:47:38 -070025#include "wifi_ap_iface.h"
Roshan Piusaabe5752016-09-29 09:03:59 -070026#include "wifi_legacy_hal.h"
Roshan Pius35d958c2016-10-06 16:47:38 -070027#include "wifi_nan_iface.h"
28#include "wifi_p2p_iface.h"
Roshan Pius59268282016-10-06 20:23:47 -070029#include "wifi_rtt_controller.h"
Roshan Pius35d958c2016-10-06 16:47:38 -070030#include "wifi_sta_iface.h"
Roshan Pius3c4e8a32016-10-03 14:53:58 -070031
32namespace android {
33namespace hardware {
34namespace wifi {
Roshan Pius79a99752016-10-04 13:03:58 -070035namespace V1_0 {
36namespace implementation {
Roshan Pius3c4e8a32016-10-03 14:53:58 -070037
Roshan Piusaabe5752016-09-29 09:03:59 -070038/**
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 Pius79a99752016-10-04 13:03:58 -070043class WifiChip : public IWifiChip {
Roshan Pius3c4e8a32016-10-03 14:53:58 -070044 public:
Roshan Piuscd566bd2016-10-10 08:03:42 -070045 WifiChip(ChipId chip_id, const std::weak_ptr<WifiLegacyHal> legacy_hal);
Roshan Pius3e2d6712016-10-06 13:16:23 -070046 // 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 Piusaabe5752016-09-29 09:03:59 -070059 void invalidate();
Roshan Pius3c4e8a32016-10-03 14:53:58 -070060
Roshan Piusaabe5752016-09-29 09:03:59 -070061 // HIDL methods exposed.
Roshan Piuscd566bd2016-10-10 08:03:42 -070062 Return<ChipId> getId() override;
Roshan Pius3c4e8a32016-10-03 14:53:58 -070063 Return<void> registerEventCallback(
Roshan Pius79a99752016-10-04 13:03:58 -070064 const sp<IWifiChipEventCallback>& callback) override;
Roshan Pius3c4e8a32016-10-03 14:53:58 -070065 Return<void> getAvailableModes(getAvailableModes_cb cb) override;
Roshan Pius3c4e8a32016-10-03 14:53:58 -070066 Return<void> configureChip(uint32_t mode_id) override;
Roshan Pius3c4e8a32016-10-03 14:53:58 -070067 Return<uint32_t> getMode() override;
Roshan Pius3c4e8a32016-10-03 14:53:58 -070068 Return<void> requestChipDebugInfo() override;
Roshan Pius3c4e8a32016-10-03 14:53:58 -070069 Return<void> requestDriverDebugDump() override;
Roshan Pius3c4e8a32016-10-03 14:53:58 -070070 Return<void> requestFirmwareDebugDump() override;
Roshan Pius35d958c2016-10-06 16:47:38 -070071 Return<void> createApIface(createApIface_cb cb) override;
72 Return<void> getApIfaceNames(getApIfaceNames_cb cb) override;
73 Return<void> getApIface(const hidl_string& ifname, getApIface_cb cb) override;
74 Return<void> createNanIface(createNanIface_cb cb) override;
75 Return<void> getNanIfaceNames(getNanIfaceNames_cb cb) override;
76 Return<void> getNanIface(const hidl_string& ifname,
77 getNanIface_cb cb) override;
78 Return<void> createP2pIface(createP2pIface_cb cb) override;
79 Return<void> getP2pIfaceNames(getP2pIfaceNames_cb cb) override;
80 Return<void> getP2pIface(const hidl_string& ifname,
81 getP2pIface_cb cb) override;
82 Return<void> createStaIface(createStaIface_cb cb) override;
83 Return<void> getStaIfaceNames(getStaIfaceNames_cb cb) override;
84 Return<void> getStaIface(const hidl_string& ifname,
85 getStaIface_cb cb) override;
Roshan Pius59268282016-10-06 20:23:47 -070086 Return<void> createRttController(const sp<IWifiIface>& bound_iface,
87 createRttController_cb cb) override;
Roshan Pius3c4e8a32016-10-03 14:53:58 -070088
89 private:
Roshan Pius35d958c2016-10-06 16:47:38 -070090 void invalidateAndRemoveAllIfaces();
91
Roshan Piuscd566bd2016-10-10 08:03:42 -070092 ChipId chip_id_;
Roshan Piusaabe5752016-09-29 09:03:59 -070093 std::weak_ptr<WifiLegacyHal> legacy_hal_;
Roshan Pius35d958c2016-10-06 16:47:38 -070094 std::vector<sp<IWifiChipEventCallback>> callbacks_;
95 sp<WifiApIface> ap_iface_;
96 sp<WifiNanIface> nan_iface_;
97 sp<WifiP2pIface> p2p_iface_;
98 sp<WifiStaIface> sta_iface_;
Roshan Pius59268282016-10-06 20:23:47 -070099 std::vector<sp<WifiRttController>> rtt_controllers_;
Roshan Pius35d958c2016-10-06 16:47:38 -0700100 bool is_valid_;
Roshan Pius3c4e8a32016-10-03 14:53:58 -0700101
102 DISALLOW_COPY_AND_ASSIGN(WifiChip);
103};
104
Roshan Pius79a99752016-10-04 13:03:58 -0700105} // namespace implementation
106} // namespace V1_0
Roshan Pius3c4e8a32016-10-03 14:53:58 -0700107} // namespace wifi
108} // namespace hardware
109} // namespace android
110
111#endif // WIFI_CHIP_H_