ソースを参照

qcacld-3.0: umac: Add TWT componentization public structs and files

Add TWT componentization public structs, files and skeleton code
i.e add new dispatcher APIs, target_if callbacks.

Change-Id: I21fd6f5c3e92f8ea725771c20cd6dfdb560b2bf3
CRs-Fixed: 3085430
Srinivas Girigowda 3 年 前
コミット
38fe8b7acb

+ 5 - 66
components/mlme/dispatcher/inc/wlan_mlme_twt_public_struct.h

@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2021, The Linux Foundation. All rights reserved.
- * Copyright (c) 2021 Qualcomm Innovation Center, Inc. All rights reserved.
+ * Copyright (c) 2021-2022 Qualcomm Innovation Center, Inc. All rights reserved.
  *
  * Permission to use, copy, modify, and/or distribute this software for any
  * purpose with or without fee is hereby granted, provided that the above
@@ -19,73 +19,12 @@
  * DOC: This file contains definitions for MLME TWT functionality.
  */
 
-#ifndef _WLAN_MLME_TWT_STRUCT_H_
-#define _WLAN_MLME_TWT_STRUCT_H_
+#ifndef _WLAN_MLME_TWT_PUBLIC_STRUCT_H_
+#define _WLAN_MLME_TWT_PUBLIC_STRUCT_H_
 
-#define TWT_ALL_SESSIONS_DIALOG_ID 255
-
-/**
- * enum wlan_twt_commands  - TWT commands
- * @WLAN_TWT_NONE: Indicates none of the TWT commands are active.
- * @WLAN_TWT_SETUP: TWT setup
- * @WLAN_TWT_TERMINATE: TWT terminate
- * @WLAN_TWT_SUSPEND: TWT suspend
- * @WLAN_TWT_RESUME: TWT resume
- * @WLAN_TWT_NUDGE: TWT nudge
- * @WLAN_TWT_STATISTICS: TWT statistics
- * @WLAN_TWT_CLEAR_STATISTICS: TWT clear statistics
- * @WLAN_TWT_SET_PARAM: TWT set parameter
- * @WLAN_TWT_ANY: Indicates one of the commands is in progress.
- */
-enum wlan_twt_commands {
-	WLAN_TWT_NONE             = 0,
-	WLAN_TWT_SETUP            = BIT(0),
-	WLAN_TWT_TERMINATE        = BIT(1),
-	WLAN_TWT_SUSPEND          = BIT(2),
-	WLAN_TWT_RESUME           = BIT(3),
-	WLAN_TWT_NUDGE            = BIT(4),
-	WLAN_TWT_STATISTICS       = BIT(5),
-	WLAN_TWT_CLEAR_STATISTICS = BIT(6),
-	WLAN_TWT_SET_PARAM        = BIT(7),
-	WLAN_TWT_ANY              = 0xFF,
-};
-
-/**
- * enum wlan_twt_capabilities  - Represents the Bitmap of TWT capabilities
- * supported by device and peer.
- * @WLAN_TWT_CAPA_REQUESTOR: TWT requestor support is advertised by TWT
- * non-scheduling STA.
- * @WLAN_TWT_CAPA_RESPONDER: TWT responder support is advertised by TWT
- * AP.
- * @WLAN_TWT_CAPA_BROADCAST: This indicates support for the role of broadcast
- * TWT scheduling/receiving functionality.
- * @WLAN_TWT_CAPA_FLEXIBLE: Device supports flexible TWT schedule.
- * @WLAN_TWT_CAPA_REQUIRED: The TWT Required is advertised by AP to indicate
- * that it mandates the associated HE STAs to support TWT.
- */
-enum wlan_twt_capabilities {
-	WLAN_TWT_CAPA_REQUESTOR = BIT(0),
-	WLAN_TWT_CAPA_RESPONDER = BIT(1),
-	WLAN_TWT_CAPA_BROADCAST = BIT(2),
-	WLAN_TWT_CAPA_FLEXIBLE =  BIT(3),
-	WLAN_TWT_CAPA_REQUIRED =  BIT(4),
-};
-
-/**
- * enum wlan_twt_session_state  - TWT session state for a dialog id
- * @WLAN_TWT_SETUP_STATE_NOT_ESTABLISHED: Session doesn't exist
- * @WLAN_TWT_SETUP_STATE_ACTIVE: TWT session is active
- * @WLAN_TWT_SETUP_STATE_SUSPEND: TWT session is suspended
- */
-enum wlan_twt_session_state {
-	WLAN_TWT_SETUP_STATE_NOT_ESTABLISHED = 0,
-	WLAN_TWT_SETUP_STATE_ACTIVE = 1,
-	WLAN_TWT_SETUP_STATE_SUSPEND = 2,
-};
+#include <wlan_twt_public_structs.h>
 
 #ifdef WLAN_SUPPORT_TWT
-#define WLAN_MAX_TWT_SESSIONS_PER_PEER 1
-
 /**
  * struct twt_session_info  - TWT session related parameters
  * @dialog_id: TWT session dialog id
@@ -114,4 +53,4 @@ struct twt_context {
 	struct twt_session_info session_info[WLAN_MAX_TWT_SESSIONS_PER_PEER];
 };
 #endif /* WLAN_SUPPORT_TWT */
-#endif /* _WLAN_MLME_TWT_STRUCT_H_ */
+#endif /* _WLAN_MLME_TWT_PUBLIC_STRUCT_H_ */

+ 107 - 0
components/umac/twt/core/src/wlan_twt_cfg.c

