diff options
author | Mohsin Kazmi <sykazmi@cisco.com> | 2022-07-18 11:21:05 +0000 |
---|---|---|
committer | Beno�t Ganne <bganne@cisco.com> | 2022-07-25 14:03:48 +0000 |
commit | 8636a320413c12d1747c695ac594ca643ac539ba (patch) | |
tree | 9c0ba086b2f92827a0a32585f3b52a839e574796 /extras/libmemif/examples/common/packet_handler.c | |
parent | c8cd079a0004b75892a08c7cac9a48b39e24e580 (diff) |
libmemif: fix chain buffer support
Type: fix
This patch fixes chain buffer support as transmit side
missing to set the flag to the descriptor in case of
chain buffers.
Signed-off-by: Mohsin Kazmi <sykazmi@cisco.com>
Change-Id: I73ff11be69a388f14fea39a19272d8eb76148fba
Diffstat (limited to 'extras/libmemif/examples/common/packet_handler.c')
-rw-r--r-- | extras/libmemif/examples/common/packet_handler.c | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/extras/libmemif/examples/common/packet_handler.c b/extras/libmemif/examples/common/packet_handler.c index 705cc728a36..9d3e4d703c1 100644 --- a/extras/libmemif/examples/common/packet_handler.c +++ b/extras/libmemif/examples/common/packet_handler.c @@ -47,19 +47,39 @@ icmp_packet_handler (memif_connection_t *c) { for (i = 0; i < c->tx_buf_num; i++) { - resolve_packet (c->rx_bufs[i].data, c->rx_bufs[i].len, - c->tx_bufs[i].data, &c->tx_bufs[i].len, c->ip_addr, - c->hw_addr); + uint32_t len; + void *packet = c->rx_bufs[i].data; + + memcpy (c->tx_bufs[i].data, c->rx_bufs[i].data, c->rx_bufs[i].len); + c->tx_bufs[i].flags = c->rx_bufs[i].flags; + len = c->tx_bufs[i].len = c->rx_bufs[i].len; + + while (c->rx_bufs[i].flags & MEMIF_BUFFER_FLAG_NEXT) + { + i++; + memcpy (c->tx_bufs[i].data, c->rx_bufs[i].data, + c->rx_bufs[i].len); + c->tx_bufs[i].flags = c->rx_bufs[i].flags; + len += c->tx_bufs[i].len = c->rx_bufs[i].len; + } + + resolve_packet (packet, &len, c->ip_addr, c->hw_addr); } } else { for (i = 0; i < c->rx_buf_num; i++) { - resolve_packet_zero_copy (c->rx_bufs[i].data, &c->rx_bufs[i].len, - c->ip_addr, c->hw_addr); + uint32_t len = c->rx_bufs[i].len; + void *packet = c->rx_bufs[i].data; + while (c->rx_bufs[i].flags & MEMIF_BUFFER_FLAG_NEXT) + { + i++; + len += c->rx_bufs[i].len; + } + resolve_packet (packet, &len, c->ip_addr, c->hw_addr); } } return 0; -}
\ No newline at end of file +} |