aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatias Elo <matias.elo@nokia.com>2018-07-26 10:33:09 +0300
committerMaxim Uvarov <maxim.uvarov@linaro.org>2018-07-27 11:02:59 +0300
commitb815170fec19fc6d0e0c269e69c0097c86ebda7e (patch)
tree86f30b601f497980d6d2a2bb96f4db83792fe97d
parentef97ffce4aea71b22f1eb87bd34d15b1125c5737 (diff)
downloadodp-dpdk-api-next.tar.gz
linux-dpdk: packet: optimize odp_packet_copy_from_mem()api-next
Sync implementation with linux-generic and use rte_memcpy. Signed-off-by: Matias Elo <matias.elo@nokia.com> Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
-rw-r--r--platform/linux-dpdk/include/odp/api/plat/packet_inlines.h21
1 files changed, 18 insertions, 3 deletions
diff --git a/platform/linux-dpdk/include/odp/api/plat/packet_inlines.h b/platform/linux-dpdk/include/odp/api/plat/packet_inlines.h
index 825cfb5e..b8116c14 100644
--- a/platform/linux-dpdk/include/odp/api/plat/packet_inlines.h
+++ b/platform/linux-dpdk/include/odp/api/plat/packet_inlines.h
@@ -336,8 +336,9 @@ _ODP_INLINE int odp_packet_copy_to_mem(odp_packet_t pkt, uint32_t offset,
return 0;
}
-_ODP_INLINE int odp_packet_copy_from_mem(odp_packet_t pkt, uint32_t offset,
- uint32_t len, const void *src)
+static inline int _odp_packet_copy_from_mem_seg(odp_packet_t pkt,
+ uint32_t offset, uint32_t len,
+ const void *src)
{
void *mapaddr;
uint32_t seglen = 0; /* GCC */
@@ -350,7 +351,7 @@ _ODP_INLINE int odp_packet_copy_from_mem(odp_packet_t pkt, uint32_t offset,
while (len > 0) {
mapaddr = odp_packet_offset(pkt, offset, &seglen, NULL);
cpylen = len > seglen ? seglen : len;
- memcpy(mapaddr, srcaddr, cpylen);
+ rte_memcpy(mapaddr, srcaddr, cpylen);
offset += cpylen;
srcaddr += cpylen;
len -= cpylen;
@@ -359,6 +360,20 @@ _ODP_INLINE int odp_packet_copy_from_mem(odp_packet_t pkt, uint32_t offset,
return 0;
}
+_ODP_INLINE int odp_packet_copy_from_mem(odp_packet_t pkt, uint32_t offset,
+ uint32_t len, const void *src)
+{
+ uint32_t seg_len = odp_packet_seg_len(pkt);
+ uint8_t *data = (uint8_t *)odp_packet_data(pkt);
+
+ if (odp_unlikely(offset + len > seg_len))
+ return _odp_packet_copy_from_mem_seg(pkt, offset, len, src);
+
+ rte_memcpy(data + offset, src, len);
+
+ return 0;
+}
+
_ODP_INLINE odp_packet_t odp_packet_from_event(odp_event_t ev)
{
return (odp_packet_t)ev;