@@ -0,0 +1,107 @@
+/*
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for
+ * any purpose with or without fee is hereby granted, provided that the
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+#include <wlan_twt_ext_type.h>
+#include <wlan_twt_api.h>
+#include <cfg_ucfg_api.h>
+#include <cfg_twt.h>
+#include "wlan_twt_cfg.h"
+#include "twt/core/src/wlan_twt_priv.h"
+
+QDF_STATUS wlan_twt_cfg_init(struct wlan_objmgr_psoc *psoc)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS wlan_twt_cfg_update(struct wlan_objmgr_psoc *psoc)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS
+wlan_twt_cfg_get_requestor(struct wlan_objmgr_psoc *psoc, bool *val)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS
+wlan_twt_cfg_get_responder(struct wlan_objmgr_psoc *psoc, bool *val)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS
+wlan_twt_cfg_get_congestion_timeout(struct wlan_objmgr_psoc *psoc,
+				    uint32_t *val)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS
+wlan_twt_cfg_set_congestion_timeout(struct wlan_objmgr_psoc *psoc, uint32_t val)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS
+wlan_twt_cfg_get_requestor_flag(struct wlan_objmgr_psoc *psoc, bool *val)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS
+wlan_twt_cfg_set_requestor_flag(struct wlan_objmgr_psoc *psoc, bool val)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS
+wlan_twt_cfg_get_responder_flag(struct wlan_objmgr_psoc *psoc, bool *val)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS
+wlan_twt_cfg_set_responder_flag(struct wlan_objmgr_psoc *psoc, bool val)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS
+wlan_twt_cfg_get_flex_sched(struct wlan_objmgr_psoc *psoc, bool *val)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS
+wlan_twt_cfg_get_24ghz_enabled(struct wlan_objmgr_psoc *psoc, bool *val)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS
+wlan_twt_cfg_get_bcast_requestor(struct wlan_objmgr_psoc *psoc, bool *val)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS
+wlan_twt_cfg_get_bcast_responder(struct wlan_objmgr_psoc *psoc, bool *val)
+{
+	return QDF_STATUS_SUCCESS;
+}
+

+ 174 - 0
components/umac/twt/core/src/wlan_twt_cfg.h

@@ -0,0 +1,174 @@
+/*
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for
+ * any purpose with or without fee is hereby granted, provided that the
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+#include <wlan_objmgr_psoc_obj.h>
+
+#if defined(WLAN_SUPPORT_TWT) && defined(WLAN_TWT_CONV_SUPPORTED)
+/**
+ * wlan_twt_cfg_init() - Initialize twt config params
+ * @psoc: Pointer to global psoc
+ *
+ * This function initializes the twt private cfg params
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS wlan_twt_cfg_init(struct wlan_objmgr_psoc *psoc);
+
+/**
+ * wlan_twt_cfg_update() - Update twt config params
+ * @psoc: Pointer to global psoc
+ *
+ * This function updates the cfg param structure based on the
+ * intersection of target capabilities and other cfg params
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS wlan_twt_cfg_update(struct wlan_objmgr_psoc *psoc);
+
+/**
+ * wlan_twt_cfg_get_requestor() - get cfg requestor
+ * @psoc: Pointer to global psoc
+ * @val: pointer to output variable
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+wlan_twt_cfg_get_requestor(struct wlan_objmgr_psoc *psoc, bool *val);
+
+/**
+ * wlan_twt_cfg_get_responder() - get cfg responder
+ * @psoc: Pointer to global psoc
+ * @val: pointer to output variable
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+wlan_twt_cfg_get_responder(struct wlan_objmgr_psoc *psoc, bool *val);
+
+/**
+ * wlan_twt_cfg_set_responder() - set cfg responder
+ * @psoc: Pointer to global psoc
+ * @val: value to be set
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+wlan_twt_cfg_set_responder(struct wlan_objmgr_psoc *psoc, bool val);
+
+/**
+ * wlan_twt_cfg_get_congestion_timeout() - get congestion timeout
+ * @psoc: Pointer to global psoc
+ * @val: pointer to output variable
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+wlan_twt_cfg_get_congestion_timeout(struct wlan_objmgr_psoc *psoc,
+				    uint32_t *val);
+
+/**
+ * wlan_twt_cfg_set_congestion_timeout() - set congestion timeout
+ * @psoc: Pointer to global psoc
+ * @val: value to be set
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+wlan_twt_cfg_set_congestion_timeout(struct wlan_objmgr_psoc *psoc,
+				    uint32_t val);
+
+/**
+ * wlan_twt_cfg_get_requestor_flag() - get requestor flag
+ * @psoc: Pointer to global psoc
+ * @val: pointer to output variable
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+wlan_twt_cfg_get_requestor_flag(struct wlan_objmgr_psoc *psoc, bool *val);
+
+/**
+ * wlan_twt_cfg_set_requestor_flag() - set requestor flag
+ * @psoc: Pointer to global psoc
+ * @val: value to be set
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+wlan_twt_cfg_set_requestor_flag(struct wlan_objmgr_psoc *psoc, bool val);
+
+/**
+ * wlan_twt_cfg_get_responder_flag() - get responder flag
+ * @psoc: Pointer to global psoc
+ * @val: pointer to output variable
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+wlan_twt_cfg_get_responder_flag(struct wlan_objmgr_psoc *psoc, bool *val);
+
+/**
+ * wlan_twt_cfg_set_responder_flag() - set responder flag
+ * @psoc: Pointer to global psoc
+ * @val: value to be set
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+wlan_twt_cfg_set_responder_flag(struct wlan_objmgr_psoc *psoc, bool val);
+
+/**
+ * wlan_twt_cfg_get_flex_twt_sched() - get flex scheduling
+ * @psoc: Pointer to global psoc
+ * @val: pointer to output variable
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+wlan_twt_cfg_get_flex_sched(struct wlan_objmgr_psoc *psoc, bool *val);
+
+/**
+ * wlan_twt_cfg_get_24ghz_enabled() - get 24ghz enable
+ * @psoc: Pointer to global psoc
+ * @val: pointer to output variable
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+wlan_twt_cfg_get_24ghz_enabled(struct wlan_objmgr_psoc *psoc, bool *val);
+
+/**
+ * wlan_twt_cfg_get_bcast_requestor() - get bcast requestor
+ * @psoc: Pointer to global psoc
+ * @val: pointer to output variable
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+wlan_twt_cfg_get_bcast_requestor(struct wlan_objmgr_psoc *psoc, bool *val);
+
+/**
+ * wlan_twt_cfg_get_bcast_responder() - get bcast responder
+ * @psoc: Pointer to global psoc
+ * @val: pointer to output variable
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+wlan_twt_cfg_get_bcast_responder(struct wlan_objmgr_psoc *psoc, bool *val);
+#endif
+

+ 602 - 0
components/umac/twt/core/src/wlan_twt_main.c

@@ -0,0 +1,602 @@
+/*
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for
+ * any purpose with or without fee is hereby granted, provided that the
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+#include <wlan_objmgr_psoc_obj.h>
+#include <wlan_objmgr_peer_obj.h>
+#include <wlan_twt_api.h>
+#include <wlan_utility.h>
+#include <wlan_mlme_api.h>
+#include <wlan_mlme_main.h>
+#include "wlan_twt_main.h"
+#include "twt/core/src/wlan_twt_priv.h"
+
+/**
+ * wlan_twt_add_session()  - Add TWT session entry in the TWT context
+ * @psoc: Pointer to global psoc object
+ * @peer_mac: Global peer mac address
+ * @dialog_id: Dialog ID
+ * @context: request context
+ *
+ * Return: QDF_STATUS
+ */
+static QDF_STATUS
+wlan_twt_add_session(struct wlan_objmgr_psoc *psoc,
+		     struct qdf_mac_addr *peer_mac,
+		     uint8_t dialog_id,
+		     void *context)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+/**
+ * wlan_twt_set_command_in_progress() - Set TWT command is in progress
+ * @psoc: Pointer to psoc object
+ * @peer_mac: Pointer to peer mac address
+ * @dialog_id: Dialog id
+ * @cmd: TWT command
+ *
+ * Return: QDF_STATUS
+ */
+static QDF_STATUS
+wlan_twt_set_command_in_progress(struct wlan_objmgr_psoc *psoc,
+				 struct qdf_mac_addr *peer_mac,
+				 uint8_t dialog_id,
+				 enum wlan_twt_commands cmd)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS
+wlan_twt_init_context(struct wlan_objmgr_psoc *psoc,
+		      struct qdf_mac_addr *peer_mac,
+		      uint8_t dialog_id)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+/**
+ * wlan_is_twt_notify_in_progress() - is TWT notify in progress
+ * @psoc: Pointer to psoc object
+ * @vdev_id: VDEV identifier
+ *
+ * Return: True if twt_notify is in progress.
+ */
+static bool
+wlan_is_twt_notify_in_progress(struct wlan_objmgr_psoc *psoc, uint32_t vdev_id)
+{
+	return false;
+}
+
+/**
+ * wlan_twt_set_wait_for_notify()  - Set wait for notify flag
+ * @psoc: Pointer to psoc object
+ * @vdev_id: VDEV identifier
+ * @is_set: Set or clear notify flag
+ *
+ * Return: QDF_STATUS
+ */
+static QDF_STATUS
+wlan_twt_set_wait_for_notify(struct wlan_objmgr_psoc *psoc, uint32_t vdev_id,
+			     bool is_set)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+/**
+ * wlan_twt_any_peer_cmd_in_progress() - Iterate through the list of peers
+ * and check if the given command is in progress
+ * @psoc: Pointer to psoc object
+ * @vdev_id: Vdev id
+ * @dialog_id: Dialog id
+ * @cmd: command
+ *
+ * This API is used to check for the given @dialog_id if the
+ * @cmd command is in progress for any of the peers.
+ *
+ * Return: true if command is in progress, false otherwise
+ */
+static bool
+wlan_twt_any_peer_cmd_in_progress(struct wlan_objmgr_psoc *psoc,
+				  uint8_t vdev_id,
+				  uint8_t dialog_id,
+				  enum wlan_twt_commands cmd)
+{
+	return false;
+}
+
+/**
+ * wlan_twt_sap_peer_is_cmd_in_progress() - For a given peer_mac check if
+ * the given command is in progress
+ * @psoc: Pointer to psoc object
+ * @peer_mac: Pointer to peer mac address
+ * @dialog_id: Dialog id
+ * @cmd: TWT command
+ *
+ * Return: True if given command is in progress.
+ */
+static bool
+wlan_twt_sap_peer_is_cmd_in_progress(struct wlan_objmgr_psoc *psoc,
+				     struct qdf_mac_addr *peer_mac,
+				     uint8_t dialog_id,
+				     enum wlan_twt_commands cmd)
+{
+	return false;
+}
+
+/**
+ * wlan_twt_sap_is_command_in_progress() - Based on the input peer mac address
+ * invoke the appropriate function to check if the given command is in progress
+ * @psoc: Pointer to psoc object
+ * @vdev_id: Vdev id
+ * @peer_mac: Peer MAC address
+ * @dialog_id: Dialog id
+ * @cmd: command
+ *
+ * If the input @peer_mac is a broadcast MAC address then the expectation is
+ * to iterate through the list of all peers and check for any given @dialog_id
+ * if the command @cmd is in progress.
+ * Note: If @peer_mac is broadcast MAC address then @dialog_id shall always
+ * be TWT_ALL_SESSIONS_DIALOG_ID.
+ * For ex: If TWT teardown command is issued on a particular @dialog_id and
+ * non-broadcast peer mac and FW response is not yet received then for that
+ * particular @dialog_id and @peer_mac, TWT teardown is the active command,
+ * then if the driver receives another TWT teardown request with broadcast
+ * peer mac, then API wlan_twt_any_peer_cmd_in_progress() shall iterate
+ * through the list of all peers and returns command in progress as true.
+ *
+ * If the input @peer_mac is a non-broadcast MAC address then
+ * wlan_twt_sap_peer_is_cmd_in_progress() shall check only for that
+ * particular @peer_mac and @dialog_id.
+ *
+ * Return: true if command is in progress, false otherwise
+ */
+static bool
+wlan_twt_sap_is_command_in_progress(struct wlan_objmgr_psoc *psoc,
+				    uint32_t vdev_id,
+				    struct qdf_mac_addr *peer_mac,
+				    uint8_t dialog_id,
+				    enum wlan_twt_commands cmd)
+{
+	if (qdf_is_macaddr_broadcast(peer_mac)) {
+		return wlan_twt_any_peer_cmd_in_progress(psoc, vdev_id,
+							 dialog_id, cmd);
+	} else {
+		return wlan_twt_sap_peer_is_cmd_in_progress(psoc, peer_mac,
+							    dialog_id, cmd);
+	}
+}
+
+/**
+ * wlan_twt_sap_add_session() - Based on the input peer mac address
+ * invoke the appropriate function to add dialog_id to the TWT session context
+ * @psoc: Pointer to psoc object
+ * @vdev_id: Vdev id
+ * @peer_mac: Peer MAC address
+ * @dialog_id: Dialog id
+ *
+ * If the input @peer_mac is a broadcast MAC address then there is nothing
+ * to do, because the initialized structure is already in the expected format
+ * Note: If @peer_mac is broadcast MAC address then @dialog_id shall always
+ * be TWT_ALL_SESSIONS_DIALOG_ID.
+ *
+ * If the input @peer_mac is a non-broadcast MAC address then
+ * wlan_twt_add_session() shall add the @dialog_id to the @peer_mac
+ * TWT session context.
+ *
+ * Return: None
+ */
+static void
+wlan_twt_sap_add_session(struct wlan_objmgr_psoc *psoc,
+			 uint8_t vdev_id,
+			 struct qdf_mac_addr *peer_mac,
+			 uint8_t dialog_id)
+{
+	if (!qdf_is_macaddr_broadcast(peer_mac))
+		wlan_twt_add_session(psoc, peer_mac, dialog_id, NULL);
+}
+
+/**
+ * wlan_twt_sap_set_all_peers_cmd_in_progress()  - Iterate through the list
+ * of peers and set the command in the TWT session entry in the TWT context
+ * @psoc: Pointer to global psoc object
+ * @vdev_id: Vdev id
+ * @dialog_id: Dialog ID
+ * @cmd: Command
+ *
+ * This API iterates through the list of peers and updates the active
+ * command to @cmd for the given dialog_id.
+ *
+ * Return: QDF_STATUS
+ */
+static QDF_STATUS
+wlan_twt_sap_set_all_peers_cmd_in_progress(struct wlan_objmgr_psoc *psoc,
+					   uint8_t vdev_id,
+					   uint8_t dialog_id,
+					   enum wlan_twt_commands cmd)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+/**
+ * wlan_twt_sap_set_command_in_progress() - Based on the input peer mac address
+ * invoke the appropriate function to set the command is in progress
+ * @psoc: Pointer to psoc object
+ * @vdev_id: Vdev id
+ * @peer_mac: Peer MAC address
+ * @dialog_id: Dialog id
+ * @cmd: command
+ *
+ * If the input @peer_mac is a broadcast MAC address then the expectation is
+ * to iterate through the list of all peers and set the active command to @cmd
+ * for the given @dialog_id
+ * Note: If @peer_mac is broadcast MAC address then @dialog_id shall always
+ * be TWT_ALL_SESSIONS_DIALOG_ID.
+ * For ex: If TWT teardown command is issued on broadcast @peer_mac, then
+ * it is same as issuing TWT teardown for all the peers (all TWT sessions).
+ * Invoking wlan_twt_sap_set_all_peers_cmd_in_progress() shall iterate through
+ * all the peers and set the active command to @cmd.
+ *
+ * If the input @peer_mac is a non-broadcast MAC address then
+ * wlan_twt_set_command_in_progress() shall set the active command to @cmd
+ * only for that particular @peer_mac and @dialog_id.
+ *
+ * Return: QDF_STATUS
+ */
+static QDF_STATUS
+wlan_twt_sap_set_command_in_progress(struct wlan_objmgr_psoc *psoc,
+				     uint8_t vdev_id,
+				     struct qdf_mac_addr *peer_mac,
+				     uint8_t dialog_id,
+				     enum wlan_twt_commands cmd)
+{
+	if (qdf_is_macaddr_broadcast(peer_mac)) {
+		return wlan_twt_sap_set_all_peers_cmd_in_progress(psoc,
+								  vdev_id,
+								  dialog_id,
+								  cmd);
+	} else {
+		return wlan_twt_set_command_in_progress(psoc, peer_mac,
+							dialog_id, cmd);
+	}
+}
+
+/**
+ * wlan_twt_init_all_peers_context()  - Iterate through the list
+ * of peers and initialize the TWT context structure
+ * @psoc: Pointer to global psoc object
+ * @vdev_id: Vdev id
+ * @dialog_id: Dialog ID
+ *
+ * This API iterates through the list of peers and initializes
+ * the TWT context structure
+ *
+ * Return: QDF_STATUS
+ */
+static QDF_STATUS
+wlan_twt_init_all_peers_context(struct wlan_objmgr_psoc *psoc,
+				uint8_t vdev_id,
+				uint8_t dialog_id)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+/**
+ * wlan_twt_sap_init_context() - Based on the input peer mac address
+ * invoke the appropriate function to initialize the TWT session context
+ * @psoc: Pointer to psoc object
+ * @vdev_id: Vdev id
+ * @peer_mac: Peer MAC address
+ * @dialog_id: Dialog id
+ *
+ * If the input @peer_mac is a broadcast MAC address then the expectation is
+ * to iterate through the list of all peers and initialize the TWT session
+ * context
+ * Note: If @peer_mac is broadcast MAC address then @dialog_id shall always
+ * be TWT_ALL_SESSIONS_DIALOG_ID.
+ * For ex: If TWT teardown command is issued on broadcast @peer_mac, then
+ * it is same as issuing TWT teardown for all the peers (all TWT sessions).
+ * Then active command for all the peers is set to @WLAN_TWT_TERMINATE.
+ * Upon receiving the TWT teardown WMI event, wlan_twt_init_all_peers_context()
+ * shall iterate through the list of all peers and initializes the TWT session
+ * context back to its initial state.
+ *
+ * If the input @peer_mac is a non-broadcast MAC address then
+ * wlan_twt_init_context() shall initialize the TWT session context
+ * only for that particular @peer_mac and @dialog_id.
+ *
+ * Return: QDF_STATUS
+ */
+static QDF_STATUS
+wlan_twt_sap_init_context(struct wlan_objmgr_psoc *psoc,
+			  uint8_t vdev_id,
+			  struct qdf_mac_addr *peer_mac,
+			  uint8_t dialog_id)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+/**
+ * wlan_is_vdev_connected_to_peer()  - find if peer exists in the vdev peer list
+ * @psoc: Pointer to global psoc object
+ * @vdev_id: Vdev id
+ * @peer_macaddr: peer mac address
+ *
+ * This API finds if for the given vdev there exists a peer with the given
+ * @peer_macaddr
+ *
+ * Return: true if exists, false otherwise
+ */
+static bool
+wlan_is_vdev_connected_to_peer(struct wlan_objmgr_psoc *psoc, uint32_t vdev_id,
+			       struct qdf_mac_addr *peer_macaddr)
+{
+	return false;
+}
+
+/**
+ * wlan_twt_is_setup_done()  - Get if TWT session is established for given
+ * dialog id.
+ * @psoc: Pointer to psoc object
+ * @peer_mac: Pointer to peer mac address
+ * @dialog_id: Dialog id
+ *
+ * Return: Return true if TWT session exists for given dialog ID.
+ */
+static
+bool wlan_twt_is_setup_done(struct wlan_objmgr_psoc *psoc,
+			    struct qdf_mac_addr *peer_mac, uint8_t dialog_id)
+{
+	return false;
+}
+
+bool wlan_twt_is_max_sessions_reached(struct wlan_objmgr_psoc *psoc,
+				      struct qdf_mac_addr *peer_mac,
+				      uint8_t dialog_id)
+{
+	return false;
+}
+
+bool wlan_twt_is_setup_in_progress(struct wlan_objmgr_psoc *psoc,
+				   struct qdf_mac_addr *peer_mac,
+				   uint8_t dialog_id)
+{
+	return false;
+}
+
+/**
+ * wlan_twt_set_ack_context() - set twt ack context
+ * for given dialog id
+ * @psoc: Pointer to global psoc object
+ * @peer_mac: Global peer mac address
+ * @dialog_id: Dialog ID
+ *
+ * Return: QDF_STATUS
+ */
+static QDF_STATUS
+wlan_twt_set_ack_context(struct wlan_objmgr_psoc *psoc,
+			 struct qdf_mac_addr *peer_mac,
+			 uint8_t dialog_id,
+			 void *context)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+/**
+ * wlan_twt_get_ack_context() - get twt ack context
+ * for given dialog id
+ * @psoc: Pointer to global psoc object
+ * @peer_mac: Global peer mac address
+ * @dialog_id: Dialog ID
+ *
+ * Return: QDF_STATUS
+ */
+static QDF_STATUS
+wlan_twt_get_ack_context(struct wlan_objmgr_psoc *psoc,
+			 struct qdf_mac_addr *peer_mac,
+			 uint8_t dialog_id,
+			 void **context)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+/**
+ * wlan_twt_is_command_in_progress() - Check if given command is in progress
+ * @psoc: Pointer to psoc object
+ * @peer_mac: Pointer to peer mac address
+ * @dialog_id: Dialog id
+ * @cmd: TWT command
+ * @active_cmd: Fill the active command in this output parameter
+ *
+ * Return: True if given command is in progress.
+ */
+static
+bool wlan_twt_is_command_in_progress(struct wlan_objmgr_psoc *psoc,
+				     struct qdf_mac_addr *peer_mac,
+				     uint8_t dialog_id,
+				     enum wlan_twt_commands cmd,
+				     enum wlan_twt_commands *pactive_cmd)
+{
+	return false;
+}
+
+QDF_STATUS wlan_twt_setup_req(struct wlan_objmgr_psoc *psoc,
+			      struct twt_add_dialog_param *req,
+			      void *context)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+/**
+ * wlan_twt_sta_teardown_req() - station TWT teardown request
+ * @psoc: Pointer to psoc object
+ * @req: TWT del dialog parameters
+ * @context: TWT context
+ *
+ * Return: QDF Status
+ */
+static QDF_STATUS
+wlan_twt_sta_teardown_req(struct wlan_objmgr_psoc *psoc,
+			  struct twt_del_dialog_param *req,
+			  void *context)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+/**
+ * wlan_twt_sap_teardown_req() - sap TWT teardown request
+ * @psoc: Pointer to psoc object
+ * @req: TWT del dialog parameters
+ * @context: TWT context
+ *
+ * Return: QDF Status
+ */
+static QDF_STATUS
+wlan_twt_sap_teardown_req(struct wlan_objmgr_psoc *psoc,
+			  struct twt_del_dialog_param *req)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS
+wlan_twt_teardown_req(struct wlan_objmgr_psoc *psoc,
+		      struct twt_del_dialog_param *req,
+		      void *context)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS
+wlan_twt_ack_event_handler(struct wlan_objmgr_psoc *psoc,
+			   struct twt_ack_complete_event_param *event)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+/**
+ * wlan_twt_set_setup_done()  - Set TWT setup complete for given dialog ID
+ * @psoc: Pointer to psoc object
+ * @peer_mac: Pointer to peer mac address
+ * @dialog_id: Dialog id
+ * @is_set: Set or clear the setup done flag
+ *
+ * Return: None
+ */
+static void
+wlan_twt_set_setup_done(struct wlan_objmgr_psoc *psoc,
+			struct qdf_mac_addr *peer_mac,
+			uint8_t dialog_id, bool is_set)
+{
+}
+
+/**
+ * wlan_twt_set_session_state() - Set the TWT session state for the given dialog
+ * id in TWT context
+ * @peer: Pointer to peer object
+ * @peer_mac: Pointer to peer mac address
+ * @dialog_id: Dialog id
+ * @state: TWT session state
+ *
+ * Return: None
+ */
+static void
+wlan_twt_set_session_state(struct wlan_objmgr_psoc *psoc,
+			   struct qdf_mac_addr *peer_mac,
+			   uint8_t dialog_id,
+			   enum wlan_twt_session_state state)
+{
+}
+
+/**
+ * wlan_twt_process_renego_failure() - Process TWT re-negotiation failure
+ * @psoc: psoc
+ * @event: pointer to event buf containing twt response parameters
+ *
+ * Return: None
+ */
+static void
+wlan_twt_process_renego_failure(struct wlan_objmgr_psoc *psoc,
+				struct twt_add_dialog_complete_event *event)
+{
+}
+
+/**
+ * wlan_twt_process_add_initial_nego() - Process initial TWT setup or
+ * re-negotiation successful setup
+ * @psoc: psoc
+ * @add_dialog_event: pointer to event buf containing twt response parameters
+ *
+ * Return: None
+ */
+static void
+wlan_twt_process_add_initial_nego(struct wlan_objmgr_psoc *psoc,
+				  struct twt_add_dialog_complete_event *event)
+{
+}
+
+QDF_STATUS
+wlan_twt_setup_complete_event_handler(struct wlan_objmgr_psoc *psoc,
+				    struct twt_add_dialog_complete_event *event)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+static bool
+wlan_is_twt_teardown_failed(enum HOST_TWT_DEL_STATUS teardown_status)
+{
+	return false;
+}
+
+static void
+wlan_twt_handle_sta_del_dialog_event(struct wlan_objmgr_psoc *psoc,
+			      struct twt_del_dialog_complete_event_param *event)
+{
+}
+
+QDF_STATUS
+wlan_twt_teardown_complete_event_handler(struct wlan_objmgr_psoc *psoc,
+			      struct twt_del_dialog_complete_event_param *event)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS
+wlan_twt_pause_complete_event_handler(struct wlan_objmgr_psoc *psoc,
+			    struct twt_pause_dialog_complete_event_param *event)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS
+wlan_twt_resume_complete_event_handler(struct wlan_objmgr_psoc *psoc,
+			   struct twt_resume_dialog_complete_event_param *event)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS
+wlan_twt_nudge_complete_event_handler(struct wlan_objmgr_psoc *psoc,
+			    struct twt_nudge_dialog_complete_event_param *event)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS
+wlan_twt_notify_event_handler(struct wlan_objmgr_psoc *psoc,
+			      struct twt_notify_event_param *event)
+{
+	return QDF_STATUS_SUCCESS;
+}

