Lines Matching full:ipa

16 #include "ipa.h"
25 * DOC: IPA Filter and Route Tables
27 * The IPA has tables defined in its local (IPA-resident) memory that define
35 * by all IPA hardware (IPA v4.2 doesn't support hashed tables).
38 * an object (such as a route or filter table) in IPA-resident memory must
52 * address of a filter rule in the memory following the bitmap. Until IPA
58 * removed starting at IPA v5.0. For IPA v5.0+, the endpoint bitmap
60 * bitmap, endpoint 1 has a filter rule. Older versions of IPA represent
72 * endpoints they "own" directly. Currently the AP does not use the IPA
76 * bitmap as defined prior to IPA v5.0.
78 * IPA Filter Table
97 * though the AP currently does not use the IPA routing functionality.
99 * IPA Route Table
145 ipa_table_mem(struct ipa *ipa, bool filter, bool hashed, bool ipv6)
158 return ipa_mem_find(ipa, mem_id);
162 bool ipa_table_hash_support(struct ipa *ipa)
164 return ipa->version != IPA_VERSION_4_2;
167 bool ipa_filtered_valid(struct ipa *ipa, u64 filtered)
169 struct device *dev = ipa->dev;
179 if (count > ipa->filter_count) {
181 count, ipa->filter_count);
190 static dma_addr_t ipa_table_addr(struct ipa *ipa, bool filter_mask, u16 count)
197 WARN_ON(count > max_t(u32, ipa->filter_count, ipa->route_count));
202 return ipa->table_addr + skip * sizeof(*ipa->table_virt);
208 struct ipa *ipa = container_of(trans->gsi, struct ipa, gsi);
215 mem = ipa_table_mem(ipa, filter, hashed, ipv6);
224 addr = ipa_table_addr(ipa, false, count);
234 ipa_filter_reset_table(struct ipa *ipa, bool hashed, bool ipv6, bool modem)
236 u64 ep_mask = ipa->filtered;
240 trans = ipa_cmd_trans_alloc(ipa, hweight64(ep_mask));
242 dev_err(ipa->dev, "no transaction for %s filter reset\n",
254 endpoint = &ipa->endpoint[endpoint_id];
270 static int ipa_filter_reset(struct ipa *ipa, bool modem)
274 ret = ipa_filter_reset_table(ipa, false, false, modem);
278 ret = ipa_filter_reset_table(ipa, false, true, modem);
279 if (ret || !ipa_table_hash_support(ipa))
282 ret = ipa_filter_reset_table(ipa, true, false, modem);
286 return ipa_filter_reset_table(ipa, true, true, modem);
293 static int ipa_route_reset(struct ipa *ipa, bool modem)
295 bool hash_support = ipa_table_hash_support(ipa);
296 u32 modem_route_count = ipa->modem_route_count;
301 trans = ipa_cmd_trans_alloc(ipa, hash_support ? 4 : 2);
303 dev_err(ipa->dev, "no transaction for %s route reset\n",
313 count = ipa->route_count - modem_route_count;
329 void ipa_table_reset(struct ipa *ipa, bool modem)
331 struct device *dev = ipa->dev;
338 ret = ipa_filter_reset(ipa, modem);
343 ret = ipa_route_reset(ipa, modem);
349 int ipa_table_hash_flush(struct ipa *ipa)
355 if (!ipa_table_hash_support(ipa))
358 trans = ipa_cmd_trans_alloc(ipa, 1);
360 dev_err(ipa->dev, "no transaction for hash flush\n");
364 if (ipa->version < IPA_VERSION_5_0) {
365 reg = ipa_reg(ipa, FILT_ROUT_HASH_FLUSH);
372 reg = ipa_reg(ipa, FILT_ROUT_CACHE_FLUSH);
374 /* IPA v5.0+ uses a unified cache (both IPv4 and IPv6) */
388 struct ipa *ipa = container_of(trans->gsi, struct ipa, gsi);
408 mem = ipa_table_mem(ipa, filter, false, ipv6);
409 hash_mem = ipa_table_mem(ipa, filter, true, ipv6);
419 count = 1 + hweight64(ipa->filtered);
431 addr = ipa_table_addr(ipa, filter, count);
432 hash_addr = ipa_table_addr(ipa, filter, hash_count);
443 ipa->zero_addr, true);
451 ipa->zero_addr, true);
454 int ipa_table_setup(struct ipa *ipa)
471 trans = ipa_cmd_trans_alloc(ipa, 8);
473 dev_err(ipa->dev, "no transaction for table setup\n");
497 struct ipa *ipa = endpoint->ipa;
502 if (ipa->version < IPA_VERSION_5_0) {
503 reg = ipa_reg(ipa, ENDP_FILTER_ROUTER_HSH_CFG);
506 val = ioread32(endpoint->ipa->reg_virt + offset);
511 /* IPA v5.0 separates filter and router cache configuration */
512 reg = ipa_reg(ipa, ENDP_FILTER_CACHE_CFG);
519 iowrite32(val, endpoint->ipa->reg_virt + offset);
523 static void ipa_filter_config(struct ipa *ipa, bool modem)
526 u64 ep_mask = ipa->filtered;
528 if (!ipa_table_hash_support(ipa))
537 endpoint = &ipa->endpoint[endpoint_id];
543 static bool ipa_route_id_modem(struct ipa *ipa, u32 route_id)
545 return route_id < ipa->modem_route_count;
550 * @ipa: IPA pointer
555 static void ipa_route_tuple_zero(struct ipa *ipa, u32 route_id)
561 if (ipa->version < IPA_VERSION_5_0) {
562 reg = ipa_reg(ipa, ENDP_FILTER_ROUTER_HSH_CFG);
565 val = ioread32(ipa->reg_virt + offset);
570 /* IPA v5.0 separates filter and router cache configuration */
571 reg = ipa_reg(ipa, ENDP_ROUTER_CACHE_CFG);
578 iowrite32(val, ipa->reg_virt + offset);
582 static void ipa_route_config(struct ipa *ipa, bool modem)
586 if (!ipa_table_hash_support(ipa))
589 for (route_id = 0; route_id < ipa->route_count; route_id++)
590 if (ipa_route_id_modem(ipa, route_id) == modem)
591 ipa_route_tuple_zero(ipa, route_id);
595 void ipa_table_config(struct ipa *ipa)
597 ipa_filter_config(ipa, false);
598 ipa_filter_config(ipa, true);
599 ipa_route_config(ipa, false);
600 ipa_route_config(ipa, true);
603 /* Verify the sizes of all IPA table filter or routing table memory regions
606 bool ipa_table_mem_valid(struct ipa *ipa, bool filter)
608 bool hash_support = ipa_table_hash_support(ipa);
618 mem_ipv4 = ipa_table_mem(ipa, filter, false, false);
622 mem_ipv6 = ipa_table_mem(ipa, filter, false, true);
634 ipa->filter_count = count - 1; /* Filter map in first entry */
636 ipa->route_count = count;
639 if (!ipa_cmd_table_init_valid(ipa, mem_ipv4, !filter))
647 if (count < 1 + hweight64(ipa->filtered))
653 if (count < ipa->modem_route_count + 1)
662 mem_hashed = ipa_table_mem(ipa, filter, true, false);
672 mem_hashed = ipa_table_mem(ipa, filter, true, true);
685 * route table data. This is used when initializing or resetting the IPA
708 * | ---- zero rule address | | Max IPA filter count
709 * | |-------------------| > or IPA route count,
715 int ipa_table_init(struct ipa *ipa)
717 struct device *dev = ipa->dev;
726 count = max_t(u32, ipa->filter_count, ipa->route_count);
728 /* The IPA hardware requires route and filter table rules to be
739 ipa->table_virt = virt;
740 ipa->table_addr = addr;
747 * it left one position. Prior to IPA v5.0, bit 0 repesents global
748 * filtering, which is possible but not used. IPA v5.0+ eliminated
751 if (ipa->version < IPA_VERSION_5_0)
752 *virt++ = cpu_to_le64(ipa->filtered << 1);
754 *virt++ = cpu_to_le64(ipa->filtered);
764 void ipa_table_exit(struct ipa *ipa)
766 u32 count = max_t(u32, 1 + ipa->filter_count, ipa->route_count);
767 struct device *dev = ipa->dev;
772 dma_free_coherent(dev, size, ipa->table_virt, ipa->table_addr);
773 ipa->table_addr = 0;
774 ipa->table_virt = NULL;