diff options
author | Alex Elder <elder@linaro.org> | 2022-10-25 14:51:41 -0500 |
---|---|---|
committer | Paolo Abeni <pabeni@redhat.com> | 2022-10-27 13:38:12 +0200 |
commit | 0439e6743c5c77520e91bf52a0d16da586214753 (patch) | |
tree | 0734c71384a36852dc1fec51fe6369cdfc6c9365 /drivers/net/ipa/ipa_table.c | |
parent | fc094058ce01984aa4cb8b580812b16f5429c7e7 (diff) |
net: ipa: determine route table size from memory region
Currently we assume that any routing table contains a fixed number
of entries. The number of entries in a routing table can actually
vary, depending only on the size of the IPA-local memory region used
to hold the table.
Stop assuming that a routing table has exactly 15 entries. Instead,
determine the number of entries in a routing table by dividing its
memory region size by the size of an entry.
The number of entries is computed early, when ipa_table_mem_valid()
is called by ipa_table_init().
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
Diffstat (limited to 'drivers/net/ipa/ipa_table.c')
-rw-r--r-- | drivers/net/ipa/ipa_table.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/drivers/net/ipa/ipa_table.c b/drivers/net/ipa/ipa_table.c index 0815c8967e91..23d3f081ac8e 100644 --- a/drivers/net/ipa/ipa_table.c +++ b/drivers/net/ipa/ipa_table.c @@ -130,12 +130,8 @@ static void ipa_table_validate_build(void) */ BUILD_BUG_ON(IPA_ZERO_RULE_SIZE != sizeof(__le64)); - /* Impose a practical limit on the number of routes */ - BUILD_BUG_ON(IPA_ROUTE_COUNT_MAX > 32); /* The modem must be allotted at least one route table entry */ BUILD_BUG_ON(!IPA_ROUTE_MODEM_COUNT); - /* AP must too, but we can't use more than what is available */ - BUILD_BUG_ON(IPA_ROUTE_MODEM_COUNT >= IPA_ROUTE_COUNT_MAX); } static const struct ipa_mem * @@ -593,18 +589,18 @@ bool ipa_table_mem_valid(struct ipa *ipa, bool modem_route_count) if (mem_ipv4->size != mem_ipv6->size) return false; - /* Record the number of routing table entries */ + /* Compute the number of entries, and for routing tables, record it */ + count = mem_ipv4->size / sizeof(__le64); + if (count < 2) + return false; if (!filter) - ipa->route_count = IPA_ROUTE_COUNT_MAX; + ipa->route_count = count; /* Table offset and size must fit in TABLE_INIT command fields */ if (!ipa_cmd_table_init_valid(ipa, mem_ipv4, !filter)) return false; /* Make sure the regions are big enough */ - count = mem_ipv4->size / sizeof(__le64); - if (count < 2) - return false; if (filter) { /* Filter tables must able to hold the endpoint bitmap plus * an entry for each endpoint that supports filtering |