1 /* Copyright 2013-2015 Freescale Semiconductor Inc.
3 * Redistribution and use in source and binary forms, with or without
4 * modification, are permitted provided that the following conditions are met:
5 * * Redistributions of source code must retain the above copyright
6 * notice, this list of conditions and the following disclaimer.
7 * * Redistributions in binary form must reproduce the above copyright
8 * notice, this list of conditions and the following disclaimer in the
9 * documentation and/or other materials provided with the distribution.
10 * * Neither the name of the above-listed copyright holders nor the
11 * names of any contributors may be used to endorse or promote products
12 * derived from this software without specific prior written permission.
15 * ALTERNATIVELY, this software may be distributed under the terms of the
16 * GNU General Public License ("GPL") as published by the Free Software
17 * Foundation, either version 2 of that License or (at your option) any
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
24 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30 * POSSIBILITY OF SUCH DAMAGE.
35 #include <linux/types.h>
38 /* Data Path Key Generator API
39 * Contains initialization APIs and runtime APIs for the Key Generator
42 /** Key Generator properties */
45 * Number of masks per key extraction
47 #define DPKG_NUM_OF_MASKS 4
49 * Number of extractions per key profile
51 #define DPKG_MAX_NUM_OF_EXTRACTS 10
54 * enum dpkg_extract_from_hdr_type - Selecting extraction by header types
55 * @DPKG_FROM_HDR: Extract selected bytes from header, by offset
56 * @DPKG_FROM_FIELD: Extract selected bytes from header, by offset from field
57 * @DPKG_FULL_FIELD: Extract a full field
59 enum dpkg_extract_from_hdr_type {
66 * enum dpkg_extract_type - Enumeration for selecting extraction type
67 * @DPKG_EXTRACT_FROM_HDR: Extract from the header
68 * @DPKG_EXTRACT_FROM_DATA: Extract from data not in specific header
69 * @DPKG_EXTRACT_FROM_PARSE: Extract from parser-result;
70 * e.g. can be used to extract header existence;
71 * please refer to 'Parse Result definition' section in the parser BG
73 enum dpkg_extract_type {
74 DPKG_EXTRACT_FROM_HDR = 0,
75 DPKG_EXTRACT_FROM_DATA = 1,
76 DPKG_EXTRACT_FROM_PARSE = 3
80 * struct dpkg_mask - A structure for defining a single extraction mask
81 * @mask: Byte mask for the extracted content
82 * @offset: Offset within the extracted content
90 * struct dpkg_extract - A structure for defining a single extraction
91 * @type: Determines how the union below is interpreted:
92 * DPKG_EXTRACT_FROM_HDR: selects 'from_hdr';
93 * DPKG_EXTRACT_FROM_DATA: selects 'from_data';
94 * DPKG_EXTRACT_FROM_PARSE: selects 'from_parse'
95 * @extract: Selects extraction method
96 * @num_of_byte_masks: Defines the number of valid entries in the array below;
97 * This is also the number of bytes to be used as masks
98 * @masks: Masks parameters
100 struct dpkg_extract {
101 enum dpkg_extract_type type;
103 * union extract - Selects extraction method
104 * @from_hdr - Used when 'type = DPKG_EXTRACT_FROM_HDR'
105 * @from_data - Used when 'type = DPKG_EXTRACT_FROM_DATA'
106 * @from_parse - Used when 'type = DPKG_EXTRACT_FROM_PARSE'
110 * struct from_hdr - Used when 'type = DPKG_EXTRACT_FROM_HDR'
111 * @prot: Any of the supported headers
112 * @type: Defines the type of header extraction:
113 * DPKG_FROM_HDR: use size & offset below;
114 * DPKG_FROM_FIELD: use field, size and offset below;
115 * DPKG_FULL_FIELD: use field below
116 * @field: One of the supported fields (NH_FLD_)
118 * @size: Size in bytes
119 * @offset: Byte offset
120 * @hdr_index: Clear for cases not listed below;
121 * Used for protocols that may have more than a single
122 * header, 0 indicates an outer header;
123 * Supported protocols (possible values):
124 * NET_PROT_VLAN (0, HDR_INDEX_LAST);
125 * NET_PROT_MPLS (0, 1, HDR_INDEX_LAST);
126 * NET_PROT_IP(0, HDR_INDEX_LAST);
127 * NET_PROT_IPv4(0, HDR_INDEX_LAST);
128 * NET_PROT_IPv6(0, HDR_INDEX_LAST);
133 enum dpkg_extract_from_hdr_type type;
140 * struct from_data - Used when 'type = DPKG_EXTRACT_FROM_DATA'
141 * @size: Size in bytes
142 * @offset: Byte offset
150 * struct from_parse - Used when
151 * 'type = DPKG_EXTRACT_FROM_PARSE'
152 * @size: Size in bytes
153 * @offset: Byte offset
161 u8 num_of_byte_masks;
162 struct dpkg_mask masks[DPKG_NUM_OF_MASKS];
166 * struct dpkg_profile_cfg - A structure for defining a full Key Generation
168 * @num_extracts: Defines the number of valid entries in the array below
169 * @extracts: Array of required extractions
171 struct dpkg_profile_cfg {
173 struct dpkg_extract extracts[DPKG_MAX_NUM_OF_EXTRACTS];
176 #endif /* __FSL_DPKG_H_ */