Commit 4bcfb35e authored by Alex Elder's avatar Alex Elder Committed by David S. Miller

net: ipa: index resource limits with type

Remove the type field from the ipa_resource_src and ipa_resource_dst
structures, and instead use that value as the index into the arrays
of source and destination resources.

Change ipa_resource_config_src() and ipa_resource_config_dst() so
the resource type is passed in as an argument.
Signed-off-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent fd2b7bc3
...@@ -150,36 +150,31 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = { ...@@ -150,36 +150,31 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = {
/* Source resource configuration data for the SC7180 SoC */ /* Source resource configuration data for the SC7180 SoC */
static const struct ipa_resource_src ipa_resource_src[] = { static const struct ipa_resource_src ipa_resource_src[] = {
{ [IPA_RESOURCE_TYPE_SRC_PKT_CONTEXTS] = {
.type = IPA_RESOURCE_TYPE_SRC_PKT_CONTEXTS,
.limits[IPA_RSRC_GROUP_SRC_UL_DL] = { .limits[IPA_RSRC_GROUP_SRC_UL_DL] = {
.min = 3, .min = 3,
.max = 63, .max = 63,
}, },
}, },
{ [IPA_RESOURCE_TYPE_SRC_DESCRIPTOR_LISTS] = {
.type = IPA_RESOURCE_TYPE_SRC_DESCRIPTOR_LISTS,
.limits[IPA_RSRC_GROUP_SRC_UL_DL] = { .limits[IPA_RSRC_GROUP_SRC_UL_DL] = {
.min = 3, .min = 3,
.max = 3, .max = 3,
}, },
}, },
{ [IPA_RESOURCE_TYPE_SRC_DESCRIPTOR_BUFF] = {
.type = IPA_RESOURCE_TYPE_SRC_DESCRIPTOR_BUFF,
.limits[IPA_RSRC_GROUP_SRC_UL_DL] = { .limits[IPA_RSRC_GROUP_SRC_UL_DL] = {
.min = 10, .min = 10,
.max = 10, .max = 10,
}, },
}, },
{ [IPA_RESOURCE_TYPE_SRC_HPS_DMARS] = {
.type = IPA_RESOURCE_TYPE_SRC_HPS_DMARS,
.limits[IPA_RSRC_GROUP_SRC_UL_DL] = { .limits[IPA_RSRC_GROUP_SRC_UL_DL] = {
.min = 1, .min = 1,
.max = 1, .max = 1,
}, },
}, },
{ [IPA_RESOURCE_TYPE_SRC_ACK_ENTRIES] = {
.type = IPA_RESOURCE_TYPE_SRC_ACK_ENTRIES,
.limits[IPA_RSRC_GROUP_SRC_UL_DL] = { .limits[IPA_RSRC_GROUP_SRC_UL_DL] = {
.min = 5, .min = 5,
.max = 5, .max = 5,
...@@ -189,15 +184,13 @@ static const struct ipa_resource_src ipa_resource_src[] = { ...@@ -189,15 +184,13 @@ static const struct ipa_resource_src ipa_resource_src[] = {
/* Destination resource configuration data for the SC7180 SoC */ /* Destination resource configuration data for the SC7180 SoC */
static const struct ipa_resource_dst ipa_resource_dst[] = { static const struct ipa_resource_dst ipa_resource_dst[] = {
{ [IPA_RESOURCE_TYPE_DST_DATA_SECTORS] = {
.type = IPA_RESOURCE_TYPE_DST_DATA_SECTORS,
.limits[IPA_RSRC_GROUP_DST_UL_DL_DPL] = { .limits[IPA_RSRC_GROUP_DST_UL_DL_DPL] = {
.min = 3, .min = 3,
.max = 3, .max = 3,
}, },
}, },
{ [IPA_RESOURCE_TYPE_DST_DPS_DMARS] = {
.type = IPA_RESOURCE_TYPE_DST_DPS_DMARS,
.limits[IPA_RSRC_GROUP_DST_UL_DL_DPL] = { .limits[IPA_RSRC_GROUP_DST_UL_DL_DPL] = {
.min = 1, .min = 1,
.max = 63, .max = 63,
......
...@@ -168,8 +168,7 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = { ...@@ -168,8 +168,7 @@ static const struct ipa_gsi_endpoint_data ipa_gsi_endpoint_data[] = {
/* Source resource configuration data for the SDM845 SoC */ /* Source resource configuration data for the SDM845 SoC */
static const struct ipa_resource_src ipa_resource_src[] = { static const struct ipa_resource_src ipa_resource_src[] = {
{ [IPA_RESOURCE_TYPE_SRC_PKT_CONTEXTS] = {
.type = IPA_RESOURCE_TYPE_SRC_PKT_CONTEXTS,
.limits[IPA_RSRC_GROUP_SRC_LWA_DL] = { .limits[IPA_RSRC_GROUP_SRC_LWA_DL] = {
.min = 1, .min = 1,
.max = 255, .max = 255,
...@@ -183,8 +182,7 @@ static const struct ipa_resource_src ipa_resource_src[] = { ...@@ -183,8 +182,7 @@ static const struct ipa_resource_src ipa_resource_src[] = {
.max = 63, .max = 63,
}, },
}, },
{ [IPA_RESOURCE_TYPE_SRC_DESCRIPTOR_LISTS] = {
.type = IPA_RESOURCE_TYPE_SRC_DESCRIPTOR_LISTS,
.limits[IPA_RSRC_GROUP_SRC_LWA_DL] = { .limits[IPA_RSRC_GROUP_SRC_LWA_DL] = {
.min = 10, .min = 10,
.max = 10, .max = 10,
...@@ -198,8 +196,7 @@ static const struct ipa_resource_src ipa_resource_src[] = { ...@@ -198,8 +196,7 @@ static const struct ipa_resource_src ipa_resource_src[] = {
.max = 8, .max = 8,
}, },
}, },
{ [IPA_RESOURCE_TYPE_SRC_DESCRIPTOR_BUFF] = {
.type = IPA_RESOURCE_TYPE_SRC_DESCRIPTOR_BUFF,
.limits[IPA_RSRC_GROUP_SRC_LWA_DL] = { .limits[IPA_RSRC_GROUP_SRC_LWA_DL] = {
.min = 12, .min = 12,
.max = 12, .max = 12,
...@@ -213,8 +210,7 @@ static const struct ipa_resource_src ipa_resource_src[] = { ...@@ -213,8 +210,7 @@ static const struct ipa_resource_src ipa_resource_src[] = {
.max = 8, .max = 8,
}, },
}, },
{ [IPA_RESOURCE_TYPE_SRC_HPS_DMARS] = {
.type = IPA_RESOURCE_TYPE_SRC_HPS_DMARS,
.limits[IPA_RSRC_GROUP_SRC_LWA_DL] = { .limits[IPA_RSRC_GROUP_SRC_LWA_DL] = {
.min = 0, .min = 0,
.max = 63, .max = 63,
...@@ -232,8 +228,7 @@ static const struct ipa_resource_src ipa_resource_src[] = { ...@@ -232,8 +228,7 @@ static const struct ipa_resource_src ipa_resource_src[] = {
.max = 63, .max = 63,
}, },
}, },
{ [IPA_RESOURCE_TYPE_SRC_ACK_ENTRIES] = {
.type = IPA_RESOURCE_TYPE_SRC_ACK_ENTRIES,
.limits[IPA_RSRC_GROUP_SRC_LWA_DL] = { .limits[IPA_RSRC_GROUP_SRC_LWA_DL] = {
.min = 14, .min = 14,
.max = 14, .max = 14,
...@@ -251,8 +246,7 @@ static const struct ipa_resource_src ipa_resource_src[] = { ...@@ -251,8 +246,7 @@ static const struct ipa_resource_src ipa_resource_src[] = {
/* Destination resource configuration data for the SDM845 SoC */ /* Destination resource configuration data for the SDM845 SoC */
static const struct ipa_resource_dst ipa_resource_dst[] = { static const struct ipa_resource_dst ipa_resource_dst[] = {
{ [IPA_RESOURCE_TYPE_DST_DATA_SECTORS] = {
.type = IPA_RESOURCE_TYPE_DST_DATA_SECTORS,
.limits[IPA_RSRC_GROUP_DST_LWA_DL] = { .limits[IPA_RSRC_GROUP_DST_LWA_DL] = {
.min = 4, .min = 4,
.max = 4, .max = 4,
...@@ -266,8 +260,7 @@ static const struct ipa_resource_dst ipa_resource_dst[] = { ...@@ -266,8 +260,7 @@ static const struct ipa_resource_dst ipa_resource_dst[] = {
.max = 3, .max = 3,
} }
}, },
{ [IPA_RESOURCE_TYPE_DST_DPS_DMARS] = {
.type = IPA_RESOURCE_TYPE_DST_DPS_DMARS,
.limits[IPA_RSRC_GROUP_DST_LWA_DL] = { .limits[IPA_RSRC_GROUP_DST_LWA_DL] = {
.min = 2, .min = 2,
.max = 63, .max = 63,
......
...@@ -220,21 +220,17 @@ struct ipa_resource_limits { ...@@ -220,21 +220,17 @@ struct ipa_resource_limits {
/** /**
* struct ipa_resource_src - source endpoint group resource usage * struct ipa_resource_src - source endpoint group resource usage
* @type: source group resource type
* @limits: array of limits to use for each resource group * @limits: array of limits to use for each resource group
*/ */
struct ipa_resource_src { struct ipa_resource_src {
enum ipa_resource_type type; /* IPA_RESOURCE_TYPE_SRC_* */
struct ipa_resource_limits limits[IPA_RESOURCE_GROUP_SRC_MAX]; struct ipa_resource_limits limits[IPA_RESOURCE_GROUP_SRC_MAX];
}; };
/** /**
* struct ipa_resource_dst - destination endpoint group resource usage * struct ipa_resource_dst - destination endpoint group resource usage
* @type: destination group resource type
* @limits: array of limits to use for each resource group * @limits: array of limits to use for each resource group
*/ */
struct ipa_resource_dst { struct ipa_resource_dst {
enum ipa_resource_type type; /* IPA_RESOURCE_TYPE_DST_* */
struct ipa_resource_limits limits[IPA_RESOURCE_GROUP_DST_MAX]; struct ipa_resource_limits limits[IPA_RESOURCE_GROUP_DST_MAX];
}; };
......
...@@ -128,54 +128,54 @@ ipa_resource_config_common(struct ipa *ipa, u32 offset, ...@@ -128,54 +128,54 @@ ipa_resource_config_common(struct ipa *ipa, u32 offset,
iowrite32(val, ipa->reg_virt + offset); iowrite32(val, ipa->reg_virt + offset);
} }
static void ipa_resource_config_src(struct ipa *ipa, static void ipa_resource_config_src(struct ipa *ipa, u32 resource_type,
const struct ipa_resource_src *resource) const struct ipa_resource_src *resource)
{ {
u32 group_count = ipa_resource_group_src_count(ipa->version); u32 group_count = ipa_resource_group_src_count(ipa->version);
const struct ipa_resource_limits *ylimits; const struct ipa_resource_limits *ylimits;
u32 offset; u32 offset;
offset = IPA_REG_SRC_RSRC_GRP_01_RSRC_TYPE_N_OFFSET(resource->type); offset = IPA_REG_SRC_RSRC_GRP_01_RSRC_TYPE_N_OFFSET(resource_type);
ylimits = group_count == 1 ? NULL : &resource->limits[1]; ylimits = group_count == 1 ? NULL : &resource->limits[1];
ipa_resource_config_common(ipa, offset, &resource->limits[0], ylimits); ipa_resource_config_common(ipa, offset, &resource->limits[0], ylimits);
if (group_count < 3) if (group_count < 3)
return; return;
offset = IPA_REG_SRC_RSRC_GRP_23_RSRC_TYPE_N_OFFSET(resource->type); offset = IPA_REG_SRC_RSRC_GRP_23_RSRC_TYPE_N_OFFSET(resource_type);
ylimits = group_count == 3 ? NULL : &resource->limits[3]; ylimits = group_count == 3 ? NULL : &resource->limits[3];
ipa_resource_config_common(ipa, offset, &resource->limits[2], ylimits); ipa_resource_config_common(ipa, offset, &resource->limits[2], ylimits);
if (group_count < 5) if (group_count < 5)
return; return;
offset = IPA_REG_SRC_RSRC_GRP_45_RSRC_TYPE_N_OFFSET(resource->type); offset = IPA_REG_SRC_RSRC_GRP_45_RSRC_TYPE_N_OFFSET(resource_type);
ylimits = group_count == 5 ? NULL : &resource->limits[5]; ylimits = group_count == 5 ? NULL : &resource->limits[5];
ipa_resource_config_common(ipa, offset, &resource->limits[4], ylimits); ipa_resource_config_common(ipa, offset, &resource->limits[4], ylimits);
} }
static void ipa_resource_config_dst(struct ipa *ipa, static void ipa_resource_config_dst(struct ipa *ipa, u32 resource_type,
const struct ipa_resource_dst *resource) const struct ipa_resource_dst *resource)
{ {
u32 group_count = ipa_resource_group_dst_count(ipa->version); u32 group_count = ipa_resource_group_dst_count(ipa->version);
const struct ipa_resource_limits *ylimits; const struct ipa_resource_limits *ylimits;
u32 offset; u32 offset;
offset = IPA_REG_DST_RSRC_GRP_01_RSRC_TYPE_N_OFFSET(resource->type); offset = IPA_REG_DST_RSRC_GRP_01_RSRC_TYPE_N_OFFSET(resource_type);
ylimits = group_count == 1 ? NULL : &resource->limits[1]; ylimits = group_count == 1 ? NULL : &resource->limits[1];
ipa_resource_config_common(ipa, offset, &resource->limits[0], ylimits); ipa_resource_config_common(ipa, offset, &resource->limits[0], ylimits);
if (group_count < 3) if (group_count < 3)
return; return;
offset = IPA_REG_DST_RSRC_GRP_23_RSRC_TYPE_N_OFFSET(resource->type); offset = IPA_REG_DST_RSRC_GRP_23_RSRC_TYPE_N_OFFSET(resource_type);
ylimits = group_count == 3 ? NULL : &resource->limits[3]; ylimits = group_count == 3 ? NULL : &resource->limits[3];
ipa_resource_config_common(ipa, offset, &resource->limits[2], ylimits); ipa_resource_config_common(ipa, offset, &resource->limits[2], ylimits);
if (group_count < 5) if (group_count < 5)
return; return;
offset = IPA_REG_DST_RSRC_GRP_45_RSRC_TYPE_N_OFFSET(resource->type); offset = IPA_REG_DST_RSRC_GRP_45_RSRC_TYPE_N_OFFSET(resource_type);
ylimits = group_count == 5 ? NULL : &resource->limits[5]; ylimits = group_count == 5 ? NULL : &resource->limits[5];
ipa_resource_config_common(ipa, offset, &resource->limits[4], ylimits); ipa_resource_config_common(ipa, offset, &resource->limits[4], ylimits);
} }
...@@ -189,10 +189,10 @@ int ipa_resource_config(struct ipa *ipa, const struct ipa_resource_data *data) ...@@ -189,10 +189,10 @@ int ipa_resource_config(struct ipa *ipa, const struct ipa_resource_data *data)
return -EINVAL; return -EINVAL;
for (i = 0; i < data->resource_src_count; i++) for (i = 0; i < data->resource_src_count; i++)
ipa_resource_config_src(ipa, &data->resource_src[i]); ipa_resource_config_src(ipa, i, &data->resource_src[i]);
for (i = 0; i < data->resource_dst_count; i++) for (i = 0; i < data->resource_dst_count; i++)
ipa_resource_config_dst(ipa, &data->resource_dst[i]); ipa_resource_config_dst(ipa, i, &data->resource_dst[i]);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment