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