Merge "[qca-nss-drv] Add adv QoS drop statistics in edma."
diff --git a/exports/nss_c2c_tx.h b/exports/nss_c2c_tx.h
index 85a9d9b..5fc9362 100644
--- a/exports/nss_c2c_tx.h
+++ b/exports/nss_c2c_tx.h
@@ -39,7 +39,7 @@
 
 /**
  * nss_c2c_tx_map
- *	Core-to-core tranmission queue address and interrupt address.
+ *	Core-to-core transmission queue address and interrupt address.
  */
 struct nss_c2c_tx_map {
 	uint32_t tx_map;		/**< Peer core core-to-core receiver queue start address. */
diff --git a/exports/nss_gre_redir_lag.h b/exports/nss_gre_redir_lag.h
index 7f26971..0bb9b5c 100644
--- a/exports/nss_gre_redir_lag.h
+++ b/exports/nss_gre_redir_lag.h
@@ -23,7 +23,7 @@
 #define __NSS_GRE_REDIR_LAG_H
 
 /**
- * @addtogroup nss_gre_redirect_subsystem.
+ * @addtogroup nss_gre_redirect_subsystem
  * @{
  */
 
diff --git a/exports/nss_ipv4.h b/exports/nss_ipv4.h
index c1de678..0d73129 100644
--- a/exports/nss_ipv4.h
+++ b/exports/nss_ipv4.h
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-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.
@@ -76,7 +76,7 @@
 #define NSS_IPV4_RULE_UPDATE_FLAG_CHANGE_MTU 0x20
 		/**< Update MTU of the connection interfaces. */
 #define NSS_IPV4_RULE_CREATE_FLAG_ICMP_NO_CME_FLUSH 0x40
-		/**< Rule for not flushing CME on an ICMP packet. */
+		/**< Rule for not flushing connection match entry on an ICMP packet. */
 
 /**
  * L2 payload is not IPv4, but it consists of an encapsulating protocol that
@@ -375,8 +375,8 @@
  *	IPv4 connection inquiry naming structure.
  */
 struct nss_ipv4_inquiry_msg {
-	/*
-	 * Request by its 5 tuple and get Response for other items.
+	/**
+	 * Request by its 5-tuple and get response for other items.
 	 */
 	struct nss_ipv4_rule_create_msg rr;
 };
diff --git a/exports/nss_ipv6.h b/exports/nss_ipv6.h
index 2d1d6bd..f949168 100644
--- a/exports/nss_ipv6.h
+++ b/exports/nss_ipv6.h
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-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.
@@ -74,7 +74,7 @@
 #define NSS_IPV6_RULE_CREATE_FLAG_VLAN_MARKING 0x10
 		/**< Rule has for a VLAN marking configured. */
 #define NSS_IPV6_RULE_CREATE_FLAG_ICMP_NO_CME_FLUSH 0x20
-		/**< Rule for not flushing CME on ICMP pkt. */
+		/**< Rule for not flushing connection match entry on ICMP packet. */
 #define NSS_IPV6_RULE_UPDATE_FLAG_CHANGE_MTU 0x40
 		/**< Rule updation for MTU change. */
 
@@ -439,8 +439,8 @@
  *	IPv6 connection inquiry sub-messages.
  */
 struct nss_ipv6_inquiry_msg {
-	/*
-	 * Request by 5 tuple, and Response in other items.
+	/**
+	 * Request by 5-tuple and response in other items.
 	 */
 	struct nss_ipv6_rule_create_msg rr;
 };
diff --git a/exports/nss_n2h.h b/exports/nss_n2h.h
index 59812f7..9a082dc 100644
--- a/exports/nss_n2h.h
+++ b/exports/nss_n2h.h
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2014-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.
@@ -148,7 +148,7 @@
 			/**< Virtual addresses of the buffers. */
 #ifndef __LP64__
 	uint32_t padding[MAX_PAGES_PER_MSG];
-			/* Pad to fit 64 bits, do not reuse. */
+			/**< Pad to fit 64 bits, do not reuse. */
 #endif
 };
 
diff --git a/exports/nss_project.h b/exports/nss_project.h
index bf32ae4..4b1b711 100644
--- a/exports/nss_project.h
+++ b/exports/nss_project.h
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2017, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2017-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.
@@ -23,7 +23,7 @@
 #define __NSS_PROJECT_H
 
 /**
- * @addtogroup nss_dscp2pri_subsystem
+ * @addtogroup nss_project_subsystem
  * @{
  */
 
