Snap for 10453563 from 11ea8d4853d264e6ae508570870301da66173cb7 to mainline-sdkext-release

Change-Id: Ic3aa573b856f77e788f95c0cec2f42924557e5c2
diff --git a/Android.bp b/Android.bp
index 7be18c7..409db5d 100644
--- a/Android.bp
+++ b/Android.bp
@@ -29,6 +29,9 @@
 cc_defaults {
     name: "libpower_defaults",
     defaults: ["system_suspend_defaults"],
+    // system_suspend_defaults adds libbinder, but libbpower doesn't need it
+    // because libpower now uses libbinder_ndk.
+    exclude_shared_libs: ["libbinder"],
     cflags: [
         "-Wexit-time-destructors",
         "-fno-c++-static-destructors",
@@ -56,9 +59,9 @@
     name: "libpower_test",
     defaults: ["libpower_defaults"],
     srcs: ["power_test.cpp"],
-    static_libs: ["libpower"],
-    shared_libs: [
-        "android.system.suspend.control.internal-cpp",
+    static_libs: [
+        "libpower",
+        "android.system.suspend.control.internal-ndk",
         "android.system.suspend-V1-ndk",
     ],
     test_suites: ["device-tests"],
diff --git a/include/hardware_legacy/link_layer_stats.h b/include/hardware_legacy/link_layer_stats.h
index bac84e1..f4e16c6 100644
--- a/include/hardware_legacy/link_layer_stats.h
+++ b/include/hardware_legacy/link_layer_stats.h
@@ -221,6 +221,72 @@
    wifi_peer_info peer_info[];           // per peer statistics

 } wifi_iface_stat;

 

+/* Various states for the link */

+typedef enum {

+  // Chip does not support reporting the state of the link.

+  WIFI_LINK_STATE_UNKNOWN = 0,

+  // Link has not been in use since last report. It is placed in power save. All

+  // management, control and data frames for the MLO connection are carried over

+  // other links. In this state the link will not listen to beacons even in DTIM

+  // period and does not perform any GTK/IGTK/BIGTK updates but remains

+  // associated.

+  WIFI_LINK_STATE_NOT_IN_USE = 1,

+  // Link is in use. In presence of traffic, it is set to be power active. When

+  // the traffic stops, the link will go into power save mode and will listen

+  // for beacons every DTIM period.

+  WIFI_LINK_STATE_IN_USE = 2,

+} wifi_link_state;

+

+/* Per link statistics */

+typedef struct {

+  u8 link_id;       // Identifier for the link.

+  wifi_link_state state; // State for the link.

+  wifi_radio radio; // Radio on which link stats are sampled.

+  u32 frequency;    // Frequency on which link is operating.

+  u32 beacon_rx;    // Beacon received count from connected AP on the link.

+  u64 average_tsf_offset;  // Average beacon offset encountered (beacon_TSF -

+                           // TBTT). The average_tsf_offset field is used so as

+                           // to calculate the typical beacon contention time on

+                           // the channel as well may be used to debug beacon

+                           // synchronization and related power consumption

+                           // issue.

+  u32 leaky_ap_detected;   // Indicate that this AP on the link typically leaks

+                           // packets beyond the driver guard time.

+  u32 leaky_ap_avg_num_frames_leaked;  // Average number of frame leaked by AP

+                                       // in the link after frame with PM bit

+                                       // set was ACK'ed by AP.

+  u32 leaky_ap_guard_time;  // Guard time currently in force (when implementing

+                            // IEEE power management based on frame control PM

+                            // bit), How long driver waits before shutting down

+                            // the radio and after receiving an ACK for a data

+                            // frame with PM bit set).

+  u32 mgmt_rx;  // Management frames received count from connected AP on the

+                // link (including Beacon).

+  u32 mgmt_action_rx;  // Action frames received count on the link.

+  u32 mgmt_action_tx;  // Action frames transmit count on the link.

+  wifi_rssi rssi_mgmt; // Access Point Beacon and Management frames RSSI

+                       // (averaged) on the link.

+  wifi_rssi rssi_data; // Access Point Data Frames RSSI (averaged) from

+                       // connected AP on the link.

+  wifi_rssi rssi_ack;  // Access Point ACK RSSI (averaged) from connected AP on

+                       // the links.

+  wifi_wmm_ac_stat ac[WIFI_AC_MAX];    // Per AC data packet statistics for the

+                                       // link.

+  u8 time_slicing_duty_cycle_percent;  // If this link is being served using

+                                       // time slicing on a radio with one or

+                                       // more links, then the duty cycle

+                                       // assigned to this link in %.

+  u32 num_peers;                       // Number of peers.

+  wifi_peer_info peer_info[];          // Peer statistics for the link.

+} wifi_link_stat;

+

+/* Multi link stats for interface  */

+typedef struct {

+  wifi_interface_handle iface;          // Wifi interface.

+  wifi_interface_link_layer_info info;  // Current state of the interface.

+  int num_links;                        // Number of links.

+  wifi_link_stat links[];               // Stats per link.

+} wifi_iface_ml_stat;

 /* configuration params */

 typedef struct {

    u32 mpdu_size_threshold;             // threshold to classify the pkts as short or long

@@ -234,10 +300,18 @@
    Interface statistics (once started) reset and start afresh after each connection */

 wifi_error wifi_set_link_stats(wifi_interface_handle iface, wifi_link_layer_params params);

 

-/* callback for reporting link layer stats */

+/* Callbacks for reporting link layer stats. Only one of the callbacks needs to

+ * be called. */

 typedef struct {

-  void (*on_link_stats_results) (wifi_request_id id, wifi_iface_stat *iface_stat,

-         int num_radios, wifi_radio_stat *radio_stat);

+   /* Legacy: Single iface/link stats. */

+   void (*on_link_stats_results)(wifi_request_id id,

+                                 wifi_iface_stat *iface_stat, int num_radios,

+                                 wifi_radio_stat *radio_stat);

+   /* Multi link stats. */

+   void (*on_multi_link_stats_results)(wifi_request_id id,

+                                       wifi_iface_ml_stat *iface_ml_stat,

+                                       int num_radios,

+                                       wifi_radio_stat *radio_stat);

 } wifi_stats_result_handler;

 

 /* api to collect the link layer statistics for a given iface and all the radio stats */

@@ -266,4 +340,3 @@
 #endif /* __cplusplus */

 

 #endif /*__WIFI_HAL_STATS_ */

-

diff --git a/include/hardware_legacy/rtt.h b/include/hardware_legacy/rtt.h
index 4ef7770..ce17443 100644
--- a/include/hardware_legacy/rtt.h
+++ b/include/hardware_legacy/rtt.h
@@ -38,13 +38,14 @@
 
 /* RTT Measurement Bandwidth */
 typedef enum {
-    WIFI_RTT_BW_5   = 0x01,
-    WIFI_RTT_BW_10  = 0x02,
-    WIFI_RTT_BW_20  = 0x04,
-    WIFI_RTT_BW_40  = 0x08,
-    WIFI_RTT_BW_80  = 0x10,
-    WIFI_RTT_BW_160 = 0x20,
-    WIFI_RTT_BW_320 = 0x40
+    WIFI_RTT_BW_UNSPECIFIED = 0x00,
+    WIFI_RTT_BW_5           = 0x01,
+    WIFI_RTT_BW_10          = 0x02,
+    WIFI_RTT_BW_20          = 0x04,
+    WIFI_RTT_BW_40          = 0x08,
+    WIFI_RTT_BW_80          = 0x10,
+    WIFI_RTT_BW_160         = 0x20,
+    WIFI_RTT_BW_320         = 0x40
 } wifi_rtt_bw;
 
 /* RTT Measurement Preamble */
@@ -150,9 +151,24 @@
     wifi_information_element *LCR; // for 11mc only
 } wifi_rtt_result;
 
-/* RTT result callback */
+/* RTT results version 2 */
 typedef struct {
+    wifi_rtt_result rtt_result;   // Legacy wifi rtt result structure
+    wifi_channel frequency;       // primary channel frequency (MHz) used for ranging measurements
+                                  // If frequency is unknown, this will be set to |UNSPECIFIED(-1)|
+    wifi_rtt_bw packet_bw;        // RTT packet bandwidth is an average BW of the BWs of RTT frames.
+                                  // Cap the average close to a specific valid RttBw.
+} wifi_rtt_result_v2;
+
+/* RTT result callbacks */
+typedef struct {
+    /*
+     * This callback is deprecated on Android 14 and onwards.
+     * Newer implementations should support on_rtt_results_v2 callback
+     */
     void (*on_rtt_results) (wifi_request_id id, unsigned num_results, wifi_rtt_result *rtt_result[]);
+    /* Called when vendor implementation supports sending RTT results version 2 */
+    void (*on_rtt_results_v2) (wifi_request_id id, unsigned num_results, wifi_rtt_result_v2 *rtt_result_v2[]);
 } wifi_rtt_event_handler;
 
 /* API to request RTT measurement */
diff --git a/include/hardware_legacy/wifi_cached_scan_results.h b/include/hardware_legacy/wifi_cached_scan_results.h
new file mode 100644
index 0000000..a2a23fe
--- /dev/null
+++ b/include/hardware_legacy/wifi_cached_scan_results.h
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2022 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __WIFI_CACHED_SCAN_RESULTS_H__
+#define __WIFI_CACHED_SCAN_RESULTS_H__
+
+#include "wifi_hal.h"
+
+#define WIFI_CACHED_SCAN_RESULT_FLAGS_NONE                         (0)
+/* Element ID 61 (HT Operation) is present (see HT 7.3.2) */
+#define WIFI_CACHED_SCAN_RESULT_FLAGS_HT_OPS_PRESENT               (1 << 0)
+/* Element ID 192 (VHT Operation) is present (see VHT 8.4.2)  */
+#define WIFI_CACHED_SCAN_RESULT_FLAGS_VHT_OPS_PRESENT              (1 << 1)
+/* Element ID 255 + Extension 36 (HE Operation) is present
+ * (see 802.11ax 9.4.2.1)
+ */
+#define WIFI_CACHED_SCAN_RESULT_FLAGS_HE_OPS_PRESENT               (1 << 2)
+/* Element ID 255 + Extension 106 (HE Operation) is present
+ * (see 802.11be D1.5 9.4.2.1)
+ */
+#define WIFI_CACHED_SCAN_RESULT_FLAGS_EHT_OPS_PRESENT              (1 << 3)
+/* Element ID 127 (Extended Capabilities) is present, and bit 70
+ * (Fine Timing Measurement Responder) is set to 1
+ * (see IEEE Std 802.11-2016 9.4.2.27)
+ */
+#define WIFI_CACHED_SCAN_RESULT_FLAGS_IS_FTM_RESPONDER             (1 << 4)
+
+/**
+ * Provides information about a single access point (AP) detected in a scan.
+ */
+typedef struct {
+    /* Number of milliseconds prior to ts in the enclosing
+     * wifi_cached_scan_result_report struct when
+     * the probe response or beacon frame that
+     * was used to populate this structure was received.
+     */
+    u32 age_ms;
+    /* The Capability Information field */
+    u16 capability;
+    /* null terminated */
+    u8 ssid[33];
+    u8 ssid_len;
+    u8 bssid[6];
+    /* A set of flags from WIFI_CACHED_SCAN_RESULT_FLAGS_* */
+    u8 flags;
+    s8  rssi;
+    wifi_channel_spec chanspec;
+}wifi_cached_scan_result;
+
+/*
+ * Data structure sent with events of type WifiCachedScanResult.
+ */
+typedef struct  {
+    /* time since boot (in microsecond) when the result was retrieved */
+    wifi_timestamp ts;
+    /* If 0, indicates that all frequencies in current regulation were
+     * scanned. Otherwise, indicates the number of frequencies scanned, as
+     * specified in scanned_freq_list.
+     */
+    u16 scanned_freq_num;
+    /* Pointer to an array containing scanned_freq_num values comprising the
+     * set of frequencies that were scanned. Frequencies are specified as
+     * channel center frequencies in MHz. May be NULL if scannedFreqListLen is
+     * 0.
+     */
+    const u32 *scanned_freq_list;
+    /* The total number of cached results returned. */
+    u8 result_cnt;
+    /* Pointer to an array containing result_cnt entries. May be NULL if
+     * result_cnt is 0.
+     */
+    const wifi_cached_scan_result *results;
+} wifi_cached_scan_report;
+
+/* callback for reporting cached scan report */
+typedef struct {
+  void (*on_cached_scan_results) (wifi_cached_scan_report *cache_report);
+} wifi_cached_scan_result_handler;
+#endif
diff --git a/include/hardware_legacy/wifi_hal.h b/include/hardware_legacy/wifi_hal.h
index 952e894..e2e2bd6 100644
--- a/include/hardware_legacy/wifi_hal.h
+++ b/include/hardware_legacy/wifi_hal.h
@@ -24,6 +24,7 @@
 #include <stdint.h>
 
 #define IFNAMSIZ 16
+#define UNSPECIFIED -1 // wifi HAL common definition for unspecified value
 
 /* typedefs */
 typedef unsigned char byte;
@@ -64,6 +65,14 @@
     WIFI_CHAN_WIDTH_INVALID = -1
 } wifi_channel_width;
 
+/* Multi-Link Operation modes */
+typedef enum {
+  WIFI_MLO_MODE_DEFAULT          = 0,
+  WIFI_MLO_MODE_LOW_LATENCY      = 1,
+  WIFI_MLO_MODE_HIGH_THROUGHPUT  = 2,
+  WIFI_MLO_MODE_LOW_POWER        = 3,
+} wifi_mlo_mode;
+
 /* Pre selected Power scenarios to be applied from BDF file */
 typedef enum {
     WIFI_POWER_SCENARIO_INVALID          = -2,
@@ -125,6 +134,7 @@
   WIFI_INTERFACE_TYPE_AP  = 1,
   WIFI_INTERFACE_TYPE_P2P = 2,
   WIFI_INTERFACE_TYPE_NAN = 3,
+  WIFI_INTERFACE_TYPE_AP_BRIDGED = 4,
 } wifi_interface_type;
 
 /*
@@ -232,6 +242,12 @@
     WIFI_ACCESS_CATEGORY_VOICE = 3
 } wifi_access_category;
 
+/* Channel category mask */
+typedef enum {
+    WIFI_INDOOR_CHANNEL = 1 << 0,
+    WIFI_DFS_CHANNEL    = 1 << 1,
+} wifi_channel_category;
+
 /* Antenna configuration */
 typedef enum {
   WIFI_ANTENNA_UNSPECIFIED = 0,
@@ -277,6 +293,125 @@
     wifi_radio_combination radio_combinations[];
 } wifi_radio_combination_matrix;
 
+typedef struct {
+    /**
+     * Maximum number of links supported by the chip for MLO association.
+     */
+    u32 max_mlo_association_link_count;
+    /**
+     * Maximum number of Simultaneous Transmit and Receive (STR) links used
+     * in Multi-Link Operation. The maximum number of STR links used can be
+     * different from the maximum number of radios supported by the chip.
+     *
+     * This is a static configuration of the chip.
+     */
+    u32 max_mlo_str_link_count;
+    /**
+     * Maximum number of concurrent TDLS sessions supported by the chip.
+     *
+     */
+    u32 max_concurrent_tdls_session_count;
+} wifi_chip_capabilities;
+
+#define MAX_IFACE_COMBINATIONS 16
+#define MAX_IFACE_LIMITS 8
+
+/* Wifi interface limit
+ * Example:
+ * 1. To allow STA+STA:
+ *     wifi_iface_limit limit1 = {
+ *         .max_limit = 2,
+ *         .iface_mask = BIT(WIFI_INTERFACE_TYPE_STA)
+ *     };
+ * 2. To allow Single P2P/NAN:
+ *     wifi_iface_limit limit2 = {
+ *         .max_limit = 1,
+ *         .iface_mask = BIT(WIFI_INTERFACE_TYPE_P2P)
+ *                       | BIT(WIFI_INTERFACE_TYPE_NAN)
+ *     };
+ */
+typedef struct {
+    /* Max number of interfaces of same type */
+    u32 max_limit;
+    /* BIT mask of interfaces from wifi_interface_type */
+    u32 iface_mask;
+} wifi_iface_limit;
+
+/* Wifi Interface combination
+ * Example:
+ * 1. To allow STA+SAP:
+ *     wifi_iface_limit limits1[] = {
+ *         {1, BIT(WIFI_INTERFACE_TYPE_STA)},
+ *     };
+ *     wifi_iface_limit limits2[] = {
+ *         {1, BIT(WIFI_INTERFACE_TYPE_AP)},
+ *     };
+ *     wifi_iface_combination comb1 = {
+ *         .max_ifaces = 2,
+ *         .num_iface_limits = 2,
+ *         .iface_limits = {limits1, limits2,},
+ *     };
+ *
+ * 2. To allow STA+P2P/NAN:
+ *     wifi_iface_limit limits3[] = {
+ *         {1, BIT(WIFI_INTERFACE_TYPE_STA)},
+ *         {1, BIT(WIFI_INTERFACE_TYPE_P2P)
+               | BIT(WIFI_INTERFACE_TYPE_NAN)},
+ *     };
+ *     wifi_iface_combination comb2 = {
+ *         .max_ifaces = 2,
+ *         .num_iface_limits = 1,
+ *         .iface_limits = {limits3,},
+ *     };
+ *
+ * 3. To allow STA+STA/AP:
+ *     wifi_iface_limit limits4[] = {
+ *         {2, BIT(WIFI_INTERFACE_TYPE_STA)},
+ *     };
+ *     wifi_iface_limit limits5[] = {
+ *         {1, BIT(WIFI_INTERFACE_TYPE_STA)},
+ *         {1, BIT(WIFI_INTERFACE_TYPE_AP)},
+ *     };
+ *     wifi_iface_combination comb3 = {
+ *         .max_ifaces = 2,
+ *         .num_iface_limits = 2,
+ *         .iface_limits = {limits4, limits5,},
+ *     };
+ *
+ * 4. To allow AP_BRIDGED (AP+AP in bridge mode):
+ *     wifi_iface_limit limits6[] = {
+ *         {1, BIT(WIFI_INTERFACE_TYPE_AP_BRIDGED)},
+ *     };
+ *     wifi_iface_combination comb4 = {
+ *         .max_ifaces = 1,
+ *         .num_iface_limits = 1,
+ *         .iface_limits = {limits6,},
+ *     };
+ */
+typedef struct {
+    /* Maximum number of concurrent interfaces allowed in this combination */
+    u32 max_ifaces;
+    /* Total number of interface limits in a combination */
+    u32 num_iface_limits;
+    /* Interface limits */
+    wifi_iface_limit iface_limits[MAX_IFACE_LIMITS];
+} wifi_iface_combination;
+
+/* Wifi Interface concurrency combination matrix
+ * Example:
+ * 1. To allow 2 port concurrency with limts defined in above comments:
+ *     wifi_iface_concurrency_matrix iface_concurrency_matrix = {
+ *         .num_iface_combinations = 4,
+ *         .iface_combinations = {comb1, comb2, comb3, comb4, }
+ *     };
+ */
+typedef struct {
+    /* Total count of possible iface combinations */
+    u32 num_iface_combinations;
+    /* Interface combinations */
+    wifi_iface_combination iface_combinations[MAX_IFACE_COMBINATIONS];
+} wifi_iface_concurrency_matrix;
+
 /* Initialize/Cleanup */
 
 wifi_error wifi_initialize(wifi_handle *handle);
@@ -331,6 +466,8 @@
 #define WIFI_FEATURE_SET_LATENCY_MODE   (uint64_t)0x40000000  // Support Latency mode setting
 #define WIFI_FEATURE_P2P_RAND_MAC       (uint64_t)0x80000000  // Support P2P MAC randomization
 #define WIFI_FEATURE_INFRA_60G          (uint64_t)0x100000000 // Support for 60GHz Band
+#define WIFI_FEATURE_AFC_CHANNEL        (uint64_t)0x200000000 // Support for setting 6GHz AFC channel allowance
+#define WIFI_FEATURE_T2LM_NEGO          (uint64_t)0x400000000 // Support for TID-To-Link mapping negotiation
 // Add more features here
 
 #define IS_MASK_SET(mask, flags)        (((flags) & (mask)) == (mask))
@@ -578,6 +715,7 @@
 
 #include "gscan.h"
 #include "link_layer_stats.h"
+#include "wifi_cached_scan_results.h"
 #include "rtt.h"
 #include "tdls.h"
 #include "wifi_logger.h"
@@ -1025,10 +1163,99 @@
     wifi_error (*wifi_enable_tx_power_limits) (wifi_interface_handle iface,
                                                bool isEnable);
 
+    /**@brief wifi_get_cached_scan_results
+     *        Retrieve scan results cached in wifi firmware
+     * @param wifi_interface_handle
+     * @param wifi_cached_scan_result_handler : callback function pointer
+     * @return Synchronous wifi_error
+     */
+    wifi_error (*wifi_get_cached_scan_results)(wifi_interface_handle iface,
+                                               wifi_cached_scan_result_handler handler);
+    /**@brief wifi_get_chip_capabilities
+     *        Retrieve capabilities supported by this chip
+     * @param wifi_handle
+     * @return Synchronous wifi_error and chip capabilites
+     */
+    wifi_error (*wifi_get_chip_capabilities)(wifi_handle handle,
+                                             wifi_chip_capabilities *chip_capabilities);
+
+    /**@brief wifi_get_supported_iface_concurrency_matrix
+     *        Request all the possible interface concurrency combinations this
+     *        Wifi Chip can offer.
+     * @param handle global wifi_handle
+     * @param wifi_iface_concurrency_matrix to return all the possible
+     *        interface concurrency combinations.
+     * @return Synchronous wifi_error
+     */
+    wifi_error (*wifi_get_supported_iface_concurrency_matrix)(
+        wifi_handle handle, wifi_iface_concurrency_matrix *matrix);
+
+    /**@brief wifi_enable_sta_channel_for_peer_network
+     *        enable or disable the feature of allowing current STA-connected
+     *        channel for WFA GO, SAP and Wi-Fi Aware when the regulatory allows.
+     * @param handle global wifi_handle
+     * @param channelCategoryEnableFlag bitmask of |wifi_channel_category|.
+     * @return Synchronous wifi_error
+     */
+    wifi_error (*wifi_enable_sta_channel_for_peer_network)(
+        wifi_handle handle, u32 channelCategoryEnableFlag);
+
+    /**@brief wifi_nan_suspend_request
+     * Request that the specified NAN session be suspended.
+     * @param transaction_id: NAN transaction id
+     * @param wifi_interface_handle
+     * @param NanSuspendRequest request message
+     * @return Synchronous wifi_error
+     */
+    wifi_error (*wifi_nan_suspend_request)(transaction_id id, wifi_interface_handle iface,
+                                                   NanSuspendRequest *msg);
+
+    /**@brief wifi_nan_resume_request
+     * Request that the specified NAN session be resumed.
+     * @param transaction_id: NAN transaction id
+     * @param wifi_interface_handle
+     * @param NanResumeRequest request message
+     * @return Synchronous wifi_error
+     */
+    wifi_error (*wifi_nan_resume_request)(transaction_id id, wifi_interface_handle iface,
+                                                   NanResumeRequest *msg);
+
+    wifi_error (*wifi_nan_pairing_request)(
+        transaction_id id, wifi_interface_handle iface,
+        NanPairingRequest *msg);
+    wifi_error (*wifi_nan_pairing_indication_response)(
+    transaction_id id, wifi_interface_handle iface,
+        NanPairingIndicationResponse *msg);
+    wifi_error (*wifi_nan_bootstrapping_request)(
+        transaction_id id, wifi_interface_handle iface,
+        NanBootstrappingRequest *msg);
+    wifi_error (*wifi_nan_bootstrapping_indication_response)(
+        transaction_id id, wifi_interface_handle iface,
+        NanBootstrappingIndicationResponse *msg);
+
+    /**@brief wifi_set_scan_mode
+     *        Notify driver/firmware current is scan only mode to allow lower
+     *        level to optimize power consumption.
+     * @param enable true if current is scan only mode
+     * @return Synchronous wifi_error
+     */
+    wifi_error (*wifi_set_scan_mode)(const char * ifname, bool enable);
+
+    wifi_error (*wifi_nan_pairing_end)(transaction_id id,
+                                    wifi_interface_handle iface,
+                                    NanPairingEndRequest *msg);
+
+    /**@brief wifi_set_mlo_mode
+     * Set Multi-Link Operation mode.
+     * @param handle global wifi_handle
+     * @param mode: MLO mode
+     * @return Synchronous wifi_error
+     */
+    wifi_error (*wifi_set_mlo_mode)(wifi_handle handle, wifi_mlo_mode mode);
 
     /*
      * when adding new functions make sure to add stubs in
-     * hal_tool.cpp::init_wifi_stub_hal_func_table
+     * wifi_legacy_hal_stubs.cpp::initHalFuncTableWithStubs
      */
 } wifi_hal_fn;
 
