[qca-nss-drv] 64 bits support

1. Set message/data buffer opaque size based on 32/64 bits platform
2. Support NET_SKBUFF_DATA_USES_OFFSET
3. Use __iomem type for system io address

Change-Id: Idc2278a2174513658046303a8e9b72d868ac97b2
Signed-off-by: Stephen Wang <wstephen@codeaurora.org>
diff --git a/exports/nss_cmn.h b/exports/nss_cmn.h
index fa9a2d6..10ef9a7 100644
--- a/exports/nss_cmn.h
+++ b/exports/nss_cmn.h
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2014, 2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014, 2016-2017, 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.
@@ -110,13 +110,20 @@
  */
 struct nss_cmn_msg {
 	uint16_t version;		/**< Version id for main message format */
-	uint16_t interface;		/**< Primary Key for all messages */
+	uint16_t len;			/**< What is the length of the message excluding this header */
+	uint32_t interface;		/**< Primary Key for all messages */
 	enum nss_cmn_response response;	/**< Primary response */
 	uint32_t type;			/**< Decetralized request #, to be used to match response # */
 	uint32_t error;			/**< Decentralized specific error message, response == EMSG */
-	uint32_t cb;			/**< Place for callback pointer */
-	uint32_t app_data;		/**< Place for app data */
-	uint32_t len;			/**< What is the length of the message excluding this header */
+	uint32_t reserved;		/**< Pad to make below cb starting from 64 bits boundary, this can be reused */
+	nss_ptr_t cb;			/**< Place for callback pointer */
+#ifndef __LP64__
+	uint32_t padding1;		/**< Pad to fit 64 bits, do not reuse */
+#endif
+	nss_ptr_t app_data;		/**< Place for app data */
+#ifndef __LP64__
+	uint32_t padding2;		/**< Pad to fit 64 bits, do not reuse */
+#endif
 };
 
 /**
diff --git a/exports/nss_def.h b/exports/nss_def.h
index 6afa295..11096fc 100644
--- a/exports/nss_def.h
+++ b/exports/nss_def.h
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2015, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2015-2017, 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.
@@ -36,4 +36,10 @@
  */
 #define NSS_MC_IF_MAX 16
 
+#ifdef __LP64__
+typedef uint64_t nss_ptr_t;
+#else
+typedef uint32_t nss_ptr_t;
+#endif
+
 #endif /** __NSS_DEF_H */
diff --git a/nss_bridge.c b/nss_bridge.c
index e1ddff9..2f6aa8f 100644
--- a/nss_bridge.c
+++ b/nss_bridge.c
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2016 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2017 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.
@@ -63,8 +63,8 @@
 	 * to the same callback/app_data.
 	 */
 	if (ncm->response == NSS_CMM_RESPONSE_NOTIFY) {
-		ncm->cb = (uint32_t)nss_ctx->nss_top->bridge_callback;
-		ncm->app_data = (uint32_t)nss_ctx->nss_top->bridge_ctx;
+		ncm->cb = (nss_ptr_t)nss_ctx->nss_top->bridge_callback;
+		ncm->app_data = (nss_ptr_t)nss_ctx->nss_top->bridge_ctx;
 	}
 
 	/*
@@ -197,8 +197,8 @@
 	bridge_pvt.cb = (void *)nbm->cm.cb;
 	bridge_pvt.app_data = (void *)nbm->cm.app_data;
 
-	nbm->cm.cb = (uint32_t)nss_bridge_callback;
-	nbm->cm.app_data = (uint32_t)NULL;
+	nbm->cm.cb = (nss_ptr_t)nss_bridge_callback;
+	nbm->cm.app_data = (nss_ptr_t)NULL;
 
 	status = nss_bridge_tx_msg(nss_ctx, nbm);
 	if (status != NSS_TX_SUCCESS) {
diff --git a/nss_capwap.c b/nss_capwap.c
index 1ba84d8..f155879 100644
--- a/nss_capwap.c
+++ b/nss_capwap.c
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2017, 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.
@@ -211,7 +211,7 @@
 	 * Update the callback and app_data for NOTIFY messages.
 	 */
 	if (ncm->response == NSS_CMM_RESPONSE_NOTIFY) {
-		ncm->cb = (uint32_t)nss_capwap_get_msg_callback(ncm->interface, (void **)&ncm->app_data);
+		ncm->cb = (nss_ptr_t)nss_capwap_get_msg_callback(ncm->interface, (void **)&ncm->app_data);
 	}
 
 	/*
diff --git a/nss_cmn.c b/nss_cmn.c
index a29546d..5bd3728 100644
--- a/nss_cmn.c
+++ b/nss_cmn.c
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2014-2016 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2017 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.
@@ -48,8 +48,8 @@
 	ncm->version = NSS_HLOS_MESSAGE_VERSION;
 	ncm->type = type;
 	ncm->len = len;
-	ncm->cb = (uint32_t)cb;
-	ncm->app_data = (uint32_t)app_data;
+	ncm->cb = (nss_ptr_t)cb;
+	ncm->app_data = (nss_ptr_t)app_data;
 }
 
 /*
diff --git a/nss_core.c b/nss_core.c
index 8e6fbfe..4fc7f64 100644
--- a/nss_core.c
+++ b/nss_core.c
@@ -347,7 +347,7 @@
 static inline void nss_dump_desc(struct nss_ctx_instance *nss_ctx, struct n2h_descriptor *desc)
 {
 	printk("bad descriptor dump for nss core = %d\n", nss_ctx->id);
-	printk("\topaque = %x\n", desc->opaque);
+	printk("\topaque = %p\n", (void *)desc->opaque);
 	printk("\tinterface = %d\n", desc->interface_num);
 	printk("\tbuffer_type = %d\n", desc->buffer_type);
 	printk("\tbit_flags = %x\n", desc->bit_flags);
@@ -833,7 +833,7 @@
 	 */
 	nbuf->data = nbuf->head + desc->payload_offs;
 	nbuf->len = desc->payload_len;
-	nbuf->tail = nbuf->data + nbuf->len;
+	skb_set_tail_pointer(nbuf, nbuf->len);
 	dma_unmap_single(nss_ctx->dev, (desc->buffer + desc->payload_offs), desc->payload_len, DMA_FROM_DEVICE);
 	prefetch((void *)(nbuf->data));
 
@@ -987,7 +987,7 @@
 	nss_assert(qid < if_map->n2h_rings);
 
 	n2h_desc_ring = &nss_ctx->n2h_desc_ring[qid];
-	desc_if = &n2h_desc_ring->desc_if;
+	desc_if = &n2h_desc_ring->desc_ring;
 	desc_ring = desc_if->desc;
 	nss_index = if_map->n2h_nss_index[qid];
 	hlos_index = n2h_desc_ring->hlos_index;
