xref: /dpdk/drivers/net/dpaa2/dpaa2_sparser.h (revision 68a03efeed657e6e05f281479b33b51102797e15)
1 /* * SPDX-License-Identifier: BSD-3-Clause
2  *   Copyright 2018-2019 NXP
3  */
4 
5 /**
6  * @file	dpaa2_sparser.h
7  *
8  * @brief	Soft parser related macros & functions support for DPAA2 device
9  *	framework based applications.
10  *
11  */
12 
13 #ifndef _DPAA2_SPARSER_H
14 #define _DPAA2_SPARSER_H
15 
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
19 
20 #define WRIOP_SS_INITIALIZER(priv)				\
21 do {								\
22 	/* Base offset of parse profile memory in WRIOP */	\
23 	(priv)->ss_offset = 0x20;				\
24 	(priv)->ss_iova	= (size_t)NULL;			\
25 	(priv)->ss_param_iova = (size_t)NULL;			\
26 } while (0)
27 
28 /**************************************************************************/
29 /*
30  * @enum   parser_starting_hxs_code
31  * @Description PARSER Starting HXS code
32  */
33 /***************************************************************************/
34 enum parser_starting_hxs_code {
35 	/** Ethernet Starting HXS coding */
36 	PARSER_ETH_STARTING_HXS = 0x0000,
37 	/** LLC+SNAP Starting HXS coding */
38 	PARSER_LLC_SNAP_STARTING_HXS = 0x0001,
39 	/** VLAN Starting HXS coding */
40 	PARSER_VLAN_STARTING_HXS = 0x0002,
41 	/** PPPoE+PPP Starting HXS coding */
42 	PARSER_PPPOE_PPP_STARTING_HXS = 0x0003,
43 	/** MPLS Starting HXS coding */
44 	PARSER_MPLS_STARTING_HXS = 0x0004,
45 	/** ARP Starting HXS coding */
46 	PARSER_ARP_STARTING_HXS = 0x0005,
47 	/** IP Starting HXS coding */
48 	PARSER_IP_STARTING_HXS  = 0x0006,
49 	/** IPv4 Starting HXS coding */
50 	PARSER_IPV4_STARTING_HXS = 0x0007,
51 	/** IPv6 Starting HXS coding */
52 	PARSER_IPV6_STARTING_HXS = 0x0008,
53 	/** GRE Starting HXS coding */
54 	PARSER_GRE_STARTING_HXS = 0x0009,
55 	/** MinEncap Starting HXS coding */
56 	PARSER_MINENCAP_STARTING_HXS = 0x000A,
57 	/** Other L3 Shell Starting HXS coding */
58 	PARSER_OTHER_L3_SHELL_STARTING_HXS = 0x000B,
59 	/** TCP Starting HXS coding */
60 	PARSER_TCP_STARTING_HXS = 0x000C,
61 	/** UDP Starting HXS coding */
62 	PARSER_UDP_STARTING_HXS = 0x000D,
63 	/** IPSec Starting HXS coding */
64 	PARSER_IPSEC_STARTING_HXS = 0x000E,
65 	/** SCTP Starting HXS coding */
66 	PARSER_SCTP_STARTING_HXS = 0x000F,
67 	/** DCCP Starting HXS coding */
68 	PARSER_DCCP_STARTING_HXS = 0x0010,
69 	/** Other L4 Shell Starting HXS coding */
70 	PARSER_OTHER_L4_SHELL_STARTING_HXS = 0x0011,
71 	/** GTP Starting HXS coding */
72 	PARSER_GTP_STARTING_HXS = 0x0012,
73 	/** ESP Starting HXS coding */
74 	PARSER_ESP_STARTING_HXS = 0x0013,
75 	/** VXLAN Starting HXS coding */
76 	PARSER_VXLAN_STARTING_HXS = 0x0014,
77 	/** L5 (and above) Shell Starting HXS coding */
78 	PARSER_L5_SHELL_STARTING_HXS = 0x001E,
79 	/** Final Shell Starting HXS coding */
80 	PARSER_FINAL_SHELL_STARTING_HXS = 0x001F
81 };
82 
83 /**************************************************************************/
84 /*
85  * @Description    struct dpni_drv_sparser_param - Structure representing the
86  *			information needed to activate(enable) a Soft Parser.
87  */
88 /***************************************************************************/
89 
90 struct dpni_drv_sparser_param {
91 	/* The "custom_header_first" must be set if the custom header to parse
92 	 * is the first header in the packet, otherwise "custom_header_first"
93 	 * must be cleared.
94 	 */
95 	uint8_t             custom_header_first;
96 	/* Hard HXS on which a soft parser is activated. This must be
97 	 * configured.
98 	 * if the header to parse is not the first header in the packet.
99 	 */
100 	enum parser_starting_hxs_code   link_to_hard_hxs;
101 	/* Soft Sequence Start PC */
102 	uint16_t            start_pc;
103 	/* Soft Sequence byte-code */
104 	uint8_t             *byte_code;
105 	/* Soft Sequence size */
106 	uint16_t            size;
107 	/* Pointer to the Parameters Array of the SP */
108 	uint8_t             *param_array;
109 	/* Parameters offset */
110 	uint8_t             param_offset;
111 	/* Parameters size */
112 	uint8_t             param_size;
113 };
114 
115 struct sp_parse_result {
116 	/* Next header */
117 	uint16_t    nxt_hdr;
118 	/* Frame Attribute Flags Extension */
119 	uint16_t    frame_attribute_flags_extension;
120 	/* Frame Attribute Flags (part 1) */
121 	uint32_t    frame_attribute_flags_1;
122 	/* Frame Attribute Flags (part 2) */
123 	uint32_t    frame_attribute_flags_2;
124 	/* Frame Attribute Flags (part 3) */
125 	uint32_t    frame_attribute_flags_3;
126 	/* Shim Offset 1 */
127 	uint8_t     shim_offset_1;
128 	/* Shim Offset 2 */
129 	uint8_t     shim_offset_2;
130 	/* Outer IP protocol field offset */
131 	uint8_t     ip_1_pid_offset;
132 	/* Ethernet offset */
133 	uint8_t     eth_offset;
134 	/* LLC+SNAP offset */
135 	uint8_t     llc_snap_offset;
136 	/* First VLAN's TCI field offset*/
137 	uint8_t     vlan_tci1_offset;
138 	/* Last VLAN's TCI field offset*/
139 	uint8_t     vlan_tcin_offset;
140 	/* Last Ethertype offset*/
141 	uint8_t     last_etype_offset;
142 	/* PPPoE offset */
143 	uint8_t     pppoe_offset;
144 	/* First MPLS offset */
145 	uint8_t     mpls_offset_1;
146 	/* Last MPLS offset */
147 	uint8_t     mpls_offset_n;
148 	/* Layer 3 (Outer IP, ARP, FCoE or FIP) offset */
149 	uint8_t     l3_offset;
150 	/* Inner IP or MinEncap offset*/
151 	uint8_t     ipn_or_minencap_offset;
152 	/* GRE offset */
153 	uint8_t     gre_offset;
154 	/* Layer 4 offset*/
155 	uint8_t     l4_offset;
156 	/* Layer 5 offset */
157 	uint8_t     l5_offset;
158 	/* Routing header offset of 1st IPv6 header */
159 	uint8_t     routing_hdr_offset1;
160 	/* Routing header offset of 2nd IPv6 header */
161 	uint8_t     routing_hdr_offset2;
162 	/* Next header offset */
163 	uint8_t     nxt_hdr_offset;
164 	/* IPv6 fragmentable part offset */
165 	uint8_t     ipv6_frag_offset;
166 	/* Frame's untouched running sum, input to parser */
167 	uint16_t    gross_running_sum;
168 	/* Running Sum */
169 	uint16_t    running_sum;
170 	/* Parse Error code */
171 	uint8_t     parse_error_code;
172 	/* Offset to the next header field before IPv6 fragment extension */
173 	uint8_t     nxt_hdr_before_ipv6_frag_ext;
174 	/* Inner IP Protocol field offset */
175 	uint8_t     ip_n_pid_offset;
176 	/* Reserved for Soft parsing context*/
177 	uint8_t     soft_parsing_context[21];
178 };
179 
180 struct frame_attr {
181 	const char *fld_name;
182 	uint8_t     faf_offset;
183 	uint32_t    fld_mask;
184 };
185 
186 struct frame_attr_ext {
187 	const char *fld_name;
188 	uint8_t     faf_ext_offset;
189 	uint16_t    fld_mask;
190 };
191 
192 
193 struct parse_err {
194 	uint16_t    code;
195 	const char *err_name;
196 };
197 
198 /* Macro definitions */
199 #define IS_ONE_BIT_FIELD(_mask)                 \
200 (!((_mask) & ((_mask) - 1)) || (_mask == 1))
201 
202 int dpaa2_eth_load_wriop_soft_parser(struct dpaa2_dev_priv *priv,
203 		enum dpni_soft_sequence_dest dest);
204 int dpaa2_eth_enable_wriop_soft_parser(struct dpaa2_dev_priv *priv,
205 		enum dpni_soft_sequence_dest dest);
206 #endif /* _DPAA2_SPARSER_H_ */
207