aboutsummaryrefslogtreecommitdiffstats
path: root/lib/libtle_l4p/stream.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/libtle_l4p/stream.h')
-rw-r--r--lib/libtle_l4p/stream.h55
1 files changed, 37 insertions, 18 deletions
diff --git a/lib/libtle_l4p/stream.h b/lib/libtle_l4p/stream.h
index 49a2809..9f2bbc1 100644
--- a/lib/libtle_l4p/stream.h
+++ b/lib/libtle_l4p/stream.h
@@ -31,7 +31,11 @@ struct tle_stream {
STAILQ_ENTRY(tle_stream) link;
struct tle_ctx *ctx;
- uint8_t type; /* TLE_V4 or TLE_V6 */
+ tle_stream_options_t option;
+ unsigned long timestamp;
+ uint16_t reuseport_seed;
+ uint8_t type; /* TLE_V4 or TLE_V6 */
+ uint8_t padding;
/* Stream address information. */
union l4_ports port;
@@ -53,15 +57,25 @@ static inline uint32_t
get_streams(struct tle_ctx *ctx, struct tle_stream *s[], uint32_t num)
{
struct tle_stream *p;
- uint32_t i, n;
+ uint32_t i, n, inc;
rte_spinlock_lock(&ctx->streams.lock);
- n = RTE_MIN(ctx->streams.nb_free, num);
- for (i = 0, p = STAILQ_FIRST(&ctx->streams.free);
- i != n;
- i++, p = STAILQ_NEXT(p, link))
+ n = ctx->streams.nb_free;
+ if (n < num) {
+ inc = tle_stream_ops[ctx->prm.proto].more_streams(ctx);
+ ctx->streams.nb_free += inc;
+ ctx->streams.nb_cur += inc;
+ n = ctx->streams.nb_free;
+ }
+ n = RTE_MIN(n, num);
+
+ for (i = 0, p = STAILQ_FIRST(&ctx->streams.free); i != n; ) {
s[i] = p;
+ p = STAILQ_NEXT(p, link);
+ s[i]->link.stqe_next = NULL;
+ i++;
+ }
if (p == NULL)
/* we retrieved all free entries */
@@ -80,9 +94,6 @@ get_stream(struct tle_ctx *ctx)
struct tle_stream *s;
s = NULL;
- if (ctx->streams.nb_free == 0)
- return s;
-
get_streams(ctx, &s, 1);
return s;
}
@@ -120,8 +131,8 @@ drb_nb_elem(const struct tle_ctx *ctx)
}
static inline int32_t
-stream_get_dest(struct tle_stream *s, const void *dst_addr,
- struct tle_dest *dst)
+stream_get_dest(uint8_t type, struct tle_stream *s, const void *src_addr,
+ const void *dst_addr, struct tle_dest *dst)
{
int32_t rc;
const struct in_addr *d4;
@@ -133,12 +144,13 @@ stream_get_dest(struct tle_stream *s, const void *dst_addr,
/* it is here just to keep gcc happy. */
d4 = NULL;
+ /* it is here just to keep gcc happy. */
d6 = NULL;
- if (s->type == TLE_V4) {
+ if (type == TLE_V4) {
d4 = dst_addr;
rc = ctx->prm.lookup4(ctx->prm.lookup4_data, d4, dst);
- } else if (s->type == TLE_V6) {
+ } else if (type == TLE_V6) {
d6 = dst_addr;
rc = ctx->prm.lookup6(ctx->prm.lookup6_data, d6, dst);
} else
@@ -148,18 +160,25 @@ stream_get_dest(struct tle_stream *s, const void *dst_addr,
return -ENOENT;
dev = dst->dev;
- dst->ol_flags = dev->tx.ol_flags[s->type];
+ dst->ol_flags = dev->tx.ol_flags[type];
- if (s->type == TLE_V4) {
+ if (type == TLE_V4) {
struct ipv4_hdr *l3h;
l3h = (struct ipv4_hdr *)(dst->hdr + dst->l2_len);
- l3h->src_addr = dev->prm.local_addr4.s_addr;
+ if (((const struct in_addr*)src_addr)->s_addr != INADDR_ANY)
+ l3h->src_addr = ((const struct in_addr*)src_addr)->s_addr;
+ else
+ l3h->src_addr = dev->prm.local_addr4.s_addr;
l3h->dst_addr = d4->s_addr;
} else {
struct ipv6_hdr *l3h;
l3h = (struct ipv6_hdr *)(dst->hdr + dst->l2_len);
- rte_memcpy(l3h->src_addr, &dev->prm.local_addr6,
- sizeof(l3h->src_addr));
+ if (!IN6_IS_ADDR_UNSPECIFIED(src_addr))
+ rte_memcpy(l3h->src_addr, src_addr,
+ sizeof(l3h->src_addr));
+ else
+ rte_memcpy(l3h->src_addr, &dev->prm.local_addr6,
+ sizeof(l3h->src_addr));
rte_memcpy(l3h->dst_addr, d6, sizeof(l3h->dst_addr));
}