Merge "[qca-nss-drv] Add the missing error code for vdev."
diff --git a/exports/nss_wifili_if.h b/exports/nss_wifili_if.h
index 3086711..856f91c 100644
--- a/exports/nss_wifili_if.h
+++ b/exports/nss_wifili_if.h
@@ -144,67 +144,79 @@
 enum nss_wifili_error_types {
 	NSS_WIFILI_EMSG_NONE,
 			/**< No error. */
+	NSS_WIFILI_EMSG_INIT_FAIL_IMPROPER_STATE,
+			/**< Device initialization failure due to improper state of device. */
 	NSS_WIFILI_EMSG_RINGS_INIT_FAIL,
 			/**< Device ring initialization failure. */
 	NSS_WIFILI_EMSG_PDEV_INIT_IMPROPER_STATE_FAIL,
 			/**< Radio initialization failure due to improper state of device. */
 	NSS_WIFILI_EMSG_PDEV_INIT_INVALID_RADIOID_FAIL,
 			/**< Radio initialization failed due to invalid radio ID. */
+	NSS_WIFILI_EMSG_PDEV_TX_IRQ_ALLOC_FAIL,
+			/**< IRQ line allocation for radio transmission failed. */
 	NSS_WIFILI_EMSG_PDEV_RESET_INVALID_RADIOID_FAIL,
 			/**< Radio reset failed due to invalid radio ID. */
+	NSS_WIFILI_EMSG_PDEV_RESET_PDEV_NULL_FAIL,
+			/**< Radio reset failed due to null physical device. */
+	NSS_WIFILI_EMSG_PDEV_RESET_IMPROPER_STATE_FAIL,
+			/**< Radio reset failed due to improper state of pdev. */
 	NSS_WIFILI_EMSG_START_IMPROPER_STATE_FAIL,
-			/**< Device start failure due to improper state. */
+			/**< Device start fail due to improper state */
 	NSS_WIFILI_EMSG_PEER_CREATE_FAIL,
-			/**< Peer creation failure. */
+			/**< Peer creation failed. */
 	NSS_WIFILI_EMSG_PEER_DELETE_FAIL,
-			/**< Peer delete failure. */
+			/**< Peer deletion failed. */
 	NSS_WIFILI_EMSG_HASHMEM_INIT_FAIL,
-			/**< Peer hash memory initialization failure. */
+			/**< Peer hash memory allocation failed. */
 	NSS_WIFILI_EMSG_PEER_FREELIST_APPEND_FAIL,
-			/**< Peer freelist append failure. */
+			/**< Appending peer to freelist failed. */
 	NSS_WIFILI_EMSG_PEER_CREATE_INVALID_VDEVID_FAIL,
-			/**< Peer creation failure due to invalid vdev ID. */
+			/**< Peer creation failure due to invalid virtual device ID. */
 	NSS_WIFILI_EMSG_PEER_CREATE_INVALID_PEER_ID_FAIL,
 			/**< Peer creation failure due to invalid peer ID. */
 	NSS_WIFILI_EMSG_PEER_CREATE_VDEV_NULL_FAIL,
-			/**< Peer creation failure due to null vdev. */
+			/**< Peer creation failure due to null virtual device. */
 	NSS_WIFILI_EMSG_PEER_CREATE_PDEV_NULL_FAIL,
-			/**< Peer creation failure due to null peer. */
+			/**< Peer creation failure due to null physical device. */
 	NSS_WIFILI_EMSG_PEER_CREATE_ALLOC_FAIL,
 			/**< Peer creation failure due to memory allocation failure. */
 	NSS_WIFILI_EMSG_PEER_DELETE_VAPID_INVALID_FAIL,
-			/**< Peer delete failure due to invalid vdev_ID. */
+			/**< Peer deletion failure due to invalid virtual device ID. */
 	NSS_WIFILI_EMSG_PEER_DELETE_INVALID_PEERID_FAIL,
-			/**< Peer delete failure due to invalid peer ID. */
+			/**< Peer deletion failed due to invalid peer ID. */
 	NSS_WIFILI_EMSG_PEER_DELETE_VDEV_NULL_FAIL,
-			/**< Peer delete failure due to null vdev. */
+			/**< Peer deletion failure due to null virtual device. */
 	NSS_WIFILI_EMSG_PEER_DELETE_PDEV_NULL_FAIL,
-			/**< Peer creation failure due to null vdev. */
+			/**< Peer deletion failure due to null physical device. */
 	NSS_WIFILI_EMSG_PEER_DELETE_PEER_NULL_FAIL,
-			/**< Peer creation failure due to null peer. */
+			/**< Peer deletion failure due to null peer. */
 	NSS_WIFILI_EMSG_PEER_DELETE_PEER_CORRUPTED_FAIL,
 			/**< Peer creation failure due to corrupted peer. */
+	NSS_WIFILI_EMSG_PEER_DUPLICATE_AST_INDEX_PEER_ID_FAIL,
+			/**< AST index provided is duplicate. */
 	NSS_WIFILI_EMSG_GROUP0_TIMER_ALLOC_FAIL,
 			/**< Timer allocation failure. */
 	NSS_WIFILI_EMSG_INSUFFICIENT_WT_FAIL,
 			/**< Insufficient worker thread error. */
 	NSS_WIFILI_EMSG_INVALID_NUM_TCL_RING_FAIL,
-			/**< Invlalid number of Transmit Classifier ring provided in initialization message. */
+			/**< Invalid number of Transmit Classifier rings provided in initialization message. */
 	NSS_WIFILI_EMSG_INVALID_NUM_REO_DST_RING_FAIL,
 			/**< Invalid number of reorder destination ring in initialization message. */
 	NSS_WIFILI_EMSG_HAL_SRNG_SOC_ALLOC_FAIL,
 			/**< Srng SoC memory allocation failure. */
-	NSS_WIFILI_EMSG_HAL_TCL_SRNG_ALLOC_FAIL,
+	NSS_WIFILI_EMSG_HAL_SRNG_INVALID_RING_INFO_FAIL,
+			/**< Device ring information is invalid. */
+	NSS_WIFILI_EMSG_HAL_SRNG_TCL_ALLOC_FAIL,
 			/**< Transmit Classifier srng ring allocation failure. */
-	NSS_WIFILI_EMSG_HAL_TXCOMP_SRNG_ALLOC_FAIL,
+	NSS_WIFILI_EMSG_HAL_SRNG_TXCOMP_ALLOC_FAIL,
 			/**< Txcomp srng ring allocation failure. */
-	NSS_WIFILI_EMSG_HAL_REODST_SRNG_ALLOC_FAIL,
+	NSS_WIFILI_EMSG_HAL_SRNG_REODST_ALLOC_FAIL,
 			/**< Reorder destination srng ring allocation failure. */
-	NSS_WIFILI_EMSG_HAL_REOREINJECT_SRNG_ALLOC_FAIL,
+	NSS_WIFILI_EMSG_HAL_SRNG_REOREINJECT_ALLOC_FAIL,
 			/**< Reorder reinject srng ring allocation failure. */
-	NSS_WIFILI_EMSG_HAL_RXRELEASE_SRNG_ALLOC_FAIL,
+	NSS_WIFILI_EMSG_HAL_SRNG_RXRELEASE_ALLOC_FAIL,
 			/**< Rx release srng ring allocation failure. */
-	NSS_WIFILI_EMSG_HAL_RXEXCP_SRNG_ALLOC_FAIL,
+	NSS_WIFILI_EMSG_HAL_SRNG_RXEXCP_ALLOC_FAIL,
 			/**< Rx exception srng ring allocation failure. */
 	NSS_WIFILI_EMSG_HAL_TX_MEMALLOC_FAIL,
 			/**< Tx HAL (hardware abstraction layer) srng ring allocation failure. */
@@ -246,12 +258,16 @@
 			 /**< Invalid peer id passed in WDS messages. */
 	NSS_WIFILI_EMSG_WDS_DUPLICATE_AST_INDEX_PEER_ID_FAIL,
 			/**< AST entry index is already filled. */
+	NSS_WIFILI_EMSG_INVALID_RADIO_CMD,
+			/**< Radio command is invalid. */
+	NSS_WIFILI_EMSG_INVALID_RADIO_IFNUM,
+			/**< Radio interface number is invalid. */
 	NSS_WIFILI_EMSG_PEER_SECURITY_PEER_NULL_FAIL,
 			/**< Security message failed as peer is null for a peer ID. */
 	NSS_WIFILI_EMSG_PEER_SECURITY_PEER_CORRUPTED_FAIL,
 			/**< Security message failed as peer is corrupted. */
 	NSS_WIFILI_EMSG_RADIO_INVALID_BUF_CFG,
-            /**< Buffer configuration message failed as invalid range value is provided. */
+			/**< Buffer configuration message failed as invalid range value is provided. */
 	NSS_WIFILI_EMSG_UNKNOWN
 			/**< Unknown error message. */
 };
