Merge "[qca-nss-clients] Add Multicast support for pptp netlink module"
diff --git a/match/nss_match_cmd.c b/match/nss_match_cmd.c
index d42ee32..6807f61 100644
--- a/match/nss_match_cmd.c
+++ b/match/nss_match_cmd.c
@@ -552,7 +552,7 @@
  */
 static ssize_t nss_match_cmd_help(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
 {
-	size_t size_wr;
+	size_t size_wr = 0;
 	size_t size_al = NSS_STATS_MAX_STR_LENGTH * 24;
 	ssize_t bytes_read = 0;
 
diff --git a/profiler/profile.c b/profiler/profile.c
index dce3084..f19e4c3 100644
--- a/profiler/profile.c
+++ b/profiler/profile.c
@@ -417,9 +417,19 @@
 	}
 	if (pn->sw_ksp_ptr) {
 		struct debug_box *db = (struct debug_box *) pn->sw_ksp_ptr;
+
+		if ((void*)db != (void*)pn) {
+			profileWarn("%p: hwe data not ready %p\n", pn, db);
+			return -EAGAIN;
+		}
+
+		profileWarn("dbda %p: %x %x %x %x %x\n", db->data,
+			db->data[0], db->data[2], db->data[4], db->data[6], db->data[7]);
+
 		slen = (PROFILE_STS_EVENT_COUNTERS + 1) * sizeof(db->data[0]);
 		if (copy_to_user(buf, db->data, slen))
 			return -EFAULT;
+		profileInfo("%p: sw_ksp_ptr %p slen %d\n", pn, pn->sw_ksp_ptr, slen);
 		return	slen;
 	}
 
@@ -652,6 +662,7 @@
 	 * save data for read()
 	 */
 	memcpy(pdb->data, db->data, (db->dlen + 1) * sizeof(db->data[0]));
+	pio->sw_ksp_ptr = (uint32_t *)pdb;
 }
 
 /*
@@ -692,40 +703,66 @@
 	}
 
 	do {
-		int idx, event;
+		unsigned long idx;
+		int event, e5x;
+		char *kstrp;
 
 		while (isspace(*cp))
 			cp++;
-		if (kstrtoul(cp, 0, (unsigned long *)&event))
-			return -EINVAL;
-
-		cp = strchr(cp, ' ');
-		if (!cp) {
-			printk("missing index %s\n", buf);
+		kstrp = strchr(cp, ' ');
+		if (!kstrp) {
+			printk(KERN_ERR "%p missing index %p %s\n", buf, cp, cp);
 			return	-EINVAL;
 		}
-		while (isspace(*cp))
-			cp++;
-		idx = event >> 16;
-		if (idx) {
+		kstrp[0] = 0;
+
+		/*
+		 * kstrtoul bugs:
+		 *	it does not use white space for delimiter.
+		 *	it cannot use base 0, thus base 10 only.
+		 */
+		event = kstrtoul(cp, 10, &idx);
+		if (event) {
+			printk(KERN_ERR "kstrtoul %d: %s\n", event, cp);
+			return -EINVAL;
+		}
+		event = idx;
+
+		/*
+		 * Processing thread specific events, which requires hex values.
+		 * Because kstrtoul cannot use base 0, it makes this task harder
+		 * in user space. Users need to convert hex value to decimal, then
+		 * pass them in userland command event-counter.
+		 */
+		e5x = event >> 16;
+		if (e5x) {
 			if ((event & 0x1FF) < 50) {
-				printk("thr ID (%d) ignored for event %d\n",
-					idx, event & 0x1FF);
-			} else if (idx > 12) {
-				if ((idx >>= 5) > 12) {
-					printk("tID %d too big [1..12]\n", idx);
+				printk(KERN_INFO "thr ID (%d) ignored for event %d\n",
+					e5x, event & 0x1FF);
+			} else if (e5x > 12) {
+				if ((e5x >>= 5) > 12) {
+					printk(KERN_INFO "tID %d too big [1..12]\n", e5x);
 					return	-E2BIG;
 				}
 			}
 		}
 
-		if (kstrtoul(cp, 10, (unsigned long *)&idx) || idx < 0 || idx > 7) {
-			printk("index %d out of range [0..7]\n", idx);
+		cp = kstrp + 1;
+		while (isspace(*cp))
+			cp++;
+		kstrp = strchr(cp, ' ');
+		if (kstrp) {
+			kstrp[0] = 0;
+			kstrp++;
+		}
+
+		if (kstrtoul(cp, 10, &idx) || idx < 0 || idx > 7) {
+			printk(KERN_ERR "bad index %ld [0..7]\n", idx);
 			return	-ERANGE;
 		}
-		printk("%p: e %d i %d\n", db, event, idx);
+		printk(KERN_INFO "%p: e %d i %ld\n", db, event, idx);
 		db->data[idx] = event;
-		cp = strchr(cp, ' ');
+		cp = kstrp;
 	} while (cp);
 	db->hd_magic = NSS_PROFILE_HD_MAGIC | NSS_PROFILER_SET_SYS_STAT_EVENT;
 	result = nss_profiler_if_tx_buf(pio->ctx, &pio->pnc.un, sizeof(pio->pnc.un),
@@ -874,7 +911,7 @@
 			/*
 			 * set flag so event-counter can read the data from FW
 			 */
-			pio->sw_ksp_ptr = (uint32_t *)db;
+			pio->sw_ksp_ptr = db->data;
 		}
 		return	result;
 	}
