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.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * * Neither the name of the above-listed copyright holders nor the
17 * names of any contributors may be used to endorse or promote products
18 * derived from this software without specific prior written permission.
22 * ALTERNATIVELY, this software may be distributed under the terms of the
23 * GNU General Public License ("GPL") as published by the Free Software
24 * Foundation, either version 2 of that License or (at your option) any
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
28 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
29 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
30 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
31 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
32 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
33 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
34 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
35 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
36 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 * POSSIBILITY OF SUCH DAMAGE.
39 #include <fsl_mc_sys.h>
40 #include <fsl_mc_cmd.h>
44 * dpkg_prepare_key_cfg() - function prepare extract parameters
45 * @cfg: defining a full Key Generation profile (rule)
46 * @key_cfg_buf: Zeroed 256 bytes of memory before mapping it to DMA
48 * This function has to be called before the following functions:
49 * - dpni_set_rx_tc_dist()
50 * - dpni_set_qos_table()
51 * - dpkg_prepare_key_cfg()
54 dpkg_prepare_key_cfg(const struct dpkg_profile_cfg *cfg, uint8_t *key_cfg_buf)
57 struct dpni_ext_set_rx_tc_dist *dpni_ext;
58 struct dpni_dist_extract *extr;
60 if (cfg->num_extracts > DPKG_MAX_NUM_OF_EXTRACTS)
63 dpni_ext = (struct dpni_ext_set_rx_tc_dist *)key_cfg_buf;
64 dpni_ext->num_extracts = cfg->num_extracts;
66 for (i = 0; i < cfg->num_extracts; i++) {
67 extr = &dpni_ext->extracts[i];
69 switch (cfg->extracts[i].type) {
70 case DPKG_EXTRACT_FROM_HDR:
71 extr->prot = cfg->extracts[i].extract.from_hdr.prot;
72 dpkg_set_field(extr->efh_type, EFH_TYPE,
73 cfg->extracts[i].extract.from_hdr.type);
74 extr->size = cfg->extracts[i].extract.from_hdr.size;
75 extr->offset = cfg->extracts[i].extract.from_hdr.offset;
76 extr->field = cpu_to_le32(
77 cfg->extracts[i].extract.from_hdr.field);
79 cfg->extracts[i].extract.from_hdr.hdr_index;
81 case DPKG_EXTRACT_FROM_DATA:
82 extr->size = cfg->extracts[i].extract.from_data.size;
84 cfg->extracts[i].extract.from_data.offset;
86 case DPKG_EXTRACT_FROM_PARSE:
87 extr->size = cfg->extracts[i].extract.from_parse.size;
89 cfg->extracts[i].extract.from_parse.offset;
95 extr->num_of_byte_masks = cfg->extracts[i].num_of_byte_masks;
96 dpkg_set_field(extr->extract_type, EXTRACT_TYPE,
97 cfg->extracts[i].type);
99 for (j = 0; j < DPKG_NUM_OF_MASKS; j++) {
100 extr->masks[j].mask = cfg->extracts[i].masks[j].mask;
101 extr->masks[j].offset =
102 cfg->extracts[i].masks[j].offset;