@@ -125,7 +125,7 @@
 				/**< Enable or disable worker thread statistics. */
 		struct nss_project_msg_wt_stats_notify wt_stats_notify;
 				/**< One-way worker thread statistics message. */
-	} msg;
+	} msg;			/**< Message payload. */
 };
 
 /**
diff --git a/exports/nss_rps.h b/exports/nss_rps.h
index 3e6ad4b..213604e 100644
--- a/exports/nss_rps.h
+++ b/exports/nss_rps.h
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2013-2017, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2013-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.
@@ -22,6 +22,10 @@
 #ifndef __NSS_RPS_H
 #define __NSS_RPS_H
 
+/**
+ * @addtogroup nss_rps_subsystem
+ * @{
+ */
 
 /**
  * nss_rps_register_sysctl
@@ -44,4 +48,8 @@
  */
 extern void nss_rps_unregister_sysctl(void);
 
+/**
+ * @}
+ */
+
 #endif /* __NSS_RPS_H */
diff --git a/exports/nss_wifi.h b/exports/nss_wifi.h
index 7925c10..6669b1e 100644
--- a/exports/nss_wifi.h
+++ b/exports/nss_wifi.h
@@ -1,6 +1,6 @@
 /*
  **************************************************************************
- * Copyright (c) 2015-2017, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2015-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.
@@ -134,6 +134,7 @@
 	NSS_WIFI_RX_EXT_INV_PEER_TYPE,
 	NSS_WIFI_RX_EXT_PKTLOG_TYPE,
 	NSS_WIFI_RX_STATS_V2_EXCEPTION,
+	NSS_WIFI_RX_MGMT_NULL_TYPE,
 	NSS_WIFI_RX_EXT_MAX_TYPE,
 };
 
diff --git a/exports/nss_wifi_vdev.h b/exports/nss_wifi_vdev.h
index b45fb38..a424842 100644
--- a/exports/nss_wifi_vdev.h
+++ b/exports/nss_wifi_vdev.h
@@ -125,7 +125,7 @@
 	NSS_WIFI_VDEV_EXT_DATA_PKT_TYPE_RX_ERR = 7,	/**< Rx error packets metadata. */
 	NSS_WIFI_VDEV_EXT_DATA_PKT_TYPE_EXTAP_TX = 8,	/**< ExtAP Tx metadata. */
 	NSS_WIFI_VDEV_EXT_DATA_PKT_TYPE_EXTAP_RX = 9,	/**< ExtAP Rx metadata. */
-	NSS_WIFI_VDEV_EXT_DATA_PKT_TYPE_WNM_TFS = 10,	/**< WNM TFGS related metadata. */
+	NSS_WIFI_VDEV_EXT_DATA_PKT_TYPE_WNM_TFS = 10,	/**< WNM TFS related metadata. */
 	NSS_WIFI_VDEV_EXT_TX_COMPL_PKT_TYPE = 11,	/**< Tx completion. */
 	NSS_WIFI_VDEV_EXT_DATA_PKT_TYPE_WDS_LEARN = 12,	/**< WDS source port learning command. */
 	NSS_WIFI_VDEV_EXT_DATA_PPDU_INFO = 13,		/**< PPDU metadata information. */
diff --git a/exports/nss_wifili_if.h b/exports/nss_wifili_if.h
index 7b8d310..2f5ad8c 100644
--- a/exports/nss_wifili_if.h
+++ b/exports/nss_wifili_if.h
@@ -132,6 +132,7 @@
 	NSS_WIFILI_RADIO_CMD_MSG,
 	NSS_WIFILI_LINK_DESC_INFO_MSG,
 	NSS_WIFILI_PEER_SECURITY_TYPE_MSG,
+	NSS_WIFILI_PEER_NAWDS_ENABLE_MSG,
 	NSS_WIFILI_MAX_MSG
 };
 
@@ -399,7 +400,7 @@
 	uint8_t is_nawds;
 			/**< NAWDS enabled for peer. */
 	uint32_t nss_peer_mem;
