Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 664adf1a authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: ipa3: SRAM NAT, DDR NAT, back-and-forth NAT"

parents f452cc65 f294db47
Loading
Loading
Loading
Loading
+28 −0
Original line number Diff line number Diff line
@@ -1519,6 +1519,23 @@ static int ipa3_ioctl_fnr_counter_set(unsigned long arg)
	return 0;
}

static int proc_sram_info_rqst(
	unsigned long arg)
{
	struct ipa_nat_in_sram_info sram_info = { 0 };

	if (ipa3_nat_get_sram_info(&sram_info))
		return  -EFAULT;

	if (copy_to_user(
		(void __user *) arg,
		&sram_info,
		sizeof(struct ipa_nat_in_sram_info)))
		return -EFAULT;

	return 0;
}

static long ipa3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
{
	int retval = 0;
@@ -1616,6 +1633,7 @@ static long ipa3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
			retval = -EFAULT;
			break;
		}

		if (ipa3_nat_init_cmd(&nat_init)) {
			retval = -EFAULT;
			break;
@@ -1681,6 +1699,7 @@ static long ipa3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
			retval = -EFAULT;
			break;
		}

		if (ipa3_del_nat_table(&table_del)) {
			retval = -EFAULT;
			break;
@@ -1693,6 +1712,7 @@ static long ipa3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
			retval = -EFAULT;
			break;
		}

		if (ipa3_del_ipv6ct_table(&table_del)) {
			retval = -EFAULT;
			break;
@@ -2732,6 +2752,11 @@ static long ipa3_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
			IPA_CLIENT_MAX,
			fst_switch.to_wigig);
		break;

	case IPA_IOC_GET_NAT_IN_SRAM_INFO:
		retval = proc_sram_info_rqst(arg);
		break;

	default:
		IPA_ACTIVE_CLIENTS_DEC_SIMPLE();
		return -ENOTTY;
@@ -4652,6 +4677,9 @@ long compat_ipa3_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
	case IPA_IOC_MDFY_RT_RULE32:
		cmd = IPA_IOC_MDFY_RT_RULE;
		break;
	case IPA_IOC_GET_NAT_IN_SRAM_INFO32:
		cmd = IPA_IOC_GET_NAT_IN_SRAM_INFO;
		break;
	case IPA_IOC_COMMIT_HDR:
	case IPA_IOC_RESET_HDR:
	case IPA_IOC_COMMIT_RT:
+303 −119
Original line number Diff line number Diff line
@@ -1634,7 +1634,8 @@ static ssize_t ipa3_read_msg(struct file *file, char __user *ubuf,
}

static void ipa3_read_table(
	char *table_addr, u32 table_size,
	char *table_addr,
	u32 table_size,
	u32 *total_num_entries,
	u32 *rule_id,
	enum ipahal_nat_type nat_type)