+ 166 - 0
components/umac/twt/core/src/wlan_twt_main.h

@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for
+ * any purpose with or without fee is hereby granted, provided that the
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/**
+ * wlan_twt_is_max_sessions_reached() - Check if the maximum number of
+ * TWT sessions reached or not excluding the given dialog_id
+ * @psoc: Pointer to global PSOC object
+ * @peer_mac: Global peer mac address
+ * @dialog_id: dialog id
+ *
+ * Check if the number of active TWT sessions is equal to the maximum number
+ * of TWT sessions supported. Only count the TWT session slot if it not
+ * TWT_ALL_SESSIONS_DIALOG_ID and dialog id is different from input dialog_id,
+ * because if same dialog_id already exists in the TWT sessions, we should
+ * return false since re-negotiation is supported on existing dialog_id.
+ *
+ * Return: True if slot is available for dialog_id, false otherwise
+ */
+bool
+wlan_twt_is_max_sessions_reached(struct wlan_objmgr_psoc *psoc,
+				 struct qdf_mac_addr *peer_mac,
+				 uint8_t dialog_id);
+
+/**
+ * wlan_twt_setup_req() - twt setup request
+ * @psoc: Pointer to psoc object
+ * @req: TWT setup request
+ * @context: context
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+wlan_twt_setup_req(struct wlan_objmgr_psoc *psoc,
+		   struct twt_add_dialog_param *req,
+		   void *context);
+
+/**
+ * wlan_twt_teardown_req() - twt teardown request
+ * @psoc: Pointer to psoc object
+ * @req: TWT setup request
+ * @context: context
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+wlan_twt_teardown_req(struct wlan_objmgr_psoc *psoc,
+		      struct twt_del_dialog_param *req,
+		      void *context);
+/**
+ * wlan_twt_is_setup_in_progress() - Get if TWT setup command is in progress
+ * for given dialog id
+ * @psoc: Pointer to global psoc object
+ * @peer_mac: Global peer mac address
+ * @dialog_id: Dialog ID
+ *
+ * Return: True if Setup is in progress
+ */
+bool
+wlan_twt_is_setup_in_progress(struct wlan_objmgr_psoc *psoc,
+			      struct qdf_mac_addr *peer_mac,
+			      uint8_t dialog_id);
+
+/**
+ * wlan_twt_setup_complete_event_handler() - twt setup complete event handler
+ * @psoc: Pointer to global psoc object
+ * @event: add dialog event
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+wlan_twt_setup_complete_event_handler(struct wlan_objmgr_psoc *psoc,
+				   struct twt_add_dialog_complete_event *event);
+
+/**
+ * wlan_twt_ack_event_handler() - ack complete event handler
+ * @psoc: Pointer to global psoc object
+ * @event: ack complete event
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+wlan_twt_ack_event_handler(struct wlan_objmgr_psoc *psoc,
+			   struct twt_ack_complete_event_param *event);
+
+/**
+ * wlan_twt_teardown_complete_event_handler() - teardown complete event handler
+ * @psoc: Pointer to global psoc object
+ * @event: del complete event
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+wlan_twt_teardown_complete_event_handler(struct wlan_objmgr_psoc *psoc,
+			     struct twt_del_dialog_complete_event_param *event);
+
+/**
+ * wlan_twt_pause_complete_event_handler() - pause complete event handler
+ * @psoc: Pointer to global psoc object
+ * @event: pause complete event
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+wlan_twt_pause_complete_event_handler(struct wlan_objmgr_psoc *psoc,
+			  struct twt_pause_dialog_complete_event_param *event);
+
+/**
+ * wlan_twt_resume_complete_event_handler() - resume complete event handler
+ * @psoc: Pointer to global psoc object
+ * @event: resume complete event
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+wlan_twt_resume_complete_event_handler(struct wlan_objmgr_psoc *psoc,
+			  struct twt_resume_dialog_complete_event_param *event);
+
+/**
+ * wlan_twt_nudge_complete_event_handler() - nudge complete event handler
+ * @psoc: Pointer to global psoc object
+ * @event: nudge complete event
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+wlan_twt_nudge_complete_event_handler(struct wlan_objmgr_psoc *psoc,
+			   struct twt_nudge_dialog_complete_event_param *event);
+
+/**
+ * wlan_twt_notify_event_handler() - notify event handler
+ * @psoc: Pointer to global psoc object
+ * @event: notify complete event
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+wlan_twt_notify_event_handler(struct wlan_objmgr_psoc *psoc,
+			      struct twt_notify_event_param *event);
+
+/**
+ * wlan_twt_init_context() - Initialize TWT context structure
+ * @psoc: Pointer to psoc object
+ * @peer_mac: Pointer to peer mac address
+ * @dialog_id: Dialog id
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+wlan_twt_init_context(struct wlan_objmgr_psoc *psoc,
+		      struct qdf_mac_addr *peer_mac,
+		      uint8_t dialog_id);

+ 206 - 0
components/umac/twt/dispatcher/inc/cfg_twt.h

@@ -0,0 +1,206 @@
+/*
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for
+ * any purpose with or without fee is hereby granted, provided that the
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/**
+ * DOC: This file contains TWT config related definitions
+ */
+
+#ifndef __CFG_TWT_H_
+#define __CFG_TWT_H_
+
+#if defined(WLAN_SUPPORT_TWT) && defined(WLAN_TWT_CONV_SUPPORTED)
+/*
+ * <ini>
+ * twt_requestor - twt requestor.
+ * @Min: 0
+ * @Max: 1
+ * @Default: 1
+ *
+ * This cfg is used to store twt requestor config.
+ *
+ * Related: NA
+ *
+ * Supported Feature: 11AX
+ *
+ * Usage: Internal
+ *
+ * </ini>
+ */
+#define CFG_TWT_REQUESTOR CFG_INI_BOOL( \
+		"twt_requestor", \
+		1, \
+		"TWT requestor")
+/*
+ * <ini>
+ * twt_responder - twt responder.
+ * @Min: 0
+ * @Max: 1
+ * @Default: 1
+ *
+ * This cfg is used to store twt responder config.
+ *
+ * Related: NA
+ *
+ * Supported Feature: 11AX
+ *
+ * Usage: Internal
+ *
+ * </ini>
+ */
+#define CFG_TWT_RESPONDER CFG_INI_BOOL( \
+		"twt_responder", \
+		1, \
+		"TWT responder")
+
+/*
+ * <ini>
+ * enable_twt - Enable Target Wake Time support.
+ * @Min: 0
+ * @Max: 1
+ * @Default: 1
+ *
+ * This ini is used to enable or disable TWT support.
+ *
+ * Related: NA
+ *
+ * Supported Feature: 11AX
+ *
+ * Usage: External
+ *
+ * </ini>
+ */
+#define CFG_ENABLE_TWT CFG_INI_BOOL( \
+		"enable_twt", \
+		1, \
+		"TWT support")
+
+/*
+ * <ini>
+ * twt_congestion_timeout - Target wake time congestion timeout.
+ * @Min: 0
+ * @Max: 10000
+ * @Default: 100
+ *
+ * STA uses this timer to continuously monitor channel congestion levels to
+ * decide whether to start or stop TWT. This ini is used to configure the
+ * target wake time congestion timeout value in the units of milliseconds.
+ * A value of Zero indicates that this is a host triggered TWT and all the
+ * necessary configuration for TWT will be directed from the host.
+ *
+ * Related: NA
+ *
+ * Supported Feature: 11AX
+ *
+ * Usage: External
+ *
+ * </ini>
+ */
+#define CFG_TWT_CONGESTION_TIMEOUT CFG_INI_UINT( \
+		"twt_congestion_timeout", \
+		0, \
+		10000, \
+		100, \
+		CFG_VALUE_OR_DEFAULT, \
+		"twt congestion timeout")
+/*
+ * <ini>
+ * twt_bcast_req_resp_config - To enable broadcast twt requestor and responder.
+ * @Min: 0 Disable the extended twt capability
+ * @Max: 3
+ * @Default: 1
+ *
+ * This cfg is used to configure the broadcast TWT requestor and responder.
+ * Bitmap for enabling the broadcast twt requestor and responder.
+ * BIT 0: Enable/Disable broadcast twt requestor.
+ * BIT 1: Enable/Disable broadcast twt responder.
+ * BIT 2-31: Reserved
+ *
+ * Related: CFG_ENABLE_TWT
+ * Related: CFG_TWT_RESPONDER
+ * Related: CFG_TWT_REQUESTOR
+ *
+ * Supported Feature: 11AX
+ *
+ * Usage: External
+ *
+ * </ini>
+ */
+/* defines to extract the requestor/responder capabilities from cfg */
+#define TWT_BCAST_REQ_INDEX    0
+#define TWT_BCAST_REQ_BITS     1
+#define TWT_BCAST_RES_INDEX    1
+#define TWT_BCAST_RES_BITS     1
+
+#define CFG_BCAST_TWT_REQ_RESP CFG_INI_UINT( \
+		"twt_bcast_req_resp_config", \
+		0, \
+		3, \
+		1, \
+		CFG_VALUE_OR_DEFAULT, \
+		"BROADCAST TWT CAPABILITY")
+
+#define CFG_TWT_GET_BCAST_REQ(_bcast_conf) \
+	QDF_GET_BITS(_bcast_conf, \
+		     TWT_BCAST_REQ_INDEX, \
+		     TWT_BCAST_REQ_BITS)
+
+#define CFG_TWT_GET_BCAST_RES(_bcast_conf) \
+	QDF_GET_BITS(_bcast_conf, \
+		     TWT_BCAST_RES_INDEX, \
+		     TWT_BCAST_RES_BITS)
+
+/*
+ * <ini>
+ * enable_twt_24ghz - Enable Target wake time when STA is connected on 2.4Ghz
+ * band.
+ * @Min: 0
+ * @Max: 1
+ * @Default: 1
+ *
+ * This ini is used to enable/disable the host TWT when STA is connected to AP
+ * in 2.4Ghz band.
+ *
+ * Related: NA
+ *
+ * Supported Feature: 11AX
+ *
+ * Usage: External
+ *
+ * </ini>
+ */
+#define CFG_ENABLE_TWT_24GHZ CFG_INI_BOOL( \
+		"enable_twt_24ghz", \
+		true, \
+		"enable twt in 2.4Ghz band")
+
+#define CFG_HE_FLEX_TWT_SCHED CFG_BOOL( \
+				"he_flex_twt_sched", \
+				0, \
+				"HE Flex Twt Sched")
+
+#define CFG_TWT_ALL \
+	CFG(CFG_ENABLE_TWT) \
+	CFG(CFG_TWT_REQUESTOR) \
+	CFG(CFG_TWT_RESPONDER) \
+	CFG(CFG_TWT_CONGESTION_TIMEOUT) \
+	CFG(CFG_BCAST_TWT_REQ_RESP) \
+	CFG(CFG_ENABLE_TWT_24GHZ)
+#elif !defined(WLAN_SUPPORT_TWT) && !defined(WLAN_TWT_CONV_SUPPORTED)
+#define CFG_TWT_ALL
+#endif
+#endif /* __CFG_TWT_H_ */

