LCOV - code coverage report
Current view: top level - lib/sched - rte_pie.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 25 25 100.0 %
Date: 2024-12-01 18:57:19 Functions: 2 2 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 12 12 100.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2020 Intel Corporation
       3                 :            :  */
       4                 :            : 
       5                 :            : #include <errno.h>
       6                 :            : #include <stdlib.h>
       7                 :            : #include <string.h>
       8                 :            : 
       9                 :            : #include "rte_sched_log.h"
      10                 :            : #include "rte_pie.h"
      11                 :            : 
      12                 :            : #ifdef __INTEL_COMPILER
      13                 :            : #pragma warning(disable:2259) /* conversion may lose significant bits */
      14                 :            : #endif
      15                 :            : 
      16                 :            : int
      17                 :         12 : rte_pie_rt_data_init(struct rte_pie *pie)
      18                 :            : {
      19         [ +  + ]:         12 :         if (pie == NULL) {
      20                 :          1 :                 SCHED_LOG(ERR, "%s: Invalid addr for pie", __func__);
      21                 :          1 :                 return -EINVAL;
      22                 :            :         }
      23                 :            : 
      24                 :            :         memset(pie, 0, sizeof(*pie));
      25                 :            : 
      26                 :         11 :         return 0;
      27                 :            : }
      28                 :            : 
      29                 :            : int
      30                 :        106 : rte_pie_config_init(struct rte_pie_config *pie_cfg,
      31                 :            :         const uint16_t qdelay_ref,
      32                 :            :         const uint16_t dp_update_interval,
      33                 :            :         const uint16_t max_burst,
      34                 :            :         const uint16_t tailq_th)
      35                 :            : {
      36                 :        106 :         uint64_t tsc_hz = rte_get_tsc_hz();
      37                 :            : 
      38         [ +  + ]:        106 :         if (pie_cfg == NULL)
      39                 :            :                 return -1;
      40                 :            : 
      41         [ +  + ]:        105 :         if (qdelay_ref <= 0) {
      42                 :          1 :                 SCHED_LOG(ERR,
      43                 :            :                         "%s: Incorrect value for qdelay_ref", __func__);
      44                 :          1 :                 return -EINVAL;
      45                 :            :         }
      46                 :            : 
      47         [ +  + ]:        104 :         if (dp_update_interval <= 0) {
      48                 :          1 :                 SCHED_LOG(ERR,
      49                 :            :                         "%s: Incorrect value for dp_update_interval", __func__);
      50                 :          1 :                 return -EINVAL;
      51                 :            :         }
      52                 :            : 
      53         [ +  + ]:        103 :         if (max_burst <= 0) {
      54                 :          1 :                 SCHED_LOG(ERR,
      55                 :            :                         "%s: Incorrect value for max_burst", __func__);
      56                 :          1 :                 return -EINVAL;
      57                 :            :         }
      58                 :            : 
      59         [ +  + ]:        102 :         if (tailq_th <= 0) {
      60                 :          1 :                 SCHED_LOG(ERR,
      61                 :            :                         "%s: Incorrect value for tailq_th", __func__);
      62                 :          1 :                 return -EINVAL;
      63                 :            :         }
      64                 :            : 
      65                 :        101 :         pie_cfg->qdelay_ref = (tsc_hz * qdelay_ref) / 1000;
      66                 :        101 :         pie_cfg->dp_update_interval = (tsc_hz * dp_update_interval) / 1000;
      67                 :        101 :         pie_cfg->max_burst = (tsc_hz * max_burst) / 1000;
      68                 :        101 :         pie_cfg->tailq_th = tailq_th;
      69                 :            : 
      70                 :        101 :         return 0;
      71                 :            : }

Generated by: LCOV version 1.14