Prepare v2023.10
[platform/kernel/u-boot.git] / include / fsl-mc / fsl_dpsparser.h
1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Data Path Soft Parser API
4  *
5  * Copyright 2018, 2023 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 #pragma pack(push, 1)
24
25 struct dpsparser_cmd_destroy {
26         __le32 dpsparser_id;
27 };
28
29 struct dpsparser_cmd_blob_set_address {
30         __le64 blob_addr;
31 };
32
33 struct dpsparser_rsp_blob_report_error {
34         __le16 error;
35 };
36
37 struct dpsparser_rsp_get_api_version {
38         __le16 major;
39         __le16 minor;
40 };
41
42 #pragma pack(pop)
43
44 /* Data Path Soft Parser API
45  * Contains initialization APIs and runtime control APIs for DPSPARSER
46  */
47
48 struct fsl_mc_io;
49
50 /* MC Unknown error: */
51 #define MC_ERROR_MSG_SPB_UNKNOWN        "Unknown MC error\n"
52
53 /* MC Error messages (in order for each error code defined above): */
54 #define MC_ERROR_MSG_APPLY_SPB \
55 { \
56         "OK\n", \
57         "BLOB : Magic number does not match\n", \
58         "BLOB : Version does not match MC API version\n", \
59         "BLOB : IP revision does not match HW revision\n", \
60         "BLOB : Blob length is not a multiple of 4\n", \
61         "BLOB : Invalid length detected\n", \
62         "BLOB : Name length < 0 in 'blob-name'\n", \
63         "BLOB : Name length not a 4 multiple in 'blob-name'\n", \
64         "BLOB : No target HW parser selected\n", \
65         "BLOB : SP size is negative\n", \
66         "BLOB : Size is zero\n", \
67         "BLOB : Number of protocols is negative\n", \
68         "BLOB : Zero protocols\n", \
69         "BLOB : Protocol name is null\n", \
70         "BLOB : SP 'seq-start' is not in [0x40, 0xffc0) range\n", \
71         "BLOB : Invalid base protocol\n", \
72         "BLOB : Invalid parameters section\n", \
73         "BLOB : Invalid parameter\n", \
74         "BLOB : Invalid parameter configuration\n", \
75         "BLOB : Not aligned value\n", \
76         "BLOB : Invalid section TAG detected\n", \
77         "BLOB : Section size is zero\n", \
78         "BLOB : Section size not a 4 multiple\n", \
79         "BLOB : Section size is too big\n", \
80         "BLOB : No 'bytecode' section before\n", \
81         "BLOB : No 'sp-protocols' section before\n", \
82         "BLOB : No 'bytecode' section defined\n", \
83         "BLOB : No 'sp-protocols' section defined\n", \
84         "BLOB : Soft Parser BLOB parsing : Error detected\n", \
85         "apply spb : Soft Parser BLOB is already applied\n", \
86         "apply spb : BLOB address is not set\n", \
87         "BLOB : SP parameter offset is not a 4 multiple\n", \
88         "BLOB : SP parameter offset can't be less than 0x40\n", \
89         "BLOB : Bytecode size is not a 4 multiple\n", \
90         "BLOB : Bytecode size cannot be zero\n", \
91         "BLOB : Bytecode can't overwrite the 0xFFE address\n", \
92         "BLOB : No hardware parser selected as target\n", \
93         "BLOB : Bytecode overlap detected\n", \
94         "BLOB : No parser support\n", \
95         "BLOB : Too many bytecode sections on WRIOP ingress\n", \
96         "BLOB : Too many bytecode sections on WRIOP egress\n", \
97         "BLOB : Too many bytecode sections on AIOP\n", \
98         "BLOB : Duplicated protocol is already registered\n", \
99         "BLOB : Maximum number of allowed protocols was exceeded\n", \
100         "BLOB : Protocols limit exceeded\n", \
101         "BLOB : Protocol is linked twice\n", \
102         "BLOB : Soft parser is linked twice\n", \
103         "BLOB : Parameter offset exceeds the maximum parameters limit\n", \
104         "BLOB : Parameter size can't be 0 or greater than 64\n", \
105         "BLOB : Parameter offset plus size exceeds the maximum limit\n", \
106         "BLOB : Parameters number exceeds the maximum limit\n", \
107         "BLOB : Duplicated parameter name\n", \
108         "BLOB : Parameters overlapped detected\n", \
109         "apply spb : No dpsparser handle.\n", \
110         \
111         MC_ERROR_MSG_SPB_UNKNOWN, \
112         NULL, \
113 }
114
115 int dpsparser_open(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 *token);
116
117 int dpsparser_close(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token);
118
119 int dpsparser_create(struct fsl_mc_io *mc_io, u16 token, u32 cmd_flags,
120                      u32 *obj_id);
121
122 int dpsparser_destroy(struct fsl_mc_io *mc_io, u16 token, u32 cmd_flags,
123                       u32 obj_id);
124
125 int dpsparser_apply_spb(struct fsl_mc_io *mc_io, u32 cmd_flags, u16 token,
126                         u64 blob_addr, u16 *error);
127
128 int dpsparser_get_api_version(struct fsl_mc_io *mc_io, u32 cmd_flags,
129                               u16 *major_ver, u16 *minor_ver);
130
131 #endif /* _FSL_DPSPARSER_H */