瀏覽代碼

qcacmn: Add Support for request control path stats

Add support in cp stats component for the control path
stats infrastructure provided by firmware via
WMI_REQUEST_CTRL_PATH_STATS_CMDID and
WMI_CTRL_PATH_STATS_EVENTID. Also add support for TWT
type operations over this infrastructure.

Change-Id: I154babff396ac39c11c7548ad91cc4dc0d0c52af
CRs-Fixed: 2847603
Rajasekaran Kalidoss 4 年之前
父節點
當前提交
b60109631e

+ 12 - 1
umac/cp_stats/core/src/wlan_cp_stats_defs.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018-2019 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2018-2019, 2021 The Linux Foundation. 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
@@ -36,10 +36,16 @@
 #include "wlan_cp_stats_cmn_defs.h"
 #include <wlan_cp_stats_utils_api.h>
 #include <wlan_cp_stats_ext_type.h>
+#include <wlan_cp_stats_public_structs.h>
 
 /* noise floor */
 #define CP_STATS_TGT_NOISE_FLOOR_DBM (-96)
 
+#ifdef WLAN_SUPPORT_INFRA_CTRL_PATH_STATS
+typedef void (*get_infra_cp_stats_cb)(struct infra_cp_stats_event *ev,
+				      void *cookie);
+#endif
+
 /**
  * struct psoc_cp_stats - defines cp stats at psoc object
  * @psoc_obj: pointer to psoc
@@ -57,6 +63,11 @@ struct psoc_cp_stats {
 	struct psoc_cmn_cp_stats *cmn_stats;
 	psoc_ext_cp_stats_t *obj_stats;
 	void (*legacy_stats_cb)(void *stats);
+#ifdef WLAN_SUPPORT_INFRA_CTRL_PATH_STATS
+	void (*get_infra_cp_stats)(struct infra_cp_stats_event *ev,
+				   void *cookie);
+	void *infra_cp_stats_req_context;
+#endif
 };
 
 /**

+ 65 - 1
umac/cp_stats/core/src/wlan_cp_stats_obj_mgr_handler.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018-2020 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2018-2021 The Linux Foundation. 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
@@ -29,6 +29,7 @@
 #include "wlan_cp_stats_ol_api.h"
 #include <wlan_cp_stats_ucfg_api.h>
 #include "wlan_cp_stats_utils_api.h"
+#include <target_if_cp_stats.h>
 
 QDF_STATUS
 wlan_cp_stats_psoc_obj_create_handler(struct wlan_objmgr_psoc *psoc, void *arg)
@@ -400,3 +401,66 @@ wlan_cp_stats_peer_obj_destroy_handler(struct wlan_objmgr_peer *peer, void *arg)
 	cp_stats_debug("peer cp stats object dettached");
 	return QDF_STATUS_SUCCESS;
 }
+
+#ifdef WLAN_SUPPORT_INFRA_CTRL_PATH_STATS
+QDF_STATUS
+wlan_cp_stats_infra_cp_register_resp_cb(struct wlan_objmgr_psoc *psoc,
+					struct infra_cp_stats_cmd_info *req)
+{
+	struct psoc_cp_stats *psoc_cp_stats_priv;
+
+	psoc_cp_stats_priv = wlan_cp_stats_get_psoc_stats_obj(psoc);
+	if (!psoc_cp_stats_priv) {
+		cp_stats_err("psoc cp stats object is null");
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+
+	wlan_cp_stats_psoc_obj_lock(psoc_cp_stats_priv);
+	psoc_cp_stats_priv->get_infra_cp_stats = req->infra_cp_stats_resp_cb;
+	psoc_cp_stats_priv->infra_cp_stats_req_context = req->request_cookie;
+	wlan_cp_stats_psoc_obj_unlock(psoc_cp_stats_priv);
+
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS
+wlan_cp_stats_infra_cp_get_context(struct wlan_objmgr_psoc *psoc,
+				   get_infra_cp_stats_cb *resp_cb,
+				   void **context)
+{
+	struct psoc_cp_stats *psoc_cp_stats_priv;
+
+	psoc_cp_stats_priv = wlan_cp_stats_get_psoc_stats_obj(psoc);
+	if (!psoc_cp_stats_priv) {
+		cp_stats_err("psoc cp stats object is null");
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+
+	wlan_cp_stats_psoc_obj_lock(psoc_cp_stats_priv);
+	*resp_cb = psoc_cp_stats_priv->get_infra_cp_stats;
+	*context = psoc_cp_stats_priv->infra_cp_stats_req_context;
+	wlan_cp_stats_psoc_obj_unlock(psoc_cp_stats_priv);
+
+	return QDF_STATUS_SUCCESS;
+}
+
+QDF_STATUS
+wlan_cp_stats_send_infra_cp_req(struct wlan_objmgr_psoc *psoc,
+				struct infra_cp_stats_cmd_info *req)
+{
+	struct wlan_lmac_if_cp_stats_tx_ops *tx_ops;
+
+	tx_ops = target_if_cp_stats_get_tx_ops(psoc);
+	if (!tx_ops) {
+		cp_stats_err("could not get tx_ops");
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+
+	if (!tx_ops->send_req_infra_cp_stats) {
+		cp_stats_err("could not get send_req_infra_twt_stats");
+		return QDF_STATUS_E_NULL_VALUE;
+	}
+	return tx_ops->send_req_infra_cp_stats(psoc, req);
+}
+#endif /* WLAN_SUPPORT_INFRA_CTRL_PATH_STATS */
+

