diff options
author | Konstantin Ananyev <konstantin.ananyev@intel.com> | 2017-11-24 15:54:01 +0000 |
---|---|---|
committer | Konstantin Ananyev <konstantin.ananyev@intel.com> | 2017-11-24 15:57:32 +0000 |
commit | 3726dc50dd2a9873ac05847be80ca615ea4a708b (patch) | |
tree | e13139519f048b273cbe5ced963e98fc7d7b6ab5 /examples/l4fwd/common.h | |
parent | c1b4951ccc6c7c5c44dbfb1d01f86bc5ea0016c8 (diff) |
l4fwd: allow to specify TX payload contents for rxtx mode
Introduce a new command-line option that specifies the file
with response payload.
Change-Id: I1a208eeebe1d87970da23956fb08949abf601422
Signed-off-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
Diffstat (limited to 'examples/l4fwd/common.h')
-rw-r--r-- | examples/l4fwd/common.h | 48 |
1 files changed, 36 insertions, 12 deletions
diff --git a/examples/l4fwd/common.h b/examples/l4fwd/common.h index ae4f266..b7750d7 100644 --- a/examples/l4fwd/common.h +++ b/examples/l4fwd/common.h @@ -634,23 +634,24 @@ netfe_rxtx_get_mss(struct netfe_stream *fes) */ return RTE_MBUF_DEFAULT_DATAROOM - TLE_DST_MAX_HDR; default: - NETFE_TRACE("%s(%u): Unhandled MSS query (family=%i)\n", - __func__, lcore, fes->proto, fes->family); return -EINVAL; } } static inline int netfe_rxtx_dispatch_reply(uint32_t lcore, struct netfe_stream *fes) - { struct pkt_buf *pb; int32_t sid; - int32_t cnt_mtu_pkts; - int32_t cnt_all_pkts; - int32_t idx_pkt; - int32_t len_tail; - int32_t mtu; + uint32_t n; + uint32_t cnt_mtu_pkts; + uint32_t cnt_all_pkts; + uint32_t idx_pkt; + uint32_t len_tail; + uint32_t mtu; + size_t csz, len; + char *dst; + const uint8_t *src; pb = &fes->pbuf; sid = rte_lcore_to_socket_id(lcore) + 1; @@ -675,14 +676,37 @@ netfe_rxtx_dispatch_reply(uint32_t lcore, struct netfe_stream *fes) return -ENOMEM; } + csz = tx_content.sz; + src = tx_content.data; + + n = pb->num; + /* Full MTU packets */ - for (idx_pkt = 0; idx_pkt < cnt_mtu_pkts; idx_pkt++) { - rte_pktmbuf_append(pb->pkt[pb->num++], mtu); + for (idx_pkt = 0; idx_pkt < cnt_mtu_pkts; idx_pkt++, n++) { + rte_pktmbuf_reset(pb->pkt[n]); + dst = rte_pktmbuf_append(pb->pkt[n], mtu); + if (csz > 0) { + len = RTE_MIN(mtu, csz); + rte_memcpy(dst, src, len); + src += len; + csz -= len; + } } /* Last non-MTU packet, if any */ - if (len_tail > 0) - rte_pktmbuf_append(pb->pkt[pb->num++], len_tail); + if (len_tail > 0) { + rte_pktmbuf_reset(pb->pkt[n]); + dst = rte_pktmbuf_append(pb->pkt[n], len_tail); + if (csz > 0) { + len = RTE_MIN(len_tail, csz); + rte_memcpy(dst, src, len); + src += len; + csz -= len; + } + n++; + } + + pb->num = n; return 0; } |