diff --git a/include/hardware_legacy/wifi_nan.h b/include/hardware_legacy/wifi_nan.h
index 8437a1d..6754252 100644
--- a/include/hardware_legacy/wifi_nan.h
+++ b/include/hardware_legacy/wifi_nan.h
@@ -40,9 +40,9 @@
 typedef u32 NanDataPathId;
 
 #define NAN_MAC_ADDR_LEN                6
-#define NAN_MAJOR_VERSION               2
+#define NAN_MAJOR_VERSION               4
 #define NAN_MINOR_VERSION               0
-#define NAN_MICRO_VERSION               1
+#define NAN_MICRO_VERSION               0
 #define NAN_MAX_SOCIAL_CHANNELS         3
 
 /* NAN Maximum Lengths */
@@ -65,29 +65,39 @@
 #define NAN_SECURITY_MIN_PASSPHRASE_LEN         8
 #define NAN_SECURITY_MAX_PASSPHRASE_LEN         63
 #define NAN_MAX_CHANNEL_INFO_SUPPORTED          4
-
+#define NAN_IDENTITY_KEY_LEN                    16
+#define NAN_IDENTITY_TAG_LEN                    8
+#define NAN_IDENTITY_NONCE_LEN                  8
+#define NAN_MAX_MATCH_IDENTITY_LEN             1024
 /*
   Definition of various NanResponseType
 */
 typedef enum {
-    NAN_RESPONSE_ENABLED                = 0,
-    NAN_RESPONSE_DISABLED               = 1,
-    NAN_RESPONSE_PUBLISH                = 2,
-    NAN_RESPONSE_PUBLISH_CANCEL         = 3,
-    NAN_RESPONSE_TRANSMIT_FOLLOWUP      = 4,
-    NAN_RESPONSE_SUBSCRIBE              = 5,
-    NAN_RESPONSE_SUBSCRIBE_CANCEL       = 6,
-    NAN_RESPONSE_STATS                  = 7,
-    NAN_RESPONSE_CONFIG                 = 8,
-    NAN_RESPONSE_TCA                    = 9,
-    NAN_RESPONSE_ERROR                  = 10,
-    NAN_RESPONSE_BEACON_SDF_PAYLOAD     = 11,
-    NAN_GET_CAPABILITIES                = 12,
-    NAN_DP_INTERFACE_CREATE             = 13,
-    NAN_DP_INTERFACE_DELETE             = 14,
-    NAN_DP_INITIATOR_RESPONSE           = 15,
-    NAN_DP_RESPONDER_RESPONSE           = 16,
-    NAN_DP_END                          = 17
+    NAN_RESPONSE_ENABLED                 = 0,
+    NAN_RESPONSE_DISABLED                = 1,
+    NAN_RESPONSE_PUBLISH                 = 2,
+    NAN_RESPONSE_PUBLISH_CANCEL          = 3,
+    NAN_RESPONSE_TRANSMIT_FOLLOWUP       = 4,
+    NAN_RESPONSE_SUBSCRIBE               = 5,
+    NAN_RESPONSE_SUBSCRIBE_CANCEL        = 6,
+    NAN_RESPONSE_STATS                   = 7,
+    NAN_RESPONSE_CONFIG                  = 8,
+    NAN_RESPONSE_TCA                     = 9,
+    NAN_RESPONSE_ERROR                   = 10,
+    NAN_RESPONSE_BEACON_SDF_PAYLOAD      = 11,
+    NAN_GET_CAPABILITIES                 = 12,
+    NAN_DP_INTERFACE_CREATE              = 13,
+    NAN_DP_INTERFACE_DELETE              = 14,
+    NAN_DP_INITIATOR_RESPONSE            = 15,
+    NAN_DP_RESPONDER_RESPONSE            = 16,
+    NAN_DP_END                           = 17,
+    NAN_PAIRING_INITIATOR_RESPONSE       = 18,
+    NAN_PAIRING_RESPONDER_RESPONSE       = 19,
+    NAN_BOOTSTRAPPING_INITIATOR_RESPONSE = 20,
+    NAN_BOOTSTRAPPING_RESPONDER_RESPONSE = 21,
+    NAN_PAIRING_END                      = 22,
+    NAN_SUSPEND_REQUEST_RESPONSE         = 23,
+    NAN_RESUME_REQUEST_RESPONSE          = 24
 } NanResponseType;
 
 /* NAN Publish Types */
