Эх сурвалжийг харах

qcacld-3.0: Add new diag events to log TX and RX mgmt frames

Add diag events and their structures to log TX and RX mgmt
frames.

Change-Id: I2f30c46d0087dc6a31fcb874713a574fe5936ea7
CRs-Fixed: 2171137
Krunal Soni 7 жил өмнө
parent
commit
c65fc490c5

+ 40 - 1
core/mac/src/pe/lim/lim_process_message_queue.c

@@ -924,6 +924,42 @@ lim_check_mgmt_registered_frames(tpAniSirGlobal mac_ctx, uint8_t *buff_desc,
 	return match;
 }
 
+#ifdef FEATURE_WLAN_DIAG_SUPPORT
+/**
+ * lim_is_mgmt_frame_loggable() - to log non-excessive mgmt frames
+ * @type: type of frames i.e. mgmt, control, data
+ * @subtype: subtype of frames i.e. beacon, probe rsp, probe req and etc
+ *
+ * This API tells if given mgmt frame is expected to come excessive in
+ * amount or not.
+ *
+ * Return: true if mgmt is expected to come not that often, so makes it
+ *         loggable. false if mgmt is expected to come too often, so makes
+ *         it not loggable
+ */
+static bool
+lim_is_mgmt_frame_loggable(uint8_t type, uint8_t subtype)
+{
+	if (type != SIR_MAC_MGMT_FRAME)
+		return false;
+
+	switch (subtype) {
+	case SIR_MAC_MGMT_BEACON:
+	case SIR_MAC_MGMT_PROBE_REQ:
+	case SIR_MAC_MGMT_PROBE_RSP:
+		return false;
+	default:
+		return true;
+	}
+}
+#else
+static bool
+lim_is_mgmt_frame_loggable(uint8_t type, uint8_t subtype)
+{
+	return false;
+}
+#endif
+
 /**
  * lim_handle80211_frames()
  *
@@ -1192,7 +1228,10 @@ lim_handle80211_frames(tpAniSirGlobal pMac, struct scheduler_msg *limMsg,
 		break;
 
 	} /* switch (fc.type) */
-
+	if (lim_is_mgmt_frame_loggable(fc.type, fc.subType))
+		lim_diag_mgmt_rx_event_report(pMac, pHdr,
+					      psessionEntry,
+					      eSIR_SUCCESS, eSIR_SUCCESS);
 end:
 	lim_pkt_free(pMac, TXRX_FRM_802_11_MGMT, pRxPacketInfo,
 		     (void *)limMsg->bodyptr);

+ 19 - 0
core/mac/src/pe/lim/lim_process_tdls.c

@@ -670,6 +670,9 @@ static tSirRetStatus lim_send_tdls_dis_req_frame(tpAniSirGlobal pMac,
 		MAC_ADDR_ARRAY(peer_mac.bytes));
 
 	pMac->lim.tdls_frm_session_id = psessionEntry->smeSessionId;
