LCOV - code coverage report
Current view: top level - drivers/net/intel/cpfl - cpfl_rules.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 0 41 0.0 %
Date: 2025-03-01 20:23:48 Functions: 0 4 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 7 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2001-2023 Intel Corporation
       3                 :            :  */
       4                 :            : 
       5                 :            : #include <base/idpf_controlq.h>
       6                 :            : #include <stdint.h>
       7                 :            : #include "cpfl_rules.h"
       8                 :            : 
       9                 :            :  /**
      10                 :            :   * cpfl_prep_rule_desc_common_ctx - get bit common context for descriptor
      11                 :            :   */
      12                 :            : static inline uint64_t
      13                 :          0 : cpfl_prep_rule_desc_common_ctx(struct cpfl_rule_cfg_data_common *cmn_cfg)
      14                 :            : {
      15                 :            :         uint64_t context = 0;
      16                 :            : 
      17         [ #  # ]:          0 :         switch (cmn_cfg->opc) {
      18                 :          0 :         case cpfl_ctlq_mod_query_rule:
      19                 :            :         case cpfl_ctlq_mod_add_update_rule:
      20                 :            :                 /* fallthrough */
      21                 :            :         case cpfl_ctlq_sem_query_rule_hash_addr:
      22                 :            :         case cpfl_ctlq_sem_query_del_rule_hash_addr:
      23                 :            :         case cpfl_ctlq_sem_add_rule:
      24                 :            :         case cpfl_ctlq_sem_del_rule:
      25                 :            :         case cpfl_ctlq_sem_query_rule:
      26                 :            :         case cpfl_ctlq_sem_update_rule:
      27                 :          0 :                 context |= SHIFT_VAL64(cmn_cfg->time_sel,
      28                 :            :                                        MEV_RULE_TIME_SEL);
      29                 :          0 :                 context |= SHIFT_VAL64(cmn_cfg->time_sel_val,
      30                 :            :                                        MEV_RULE_TIME_SEL_VAL);
      31                 :          0 :                 context |= SHIFT_VAL64(cmn_cfg->host_id,
      32                 :            :                                        MEV_RULE_HOST_ID);
      33                 :          0 :                 context |= SHIFT_VAL64(cmn_cfg->port_num,
      34                 :            :                                        MEV_RULE_PORT_NUM);
      35                 :          0 :                 context |= SHIFT_VAL64(cmn_cfg->resp_req,
      36                 :            :                                        MEV_RULE_RESP_REQ);
      37                 :          0 :                 context |= SHIFT_VAL64(cmn_cfg->cache_wr_thru,
      38                 :            :                                        MEV_RULE_CACHE_WR_THRU);
      39                 :          0 :                 break;
      40                 :            :         default:
      41                 :            :                 break;
      42                 :            :         }
      43                 :            : 
      44                 :          0 :         return context;
      45                 :            : }
      46                 :            : 
      47                 :            : /**
      48                 :            :  * cpfl_prep_rule_desc_ctx - get bit context for descriptor
      49                 :            :  */
      50                 :            : static inline uint64_t
      51                 :          0 : cpfl_prep_rule_desc_ctx(struct cpfl_rule_cfg_data *cfg_data)
      52                 :            : {
      53                 :            :         uint64_t context = 0;
      54                 :            : 
      55                 :          0 :         context |= cpfl_prep_rule_desc_common_ctx(&cfg_data->common);
      56                 :            : 
      57      [ #  #  # ]:          0 :         switch (cfg_data->common.opc) {
      58                 :          0 :         case cpfl_ctlq_mod_query_rule:
      59                 :            :         case cpfl_ctlq_mod_add_update_rule:
      60                 :          0 :                 context |= SHIFT_VAL64(cfg_data->ext.mod_content.obj_size,
      61                 :            :                                        MEV_RULE_MOD_OBJ_SIZE);
      62                 :          0 :                 context |= SHIFT_VAL64(cfg_data->ext.mod_content.pin_content,
      63                 :            :                                        MEV_RULE_PIN_MOD_CONTENT);
      64                 :          0 :                 context |= SHIFT_VAL64(cfg_data->ext.mod_content.index,
      65                 :            :                                        MEV_RULE_MOD_INDEX);
      66                 :          0 :                 break;
      67                 :          0 :         case cpfl_ctlq_sem_query_rule_hash_addr:
      68                 :            :         case cpfl_ctlq_sem_query_del_rule_hash_addr:
      69                 :          0 :                 context |= SHIFT_VAL64(cfg_data->ext.query_del_addr.obj_id,
      70                 :            :                                        MEV_RULE_OBJ_ID);
      71                 :          0 :                 context |= SHIFT_VAL64(cfg_data->ext.query_del_addr.obj_addr,
      72                 :            :                                        MEV_RULE_OBJ_ADDR);
      73                 :          0 :                 break;
      74                 :            :         default:
      75                 :            :                 break;
      76                 :            :         }
      77                 :            : 
      78                 :          0 :         return context;
      79                 :            : }
      80                 :            : 
      81                 :            : /**
      82                 :            :  * cpfl_prep_rule_desc - build descriptor data from rule config data
      83                 :            :  *
      84                 :            :  * note: call this function before sending rule to HW via fast path
      85                 :            :  */
      86                 :            : void
      87                 :          0 : cpfl_prep_rule_desc(struct cpfl_rule_cfg_data *cfg_data,
      88                 :            :                     struct idpf_ctlq_msg *ctlq_msg)
      89                 :            : {
      90                 :            :         uint64_t context;
      91                 :            :         uint64_t *ctlq_ctx = (uint64_t *)&ctlq_msg->ctx.indirect.context[0];
      92                 :            : 
      93                 :          0 :         context = cpfl_prep_rule_desc_ctx(cfg_data);
      94                 :          0 :         *ctlq_ctx = CPU_TO_LE64(context);
      95                 :          0 :         memcpy(&ctlq_msg->cookie, &cfg_data->common.cookie, sizeof(uint64_t));
      96                 :          0 :         ctlq_msg->opcode = (uint16_t)cfg_data->common.opc;
      97                 :          0 :         ctlq_msg->data_len = cfg_data->common.buf_len;
      98                 :          0 :         ctlq_msg->status = 0;
      99                 :          0 :         ctlq_msg->ctx.indirect.payload = cfg_data->common.payload;
     100                 :          0 : }
     101                 :            : 
     102                 :            : /**
     103                 :            :  * cpfl_prep_sem_rule_blob - build SEM rule blob data from rule entry info
     104                 :            :  * note: call this function before sending rule to HW via fast path
     105                 :            :  */
     106                 :            : void
     107                 :          0 : cpfl_prep_sem_rule_blob(const uint8_t *key,
     108                 :            :                         uint8_t key_byte_len,
     109                 :            :                         const uint8_t *act_bytes,
     110                 :            :                         uint8_t act_byte_len,
     111                 :            :                         uint16_t cfg_ctrl,
     112                 :            :                         union cpfl_rule_cfg_pkt_record *rule_blob)
     113                 :            : {
     114                 :          0 :         uint32_t *act_dst = (uint32_t *)&rule_blob->sem_rule.actions;
     115                 :            :         const uint32_t *act_src = (const uint32_t *)act_bytes;
     116                 :            :         uint32_t i;
     117                 :            : 
     118                 :            :         idpf_memset(rule_blob, 0, sizeof(*rule_blob), IDPF_DMA_MEM);
     119                 :          0 :         memcpy(rule_blob->sem_rule.key, key, key_byte_len);
     120                 :            : 
     121         [ #  # ]:          0 :         for (i = 0; i < act_byte_len / sizeof(uint32_t); i++)
     122                 :          0 :                 *act_dst++ = CPU_TO_LE32(*act_src++);
     123                 :            : 
     124                 :          0 :         rule_blob->sem_rule.cfg_ctrl[0] = cfg_ctrl & 0xFF;
     125                 :          0 :         rule_blob->sem_rule.cfg_ctrl[1] = (cfg_ctrl >> 8) & 0xFF;
     126                 :          0 : }

Generated by: LCOV version 1.14