Parcourir la source

msm: ipa: Add support to configure COAL_MASTER_CFG

Make changes to configure COAL_MASTER_CFG. Enable IPv4 ID
ignore bit by default. Give provision to configure via DT.

Change-Id: I17d4b368458417f4379d82bbfce754672b5f27aa
Signed-off-by: Chaitanya Pratapa <[email protected]>
Chaitanya Pratapa il y a 3 ans
Parent
commit
8b281fbc53

+ 13 - 0
drivers/platform/msm/ipa/ipa_v3/ipa.c

@@ -8780,6 +8780,7 @@ static int ipa3_pre_init(const struct ipa3_plat_drv_res *resource_p,
 	ipa3_ctx->ipa_endp_delay_wa = resource_p->ipa_endp_delay_wa;
 	ipa3_ctx->ipa_endp_delay_wa_v2 = resource_p->ipa_endp_delay_wa_v2;
 	ipa3_ctx->ulso_wa = resource_p->ulso_wa;
+	ipa3_ctx->coal_ipv4_id_ignore = resource_p->coal_ipv4_id_ignore;
 
 	WARN(!IPA_IS_REGULAR_CLK_MODE(ipa3_ctx->ipa3_hw_mode),
 		"Non NORMAL IPA HW mode, is this emulation platform ?");
@@ -9607,6 +9608,7 @@ static int get_ipa_dts_configuration(struct platform_device *pdev,
 	ipa_drv_res->rmnet_ctl_enable = 0;
 	ipa_drv_res->rmnet_ll_enable = 0;
 	ipa_drv_res->ulso_wa = false;
+	ipa_drv_res->coal_ipv4_id_ignore = true;
 
 	/* Get IPA HW Version */
 	result = of_property_read_u32(pdev->dev.of_node, "qcom,ipa-hw-ver",
@@ -10252,6 +10254,17 @@ static int get_ipa_dts_configuration(struct platform_device *pdev,
 		IPADBG(": found ipa_drv_res->max_num_smmu_cb = %d\n",
 			ipa_drv_res->max_num_smmu_cb);
 
+	result = of_property_read_u8(pdev->dev.of_node,
+					"qcom,coal-ipv4-id-ignore",
+					&ipa_drv_res->coal_ipv4_id_ignore);
+	if (result || ipa_drv_res->coal_ipv4_id_ignore > 1) {
+		IPADBG(":Resource not present for coal-ipv4-id-ignore, use def\n");
+		ipa_drv_res->coal_ipv4_id_ignore = true;
+	}
+	IPADBG(": coal-ipv4-id-ignore = %s\n",
+			ipa_drv_res->coal_ipv4_id_ignore
+			? "True" : "False");
+
 	return 0;
 }
 

+ 3 - 0
drivers/platform/msm/ipa/ipa_v3/ipa_i.h

@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
 /*
  * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #ifndef _IPA3_I_H_
@@ -2401,6 +2402,7 @@ struct ipa3_context {
 	int ipa_pil_load;
 	u32 ipa_max_napi_sort_page_thrshld;
 	u32 page_wq_reschd_time;
+	bool coal_ipv4_id_ignore;
 };
 
 struct ipa3_plat_drv_res {
@@ -2481,6 +2483,7 @@ struct ipa3_plat_drv_res {
 	bool use_pm_wrapper;
 	bool use_tput_est_ep;
 	bool ulso_wa;
+	u8 coal_ipv4_id_ignore;
 };
 
 /**

+ 13 - 1
drivers/platform/msm/ipa/ipa_v3/ipa_utils.c

@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0-only
 /*
  * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved.
+ * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  */
 
 #include <net/ip.h>
@@ -7374,6 +7375,7 @@ int ipa3_init_hw(void)
 {
 	u32 ipa_version = 0;
 	struct ipahal_reg_counter_cfg cnt_cfg;
+	struct ipahal_reg_coal_master_cfg master_cfg;
 
 	/* Read IPA version and make sure we have access to the registers */
 	ipa_version = ipahal_read_reg(IPA_VERSION);
@@ -7441,8 +7443,18 @@ int ipa3_init_hw(void)
 		ipa3_ctx->ulso_ip_id_max);
 	}
 
-	ipa_comp_cfg();
+	/* Configure COAL_MASTER_CFG */
+	memset(&master_cfg, 0, sizeof(master_cfg));
+	ipahal_read_reg_fields(IPA_COAL_MASTER_CFG, &master_cfg);
+	master_cfg.coal_ipv4_id_ignore = ipa3_ctx->coal_ipv4_id_ignore;
+	ipahal_write_reg_fields(IPA_COAL_MASTER_CFG, &master_cfg);
+
+	IPADBG(": coal-ipv4-id-ignore = %s\n",
+			master_cfg.coal_ipv4_id_ignore
+			? "True" : "False");
 
+
+	ipa_comp_cfg();
 	/*
 	 * In IPA 4.2 filter and routing hashing not supported
 	 * disabling hash enable register.

+ 44 - 0
drivers/platform/msm/ipa/ipa_v3/ipahal/ipahal_reg.c

@@ -180,6 +180,7 @@ static const char *ipareg_name_to_str[IPA_REG_MAX] = {
 	__stringify(IPA_RAM_INGRESS_POLICER_DB_BASE_ADDR),
 	__stringify(IPA_RAM_EGRESS_SHAPING_PROD_DB_BASE_ADDR),
 	__stringify(IPA_RAM_EGRESS_SHAPING_TC_DB_BASE_ADDR),
+	__stringify(IPA_COAL_MASTER_CFG),
 };
 
 static void ipareg_construct_dummy(enum ipahal_reg_name reg,
@@ -3331,6 +3332,46 @@ static void ipareg_parse_coal_qmap_cfg(enum ipahal_reg_name reg,
 		IPA_COAL_QMAP_CFG_SHFT, IPA_COAL_QMAP_CFG_BMSK);
 }
 
+static void ipareg_construct_coal_master_cfg(enum ipahal_reg_name reg,
+	const void *fields, u32 *val)
+{
+	struct ipahal_reg_coal_master_cfg *master_cfg =
+		(struct ipahal_reg_coal_master_cfg *)fields;
+
+	IPA_SETFIELD_IN_REG(*val, master_cfg->coal_ipv4_id_ignore,
+		IPA_COAL_MASTER_CFG_IPV4_ID_IGNORE_EN_SHFT,
+		IPA_COAL_MASTER_CFG_IPV4_ID_IGNORE_EN_BMSK);
+
+	IPA_SETFIELD_IN_REG(*val, master_cfg->coal_enhanced_ipv4_id_en,
+		IPA_COAL_MASTER_CFG_ENHANCED_IPV4_ID_EN_SHFT,
+		IPA_COAL_MASTER_CFG_ENHANCED_IPV4_ID_EN_BMSK);
+
+	IPA_SETFIELD_IN_REG(*val, master_cfg->coal_force_to_default,
+		IPA_COAL_MASTER_CFG_FORCE_TO_DEFAULT_EN_SHFT,
+		IPA_COAL_MASTER_CFG_FORCE_TO_DEFAULT_EN_BMSK);
+}
+
+static void ipareg_parse_coal_master_cfg(enum ipahal_reg_name reg,
+	void *fields, u32 val)
+{
+	struct ipahal_reg_coal_master_cfg *master_cfg =
+		(struct ipahal_reg_coal_master_cfg *)fields;
+
+	memset(master_cfg, 0, sizeof(*master_cfg));
+
+	master_cfg->coal_ipv4_id_ignore = IPA_GETFIELD_FROM_REG(val,
+		IPA_COAL_MASTER_CFG_IPV4_ID_IGNORE_EN_SHFT,
+		IPA_COAL_MASTER_CFG_IPV4_ID_IGNORE_EN_BMSK);
+
+	master_cfg->coal_enhanced_ipv4_id_en = IPA_GETFIELD_FROM_REG(val,
+		IPA_COAL_MASTER_CFG_ENHANCED_IPV4_ID_EN_SHFT,
+		IPA_COAL_MASTER_CFG_ENHANCED_IPV4_ID_EN_BMSK);
+
+	master_cfg->coal_force_to_default = IPA_GETFIELD_FROM_REG(val,
+		IPA_COAL_MASTER_CFG_FORCE_TO_DEFAULT_EN_SHFT,
+		IPA_COAL_MASTER_CFG_FORCE_TO_DEFAULT_EN_BMSK);
+}
+
 static void ipareg_parse_ipa_flavor_0(enum ipahal_reg_name reg,
 	void *fields, u32 val)
 {
@@ -5129,6 +5170,9 @@ static struct ipahal_reg_obj ipahal_reg_objs[IPA_HW_MAX][IPA_REG_MAX] = {
 	[IPA_HW_v5_5][IPA_COAL_EVICT_LRU] = {
 		ipareg_construct_coal_evict_lru_v5_5, ipareg_parse_coal_evict_lru_v5_5,
 		0x00000918, 0, 0, 0, 0, 0},
+	[IPA_HW_v5_5][IPA_COAL_MASTER_CFG] = {
+		ipareg_construct_coal_master_cfg, ipareg_parse_coal_master_cfg,
+		0x00000914, 0, 0, 0, 0, 0},
 	[IPA_HW_v5_5][IPA_COAL_QMAP_CFG] = {
 		ipareg_construct_coal_qmap_cfg, ipareg_parse_coal_qmap_cfg,
 		0x0000091c, 0, 0, 0, 0, 0},

+ 19 - 0
drivers/platform/msm/ipa/ipa_v3/ipahal/ipahal_reg.h

@@ -178,6 +178,7 @@ enum ipahal_reg_name {
 	IPA_RAM_INGRESS_POLICER_DB_BASE_ADDR,
 	IPA_RAM_EGRESS_SHAPING_PROD_DB_BASE_ADDR,
 	IPA_RAM_EGRESS_SHAPING_TC_DB_BASE_ADDR,
+	IPA_COAL_MASTER_CFG,
 	IPA_REG_MAX,
 };
 
@@ -804,6 +805,24 @@ struct ipahal_reg_coal_qmap_cfg {
 	u32 mux_id_byte_sel;
 };
 
+/*
+ * struct ipahal_reg_coal_master_cfg - IPA_COAL_MASTER_CFG register
+ * @coal_ipv4_id_ignore: 1 - global ignore IPV4 ID checks regardles DF,
+ * val 0 -keep checks according to DF/MF  conditions.
+ * @coal_enhanced_ipv4_id_en: 1 - if (DF == 1 && MF == 0 && frag_offset == 0)
+ * Coalescingwill ignore IPv4 identification field, else legacy behaviour
+ * is used.
+ * 0 - Coalescing will use original legacy IPv4 identification field check.
+ * @coal_force_to_default: 1 - force any new packet that arrives to coal master
+ * to default pipe, and close any open frames with the same tuple
+ * 0 - regular coalescing activity.
+ */
+struct ipahal_reg_coal_master_cfg {
+	bool coal_ipv4_id_ignore;
+	bool coal_enhanced_ipv4_id_en;
+	bool coal_force_to_default;
+};
+
 /*
  * struct ipahal_ipa_flavor_0 - IPA_FLAVOR_0 register
  * @ipa_pipes: Number of supported pipes

+ 8 - 0
drivers/platform/msm/ipa/ipa_v3/ipahal/ipahal_reg_i.h

@@ -899,6 +899,14 @@ int ipahal_reg_init(enum ipa_hw_type ipa_hw_type);
 #define IPA_COAL_EVICTION_EN_BMSK_v5_5 0x1
 #define IPA_COAL_EVICTION_EN_SHFT_v5_5 0
 
+/* IPA_COAL_MASTER_CFG */
+#define IPA_COAL_MASTER_CFG_IPV4_ID_IGNORE_EN_BMSK 0x4
+#define IPA_COAL_MASTER_CFG_IPV4_ID_IGNORE_EN_SHFT 2
+#define IPA_COAL_MASTER_CFG_ENHANCED_IPV4_ID_EN_BMSK 0x2
+#define IPA_COAL_MASTER_CFG_ENHANCED_IPV4_ID_EN_SHFT 1
+#define IPA_COAL_MASTER_CFG_FORCE_TO_DEFAULT_EN_BMSK 0x1
+#define IPA_COAL_MASTER_CFG_FORCE_TO_DEFAULT_EN_SHFT 0
+
 /* IPA_ENDP_INIT_NAT_EXC_SUPPRESS_n register */
 #define IPA_ENDP_INIT_NAT_EXC_SUPPRESS_n_EN_BMSK 0x1
 #define IPA_ENDP_INIT_NAT_EXC_SUPPRESS_n_EN_SHFT 0x0