Merge 26b2501fb918845db2ad7f41b0d768bb12f107a2 on remote branch

Change-Id: Ib019482aff95c88e5c33f290fa4b56d14911de51
diff --git a/drivers/platform/msm/gsi/gsi.c b/drivers/platform/msm/gsi/gsi.c
index 728c283..2145042 100644
--- a/drivers/platform/msm/gsi/gsi.c
+++ b/drivers/platform/msm/gsi/gsi.c
@@ -1865,8 +1865,8 @@
 	struct gsihal_reg_ev_ch_k_cntxt_3 ev_ch_k_cntxt_3;
 	struct gsihal_reg_ev_ch_k_cntxt_8 ev_ch_k_cntxt_8;
 	struct gsihal_reg_ev_ch_k_cntxt_9 ev_ch_k_cntxt_9;
-	struct gsihal_reg_ev_ch_k_cntxt_10 ev_ch_k_cntxt_10;
-	struct gsihal_reg_ev_ch_k_cntxt_11 ev_ch_k_cntxt_11;
+	union gsihal_reg_ev_ch_k_cntxt_10 ev_ch_k_cntxt_10;
+	union gsihal_reg_ev_ch_k_cntxt_11 ev_ch_k_cntxt_11;
 	struct gsihal_reg_ev_ch_k_cntxt_12 ev_ch_k_cntxt_12;
 	struct gsihal_reg_ev_ch_k_cntxt_13 ev_ch_k_cntxt_13;
 
@@ -1904,25 +1904,41 @@
 		ee, evt_id,
 		&ev_ch_k_cntxt_9);
 
-	ev_ch_k_cntxt_10.msi_addr_lsb = GSI_LSB(props->msi_addr);
-	gsihal_write_reg_nk_fields(GSI_EE_n_EV_CH_k_CNTXT_10,
-		ee, evt_id,
-		&ev_ch_k_cntxt_10);
+	if(props->intf != GSI_EVT_CHTYPE_WDI3_V2_EV) {
+		ev_ch_k_cntxt_10.msi_addr_lsb = GSI_LSB(props->msi_addr);
+		gsihal_write_reg_nk_fields(GSI_EE_n_EV_CH_k_CNTXT_10,
+			ee, evt_id,
+			&ev_ch_k_cntxt_10);
 
-	ev_ch_k_cntxt_11.msi_addr_msb = GSI_MSB(props->msi_addr);
-	gsihal_write_reg_nk_fields(GSI_EE_n_EV_CH_k_CNTXT_11,
-		ee, evt_id,
-		&ev_ch_k_cntxt_11);
+		ev_ch_k_cntxt_11.msi_addr_msb = GSI_MSB(props->msi_addr);
+		gsihal_write_reg_nk_fields(GSI_EE_n_EV_CH_k_CNTXT_11,
+			ee, evt_id,
+			&ev_ch_k_cntxt_11);
 
-	ev_ch_k_cntxt_12.rp_update_addr_lsb = GSI_LSB(props->rp_update_addr);
-	gsihal_write_reg_nk_fields(GSI_EE_n_EV_CH_k_CNTXT_12,
-		ee, evt_id,
-		&ev_ch_k_cntxt_12);
 
-	ev_ch_k_cntxt_13.rp_update_addr_msb = GSI_MSB(props->rp_update_addr);
-	gsihal_write_reg_nk_fields(GSI_EE_n_EV_CH_k_CNTXT_13,
-		ee, evt_id,
-		&ev_ch_k_cntxt_13);
+		ev_ch_k_cntxt_12.rp_update_addr_lsb = GSI_LSB(props->rp_update_addr);
+		gsihal_write_reg_nk_fields(GSI_EE_n_EV_CH_k_CNTXT_12,
+			ee, evt_id,
+			&ev_ch_k_cntxt_12);
+
+		ev_ch_k_cntxt_13.rp_update_addr_msb = GSI_MSB(props->rp_update_addr);
+		gsihal_write_reg_nk_fields(GSI_EE_n_EV_CH_k_CNTXT_13,
+			ee, evt_id,
+			&ev_ch_k_cntxt_13);
+	}
+	else {
+		ev_ch_k_cntxt_10.rp_addr_lsb = GSI_LSB(props->rp_update_addr);
+		gsihal_write_reg_nk_fields(GSI_EE_n_EV_CH_k_CNTXT_10,
+			ee, evt_id,
+			&ev_ch_k_cntxt_10);
+
+		ev_ch_k_cntxt_11.rp_addr_msb = GSI_MSB(props->rp_update_addr);
+		gsihal_write_reg_nk_fields(GSI_EE_n_EV_CH_k_CNTXT_11,
+			ee, evt_id,
+			&ev_ch_k_cntxt_11);
+	}
+
+
 }
 
 static void gsi_init_evt_ring(struct gsi_evt_ring_props *props,
@@ -2721,6 +2737,7 @@
 	case GSI_CHAN_PROT_WDI3:
 	case GSI_CHAN_PROT_GCI:
 	case GSI_CHAN_PROT_MHIP:
+	case GSI_CHAN_PROT_WDI3_V2:
 		ch_k_cntxt_0.chtype_protocol_msb = 0;
 		break;
 	case GSI_CHAN_PROT_AQC:
diff --git a/drivers/platform/msm/gsi/gsi.h b/drivers/platform/msm/gsi/gsi.h
index bae59d2..f0b5814 100644
--- a/drivers/platform/msm/gsi/gsi.h
+++ b/drivers/platform/msm/gsi/gsi.h
@@ -115,6 +115,7 @@
 	GSI_VER_2_11 = 9,
 	GSI_VER_3_0 = 10,
 	GSI_VER_5_5 = 11,
+	GSI_VER_6_0 = 12,
 	GSI_VER_MAX,
 };
 