@@ -137,6 +147,18 @@
     NAN_TCA_ID_CLUSTER_SIZE = 0
 } NanTcaType;
 
+/* pairing request type*/
+typedef enum {
+    NAN_PAIRING_SETUP = 0,
+    NAN_PAIRING_VERIFICATION = 1
+} NanPairingRequestType;
+
+/* Nan AKM type */
+typedef enum {
+    SAE = 0,
+    PASN = 1
+} NanAkm;
+
 /* NAN Channel Info */
 typedef struct {
     u32 channel;
@@ -173,7 +195,17 @@
     /* If followup message internal queue is full */
     NAN_STATUS_FOLLOWUP_QUEUE_FULL = 11,
     /* Unsupported concurrency session enabled, NAN disabled notified */
-    NAN_STATUS_UNSUPPORTED_CONCURRENCY_NAN_DISABLED = 12
+    NAN_STATUS_UNSUPPORTED_CONCURRENCY_NAN_DISABLED = 12,
+    /*  if the pairing id is invalid */
+    NAN_STATUS_INVALID_PAIRING_ID = 13,
+    /*  if the bootstrapping id is invalid */
+    NAN_STATUS_INVALID_BOOTSTRAPPING_ID = 14,
+    /* If same request is received again */
+    NAN_STATUS_REDUNDANT_REQUEST = 15,
+    /* If current request is not supported */
+    NAN_STATUS_NOT_SUPPORTED = 16,
+    /* If no Wifi Aware connection is active */
+    NAN_STATUS_NO_CONNECTION = 17,
 } NanStatusType;
 
 /* NAN Transmit Types */
