diff options
author | Konstantin Ananyev <konstantin.ananyev@intel.com> | 2019-11-04 13:50:31 +0000 |
---|---|---|
committer | Konstantin Ananyev <konstantin.ananyev@intel.com> | 2019-12-31 11:51:05 +0000 |
commit | b8f1ef2b02b8709c72408ee4803f442efc9f4576 (patch) | |
tree | 95a16adc465206d351cbf1b823f793c7592f00e7 /lib/libtle_l4p/tcp_ctl.h | |
parent | 47eb00f25ab06a699dc27507814c7656940340af (diff) |
v6: make TCP stream alloc/free to use memtank API
Introduce two extra parameters for TCP context creation:
struct {
uint32_t min;
/**< min number of free streams (grow threshold). */
uint32_t max;
/**< max number of free streams (shrink threshold). */
} free_streams;
By default these params are equal to max_streams value
(avoid dynamic allocation and preserve current beahviour).
grow() is invoked from accept() FE call to refill streams tank for BE.
shrink() is invoked from close() FE call.
Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
Change-Id: I7af6a76d64813ee4a535323e27ffbfd75037fc92
Diffstat (limited to 'lib/libtle_l4p/tcp_ctl.h')
-rw-r--r-- | lib/libtle_l4p/tcp_ctl.h | 37 |
1 files changed, 33 insertions, 4 deletions
diff --git a/lib/libtle_l4p/tcp_ctl.h b/lib/libtle_l4p/tcp_ctl.h index bec1e76..7dde8ff 100644 --- a/lib/libtle_l4p/tcp_ctl.h +++ b/lib/libtle_l4p/tcp_ctl.h @@ -143,10 +143,10 @@ empty_lq(struct tle_tcp_stream *s) static inline void tcp_stream_reset(struct tle_ctx *ctx, struct tle_tcp_stream *s) { - struct stbl *st; uint16_t uop; + struct tcp_streams *ts; - st = CTX_TCP_STLB(ctx); + ts = CTX_TCP_STREAMS(ctx); /* reset TX armed */ rte_atomic32_set(&s->tx.arm, 0); @@ -167,7 +167,7 @@ tcp_stream_reset(struct tle_ctx *ctx, struct tle_tcp_stream *s) if (s->ste != NULL) { /* remove entry from RX streams table */ - stbl_del_stream(st, s->ste, s, + stbl_del_stream(&ts->st, s->ste, s, (s->flags & TLE_CTX_FLAG_ST) == 0); s->ste = NULL; empty_rq(s); @@ -181,7 +181,36 @@ tcp_stream_reset(struct tle_ctx *ctx, struct tle_tcp_stream *s) * if there still are pkts queued for TX, * then put this stream to the tail of free list. */ - put_stream(ctx, &s->s, TCP_STREAM_TX_FINISHED(s)); + if (TCP_STREAM_TX_PENDING(s)) + put_stream(ctx, &s->s, 0); + else { + s->s.type = TLE_VNUM; + tle_memtank_free(ts->mts, (void **)&s, 1, 0); + } +} + +static inline struct tle_tcp_stream * +tcp_stream_get(struct tle_ctx *ctx, uint32_t flag) +{ + struct tle_stream *s; + struct tle_tcp_stream *cs; + struct tcp_streams *ts; + + ts = CTX_TCP_STREAMS(ctx); + + /* check TX pending list */ + s = get_stream(ctx); + cs = TCP_STREAM(s); + if (s != NULL) { + if (TCP_STREAM_TX_FINISHED(cs)) + return cs; + put_stream(ctx, &cs->s, 0); + } + + if (tle_memtank_alloc(ts->mts, (void **)&cs, 1, flag) != 1) + return NULL; + + return cs; } #ifdef __cplusplus |