Specify latency bucket size & correct calculation
[samplevnf.git] / VNFs / DPPD-PROX / handle_sched.h
1 /*
2 // Copyright (c) 2019 Intel Corporation
3 //
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 */
16
17 #ifndef _PROX_SCHED_H
18 #define _PROX_SCHED_H
19
20 #include "task_init.h"
21 #include "lconf.h"
22
23 static int init_port_sched(struct rte_sched_port **sched_port, struct task_args *targ)
24 {
25         *sched_port = NULL;
26 #if RTE_VERSION >= RTE_VERSION_NUM(19,2,0,0)
27         for (uint8_t idx = 0; idx < MAX_PROTOCOLS; ++idx) {
28                 for (uint8_t ring_idx = 0; ring_idx < targ->core_task_set[idx].n_elems; ++ring_idx) {
29                         struct core_task ct = targ->core_task_set[idx].core_task[ring_idx];
30                         struct task_args *dtarg = core_targ_get(ct.core, ct.task);
31                         enum task_mode dmode = dtarg->mode;
32                         if ((dmode == QOS)  || (dmode == POLICE)) {
33                                 // Next task is QOS or POLICE
34                                 // We use the same configuration as the QoS we are transmitting to
35                                 *sched_port = rte_sched_port_config(&dtarg->qos_conf.port_params);
36                                 plog_info("\tInitializing sched_port based on QoS config of core %d task %d\n", ct.core, ct.task);
37                                 return 0;
38                         }
39                 }
40         }
41         return -1;
42 #endif
43         return 0;
44 }
45 #endif