+	lim_diag_mgmt_tx_event_report(pMac, (tpSirMacMgmtHdr) pFrame,
+				      psessionEntry, eSIR_SUCCESS,
+				      eSIR_SUCCESS);
 	qdf_status = wma_tx_frameWithTxComplete(pMac, pPacket,
 					(uint16_t) nBytes,
 					TXRX_FRM_802_11_DATA,
@@ -971,6 +974,9 @@ static tSirRetStatus lim_send_tdls_dis_rsp_frame(tpAniSirGlobal pMac,
 		MAC_ADDR_ARRAY(peer_mac.bytes));
 
 	pMac->lim.tdls_frm_session_id = psessionEntry->smeSessionId;
+	lim_diag_mgmt_tx_event_report(pMac, (tpSirMacMgmtHdr) pFrame,
+				      psessionEntry, eSIR_SUCCESS,
+				      eSIR_SUCCESS);
 	/*
 	 * Transmit Discovery response and watch if this is delivered to
 	 * peer STA.
@@ -1344,6 +1350,9 @@ tSirRetStatus lim_send_tdls_link_setup_req_frame(tpAniSirGlobal pMac,
 		MAC_ADDR_ARRAY(peer_mac.bytes));
 
 	pMac->lim.tdls_frm_session_id = psessionEntry->smeSessionId;
+	lim_diag_mgmt_tx_event_report(pMac, (tpSirMacMgmtHdr) pFrame,
+				      psessionEntry, eSIR_SUCCESS,
+				      eSIR_SUCCESS);
 
 	qdf_status = wma_tx_frame_with_tx_complete_send(pMac, pPacket,
 						     (uint16_t) nBytes,
@@ -1534,6 +1543,9 @@ tSirRetStatus lim_send_tdls_teardown_frame(tpAniSirGlobal pMac,
 		MAC_ADDR_ARRAY(peer_mac.bytes));
 
 	pMac->lim.tdls_frm_session_id = psessionEntry->smeSessionId;
+	lim_diag_mgmt_tx_event_report(pMac, (tpSirMacMgmtHdr) pFrame,
+				      psessionEntry, eSIR_SUCCESS,
+				      eSIR_SUCCESS);
 
 	qdf_status = wma_tx_frame_with_tx_complete_send(pMac, pPacket,
 						     (uint16_t) nBytes,
@@ -1549,6 +1561,7 @@ tSirRetStatus lim_send_tdls_teardown_frame(tpAniSirGlobal pMac,
 		return eSIR_FAILURE;
 
 	}
+
 	return eSIR_SUCCESS;
 }
 
@@ -1790,6 +1803,9 @@ static tSirRetStatus lim_send_tdls_setup_rsp_frame(tpAniSirGlobal pMac,
 		MAC_ADDR_ARRAY(peer_mac.bytes));
 
 	pMac->lim.tdls_frm_session_id = psessionEntry->smeSessionId;
+	lim_diag_mgmt_tx_event_report(pMac, (tpSirMacMgmtHdr) pFrame,
+				      psessionEntry, eSIR_SUCCESS,
+				      eSIR_SUCCESS);
 
 	qdf_status = wma_tx_frame_with_tx_complete_send(pMac, pPacket,
 						     (uint16_t) nBytes,
@@ -1994,6 +2010,9 @@ tSirRetStatus lim_send_tdls_link_setup_cnf_frame(tpAniSirGlobal pMac,
 	       MAC_ADDR_ARRAY(peer_mac.bytes));
 
 	pMac->lim.tdls_frm_session_id = psessionEntry->smeSessionId;
+	lim_diag_mgmt_tx_event_report(pMac, (tpSirMacMgmtHdr) pFrame,
+				      psessionEntry, eSIR_SUCCESS,
+				      eSIR_SUCCESS);
 
 	qdf_status = wma_tx_frame_with_tx_complete_send(pMac, pPacket,
 						     (uint16_t) nBytes,

+ 10 - 9
core/mac/src/pe/lim/lim_send_frames_host_roam.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2016-2017 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2018 The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -442,12 +442,12 @@ void lim_send_reassoc_req_with_ft_ies_mgmt_frame(tpAniSirGlobal mac_ctx,
 		pe_session->assocReqLen = 0;
 	}
 
-#ifdef FEATURE_WLAN_DIAG_SUPPORT
-	lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_START_EVENT,
-			      pe_session, eSIR_SUCCESS, eSIR_SUCCESS);
-#endif
 	MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
 			 pe_session->peSessionId, mac_hdr->fc.subType));
+	lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_REASSOC_START_EVENT,
+			      pe_session, eSIR_SUCCESS, eSIR_SUCCESS);
+	lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
+				      pe_session, eSIR_SUCCESS, eSIR_SUCCESS);
 	qdf_status = wma_tx_frame(mac_ctx, packet,
 				(uint16_t) (bytes + ft_ies_length),
 				TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS, 7,
@@ -770,12 +770,13 @@ void lim_send_reassoc_req_mgmt_frame(tpAniSirGlobal pMac,
 		psessionEntry->pePersona == QDF_STA_MODE)
 		txFlag |= HAL_USE_PEER_STA_REQUESTED_MASK;
 
-#ifdef FEATURE_WLAN_DIAG_SUPPORT
-	lim_diag_event_report(pMac, WLAN_PE_DIAG_REASSOC_START_EVENT,
-			      psessionEntry, eSIR_SUCCESS, eSIR_SUCCESS);
-#endif
 	MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
 			 psessionEntry->peSessionId, pMacHdr->fc.subType));
+	lim_diag_event_report(pMac, WLAN_PE_DIAG_REASSOC_START_EVENT,
+			      psessionEntry, eSIR_SUCCESS, eSIR_SUCCESS);
+	lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
+				      psessionEntry, eSIR_SUCCESS,
+				      eSIR_SUCCESS);
 	qdf_status =
 		wma_tx_frame(pMac, pPacket,
 			   (uint16_t) (sizeof(tSirMacMgmtHdr) + nPayload),

+ 31 - 4
core/mac/src/pe/lim/lim_send_management_frames.c

@@ -1073,6 +1073,9 @@ lim_send_addts_req_action_frame(tpAniSirGlobal pMac,
 
 	MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
 			 psessionEntry->peSessionId, pMacHdr->fc.subType));
+	lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
+				      psessionEntry, eSIR_SUCCESS,
+				      eSIR_SUCCESS);
 
 	/* Queue Addts Response frame in high priority WQ */
 	qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
@@ -1424,6 +1427,8 @@ lim_send_assoc_rsp_mgmt_frame(tpAniSirGlobal mac_ctx,
 
 	MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
 			 pe_session->peSessionId, mac_hdr->fc.subType));