@@ -174,6 +175,7 @@
 	GSI_EVT_CHTYPE_11AD_EV = 0x9,
 	GSI_EVT_CHTYPE_RTK_EV = 0xC,
 	GSI_EVT_CHTYPE_NTN_EV = 0xD,
+	GSI_EVT_CHTYPE_WDI3_V2_EV = 0XF,
 };
 
 enum gsi_evt_ring_elem_size {
@@ -263,6 +265,7 @@
 	GSI_CHAN_PROT_QDSS = 0xB,
 	GSI_CHAN_PROT_RTK = 0xC,
 	GSI_CHAN_PROT_NTN = 0xD,
+	GSI_CHAN_PROT_WDI3_V2 = 0XF,
 };
 
 enum gsi_max_prefetch {
@@ -954,6 +957,35 @@
 	uint32_t fixed_data_buffer_size_pow_2:16;
 	uint32_t resv2:8;
 };
+/**
+ * gsi_wdi3_hamilton_channel_scratch - WDI 3 protocol, hamilton chipset
+ * SW config area of channel scratch
+ *
+ * @wifi_rx_ri_addr_low: Low 32 bits of Transfer ring Read Index address.
+ * @wifi_rx_ri_addr_high: High 32 bits of Transer ring Read Index address.
+ * @update_ri_moderation_threshold: Threshold N for Transfer ring Read Index
+				    N is the number of packets that IPA will
+				    process before wifi transfer ring Ri will
+				    be updated.
+ * @endp_metadata_reg_offset: Rx only, the offset of IPA_ENDP_INIT_HDR_METADATA_n
+			      of the corresponding endpoint in 4B words from IPA
+			      base address.
+ * @qmap_id: Rx only, used for setting metadata register in IPA, Read only field
+	     for MCS, Write for SW
+ */
+
+struct __packed gsi_wdi3_v2_channel_scratch {
+	uint32_t wifi_rp_address_low;
+	uint32_t wifi_rp_address_high;
+	uint32_t update_rp_moderation_threshold : 5;
+	uint32_t qmap_id : 8;
+	uint32_t reserved1 : 3;
+	uint32_t endp_metadata_reg_offset : 16;
+	uint32_t rx_pkt_offset : 16;
+	uint32_t reserved2 : 6;
+	uint32_t bank_id : 6;
+	uint32_t reserved3: 4;
+};
 
 /**
  * gsi_wdi3_channel_scratch - WDI protocol 3 SW config area of
@@ -1125,6 +1157,7 @@
 	struct __packed gsi_11ad_rx_channel_scratch rx_11ad;
 	struct __packed gsi_11ad_tx_channel_scratch tx_11ad;
 	struct __packed gsi_wdi3_channel_scratch wdi3;
+	struct __packed gsi_wdi3_v2_channel_scratch wdi3_v2;
 	struct __packed gsi_mhip_channel_scratch mhip;
 	struct __packed gsi_wdi2_channel_scratch_new wdi2_new;
 	struct __packed gsi_aqc_channel_scratch aqc;
diff --git a/drivers/platform/msm/gsi/gsihal/gsihal_reg.c b/drivers/platform/msm/gsi/gsihal/gsihal_reg.c
index 803d215..613cfbc 100644
--- a/drivers/platform/msm/gsi/gsihal/gsihal_reg.c
+++ b/drivers/platform/msm/gsi/gsihal/gsihal_reg.c
@@ -746,23 +746,23 @@
 static void gsireg_construct_ev_ch_k_cntxt_10(enum gsihal_reg_name reg,
 	const void *fields, u32 *val)
 {
-	struct gsihal_reg_ev_ch_k_cntxt_10 *ctxt =
-		(struct gsihal_reg_ev_ch_k_cntxt_10 *)fields;
+	union gsihal_reg_ev_ch_k_cntxt_10 *ctxt =
+		(union gsihal_reg_ev_ch_k_cntxt_10 *)fields;
 
 	GSI_SETFIELD_IN_REG(*val, ctxt->msi_addr_lsb,
-		GSI_EE_n_EV_CH_k_CNTXT_10_MSI_ADDR_LSB_SHFT,
-		GSI_EE_n_EV_CH_k_CNTXT_10_MSI_ADDR_LSB_BMSK);
+		GSI_EE_n_EV_CH_k_CNTXT_10_ADDR_LSB_SHFT,
+		GSI_EE_n_EV_CH_k_CNTXT_10_ADDR_LSB_BMSK);
 }
 
 static void gsireg_construct_ev_ch_k_cntxt_11(enum gsihal_reg_name reg,
 	const void *fields, u32 *val)
 {
-	struct gsihal_reg_ev_ch_k_cntxt_11 *ctxt =
-		(struct gsihal_reg_ev_ch_k_cntxt_11 *)fields;
+	union gsihal_reg_ev_ch_k_cntxt_11 *ctxt =
+		(union gsihal_reg_ev_ch_k_cntxt_11 *)fields;
 
 	GSI_SETFIELD_IN_REG(*val, ctxt->msi_addr_msb,
-		GSI_EE_n_EV_CH_k_CNTXT_11_MSI_ADDR_MSB_SHFT,
-		GSI_EE_n_EV_CH_k_CNTXT_11_MSI_ADDR_MSB_BMSK);
+		GSI_EE_n_EV_CH_k_CNTXT_11_ADDR_MSB_SHFT,
+		GSI_EE_n_EV_CH_k_CNTXT_11_ADDR_MSB_BMSK);
 }
 
 static void gsireg_construct_ev_ch_k_cntxt_12(enum gsihal_reg_name reg,
diff --git a/drivers/platform/msm/gsi/gsihal/gsihal_reg.h b/drivers/platform/msm/gsi/gsihal/gsihal_reg.h
index 667762a..bd02a28 100644
--- a/drivers/platform/msm/gsi/gsihal/gsihal_reg.h
+++ b/drivers/platform/msm/gsi/gsihal/gsihal_reg.h
@@ -264,12 +264,14 @@
 	uint32_t intvec;
 };
 
-struct gsihal_reg_ev_ch_k_cntxt_10 {
+union gsihal_reg_ev_ch_k_cntxt_10 {
 	uint32_t msi_addr_lsb;
+	uint32_t rp_addr_lsb;
 };
 
-struct gsihal_reg_ev_ch_k_cntxt_11 {
+union gsihal_reg_ev_ch_k_cntxt_11 {
 	uint32_t msi_addr_msb;
+	uint32_t rp_addr_msb;
 };
 
 struct gsihal_reg_ev_ch_k_cntxt_12 {
diff --git a/drivers/platform/msm/gsi/gsihal/gsihal_reg_i.h b/drivers/platform/msm/gsi/gsihal/gsihal_reg_i.h
index 5e16c25..37bde4d 100644
--- a/drivers/platform/msm/gsi/gsihal/gsihal_reg_i.h
+++ b/drivers/platform/msm/gsi/gsihal/gsihal_reg_i.h
@@ -237,12 +237,12 @@
 #define GSI_EE_n_EV_CH_k_CNTXT_9_INTVEC_SHFT 0x0
 
 /* GSI_EE_n_EV_CH_k_CNTXT_10 */
