Browse Source

qcacmn: Add WMI support for peer_extd2 stats

Add the necessary support for peer_extd2 stats in the WMI layer. The
stats contain rx_bytes, rx_err and rx_mpdus

Change-Id: I9f787e28a8e128471489c8f47ac03fef77dae930
CRs-Fixed: 2395636
Sourav Mohapatra 6 years ago
parent
commit
9a6ee7d0ce

+ 6 - 1
wmi/inc/wmi_unified_api.h

@@ -116,7 +116,8 @@ typedef qdf_nbuf_t wmi_buf_t;
 #define WMI_LOGP(args ...) \
 	QDF_TRACE(QDF_MODULE_ID_WMI, QDF_TRACE_LEVEL_FATAL, ## args)
 
-
+/* Number of bits to shift to combine 32 bit integer to 64 bit */
+#define WMI_LOWER_BITS_SHIFT_32	0x20
 
 #define PHYERROR_MAX_BUFFER_LENGTH 0x7F000000
 
@@ -1222,6 +1223,10 @@ QDF_STATUS wmi_extract_peer_extd_stats(void *wmi_hdl, void *evt_buf,
 			uint32_t index,
 			wmi_host_peer_extd_stats *peer_extd_stats);
 
+QDF_STATUS wmi_extract_peer_adv_stats(wmi_unified_t wmi_handle, void *evt_buf,
+				      struct wmi_host_peer_adv_stats
+				      *peer_adv_stats);
+
 QDF_STATUS wmi_extract_bss_chan_info_event(void *wmi_hdl, void *evt_buf,
 			wmi_host_pdev_bss_chan_info_event *bss_chan_info);
 

+ 19 - 2
wmi/inc/wmi_unified_param.h

@@ -998,6 +998,7 @@ typedef enum {
 	WMI_HOST_REQUEST_BCN_STAT =  0x800,
 	WMI_HOST_REQUEST_BCN_STAT_RESET =  0x1000,
 	WMI_HOST_REQUEST_PEER_RETRY_STAT = 0x2000,
+	WMI_HOST_REQUEST_PEER_ADV_STATS = 0x4000,
 } wmi_host_stats_id;
 
 typedef struct {
@@ -4084,6 +4085,8 @@ struct rx_reorder_queue_remove_params {
  * @pdev_id: device id for the radio
  * @num_bcn_stats: number of beacon stats
  * @num_rssi_stats: number of rssi stats
+ * @num_peer_adv_stats: number of peer adv stats
+ * @last_event: specify if the current event is the last event
  */
 typedef struct {
 	wmi_host_stats_id stats_id;
@@ -4096,6 +4099,8 @@ typedef struct {
 	uint32_t pdev_id;
 	uint32_t num_bcn_stats;
 	uint32_t num_rssi_stats;
+	uint32_t num_peer_adv_stats;
+	uint32_t last_event;
 } wmi_host_stats_event;
 
 /**
@@ -4105,7 +4110,6 @@ typedef struct {
  * @peer_chain_rssi: peer rssi
  * @rx_duration: RX duration
  * @peer_tx_bytes: TX bytes
- * @peer_rx_bytes: RX bytes
  * @last_tx_rate_code: Tx rate code of last frame
  * @last_tx_power: Tx power latest
  * @atf_tokens_allocated: atf tokens allocated
@@ -4120,7 +4124,6 @@ typedef struct {
 	uint32_t peer_chain_rssi;
 	uint32_t rx_duration;
 	uint32_t peer_tx_bytes;
-	uint32_t peer_rx_bytes;
 	uint32_t last_tx_rate_code;
 	uint32_t last_tx_power;
 	uint32_t atf_tokens_allocated;
@@ -4130,6 +4133,20 @@ typedef struct {
 	uint32_t reserved[2];
 } wmi_host_peer_extd_stats;
 
+/**
+ * struct wmi_host_peer_adv_stats - peer adv stats event structure
+ * @peer_macaddr: mac address
+ * @fcs_count: fcs count
+ * @rx_bytes: rx bytes
+ * @rx_count: rx count
+ */
+struct wmi_host_peer_adv_stats {
+	uint8_t peer_macaddr[WLAN_MACADDR_LEN];
+	uint32_t fcs_count;
+	uint64_t rx_bytes;
+	uint32_t rx_count;
+};
+
 /**
  * struct wmi_host_pdev_ext_stats - peer ext stats structure
  * @rx_rssi_comb: RX rssi

+ 4 - 0
wmi/inc/wmi_unified_priv.h

@@ -1538,6 +1538,10 @@ QDF_STATUS (*extract_peer_retry_stats)(wmi_unified_t wmi_handle, void *evt_buf,
 	    uint32_t index,
 	    struct wmi_host_peer_retry_stats *peer_retry_stats);
 
+QDF_STATUS (*extract_peer_adv_stats)(wmi_unified_t wmi_handle, void *evt_buf,
+				     struct wmi_host_peer_adv_stats
+				     *peer_adv_stats);
+
 QDF_STATUS (*extract_chan_stats)(wmi_unified_t wmi_handle, void *evt_buf,
 			 uint32_t index, wmi_host_chan_stats *chan_stats);
 

+ 19 - 0
wmi/src/wmi_unified_api.c

@@ -3600,6 +3600,25 @@ QDF_STATUS wmi_extract_peer_retry_stats(void *wmi_hdl, void *evt_buf,
 	return QDF_STATUS_E_FAILURE;
 }
 
+/**
+ * wmi_extract_peer_adv_stats() - extract advance (extd2) peer stats from event
+ * @wmi_handle: wmi handle
+ * @param evt_buf: pointer to event buffer
+ * @param peer_adv_stats: Pointer to hold extended peer stats
+ *
+ * Return: QDF_STATUS_SUCCESS on success and QDF_STATUS_E_FAILURE for failure
+ */
+QDF_STATUS wmi_extract_peer_adv_stats(wmi_unified_t wmi_handle, void *evt_buf,
+				      struct wmi_host_peer_adv_stats
+				      *peer_adv_stats)
+{
+	if (wmi_handle->ops->extract_peer_adv_stats)
+		return wmi_handle->ops->extract_peer_adv_stats(wmi_handle,
+			evt_buf, peer_adv_stats);
+
+	return QDF_STATUS_E_FAILURE;
+}
+
 /**
  * wmi_extract_rtt_error_report_ev() - extract rtt error report from event
  * @wmi_handle: wmi handle

+ 58 - 6
wmi/src/wmi_unified_tlv.c

@@ -8313,33 +8313,37 @@ static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
 
 	switch (ev->stats_id) {
 	case WMI_REQUEST_PEER_STAT:
-		stats_param->stats_id = WMI_HOST_REQUEST_PEER_STAT;
+		stats_param->stats_id |= WMI_HOST_REQUEST_PEER_STAT;
 		break;
 
 	case WMI_REQUEST_AP_STAT:
-		stats_param->stats_id = WMI_HOST_REQUEST_AP_STAT;
+		stats_param->stats_id |= WMI_HOST_REQUEST_AP_STAT;
 		break;
 
 	case WMI_REQUEST_PDEV_STAT:
-		stats_param->stats_id = WMI_HOST_REQUEST_PDEV_STAT;
+		stats_param->stats_id |= WMI_HOST_REQUEST_PDEV_STAT;
 		break;
 
 	case WMI_REQUEST_VDEV_STAT:
-		stats_param->stats_id = WMI_HOST_REQUEST_VDEV_STAT;
+		stats_param->stats_id |= WMI_HOST_REQUEST_VDEV_STAT;
 		break;
 
 	case WMI_REQUEST_BCNFLT_STAT:
-		stats_param->stats_id = WMI_HOST_REQUEST_BCNFLT_STAT;
+		stats_param->stats_id |= WMI_HOST_REQUEST_BCNFLT_STAT;
 		break;
 
 	case WMI_REQUEST_VDEV_RATE_STAT:
-		stats_param->stats_id = WMI_HOST_REQUEST_VDEV_RATE_STAT;
+		stats_param->stats_id |= WMI_HOST_REQUEST_VDEV_RATE_STAT;
 		break;
 
 	case WMI_REQUEST_BCN_STAT:
 		stats_param->stats_id |= WMI_HOST_REQUEST_BCN_STAT;
 		break;
 
+	case WMI_REQUEST_PEER_EXTD2_STAT:
+		stats_param->stats_id |= WMI_HOST_REQUEST_PEER_ADV_STATS;
+		break;
+
 	default:
 		stats_param->stats_id = 0;
 		break;
@@ -8366,6 +8370,7 @@ static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
 		return QDF_STATUS_E_FAULT;
 	}
 
+	stats_param->last_event = ev->last_event;
 	stats_param->num_pdev_stats = ev->num_pdev_stats;
 	stats_param->num_pdev_ext_stats = 0;
 	stats_param->num_vdev_stats = ev->num_vdev_stats;
@@ -8396,6 +8401,12 @@ static QDF_STATUS extract_all_stats_counts_tlv(wmi_unified_t wmi_handle,
 	}
 	stats_param->num_rssi_stats = rssi_event->num_per_chain_rssi_stats;
 
+	/* if peer_adv_stats is not populated */
+	if (!param_buf->num_peer_extd2_stats)
+		return QDF_STATUS_SUCCESS;
+
+	stats_param->num_peer_adv_stats = param_buf->num_peer_extd2_stats;
+
 	return QDF_STATUS_SUCCESS;
 }
 
@@ -8755,6 +8766,46 @@ static QDF_STATUS extract_bcnflt_stats_tlv(wmi_unified_t wmi_handle,
 	return QDF_STATUS_SUCCESS;
 }
 
+/**
+ * extract_peer_adv_stats_tlv() - extract adv peer stats from event
+ * @wmi_handle: wmi handle
+ * @param evt_buf: pointer to event buffer
+ * @param index: Index into extended peer stats
+ * @param peer_adv_stats: Pointer to hold adv peer stats
+ *
+ * Return: QDF_STATUS_SUCCESS for success or error code
+ */
+static QDF_STATUS extract_peer_adv_stats_tlv(wmi_unified_t wmi_handle,
+					     void *evt_buf,
+					     struct wmi_host_peer_adv_stats
+					     *peer_adv_stats)
+{
+	WMI_UPDATE_STATS_EVENTID_param_tlvs *param_buf;
+	wmi_peer_extd2_stats *adv_stats;
+	int i;
+
+	param_buf = (WMI_UPDATE_STATS_EVENTID_param_tlvs *)evt_buf;
+
+	adv_stats = param_buf->peer_extd2_stats;
+	if (!adv_stats) {
+		WMI_LOGD("%s: no peer_adv stats in event buffer", __func__);
+		return QDF_STATUS_E_INVAL;
+	}
+
+	for (i = 0; i < param_buf->num_peer_extd2_stats; i++) {
+		WMI_MAC_ADDR_TO_CHAR_ARRAY(&adv_stats[i].peer_macaddr,
+					   peer_adv_stats[i].peer_macaddr);
+		peer_adv_stats[i].fcs_count = adv_stats[i].rx_fcs_err;
+		peer_adv_stats[i].rx_bytes =
+				(uint64_t)adv_stats[i].rx_bytes_u32 <<
+				WMI_LOWER_BITS_SHIFT_32 |
+				adv_stats[i].rx_bytes_l32;
+		peer_adv_stats[i].rx_count = adv_stats[i].rx_mpdus;
+	}
+
+	return QDF_STATUS_SUCCESS;
+}
+
 /**
  * extract_peer_extd_stats_tlv() - extract extended peer stats from event
  * @wmi_handle: wmi handle
@@ -11292,6 +11343,7 @@ struct wmi_ops tlv_ops =  {
 	.extract_bcn_stats = extract_bcn_stats_tlv,
 	.extract_bcnflt_stats = extract_bcnflt_stats_tlv,
 	.extract_peer_extd_stats = extract_peer_extd_stats_tlv,
+	.extract_peer_adv_stats = extract_peer_adv_stats_tlv,
 	.extract_chan_stats = extract_chan_stats_tlv,
 	.extract_profile_ctx = extract_profile_ctx_tlv,
 	.extract_profile_data = extract_profile_data_tlv,