Ver código fonte

qcacmn: Add new apis for High Latency systems (Part 3 - HL Datapath)

Add two new apis of dump bundle stats and clear bundle stats
for debug logging support.

CRs-Fixed: 975526
Change-Id: If8e3bc2bc5e5a4f1b2e180d7d5c4ce0695e933ee
Poddar, Siddarth 9 anos atrás
pai
commit
df030095a3
5 arquivos alterados com 230 adições e 6 exclusões
  1. 91 5
      htc/htc.c
  2. 19 0
      htc/htc_api.h
  3. 7 0
      htc/htc_internal.h
  4. 59 1
      htc/htc_send.c
  5. 54 0
      htc/htc_services.c

+ 91 - 5
htc/htc.c

@@ -145,6 +145,7 @@ static void htc_cleanup(HTC_TARGET *target)
 
 	if (target->hif_dev != NULL) {
 		hif_detach_htc(target->hif_dev);
+		hif_mask_interrupt_call(target->hif_dev);
 		target->hif_dev = NULL;
 	}
 
@@ -352,6 +353,40 @@ void htc_control_tx_complete(void *Context, HTC_PACKET *pPacket)
 /* TODO, this is just a temporary max packet size */
 #define MAX_MESSAGE_SIZE 1536
 
+/**
+ * htc_setup_epping_credit_allocation() - allocate credits/HTC buffers to WMI
+ * @scn: pointer to hif_opaque_softc
+ * @pEntry: pointer to tx credit allocation entry
+ * @credits: number of credits
+ *
+ * Return: None
+ */
+static void
+htc_setup_epping_credit_allocation(struct hif_opaque_softc *scn,
+				   HTC_SERVICE_TX_CREDIT_ALLOCATION *pEntry,
+				   int credits)
+{
+	switch (hif_get_bus_type(scn)) {
+	case QDF_BUS_TYPE_PCI:
+		pEntry++;
+		pEntry->service_id = WMI_DATA_BE_SVC;
+		pEntry->CreditAllocation = (credits >> 1);
+
+		pEntry++;
+		pEntry->service_id = WMI_DATA_BK_SVC;
+		pEntry->CreditAllocation = (credits >> 1);
+		break;
+	case QDF_BUS_TYPE_SDIO:
+		pEntry++;
+		pEntry->service_id = WMI_DATA_BE_SVC;
+		pEntry->CreditAllocation = credits;
+		break;
+	default:
+		break;
+	}
+	return;
+}
+
 /**
  * htc_setup_target_buffer_assignments() - setup target buffer assignments
  * @target: HTC Target Pointer
@@ -409,12 +444,9 @@ A_STATUS htc_setup_target_buffer_assignments(HTC_TARGET *target)
 		 * BE and BK services to stress the bus so that the total credits
 		 * are equally distributed to BE and BK services.
 		 */
-		pEntry->service_id = WMI_DATA_BE_SVC;
-		pEntry->CreditAllocation = (credits >> 1);
 
-		pEntry++;
-		pEntry->service_id = WMI_DATA_BK_SVC;
-		pEntry->CreditAllocation = (credits >> 1);
+		htc_setup_epping_credit_allocation(target->hif_dev,
+						   pEntry, credits);
 	}
 
 	if (A_SUCCESS(status)) {
@@ -846,6 +878,60 @@ void htc_ipa_get_ce_resource(HTC_HANDLE htc_handle,
 }
 #endif /* IPA_OFFLOAD */
 
+#if defined(DEBUG_HL_LOGGING) && defined(CONFIG_HL_SUPPORT)
+
+void htc_dump_bundle_stats(HTC_HANDLE HTCHandle)
+{
+	HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle);
+	int total, i;
+
+	total = 0;
+	for (i = 0; i < HTC_MAX_MSG_PER_BUNDLE_RX; i++)
+		total += target->rx_bundle_stats[i];
+
+	if (total) {
+		AR_DEBUG_PRINTF(ATH_DEBUG_ANY, ("RX Bundle stats:\n"));
+		AR_DEBUG_PRINTF(ATH_DEBUG_ANY, ("Total RX packets: %d\n",
+						total));
+		AR_DEBUG_PRINTF(ATH_DEBUG_ANY, (
+				"Number of bundle: Number of packets\n"));
+		for (i = 0; i < HTC_MAX_MSG_PER_BUNDLE_RX; i++)
+			AR_DEBUG_PRINTF(ATH_DEBUG_ANY,
+					("%10d:%10d(%2d%s)\n", (i+1),
+					 target->rx_bundle_stats[i],
+					 ((target->rx_bundle_stats[i]*100)/
+					  total), "%"));
+	}
+
+
+	total = 0;
+	for (i = 0; i < HTC_MAX_MSG_PER_BUNDLE_TX; i++)
+		total += target->tx_bundle_stats[i];
+
+	if (total) {
+		AR_DEBUG_PRINTF(ATH_DEBUG_ANY, ("TX Bundle stats:\n"));
+		AR_DEBUG_PRINTF(ATH_DEBUG_ANY, ("Total TX packets: %d\n",
+						total));
+		AR_DEBUG_PRINTF(ATH_DEBUG_ANY,
+				("Number of bundle: Number of packets\n"));
+		for (i = 0; i < HTC_MAX_MSG_PER_BUNDLE_TX; i++)
+			AR_DEBUG_PRINTF(ATH_DEBUG_ANY,
+					("%10d:%10d(%2d%s)\n", (i+1),
+					 target->tx_bundle_stats[i],
+					 ((target->tx_bundle_stats[i]*100)/
+					  total), "%"));
+	}
+}
+
+void htc_clear_bundle_stats(HTC_HANDLE HTCHandle)
+{
+	HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle);
+
+	qdf_mem_zero(&target->rx_bundle_stats, sizeof(target->rx_bundle_stats));
+	qdf_mem_zero(&target->tx_bundle_stats, sizeof(target->tx_bundle_stats));
+}
+#endif
+
 /**
  * htc_vote_link_down - API to vote for link down
  * @htc_handle: HTC handle

+ 19 - 0
htc/htc_api.h

@@ -730,4 +730,23 @@ void htc_ipa_get_ce_resource(HTC_HANDLE htc_handle,
 			ce_reg_paddr)                      /* NO-OP */
 #endif /* IPA_OFFLOAD */
 