-#define GSI_EE_n_EV_CH_k_CNTXT_10_MSI_ADDR_LSB_BMSK 0xffffffff
-#define GSI_EE_n_EV_CH_k_CNTXT_10_MSI_ADDR_LSB_SHFT 0x0
+#define GSI_EE_n_EV_CH_k_CNTXT_10_ADDR_LSB_BMSK 0xffffffff
+#define GSI_EE_n_EV_CH_k_CNTXT_10_ADDR_LSB_SHFT 0x0
 
 /* GSI_EE_n_EV_CH_k_CNTXT_11 */
-#define GSI_EE_n_EV_CH_k_CNTXT_11_MSI_ADDR_MSB_BMSK 0xffffffff
-#define GSI_EE_n_EV_CH_k_CNTXT_11_MSI_ADDR_MSB_SHFT 0x0
+#define GSI_EE_n_EV_CH_k_CNTXT_11_ADDR_MSB_BMSK 0xffffffff
+#define GSI_EE_n_EV_CH_k_CNTXT_11_ADDR_MSB_SHFT 0x0
 
 /* GSI_EE_n_EV_CH_k_CNTXT_12 */
 #define GSI_EE_n_EV_CH_k_CNTXT_12_RP_UPDATE_ADDR_LSB_BMSK 0xffffffff
diff --git a/drivers/platform/msm/ipa/ipa_clients/ipa_wdi3.c b/drivers/platform/msm/ipa/ipa_clients/ipa_wdi3.c
index d12bbd0..15f26b3 100644
--- a/drivers/platform/msm/ipa/ipa_clients/ipa_wdi3.c
+++ b/drivers/platform/msm/ipa/ipa_clients/ipa_wdi3.c
@@ -208,7 +208,7 @@
 		return -EINVAL;
 	}
 