+ 58 - 0
components/umac/twt/dispatcher/inc/wlan_twt_cfg_ext_api.h

@@ -0,0 +1,58 @@
+/*
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for
+ * any purpose with or without fee is hereby granted, provided that the
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _WLAN_TWT_CFG_EXT_API_H
+#define _WLAN_TWT_CFG_EXT_API_H
+
+#if defined(WLAN_SUPPORT_TWT) && defined(WLAN_TWT_CONV_SUPPORTED)
+#include <wlan_objmgr_psoc_obj.h>
+#include <wlan_twt_public_structs.h>
+/**
+ * wlan_twt_cfg_get_req_flag() - Get TWT requestor flag
+ * @psoc: Pointer to global psoc object
+ * @val: pointer to output variable
+ *
+ * Return: QDF_STATUS_SUCCESS
+ */
+QDF_STATUS
+wlan_twt_cfg_get_req_flag(struct wlan_objmgr_psoc *psoc, bool *val);
+
+/**
+ * wlan_twt_cfg_get_res_flag() - Get TWT responder flag
+ * @psoc: Pointer to global psoc object
+ * @val: pointer to output variable
+ *
+ * Return: QDF_STATUS_SUCCESS
+ */
+QDF_STATUS
+wlan_twt_cfg_get_res_flag(struct wlan_objmgr_psoc *psoc, bool *val);
+#else
+static inline
+wlan_twt_cfg_get_res_flag(struct wlan_objmgr_psoc *psoc, bool *val)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+static inline
+wlan_twt_cfg_get_req_flag(struct wlan_objmgr_psoc *psoc, bool *val)
+{
+	return QDF_STATUS_SUCCESS;
+}
+#endif
+
+#endif