@@ -243,6 +275,19 @@
     NAN_DP_REQUEST_REJECT
 } NanDataPathResponseCode;
 
+/* Pairing request Responder's response */
+typedef enum {
+    NAN_PAIRING_REQUEST_ACCEPT = 0,
+    NAN_PAIRING_REQUEST_REJECT
+} NanPairingResponseCode;
+
+/* Pairing bootstrapping Responder's response */
+typedef enum {
+    NAN_BOOTSTRAPPING_REQUEST_ACCEPT = 0,
+    NAN_BOOTSTRAPPING_REQUEST_REJECT = 1,
+    NAN_BOOTSTRAPPING_REQUEST_COMEBACK = 2
+} NanBootstrappingResponseCode;
+
 /* NAN DP channel config options */
 typedef enum {
     NAN_DP_CHANNEL_NOT_REQUESTED = 0,
@@ -311,6 +356,8 @@
 #define NAN_CIPHER_SUITE_SHARED_KEY_256_MASK           0x02
 #define NAN_CIPHER_SUITE_PUBLIC_KEY_2WDH_128_MASK      0x04
 #define NAN_CIPHER_SUITE_PUBLIC_KEY_2WDH_256_MASK      0x08
+#define NAN_CIPHER_SUITE_PUBLIC_KEY_PASN_128_MASK      0x40
+#define NAN_CIPHER_SUITE_PUBLIC_KEY_PASN_256_MASK      0x80
 
 /* NAN ranging indication condition MASKS */
 #define NAN_RANGING_INDICATE_CONTINUOUS_MASK   0x01
@@ -321,6 +368,19 @@
 #define NAN_SCHEDULE_UPDATE_NSS_MASK   0x01
 #define NAN_SCHEDULE_UPDATE_CHANNEL_MASK  0x02
 
+/* NAN pairing bootstrapping method */
+#define NAN_PAIRING_BOOTSTRAPPING_OPPORTUNISTIC_MASK       0x01
+#define NAN_PAIRING_BOOTSTRAPPING_PIN_CODE_DISPLAY_MASK    0x02
+#define NAN_PAIRING_BOOTSTRAPPING_PASSPHRASE_DISPLAY_MASK  0x04
+#define NAN_PAIRING_BOOTSTRAPPING_QR_DISPLAY_MASK          0x08
+#define NAN_PAIRING_BOOTSTRAPPING_NFC_TAG_MASK             0x10
+#define NAN_PAIRING_BOOTSTRAPPING_PIN_CODE_KEYPAD_MASK     0x20
+#define NAN_PAIRING_BOOTSTRAPPING_PASSPHRASE_KEYPAD_MASK   0x40
+#define NAN_PAIRING_BOOTSTRAPPING_QR_SCAN_MASK             0x80
+#define NAN_PAIRING_BOOTSTRAPPING_NFC_READER_MASK          0x100
+#define NAN_PAIRING_BOOTSTRAPPING_SERVICE_MANAGED_MASK     0x4000
+#define NAN_PAIRING_BOOTSTRAPPING_HANDSHAKE_SHIP_MASK      0x8000
+
 /*
    Structure to set the Service Descriptor Extension
    Attribute (SDEA) passed as part of NanPublishRequest/
@@ -354,6 +414,25 @@
       if QOS is required or not.
     */
     NanQosCfgStatus qos_cfg;
+    /*
+      Config to set FSD with Gas bit
+      in the SDEA Control Field.
+     */
+    u8 config_fsd_gas;
+    u8 enable_fsd_gas;
+
+    /*
+      Config to set FSD Required bit
+      in the SDEA Control Field.
+     */
+    u8 config_fsd_req;
+    u8 enable_fsd_req;
+
+    /*
+      Config to set gtk protection bit
+      in the SDEA Control Field.
+     */
+    u8 gtk_protection;
 } NanSdeaCtrlParams;
 
 /*
@@ -392,6 +471,11 @@
     u32 max_subscribe_address;
     u32 ndpe_attr_supported;
     bool is_instant_mode_supported;
+    bool is_6g_supported;
+    bool is_he_supported;
+    bool is_pairing_supported;
+    bool is_set_cluster_id_supported;
+    bool is_suspension_supported;
 } NanCapabilities;
 
 /*
@@ -1054,9 +1138,49 @@
     */
     u8 config_instant_mode_channel;
     wifi_channel instant_mode_channel;