diff --git a/nss_core.c b/nss_core.c
index 7687d3c..a334e16 100644
--- a/nss_core.c
+++ b/nss_core.c
@@ -2806,8 +2806,8 @@
 	}
 
 	if (nss_cmn_get_msg_len(ncm) > size) {
-		nss_warning("%p: interface: %d type: %d message length %d is invalid for\n",
-					nss_ctx, ncm->interface, ncm->type, nss_cmn_get_msg_len(ncm));
+		nss_warning("%p: interface: %d type: %d message length %d is invalid, size = %d\n",
+					nss_ctx, ncm->interface, ncm->type, nss_cmn_get_msg_len(ncm), size);
 		return NSS_TX_FAILURE_TOO_LARGE;
 	}
 
diff --git a/nss_hal/ipq807x/nss_hal_pvt.c b/nss_hal/ipq807x/nss_hal_pvt.c
index 389c5a5..d9521ec 100644
--- a/nss_hal/ipq807x/nss_hal_pvt.c
+++ b/nss_hal/ipq807x/nss_hal_pvt.c
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2016-2017, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2018, The Linux Foundation. All rights reserved.
  * Permission to use, copy, modify, and/or distribute this software for
  * any purpose with or without fee is hereby granted, provided that the
  * above copyright notice and this permission notice appear in all copies.
