Revert "l4p/tcp: introduce tle_tcp_stream_establish() API"
[tldk.git] / lib / libtle_l4p / udp_stream.h
1 /*
2  * Copyright (c) 2016  Intel Corporation.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at:
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15
16 #ifndef _UDP_STREAM_H_
17 #define _UDP_STREAM_H_
18
19 #include <rte_vect.h>
20 #include <tle_dring.h>
21 #include <tle_udp.h>
22 #include <tle_event.h>
23
24 #include "osdep.h"
25 #include "ctx.h"
26 #include "stream.h"
27
28 #ifdef __cplusplus
29 extern "C" {
30 #endif
31
32 union udph {
33         uint64_t raw;
34         struct {
35                 union l4_ports ports;
36                 uint16_t len;
37                 uint16_t cksum;
38         };
39 };
40
41 struct tle_udp_stream {
42
43         struct tle_stream s;
44
45         struct {
46                 struct rte_ring *q;
47                 struct tle_event *ev;
48                 struct tle_stream_cb cb;
49                 rte_atomic32_t use;
50         } rx __rte_cache_aligned;
51
52         struct {
53                 rte_atomic32_t use;
54                 struct {
55                         uint32_t nb_elem;  /* number of obects per drb. */
56                         uint32_t nb_max;   /* number of drbs per stream. */
57                         struct rte_ring *r;
58                 } drb;
59                 struct tle_event *ev;
60                 struct tle_stream_cb cb;
61         } tx __rte_cache_aligned;
62
63         struct tle_udp_stream_param prm;
64 } __rte_cache_aligned;
65
66 #define UDP_STREAM(p)   \
67 ((struct tle_udp_stream *)((uintptr_t)(p) - offsetof(struct tle_udp_stream, s)))
68
69 #define UDP_STREAM_TX_PENDING(s)        \
70         ((s)->tx.drb.nb_max != rte_ring_count((s)->tx.drb.r))
71
72 #define UDP_STREAM_TX_FINISHED(s)       \
73         ((s)->tx.drb.nb_max == rte_ring_count((s)->tx.drb.r))
74
75 #ifdef __cplusplus
76 }
77 #endif
78
79 #endif /* _UDP_STREAM_H_ */