Browse Source

qcacmn: Add implementation of pdev cp stats

Add change to define pdev cp stats structure
and provide APIs to set cp stats fields
into cp stats component

Change-Id: I6559a19e11771d16e9207fb0a2fee96f620273b0
CRs-Fixed: 2236328
Naga 7 years ago
parent
commit
5ce6fc8d9a

+ 145 - 4
umac/cp_stats/dispatcher/inc/wlan_cp_stats_ic_defs.h

@@ -27,6 +27,32 @@
 
 #ifdef QCA_SUPPORT_CP_STATS
 
+/**
+ * struct pdev_rx_rssi - rx rssi information
+ *
+ * @rx_rssi_pri20: primary 20 rssi
+ * @rx_rssi_sec20: secondary 20 rssi
+ * @rx_rssi_sec40: secondary 40 rssi
+ * @rx_rssi_sec80: secondary 80 rssi
+ */
+struct pdev_rx_rssi {
+	uint8_t     rx_rssi_pri20;
+	uint8_t     rx_rssi_sec20;
+	uint8_t     rx_rssi_sec40;
+	uint8_t     rx_rssi_sec80;
+};
+
+/**
+ * struct pdev_hw_stats - pdev hw stats
+ *
+ * @tx_hw_retries: tx hw retries
+ * @rx_hw_retries: rx hw retries
+ */
+struct pdev_hw_stats {
+	uint64_t tx_hw_retries;
+	uint64_t tx_hw_failures;
+};
+
 /**
  * struct pdev_80211_stats - control plane stats at pdev
  *
@@ -35,12 +61,127 @@
  * used as interface structure with user space application
  * make sure to align this structure with ieee80211_mac_stats
  *
- * @cs_tx_hw_retries:
- * @cs_tx_hw_failures:
+ * @cs_tx_beacon: tx beacon
+ * @cs_be_nobuf: no skbuff available for beacon
+ * @cs_tx_buf_count: tx buf count
+ * @cs_tx_packets: tx packets
+ * @cs_rx_packets: rx packets
+ * @cs_tx_mgmt: tx mgmt
+ * @cs_tx_num_data: tx data
+ * @cs_rx_num_data: rx data
+ * @cs_rx_mgmt: rx mgmt
+ * @cs_rx_num_mgmt: rx num mgmt
+ * @cs_rx_num_ctl: rx num ctrl
+ * @cs_rx_ctrl: rx ctrl
+ * @cs_tx_ctrl: tx ctrl
+ * @cs_tx_rssi: tx rssi
+ * @cs_tx_mcs[]: tx mcs
+ * @cs_rx_mcs[]: rx mcs
+ * @cs_rx_rssi_comb: rx rssi comb
+ * @cs_rx_bytes: rx bytes
+ * @cs_tx_bytes: tx bytes
+ * @cs_tx_compaggr: tx comp aggr
+ * @cs_rx_aggr: rx aggr
+ * @cs_tx_bawadv: tx bad adv frames
+ * @cs_tx_compunaggr: tx comp unaggr frames
+ * @cs_rx_overrun: rx over run frames
+ * @cs_rx_crypt_err: rx crypt error count
+ * @cs_rx_mic_err: rx mic error count
+ * @cs_rx_crc_err: rx crc error count
+ * @cs_rx_phy_err: rx phy error count
+ * @cs_rx_ack_err: rx ack error count
+ * @cs_rx_rts_err: rx rts error count
+ * @cs_rx_rts_success: rx rts success count
+ * @cs_rx_fcs_err: rx fcs error count
+ * @cs_no_beacons: rx beacon
+ * @cs_mib_int_count: mib int count
+ * @cs_rx_looplimit_start: rx loop limit start
+ * @cs_rx_looplimit_end: rx loop limit end
+ * @cs_ap_stats_tx_cal_enable: ap stats tx cal enable status
+ * @cs_tgt_asserts: tgt assert count
+ * @cs_chan_nf: channel noise floor
+ * @cs_rx_last_msdu_unset_cnt: rx last msdu unset count
+ * @cs_chan_nf_sec80: channel noise floor secondary 80
+ * @cs_wmi_tx_mgmt: wmi tx mgmt
+ * @cs_wmi_tx_mgmt_completions: wmi tx mgmt complete
+ * @cs_wmi_tx_mgmt_completion_err: wmi tx mgmt error
+ * @cs_peer_delete_req: peer del request
+ * @cs_peer_delete_resp: peer del response
+ * @cs_rx_mgmt_rssi_drop: rx mgmt rssi drop
+ * @cs_tx_retries: tx retries
+ * @cs_rx_data_bytes: rx data bytes
+ * @cs_tx_frame_count: tx frame count
+ * @cs_rx_frame_count: rx frame count
+ * @cs_rx_clear_count: rx clear count
+ * @cs_cycle_count: cycle count
+ * @cs_phy_err_count: phy error count
+ * @cs_chan_tx_pwr: channel tx power
  */
 struct pdev_80211_stats {
-	uint64_t cs_tx_hw_retries;
-	uint64_t cs_tx_hw_failures;
+	uint64_t cs_tx_beacon;
+	uint32_t cs_be_nobuf;
+	uint32_t cs_tx_buf_count;
+	uint32_t cs_tx_packets;
+	uint32_t cs_rx_packets;
+	uint32_t cs_tx_mgmt;
+	uint32_t cs_tx_num_data;
+	uint32_t cs_rx_num_data;
+	uint32_t cs_rx_mgmt;
+	uint32_t cs_rx_num_mgmt;
+	uint32_t cs_rx_num_ctl;
+	uint64_t cs_rx_ctrl;
+	uint64_t cs_tx_ctrl;
+	uint32_t cs_tx_rssi;
+	uint32_t cs_tx_mcs[10];
+	uint32_t cs_rx_mcs[10];
+	uint32_t cs_rx_rssi_comb;
+	struct pdev_rx_rssi cs_rx_rssi_chain0;
+	struct pdev_rx_rssi cs_rx_rssi_chain1;
+	struct pdev_rx_rssi cs_rx_rssi_chain2;
+	struct pdev_rx_rssi cs_rx_rssi_chain3;
+	uint64_t cs_rx_bytes;
+	uint64_t cs_tx_bytes;
+	uint32_t cs_tx_compaggr;
+	uint32_t cs_rx_aggr;
+	uint32_t cs_tx_bawadv;
+	uint32_t cs_tx_compunaggr;
+	uint32_t cs_rx_overrun;
+	uint32_t cs_rx_crypt_err;
+	uint32_t cs_rx_mic_err;
+	uint32_t cs_rx_crc_err;
+	uint32_t cs_rx_phy_err;
+	uint32_t cs_rx_ack_err;
+	uint32_t cs_rx_rts_err;
+	uint32_t cs_rx_rts_success;
+	uint32_t cs_rx_fcs_err;
+	uint32_t cs_no_beacons;
+	uint32_t cs_mib_int_count;
+	uint32_t cs_rx_looplimit_start;
+	uint32_t cs_rx_looplimit_end;
+	uint8_t  cs_ap_stats_tx_cal_enable;
+	uint8_t  cs_self_bss_util;
+	uint8_t  cs_obss_util;
+	uint32_t cs_tgt_asserts;
+	int16_t  cs_chan_nf;
+	uint32_t cs_rx_last_msdu_unset_cnt;
+	int16_t  cs_chan_nf_sec80;
+	uint64_t cs_wmi_tx_mgmt;
+	uint64_t cs_wmi_tx_mgmt_completions;
+	uint32_t cs_wmi_tx_mgmt_completion_err;
+	uint32_t cs_peer_delete_req;
+	uint32_t cs_peer_delete_resp;
+	uint32_t cs_rx_mgmt_rssi_drop;
+	uint32_t cs_tx_retries;
+	uint32_t cs_rx_data_bytes;
+	uint32_t cs_tx_frame_count;
+	uint32_t cs_rx_frame_count;
+	uint32_t cs_rx_clear_count;
+	uint32_t cs_cycle_count;
+	uint32_t cs_phy_err_count;
+	uint32_t cs_chan_tx_pwr;
+
+	/* at places of copying required for scn-stats, copy till here only */
+	struct pdev_hw_stats hw_stats;
 };
 
 /**

+ 171 - 0
umac/cp_stats/dispatcher/inc/wlan_cp_stats_ic_ucfg_api.h

@@ -29,6 +29,138 @@
 #include <wlan_cp_stats_ic_defs.h>
 #include "../../core/src/wlan_cp_stats_defs.h"
 
+#define UCFG_PDEV_CP_STATS_SET_FUNCS(field) \
+	static inline void \
+	ucfg_pdev_cp_stats_##field##_inc(struct wlan_objmgr_pdev *_pdev, \
+					 uint64_t _val) \
+	{ \
+		struct pdev_cp_stats *_pdev_cs = \
+			wlan_cp_stats_get_pdev_stats_obj(_pdev); \
+		if (_pdev_cs) { \
+			struct pdev_ic_cp_stats *_pdev_ics = \
+						_pdev_cs->pdev_stats; \
+			if (_pdev_ics) { \
+				_pdev_ics->stats.cs_##field += _val;\
+			} \
+		} \
+	} \
+	static inline void \
+	ucfg_pdev_cp_stats_##field##_dec(struct wlan_objmgr_pdev *_pdev, \
+					 uint64_t _val) \
+	{ \
+		struct pdev_cp_stats *_pdev_cs = \
+			wlan_cp_stats_get_pdev_stats_obj(_pdev); \
+		if (_pdev_cs) { \
+			struct pdev_ic_cp_stats *_pdev_ics = \
+						_pdev_cs->pdev_stats; \
+			if (_pdev_ics) { \
+				_pdev_ics->stats.cs_##field -= _val;\
+			} \
+		} \
+	} \
+	static inline void \
+	ucfg_pdev_cp_stats_##field##_update(struct wlan_objmgr_pdev *_pdev, \
+					    uint64_t _val) \
+	{ \
+		struct pdev_cp_stats *_pdev_cs = \
+				wlan_cp_stats_get_pdev_stats_obj(_pdev); \
+		if (_pdev_cs) { \
+			struct pdev_ic_cp_stats *_pdev_ics = \
+						_pdev_cs->pdev_stats; \
+			if (_pdev_ics) { \
+				_pdev_ics->stats.cs_##field = _val;\
+			} \
+		} \
+	}
+
+UCFG_PDEV_CP_STATS_SET_FUNCS(tx_beacon);
+UCFG_PDEV_CP_STATS_SET_FUNCS(be_nobuf);
+UCFG_PDEV_CP_STATS_SET_FUNCS(tx_buf_count);
+UCFG_PDEV_CP_STATS_SET_FUNCS(tx_packets);
+UCFG_PDEV_CP_STATS_SET_FUNCS(rx_packets);
+UCFG_PDEV_CP_STATS_SET_FUNCS(tx_mgmt);
+UCFG_PDEV_CP_STATS_SET_FUNCS(tx_num_data);
+UCFG_PDEV_CP_STATS_SET_FUNCS(rx_num_data);
+UCFG_PDEV_CP_STATS_SET_FUNCS(rx_mgmt);
+UCFG_PDEV_CP_STATS_SET_FUNCS(rx_num_mgmt);
+UCFG_PDEV_CP_STATS_SET_FUNCS(rx_num_ctl);
+UCFG_PDEV_CP_STATS_SET_FUNCS(rx_ctrl);
+UCFG_PDEV_CP_STATS_SET_FUNCS(tx_ctrl);
+UCFG_PDEV_CP_STATS_SET_FUNCS(tx_rssi);
+UCFG_PDEV_CP_STATS_SET_FUNCS(rx_rssi_comb);
+UCFG_PDEV_CP_STATS_SET_FUNCS(rx_bytes);
+UCFG_PDEV_CP_STATS_SET_FUNCS(tx_bytes);
+UCFG_PDEV_CP_STATS_SET_FUNCS(tx_compaggr);
+UCFG_PDEV_CP_STATS_SET_FUNCS(rx_aggr);
+UCFG_PDEV_CP_STATS_SET_FUNCS(tx_bawadv);
+UCFG_PDEV_CP_STATS_SET_FUNCS(tx_compunaggr);
+UCFG_PDEV_CP_STATS_SET_FUNCS(rx_overrun);
+UCFG_PDEV_CP_STATS_SET_FUNCS(rx_crypt_err);
+UCFG_PDEV_CP_STATS_SET_FUNCS(rx_mic_err);
+UCFG_PDEV_CP_STATS_SET_FUNCS(rx_crc_err);
+UCFG_PDEV_CP_STATS_SET_FUNCS(rx_phy_err);
+UCFG_PDEV_CP_STATS_SET_FUNCS(rx_ack_err);
+UCFG_PDEV_CP_STATS_SET_FUNCS(rx_rts_err);
+UCFG_PDEV_CP_STATS_SET_FUNCS(rx_rts_success);
+UCFG_PDEV_CP_STATS_SET_FUNCS(rx_fcs_err);
+UCFG_PDEV_CP_STATS_SET_FUNCS(no_beacons);
+UCFG_PDEV_CP_STATS_SET_FUNCS(mib_int_count);
+UCFG_PDEV_CP_STATS_SET_FUNCS(rx_looplimit_start);
+UCFG_PDEV_CP_STATS_SET_FUNCS(rx_looplimit_end);
+UCFG_PDEV_CP_STATS_SET_FUNCS(ap_stats_tx_cal_enable);
+UCFG_PDEV_CP_STATS_SET_FUNCS(tgt_asserts);
+UCFG_PDEV_CP_STATS_SET_FUNCS(chan_nf);
+UCFG_PDEV_CP_STATS_SET_FUNCS(rx_last_msdu_unset_cnt);
+UCFG_PDEV_CP_STATS_SET_FUNCS(chan_nf_sec80);
+UCFG_PDEV_CP_STATS_SET_FUNCS(wmi_tx_mgmt);
+UCFG_PDEV_CP_STATS_SET_FUNCS(wmi_tx_mgmt_completions);
+UCFG_PDEV_CP_STATS_SET_FUNCS(wmi_tx_mgmt_completion_err);
+UCFG_PDEV_CP_STATS_SET_FUNCS(peer_delete_req);
+UCFG_PDEV_CP_STATS_SET_FUNCS(peer_delete_resp);
+UCFG_PDEV_CP_STATS_SET_FUNCS(rx_mgmt_rssi_drop);
+UCFG_PDEV_CP_STATS_SET_FUNCS(tx_retries);
+UCFG_PDEV_CP_STATS_SET_FUNCS(rx_data_bytes);
+UCFG_PDEV_CP_STATS_SET_FUNCS(tx_frame_count);
+UCFG_PDEV_CP_STATS_SET_FUNCS(rx_frame_count);
+UCFG_PDEV_CP_STATS_SET_FUNCS(rx_clear_count);
+UCFG_PDEV_CP_STATS_SET_FUNCS(cycle_count);
+UCFG_PDEV_CP_STATS_SET_FUNCS(phy_err_count);
+UCFG_PDEV_CP_STATS_SET_FUNCS(chan_tx_pwr);
+UCFG_PDEV_CP_STATS_SET_FUNCS(self_bss_util);
+UCFG_PDEV_CP_STATS_SET_FUNCS(obss_util);
+
+#define UCFG_PDEV_CP_STATS_GET_FUNCS(field) \
+	static inline uint64_t \
+	ucfg_pdev_cp_stats_##field##_get(struct wlan_objmgr_pdev *_pdev) \
+	{ \
+		struct pdev_cp_stats *_pdev_cs = \
+				wlan_cp_stats_get_pdev_stats_obj(_pdev); \
+		struct pdev_ic_cp_stats *_pdev_ics; \
+		if (_pdev_cs) { \
+			_pdev_ics = _pdev_cs->pdev_stats; \
+			if (_pdev_ics) \
+				return _pdev_ics->stats.cs_##field; \
+		} \
+		return 0; \
+	}
+
+UCFG_PDEV_CP_STATS_GET_FUNCS(ap_stats_tx_cal_enable);
+UCFG_PDEV_CP_STATS_GET_FUNCS(wmi_tx_mgmt);
+UCFG_PDEV_CP_STATS_GET_FUNCS(wmi_tx_mgmt_completions);
+UCFG_PDEV_CP_STATS_GET_FUNCS(wmi_tx_mgmt_completion_err);
+UCFG_PDEV_CP_STATS_GET_FUNCS(tgt_asserts);
+
+static inline void ucfg_pdev_cp_stats_reset(struct wlan_objmgr_pdev *_pdev)
+{
+	struct pdev_cp_stats *pdev_cps = NULL;
+
+	pdev_cps = wlan_cp_stats_get_pdev_stats_obj(_pdev);
+	if (!pdev_cps)
+		return;
+
+	qdf_mem_zero(pdev_cps->pdev_stats, sizeof(struct pdev_ic_cp_stats));
+}
+
 #define UCFG_VDEV_CP_STATS_SET_FUNCS(field) \
 	static inline void \
 	ucfg_vdev_cp_stats_##field##_inc(struct wlan_objmgr_vdev *_vdev, \
@@ -459,5 +591,44 @@ QDF_STATUS wlan_ucfg_get_peer_cp_stats(struct wlan_objmgr_peer *peer,
 QDF_STATUS wlan_ucfg_get_vdev_cp_stats(struct wlan_objmgr_vdev *vdev,
 				       struct vdev_ic_cp_stats *vdev_cps);
 
+/**
+ * wlan_ucfg_get_pdev_cp_stats_ref() - API to get reference to pdev cp stats
+ * @pdev_obj: pointer to pdev object
+ *
+ * Return: pdev_ic_cp_stats or NULL
+ */
+struct pdev_ic_cp_stats
+*wlan_ucfg_get_pdev_cp_stats_ref(struct wlan_objmgr_pdev *pdev);
+
+/**
+ * wlan_ucfg_get_pdev_cp_stats() - ucfg API to get pdev cp stats
+ * @pdev_obj: pointer to pdev object
+ * @pdev_cps: pointer to pdev cp stats object to populate
+ *
+ * Return: QDF_STATUS - Success or Failure
+ */
+QDF_STATUS wlan_ucfg_get_pdev_cp_stats(struct wlan_objmgr_pdev *pdev,
+				       struct pdev_ic_cp_stats *pdev_cps);
+
+/**
+ * wlan_ucfg_get_pdev_cp_stats() - ucfg API to get pdev hw stats
+ * @pdev_obj: pointer to pdev object
+ * @hw_stats: pointer to pdev hw cp stats to populate
+ *
+ * Return: QDF_STATUS - Success or Failure
+ */
+QDF_STATUS wlan_ucfg_get_pdev_hw_cp_stats(struct wlan_objmgr_pdev *pdev,
+					  struct pdev_hw_stats *hw_stats);
+
+/**
+ * wlan_ucfg_set_pdev_cp_stats() - ucfg API to set pdev hw stats
+ * @pdev_obj: pointer to pdev object
+ * @hw_stats: pointer to pdev hw cp stats
+ *
+ * Return: QDF_STATUS - Success or Failure
+ */
+QDF_STATUS wlan_ucfg_set_pdev_hw_cp_stats(struct wlan_objmgr_pdev *pdev,
+					  struct pdev_hw_stats *hw_stats);
+
 #endif /* QCA_SUPPORT_CP_STATS */
 #endif /* __WLAN_CP_STATS_IC_UCFG_API_H__ */

