blob: dd9117e63e2ee9036174d519bed5cc84172e4aaf [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 Pius5c055462016-10-11 08:27:27 -070062 Return<void> getId(getId_cb hidl_status_cb) override;
Roshan Pius3c4e8a32016-10-03 14:53:58 -070063 Return<void> registerEventCallback(
Roshan Pius5c055462016-10-11 08:27:27 -070064 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 Pius35d958c2016-10-06 16:47:38 -070082 Return<void> getNanIface(const hidl_string& ifname,
Roshan Pius5c055462016-10-11 08:27:27 -070083 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 Pius35d958c2016-10-06 16:47:38 -070086 Return<void> getP2pIface(const hidl_string& ifname,
Roshan Pius5c055462016-10-11 08:27:27 -070087 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 Pius35d958c2016-10-06 16:47:38 -070090 Return<void> getStaIface(const hidl_string& ifname,
Roshan Pius5c055462016-10-11 08:27:27 -070091 getStaIface_cb hidl_status_cb) override;
92 Return<void> createRttController(
93 const sp<IWifiIface>& bound_iface,
94 createRttController_cb hidl_status_cb) override;
Roshan Pius3c4e8a32016-10-03 14:53:58 -070095
96 private:
Roshan Pius35d958c2016-10-06 16:47:38 -070097 void invalidateAndRemoveAllIfaces();
98
Roshan Piuscd566bd2016-10-10 08:03:42 -070099 ChipId chip_id_;
Roshan Piusaabe5752016-09-29 09:03:59 -0700100 std::weak_ptr<WifiLegacyHal> legacy_hal_;
Roshan Pius5c055462016-10-11 08:27:27 -0700101 std::vector<sp<IWifiChipEventCallback>> event_callbacks_;
Roshan Pius35d958c2016-10-06 16:47:38 -0700102 sp<WifiApIface> ap_iface_;
103 sp<WifiNanIface> nan_iface_;
104 sp<WifiP2pIface> p2p_iface_;
105 sp<WifiStaIface> sta_iface_;
Roshan Pius59268282016-10-06 20:23:47 -0700106 std::vector<sp<WifiRttController>> rtt_controllers_;
Roshan Pius35d958c2016-10-06 16:47:38 -0700107 bool is_valid_;
Roshan Pius3c4e8a32016-10-03 14:53:58 -0700108
109 DISALLOW_COPY_AND_ASSIGN(WifiChip);
110};
111
Roshan Pius79a99752016-10-04 13:03:58 -0700112} // namespace implementation
113} // namespace V1_0
Roshan Pius3c4e8a32016-10-03 14:53:58 -0700114} // namespace wifi
115} // namespace hardware
116} // namespace android
117
118#endif // WIFI_CHIP_H_