Lines Matching +full:non +full:- +full:zero

1 // SPDX-License-Identifier: GPL-2.0
3 /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
4 * Copyright (C) 2018-2022 Linaro Ltd.
15 #include <linux/dma-mapping.h>
30 * The IPA has tables defined in its local (IPA-resident) memory that define
32 * endian 64-bit "slot" that holds the address of a rule definition. (The
41 * an object (such as a route or filter table) in IPA-resident memory must
42 * 128-byte aligned. An object in system memory (such as a route or filter
43 * rule) must be at an 8-byte aligned address. We currently only place
46 * A rule consists of a contiguous block of 32-bit values terminated with
47 * 32 zero bits. A special "zero entry" rule consisting of 64 zero bits
52 * not all TX endpoints support filtering. The first 64-bit slot in a
54 * the table. The low-order bit (bit 0) in this bitmap represents a
63 * The AP initializes all entries in a filter table to refer to a "zero"
69 * ----------------------
71 * |--------------------|
73 * |--------------------|
75 * |--------------------|
77 * |--------------------|
79 * |--------------------|
81 * ----------------------
85 * a "zero entry". Once initialized, the modem and AP are responsible for
90 * ----------------------
92 * |--------------------|
94 * |--------------------|
96 * |--------------------|
98 * |--------------------|
100 * |--------------------|
102 * |--------------------|
104 * |--------------------|
106 * ----------------------
113 (IPA_ROUTE_COUNT_MAX - IPA_ROUTE_MODEM_COUNT)
115 /* Filter or route rules consist of a set of 32-bit values followed by a
116 * 32-bit all-zero rule list terminator. The "zero rule" is simply an
117 * all-zero rule followed by the list terminator.
133 /* A "zero rule" is used to represent no filtering or no routing. in ipa_table_validate_build()
134 * It is a 64-bit block of zeroed memory. Code in ipa_table_init() in ipa_table_validate_build()
152 struct device *dev = &ipa->pdev->dev; in ipa_table_valid_one()
163 /* mem->size >= size is sufficient, but we'll demand more */ in ipa_table_valid_one()
164 if (mem->size == size) in ipa_table_valid_one()
167 /* Hashed table regions can be zero size if hashing is not supported */ in ipa_table_valid_one()
168 if (ipa_table_hash_support(ipa) && !mem->size) in ipa_table_valid_one()
172 route ? "route" : "filter", mem_id, mem->size, size); in ipa_table_valid_one()
204 struct device *dev = &ipa->pdev->dev; in ipa_filter_map_valid()
224 /* Zero entry count means no table, so just return a 0 address */
234 /* Skip over the zero rule and possibly the filter mask */ in ipa_table_addr()
237 return ipa->table_addr + skip * sizeof(*ipa->table_virt); in ipa_table_addr()
243 struct ipa *ipa = container_of(trans->gsi, struct ipa, gsi); in ipa_table_reset_add()
250 if (!mem->size) in ipa_table_reset_add()
256 offset = mem->offset + first * sizeof(__le64); in ipa_table_reset_add()
264 * modem to refer to the zero entry. The memory region supplied will be
265 * for the IPv4 and IPv6 non-hashed and hashed filter tables.
270 u32 ep_mask = ipa->filter_map; in ipa_filter_reset_table()
277 dev_err(&ipa->pdev->dev, in ipa_filter_reset_table()
280 return -EBUSY; in ipa_filter_reset_table()
290 endpoint = &ipa->endpoint[endpoint_id]; in ipa_filter_reset_table()
291 if (endpoint->ee_id != ee_id) in ipa_filter_reset_table()
328 * won't exceed the per-transaction command limit.
338 dev_err(&ipa->pdev->dev, in ipa_route_reset()
341 return -EBUSY; in ipa_route_reset()
367 struct device *dev = &ipa->pdev->dev; in ipa_table_reset()
397 dev_err(&ipa->pdev->dev, "no transaction for hash flush\n"); in ipa_table_hash_flush()
398 return -EBUSY; in ipa_table_hash_flush()
421 struct ipa *ipa = container_of(trans->gsi, struct ipa, gsi); in ipa_table_init_add()
438 * table is either the same as the non-hashed one, or zero. in ipa_table_init_add()
440 count = 1 + hweight32(ipa->filter_map); in ipa_table_init_add()
441 hash_count = hash_mem->size ? count : 0; in ipa_table_init_add()
446 count = mem->size / sizeof(__le64); in ipa_table_init_add()
447 hash_count = hash_mem->size / sizeof(__le64); in ipa_table_init_add()
455 ipa_cmd_table_init_add(trans, opcode, size, mem->offset, addr, in ipa_table_init_add()
456 hash_size, hash_mem->offset, hash_addr); in ipa_table_init_add()
460 /* Zero the unused space in the filter table */ in ipa_table_init_add()
461 zero_offset = mem->offset + size; in ipa_table_init_add()
462 zero_size = mem->size - size; in ipa_table_init_add()
464 ipa->zero_addr, true); in ipa_table_init_add()
468 /* Zero the unused space in the hashed filter table */ in ipa_table_init_add()
469 zero_offset = hash_mem->offset + hash_size; in ipa_table_init_add()
470 zero_size = hash_mem->size - hash_size; in ipa_table_init_add()
472 ipa->zero_addr, true); in ipa_table_init_add()
480 * - IPv4: in ipa_table_setup()
481 * - One for route table initialization (non-hashed and hashed) in ipa_table_setup()
482 * - One for filter table initialization (non-hashed and hashed) in ipa_table_setup()
483 * - One to zero unused entries in the non-hashed filter table in ipa_table_setup()
484 * - One to zero unused entries in the hashed filter table in ipa_table_setup()
485 * - IPv6: in ipa_table_setup()
486 * - One for route table initialization (non-hashed and hashed) in ipa_table_setup()
487 * - One for filter table initialization (non-hashed and hashed) in ipa_table_setup()
488 * - One to zero unused entries in the non-hashed filter table in ipa_table_setup()
489 * - One to zero unused entries in the hashed filter table in ipa_table_setup()
494 dev_err(&ipa->pdev->dev, "no transaction for table setup\n"); in ipa_table_setup()
495 return -EBUSY; in ipa_table_setup()
516 * ipa_filter_tuple_zero() - Zero an endpoint's hashed filter tuple
524 u32 endpoint_id = endpoint->endpoint_id; in ipa_filter_tuple_zero()
525 struct ipa *ipa = endpoint->ipa; in ipa_filter_tuple_zero()
533 val = ioread32(endpoint->ipa->reg_virt + offset); in ipa_filter_tuple_zero()
535 /* Zero all filter-related fields, preserving the rest */ in ipa_filter_tuple_zero()
538 iowrite32(val, endpoint->ipa->reg_virt + offset); in ipa_filter_tuple_zero()
545 u32 ep_mask = ipa->filter_map; in ipa_filter_config()
556 endpoint = &ipa->endpoint[endpoint_id]; in ipa_filter_config()
557 if (endpoint->ee_id == ee_id) in ipa_filter_config()
565 route_id <= IPA_ROUTE_MODEM_MIN + IPA_ROUTE_MODEM_COUNT - 1; in ipa_route_id_modem()
569 * ipa_route_tuple_zero() - Zero a hashed route table entry tuple
584 val = ioread32(ipa->reg_virt + offset); in ipa_route_tuple_zero()
586 /* Zero all route-related fields, preserving the rest */ in ipa_route_tuple_zero()
589 iowrite32(val, ipa->reg_virt + offset); in ipa_route_tuple_zero()
623 * address of a filter rule. A "zero rule" indicates no filtering, and
625 * reset) its entries are made to refer to the zero rule.
628 * routing there is also a 64-bit "zero rule" that means no routing, and
630 * to the zero rule. The zero rule is shared for route and filter tables.
634 * has a minimum alignment, and we place the zero rule at the base of that
638 * +-------------------+
639 * --> | zero rule |
640 * / |-------------------|
642 * |\ |-------------------|
643 * | ---- zero rule address | \
644 * |\ |-------------------| |
645 * | ---- zero rule address | | IPA_FILTER_COUNT_MAX
646 * | |-------------------| > or IPA_ROUTE_COUNT_MAX,
648 * \ |-------------------| |
649 * ---- zero rule address | /
650 * +-------------------+
655 struct device *dev = &ipa->pdev->dev; in ipa_table_init()
664 * aligned on a 128-byte boundary. We put the "zero rule" at the in ipa_table_init()
666 * by dma_alloc_coherent() is guaranteed to be a power-of-2 number in ipa_table_init()
672 return -ENOMEM; in ipa_table_init()
674 ipa->table_virt = virt; in ipa_table_init()
675 ipa->table_addr = addr; in ipa_table_init()
677 /* First slot is the zero rule */ in ipa_table_init()
685 *virt++ = cpu_to_le64((u64)ipa->filter_map << 1); in ipa_table_init()
687 /* All the rest contain the DMA address of the zero rule */ in ipa_table_init()
689 while (count--) in ipa_table_init()
698 struct device *dev = &ipa->pdev->dev; in ipa_table_exit()
703 dma_free_coherent(dev, size, ipa->table_virt, ipa->table_addr); in ipa_table_exit()
704 ipa->table_addr = 0; in ipa_table_exit()
705 ipa->table_virt = NULL; in ipa_table_exit()