xref: /OK3568_Linux_fs/external/rkwifibt/drivers/infineon/include/bcmiov.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun  * bcmiov.h
3*4882a593Smuzhiyun  * Common iovar handling/parsing support - batching, parsing, sub-cmd dispatch etc.
4*4882a593Smuzhiyun  * To be used in firmware and host apps or dhd - reducing code size,
5*4882a593Smuzhiyun  * duplication, and maintenance overhead.
6*4882a593Smuzhiyun  *
7*4882a593Smuzhiyun  * Portions of this code are copyright (c) 2021 Cypress Semiconductor Corporation
8*4882a593Smuzhiyun  *
9*4882a593Smuzhiyun  * Copyright (C) 1999-2017, Broadcom Corporation
10*4882a593Smuzhiyun  *
11*4882a593Smuzhiyun  *      Unless you and Broadcom execute a separate written software license
12*4882a593Smuzhiyun  * agreement governing use of this software, this software is licensed to you
13*4882a593Smuzhiyun  * under the terms of the GNU General Public License version 2 (the "GPL"),
14*4882a593Smuzhiyun  * available at http://www.broadcom.com/licenses/GPLv2.php, with the
15*4882a593Smuzhiyun  * following added to such license:
16*4882a593Smuzhiyun  *
17*4882a593Smuzhiyun  *      As a special exception, the copyright holders of this software give you
18*4882a593Smuzhiyun  * permission to link this software with independent modules, and to copy and
19*4882a593Smuzhiyun  * distribute the resulting executable under terms of your choice, provided that
20*4882a593Smuzhiyun  * you also meet, for each linked independent module, the terms and conditions of
21*4882a593Smuzhiyun  * the license of that module.  An independent module is a module which is not
22*4882a593Smuzhiyun  * derived from this software.  The special exception does not apply to any
23*4882a593Smuzhiyun  * modifications of the software.
24*4882a593Smuzhiyun  *
25*4882a593Smuzhiyun  *      Notwithstanding the above, under no circumstances may you combine this
26*4882a593Smuzhiyun  * software in any way with any other Broadcom software provided under a license
27*4882a593Smuzhiyun  * other than the GPL, without Broadcom's express prior written consent.
28*4882a593Smuzhiyun  *
29*4882a593Smuzhiyun  *
30*4882a593Smuzhiyun  * <<Broadcom-WL-IPTag/Open:>>
31*4882a593Smuzhiyun  *
32*4882a593Smuzhiyun  * $Id$
33*4882a593Smuzhiyun  */
34*4882a593Smuzhiyun 
35*4882a593Smuzhiyun #ifndef _bcmiov_h_
36*4882a593Smuzhiyun #define _bcmiov_h_
37*4882a593Smuzhiyun 
38*4882a593Smuzhiyun #include <typedefs.h>
39*4882a593Smuzhiyun #include <bcmutils.h>
40*4882a593Smuzhiyun #include <wlioctl.h>
41*4882a593Smuzhiyun #ifdef BCMDRIVER
42*4882a593Smuzhiyun #include <osl.h>
43*4882a593Smuzhiyun #else
44*4882a593Smuzhiyun #include <stddef.h>  /* For size_t */
45*4882a593Smuzhiyun #endif /* BCMDRIVER */
46*4882a593Smuzhiyun 
47*4882a593Smuzhiyun /* Forward declarations */
48*4882a593Smuzhiyun typedef uint16 bcm_iov_cmd_id_t;
49*4882a593Smuzhiyun typedef uint16 bcm_iov_cmd_flags_t;
50*4882a593Smuzhiyun typedef uint16 bcm_iov_cmd_mflags_t;
51*4882a593Smuzhiyun typedef struct bcm_iov_cmd_info bcm_iov_cmd_info_t;
52*4882a593Smuzhiyun typedef struct bcm_iov_cmd_digest bcm_iov_cmd_digest_t;
53*4882a593Smuzhiyun typedef struct bcm_iov_cmd_tlv_info bcm_iov_cmd_tlv_info_t;
54*4882a593Smuzhiyun typedef struct bcm_iov_buf bcm_iov_buf_t;
55*4882a593Smuzhiyun typedef struct bcm_iov_batch_buf bcm_iov_batch_buf_t;
56*4882a593Smuzhiyun typedef struct bcm_iov_parse_context bcm_iov_parse_context_t;
57*4882a593Smuzhiyun typedef struct bcm_iov_sub_cmd_context bcm_iov_sub_cmd_context_t;
58*4882a593Smuzhiyun 
59*4882a593Smuzhiyun typedef void* (*bcm_iov_malloc_t)(void* alloc_ctx, size_t len);
60*4882a593Smuzhiyun typedef void (*bcm_iov_free_t)(void* alloc_ctx, void *buf, size_t len);
61*4882a593Smuzhiyun 
62*4882a593Smuzhiyun typedef uint8 bcm_iov_tlp_data_type_t;
63*4882a593Smuzhiyun typedef struct bcm_iov_tlp bcm_iov_tlp_t;
64*4882a593Smuzhiyun typedef struct bcm_iov_tlp_node bcm_iov_tlp_node_t;
65*4882a593Smuzhiyun typedef struct bcm_iov_batch_subcmd bcm_iov_batch_subcmd_t;
66*4882a593Smuzhiyun 
67*4882a593Smuzhiyun /*
68*4882a593Smuzhiyun  * iov validation handler - All the common checks that are required
69*4882a593Smuzhiyun  * for processing of iovars for any given command.
70*4882a593Smuzhiyun  */
71*4882a593Smuzhiyun typedef int (*bcm_iov_cmd_validate_t)(const bcm_iov_cmd_digest_t *dig,
72*4882a593Smuzhiyun 	uint32 actionid, const uint8* ibuf, size_t ilen, uint8 *obuf, size_t *olen);
73*4882a593Smuzhiyun 
74*4882a593Smuzhiyun /* iov get handler - process subcommand specific input and return output.
75*4882a593Smuzhiyun  * input and output may overlap, so the callee needs to check if
76*4882a593Smuzhiyun  * that is supported. For xtlv data a tlv digest is provided to make
77*4882a593Smuzhiyun  * parsing simpler. Output tlvs may be packed into output buffer using
78*4882a593Smuzhiyun  * bcm xtlv support. olen is input/output parameter. On input contains
79*4882a593Smuzhiyun  * max available obuf length and callee must fill the correct length
80*4882a593Smuzhiyun  * to represent the length of output returned.
81*4882a593Smuzhiyun  */
82*4882a593Smuzhiyun typedef int (*bcm_iov_cmd_get_t)(const bcm_iov_cmd_digest_t *dig,
83*4882a593Smuzhiyun 	const uint8* ibuf, size_t ilen, uint8 *obuf, size_t *olen);
84*4882a593Smuzhiyun 
85*4882a593Smuzhiyun /* iov set handler - process subcommand specific input and return output
86*4882a593Smuzhiyun  * input and output may overlap, so the callee needs to check if
87*4882a593Smuzhiyun  * that is supported. olen is input/output parameter. On input contains
88*4882a593Smuzhiyun  * max available obuf length and callee must fill the correct length
89*4882a593Smuzhiyun  * to represent the length of output returned.
90*4882a593Smuzhiyun  */
91*4882a593Smuzhiyun typedef int (*bcm_iov_cmd_set_t)(const bcm_iov_cmd_digest_t *dig,
92*4882a593Smuzhiyun 	const uint8* ibuf, size_t ilen, uint8 *obuf, size_t *olen);
93*4882a593Smuzhiyun 
94*4882a593Smuzhiyun /* iov (sub-cmd) batch - a vector of commands. count can be zero
95*4882a593Smuzhiyun  * to support a version query. Each command is a tlv - whose data
96*4882a593Smuzhiyun  * portion may have an optional return status, followed by a fixed
97*4882a593Smuzhiyun  * length data header, optionally followed by tlvs.
98*4882a593Smuzhiyun  *    cmd = type|length|<status|options>[header][tlvs]
99*4882a593Smuzhiyun  */
100*4882a593Smuzhiyun 
101*4882a593Smuzhiyun /*
102*4882a593Smuzhiyun  * Batch sub-commands have status length included in the
103*4882a593Smuzhiyun  * response length packed in TLV.
104*4882a593Smuzhiyun  */
105*4882a593Smuzhiyun #define BCM_IOV_STATUS_LEN sizeof(uint32)
106*4882a593Smuzhiyun 
107*4882a593Smuzhiyun /* batch version is indicated by setting high bit. */
108*4882a593Smuzhiyun #define BCM_IOV_BATCH_MASK 0x8000
109*4882a593Smuzhiyun 
110*4882a593Smuzhiyun /*
111*4882a593Smuzhiyun  * Batched commands will have the following memory layout
112*4882a593Smuzhiyun  * +--------+---------+--------+-------+
113*4882a593Smuzhiyun  * |version |count    | is_set |sub-cmd|
114*4882a593Smuzhiyun  * +--------+---------+--------+-------+
115*4882a593Smuzhiyun  * version >= 0x8000
116*4882a593Smuzhiyun  * count = number of sub-commands encoded in the iov buf
117*4882a593Smuzhiyun  * sub-cmd one or more sub-commands for processing
118*4882a593Smuzhiyun  * Where sub-cmd is padded byte buffer with memory layout as follows
119*4882a593Smuzhiyun  * +--------+---------+-----------------------+-------------+------
120*4882a593Smuzhiyun  * |cmd-id  |length   |IN(options) OUT(status)|command data |......
121*4882a593Smuzhiyun  * +--------+---------+-----------------------+-------------+------
122*4882a593Smuzhiyun  * cmd-id =sub-command ID
123*4882a593Smuzhiyun  * length = length of this sub-command
124*4882a593Smuzhiyun  * IN(options) = On input processing options/flags for this command
125*4882a593Smuzhiyun  * OUT(status) on output processing status for this command
126*4882a593Smuzhiyun  * command data = encapsulated IOVAR data as a single structure or packed TLVs for each
127*4882a593Smuzhiyun  * individual sub-command.
128*4882a593Smuzhiyun  */
129*4882a593Smuzhiyun struct bcm_iov_batch_subcmd {
130*4882a593Smuzhiyun 	uint16 id;
131*4882a593Smuzhiyun 	uint16 len;
132*4882a593Smuzhiyun 	union {
133*4882a593Smuzhiyun 		uint32 options;
134*4882a593Smuzhiyun 		uint32 status;
135*4882a593Smuzhiyun 	} u;
136*4882a593Smuzhiyun 	uint8 data[1];
137*4882a593Smuzhiyun };
138*4882a593Smuzhiyun 
139*4882a593Smuzhiyun struct bcm_iov_batch_buf {
140*4882a593Smuzhiyun 	uint16 version;
141*4882a593Smuzhiyun 	uint8 count;
142*4882a593Smuzhiyun 	uint8 is_set; /* to differentiate set or get */
143*4882a593Smuzhiyun 	struct bcm_iov_batch_subcmd cmds[0];
144*4882a593Smuzhiyun };
145*4882a593Smuzhiyun 
146*4882a593Smuzhiyun /* non-batched command version = major|minor w/ major <= 127 */
147*4882a593Smuzhiyun struct bcm_iov_buf {
148*4882a593Smuzhiyun 	uint16 version;
149*4882a593Smuzhiyun 	uint16 len;
150*4882a593Smuzhiyun 	bcm_iov_cmd_id_t id;
151*4882a593Smuzhiyun 	uint16 data[1]; /* 32 bit alignment may be repurposed by the command */
152*4882a593Smuzhiyun 	/* command specific data follows */
153*4882a593Smuzhiyun };
154*4882a593Smuzhiyun 
155*4882a593Smuzhiyun /* iov options flags */
156*4882a593Smuzhiyun enum {
157*4882a593Smuzhiyun 	BCM_IOV_CMD_OPT_ALIGN_NONE = 0x0000,
158*4882a593Smuzhiyun 	BCM_IOV_CMD_OPT_ALIGN32 = 0x0001,
159*4882a593Smuzhiyun 	BCM_IOV_CMD_OPT_TERMINATE_SUB_CMDS = 0x0002
160*4882a593Smuzhiyun };
161*4882a593Smuzhiyun 
162*4882a593Smuzhiyun /* iov command flags */
163*4882a593Smuzhiyun enum {
164*4882a593Smuzhiyun 	BCM_IOV_CMD_FLAG_NONE = 0,
165*4882a593Smuzhiyun 	BCM_IOV_CMD_FLAG_STATUS_PRESENT = (1 << 0), /* status present at data start - output only */
166*4882a593Smuzhiyun 	BCM_IOV_CMD_FLAG_XTLV_DATA = (1 << 1),  /* data is a set of xtlvs */
167*4882a593Smuzhiyun 	BCM_IOV_CMD_FLAG_HDR_IN_LEN = (1 << 2), /* length starts at version - non-bacthed only */
168*4882a593Smuzhiyun 	BCM_IOV_CMD_FLAG_NOPAD = (1 << 3) /* No padding needed after iov_buf */
169*4882a593Smuzhiyun };
170*4882a593Smuzhiyun 
171*4882a593Smuzhiyun /* information about the command, xtlv options and xtlvs_off are meaningful
172*4882a593Smuzhiyun  * only if XTLV_DATA cmd flag is selected
173*4882a593Smuzhiyun  */
174*4882a593Smuzhiyun struct bcm_iov_cmd_info {
175*4882a593Smuzhiyun 	bcm_iov_cmd_id_t	cmd;		/* the (sub)command - module specific */
176*4882a593Smuzhiyun 	bcm_iov_cmd_flags_t	flags;		/* checked by bcmiov but set by module */
177*4882a593Smuzhiyun 	bcm_iov_cmd_mflags_t	mflags;		/* owned and checked by module */
178*4882a593Smuzhiyun 	bcm_xtlv_opts_t		xtlv_opts;
179*4882a593Smuzhiyun 	bcm_iov_cmd_validate_t	validate_h;	/* command validation handler */
180*4882a593Smuzhiyun 	bcm_iov_cmd_get_t	get_h;
181*4882a593Smuzhiyun 	bcm_iov_cmd_set_t	set_h;
182*4882a593Smuzhiyun 	uint16			xtlvs_off;	/* offset to beginning of xtlvs in cmd data */
183*4882a593Smuzhiyun 	uint16			min_len_set;
184*4882a593Smuzhiyun 	uint16			max_len_set;
185*4882a593Smuzhiyun 	uint16			min_len_get;
186*4882a593Smuzhiyun 	uint16			max_len_get;
187*4882a593Smuzhiyun };
188*4882a593Smuzhiyun 
189*4882a593Smuzhiyun /* tlv digest to support parsing of xtlvs for commands w/ tlv data; the tlv
190*4882a593Smuzhiyun  * digest is available in the handler for the command. The count and order in
191*4882a593Smuzhiyun  * which tlvs appear in the digest are exactly the same as the order of tlvs
192*4882a593Smuzhiyun  * passed in the registration for the command. Unknown tlvs are ignored.
193*4882a593Smuzhiyun  * If registered tlvs are missing datap will be NULL. common iov rocessing
194*4882a593Smuzhiyun  * acquires an input digest to process input buffer. The handler is responsible
195*4882a593Smuzhiyun  * for constructing an output digest and use packing functions to generate
196*4882a593Smuzhiyun  * the output buffer. The handler may use the input digest as output digest once
197*4882a593Smuzhiyun  * the tlv data is extracted and used. Multiple tlv support involves allocation of
198*4882a593Smuzhiyun  * tlp nodes, except the first, as required,
199*4882a593Smuzhiyun  */
200*4882a593Smuzhiyun 
201*4882a593Smuzhiyun /* tlp data type indicates if the data is not used/invalid, input or output */
202*4882a593Smuzhiyun enum {
203*4882a593Smuzhiyun 	BCM_IOV_TLP_NODE_INVALID = 0,
204*4882a593Smuzhiyun 	BCM_IOV_TLP_NODE_IN = 1,
205*4882a593Smuzhiyun 	BCM_IOV_TLP_NODE_OUT = 2
206*4882a593Smuzhiyun };
207*4882a593Smuzhiyun 
208*4882a593Smuzhiyun struct bcm_iov_tlp {
209*4882a593Smuzhiyun 	uint16 type;
210*4882a593Smuzhiyun 	uint16 len;
211*4882a593Smuzhiyun 	uint16 nodeix;	/* node index */
212*4882a593Smuzhiyun };
213*4882a593Smuzhiyun 
214*4882a593Smuzhiyun /* tlp data for a given tlv - multiple tlvs of same type chained */
215*4882a593Smuzhiyun struct bcm_iov_tlp_node {
216*4882a593Smuzhiyun 	uint8 *next;	/* multiple tlv support */
217*4882a593Smuzhiyun 	bcm_iov_tlp_data_type_t type;
218*4882a593Smuzhiyun 	uint8 *data;	/* pointer to data in buffer or state */
219*4882a593Smuzhiyun };
220*4882a593Smuzhiyun 
221*4882a593Smuzhiyun struct bcm_iov_cmd_digest {
222*4882a593Smuzhiyun 	uint32 version;		/* Version */
223*4882a593Smuzhiyun 	void *cmd_ctx;
224*4882a593Smuzhiyun 	struct wlc_bsscfg *bsscfg;
225*4882a593Smuzhiyun 	const bcm_iov_cmd_info_t *cmd_info;
226*4882a593Smuzhiyun 	uint16 max_tlps;	/* number of tlps allocated */
227*4882a593Smuzhiyun 	uint16 max_nodes;	/* number of nods allocated */
228*4882a593Smuzhiyun 	uint16 num_tlps;	/* number of tlps valid */
229*4882a593Smuzhiyun 	uint16 num_nodes;	/* number of nods valid */
230*4882a593Smuzhiyun 	uint16 tlps_off;	/* offset to tlps */
231*4882a593Smuzhiyun 	uint16 nodes_off;	/* offset to nodes */
232*4882a593Smuzhiyun 	/*
233*4882a593Smuzhiyun 	 * bcm_iov_tlp_t tlps[max_tlps];
234*4882a593Smuzhiyun 	 * bcm_iov_tlp_node_t nodes[max_nodes]
235*4882a593Smuzhiyun 	*/
236*4882a593Smuzhiyun };
237*4882a593Smuzhiyun 
238*4882a593Smuzhiyun /* get length callback - default length is min_len taken from digest */
239*4882a593Smuzhiyun typedef size_t (*bcm_iov_xtlv_get_len_t)(const bcm_iov_cmd_digest_t *dig,
240*4882a593Smuzhiyun 	const bcm_iov_cmd_tlv_info_t *tlv_info);
241*4882a593Smuzhiyun 
242*4882a593Smuzhiyun /* pack to buffer data callback. under some conditions it might
243*4882a593Smuzhiyun  * not be a straight copy and can refer to context(ual) information and
244*4882a593Smuzhiyun  * endian conversions...
245*4882a593Smuzhiyun  */
246*4882a593Smuzhiyun typedef void (*bcm_iov_xtlv_pack_t)(const bcm_iov_cmd_digest_t *dig,
247*4882a593Smuzhiyun 	const bcm_iov_cmd_tlv_info_t *tlv_info,
248*4882a593Smuzhiyun 	uint8 *out_buf, const uint8 *in_data, size_t len);
249*4882a593Smuzhiyun 
250*4882a593Smuzhiyun struct bcm_iov_cmd_tlv_info {
251*4882a593Smuzhiyun 	uint16 id;
252*4882a593Smuzhiyun 	uint16 min_len; /* inclusive */
253*4882a593Smuzhiyun 	uint16 max_len; /* inclusive */
254*4882a593Smuzhiyun 	bcm_iov_xtlv_get_len_t get_len;
255*4882a593Smuzhiyun 	bcm_iov_xtlv_pack_t pack;
256*4882a593Smuzhiyun };
257*4882a593Smuzhiyun 
258*4882a593Smuzhiyun /*
259*4882a593Smuzhiyun  * module private parse context. Default version type len is uint16
260*4882a593Smuzhiyun  */
261*4882a593Smuzhiyun enum {
262*4882a593Smuzhiyun 	BCM_IOV_PARSE_CMD_NONE = 0
263*4882a593Smuzhiyun };
264*4882a593Smuzhiyun typedef uint32 parse_context_opts_t;
265*4882a593Smuzhiyun 
266*4882a593Smuzhiyun /* get digest callback */
267*4882a593Smuzhiyun typedef int (*bcm_iov_get_digest_t)(void *cmd_ctx, bcm_iov_cmd_digest_t **dig);
268*4882a593Smuzhiyun 
269*4882a593Smuzhiyun typedef struct bcm_iov_parse_config {
270*4882a593Smuzhiyun 	parse_context_opts_t options; /* to handle different ver lengths */
271*4882a593Smuzhiyun 	bcm_iov_malloc_t alloc_fn;
272*4882a593Smuzhiyun 	bcm_iov_free_t free_fn;
273*4882a593Smuzhiyun 	bcm_iov_get_digest_t dig_fn;
274*4882a593Smuzhiyun 	int max_regs;
275*4882a593Smuzhiyun 	void *alloc_ctx;
276*4882a593Smuzhiyun } bcm_iov_parse_config_t;
277*4882a593Smuzhiyun 
278*4882a593Smuzhiyun /* API */
279*4882a593Smuzhiyun 
280*4882a593Smuzhiyun /* All calls return an integer status code BCME_* unless otherwise indicated */
281*4882a593Smuzhiyun 
282*4882a593Smuzhiyun /* return length of allocation for 'num_cmds' commands. data_len
283*4882a593Smuzhiyun  * includes length of data for all the commands excluding the headers
284*4882a593Smuzhiyun  */
285*4882a593Smuzhiyun size_t bcm_iov_get_alloc_len(int num_cmds, size_t data_len);
286*4882a593Smuzhiyun 
287*4882a593Smuzhiyun /* create parsing context using allocator provided; max_regs provides
288*4882a593Smuzhiyun  * the number of allowed registrations for commands using the context
289*4882a593Smuzhiyun  * sub-components of a module may register their own commands indepdently
290*4882a593Smuzhiyun  * using the parsing context. If digest callback is NULL or returns NULL,
291*4882a593Smuzhiyun  * the (input) digest is allocated using the provided allocators and released on
292*4882a593Smuzhiyun  * completion of processing.
293*4882a593Smuzhiyun  */
294*4882a593Smuzhiyun int bcm_iov_create_parse_context(const bcm_iov_parse_config_t *parse_cfg,
295*4882a593Smuzhiyun 	bcm_iov_parse_context_t **parse_ctx);
296*4882a593Smuzhiyun 
297*4882a593Smuzhiyun /* free the parsing context; ctx is set to NULL on exit */
298*4882a593Smuzhiyun int bcm_iov_free_parse_context(bcm_iov_parse_context_t **ctx, bcm_iov_free_t free_fn);
299*4882a593Smuzhiyun 
300*4882a593Smuzhiyun /* Return the command context for the module */
301*4882a593Smuzhiyun void *bcm_iov_get_cmd_ctx_info(bcm_iov_parse_context_t *parse_ctx);
302*4882a593Smuzhiyun 
303*4882a593Smuzhiyun /* register a command info vector along with supported tlvs. Each command
304*4882a593Smuzhiyun  * may support a subset of tlvs
305*4882a593Smuzhiyun  */
306*4882a593Smuzhiyun int bcm_iov_register_commands(bcm_iov_parse_context_t *parse_ctx, void *cmd_ctx,
307*4882a593Smuzhiyun 	const bcm_iov_cmd_info_t *info, size_t num_cmds,
308*4882a593Smuzhiyun 	const bcm_iov_cmd_tlv_info_t *tlv_info, size_t num_tlvs);
309*4882a593Smuzhiyun 
310*4882a593Smuzhiyun /* pack the xtlvs provided in the digest. may returns BCME_BUFTOOSHORT, but the
311*4882a593Smuzhiyun  * out_len is set to required length in that case.
312*4882a593Smuzhiyun  */
313*4882a593Smuzhiyun int bcm_iov_pack_xtlvs(const bcm_iov_cmd_digest_t *dig,  bcm_xtlv_opts_t xtlv_opts,
314*4882a593Smuzhiyun 	uint8 *out_buf, size_t out_size, size_t *out_len);
315*4882a593Smuzhiyun 
316*4882a593Smuzhiyun #ifdef BCMDRIVER
317*4882a593Smuzhiyun /* wlc modules register their iovar(s) using the parsing context w/ wlc layer
318*4882a593Smuzhiyun  * during attach.
319*4882a593Smuzhiyun  */
320*4882a593Smuzhiyun struct wlc_if;
321*4882a593Smuzhiyun struct wlc_info;
322*4882a593Smuzhiyun extern struct wlc_bsscfg *bcm_iov_bsscfg_find_from_wlcif(struct wlc_info *wlc,
323*4882a593Smuzhiyun 	struct wlc_if *wlcif);
324*4882a593Smuzhiyun int bcm_iov_doiovar(void *parse_ctx, uint32 id, void *params, uint params_len,
325*4882a593Smuzhiyun     void *arg, uint arg_len, uint vsize, struct wlc_if *intf);
326*4882a593Smuzhiyun #endif /* BCMDRIVER */
327*4882a593Smuzhiyun 
328*4882a593Smuzhiyun /* parsing context helpers */
329*4882a593Smuzhiyun 
330*4882a593Smuzhiyun /* get the maximum number of tlvs - can be used to allocate digest for all
331*4882a593Smuzhiyun  * commands. the digest can be shared. Negative values are BCM_*, >=0, the
332*4882a593Smuzhiyun  * number of tlvs
333*4882a593Smuzhiyun  */
334*4882a593Smuzhiyun int  bcm_iov_parse_get_max_tlvs(const bcm_iov_parse_context_t *ctx);
335*4882a593Smuzhiyun 
336*4882a593Smuzhiyun /* common packing support */
337*4882a593Smuzhiyun 
338*4882a593Smuzhiyun /* pack a buffer of uint8s - memcpy wrapper */
339*4882a593Smuzhiyun int bcm_iov_pack_buf(const bcm_iov_cmd_digest_t *dig, uint8 *buf,
340*4882a593Smuzhiyun 	const uint8 *data, size_t len);
341*4882a593Smuzhiyun 
342*4882a593Smuzhiyun #define bcm_iov_packv_u8 bcm_iov_pack_buf
343*4882a593Smuzhiyun 
344*4882a593Smuzhiyun /*
345*4882a593Smuzhiyun  * pack a buffer with uint16s - serialized in LE order, data points to uint16
346*4882a593Smuzhiyun  * length is not checked.
347*4882a593Smuzhiyun  */
348*4882a593Smuzhiyun int bcm_iov_packv_u16(const bcm_iov_cmd_digest_t *dig, uint8 *buf,
349*4882a593Smuzhiyun 	const uint16 *data, int n);
350*4882a593Smuzhiyun 
351*4882a593Smuzhiyun /*
352*4882a593Smuzhiyun  * pack a buffer with uint32s - serialized in LE order - data points to uint32
353*4882a593Smuzhiyun  * length is not checked.
354*4882a593Smuzhiyun  */
355*4882a593Smuzhiyun int bcm_iov_packv_u32(const bcm_iov_cmd_digest_t *dig, uint8 *buf,
356*4882a593Smuzhiyun 	const uint32 *data, int n);
357*4882a593Smuzhiyun 
358*4882a593Smuzhiyun #endif /* _bcmiov_h_ */
359