+
+    /*
+       Enable/Disable unsync service discovery.
+       0 - Disable
+       1 - Enable
+    */
+    u8 config_unsync_srvdsc;
+    u8 enable_unsync_srvdsc;
+
+    /*
+      Configure regulatory information.
+    */
+    u8 config_reg_info;
+    u8 reg_info_val;
 } NanEnableRequest;
 
 /*
+  NAN pairing config.
+*/
+typedef struct {
+
+    /*
+      Enable Nan pairing setup
+    */
+    u32 enable_pairing_setup;
+
+    /*
+      Enable cache NIK/NPK after Nan pairing setup
+    */
+    u32 enable_pairing_cache;
+
+    /*
+      Enable Nan pairing verification with cached NIK/NPK
+    */
+    u32 enable_pairing_verification;
+
+    /*
+      The set of supported bootstrapping methods.
+    */
+    u16 supported_bootstrapping_methods;
+} NanPairingConfig;
+
+/*
   Publish Msg Structure
   Message is used to request the DE to publish the Service Name
   using the parameters passed into the Discovery Window
@@ -1187,6 +1311,29 @@
     */
     u16 sdea_service_specific_info_len;
     u8 sdea_service_specific_info[NAN_MAX_SDEA_SERVICE_SPECIFIC_INFO_LEN];
+
+    /*
+       The Identity key for pairing, used to generate NIRA
+    */
+    u8 nan_identity_key[NAN_IDENTITY_KEY_LEN];
+
+    /*
+      The config for Nan pairing
+    */
+    NanPairingConfig nan_pairing_config;
+
+    /*
+      Specifies whether suspension can be possible in this publish session.
+      The request would fail if enable_suspendability is true but
+      is_suspension_supported is false in NanCapabilities.
+    */
+    bool enable_suspendability;
+
+    /* s3 capabilities */
+    u16 s3_capabilities;
+
+    /* cipher capabilities */
+    u8 cipher_capabilities;
 } NanPublishRequest;
 
 /*
@@ -1350,6 +1497,25 @@
     */
     u16 sdea_service_specific_info_len;
     u8 sdea_service_specific_info[NAN_MAX_SDEA_SERVICE_SPECIFIC_INFO_LEN];
+    /*
+       The Identity key for pairing, used to generate NIRA
+    */
+    u8 nan_identity_key[NAN_IDENTITY_KEY_LEN];
+
+    /*
+      The config for Nan pairing
+    */
+    NanPairingConfig nan_pairing_config;
+
+    /*
+      Specifies whether suspension can be possible in this subscribe session.
+      The request would fail if enable_suspendability is true but
+      is_suspension_supported is false in NanCapabilities.
+    */
+    bool enable_suspendability;
+
+    /* cipher capabilities */
+    u8 cipher_capabilities;
 } NanSubscribeRequest;
 
 /*
@@ -1395,6 +1561,12 @@
     */
     u16 sdea_service_specific_info_len;
     u8 sdea_service_specific_info[NAN_MAX_SDEA_SERVICE_SPECIFIC_INFO_LEN];