@@ -1012,7 +1012,7 @@
 	count_temp = count;
 	while (count_temp) {
 		unsigned int buffer_type;
-		uint32_t opaque;
+		nss_ptr_t opaque;
 		uint16_t bit_flags;
 
 		desc = &desc_ring[hlos_index];
@@ -1157,19 +1157,15 @@
 	 */
 	for (i = 0; i < if_map->n2h_rings; i++) {
 		struct hlos_n2h_desc_ring *n2h_desc_ring = &nss_ctx->n2h_desc_ring[i];
-		n2h_desc_ring->desc_if.desc =
-			(struct n2h_descriptor *)((uint32_t)if_map->n2h_desc_if[i].desc - (uint32_t)nss_ctx->vphys + (uint32_t)nss_ctx->vmap);
-		n2h_desc_ring->desc_if.size = if_map->n2h_desc_if[i].size;
-		n2h_desc_ring->desc_if.int_bit = if_map->n2h_desc_if[i].int_bit;
+		n2h_desc_ring->desc_ring.desc = (struct n2h_descriptor *)(nss_ctx->vmap + if_map->n2h_desc_if[i].desc_addr - nss_ctx->vphys);
+		n2h_desc_ring->desc_ring.size = if_map->n2h_desc_if[i].size;
 		n2h_desc_ring->hlos_index = if_map->n2h_hlos_index[i];
 	}
 
 	for (i = 0; i < if_map->h2n_rings; i++) {
 		struct hlos_h2n_desc_rings *h2n_desc_ring = &nss_ctx->h2n_desc_rings[i];
-		h2n_desc_ring->desc_ring.desc =
-			(struct h2n_descriptor *)((uint32_t)if_map->h2n_desc_if[i].desc - (uint32_t)nss_ctx->vphys + (uint32_t)nss_ctx->vmap);
+		h2n_desc_ring->desc_ring.desc = (struct h2n_descriptor *)(nss_ctx->vmap + if_map->h2n_desc_if[i].desc_addr - nss_ctx->vphys);
 		h2n_desc_ring->desc_ring.size = if_map->h2n_desc_if[i].size;
-		h2n_desc_ring->desc_ring.int_bit = if_map->h2n_desc_if[i].int_bit;
 		h2n_desc_ring->hlos_index = if_map->h2n_hlos_index[i];
 		spin_lock_init(&h2n_desc_ring->lock);
 	}
@@ -1255,12 +1251,12 @@
 		if (unlikely(nss_ctx->state == NSS_CORE_STATE_UNINITIALIZED)) {
 			nss_core_init_nss(nss_ctx, if_map);
 
+#if (NSS_MAX_CORES > 1)
 			/*
 			 * Pass C2C addresses of already brought up cores to the recently brought
 			 * up core. No NSS core knows the state of other other cores in system so
 			 * NSS driver needs to mediate and kick start C2C between them
 			 */
-#if (NSS_MAX_CORES > 1)
 			for (i = 0; i < NSS_MAX_CORES; i++) {
 				/*
 				 * Loop through all NSS cores and send exchange C2C addresses
@@ -1302,7 +1298,7 @@
 		mask = size - 1;
 		count = ((nss_index - hlos_index - 1) + size) & (mask);
 
-		nss_trace("%p: Adding %d buffers to empty queue", nss_ctx, count);
+		nss_trace("%p: Adding %d buffers to empty queue\n", nss_ctx, count);
 
 		/*
 		 * Fill empty buffer queue with buffers leaving one empty descriptor
@@ -1404,7 +1400,7 @@
 			kmemleak_not_leak(nbuf);
 			NSS_PKT_STATS_INCREMENT(nss_ctx, &nss_ctx->nss_top->stats_drv[NSS_STATS_DRV_NSS_SKB_COUNT]);
 
-			desc->opaque = (uint32_t)nbuf;
+			desc->opaque = (nss_ptr_t)nbuf;
 			desc->buffer = buffer;
 			desc->buffer_type = H2N_BUFFER_EMPTY;
 			hlos_index = (hlos_index + 1) & (mask);
@@ -1594,7 +1590,7 @@
  */
 static inline void nss_core_write_one_descriptor(struct h2n_descriptor *desc,
 	uint16_t buffer_type, uint32_t buffer, uint32_t if_num,
-	uint32_t opaque, uint16_t payload_off, uint16_t payload_len, uint16_t buffer_len,
+	nss_ptr_t opaque, uint16_t payload_off, uint16_t payload_len, uint16_t buffer_len,
 	uint32_t qos_tag, uint16_t mss, uint16_t bit_flags)
 {
 	desc->buffer_type = buffer_type;
@@ -1632,6 +1628,26 @@
 	}
 }
 
+/*
+ * nss_core_skb_tail_offset()
+ */
+static inline uint32_t nss_core_skb_tail_offset(struct sk_buff *skb)
+{
+#ifdef NET_SKBUFF_DATA_USES_OFFSET
+	return skb->tail;
+#else
+	return skb->tail - skb->head;
+#endif
+}
+
+/*
+ * nss_core_dma_map_single()
+ */
+static inline uint32_t nss_core_dma_map_single(struct device *dev, struct sk_buff *skb)
+{
+	return (uint32_t)dma_map_single(dev, skb->head, nss_core_skb_tail_offset(skb), DMA_TO_DEVICE);
+}
+
 #if (NSS_SKB_RECYCLE_SUPPORT == 1)
 /*
  * nss_skb_can_recycle
@@ -1786,7 +1802,7 @@
 	 * We are going to do both Tx and then Rx on this buffer, unmap the Tx
 	 * and then map Rx over the entire buffer.
 	 */
-	sz = max((uint16_t)(nbuf->tail - nbuf->head), (uint16_t)(nss_ctx->max_buf_size + NET_SKB_PAD));
+	sz = max((uint16_t)nss_core_skb_tail_offset(nbuf), (uint16_t)(nss_ctx->max_buf_size + NET_SKB_PAD));
 	frag0phyaddr = (uint32_t)dma_map_single(nss_ctx->dev, nbuf->head, sz, DMA_TO_DEVICE);
 	if (unlikely(dma_mapping_error(nss_ctx->dev, frag0phyaddr))) {
 		goto no_reuse;
@@ -1797,7 +1813,7 @@
 	 */
 	bit_flags |= H2N_BIT_FLAG_BUFFER_REUSE;
 	nss_core_write_one_descriptor(desc, buffer_type, frag0phyaddr, if_num,
-		(uint32_t)nbuf, (uint16_t)(nbuf->data - nbuf->head), nbuf->len,
+		(nss_ptr_t)nbuf, (uint16_t)(nbuf->data - nbuf->head), nbuf->len,
 		sz, (uint32_t)nbuf->priority, mss, bit_flags);
 
 	/*
@@ -1811,16 +1827,15 @@
 no_reuse:
 #endif
 
-	frag0phyaddr = 0;
-	frag0phyaddr = (uint32_t)dma_map_single(nss_ctx->dev, nbuf->head, (nbuf->tail - nbuf->head), DMA_TO_DEVICE);
+	frag0phyaddr = nss_core_dma_map_single(nss_ctx->dev, nbuf);
 	if (unlikely(dma_mapping_error(nss_ctx->dev, frag0phyaddr))) {
-		nss_warning("%p: DMA mapping failed for virtual address = %x", nss_ctx, (uint32_t)nbuf->head);
+		nss_warning("%p: DMA mapping failed for virtual address = %p", nss_ctx, nbuf->head);
 		return 0;
 	}
 
 	nss_core_write_one_descriptor(desc, buffer_type, frag0phyaddr, if_num,
-		(uint32_t)nbuf, (uint16_t)(nbuf->data - nbuf->head), nbuf->len,
-		(uint16_t)(nbuf->end - nbuf->head), (uint32_t)nbuf->priority, mss, bit_flags);
+		(nss_ptr_t)nbuf, (uint16_t)(nbuf->data - nbuf->head), nbuf->len,
+		(uint16_t)skb_end_offset(nbuf), (uint32_t)nbuf->priority, mss, bit_flags);
 
 	NSS_PKT_STATS_INCREMENT(nss_ctx, &nss_ctx->nss_top->stats_drv[NSS_STATS_DRV_TX_SIMPLE]);
 	return 1;
@@ -1846,10 +1861,9 @@
 	int16_t i;
 	uint16_t mask;
 
-	uint32_t frag0phyaddr = 0;
-	frag0phyaddr = (uint32_t)dma_map_single(nss_ctx->dev, nbuf->head, (nbuf->tail - nbuf->head), DMA_TO_DEVICE);
+	uint32_t frag0phyaddr = nss_core_dma_map_single(nss_ctx->dev, nbuf);
 	if (unlikely(dma_mapping_error(nss_ctx->dev, frag0phyaddr))) {
-		nss_warning("%p: DMA mapping failed for virtual address = %x", nss_ctx, (uint32_t)nbuf->head);
+		nss_warning("%p: DMA mapping failed for virtual address = %p", nss_ctx, nbuf->head);
 		return 0;
 	}
 
@@ -1868,8 +1882,8 @@
 	 * First fragment/descriptor is special
 	 */
 	nss_core_write_one_descriptor(desc, buffer_type, frag0phyaddr, if_num,
-		(uint32_t)NULL, nbuf->data - nbuf->head, nbuf->len - nbuf->data_len,
-		nbuf->end - nbuf->head, (uint32_t)nbuf->priority, mss, bit_flags | H2N_BIT_FLAG_FIRST_SEGMENT);
+		(nss_ptr_t)NULL, nbuf->data - nbuf->head, nbuf->len - nbuf->data_len,
+		skb_end_offset(nbuf), (uint32_t)nbuf->priority, mss, bit_flags | H2N_BIT_FLAG_FIRST_SEGMENT);
 
 	/*
 	 * Now handle rest of the fragments.
@@ -1890,7 +1904,7 @@
 		desc = &(desc_if->desc[hlos_index]);
 
 		nss_core_write_one_descriptor(desc, buffer_type, buffer, if_num,
-			(uint32_t)NULL, 0, skb_frag_size(frag), skb_frag_size(frag),
+			(nss_ptr_t)NULL, 0, skb_frag_size(frag), skb_frag_size(frag),
 			nbuf->priority, mss, bit_flags);
 	}
 
@@ -1905,7 +1919,7 @@
 	 */
 	desc->bit_flags |= H2N_BIT_FLAG_LAST_SEGMENT;
 	desc->bit_flags &= ~(H2N_BIT_FLAG_DISCARD);
-	desc->opaque = (uint32_t)nbuf;
+	desc->opaque = (nss_ptr_t)nbuf;
 	NSS_PKT_STATS_INCREMENT(nss_ctx, &nss_ctx->nss_top->stats_drv[NSS_STATS_DRV_TX_NR_FRAGS]);
 	return i+1;
 }
@@ -1929,10 +1943,9 @@
 	uint16_t bit_flags;
 	int16_t i;
 
-	uint32_t frag0phyaddr = 0;
-	frag0phyaddr = (uint32_t)dma_map_single(nss_ctx->dev, nbuf->head, (nbuf->tail - nbuf->head), DMA_TO_DEVICE);
+	uint32_t frag0phyaddr = nss_core_dma_map_single(nss_ctx->dev, nbuf);
 	if (unlikely(dma_mapping_error(nss_ctx->dev, frag0phyaddr))) {
-		nss_warning("%p: DMA mapping failed for virtual address = %x", nss_ctx, (uint32_t)nbuf->head);
+		nss_warning("%p: DMA mapping failed for virtual address = %p", nss_ctx, nbuf->head);
 		return 0;
 	}
 
@@ -1951,8 +1964,8 @@
 	 * First fragment/descriptor is special. Will hold the Opaque
 	 */
 	nss_core_write_one_descriptor(desc, buffer_type, frag0phyaddr, if_num,
-		(uint32_t)nbuf, nbuf->data - nbuf->head, nbuf->len - nbuf->data_len,
-		nbuf->end - nbuf->head, (uint32_t)nbuf->priority, mss, bit_flags | H2N_BIT_FLAG_FIRST_SEGMENT);
+		(nss_ptr_t)nbuf, nbuf->data - nbuf->head, nbuf->len - nbuf->data_len,
+		skb_end_offset(nbuf), (uint32_t)nbuf->priority, mss, bit_flags | H2N_BIT_FLAG_FIRST_SEGMENT);
 
 	/*
 	 * Set everyone but first fragment/descriptor as discard
@@ -1966,9 +1979,9 @@
 	skb_walk_frags(nbuf, iter) {
 		uint32_t nr_frags;
 
-		buffer = (uint32_t)dma_map_single(nss_ctx->dev, iter->head, (iter->tail - iter->head), DMA_TO_DEVICE);
+		buffer = nss_core_dma_map_single(nss_ctx->dev, iter);
 		if (unlikely(dma_mapping_error(nss_ctx->dev, buffer))) {
-			nss_warning("%p: DMA mapping failed for virtual address = %x", nss_ctx, (uint32_t)iter->head);
+			nss_warning("%p: DMA mapping failed for virtual address = %p", nss_ctx, iter->head);
 			nss_core_send_unwind_dma(nss_ctx->dev, desc_if, hlos_index, i + 1, is_fraglist);
 			return -(i+1);
 		}
@@ -1991,8 +2004,8 @@
 		desc = &(desc_if->desc[hlos_index]);
 
 		nss_core_write_one_descriptor(desc, buffer_type, buffer, if_num,
-			(uint32_t)NULL, iter->data - iter->head, iter->len - iter->data_len,
-			iter->end - iter->head, iter->priority, mss, bit_flags);
+			(nss_ptr_t)NULL, iter->data - iter->head, iter->len - iter->data_len,
+			skb_end_offset(iter), iter->priority, mss, bit_flags);
 
 		i++;
 	}
@@ -2027,8 +2040,6 @@
 	size = desc_if->size;
 	mask = size - 1;
 
-
-
 	/*
 	 * If nbuf does not have fraglist, then update nr_frags
 	 * from frags[] array. Otherwise walk the frag_list.
diff --git a/nss_core.h b/nss_core.h
index e19c5bb..e396f1f 100644
--- a/nss_core.h
+++ b/nss_core.h
@@ -830,7 +830,7 @@
  * N2H descriptor ring information
  */
 struct hlos_n2h_desc_ring {
-	struct n2h_desc_if_instance desc_if;
+	struct n2h_desc_if_instance desc_ring;
 					/* Descriptor ring */
 	uint32_t hlos_index;		/* Current HLOS index for this ring */
 	struct sk_buff *head;		/* First segment of an skb fraglist */
@@ -871,9 +871,9 @@
 					/* Back pointer to NSS Top */
 	struct device *dev;		/* Pointer to the original device from probe */
 	uint32_t id;			/* Core ID for this instance */
-	uint32_t nmap;			/* Pointer to NSS CSM registers */
-	uint32_t vmap;			/* Virt mem pointer to virtual register map */
-	uint32_t qgic_map;		/* Virt mem pointer to QGIC register */
+	void __iomem *nmap;		/* Pointer to NSS CSM registers */
+	void __iomem *vmap;		/* Virt mem pointer to virtual register map */
+	void __iomem *qgic_map;	/* Virt mem pointer to QGIC register */
 	uint32_t nphys;			/* Phys mem pointer to CSM register map */
 	uint32_t vphys;			/* Phys mem pointer to virtual register map */
 	uint32_t qgic_phys;		/* Phys mem pointer to QGIC register map */
@@ -1227,16 +1227,16 @@
 
 /*
  * nss_platform_data
- *	Platform data per core
+ *      Platform data per core
  */
 struct nss_platform_data {
 	uint32_t id;					/* NSS core ID */
 	uint32_t num_queue;				/* No. of queues supported per core */
 	uint32_t num_irq;				/* No. of irq binded per queue */
 	uint32_t irq[5];				/* IRQ numbers per queue */
-	uint32_t nmap;					/* Virtual addr of NSS CSM space */
-	uint32_t vmap;					/* Virtual addr of NSS virtual register map */
-	uint32_t qgic_map;				/* Virtual addr of QGIC interrupt register */
+	void __iomem *nmap;				/* Virtual addr of NSS CSM space */
+	void __iomem *vmap;				/* Virtual addr of NSS virtual register map */
+	void __iomem *qgic_map;			/* Virtual addr of QGIC interrupt register */
 	uint32_t nphys;					/* Physical addr of NSS CSM space */
 	uint32_t vphys;					/* Physical addr of NSS virtual register map */
 	uint32_t qgic_phys;				/* Physical addr of QGIC virtual register map */
diff --git a/nss_coredump.c b/nss_coredump.c
index f621d88..1d870a2 100644
--- a/nss_coredump.c
+++ b/nss_coredump.c
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2015, 2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2015-2017, 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.
@@ -78,7 +78,7 @@
 			continue;
 		nss_ctx->state |= NSS_CORE_STATE_PANIC;
 		nss_hal_send_interrupt(nss_ctx, NSS_H2N_INTR_TRIGGER_COREDUMP);
-		nss_warning("panic call NSS FW %x to dump %x\n",
+		nss_warning("panic call NSS FW %p to dump %x\n",
 			nss_ctx->nmap, nss_ctx->state);
 	}
 
@@ -132,7 +132,7 @@
 				int intr __attribute__ ((unused)))
 {
 	int i;
-	nss_warning("\n%p: COREDUMP %x Baddr %x stat %x\n",
+	nss_warning("\n%p: COREDUMP %x Baddr %p stat %x\n",
 			nss_own, intr, nss_own->nmap, nss_own->state);
 	nss_own->state |= NSS_CORE_STATE_FW_DEAD;
 	queue_delayed_work(coredump_workqueue, &coredump_queuewait,
@@ -157,7 +157,7 @@
 				 */
 				panic("NSS FW coredump: bringing system down\n");
 			}
-			nss_warning("notify NSS FW %X for coredump\n",
+			nss_warning("notify NSS FW %p for coredump\n",
 				nss_ctx->nmap);
 			nss_hal_send_interrupt(nss_ctx, NSS_H2N_INTR_TRIGGER_COREDUMP);
 		}
diff --git a/nss_crypto.c b/nss_crypto.c
index 7697414..75ad1e0 100644
--- a/nss_crypto.c
+++ b/nss_crypto.c
@@ -87,8 +87,8 @@
 	}
 
 	if (ncm->response == NSS_CMM_RESPONSE_NOTIFY) {
-		ncm->cb = (uint32_t)nss_crypto_get_msg_callback(nss_ctx, &crypto_ctx);
-		ncm->app_data = (uint32_t)crypto_ctx;
+		ncm->cb = (nss_ptr_t)nss_crypto_get_msg_callback(nss_ctx, &crypto_ctx);
+		ncm->app_data = (nss_ptr_t)crypto_ctx;
 	}
 
 
@@ -132,7 +132,7 @@
 
 	if (NSS_NBUF_PAYLOAD_SIZE < sizeof(struct nss_crypto_msg)) {
 		nss_warning("%p: tx message request is too large: %d (desired), %d (requested)", nss_ctx,
-				NSS_NBUF_PAYLOAD_SIZE, sizeof(struct nss_crypto_msg));
+				NSS_NBUF_PAYLOAD_SIZE, (int)sizeof(struct nss_crypto_msg));
 		return NSS_TX_FAILURE_TOO_LARGE;
 	}
 
@@ -157,8 +157,8 @@
 		return NSS_TX_FAILURE;
 	}
 