diff --git a/tls/nss_tlsmgr_ctx.c b/tls/nss_tlsmgr_ctx.c
index e846f0b..f6c5d9d 100644
--- a/tls/nss_tlsmgr_ctx.c
+++ b/tls/nss_tlsmgr_ctx.c
@@ -79,14 +79,12 @@
 	{"\trx_ccs_rec", NSS_TLSMGR_PRINT_DWORD},
 	{"\tfail_ccs", NSS_TLSMGR_PRINT_DWORD},
 	{"\teth_node_deactive", NSS_TLSMGR_PRINT_DWORD},
-	{"\tfail_dma_avail", NSS_TLSMGR_PRINT_DWORD},
 	{"\tcrypto_alloc_success", NSS_TLSMGR_PRINT_DWORD},
 	{"\tcrypto_free_req", NSS_TLSMGR_PRINT_DWORD},
 	{"\tcrypto_free_success", NSS_TLSMGR_PRINT_DWORD},
 	{"\tfail_crypto_alloc", NSS_TLSMGR_PRINT_DWORD},
 	{"\tfail_crypto_lookup", NSS_TLSMGR_PRINT_DWORD},
 	{"\tfail_req_alloc", NSS_TLSMGR_PRINT_DWORD},
-	{"\tfail_req_detach", NSS_TLSMGR_PRINT_DWORD},
 	{"\tfail_pbuf_stats", NSS_TLSMGR_PRINT_DWORD},
 	{"\tfail_ctx_active", NSS_TLSMGR_PRINT_DWORD},
 
@@ -101,6 +99,10 @@
 	{"\thw_auth_error", NSS_TLSMGR_PRINT_DWORD},
 	{"\thw_pad_verify_error", NSS_TLSMGR_PRINT_DWORD},
 	{"\thw_timeout_error", NSS_TLSMGR_PRINT_DWORD},
+
+	{"\tno_desc_in", NSS_TLSMGR_PRINT_DWORD},
+	{"\tno_desc_out", NSS_TLSMGR_PRINT_DWORD},
+	{"\tno_reqs", NSS_TLSMGR_PRINT_DWORD},
 };
 
 #ifdef NSS_TLSMGR_DEBUG_DUMP
diff --git a/tls/nss_tlsmgr_ctx.h b/tls/nss_tlsmgr_ctx.h
index bec13af..ff49a42 100644
--- a/tls/nss_tlsmgr_ctx.h
+++ b/tls/nss_tlsmgr_ctx.h
@@ -42,14 +42,12 @@
 	uint64_t rx_ccs_rec;			/**< Number of change cipher spec records received. */
 	uint64_t fail_ccs;			/**< Failed to switch to new crypto. */
 	uint64_t eth_node_deactive;		/**< Ethernet node deactivated as no crypto available. */
-	uint64_t fail_dma_avail;		/**< No DMA avail. */
 	uint64_t crypto_alloc_success;		/**< Number of crypto allocation. */
 	uint64_t crypto_free_req;		/**< Number of crypto free request. */
 	uint64_t crypto_free_success;		/**< Number of crypto free success. */
 	uint64_t fail_crypto_alloc;		/**< Number of crypto allocation failed. */
 	uint64_t fail_crypto_lookup;		/**< Failed to find acive crypto session. */
 	uint64_t fail_req_alloc;		/**< Failuer to allocate request memory pool.  */
-	uint64_t fail_req_detach;		/**< Failure to get new request from pool. */
 	uint64_t fail_pbuf_stats;		/**< Failure in pbuf allocation for statistics. */
 	uint64_t fail_ctx_active;		/**< Failure in enqueue due to inactive context. */
 
@@ -67,6 +65,13 @@
 	uint64_t hw_auth_error;         	/**< Hash input overflow. */
 	uint64_t hw_pad_verify_error;		/**< Pad verification error. */
 	uint64_t hw_timeout_error;              /**< Data timed-out. */
+
+	/*
+	 * Performance statistics
+	 */
+	uint64_t no_desc_in;			/**< Ingress DMA descriptor not available. */
+	uint64_t no_desc_out;			/**< Egress DMA descriptor not available. */
+	uint64_t no_reqs;			/**< Not enough requests available for records. */
 };
 
 /*