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