-	nss_info("msg params version:%d, interface:%d, type:%d, cb:%d, app_data:%d, len:%d\n",
-			ncm->version, ncm->interface, ncm->type, ncm->cb, ncm->app_data, ncm->len);
+	nss_info("msg params version:%d, interface:%d, type:%d, cb:%p, app_data:%p, len:%d\n",
+			ncm->version, ncm->interface, ncm->type, (void *)ncm->cb, (void *)ncm->app_data, ncm->len);
 
 	nim = (struct nss_crypto_msg *)skb_put(nbuf, sizeof(struct nss_crypto_msg));
 	memcpy(nim, msg, sizeof(struct nss_crypto_msg));
diff --git a/nss_dtls.c b/nss_dtls.c
index d4e21ee..5c9ec5c 100644
--- a/nss_dtls.c
+++ b/nss_dtls.c
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2017, 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.
@@ -185,8 +185,8 @@
 	 * Update the callback and app_data for NOTIFY messages
 	 */
 	if (ncm->response == NSS_CMM_RESPONSE_NOTIFY) {
-		ncm->cb = (uint32_t)nss_ctx->nss_top->dtls_msg_callback;
-		ncm->app_data = (uint32_t)nss_ctx->nss_top->subsys_dp_register[ncm->interface].app_data;
+		ncm->cb = (nss_ptr_t)nss_ctx->nss_top->dtls_msg_callback;
+		ncm->app_data = (nss_ptr_t)nss_ctx->nss_top->subsys_dp_register[ncm->interface].app_data;
 	}
 
 	/*
@@ -364,8 +364,8 @@
 	dtls_pvt.cb = (void *)msg->cm.cb;
 	dtls_pvt.app_data = (void *)msg->cm.app_data;
 
-	msg->cm.cb = (uint32_t)nss_dtls_callback;
-	msg->cm.app_data = (uint32_t)NULL;
+	msg->cm.cb = (nss_ptr_t)nss_dtls_callback;
+	msg->cm.app_data = (nss_ptr_t)NULL;
 
 	status = nss_dtls_tx_msg(nss_ctx, msg);
 	if (status != NSS_TX_SUCCESS) {
@@ -452,8 +452,6 @@
 {
 	int32_t i;
 
-	struct nss_ctx_instance *nss_ctx = nss_dtls_get_context();
-
 	BUG_ON(!nss_dtls_verify_if_num(if_num));
 
 	spin_lock_bh(&nss_dtls_session_debug_stats_lock);
@@ -468,13 +466,13 @@
 
 	if (i == NSS_MAX_DTLS_SESSIONS) {
 		nss_warning("%p: Cannot find debug stats for "
-			    "DTLS session %d\n", nss_ctx, if_num);
+			    "DTLS session %d\n", nss_dtls_get_context(), if_num);
 		return;
 	}
 
 	if (!nss_top_main.subsys_dp_register[if_num].ndev) {
 		nss_warning("%p: Cannot find registered netdev for "
-			    "DTLS NSS I/F:%u\n", nss_ctx, if_num);
+			    "DTLS NSS I/F:%u\n", nss_dtls_get_context(), if_num);
 
 		return;
 	}
diff --git a/nss_edma.c b/nss_edma.c
index 5af20f3..9772c82 100644
--- a/nss_edma.c
+++ b/nss_edma.c
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2017, 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.
@@ -147,8 +147,8 @@
 	 * to the same callback/app_data.
 	 */
 	if (nem->cm.response == NSS_CMM_RESPONSE_NOTIFY) {
-		ncm->cb = (uint32_t)nss_ctx->nss_top->edma_callback;
-		ncm->app_data = (uint32_t)nss_ctx->nss_top->edma_ctx;
+		ncm->cb = (nss_ptr_t)nss_ctx->nss_top->edma_callback;
+		ncm->app_data = (nss_ptr_t)nss_ctx->nss_top->edma_ctx;
 	}
 
 	/*
diff --git a/nss_gre_redir.c b/nss_gre_redir.c
index 8ffa9a1..f6431b7 100644
--- a/nss_gre_redir.c
+++ b/nss_gre_redir.c
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2017, 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.
@@ -87,7 +87,7 @@
 	 * to the same callback/app_data.
 	 */
 	if (ncm->response == NSS_CMM_RESPONSE_NOTIFY) {
-		ncm->cb = (uint32_t)nss_ctx->nss_top->if_rx_msg_callback[ncm->interface];
+		ncm->cb = (nss_ptr_t)nss_ctx->nss_top->if_rx_msg_callback[ncm->interface];
 	}
 
 	/*
diff --git a/nss_gre_tunnel.c b/nss_gre_tunnel.c
index e363021..1f3944a 100644
--- a/nss_gre_tunnel.c
+++ b/nss_gre_tunnel.c
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2017, 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.
@@ -166,8 +166,8 @@
 	 * Update the callback and app_data for NOTIFY messages
 	 */
 	if (ncm->response == NSS_CMM_RESPONSE_NOTIFY) {
-		ncm->cb = (uint32_t)nss_ctx->nss_top->gre_tunnel_msg_callback;
-		ncm->app_data = (uint32_t)nss_ctx->nss_top->subsys_dp_register[ncm->interface].app_data;
+		ncm->cb = (nss_ptr_t)nss_ctx->nss_top->gre_tunnel_msg_callback;
+		ncm->app_data = (nss_ptr_t)nss_ctx->nss_top->subsys_dp_register[ncm->interface].app_data;
 	}
 
 	nss_core_log_msg_failures(nss_ctx, ncm);
@@ -225,7 +225,6 @@
 				struct nss_ctx_instance *nss_ctx)
 {
 	int32_t status;
-	uint16_t int_bit = 0;
 
 	BUG_ON(!nss_gre_tunnel_verify_if_num(if_num));
 	NSS_VERIFY_CTX_MAGIC(nss_ctx);
@@ -235,7 +234,6 @@
 		return NSS_TX_FAILURE_NOT_READY;
 	}
 
