Commit 546948bf authored by Alex Elder's avatar Alex Elder Committed by David S. Miller

net: ipa: always validate filter and route tables

All checks in ipa_table_validate_build() are computed at build time,
so build that unconditionally.

In ipa_table_valid() calls to ipa_table_valid_one() are missing the
IPA pointer parameter is missing in (a bug that shows up only when
IPA_VALIDATE is defined).  Don't bother checking whether hashed
table memory regions are valid if hashed tables are not supported.

With those things fixed, have these table validation functions built
unconditionally (not dependent on IPA_VALIDATE).
Signed-off-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f2c1dac0
...@@ -120,8 +120,6 @@ ...@@ -120,8 +120,6 @@
*/ */
#define IPA_ZERO_RULE_SIZE (2 * sizeof(__le32)) #define IPA_ZERO_RULE_SIZE (2 * sizeof(__le32))
#ifdef IPA_VALIDATE
/* Check things that can be validated at build time. */ /* Check things that can be validated at build time. */
static void ipa_table_validate_build(void) static void ipa_table_validate_build(void)
{ {
...@@ -169,7 +167,7 @@ ipa_table_valid_one(struct ipa *ipa, enum ipa_mem_id mem_id, bool route) ...@@ -169,7 +167,7 @@ ipa_table_valid_one(struct ipa *ipa, enum ipa_mem_id mem_id, bool route)
return true; return true;
/* Hashed table regions can be zero size if hashing is not supported */ /* Hashed table regions can be zero size if hashing is not supported */
if (hashed && !mem->size) if (ipa_table_hash_support(ipa) && !mem->size)
return true; return true;
dev_err(dev, "%s table region %u size 0x%02x, expected 0x%02x\n", dev_err(dev, "%s table region %u size 0x%02x, expected 0x%02x\n",
...@@ -183,14 +181,22 @@ bool ipa_table_valid(struct ipa *ipa) ...@@ -183,14 +181,22 @@ bool ipa_table_valid(struct ipa *ipa)
{ {
bool valid; bool valid;
valid = ipa_table_valid_one(IPA_MEM_V4_FILTER, false); valid = ipa_table_valid_one(ipa, IPA_MEM_V4_FILTER, false);
valid = valid && ipa_table_valid_one(IPA_MEM_V4_FILTER_HASHED, false); valid = valid && ipa_table_valid_one(ipa, IPA_MEM_V6_FILTER, false);
valid = valid && ipa_table_valid_one(IPA_MEM_V6_FILTER, false); valid = valid && ipa_table_valid_one(ipa, IPA_MEM_V4_ROUTE, true);
valid = valid && ipa_table_valid_one(IPA_MEM_V6_FILTER_HASHED, false); valid = valid && ipa_table_valid_one(ipa, IPA_MEM_V6_ROUTE, true);
valid = valid && ipa_table_valid_one(IPA_MEM_V4_ROUTE, true);
valid = valid && ipa_table_valid_one(IPA_MEM_V4_ROUTE_HASHED, true); if (!ipa_table_hash_support(ipa))
valid = valid && ipa_table_valid_one(IPA_MEM_V6_ROUTE, true); return valid;
valid = valid && ipa_table_valid_one(IPA_MEM_V6_ROUTE_HASHED, true);
valid = valid && ipa_table_valid_one(ipa, IPA_MEM_V4_FILTER_HASHED,
false);
valid = valid && ipa_table_valid_one(ipa, IPA_MEM_V6_FILTER_HASHED,
false);
valid = valid && ipa_table_valid_one(ipa, IPA_MEM_V4_ROUTE_HASHED,
true);
valid = valid && ipa_table_valid_one(ipa, IPA_MEM_V6_ROUTE_HASHED,
true);
return valid; return valid;
} }
...@@ -217,14 +223,6 @@ bool ipa_filter_map_valid(struct ipa *ipa, u32 filter_map) ...@@ -217,14 +223,6 @@ bool ipa_filter_map_valid(struct ipa *ipa, u32 filter_map)
return true; return true;
} }
#else /* !IPA_VALIDATE */
static void ipa_table_validate_build(void)
{
}
#endif /* !IPA_VALIDATE */
/* Zero entry count means no table, so just return a 0 address */ /* Zero entry count means no table, so just return a 0 address */
static dma_addr_t ipa_table_addr(struct ipa *ipa, bool filter_mask, u16 count) static dma_addr_t ipa_table_addr(struct ipa *ipa, bool filter_mask, u16 count)
{ {
......
...@@ -16,8 +16,6 @@ struct ipa; ...@@ -16,8 +16,6 @@ struct ipa;
/* The maximum number of route table entries (IPv4, IPv6; hashed or not) */ /* The maximum number of route table entries (IPv4, IPv6; hashed or not) */
#define IPA_ROUTE_COUNT_MAX 15 #define IPA_ROUTE_COUNT_MAX 15
#ifdef IPA_VALIDATE
/** /**
* ipa_table_valid() - Validate route and filter table memory regions * ipa_table_valid() - Validate route and filter table memory regions
* @ipa: IPA pointer * @ipa: IPA pointer
...@@ -35,20 +33,6 @@ bool ipa_table_valid(struct ipa *ipa); ...@@ -35,20 +33,6 @@ bool ipa_table_valid(struct ipa *ipa);
*/ */
bool ipa_filter_map_valid(struct ipa *ipa, u32 filter_mask); bool ipa_filter_map_valid(struct ipa *ipa, u32 filter_mask);
#else /* !IPA_VALIDATE */
static inline bool ipa_table_valid(struct ipa *ipa)
{
return true;
}
static inline bool ipa_filter_map_valid(struct ipa *ipa, u32 filter_mask)
{
return true;
}
#endif /* !IPA_VALIDATE */
/** /**
* ipa_table_hash_support() - Return true if hashed tables are supported * ipa_table_hash_support() - Return true if hashed tables are supported
* @ipa: IPA pointer * @ipa: IPA pointer
......
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