-			/**< Holds peer memory adderss for nss. */
+			/**< Holds peer memory adderss for NSS. */
 };
 
 /**
@@ -591,7 +592,7 @@
  */
 struct nss_wifili_rx_dma_ring_stats {
 	uint32_t rx_hw_desc_unavailable;	/**< Number of times hardware descriptor is unavailable. */
-	uint32_t rx_buf_replenished;		/**< Number of buffers replinshed.. */
+	uint32_t rx_buf_replenished;		/**< Number of buffers replenished. */
 };
 
 /**
@@ -644,10 +645,14 @@
  *	Per packet special data that has to be sent to host.
  */
 struct nss_wifili_soc_per_packet_metadata {
-	uint32_t pkt_type;
+	uint32_t pkt_type;	/**< Packet type. */
+
+	/**
+	 *  Link descriptor per packet metadata.
+	 */
 	union {
 		struct nss_wifili_soc_linkdesc_per_packet_metadata linkdesc_metadata;
-	} metadata;
+	} metadata;	/**< Per packet link descriptor metadata. */
 };
 
 /**
@@ -669,6 +674,10 @@
 	uint32_t ofdma; 		/**< Total number of OFDMA packets. */
 	uint32_t non_amsdu_cnt; 	/**< Number of MSDUs with no MSDU level aggregation. */
 	uint32_t amsdu_cnt;		/**< Number of MSDUs part of AMSDU. */
+	uint32_t tx_mcast_cnt;          /**< Total number of multicast packets sent. */
+	uint32_t tx_mcast_bytes;        /**< Total number of multicast bytes sent. */
+	uint32_t tx_ucast_cnt;          /**< Total number of unicast packets sent. */
+	uint32_t tx_ucast_bytes;        /**< Total number of unicast bytes sent. */
 	struct nss_wifili_tx_dropped dropped;	/**< Tx peer dropped. */
 };
 
@@ -797,6 +806,15 @@
 };
 
 /**
+ * nss_wifili_peer_nawds_enable_msg
+ *	Wifili NAWDS enable for this peer.
+ */
+struct nss_wifili_peer_nawds_enable_msg {
+	uint16_t peer_id;			/**< Peer ID. */
+	uint16_t is_nawds;			/**< Enable NAWDS on this peer. */
+};
+
+/**
  * nss_wifili_reo_tidq_msg
  *	REO TID queue setup message.
  */
@@ -821,10 +839,14 @@
  */
 struct nss_wifili_radio_cfg_msg {
 	uint32_t radio_if_num;	/**< NSS assigned interface number for radio. */
+
+	/**
+	 * Wi-Fi radio specific special command message.
+	 */
 	union {
 		struct nss_wifili_radio_cmd_msg radiocmdmsg;
 							/**< Radio specific commands. */
-	} radiomsg;
+	} radiomsg;	/**< Wi-Fi radio command message. */
 };
 
 /**
@@ -833,6 +855,10 @@
  */
 struct nss_wifili_msg {
 	struct nss_cmn_msg cm;                  /**< Common message header. */
+
+	/**
+	 * Payload of wifili message.
+	 */
 	union {
 		struct nss_wifili_init_msg init;
 				/**< Wi-Fi initialization data. */
@@ -866,7 +892,9 @@
 				/**< Link descriptor buffer address information. */
 		struct nss_wifili_peer_security_type_msg securitymsg;
 				/**< Wifili peer security message. */
-	} msg;
+		struct nss_wifili_peer_nawds_enable_msg nawdsmsg;
+				/**< Wifili peer enable NAWDS message. */
+	} msg;			/**< Message payload. */
 };
 
 /**
diff --git a/nss_c2c_tx.c b/nss_c2c_tx.c
index dd866de..819e97d 100644
--- a/nss_c2c_tx.c
+++ b/nss_c2c_tx.c
@@ -81,7 +81,7 @@
 
 	case NSS_C2C_TX_MSG_TYPE_STATS:
 		nss_c2c_tx_stats_sync(nss_ctx, &nctm->msg.stats);
-		return;
+		break;
 	}
 
 	/*
diff --git a/nss_core.c b/nss_core.c
index 8b19221..22779f7 100644
--- a/nss_core.c
+++ b/nss_core.c
@@ -773,10 +773,11 @@
  * nss_core_rx_pbuf()
  *	Receive a pbuf from the NSS into Linux.
  */
