Jelajahi Sumber

qcacmn: Fix kernel module check patch warnings

Fix kernel module check patch warnings in Host Target Communication
module files

Change-Id: I151f597142d93a26e5e037cf7fce944f86fba72a
CRs-fixed: 2033001
Manikandan Mohan 8 tahun lalu
induk
melakukan
e3e209e1fd
9 mengubah file dengan 1065 tambahan dan 984 penghapusan
  1. 32 32
      htc/dl_list.h
  2. 59 57
      htc/htc.c
  3. 526 499
      htc/htc_api.h
  4. 66 53
      htc/htc_internal.h
  5. 89 55
      htc/htc_packet.h
  6. 44 65
      htc/htc_recv.c
  7. 216 190
      htc/htc_send.c
  8. 31 31
      htc/htc_services.c
  9. 2 2
      wmi/src/wmi_unified.c

+ 32 - 32
htc/dl_list.h

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2014 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2014, 2017 The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -25,17 +25,18 @@
  * to the Linux Foundation.
  */
 
-/* ============================================================================== */
+/*=========================================================================== */
 /* Double-link list definitions (adapted from Atheros SDIO stack) */
 /* */
 /* Author(s): ="Atheros" */
-/* ============================================================================== */
+/*=========================================================================== */
 
 #ifndef __DL_LIST_H___
 #define __DL_LIST_H___
 
 #define A_CONTAINING_STRUCT(address, struct_type, field_name) \
-	((struct_type *)((char *)(address) - (char *)(&((struct_type *)0)->field_name)))
+			((struct_type *)((char *)(address) - \
+				 (char *)(&((struct_type *)0)->field_name)))
 
 /* list functions */
 /* pointers for the list */
@@ -50,14 +51,15 @@ typedef struct _DL_LIST {
 	{(pList)->pPrev = pList; (pList)->pNext = pList; }
 
 /* faster macro to init list and add a single item */
-#define DL_LIST_INIT_AND_ADD(pList,pItem) \
+#define DL_LIST_INIT_AND_ADD(pList, pItem) \
 	{   (pList)->pPrev = (pItem); \
 	    (pList)->pNext = (pItem); \
 	    (pItem)->pNext = (pList); \
 	    (pItem)->pPrev = (pList); \
 	}
 
-#define DL_LIST_IS_EMPTY(pList) (((pList)->pPrev == (pList)) && ((pList)->pNext == (pList)))
+#define DL_LIST_IS_EMPTY(pList) (((pList)->pPrev == (pList)) && \
+				((pList)->pNext == (pList)))
 #define DL_LIST_GET_ITEM_AT_HEAD(pList) (pList)->pNext
 #define DL_LIST_GET_ITEM_AT_TAIL(pList) (pList)->pPrev
 /*
@@ -66,9 +68,10 @@ typedef struct _DL_LIST {
  * iteration loop
  */
 #define ITERATE_OVER_LIST(pStart, pTemp) \
-	for((pTemp) =(pStart)->pNext; pTemp != (pStart); (pTemp) = (pTemp)->pNext)
+		for ((pTemp) = (pStart)->pNext; pTemp != (pStart); \
+					(pTemp) = (pTemp)->pNext)
 
