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