+ 42 - 1
umac/cp_stats/core/src/wlan_cp_stats_obj_mgr_handler.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018, 2020 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2018, 2021 The Linux Foundation. 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
@@ -124,6 +124,47 @@ QDF_STATUS wlan_cp_stats_peer_obj_create_handler(
 QDF_STATUS wlan_cp_stats_peer_obj_destroy_handler(
 		struct wlan_objmgr_peer *peer, void *data);
 
+#ifdef WLAN_SUPPORT_INFRA_CTRL_PATH_STATS
+/**
+ * wlan_cp_stats_infra_cp_register_resp_cb() - Register the response callback
+ * and cookie in the psoc mc_stats object
+ * @psoc: pointer to psoc object
+ * @req: pointer to request parameter structure
+ *
+ * Return: QDF_STATUS_SUCCESS on Success, other QDF_STATUS error codes on
+ * failure
+ */
+QDF_STATUS
+wlan_cp_stats_infra_cp_register_resp_cb(struct wlan_objmgr_psoc *psoc,
+					struct infra_cp_stats_cmd_info *req);
+
+/**
+ * wlan_cp_stats_infra_cp_get_context() - get the context and callback
+ * for sending response
+ * @psoc: pointer to psoc object
+ * @resp_cb: pointer to store the response callback
+ * @context: pointer to store context
+ *
+ * Return: QDF_STATUS_SUCCESS on Success, other QDF_STATUS error codes on
+ * failure
+ */
+QDF_STATUS
+wlan_cp_stats_infra_cp_get_context(struct wlan_objmgr_psoc *psoc,
+				   get_infra_cp_stats_cb *resp_cb,
+				   void **context);
+/**
+ * wlan_cp_stats_send_infra_cp_req() - API to send infra cp stats request to
+ * lmac
+ * @psoc: pointer to psoc object
+ * @req: pointer to infra cp stats request
+ *
+ * Return: QDF_STATUS_SUCCESS on Success, other QDF_STATUS error codes on
+ * failure
+ */
+QDF_STATUS
+wlan_cp_stats_send_infra_cp_req(struct wlan_objmgr_psoc *psoc,
+				struct infra_cp_stats_cmd_info *req);
 
+#endif /* WLAN_SUPPORT_INFRA_CTRL_PATH_STATS */
 #endif /* QCA_SUPPORT_CP_STATS */
 #endif /* __WLAN_CP_STATS_OBJ_MGR_HANDLER_H__ */

+ 144 - 0
umac/cp_stats/dispatcher/inc/wlan_cp_stats_public_structs.h

@@ -0,0 +1,144 @@
+/*
+ * Copyright (c) 2021 The Linux Foundation. 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: contains cp_stats structure definitions
+ */
+
+#ifndef _WLAN_CP_STATS_PUBLIC_STRUCTS_H_
+#define _WLAN_CP_STATS_PUBLIC_STRUCTS_H_
+
+#define CTRL_PATH_STATS_MAX_MAC_ADDR 1
+#define CTRL_PATH_STATS_MAX_PDEV_ID 1
+#define CTRL_PATH_STATS_MAX_VDEV_ID 1
+
+
+#define INFRA_CP_STATS_MAX_REQ_TWT_DIALOG_ID 1
+
+/*
+ * Maximum of 1 TWT session can be supported per vdev.
+ * This can be extended later to support more sessions.
+ * if there is a request to retrieve stats for all existing
+ * TWT sessions then response path can have multiple session
+ * stats.
+ */
+#define INFRA_CP_STATS_MAX_RESP_TWT_DIALOG_ID 1
+
+#ifdef WLAN_SUPPORT_TWT
+/**
+ * struct twt_infra_cp_stats_event - TWT statistics event structure
+ * @vdev_id: virtual interface id
+ * @peer_mac_addr: peer mac address corresponding to a TWT session
+ * @dialog_id: Represents dialog_id of the TWT session
+ * @num_sp_cycles: Number of TWT service period elapsed so far
+ * @avg_sp_dur_us: Average of actual wake duration observed so far
+ * @min_sp_dur_us: Minimum value of wake duration observed across
+ * @max_sp_dur_us: Maximum value of wake duration observed
+ * @tx_mpdu_per_sp: Average number of MPDU's transmitted successfully
+ * @rx_mpdu_per_sp: Average number of MPDU's received successfully
+ * @tx_bytes_per_sp: Average number of bytes transmitted successfully
+ * @rx_bytes_per_sp: Average number of bytes received successfully
+ */
+struct twt_infra_cp_stats_event {
+	uint8_t vdev_id;
+	struct qdf_mac_addr peer_macaddr;
+	uint32_t dialog_id;
+	uint32_t status;
+	uint32_t num_sp_cycles;
+	uint32_t avg_sp_dur_us;
+	uint32_t min_sp_dur_us;
+	uint32_t max_sp_dur_us;
+	uint32_t tx_mpdu_per_sp;
+	uint32_t rx_mpdu_per_sp;
+	uint32_t tx_bytes_per_sp;
+	uint32_t rx_bytes_per_sp;
+};
+#endif /* WLAN_SUPPORT_TWT */
+
+/**
+ * struct infra_cp_stats_event - Event structure to store stats
+ * @action: action for which this response was recevied
+ *          (get/reset/start/stop)
+ * @request_id: request cookie sent to Firmware in the command
+ * @status: status of the infra_cp_stats command processing
+ * @num_twt_infra_cp_stats: number of twt_infra_cp_stats buffers
+ *                          available
+ * @twt_infra_cp_stats: pointer to TWT session statistics structures
+ *
+ * This structure is used to store the statistics information
+ * extracted from firmware event(wmi_pdev_cp_fwstats_eventid)
+ */
+struct infra_cp_stats_event {
+	uint32_t action;
+	uint32_t request_id;
+	uint32_t status;
+#ifdef WLAN_SUPPORT_TWT
+	uint32_t num_twt_infra_cp_stats;
+	struct twt_infra_cp_stats_event *twt_infra_cp_stats;
+#endif
+	/* Extend with other required infra_cp_stats structs */
+};
+
+enum infra_cp_stats_action {
+	ACTION_REQ_CTRL_PATH_STAT_GET = 0,
+	ACTION_REQ_CTRL_PATH_STAT_RESET,
+	ACTION_REQ_CTRL_PATH_STAT_START,
+	ACTION_REQ_CTRL_PATH_STAT_STOP,
+};
+
+enum infra_cp_stats_id {
+	TYPE_REQ_CTRL_PATH_PDEV_TX_STAT = 0,
+	TYPE_REQ_CTRL_PATH_VDEV_EXTD_STAT,
+	TYPE_REQ_CTRL_PATH_MEM_STAT,
+	TYPE_REQ_CTRL_PATH_TWT_STAT,
+};
+
+/**
+ * struct infra_cp_stats_cmd_info - details of infra cp stats request
+ * @stats_id: ID of the statistics type requested
+ * @action: action to be performed (get/reset/start/stop)
+ * @request_cookie: osif request cookie
+ * @request_id: request id cookie to FW
+ * @num_pdev_ids: number of pdev ids in the request
+ * @pdev_id: array of pdev_ids
+ * @num_vdev_ids: number of vdev ids in the request
+ * @vdev_id: array of vdev_ids
+ * @num_mac_addr_list: number of mac addresses in the request
+ * @peer_mac_addr: array of mac addresses
+ * @dialog_id: This is a TWT specific field. only one dialog_id
+ *             can be specified for TWT stats. 0 to 254 are
+ *             valid dialog_id's representing a single TWT session.
+ *             255 represents all twt sessions
+ * @infra_cp_stats_resp_cb: callback function to handle the response
+ */
+struct infra_cp_stats_cmd_info {
+	enum infra_cp_stats_id stats_id;
+	enum infra_cp_stats_action action;
+	void *request_cookie;
+	uint32_t request_id;
+	uint32_t num_pdev_ids;
+	uint32_t pdev_id[CTRL_PATH_STATS_MAX_PDEV_ID];
+	uint32_t num_vdev_ids;
+	uint32_t vdev_id[CTRL_PATH_STATS_MAX_VDEV_ID];
+	uint32_t num_mac_addr_list;
+	uint8_t peer_mac_addr[CTRL_PATH_STATS_MAX_MAC_ADDR][QDF_MAC_ADDR_SIZE];
+#ifdef WLAN_SUPPORT_TWT
+	uint32_t dialog_id;
+#endif
+	void (*infra_cp_stats_resp_cb)(struct infra_cp_stats_event *ev,
+				       void *cookie);
+};
+#endif

+ 25 - 1
umac/cp_stats/dispatcher/inc/wlan_cp_stats_ucfg_api.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2018, 2021 The Linux Foundation. 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
@@ -30,5 +30,29 @@
 #include "../../core/src/wlan_cp_stats_defs.h"
 #include "../../core/src/wlan_cp_stats_cmn_api_i.h"
 
+/**
+ * @ucfg_infra_cp_stats_register_resp_cb() - Register the response callback
+ * and cookie in the psoc mc_stats object
+ * @psoc: pointer to psoc object
+ * @req: pointer to request parameter structure
+ *
+ * Return: QDF_STATUS_SUCCESS on Success, other QDF_STATUS error codes on
+ * failure
+ */
+QDF_STATUS
+ucfg_infra_cp_stats_register_resp_cb(struct wlan_objmgr_psoc *psoc,
+				     struct infra_cp_stats_cmd_info *req);
+
+/**
+ * @ucfg_send_infra_cp_stats_request() - send a infra cp stats command
+ * @vdev: pointer to vdev object
+ * @req: pointer to request parameter structure
+ *
+ * Return: QDF_STATUS_SUCCESS on Success, other QDF_STATUS error codes
+ * on failure
+ */
+QDF_STATUS
+ucfg_send_infra_cp_stats_request(struct wlan_objmgr_vdev *vdev,
+				 struct infra_cp_stats_cmd_info *req);
 #endif /* QCA_SUPPORT_CP_STATS */
 #endif /* __WLAN_CP_STATS_UCFG_API_H__ */

+ 20 - 5
umac/cp_stats/dispatcher/src/wlan_cp_stats_ucfg_api.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2018 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2018, 2021 The Linux Foundation. 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
@@ -17,12 +17,27 @@
  */
 
 /**
- * DOC: wlan_cp_stats_ucfg_api.h
+ * DOC: wlan_cp_stats_ucfg_api.c
  *
  * This file provide API definitions required for northbound interaction
  */
 
-#ifndef __WLAN_CP_STATS_UCFG_API_H__
-#define __WLAN_CP_STATS_UCFG_API_H__
+#include <wlan_cp_stats_utils_api.h>
+#include <wlan_cp_stats_ucfg_api.h>
+#include "../../core/src/wlan_cp_stats_obj_mgr_handler.h"
 
-#endif /* __WLAN_CP_STATS_UCFG_API_H__ */
+#ifdef WLAN_SUPPORT_INFRA_CTRL_PATH_STATS
+QDF_STATUS
+ucfg_infra_cp_stats_register_resp_cb(struct wlan_objmgr_psoc *psoc,
+				     struct infra_cp_stats_cmd_info *req)
+{
+	return wlan_cp_stats_infra_cp_register_resp_cb(psoc, req);
+}
+
+QDF_STATUS
+ucfg_send_infra_cp_stats_request(struct wlan_objmgr_vdev *vdev,
+				 struct infra_cp_stats_cmd_info *req)
+{
+	return wlan_cp_stats_send_infra_cp_req(wlan_vdev_get_psoc(vdev), req);
+}
+#endif /* WLAN_SUPPORT_INFRA_CTRL_PATH_STATS */

+ 15 - 1
umac/global_umac_dispatcher/lmac_if/inc/wlan_lmac_if_def.h

@@ -87,6 +87,7 @@ struct dbr_module_config;
 #endif
 
 #ifdef QCA_SUPPORT_CP_STATS
+#include <wlan_cp_stats_public_structs.h>
 
 /**
  * typedef cp_stats_event - Definition of cp stats event
@@ -124,6 +125,8 @@ typedef struct wake_lock_stats stats_wake_lock;
  *                       to FW
  * @set_pdev_stats_update_period: function pointer to set pdev stats update
  *                                period to FW
+ * @send_req_infra_cp_stats: function pointer to send infra cp stats request
+ *                           command to FW
  */
 struct wlan_lmac_if_cp_stats_tx_ops {
 	QDF_STATUS (*cp_stats_attach)(struct wlan_objmgr_psoc *psoc);
@@ -141,17 +144,28 @@ struct wlan_lmac_if_cp_stats_tx_ops {
 	QDF_STATUS (*set_pdev_stats_update_period)(
 					struct wlan_objmgr_psoc *psoc,
 					uint8_t pdev_id, uint32_t val);
+#ifdef WLAN_SUPPORT_INFRA_CTRL_PATH_STATS
+	QDF_STATUS (*send_req_infra_cp_stats)(
+					struct wlan_objmgr_psoc *psoc,
+					struct infra_cp_stats_cmd_info *req);
+#endif
 };
 
 /**
  * struct wlan_lmac_if_cp_stats_rx_ops - defines southbound rx callbacks for
  * control plane statistics component
  * @cp_stats_rx_event_handler:	function pointer to rx FW events
+ * @process_stats_event: function pointer to process stats event
  */
 struct wlan_lmac_if_cp_stats_rx_ops {
 	QDF_STATUS (*cp_stats_rx_event_handler)(struct wlan_objmgr_vdev *vdev);
 	QDF_STATUS (*process_stats_event)(struct wlan_objmgr_psoc *psoc,
-					  cp_stats_event *ev);
+					  struct stats_event *ev);
+#ifdef WLAN_SUPPORT_INFRA_CTRL_PATH_STATS
+	QDF_STATUS
+	(*process_infra_stats_event)(struct wlan_objmgr_psoc *psoc,
+				     struct infra_cp_stats_event *infra_event);
+#endif /* WLAN_SUPPORT_INFRA_CTRL_PATH_STATS */
 };
 #endif