blob: 48fb495059ebe944b01c6b12c2cbf842374dbd1c [file] [log] [blame]
Florinel Iordacheae6d8522019-11-19 10:28:17 +00001/* SPDX-License-Identifier: GPL-2.0+ */
2/*
3 * Data Path Soft Parser API
4 *
5 * Copyright 2018 NXP
6 */
7#ifndef _FSL_DPSPARSER_H
8#define _FSL_DPSPARSER_H
9
10/* DPSPARSER last supported API version */
11#define DPSPARSER_VER_MAJOR 1
12#define DPSPARSER_VER_MINOR 0
13
14/* Command IDs */
15#define DPSPARSER_CMDID_CLOSE 0x8001
16#define DPSPARSER_CMDID_OPEN 0x8111
17#define DPSPARSER_CMDID_CREATE 0x9111
18#define DPSPARSER_CMDID_DESTROY 0x9911
19#define DPSPARSER_CMDID_GET_API_VERSION 0xa111
20
21#define DPSPARSER_CMDID_APPLY_SPB 0x1181
22
23/* cmd, param, offset, width, type, arg_name */
24#define DPSPARSER_CMD_BLOB_SET_ADDR(cmd, addr) \
25 MC_CMD_OP(cmd, 0, 0, 64, u64, addr)
26
27/* cmd, param, offset, width, type, arg_name */
28#define DPSPARSER_CMD_BLOB_REPORT_ERROR(cmd, err) \
29 MC_RSP_OP(cmd, 0, 0, 16, u16, err)
30
31/* Data Path Soft Parser API
32 * Contains initialization APIs and runtime control APIs for DPSPARSER
33 */
34
35struct fsl_mc_io;
36
37/* MC Unknown error: */
38#define MC_ERROR_MSG_SPB_UNKNOWN "Unknown MC error\n"
39
40/* MC Error messages (in order for each error code defined above): */
41#define MC_ERROR_MSG_APPLY_SPB \
42{ \
43 "OK\n", \
44 "BLOB : Magic number does not match\n", \
45 "BLOB : Version does not match MC API version\n", \
46 "BLOB : IP revision does not match HW revision\n", \
47 "BLOB : Blob length is not a multiple of 4\n", \
48 "BLOB : Invalid length detected\n", \
49 "BLOB : Name length < 0 in 'blob-name'\n", \
50 "BLOB : Name length not a 4 multiple in 'blob-name'\n", \
51 "BLOB : No target HW parser selected\n", \
52 "BLOB : SP size is negative\n", \
53 "BLOB : Size is zero\n", \
54 "BLOB : Number of protocols is negative\n", \
55 "BLOB : Zero protocols\n", \
56 "BLOB : Protocol name is null\n", \
57 "BLOB : SP 'seq-start' is not in [0x40, 0xffc0) range\n", \
58 "BLOB : Invalid base protocol\n", \
59 "BLOB : Invalid parameters section\n", \
60 "BLOB : Invalid parameter\n", \
61 "BLOB : Invalid parameter configuration\n", \
62 "BLOB : Not aligned value\n", \
63 "BLOB : Invalid section TAG detected\n", \
64 "BLOB : Section size is zero\n", \
65 "BLOB : Section size not a 4 multiple\n", \
66 "BLOB : Section size is too big\n", \
67 "BLOB : No 'bytecode' section before\n", \
68 "BLOB : No 'sp-protocols' section before\n", \
69 "BLOB : No 'bytecode' section defined\n", \
70 "BLOB : No 'sp-protocols' section defined\n", \
71 "BLOB : Soft Parser BLOB parsing : Error detected\n", \
72 "apply spb : Soft Parser BLOB is already applied\n", \
73 "apply spb : BLOB address is not set\n", \
74 "BLOB : SP parameter offset is not a 4 multiple\n", \
75 "BLOB : SP parameter offset can't be less than 0x40\n", \
76 "BLOB : Bytecode size is not a 4 multiple\n", \
77 "BLOB : Bytecode size cannot be zero\n", \
78 "BLOB : Bytecode can't overwrite the 0xFFE address\n", \
79 "BLOB : No hardware parser selected as target\n", \
80 "BLOB : Bytecode overlap detected\n", \
81 "BLOB : No parser support\n", \
82 "BLOB : Too many bytecode sections on WRIOP ingress\n", \
83 "BLOB : Too many bytecode sections on WRIOP egress\n", \
84 "BLOB : Too many bytecode sections on AIOP\n", \
85 "BLOB : Duplicated protocol is already registered\n", \
86 "BLOB : Maximum number of allowed protocols was exceeded\n", \
87 "BLOB : Protocols limit exceeded\n", \
88 "BLOB : Protocol is linked twice\n", \
89 "BLOB : Soft parser is linked twice\n", \
90 "BLOB : Parameter offset exceeds the maximum parameters limit\n", \
91 "BLOB : Parameter size can't be 0 or greater than 64\n", \
92 "BLOB : Parameter offset plus size exceeds the maximum limit\n", \
93 "BLOB : Parameters number exceeds the maximum limit\n", \
94 "BLOB : Duplicated parameter name\n", \
95 "BLOB : Parameters overlapped detected\n", \
96 "apply spb : No dpsparser handle.\n", \
97 \
98 MC_ERROR_MSG_SPB_UNKNOWN, \
99 NULL, \
100}
101
102/**
103 * dpsparser_open() - Open a control session for the specified object.
104 * @mc_io: Pointer to MC portal's I/O object
105 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
106 * @token: Returned token; use in subsequent API calls
107 *
108 * This function can be used to open a control session for an
109 * already created object; an object may have been declared in
110 * the DPL or by calling the dpsparser_create function.
111 * This function returns a unique authentication token,
112 * associated with the specific object ID and the specific MC
113 * portal; this token must be used in all subsequent commands for
114 * this specific object
115 *
116 * Return: '0' on Success; Error code otherwise.
117 */
118int dpsparser_open(struct fsl_mc_io *mc_io,
119 u32 cmd_flags,
120 u16 *token);
121
122/**
123 * dpsparser_close() - Close the control session of the object
124 * @mc_io: Pointer to MC portal's I/O object
125 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
126 * @token: Token of DPSPARSER object
127 *
128 * After this function is called, no further operations are
129 * allowed on the object without opening a new control session.
130 *
131 * Return: '0' on Success; Error code otherwise.
132 */
133int dpsparser_close(struct fsl_mc_io *mc_io,
134 u32 cmd_flags,
135 u16 token);
136
137/**
138 * dpsparser_create() - Create the DPSPARSER object.
139 * @mc_io: Pointer to MC portal's I/O object
140 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
141 * @token: Returned token; use in subsequent API calls
142 *
143 * Create the DPSPARSER object, allocate required resources and
144 * perform required initialization.
145 *
146 * The object can be created either by declaring it in the
147 * DPL file, or by calling this function.
148 * This function returns a unique authentication token,
149 * associated with the specific object ID and the specific MC
150 * portal; this token must be used in all subsequent calls to
151 * this specific object. For objects that are created using the
152 * DPL file, call dpsparser_open function to get an authentication
153 * token first.
154 *
155 * Return: '0' on Success; Error code otherwise.
156 */
157int dpsparser_create(struct fsl_mc_io *mc_io,
158 u16 token,
159 u32 cmd_flags,
160 u32 *obj_id);
161
162/**
163 * dpsparser_destroy() - Destroy the DPSPARSER object and release all its
164 * resources.
165 * @mc_io: Pointer to MC portal's I/O object
166 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
167 * @token: Token of DPSPARSER object
168 *
169 * Return: '0' on Success; error code otherwise.
170 */
171int dpsparser_destroy(struct fsl_mc_io *mc_io,
172 u16 token,
173 u32 cmd_flags,
174 u32 obj_id);
175
176/**
177 * dpsparser_apply_spb() - Applies the Soft Parser Blob loaded at specified
178 * address.
179 * @mc_io: Pointer to MC portal's I/O object
180 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
181 * @token: Token of DPSPARSER object
182 * @blob_addr: Blob loading address
183 * @error: Error reported by MC related to SP Blob parsing and apply
184 *
185 * Return: '0' on Success; error code otherwise.
186 */
187int dpsparser_apply_spb(struct fsl_mc_io *mc_io,
188 u32 cmd_flags,
189 u16 token,
190 u64 blob_addr,
191 u16 *error);
192
193/**
194 * dpsparser_get_api_version - Retrieve DPSPARSER Major and Minor version info.
195 *
196 * @mc_io: Pointer to MC portal's I/O object
197 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
198 * @major_ver: DPSPARSER major version
199 * @minor_ver: DPSPARSER minor version
200 *
201 * Return: '0' on Success; Error code otherwise.
202 */
203int dpsparser_get_api_version(struct fsl_mc_io *mc_io,
204 u32 cmd_flags,
205 u16 *major_ver,
206 u16 *minor_ver);
207
208#endif /* _FSL_DPSPARSER_H */