diff options
author | Konstantin Ananyev <konstantin.ananyev@intel.com> | 2017-07-27 12:00:57 +0100 |
---|---|---|
committer | Konstantin Ananyev <konstantin.ananyev@intel.com> | 2017-07-27 20:24:53 +0100 |
commit | 7e18fa1bf263822c46d7431a911b41d6377d5f69 (patch) | |
tree | ddf5ce05545419d6d77bb9d8b3c48fc90d221a7a /lib/libtle_l4p/misc.h | |
parent | e151ee29d02d7802fab9e32b50ced54fd8d64160 (diff) |
- Introduce tle_tcp_stream_readv() and tle_tcp_stream_writev().
- Introduce flags for tle_ctx_param.
- Introduce TLE_CTX_FLAG_ST - indicates that given ctx will be used
by single thread only.
- Introduce new parameters for tcp context:
timewait - allows user to configure max timeout in TCP_TIMEWAIT state.
icw - allows user to specify desired initial congestion window
for new connections.
-Few optimisations:
cache tx.ol_flags inside tle destination.
calcualte and cache inside ctx cycles_to_ms shift value.
reorder restoring SYN opts and filling TCB a bit.
Change-Id: Ie05087783b3b7f1e4ce99d3555bc5bd098f83fe0
Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
Signed-off-by: Mohammad Abdul Awal <mohammad.abdul.awal@intel.com>
Diffstat (limited to 'lib/libtle_l4p/misc.h')
-rw-r--r-- | lib/libtle_l4p/misc.h | 91 |
1 files changed, 87 insertions, 4 deletions
diff --git a/lib/libtle_l4p/misc.h b/lib/libtle_l4p/misc.h index 6450b67..9bff459 100644 --- a/lib/libtle_l4p/misc.h +++ b/lib/libtle_l4p/misc.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Intel Corporation. + * Copyright (c) 2016-2017 Intel Corporation. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at: @@ -396,20 +396,103 @@ compress_pkt_list(struct rte_mbuf *pkt[], uint32_t nb_pkt, uint32_t nb_zero) return nb_pkt; } +static inline void +free_mbufs(struct rte_mbuf *mb[], uint32_t num) +{ + uint32_t i; + + for (i = 0; i != num; i++) + rte_pktmbuf_free(mb[i]); +} + /* empty ring and free queued mbufs */ static inline void empty_mbuf_ring(struct rte_ring *r) { - uint32_t i, n; + uint32_t n; struct rte_mbuf *mb[MAX_PKT_BURST]; do { n = _rte_ring_dequeue_burst(r, (void **)mb, RTE_DIM(mb)); - for (i = 0; i != n; i++) - rte_pktmbuf_free(mb[i]); + free_mbufs(mb, n); } while (n != 0); } +static inline uint32_t +_mbus_to_iovec(struct iovec *iv, struct rte_mbuf *mb[], uint32_t num) +{ + uint32_t i, ns; + uint32_t len, slen, tlen; + struct rte_mbuf *m, *next; + const void *src; + + for (i = 0; i != num; i++) { + + m = mb[i]; + tlen = 0; + ns = 0; + + do { + slen = m->data_len; + src = rte_pktmbuf_mtod(m, const void *); + len = RTE_MIN(iv->iov_len - tlen, slen); + rte_memcpy((uint8_t *)iv->iov_base + tlen, src, len); + slen -= len; + tlen += len; + if (slen != 0) + break; + ns++; + next = m->next; + rte_pktmbuf_free_seg(m); + m = next; + } while (m != NULL); + + iv->iov_base = (uint8_t *)iv->iov_base + tlen; + iv->iov_len -= tlen; + + /* partly consumed mbuf */ + if (m != NULL) { + m->pkt_len = mb[i]->pkt_len - tlen; + m->data_len = slen; + m->data_off += len; + m->nb_segs = mb[i]->nb_segs - ns; + mb[i] = m; + break; + } + } + + return i; +} + +static inline uint32_t +_iovec_to_mbsegs(struct iovec *iv, uint32_t seglen, struct rte_mbuf *mb[], + uint32_t num) +{ + uint32_t i; + uint32_t len, slen, tlen; + struct rte_mbuf *m; + void *dst; + + tlen = 0; + for (i = 0; i != num; i++) { + + m = mb[i]; + slen = rte_pktmbuf_tailroom(m); + slen = RTE_MIN(slen, seglen - m->data_len); + len = RTE_MIN(iv->iov_len - tlen, slen); + dst = rte_pktmbuf_append(m, len); + rte_memcpy(dst, (uint8_t *)iv->iov_base + tlen, len); + tlen += len; + if (len != slen) + break; + } + + iv->iov_base = (uint8_t *)iv->iov_base + tlen; + iv->iov_len -= tlen; + + return i; +} + #ifdef __cplusplus } #endif |