@@ -1648,46 +1649,51 @@ static void ipa3_read_table(
	char *buff;
	size_t buff_size = 2 * IPA_MAX_ENTRY_STRING_LEN;

	IPADBG("\n");
	IPADBG("In\n");

	if (table_addr == NULL) {
		pr_err("NULL NAT table\n");
		return;
		goto bail;
	}

	result = ipahal_nat_entry_size(nat_type, &entry_size);

	if (result) {
		IPAERR("Failed to retrieve size of %s entry\n",
			ipahal_nat_type_str(nat_type));
		return;
		goto bail;
	}

	buff = kzalloc(buff_size, GFP_KERNEL);

	if (!buff) {
		IPAERR("Out of memory\n");
		return;
		goto bail;
	}

	for (i = 0, entry = table_addr;
		i < table_size;
		++i, ++id, entry += entry_size) {

		result = ipahal_nat_is_entry_zeroed(nat_type, entry,
			&entry_zeroed);

		if (result) {
			IPAERR(
				"Failed to determine whether the %s entry is definitely zero\n"
					, ipahal_nat_type_str(nat_type));
			goto bail;
			IPAERR("Undefined if %s entry is zero\n",
				   ipahal_nat_type_str(nat_type));
			goto free_buf;
		}

		if (entry_zeroed)
			continue;

		result = ipahal_nat_is_entry_valid(nat_type, entry,
			&entry_valid);

		if (result) {
			IPAERR(
				"Failed to determine whether the %s entry is valid\n"
					, ipahal_nat_type_str(nat_type));
			goto bail;
			IPAERR("Undefined if %s entry is valid\n",
				   ipahal_nat_type_str(nat_type));
			goto free_buf;
		}

		if (entry_valid) {
@@ -1698,7 +1704,9 @@ static void ipa3_read_table(

		ipahal_nat_stringify_entry(nat_type, entry,
			buff, buff_size);

		pr_err("%s\n", buff);

		memset(buff, 0, buff_size);
	}

@@ -1706,21 +1714,27 @@ static void ipa3_read_table(
		pr_err("\n");
	else
		pr_err("\tEmpty\n\n");
	IPADBG("return\n");
bail:

free_buf:
	kfree(buff);
	*rule_id = id;
	*total_num_entries += num_entries;

bail:
	IPADBG("Out\n");
}

static void ipa3_start_read_memory_device(
	struct ipa3_nat_ipv6ct_common_mem *dev,
	enum ipahal_nat_type nat_type,
	u32 *num_entries)
	u32 *num_ddr_ent_ptr,
	u32 *num_sram_ent_ptr)
{
	u32 rule_id = 0;

	IPADBG("\n");
	if (dev->is_ipv6ct_mem) {

		IPADBG("In: v6\n");

		pr_err("%s_Table_Size=%d\n",
			   dev->name, dev->table_entries + 1);
@@ -1728,30 +1742,122 @@ static void ipa3_start_read_memory_device(
		pr_err("%s_Expansion_Table_Size=%d\n",
			   dev->name, dev->expn_table_entries);

	if (!dev->is_sys_mem)
		pr_err("Not supported for local(shared) memory\n");

		pr_err("\n%s Base Table:\n", dev->name);
	ipa3_read_table(dev->base_table_addr, dev->table_entries + 1,
		num_entries, &rule_id, nat_type);

		if (dev->base_table_addr)
			ipa3_read_table(
				dev->base_table_addr,
				dev->table_entries + 1,
				num_ddr_ent_ptr,
				&rule_id,
				nat_type);

		pr_err("%s Expansion Table:\n", dev->name);

		if (dev->expansion_table_addr)
			ipa3_read_table(
				dev->expansion_table_addr,
				dev->expn_table_entries,
				num_ddr_ent_ptr,
				&rule_id,
				nat_type);
	}

	if (dev->is_nat_mem) {
		struct ipa3_nat_mem *nm_ptr = (struct ipa3_nat_mem *) dev;
		struct ipa3_nat_mem_loc_data *mld_ptr = NULL;
		u32 *num_ent_ptr;
		const char *type_ptr;

		IPADBG("In: v4\n");

		if (nm_ptr->active_table == IPA_NAT_MEM_IN_DDR &&
			nm_ptr->ddr_in_use) {

			mld_ptr     = &nm_ptr->mem_loc[IPA_NAT_MEM_IN_DDR];
			num_ent_ptr = num_ddr_ent_ptr;
			type_ptr    = "DDR based table";
		}

		if (nm_ptr->active_table == IPA_NAT_MEM_IN_SRAM &&
			nm_ptr->sram_in_use) {

			mld_ptr     = &nm_ptr->mem_loc[IPA_NAT_MEM_IN_SRAM];
			num_ent_ptr = num_sram_ent_ptr;
			type_ptr    = "SRAM based table";
		}

		if (mld_ptr) {
			pr_err("(%s) %s_Table_Size=%d\n",
				   type_ptr,
				   dev->name,
				   mld_ptr->table_entries + 1);

			pr_err("(%s) %s_Expansion_Table_Size=%d\n",
				   type_ptr,
				   dev->name,
				   mld_ptr->expn_table_entries);

			pr_err("\n(%s) %s_Base Table:\n",
				   type_ptr,
				   dev->name);

			if (mld_ptr->base_table_addr)
				ipa3_read_table(
					mld_ptr->base_table_addr,
					mld_ptr->table_entries + 1,
					num_ent_ptr,
					&rule_id,
					nat_type);

			pr_err("(%s) %s_Expansion Table:\n",
				   type_ptr,
				   dev->name);

			if (mld_ptr->expansion_table_addr)
				ipa3_read_table(
		dev->expansion_table_addr, dev->expn_table_entries,
		num_entries,
					mld_ptr->expansion_table_addr,
					mld_ptr->expn_table_entries,
					num_ent_ptr,
					&rule_id,
					nat_type);
		}
	}

	IPADBG("return\n");
	IPADBG("Out\n");
}

static void ipa3_finish_read_memory_device(
	struct ipa3_nat_ipv6ct_common_mem *dev,
	u32 num_entries)
	u32 num_ddr_entries,
	u32 num_sram_entries)
{
	IPADBG("\n");
	pr_err("Overall number %s entries: %d\n\n", dev->name, num_entries);
	IPADBG("return\n");
	IPADBG("In\n");

	if (dev->is_ipv6ct_mem) {
		pr_err("Overall number %s entries: %u\n\n",
			   dev->name,
			   num_ddr_entries);
	} else {
		struct ipa3_nat_mem *nm_ptr = (struct ipa3_nat_mem *) dev;

		if (num_ddr_entries)
			pr_err("%s: Overall number of DDR entries: %u\n\n",
				   dev->name,
				   num_ddr_entries);

		if (num_sram_entries)
			pr_err("%s: Overall number of SRAM entries: %u\n\n",
				   dev->name,
				   num_sram_entries);

		pr_err("%s: Driver focus changes to DDR(%u) to SRAM(%u)\n",
			   dev->name,
			   nm_ptr->switch2ddr_cnt,
			   nm_ptr->switch2sram_cnt);
	}

	IPADBG("Out\n");
}

static void ipa3_read_pdn_table(void)
@@ -1764,72 +1870,104 @@ static void ipa3_read_pdn_table(void)
	char *buff;
	size_t buff_size = 128;

	IPADBG("\n");
	IPADBG("In\n");

	if (ipa3_ctx->nat_mem.pdn_mem.base) {

		result = ipahal_nat_entry_size(
			IPAHAL_NAT_IPV4_PDN, &pdn_entry_size);

	result = ipahal_nat_entry_size(IPAHAL_NAT_IPV4_PDN, &pdn_entry_size);
		if (result) {
			IPAERR("Failed to retrieve size of PDN entry");
		return;
			goto bail;
		}

		buff = kzalloc(buff_size, GFP_KERNEL);
		if (!buff) {
			IPAERR("Out of memory\n");
		return;
			goto bail;
		}

		for (i = 0, pdn_entry = ipa3_ctx->nat_mem.pdn_mem.base;
			 i < IPA_MAX_PDN_NUM;
			 ++i, pdn_entry += pdn_entry_size) {
		result = ipahal_nat_is_entry_zeroed(IPAHAL_NAT_IPV4_PDN,

			result = ipahal_nat_is_entry_zeroed(
				IPAHAL_NAT_IPV4_PDN,
				pdn_entry, &entry_zeroed);

			if (result) {
			IPAERR(
				"Failed to determine whether the PDN entry is definitely zero\n");
			goto bail;
				IPAERR("ipahal_nat_is_entry_zeroed() fail\n");
				goto free;
			}

			if (entry_zeroed)
				continue;

		result = ipahal_nat_is_entry_valid(IPAHAL_NAT_IPV4_PDN,
			result = ipahal_nat_is_entry_valid(
				IPAHAL_NAT_IPV4_PDN,
				pdn_entry, &entry_valid);

			if (result) {
				IPAERR(
					"Failed to determine whether the PDN entry is valid\n");
			goto bail;
				goto free;
			}

			ipahal_nat_stringify_entry(
				IPAHAL_NAT_IPV4_PDN,
				pdn_entry, buff, buff_size);

			if (entry_valid)
			pr_err("PDN %d:\n", i);
				pr_err("PDN %d: %s\n", i, buff);
			else
			pr_err("PDN %d - Invalid:\n", i);
				pr_err("PDN %d - Invalid: %s\n", i, buff);

		ipahal_nat_stringify_entry(IPAHAL_NAT_IPV4_PDN,
				pdn_entry, buff, buff_size);
		pr_err("%s\n", buff);
			memset(buff, 0, buff_size);
		}
		pr_err("\n");
bail:
free:
		kfree(buff);
	IPADBG("return\n");
	}
bail:
	IPADBG("Out\n");
}

static ssize_t ipa3_read_nat4(struct file *file,
		char __user *ubuf, size_t count,
static ssize_t ipa3_read_nat4(
	struct file *file,
	char __user *ubuf,
	size_t count,
	loff_t *ppos)
{
	u32 rule_id = 0, num_entries = 0, index_num_entries = 0;
	struct ipa3_nat_ipv6ct_common_mem *dev = &ipa3_ctx->nat_mem.dev;
	struct ipa3_nat_mem *nm_ptr = (struct ipa3_nat_mem *) dev;
	struct ipa3_nat_mem_loc_data *mld_ptr = NULL;

	u32  rule_id = 0;

	u32 *num_ents_ptr;
	u32  num_ddr_ents = 0;
	u32  num_sram_ents = 0;

	u32 *num_index_ents_ptr;
	u32  num_ddr_index_ents = 0;
	u32  num_sram_index_ents = 0;

	const char *type_ptr;

	bool any_table_active = (nm_ptr->ddr_in_use || nm_ptr->sram_in_use);

	pr_err("IPA3 NAT stats\n");
	if (!ipa3_ctx->nat_mem.dev.is_dev_init) {

	if (!dev->is_dev_init) {
		pr_err("NAT hasn't been initialized or not supported\n");
		goto ret;
	}

	mutex_lock(&ipa3_ctx->nat_mem.dev.lock);
	mutex_lock(&dev->lock);

	if (!ipa3_ctx->nat_mem.dev.is_hw_init) {
		pr_err("NAT H/W hasn't been initialized\n");
	if (!dev->is_hw_init || !any_table_active) {
		pr_err("NAT H/W and/or S/W not initialized\n");
		goto bail;
	}

@@ -1840,68 +1978,114 @@ static ssize_t ipa3_read_nat4(struct file *file,
			   &ipa3_ctx->nat_mem.public_ip_addr);
	}

	ipa3_start_read_memory_device(&ipa3_ctx->nat_mem.dev,
		IPAHAL_NAT_IPV4, &num_entries);
	ipa3_start_read_memory_device(
		dev,
		IPAHAL_NAT_IPV4,
		&num_ddr_ents,
		&num_sram_ents);

	if (nm_ptr->active_table == IPA_NAT_MEM_IN_DDR &&
		nm_ptr->ddr_in_use) {

		mld_ptr            = &nm_ptr->mem_loc[IPA_NAT_MEM_IN_DDR];
		num_ents_ptr       = &num_ddr_ents;
		num_index_ents_ptr = &num_ddr_index_ents;
		type_ptr           = "DDR based table";
	}

	if (nm_ptr->active_table == IPA_NAT_MEM_IN_SRAM &&
		nm_ptr->sram_in_use) {

		mld_ptr            = &nm_ptr->mem_loc[IPA_NAT_MEM_IN_SRAM];
		num_ents_ptr       = &num_sram_ents;
		num_index_ents_ptr = &num_sram_index_ents;
		type_ptr           = "SRAM based table";
	}

	if (mld_ptr) {
		/* Print Index tables */
	pr_err("ipaNatTable Index Table:\n");
		pr_err("(%s) ipaNatTable Index Table:\n", type_ptr);

		ipa3_read_table(
		ipa3_ctx->nat_mem.index_table_addr,
		ipa3_ctx->nat_mem.dev.table_entries + 1,
		&index_num_entries,
			mld_ptr->index_table_addr,
			mld_ptr->table_entries + 1,
			num_index_ents_ptr,
			&rule_id,
			IPAHAL_NAT_IPV4_INDEX);

	pr_err("ipaNatTable Expansion Index Table:\n");
		pr_err("(%s) ipaNatTable Expansion Index Table:\n", type_ptr);

		ipa3_read_table(
		ipa3_ctx->nat_mem.index_table_expansion_addr,
		ipa3_ctx->nat_mem.dev.expn_table_entries,
		&index_num_entries,
			mld_ptr->index_table_expansion_addr,
			mld_ptr->expn_table_entries,
			num_index_ents_ptr,
			&rule_id,
			IPAHAL_NAT_IPV4_INDEX);

	if (num_entries != index_num_entries)
		if (*num_ents_ptr != *num_index_ents_ptr)
			IPAERR(
			"The NAT table number of entries %d is different from index table number of entries %d\n",
			num_entries, index_num_entries);
				"(%s) Base Table vs Index Table entry count differs (%u vs %u)\n",
				type_ptr, *num_ents_ptr, *num_index_ents_ptr);
	}

	ipa3_finish_read_memory_device(&ipa3_ctx->nat_mem.dev, num_entries);
	ipa3_finish_read_memory_device(
		dev,
		num_ddr_ents,
		num_sram_ents);

	IPADBG("return\n");
bail:
	mutex_unlock(&ipa3_ctx->nat_mem.dev.lock);
	mutex_unlock(&dev->lock);

ret:
	IPADBG("Out\n");

	return 0;
}

static ssize_t ipa3_read_ipv6ct(struct file *file,
	char __user *ubuf, size_t count,
static ssize_t ipa3_read_ipv6ct(
	struct file *file,
	char __user *ubuf,
	size_t count,
	loff_t *ppos)
{
	u32 num_entries = 0;
	struct ipa3_nat_ipv6ct_common_mem *dev = &ipa3_ctx->ipv6ct_mem.dev;

	u32 num_ddr_ents, num_sram_ents;

	num_ddr_ents = num_sram_ents = 0;

	IPADBG("In\n");

	pr_err("\n");

	if (!ipa3_ctx->ipv6ct_mem.dev.is_dev_init) {
	if (!dev->is_dev_init) {
		pr_err("IPv6 Conntrack not initialized or not supported\n");
		return 0;
		goto bail;
	}

	mutex_lock(&ipa3_ctx->ipv6ct_mem.dev.lock);

	if (!ipa3_ctx->ipv6ct_mem.dev.is_hw_init) {
	if (!dev->is_hw_init) {
		pr_err("IPv6 connection tracking H/W hasn't been initialized\n");
		goto bail;
	}

	ipa3_start_read_memory_device(&ipa3_ctx->ipv6ct_mem.dev,
		IPAHAL_NAT_IPV6CT, &num_entries);
	ipa3_finish_read_memory_device(&ipa3_ctx->ipv6ct_mem.dev,
		num_entries);
	mutex_lock(&dev->lock);

	ipa3_start_read_memory_device(
		dev,
		IPAHAL_NAT_IPV6CT,
		&num_ddr_ents,
		&num_sram_ents);

	ipa3_finish_read_memory_device(
		dev,
		num_ddr_ents,
		num_sram_ents);

	mutex_unlock(&dev->lock);

	IPADBG("return\n");
bail:
	mutex_unlock(&ipa3_ctx->ipv6ct_mem.dev.lock);
	IPADBG("Out\n");

	return 0;
}

+112 −53
Original line number Diff line number Diff line
@@ -140,12 +140,20 @@
#define WLAN3_CONS_RX_EP  17
#define WLAN4_CONS_RX_EP  18

#define IPA_RAM_NAT_OFST    0
#define IPA_RAM_NAT_SIZE    0
#define IPA_RAM_NAT_OFST \
	IPA_MEM_PART(nat_tbl_ofst)
#define IPA_RAM_NAT_SIZE \
	IPA_MEM_PART(nat_tbl_size)
#define IPA_RAM_IPV6CT_OFST 0
#define IPA_RAM_IPV6CT_SIZE 0
#define IPA_MEM_CANARY_VAL 0xdeadbeef

#define IS_IPV6CT_MEM_DEV(d) \
	(((void *) (d) == (void *) &ipa3_ctx->ipv6ct_mem))

#define IS_NAT_MEM_DEV(d) \
	(((void *) (d) == (void *) &ipa3_ctx->nat_mem))

#define IPA_STATS

#ifdef IPA_STATS
@@ -424,6 +432,9 @@ enum {
#define IPA_IOC_MDFY_RT_RULE32 _IOWR(IPA_IOC_MAGIC, \
				IPA_IOCTL_MDFY_RT_RULE, \
				compat_uptr_t)
#define IPA_IOC_GET_NAT_IN_SRAM_INFO32 _IOWR(IPA_IOC_MAGIC, \
				IPA_IOCTL_GET_NAT_IN_SRAM_INFO, \
				compat_uptr_t)
#endif /* #ifdef CONFIG_COMPAT */

#define IPA_TZ_UNLOCK_ATTRIBUTE 0x0C0311
@@ -1152,75 +1163,131 @@ struct ipa3_nat_ipv6ct_tmp_mem {

/**
 * struct ipa3_nat_ipv6ct_common_mem - IPA NAT/IPv6CT memory device
 * @name: the device name
 * @lock: memory mutex
 * @class: pointer to the struct class
 * @dev: the dev_t of the device
 * @cdev: cdev of the device
 * @dev_num: device number
 * @is_nat_mem: is the memory for v4 nat
 * @is_ipv6ct_mem: is the memory for v6 nat
 * @is_dev_init: flag indicating if device is initialized
 * @is_hw_init: flag indicating if the corresponding HW is initialized
 * @is_mapped: flag indicating if memory is mapped
 * @phys_mem_size: the physical size in the shared memory
 * @phys_mem_ofst: the offset in the shared memory
 * @table_alloc_size: size (bytes) of table
 * @vaddr: the virtual address in the system memory
 * @dma_handle: the system memory DMA handle
 * @phys_mem_size: the physical size in the shared memory
 * @smem_offset: the offset in the shared memory
 * @size: memory size
 * @is_mapped: flag indicating if memory is mapped
 * @is_sys_mem: flag indicating if memory is sys memory
 * @is_mem_allocated: flag indicating if the memory is allocated
 * @is_hw_init: flag indicating if the corresponding HW is initialized
 * @is_dev_init: flag indicating if device is initialized
 * @lock: memory mutex
 * @base_address: table virtual address
 * @base_table_addr: base table address
 * @expansion_table_addr: expansion table address
 * @table_entries: num of entries in the base table
 * @expn_table_entries: num of entries in the expansion table
 * @tmp_mem: temporary memory used to always provide HW with a legal memory
 * @name: the device name
 */
struct ipa3_nat_ipv6ct_common_mem {
	char           name[IPA_DEV_NAME_MAX_LEN];
	struct mutex   lock;
	struct class  *class;
	struct device *dev;
	struct cdev    cdev;
	dev_t          dev_num;

	/* system memory */
	void *vaddr;
	dma_addr_t dma_handle;
	bool           is_nat_mem;
	bool           is_ipv6ct_mem;

	bool           is_dev_init;
	bool           is_hw_init;
	bool           is_mapped;

	/* shared memory */
	u32            phys_mem_size;
	u32 smem_offset;
	u32            phys_mem_ofst;
	size_t         table_alloc_size;

	size_t size;
	bool is_mapped;
	bool is_sys_mem;
	bool is_mem_allocated;
	bool is_hw_init;
	bool is_dev_init;
	struct mutex lock;
	void          *vaddr;
	dma_addr_t     dma_handle;
	void          *base_address;
	char          *base_table_addr;
	char          *expansion_table_addr;
	u32            table_entries;
	u32            expn_table_entries;

	struct ipa3_nat_ipv6ct_tmp_mem *tmp_mem;
	char name[IPA_DEV_NAME_MAX_LEN];
};

/**
 * struct ipa3_nat_mem_loc_data - memory specific info per table memory type
 * @is_mapped: has the memory been mapped?
 * @io_vaddr: the virtual address in the sram memory
 * @vaddr: the virtual address in the system memory
 * @dma_handle: the system memory DMA handle
 * @phys_addr: physical sram memory location
 * @table_alloc_size: size (bytes) of table
 * @table_entries: number of entries in table
 * @expn_table_entries: number of entries in expansion table
 * @base_address: same as vaddr above
 * @base_table_addr: base table address
 * @expansion_table_addr: base table's expansion table address
 * @index_table_addr: index table address
 * @index_table_expansion_addr: index table's expansion table address
 */
struct ipa3_nat_mem_loc_data {
	bool          is_mapped;

	void __iomem *io_vaddr;

	void         *vaddr;
	dma_addr_t    dma_handle;

	unsigned long phys_addr;

	size_t        table_alloc_size;

	u32           table_entries;
	u32           expn_table_entries;

	void         *base_address;

	char         *base_table_addr;
	char         *expansion_table_addr;

	char         *index_table_addr;
	char         *index_table_expansion_addr;
};

/**
 * struct ipa3_nat_mem - IPA NAT memory description
 * @dev: the memory device structure
 * @index_table_addr: index table address
 * @index_table_expansion_addr: index expansion table address
 * @public_ip_addr: ip address of nat table
 * @pdn_mem: pdn config table SW cache memory structure
 * @is_tmp_mem_allocated: indicate if tmp mem has been allocated
 * @last_alloc_loc: last memory type allocated
 * @active_table: which table memory type is currently active
 * @switch2ddr_cnt: how many times we've switched focust to ddr
 * @switch2sram_cnt: how many times we've switched focust to sram
 * @ddr_in_use: is there table in ddr
 * @sram_in_use: is there table in sram
 * @mem_loc: memory specific info per table memory type
 */
struct ipa3_nat_mem {
	struct ipa3_nat_ipv6ct_common_mem dev;
	char *index_table_addr;
	char *index_table_expansion_addr;
	struct ipa3_nat_ipv6ct_common_mem dev; /* this item must be first */

	u32                          public_ip_addr;
	struct ipa_mem_buffer        pdn_mem;

	bool                         is_tmp_mem_allocated;

	enum ipa3_nat_mem_in         last_alloc_loc;

	enum ipa3_nat_mem_in         active_table;
	u32                          switch2ddr_cnt;
	u32                          switch2sram_cnt;

	bool                         ddr_in_use;
	bool                         sram_in_use;

	struct ipa3_nat_mem_loc_data mem_loc[IPA_NAT_MEM_IN_MAX];
};

/**
@@ -1228,7 +1295,7 @@ struct ipa3_nat_mem {
 * @dev: the memory device structure
 */
struct ipa3_ipv6ct_mem {
	struct ipa3_nat_ipv6ct_common_mem dev;
	struct ipa3_nat_ipv6ct_common_mem dev; /* this item must be first */
};

/**
@@ -1667,8 +1734,7 @@ struct ipa3_pc_mbox_data {
 * struct ipa3_context - IPA context
 * @cdev: cdev context
 * @ep: list of all end points
 * @skip_ep_cfg_shadow: state to update filter table correctly across
  power-save
 * @skip_ep_cfg_shadow: state to update filter table correctly across power-save
 * @ep_flt_bitmap: End-points supporting filtering bitmap
 * @ep_flt_num: End-points supporting filtering number
 * @resume_on_connect: resume ep on ipa connect
@@ -2066,10 +2132,6 @@ struct ipa3_plat_drv_res {
 * +-------------------------+
 * | NAT TABLE (IPA4.5)      |
 * +-------------------------+
 * | NAT IDX TABLE (IPA4.5)  |
 * +-------------------------+
 * | NAT EXP TABLE (IPA4.5)  |
 * +-------------------------+
 * |    CANARY (IPA4.5)      |
 * +-------------------------+
 * |    CANARY (IPA4.5)      |
@@ -2149,10 +2211,6 @@ struct ipa3_mem_partition {
	u32 apps_hdr_proc_ctx_size_ddr;
	u32 nat_tbl_ofst;
	u32 nat_tbl_size;
	u32 nat_index_tbl_ofst;
	u32 nat_index_tbl_size;
	u32 nat_exp_tbl_ofst;
	u32 nat_exp_tbl_size;
	u32 modem_comp_decomp_ofst;
	u32 modem_comp_decomp_size;
	u32 modem_ofst;
@@ -2440,6 +2498,7 @@ int ipa3_del_nat_table(struct ipa_ioc_nat_ipv6ct_table_del *del);
int ipa3_del_ipv6ct_table(struct ipa_ioc_nat_ipv6ct_table_del *del);

int ipa3_nat_mdfy_pdn(struct ipa_ioc_nat_pdn_entry *mdfy_pdn);
int ipa3_nat_get_sram_info(struct ipa_nat_in_sram_info *info_ptr);

/*
 * Messaging
+1127 −407

File changed.

Preview size limit exceeded, changes collapsed.

+6 −34
Original line number Diff line number Diff line
@@ -3110,11 +3110,7 @@ static struct ipa3_mem_partition ipa_4_5_mem_part = {
	.apps_hdr_proc_ctx_size		= 0x200,
	.apps_hdr_proc_ctx_size_ddr	= 0x0,
	.nat_tbl_ofst			= 0x1800,
	.nat_tbl_size			= 0x800,
	.nat_index_tbl_ofst		= 0x2000,
	.nat_index_tbl_size		= 0x100,
	.nat_exp_tbl_ofst		= 0x2100,
	.nat_exp_tbl_size		= 0x400,
	.nat_tbl_size			= 0xd00,
	.stats_quota_ofst		= 0x2510,
	.stats_quota_size		= 0x78,
	.stats_tethering_ofst		= 0x2588,
@@ -3207,11 +3203,7 @@ static struct ipa3_mem_partition ipa_4_7_mem_part = {
	.apps_hdr_proc_ctx_size		= 0x200,
	.apps_hdr_proc_ctx_size_ddr	= 0x0,
	.nat_tbl_ofst			= 0x17A0,
	.nat_tbl_size			= 0x800,
	.nat_index_tbl_ofst		= 0x1FA0,
	.nat_index_tbl_size		= 0x100,
	.nat_exp_tbl_ofst		= 0x20A0,
	.nat_exp_tbl_size		= 0x400,
	.nat_tbl_size			= 0xd00,
	.pdn_config_ofst		= 0x24A8,
	.pdn_config_size		= 0x50,
	.stats_quota_ofst		= 0x2500,
@@ -5833,31 +5825,11 @@ int ipa3_init_mem_partition(enum ipa_hw_type type)
		   IPA_MEM_PART(nat_tbl_size));

	if (IPA_MEM_PART(nat_tbl_ofst) & 31) {
		IPAERR("NAT TBL OFST 0x%x is unaligned\n",
		IPAERR("NAT TBL OFST 0x%x is not aligned properly\n",
			   IPA_MEM_PART(nat_tbl_ofst));
		return -ENODEV;
	}

	IPADBG("NAT INDEX TBL OFST 0x%x SIZE 0x%x\n",
		IPA_MEM_PART(nat_index_tbl_ofst),
		IPA_MEM_PART(nat_index_tbl_size));

	if (IPA_MEM_PART(nat_index_tbl_ofst) & 3) {
		IPAERR("NAT INDEX TBL OFST 0x%x is unaligned\n",
			IPA_MEM_PART(nat_index_tbl_ofst));
		return -ENODEV;
	}

	IPADBG("NAT EXP TBL OFST 0x%x SIZE 0x%x\n",
		IPA_MEM_PART(nat_exp_tbl_ofst),
		IPA_MEM_PART(nat_exp_tbl_size));

	if (IPA_MEM_PART(nat_exp_tbl_ofst) & 31) {
		IPAERR("NAT EXP TBL OFST 0x%x is unaligned\n",
			IPA_MEM_PART(nat_exp_tbl_ofst));
		return -ENODEV;
	}

	IPADBG("PDN CONFIG OFST 0x%x SIZE 0x%x\n",
		IPA_MEM_PART(pdn_config_ofst),
		IPA_MEM_PART(pdn_config_size));