Support packets in flight
[samplevnf.git] / VNFs / DPPD-PROX / handle_gen.h
1 /*
2 // Copyright (c) 2010-2017 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 _HANDLE_GEN_H_
18 #define _HANDLE_GEN_H_
19
20 #include "task_init.h"
21
22 struct unique_id {
23         uint8_t  generator_id;
24         uint32_t packet_id;
25 } __attribute__((packed));
26
27 static void unique_id_init(struct unique_id *unique_id, uint8_t generator_id, uint32_t packet_id)
28 {
29         unique_id->generator_id = generator_id;
30         unique_id->packet_id = packet_id;
31 }
32
33 static void unique_id_get(struct unique_id *unique_id, uint8_t *generator_id, uint32_t *packet_id)
34 {
35         *generator_id = unique_id->generator_id;
36         *packet_id = unique_id->packet_id;
37 }
38
39 struct task_base;
40
41 void task_gen_set_pkt_count(struct task_base *tbase, uint32_t count);
42 int task_gen_set_pkt_size(struct task_base *tbase, uint32_t pkt_size);
43 int task_gen_set_imix(struct task_base *tbase, uint32_t nb_pkts, uint32_t *pkt_size);
44 void task_gen_set_rate(struct task_base *tbase, uint64_t bps);
45 void task_gen_reset_randoms(struct task_base *tbase);
46 void task_gen_reset_ranges(struct task_base *tbase);
47 void task_gen_reset_values(struct task_base *tbase);
48 int task_gen_set_value(struct task_base *tbase, uint32_t value, uint32_t offset, uint32_t len);
49 int task_gen_add_rand(struct task_base *tbase, const char *rand_str, uint32_t offset, uint32_t rand_id);
50 int task_gen_add_range(struct task_base *tbase, struct range *range);
51
52 uint32_t task_gen_get_n_randoms(struct task_base *tbase);
53 uint32_t task_gen_get_n_ranges(struct task_base *tbase);
54 uint32_t task_gen_get_n_values(struct task_base *tbase);
55
56 #endif /* _HANDLE_GEN_H_ */