-static __inline bool dl_list_is_entry_in_list(const DL_LIST *pList,
+static inline bool dl_list_is_entry_in_list(const DL_LIST *pList,
 					      const DL_LIST *pEntry)
 {
 	const DL_LIST *pTmp;
@@ -77,9 +80,8 @@ static __inline bool dl_list_is_entry_in_list(const DL_LIST *pList,
 		return true;
 
 	ITERATE_OVER_LIST(pList, pTmp) {
-		if (pTmp == pEntry) {
+		if (pTmp == pEntry)
 			return true;
-		}
 	}
 
 	return false;
@@ -88,30 +90,29 @@ static __inline bool dl_list_is_entry_in_list(const DL_LIST *pList,
 /* safe iterate macro that allows the item to be removed from the list
  * the iteration continues to the next item in the list
  */
-#define ITERATE_OVER_LIST_ALLOW_REMOVE(pStart,pItem,st,offset)	\
+#define ITERATE_OVER_LIST_ALLOW_REMOVE(pStart, pItem, st, offset) \
 	{							\
 		PDL_LIST pTemp;					    \
-		pTemp = (pStart)->pNext;			    \
+		{ pTemp = (pStart)->pNext; }			    \
 		while (pTemp != (pStart)) {			    \
-			(pItem) = A_CONTAINING_STRUCT(pTemp,st,offset);	  \
-			pTemp = pTemp->pNext;			       \
+			{ (pItem) = A_CONTAINING_STRUCT(pTemp, st, offset); } \
+			{ pTemp = pTemp->pNext; }			       \
 
 #define ITERATE_IS_VALID(pStart)    dl_list_is_entry_in_list(pStart, pTemp)
-#define ITERATE_RESET(pStart)       pTemp=(pStart)->pNext
+#define ITERATE_RESET(pStart) { pTemp = (pStart)->pNext; }
 
 #define ITERATE_END }}
 
 /*
  * dl_list_insert_tail - insert pAdd to the end of the list
  */
-static __inline PDL_LIST dl_list_insert_tail(PDL_LIST pList, PDL_LIST pAdd)
+static inline PDL_LIST dl_list_insert_tail(PDL_LIST pList, PDL_LIST pAdd)
 {
 	/* insert at tail */
 	pAdd->pPrev = pList->pPrev;
 	pAdd->pNext = pList;
-	if (pList->pPrev) {
+	if (pList->pPrev)
 		pList->pPrev->pNext = pAdd;
-	}
 	pList->pPrev = pAdd;
 	return pAdd;
 }
@@ -119,7 +120,7 @@ static __inline PDL_LIST dl_list_insert_tail(PDL_LIST pList, PDL_LIST pAdd)
 /*
  * dl_list_insert_head - insert pAdd into the head of the list
  */
-static __inline PDL_LIST dl_list_insert_head(PDL_LIST pList, PDL_LIST pAdd)
+static inline PDL_LIST dl_list_insert_head(PDL_LIST pList, PDL_LIST pAdd)
 {
 	/* insert at head */
 	pAdd->pPrev = pList;
@@ -129,20 +130,17 @@ static __inline PDL_LIST dl_list_insert_head(PDL_LIST pList, PDL_LIST pAdd)
 	return pAdd;
 }
 
-#define DL_ListAdd(pList,pItem) dl_list_insert_head((pList),(pItem))
+#define DL_ListAdd(pList, pItem) dl_list_insert_head((pList), (pItem))
 /*
  * dl_list_remove - remove pDel from list
  */
-static __inline PDL_LIST dl_list_remove(PDL_LIST pDel)
+static inline PDL_LIST dl_list_remove(PDL_LIST pDel)
 {
-	if (pDel->pNext != NULL) {
+	if (pDel->pNext != NULL)
 		pDel->pNext->pPrev = pDel->pPrev;
-	}
-	if (pDel->pPrev != NULL) {
+	if (pDel->pPrev != NULL)
 		pDel->pPrev->pNext = pDel->pNext;
-	}
-
-	/* point back to itself just to be safe, incase remove is called again */
+	/* point back to itself just to be safe, if remove is called again */
 	pDel->pNext = pDel;
 	pDel->pPrev = pDel;
 	return pDel;
@@ -151,9 +149,10 @@ static __inline PDL_LIST dl_list_remove(PDL_LIST pDel)
 /*
  * dl_list_remove_item_from_head - get a list item from the head
  */
-static __inline PDL_LIST dl_list_remove_item_from_head(PDL_LIST pList)
+static inline PDL_LIST dl_list_remove_item_from_head(PDL_LIST pList)
 {
 	PDL_LIST pItem = NULL;
+
 	if (pList->pNext != pList) {
 		pItem = pList->pNext;
 		/* remove the first item from head */
@@ -162,9 +161,10 @@ static __inline PDL_LIST dl_list_remove_item_from_head(PDL_LIST pList)
 	return pItem;
 }
 
-static __inline PDL_LIST dl_list_remove_item_from_tail(PDL_LIST pList)
+static inline PDL_LIST dl_list_remove_item_from_tail(PDL_LIST pList)
 {
 	PDL_LIST pItem = NULL;
+
 	if (pList->pPrev != pList) {
 		pItem = pList->pPrev;
 		/* remove the item from tail */
@@ -174,7 +174,7 @@ static __inline PDL_LIST dl_list_remove_item_from_tail(PDL_LIST pList)
 }
 
 /* transfer src list items to the tail of the destination list */
-static __inline void dl_list_transfer_items_to_tail(PDL_LIST pDest, PDL_LIST pSrc)
+static inline void dl_list_transfer_items_to_tail(PDL_LIST pDest, PDL_LIST pSrc)
 {
 	/* only concatenate if src is not empty */
 	if (!DL_LIST_IS_EMPTY(pSrc)) {
@@ -190,11 +190,11 @@ static __inline void dl_list_transfer_items_to_tail(PDL_LIST pDest, PDL_LIST pSr
 }
 
 /* transfer src list items to the head of the destination list */
-static __inline void dl_list_transfer_items_to_head(PDL_LIST pDest, PDL_LIST pSrc)
+static inline void dl_list_transfer_items_to_head(PDL_LIST pDest, PDL_LIST pSrc)
 {
 	/* only concatenate if src is not empty */
 	if (!DL_LIST_IS_EMPTY(pSrc)) {
-		/* cut out circular list in src and re-attach to start of dest */
+		/* cut out circular list in src and reattach to start of dest */
 		pSrc->pNext->pPrev = pDest;
 		pDest->pNext->pPrev = pSrc->pPrev;
 		pSrc->pPrev->pNext = pDest->pNext;

+ 59 - 57
htc/htc.c

@@ -60,12 +60,11 @@ static void reset_endpoint_states(HTC_TARGET *target);
 static void destroy_htc_tx_ctrl_packet(HTC_PACKET *pPacket)
 {
 	qdf_nbuf_t netbuf;
+
 	netbuf = (qdf_nbuf_t) GET_HTC_PACKET_NET_BUF_CONTEXT(pPacket);
 	AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("free ctrl netbuf :0x%p\n", netbuf));
-	if (netbuf != NULL) {
+	if (netbuf != NULL)
 		qdf_nbuf_free(netbuf);
-	}
-
 	qdf_mem_free(pPacket);
 }
 
@@ -76,9 +75,8 @@ static HTC_PACKET *build_htc_tx_ctrl_packet(qdf_device_t osdev)
 
 	do {
 		pPacket = (HTC_PACKET *) qdf_mem_malloc(sizeof(HTC_PACKET));
-		if (NULL == pPacket) {
+		if (pPacket == NULL)
 			break;
-		}
 		netbuf = qdf_nbuf_alloc(osdev, HTC_CONTROL_BUFFER_SIZE,
 					20, 4, true);
 		if (NULL == netbuf) {
@@ -88,7 +86,7 @@ static HTC_PACKET *build_htc_tx_ctrl_packet(qdf_device_t osdev)
 			break;
 		}
 		AR_DEBUG_PRINTF(ATH_DEBUG_TRC,
-				("alloc ctrl netbuf :0x%p \n", netbuf));
+				("alloc ctrl netbuf :0x%p\n", netbuf));
 		SET_HTC_PACKET_NET_BUF_CONTEXT(pPacket, netbuf);
 	} while (false);
 
@@ -129,12 +127,14 @@ void htc_set_target_failure_callback(HTC_HANDLE HTCHandle,
 				     HTC_TARGET_FAILURE Callback)
 {
 	HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle);
+
 	target->HTCInitInfo.TargetFailure = Callback;
 }
 
 void htc_dump(HTC_HANDLE HTCHandle, uint8_t CmdId, bool start)
 {
 	HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle);
+
 	hif_dump(target->hif_dev, CmdId, start);
 }
 
@@ -152,29 +152,26 @@ static void htc_cleanup(HTC_TARGET *target)
 
 	while (true) {
 		pPacket = allocate_htc_packet_container(target);
-		if (NULL == pPacket) {
+		if (pPacket == NULL)
 			break;
-		}
 		qdf_mem_free(pPacket);
 	}
 
 	pPacket = target->pBundleFreeList;
 	while (pPacket) {
 		HTC_PACKET *pPacketTmp = (HTC_PACKET *) pPacket->ListLink.pNext;
+
 		qdf_mem_free(pPacket);
 		pPacket = pPacketTmp;
 	}
 #ifdef TODO_FIXME
 	while (true) {
 		pPacket = htc_alloc_control_tx_packet(target);
-		if (NULL == pPacket) {
+		if (pPacket == NULL)
 			break;
-		}
 		netbuf = (qdf_nbuf_t) GET_HTC_PACKET_NET_BUF_CONTEXT(pPacket);
-		if (netbuf != NULL) {
+		if (netbuf != NULL)
 			qdf_nbuf_free(netbuf);
-		}
-
 		qdf_mem_free(pPacket);
 	}
 #endif
@@ -238,8 +235,8 @@ static inline void htc_runtime_pm_init(HTC_TARGET *target) { }
 #endif
 
 /* registered target arrival callback from the HIF layer */
-HTC_HANDLE htc_create(void *ol_sc, HTC_INIT_INFO *pInfo, qdf_device_t osdev,
-		      uint32_t con_mode)
+HTC_HANDLE htc_create(void *ol_sc, struct htc_init_info *pInfo,
+			qdf_device_t osdev, uint32_t con_mode)
 {
 	struct hif_msg_callbacks htcCallbacks;
 	HTC_ENDPOINT *pEndpoint = NULL;
@@ -270,7 +267,7 @@ HTC_HANDLE htc_create(void *ol_sc, HTC_INIT_INFO *pInfo, qdf_device_t osdev,
 
 	do {
 		qdf_mem_copy(&target->HTCInitInfo, pInfo,
-			     sizeof(HTC_INIT_INFO));
+			     sizeof(struct htc_init_info));
 		target->host_handle = pInfo->pContext;
 		target->osdev = osdev;
 		target->con_mode = con_mode;
@@ -280,19 +277,17 @@ HTC_HANDLE htc_create(void *ol_sc, HTC_INIT_INFO *pInfo, qdf_device_t osdev,
 		INIT_HTC_PACKET_QUEUE(&target->ControlBufferTXFreeList);
 
 		for (i = 0; i < HTC_PACKET_CONTAINER_ALLOCATION; i++) {
-			HTC_PACKET *pPacket =
-				(HTC_PACKET *) qdf_mem_malloc(sizeof(HTC_PACKET));
-			if (pPacket != NULL) {
+			HTC_PACKET *pPacket = (HTC_PACKET *)
+					qdf_mem_malloc(sizeof(HTC_PACKET));
+			if (pPacket != NULL)
 				free_htc_packet_container(target, pPacket);
-			}
 		}
 
 #ifdef TODO_FIXME
 		for (i = 0; i < NUM_CONTROL_TX_BUFFERS; i++) {
 			pPacket = build_htc_tx_ctrl_packet();
-			if (NULL == pPacket) {
+			if (pPacket == NULL)
 				break;
-			}
 			htc_free_control_tx_packet(target, pPacket);
 		}
 #endif
@@ -302,7 +297,8 @@ HTC_HANDLE htc_create(void *ol_sc, HTC_INIT_INFO *pInfo, qdf_device_t osdev,
 		htcCallbacks.Context = target;
 		htcCallbacks.rxCompletionHandler = htc_rx_completion_handler;
 		htcCallbacks.txCompletionHandler = htc_tx_completion_handler;
-		htcCallbacks.txResourceAvailHandler = htc_tx_resource_avail_handler;
+		htcCallbacks.txResourceAvailHandler =
+						 htc_tx_resource_avail_handler;
 		htcCallbacks.fwEventHandler = htc_fw_event_handler;
 		target->hif_dev = ol_sc;
 
@@ -325,6 +321,7 @@ HTC_HANDLE htc_create(void *ol_sc, HTC_INIT_INFO *pInfo, qdf_device_t osdev,
 void htc_destroy(HTC_HANDLE HTCHandle)
 {
 	HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle);
+
 	AR_DEBUG_PRINTF(ATH_DEBUG_TRC,
 			("+htc_destroy ..  Destroying :0x%p\n", target));
 	hif_stop(htc_get_hif_device(HTCHandle));
@@ -333,19 +330,22 @@ void htc_destroy(HTC_HANDLE HTCHandle)
 	AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("-htc_destroy\n"));
 }
 
-/* get the low level HIF device for the caller , the caller may wish to do low level
- * HIF requests */
+/* get the low level HIF device for the caller , the caller may wish to do low
+ * level HIF requests
+ */
 void *htc_get_hif_device(HTC_HANDLE HTCHandle)
 {
 	HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle);
+
 	return target->hif_dev;
 }
 
 static void htc_control_tx_complete(void *Context, HTC_PACKET *pPacket)
 {
 	HTC_TARGET *target = (HTC_TARGET *) Context;
+
 	AR_DEBUG_PRINTF(ATH_DEBUG_TRC,
-			("+-htc_control_tx_complete 0x%p (l:%d) \n", pPacket,
+			("+-htc_control_tx_complete 0x%p (l:%d)\n", pPacket,
 			 pPacket->ActualLength));
 	htc_free_control_tx_packet(target, pPacket);
 }
@@ -363,8 +363,8 @@ static void htc_control_tx_complete(void *Context, HTC_PACKET *pPacket)
  */
 static void
 htc_setup_epping_credit_allocation(struct hif_opaque_softc *scn,
-				   HTC_SERVICE_TX_CREDIT_ALLOCATION *pEntry,
-				   int credits)
+			   struct htc_service_tx_credit_allocation *pEntry,
+			   int credits)
 {
 	switch (hif_get_bus_type(scn)) {
 	case QDF_BUS_TYPE_PCI:
@@ -384,7 +384,6 @@ htc_setup_epping_credit_allocation(struct hif_opaque_softc *scn,
 	default:
 		break;
 	}
-	return;
 }
 
 /**
@@ -396,15 +395,14 @@ htc_setup_epping_credit_allocation(struct hif_opaque_softc *scn,
 static
 A_STATUS htc_setup_target_buffer_assignments(HTC_TARGET *target)
 {
-	HTC_SERVICE_TX_CREDIT_ALLOCATION *pEntry;
+	struct htc_service_tx_credit_allocation *pEntry;
 	A_STATUS status;
 	int credits;
 	int creditsPerMaxMsg;
 
 	creditsPerMaxMsg = MAX_MESSAGE_SIZE / target->TargetCreditSize;
-	if (MAX_MESSAGE_SIZE % target->TargetCreditSize) {
+	if (MAX_MESSAGE_SIZE % target->TargetCreditSize)
 		creditsPerMaxMsg++;
-	}
 
 	/* TODO, this should be configured by the caller! */
 
@@ -423,7 +421,7 @@ A_STATUS htc_setup_target_buffer_assignments(HTC_TARGET *target)
 		pEntry->CreditAllocation = credits;
 		/* endpoint ping is a testing tool directly on top of HTC in
 		 * both target and host sides.
-		 * In target side, the endppint ping fw has no wlan stack and the
+		 * In target side, the endppint ping fw has no wlan stack and
 		 * FW mboxping app directly sits on HTC and it simply drops
 		 * or loops back TX packets. For rx perf, FW mboxping app
 		 * generates packets and passes packets to HTC to send to host.
@@ -440,9 +438,9 @@ A_STATUS htc_setup_target_buffer_assignments(HTC_TARGET *target)
 		 * space through the Ethernet interface.
 		 * For credit allocation, in SDIO bus case, only BE service is
 		 * used for tx/rx perf testing so that all credits are given
-		 * to BE service. In PCIe and USB bus case, endpoint ping uses both
-		 * BE and BK services to stress the bus so that the total credits
-		 * are equally distributed to BE and BK services.
+		 * to BE service. In PCIe and USB bus case, endpoint ping uses
+		 * both BE and BK services to stress the bus so that the total
+		 * credits are equally distributed to BE and BK services.
 		 */
 
 		htc_setup_epping_credit_allocation(target->hif_dev,
@@ -471,6 +469,7 @@ A_STATUS htc_setup_target_buffer_assignments(HTC_TARGET *target)
 
 	if (A_SUCCESS(status)) {
 		int i;
+
 		for (i = 0; i < HTC_MAX_SERVICE_ALLOC_ENTRIES; i++) {
 			if (target->ServiceTxAllocTable[i].service_id != 0) {
 				AR_DEBUG_PRINTF(ATH_DEBUG_INIT,
@@ -513,8 +512,8 @@ A_STATUS htc_wait_target(HTC_HANDLE HTCHandle)
 	A_STATUS status = A_OK;
 	HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle);
 	HTC_READY_EX_MSG *pReadyMsg;
-	HTC_SERVICE_CONNECT_REQ connect;
-	HTC_SERVICE_CONNECT_RESP resp;
+	struct htc_service_connect_req connect;
+	struct htc_service_connect_resp resp;
 	HTC_READY_MSG *rdy_msg;
 	uint16_t htc_rdy_msg_id;
 	uint8_t i = 0;
@@ -528,19 +527,19 @@ A_STATUS htc_wait_target(HTC_HANDLE HTCHandle)
 
 		status = hif_start(target->hif_dev);
 		if (A_FAILED(status)) {
-			AR_DEBUG_PRINTF(ATH_DEBUG_ERROR, ("hif_start failed\n"));
+			AR_DEBUG_PRINTF(ATH_DEBUG_ERROR,
+					("hif_start failed\n"));
 			break;
 		}
 
 		status = htc_wait_recv_ctrl_message(target);
 
-		if (A_FAILED(status)) {
+		if (A_FAILED(status))
 			break;
-		}
 
 		if (target->CtrlResponseLength < (sizeof(HTC_READY_EX_MSG))) {
 			AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
-					("Invalid HTC Ready Msg Len:%d! \n",
+					("Invalid HTC Ready Msg Len:%d!\n",
 					 target->CtrlResponseLength));
 			status = A_ECOMM;
 			break;
@@ -553,7 +552,7 @@ A_STATUS htc_wait_target(HTC_HANDLE HTCHandle)
 			HTC_GET_FIELD(rdy_msg, HTC_READY_MSG, MESSAGEID);
 		if (htc_rdy_msg_id != HTC_MSG_READY_ID) {
 			AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
-					("Invalid HTC Ready Msg : 0x%X ! \n",
+					("Invalid HTC Ready Msg : 0x%X!\n",
 					 htc_rdy_msg_id));
 			status = A_ECOMM;
 			break;
@@ -565,8 +564,9 @@ A_STATUS htc_wait_target(HTC_HANDLE HTCHandle)
 			(int)HTC_GET_FIELD(rdy_msg, HTC_READY_MSG, CREDITSIZE);
 		target->MaxMsgsPerHTCBundle =
 			(uint8_t) pReadyMsg->MaxMsgsPerHTCBundle;
-		/* for old fw this value is set to 0. But the minimum value should be 1,
-		 * i.e., no bundling */
+		/* for old fw this value is set to 0. But the minimum value
+		 * should be 1, i.e., no bundling
+		 */
 		if (target->MaxMsgsPerHTCBundle < 1)
 			target->MaxMsgsPerHTCBundle = 1;
 
@@ -619,7 +619,8 @@ A_STATUS htc_wait_target(HTC_HANDLE HTCHandle)
 
 	} while (false);
 
-	AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("htc_wait_target - Exit (%d)\n", status));
+	AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("htc_wait_target - Exit (%d)\n",
+			status));
 	AR_DEBUG_PRINTF(ATH_DEBUG_ANY, ("-HWT\n"));
 	return status;
 }
@@ -703,7 +704,8 @@ A_STATUS htc_start(HTC_HANDLE HTCHandle)
 		}
 
 		if ((hif_get_bus_type(target->hif_dev) == QDF_BUS_TYPE_SDIO) ||
-			(hif_get_bus_type(target->hif_dev) == QDF_BUS_TYPE_USB)) {
+					(hif_get_bus_type(target->hif_dev) ==
+							 QDF_BUS_TYPE_USB)) {
 			if (HTC_RX_BUNDLE_ENABLED(target))
 			pSetupComp->SetupFlags |=
 				HTC_SETUP_COMPLETE_FLAGS_ENABLE_BUNDLE_RECV;
@@ -718,10 +720,8 @@ A_STATUS htc_start(HTC_HANDLE HTCHandle)
 				       ENDPOINT_0, HTC_SERVICE_TX_PACKET_TAG);
 
 		status = htc_send_pkt((HTC_HANDLE) target, pSendPacket);
-		if (A_FAILED(status)) {
+		if (A_FAILED(status))
 			break;
-		}
-
 	} while (false);
 
 	AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("htc_start Exit\n"));
@@ -760,10 +760,12 @@ void htc_flush_surprise_remove(HTC_HANDLE HTCHandle)
 
 	reset_endpoint_states(target);
 
-	AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("-htc_flush_surprise_remove \n"));
+	AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("-htc_flush_surprise_remove\n"));
 }
 
-/* stop HTC communications, i.e. stop interrupt reception, and flush all queued buffers */
+/* stop HTC communications, i.e. stop interrupt reception, and flush all queued
+ * buffers
+ */
 void htc_stop(HTC_HANDLE HTCHandle)
 {
 	HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle);
@@ -836,14 +838,14 @@ void htc_dump_credit_states(HTC_HANDLE HTCHandle)
 				(" TxQueueDepth       : %d\n",
 				 HTC_PACKET_QUEUE_DEPTH(&pEndpoint->TxQueue)));
 		AR_DEBUG_PRINTF(ATH_DEBUG_ANY,
-				("----------------------------------------------------\n"));
+				("----------------------------------------\n"));
 	}
 }
 
 bool htc_get_endpoint_statistics(HTC_HANDLE HTCHandle,
 				   HTC_ENDPOINT_ID Endpoint,
-				   HTC_ENDPOINT_STAT_ACTION Action,
-				   HTC_ENDPOINT_STATS *pStats)
+				   enum htc_endpoint_stat_action Action,
+				   struct htc_endpoint_stats *pStats)
 {
 #ifdef HTC_EP_STAT_PROFILING
 	HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle);
@@ -875,13 +877,13 @@ bool htc_get_endpoint_statistics(HTC_HANDLE HTCHandle,
 		A_ASSERT(pStats != NULL);
 		/* return the stats to the caller */
 		qdf_mem_copy(pStats, &target->endpoint[Endpoint].endpoint_stats,
-			 sizeof(HTC_ENDPOINT_STATS));
+			 sizeof(struct htc_endpoint_stats));
 	}
 
 	if (clearStats) {
 		/* reset stats */
 		qdf_mem_zero(&target->endpoint[Endpoint].endpoint_stats,
-			  sizeof(HTC_ENDPOINT_STATS));
+			  sizeof(struct htc_endpoint_stats));
 	}
 
 	UNLOCK_HTC_RX(target);

File diff ditekan karena terlalu besar
+ 526 - 499
htc/htc_api.h


+ 66 - 53
htc/htc_internal.h

@@ -69,7 +69,8 @@ extern "C" {
 
 #define HTC_PACKET_CONTAINER_ALLOCATION     32
 #define NUM_CONTROL_TX_BUFFERS              2
-#define HTC_CONTROL_BUFFER_SIZE             (HTC_MAX_CONTROL_MESSAGE_LENGTH + HTC_HDR_LENGTH)
+#define HTC_CONTROL_BUFFER_SIZE             (HTC_MAX_CONTROL_MESSAGE_LENGTH + \
+					     HTC_HDR_LENGTH)
 #define HTC_CONTROL_BUFFER_ALIGN            32
 #define HTC_TARGET_RESPONSE_POLL_MS         10
 #if !defined(A_SIMOS_DEVHOST)
@@ -84,16 +85,16 @@ extern "C" {
 
 #define HTC_IS_EPPING_ENABLED(_x)           ((_x) == QDF_GLOBAL_EPPING_MODE)
 
-typedef enum {
+enum htc_credit_exchange_type {
 	HTC_REQUEST_CREDIT,
 	HTC_PROCESS_CREDIT_REPORT,
 	HTC_SUSPEND_ACK,
 	HTC_SUSPEND_NACK,
 	HTC_INITIAL_WAKE_UP,
-} htc_credit_exchange_type;
+};
 
 static inline const char*
-htc_credit_exchange_type_str(htc_credit_exchange_type type)
+htc_credit_exchange_type_str(enum htc_credit_exchange_type type)
 {
 	switch (type) {
 	case HTC_REQUEST_CREDIT:
@@ -111,12 +112,12 @@ htc_credit_exchange_type_str(htc_credit_exchange_type type)
 	}
 }
 
-typedef struct {
-	htc_credit_exchange_type type;
+struct HTC_CREDIT_HISTORY {
+	enum htc_credit_exchange_type type;
 	uint64_t time;
 	uint32_t tx_credit;
 	uint32_t htc_tx_queue_depth;
-} HTC_CREDIT_HISTORY;
+};
 
 typedef struct _HTC_ENDPOINT {
 	HTC_ENDPOINT_ID Id;
@@ -126,32 +127,44 @@ typedef struct _HTC_ENDPOINT {
 	 */
 	HTC_SERVICE_ID service_id;
 
-	HTC_EP_CALLBACKS EpCallBacks;           /* callbacks associated with this endpoint */
-	HTC_PACKET_QUEUE TxQueue;               /* HTC frame buffer TX queue */
-	int MaxTxQueueDepth;            /* max depth of the TX queue before we need to
-					call driver's full handler */
-	int MaxMsgLength;               /* max length of endpoint message */
+	/* callbacks associated with this endpoint */
+	struct htc_ep_callbacks EpCallBacks;
+	/* HTC frame buffer TX queue */
+	HTC_PACKET_QUEUE TxQueue;
+	/* max depth of the TX queue before calling driver's full handler */
+	int MaxTxQueueDepth;
+	/* max length of endpoint message */
+	int MaxMsgLength;
 	uint8_t UL_PipeID;
 	uint8_t DL_PipeID;
-	int ul_is_polled;               /* Need to call HIF to get tx completion callbacks? */
+	/* Need to call HIF to get tx completion callbacks? */
+	int ul_is_polled;
 	qdf_timer_t ul_poll_timer;
 	int ul_poll_timer_active;
 	int ul_outstanding_cnt;
-	int dl_is_polled;               /* Need to call HIF to fetch rx?  (Not currently supported.) */
-#if 0                           /* not currently supported */
-	qdf_timer_t dl_poll_timer;
-#endif
-
-	HTC_PACKET_QUEUE TxLookupQueue;         /* lookup queue to match netbufs to htc packets */
-	HTC_PACKET_QUEUE RxBufferHoldQueue;             /* temporary hold queue for back compatibility */
-	uint8_t SeqNo;          /* TX seq no (helpful) for debugging */
-	qdf_atomic_t TxProcessCount;            /* serialization */
+	/* Need to call HIF to fetch rx?  (Not currently supported.) */
+	int dl_is_polled;
+	/* not currently supported */
+	/* qdf_timer_t dl_poll_timer; */
+
+	/* lookup queue to match netbufs to htc packets */
+	HTC_PACKET_QUEUE TxLookupQueue;
+	/* temporary hold queue for back compatibility */
+	HTC_PACKET_QUEUE RxBufferHoldQueue;
+	/* TX seq no (helpful) for debugging */
+	uint8_t SeqNo;
+	/* serialization */
+	qdf_atomic_t TxProcessCount;
 	struct _HTC_TARGET *target;
-	int TxCredits;          /* TX credits available on this endpoint */
-	int TxCreditSize;               /* size in bytes of each credit (set by HTC) */
-	int TxCreditsPerMaxMsg;         /* credits required per max message (precalculated) */
+	/* TX credits available on this endpoint */
+	int TxCredits;
+	/* size in bytes of each credit (set by HTC) */
+	int TxCreditSize;
+	/* credits required per max message (precalculated) */
+	int TxCreditsPerMaxMsg;
 #ifdef HTC_EP_STAT_PROFILING
-	HTC_ENDPOINT_STATS endpoint_stats;     /* endpoint statistics */
+	/* endpoint statistics */
+	struct htc_endpoint_stats endpoint_stats;
 #endif
 	bool TxCreditFlowEnabled;
 	bool async_update;  /* packets can be queued asynchronously */
@@ -163,16 +176,17 @@ typedef struct _HTC_ENDPOINT {
 #define INC_HTC_EP_STAT(p, stat, count)
 #endif
 
-typedef struct {
+struct htc_service_tx_credit_allocation {
 	uint16_t service_id;
 	uint8_t CreditAllocation;
-} HTC_SERVICE_TX_CREDIT_ALLOCATION;
+};
 
 #define HTC_MAX_SERVICE_ALLOC_ENTRIES 8
 
 /* Error codes for HTC layer packet stats*/
 enum ol_ath_htc_pkt_ecodes {
-	GET_HTC_PKT_Q_FAIL = 0,         /* error- get packet at head of HTC_PACKET_Q */
+	/* error- get packet at head of HTC_PACKET_Q */
+	GET_HTC_PKT_Q_FAIL = 0,
 	HTC_PKT_Q_EMPTY,
 	HTC_SEND_Q_EMPTY
 };
@@ -186,15 +200,15 @@ typedef struct _HTC_TARGET {
 	qdf_spinlock_t HTCCreditLock;
 	uint32_t HTCStateFlags;
 	void *host_handle;
-	HTC_INIT_INFO HTCInitInfo;
-	HTC_PACKET *pHTCPacketStructPool;               /* pool of HTC packets */
+	struct htc_init_info HTCInitInfo;
+	HTC_PACKET *pHTCPacketStructPool; /* pool of HTC packets */
 	HTC_PACKET_QUEUE ControlBufferTXFreeList;
 	uint8_t CtrlResponseBuffer[HTC_MAX_CONTROL_MESSAGE_LENGTH];
 	int CtrlResponseLength;
 	qdf_event_t ctrl_response_valid;
 	bool CtrlResponseProcessing;
 	int TotalTransmitCredits;
-	HTC_SERVICE_TX_CREDIT_ALLOCATION
+	struct htc_service_tx_credit_allocation
 		ServiceTxAllocTable[HTC_MAX_SERVICE_ALLOC_ENTRIES];
 	int TargetCreditSize;
 #ifdef RX_SG_SUPPORT
@@ -252,21 +266,23 @@ typedef struct _HTC_TARGET {
 
 #ifdef RX_SG_SUPPORT
 #define RESET_RX_SG_CONFIG(_target) \
+do { \
 	_target->ExpRxSgTotalLen = 0; \
 	_target->CurRxSgTotalLen = 0; \
-	_target->IsRxSgInprogress = false;
+	_target->IsRxSgInprogress = false; \
+} while (0)
 #endif
 
 #define HTC_STATE_STOPPING      (1 << 0)
 #define HTC_STOPPING(t)         ((t)->HTCStateFlags & HTC_STATE_STOPPING)
-#define LOCK_HTC(t)             qdf_spin_lock_bh(&(t)->HTCLock);
-#define UNLOCK_HTC(t)           qdf_spin_unlock_bh(&(t)->HTCLock);
-#define LOCK_HTC_RX(t)          qdf_spin_lock_bh(&(t)->HTCRxLock);
-#define UNLOCK_HTC_RX(t)        qdf_spin_unlock_bh(&(t)->HTCRxLock);
-#define LOCK_HTC_TX(t)          qdf_spin_lock_bh(&(t)->HTCTxLock);
-#define UNLOCK_HTC_TX(t)        qdf_spin_unlock_bh(&(t)->HTCTxLock);
-#define LOCK_HTC_CREDIT(t)      qdf_spin_lock_bh(&(t)->HTCCreditLock);
-#define UNLOCK_HTC_CREDIT(t)    qdf_spin_unlock_bh(&(t)->HTCCreditLock);
+#define LOCK_HTC(t)             qdf_spin_lock_bh(&(t)->HTCLock)
+#define UNLOCK_HTC(t)           qdf_spin_unlock_bh(&(t)->HTCLock)
+#define LOCK_HTC_RX(t)          qdf_spin_lock_bh(&(t)->HTCRxLock)
+#define UNLOCK_HTC_RX(t)        qdf_spin_unlock_bh(&(t)->HTCRxLock)
+#define LOCK_HTC_TX(t)          qdf_spin_lock_bh(&(t)->HTCTxLock)
+#define UNLOCK_HTC_TX(t)        qdf_spin_unlock_bh(&(t)->HTCTxLock)
+#define LOCK_HTC_CREDIT(t)      qdf_spin_lock_bh(&(t)->HTCCreditLock)
+#define UNLOCK_HTC_CREDIT(t)    qdf_spin_unlock_bh(&(t)->HTCCreditLock)
 
 #define GET_HTC_TARGET_FROM_HANDLE(hnd) ((HTC_TARGET *)(hnd))
 
@@ -278,21 +294,19 @@ typedef struct _HTC_TARGET {
 #define OL_ATH_HTC_PKT_ERROR_COUNT_INCR(_target, _ecode)	\
 	do { \
 		if (_ecode == GET_HTC_PKT_Q_FAIL) \
-		(_target->htc_pkt_stats.htc_get_pkt_q_fail_count) += 1 \
-		; \
+		(_target->htc_pkt_stats.htc_get_pkt_q_fail_count) += 1; \
 		if (_ecode == HTC_PKT_Q_EMPTY) \
-		(_target->htc_pkt_stats.htc_pkt_q_empty_count) += 1 \
-		; \
+		(_target->htc_pkt_stats.htc_pkt_q_empty_count) += 1; \
 		if (_ecode == HTC_SEND_Q_EMPTY) \
-		(_target->htc_pkt_stats.htc_send_q_empty_count) += 1 \
-		; \
-	} while (0);
+		(_target->htc_pkt_stats.htc_send_q_empty_count) += 1; \
+	} while (0)
 /* internal HTC functions */
 
 QDF_STATUS htc_rx_completion_handler(void *Context, qdf_nbuf_t netbuf,
 				   uint8_t pipeID);
 QDF_STATUS htc_tx_completion_handler(void *Context, qdf_nbuf_t netbuf,
-				   unsigned int transferID, uint32_t toeplitz_hash_result);
+					unsigned int transferID,
+					uint32_t toeplitz_hash_result);
 
 HTC_PACKET *allocate_htc_bundle_packet(HTC_TARGET *target);
 void free_htc_bundle_packet(HTC_TARGET *target, HTC_PACKET *pPacket);
@@ -318,7 +332,7 @@ void htc_send_complete_check_cleanup(void *context);
 void htc_kick_queues(void *context);
 #endif
 
-void htc_credit_record(htc_credit_exchange_type type, uint32_t tx_credit,
+void htc_credit_record(enum htc_credit_exchange_type type, uint32_t tx_credit,
 		       uint32_t htc_tx_queue_depth);
 
 static inline void htc_send_complete_poll_timer_stop(HTC_ENDPOINT *
@@ -336,9 +350,8 @@ static inline void htc_send_complete_poll_timer_start(HTC_ENDPOINT *
 	LOCK_HTC_TX(pEndpoint->target);
 	if (pEndpoint->ul_outstanding_cnt
 	    && !pEndpoint->ul_poll_timer_active) {
-		/*
-		   qdf_timer_start(
-		   &pEndpoint->ul_poll_timer, HTC_POLL_CLEANUP_PERIOD_MS);
+		/* qdf_timer_start(
+		 * &pEndpoint->ul_poll_timer, HTC_POLL_CLEANUP_PERIOD_MS);
 		 */
 		pEndpoint->ul_poll_timer_active = 1;
 	}

+ 89 - 55
htc/htc_packet.h

@@ -52,13 +52,21 @@ typedef void (*HTC_PACKET_COMPLETION)(void *, struct _HTC_PACKET *);
 
 typedef uint16_t HTC_TX_TAG;
 
-typedef struct _HTC_TX_PACKET_INFO {
-	HTC_TX_TAG Tag;         /* tag used to selective flush packets */
-	int CreditsUsed;        /* number of credits used for this TX packet (HTC internal) */
-	uint8_t SendFlags;      /* send flags (HTC internal) */
-	int SeqNo;              /* internal seq no for debugging (HTC internal) */
-	uint32_t Flags;         /* internal use */
-} HTC_TX_PACKET_INFO;
+/**
+ * struct htc_tx_packet_info - HTC TX packet information
+ * @Tag: tag used to selective flush packets
+ * @CreditsUsed: number of credits used for this TX packet (HTC internal)
+ * @SendFlags: send flags (HTC internal)
+ * @SeqNo: internal seq no for debugging (HTC internal)
+ * @Flags: Internal use
+ */
+struct htc_tx_packet_info {
+	HTC_TX_TAG Tag;
+	int CreditsUsed;
+	uint8_t SendFlags;
+	int SeqNo;
+	uint32_t Flags;
+};
 
 /**
  * HTC_TX_PACKET_TAG_XXX - #defines for tagging packets for special handling
@@ -80,26 +88,51 @@ typedef struct _HTC_TX_PACKET_INFO {
 
 #define HTC_TX_PACKET_FLAG_FIXUP_NETBUF (1 << 0)
 
-typedef struct _HTC_RX_PACKET_INFO {
-	uint32_t ExpectedHdr;   /* HTC internal use */
-	uint32_t HTCRxFlags;    /* HTC internal use */
-	uint32_t IndicationFlags;       /* indication flags set on each RX packet indication */
-} HTC_RX_PACKET_INFO;
-
-#define HTC_RX_FLAGS_INDICATE_MORE_PKTS  (1 << 0)       /* more packets on this endpoint are being fetched */
+/**
+ * struct htc_rx_packet_info - HTC RX Packet information
+ * @ExpectedHdr: HTC Internal use
+ * @HTCRxFlags: HTC Internal use
+ * @IndicationFlags: indication flags set on each RX packet indication
+ */
+struct htc_rx_packet_info {
+	uint32_t ExpectedHdr;
+	uint32_t HTCRxFlags;
+	uint32_t IndicationFlags;
+};
+
+/* more packets on this endpoint are being fetched */
+#define HTC_RX_FLAGS_INDICATE_MORE_PKTS  (1 << 0)
 #define HTC_PACKET_MAGIC_COOKIE          0xdeadbeef
 
 /* wrapper around endpoint-specific packets */
+/**
+ * struct _HTC_PACKET - HTC Packet data structure
+ * @ListLink: double link
+ * @pPktContext: caller's per packet specific context
+ * @pBufferStart: The true buffer start, the caller can store the real buffer
+ *                start here.  In receive callbacks, the HTC layer sets pBuffer
+ *                to the start of the payload past the header. This field allows
+ *                the caller to reset pBuffer when it recycles receive packets
+ *                back to HTC
+ * @pBuffer: payload start (RX/TX)
+ * @BufferLength: length of buffer
+ * @ActualLength: actual length of payload
+ * @Endpoint: endpoint that this packet was sent/recv'd from
+ * @Status: completion status
+ * @PktInfo: Packet specific info
+ * @netbufOrigHeadRoom: Original head room of skb
+ * @Completion: completion
+ * @pContext: HTC private completion context
+ * @pNetBufContext: optimization for network-oriented data, the HTC packet can
+ *                  pass the network buffer corresponding to the HTC packet
+ *                  lower layers may optimized the transfer knowing this is a
+ *                  network buffer
+ * @magic_cookie: HTC Magic cookie
+ */
 typedef struct _HTC_PACKET {
-	DL_LIST ListLink;       /* double link */
-	void *pPktContext;      /* caller's per packet specific context */
-
-	uint8_t *pBufferStart;  /* the true buffer start , the caller can
-				store the real buffer start here.  In
-				receive callbacks, the HTC layer sets pBuffer
-				to the start of the payload past the header. This
-				field allows the caller to reset pBuffer when it
-				recycles receive packets back to HTC */
+	DL_LIST ListLink;
+	void *pPktContext;
+	uint8_t *pBufferStart;
 	/*
 	 * Pointer to the start of the buffer. In the transmit
 	 * direction this points to the start of the payload. In the
@@ -107,24 +140,20 @@ typedef struct _HTC_PACKET {
 	 * points to the start of the HTC header but when returned
 	 * to the caller points to the start of the payload
 	 */
-	uint8_t *pBuffer;       /* payload start (RX/TX) */
-	uint32_t BufferLength;  /* length of buffer */
-	uint32_t ActualLength;  /* actual length of payload */
-	HTC_ENDPOINT_ID Endpoint;       /* endpoint that this packet was sent/recv'd from */
-	A_STATUS Status;        /* completion status */
+	uint8_t *pBuffer;
+	uint32_t BufferLength;
+	uint32_t ActualLength;
+	HTC_ENDPOINT_ID Endpoint;
+	A_STATUS Status;
 	union {
-		HTC_TX_PACKET_INFO AsTx;        /* Tx Packet specific info */
-		HTC_RX_PACKET_INFO AsRx;        /* Rx Packet specific info */
+		struct htc_tx_packet_info AsTx;
+		struct htc_rx_packet_info AsRx;
 	} PktInfo;
-
 	/* the following fields are for internal HTC use */
 	uint32_t netbufOrigHeadRoom;
-	HTC_PACKET_COMPLETION Completion;       /* completion */
-	void *pContext;         /* HTC private completion context */
-	void *pNetBufContext;   /* optimization for network-oriented data, the HTC packet
-				can pass the network buffer corresponding to the HTC packet
-				lower layers may optimized the transfer knowing this is
-				a network buffer */
+	HTC_PACKET_COMPLETION Completion;
+	void *pContext;
+	void *pNetBufContext;
 	uint32_t magic_cookie;
 } HTC_PACKET;
 
@@ -167,9 +196,9 @@ typedef struct _HTC_PACKET {
 	} while (0)
 
 #define SET_HTC_PACKET_NET_BUF_CONTEXT(p, nb) \
-	do { \
-	(p)->pNetBufContext = (nb); \
-	} while (0)
+	{ \
+		(p)->pNetBufContext = (nb); \
+	}
 
 #define GET_HTC_PACKET_NET_BUF_CONTEXT(p)  (p)->pNetBufContext
 
@@ -202,11 +231,11 @@ typedef struct _HTC_PACKET_QUEUE {
 /* get packet at head without removing it */
 static inline HTC_PACKET *htc_get_pkt_at_head(HTC_PACKET_QUEUE *queue)
 {
-	if (queue->Depth == 0) {
+	if (queue->Depth == 0)
 		return NULL;
-	}
-	return
-		A_CONTAINING_STRUCT((DL_LIST_GET_ITEM_AT_HEAD(&queue->QueueHead)),
+
+	return A_CONTAINING_STRUCT((DL_LIST_GET_ITEM_AT_HEAD(
+					&queue->QueueHead)),
 				    HTC_PACKET, ListLink);
 }
 
@@ -221,6 +250,7 @@ static inline HTC_PACKET *htc_get_pkt_at_head(HTC_PACKET_QUEUE *queue)
 static inline HTC_PACKET *htc_packet_dequeue(HTC_PACKET_QUEUE *queue)
 {
 	DL_LIST *pItem = dl_list_remove_item_from_head(&queue->QueueHead);
+
 	if (pItem != NULL) {
 		queue->Depth--;
 		return A_CONTAINING_STRUCT(pItem, HTC_PACKET, ListLink);
@@ -232,6 +262,7 @@ static inline HTC_PACKET *htc_packet_dequeue(HTC_PACKET_QUEUE *queue)
 static inline HTC_PACKET *htc_packet_dequeue_tail(HTC_PACKET_QUEUE *queue)
 {
 	DL_LIST *pItem = dl_list_remove_item_from_tail(&queue->QueueHead);
+
 	if (pItem != NULL) {
 		queue->Depth--;
 		return A_CONTAINING_STRUCT(pItem, HTC_PACKET, ListLink);
@@ -245,11 +276,12 @@ static inline HTC_PACKET *htc_packet_dequeue_tail(HTC_PACKET_QUEUE *queue)
 #define HTC_GET_TAG_FROM_PKT(p)      (p)->PktInfo.AsTx.Tag
 
 /* transfer the packets from one queue to the tail of another queue */
-#define HTC_PACKET_QUEUE_TRANSFER_TO_TAIL(pQDest, pQSrc)	\
-	{									    \
-		dl_list_transfer_items_to_tail(&(pQDest)->QueueHead, &(pQSrc)->QueueHead);   \
-		(pQDest)->Depth += (pQSrc)->Depth;					\
-		(pQSrc)->Depth = 0;							\
+#define HTC_PACKET_QUEUE_TRANSFER_TO_TAIL(pQDest, pQSrc) \
+	{ \
+		dl_list_transfer_items_to_tail(&(pQDest)->QueueHead, \
+					       &(pQSrc)->QueueHead); \
+		(pQDest)->Depth += (pQSrc)->Depth; \
+		(pQSrc)->Depth = 0; \
 	}
 
 /*
@@ -259,10 +291,11 @@ static inline HTC_PACKET *htc_packet_dequeue_tail(HTC_PACKET_QUEUE *queue)
  * to the concatenated queue.
  */
 #define HTC_PACKET_QUEUE_TRANSFER_TO_HEAD(pQDest, pQSrc)  \
-	{									    \
-		dl_list_transfer_items_to_head(&(pQDest)->QueueHead, &(pQSrc)->QueueHead);   \
-		(pQDest)->Depth += (pQSrc)->Depth;					\
-		(pQSrc)->Depth = 0;							\
+	{ \
+		dl_list_transfer_items_to_head(&(pQDest)->QueueHead, \
+					       &(pQSrc)->QueueHead); \
+		(pQDest)->Depth += (pQSrc)->Depth; \
+		(pQSrc)->Depth = 0; \
 	}
 
 /* fast version to init and add a single packet to a queue */
@@ -273,9 +306,10 @@ static inline HTC_PACKET *htc_packet_dequeue_tail(HTC_PACKET_QUEUE *queue)
 	}
 
 #define HTC_PACKET_QUEUE_ITERATE_ALLOW_REMOVE(pQ, pPTemp) \
-	ITERATE_OVER_LIST_ALLOW_REMOVE(&(pQ)->QueueHead, (pPTemp), HTC_PACKET, ListLink)
+		ITERATE_OVER_LIST_ALLOW_REMOVE(&(pQ)->QueueHead, \
+						(pPTemp), HTC_PACKET, ListLink)
 
-#define HTC_PACKET_QUEUE_ITERATE_IS_VALID(pQ)   ITERATE_IS_VALID(&(pQ)->QueueHead)
+#define HTC_PACKET_QUEUE_ITERATE_IS_VALID(pQ) ITERATE_IS_VALID(&(pQ)->QueueHead)
 #define HTC_PACKET_QUEUE_ITERATE_RESET(pQ) ITERATE_RESET(&(pQ)->QueueHead)
 
 #define HTC_PACKET_QUEUE_ITERATE_END ITERATE_END

+ 44 - 65
htc/htc_recv.c

@@ -94,15 +94,16 @@ static void do_recv_completion(HTC_ENDPOINT *pEndpoint,
 
 		if (pEndpoint->EpCallBacks.EpRecvPktMultiple != NULL) {
 			AR_DEBUG_PRINTF(ATH_DEBUG_RECV,
-					(" HTC calling ep %d, recv multiple callback (%d pkts) \n",
+					("HTC calling ep %d, recv multiple callback (%d pkts)\n",
 					 pEndpoint->Id,
 					 HTC_PACKET_QUEUE_DEPTH
 						 (pQueueToIndicate)));
-			/* a recv multiple handler is being used, pass the queue to the handler */
-			pEndpoint->EpCallBacks.EpRecvPktMultiple(pEndpoint->
-								 EpCallBacks.
-								 pContext,
-								 pQueueToIndicate);
+			/* a recv multiple handler is being used, pass the queue
+			 * to the handler
+			 */
+			pEndpoint->EpCallBacks.EpRecvPktMultiple(
+						pEndpoint->EpCallBacks.pContext,
+						pQueueToIndicate);
 			INIT_HTC_PACKET_QUEUE(pQueueToIndicate);
 		} else {
 			HTC_PACKET *pPacket;
@@ -137,6 +138,7 @@ static void recv_packet_completion(HTC_TARGET *target, HTC_ENDPOINT *pEndpoint,
 				   HTC_PACKET *pPacket)
 {
 	HTC_PACKET_QUEUE container;
+
 	INIT_HTC_PACKET_QUEUE_AND_ADD(&container, pPacket);
 	/* do completion */
 	do_recv_completion(pEndpoint, &container);
@@ -169,6 +171,7 @@ void htc_disable_recv(HTC_HANDLE HTCHandle)
 int htc_get_num_recv_buffers(HTC_HANDLE HTCHandle, HTC_ENDPOINT_ID Endpoint)
 {
 	HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle);
+
 	HTC_ENDPOINT *pEndpoint = &target->endpoint[Endpoint];
 	return HTC_PACKET_QUEUE_DEPTH(&pEndpoint->RxBufferHoldQueue);
 }
@@ -278,7 +281,7 @@ QDF_STATUS htc_rx_completion_handler(void *Context, qdf_nbuf_t netbuf,
 	uint16_t payloadLen;
 	uint32_t trailerlen = 0;
 	uint8_t htc_ep_id;
-	HTC_INIT_INFO *info;
+	struct htc_init_info *info;
 
 #ifdef RX_SG_SUPPORT
 	LOCK_HTC_RX(target);
@@ -314,7 +317,8 @@ QDF_STATUS htc_rx_completion_handler(void *Context, qdf_nbuf_t netbuf,
 					("HTC Rx: invalid EndpointID=%d\n",
 					 htc_ep_id));
 			debug_dump_bytes((uint8_t *) HtcHdr,
-					 sizeof(HTC_FRAME_HDR), "BAD HTC Header");
+					sizeof(HTC_FRAME_HDR),
+					"BAD HTC Header");
 			status = QDF_STATUS_E_FAILURE;
 			QDF_BUG(0);
 			break;
@@ -325,12 +329,11 @@ QDF_STATUS htc_rx_completion_handler(void *Context, qdf_nbuf_t netbuf,
 		/*
 		 * If this endpoint that received a message from the target has
 		 * a to-target HIF pipe whose send completions are polled rather
-		 * than interrupt-driven, this is a good point to ask HIF to check
-		 * whether it has any completed sends to handle.
+		 * than interrupt driven, this is a good point to ask HIF to
+		 * check whether it has any completed sends to handle.
 		 */
-		if (pEndpoint->ul_is_polled) {
+		if (pEndpoint->ul_is_polled)
 			htc_send_complete_check(pEndpoint, 1);
-		}
 
 		payloadLen = HTC_GET_FIELD(HtcHdr, HTC_FRAME_HDR, PAYLOADLEN);
 
@@ -384,12 +387,14 @@ QDF_STATUS htc_rx_completion_handler(void *Context, qdf_nbuf_t netbuf,
 				}
 
 				trailerlen = temp;
-				/* process trailer data that follows HDR + application payload */
+				/* process trailer data that follows HDR +
+				 * application payload
+				 */
 				temp_status = htc_process_trailer(target,
-							     ((uint8_t *) HtcHdr +
-							      HTC_HDR_LENGTH +
-							      payloadLen - temp),
-							     temp, htc_ep_id);
+						((uint8_t *) HtcHdr +
+							HTC_HDR_LENGTH +
+							payloadLen - temp),
+						temp, htc_ep_id);
 				if (A_FAILED(temp_status)) {
 					status = QDF_STATUS_E_FAILURE;
 					break;
@@ -399,7 +404,7 @@ QDF_STATUS htc_rx_completion_handler(void *Context, qdf_nbuf_t netbuf,
 		}
 
 		if (((int)payloadLen - (int)trailerlen) <= 0) {
-			/* zero length packet with trailer data, just drop these */
+			/* 0 length packet with trailer data, just drop these */
 			break;
 		}
 
@@ -414,15 +419,17 @@ QDF_STATUS htc_rx_completion_handler(void *Context, qdf_nbuf_t netbuf,
 			netlen = qdf_nbuf_len(netbuf);
 
 			htc_msg = (HTC_UNKNOWN_MSG *) netdata;
-			message_id =
-				HTC_GET_FIELD(htc_msg, HTC_UNKNOWN_MSG, MESSAGEID);
+			message_id = HTC_GET_FIELD(htc_msg, HTC_UNKNOWN_MSG,
+						   MESSAGEID);
 
 			switch (message_id) {
 			default:
 				/* handle HTC control message */
 				if (target->CtrlResponseProcessing) {
-					/* this is a fatal error, target should not be sending unsolicited messages
-					 * on the endpoint 0 */
+					/* this is a fatal error, target should
+					 * not be sending unsolicited messages
+					 * on the endpoint 0
+					 */
 					AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
 							("HTC Rx Ctrl still processing\n"));
 					status = QDF_STATUS_E_FAILURE;
@@ -496,10 +503,11 @@ QDF_STATUS htc_rx_completion_handler(void *Context, qdf_nbuf_t netbuf,
 			break;
 		}
 
-		/* the current message based HIF architecture allocates net bufs for recv packets
-		 * since this layer bridges that HIF to upper layers , which expects HTC packets,
-		 * we form the packets here
-		 * TODO_FIXME */
+		/* the current message based HIF architecture allocates net bufs
+		 * for recv packets since this layer bridges that HIF to upper
+		 * layers , which expects HTC packets, we form the packets here
+		 * TODO_FIXME
+		 */
 		pPacket = allocate_htc_packet_container(target);
 		if (NULL == pPacket) {
 			status = QDF_STATUS_E_RESOURCES;
@@ -525,9 +533,8 @@ QDF_STATUS htc_rx_completion_handler(void *Context, qdf_nbuf_t netbuf,
 _out:
 #endif
 
-	if (netbuf != NULL) {
+	if (netbuf != NULL)
 		qdf_nbuf_free(netbuf);
-	}
 
 	return status;
 
@@ -592,6 +599,7 @@ A_STATUS htc_add_receive_pkt_multiple(HTC_HANDLE HTCHandle,
 A_STATUS htc_add_receive_pkt(HTC_HANDLE HTCHandle, HTC_PACKET *pPacket)
 {
 	HTC_PACKET_QUEUE queue;
+
 	INIT_HTC_PACKET_QUEUE_AND_ADD(&queue, pPacket);
 	return htc_add_receive_pkt_multiple(HTCHandle, &queue);
 }
@@ -605,14 +613,13 @@ void htc_flush_rx_hold_queue(HTC_TARGET *target, HTC_ENDPOINT *pEndpoint)
 
 	while (1) {
 		pPacket = htc_packet_dequeue(&pEndpoint->RxBufferHoldQueue);
-		if (NULL == pPacket) {
+		if (pPacket == NULL)
 			break;
-		}
 		UNLOCK_HTC_RX(target);
 		pPacket->Status = A_ECANCELED;
 		pPacket->ActualLength = 0;
 		AR_DEBUG_PRINTF(ATH_DEBUG_RECV,
-				("  Flushing RX packet:%p, length:%d, ep:%d \n",
+				("Flushing RX packet:%p, length:%d, ep:%d\n",
 				 pPacket, pPacket->BufferLength,
 				 pPacket->Endpoint));
 		INIT_HTC_PACKET_QUEUE_AND_ADD(&container, pPacket);
@@ -650,32 +657,6 @@ A_STATUS htc_wait_recv_ctrl_message(HTC_TARGET *target)
 
 	UNLOCK_HTC_RX(target);
 
-#if 0
-	while (count > 0) {
-
-		LOCK_HTC_RX(target);
-
-		if (target->CtrlResponseValid) {
-			target->CtrlResponseValid = false;
-			/* caller will clear this flag */
-			target->CtrlResponseProcessing = true;
-			UNLOCK_HTC_RX(target);
-			break;
-		}
-
-		UNLOCK_HTC_RX(target);
-
-		count--;
-		A_MSLEEP(HTC_TARGET_RESPONSE_POLL_MS);
-	}
-
-	if (count <= 0) {
-		AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
-				("-HTCWaitCtrlMessageRecv: Timeout!\n"));
-		return A_ECOMM;
-	}
-#endif
-
 	AR_DEBUG_PRINTF(ATH_DEBUG_TRC, ("-HTCWaitCtrlMessageRecv success\n"));
 	return A_OK;
 }
@@ -693,11 +674,10 @@ static A_STATUS htc_process_trailer(HTC_TARGET *target,
 	A_STATUS status;
 
 	AR_DEBUG_PRINTF(ATH_DEBUG_RECV,
-			("+htc_process_trailer (length:%d) \n", Length));
+			("+htc_process_trailer (length:%d)\n", Length));
 
-	if (AR_DEBUG_LVL_CHECK(ATH_DEBUG_RECV)) {
+	if (AR_DEBUG_LVL_CHECK(ATH_DEBUG_RECV))
 		AR_DEBUG_PRINTBUF(pBuffer, Length, "Recv Trailer");
-	}
 
 	pOrigBuffer = pBuffer;
 	origLength = Length;
@@ -720,7 +700,7 @@ static A_STATUS htc_process_trailer(HTC_TARGET *target,
 		if (htc_rec_len > Length) {
 			/* no room left in buffer for record */
 			AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
-					(" invalid record length: %d (id:%d) buffer has: %d bytes left \n",
+					("invalid record length: %d (id:%d) buffer has: %d bytes left\n",
 					 htc_rec_len, htc_rec_id, Length));
 			status = A_EPROTO;
 			break;
@@ -751,7 +731,7 @@ static A_STATUS htc_process_trailer(HTC_TARGET *target,
 
 		default:
 			AR_DEBUG_PRINTF(ATH_DEBUG_ERR,
-					(" HTC unhandled record: id:%d length:%d \n",
+					("HTC unhandled record: id:%d length:%d\n",
 					 htc_rec_id, htc_rec_len));
 			break;
 		}
@@ -765,11 +745,10 @@ static A_STATUS htc_process_trailer(HTC_TARGET *target,
 		Length -= htc_rec_len;
 	}
 
-	if (A_FAILED(status)) {
+	if (A_FAILED(status))
 		debug_dump_bytes(pOrigBuffer, origLength, "BAD Recv Trailer");
-	}
 
-	AR_DEBUG_PRINTF(ATH_DEBUG_RECV, ("-htc_process_trailer \n"));
+	AR_DEBUG_PRINTF(ATH_DEBUG_RECV, ("-htc_process_trailer\n"));
 	return status;
 
 }

File diff ditekan karena terlalu besar
+ 216 - 190
htc/htc_send.c


+ 31 - 31
htc/htc_services.c

@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2013-2016 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2017 The Linux Foundation. All rights reserved.
  *
  * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
  *
@@ -83,7 +83,6 @@ htc_alt_data_credit_size_update(HTC_TARGET *target,
 	    (*ul_pipe == 1) && (*dl_pipe == 0))
 		*txCreditSize = target->AltDataCreditSize;
 
-	return;
 }
 #else
 
@@ -93,13 +92,12 @@ htc_alt_data_credit_size_update(HTC_TARGET *target,
 				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)
+			     struct htc_service_connect_req *pConnectReq,
+			     struct htc_service_connect_resp *pConnectResp)
 {
 	HTC_TARGET *target = GET_HTC_TARGET_FROM_HANDLE(HTCHandle);
 	A_STATUS status = A_OK;
@@ -189,15 +187,14 @@ A_STATUS htc_connect_service(HTC_HANDLE HTCHandle,
 				disableCreditFlowCtrl = true;
 			}
 
-			if (!htc_credit_flow) {
+			if (!htc_credit_flow)
 				disableCreditFlowCtrl = true;
-			}
 
 			/* check caller if it wants to transfer meta data */
 			if ((pConnectReq->pMetaData != NULL) &&
 			    (pConnectReq->MetaDataLength <=
 			     HTC_SERVICE_META_DATA_MAX_LENGTH)) {
-				/* copy meta data into message buffer (after header ) */
+				/* copy meta data into msg buffer (after hdr) */
 				qdf_mem_copy((uint8_t *) pConnectMsg +
 					 sizeof(HTC_CONNECT_SERVICE_MSG),
 					 pConnectReq->pMetaData,
@@ -219,23 +216,23 @@ A_STATUS htc_connect_service(HTC_HANDLE HTCHandle,
 			status = htc_send_pkt((HTC_HANDLE) target, pSendPacket);
 			/* we don't own it anymore */
 			pSendPacket = NULL;
-			if (A_FAILED(status)) {
+			if (A_FAILED(status))
 				break;
-			}
 
 			/* wait for response */
 			status = htc_wait_recv_ctrl_message(target);
-			if (A_FAILED(status)) {
+			if (A_FAILED(status))
 				break;
-			}
-			/* we controlled the buffer creation so it has to be properly aligned */
+			/* we controlled the buffer creation so it has to be
+			 * properly aligned
+			 */
 			pResponseMsg =
 				(HTC_CONNECT_SERVICE_RESPONSE_MSG *) target->
 				CtrlResponseBuffer;
 
 			rsp_msg_id = HTC_GET_FIELD(pResponseMsg,
-						   HTC_CONNECT_SERVICE_RESPONSE_MSG,
-						   MESSAGEID);
+					   HTC_CONNECT_SERVICE_RESPONSE_MSG,
+					   MESSAGEID);
 			rsp_msg_serv_id =
 				HTC_GET_FIELD(pResponseMsg,
 					      HTC_CONNECT_SERVICE_RESPONSE_MSG,
@@ -280,12 +277,13 @@ A_STATUS htc_connect_service(HTC_HANDLE HTCHandle,
 						 rsp_msg_serv_id,
 						 rsp_msg_status));
 				status = A_EPROTO;
-/* TODO: restore the ifdef when FW supports services 301 and 302 (HTT_MSG_DATA[23]_MSG_SVC)
-#ifdef QCA_TX_HTT2_SUPPORT
-*/
-				/* Keep work and not to block the control message. */
+/* TODO: restore the ifdef when FW supports services 301 and 302
+ * (HTT_MSG_DATA[23]_MSG_SVC)
+ */
+/* #ifdef QCA_TX_HTT2_SUPPORT */
+				/* Keep work and not to block the control msg */
 				target->CtrlResponseProcessing = false;
-/*#endif */ /* QCA_TX_HTT2_SUPPORT */
+/* #endif */ /* QCA_TX_HTT2_SUPPORT */
 				break;
 			}
 
@@ -296,7 +294,9 @@ A_STATUS htc_connect_service(HTC_HANDLE HTCHandle,
 			    (rsp_msg_serv_meta_len > 0) &&
 			    (rsp_msg_serv_meta_len <=
 			     HTC_SERVICE_META_DATA_MAX_LENGTH)) {
-				/* caller supplied a buffer and the target responded with data */
+				/* caller supplied a buffer and the target
+				 * responded with data
+				 */
 				int copyLength =
 					min((int)pConnectResp->BufferLength,
 					    (int)rsp_msg_serv_meta_len);
@@ -312,7 +312,7 @@ A_STATUS htc_connect_service(HTC_HANDLE HTCHandle,
 			target->CtrlResponseProcessing = false;
 		}
 
-		/* the rest of these are parameter checks so set the error status */
+		/* rest of these are parameter checks so set the error status */
 		status = A_EPROTO;
 
 		if (assignedEndpoint >= ENDPOINT_MAX) {
@@ -346,9 +346,8 @@ A_STATUS htc_connect_service(HTC_HANDLE HTCHandle,
 		pEndpoint->TxCreditSize = target->TargetCreditSize;
 		pEndpoint->TxCreditsPerMaxMsg =
 			maxMsgSize / target->TargetCreditSize;
-		if (maxMsgSize % target->TargetCreditSize) {
+		if (maxMsgSize % target->TargetCreditSize)
 			pEndpoint->TxCreditsPerMaxMsg++;
-		}
 #if DEBUG_CREDIT
 		qdf_print(" Endpoint%d initial credit:%d, size:%d.\n",
 			  pEndpoint->Id, pEndpoint->TxCredits,
@@ -365,16 +364,16 @@ A_STATUS htc_connect_service(HTC_HANDLE HTCHandle,
 						 &pEndpoint->DL_PipeID,
 						 &pEndpoint->ul_is_polled,
 						 &pEndpoint->dl_is_polled);
-		if (A_FAILED(status)) {
+		if (A_FAILED(status))
 			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 */
+		/* not currently supported */
+		qdf_assert(!pEndpoint->dl_is_polled);
 
 		if (pEndpoint->ul_is_polled) {
 			qdf_timer_init(target->osdev,
@@ -411,19 +410,20 @@ void htc_set_credit_distribution(HTC_HANDLE HTCHandle,
 				 HTC_SERVICE_ID ServicePriorityOrder[],
 				 int ListLength)
 {
-	/* NOT Supported, this transport does not use a credit based flow control mechanism */
+	/* NOT Supported, this transport does not use a credit based flow
+	 * control mechanism
+	 */
 
 }
 
 void htc_fw_event_handler(void *context, QDF_STATUS status)
 {
 	HTC_TARGET *target = (HTC_TARGET *) context;
-	HTC_INIT_INFO *initInfo = &target->HTCInitInfo;
+	struct htc_init_info *initInfo = &target->HTCInitInfo;
 
 	/* check if target failure handler exists and pass error code to it. */
-	if (target->HTCInitInfo.TargetFailure != NULL) {
+	if (target->HTCInitInfo.TargetFailure != NULL)
 		initInfo->TargetFailure(initInfo->pContext, status);
-	}
 }
 
 

+ 2 - 2
wmi/src/wmi_unified.c

@@ -2871,8 +2871,8 @@ static int wmi_connect_pdev_htc_service(struct wmi_soc *soc,
 	int status;
 	uint32_t svc_id[] = {WMI_CONTROL_SVC, WMI_CONTROL_SVC_WMAC1,
 						WMI_CONTROL_SVC_WMAC2};
-	HTC_SERVICE_CONNECT_RESP response;
-	HTC_SERVICE_CONNECT_REQ connect;
+	struct htc_service_connect_resp response;
+	struct htc_service_connect_req connect;
 
 	OS_MEMZERO(&connect, sizeof(connect));
 	OS_MEMZERO(&response, sizeof(response));

Beberapa file tidak ditampilkan karena terlalu banyak file yang berubah dalam diff ini