net: ipa: record number of groups in data
authorAlex Elder <elder@linaro.org>
Fri, 26 Mar 2021 15:11:21 +0000 (10:11 -0500)
committerDavid S. Miller <davem@davemloft.net>
Fri, 26 Mar 2021 22:02:39 +0000 (15:02 -0700)
The arrays of source and destination resource limits defined in
configuration data are of a fixed size--which is the maximum number
of resource groups supported for any platform.  Most platforms will
use fewer than that many groups.

Add new members to the ipa_rsrc_group_id enumerated type to define
the number of source and destination resource groups are defined for
the platform.  (This type is defined for each platform in its data
file.)

Add a new field to the resource configuration data that indicates
how many of the source and destination resource groups are actually
used for the platform, and initialize it with the count value.  This
allows us to determine the number of groups defined for the platform
without exposing the ipa_rsrc_group_id enumerated type.

As a result, we no longer need ipa_resource_group_src_count()
and ipa_resource_group_dst_count(), because each platform now
defines its supported number of resource groups.  So get rid of
those two functions.

Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ipa/ipa_data-sc7180.c
drivers/net/ipa/ipa_data-sdm845.c
drivers/net/ipa/ipa_data.h
drivers/net/ipa/ipa_resource.c

index 631b50fc8d53423d7dd38857e83f96a1c52e6fe9..c9b6a6aaadacc6448333923798fbc6ef0885090c 100644 (file)
@@ -27,9 +27,11 @@ enum ipa_resource_type {
 enum ipa_rsrc_group_id {
        /* Source resource group identifiers */
        IPA_RSRC_GROUP_SRC_UL_DL        = 0,
+       IPA_RSRC_GROUP_SRC_COUNT,       /* Last in set; not a source group */
 
        /* Destination resource group identifiers */
        IPA_RSRC_GROUP_DST_UL_DL_DPL    = 0,
+       IPA_RSRC_GROUP_DST_COUNT,       /* Last; not a destination group */
 };
 
 /* QSB configuration for the SC7180 SoC. */
@@ -207,6 +209,8 @@ static const struct ipa_resource ipa_resource_dst[] = {
 
 /* Resource configuration for the SC7180 SoC. */
 static const struct ipa_resource_data ipa_resource_data = {
+       .rsrc_group_src_count   = IPA_RSRC_GROUP_SRC_COUNT,
+       .rsrc_group_dst_count   = IPA_RSRC_GROUP_DST_COUNT,
        .resource_src_count     = ARRAY_SIZE(ipa_resource_src),
        .resource_src           = ipa_resource_src,
        .resource_dst_count     = ARRAY_SIZE(ipa_resource_dst),
index 3c9675ce556cea7045ff243f0b243e20018ff11f..e14e3fb1d970041d51c668d7d6cfa05b25b6c54d 100644 (file)
@@ -32,11 +32,13 @@ enum ipa_rsrc_group_id {
        IPA_RSRC_GROUP_SRC_UL_DL,
        IPA_RSRC_GROUP_SRC_MHI_DMA,
        IPA_RSRC_GROUP_SRC_UC_RX_Q,
+       IPA_RSRC_GROUP_SRC_COUNT,       /* Last in set; not a source group */
 
        /* Destination resource group identifiers */
        IPA_RSRC_GROUP_DST_LWA_DL       = 0,
        IPA_RSRC_GROUP_DST_UL_DL_DPL,
        IPA_RSRC_GROUP_DST_UNUSED_2,
+       IPA_RSRC_GROUP_DST_COUNT,       /* Last; not a destination group */
 };
 
 /* QSB configuration for the SDM845 SoC. */
@@ -270,6 +272,8 @@ static const struct ipa_resource ipa_resource_dst[] = {
 
 /* Resource configuration for the SDM845 SoC. */
 static const struct ipa_resource_data ipa_resource_data = {
+       .rsrc_group_src_count   = IPA_RSRC_GROUP_SRC_COUNT,
+       .rsrc_group_dst_count   = IPA_RSRC_GROUP_DST_COUNT,
        .resource_src_count     = ARRAY_SIZE(ipa_resource_src),
        .resource_src           = ipa_resource_src,
        .resource_dst_count     = ARRAY_SIZE(ipa_resource_dst),
index 9060586eb7cbafaf4e3d79f5abdb6a58c6b6a88d..c5d763a3782fd74d7e953b699701b077ebeea8b9 100644 (file)
@@ -213,6 +213,8 @@ struct ipa_resource {
 
 /**
  * struct ipa_resource_data - IPA resource configuration data
+ * @rsrc_group_src_count: number of source resource groups supported
+ * @rsrc_group_dst_count: number of destination resource groups supported
  * @resource_src_count:        number of entries in the resource_src array
  * @resource_src:      source endpoint group resources
  * @resource_dst_count:        number of entries in the resource_dst array
@@ -224,6 +226,8 @@ struct ipa_resource {
  * programming it at initialization time, so we specify it here.
  */
 struct ipa_resource_data {
+       u32 rsrc_group_src_count;
+       u32 rsrc_group_dst_count;
        u32 resource_src_count;
        const struct ipa_resource *resource_src;
        u32 resource_dst_count;
index 3db4dd3bda9ccd60b8ec62c93237ce38105851b4..578ff070d40555defd5d8e9df8f6e416de69e7a4 100644 (file)
  * total resources of each type is assigned for use by each group.
  */
 
-/* # IPA source resource groups available based on version */
-static u32 ipa_resource_group_src_count(enum ipa_version version)
-{
-       switch (version) {
-       case IPA_VERSION_3_5_1:
-       case IPA_VERSION_4_0:
-       case IPA_VERSION_4_1:
-               return 4;
-
-       case IPA_VERSION_4_2:
-               return 1;
-
-       case IPA_VERSION_4_5:
-               return 5;
-
-       default:
-               return 0;
-       }
-}
-
-/* # IPA destination resource groups available based on version */
-static u32 ipa_resource_group_dst_count(enum ipa_version version)
-{
-       switch (version) {
-       case IPA_VERSION_3_5_1:
-               return 3;
-
-       case IPA_VERSION_4_0:
-       case IPA_VERSION_4_1:
-               return 4;
-
-       case IPA_VERSION_4_2:
-               return 1;
-
-       case IPA_VERSION_4_5:
-               return 5;
-
-       default:
-               return 0;
-       }
-}
-
 static bool ipa_resource_limits_valid(struct ipa *ipa,
                                      const struct ipa_resource_data *data)
 {
@@ -79,7 +37,7 @@ static bool ipa_resource_limits_valid(struct ipa *ipa,
        /* We program at most 6 source or destination resource group limits */
        BUILD_BUG_ON(IPA_RESOURCE_GROUP_MAX > 6);
 
-       group_count = ipa_resource_group_src_count(ipa->version);
+       group_count = data->rsrc_group_src_count;
        if (!group_count || group_count > IPA_RESOURCE_GROUP_MAX)
                return false;
 
@@ -95,7 +53,7 @@ static bool ipa_resource_limits_valid(struct ipa *ipa,
                                return false;
        }
 
-       group_count = ipa_resource_group_dst_count(ipa->version);
+       group_count = data->rsrc_group_src_count;
        if (!group_count || group_count > IPA_RESOURCE_GROUP_MAX)
                return false;
 
@@ -131,7 +89,7 @@ ipa_resource_config_common(struct ipa *ipa, u32 offset,
 static void ipa_resource_config_src(struct ipa *ipa, u32 resource_type,
                                    const struct ipa_resource_data *data)
 {
-       u32 group_count = ipa_resource_group_src_count(ipa->version);
+       u32 group_count = data->rsrc_group_src_count;
        const struct ipa_resource_limits *ylimits;
        const struct ipa_resource *resource;
        u32 offset;
@@ -160,7 +118,7 @@ static void ipa_resource_config_src(struct ipa *ipa, u32 resource_type,
 static void ipa_resource_config_dst(struct ipa *ipa, u32 resource_type,
                                    const struct ipa_resource_data *data)
 {
-       u32 group_count = ipa_resource_group_dst_count(ipa->version);
+       u32 group_count = data->rsrc_group_dst_count;
        const struct ipa_resource_limits *ylimits;
        const struct ipa_resource *resource;
        u32 offset;