+
+    /*
+       Add shared key descriptor attribute to the Followup request when the
+       flag is set
+    */
+    u8 shared_key_desc_flag;
 } NanTransmitFollowupRequest;
 
 /*
@@ -1408,6 +1580,23 @@
 } NanStatsRequest;
 
 /*
+  Suspend Request Structure
+  The SuspendRequest message is used to request that the specified session is suspended.
+  The session can be resumed using the NanResumeRequest message.
+*/
+typedef struct {
+    u16 publish_subscribe_id;
+} NanSuspendRequest;
+
+/*
+  Resume Request Structure
+  The ResumeRequest message is used to request that the specified session is resumed.
+*/
+typedef struct {
+    u16 publish_subscribe_id;
+} NanResumeRequest;
+
+/*
   Config Structure
   The NanConfigurationReq message is sent by the Host to the
   Discovery Engine in order to configure the Discovery Engine during runtime.
@@ -1557,6 +1746,11 @@
     */
     u8 config_instant_mode_channel;
     wifi_channel instant_mode_channel;
+    /*
+       Config cluster ID with the cluster ID selected over NFC/OOB method.
+    */
+    u8 config_cluster_id;
+    u16 cluster_id_val; // default value 0x0
 } NanConfigRequest;
 
 /*
@@ -1814,6 +2008,24 @@
     NanDataPathId ndp_instance_id;
 } NanDataPathRequestResponse;
 
+/* Response returned for Initiators pairing request */
+typedef struct {
+    /*
+      Unique token Id generated on the initiator
+      side used for a pairing session between two NAN devices
+    */
+    u32 paring_instance_id;
+} NanPairingRequestResponse;
+
+/* Response returned for Initiators bootstrapping request */
+typedef struct {
+    /*
+      Unique token Id generated on the initiator
+      side used for a bootstrapping session between two NAN devices
+    */
+    u32 bootstrapping_instance_id;
+} NanBootstrappingRequestResponse;
+
 /*
   NAN Response messages
 */
@@ -1827,6 +2039,8 @@
         NanStatsResponse stats_response;
         NanDataPathRequestResponse data_request_response;
         NanCapabilities nan_capabilities;
+        NanPairingRequestResponse pairing_request_response;
+        NanBootstrappingRequestResponse bootstrapping_request_response;
     } body;
 } NanResponseMsg;
 
@@ -1867,6 +2081,12 @@
     char nan_reason[NAN_ERROR_STR_LEN]; /* Describe the NAN reason type */
 } NanPublishTerminatedInd;
 
+/* The NIRA used to identify the pairing devices*/
+typedef struct {
+    u8 nonce[NAN_IDENTITY_NONCE_LEN];
+    u8 tag[NAN_IDENTITY_TAG_LEN];
+} NanIdentityResolutionAttribute;
+
 /*
   Match Indication
   The MatchInd message is sent once per responding MAC address whenever
@@ -1990,6 +2210,16 @@
     */
     u16 sdea_service_specific_info_len;
     u8 sdea_service_specific_info[NAN_MAX_SDEA_SERVICE_SPECIFIC_INFO_LEN];
+
+    /*
+      The config for Nan pairing set by the peer
+    */
+    NanPairingConfig peer_pairing_config;
+
+    /*
+      The NIRA from peer for Nan pairing verification
+    */
+    NanIdentityResolutionAttribute nira;
 } NanMatchInd;
 
 /*
@@ -2259,6 +2489,9 @@
        for setting up the Secure Data Path.
     */
     u8 scid[NAN_MAX_SCID_BUF_LEN];
+
+    /* Publish or Subscribe Id of an earlier Publish/Subscribe */
+    u16 publish_subscribe_id;
 } NanDataPathInitiatorRequest;
 
 /*
@@ -2311,8 +2544,23 @@
        for setting up the Secure Data Path.
     */
     u8 scid[NAN_MAX_SCID_BUF_LEN];
+
+    /* Publish or Subscribe Id of an earlier Publish/Subscribe */
+    u16 publish_subscribe_id;
+
+    /*
+      Discovery MAC addr of the publisher/peer
+    */
+    u8 peer_disc_mac_addr[NAN_MAC_ADDR_LEN];
 } NanDataPathIndicationResponse;
 
+/* Sub slot parameters */
+typedef struct {
+    u8 entry_control;
+    u16 time_bitmap_control;
+    u32 time_bitmap;
+} NanS3Params;
+
 /* NDP termination info */
 typedef struct {
     u8 num_ndp_instances;
@@ -2462,6 +2710,333 @@
     u32 range_measurement_mm;
 } NanRangeReportInd;
 