-	if (in->wdi_version > IPA_WDI_3 || in->wdi_version < IPA_WDI_1) {
+	if (in->wdi_version > IPA_WDI_3_V2 || in->wdi_version < IPA_WDI_1) {
 		IPA_WDI_ERR("wrong wdi version: %d\n", in->wdi_version);
 		return -EFAULT;
 	}
@@ -255,7 +255,7 @@
 
 	ipa_wdi_ctx_list[hdl]->is_smmu_enabled = out->is_smmu_enabled;
 
-	if (IPA_WDI2_OVER_GSI() || (in->wdi_version == IPA_WDI_3))
+	if (IPA_WDI2_OVER_GSI() || (in->wdi_version >= IPA_WDI_3))
 		out->is_over_gsi = true;
 	else
 		out->is_over_gsi = false;
@@ -400,7 +400,7 @@
 	rx.prop = rx_prop;
 	memset(rx_prop, 0, sizeof(rx_prop));
 	rx_prop[0].ip = IPA_IP_v4;
-	if (ipa_wdi_ctx_list[in->hdl]->wdi_version == IPA_WDI_3) {
+	if (ipa_wdi_ctx_list[in->hdl]->wdi_version >= IPA_WDI_3) {
 		if (IPA_CLIENT_IS_WLAN0_INSTANCE(ipa_wdi_ctx_list[in->hdl]->inst_id))
 			rx_prop[0].src_pipe = IPA_CLIENT_WLAN2_PROD;
 		else
@@ -416,7 +416,7 @@
 	}
 
 	rx_prop[1].ip = IPA_IP_v6;
-	if (ipa_wdi_ctx_list[in->hdl]->wdi_version == IPA_WDI_3) {
+	if (ipa_wdi_ctx_list[in->hdl]->wdi_version >= IPA_WDI_3) {
 		if (IPA_CLIENT_IS_WLAN0_INSTANCE(ipa_wdi_ctx_list[in->hdl]->inst_id))
 			rx_prop[1].src_pipe = IPA_CLIENT_WLAN2_PROD;
 		else
@@ -537,7 +537,7 @@
 		goto fail_setup_sys_pipe;
 	}
 	IPA_WDI_DBG("PM handle Registered\n");
-	if (ipa_wdi_ctx_list[in->hdl]->wdi_version == IPA_WDI_3) {
+	if (ipa_wdi_ctx_list[in->hdl]->wdi_version >= IPA_WDI_3) {
 		if (ipa3_conn_wdi3_pipes(in, out, ipa_wdi_ctx_list[in->hdl]->wdi_notify)) {
 			IPA_WDI_ERR("fail to setup wdi pipes\n");
 			ret = -EFAULT;
@@ -725,7 +725,7 @@
 		return -EPERM;
 	}
 
-	if (ipa_wdi_ctx_list[hdl]->wdi_version == IPA_WDI_3) {
+	if (ipa_wdi_ctx_list[hdl]->wdi_version >= IPA_WDI_3) {
 		if (IPA_CLIENT_IS_WLAN0_INSTANCE(ipa_wdi_ctx_list[hdl]->inst_id)) {
 			ipa_ep_idx_rx = ipa_get_ep_mapping(IPA_CLIENT_WLAN2_PROD);
 			ipa_ep_idx_tx = ipa_get_ep_mapping(IPA_CLIENT_WLAN2_CONS);
@@ -749,7 +749,7 @@
 		return -EFAULT;
 	}
 	IPA_WDI_DBG("Enable WDI pipes\n");
-	if (ipa_wdi_ctx_list[hdl]->wdi_version == IPA_WDI_3) {
+	if (ipa_wdi_ctx_list[hdl]->wdi_version >= IPA_WDI_3) {
 		if (ipa3_enable_wdi3_pipes(
 			ipa_ep_idx_tx, ipa_ep_idx_rx, ipa_ep_idx_tx1)) {
 			IPA_WDI_ERR("fail to enable wdi pipes\n");
@@ -1092,7 +1092,7 @@
 		}
 	}
 
-	if (ipa_wdi_ctx_list[hdl]->wdi_version == IPA_WDI_3) {
+	if (ipa_wdi_ctx_list[hdl]->wdi_version >= IPA_WDI_3) {
 		if (IPA_CLIENT_IS_WLAN0_INSTANCE(ipa_wdi_ctx_list[hdl]->inst_id)) {
 			ipa_ep_idx_rx = ipa_get_ep_mapping(IPA_CLIENT_WLAN2_PROD);
 			ipa_ep_idx_tx = ipa_get_ep_mapping(IPA_CLIENT_WLAN2_CONS);
@@ -1109,7 +1109,7 @@
 		ipa_ep_idx_tx = ipa_get_ep_mapping(IPA_CLIENT_WLAN1_CONS);
 	}
 
-	if (ipa_wdi_ctx_list[hdl]->wdi_version == IPA_WDI_3) {
+	if (ipa_wdi_ctx_list[hdl]->wdi_version >= IPA_WDI_3) {
 		if (ipa3_disconn_wdi3_pipes(
 			ipa_ep_idx_tx, ipa_ep_idx_rx, ipa_ep_idx_tx1)) {
 			IPA_WDI_ERR("fail to tear down wdi pipes\n");
@@ -1167,7 +1167,7 @@
 		return -EPERM;
 	}
 
-	if (ipa_wdi_ctx_list[hdl]->wdi_version == IPA_WDI_3) {
+	if (ipa_wdi_ctx_list[hdl]->wdi_version >= IPA_WDI_3) {
 		if (IPA_CLIENT_IS_WLAN0_INSTANCE(ipa_wdi_ctx_list[hdl]->inst_id)) {
 			ipa_ep_idx_rx = ipa_get_ep_mapping(IPA_CLIENT_WLAN2_PROD);
 			ipa_ep_idx_tx = ipa_get_ep_mapping(IPA_CLIENT_WLAN2_CONS);
@@ -1184,7 +1184,7 @@
 		ipa_ep_idx_tx = ipa_get_ep_mapping(IPA_CLIENT_WLAN1_CONS);
 	}
 
-	if (ipa_wdi_ctx_list[hdl]->wdi_version == IPA_WDI_3) {
+	if (ipa_wdi_ctx_list[hdl]->wdi_version >= IPA_WDI_3) {
 		if (ipa3_disable_wdi3_pipes(
 			ipa_ep_idx_tx, ipa_ep_idx_rx, ipa_ep_idx_tx1)) {
 			IPA_WDI_ERR("fail to disable wdi pipes\n");
diff --git a/drivers/platform/msm/ipa/ipa_common_i.h b/drivers/platform/msm/ipa/ipa_common_i.h
index 730a57e..186ee54 100644
--- a/drivers/platform/msm/ipa/ipa_common_i.h
+++ b/drivers/platform/msm/ipa/ipa_common_i.h
@@ -189,8 +189,8 @@
 	 (x == ipa3_get_ep_mapping(IPA_CLIENT_AQC_ETHERNET_PROD)) || \
 	 (x == ipa3_get_ep_mapping(IPA_CLIENT_RTK_ETHERNET_PROD)))
 
-#define IPA_GSI_CHANNEL_STOP_SLEEP_MIN_USEC (3000)
-#define IPA_GSI_CHANNEL_STOP_SLEEP_MAX_USEC (5000)
+#define IPA_GSI_CHANNEL_STOP_SLEEP_MIN_USEC (1000)
+#define IPA_GSI_CHANNEL_STOP_SLEEP_MAX_USEC (2000)
 
 #define STR_ETH_IFACE "eth"
 #define STR_ETH0_IFACE "eth0"
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa.c b/drivers/platform/msm/ipa/ipa_v3/ipa.c
index 0d96a11..24f1923 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa.c
@@ -9109,6 +9109,25 @@
 };
 #endif
 
+static u32 get_ipa_gen_rx_cmn_page_pool_size(u32 rx_cmn_page_pool_size)
+{
+        if (!rx_cmn_page_pool_size)
+                return IPA_GENERIC_RX_CMN_PAGE_POOL_SZ_FACTOR;
+        if (rx_cmn_page_pool_size <= IPA_GENERIC_RX_CMN_PAGE_POOL_SZ_FACTOR)
+                return rx_cmn_page_pool_size;
+        return IPA_GENERIC_RX_CMN_PAGE_POOL_SZ_FACTOR;
+}
+
+
+static u32 get_ipa_gen_rx_cmn_temp_pool_size(u32 rx_cmn_temp_pool_size)
+{
+        if (!rx_cmn_temp_pool_size)
+                return IPA_GENERIC_RX_CMN_TEMP_POOL_SZ_FACTOR;
+        if (rx_cmn_temp_pool_size <= IPA_GENERIC_RX_CMN_TEMP_POOL_SZ_FACTOR)
+                return rx_cmn_temp_pool_size;
+        return IPA_GENERIC_RX_CMN_TEMP_POOL_SZ_FACTOR;
+}
+
 /**
  * ipa3_pre_init() - Initialize the IPA Driver.
  * This part contains all initialization which doesn't require IPA HW, such
@@ -9262,6 +9281,10 @@
 	ipa3_ctx->rmnet_ll_enable = resource_p->rmnet_ll_enable;
 	ipa3_ctx->tx_wrapper_cache_max_size = get_tx_wrapper_cache_size(
 			resource_p->tx_wrapper_cache_max_size);
+	ipa3_ctx->ipa_gen_rx_cmn_page_pool_sz_factor = get_ipa_gen_rx_cmn_page_pool_size(
+                        resource_p->ipa_gen_rx_cmn_page_pool_sz_factor);
+        ipa3_ctx->ipa_gen_rx_cmn_temp_pool_sz_factor = get_ipa_gen_rx_cmn_temp_pool_size(
+                        resource_p->ipa_gen_rx_cmn_temp_pool_sz_factor);
 	ipa3_ctx->ipa_config_is_auto = resource_p->ipa_config_is_auto;
 	ipa3_ctx->ipa_mhi_proxy = resource_p->ipa_mhi_proxy;
 	ipa3_ctx->max_num_smmu_cb = resource_p->max_num_smmu_cb;
@@ -10110,6 +10133,40 @@
 		ipa_drv_res->tx_wrapper_cache_max_size);
 }
 
+
+static void get_dts_ipa_gen_rx_cmn_page_pool_sz_factor(struct platform_device *pdev,
+                struct ipa3_plat_drv_res *ipa_drv_res)
+{
+        int result;
+
+        result = of_property_read_u32 (
+                pdev->dev.of_node,
+                "qcom,ipa-gen-rx-cmn-page-pool-sz-factor",
+                &ipa_drv_res->ipa_gen_rx_cmn_page_pool_sz_factor);
+        if (result)
+                ipa_drv_res->ipa_gen_rx_cmn_page_pool_sz_factor = 0;
+
+        IPADBG("ipa_gen_rx_cmn_page_pool_sz_factor is set to %d",
+                ipa_drv_res->ipa_gen_rx_cmn_page_pool_sz_factor);
+}
+
+
+static void get_dts_ipa_gen_rx_cmn_temp_pool_sz_factor(struct platform_device *pdev,
+                struct ipa3_plat_drv_res *ipa_drv_res)
+{
+        int result;
+
+        result = of_property_read_u32 (
+                pdev->dev.of_node,
+                "qcom,ipa-gen-rx-cmn-temp-pool-sz-factor",
+                &ipa_drv_res->ipa_gen_rx_cmn_temp_pool_sz_factor);
+        if (result)
+                ipa_drv_res->ipa_gen_rx_cmn_temp_pool_sz_factor = 0;
+
+        IPADBG("ipa_gen_rx_cmn_temp_pool_sz_factor is set to %d",
+                ipa_drv_res->ipa_gen_rx_cmn_temp_pool_sz_factor);
+}
+
 static void ipa_dts_get_ulso_data(struct platform_device *pdev,
 		struct ipa3_plat_drv_res *ipa_drv_res)
 {
@@ -10832,6 +10889,10 @@
 
 	get_dts_tx_wrapper_cache_size(pdev, ipa_drv_res);
 
+	get_dts_ipa_gen_rx_cmn_page_pool_sz_factor(pdev, ipa_drv_res);
+
+        get_dts_ipa_gen_rx_cmn_temp_pool_sz_factor(pdev, ipa_drv_res);
+
 	ipa_dts_get_ulso_data(pdev, ipa_drv_res);
 
 	result = of_property_read_u32(pdev->dev.of_node,
@@ -11975,7 +12036,7 @@
 
 	switch (in->smmu_client) {
 	case IPA_SMMU_WLAN_CLIENT:
-		if (ipa_get_wdi_version() == IPA_WDI_3 ||
+		if (ipa_get_wdi_version() >= IPA_WDI_3 ||
 			IPA_WDI2_OVER_GSI())
 			is_smmu_enable =
 				!(ipa3_ctx->s1_bypass_arr[IPA_SMMU_CB_AP] ||
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_client.c b/drivers/platform/msm/ipa/ipa_v3/ipa_client.c
index e53be43..37c466b 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa_client.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_client.c
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <asm/barrier.h>
@@ -80,6 +81,14 @@
 			ep->client == IPA_CLIENT_USB_CONS) {
 			holb_cfg.en = IPA_HOLB_TMR_EN;
 			holb_cfg.tmr_val = IPA_HOLB_TMR_VAL_4_5;
+		} else if ((ipa3_ctx->ipa_hw_type == IPA_HW_v4_5) &&
+				(ep->client == IPA_CLIENT_USB_CONS)) {
+			holb_cfg.tmr_val = IPA_HOLB_TMR_VAL_4_5;
+			holb_cfg.en = IPA_HOLB_TMR_EN;
+		} else if ((ipa3_ctx->ipa_hw_type >= IPA_HW_v5_2) &&
+				(ep->client == IPA_CLIENT_USB_CONS)) {
+			holb_cfg.tmr_val = IPA_HOLB_TMR_VAL_4_5;
+			holb_cfg.en = IPA_HOLB_TMR_EN;
 		} else {
 			holb_cfg.en = IPA_HOLB_TMR_DIS;
 			holb_cfg.tmr_val = 0;
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_dp.c b/drivers/platform/msm/ipa/ipa_v3/ipa_dp.c
index 71408e9..d7a09a8 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa_dp.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_dp.c
@@ -1730,7 +1730,7 @@
 					sys_in->client == IPA_CLIENT_APPS_WAN_COAL_CONS)
 					ep->sys->page_recycle_repl->capacity =
 							(ep->sys->rx_pool_sz + 1) *
-							IPA_GENERIC_RX_CMN_PAGE_POOL_SZ_FACTOR;
+							ipa3_ctx->ipa_gen_rx_cmn_page_pool_sz_factor;
 				else
 					ep->sys->page_recycle_repl->capacity =
 							(ep->sys->rx_pool_sz + 1) *
@@ -1759,7 +1759,7 @@
 			if (ipa3_ctx->wan_common_page_pool &&
 				sys_in->client == IPA_CLIENT_APPS_WAN_COAL_CONS)
 				ep->sys->repl->capacity = (ep->sys->rx_pool_sz + 1) *
-				IPA_GENERIC_RX_CMN_TEMP_POOL_SZ_FACTOR;
+				ipa3_ctx->ipa_gen_rx_cmn_temp_pool_sz_factor;
 			else
 				ep->sys->repl->capacity = (ep->sys->rx_pool_sz + 1);
 			IPADBG("Repl capacity for client:%d, value:%d\n",
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_hw_stats.c b/drivers/platform/msm/ipa/ipa_v3/ipa_hw_stats.c
index 3043ad7..b255adb 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa_hw_stats.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_hw_stats.c
@@ -1161,7 +1161,7 @@
 		goto destroy_imm;
 	}
 
-	stats_all = kzalloc(sizeof(*stats_all), GFP_KERNEL);
+	stats_all = vmalloc(sizeof(*stats_all));
 	if (!stats_all) {
 		IPADBG("failed to alloc memory\n");
 		ret = -ENOMEM;
@@ -1248,7 +1248,7 @@
 
 	ret = 0;
 free_stats:
-	kfree(stats_all);
+	vfree(stats_all);
 	stats = NULL;
 destroy_imm:
 	for (i = 0; i < num_cmd; i++)
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_i.h b/drivers/platform/msm/ipa/ipa_v3/ipa_i.h
index 1922d0f..b603378 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa_i.h
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_i.h
@@ -2526,6 +2526,8 @@
 	struct ipahal_imm_cmd_pyld *coal_cmd_pyld[MAX_CCP_SUB];
 	struct ipa_mem_buffer ulso_wa_cmd;
 	u32 tx_wrapper_cache_max_size;
+	u32 ipa_gen_rx_cmn_page_pool_sz_factor;
+        u32 ipa_gen_rx_cmn_temp_pool_sz_factor;
 	struct ipa3_app_clock_vote app_clock_vote;
 	bool clients_registered;
 	bool ipa_gpi_event_rp_ddr;
@@ -2660,6 +2662,8 @@
 	const char *gsi_fw_file_name;
 	const char *uc_fw_file_name;
 	u32 tx_wrapper_cache_max_size;
+	u32 ipa_gen_rx_cmn_page_pool_sz_factor;
+        u32 ipa_gen_rx_cmn_temp_pool_sz_factor;
 	u32 ipa_wan_aggr_pkt_cnt;
 	bool ipa_mhi_proxy;
 	u32 max_num_smmu_cb;
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_uc_wdi.c b/drivers/platform/msm/ipa/ipa_v3/ipa_uc_wdi.c
index 52b96d5..1762de6 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa_uc_wdi.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_uc_wdi.c
@@ -740,14 +740,14 @@
 
 	if (IPA_CLIENT_IS_CONS(client)) {
 		start = IPA_WDI_TX_RING_RES;
-		if (ipa_get_wdi_version() == IPA_WDI_3)
+		if (ipa_get_wdi_version() >= IPA_WDI_3)
 			end = IPA_WDI_TX_DB_RES;
 		else
 			end = IPA_WDI_CE_DB_RES;
 	} else {
 		start = IPA_WDI_RX_RING_RES;
 		if (ipa3_ctx->ipa_wdi2 ||
-			(ipa_get_wdi_version() == IPA_WDI_3))
+			(ipa_get_wdi_version() >= IPA_WDI_3))
 			end = IPA_WDI_RX_COMP_RING_WP_RES;
 		else
 			end = IPA_WDI_RX_RING_RP_RES;
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_utils.c b/drivers/platform/msm/ipa/ipa_v3/ipa_utils.c
index fd44782..cc48442 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa_utils.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_utils.c
@@ -4180,7 +4180,7 @@
 	[IPA_5_0][IPA_CLIENT_ODU_PROD]  = {
 			true, IPA_v5_0_GROUP_UL,
 			true,
-			IPA_DPS_HPS_SEQ_TYPE_PKT_PROCESS_NO_DEC_UCP,
+			IPA_DPS_HPS_SEQ_TYPE_2ND_PKT_PROCESS_PASS_NO_DEC_UCP,
 			QMB_MASTER_SELECT_DDR,
 			{ 7, 17, 8, 16, IPA_EE_AP, GSI_SMART_PRE_FETCH, 3 },
 			IPA_TX_INSTANCE_NA },
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_wdi3_i.c b/drivers/platform/msm/ipa/ipa_v3/ipa_wdi3_i.c
index e97a7b4..89ade11 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa_wdi3_i.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_wdi3_i.c
@@ -13,6 +13,7 @@
 #define IPA_WLAN_AGGR_BYTE_LIMIT 2 /*2 Kbytes Agger hard byte limit*/
 
 #define IPA_WDI3_GSI_EVT_RING_INT_MODT 32
+#define IPA_WDI3_MAX_VALUE_OF_BANK_ID 63
 
 static void ipa3_wdi3_gsi_evt_ring_err_cb(struct gsi_evt_err_notify *notify)
 {
@@ -80,9 +81,20 @@
 		IPAERR("invalid input\n");
 		return -EINVAL;
 	}
-	/* setup event ring */
 	memset(&gsi_evt_ring_props, 0, sizeof(gsi_evt_ring_props));
-	gsi_evt_ring_props.intf = GSI_EVT_CHTYPE_WDI3_EV;
+	memset(&gsi_channel_props, 0, sizeof(gsi_channel_props));
+
+	if(ipa_get_wdi_version() == IPA_WDI_3_V2) {
+		gsi_channel_props.prot = GSI_CHAN_PROT_WDI3_V2;
+		gsi_evt_ring_props.intf = GSI_EVT_CHTYPE_WDI3_V2_EV;
+	}
+	else {
+		gsi_channel_props.prot = GSI_CHAN_PROT_WDI3;
+		gsi_evt_ring_props.intf = GSI_EVT_CHTYPE_WDI3_EV;
+	}
+
+	/* setup event ring */
+
 	if (ipa3_ctx->ipa_hw_type >= IPA_HW_v4_9) {
 		gsi_evt_ring_props.intr = GSI_INTR_MSI;
 		/* 32 (for Tx) and 8 (for Rx) */
@@ -166,8 +178,6 @@
 		gsi_evt_ring_props.ring_base_addr;
 
 	/* setup channel ring */
-	memset(&gsi_channel_props, 0, sizeof(gsi_channel_props));
-	gsi_channel_props.prot = GSI_CHAN_PROT_WDI3;
 	if ((dir == IPA_WDI3_TX_DIR) || (dir == IPA_WDI3_TX1_DIR) ||
 		(dir == IPA_WDI3_TX2_DIR))
 		gsi_channel_props.dir = GSI_CHAN_DIR_FROM_GSI;
@@ -185,13 +195,19 @@
 
 	gsi_channel_props.db_in_bytes = 0;
 	gsi_channel_props.evt_ring_hdl = ep->gsi_evt_ring_hdl;
+
 	if (ipa3_ctx->ipa_hw_type >= IPA_HW_v4_9) {
 		/* 32 (for Tx) and 64 (for Rx) */
 		if ((dir == IPA_WDI3_TX_DIR) || (dir == IPA_WDI3_TX1_DIR) ||
 			(dir == IPA_WDI3_TX2_DIR))
 			gsi_channel_props.re_size = GSI_CHAN_RE_SIZE_32B;
-		else
-			gsi_channel_props.re_size = GSI_CHAN_RE_SIZE_64B;
+		else {
+			if (gsi_channel_props.prot == GSI_CHAN_PROT_WDI3_V2)
+				gsi_channel_props.re_size = GSI_CHAN_RE_SIZE_32B;
+			else 
+				gsi_channel_props.re_size = GSI_CHAN_RE_SIZE_64B;
+		}
+
 	} else
 		gsi_channel_props.re_size = GSI_CHAN_RE_SIZE_16B;
 
@@ -519,6 +535,48 @@
 			(1 << 8));
 	}
 
+	if(ipa_get_wdi_version() == IPA_WDI_3_V2) {
+
+		ch_scratch.wdi3_v2.wifi_rp_address_high =
+			ch_scratch.wdi3.wifi_rp_address_high;
+
+		ch_scratch.wdi3_v2.wifi_rp_address_low =
+			ch_scratch.wdi3.wifi_rp_address_low;
+
+		ch_scratch.wdi3_v2.update_rp_moderation_threshold =
+			ch_scratch.wdi3.update_rp_moderation_threshold;
+
+
+		if ( dir == IPA_WDI3_RX_DIR) {
+
+			ch_scratch.wdi3_v2.rx_pkt_offset = ch_scratch.wdi3.rx_pkt_offset;
+			ch_scratch.wdi3_v2.endp_metadata_reg_offset =
+						ch_scratch.wdi3.endp_metadata_reg_offset;
+		} else {
+
+
+				if(is_smmu_enabled) {
+					if(info_smmu->rx_bank_id > IPA_WDI3_MAX_VALUE_OF_BANK_ID) {
+						IPAERR("Incorrect bank id value %d Exceeding the 6bit range\n", info_smmu->rx_bank_id);
+						goto fail_write_scratch;
+					}
+					ch_scratch.wdi3_v2.bank_id = info_smmu->rx_bank_id;
+				}
+				else {
+					if(info->rx_bank_id > IPA_WDI3_MAX_VALUE_OF_BANK_ID) {
+						IPAERR("Incorrect bank id value %d Exceeding the 6bit range\n", info->rx_bank_id);
+						goto fail_write_scratch;
+					}
+
+					ch_scratch.wdi3_v2.bank_id = info->rx_bank_id;
+				}
+		}
+
+		ch_scratch.wdi3_v2.qmap_id = 0;
+		ch_scratch.wdi3_v2.reserved1 = 0;
+		ch_scratch.wdi3_v2.reserved2 = 0;
+	}
+
 	result = gsi_write_channel_scratch(ep->gsi_chan_hdl, ch_scratch);
 	if (result != GSI_STATUS_SUCCESS) {
 		IPAERR("failed to write evt ring scratch\n");
@@ -557,7 +615,7 @@
 	u8 rx_dir, tx_dir;
 
 	/* wdi3 only support over gsi */
-	if (ipa_get_wdi_version() != IPA_WDI_3) {
+	if (ipa_get_wdi_version() < IPA_WDI_3) {
 		IPAERR("wdi3 over uc offload not supported");
 		WARN_ON(1);
 		return -EFAULT;
@@ -870,12 +928,12 @@
 	int ipa_ep_idx_tx1)
 {
 	struct ipa3_ep_context *ep_tx, *ep_rx, *ep_tx1;
-	int result = 0;
 	enum ipa_client_type rx_client;
 	enum ipa_client_type tx_client;
+	int result = 0;
 
 	/* wdi3 only support over gsi */
-	if (ipa_get_wdi_version() != IPA_WDI_3) {
+	if (ipa_get_wdi_version() < IPA_WDI_3) {
 		IPAERR("wdi3 over uc offload not supported");
 		WARN_ON(1);
 		return -EFAULT;
@@ -988,7 +1046,7 @@
 	u32 holb_max_cnt = ipa3_ctx->uc_ctx.holb_monitor.max_cnt_wlan;
 
 	/* wdi3 only support over gsi */
-	if (ipa_get_wdi_version() != IPA_WDI_3) {
+	if (ipa_get_wdi_version() < IPA_WDI_3) {
 		IPAERR("wdi3 over uc offload not supported");
 		WARN_ON(1);
 		return -EFAULT;
@@ -1133,7 +1191,7 @@
 	struct ipahal_ep_cfg_ctrl_scnd ep_ctrl_scnd = { 0 };
 
 	/* wdi3 only support over gsi */
-	if (ipa_get_wdi_version() != IPA_WDI_3) {
+	if (ipa_get_wdi_version() < IPA_WDI_3) {
 		IPAERR("wdi3 over uc offload not supported");
 		WARN_ON(1);
 		return -EFAULT;
diff --git a/kernel-tests/network_traffic/UlsoPacket.h b/kernel-tests/network_traffic/UlsoPacket.h
index f98ef3e..8d1498d 100644
--- a/kernel-tests/network_traffic/UlsoPacket.h
+++ b/kernel-tests/network_traffic/UlsoPacket.h
@@ -205,7 +205,7 @@
         uint32_t seqNum = 0;
 
         if(isSegmented()){
-            throw std::logic_error("A segmented packet cannot be segmented again!");
+            return vector<UlsoPacket>();
         }
         unsigned int segmentSize = mQmapHeader.mSegmentSize.to_ulong();
         vector<vector<uint8_t>> payloads = segmentPayload(segmentSize, mPayload);
diff --git a/kernel-tests/network_traffic/bits_utils.h b/kernel-tests/network_traffic/bits_utils.h
index ba40258..4611cb5 100644
--- a/kernel-tests/network_traffic/bits_utils.h
+++ b/kernel-tests/network_traffic/bits_utils.h
@@ -98,7 +98,7 @@
     vector<bool> outVec;
 
     for(int i = N-1; i >= 0; i--){
-	    outVect.push_back(bits[i]);
+	    outVec.push_back(bits[i]);
     }
     return outVec;
 }