+#if defined(DEBUG_HL_LOGGING) && defined(CONFIG_HL_SUPPORT)
+
+/**
+ * htc_dump_bundle_stats() - dump tx and rx htc message bundle stats
+ * @HTCHandle: htc handle
+ *
+ * Return: None
+ */
+void htc_dump_bundle_stats(HTC_HANDLE HTCHandle);
+
+/**
+ * htc_clear_bundle_stats() - clear tx and rx htc message bundle stats
+ * @HTCHandle: htc handle
+ *
+ * Return: None
+ */
+void htc_clear_bundle_stats(HTC_HANDLE HTCHandle);
+#endif
+
 #endif /* _HTC_API_H_ */

+ 7 - 0
htc/htc_internal.h

@@ -56,6 +56,7 @@ extern "C" {
 #define HTC_MAX_MSG_PER_BUNDLE              16
 #define HTC_MAX_MSG_PER_BUNDLE_TX           32
 #endif
+
 /*
  * HTC_MAX_TX_BUNDLE_SEND_LIMIT -
  * This value is in units of tx frame fragments.
@@ -188,10 +189,16 @@ typedef struct _HTC_TARGET {
 	uint32_t TX_comp_cnt;
 	uint8_t MaxMsgsPerHTCBundle;
 	qdf_work_t queue_kicker;
+
+#ifdef HIF_SDIO
+	A_UINT16 AltDataCreditSize;
+#endif
+
 #if defined(DEBUG_HL_LOGGING) && defined(CONFIG_HL_SUPPORT)
 	A_UINT32 rx_bundle_stats[HTC_MAX_MSG_PER_BUNDLE_RX];
 	A_UINT32 tx_bundle_stats[HTC_MAX_MSG_PER_BUNDLE_TX];
 #endif
+
 	uint32_t con_mode;
 } HTC_TARGET;
 

+ 59 - 1
htc/htc_send.c

@@ -298,6 +298,57 @@ void free_htc_bundle_packet(HTC_TARGET *target, HTC_PACKET *pPacket)
 	UNLOCK_HTC_TX(target);
 }
 
+#if defined(DEBUG_HL_LOGGING) && defined(CONFIG_HL_SUPPORT)
+
+/**
+ * htc_send_update_tx_bundle_stats() - update tx bundle stats depends
+ *				on max bundle size
+ * @target: hif context
+ * @data_len: tx data len
+ * @TxCreditSize: endpoint tx credit size
+ *
+ * Return: None
+ */
+static inline void
+htc_send_update_tx_bundle_stats(HTC_TARGET *target,
+				qdf_size_t data_len,
+				int TxCreditSize)
+{
+	if ((data_len / TxCreditSize) <= HTC_MAX_MSG_PER_BUNDLE_TX)
+		target->tx_bundle_stats[(data_len / TxCreditSize) - 1]++;
+
+	return;
+}
+
+/**
+ * htc_issue_tx_bundle_stats_inc() - increment in tx bundle stats
+ *				on max bundle size
+ * @target: hif context
+ *
+ * Return: None
+ */
+static inline void
+htc_issue_tx_bundle_stats_inc(HTC_TARGET *target)
+{
+	target->tx_bundle_stats[0]++;
+}
+#else
+
+static inline void
+htc_send_update_tx_bundle_stats(HTC_TARGET *target,
+				qdf_size_t data_len,
+				int TxCreditSize)
+{
+	return;
+}
+
+static inline void
+htc_issue_tx_bundle_stats_inc(HTC_TARGET *target)
+{
+	return;
+}
+#endif
+
 #if defined(HIF_USB) || defined(HIF_SDIO)
 #ifdef ENABLE_BUNDLE_TX
 static A_STATUS htc_send_bundled_netbuf(HTC_TARGET *target,
@@ -327,6 +378,10 @@ static A_STATUS htc_send_bundled_netbuf(HTC_TARGET *target,
 		  pEndpoint->TxCreditSize,
 		  data_len, data_len / pEndpoint->TxCreditSize);
 #endif
+
+	htc_send_update_tx_bundle_stats(target, data_len,
+					pEndpoint->TxCreditSize);
+
 	status = hif_send_head(target->hif_dev,
 			       pEndpoint->UL_PipeID,
 			       pEndpoint->Id, data_len,
@@ -543,6 +598,7 @@ static A_STATUS htc_issue_packets(HTC_TARGET *target,
 			  pEndpoint->TxCreditSize,
 			  HTC_HDR_LENGTH + pPacket->ActualLength);
 #endif
+		htc_issue_tx_bundle_stats_inc(target);
 
 		target->ce_send_cnt++;
 
@@ -1585,6 +1641,8 @@ A_STATUS htc_send_data_pkt(HTC_HANDLE HTCHandle, HTC_PACKET *pPacket,
 			  HTC_HDR_LENGTH + pPacket->ActualLength);
 #endif
 
+		htc_issue_tx_bundle_stats_inc(target);
+
 		if (qdf_unlikely(A_FAILED(status))) {
 			LOCK_HTC_TX(target);
 			pEndpoint->ul_outstanding_cnt--;
@@ -1759,7 +1817,7 @@ QDF_STATUS htc_tx_completion_handler(void *Context,
 	return QDF_STATUS_SUCCESS;
 }
 
-#if WLAN_FEATURE_FASTPATH
+#ifdef WLAN_FEATURE_FASTPATH
 /**
  * htc_ctrl_msg_cmpl(): checks for tx completion for the endpoint specified
  * @HTC_HANDLE : pointer to the htc target context

+ 54 - 0
htc/htc_services.c

@@ -48,6 +48,55 @@ void htc_global_credit_flow_enable(void)
 	htc_credit_flow = 1;
 }
 
+#ifdef HIF_SDIO
+
+/**
+ * htc_alt_data_credit_size_update() - update tx credit size info
+ *				on max bundle size
+ * @target: hif context
+ * @ul_pipe: endpoint ul pipe id
+ * @dl_pipe: endpoint dl pipe id
+ * @txCreditSize: endpoint tx credit size
+ *
+ *
+ * When AltDataCreditSize is non zero, it indicates the credit size for
+ * HTT and all other services on Mbox0. Mbox1 has WMI_CONTROL_SVC which
+ * uses the default credit size. Use AltDataCreditSize only when
+ * mailbox is swapped. Mailbox swap bit is set by bmi_target_ready at
+ * the end of BMI phase.
+ *
+ * The Credit Size is a parameter associated with the mbox rather than
+ * a service. Multiple services can run on this mbox.
+ *
+ * If AltDataCreditSize is 0, that means the firmware doesn't support
+ * this feature. Default to the TargetCreditSize
+ *
+ * Return: None
+ */
+static inline void
+htc_alt_data_credit_size_update(HTC_TARGET *target,
+				uint8_t *ul_pipe,
+				uint8_t *dl_pipe,
+				int *txCreditSize)
+{
+	if ((target->AltDataCreditSize) &&
+	    (*ul_pipe == 1) && (*dl_pipe == 0))
+		*txCreditSize = target->AltDataCreditSize;
+
+	return;
+}
+#else
+
+static inline void
+htc_alt_data_credit_size_update(HTC_TARGET *target,
+				uint8_t *ul_pipe,
+				uint8_t *dl_pipe,
+				int *txCreditSize)
+{
+	return;
+}
+#endif
+
 A_STATUS htc_connect_service(HTC_HANDLE HTCHandle,
 			     HTC_SERVICE_CONNECT_REQ *pConnectReq,
 			     HTC_SERVICE_CONNECT_RESP *pConnectResp)
@@ -319,6 +368,11 @@ A_STATUS htc_connect_service(HTC_HANDLE HTCHandle,
 			break;
 		}
 
+		htc_alt_data_credit_size_update(target,
+						&pEndpoint->UL_PipeID,
+						&pEndpoint->DL_PipeID,
+						&pEndpoint->TxCreditSize);
+
 		qdf_assert(!pEndpoint->dl_is_polled);   /* not currently supported */
 
 		if (pEndpoint->ul_is_polled) {