-static inline void nss_core_rx_pbuf(struct nss_ctx_instance *nss_ctx, struct n2h_descriptor *desc, struct napi_struct *napi, uint8_t buffer_type, struct sk_buff *nbuf)
+static inline void nss_core_rx_pbuf(struct nss_ctx_instance *nss_ctx, struct napi_struct *napi,
+				uint8_t buffer_type, struct sk_buff *nbuf, uint32_t desc_ifnum, uint32_t bit_flags)
 {
-	unsigned int interface_num = NSS_INTERFACE_NUM_GET(desc->interface_num);
-	unsigned int core_id = NSS_INTERFACE_NUM_GET_COREID(desc->interface_num);
+	unsigned int interface_num = NSS_INTERFACE_NUM_GET(desc_ifnum);
+	unsigned int core_id = NSS_INTERFACE_NUM_GET_COREID(desc_ifnum);
 	struct nss_shaper_bounce_registrant *reg = NULL;
 	int32_t status;
 
@@ -816,11 +817,11 @@
 		break;
 
 	case N2H_BUFFER_PACKET:
-		nss_core_handle_buffer_pkt(nss_ctx, interface_num, nbuf, napi, desc->bit_flags);
+		nss_core_handle_buffer_pkt(nss_ctx, interface_num, nbuf, napi, bit_flags);
 		break;
 
 	case N2H_BUFFER_PACKET_EXT:
-		nss_core_handle_ext_buffer_pkt(nss_ctx, interface_num, nbuf, napi, desc->bit_flags);
+		nss_core_handle_ext_buffer_pkt(nss_ctx, interface_num, nbuf, napi, bit_flags);
 		break;
 
 	case N2H_BUFFER_STATUS:
@@ -861,7 +862,7 @@
  * nss_core_handle_nrfrag_skb()
  *	Handled the processing of fragmented skb's
  */
-static inline bool nss_core_handle_nr_frag_skb(struct nss_ctx_instance *nss_ctx, struct sk_buff **nbuf_ptr, struct sk_buff **jumbo_start_ptr, struct n2h_descriptor *desc, unsigned int buffer_type)
+static inline bool nss_core_handle_nr_frag_skb(struct nss_ctx_instance *nss_ctx, struct sk_buff **nbuf_ptr, struct sk_buff **jumbo_start_ptr, struct n2h_descriptor *desc, struct hlos_n2h_desc_ring *n2h_desc_ring, unsigned int buffer_type)
 {
 	struct sk_buff *nbuf = *nbuf_ptr;
 	struct sk_buff *jumbo_start = *jumbo_start_ptr;
@@ -879,6 +880,13 @@
 	 * chains (or it's not a scattered one).
 	 */
 	if (likely(bit_flags & N2H_BIT_FLAG_FIRST_SEGMENT) && likely(bit_flags & N2H_BIT_FLAG_LAST_SEGMENT)) {
+		/*
+		 * This is considered safe for linear skb since
+		 * every skb has a FIRST and LAST bit. So this will
+		 * be updated for every packet.
+		 */
+		n2h_desc_ring->interface_num = desc->interface_num;
+		n2h_desc_ring->bit_flags = desc->bit_flags;
 
 		/*
 		 * We have received another head before we saw the last segment.
@@ -916,6 +924,17 @@
 	 * Build a frags[] out of segments.
 	 */
 	if (unlikely((bit_flags & N2H_BIT_FLAG_FIRST_SEGMENT))) {
+		/*
+		 * We want to grab the head descripter information
+		 * and consume the pbuf on that information only.
+		 *
+		 * This is considered safe since we will construct the
+		 * chain in the order of seeing a FIRST and a LAST.
+		 * Every other order will be dropped or destroyed.
+		 *
+		 */
+		n2h_desc_ring->interface_num = desc->interface_num;
+		n2h_desc_ring->bit_flags = desc->bit_flags;
 
 		/*
 		 * We have received another head before we saw the last segment.
@@ -1006,7 +1025,7 @@
  *	Handler for processing linear skbs.
  */
 static inline bool nss_core_handle_linear_skb(struct nss_ctx_instance *nss_ctx, struct sk_buff **nbuf_ptr, struct sk_buff **head_ptr,
-						struct sk_buff **tail_ptr, struct n2h_descriptor *desc)
+						struct sk_buff **tail_ptr, struct hlos_n2h_desc_ring *n2h_desc_ring, struct n2h_descriptor *desc)
 {
 	uint16_t bit_flags = desc->bit_flags;
 	struct sk_buff *nbuf = *nbuf_ptr;
@@ -1023,6 +1042,13 @@
 	prefetch((void *)(nbuf->data));
 
 	if (likely(bit_flags & N2H_BIT_FLAG_FIRST_SEGMENT) && likely(bit_flags & N2H_BIT_FLAG_LAST_SEGMENT)) {
+		/*
+		 * This is considered safe for linear skb since
+		 * every skb has a FIRST and LAST bit. So this will
+		 * be updated for every packet.
+		 */
+		n2h_desc_ring->interface_num = desc->interface_num;
+		n2h_desc_ring->bit_flags = desc->bit_flags;
 
 		/*
 		 * We have received another head before we saw the last segment.
@@ -1055,6 +1081,17 @@
 	 * Build a frag list out of segments.
 	 */
 	if (unlikely((bit_flags & N2H_BIT_FLAG_FIRST_SEGMENT))) {
+		/*
+		 * We want to grab the head descripter information
+		 * and consume the pbuf on that information only.
+		 *
+		 * This is considered safe since we will construct the
+		 * chain in the order of seeing a FIRST and a LAST.
+		 * Every other order will be dropped or destroyed.
+		 *
+		 */
+		n2h_desc_ring->interface_num = desc->interface_num;
+		n2h_desc_ring->bit_flags = desc->bit_flags;
 
 		/*
 		 * We have received another head before we saw the last segment.
@@ -1334,6 +1371,8 @@
 		 * one of them is actually looked at.
 		 */
 		if ((unlikely(buffer_type == N2H_BUFFER_SHAPER_BOUNCED_INTERFACE)) || (unlikely(buffer_type == N2H_BUFFER_SHAPER_BOUNCED_BRIDGE))) {
+			n2h_desc_ring->interface_num = desc->interface_num;
+			n2h_desc_ring->bit_flags = desc->bit_flags;
 			dma_unmap_page(nss_ctx->dev, (desc->buffer + desc->payload_offs), desc->payload_len, DMA_TO_DEVICE);
 			goto consume;
 		}
@@ -1343,6 +1382,8 @@
 		 *
 		 */
 		if (unlikely((buffer_type == N2H_BUFFER_CRYPTO_RESP))) {
+			n2h_desc_ring->interface_num = desc->interface_num;
+			n2h_desc_ring->bit_flags = desc->bit_flags;
 			dma_unmap_single(NULL, (desc->buffer + desc->payload_offs), desc->payload_len, DMA_FROM_DEVICE);
 			goto consume;
 		}
@@ -1364,7 +1405,7 @@
 				n2h_desc_ring->head = NULL;
 			}
 
-			if (!nss_core_handle_nr_frag_skb(nss_ctx, &nbuf, &n2h_desc_ring->jumbo_start, desc, buffer_type)) {
+			if (!nss_core_handle_nr_frag_skb(nss_ctx, &nbuf, &n2h_desc_ring->jumbo_start, desc, n2h_desc_ring, buffer_type)) {
 				goto next;
 			}
 			NSS_PKT_STATS_INCREMENT(nss_ctx, &nss_ctx->nss_top->stats_drv[NSS_STATS_DRV_RX_NR_FRAGS]);
@@ -1388,12 +1429,12 @@
 		 * This is a simple linear skb. Use the the linear skb
 		 * handler to process it.
 		 */
-		if (!nss_core_handle_linear_skb(nss_ctx, &nbuf, &n2h_desc_ring->head, &n2h_desc_ring->tail, desc)) {
+		if (!nss_core_handle_linear_skb(nss_ctx, &nbuf, &n2h_desc_ring->head, &n2h_desc_ring->tail, n2h_desc_ring, desc)) {
 			goto next;
 		}
 
 consume:
-		nss_core_rx_pbuf(nss_ctx, desc, &(int_ctx->napi), buffer_type, nbuf);
+		nss_core_rx_pbuf(nss_ctx, &(int_ctx->napi), buffer_type, nbuf, n2h_desc_ring->interface_num, n2h_desc_ring->bit_flags);
 
 next:
 
diff --git a/nss_core.h b/nss_core.h
index 9357f5a..250009a 100644
--- a/nss_core.h
+++ b/nss_core.h
@@ -399,6 +399,8 @@
 	struct sk_buff *head;		/* First segment of an skb fraglist */
 	struct sk_buff *tail;		/* Last segment received of an skb fraglist */
 	struct sk_buff *jumbo_start;	/* First segment of an skb with frags[] */
+	uint32_t interface_num;		/* Store head descriptor interface number */
+	uint32_t bit_flags;		/* Store head descriptor bit flags */
 };
 
 /*