-	int_bit = nss_ctx->h2n_desc_rings[NSS_IF_DATA_QUEUE_0].desc_ring.int_bit;
 	nss_info("%p: Sending to %d\n", nss_ctx, if_num);
 
 	status = nss_core_send_buffer(nss_ctx, if_num, skb,
@@ -353,8 +351,8 @@
 	gre_tunnel_pvt.cb = (void *)ngtm->cm.cb;
 	gre_tunnel_pvt.app_data = (void *)ngtm->cm.app_data;
 
-	ngtm->cm.cb = (uint32_t)nss_gre_tunnel_callback;
-	ngtm->cm.app_data = (uint32_t)NULL;
+	ngtm->cm.cb = (nss_ptr_t)nss_gre_tunnel_callback;
+	ngtm->cm.app_data = (nss_ptr_t)NULL;
 
 	status = nss_gre_tunnel_tx_msg(nss_ctx, ngtm);
 	if (status != NSS_TX_SUCCESS) {
@@ -447,8 +445,6 @@
 {
 	int32_t i;
 
-	struct nss_ctx_instance *nss_ctx = nss_gre_tunnel_get_ctx();
-
 	BUG_ON(!nss_gre_tunnel_verify_if_num(if_num));
 
 	spin_lock_bh(&nss_gre_tunnel_session_debug_stats_lock);
@@ -462,12 +458,12 @@
 	spin_unlock_bh(&nss_gre_tunnel_session_debug_stats_lock);
 
 	if (i == NSS_MAX_GRE_TUNNEL_SESSIONS) {
-		nss_warning("%p: Cannot find debug stats for GRE Tunnel session: %d\n", nss_ctx, if_num);
+		nss_warning("%p: Cannot find debug stats for GRE Tunnel session: %d\n", nss_gre_tunnel_get_ctx(), if_num);
 		return;
 	}
 
 	if (!nss_top_main.subsys_dp_register[if_num].ndev) {
-		nss_warning("%p: Cannot find registered netdev for GRE Tunnel NSS I/F: %d\n", nss_ctx, if_num);
+		nss_warning("%p: Cannot find registered netdev for GRE Tunnel NSS I/F: %d\n", nss_gre_tunnel_get_ctx(), if_num);
 
 		return;
 	}
diff --git a/nss_hal/include/nss_hal_ops.h b/nss_hal/include/nss_hal_ops.h
index c30c6f4..1e09b8f 100644
--- a/nss_hal/include/nss_hal_ops.h
+++ b/nss_hal/include/nss_hal_ops.h
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2016 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2017 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.
@@ -32,7 +32,7 @@
  */
 struct nss_hal_ops {
 	int (*common_reset)(struct platform_device *pdev);
-	int (*core_reset)(struct platform_device *nss_dev, uint32_t map, uint32_t addr, uint32_t clk_src);
+	int (*core_reset)(struct platform_device *nss_dev, void __iomem *map, uint32_t addr, uint32_t clk_src);
 	int (*clock_configure)(struct nss_ctx_instance *nss_ctx, struct platform_device *nss_dev, struct nss_platform_data *npd);
 	void (*debug_enable)(void);
 	struct nss_platform_data * (*of_get_pdata)(struct platform_device *pdev);
diff --git a/nss_hal/include/nss_regs.h b/nss_hal/include/nss_regs.h
index 54a80d1..b33b0b8 100644
--- a/nss_hal/include/nss_regs.h
+++ b/nss_hal/include/nss_regs.h
@@ -90,18 +90,18 @@
  * nss_read_32()
  *	Read NSS register
  */
-static inline uint32_t nss_read_32(uint32_t addr, uint32_t offs)
+static inline uint32_t nss_read_32(void __iomem *addr, uint32_t offs)
 {
-	return readl((void *)(addr + offs));
+	return readl(addr + offs);
 }
 
 /*
  * nss_write_32()
  *	Write NSS register
  */
-static inline void nss_write_32(uint32_t addr, uint32_t offs, uint32_t val)
+static inline void nss_write_32(void __iomem *addr, uint32_t offs, uint32_t val)
 {
-	writel(val, (void *)(addr + offs));
+	writel(val, addr + offs);
 }
 
 #endif /* __NSS_REGS_H */
diff --git a/nss_hal/ipq806x/nss_hal_pvt.c b/nss_hal/ipq806x/nss_hal_pvt.c
index ef95a62..7c51af5 100644
--- a/nss_hal/ipq806x/nss_hal_pvt.c
+++ b/nss_hal/ipq806x/nss_hal_pvt.c
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2013, 2015-2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013, 2015-2017, 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.
@@ -332,13 +332,13 @@
 	npd->nphys = res_nphys.start;
 	npd->vphys = res_vphys.start;
 
-	npd->nmap = (uint32_t)ioremap_nocache(npd->nphys, resource_size(&res_nphys));
+	npd->nmap = ioremap_nocache(npd->nphys, resource_size(&res_nphys));
 	if (!npd->nmap) {
 		nss_info_always("%p: nss%d: ioremap() fail for nphys\n", nss_ctx, nss_ctx->id);
 		goto out;
 	}
 
-	npd->vmap = (uint32_t)ioremap_nocache(npd->vphys, resource_size(&res_vphys));
+	npd->vmap = ioremap_nocache(npd->vphys, resource_size(&res_vphys));
 	if (!npd->vmap) {
 		nss_info_always("%p: nss%d: ioremap() fail for vphys\n", nss_ctx, nss_ctx->id);
 		goto out;
@@ -348,7 +348,7 @@
 	 * Clear TCM memory used by this core
 	 */
 	for (i = 0; i < resource_size(&res_vphys) ; i += 4) {
-		nss_write_32((uint32_t)npd->vmap, i, 0);
+		nss_write_32(npd->vmap, i, 0);
 	}
 
 	/*
@@ -369,11 +369,11 @@
 
 out:
 	if (npd->nmap) {
-		iounmap((void *)npd->nmap);
+		iounmap(npd->nmap);
 	}
 
 	if (npd->vmap) {
-		iounmap((void *)npd->vmap);
+		iounmap(npd->vmap);
 	}
 
 	devm_kfree(&pdev->dev, npd);
@@ -385,7 +385,7 @@
 /*
  * __nss_hal_core_reset()
  */
-static int __nss_hal_core_reset(struct platform_device *nss_dev, uint32_t map, uint32_t addr, uint32_t clk_src)
+static int __nss_hal_core_reset(struct platform_device *nss_dev, void __iomem *map, uint32_t addr, uint32_t clk_src)
 {
 #if (NSS_DT_SUPPORT == 1)
 	struct reset_control *rstctl = NULL;
@@ -591,7 +591,7 @@
 	/*
 	 * Attach debug interface to TLMM
 	 */
-	nss_write_32((uint32_t)fpb_base, NSS_REGS_FPB_CSR_CFG_OFFSET, 0x360);
+	nss_write_32(fpb_base, NSS_REGS_FPB_CSR_CFG_OFFSET, 0x360);
 
 	/*
 	 * NSS TCM CLOCK
diff --git a/nss_hal/ipq807x/nss_hal_pvt.c b/nss_hal/ipq807x/nss_hal_pvt.c
index b111785..f082ee6 100644
--- a/nss_hal/ipq807x/nss_hal_pvt.c
+++ b/nss_hal/ipq807x/nss_hal_pvt.c
@@ -183,19 +183,19 @@
 	npd->vphys = res_vphys.start;
 	npd->qgic_phys = res_qgic_phys.start;
 
-	npd->nmap = (uint32_t)ioremap_nocache(npd->nphys, resource_size(&res_nphys));
+	npd->nmap = ioremap_nocache(npd->nphys, resource_size(&res_nphys));
 	if (!npd->nmap) {
 		nss_info_always("%p: nss%d: ioremap() fail for nphys\n", nss_ctx, nss_ctx->id);
 		goto out;
 	}
 
-	npd->vmap = (uint32_t)ioremap_nocache(npd->vphys, resource_size(&res_vphys));
+	npd->vmap = ioremap_nocache(npd->vphys, resource_size(&res_vphys));
 	if (!npd->vmap) {
 		nss_info_always("%p: nss%d: ioremap() fail for vphys\n", nss_ctx, nss_ctx->id);
 		goto out;
 	}
 
-	npd->qgic_map = (uint32_t)ioremap_nocache(npd->qgic_phys, resource_size(&res_qgic_phys));
+	npd->qgic_map = ioremap_nocache(npd->qgic_phys, resource_size(&res_qgic_phys));
 	if (!npd->qgic_map) {
 		nss_info_always("%p: nss%d: ioremap() fail for qgic map\n", nss_ctx, nss_ctx->id);
 		goto out;
@@ -205,7 +205,7 @@
 	 * Clear TCM memory used by this core
 	 */
 	for (i = 0; i < resource_size(&res_vphys) ; i += 4) {
-		nss_write_32((uint32_t)npd->vmap, i, 0);
+		nss_write_32(npd->vmap, i, 0);
 	}
 
 	/*
@@ -226,11 +226,11 @@
 
 out:
 	if (npd->nmap) {
-		iounmap((void *)npd->nmap);
+		iounmap(npd->nmap);
 	}
 
 	if (npd->vmap) {
-		iounmap((void *)npd->vmap);
+		iounmap(npd->vmap);
 	}
 
 	devm_kfree(&pdev->dev, npd);
@@ -241,7 +241,7 @@
 /*
  * __nss_hal_core_reset()
  */
-static int __nss_hal_core_reset(struct platform_device *nss_dev, uint32_t map, uint32_t addr, uint32_t clk_src)
+static int __nss_hal_core_reset(struct platform_device *nss_dev, void __iomem *map, uint32_t addr, uint32_t clk_src)
 {
 	/*
 	 * Todo: AHB/AXI/ubi32 core reset is done in the T32 scripts for RUMI.
diff --git a/nss_hal/nss_hal.c b/nss_hal/nss_hal.c
index da94470..8adade5 100644
--- a/nss_hal/nss_hal.c
+++ b/nss_hal/nss_hal.c
@@ -72,7 +72,7 @@
 	}
 
 	if (nss_fw->size < MIN_IMG_SIZE) {
-		nss_info_always("%p: nss firmware is truncated, size:%d", nss_ctx, nss_fw->size);
+		nss_info_always("%p: nss firmware is truncated, size:%d", nss_ctx, (int)nss_fw->size);
 		return rc;
 	}
 
@@ -83,7 +83,7 @@
 		return rc;
 	}
 
-	nss_info_always("nss_driver - fw of size %u  bytes copied to load addr: %x, nss_id : %d\n", nss_fw->size, npd->load_addr, nss_dev->id);
+	nss_info_always("nss_driver - fw of size %d  bytes copied to load addr: %x, nss_id : %d\n", (int)nss_fw->size, npd->load_addr, nss_dev->id);
 	memcpy_toio(load_mem, nss_fw->data, nss_fw->size);
 	release_firmware(nss_fw);
 	iounmap(load_mem);
@@ -308,8 +308,8 @@
 	 */
 	nss_ctx->vphys = npd->vphys;
 	nss_assert(nss_ctx->vphys);
-	nss_info("%d:ctx=%p, vphys=%x, vmap=%x, nphys=%x, nmap=%x",
-			nss_ctx->id, nss_ctx, nss_ctx->vphys, nss_ctx->vmap, nss_ctx->nphys, nss_ctx->nmap);
+	nss_info("%d:ctx=%p, vphys=%x, vmap=%p, nphys=%x, nmap=%p", nss_ctx->id,
+			nss_ctx, nss_ctx->vphys, nss_ctx->vmap, nss_ctx->nphys, nss_ctx->nmap);
 
 	/*
 	 * Register netdevice for queue 0
@@ -566,11 +566,11 @@
 err_init:
 	if (nss_dev->dev.of_node) {
 		if (npd->nmap) {
-			iounmap((void *)npd->nmap);
+			iounmap(npd->nmap);
 		}
 
 		if (npd->vmap) {
-			iounmap((void *)npd->vmap);
+			iounmap(npd->vmap);
 		}
 	}
 
@@ -621,12 +621,12 @@
 
 	if (nss_dev->dev.of_node) {
 		if (nss_ctx->nmap) {
-			iounmap((void *)nss_ctx->nmap);
+			iounmap(nss_ctx->nmap);
 			nss_ctx->nmap = 0;
 		}
 
 		if (nss_ctx->vmap) {
-			iounmap((void *)nss_ctx->vmap);
+			iounmap(nss_ctx->vmap);
 			nss_ctx->vmap = 0;
 		}
 	}
diff --git a/nss_hlos_if.h b/nss_hlos_if.h
index 0b7bc3b..c0cff01 100644
--- a/nss_hlos_if.h
+++ b/nss_hlos_if.h
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2017, 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.
@@ -330,30 +330,20 @@
  * HLOS to NSS descriptor structure.
  */
 struct h2n_descriptor {
-	uint32_t opaque;
-				/* 32-bit value provided by the HLOS to associate with the buffer. The cookie has no meaning to the NSS */
-	uint32_t buffer;
-				/* Physical buffer address. This is the address of the start of the usable buffer being provided by the HLOS */
-	uint16_t buffer_len;
-				/* Length of the buffer (in bytes) */
-	uint16_t metadata_off;
-				/* Reserved for future use */
-	uint16_t payload_len;
-				/* Length of the active payload of the buffer (in bytes) */
-	uint16_t mss;	/* MSS to be used with TSO/UFO */
-	uint16_t payload_offs;
-				/* Offset from the start of the buffer to the start of the payload (in bytes) */
-	uint16_t interface_num;
-				/* Interface number to which the buffer is to be sent (where appropriate) */
-	uint8_t buffer_type;
-				/* Type of buffer */
-	uint8_t reserved3;
-				/* Reserved for future use */
-	uint16_t bit_flags;
-				/* Bit flags associated with the buffer */
-	uint32_t qos_tag;
-				/* QoS tag information of the buffer (where appropriate) */
-	uint32_t reserved4;	/* Reserved for future use */
+	uint32_t interface_num;	/* Interface number to which the buffer is to be sent (where appropriate) */
+	uint32_t buffer;	/* Physical buffer address. This is the address of the start of the usable buffer being provided by the HLOS */
+	uint32_t qos_tag;	/* QoS tag information of the buffer (where appropriate) */
+	uint16_t buffer_len;	/* Length of the buffer (in bytes) */
+	uint16_t payload_len;	/* Length of the active payload of the buffer (in bytes) */
+	uint16_t mss;		/* MSS to be used with TSO/UFO */
+	uint16_t payload_offs;	/* Offset from the start of the buffer to the start of the payload (in bytes) */
+	uint16_t bit_flags;	/* Bit flags associated with the buffer */
+	uint8_t buffer_type;	/* Type of buffer */
+	uint8_t reserved;	/* Reserved for future use */
+	nss_ptr_t opaque;	/* 32 or 64-bit value provided by the HLOS to associate with the buffer. The cookie has no meaning to the NSS */
+#ifndef __LP64__
+	uint32_t padding;	/* Pad to fit 64bits, do not reuse */
+#endif
 };
 
 /*
@@ -393,32 +383,19 @@
  * NSS to HLOS descriptor structure
  */
 struct n2h_descriptor {
-	uint32_t opaque;
-				/* 32-bit value provided by the HLOS to associate with the buffer. The cookie has no meaning to the NSS */
-	uint32_t buffer;
-				/* Physical buffer address. This is the address of the start of the usable buffer being provided by the HLOS */
-	uint16_t buffer_len;
-				/* Length of the buffer (in bytes) */
-	uint16_t reserved1;
-				/* Reserved for future use */
-	uint16_t payload_len;
-				/* Length of the active payload of the buffer (in bytes) */
-	uint16_t reserved2;
-				/* Reserved for future use */
-	uint16_t payload_offs;
-				/* Offset from the start of the buffer to the start of the payload (in bytes) */
-	uint16_t interface_num;
-				/* Interface number to which the buffer is to be sent (where appropriate) */
-	uint8_t buffer_type;
-				/* Type of buffer */
-	uint8_t response_type;
-				/* Response type if the buffer is a command response */
-	uint16_t bit_flags;
-				/* Bit flags associated with the buffer */
-	uint32_t timestamp_lo;
-				/* Low 32 bits of any timestamp associated with the buffer */
-	uint32_t timestamp_hi;
-				/* High 32 bits of any timestamp associated with the buffer */
+	uint32_t interface_num;	/* Interface number to which the buffer is to be sent (where appropriate) */
+	uint32_t buffer;	/* Physical buffer address. This is the address of the start of the usable buffer being provided by the HLOS */
+	uint16_t buffer_len;	/* Length of the buffer (in bytes) */
+	uint16_t payload_len;	/* Length of the active payload of the buffer (in bytes) */
+	uint16_t payload_offs;	/* Offset from the start of the buffer to the start of the payload (in bytes) */
+	uint16_t bit_flags;	/* Bit flags associated with the buffer */
+	uint8_t buffer_type;	/* Type of buffer */
+	uint8_t response_type;	/* Response type if the buffer is a command response */
+	uint16_t reserved[3];	/* Reserved for future use */
+	nss_ptr_t opaque;	/* 32 or 64-bit value provided by the HLOS to associate with the buffer. The cookie has no meaning to the NSS */
+#ifndef __LP64__
+	uint32_t padding;	/* Pad to fit 64 bits, do not reuse */
+#endif
 };
 
 /*
@@ -429,12 +406,29 @@
 #define DEV_DESCRIPTORS		256 /* Do we need it here? */
 
 /**
+ * H2N descriptor METADATA
+ */
+struct h2n_desc_if_meta {
+	uint32_t desc_addr;
+	uint16_t size;
+	uint16_t padding;
+};
+
+/**
  * H2N descriptor ring
  */
 struct h2n_desc_if_instance {
 	struct h2n_descriptor *desc;
 	uint16_t size;			/* Size in entries of the H2N0 descriptor ring */
-	uint16_t int_bit;		/* H2N0 descriptor ring interrupt */
+};
+
+/**
+ * N2H descriptor METADATA
+ */
+struct n2h_desc_if_meta {
+	uint32_t desc_addr;
+	uint16_t size;
+	uint16_t padding;
 };
 
 /**
@@ -443,15 +437,14 @@
 struct n2h_desc_if_instance {
 	struct n2h_descriptor *desc;
 	uint16_t size;			/* Size in entries of the H2N0 descriptor ring */
-	uint16_t int_bit;		/* H2N0 descriptor ring interrupt */
 };
 
 /**
  * NSS virtual interface map
  */
 struct nss_if_mem_map {
-	struct h2n_desc_if_instance h2n_desc_if[16];	/* Base address of H2N0 descriptor ring */
-	struct n2h_desc_if_instance n2h_desc_if[15];	/* Base address of N2H0 descriptor ring */
+	struct h2n_desc_if_meta h2n_desc_if[16];/* Base address of H2N0 descriptor ring */
+	struct n2h_desc_if_meta n2h_desc_if[15];/* Base address of N2H0 descriptor ring */
 	uint32_t magic;				/* Magic value used to identify NSS implementations (must be 0x4e52522e) */
 	uint16_t if_version;			/* Interface version number (must be 1 for this version) */
 	uint8_t h2n_rings;			/* Number of descriptor rings in the H2N direction */
diff --git a/nss_ipsec.c b/nss_ipsec.c
index 76ccbda..6e90771 100644
--- a/nss_ipsec.c
+++ b/nss_ipsec.c
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2017, 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.
@@ -134,8 +134,8 @@
 	 * locally stored state
 	 */
 	if (ncm->response == NSS_CMM_RESPONSE_NOTIFY) {
-		ncm->cb = (uint32_t)nss_ipsec_get_msg_callback(nss_ctx, if_num, &ipsec_ctx);
-		ncm->app_data = (uint32_t)ipsec_ctx;
+		ncm->cb = (nss_ptr_t)nss_ipsec_get_msg_callback(nss_ctx, if_num, &ipsec_ctx);
+		ncm->app_data = (nss_ptr_t)ipsec_ctx;
 	}
 
 
@@ -180,7 +180,7 @@
 
 	if (NSS_NBUF_PAYLOAD_SIZE < sizeof(struct nss_ipsec_msg)) {
 		nss_ipsec_warning("%p: tx message request is too large: %d (desired), %d (requested)", nss_ctx,
-				NSS_NBUF_PAYLOAD_SIZE, sizeof(struct nss_ipsec_msg));
+				NSS_NBUF_PAYLOAD_SIZE, (int)sizeof(struct nss_ipsec_msg));
 		return NSS_TX_FAILURE_TOO_LARGE;
 	}
 
@@ -206,8 +206,8 @@
 		return NSS_TX_FAILURE;
 	}
 
-	nss_ipsec_info("msg params version:%d, interface:%d, type:%d, cb:%d, app_data:%d, len:%d\n",
-			ncm->version, ncm->interface, ncm->type, ncm->cb, ncm->app_data, ncm->len);
+	nss_ipsec_info("msg params version:%d, interface:%d, type:%d, cb:%p, app_data:%p, len:%d\n",
+			ncm->version, ncm->interface, ncm->type, (void *)ncm->cb, (void *)ncm->app_data, ncm->len);
 
 	nim = (struct nss_ipsec_msg *)skb_put(nbuf, sizeof(struct nss_ipsec_msg));
 	memcpy(nim, msg, sizeof(struct nss_ipsec_msg));
diff --git a/nss_ipv4.c b/nss_ipv4.c
index f1a1559..a26e986 100644
--- a/nss_ipv4.c
+++ b/nss_ipv4.c
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2017, 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.
@@ -185,7 +185,7 @@
 		 * Update driver statistics on connection sync many.
 		 */
 		nss_ipv4_driver_conn_sync_many_update(nss_ctx, &nim->msg.conn_stats_many);
-		ncm->cb = (uint32_t)nss_ipv4_conn_sync_many_msg_cb;
+		ncm->cb = (nss_ptr_t)nss_ipv4_conn_sync_many_msg_cb;
 		break;
 	}
 
@@ -194,8 +194,8 @@
 	 * to the same callback/app_data.
 	 */
 	if (nim->cm.response == NSS_CMM_RESPONSE_NOTIFY) {
-		ncm->cb = (uint32_t)nss_ctx->nss_top->ipv4_callback;
-		ncm->app_data = (uint32_t)nss_ctx->nss_top->ipv4_ctx;
+		ncm->cb = (nss_ptr_t)nss_ctx->nss_top->ipv4_callback;
+		ncm->app_data = (nss_ptr_t)nss_ctx->nss_top->ipv4_ctx;
 	}
 
 	/*
diff --git a/nss_ipv6.c b/nss_ipv6.c
index e40d092..64af645 100644
--- a/nss_ipv6.c
+++ b/nss_ipv6.c
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2017, 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.
@@ -188,7 +188,7 @@
 		 * Update driver statistics on connection sync many.
 		 */
 		nss_ipv6_driver_conn_sync_many_update(nss_ctx, &nim->msg.conn_stats_many);
-		ncm->cb = (uint32_t)nss_ipv6_conn_sync_many_msg_cb;
+		ncm->cb = (nss_ptr_t)nss_ipv6_conn_sync_many_msg_cb;
 		break;
 	}
 
@@ -197,8 +197,8 @@
 	 * to the same callback/app_data.
 	 */
 	if (nim->cm.response == NSS_CMM_RESPONSE_NOTIFY) {
-		ncm->cb = (uint32_t)nss_ctx->nss_top->ipv6_callback;
-		ncm->app_data = (uint32_t)nss_ctx->nss_top->ipv6_ctx;
+		ncm->cb = (nss_ptr_t)nss_ctx->nss_top->ipv6_callback;
+		ncm->app_data = (nss_ptr_t)nss_ctx->nss_top->ipv6_ctx;
 	}
 
 	/*
diff --git a/nss_l2tpv2.c b/nss_l2tpv2.c
index 64d3a25..a937203 100644
--- a/nss_l2tpv2.c
+++ b/nss_l2tpv2.c
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2015-2017, 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.
@@ -110,7 +110,7 @@
 	 * to the same callback/app_data.
 	 */
 	if (ncm->response == NSS_CMM_RESPONSE_NOTIFY) {
-		ncm->cb = (uint32_t)nss_ctx->nss_top->l2tpv2_msg_callback;
+		ncm->cb = (nss_ptr_t)nss_ctx->nss_top->l2tpv2_msg_callback;
 	}
 
 	/*
diff --git a/nss_lag.c b/nss_lag.c
index d831036..772c6c8 100644
--- a/nss_lag.c
+++ b/nss_lag.c
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2017, 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.
@@ -141,7 +141,7 @@
 	 * LAG sends all notify messages to the same callback.
 	 */
 	if (ncm->response == NSS_CMM_RESPONSE_NOTIFY) {
-		ncm->cb = (uint32_t)nss_ctx->nss_top->lag_event_callback;
+		ncm->cb = (nss_ptr_t)nss_ctx->nss_top->lag_event_callback;
 	}
 
 	/**
diff --git a/nss_log.c b/nss_log.c
index ba4973d..7bed5f8 100644
--- a/nss_log.c
+++ b/nss_log.c
@@ -105,7 +105,7 @@
 	/*
 	 * i_private is passed to us by debug_fs_create()
 	 */
-	nss_id = (int)inode->i_private;
+	nss_id = (int)(nss_ptr_t)inode->i_private;
 	if (nss_id < 0 || nss_id >= NSS_MAX_CORES) {
 		nss_warning("nss_id is not valid :%d\n", nss_id);
 		return -ENODEV;
@@ -355,8 +355,8 @@
 	 * Update the callback and app_data for NOTIFY messages.
 	 */
 	if (ncm->response == NSS_CMM_RESPONSE_NOTIFY) {
-		ncm->cb = (uint32_t)nss_debug_interface_cb;
-		ncm->app_data = (uint32_t)nss_debug_interface_app_data;
+		ncm->cb = (nss_ptr_t)nss_debug_interface_cb;
+		ncm->app_data = (nss_ptr_t)nss_debug_interface_app_data;
 	}
 
 	/*
@@ -667,7 +667,7 @@
 
 		snprintf(file, sizeof(file), "core%d", i);
 		nss_top_main.core_log_dentry = debugfs_create_file(file, 0400,
-						nss_top_main.logs_dentry, (void *)i, &nss_logs_core_ops);
+						nss_top_main.logs_dentry, (void *)(nss_ptr_t)i, &nss_logs_core_ops);
 		if (unlikely(!nss_top_main.core_log_dentry)) {
 			nss_warning("Failed to create qca-nss-drv/logs/%s file in debugfs", file);
 			return;
diff --git a/nss_map_t.c b/nss_map_t.c
index 6c92391..8ca7f96 100644
--- a/nss_map_t.c
+++ b/nss_map_t.c
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2017, 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.
@@ -148,8 +148,8 @@
 	 * to the same callback/app_data.
 	 */
 	if (ncm->response == NSS_CMM_RESPONSE_NOTIFY) {
-		ncm->cb = (uint32_t)nss_ctx->nss_top->map_t_msg_callback;
-		ncm->app_data = (uint32_t)nss_ctx->nss_top->subsys_dp_register[ncm->interface].app_data;
+		ncm->cb = (nss_ptr_t)nss_ctx->nss_top->map_t_msg_callback;
+		ncm->app_data = (nss_ptr_t)nss_ctx->nss_top->subsys_dp_register[ncm->interface].app_data;
 	}
 
 	/*
@@ -279,8 +279,8 @@
 	nss_map_t_pvt.cb = (void *)msg->cm.cb;
 	nss_map_t_pvt.app_data = (void *)msg->cm.app_data;
 
-	msg->cm.cb = (uint32_t)nss_map_t_callback;
-	msg->cm.app_data = (uint32_t)NULL;
+	msg->cm.cb = (nss_ptr_t)nss_map_t_callback;
+	msg->cm.app_data = (nss_ptr_t)NULL;
 
 	status = nss_map_t_tx(nss_ctx, msg);
 	if (status != NSS_TX_SUCCESS) {
diff --git a/nss_n2h.c b/nss_n2h.c
index f6586dd..fc4ee15 100644
--- a/nss_n2h.c
+++ b/nss_n2h.c
@@ -178,8 +178,8 @@
 		 * Place holder for the user to create right call
 		 * back and app data when response is NSS_CMM_RESPONSE_NOTIFY
 		 */
-		ncm->cb = (uint32_t)nss_n2h_rd[nss_ctx->id].n2h_callback;
-		ncm->app_data = (uint32_t)nss_n2h_rd[nss_ctx->id].app_data;
+		ncm->cb = (nss_ptr_t)nss_n2h_rd[nss_ctx->id].n2h_callback;
+		ncm->app_data = (nss_ptr_t)nss_n2h_rd[nss_ctx->id].app_data;
 	}
 
 	/*
@@ -229,7 +229,7 @@
  */
 static void nss_n2h_mitigation_cfg_callback(void *app_data, struct nss_n2h_msg *nnm)
 {
-	int core_num = (int)app_data;
+	uint32_t core_num = (uint32_t)(nss_ptr_t)app_data;
 	struct nss_top_instance *nss_top = &nss_top_main;
 	struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_num];
 
@@ -257,7 +257,7 @@
  */
 static void nss_n2h_bufs_cfg_callback(void *app_data, struct nss_n2h_msg *nnm)
 {
-	int core_num = (int)app_data;
+	uint32_t core_num = (uint32_t)(nss_ptr_t)app_data;
 	unsigned int allocated_sz;
 
 	struct nss_top_instance *nss_top = &nss_top_main;
@@ -287,7 +287,7 @@
 static void nss_n2h_payload_stats_callback(void *app_data,
 					struct nss_n2h_msg *nnm)
 {
-	int core_num = (int)app_data;
+	uint32_t core_num = (uint32_t)(nss_ptr_t)app_data;
 
 	if (nnm->cm.response != NSS_CMN_RESPONSE_ACK) {
 		struct nss_n2h_empty_pool_buf *nnepbcm;
@@ -343,7 +343,7 @@
  */
 static int nss_n2h_get_payload_info(struct ctl_table *ctl, int write,
 			void __user *buffer, size_t *lenp, loff_t *ppos,
-			int core_num)
+			nss_ptr_t core_num)
 {
 	struct nss_top_instance *nss_top = &nss_top_main;
 	struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_num];
@@ -366,8 +366,7 @@
 	nss_tx_status = nss_n2h_tx_msg(nss_ctx, &nnm);
 
 	if (nss_tx_status != NSS_TX_SUCCESS) {
-		nss_warning("%p: core %d nss_tx error errorn",
-				nss_ctx, core_num);
+		nss_warning("%p: core %d nss_tx error errorn", nss_ctx, (int)core_num);
 		return NSS_FAILURE;
 	}
 
@@ -377,14 +376,12 @@
 	ret = wait_for_completion_timeout(&nss_n2h_nepbcfgp[core_num].complete,
 			msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT));
 	if (ret == 0) {
-		nss_warning("%p: core %d waiting for ack timed out\n", nss_ctx,
-				core_num);
+		nss_warning("%p: core %d waiting for ack timed out\n", nss_ctx, (int)core_num);
 		return NSS_FAILURE;
 	}
 
 	if (NSS_FAILURE == nss_n2h_nepbcfgp[core_num].response) {
-		nss_warning("%p: core %d response returned failure\n", nss_ctx,
-				core_num);
+		nss_warning("%p: core %d response returned failure\n", nss_ctx, (int)core_num);
 		return NSS_FAILURE;
 	}
 
@@ -398,7 +395,7 @@
 static int nss_n2h_set_empty_pool_buf(struct ctl_table *ctl, int write,
 				void __user *buffer,
 				size_t *lenp, loff_t *ppos,
-				int core_num, int *new_val)
+				nss_ptr_t core_num, int *new_val)
 {
 	struct nss_top_instance *nss_top = &nss_top_main;
 	struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_num];
@@ -440,18 +437,18 @@
 
 	if ((*new_val < NSS_N2H_MIN_EMPTY_POOL_BUF_SZ)) {
 		nss_warning("%p: core %d setting %d < min number of buffer",
-				nss_ctx, core_num, *new_val);
+				nss_ctx, (int)core_num, *new_val);
 		goto failure;
 	}
 
 	nss_info("%p: core %d number of empty pool buffer is : %d\n",
-		nss_ctx, core_num, *new_val);
+		nss_ctx, (int)core_num, *new_val);
 
 	nss_n2h_msg_init(&nnm, NSS_N2H_INTERFACE,
 			NSS_TX_METADATA_TYPE_N2H_EMPTY_POOL_BUF_CFG,
 			sizeof(struct nss_n2h_empty_pool_buf),
 			nss_n2h_payload_stats_callback,
-			(void *)core_num);
+			(nss_ptr_t *)core_num);
 
 	nnepbcm = &nnm.msg.empty_pool_buf_cfg;
 	nnepbcm->pool_size = htonl(*new_val);
