xref: /linux/drivers/net/ipa/ipa_cmd.c (revision 621cde16e49b3ecf7d59a8106a20aaebfb4a59a9)
1731c46edSAlex Elder // SPDX-License-Identifier: GPL-2.0
2731c46edSAlex Elder 
3731c46edSAlex Elder /* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
4ff39eefdSAlex Elder  * Copyright (C) 2019-2024 Linaro Ltd.
5731c46edSAlex Elder  */
6731c46edSAlex Elder 
7731c46edSAlex Elder #include <linux/bitfield.h>
8*88412277SAlex Elder #include <linux/bits.h>
9*88412277SAlex Elder #include <linux/device.h>
10731c46edSAlex Elder #include <linux/dma-direction.h>
11*88412277SAlex Elder #include <linux/types.h>
12731c46edSAlex Elder 
13731c46edSAlex Elder #include "gsi.h"
14731c46edSAlex Elder #include "gsi_trans.h"
15731c46edSAlex Elder #include "ipa.h"
16*88412277SAlex Elder #include "ipa_cmd.h"
17731c46edSAlex Elder #include "ipa_endpoint.h"
18*88412277SAlex Elder #include "ipa_mem.h"
19a53c85f3SAlex Elder #include "ipa_reg.h"
20731c46edSAlex Elder #include "ipa_table.h"
21731c46edSAlex Elder 
22731c46edSAlex Elder /**
23731c46edSAlex Elder  * DOC:  IPA Immediate Commands
24731c46edSAlex Elder  *
25731c46edSAlex Elder  * The AP command TX endpoint is used to issue immediate commands to the IPA.
26731c46edSAlex Elder  * An immediate command is generally used to request the IPA do something
27731c46edSAlex Elder  * other than data transfer to another endpoint.
28731c46edSAlex Elder  *
29731c46edSAlex Elder  * Immediate commands are represented by GSI transactions just like other
30d15180b4SAlex Elder  * transfer requests, and use a single GSI TRE.  Each immediate command
31d15180b4SAlex Elder  * has a well-defined format, having a payload of a known length.  This
32d15180b4SAlex Elder  * allows the transfer element's length field to be used to hold an
33d15180b4SAlex Elder  * immediate command's opcode.  The payload for a command resides in AP
34d15180b4SAlex Elder  * memory and is described by a single scatterlist entry in its transaction.
35d15180b4SAlex Elder  * Commands do not require a transaction completion callback, and are
36ace5dc61SAlex Elder  * always issued using gsi_trans_commit_wait().
37731c46edSAlex Elder  */
38731c46edSAlex Elder 
39731c46edSAlex Elder /* Some commands can wait until indicated pipeline stages are clear */
40731c46edSAlex Elder enum pipeline_clear_options {
418701cb00SAlex Elder 	pipeline_clear_hps		= 0x0,
428701cb00SAlex Elder 	pipeline_clear_src_grp		= 0x1,
438701cb00SAlex Elder 	pipeline_clear_full		= 0x2,
44731c46edSAlex Elder };
45731c46edSAlex Elder 
46731c46edSAlex Elder /* IPA_CMD_IP_V{4,6}_{FILTER,ROUTING}_INIT */
47731c46edSAlex Elder 
48731c46edSAlex Elder struct ipa_cmd_hw_ip_fltrt_init {
49731c46edSAlex Elder 	__le64 hash_rules_addr;
50731c46edSAlex Elder 	__le64 flags;
51731c46edSAlex Elder 	__le64 nhash_rules_addr;
52731c46edSAlex Elder };
53731c46edSAlex Elder 
54731c46edSAlex Elder /* Field masks for ipa_cmd_hw_ip_fltrt_init structure fields */
55731c46edSAlex Elder #define IP_FLTRT_FLAGS_HASH_SIZE_FMASK			GENMASK_ULL(11, 0)
56731c46edSAlex Elder #define IP_FLTRT_FLAGS_HASH_ADDR_FMASK			GENMASK_ULL(27, 12)
57731c46edSAlex Elder #define IP_FLTRT_FLAGS_NHASH_SIZE_FMASK			GENMASK_ULL(39, 28)
58731c46edSAlex Elder #define IP_FLTRT_FLAGS_NHASH_ADDR_FMASK			GENMASK_ULL(55, 40)
59731c46edSAlex Elder 
60731c46edSAlex Elder /* IPA_CMD_HDR_INIT_LOCAL */
61731c46edSAlex Elder 
62731c46edSAlex Elder struct ipa_cmd_hw_hdr_init_local {
63731c46edSAlex Elder 	__le64 hdr_table_addr;
64731c46edSAlex Elder 	__le32 flags;
65731c46edSAlex Elder 	__le32 reserved;
66731c46edSAlex Elder };
67731c46edSAlex Elder 
68731c46edSAlex Elder /* Field masks for ipa_cmd_hw_hdr_init_local structure fields */
69731c46edSAlex Elder #define HDR_INIT_LOCAL_FLAGS_TABLE_SIZE_FMASK		GENMASK(11, 0)
70731c46edSAlex Elder #define HDR_INIT_LOCAL_FLAGS_HDR_ADDR_FMASK		GENMASK(27, 12)
71731c46edSAlex Elder 
72731c46edSAlex Elder /* IPA_CMD_REGISTER_WRITE */
73731c46edSAlex Elder 
74d7f3087bSAlex Elder /* For IPA v4.0+, the pipeline clear options are encoded in the opcode */
75731c46edSAlex Elder #define REGISTER_WRITE_OPCODE_SKIP_CLEAR_FMASK		GENMASK(8, 8)
76731c46edSAlex Elder #define REGISTER_WRITE_OPCODE_CLEAR_OPTION_FMASK	GENMASK(10, 9)
77731c46edSAlex Elder 
78731c46edSAlex Elder struct ipa_cmd_register_write {
79d7f3087bSAlex Elder 	__le16 flags;		/* Unused/reserved prior to IPA v4.0 */
80731c46edSAlex Elder 	__le16 offset;
81731c46edSAlex Elder 	__le32 value;
82731c46edSAlex Elder 	__le32 value_mask;
83731c46edSAlex Elder 	__le32 clear_options;	/* Unused/reserved for IPA v4.0+ */
84731c46edSAlex Elder };
85731c46edSAlex Elder 
86731c46edSAlex Elder /* Field masks for ipa_cmd_register_write structure fields */
87d7f3087bSAlex Elder /* The next field is present for IPA v4.0+ */
88731c46edSAlex Elder #define REGISTER_WRITE_FLAGS_OFFSET_HIGH_FMASK		GENMASK(14, 11)
89d7f3087bSAlex Elder /* The next field is not present for IPA v4.0+ */
90731c46edSAlex Elder #define REGISTER_WRITE_FLAGS_SKIP_CLEAR_FMASK		GENMASK(15, 15)
91731c46edSAlex Elder 
92d7f3087bSAlex Elder /* The next field and its values are not present for IPA v4.0+ */
93731c46edSAlex Elder #define REGISTER_WRITE_CLEAR_OPTIONS_FMASK		GENMASK(1, 0)
94731c46edSAlex Elder 
95731c46edSAlex Elder /* IPA_CMD_IP_PACKET_INIT */
96731c46edSAlex Elder 
97731c46edSAlex Elder struct ipa_cmd_ip_packet_init {
98c84ddc11SAlex Elder 	u8 dest_endpoint;	/* Full 8 bits used for IPA v5.0+ */
99731c46edSAlex Elder 	u8 reserved[7];
100731c46edSAlex Elder };
101731c46edSAlex Elder 
102c84ddc11SAlex Elder /* Field mask for ipa_cmd_ip_packet_init dest_endpoint field (unused v5.0+) */
103731c46edSAlex Elder #define IPA_PACKET_INIT_DEST_ENDPOINT_FMASK		GENMASK(4, 0)
104731c46edSAlex Elder 
105731c46edSAlex Elder /* IPA_CMD_DMA_SHARED_MEM */
106731c46edSAlex Elder 
107731c46edSAlex Elder /* For IPA v4.0+, this opcode gets modified with pipeline clear options */
108731c46edSAlex Elder 
109731c46edSAlex Elder #define DMA_SHARED_MEM_OPCODE_SKIP_CLEAR_FMASK		GENMASK(8, 8)
110731c46edSAlex Elder #define DMA_SHARED_MEM_OPCODE_CLEAR_OPTION_FMASK	GENMASK(10, 9)
111731c46edSAlex Elder 
112731c46edSAlex Elder struct ipa_cmd_hw_dma_mem_mem {
113731c46edSAlex Elder 	__le16 clear_after_read; /* 0 or DMA_SHARED_MEM_CLEAR_AFTER_READ */
114731c46edSAlex Elder 	__le16 size;
115731c46edSAlex Elder 	__le16 local_addr;
116731c46edSAlex Elder 	__le16 flags;
117731c46edSAlex Elder 	__le64 system_addr;
118731c46edSAlex Elder };
119731c46edSAlex Elder 
120731c46edSAlex Elder /* Flag allowing atomic clear of target region after reading data (v4.0+)*/
121731c46edSAlex Elder #define DMA_SHARED_MEM_CLEAR_AFTER_READ			GENMASK(15, 15)
122731c46edSAlex Elder 
123731c46edSAlex Elder /* Field masks for ipa_cmd_hw_dma_mem_mem structure fields */
124731c46edSAlex Elder #define DMA_SHARED_MEM_FLAGS_DIRECTION_FMASK		GENMASK(0, 0)
125d7f3087bSAlex Elder /* The next two fields are not present for IPA v4.0+ */
126731c46edSAlex Elder #define DMA_SHARED_MEM_FLAGS_SKIP_CLEAR_FMASK		GENMASK(1, 1)
127731c46edSAlex Elder #define DMA_SHARED_MEM_FLAGS_CLEAR_OPTIONS_FMASK	GENMASK(3, 2)
128731c46edSAlex Elder 
129731c46edSAlex Elder /* IPA_CMD_IP_PACKET_TAG_STATUS */
130731c46edSAlex Elder 
131731c46edSAlex Elder struct ipa_cmd_ip_packet_tag_status {
132731c46edSAlex Elder 	__le64 tag;
133731c46edSAlex Elder };
134731c46edSAlex Elder 
135731c46edSAlex Elder #define IP_PACKET_TAG_STATUS_TAG_FMASK			GENMASK_ULL(63, 16)
136731c46edSAlex Elder 
137731c46edSAlex Elder /* Immediate command payload */
138731c46edSAlex Elder union ipa_cmd_payload {
139731c46edSAlex Elder 	struct ipa_cmd_hw_ip_fltrt_init table_init;
140731c46edSAlex Elder 	struct ipa_cmd_hw_hdr_init_local hdr_init_local;
141731c46edSAlex Elder 	struct ipa_cmd_register_write register_write;
142731c46edSAlex Elder 	struct ipa_cmd_ip_packet_init ip_packet_init;
143731c46edSAlex Elder 	struct ipa_cmd_hw_dma_mem_mem dma_shared_mem;
144731c46edSAlex Elder 	struct ipa_cmd_ip_packet_tag_status ip_packet_tag_status;
145731c46edSAlex Elder };
146731c46edSAlex Elder 
ipa_cmd_validate_build(void)147731c46edSAlex Elder static void ipa_cmd_validate_build(void)
148731c46edSAlex Elder {
1490439e674SAlex Elder 	/* The size of a filter table needs to fit into fields in the
1500439e674SAlex Elder 	 * ipa_cmd_hw_ip_fltrt_init structure.  Although hashed tables
151731c46edSAlex Elder 	 * might not be used, non-hashed and hashed tables have the same
152731c46edSAlex Elder 	 * maximum size.  IPv4 and IPv6 filter tables have the same number
153731c46edSAlex Elder 	 * of entries.
154731c46edSAlex Elder 	 */
155f2c1dac0SAlex Elder 	/* Hashed and non-hashed fields are assumed to be the same size */
156f2c1dac0SAlex Elder 	BUILD_BUG_ON(field_max(IP_FLTRT_FLAGS_HASH_SIZE_FMASK) !=
157f2c1dac0SAlex Elder 		     field_max(IP_FLTRT_FLAGS_NHASH_SIZE_FMASK));
158f2c1dac0SAlex Elder 	BUILD_BUG_ON(field_max(IP_FLTRT_FLAGS_HASH_ADDR_FMASK) !=
159f2c1dac0SAlex Elder 		     field_max(IP_FLTRT_FLAGS_NHASH_ADDR_FMASK));
1605bc55884SAlex Elder 
16107abde54SAlex Elder 	/* Prior to IPA v5.0, we supported no more than 32 endpoints,
16207abde54SAlex Elder 	 * and this was reflected in some 5-bit fields that held
16307abde54SAlex Elder 	 * endpoint numbers.  Starting with IPA v5.0, the widths of
16407abde54SAlex Elder 	 * these fields were extended to 8 bits, meaning up to 256
16507abde54SAlex Elder 	 * endpoints.  If the driver claims to support more than
16607abde54SAlex Elder 	 * that it's an error.
16707abde54SAlex Elder 	 */
16807abde54SAlex Elder 	BUILD_BUG_ON(IPA_ENDPOINT_MAX - 1 > U8_MAX);
169731c46edSAlex Elder }
170731c46edSAlex Elder 
171731c46edSAlex Elder /* Validate a memory region holding a table */
ipa_cmd_table_init_valid(struct ipa * ipa,const struct ipa_mem * mem,bool route)1725444b0eaSAlex Elder bool ipa_cmd_table_init_valid(struct ipa *ipa, const struct ipa_mem *mem,
1735444b0eaSAlex Elder 			      bool route)
174731c46edSAlex Elder {
175f2c1dac0SAlex Elder 	u32 offset_max = field_max(IP_FLTRT_FLAGS_NHASH_ADDR_FMASK);
176f2c1dac0SAlex Elder 	u32 size_max = field_max(IP_FLTRT_FLAGS_NHASH_SIZE_FMASK);
177f2c1dac0SAlex Elder 	const char *table = route ? "route" : "filter";
1785245f4fdSAlex Elder 	struct device *dev = ipa->dev;
1790439e674SAlex Elder 	u32 size;
1800439e674SAlex Elder 
181f787d848SAlex Elder 	size = route ? ipa->route_count : ipa->filter_count + 1;
182f787d848SAlex Elder 	size *= sizeof(__le64);
183731c46edSAlex Elder 
184f2c1dac0SAlex Elder 	/* Size must fit in the immediate command field that holds it */
1850439e674SAlex Elder 	if (size > size_max) {
186f2c1dac0SAlex Elder 		dev_err(dev, "%s table region size too large\n", table);
1870439e674SAlex Elder 		dev_err(dev, "    (0x%04x > 0x%04x)\n", size, size_max);
188f2c1dac0SAlex Elder 
189f2c1dac0SAlex Elder 		return false;
190f2c1dac0SAlex Elder 	}
191f2c1dac0SAlex Elder 
192f2c1dac0SAlex Elder 	/* Offset must fit in the immediate command field that holds it */
193731c46edSAlex Elder 	if (mem->offset > offset_max ||
194731c46edSAlex Elder 	    ipa->mem_offset > offset_max - mem->offset) {
195f2c1dac0SAlex Elder 		dev_err(dev, "%s table region offset too large\n", table);
196b4afd4b9SAlex Elder 		dev_err(dev, "    (0x%04x + 0x%04x > 0x%04x)\n",
197731c46edSAlex Elder 			ipa->mem_offset, mem->offset, offset_max);
198b4afd4b9SAlex Elder 
199731c46edSAlex Elder 		return false;
200731c46edSAlex Elder 	}
201731c46edSAlex Elder 
202731c46edSAlex Elder 	return true;
203731c46edSAlex Elder }
204731c46edSAlex Elder 
205731c46edSAlex Elder /* Validate the memory region that holds headers */
ipa_cmd_header_init_local_valid(struct ipa * ipa)2067fd10a2aSAlex Elder static bool ipa_cmd_header_init_local_valid(struct ipa *ipa)
207731c46edSAlex Elder {
2085245f4fdSAlex Elder 	struct device *dev = ipa->dev;
209ce05a9f3SAlex Elder 	const struct ipa_mem *mem;
210731c46edSAlex Elder 	u32 offset_max;
211731c46edSAlex Elder 	u32 size_max;
212ce05a9f3SAlex Elder 	u32 offset;
213731c46edSAlex Elder 	u32 size;
214731c46edSAlex Elder 
215ce05a9f3SAlex Elder 	/* In ipa_cmd_hdr_init_local_add() we record the offset and size of
216ce05a9f3SAlex Elder 	 * the header table memory area in an immediate command.  Make sure
217ce05a9f3SAlex Elder 	 * the offset and size fit in the fields that need to hold them, and
218ce05a9f3SAlex Elder 	 * that the entire range is within the overall IPA memory range.
219b4afd4b9SAlex Elder 	 */
220731c46edSAlex Elder 	offset_max = field_max(HDR_INIT_LOCAL_FLAGS_HDR_ADDR_FMASK);
221ce05a9f3SAlex Elder 	size_max = field_max(HDR_INIT_LOCAL_FLAGS_TABLE_SIZE_FMASK);
222ce05a9f3SAlex Elder 
223ce05a9f3SAlex Elder 	/* The header memory area contains both the modem and AP header
224ce05a9f3SAlex Elder 	 * regions.  The modem portion defines the address of the region.
225ce05a9f3SAlex Elder 	 */
2265e3bc1e5SAlex Elder 	mem = ipa_mem_find(ipa, IPA_MEM_MODEM_HEADER);
227ce05a9f3SAlex Elder 	offset = mem->offset;
228ce05a9f3SAlex Elder 	size = mem->size;
229ce05a9f3SAlex Elder 
230ce05a9f3SAlex Elder 	/* Make sure the offset fits in the IPA command */
231ce05a9f3SAlex Elder 	if (offset > offset_max || ipa->mem_offset > offset_max - offset) {
232b4afd4b9SAlex Elder 		dev_err(dev, "header table region offset too large\n");
233b4afd4b9SAlex Elder 		dev_err(dev, "    (0x%04x + 0x%04x > 0x%04x)\n",
234ce05a9f3SAlex Elder 			ipa->mem_offset, offset, offset_max);
235b4afd4b9SAlex Elder 
236731c46edSAlex Elder 		return false;
237731c46edSAlex Elder 	}
238731c46edSAlex Elder 
2395e3bc1e5SAlex Elder 	/* Add the size of the AP portion (if defined) to the combined size */
2405e3bc1e5SAlex Elder 	mem = ipa_mem_find(ipa, IPA_MEM_AP_HEADER);
2415e3bc1e5SAlex Elder 	if (mem)
2425e3bc1e5SAlex Elder 		size += mem->size;
243b4afd4b9SAlex Elder 
244ce05a9f3SAlex Elder 	/* Make sure the combined size fits in the IPA command */
245b4afd4b9SAlex Elder 	if (size > size_max) {
246b4afd4b9SAlex Elder 		dev_err(dev, "header table region size too large\n");
247b4afd4b9SAlex Elder 		dev_err(dev, "    (0x%04x > 0x%08x)\n", size, size_max);
248b4afd4b9SAlex Elder 
249b4afd4b9SAlex Elder 		return false;
250b4afd4b9SAlex Elder 	}
251ce05a9f3SAlex Elder 
252731c46edSAlex Elder 	return true;
253731c46edSAlex Elder }
254731c46edSAlex Elder 
255731c46edSAlex Elder /* Indicate whether an offset can be used with a register_write command */
ipa_cmd_register_write_offset_valid(struct ipa * ipa,const char * name,u32 offset)256731c46edSAlex Elder static bool ipa_cmd_register_write_offset_valid(struct ipa *ipa,
257731c46edSAlex Elder 						const char *name, u32 offset)
258731c46edSAlex Elder {
259731c46edSAlex Elder 	struct ipa_cmd_register_write *payload;
2605245f4fdSAlex Elder 	struct device *dev = ipa->dev;
261731c46edSAlex Elder 	u32 offset_max;
262731c46edSAlex Elder 	u32 bit_count;
263731c46edSAlex Elder 
264731c46edSAlex Elder 	/* The maximum offset in a register_write immediate command depends
265d7f3087bSAlex Elder 	 * on the version of IPA.  A 16 bit offset is always supported,
266d7f3087bSAlex Elder 	 * but starting with IPA v4.0 some additional high-order bits are
267d7f3087bSAlex Elder 	 * allowed.
268731c46edSAlex Elder 	 */
269731c46edSAlex Elder 	bit_count = BITS_PER_BYTE * sizeof(payload->offset);
270d7f3087bSAlex Elder 	if (ipa->version >= IPA_VERSION_4_0)
271731c46edSAlex Elder 		bit_count += hweight32(REGISTER_WRITE_FLAGS_OFFSET_HIGH_FMASK);
272731c46edSAlex Elder 	BUILD_BUG_ON(bit_count > 32);
2732d65ed76SAlex Elder 	offset_max = ~0U >> (32 - bit_count);
274731c46edSAlex Elder 
2752d65ed76SAlex Elder 	/* Make sure the offset can be represented by the field(s)
2762d65ed76SAlex Elder 	 * that holds it.  Also make sure the offset is not outside
2772d65ed76SAlex Elder 	 * the overall IPA memory range.
2782d65ed76SAlex Elder 	 */
279731c46edSAlex Elder 	if (offset > offset_max || ipa->mem_offset > offset_max - offset) {
280731c46edSAlex Elder 		dev_err(dev, "%s offset too large 0x%04x + 0x%04x > 0x%04x)\n",
2812d65ed76SAlex Elder 			name, ipa->mem_offset, offset, offset_max);
282731c46edSAlex Elder 		return false;
283731c46edSAlex Elder 	}
284731c46edSAlex Elder 
285731c46edSAlex Elder 	return true;
286731c46edSAlex Elder }
287731c46edSAlex Elder 
288731c46edSAlex Elder /* Check whether offsets passed to register_write are valid */
ipa_cmd_register_write_valid(struct ipa * ipa)289731c46edSAlex Elder static bool ipa_cmd_register_write_valid(struct ipa *ipa)
290731c46edSAlex Elder {
29181772e44SAlex Elder 	const struct reg *reg;
292731c46edSAlex Elder 	const char *name;
293731c46edSAlex Elder 	u32 offset;
294731c46edSAlex Elder 
2952d65ed76SAlex Elder 	/* If hashed tables are supported, ensure the hash flush register
2962d65ed76SAlex Elder 	 * offset will fit in a register write IPA immediate command.
2972d65ed76SAlex Elder 	 */
298a266ad6bSAlex Elder 	if (ipa_table_hash_support(ipa)) {
2998e7c89d8SAlex Elder 		if (ipa->version < IPA_VERSION_5_0)
3006a244b75SAlex Elder 			reg = ipa_reg(ipa, FILT_ROUT_HASH_FLUSH);
3018e7c89d8SAlex Elder 		else
3028e7c89d8SAlex Elder 			reg = ipa_reg(ipa, FILT_ROUT_CACHE_FLUSH);
3038e7c89d8SAlex Elder 
304fc4cecf7SAlex Elder 		offset = reg_offset(reg);
305731c46edSAlex Elder 		name = "filter/route hash flush";
306731c46edSAlex Elder 		if (!ipa_cmd_register_write_offset_valid(ipa, name, offset))
307731c46edSAlex Elder 			return false;
3082d65ed76SAlex Elder 	}
309731c46edSAlex Elder 
3102d65ed76SAlex Elder 	/* Each endpoint can have a status endpoint associated with it,
3112d65ed76SAlex Elder 	 * and this is recorded in an endpoint register.  If the modem
3122d65ed76SAlex Elder 	 * crashes, we reset the status endpoint for all modem endpoints
3132d65ed76SAlex Elder 	 * using a register write IPA immediate command.  Make sure the
3142d65ed76SAlex Elder 	 * worst case (highest endpoint number) offset of that endpoint
3152d65ed76SAlex Elder 	 * fits in the register write command field(s) that must hold it.
3162d65ed76SAlex Elder 	 */
3176a244b75SAlex Elder 	reg = ipa_reg(ipa, ENDP_STATUS);
318fc4cecf7SAlex Elder 	offset = reg_n_offset(reg, IPA_ENDPOINT_COUNT - 1);
319731c46edSAlex Elder 	name = "maximal endpoint status";
320731c46edSAlex Elder 	if (!ipa_cmd_register_write_offset_valid(ipa, name, offset))
321731c46edSAlex Elder 		return false;
322731c46edSAlex Elder 
323731c46edSAlex Elder 	return true;
324731c46edSAlex Elder }
325731c46edSAlex Elder 
ipa_cmd_pool_init(struct gsi_channel * channel,u32 tre_max)326731c46edSAlex Elder int ipa_cmd_pool_init(struct gsi_channel *channel, u32 tre_max)
327731c46edSAlex Elder {
328731c46edSAlex Elder 	struct gsi_trans_info *trans_info = &channel->trans_info;
329731c46edSAlex Elder 	struct device *dev = channel->gsi->dev;
330731c46edSAlex Elder 
33188e03057SAlex Elder 	/* Command payloads are allocated one at a time, but a single
33288e03057SAlex Elder 	 * transaction can require up to the maximum supported by the
33388e03057SAlex Elder 	 * channel; treat them as if they were allocated all at once.
334731c46edSAlex Elder 	 */
3358797972aSAlex Elder 	return gsi_trans_pool_init_dma(dev, &trans_info->cmd_pool,
336731c46edSAlex Elder 				       sizeof(union ipa_cmd_payload),
33788e03057SAlex Elder 				       tre_max, channel->trans_tre_max);
338731c46edSAlex Elder }
339731c46edSAlex Elder 
ipa_cmd_pool_exit(struct gsi_channel * channel)340731c46edSAlex Elder void ipa_cmd_pool_exit(struct gsi_channel *channel)
341731c46edSAlex Elder {
342731c46edSAlex Elder 	struct gsi_trans_info *trans_info = &channel->trans_info;
343731c46edSAlex Elder 	struct device *dev = channel->gsi->dev;
344731c46edSAlex Elder 
345731c46edSAlex Elder 	gsi_trans_pool_exit_dma(dev, &trans_info->cmd_pool);
346731c46edSAlex Elder }
347731c46edSAlex Elder 
348731c46edSAlex Elder static union ipa_cmd_payload *
ipa_cmd_payload_alloc(struct ipa * ipa,dma_addr_t * addr)349731c46edSAlex Elder ipa_cmd_payload_alloc(struct ipa *ipa, dma_addr_t *addr)
350731c46edSAlex Elder {
351731c46edSAlex Elder 	struct gsi_trans_info *trans_info;
352731c46edSAlex Elder 	struct ipa_endpoint *endpoint;
353731c46edSAlex Elder 
354731c46edSAlex Elder 	endpoint = ipa->name_map[IPA_ENDPOINT_AP_COMMAND_TX];
355731c46edSAlex Elder 	trans_info = &ipa->gsi.channel[endpoint->channel_id].trans_info;
356731c46edSAlex Elder 
357731c46edSAlex Elder 	return gsi_trans_pool_alloc_dma(&trans_info->cmd_pool, addr);
358731c46edSAlex Elder }
359731c46edSAlex Elder 
360731c46edSAlex Elder /* If hash_size is 0, hash_offset and hash_addr ignored. */
ipa_cmd_table_init_add(struct gsi_trans * trans,enum ipa_cmd_opcode opcode,u16 size,u32 offset,dma_addr_t addr,u16 hash_size,u32 hash_offset,dma_addr_t hash_addr)361731c46edSAlex Elder void ipa_cmd_table_init_add(struct gsi_trans *trans,
362731c46edSAlex Elder 			    enum ipa_cmd_opcode opcode, u16 size, u32 offset,
363731c46edSAlex Elder 			    dma_addr_t addr, u16 hash_size, u32 hash_offset,
364731c46edSAlex Elder 			    dma_addr_t hash_addr)
365731c46edSAlex Elder {
366731c46edSAlex Elder 	struct ipa *ipa = container_of(trans->gsi, struct ipa, gsi);
367731c46edSAlex Elder 	struct ipa_cmd_hw_ip_fltrt_init *payload;
368731c46edSAlex Elder 	union ipa_cmd_payload *cmd_payload;
369731c46edSAlex Elder 	dma_addr_t payload_addr;
370731c46edSAlex Elder 	u64 val;
371731c46edSAlex Elder 
372731c46edSAlex Elder 	/* Record the non-hash table offset and size */
373731c46edSAlex Elder 	offset += ipa->mem_offset;
374731c46edSAlex Elder 	val = u64_encode_bits(offset, IP_FLTRT_FLAGS_NHASH_ADDR_FMASK);
375731c46edSAlex Elder 	val |= u64_encode_bits(size, IP_FLTRT_FLAGS_NHASH_SIZE_FMASK);
376731c46edSAlex Elder 
377731c46edSAlex Elder 	/* The hash table offset and address are zero if its size is 0 */
378731c46edSAlex Elder 	if (hash_size) {
379731c46edSAlex Elder 		/* Record the hash table offset and size */
380731c46edSAlex Elder 		hash_offset += ipa->mem_offset;
381731c46edSAlex Elder 		val |= u64_encode_bits(hash_offset,
382731c46edSAlex Elder 				       IP_FLTRT_FLAGS_HASH_ADDR_FMASK);
383731c46edSAlex Elder 		val |= u64_encode_bits(hash_size,
384731c46edSAlex Elder 				       IP_FLTRT_FLAGS_HASH_SIZE_FMASK);
385731c46edSAlex Elder 	}
386731c46edSAlex Elder 
387731c46edSAlex Elder 	cmd_payload = ipa_cmd_payload_alloc(ipa, &payload_addr);
388731c46edSAlex Elder 	payload = &cmd_payload->table_init;
389731c46edSAlex Elder 
390731c46edSAlex Elder 	/* Fill in all offsets and sizes and the non-hash table address */
391731c46edSAlex Elder 	if (hash_size)
392731c46edSAlex Elder 		payload->hash_rules_addr = cpu_to_le64(hash_addr);
393731c46edSAlex Elder 	payload->flags = cpu_to_le64(val);
394731c46edSAlex Elder 	payload->nhash_rules_addr = cpu_to_le64(addr);
395731c46edSAlex Elder 
396731c46edSAlex Elder 	gsi_trans_cmd_add(trans, payload, sizeof(*payload), payload_addr,
3974de284b7SAlex Elder 			  opcode);
398731c46edSAlex Elder }
399731c46edSAlex Elder 
400731c46edSAlex Elder /* Initialize header space in IPA-local memory */
ipa_cmd_hdr_init_local_add(struct gsi_trans * trans,u32 offset,u16 size,dma_addr_t addr)401731c46edSAlex Elder void ipa_cmd_hdr_init_local_add(struct gsi_trans *trans, u32 offset, u16 size,
402731c46edSAlex Elder 				dma_addr_t addr)
403731c46edSAlex Elder {
404731c46edSAlex Elder 	struct ipa *ipa = container_of(trans->gsi, struct ipa, gsi);
405731c46edSAlex Elder 	enum ipa_cmd_opcode opcode = IPA_CMD_HDR_INIT_LOCAL;
406731c46edSAlex Elder 	struct ipa_cmd_hw_hdr_init_local *payload;
407731c46edSAlex Elder 	union ipa_cmd_payload *cmd_payload;
408731c46edSAlex Elder 	dma_addr_t payload_addr;
409731c46edSAlex Elder 	u32 flags;
410731c46edSAlex Elder 
411731c46edSAlex Elder 	offset += ipa->mem_offset;
412731c46edSAlex Elder 
413731c46edSAlex Elder 	/* With this command we tell the IPA where in its local memory the
414731c46edSAlex Elder 	 * header tables reside.  The content of the buffer provided is
415731c46edSAlex Elder 	 * also written via DMA into that space.  The IPA hardware owns
416731c46edSAlex Elder 	 * the table, but the AP must initialize it.
417731c46edSAlex Elder 	 */
418731c46edSAlex Elder 	cmd_payload = ipa_cmd_payload_alloc(ipa, &payload_addr);
419731c46edSAlex Elder 	payload = &cmd_payload->hdr_init_local;
420731c46edSAlex Elder 
421731c46edSAlex Elder 	payload->hdr_table_addr = cpu_to_le64(addr);
422731c46edSAlex Elder 	flags = u32_encode_bits(size, HDR_INIT_LOCAL_FLAGS_TABLE_SIZE_FMASK);
423731c46edSAlex Elder 	flags |= u32_encode_bits(offset, HDR_INIT_LOCAL_FLAGS_HDR_ADDR_FMASK);
424731c46edSAlex Elder 	payload->flags = cpu_to_le32(flags);
425731c46edSAlex Elder 
426731c46edSAlex Elder 	gsi_trans_cmd_add(trans, payload, sizeof(*payload), payload_addr,
4274de284b7SAlex Elder 			  opcode);
428731c46edSAlex Elder }
429731c46edSAlex Elder 
ipa_cmd_register_write_add(struct gsi_trans * trans,u32 offset,u32 value,u32 mask,bool clear_full)430731c46edSAlex Elder void ipa_cmd_register_write_add(struct gsi_trans *trans, u32 offset, u32 value,
431731c46edSAlex Elder 				u32 mask, bool clear_full)
432731c46edSAlex Elder {
433731c46edSAlex Elder 	struct ipa *ipa = container_of(trans->gsi, struct ipa, gsi);
434731c46edSAlex Elder 	struct ipa_cmd_register_write *payload;
435731c46edSAlex Elder 	union ipa_cmd_payload *cmd_payload;
436731c46edSAlex Elder 	u32 opcode = IPA_CMD_REGISTER_WRITE;
437731c46edSAlex Elder 	dma_addr_t payload_addr;
438731c46edSAlex Elder 	u32 clear_option;
439731c46edSAlex Elder 	u32 options;
440731c46edSAlex Elder 	u16 flags;
441731c46edSAlex Elder 
442731c46edSAlex Elder 	/* pipeline_clear_src_grp is not used */
443731c46edSAlex Elder 	clear_option = clear_full ? pipeline_clear_full : pipeline_clear_hps;
444731c46edSAlex Elder 
445d7f3087bSAlex Elder 	/* IPA v4.0+ represents the pipeline clear options in the opcode.  It
446d7f3087bSAlex Elder 	 * also supports a larger offset by encoding additional high-order
447d7f3087bSAlex Elder 	 * bits in the payload flags field.
448d7f3087bSAlex Elder 	 */
449d7f3087bSAlex Elder 	if (ipa->version >= IPA_VERSION_4_0) {
450731c46edSAlex Elder 		u16 offset_high;
451731c46edSAlex Elder 		u32 val;
452731c46edSAlex Elder 
453731c46edSAlex Elder 		/* Opcode encodes pipeline clear options */
454731c46edSAlex Elder 		/* SKIP_CLEAR is always 0 (don't skip pipeline clear) */
455731c46edSAlex Elder 		val = u16_encode_bits(clear_option,
456731c46edSAlex Elder 				      REGISTER_WRITE_OPCODE_CLEAR_OPTION_FMASK);
457731c46edSAlex Elder 		opcode |= val;
458731c46edSAlex Elder 
459731c46edSAlex Elder 		/* Extract the high 4 bits from the offset */
460731c46edSAlex Elder 		offset_high = (u16)u32_get_bits(offset, GENMASK(19, 16));
461731c46edSAlex Elder 		offset &= (1 << 16) - 1;
462731c46edSAlex Elder 
463731c46edSAlex Elder 		/* Extract the top 4 bits and encode it into the flags field */
464731c46edSAlex Elder 		flags = u16_encode_bits(offset_high,
465731c46edSAlex Elder 				REGISTER_WRITE_FLAGS_OFFSET_HIGH_FMASK);
466731c46edSAlex Elder 		options = 0;	/* reserved */
467731c46edSAlex Elder 
468731c46edSAlex Elder 	} else {
469731c46edSAlex Elder 		flags = 0;	/* SKIP_CLEAR flag is always 0 */
470731c46edSAlex Elder 		options = u16_encode_bits(clear_option,
471731c46edSAlex Elder 					  REGISTER_WRITE_CLEAR_OPTIONS_FMASK);
472731c46edSAlex Elder 	}
473731c46edSAlex Elder 
474731c46edSAlex Elder 	cmd_payload = ipa_cmd_payload_alloc(ipa, &payload_addr);
475731c46edSAlex Elder 	payload = &cmd_payload->register_write;
476731c46edSAlex Elder 
477731c46edSAlex Elder 	payload->flags = cpu_to_le16(flags);
478731c46edSAlex Elder 	payload->offset = cpu_to_le16((u16)offset);
479731c46edSAlex Elder 	payload->value = cpu_to_le32(value);
480731c46edSAlex Elder 	payload->value_mask = cpu_to_le32(mask);
481731c46edSAlex Elder 	payload->clear_options = cpu_to_le32(options);
482731c46edSAlex Elder 
483731c46edSAlex Elder 	gsi_trans_cmd_add(trans, payload, sizeof(*payload), payload_addr,
4844de284b7SAlex Elder 			  opcode);
485731c46edSAlex Elder }
486731c46edSAlex Elder 
487731c46edSAlex Elder /* Skip IP packet processing on the next data transfer on a TX channel */
ipa_cmd_ip_packet_init_add(struct gsi_trans * trans,u8 endpoint_id)488731c46edSAlex Elder static void ipa_cmd_ip_packet_init_add(struct gsi_trans *trans, u8 endpoint_id)
489731c46edSAlex Elder {
490731c46edSAlex Elder 	struct ipa *ipa = container_of(trans->gsi, struct ipa, gsi);
491731c46edSAlex Elder 	enum ipa_cmd_opcode opcode = IPA_CMD_IP_PACKET_INIT;
492731c46edSAlex Elder 	struct ipa_cmd_ip_packet_init *payload;
493731c46edSAlex Elder 	union ipa_cmd_payload *cmd_payload;
494731c46edSAlex Elder 	dma_addr_t payload_addr;
495731c46edSAlex Elder 
496731c46edSAlex Elder 	cmd_payload = ipa_cmd_payload_alloc(ipa, &payload_addr);
497731c46edSAlex Elder 	payload = &cmd_payload->ip_packet_init;
498731c46edSAlex Elder 
499c84ddc11SAlex Elder 	if (ipa->version < IPA_VERSION_5_0) {
500c84ddc11SAlex Elder 		payload->dest_endpoint =
501c84ddc11SAlex Elder 			u8_encode_bits(endpoint_id,
502731c46edSAlex Elder 				       IPA_PACKET_INIT_DEST_ENDPOINT_FMASK);
503c84ddc11SAlex Elder 	} else {
504c84ddc11SAlex Elder 		payload->dest_endpoint = endpoint_id;
505c84ddc11SAlex Elder 	}
506731c46edSAlex Elder 
507731c46edSAlex Elder 	gsi_trans_cmd_add(trans, payload, sizeof(*payload), payload_addr,
5084de284b7SAlex Elder 			  opcode);
509731c46edSAlex Elder }
510731c46edSAlex Elder 
511731c46edSAlex Elder /* Use a DMA command to read or write a block of IPA-resident memory */
ipa_cmd_dma_shared_mem_add(struct gsi_trans * trans,u32 offset,u16 size,dma_addr_t addr,bool toward_ipa)512731c46edSAlex Elder void ipa_cmd_dma_shared_mem_add(struct gsi_trans *trans, u32 offset, u16 size,
513731c46edSAlex Elder 				dma_addr_t addr, bool toward_ipa)
514731c46edSAlex Elder {
515731c46edSAlex Elder 	struct ipa *ipa = container_of(trans->gsi, struct ipa, gsi);
516731c46edSAlex Elder 	enum ipa_cmd_opcode opcode = IPA_CMD_DMA_SHARED_MEM;
517731c46edSAlex Elder 	struct ipa_cmd_hw_dma_mem_mem *payload;
518731c46edSAlex Elder 	union ipa_cmd_payload *cmd_payload;
519731c46edSAlex Elder 	dma_addr_t payload_addr;
520731c46edSAlex Elder 	u16 flags;
521731c46edSAlex Elder 
522731c46edSAlex Elder 	/* size and offset must fit in 16 bit fields */
5235bc55884SAlex Elder 	WARN_ON(!size);
5245bc55884SAlex Elder 	WARN_ON(size > U16_MAX);
5255bc55884SAlex Elder 	WARN_ON(offset > U16_MAX || ipa->mem_offset > U16_MAX - offset);
526731c46edSAlex Elder 
527731c46edSAlex Elder 	offset += ipa->mem_offset;
528731c46edSAlex Elder 
529731c46edSAlex Elder 	cmd_payload = ipa_cmd_payload_alloc(ipa, &payload_addr);
530731c46edSAlex Elder 	payload = &cmd_payload->dma_shared_mem;
531731c46edSAlex Elder 
532731c46edSAlex Elder 	/* payload->clear_after_read was reserved prior to IPA v4.0.  It's
533731c46edSAlex Elder 	 * never needed for current code, so it's 0 regardless of version.
534731c46edSAlex Elder 	 */
535731c46edSAlex Elder 	payload->size = cpu_to_le16(size);
536731c46edSAlex Elder 	payload->local_addr = cpu_to_le16(offset);
537731c46edSAlex Elder 	/* payload->flags:
538731c46edSAlex Elder 	 *   direction:		0 = write to IPA, 1 read from IPA
539731c46edSAlex Elder 	 * Starting at v4.0 these are reserved; either way, all zero:
540731c46edSAlex Elder 	 *   pipeline clear:	0 = wait for pipeline clear (don't skip)
541731c46edSAlex Elder 	 *   clear_options:	0 = pipeline_clear_hps
542731c46edSAlex Elder 	 * Instead, for v4.0+ these are encoded in the opcode.  But again
543731c46edSAlex Elder 	 * since both values are 0 we won't bother OR'ing them in.
544731c46edSAlex Elder 	 */
545731c46edSAlex Elder 	flags = toward_ipa ? 0 : DMA_SHARED_MEM_FLAGS_DIRECTION_FMASK;
546731c46edSAlex Elder 	payload->flags = cpu_to_le16(flags);
547731c46edSAlex Elder 	payload->system_addr = cpu_to_le64(addr);
548731c46edSAlex Elder 
549731c46edSAlex Elder 	gsi_trans_cmd_add(trans, payload, sizeof(*payload), payload_addr,
5504de284b7SAlex Elder 			  opcode);
551731c46edSAlex Elder }
552731c46edSAlex Elder 
ipa_cmd_ip_tag_status_add(struct gsi_trans * trans)553792b75b1SAlex Elder static void ipa_cmd_ip_tag_status_add(struct gsi_trans *trans)
554731c46edSAlex Elder {
555731c46edSAlex Elder 	struct ipa *ipa = container_of(trans->gsi, struct ipa, gsi);
556731c46edSAlex Elder 	enum ipa_cmd_opcode opcode = IPA_CMD_IP_PACKET_TAG_STATUS;
557731c46edSAlex Elder 	struct ipa_cmd_ip_packet_tag_status *payload;
558731c46edSAlex Elder 	union ipa_cmd_payload *cmd_payload;
559731c46edSAlex Elder 	dma_addr_t payload_addr;
560731c46edSAlex Elder 
561731c46edSAlex Elder 	cmd_payload = ipa_cmd_payload_alloc(ipa, &payload_addr);
562731c46edSAlex Elder 	payload = &cmd_payload->ip_packet_tag_status;
563731c46edSAlex Elder 
564792b75b1SAlex Elder 	payload->tag = le64_encode_bits(0, IP_PACKET_TAG_STATUS_TAG_FMASK);
565731c46edSAlex Elder 
566731c46edSAlex Elder 	gsi_trans_cmd_add(trans, payload, sizeof(*payload), payload_addr,
5674de284b7SAlex Elder 			  opcode);
568731c46edSAlex Elder }
569731c46edSAlex Elder 
570731c46edSAlex Elder /* Issue a small command TX data transfer */
ipa_cmd_transfer_add(struct gsi_trans * trans)571070740d3SAlex Elder static void ipa_cmd_transfer_add(struct gsi_trans *trans)
572731c46edSAlex Elder {
573731c46edSAlex Elder 	struct ipa *ipa = container_of(trans->gsi, struct ipa, gsi);
574731c46edSAlex Elder 	enum ipa_cmd_opcode opcode = IPA_CMD_NONE;
575731c46edSAlex Elder 	union ipa_cmd_payload *payload;
576731c46edSAlex Elder 	dma_addr_t payload_addr;
577731c46edSAlex Elder 
578731c46edSAlex Elder 	/* Just transfer a zero-filled payload structure */
579731c46edSAlex Elder 	payload = ipa_cmd_payload_alloc(ipa, &payload_addr);
580731c46edSAlex Elder 
581731c46edSAlex Elder 	gsi_trans_cmd_add(trans, payload, sizeof(*payload), payload_addr,
5824de284b7SAlex Elder 			  opcode);
583731c46edSAlex Elder }
584731c46edSAlex Elder 
585aa56e3e5SAlex Elder /* Add immediate commands to a transaction to clear the hardware pipeline */
ipa_cmd_pipeline_clear_add(struct gsi_trans * trans)586aa56e3e5SAlex Elder void ipa_cmd_pipeline_clear_add(struct gsi_trans *trans)
587731c46edSAlex Elder {
588731c46edSAlex Elder 	struct ipa *ipa = container_of(trans->gsi, struct ipa, gsi);
5892c4bb809SAlex Elder 	struct ipa_endpoint *endpoint;
590731c46edSAlex Elder 
59151c48ce2SAlex Elder 	/* This will complete when the transfer is received */
59251c48ce2SAlex Elder 	reinit_completion(&ipa->completion);
59351c48ce2SAlex Elder 
594aa56e3e5SAlex Elder 	/* Issue a no-op register write command (mask 0 means no write) */
5952c4bb809SAlex Elder 	ipa_cmd_register_write_add(trans, 0, 0, 0, true);
596aa56e3e5SAlex Elder 
597aa56e3e5SAlex Elder 	/* Send a data packet through the IPA pipeline.  The packet_init
598aa56e3e5SAlex Elder 	 * command says to send the next packet directly to the exception
599aa56e3e5SAlex Elder 	 * endpoint without any other IPA processing.  The tag_status
600aa56e3e5SAlex Elder 	 * command requests that status be generated on completion of
601792b75b1SAlex Elder 	 * that transfer, and that it will be tagged with a value.
602aa56e3e5SAlex Elder 	 * Finally, the transfer command sends a small packet of data
603aa56e3e5SAlex Elder 	 * (instead of a command) using the command endpoint.
604aa56e3e5SAlex Elder 	 */
605aa56e3e5SAlex Elder 	endpoint = ipa->name_map[IPA_ENDPOINT_AP_LAN_RX];
606731c46edSAlex Elder 	ipa_cmd_ip_packet_init_add(trans, endpoint->endpoint_id);
607792b75b1SAlex Elder 	ipa_cmd_ip_tag_status_add(trans);
608070740d3SAlex Elder 	ipa_cmd_transfer_add(trans);
609731c46edSAlex Elder }
610731c46edSAlex Elder 
611aa56e3e5SAlex Elder /* Returns the number of commands required to clear the pipeline */
ipa_cmd_pipeline_clear_count(void)612aa56e3e5SAlex Elder u32 ipa_cmd_pipeline_clear_count(void)
613731c46edSAlex Elder {
614731c46edSAlex Elder 	return 4;
615731c46edSAlex Elder }
616731c46edSAlex Elder 
ipa_cmd_pipeline_clear_wait(struct ipa * ipa)61751c48ce2SAlex Elder void ipa_cmd_pipeline_clear_wait(struct ipa *ipa)
61851c48ce2SAlex Elder {
61951c48ce2SAlex Elder 	wait_for_completion(&ipa->completion);
62051c48ce2SAlex Elder }
62151c48ce2SAlex Elder 
622731c46edSAlex Elder /* Allocate a transaction for the command TX endpoint */
ipa_cmd_trans_alloc(struct ipa * ipa,u32 tre_count)623731c46edSAlex Elder struct gsi_trans *ipa_cmd_trans_alloc(struct ipa *ipa, u32 tre_count)
624731c46edSAlex Elder {
625731c46edSAlex Elder 	struct ipa_endpoint *endpoint;
6268797972aSAlex Elder 
6278797972aSAlex Elder 	if (WARN_ON(tre_count > IPA_COMMAND_TRANS_TRE_MAX))
6288797972aSAlex Elder 		return NULL;
629731c46edSAlex Elder 
630731c46edSAlex Elder 	endpoint = ipa->name_map[IPA_ENDPOINT_AP_COMMAND_TX];
631731c46edSAlex Elder 
6328797972aSAlex Elder 	return gsi_channel_trans_alloc(&ipa->gsi, endpoint->channel_id,
633731c46edSAlex Elder 				       tre_count, DMA_NONE);
634731c46edSAlex Elder }
6357fd10a2aSAlex Elder 
6367fd10a2aSAlex Elder /* Init function for immediate commands; there is no ipa_cmd_exit() */
ipa_cmd_init(struct ipa * ipa)6377fd10a2aSAlex Elder int ipa_cmd_init(struct ipa *ipa)
6387fd10a2aSAlex Elder {
6397fd10a2aSAlex Elder 	ipa_cmd_validate_build();
6407fd10a2aSAlex Elder 
6417fd10a2aSAlex Elder 	if (!ipa_cmd_header_init_local_valid(ipa))
6427fd10a2aSAlex Elder 		return -EINVAL;
6437fd10a2aSAlex Elder 
6447fd10a2aSAlex Elder 	if (!ipa_cmd_register_write_valid(ipa))
6457fd10a2aSAlex Elder 		return -EINVAL;
6467fd10a2aSAlex Elder 
6477fd10a2aSAlex Elder 	return 0;
6487fd10a2aSAlex Elder }
649