+	lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
+				      pe_session, eSIR_SUCCESS, status_code);
 	/* Queue Association Response frame in high priority WQ */
 	qdf_status = wma_tx_frame(mac_ctx, packet, (uint16_t) bytes,
 				TXRX_FRM_802_11_MGMT,
@@ -1572,6 +1577,9 @@ lim_send_delts_req_action_frame(tpAniSirGlobal pMac,
 
 	MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
 			 psessionEntry->peSessionId, pMacHdr->fc.subType));
+	lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
+				      psessionEntry, eSIR_SUCCESS,
+				      eSIR_SUCCESS);
 	qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
 				TXRX_FRM_802_11_MGMT,
 				ANI_TXDIR_TODS,
@@ -2069,16 +2077,16 @@ lim_send_assoc_req_mgmt_frame(tpAniSirGlobal mac_ctx,
 		pe_session->pePersona == QDF_STA_MODE)
 		tx_flag |= HAL_USE_PEER_STA_REQUESTED_MASK;
 
-#ifdef FEATURE_WLAN_DIAG_SUPPORT
-	lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_START_EVENT,
-			      pe_session, eSIR_SUCCESS, eSIR_SUCCESS);
-#endif
 	mac_hdr = (tpSirMacMgmtHdr) frame;
 	MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
 			 pe_session->peSessionId, mac_hdr->fc.subType));
 
 	pe_debug("Sending Association Request length %d to ", bytes);
 	min_rid = lim_get_min_session_txrate(pe_session);
+	lim_diag_event_report(mac_ctx, WLAN_PE_DIAG_ASSOC_START_EVENT,
+			      pe_session, eSIR_SUCCESS, eSIR_SUCCESS);
+	lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
+				      pe_session, eSIR_SUCCESS, eSIR_SUCCESS);
 	qdf_status =
 		wma_tx_frameWithTxComplete(mac_ctx, packet,
 			   (uint16_t) (sizeof(tSirMacMgmtHdr) + payload),
@@ -2455,6 +2463,8 @@ alloc_packet:
 
 	mac_ctx->auth_ack_status = LIM_AUTH_ACK_NOT_RCD;
 	min_rid = lim_get_min_session_txrate(session);
+	lim_diag_mgmt_tx_event_report(mac_ctx, mac_hdr,
+				      session, eSIR_SUCCESS, eSIR_SUCCESS);
 	qdf_status = wma_tx_frameWithTxComplete(mac_ctx, packet,
 				 (uint16_t)frame_len,
 				 TXRX_FRM_802_11_MGMT, ANI_TXDIR_TODS,
@@ -2840,6 +2850,9 @@ lim_send_disassoc_mgmt_frame(tpAniSirGlobal pMac,
 		MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
 				 psessionEntry->peSessionId,
 				 pMacHdr->fc.subType));
+		lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
+					      psessionEntry, eSIR_SUCCESS,
+					      eSIR_SUCCESS);
 		/* Queue Disassociation frame in high priority WQ */
 		/* get the duration from the request */
 		qdf_status =
@@ -2872,6 +2885,9 @@ lim_send_disassoc_mgmt_frame(tpAniSirGlobal pMac,
 		MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
 				 psessionEntry->peSessionId,
 				 pMacHdr->fc.subType));
+		lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
+					      psessionEntry,
+					      eSIR_SUCCESS, eSIR_SUCCESS);
 		/* Queue Disassociation frame in high priority WQ */
 		qdf_status = wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
 					TXRX_FRM_802_11_MGMT,