@@ -459,7 +456,7 @@
 
 	if (nss_tx_status != NSS_TX_SUCCESS) {
 		nss_warning("%p: core %d nss_tx error empty pool buffer: %d\n",
-				nss_ctx, core_num, *new_val);
+				nss_ctx, (int)core_num, *new_val);
 		goto failure;
 	}
 
@@ -469,8 +466,7 @@
 	ret = wait_for_completion_timeout(&nss_n2h_nepbcfgp[core_num].complete,
 			msecs_to_jiffies(NSS_CONN_CFG_TIMEOUT));
 	if (ret == 0) {
-		nss_warning("%p: core %d Waiting for ack timed out\n", nss_ctx,
-			core_num);
+		nss_warning("%p: core %d Waiting for ack timed out\n", nss_ctx, (int)core_num);
 		goto failure;
 	}
 
@@ -502,7 +498,7 @@
 static int nss_n2h_set_water_mark(struct ctl_table *ctl, int write,
 					void __user *buffer,
 					size_t *lenp, loff_t *ppos,
-					int core_num, int *low, int *high)
+					uint32_t core_num, int *low, int *high)
 {
 	struct nss_top_instance *nss_top = &nss_top_main;
 	struct nss_ctx_instance *nss_ctx = &nss_top->nss[core_num];
@@ -578,7 +574,7 @@
 			NSS_TX_METADATA_TYPE_SET_WATER_MARK,
 			sizeof(struct nss_n2h_water_mark),
 			nss_n2h_payload_stats_callback,
-			(void *)core_num);
+			(void *)(nss_ptr_t)core_num);
 
 	wm = &nnm.msg.wm;
 	wm->low_water = htonl(*low);
