Home | History | Annotate | Download | only in default
      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 HIDL_STRUCT_UTIL_H_
     18 #define HIDL_STRUCT_UTIL_H_
     19 
     20 #include <vector>
     21 
     22 #include <android/hardware/wifi/1.0/types.h>
     23 #include <android/hardware/wifi/1.0/IWifiChip.h>
     24 #include <android/hardware/wifi/1.1/IWifiChip.h>
     25 
     26 #include "wifi_legacy_hal.h"
     27 
     28 /**
     29  * This file contains a bunch of functions to convert structs from the legacy
     30  * HAL to HIDL and vice versa.
     31  * TODO(b/32093047): Add unit tests for these conversion methods in the VTS test
     32  * suite.
     33  */
     34 namespace android {
     35 namespace hardware {
     36 namespace wifi {
     37 namespace V1_1 {
     38 namespace implementation {
     39 namespace hidl_struct_util {
     40 using namespace android::hardware::wifi::V1_0;
     41 
     42 // Chip conversion methods.
     43 bool convertLegacyFeaturesToHidlChipCapabilities(
     44     uint32_t legacy_feature_set,
     45     uint32_t legacy_logger_feature_set,
     46     uint32_t* hidl_caps);
     47 bool convertLegacyDebugRingBufferStatusToHidl(
     48     const legacy_hal::wifi_ring_buffer_status& legacy_status,
     49     WifiDebugRingBufferStatus* hidl_status);
     50 bool convertLegacyVectorOfDebugRingBufferStatusToHidl(
     51     const std::vector<legacy_hal::wifi_ring_buffer_status>& legacy_status_vec,
     52     std::vector<WifiDebugRingBufferStatus>* hidl_status_vec);
     53 bool convertLegacyWakeReasonStatsToHidl(
     54     const legacy_hal::WakeReasonStats& legacy_stats,
     55     WifiDebugHostWakeReasonStats* hidl_stats);
     56 legacy_hal::wifi_power_scenario convertHidlTxPowerScenarioToLegacy(
     57     V1_1::IWifiChip::TxPowerScenario hidl_scenario);
     58 
     59 // STA iface conversion methods.
     60 bool convertLegacyFeaturesToHidlStaCapabilities(
     61     uint32_t legacy_feature_set,
     62     uint32_t legacy_logger_feature_set,
     63     uint32_t* hidl_caps);
     64 bool convertLegacyApfCapabilitiesToHidl(
     65     const legacy_hal::PacketFilterCapabilities& legacy_caps,
     66     StaApfPacketFilterCapabilities* hidl_caps);
     67 bool convertLegacyGscanCapabilitiesToHidl(
     68     const legacy_hal::wifi_gscan_capabilities& legacy_caps,
     69     StaBackgroundScanCapabilities* hidl_caps);
     70 legacy_hal::wifi_band convertHidlWifiBandToLegacy(WifiBand band);
     71 bool convertHidlGscanParamsToLegacy(
     72     const StaBackgroundScanParameters& hidl_scan_params,
     73     legacy_hal::wifi_scan_cmd_params* legacy_scan_params);
     74 // |has_ie_data| indicates whether or not the wifi_scan_result includes 802.11
     75 // Information Elements (IEs)
     76 bool convertLegacyGscanResultToHidl(
     77     const legacy_hal::wifi_scan_result& legacy_scan_result,
     78     bool has_ie_data,
     79     StaScanResult* hidl_scan_result);
     80 // |cached_results| is assumed to not include IEs.
     81 bool convertLegacyVectorOfCachedGscanResultsToHidl(
     82     const std::vector<legacy_hal::wifi_cached_scan_results>&
     83         legacy_cached_scan_results,
     84     std::vector<StaScanData>* hidl_scan_datas);
     85 bool convertLegacyLinkLayerStatsToHidl(
     86     const legacy_hal::LinkLayerStats& legacy_stats,
     87     StaLinkLayerStats* hidl_stats);
     88 bool convertLegacyRoamingCapabilitiesToHidl(
     89     const legacy_hal::wifi_roaming_capabilities& legacy_caps,
     90     StaRoamingCapabilities* hidl_caps);
     91 bool convertHidlRoamingConfigToLegacy(
     92     const StaRoamingConfig& hidl_config,
     93     legacy_hal::wifi_roaming_config* legacy_config);
     94 legacy_hal::fw_roaming_state_t convertHidlRoamingStateToLegacy(
     95     StaRoamingState state);
     96 bool convertLegacyVectorOfDebugTxPacketFateToHidl(
     97     const std::vector<legacy_hal::wifi_tx_report>& legacy_fates,
     98     std::vector<WifiDebugTxPacketFateReport>* hidl_fates);
     99 bool convertLegacyVectorOfDebugRxPacketFateToHidl(
    100     const std::vector<legacy_hal::wifi_rx_report>& legacy_fates,
    101     std::vector<WifiDebugRxPacketFateReport>* hidl_fates);
    102 
    103 // NAN iface conversion methods.
    104 void convertToWifiNanStatus(legacy_hal::NanStatusType type, const char* str, size_t max_len,
    105     WifiNanStatus* wifiNanStatus);
    106 bool convertHidlNanEnableRequestToLegacy(
    107     const NanEnableRequest& hidl_request,
    108     legacy_hal::NanEnableRequest* legacy_request);
    109 bool convertHidlNanConfigRequestToLegacy(
    110     const NanConfigRequest& hidl_request,
    111     legacy_hal::NanConfigRequest* legacy_request);
    112 bool convertHidlNanPublishRequestToLegacy(
    113     const NanPublishRequest& hidl_request,
    114     legacy_hal::NanPublishRequest* legacy_request);
    115 bool convertHidlNanSubscribeRequestToLegacy(
    116     const NanSubscribeRequest& hidl_request,
    117     legacy_hal::NanSubscribeRequest* legacy_request);
    118 bool convertHidlNanTransmitFollowupRequestToLegacy(
    119     const NanTransmitFollowupRequest& hidl_request,
    120     legacy_hal::NanTransmitFollowupRequest* legacy_request);
    121 bool convertHidlNanDataPathInitiatorRequestToLegacy(
    122     const NanInitiateDataPathRequest& hidl_request,
    123     legacy_hal::NanDataPathInitiatorRequest* legacy_request);
    124 bool convertHidlNanDataPathIndicationResponseToLegacy(
    125     const NanRespondToDataPathIndicationRequest& hidl_response,
    126     legacy_hal::NanDataPathIndicationResponse* legacy_response);
    127 bool convertLegacyNanResponseHeaderToHidl(
    128     const legacy_hal::NanResponseMsg& legacy_response,
    129     WifiNanStatus* wifiNanStatus);
    130 bool convertLegacyNanCapabilitiesResponseToHidl(
    131     const legacy_hal::NanCapabilities& legacy_response,
    132     NanCapabilities* hidl_response);
    133 bool convertLegacyNanMatchIndToHidl(const legacy_hal::NanMatchInd& legacy_ind,
    134                                     NanMatchInd* hidl_ind);
    135 bool convertLegacyNanFollowupIndToHidl(
    136     const legacy_hal::NanFollowupInd& legacy_ind, NanFollowupReceivedInd* hidl_ind);
    137 bool convertLegacyNanDataPathRequestIndToHidl(
    138     const legacy_hal::NanDataPathRequestInd& legacy_ind,
    139     NanDataPathRequestInd* hidl_ind);
    140 bool convertLegacyNanDataPathConfirmIndToHidl(
    141     const legacy_hal::NanDataPathConfirmInd& legacy_ind,
    142     NanDataPathConfirmInd* hidl_ind);
    143 
    144 // RTT controller conversion methods.
    145 bool convertHidlVectorOfRttConfigToLegacy(
    146     const std::vector<RttConfig>& hidl_configs,
    147     std::vector<legacy_hal::wifi_rtt_config>* legacy_configs);
    148 bool convertHidlRttLciInformationToLegacy(
    149     const RttLciInformation& hidl_info,
    150     legacy_hal::wifi_lci_information* legacy_info);
    151 bool convertHidlRttLcrInformationToLegacy(
    152     const RttLcrInformation& hidl_info,
    153     legacy_hal::wifi_lcr_information* legacy_info);
    154 bool convertHidlRttResponderToLegacy(
    155     const RttResponder& hidl_responder,
    156     legacy_hal::wifi_rtt_responder* legacy_responder);
    157 bool convertHidlWifiChannelInfoToLegacy(
    158     const WifiChannelInfo& hidl_info,
    159     legacy_hal::wifi_channel_info* legacy_info);
    160 bool convertLegacyRttResponderToHidl(
    161     const legacy_hal::wifi_rtt_responder& legacy_responder,
    162     RttResponder* hidl_responder);
    163 bool convertLegacyRttCapabilitiesToHidl(
    164     const legacy_hal::wifi_rtt_capabilities& legacy_capabilities,
    165     RttCapabilities* hidl_capabilities);
    166 bool convertLegacyVectorOfRttResultToHidl(
    167     const std::vector<const legacy_hal::wifi_rtt_result*>& legacy_results,
    168     std::vector<RttResult>* hidl_results);
    169 }  // namespace hidl_struct_util
    170 }  // namespace implementation
    171 }  // namespace V1_1
    172 }  // namespace wifi
    173 }  // namespace hardware
    174 }  // namespace android
    175 
    176 #endif  // HIDL_STRUCT_UTIL_H_
    177