Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4411c560 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: ipa: remove aggregation sysfs parameters"

parents 07779f7c 308d4547
Loading
Loading
Loading
Loading
+0 −217
Original line number Diff line number Diff line
@@ -133,8 +133,6 @@ static int ipa_load_pipe_connection(struct platform_device *pdev,
static int ipa_update_connections_info(struct device_node *node,
			struct a2_mux_pipe_connection *pipe_connection);

static void ipa_set_aggregation_params(void);

static int ipa_open(struct inode *inode, struct file *filp)
{
	struct ipa_context *ctx = NULL;
@@ -1309,206 +1307,6 @@ int ipa_get_a2_mux_bam_info(u32 *a2_bam_mem_base, u32 *a2_bam_mem_size,
	return 0;
}

static void ipa_set_aggregation_params(void)
{
	struct ipa_ep_cfg_aggr agg_params;
	struct ipa_ep_cfg_hdr hdr_params;
	u32 producer_hdl = 0;
	u32 consumer_hdl = 0;

	teth_bridge_get_client_handles(&producer_hdl, &consumer_hdl);

	/* configure aggregation on producer */
	memset(&agg_params, 0, sizeof(struct ipa_ep_cfg_aggr));
	agg_params.aggr_en = IPA_ENABLE_AGGR;
	agg_params.aggr = ipa_ctx->aggregation_type;
	agg_params.aggr_byte_limit = ipa_ctx->aggregation_byte_limit;
	agg_params.aggr_time_limit = ipa_ctx->aggregation_time_limit;
	ipa_cfg_ep_aggr(producer_hdl, &agg_params);

	if (ipa_ctx->ipa_hw_type == IPA_HW_v1_0) {
		/* configure header on producer */
		memset(&hdr_params, 0, sizeof(struct ipa_ep_cfg_hdr));
		hdr_params.hdr_len = 1;
		ipa_cfg_ep_hdr(producer_hdl, &hdr_params);
	}

	/* configure deaggregation on consumer */
	memset(&agg_params, 0, sizeof(struct ipa_ep_cfg_aggr));
	agg_params.aggr_en = IPA_ENABLE_DEAGGR;
	agg_params.aggr = ipa_ctx->aggregation_type;
	ipa_cfg_ep_aggr(consumer_hdl, &agg_params);
}

/*
 * The following device attributes are for configuring the aggregation
 * attributes when the driver is already running.
 * The attributes are for configuring the aggregation type
 * (MBIM_16/TLP), the aggregation byte limit and the aggregation
 * time limit.
 */
static ssize_t ipa_show_aggregation_type(struct device *dev,
		struct device_attribute *attr,
		char *buf)
{
	ssize_t ret_val;
	char str[IPA_AGGR_MAX_STR_LENGTH];

	if (!buf) {
		IPAERR("buffer for ipa_show_aggregation_type is NULL\n");
		return -EINVAL;
	}

	memset(str, 0, sizeof(str));

	switch (ipa_ctx->aggregation_type) {
	case IPA_MBIM_16:
		strlcpy(str, "MBIM_16", IPA_AGGR_STR_IN_BYTES("MBIM_16"));
		break;
	case IPA_TLP:
		strlcpy(str, "TLP", IPA_AGGR_STR_IN_BYTES("TLP"));
		break;
	default:
		strlcpy(str, "NONE", IPA_AGGR_STR_IN_BYTES("NONE"));
		break;
	}

	ret_val = scnprintf(buf, PAGE_SIZE, "%s\n", str);

	return ret_val;
}

static ssize_t ipa_store_aggregation_type(struct device *dev,
				     struct device_attribute *attr,
				     const char *buf, size_t count)
{
	char str[IPA_AGGR_MAX_STR_LENGTH], *pstr;

	if (!buf) {
		IPAERR("buffer for ipa_store_aggregation_type is NULL\n");
		return -EINVAL;
	}

	strlcpy(str, buf, sizeof(str));
	pstr = strim(str);

	if (!strncmp(pstr, "MBIM_16", IPA_AGGR_STR_IN_BYTES("MBIM_16")))
		ipa_ctx->aggregation_type = IPA_MBIM_16;
	else if (!strncmp(pstr, "TLP", IPA_AGGR_STR_IN_BYTES("TLP")))
		ipa_ctx->aggregation_type = IPA_TLP;
	else {
		IPAERR("ipa_store_aggregation_type wrong input\n");
		return -EINVAL;
	}

	ipa_set_aggregation_params();

	return count;
}

static DEVICE_ATTR(aggregation_type, S_IWUSR | S_IRUSR,
		ipa_show_aggregation_type,
		ipa_store_aggregation_type);

static ssize_t ipa_show_aggregation_byte_limit(struct device *dev,
		struct device_attribute *attr,
		char *buf)
{
	ssize_t ret_val;

	if (!buf) {
		IPAERR("buffer for ipa_show_aggregation_byte_limit is NULL\n");
		return -EINVAL;
	}

	ret_val = scnprintf(buf, PAGE_SIZE, "%u\n",
			    ipa_ctx->aggregation_byte_limit);

	return ret_val;
}

static ssize_t ipa_store_aggregation_byte_limit(struct device *dev,
				     struct device_attribute *attr,
				     const char *buf, size_t count)
{
	char str[IPA_AGGR_MAX_STR_LENGTH];
	char *pstr;
	u32 ret = 0;

	if (!buf) {
		IPAERR("buffer for ipa_store_aggregation_byte_limit is NULL\n");
		return -EINVAL;
	}

	strlcpy(str, buf, sizeof(str));
	pstr = strim(str);

	if (kstrtouint(pstr, IPA_AGGR_MAX_STR_LENGTH, &ret)) {
		IPAERR("ipa_store_aggregation_byte_limit wrong input\n");
		return -EINVAL;
	}

	ipa_ctx->aggregation_byte_limit = ret;

	ipa_set_aggregation_params();

	return count;
}

static DEVICE_ATTR(aggregation_byte_limit, S_IWUSR | S_IRUSR,
		ipa_show_aggregation_byte_limit,
		ipa_store_aggregation_byte_limit);

static ssize_t ipa_show_aggregation_time_limit(struct device *dev,
		struct device_attribute *attr,
		char *buf)
{
	ssize_t ret_val;

	if (!buf) {
		IPAERR("buffer for ipa_show_aggregation_time_limit is NULL\n");
		return -EINVAL;
	}

	ret_val = scnprintf(buf,
			    PAGE_SIZE,
			    "%u\n",
			    ipa_ctx->aggregation_time_limit);

	return ret_val;
}

static ssize_t ipa_store_aggregation_time_limit(struct device *dev,
				     struct device_attribute *attr,
				     const char *buf, size_t count)
{
	char str[IPA_AGGR_MAX_STR_LENGTH], *pstr;
	u32 ret = 0;

	if (!buf) {
		IPAERR("buffer for ipa_store_aggregation_time_limit is NULL\n");
		return -EINVAL;
	}

	strlcpy(str, buf, sizeof(str));
	pstr = strim(str);

	if (kstrtouint(pstr, IPA_AGGR_MAX_STR_LENGTH, &ret)) {
		IPAERR("ipa_store_aggregation_time_limit wrong input\n");
		return -EINVAL;
	}

	ipa_ctx->aggregation_time_limit = ret;

	ipa_set_aggregation_params();

	return count;
}

static DEVICE_ATTR(aggregation_time_limit, S_IWUSR | S_IRUSR,
		ipa_show_aggregation_time_limit,
		ipa_store_aggregation_time_limit);

static const struct file_operations ipa_drv_fops = {
	.owner = THIS_MODULE,
	.open = ipa_open,
@@ -2444,21 +2242,6 @@ static int ipa_plat_drv_probe(struct platform_device *pdev_p)
		return result;
	}

	result = device_create_file(&pdev_p->dev,
			&dev_attr_aggregation_type);
	if (result)
		IPAERR("failed to create device file\n");

	result = device_create_file(&pdev_p->dev,
			&dev_attr_aggregation_byte_limit);
	if (result)
		IPAERR("failed to create device file\n");

	result = device_create_file(&pdev_p->dev,
			&dev_attr_aggregation_time_limit);
	if (result)
		IPAERR("failed to create device file\n");

	return result;
}