diff --git a/nss_oam.c b/nss_oam.c
index cfac00d..9d3204e 100644
--- a/nss_oam.c
+++ b/nss_oam.c
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2016 The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2017 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.
@@ -54,8 +54,8 @@
 	nss_core_log_msg_failures(nss_ctx, ncm);
 
 	if (ncm->response == NSS_CMM_RESPONSE_NOTIFY) {
-		ncm->cb = (int)nss_top_main.oam_callback;
-		ncm->app_data = (int)nss_top_main.oam_ctx;
+		ncm->cb = (nss_ptr_t)nss_top_main.oam_callback;
+		ncm->app_data = (nss_ptr_t)nss_top_main.oam_ctx;
 	}
 
 	cb = (nss_oam_msg_callback_t)ncm->cb;
diff --git a/nss_phys_if.c b/nss_phys_if.c
index da24124..4d1c7a2 100644
--- a/nss_phys_if.c
+++ b/nss_phys_if.c
@@ -117,8 +117,8 @@
 	 * to the same callback/app_data.
 	 */
 	if (ncm->response == NSS_CMM_RESPONSE_NOTIFY) {
-		ncm->cb = (uint32_t)nss_ctx->nss_top->phys_if_msg_callback[ncm->interface];
-		ncm->app_data = (uint32_t)nss_ctx->nss_top->subsys_dp_register[ncm->interface].ndev;
+		ncm->cb = (nss_ptr_t)nss_ctx->nss_top->phys_if_msg_callback[ncm->interface];
+		ncm->app_data = (nss_ptr_t)nss_ctx->nss_top->subsys_dp_register[ncm->interface].ndev;
 	}
 
 	/*
diff --git a/nss_portid.c b/nss_portid.c
index 4209141..41aa010 100644
--- a/nss_portid.c
+++ b/nss_portid.c
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2015-2017, 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.
@@ -133,8 +133,8 @@
 	 * to the same callback/app_data.
 	 */
 	if (ncm->response == NSS_CMM_RESPONSE_NOTIFY) {
-		ncm->cb = (uint32_t)nss_ctx->nss_top->if_rx_msg_callback[ncm->interface];
-		ncm->app_data = (uint32_t)nss_ctx->nss_top->subsys_dp_register[ncm->interface].ndev;
+		ncm->cb = (nss_ptr_t)nss_ctx->nss_top->if_rx_msg_callback[ncm->interface];
+		ncm->app_data = (nss_ptr_t)nss_ctx->nss_top->subsys_dp_register[ncm->interface].ndev;
 	}
 
 	/*
diff --git a/nss_pptp.c b/nss_pptp.c
index bbde710..53df9d8 100644
--- a/nss_pptp.c
+++ b/nss_pptp.c
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2015-2017, 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.
@@ -138,8 +138,8 @@
 	 * to the same callback/app_data.
 	 */
 	if (ncm->response == NSS_CMM_RESPONSE_NOTIFY) {
-		ncm->cb = (uint32_t)nss_ctx->nss_top->pptp_msg_callback;
-		ncm->app_data =  (uint32_t)nss_ctx->nss_top->subsys_dp_register[ncm->interface].app_data;
+		ncm->cb = (nss_ptr_t)nss_ctx->nss_top->pptp_msg_callback;
+		ncm->app_data =  (nss_ptr_t)nss_ctx->nss_top->subsys_dp_register[ncm->interface].app_data;
 	}
 
 	/*
@@ -281,8 +281,8 @@
 	pptp_pvt.cb = (void *)msg->cm.cb;
 	pptp_pvt.app_data = (void *)msg->cm.app_data;
 
-	msg->cm.cb = (uint32_t)nss_pptp_sync_msg_callback;
-	msg->cm.app_data = (uint32_t)NULL;
+	msg->cm.cb = (nss_ptr_t)nss_pptp_sync_msg_callback;
+	msg->cm.app_data = (nss_ptr_t)NULL;
 
 	status = nss_pptp_tx_msg(nss_ctx, msg);
 	if (status != NSS_TX_SUCCESS) {
diff --git a/nss_profiler.c b/nss_profiler.c
index b49b739..5ead651 100644
--- a/nss_profiler.c
+++ b/nss_profiler.c
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2017, 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.
@@ -57,7 +57,7 @@
 	 * status per request callback
 	 */
 	if (ncm->response != NSS_CMM_RESPONSE_NOTIFY && ncm->cb) {
-		nss_info("%p: reply CB %x for %d %d\n", nss_ctx, ncm->cb, ncm->type, ncm->response);
+		nss_info("%p: reply CB %p for %d %d\n", nss_ctx, (void *)ncm->cb, ncm->type, ncm->response);
 		cb = (nss_profiler_callback_t)ncm->cb;
 	}
 