+ 57 - 0
components/umac/twt/dispatcher/inc/wlan_twt_ext_defs.h

@@ -0,0 +1,57 @@
+/*
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for
+ * any purpose with or without fee is hereby granted, provided that the
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/**
+ * DOC: wlan_twt_ext_defs.h
+ *
+ * This file provide definition for structure/enums/defines related to
+ * twt component
+ */
+
+#ifndef __WLAN_TWT_EXT_DEFS_H__
+#define __WLAN_TWT_EXT_DEFS_H__
+
+/*
+ * struct twt_mc_cfg_params - All twt related cfg items
+ * @enable_twt: global twt configuration
+ * @twt_responder: twt responder enable/disable
+ * @twt_requestor: twt requestor enable/disable
+ * @twt_congestion_timeout: congestion timeout value
+ * @bcast_requestor_enabled: bcast requestor enable/disable
+ * @bcast_responder_enabled: bcast responder enable/disable
+ * @enable_twt_24ghz: Enable/disable host TWT when STA is connected in
+ * 2.4Ghz
+ * @flex_twt_sched: flex twt scheduling enable/disable
+ * @req_flag: requestor flag enable/disable
+ * @res_flag: responder flag enable/disable
+ */
+struct twt_mc_cfg_params {
+	bool enable_twt;
+	bool twt_responder;
+	bool twt_requestor;
+	uint32_t twt_congestion_timeout;
+	bool bcast_requestor_enabled;
+	bool bcast_responder_enabled;
+	bool enable_twt_24ghz;
+	bool flex_twt_sched;
+	bool req_flag;
+	bool res_flag;
+};
+
+#endif /* __WLAN_TWT_EXT_DEFS_H__ */
+

