aboutsummaryrefslogtreecommitdiff
path: root/include/fsl-mc/fsl_dpsparser.h
blob: 48fb495059ebe944b01c6b12c2cbf842374dbd1c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
/* SPDX-License-Identifier: GPL-2.0+ */
/*
 * Data Path Soft Parser API
 *
 * Copyright 2018 NXP
 */
#ifndef _FSL_DPSPARSER_H
#define _FSL_DPSPARSER_H

/* DPSPARSER last supported API version */
#define DPSPARSER_VER_MAJOR				1
#define DPSPARSER_VER_MINOR				0

/* Command IDs */
#define DPSPARSER_CMDID_CLOSE				0x8001
#define DPSPARSER_CMDID_OPEN				0x8111
#define DPSPARSER_CMDID_CREATE				0x9111
#define DPSPARSER_CMDID_DESTROY				0x9911
#define DPSPARSER_CMDID_GET_API_VERSION			0xa111

#define DPSPARSER_CMDID_APPLY_SPB			0x1181

/*                cmd, param, offset, width, type, arg_name */
#define DPSPARSER_CMD_BLOB_SET_ADDR(cmd, addr) \
	MC_CMD_OP(cmd, 0, 0,  64, u64,	    addr)

/*                cmd, param, offset, width, type,	arg_name */
#define DPSPARSER_CMD_BLOB_REPORT_ERROR(cmd, err) \
	MC_RSP_OP(cmd, 0, 0, 16, u16, err)

/* Data Path Soft Parser API
 * Contains initialization APIs and runtime control APIs for DPSPARSER
 */

struct fsl_mc_io;

/* MC Unknown error: */
#define MC_ERROR_MSG_SPB_UNKNOWN	"Unknown MC error\n"

/* MC Error messages (in order for each error code defined above): */
#define MC_ERROR_MSG_APPLY_SPB \
{ \
	"OK\n", \
	"BLOB : Magic number does not match\n", \
	"BLOB : Version does not match MC API version\n", \
	"BLOB : IP revision does not match HW revision\n", \
	"BLOB : Blob length is not a multiple of 4\n", \
	"BLOB : Invalid length detected\n", \
	"BLOB : Name length < 0 in 'blob-name'\n", \
	"BLOB : Name length not a 4 multiple in 'blob-name'\n", \
	"BLOB : No target HW parser selected\n", \
	"BLOB : SP size is negative\n", \
	"BLOB : Size is zero\n", \
	"BLOB : Number of protocols is negative\n", \
	"BLOB : Zero protocols\n", \
	"BLOB : Protocol name is null\n", \
	"BLOB : SP 'seq-start' is not in [0x40, 0xffc0) range\n", \
	"BLOB : Invalid base protocol\n", \
	"BLOB : Invalid parameters section\n", \
	"BLOB : Invalid parameter\n", \
	"BLOB : Invalid parameter configuration\n", \
	"BLOB : Not aligned value\n", \
	"BLOB : Invalid section TAG detected\n", \
	"BLOB : Section size is zero\n", \
	"BLOB : Section size not a 4 multiple\n", \
	"BLOB : Section size is too big\n", \
	"BLOB : No 'bytecode' section before\n", \
	"BLOB : No 'sp-protocols' section before\n", \
	"BLOB : No 'bytecode' section defined\n", \
	"BLOB : No 'sp-protocols' section defined\n", \
	"BLOB : Soft Parser BLOB parsing : Error detected\n", \
	"apply spb : Soft Parser BLOB is already applied\n", \
	"apply spb : BLOB address is not set\n", \
	"BLOB : SP parameter offset is not a 4 multiple\n", \
	"BLOB : SP parameter offset can't be less than 0x40\n", \
	"BLOB : Bytecode size is not a 4 multiple\n", \
	"BLOB : Bytecode size cannot be zero\n", \
	"BLOB : Bytecode can't overwrite the 0xFFE address\n", \
	"BLOB : No hardware parser selected as target\n", \
	"BLOB : Bytecode overlap detected\n", \
	"BLOB : No parser support\n", \
	"BLOB : Too many bytecode sections on WRIOP ingress\n", \
	"BLOB : Too many bytecode sections on WRIOP egress\n", \
	"BLOB : Too many bytecode sections on AIOP\n", \
	"BLOB : Duplicated protocol is already registered\n", \
	"BLOB : Maximum number of allowed protocols was exceeded\n", \
	"BLOB : Protocols limit exceeded\n", \
	"BLOB : Protocol is linked twice\n", \
	"BLOB : Soft parser is linked twice\n", \
	"BLOB : Parameter offset exceeds the maximum parameters limit\n", \
	"BLOB : Parameter size can't be 0 or greater than 64\n", \
	"BLOB : Parameter offset plus size exceeds the maximum limit\n", \
	"BLOB : Parameters number exceeds the maximum limit\n", \
	"BLOB : Duplicated parameter name\n", \
	"BLOB : Parameters overlapped detected\n", \
	"apply spb : No dpsparser handle.\n", \
	\
	MC_ERROR_MSG_SPB_UNKNOWN, \
	NULL, \
}