@@ -70,11 +70,26 @@
 #define TURBO_VOLTAGE 2
 
 /*
+ * Core reset part 1
+ */
+#define NSS_CORE_GCC_RESET_1 0x00000020
+
+/*
+ * Core reset part 2
+ */
+#define NSS_CORE_GCC_RESET_2 0x00000017
+
+/*
  * Voltage regulator
  */
 struct regulator *npu_reg;
 
 /*
+ * GCC reset
+ */
+void __iomem *nss_misc_reset;
+
+/*
  * Purpose of each interrupt index: This should match the order defined in the NSS firmware
  */
 enum nss_hal_n2h_intr_purpose {
@@ -280,6 +295,27 @@
  */
 static int __nss_hal_core_reset(struct platform_device *nss_dev, void __iomem *map, uint32_t addr, uint32_t clk_src)
 {
+	uint32_t value;
+
+	/*
+	 * De-assert reset for first set
+	 */
+	value = nss_read_32(nss_misc_reset, 0x0);
+	value &= ~(NSS_CORE_GCC_RESET_1 << (nss_dev->id << 3));
+	nss_write_32(nss_misc_reset, 0x0, value);
+
+	/*
+	 * Minimum 10 - 20 cycles delay is required after
+	 * de-asserting UBI reset clamp
+	 */
+	usleep_range(10, 20);
+
+	/*
+	 * De-assert reset for second set
+	 */
+	value &= ~(NSS_CORE_GCC_RESET_2 << (nss_dev->id << 3));
+	nss_write_32(nss_misc_reset, 0x0, value);
+
 	/*
 	 * Apply ubi32 core reset
 	 */
@@ -358,7 +394,6 @@
 {
 	struct device_node *cmn = NULL;
 	struct resource res_nss_misc_reset;
-	void __iomem *nss_misc_reset;
 
 	if (nss_hal_clock_set_and_enable(&nss_dev->dev, NSS_NOC_CLK, 461500000)) {
 		return -EFAULT;
@@ -434,11 +469,6 @@
 		return -EFAULT;
 	}
 
-	/*
-	 * Release UBI reset from GCC
-	 */
-	nss_write_32(nss_misc_reset, 0x0, 0x0);
-
 	nss_top_main.nss_hal_common_init_done = true;
 	nss_info("nss_hal_common_reset Done\n");
 	return 0;
diff --git a/nss_profiler.c b/nss_profiler.c
index 0ab421b..f0fb428 100644
--- a/nss_profiler.c
+++ b/nss_profiler.c
@@ -82,12 +82,18 @@
 	struct nss_ctx_instance *nss_ctx = (struct nss_ctx_instance *)ctx;
 	struct nss_profiler_msg *npm;
 	struct nss_profiler_data_msg *pdm = (struct nss_profiler_data_msg *)buf;
-	struct nss_cmn_msg *ncm;
 	nss_tx_status_t ret;
 
 	nss_trace("%p: Profiler If Tx, buf=%p", nss_ctx, buf);
 
-	if (NSS_NBUF_PAYLOAD_SIZE < (len + sizeof(npm))) {
+	if (sizeof(npm->payload) < len) {
+		nss_warning("%p: (%u)Bad message length(%u)", nss_ctx, NSS_PROFILER_INTERFACE, len);
+		return NSS_TX_FAILURE_TOO_LARGE;
+	}
+
+	if (NSS_NBUF_PAYLOAD_SIZE < (len + sizeof(npm->cm))) {
+		nss_warning("%p: (%u)Message length(%u) is larger than payload size (%u)",
+			nss_ctx, NSS_PROFILER_INTERFACE, (uint32_t)(len + sizeof(npm->cm)), NSS_NBUF_PAYLOAD_SIZE);
 		return NSS_TX_FAILURE_TOO_LARGE;
 	}
 
@@ -97,12 +103,11 @@
 		return NSS_TX_FAILURE;
 	}
 
-	ncm = &npm->cm;
 	memcpy(&npm->payload, pdm, len);
-	nss_profiler_msg_init(npm, NSS_PROFILER_INTERFACE, pdm->hd_magic & 0xFF, sizeof(npm),
+	nss_profiler_msg_init(npm, NSS_PROFILER_INTERFACE, pdm->hd_magic & 0xFF, len,
 				cb, app_data);
 
-	ret = nss_core_send_cmd(nss_ctx, npm, sizeof(*npm), NSS_NBUF_PAYLOAD_SIZE);
+	ret = nss_core_send_cmd(nss_ctx, npm, sizeof(npm->cm) + len, NSS_NBUF_PAYLOAD_SIZE);
 	kfree(npm);
 	return ret;
 }