diff --git a/nss_sjack.c b/nss_sjack.c
index d73536d..8dcc213 100644
--- a/nss_sjack.c
+++ b/nss_sjack.c
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2017, 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.
@@ -67,7 +67,7 @@
 	 * to the same callback/app_data.
 	 */
 	if (ncm->response == NSS_CMM_RESPONSE_NOTIFY) {
-		ncm->cb = (uint32_t)nss_ctx->nss_top->if_rx_msg_callback[ncm->interface];
+		ncm->cb = (nss_ptr_t)nss_ctx->nss_top->if_rx_msg_callback[ncm->interface];
 	}
 
 	/*
diff --git a/nss_stats.c b/nss_stats.c
index a16101b..59c1ff2 100644
--- a/nss_stats.c
+++ b/nss_stats.c
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2017, 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.
@@ -1890,7 +1890,7 @@
 
 /*
  * nss_stats_wifi_read()
- *	Read wifi statistics
+ * 	Read wifi statistics
  */
 static ssize_t nss_stats_wifi_read(struct file *fp, char __user *ubuf, size_t sz, loff_t *ppos)
 {
@@ -3237,7 +3237,7 @@
 	memset(data, 0, sizeof (struct nss_stats_data));
 	data->if_num = NSS_DYNAMIC_IF_START;
 	data->index = 0;
-	data->edma_id = (uint32_t)inode->i_private;
+	data->edma_id = (nss_ptr_t)inode->i_private;
 	filp->private_data = data;
 
 	return 0;
@@ -3556,19 +3556,19 @@
 			return;
 		}
 
-		edma_port_stats_d = debugfs_create_file("stats", 0400, edma_port_d, (void *)i, &nss_stats_edma_port_stats_ops);
+		edma_port_stats_d = debugfs_create_file("stats", 0400, edma_port_d, (void *)(nss_ptr_t)i, &nss_stats_edma_port_stats_ops);
 		if (unlikely(edma_port_stats_d == NULL)) {
 			nss_warning("Failed to create qca-nss-drv/stats/edma/ports/%d/stats file in debugfs", i);
 			return;
 		}
 
-		edma_port_type_d = debugfs_create_file("type", 0400, edma_port_d, (void *)i, &nss_stats_edma_port_type_ops);
+		edma_port_type_d = debugfs_create_file("type", 0400, edma_port_d, (void *)(nss_ptr_t)i, &nss_stats_edma_port_type_ops);
 		if (unlikely(edma_port_type_d == NULL)) {
 			nss_warning("Failed to create qca-nss-drv/stats/edma/ports/%d/type file in debugfs", i);
 			return;
 		}
 
