1 /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
6 #include <fsl_mc_sys.h>
7 #include <fsl_mc_cmd.h>
11 * dpkg_prepare_key_cfg() - function prepare extract parameters
12 * @cfg: defining a full Key Generation profile (rule)
13 * @key_cfg_buf: Zeroed 256 bytes of memory before mapping it to DMA
15 * This function has to be called before the following functions:
16 * - dpni_set_rx_tc_dist()
17 * - dpni_set_qos_table()
18 * - dpkg_prepare_key_cfg()
21 dpkg_prepare_key_cfg(const struct dpkg_profile_cfg *cfg, uint8_t *key_cfg_buf)
24 struct dpni_ext_set_rx_tc_dist *dpni_ext;
25 struct dpni_dist_extract *extr;
27 if (cfg->num_extracts > DPKG_MAX_NUM_OF_EXTRACTS)
30 dpni_ext = (struct dpni_ext_set_rx_tc_dist *)key_cfg_buf;
31 dpni_ext->num_extracts = cfg->num_extracts;
33 for (i = 0; i < cfg->num_extracts; i++) {
34 extr = &dpni_ext->extracts[i];
36 switch (cfg->extracts[i].type) {
37 case DPKG_EXTRACT_FROM_HDR:
38 extr->prot = cfg->extracts[i].extract.from_hdr.prot;
39 dpkg_set_field(extr->efh_type, EFH_TYPE,
40 cfg->extracts[i].extract.from_hdr.type);
41 extr->size = cfg->extracts[i].extract.from_hdr.size;
42 extr->offset = cfg->extracts[i].extract.from_hdr.offset;
43 extr->field = cpu_to_le32(
44 cfg->extracts[i].extract.from_hdr.field);
46 cfg->extracts[i].extract.from_hdr.hdr_index;
48 case DPKG_EXTRACT_FROM_DATA:
49 extr->size = cfg->extracts[i].extract.from_data.size;
51 cfg->extracts[i].extract.from_data.offset;
53 case DPKG_EXTRACT_FROM_PARSE:
54 extr->size = cfg->extracts[i].extract.from_parse.size;
56 cfg->extracts[i].extract.from_parse.offset;
62 extr->num_of_byte_masks = cfg->extracts[i].num_of_byte_masks;
63 dpkg_set_field(extr->extract_type, EXTRACT_TYPE,
64 cfg->extracts[i].type);
66 if (extr->num_of_byte_masks > DPKG_NUM_OF_MASKS)
69 for (j = 0; j < extr->num_of_byte_masks; j++) {
70 extr->masks[j].mask = cfg->extracts[i].masks[j].mask;
71 extr->masks[j].offset =
72 cfg->extracts[i].masks[j].offset;