2 * This file is provided under a dual BSD/GPLv2 license. When using or
3 * redistributing this file, you may do so under either license.
7 * Copyright 2013-2015 Freescale Semiconductor Inc.
8 * Copyright (c) 2016 NXP.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met:
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * * Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * * Neither the name of the above-listed copyright holders nor the
18 * names of any contributors may be used to endorse or promote products
19 * derived from this software without specific prior written permission.
23 * ALTERNATIVELY, this software may be distributed under the terms of the
24 * GNU General Public License ("GPL") as published by the Free Software
25 * Foundation, either version 2 of that License or (at your option) any
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
29 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
31 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
32 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
33 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
34 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
35 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
36 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
37 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
38 * POSSIBILITY OF SUCH DAMAGE.
45 /* Data Path Key Generator API
46 * Contains initialization APIs and runtime APIs for the Key Generator
49 /** Key Generator properties */
52 * Number of masks per key extraction
54 #define DPKG_NUM_OF_MASKS 4
56 * Number of extractions per key profile
58 #define DPKG_MAX_NUM_OF_EXTRACTS 10
61 * enum dpkg_extract_from_hdr_type - Selecting extraction by header types
62 * @DPKG_FROM_HDR: Extract selected bytes from header, by offset
63 * @DPKG_FROM_FIELD: Extract selected bytes from header, by offset from field
64 * @DPKG_FULL_FIELD: Extract a full field
66 enum dpkg_extract_from_hdr_type {
73 * enum dpkg_extract_type - Enumeration for selecting extraction type
74 * @DPKG_EXTRACT_FROM_HDR: Extract from the header
75 * @DPKG_EXTRACT_FROM_DATA: Extract from data not in specific header
76 * @DPKG_EXTRACT_FROM_PARSE: Extract from parser-result;
77 * e.g. can be used to extract header existence;
78 * please refer to 'Parse Result definition' section in the parser BG
80 enum dpkg_extract_type {
81 DPKG_EXTRACT_FROM_HDR = 0,
82 DPKG_EXTRACT_FROM_DATA = 1,
83 DPKG_EXTRACT_FROM_PARSE = 3
87 * struct dpkg_mask - A structure for defining a single extraction mask
88 * @mask: Byte mask for the extracted content
89 * @offset: Offset within the extracted content
97 * struct dpkg_extract - A structure for defining a single extraction
98 * @type: Determines how the union below is interpreted:
99 * DPKG_EXTRACT_FROM_HDR: selects 'from_hdr';
100 * DPKG_EXTRACT_FROM_DATA: selects 'from_data';
101 * DPKG_EXTRACT_FROM_PARSE: selects 'from_parse'
102 * @extract: Selects extraction method
103 * @num_of_byte_masks: Defines the number of valid entries in the array below;
104 * This is also the number of bytes to be used as masks
105 * @masks: Masks parameters
107 struct dpkg_extract {
108 enum dpkg_extract_type type;
110 * union extract - Selects extraction method
111 * @from_hdr - Used when 'type = DPKG_EXTRACT_FROM_HDR'
112 * @from_data - Used when 'type = DPKG_EXTRACT_FROM_DATA'
113 * @from_parse - Used when 'type = DPKG_EXTRACT_FROM_PARSE'
117 * struct from_hdr - Used when 'type = DPKG_EXTRACT_FROM_HDR'
118 * @prot: Any of the supported headers
119 * @type: Defines the type of header extraction:
120 * DPKG_FROM_HDR: use size & offset below;
121 * DPKG_FROM_FIELD: use field, size and offset below;
122 * DPKG_FULL_FIELD: use field below
123 * @field: One of the supported fields (NH_FLD_)
125 * @size: Size in bytes
126 * @offset: Byte offset
127 * @hdr_index: Clear for cases not listed below;
128 * Used for protocols that may have more than a single
129 * header, 0 indicates an outer header;
130 * Supported protocols (possible values):
131 * NET_PROT_VLAN (0, HDR_INDEX_LAST);
132 * NET_PROT_MPLS (0, 1, HDR_INDEX_LAST);
133 * NET_PROT_IP(0, HDR_INDEX_LAST);
134 * NET_PROT_IPv4(0, HDR_INDEX_LAST);
135 * NET_PROT_IPv6(0, HDR_INDEX_LAST);
140 enum dpkg_extract_from_hdr_type type;
148 * Used when 'type = DPKG_EXTRACT_FROM_DATA'
149 * @size: Size in bytes
150 * @offset: Byte offset
159 * Used when 'type = DPKG_EXTRACT_FROM_PARSE'
160 * @size: Size in bytes
161 * @offset: Byte offset
169 uint8_t num_of_byte_masks;
170 struct dpkg_mask masks[DPKG_NUM_OF_MASKS];
174 * struct dpkg_profile_cfg - A structure for defining a full Key Generation
176 * @num_extracts: Defines the number of valid entries in the array below
177 * @extracts: Array of required extractions
179 struct dpkg_profile_cfg {
180 uint8_t num_extracts;
181 struct dpkg_extract extracts[DPKG_MAX_NUM_OF_EXTRACTS];
184 #endif /* __FSL_DPKG_H_ */