@@ -3017,6 +3033,9 @@ lim_send_deauth_mgmt_frame(tpAniSirGlobal pMac,
 		MTRACE(qdf_trace(QDF_MODULE_ID_PE, TRACE_CODE_TX_MGMT,
 				 psessionEntry->peSessionId,
 				 pMacHdr->fc.subType));
+		lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
+					      psessionEntry,
+					      eSIR_SUCCESS, eSIR_SUCCESS);
 		/* Queue Disassociation frame in high priority WQ */
 		qdf_status =
 			wma_tx_frameWithTxComplete(pMac, pPacket, (uint16_t) nBytes,
@@ -3063,6 +3082,10 @@ lim_send_deauth_mgmt_frame(tpAniSirGlobal pMac,
 		if ((NULL != pStaDs)
 		    && (STA_ENTRY_TDLS_PEER == pStaDs->staType)) {
 			/* Queue Disassociation frame in high priority WQ */
+			lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
+						      psessionEntry,
+						      eSIR_SUCCESS,
+						      eSIR_SUCCESS);
 			qdf_status =
 				wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,
 					   TXRX_FRM_802_11_MGMT, ANI_TXDIR_IBSS,
@@ -3070,6 +3093,10 @@ lim_send_deauth_mgmt_frame(tpAniSirGlobal pMac,
 					   smeSessionId, 0, RATEID_DEFAULT);
 		} else {
 #endif
+		lim_diag_mgmt_tx_event_report(pMac, pMacHdr,
+					      psessionEntry,
+					      eSIR_SUCCESS,
+					      eSIR_SUCCESS);
 		/* Queue Disassociation frame in high priority WQ */
 		qdf_status =
 			wma_tx_frame(pMac, pPacket, (uint16_t) nBytes,

+ 73 - 0
core/mac/src/pe/lim/lim_utils.c

@@ -5641,6 +5641,79 @@ void lim_diag_event_report(tpAniSirGlobal pMac, uint16_t eventType,
 	return;
 }
 
+static void lim_diag_fill_mgmt_event_report(tpAniSirGlobal mac_ctx,
+			tpSirMacMgmtHdr mac_hdr,
+			tpPESession session, uint16_t result_code,
+			uint16_t reason_code,
+			struct host_event_wlan_mgmt_payload_type *mgmt_event)
+{
+	uint8_t length;
+
+	qdf_mem_set(mgmt_event, sizeof(*mgmt_event), 0);
+	mgmt_event->mgmt_type = mac_hdr->fc.type;
+	mgmt_event->mgmt_subtype = mac_hdr->fc.subType;
+	qdf_mem_copy(mgmt_event->self_mac_addr, session->selfMacAddr,
+		     QDF_MAC_ADDR_SIZE);
+	qdf_mem_copy(mgmt_event->bssid, session->bssId,
+		     QDF_MAC_ADDR_SIZE);
+	length = session->ssId.length;
+	if (length > SIR_MAC_MAX_SSID_LENGTH)
+		length = SIR_MAC_MAX_SSID_LENGTH;
+	qdf_mem_copy(mgmt_event->ssid, session->ssId.ssId, length);
+	mgmt_event->ssid_len = length;
+	mgmt_event->operating_channel = session->currentOperChannel;
+	mgmt_event->result_code = result_code;
+	mgmt_event->reason_code = reason_code;
+}
+
+void lim_diag_mgmt_tx_event_report(tpAniSirGlobal mac_ctx, void *mgmt_hdr,
+				   tpPESession session, uint16_t result_code,
+				   uint16_t reason_code)
+{
+	tpSirMacMgmtHdr mac_hdr = mgmt_hdr;
+
+	WLAN_HOST_DIAG_EVENT_DEF(mgmt_event,
+				 struct host_event_wlan_mgmt_payload_type);
+	if (!session || !mac_hdr) {
+		pe_err("not valid input");
+		return;
+	}
+	lim_diag_fill_mgmt_event_report(mac_ctx, mac_hdr, session,
+					result_code, reason_code, &mgmt_event);
+
+	pe_debug("TX frame: type:%d sub_type:%d seq_num:%d ssid:%.*s selfmacaddr:%pM bssid:%pM channel:%d",
+		 mgmt_event.mgmt_type, mgmt_event.mgmt_subtype,
+		 ((mac_hdr->seqControl.seqNumHi << 4) |
+				mac_hdr->seqControl.seqNumLo),
+		 mgmt_event.ssid_len, mgmt_event.ssid,
+		 mgmt_event.self_mac_addr, mgmt_event.bssid,
+		 mgmt_event.operating_channel);
+	WLAN_HOST_DIAG_EVENT_REPORT(&mgmt_event, EVENT_WLAN_HOST_MGMT_TX_V2);
+}
+
+void lim_diag_mgmt_rx_event_report(tpAniSirGlobal mac_ctx, void *mgmt_hdr,
+				   tpPESession session, uint16_t result_code,
+				   uint16_t reason_code)
+{
+	tpSirMacMgmtHdr mac_hdr = mgmt_hdr;
+
+	WLAN_HOST_DIAG_EVENT_DEF(mgmt_event,
+				 struct host_event_wlan_mgmt_payload_type);
+	if (!session || !mac_hdr) {
+		pe_err("not valid input");
+		return;
+	}
+	lim_diag_fill_mgmt_event_report(mac_ctx, mac_hdr, session,
+					result_code, reason_code, &mgmt_event);
+	pe_debug("RX frame: type:%d sub_type:%d seq_num:%d ssid:%.*s selfmacaddr:%pM bssid:%pM channel:%d",
+		 mgmt_event.mgmt_type, mgmt_event.mgmt_subtype,
+		 ((mac_hdr->seqControl.seqNumHi << 4) |
+				mac_hdr->seqControl.seqNumLo),
+		 mgmt_event.ssid_len, mgmt_event.ssid,
+		 mgmt_event.self_mac_addr, mgmt_event.bssid,
+		 mgmt_event.operating_channel);
+	WLAN_HOST_DIAG_EVENT_REPORT(&mgmt_event, EVENT_WLAN_HOST_MGMT_RX_V2);
+}
 #endif /* FEATURE_WLAN_DIAG_SUPPORT */
 
 /* Returns length of P2P stream and Pointer ie passed to this function is filled with noa stream */

+ 40 - 0
core/mac/src/pe/lim/lim_utils.h

@@ -679,10 +679,50 @@ typedef enum {
 void lim_diag_event_report(tpAniSirGlobal pMac, uint16_t eventType,
 		tpPESession pSessionEntry, uint16_t status,
 		uint16_t reasonCode);
+/**
+ * lim_diag_mgmt_tx_event_report() - to log TX event to external application
+ * @mac_ctx: mac context
+ * @mgmt_hdr: 802.11 mgmt header of given frame
+ * @session: PE session for given frame
+ * @result_code: result code of to be populated in TX frame
+ * @reason_code: reason code if TX OTA status
+ *
+ * Anytime driver sends some mgmt frame down to firmware for OTA delivery,
+ * log mgmt frame through DIAG utility. Don't log frames which come too
+ * excessively.
+ *
+ * Return: void
+ */
+void lim_diag_mgmt_tx_event_report(tpAniSirGlobal mac_ctx, void *mgmt_hdr,
+		tpPESession session, uint16_t result_code,
+		uint16_t reason_code);
+/**
+ * lim_diag_mgmt_rx_event_report() - to log RX event to external application
+ * @mac_ctx: mac context
+ * @mgmt_hdr: 802.11 mgmt header of given frame
+ * @session: PE session for given frame
+ * @result_code: result code given in RX frame
+ * @reason_code: reason code for RX OTA status
+ *
+ * Anytime driver receives some mgmt frame from firmware OTA,
+ * log mgmt frame through DIAG utility. Don't log frames which come too
+ * excessively.
+ *
+ * Return: void
+ */
+void lim_diag_mgmt_rx_event_report(tpAniSirGlobal mac_ctx, void *mgmt_hdr,
+		tpPESession session, uint16_t result_code,
+		uint16_t reason_code);
 #else
 static inline void lim_diag_event_report(tpAniSirGlobal pMac, uint16_t
 		eventType, tpPESession pSessionEntry, uint16_t status,
 		uint16_t reasonCode) {}
+void lim_diag_mgmt_tx_event_report(tpAniSirGlobal mac_ctx, void *mgmt_hdr,
+		tpPESession session, uint16_t result_code,
+		uint16_t reason_code) {}
+void lim_diag_mgmt_rx_event_report(tpAniSirGlobal mac_ctx, void *mgmt_hdr,
+		tpPESession session, uint16_t result_code,
+		uint16_t reason_code) {}
 #endif /* FEATURE_WLAN_DIAG_SUPPORT */
 
 void pe_set_resume_channel(tpAniSirGlobal pMac, uint16_t channel,