/**
 * dpsparser_open() - Open a control session for the specified object.
 * @mc_io:	Pointer to MC portal's I/O object
 * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
 * @token:	Returned token; use in subsequent API calls
 *
 * This function can be used to open a control session for an
 * already created object; an object may have been declared in
 * the DPL or by calling the dpsparser_create function.
 * This function returns a unique authentication token,
 * associated with the specific object ID and the specific MC
 * portal; this token must be used in all subsequent commands for
 * this specific object
 *
 * Return:	'0' on Success; Error code otherwise.
 */
int dpsparser_open(struct fsl_mc_io	*mc_io,
		   u32 cmd_flags,
		   u16 *token);

/**
 * dpsparser_close() - Close the control session of the object
 * @mc_io:	Pointer to MC portal's I/O object
 * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
 * @token:	Token of DPSPARSER object
 *
 * After this function is called, no further operations are
 * allowed on the object without opening a new control session.
 *
 * Return:	'0' on Success; Error code otherwise.
 */
int dpsparser_close(struct fsl_mc_io *mc_io,
		    u32 cmd_flags,
		    u16	token);

/**
 * dpsparser_create() - Create the DPSPARSER object.
 * @mc_io:	Pointer to MC portal's I/O object
 * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
 * @token:	Returned token; use in subsequent API calls
 *
 * Create the DPSPARSER object, allocate required resources and
 * perform required initialization.
 *
 * The object can be created either by declaring it in the
 * DPL file, or by calling this function.
 * This function returns a unique authentication token,
 * associated with the specific object ID and the specific MC
 * portal; this token must be used in all subsequent calls to
 * this specific object. For objects that are created using the
 * DPL file, call dpsparser_open function to get an authentication
 * token first.
 *
 * Return:	'0' on Success; Error code otherwise.
 */
int dpsparser_create(struct fsl_mc_io *mc_io,
		     u16 token,
		     u32 cmd_flags,
		     u32 *obj_id);

/**
 * dpsparser_destroy() - Destroy the DPSPARSER object and release all its
 * resources.
 * @mc_io:	Pointer to MC portal's I/O object
 * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
 * @token:	Token of DPSPARSER object
 *
 * Return:	'0' on Success; error code otherwise.
 */
int dpsparser_destroy(struct fsl_mc_io *mc_io,
		      u16 token,
		      u32 cmd_flags,
		      u32 obj_id);

/**
 * dpsparser_apply_spb() - Applies the Soft Parser Blob loaded at specified
 * address.
 * @mc_io:	Pointer to MC portal's I/O object
 * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
 * @token:	Token of DPSPARSER object
 * @blob_addr:	Blob loading address
 * @error: Error reported by MC related to SP Blob parsing and apply
 *
 * Return:	'0' on Success; error code otherwise.
 */
int dpsparser_apply_spb(struct fsl_mc_io *mc_io,
			u32 cmd_flags,
			u16 token,
			u64 blob_addr,
			u16 *error);

/**
 * dpsparser_get_api_version - Retrieve DPSPARSER Major and Minor version info.
 *
 * @mc_io:	Pointer to MC portal's I/O object
 * @cmd_flags:	Command flags; one or more of 'MC_CMD_FLAG_'
 * @major_ver:	DPSPARSER major version
 * @minor_ver:	DPSPARSER minor version
 *
 * Return:	'0' on Success; Error code otherwise.
 */
int dpsparser_get_api_version(struct fsl_mc_io *mc_io,
			      u32 cmd_flags,
			      u16 *major_ver,
			      u16 *minor_ver);

#endif /* _FSL_DPSPARSER_H */