+ 97 - 0
umac/cp_stats/dispatcher/inc/wlan_cp_stats_ic_utils_api.h

@@ -285,5 +285,102 @@ static inline void vdev_cp_stats_reset(struct wlan_objmgr_vdev *vdev)
 	qdf_mem_set(vdev_cs, sizeof(struct vdev_ic_cp_stats), 0x0);
 }
 
+#define PDEV_CP_STATS_SET_FUNCS(field) \
+	static inline void \
+	pdev_cp_stats_##field##_inc(struct wlan_objmgr_pdev *_pdev, \
+				    uint64_t _val) \
+	{ \
+		ucfg_pdev_cp_stats_##field##_inc(_pdev, _val); \
+	} \
+	static inline void \
+	pdev_cp_stats_##field##_update(struct wlan_objmgr_pdev *_pdev, \
+				       uint64_t _val) \
+	{ \
+		ucfg_pdev_cp_stats_##field##_update(_pdev, _val); \
+	}
+
+PDEV_CP_STATS_SET_FUNCS(tx_beacon);
+PDEV_CP_STATS_SET_FUNCS(be_nobuf);
+PDEV_CP_STATS_SET_FUNCS(tx_buf_count);
+PDEV_CP_STATS_SET_FUNCS(tx_packets);
+PDEV_CP_STATS_SET_FUNCS(rx_packets);
+PDEV_CP_STATS_SET_FUNCS(tx_mgmt);
+PDEV_CP_STATS_SET_FUNCS(tx_num_data);
+PDEV_CP_STATS_SET_FUNCS(rx_num_data);
+PDEV_CP_STATS_SET_FUNCS(rx_mgmt);
+PDEV_CP_STATS_SET_FUNCS(rx_num_mgmt);
+PDEV_CP_STATS_SET_FUNCS(rx_num_ctl);
+PDEV_CP_STATS_SET_FUNCS(rx_ctrl);
+PDEV_CP_STATS_SET_FUNCS(tx_ctrl);
+PDEV_CP_STATS_SET_FUNCS(tx_rssi);
+PDEV_CP_STATS_SET_FUNCS(rx_rssi_comb);
+PDEV_CP_STATS_SET_FUNCS(rx_bytes);
+PDEV_CP_STATS_SET_FUNCS(tx_bytes);
+PDEV_CP_STATS_SET_FUNCS(tx_compaggr);
+PDEV_CP_STATS_SET_FUNCS(rx_aggr);
+PDEV_CP_STATS_SET_FUNCS(tx_bawadv);
+PDEV_CP_STATS_SET_FUNCS(tx_compunaggr);
+PDEV_CP_STATS_SET_FUNCS(rx_overrun);
+PDEV_CP_STATS_SET_FUNCS(rx_crypt_err);
+PDEV_CP_STATS_SET_FUNCS(rx_mic_err);
+PDEV_CP_STATS_SET_FUNCS(rx_crc_err);
+PDEV_CP_STATS_SET_FUNCS(rx_phy_err);
+PDEV_CP_STATS_SET_FUNCS(rx_ack_err);
+PDEV_CP_STATS_SET_FUNCS(rx_rts_err);
+PDEV_CP_STATS_SET_FUNCS(rx_rts_success);
+PDEV_CP_STATS_SET_FUNCS(rx_fcs_err);
+PDEV_CP_STATS_SET_FUNCS(no_beacons);
+PDEV_CP_STATS_SET_FUNCS(mib_int_count);
+PDEV_CP_STATS_SET_FUNCS(rx_looplimit_start);
+PDEV_CP_STATS_SET_FUNCS(rx_looplimit_end);
+PDEV_CP_STATS_SET_FUNCS(ap_stats_tx_cal_enable);
+PDEV_CP_STATS_SET_FUNCS(tgt_asserts);
+PDEV_CP_STATS_SET_FUNCS(chan_nf);
+PDEV_CP_STATS_SET_FUNCS(rx_last_msdu_unset_cnt);
+PDEV_CP_STATS_SET_FUNCS(chan_nf_sec80);
+PDEV_CP_STATS_SET_FUNCS(wmi_tx_mgmt);
+PDEV_CP_STATS_SET_FUNCS(wmi_tx_mgmt_completions);
+PDEV_CP_STATS_SET_FUNCS(wmi_tx_mgmt_completion_err);
+PDEV_CP_STATS_SET_FUNCS(peer_delete_req);
+PDEV_CP_STATS_SET_FUNCS(peer_delete_resp);
+PDEV_CP_STATS_SET_FUNCS(rx_mgmt_rssi_drop);
+PDEV_CP_STATS_SET_FUNCS(tx_retries);
+PDEV_CP_STATS_SET_FUNCS(rx_data_bytes);
+PDEV_CP_STATS_SET_FUNCS(tx_frame_count);
+PDEV_CP_STATS_SET_FUNCS(rx_frame_count);
+PDEV_CP_STATS_SET_FUNCS(rx_clear_count);
+PDEV_CP_STATS_SET_FUNCS(cycle_count);
+PDEV_CP_STATS_SET_FUNCS(phy_err_count);
+PDEV_CP_STATS_SET_FUNCS(chan_tx_pwr);
+PDEV_CP_STATS_SET_FUNCS(self_bss_util);
+PDEV_CP_STATS_SET_FUNCS(obss_util);
+
+#define PDEV_CP_STATS_GET_FUNCS(field) \
+	static inline uint64_t \
+	pdev_cp_stats_##field##_get(struct wlan_objmgr_pdev *_pdev) \
+	{ \
+		return ucfg_pdev_cp_stats_##field##_get(_pdev); \
+	}
+
+PDEV_CP_STATS_GET_FUNCS(ap_stats_tx_cal_enable);
+PDEV_CP_STATS_GET_FUNCS(wmi_tx_mgmt);
+PDEV_CP_STATS_GET_FUNCS(wmi_tx_mgmt_completions);
+PDEV_CP_STATS_GET_FUNCS(wmi_tx_mgmt_completion_err);
+PDEV_CP_STATS_GET_FUNCS(tgt_asserts);
+
+static inline void pdev_cp_stats_reset(struct wlan_objmgr_pdev *pdev)
+{
+	ucfg_pdev_cp_stats_reset(pdev);
+}
+
+/**
+ * wlan_get_pdev_cp_stats_ref() - API to reference to pdev cp stats object
+ * @pdev: pointer to pdev object
+ *
+ * Return: pdev_ic_cp_stats or NULL
+ */
+struct pdev_ic_cp_stats
+*wlan_get_pdev_cp_stats_ref(struct wlan_objmgr_pdev *pdev);
+
 #endif /* QCA_SUPPORT_CP_STATS */
 #endif /* __WLAN_CP_STATS_IC_UTILS_API_H__ */