+ 37 - 0
components/umac/twt/dispatcher/inc/wlan_twt_ext_type.h

@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for
+ * any purpose with or without fee is hereby granted, provided that the
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/**
+ * DOC: wlan_twt_ext_type.h
+ *
+ * This header file is included by the converged twt
+ * component to map legacy structures to the external
+ * (ext)typedefs used by the converged code.
+ */
+
+#ifndef __WLAN_TWT_EXT_TYPE_H__
+#define __WLAN_TWT_EXT_TYPE_H__
+
+/**
+ * typedef psoc_twt_ext_cfg_params_t  - Definition of psoc twt cfg params
+ * Define twt cfg params from external umac/twt component point to this type
+ */
+typedef struct twt_mc_cfg_params psoc_twt_ext_cfg_params_t;
+
+#endif /* __WLAN_TWT_EXT_TYPE_H__ */
+

+ 81 - 0
components/umac/twt/dispatcher/inc/wlan_twt_tgt_if_ext_tx_api.h

@@ -0,0 +1,81 @@
+/*
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for
+ * any purpose with or without fee is hereby granted, provided that the
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/**
+ * DOC: wlan_twt_tgt_if_ext_tx_api.h
+ *
+ * API declarations to send WMI command using Tx Ops
+ */
+#ifndef _WLAN_TWT_TGT_IF_EXT_TX_API_H_
+#define _WLAN_TWT_TGT_IF_EXT_TX_API_H_
+
+/**
+ * tgt_twt_setup_req_send() - Send twt setup request
+ * @psoc: Pointer to psoc object
+ * @req: TWT setup request
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+tgt_twt_setup_req_send(struct wlan_objmgr_psoc *psoc,
+		       struct twt_add_dialog_param *req);
+
+/**
+ * tgt_twt_teardown_req_send() - Send twt teardown request
+ * @psoc: Pointer to psoc object
+ * @req: TWT setup request
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+tgt_twt_teardown_req_send(struct wlan_objmgr_psoc *psoc,
+			  struct twt_del_dialog_param *req);
+
+/**
+ * tgt_twt_pause_req_send() - Send twt pause request
+ * @psoc: Pointer to psoc object
+ * @req: TWT pause request
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+tgt_twt_pause_req_send(struct wlan_objmgr_psoc *psoc,
+		       struct twt_pause_dialog_cmd_param *req);
+
+/**
+ * tgt_twt_resume_req_send() - Send twt resume request
+ * @psoc: Pointer to psoc object
+ * @req: TWT resume request
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+tgt_twt_resume_req_send(struct wlan_objmgr_psoc *psoc,
+			struct twt_resume_dialog_cmd_param *req);
+
+/**
+ * tgt_twt_nudge_req_send() - Send twt nudge request
+ * @psoc: Pointer to psoc object
+ * @req: TWT nudge request
+ *
+ * Return: QDF_STATUS
+ */
+QDF_STATUS
+tgt_twt_nudge_req_send(struct wlan_objmgr_psoc *psoc,
+		       struct twt_nudge_dialog_cmd_param *req);
+
+#endif

