These header includes have been flagged by the iwyu_tool and removed. Signed-off-by: Sean Morrissey <sean.morrissey@intel.com>
85 lines
1.7 KiB
C
85 lines
1.7 KiB
C
/* SPDX-License-Identifier: BSD-3-Clause
|
|
* Copyright(c) 2020 Intel Corporation
|
|
*/
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "rte_pie.h"
|
|
#include <rte_malloc.h>
|
|
|
|
#ifdef __INTEL_COMPILER
|
|
#pragma warning(disable:2259) /* conversion may lose significant bits */
|
|
#endif
|
|
|
|
int
|
|
rte_pie_rt_data_init(struct rte_pie *pie)
|
|
{
|
|
if (pie == NULL) {
|
|
/* Allocate memory to use the PIE data structure */
|
|
pie = rte_malloc(NULL, sizeof(struct rte_pie), 0);
|
|
|
|
if (pie == NULL)
|
|
RTE_LOG(ERR, SCHED, "%s: Memory allocation fails\n", __func__);
|
|
|
|
return -1;
|
|
}
|
|
|
|
pie->active = 0;
|
|
pie->in_measurement = 0;
|
|
pie->departed_bytes_count = 0;
|
|
pie->start_measurement = 0;
|
|
pie->last_measurement = 0;
|
|
pie->qlen = 0;
|
|
pie->avg_dq_time = 0;
|
|
pie->burst_allowance = 0;
|
|
pie->qdelay_old = 0;
|
|
pie->drop_prob = 0;
|
|
pie->accu_prob = 0;
|
|
|
|
return 0;
|
|
}
|
|
|
|
int
|
|
rte_pie_config_init(struct rte_pie_config *pie_cfg,
|
|
const uint16_t qdelay_ref,
|
|
const uint16_t dp_update_interval,
|
|
const uint16_t max_burst,
|
|
const uint16_t tailq_th)
|
|
{
|
|
uint64_t tsc_hz = rte_get_tsc_hz();
|
|
|
|
if (pie_cfg == NULL)
|
|
return -1;
|
|
|
|
if (qdelay_ref <= 0) {
|
|
RTE_LOG(ERR, SCHED,
|
|
"%s: Incorrect value for qdelay_ref\n", __func__);
|
|
return -EINVAL;
|
|
}
|
|
|
|
if (dp_update_interval <= 0) {
|
|
RTE_LOG(ERR, SCHED,
|
|
"%s: Incorrect value for dp_update_interval\n", __func__);
|
|
return -EINVAL;
|
|
}
|
|
|
|
if (max_burst <= 0) {
|
|
RTE_LOG(ERR, SCHED,
|
|
"%s: Incorrect value for max_burst\n", __func__);
|
|
return -EINVAL;
|
|
}
|
|
|
|
if (tailq_th <= 0) {
|
|
RTE_LOG(ERR, SCHED,
|
|
"%s: Incorrect value for tailq_th\n", __func__);
|
|
return -EINVAL;
|
|
}
|
|
|
|
pie_cfg->qdelay_ref = (tsc_hz * qdelay_ref) / 1000;
|
|
pie_cfg->dp_update_interval = (tsc_hz * dp_update_interval) / 1000;
|
|
pie_cfg->max_burst = (tsc_hz * max_burst) / 1000;
|
|
pie_cfg->tailq_th = tailq_th;
|
|
|
|
return 0;
|
|
}
|