2020-03-05 21:28:19 -07:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
|
|
|
|
/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
|
net: ipa: include some standard header files
Some IPA header files use types defined in <linux/types.h>, but do
not include that file:
- In "ipa_mem.h", the ipa_mem structure has u16 and u32 fields
- In "ipa_power.h", ipa_power_retention() takes a bool argument,
and ipa_core_clock_rate() returns u32
- In "ipa_version.h", ipa_version_supported() returns bool
Include it in these files to satisfy their dependencies.
The ipa_qmi structure (defined in "ipa_qmi.h") contains a work
structure, so include <linux/workqueue.h> in there.
All of the data and register definition files, as well as "reg.h",
use the ARRAY_SIZE() macro. Include <linux/array_size.h> everywhere
it's used.
Similarly, all register definition files (and a few others) use the
GENMASK() macro, so include <linux/bits.h> to ensure it's defined
where used. BIT() becomes available by including this file also.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2024-04-16 16:10:12 -07:00
|
|
|
* Copyright (C) 2019-2024 Linaro Ltd.
|
2020-03-05 21:28:19 -07:00
|
|
|
*/
|
|
|
|
#ifndef _IPA_MEM_H_
|
|
|
|
#define _IPA_MEM_H_
|
|
|
|
|
net: ipa: include some standard header files
Some IPA header files use types defined in <linux/types.h>, but do
not include that file:
- In "ipa_mem.h", the ipa_mem structure has u16 and u32 fields
- In "ipa_power.h", ipa_power_retention() takes a bool argument,
and ipa_core_clock_rate() returns u32
- In "ipa_version.h", ipa_version_supported() returns bool
Include it in these files to satisfy their dependencies.
The ipa_qmi structure (defined in "ipa_qmi.h") contains a work
structure, so include <linux/workqueue.h> in there.
All of the data and register definition files, as well as "reg.h",
use the ARRAY_SIZE() macro. Include <linux/array_size.h> everywhere
it's used.
Similarly, all register definition files (and a few others) use the
GENMASK() macro, so include <linux/bits.h> to ensure it's defined
where used. BIT() becomes available by including this file also.
Signed-off-by: Alex Elder <elder@linaro.org>
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2024-04-16 16:10:12 -07:00
|
|
|
#include <linux/types.h>
|
|
|
|
|
2024-03-01 10:02:39 -07:00
|
|
|
struct platform_device;
|
|
|
|
|
2020-03-05 21:28:19 -07:00
|
|
|
struct ipa;
|
2020-05-04 10:58:57 -07:00
|
|
|
struct ipa_mem_data;
|
2020-03-05 21:28:19 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* DOC: IPA Local Memory
|
|
|
|
*
|
|
|
|
* The IPA has a block of shared memory, divided into regions used for
|
|
|
|
* specific purposes.
|
|
|
|
*
|
|
|
|
* The regions within the shared block are bounded by an offset (relative to
|
|
|
|
* the "ipa-shared" memory range) and size found in the IPA_SHARED_MEM_SIZE
|
|
|
|
* register.
|
|
|
|
*
|
|
|
|
* Each region is optionally preceded by one or more 32-bit "canary" values.
|
|
|
|
* These are meant to detect out-of-range writes (if they become corrupted).
|
|
|
|
* A given region (such as a filter or routing table) has the same number
|
|
|
|
* of canaries for all IPA hardware versions. Still, the number used is
|
|
|
|
* defined in the config data, allowing for generic handling of regions.
|
|
|
|
*
|
|
|
|
* The set of memory regions is defined in configuration data. They are
|
|
|
|
* subject to these constraints:
|
|
|
|
* - a zero offset and zero size represents and undefined region
|
2021-03-19 08:24:21 -07:00
|
|
|
* - a region's size does not include space for its "canary" values
|
2020-03-05 21:28:19 -07:00
|
|
|
* - a region's offset is defined to be *past* all "canary" values
|
|
|
|
* - offset must be large enough to account for all canaries
|
|
|
|
* - a region's size may be zero, but may still have canaries
|
|
|
|
* - all offsets must be 8-byte aligned
|
|
|
|
* - most sizes must be a multiple of 8
|
|
|
|
* - modem memory size must be a multiple of 4
|
|
|
|
* - the microcontroller ring offset must be a multiple of 1024
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* The maximum allowed size for any memory region */
|
|
|
|
#define IPA_MEM_MAX (2 * PAGE_SIZE)
|
|
|
|
|
|
|
|
/* IPA-resident memory region ids */
|
|
|
|
enum ipa_mem_id {
|
|
|
|
IPA_MEM_UC_SHARED, /* 0 canaries */
|
|
|
|
IPA_MEM_UC_INFO, /* 0 canaries */
|
|
|
|
IPA_MEM_V4_FILTER_HASHED, /* 2 canaries */
|
|
|
|
IPA_MEM_V4_FILTER, /* 2 canaries */
|
|
|
|
IPA_MEM_V6_FILTER_HASHED, /* 2 canaries */
|
|
|
|
IPA_MEM_V6_FILTER, /* 2 canaries */
|
|
|
|
IPA_MEM_V4_ROUTE_HASHED, /* 2 canaries */
|
|
|
|
IPA_MEM_V4_ROUTE, /* 2 canaries */
|
|
|
|
IPA_MEM_V6_ROUTE_HASHED, /* 2 canaries */
|
|
|
|
IPA_MEM_V6_ROUTE, /* 2 canaries */
|
|
|
|
IPA_MEM_MODEM_HEADER, /* 2 canaries */
|
2021-06-09 15:35:00 -07:00
|
|
|
IPA_MEM_AP_HEADER, /* 0 canaries, optional */
|
2020-03-05 21:28:19 -07:00
|
|
|
IPA_MEM_MODEM_PROC_CTX, /* 2 canaries */
|
|
|
|
IPA_MEM_AP_PROC_CTX, /* 0 canaries */
|
2021-06-09 15:35:00 -07:00
|
|
|
IPA_MEM_MODEM, /* 0/2 canaries */
|
|
|
|
IPA_MEM_UC_EVENT_RING, /* 1 canary, optional */
|
|
|
|
IPA_MEM_PDN_CONFIG, /* 0/2 canaries (IPA v4.0+) */
|
|
|
|
IPA_MEM_STATS_QUOTA_MODEM, /* 2/4 canaries (IPA v4.0+) */
|
|
|
|
IPA_MEM_STATS_QUOTA_AP, /* 0 canaries, optional (IPA v4.0+) */
|
2023-01-30 14:01:58 -07:00
|
|
|
IPA_MEM_STATS_TETHERING, /* 0 canaries, optional (IPA v4.0+) */
|
2021-06-09 15:35:00 -07:00
|
|
|
IPA_MEM_STATS_DROP, /* 0 canaries, optional (IPA v4.0+) */
|
2023-01-30 14:01:58 -07:00
|
|
|
/* The next 7 filter and route statistics regions are optional */
|
2021-03-19 08:24:21 -07:00
|
|
|
IPA_MEM_STATS_V4_FILTER, /* 0 canaries (IPA v4.0-v4.2) */
|
|
|
|
IPA_MEM_STATS_V6_FILTER, /* 0 canaries (IPA v4.0-v4.2) */
|
|
|
|
IPA_MEM_STATS_V4_ROUTE, /* 0 canaries (IPA v4.0-v4.2) */
|
|
|
|
IPA_MEM_STATS_V6_ROUTE, /* 0 canaries (IPA v4.0-v4.2) */
|
2023-01-30 14:01:58 -07:00
|
|
|
IPA_MEM_AP_V4_FILTER, /* 2 canaries (IPA v5.0) */
|
|
|
|
IPA_MEM_AP_V6_FILTER, /* 0 canaries (IPA v5.0) */
|
2021-06-09 15:35:00 -07:00
|
|
|
IPA_MEM_STATS_FILTER_ROUTE, /* 0 canaries (IPA v4.5+) */
|
|
|
|
IPA_MEM_NAT_TABLE, /* 4 canaries, optional (IPA v4.5+) */
|
2021-06-09 15:34:53 -07:00
|
|
|
IPA_MEM_END_MARKER, /* 1 canary (not a real region) */
|
2020-03-05 21:28:19 -07:00
|
|
|
IPA_MEM_COUNT, /* Number of regions (not an index) */
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* struct ipa_mem - IPA local memory region description
|
2021-06-09 15:34:54 -07:00
|
|
|
* @id: memory region identifier
|
2020-03-05 21:28:19 -07:00
|
|
|
* @offset: offset in IPA memory space to base of the region
|
|
|
|
* @size: size in bytes base of the region
|
2021-03-28 10:31:05 -07:00
|
|
|
* @canary_count: Number of 32-bit "canary" values that precede region
|
2020-03-05 21:28:19 -07:00
|
|
|
*/
|
|
|
|
struct ipa_mem {
|
2021-06-09 15:34:54 -07:00
|
|
|
enum ipa_mem_id id;
|
2020-03-05 21:28:19 -07:00
|
|
|
u32 offset;
|
|
|
|
u16 size;
|
|
|
|
u16 canary_count;
|
|
|
|
};
|
|
|
|
|
2021-06-10 12:23:07 -07:00
|
|
|
const struct ipa_mem *ipa_mem_find(struct ipa *ipa, enum ipa_mem_id mem_id);
|
|
|
|
|
2020-03-05 21:28:19 -07:00
|
|
|
int ipa_mem_config(struct ipa *ipa);
|
|
|
|
void ipa_mem_deconfig(struct ipa *ipa);
|
|
|
|
|
2021-04-09 11:07:20 -07:00
|
|
|
int ipa_mem_setup(struct ipa *ipa); /* No ipa_mem_teardown() needed */
|
2020-03-05 21:28:19 -07:00
|
|
|
|
|
|
|
int ipa_mem_zero_modem(struct ipa *ipa);
|
|
|
|
|
2024-03-01 10:02:39 -07:00
|
|
|
int ipa_mem_init(struct ipa *ipa, struct platform_device *pdev,
|
|
|
|
const struct ipa_mem_data *mem_data);
|
2020-03-05 21:28:19 -07:00
|
|
|
void ipa_mem_exit(struct ipa *ipa);
|
|
|
|
|
|
|
|
#endif /* _IPA_MEM_H_ */
|