+ 187 - 0
components/umac/twt/dispatcher/inc/wlan_twt_ucfg_ext_api.h

@@ -0,0 +1,187 @@
+/*
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for
+ * any purpose with or without fee is hereby granted, provided that the
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#ifndef _WLAN_TWT_UCFG_EXT_API_H
+#define _WLAN_TWT_UCFG_EXT_API_H
+
+
+#include <wlan_objmgr_psoc_obj.h>
+#include <wlan_twt_public_structs.h>
+#include <include/wlan_mlme_cmn.h>
+
+/* dialog_id used to get all peer's twt session parameters */
+#define TWT_GET_ALL_PEER_PARAMS_DIALOG_ID (0xFF)
+
+/* Valid dialog_id 0 to (0xFF - 1) */
+#define TWT_MAX_DIALOG_ID (TWT_GET_ALL_PEER_PARAMS_DIALOG_ID - 1)
+
+#if defined(WLAN_SUPPORT_TWT) && defined(WLAN_TWT_CONV_SUPPORTED)
+/**
+ * ucfg_twt_psoc_open() - TWT psoc open
+ * @psoc: Pointer to global PSOC object
+ *
+ * Upon psoc open, this function initializes the twt config params
+ *
+ * Return: QDF_STATUS_SUCCESS
+ */
+QDF_STATUS ucfg_twt_psoc_open(struct wlan_objmgr_psoc *psoc);
+
+/**
+ * ucfg_twt_psoc_close() - TWT psoc close
+ * @psoc: Pointer to global PSOC object
+ *
+ * Return: QDF_STATUS_SUCCESS
+ */
+QDF_STATUS ucfg_twt_psoc_close(struct wlan_objmgr_psoc *psoc);
+
+/**
+ * ucfg_twt_update_psoc_config() - TWT update config
+ * @psoc: Pointer to global PSOC object
+ *
+ * Return: QDF_STATUS_SUCCESS
+ */
+QDF_STATUS ucfg_twt_update_psoc_config(struct wlan_objmgr_psoc *psoc);
+
+/**
+ * ucfg_twt_setup_req() - TWT setup
+ * @psoc: Pointer to global PSOC object
+ * @params: add dialog params
+ * @context: twt context
+ *
+ * Return: QDF_STATUS_SUCCESS
+ */
+QDF_STATUS ucfg_twt_setup_req(struct wlan_objmgr_psoc *psoc,
+			      struct twt_add_dialog_param *params,
+			      void *context);
+
+/**
+ * ucfg_twt_teardown_req() - TWT teardown
+ * @psoc: Pointer to global PSOC object
+ * @params: delete dialog params
+ * @context: twt context
+ *
+ * Return: QDF_STATUS_SUCCESS
+ */
+QDF_STATUS ucfg_twt_teardown_req(struct wlan_objmgr_psoc *psoc,
+				 struct twt_del_dialog_param *params,
+				 void *context);
+
+/**
+ * ucfg_twt_is_max_sessions_reached() - Check if the maximum number of
+ * TWT sessions reached or not excluding the given dialog_id
+ * @psoc: Pointer to global PSOC object
+ * @peer_mac: Global peer mac address
+ * @dialog_id: dialog id
+ *
+ * Check if the number of active TWT sessions is equal to the maximum number
+ * of TWT sessions supported. Only count the TWT session slot if it not
+ * TWT_ALL_SESSIONS_DIALOG_ID and dialog id is different from input dialog_id,
+ * because if same dialog_id already exists in the TWT sessions, we should
+ * return false since re-negotiation is supported on existing dialog_id.
+ *
+ * Return: True if slot is available for dialog_id, false otherwise
+ */
+bool ucfg_twt_is_max_sessions_reached(struct wlan_objmgr_psoc *psoc,
+				      struct qdf_mac_addr *peer_mac,
+				      uint8_t dialog_id);
+
+/**
+ * ucfg_twt_is_setup_in_progress() - Get if TWT setup command is in progress
+ * for given dialog id
+ * @psoc: Pointer to global psoc object
+ * @peer_mac: Global peer mac address
+ * @dialog_id: Dialog ID
+ *
+ * Return: True if Setup is in progress
+ */
+bool ucfg_twt_is_setup_in_progress(struct wlan_objmgr_psoc *psoc,
+				   struct qdf_mac_addr *peer_mac,
+				   uint8_t dialog_id);
+
+/**
+ * ucfg_twt_init_context() - Initialize TWT context
+ * @psoc: Pointer to global psoc object
+ * @peer_mac: Global peer mac address
+ * @dialog_id: Dialog ID
+ *
+ * Return: QDF_STATUS_SUCCESS
+ */
+QDF_STATUS
+ucfg_twt_init_context(struct wlan_objmgr_psoc *psoc,
+		      struct qdf_mac_addr *peer_mac,
+		      uint8_t dialog_id);
+
+/**
+ * ucfg_twt_set_osif_cb() - Set TWT osif callbacks
+ * @osif_twt_ops: pointer to global osif ops
+ *
+ * Return: QDF_STATUS_SUCCESS
+ */
+QDF_STATUS
+ucfg_twt_set_osif_cb(osif_twt_get_global_ops_cb osif_twt_ops);
+#else
+static inline
+QDF_STATUS ucfg_twt_psoc_open(struct wlan_objmgr_psoc *psoc)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+static inline
+QDF_STATUS ucfg_twt_psoc_close(struct wlan_objmgr_psoc *psoc)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+static inline
+QDF_STATUS ucfg_twt_update_psoc_config(struct wlan_objmgr_psoc *psoc)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+static inline
+QDF_STATUS ucfg_twt_setup_req(struct wlan_objmgr_psoc *psoc,
+			      struct twt_add_dialog_param *params,
+			      void *context)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+static inline
+QDF_STATUS ucfg_twt_teardown_req(struct wlan_objmgr_psoc *psoc,
+				     struct twt_del_dialog_param *params,
+				     void *context)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+static inline QDF_STATUS
+ucfg_twt_init_context(struct wlan_objmgr_psoc *psoc,
+		      struct qdf_mac_addr *peer_mac,
+		      uint8_t dialog_id)
+{
+	return QDF_STATUS_E_NOSUPPORT;
+}
+
+static inline QDF_STATUS
+ucfg_twt_set_osif_cb(osif_twt_get_global_ops_cb osif_twt_ops)
+{
+	return QDF_STATUS_E_NOSUPPORT;
+}
+#endif
+
+#endif

+ 31 - 0
components/umac/twt/dispatcher/src/wlan_twt_cfg_ext_api.c

@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for
+ * any purpose with or without fee is hereby granted, provided that the
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+#include <wlan_twt_cfg_ext_api.h>
+#include "twt/core/src/wlan_twt_cfg.h"
+
+QDF_STATUS
+wlan_twt_cfg_get_req_flag(struct wlan_objmgr_psoc *psoc, bool *val)
+{
+	return wlan_twt_cfg_get_requestor_flag(psoc, val);
+}
+
+QDF_STATUS
+wlan_twt_cfg_get_res_flag(struct wlan_objmgr_psoc *psoc, bool *val)
+{
+	return wlan_twt_cfg_get_responder_flag(psoc, val);
+}

+ 90 - 0
components/umac/twt/dispatcher/src/wlan_twt_tgt_if_ext_rx_api.c