-		edma_port_ring_map_d = debugfs_create_file("ring_map", 0400, edma_port_d, (void *)i, &nss_stats_edma_port_ring_map_ops);
+		edma_port_ring_map_d = debugfs_create_file("ring_map", 0400, edma_port_d, (void *)(nss_ptr_t)i, &nss_stats_edma_port_ring_map_ops);
 		if (unlikely(edma_port_ring_map_d == NULL)) {
 			nss_warning("Failed to create qca-nss-drv/stats/edma/ports/%d/ring_map file in debugfs", i);
 			return;
@@ -3597,7 +3597,7 @@
 		memset(file_name, 0, sizeof(file_name));
 		scnprintf(file_name, sizeof(file_name), "%d", i);
 		edma_tx_d = NULL;
-		edma_tx_d = debugfs_create_file(file_name, 0400, edma_tx_dir_d, (void *)i, &nss_stats_edma_txring_ops);
+		edma_tx_d = debugfs_create_file(file_name, 0400, edma_tx_dir_d, (void *)(nss_ptr_t)i, &nss_stats_edma_txring_ops);
 		if (unlikely(edma_tx_d == NULL)) {
 			nss_warning("Failed to create qca-nss-drv/stats/edma/rings/tx/%d file in debugfs", i);
 			return;
@@ -3617,7 +3617,7 @@
 		memset(file_name, 0, sizeof(file_name));
 		scnprintf(file_name, sizeof(file_name), "%d", i);
 		edma_rx_d = NULL;
-		edma_rx_d = debugfs_create_file(file_name, 0400, edma_rx_dir_d, (void *)i, &nss_stats_edma_rxring_ops);
+		edma_rx_d = debugfs_create_file(file_name, 0400, edma_rx_dir_d, (void *)(nss_ptr_t)i, &nss_stats_edma_rxring_ops);
 		if (unlikely(edma_rx_d == NULL)) {
 			nss_warning("Failed to create qca-nss-drv/stats/edma/rings/rx/%d file in debugfs", i);
 			return;
@@ -3637,7 +3637,7 @@
 		memset(file_name, 0, sizeof(file_name));
 		scnprintf(file_name, sizeof(file_name), "%d", i);
 		edma_txcmpl_d = NULL;
-		edma_txcmpl_d = debugfs_create_file(file_name, 0400, edma_txcmpl_dir_d, (void *)i, &nss_stats_edma_txcmplring_ops);
+		edma_txcmpl_d = debugfs_create_file(file_name, 0400, edma_txcmpl_dir_d, (void *)(nss_ptr_t)i, &nss_stats_edma_txcmplring_ops);
 		if (unlikely(edma_txcmpl_d == NULL)) {
 			nss_warning("Failed to create qca-nss-drv/stats/edma/rings/txcmpl/%d file in debugfs", i);
 			return;
@@ -3657,7 +3657,7 @@
 		memset(file_name, 0, sizeof(file_name));
 		scnprintf(file_name, sizeof(file_name), "%d", i);
 		edma_rxfill_d = NULL;
-		edma_rxfill_d = debugfs_create_file(file_name, 0400, edma_rxfill_dir_d, (void *)i, &nss_stats_edma_rxfillring_ops);
+		edma_rxfill_d = debugfs_create_file(file_name, 0400, edma_rxfill_dir_d, (void *)(nss_ptr_t)i, &nss_stats_edma_rxfillring_ops);
 		if (unlikely(edma_rxfill_d == NULL)) {
 			nss_warning("Failed to create qca-nss-drv/stats/edma/rings/rxfill/%d file in debugfs", i);
 			return;
diff --git a/nss_trustsec_tx.c b/nss_trustsec_tx.c
index 1f10ba8..3b195d0 100644
--- a/nss_trustsec_tx.c
+++ b/nss_trustsec_tx.c
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2016-2017, 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.
@@ -99,8 +99,8 @@
 	 * to the same callback/app_data.
 	 */
 	if (ncm->response == NSS_CMM_RESPONSE_NOTIFY) {
-		ncm->cb = (uint32_t)nss_ctx->nss_top->if_rx_msg_callback[ncm->interface];
-		ncm->app_data = (uint32_t)nss_ctx->nss_top->subsys_dp_register[ncm->interface].ndev;
+		ncm->cb = (nss_ptr_t)nss_ctx->nss_top->if_rx_msg_callback[ncm->interface];
+		ncm->app_data = (nss_ptr_t)nss_ctx->nss_top->subsys_dp_register[ncm->interface].ndev;
 	}
 
 	/*
@@ -208,8 +208,8 @@
 
 	down(&ttx.sem);
 
-	msg->cm.cb = (uint32_t)nss_trustsec_tx_callback;
-	msg->cm.app_data = (uint32_t)NULL;
+	msg->cm.cb = (nss_ptr_t)nss_trustsec_tx_callback;
+	msg->cm.app_data = (nss_ptr_t)NULL;
 
 	status = nss_trustsec_tx_msg(nss_ctx, msg);
 	if (status != NSS_TX_SUCCESS) {
diff --git a/nss_tun6rd.c b/nss_tun6rd.c
index 1d356a4..7768a60 100644
--- a/nss_tun6rd.c
+++ b/nss_tun6rd.c
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2017, 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.
@@ -47,7 +47,7 @@
  	 * to the same callback/app_data.
  	 */
 	if (ncm->response == NSS_CMM_RESPONSE_NOTIFY) {
-		ncm->cb = (uint32_t)nss_ctx->nss_top->tun6rd_msg_callback;
+		ncm->cb = (nss_ptr_t)nss_ctx->nss_top->tun6rd_msg_callback;
 	}
 
 	/*
diff --git a/nss_tunipip6.c b/nss_tunipip6.c
index 214ea75..4ceadbc 100644
--- a/nss_tunipip6.c
+++ b/nss_tunipip6.c
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2017, 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.
@@ -45,7 +45,7 @@
 	 * to the same callback/app_data.
 	 */
 	if (ncm->response == NSS_CMM_RESPONSE_NOTIFY) {
-		ncm->cb = (uint32_t)nss_ctx->nss_top->tunipip6_msg_callback;
+		ncm->cb = (nss_ptr_t)nss_ctx->nss_top->tunipip6_msg_callback;
 	}
 
 	/*
diff --git a/nss_tx_rx_common.h b/nss_tx_rx_common.h
index 86dbd03..04807d6 100644
--- a/nss_tx_rx_common.h
+++ b/nss_tx_rx_common.h
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2013-2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-2017, 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.
@@ -29,7 +29,7 @@
 /*
  * Global definitions
  */
-#define NSS_HLOS_MESSAGE_VERSION 0
+#define NSS_HLOS_MESSAGE_VERSION 1	/* Update when the common message structure changed */
 
 #if (NSS_DEBUG_LEVEL > 0)
 #define NSS_VERIFY_CTX_MAGIC(x) nss_verify_ctx_magic(x)
diff --git a/nss_tx_rx_virt_if.c b/nss_tx_rx_virt_if.c
index fba33ac..56947fc 100644
--- a/nss_tx_rx_virt_if.c
+++ b/nss_tx_rx_virt_if.c
@@ -119,8 +119,8 @@
 	 * to the same callback/app_data.
 	 */
 	if (ncm->response == NSS_CMM_RESPONSE_NOTIFY) {
-		ncm->cb = (uint32_t)nss_ctx->nss_top->if_rx_msg_callback[ncm->interface];
-		ncm->app_data = (uint32_t)nss_ctx->nss_top->subsys_dp_register[ncm->interface].ndev;
+		ncm->cb = (nss_ptr_t)nss_ctx->nss_top->if_rx_msg_callback[ncm->interface];
+		ncm->app_data = (nss_ptr_t)nss_ctx->nss_top->subsys_dp_register[ncm->interface].ndev;
 	}
 
 	/*
@@ -450,7 +450,7 @@
 
 	if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_tx_rx_virt_if_msg)) {
 		nss_warning("%p: invalid length: %d. Length of redir msg is %d",
-				nss_ctx, nss_cmn_get_msg_len(ncm), sizeof(struct nss_tx_rx_virt_if_msg));
+				nss_ctx, nss_cmn_get_msg_len(ncm), (int)sizeof(struct nss_tx_rx_virt_if_msg));
 		return NSS_TX_FAILURE;
 	}
 
diff --git a/nss_virt_if.c b/nss_virt_if.c
index 3910eb5..e9ca9d1 100644
--- a/nss_virt_if.c
+++ b/nss_virt_if.c
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-2017, 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.
@@ -117,8 +117,8 @@
 	 * to the same callback/app_data.
 	 */
 	if (ncm->response == NSS_CMM_RESPONSE_NOTIFY) {
-		ncm->cb = (uint32_t)nss_ctx->nss_top->if_rx_msg_callback[ncm->interface];
-		ncm->app_data = (uint32_t)nss_ctx->nss_top->subsys_dp_register[ncm->interface].ndev;
+		ncm->cb = (nss_ptr_t)nss_ctx->nss_top->if_rx_msg_callback[ncm->interface];
+		ncm->app_data = (nss_ptr_t)nss_ctx->nss_top->subsys_dp_register[ncm->interface].ndev;
 	}
 
 	/*
@@ -831,7 +831,7 @@
 
 	if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_virt_if_msg)) {
 		nss_warning("%p: invalid length: %d. Length of virt msg is %d",
-				nss_ctx, nss_cmn_get_msg_len(ncm), sizeof(struct nss_virt_if_msg));
+				nss_ctx, nss_cmn_get_msg_len(ncm), (int)sizeof(struct nss_virt_if_msg));
 		return NSS_TX_FAILURE;
 	}
 
diff --git a/nss_wifi.c b/nss_wifi.c
index dd684d4..4472210 100644
--- a/nss_wifi.c
+++ b/nss_wifi.c
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2015-2017, 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.
@@ -116,7 +116,7 @@
 	 * to the same callback/app_data.
 	 */
 	if (ncm->response == NSS_CMM_RESPONSE_NOTIFY) {
-		ncm->cb = (uint32_t)nss_ctx->nss_top->wifi_msg_callback;
+		ncm->cb = (nss_ptr_t)nss_ctx->nss_top->wifi_msg_callback;
 	}
 
 	/*
diff --git a/nss_wifi_if.c b/nss_wifi_if.c
index 47ef4dc..3c5480e 100644
--- a/nss_wifi_if.c
+++ b/nss_wifi_if.c
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2015-2017, 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.
@@ -115,8 +115,8 @@
 	 * Update the callback and app_data for NOTIFY messages.
 	 */
 	if (nwim->cm.response == NSS_CMM_RESPONSE_NOTIFY) {
-		ncm->cb = (uint32_t)handle->cb;
-		ncm->app_data = (uint32_t)handle->app_data;
+		ncm->cb = (nss_ptr_t)handle->cb;
+		ncm->app_data = (nss_ptr_t)handle->app_data;
 	}
 
 	/*
@@ -205,7 +205,7 @@
 
 	if (nss_cmn_get_msg_len(ncm) > sizeof(struct nss_wifi_if_msg)) {
 		nss_warning("%p: invalid length: %d. Length of wifi msg is %d\n",
-				nss_ctx, nss_cmn_get_msg_len(ncm), sizeof(struct nss_wifi_if_msg));
+				nss_ctx, nss_cmn_get_msg_len(ncm), (int)sizeof(struct nss_wifi_if_msg));
 		return NSS_TX_FAILURE;
 	}
 
diff --git a/nss_wifi_vdev.c b/nss_wifi_vdev.c
index beee2d1..01389fc 100644
--- a/nss_wifi_vdev.c
+++ b/nss_wifi_vdev.c
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2015-2017, 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.
@@ -52,8 +52,8 @@
 	}
 
 	if (ncm->response == NSS_CMM_RESPONSE_NOTIFY) {
-		ncm->cb = (uint32_t)nss_ctx->nss_top->if_rx_msg_callback[ncm->interface];
-		ncm->app_data = (uint32_t)nss_ctx->nss_top->subsys_dp_register[ncm->interface].ndev;
+		ncm->cb = (nss_ptr_t)nss_ctx->nss_top->if_rx_msg_callback[ncm->interface];
+		ncm->app_data = (nss_ptr_t)nss_ctx->nss_top->subsys_dp_register[ncm->interface].ndev;
 	}
 
 	/*