LCOV - code coverage report
Current view: top level - drivers/net/dpaa2/mc - dpkg.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 31 0.0 %
Date: 2025-02-01 18:54:23 Functions: 0 1 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 14 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: (BSD-3-Clause OR GPL-2.0)
       2                 :            :  *
       3                 :            :  * Copyright 2017-2021, 2023 NXP
       4                 :            :  *
       5                 :            :  */
       6                 :            : #include <fsl_mc_sys.h>
       7                 :            : #include <fsl_mc_cmd.h>
       8                 :            : #include <fsl_dpkg.h>
       9                 :            : #include <string.h>
      10                 :            : 
      11                 :            : /**
      12                 :            :  * dpkg_prepare_key_cfg() - function prepare extract parameters
      13                 :            :  * @cfg: defining a full Key Generation profile (rule)
      14                 :            :  * @key_cfg_buf: Zeroed memory whose size is sizeo of
      15                 :            :  *              "struct dpni_ext_set_rx_tc_dist" before mapping it to DMA
      16                 :            :  *
      17                 :            :  * This function has to be called before the following functions:
      18                 :            :  *      - dpni_set_rx_tc_dist()
      19                 :            :  *      - dpni_set_qos_table()
      20                 :            :  *      - dpkg_prepare_key_cfg()
      21                 :            :  */
      22                 :            : int
      23                 :          0 : dpkg_prepare_key_cfg(const struct dpkg_profile_cfg *cfg,
      24                 :            :         void *key_cfg_buf)
      25                 :            : {
      26                 :            :         int i, j;
      27                 :            :         struct dpni_ext_set_rx_tc_dist *dpni_ext;
      28                 :            :         struct dpni_dist_extract *extr;
      29                 :            : 
      30         [ #  # ]:          0 :         if (cfg->num_extracts > DPKG_MAX_NUM_OF_EXTRACTS)
      31                 :            :                 return -EINVAL;
      32                 :            : 
      33                 :            :         dpni_ext = key_cfg_buf;
      34                 :          0 :         dpni_ext->num_extracts = cfg->num_extracts;
      35                 :            : 
      36         [ #  # ]:          0 :         for (i = 0; i < cfg->num_extracts; i++) {
      37   [ #  #  #  # ]:          0 :                 extr = &dpni_ext->extracts[i];
      38                 :            :                 memset(extr, 0, sizeof(struct dpni_dist_extract));
      39                 :            : 
      40   [ #  #  #  # ]:          0 :                 switch (cfg->extracts[i].type) {
      41                 :          0 :                 case DPKG_EXTRACT_FROM_HDR:
      42                 :          0 :                         extr->prot = cfg->extracts[i].extract.from_hdr.prot;
      43                 :          0 :                         dpkg_set_field(extr->efh_type, EFH_TYPE,
      44                 :            :                                        cfg->extracts[i].extract.from_hdr.type);
      45                 :          0 :                         extr->size = cfg->extracts[i].extract.from_hdr.size;
      46                 :          0 :                         extr->offset = cfg->extracts[i].extract.from_hdr.offset;
      47                 :          0 :                         extr->field = cpu_to_le32(
      48                 :            :                                 cfg->extracts[i].extract.from_hdr.field);
      49                 :          0 :                         extr->hdr_index =
      50                 :          0 :                                 cfg->extracts[i].extract.from_hdr.hdr_index;
      51                 :          0 :                         break;
      52                 :          0 :                 case DPKG_EXTRACT_FROM_DATA:
      53                 :          0 :                         extr->size = cfg->extracts[i].extract.from_data.size;
      54                 :          0 :                         extr->offset =
      55                 :          0 :                                 cfg->extracts[i].extract.from_data.offset;
      56                 :          0 :                         break;
      57                 :          0 :                 case DPKG_EXTRACT_FROM_PARSE:
      58                 :          0 :                         extr->size = cfg->extracts[i].extract.from_parse.size;
      59                 :          0 :                         extr->offset =
      60                 :          0 :                                 cfg->extracts[i].extract.from_parse.offset;
      61                 :          0 :                         break;
      62                 :            :                 default:
      63                 :            :                         return -EINVAL;
      64                 :            :                 }
      65                 :            : 
      66                 :          0 :                 extr->num_of_byte_masks = cfg->extracts[i].num_of_byte_masks;
      67                 :          0 :                 dpkg_set_field(extr->extract_type, EXTRACT_TYPE,
      68                 :            :                                cfg->extracts[i].type);
      69                 :            : 
      70         [ #  # ]:          0 :                 for (j = 0; j < DPKG_NUM_OF_MASKS; j++) {
      71                 :          0 :                         extr->masks[j].mask = cfg->extracts[i].masks[j].mask;
      72                 :          0 :                         extr->masks[j].offset =
      73                 :          0 :                                 cfg->extracts[i].masks[j].offset;
      74                 :            :                 }
      75                 :            :         }
      76                 :            : 
      77                 :            :         return 0;
      78                 :            : }

Generated by: LCOV version 1.14