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_cmd.c | |
| parent | fc094058ce01984aa4cb8b580812b16f5429c7e7 (diff) | |
| download | linux-0439e6743c5c77520e91bf52a0d16da586214753.tar.gz linux-0439e6743c5c77520e91bf52a0d16da586214753.tar.bz2 linux-0439e6743c5c77520e91bf52a0d16da586214753.zip | |
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_cmd.c')
| -rw-r--r-- | drivers/net/ipa/ipa_cmd.c | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/drivers/net/ipa/ipa_cmd.c b/drivers/net/ipa/ipa_cmd.c index de2cd86aa9e2..08e3f395a945 100644 --- a/drivers/net/ipa/ipa_cmd.c +++ b/drivers/net/ipa/ipa_cmd.c @@ -145,18 +145,15 @@ union ipa_cmd_payload { static void ipa_cmd_validate_build(void) { - /* The sizes of a filter and route tables need to fit into fields - * in the ipa_cmd_hw_ip_fltrt_init structure. Although hashed tables + /* The size of a filter table needs to fit into fields in the + * ipa_cmd_hw_ip_fltrt_init structure. Although hashed tables * might not be used, non-hashed and hashed tables have the same * maximum size. IPv4 and IPv6 filter tables have the same number - * of entries, as and IPv4 and IPv6 route tables have the same number * of entries. */ -#define TABLE_SIZE (TABLE_COUNT_MAX * sizeof(__le64)) -#define TABLE_COUNT_MAX max_t(u32, IPA_ROUTE_COUNT_MAX, IPA_FILTER_COUNT_MAX) +#define TABLE_SIZE (IPA_FILTER_COUNT_MAX * sizeof(__le64)) BUILD_BUG_ON(TABLE_SIZE > field_max(IP_FLTRT_FLAGS_HASH_SIZE_FMASK)); BUILD_BUG_ON(TABLE_SIZE > field_max(IP_FLTRT_FLAGS_NHASH_SIZE_FMASK)); -#undef TABLE_COUNT_MAX #undef TABLE_SIZE /* Hashed and non-hashed fields are assumed to be the same size */ @@ -178,12 +175,14 @@ bool ipa_cmd_table_init_valid(struct ipa *ipa, const struct ipa_mem *mem, u32 size_max = field_max(IP_FLTRT_FLAGS_NHASH_SIZE_FMASK); const char *table = route ? "route" : "filter"; struct device *dev = &ipa->pdev->dev; + u32 size; + + size = route ? ipa->route_count * sizeof(__le64) : mem->size; /* Size must fit in the immediate command field that holds it */ - if (mem->size > size_max) { + if (size > size_max) { dev_err(dev, "%s table region size too large\n", table); - dev_err(dev, " (0x%04x > 0x%04x)\n", - mem->size, size_max); + dev_err(dev, " (0x%04x > 0x%04x)\n", size, size_max); return false; } |
