1 /* SPDX-License-Identifier: GPL-2.0 */
3 /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
4 * Copyright (C) 2019-2020 Linaro Ltd.
12 * DOC: IPA Local Memory
14 * The IPA has a block of shared memory, divided into regions used for
17 * The regions within the shared block are bounded by an offset (relative to
18 * the "ipa-shared" memory range) and size found in the IPA_SHARED_MEM_SIZE
21 * Each region is optionally preceded by one or more 32-bit "canary" values.
22 * These are meant to detect out-of-range writes (if they become corrupted).
23 * A given region (such as a filter or routing table) has the same number
24 * of canaries for all IPA hardware versions. Still, the number used is
25 * defined in the config data, allowing for generic handling of regions.
27 * The set of memory regions is defined in configuration data. They are
28 * subject to these constraints:
29 * - a zero offset and zero size represents and undefined region
30 * - a region's offset is defined to be *past* all "canary" values
31 * - offset must be large enough to account for all canaries
32 * - a region's size may be zero, but may still have canaries
33 * - all offsets must be 8-byte aligned
34 * - most sizes must be a multiple of 8
35 * - modem memory size must be a multiple of 4
36 * - the microcontroller ring offset must be a multiple of 1024
39 /* The maximum allowed size for any memory region */
40 #define IPA_MEM_MAX (2 * PAGE_SIZE)
42 /* IPA-resident memory region ids */
44 IPA_MEM_UC_SHARED
, /* 0 canaries */
45 IPA_MEM_UC_INFO
, /* 0 canaries */
46 IPA_MEM_V4_FILTER_HASHED
, /* 2 canaries */
47 IPA_MEM_V4_FILTER
, /* 2 canaries */
48 IPA_MEM_V6_FILTER_HASHED
, /* 2 canaries */
49 IPA_MEM_V6_FILTER
, /* 2 canaries */
50 IPA_MEM_V4_ROUTE_HASHED
, /* 2 canaries */
51 IPA_MEM_V4_ROUTE
, /* 2 canaries */
52 IPA_MEM_V6_ROUTE_HASHED
, /* 2 canaries */
53 IPA_MEM_V6_ROUTE
, /* 2 canaries */
54 IPA_MEM_MODEM_HEADER
, /* 2 canaries */
55 IPA_MEM_AP_HEADER
, /* 0 canaries */
56 IPA_MEM_MODEM_PROC_CTX
, /* 2 canaries */
57 IPA_MEM_AP_PROC_CTX
, /* 0 canaries */
58 IPA_MEM_PDN_CONFIG
, /* 2 canaries (IPA v4.0 and above) */
59 IPA_MEM_STATS_QUOTA
, /* 2 canaries (IPA v4.0 and above) */
60 IPA_MEM_STATS_TETHERING
, /* 0 canaries (IPA v4.0 and above) */
61 IPA_MEM_STATS_DROP
, /* 0 canaries (IPA v4.0 and above) */
62 IPA_MEM_MODEM
, /* 0 canaries */
63 IPA_MEM_UC_EVENT_RING
, /* 1 canary */
64 IPA_MEM_COUNT
, /* Number of regions (not an index) */
68 * struct ipa_mem - IPA local memory region description
69 * @offset: offset in IPA memory space to base of the region
70 * @size: size in bytes base of the region
71 * @canary_count # 32-bit "canary" values that precede region
79 int ipa_mem_config(struct ipa
*ipa
);
80 void ipa_mem_deconfig(struct ipa
*ipa
);
82 int ipa_mem_setup(struct ipa
*ipa
);
83 void ipa_mem_teardown(struct ipa
*ipa
);
85 int ipa_mem_zero_modem(struct ipa
*ipa
);
87 int ipa_mem_init(struct ipa
*ipa
, u32 count
, const struct ipa_mem
*mem
);
88 void ipa_mem_exit(struct ipa
*ipa
);
90 #endif /* _IPA_MEM_H_ */