2 * Copyright (c) 2016-2017 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:
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 #ifndef _TCP_STREAM_H_
17 #define _TCP_STREAM_H_
20 #include <tle_dring.h>
21 #include <tle_memtank.h>
23 #include <tle_event.h>
56 volatile uint16_t state;
57 volatile uint16_t uop; /* operations by user performed */
60 uint32_t irs; /* initial received sequence */
67 uint32_t srtt; /* smoothed round trip time (scaled by >> 3) */
68 uint32_t rttvar; /* rtt variance */
76 uint64_t rcvr; /* recover RFC 6582 */
77 uint64_t fss; /* FIN sequence # */
78 uint32_t fastack; /* # of partial acks in fast retransmit */
80 union wui wu; /* window update */
81 uint32_t ack; /* last sent ack */
83 uint32_t cwnd; /* congestion window */
84 uint32_t ssthresh; /* slow start threshold */
85 uint32_t rto; /* retransmission timeout */
86 uint32_t rto_tw; /* TIME_WAIT retransmission timeout */
87 uint32_t iss; /* initial send sequence */
90 uint8_t nb_retx; /* number of retransmission */
91 uint8_t nb_retm; /**< max number of retx attempts. */
93 struct syn_opts so; /* initial syn options. */
96 struct tle_tcp_stream {
103 struct stbl_entry *ste; /* entry in streams table. */
111 struct tle_event *ev;
112 struct tle_stream_cb cb;
116 struct rte_ring *q; /* listen (syn) queue */
118 struct tle_event *ev; /* user provided recv event. */
119 struct tle_stream_cb cb; /* user provided recv callback. */
120 } rx __rte_cache_aligned;
123 rte_atomic32_t arm; /* when > 0 stream is in to-send queue */
125 uint32_t nb_elem; /* number of objects per drb. */
126 uint32_t nb_max; /* number of drbs per stream. */
129 struct rte_ring *q; /* (re)tx queue */
130 struct tle_event *ev;
131 struct tle_stream_cb cb;
133 } tx __rte_cache_aligned;
135 } __rte_cache_aligned;
137 #define TCP_STREAM(p) \
138 ((struct tle_tcp_stream *)((uintptr_t)(p) - offsetof(struct tle_tcp_stream, s)))
140 #define TCP_STREAM_TX_PENDING(s) \
141 ((s)->tx.drb.nb_max != rte_ring_count((s)->tx.drb.r))
143 #define TCP_STREAM_TX_FINISHED(s) \
144 ((s)->tx.drb.nb_max == rte_ring_count((s)->tx.drb.r))
146 #include "stream_table.h"
150 STAILQ_HEAD(, tle_stream) fe;
151 STAILQ_HEAD(, tle_stream) be;
154 /* tempalte sizes/offsets/etc. for tcp stream */
155 struct stream_szofs {
178 struct tle_timer_wheel *tmr; /* timer wheel */
179 struct rte_ring *tsq; /* to-send streams queue */
180 struct tle_memtank *mts; /* memtank to allocate streams from */
181 struct sdr dr; /* death row for zombie streams */
182 struct stream_szofs szofs; /* size and offsets for stream data */
185 #define CTX_TCP_STREAMS(ctx) ((struct tcp_streams *)(ctx)->streams.buf)
186 #define CTX_TCP_STLB(ctx) (&CTX_TCP_STREAMS(ctx)->st)
187 #define CTX_TCP_TMWHL(ctx) (CTX_TCP_STREAMS(ctx)->tmr)
188 #define CTX_TCP_TSQ(ctx) (CTX_TCP_STREAMS(ctx)->tsq)
189 #define CTX_TCP_SDR(ctx) (&CTX_TCP_STREAMS(ctx)->dr)
190 #define CTX_TCP_MTS(ctx) (CTX_TCP_STREAMS(ctx)->mts)
196 #endif /* _TCP_STREAM_H_ */