* maximum size. IPv4 and IPv6 filter tables have the same number
* of entries.
*/
-#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_SIZE
-
/* Hashed and non-hashed fields are assumed to be the same size */
BUILD_BUG_ON(field_max(IP_FLTRT_FLAGS_HASH_SIZE_FMASK) !=
field_max(IP_FLTRT_FLAGS_NHASH_SIZE_FMASK));
struct device *dev = &ipa->pdev->dev;
u32 size;
- size = route ? ipa->route_count * sizeof(__le64) : mem->size;
+ size = route ? ipa->route_count : ipa->filter_count + 1;
+ size *= sizeof(__le64);
/* Size must fit in the immediate command field that holds it */
if (size > size_max) {
}
count = hweight32(filter_map);
- if (count > IPA_FILTER_COUNT_MAX) {
+ if (count > ipa->filter_count) {
dev_err(dev, "too many filtering endpoints (%u, max %u)\n",
- count, IPA_FILTER_COUNT_MAX);
+ count, ipa->filter_count);
return false;
}
if (!count)
return 0;
- WARN_ON(count > max_t(u32, IPA_FILTER_COUNT_MAX, ipa->route_count));
+ WARN_ON(count > max_t(u32, ipa->filter_count, ipa->route_count));
/* Skip over the zero rule and possibly the filter mask */
skip = filter_mask ? 1 : 2;
if (mem_ipv4->size != mem_ipv6->size)
return false;
- /* Compute the number of entries, and for routing tables, record it */
+ /* Compute and record the number of entries for each table type */
count = mem_ipv4->size / sizeof(__le64);
if (count < 2)
return false;
- if (!filter)
+ if (filter)
+ ipa->filter_count = count - 1; /* Filter map in first entry */
+ else
ipa->route_count = count;
/* Table offset and size must fit in TABLE_INIT command fields */
*
* The first entry in a filter table contains a bitmap indicating which
* endpoints contain entries in the table. In addition to that first entry,
- * there are at most IPA_FILTER_COUNT_MAX entries that follow. Filter table
+ * there is a fixed maximum number of entries that follow. Filter table
* entries are 64 bits wide, and (other than the bitmap) contain the DMA
* address of a filter rule. A "zero rule" indicates no filtering, and
* consists of 64 bits of zeroes. When a filter table is initialized (or
* |\ |-------------------|
* | ---- zero rule address | \
* |\ |-------------------| |
- * | ---- zero rule address | | IPA_FILTER_COUNT_MAX
+ * | ---- zero rule address | | Max IPA filter count
* | |-------------------| > or IPA route count,
* | ... | whichever is greater
* \ |-------------------| |
ipa_table_validate_build();
- count = max_t(u32, IPA_FILTER_COUNT_MAX, ipa->route_count);
+ count = max_t(u32, ipa->filter_count, ipa->route_count);
/* The IPA hardware requires route and filter table rules to be
* aligned on a 128-byte boundary. We put the "zero rule" at the
void ipa_table_exit(struct ipa *ipa)
{
- u32 count = max_t(u32, 1 + IPA_FILTER_COUNT_MAX, ipa->route_count);
+ u32 count = max_t(u32, 1 + ipa->filter_count, ipa->route_count);
struct device *dev = &ipa->pdev->dev;
size_t size;