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 <eal_export.h> 10 : : #include "rte_sched_log.h" 11 : : #include "rte_pie.h" 12 : : 13 : : RTE_EXPORT_SYMBOL(rte_pie_rt_data_init) 14 : : int 15 : 12 : rte_pie_rt_data_init(struct rte_pie *pie) 16 : : { 17 [ + + ]: 12 : if (pie == NULL) { 18 : 1 : SCHED_LOG(ERR, "%s: Invalid addr for pie", __func__); 19 : 1 : return -EINVAL; 20 : : } 21 : : 22 : : memset(pie, 0, sizeof(*pie)); 23 : : 24 : 11 : return 0; 25 : : } 26 : : 27 : : RTE_EXPORT_SYMBOL(rte_pie_config_init) 28 : : int 29 : 106 : rte_pie_config_init(struct rte_pie_config *pie_cfg, 30 : : const uint16_t qdelay_ref, 31 : : const uint16_t dp_update_interval, 32 : : const uint16_t max_burst, 33 : : const uint16_t tailq_th) 34 : : { 35 : 106 : uint64_t tsc_hz = rte_get_tsc_hz(); 36 : : 37 [ + + ]: 106 : if (pie_cfg == NULL) 38 : : return -1; 39 : : 40 [ + + ]: 105 : if (qdelay_ref <= 0) { 41 : 1 : SCHED_LOG(ERR, 42 : : "%s: Incorrect value for qdelay_ref", __func__); 43 : 1 : return -EINVAL; 44 : : } 45 : : 46 [ + + ]: 104 : if (dp_update_interval <= 0) { 47 : 1 : SCHED_LOG(ERR, 48 : : "%s: Incorrect value for dp_update_interval", __func__); 49 : 1 : return -EINVAL; 50 : : } 51 : : 52 [ + + ]: 103 : if (max_burst <= 0) { 53 : 1 : SCHED_LOG(ERR, 54 : : "%s: Incorrect value for max_burst", __func__); 55 : 1 : return -EINVAL; 56 : : } 57 : : 58 [ + + ]: 102 : if (tailq_th <= 0) { 59 : 1 : SCHED_LOG(ERR, 60 : : "%s: Incorrect value for tailq_th", __func__); 61 : 1 : return -EINVAL; 62 : : } 63 : : 64 : 101 : pie_cfg->qdelay_ref = (tsc_hz * qdelay_ref) / 1000; 65 : 101 : pie_cfg->dp_update_interval = (tsc_hz * dp_update_interval) / 1000; 66 : 101 : pie_cfg->max_burst = (tsc_hz * max_burst) / 1000; 67 : 101 : pie_cfg->tailq_th = tailq_th; 68 : : 69 : 101 : return 0; 70 : : }