+/*
+  NAN pairing initator request
+*/
+typedef struct {
+    /*
+       This Id is the Requestor Instance that is passed as
+       part of earlier MatchInd/FollowupInd message.
+    */
+    u32 requestor_instance_id;
+
+    /*
+      Discovery MAC addr of the publisher/peer
+    */
+    u8 peer_disc_mac_addr[NAN_MAC_ADDR_LEN];
+
+    /*
+      Indicate the pairing session is of setup or verification
+    */
+    NanPairingRequestType nan_pairing_request_type;
+
+    /*
+      whether the pairing is opportunistic or password
+    */
+    u8 is_opportunistic;
+
+    /*
+      Security key info used for the pairing setup or verification
+    */
+    NanSecurityKeyInfo key_info;
+    /*
+      AKM used for the pairing verification
+    */
+    NanAkm akm;
+
+    /*
+      Whether should cache the negotiated NIK/NPK for future verification
+    */
+    u8 enable_pairing_cache;
+
+    /*
+      The Identity key for pairing, can be used for pairing verification
+    */
+    u8 nan_identity_key[NAN_IDENTITY_KEY_LEN];
+
+    /*
+      NAN Cipher Suite Type
+    */
+    u32 cipher_type;
+
+} NanPairingRequest;
+
+/*
+  Data struct to initiate a pairing response on the responder side for an indication received with a
+  pairing request
+*/
+typedef struct {
+
+    /*
+      Unique token Id generated on the initiator/responder side
+      used for a pairing session between two NAN devices
+    */
+    u32 pairing_instance_id;
+
+    /*
+      Indicate the pairing session is setup or verification
+    */
+    NanPairingRequestType nan_pairing_request_type;
+
+    /* Response Code indicating ACCEPT/REJECT */
+    NanPairingResponseCode rsp_code;
+
+    /*
+      whether the pairing is opportunistic or password
+    */
+    u8 is_opportunistic;
+
+    /*
+      Security key info used for the pairing setup or verification
+    */
+    NanSecurityKeyInfo key_info;
+
+    /*
+      AKM used for the pairing verification
+    */
+    NanAkm akm;
+
+    /*
+      Whether should cache the negotiated NIK/NPK for future verification
+    */
+    u8 enable_pairing_cache;
+
+    /*
+      The Identity key for pairing, can be used for pairing verification
+    */
+    u8 nan_identity_key[NAN_IDENTITY_KEY_LEN];
+
+    /*
+      NAN Cipher Suite Type
+    */
+    u32 cipher_type;
+} NanPairingIndicationResponse;
+
+typedef struct {
+    /*
+      Unique token Id generated on the initiator/responder side
+      used for a pairing session between two NAN devices
+    */
+    u32 pairing_instance_id;
+} NanPairingEndRequest;
+
+/*
+  Event indication received on the responder side when a Nan pairing session is initiated on the
+  Initiator side
+*/
+typedef struct {
+    /* Publish or Subscribe Id of an earlier Publish/Subscribe */
+    u16 publish_subscribe_id;
+    /*
+      This Id is the Requestor Instance that is passed as
+      part of earlier MatchInd/FollowupInd message.
+    */
+    u32 requestor_instance_id;
+    /*
+      Unique Instance Id corresponding to a service/session.
+      This is similar to the publish_id generated on the
+      publisher side
+    */
+    u32 pairing_instance_id;
+    /* Discovery MAC addr of the peer/initiator */
+    u8 peer_disc_mac_addr[NAN_MAC_ADDR_LEN];
+    /* Indicate the pairing session is setup or verification */
+    NanPairingRequestType nan_pairing_request_type;
+    /* Whether should cache the negotiated NIK/NPK for future verification */
+    u8 enable_pairing_cache;
+    /* The NIRA from peer for Nan pairing verification */
+    NanIdentityResolutionAttribute nira;
+} NanPairingRequestInd;
+
+/*
+  The security info negotiate after the pairing setup for caching
+*/
+typedef struct {
+    /* The inentity key of peer device*/
+    u8 peer_nan_identity_key[NAN_IDENTITY_KEY_LEN];
+    /* The inentity key of local device*/
+    u8 local_nan_identity_key[NAN_IDENTITY_KEY_LEN];
+    /* The PMK excahnge between two devices*/
+    NanSecurityPmk npk;
+    /* The AKM used during the key exchange*/
+    NanAkm akm;
+    /* NAN Cipher Suite Type */
+    u32 cipher_type;
+} NpkSecurityAssociation;
+
+/*
+ Event indication of pairing confirm is received on both
+ initiator and responder side confirming a pairing session
+*/
+typedef struct {
+    /*
+      Unique token Id generated on the initiator/responder side
+      used for a pairing session between two NAN devices
+    */
+    u32 pairing_instance_id;
+    /* Response code indicating ACCEPT/REJECT */
+    NanPairingResponseCode rsp_code;
+    /*
+      Reason code indicating the cause for REJECT.
+      NAN_STATUS_SUCCESS and NAN_STATUS_PROTOCOL_FAILURE are
+      expected reason codes.
+    */
+    NanStatusType reason_code;
+    /*
+      Indicate the pairing session is setup or verification
+    */
+    NanPairingRequestType nan_pairing_request_type;
+    /* Whether should cache the negotiated NIK/NPK for future verification */
+    u8 enable_pairing_cache;
+    /*
+      The security association info negotiated in the pairing setup, used for future verification
+    */
+    NpkSecurityAssociation npk_security_association;
+} NanPairingConfirmInd;
+
+/*
+  NAN pairing bootstrapping initiator request
+*/
+typedef struct {
+    /*
+       This Id is the Requestor Instance that is passed as
+       part of earlier MatchInd/FollowupInd message.
+    */
+    u32 requestor_instance_id;
+
+    /*
+      Discovery MAC addr of the publisher/peer
+    */
+    u8 peer_disc_mac_addr[NAN_MAC_ADDR_LEN];
+
+    /* Proposed bootstrapping method */
+    u16 request_bootstrapping_method;
+
+    /*
+       Sequence of values which further specify the published service beyond
+       the service name.
+    */
+    u16 service_specific_info_len;
+    u8 service_specific_info[NAN_MAX_SERVICE_SPECIFIC_INFO_LEN];
+
+    /*
+       Sequence of values indicating the service specific info in SDEA
+       Used for service managed bootstrapping method
+    */
+    u16 sdea_service_specific_info_len;
+    u8 sdea_service_specific_info[NAN_MAX_SDEA_SERVICE_SPECIFIC_INFO_LEN];
+
+    /* The length of cookie. */
+    u32 cookie_length;
+
+    /* Cookie for the follow up request */
+    u8 cookie[];
+
+} NanBootstrappingRequest;
+/*
+ NAN pairing bootstrapping response from responder to a initate request
+*/
+typedef struct {
+
+    /*
+       This Id is the Requestor Instance that is passed as
+       part of earlier MatchInd/FollowupInd message.
+    */
+    u32 service_instance_id;
+
+    /* Discovery MAC addr of the peer/initiator */
+    u8 peer_disc_mac_addr[NAN_MAC_ADDR_LEN];
+
+    /*
+       Sequence of values which further specify the published service beyond
+       the service name.
+    */
+    u16 service_specific_info_len;
+    u8 service_specific_info[NAN_MAX_SERVICE_SPECIFIC_INFO_LEN];
+
+    /*
+       Sequence of values indicating the service specific info in SDEA
+       Used for service managed bootstrapping method
+    */
+    u16 sdea_service_specific_info_len;
+    u8 sdea_service_specific_info[NAN_MAX_SDEA_SERVICE_SPECIFIC_INFO_LEN];
+
+    /* Response Code indicating ACCEPT/REJECT */
+    NanBootstrappingResponseCode rsp_code;
+
+    /* The delay of bootstrapping in seconds */
+    u32 come_back_delay;
+
+    /* The length of cookie. */
+    u32 cookie_length;
+
+    /* Cookie for the follow up response */
+    u8 cookie[];
+
+} NanBootstrappingIndicationResponse;
+
+/*
+  Event indication received on the responder side when a Nan boostrapping session is initiated on
+  the Initiator side
+*/
+typedef struct {
+    /* Publish or Subscribe Id of an earlier Publish/Subscribe */
+    u16 publish_subscribe_id;
+    /*
+      Unique Instance Id corresponding to a service/session.
+      This is similar to the publish_id generated on the
+      publisher side
+    */
+    u32 bootstrapping_instance_id;
+    /*
+      This Id is the Requestor Instance that is passed as
+      part of earlier MatchInd/FollowupInd message.
+    */
+    u32 requestor_instance_id;
+    /* Discovery MAC addr of the peer/initiator */
+    u8 peer_disc_mac_addr[NAN_MAC_ADDR_LEN];
+    /* Proposed bootstrapping method from peer*/
+    u16 request_bootstrapping_method;
+
+} NanBootstrappingRequestInd;
+
+/*
+ Event indication of bootstapping confirm is received on both
+ initiator side confirming a bootstrapping method
+*/
+typedef struct {
+    /*
+      Unique token Id generated on the initiator/responder side
+      used for a bootstrapping session between two NAN devices
+    */
+    u32 bootstrapping_instance_id;
+    /* Response Code indicating ACCEPT/REJECT */
+    NanBootstrappingResponseCode rsp_code;
+    /*
+      Reason code indicating the cause for REJECT.
+      NAN_STATUS_SUCCESS and NAN_STATUS_PROTOCOL_FAILURE are
+      expected reason codes.
+    */
+    NanStatusType reason_code;
+    /* The delay of bootstrapping in seconds */
+    u32 come_back_delay;
+
+    /* The length of cookie. */
+    u32 cookie_length;
+
+    /* Cookie received from the comeback response */
+    u8 cookie[];
+
+} NanBootstrappingConfirmInd;
+
+/*
+ Event indication the device enter or exist the suspension mode
+*/
+typedef struct {
+    /* Indication the device is suspended or not */
+    bool is_suspended;
+} NanSuspensionModeChangeInd;
+
 /* Response and Event Callbacks */
 typedef struct {
     /* NotifyResponse invoked to notify the status of the Request */
@@ -2483,7 +3058,12 @@
     void (*EventTransmitFollowup) (NanTransmitFollowupInd* event);
     void (*EventRangeRequest) (NanRangeRequestInd* event);
     void (*EventRangeReport) (NanRangeReportInd* event);
-    void (*EventScheduleUpdate)(NanDataPathScheduleUpdateInd* event);
+    void (*EventScheduleUpdate) (NanDataPathScheduleUpdateInd* event);
+    void (*EventPairingRequest) (NanPairingRequestInd* event);
+    void (*EventPairingConfirm) (NanPairingConfirmInd* event);
+    void (*EventBootstrappingRequest) (NanBootstrappingRequestInd* event);
+    void (*EventBootstrappingConfirm) (NanBootstrappingConfirmInd* event);
+    void (*EventSuspensionModeChange) (NanSuspensionModeChangeInd* event);
 } NanCallbackHandler;
 
 /**@brief nan_enable_request
@@ -2789,6 +3369,97 @@
 wifi_error nan_data_end(transaction_id id,
                         wifi_interface_handle iface,
                         NanDataPathEndRequest* msg);
+/**@brief nan_pairing_request
+ *        Initiate a NAN Pairingsession.
+ *
+ * @param transaction_id:
+ * @param wifi_interface_handle:
+ * @param NanPairingRequest:
+ * @return Synchronous wifi_error
+ * @return Asynchronous NotifyResponse CB return
+ *                      NAN_STATUS_SUCCESS
+ *                      NAN_STATUS_INVALID_PARAM
+ *                      NAN_STATUS_INTERNAL_FAILURE
+ *                      NAN_STATUS_PROTOCOL_FAILURE
+ *                      NAN_STATUS_INVALID_REQUESTOR_INSTANCE_ID
+ */
+wifi_error nan_pairing_request(transaction_id id, wifi_interface_handle iface,
+                               NanPairingRequest* msg);
+
+/**@brief nan_pairing_indication_response
+ *        Response to a pairing indication received
+ *        corresponding to a pairing session. An indication
+ *        is received with a pairing request and the responder
+ *        will send a pairing response
+ *
+ * @param transaction_id:
+ * @param wifi_interface_handle:
+ * @param NanPairingIndicationResponse:
+ * @return Synchronous wifi_error
+ * @return Asynchronous NotifyResponse CB return
+ *                      NAN_STATUS_SUCCESS
+ *                      NAN_STATUS_INVALID_PARAM
+ *                      NAN_STATUS_INTERNAL_FAILURE
+ *                      NAN_STATUS_PROTOCOL_FAILURE
+ *                      NAN_STATUS_INVALID_PAIRING_ID
+ */
+wifi_error nan_pairing_indication_response(transaction_id id, wifi_interface_handle iface,
+                                           NanPairingIndicationResponse* msg);
+
+/**@brief nan_pairing_end
+ *        Cancel and remove the existing Pairing setups
+ *
+ * @param transaction_id:
+ * @param wifi_interface_handle:
+ * @param NanPairingEndRequest:
+ * @return Synchronous wifi_error
+ * @return Asynchronous NotifyResponse CB return
+ *                      NAN_STATUS_SUCCESS
+ *                      NAN_STATUS_INVALID_PARAM
+ *                      NAN_STATUS_INTERNAL_FAILURE
+ *                      NAN_STATUS_PROTOCOL_FAILURE
+ *                      NAN_STATUS_INVALID_PAIRING_ID
+ */
+wifi_error nan_pairing_end(transaction_id id, wifi_interface_handle iface,
+                                                 NanPairingEndRequest* msg);
+
+/**@brief nan_bootstrapping_request
+ *        Initiate a NAN Bootstrapping session.
+ *
+ * @param transaction_id:
+ * @param wifi_interface_handle:
+ * @param NanBootstrappingRequest:
+ * @return Synchronous wifi_error
+ * @return Asynchronous NotifyResponse CB return
+ *                      NAN_STATUS_SUCCESS
+ *                      NAN_STATUS_INVALID_PARAM
+ *                      NAN_STATUS_INTERNAL_FAILURE
+ *                      NAN_STATUS_PROTOCOL_FAILURE
+ *                      NAN_STATUS_INVALID_REQUESTOR_INSTANCE_ID
+ */
+wifi_error nan_bootstrapping_request(transaction_id id, wifi_interface_handle iface,
+                                     NanBootstrappingRequest* msg);
+
+/**@brief nan_bootstrapping_indication_response
+ *         Response to a pairing indication received
+ *         corresponding to a pairing session. An indication
+ *         is received with a pairing request and the responder
+ *         will send a pairing response
+ *
+ * @param transaction_id:
+ * @param wifi_interface_handle:
+ * @param NanBootstrappingIndicationResponse:
+ * @return Synchronous wifi_error
+ * @return Asynchronous NotifyResponse CB return
+ *                      NAN_STATUS_SUCCESS
+ *                      NAN_STATUS_INVALID_PARAM
+ *                      NAN_STATUS_INTERNAL_FAILURE
+ *                      NAN_STATUS_PROTOCOL_FAILURE
+ *                      NAN_STATUS_INVALID_BOOTSTRAPPING_ID
+ */
+wifi_error nan_bootstrapping_indication_response(transaction_id id, wifi_interface_handle iface,
+                                                 NanBootstrappingIndicationResponse* msg);
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
diff --git a/power_test.cpp b/power_test.cpp
index 9a68651..7e0b68e 100644
--- a/power_test.cpp
+++ b/power_test.cpp
@@ -14,21 +14,21 @@
  * limitations under the License.
  */
 
