2 // Copyright (c) 2010-2017 Intel Corporation
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
17 #ifndef _GENL4_BUNDLE_H_
18 #define _GENL4_BUNDLE_H_
21 #include "genl4_stream.h"
24 /* Configured once and used during packet generation. The structure
25 describes a single set of consecutive streams. When used at the
26 server side, it only contains a simple stream to represent a
29 struct host_set clients;
30 uint32_t n_stream_cfgs;
31 struct stream_cfg **stream_cfgs;
34 /* A bundle_ctx represents a an active stream between a client and a
37 struct pkt_tuple tuple; /* Client IP/PORT generated once at bundle creation time, client PORT and server IP/PORT created when stream_idx++ */
38 struct heap_ref heap_ref; /* Back reference into heap */
39 struct heap *heap; /* timer management */
41 const struct bundle_cfg *cfg; /* configuration time read only structure */
43 struct stream_ctx ctx; /* state management info for stream_cfg (reset when stream_idx++) */
44 uint32_t stream_idx; /* iterate through cfg->straem_cfgs */
47 #define BUNDLE_CTX_UPCAST(r) ((struct bundle_ctx *)((uint8_t *)r - offsetof(struct bundle_ctx, heap_ref)))
49 struct bundle_ctx_pool {
50 struct rte_hash *hash;
51 struct bundle_ctx **hash_entries;
52 struct bundle_ctx **free_bundles;
53 struct bundle_ctx *bundles; /* Memory containing all communications */
55 struct bundle_cfg *bundle_cfg;
58 uint32_t n_free_bundles;
63 uint64_t bundles_created;
64 uint64_t tcp_finished_no_retransmit;
65 uint64_t tcp_finished_retransmit;
66 uint64_t udp_finished;
70 uint64_t tcp_retransmits;
75 int bundle_ctx_pool_create(const char *name, uint32_t n_elems, struct bundle_ctx_pool *ret, uint32_t *occur, uint32_t n_occur, struct bundle_cfg *cfg, int socket_id);
77 struct bundle_ctx *bundle_ctx_pool_get(struct bundle_ctx_pool *p);
78 struct bundle_ctx *bundle_ctx_pool_get_w_cfg(struct bundle_ctx_pool *p);
79 void bundle_ctx_pool_put(struct bundle_ctx_pool *p, struct bundle_ctx *bundle);
81 void bundle_create_tuple(struct pkt_tuple *tp, const struct host_set *clients, const struct stream_cfg *stream_cfg, int rnd_ip, unsigned *seed);
82 void bundle_init(struct bundle_ctx *bundle, struct heap *heap, enum l4gen_peer peer, unsigned *seed);
83 void bundle_init_w_cfg(struct bundle_ctx *bundle, const struct bundle_cfg *cfg, struct heap *heap, enum l4gen_peer peer, unsigned *seed);
84 void bundle_expire(struct bundle_ctx *bundle, struct bundle_ctx_pool *pool, struct l4_stats *l4_stats);
85 int bundle_proc_data(struct bundle_ctx *bundle, struct rte_mbuf *mbuf, struct l4_meta *l4_meta, struct bundle_ctx_pool *pool, unsigned *seed, struct l4_stats *l4_stats);
86 uint32_t bundle_cfg_length(struct bundle_cfg *cfg);
87 uint32_t bundle_cfg_max_n_segments(struct bundle_cfg *cfg);
89 #endif /* _GENL4_BUNDLE_H_ */