@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for
+ * any purpose with or without fee is hereby granted, provided that the
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/**
+ * DOC: wlan_twt_tgt_if_ext_rx_api.c
+ *
+ * This file provide definition for APIs registered for LMAC TWT Rx Ops
+ */
+#include <qdf_types.h>
+#include <wlan_objmgr_psoc_obj.h>
+#include <wlan_twt_public_structs.h>
+#include <wlan_twt_tgt_if_ext_rx_ops.h>
+
+static QDF_STATUS
+tgt_twt_setup_complete_resp_handler(struct wlan_objmgr_psoc *psoc,
+			     struct twt_add_dialog_complete_event *event)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+static QDF_STATUS
+tgt_twt_teardown_complete_resp_handler(struct wlan_objmgr_psoc *psoc,
+			     struct twt_del_dialog_complete_event_param *event)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+static QDF_STATUS
+tgt_twt_pause_complete_resp_handler(struct wlan_objmgr_psoc *psoc,
+			    struct twt_pause_dialog_complete_event_param *event)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+static QDF_STATUS
+tgt_twt_resume_complete_resp_handler(struct wlan_objmgr_psoc *psoc,
+			   struct twt_resume_dialog_complete_event_param *event)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+static QDF_STATUS
+tgt_twt_nudge_complete_resp_handler(struct wlan_objmgr_psoc *psoc,
+			    struct twt_nudge_dialog_complete_event_param *event)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+static QDF_STATUS
+tgt_twt_notify_complete_resp_handler(struct wlan_objmgr_psoc *psoc,
+			    struct twt_notify_event_param *event)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+static QDF_STATUS
+tgt_twt_ack_complete_resp_handler(struct wlan_objmgr_psoc *psoc,
+			    struct twt_ack_complete_event_param *event)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+void tgt_twt_register_ext_rx_ops(struct wlan_lmac_if_rx_ops *rx_ops)
+{
+	struct wlan_lmac_if_twt_rx_ops *twt_rx_ops = &rx_ops->twt_rx_ops;
+
+	twt_rx_ops->twt_setup_comp_cb = tgt_twt_setup_complete_resp_handler;
+	twt_rx_ops->twt_teardown_comp_cb =
+					tgt_twt_teardown_complete_resp_handler;
+	twt_rx_ops->twt_pause_comp_cb = tgt_twt_pause_complete_resp_handler;
+	twt_rx_ops->twt_resume_comp_cb = tgt_twt_resume_complete_resp_handler;
+	twt_rx_ops->twt_nudge_comp_cb = tgt_twt_nudge_complete_resp_handler;
+	twt_rx_ops->twt_notify_comp_cb = tgt_twt_notify_complete_resp_handler;
+	twt_rx_ops->twt_ack_comp_cb = tgt_twt_ack_complete_resp_handler;
+}
+

+ 65 - 0
components/umac/twt/dispatcher/src/wlan_twt_tgt_if_ext_tx_api.c

@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for
+ * any purpose with or without fee is hereby granted, provided that the
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+/**
+ * DOC: wlan_twt_tgt_if_ext_tx_api.c
+ *
+ * This file provides definitions for twt tgt_if APIs, which will
+ * further call target_if component using LMAC TWT txops
+ */
+#include <qdf_types.h>
+#include <wlan_objmgr_psoc_obj.h>
+#include <wlan_twt_public_structs.h>
+#include <wlan_twt_api.h>
+#include <wlan_twt_tgt_if_ext_tx_api.h>
+#include <wlan_lmac_if_def.h>
+
+QDF_STATUS
+tgt_twt_setup_req_send(struct wlan_objmgr_psoc *psoc,
+		       struct twt_add_dialog_param *req)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS
+tgt_twt_teardown_req_send(struct wlan_objmgr_psoc *psoc,
+			  struct twt_del_dialog_param *req)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS
+tgt_twt_pause_req_send(struct wlan_objmgr_psoc *psoc,
+		       struct twt_pause_dialog_cmd_param *req)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS
+tgt_twt_resume_req_send(struct wlan_objmgr_psoc *psoc,
+			struct twt_resume_dialog_cmd_param *req)
+{
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS
+tgt_twt_nudge_req_send(struct wlan_objmgr_psoc *psoc,
+		       struct twt_nudge_dialog_cmd_param *req)
+{
+	return QDF_STATUS_SUCCESS;
+}
+

+ 118 - 0
components/umac/twt/dispatcher/src/wlan_twt_ucfg_ext_api.c

@@ -0,0 +1,118 @@
+/*
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for
+ * any purpose with or without fee is hereby granted, provided that the
+ * above copyright notice and this permission notice appear in all
+ * copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
+ * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
+ * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
+ * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
+ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+#include <wlan_twt_ucfg_ext_api.h>
+#include <wlan_twt_ucfg_ext_cfg.h>
+#include "twt/core/src/wlan_twt_cfg.h"
+#include "twt/core/src/wlan_twt_main.h"
+
+QDF_STATUS ucfg_twt_psoc_open(struct wlan_objmgr_psoc *psoc)
+{
+	return wlan_twt_cfg_init(psoc);
+}
+
+QDF_STATUS ucfg_twt_update_psoc_config(struct wlan_objmgr_psoc *psoc)
+{
+	return wlan_twt_cfg_update(psoc);
+}
+
+QDF_STATUS
+ucfg_twt_cfg_get_requestor(struct wlan_objmgr_psoc *psoc, bool *val)
+{
+	return wlan_twt_cfg_get_requestor(psoc, val);
+}
+
+QDF_STATUS
+ucfg_twt_cfg_get_responder(struct wlan_objmgr_psoc *psoc, bool *val)
+{
+	return wlan_twt_cfg_get_responder(psoc, val);
+}
+
+QDF_STATUS
+ucfg_twt_setup_req(struct wlan_objmgr_psoc *psoc,
+		   struct twt_add_dialog_param *params,
+		   void *context)
+{
+	return wlan_twt_setup_req(psoc, params, context);
+}
+
+QDF_STATUS ucfg_twt_teardown_req(struct wlan_objmgr_psoc *psoc,
+				 struct twt_del_dialog_param *params,
+				 void *context)
+{
+	return wlan_twt_teardown_req(psoc, params, context);
+}
+
+bool ucfg_twt_is_max_sessions_reached(struct wlan_objmgr_psoc *psoc,
+				      struct qdf_mac_addr *peer_mac,
+				      uint8_t dialog_id)
+{
+	return wlan_twt_is_max_sessions_reached(psoc, peer_mac, dialog_id);
+}
+
+bool ucfg_twt_is_setup_in_progress(struct wlan_objmgr_psoc *psoc,
+				   struct qdf_mac_addr *peer_mac,
+				   uint8_t dialog_id)
+{
+	return wlan_twt_is_setup_in_progress(psoc, peer_mac, dialog_id);
+}
+
+QDF_STATUS
+ucfg_twt_cfg_get_congestion_timeout(struct wlan_objmgr_psoc *psoc,
+				    uint32_t *val)
+{
+	return wlan_twt_cfg_get_congestion_timeout(psoc, val);
+}
+
+QDF_STATUS
+ucfg_twt_cfg_set_congestion_timeout(struct wlan_objmgr_psoc *psoc, uint32_t val)
+{
+	return wlan_twt_cfg_set_congestion_timeout(psoc, val);
+}
+
+QDF_STATUS
+ucfg_twt_cfg_get_24ghz_enabled(struct wlan_objmgr_psoc *psoc, bool *val)
+{
+	return wlan_twt_cfg_get_24ghz_enabled(psoc, val);
+}
+
+QDF_STATUS
+ucfg_twt_cfg_get_bcast_requestor(struct wlan_objmgr_psoc *psoc, bool *val)
+{
+	return wlan_twt_cfg_get_bcast_requestor(psoc, val);
+}
+
+QDF_STATUS
+ucfg_twt_cfg_get_flex_sched(struct wlan_objmgr_psoc *psoc, bool *val)
+{
+	return wlan_twt_cfg_get_flex_sched(psoc, val);
+}
+
+QDF_STATUS
+ucfg_twt_init_context(struct wlan_objmgr_psoc *psoc,
+		      struct qdf_mac_addr *peer_mac,
+		      uint8_t dialog_id)
+{
+	return wlan_twt_init_context(psoc, peer_mac, dialog_id);
+}
+
+QDF_STATUS
+ucfg_twt_set_osif_cb(osif_twt_get_global_ops_cb osif_twt_ops)
+{
+	mlme_set_osif_twt_cb(osif_twt_ops);
+	return QDF_STATUS_SUCCESS;
+}