-#include <android/system/suspend/internal/ISuspendControlServiceInternal.h>
-#include <binder/IServiceManager.h>
+#include <aidl/android/system/suspend/internal/ISuspendControlServiceInternal.h>
+#include <android/binder_manager.h>
 #include <gtest/gtest.h>
 #include <hardware_legacy/power.h>
 #include <wakelock/wakelock.h>
 
 #include <csignal>
 #include <cstdlib>
+#include <memory>
 #include <string>
 #include <thread>
 #include <vector>
 
-using android::sp;
-using android::system::suspend::internal::ISuspendControlServiceInternal;
-using android::system::suspend::internal::WakeLockInfo;
+using aidl::android::system::suspend::internal::ISuspendControlServiceInternal;
+using aidl::android::system::suspend::internal::WakeLockInfo;
 using namespace std::chrono_literals;
 
 namespace android {
@@ -93,17 +93,16 @@
 class WakeLockTest : public ::testing::Test {
    public:
     virtual void SetUp() override {
-        sp<IBinder> control =
-            android::defaultServiceManager()->getService(android::String16("suspend_control_internal"));
-        ASSERT_NE(control, nullptr) << "failed to get the internal suspend control service";
-        controlService = interface_cast<ISuspendControlServiceInternal>(control);
+        ndk::SpAIBinder binder(AServiceManager_waitForService("suspend_control_internal"));
+        controlService = ISuspendControlServiceInternal::fromBinder(binder);
+        ASSERT_NE(controlService, nullptr) << "failed to get the internal suspend control service";
     }
 
     // Returns true iff found.
-    bool findWakeLockInfoByName(const sp<ISuspendControlServiceInternal>& service, const std::string& name,
+    bool findWakeLockInfoByName(const std::string& name,
                                 WakeLockInfo* info) {
         std::vector<WakeLockInfo> wlStats;
-        service->getWakeLockStats(&wlStats);
+        controlService->getWakeLockStats(&wlStats);
         auto it = std::find_if(wlStats.begin(), wlStats.end(),
                                [&name](const auto& x) { return x.name == name; });
         if (it != wlStats.end()) {
@@ -114,7 +113,7 @@
     }
 
     // All userspace wake locks are registered with system suspend.
-    sp<ISuspendControlServiceInternal> controlService;
+    std::shared_ptr<ISuspendControlServiceInternal> controlService;
 };
 
 // Test RAII properties of WakeLock destructor.
@@ -127,7 +126,7 @@
         }
 
         WakeLockInfo info;
-        auto success = findWakeLockInfoByName(controlService, name, &info);
+        auto success = findWakeLockInfoByName(name, &info);
         ASSERT_TRUE(success);
         ASSERT_EQ(info.name, name);
         ASSERT_EQ(info.pid, getpid());
@@ -138,7 +137,7 @@
     // come on binder thread. Sleep to make sure that stats are reported *after* wake lock release.
     std::this_thread::sleep_for(1ms);
     WakeLockInfo info;
-    auto success = findWakeLockInfoByName(controlService, name, &info);
+    auto success = findWakeLockInfoByName(name, &info);
     ASSERT_TRUE(success);
     ASSERT_EQ(info.name, name);
     ASSERT_EQ(info.pid, getpid());