+ 114 - 4
umac/cp_stats/dispatcher/src/wlan_cp_stats_ic_ucfg_api.c

@@ -22,11 +22,12 @@
  * This file provide APIs definition for registering cp stats cfg80211 command
  * handlers
  */
-#include "wlan_cp_stats_ic_ucfg_api.h"
+#include <wlan_cp_stats_ic_ucfg_api.h>
 #include <wlan_cfg80211_ic_cp_stats.h>
 #include <wlan_cp_stats_ic_atf_defs.h>
 #include <wlan_cp_stats_ic_defs.h>
 #include "../../core/src/wlan_cp_stats_cmn_api_i.h"
+#include <qdf_module.h>
 
 QDF_STATUS wlan_cp_stats_psoc_cs_init(struct psoc_cp_stats *psoc_cs)
 {
@@ -116,9 +117,8 @@ QDF_STATUS wlan_ucfg_get_peer_cp_stats(struct wlan_objmgr_peer *peer,
 	return QDF_STATUS_E_FAILURE;
 }
 
-QDF_STATUS
-wlan_ucfg_get_vdev_cp_stats(struct wlan_objmgr_vdev *vdev,
-			    struct vdev_ic_cp_stats *vdev_cps)
+QDF_STATUS wlan_ucfg_get_vdev_cp_stats(struct wlan_objmgr_vdev *vdev,
+				       struct vdev_ic_cp_stats *vdev_cps)
 {
 	struct vdev_cp_stats *vdev_cs;
 
@@ -143,3 +143,113 @@ wlan_ucfg_get_vdev_cp_stats(struct wlan_objmgr_vdev *vdev,
 
 	return QDF_STATUS_E_FAILURE;
 }
+
+QDF_STATUS wlan_ucfg_get_pdev_cp_stats(struct wlan_objmgr_pdev *pdev,
+				       struct pdev_ic_cp_stats *pdev_cps)
+{
+	struct pdev_cp_stats *pdev_cs;
+
+	if (!pdev) {
+		cp_stats_err("Invalid input, pdev obj is null");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	if (!pdev_cps) {
+		cp_stats_err("Invalid input, pdev cp obj is null");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	pdev_cs = wlan_cp_stats_get_pdev_stats_obj(pdev);
+	if (pdev_cs && pdev_cs->pdev_stats) {
+		wlan_cp_stats_pdev_obj_lock(pdev_cs);
+		qdf_mem_copy(pdev_cps, pdev_cs->pdev_stats,
+			     sizeof(*pdev_cps));
+		wlan_cp_stats_pdev_obj_unlock(pdev_cs);
+		return QDF_STATUS_SUCCESS;
+	}
+
+	return QDF_STATUS_E_FAILURE;
+}
+
+QDF_STATUS wlan_ucfg_get_pdev_hw_cp_stats(struct wlan_objmgr_pdev *pdev,
+					  struct pdev_hw_stats *hw_stats)
+{
+	struct pdev_cp_stats *pdev_cs;
+	struct pdev_ic_cp_stats *pdev_cps;
+
+	if (!pdev) {
+		cp_stats_err("Invalid input, pdev obj is null");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	if (!hw_stats) {
+		cp_stats_err("Invalid input, pdev hw_stats is null");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	pdev_cs = wlan_cp_stats_get_pdev_stats_obj(pdev);
+	if (pdev_cs && pdev_cs->pdev_stats) {
+		pdev_cps = pdev_cs->pdev_stats;
+		wlan_cp_stats_pdev_obj_lock(pdev_cs);
+		qdf_mem_copy(hw_stats, &pdev_cps->stats.hw_stats,
+			     sizeof(*hw_stats));
+		wlan_cp_stats_pdev_obj_unlock(pdev_cs);
+		return QDF_STATUS_SUCCESS;
+	}
+
+	return QDF_STATUS_E_FAILURE;
+}
+
+QDF_STATUS wlan_ucfg_set_pdev_hw_cp_stats(struct wlan_objmgr_pdev *pdev,
+					  struct pdev_hw_stats *hw_stats)
+{
+	struct pdev_cp_stats *pdev_cs;
+	struct pdev_ic_cp_stats *pdev_cps;
+
+	if (!pdev) {
+		cp_stats_err("Invalid input, pdev obj is null");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	if (!hw_stats) {
+		cp_stats_err("Invalid input, pdev hw_stats is null");
+		return QDF_STATUS_E_INVAL;
+	}
+
+	pdev_cs = wlan_cp_stats_get_pdev_stats_obj(pdev);
+	if (pdev_cs && pdev_cs->pdev_stats) {
+		pdev_cps = pdev_cs->pdev_stats;
+		wlan_cp_stats_pdev_obj_lock(pdev_cs);
+		qdf_mem_copy(&pdev_cps->stats.hw_stats, hw_stats,
+			     sizeof(*hw_stats));
+		wlan_cp_stats_pdev_obj_unlock(pdev_cs);
+		return QDF_STATUS_SUCCESS;
+	}
+
+	return QDF_STATUS_E_FAILURE;
+}
+
+struct pdev_ic_cp_stats
+*wlan_ucfg_get_pdev_cp_stats_ref(struct wlan_objmgr_pdev *pdev)
+{
+	struct pdev_cp_stats *pdev_cs = NULL;
+
+	if (!pdev) {
+		cp_stats_err("pdev is null");
+		return NULL;
+	}
+
+	pdev_cs = wlan_cp_stats_get_pdev_stats_obj(pdev);
+	if (pdev_cs && pdev_cs->pdev_stats)
+		return pdev_cs->pdev_stats;
+
+	return NULL;
+}
+
+struct pdev_ic_cp_stats
+*wlan_get_pdev_cp_stats_ref(struct  wlan_objmgr_pdev *pdev)
+{
+	return wlan_ucfg_get_pdev_cp_stats_ref(pdev);
+}
+
+qdf_export_symbol(wlan_get_pdev_cp_stats_ref);