aboutsummaryrefslogtreecommitdiff
path: root/platform/linux-dpdk/include
diff options
context:
space:
mode:
authorVincent Hsu <vincent.hsu@linaro.org>2014-07-21 11:52:01 +0530
committerMaxim Uvarov <maxim.uvarov@linaro.org>2014-07-23 15:15:25 +0400
commit7cc718acd1fefaf3375fd7bbfad3dade0ca9e2dc (patch)
tree083dae11a6828a494325c0c0cce0b697ad63825b /platform/linux-dpdk/include
parentf9c3c07126c2d91e671464450cceb9c389a13cc9 (diff)
Initial ODP-DPDK port
- Pulled necessary files from platform/linux-generic into platform/linux-dpdk - Made necessary changes in files to get it compiled with dpdk library for eg., * odp_buffer_hdr_t is mapped to struct rte_mbuf * All odp_buffer_* maps to rte_* in dpdk * necessary initialisations like odp_init_dpdk * All packet related changes in odp_packet.c and odp_packet_io.c * dpdk support in odp_packet_dpdk.c Signed-off-by: Vincent Hsu <vincent.hsu@linaro.org> - Add/modify files to support linux-dpdk compilation in new automake environment. * Modified configure.ac * Added platform/linux-dpdk/Makefile.am * Moved all files from platform/linux-dpdk/source to platform/linux-dpdk/. - Added platform/linux-dpdk/README on how to clone, compile DPDK and commands to execute on ODP. - Made ODP_BUFFER_<TYPES> consistent with linux-generic. - Removed odp_buffer_is_scatter API to be inline with linux-generic. - Added platform/linux-dpdk/odp_linux.c to supply the function and argument to the pthread created by dpdk. Signed-off-by: Venkatesh Vivekanandan <venkatesh.vivekanandan@linaro.org>
Diffstat (limited to 'platform/linux-dpdk/include')
-rw-r--r--platform/linux-dpdk/include/api/odp_buffer.h94
-rw-r--r--platform/linux-dpdk/include/api/odp_buffer_pool.h99
-rw-r--r--platform/linux-dpdk/include/api/odp_packet.h228
-rw-r--r--platform/linux-dpdk/include/api/odp_pktio_types.h45
-rw-r--r--platform/linux-dpdk/include/odp_buffer_internal.h72
-rw-r--r--platform/linux-dpdk/include/odp_buffer_pool_internal.h90
-rw-r--r--platform/linux-dpdk/include/odp_packet_dpdk.h87
-rw-r--r--platform/linux-dpdk/include/odp_packet_internal.h139
-rw-r--r--platform/linux-dpdk/include/odp_packet_io_internal.h51
9 files changed, 905 insertions, 0 deletions
diff --git a/platform/linux-dpdk/include/api/odp_buffer.h b/platform/linux-dpdk/include/api/odp_buffer.h
new file mode 100644
index 000000000..9ea1ed8a1
--- /dev/null
+++ b/platform/linux-dpdk/include/api/odp_buffer.h
@@ -0,0 +1,94 @@
+/* Copyright (c) 2013, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+
+/**
+ * @file
+ *
+ * ODP buffer descriptor
+ */
+
+#ifndef ODP_BUFFER_H_
+#define ODP_BUFFER_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+
+#include <odp_std_types.h>
+
+
+
+
+
+/**
+ * ODP buffer
+ */
+typedef unsigned long odp_buffer_t;
+
+
+#define ODP_BUFFER_INVALID (0xffffffff) /**< Invalid buffer */
+
+
+/**
+ * Buffer start address
+ *
+ * @param buf Buffer handle
+ *
+ * @return Buffer start address
+ */
+void *odp_buffer_addr(odp_buffer_t buf);
+
+/**
+ * Buffer maximum data size
+ *
+ * @param buf Buffer handle
+ *
+ * @return Buffer maximum data size
+ */
+size_t odp_buffer_size(odp_buffer_t buf);
+
+/**
+ * Buffer type
+ *
+ * @param buf Buffer handle
+ *
+ * @return Buffer type
+ */
+int odp_buffer_type(odp_buffer_t buf);
+
+#define ODP_BUFFER_TYPE_INVALID (-1) /**< Buffer type invalid */
+#define ODP_BUFFER_TYPE_ANY 0 /**< Buffer that can hold any other
+ buffer type */
+#define ODP_BUFFER_TYPE_RAW 1 /**< Raw buffer, no additional metadata */
+#define ODP_BUFFER_TYPE_PACKET 2 /**< Packet buffer */
+#define ODP_BUFFER_TYPE_TIMEOUT 3 /**< Timeout buffer */
+
+/**
+ * Tests if buffer is valid
+ *
+ * @param buf Buffer handle
+ *
+ * @return 1 if valid, otherwise 0
+ */
+int odp_buffer_is_valid(odp_buffer_t buf);
+
+/**
+ * Print buffer metadata to STDOUT
+ *
+ * @param buf Buffer handle
+ *
+ */
+void odp_buffer_print(odp_buffer_t buf);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/platform/linux-dpdk/include/api/odp_buffer_pool.h b/platform/linux-dpdk/include/api/odp_buffer_pool.h
new file mode 100644
index 000000000..4b75cf53c
--- /dev/null
+++ b/platform/linux-dpdk/include/api/odp_buffer_pool.h
@@ -0,0 +1,99 @@
+/* Copyright (c) 2013, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+
+/**
+ * @file
+ *
+ * ODP buffer pool
+ */
+
+#ifndef ODP_BUFFER_POOL_H_
+#define ODP_BUFFER_POOL_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+
+#include <odp_std_types.h>
+#include <odp_buffer.h>
+
+/** Maximum queue name lenght in chars */
+#define ODP_BUFFER_POOL_NAME_LEN 32
+
+/** Invalid buffer pool */
+#define ODP_BUFFER_POOL_INVALID (0xffffffff)
+
+/** ODP buffer pool */
+typedef unsigned long odp_buffer_pool_t;
+
+
+/**
+ * Create a buffer pool
+ *
+ * @param name Name of the pool (max ODP_BUFFER_POOL_NAME_LEN - 1 chars)
+ * @param base_addr Pool base address
+ * @param size Pool size in bytes
+ * @param buf_size Buffer size in bytes
+ * @param buf_align Minimum buffer alignment
+ * @param buf_type Buffer type
+ *
+ * @return Buffer pool handle
+ */
+odp_buffer_pool_t odp_buffer_pool_create(const char *name,
+ void *base_addr, uint64_t size,
+ size_t buf_size, size_t buf_align,
+ int buf_type);
+
+
+/**
+ * Find a buffer pool by name
+ *
+ * @param name Name of the pool
+ *
+ * @return Buffer pool handle, or ODP_BUFFER_POOL_INVALID if not found.
+ */
+odp_buffer_pool_t odp_buffer_pool_lookup(const char *name);
+
+
+/**
+ * Print buffer pool info
+ *
+ * @param pool Pool handle
+ *
+ */
+void odp_buffer_pool_print(odp_buffer_pool_t pool);
+
+
+
+/**
+ * Buffer alloc
+ *
+ * @param pool Pool handle
+ *
+ * @return Buffer handle or ODP_BUFFER_INVALID
+ */
+odp_buffer_t odp_buffer_alloc(odp_buffer_pool_t pool);
+
+
+/**
+ * Buffer free
+ *
+ * @param buf Buffer handle
+ *
+ */
+void odp_buffer_free(odp_buffer_t buf);
+
+
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/platform/linux-dpdk/include/api/odp_packet.h b/platform/linux-dpdk/include/api/odp_packet.h
new file mode 100644
index 000000000..bdb34170f
--- /dev/null
+++ b/platform/linux-dpdk/include/api/odp_packet.h
@@ -0,0 +1,228 @@
+/* Copyright (c) 2013, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+
+/**
+ * @file
+ *
+ * ODP packet descriptor
+ */
+
+#ifndef ODP_PACKET_H_
+#define ODP_PACKET_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <odp_buffer.h>
+
+
+/**
+ * ODP packet descriptor
+ */
+typedef unsigned long odp_packet_t;
+
+
+/** Invalid packet */
+#define ODP_PACKET_INVALID ODP_BUFFER_INVALID
+
+/** Invalid offset */
+#define ODP_PACKET_OFFSET_INVALID ((size_t)-1)
+
+
+/**
+ * Initialize the packet
+ *
+ * Needs to be called if the user allocates a packet buffer, i.e. the packet
+ * has not been received from I/O through ODP.
+ *
+ * @param pkt Packet handle
+ */
+void odp_packet_init(odp_packet_t pkt);
+
+/**
+ * Convert from packet handle to buffer handle
+ *
+ * @param buf Buffer handle
+ *
+ * @return Packet handle
+ */
+odp_packet_t odp_packet_from_buffer(odp_buffer_t buf);
+
+/**
+ * Convert from buffer handle to packet handle
+ *
+ * @param pkt Packet handle
+ *
+ * @return Buffer handle
+ */
+odp_buffer_t odp_buffer_from_packet(odp_packet_t pkt);
+
+/**
+ * Set the packet length
+ *
+ * @param pkt Packet handle
+ * @param len Length of packet in bytes
+ */
+void odp_packet_set_len(odp_packet_t pkt, size_t len);
+
+/**
+ * Get the packet length
+ *
+ * @param pkt Packet handle
+ *
+ * @return Packet length in bytes
+ */
+size_t odp_packet_get_len(odp_packet_t pkt);
+
+/**
+ * Get address to the start of the packet buffer
+ *
+ * The address of the packet buffer is not necessarily the same as the start
+ * address of the received frame, e.g. an eth frame may be offset by 2 or 6
+ * bytes to ensure 32 or 64-bit alignment of the IP header.
+ * Use odp_packet_l2(pkt) to get the start address of a received valid frame
+ * or odp_packet_start(pkt) to get the start address even if no valid L2 header
+ * could be found.
+ *
+ * @param pkt Packet handle
+ *
+ * @return Pointer to the start of the packet buffer
+ *
+ * @see odp_packet_l2(), odp_packet_start()
+ */
+uint8_t *odp_packet_buf_addr(odp_packet_t pkt);
+
+/**
+ * Get pointer to the start of the received frame
+ *
+ * The address of the packet buffer is not necessarily the same as the start
+ * address of the received frame, e.g. an eth frame may be offset by 2 or 6
+ * bytes to ensure 32 or 64-bit alignment of the IP header.
+ * Use odp_packet_l2(pkt) to get the start address of a received valid eth frame
+ *
+ * odp_packet_start() will always return a pointer to the start of the frame,
+ * even if the frame is unrecognized and no valid L2 header could be found.
+ *
+ * @param pkt Packet handle
+ *
+ * @return Pointer to the start of the received frame
+ *
+ * @see odp_packet_l2(), odp_packet_buf_addr()
+ */
+uint8_t *odp_packet_start(odp_packet_t pkt);
+
+/**
+ * Get pointer to the start of the L2 frame
+ *
+ * The L2 frame header address is not necessarily the same as the address of the
+ * packet buffer, see odp_packet_buf_addr()
+ *
+ * @param pkt Packet handle
+ *
+ * @return Pointer to L2 header or NULL if not found
+ *
+ * @see odp_packet_buf_addr(), odp_packet_start()
+ */
+uint8_t *odp_packet_l2(odp_packet_t pkt);
+
+/**
+ * Return the byte offset from the packet buffer to the L2 frame
+ *
+ * @param pkt Packet handle
+ *
+ * @return L2 byte offset or ODP_PACKET_OFFSET_INVALID if not found
+ */
+size_t odp_packet_l2_offset(odp_packet_t pkt);
+
+/**
+ * Set the byte offset to the L2 frame
+ *
+ * @param pkt Packet handle
+ * @param offset L2 byte offset
+ */
+void odp_packet_set_l2_offset(odp_packet_t pkt, size_t offset);
+
+
+/**
+ * Get pointer to the start of the L3 packet
+ *
+ * @param pkt Packet handle
+ *
+ * @return Pointer to L3 packet or NULL if not found
+ *
+ */
+uint8_t *odp_packet_l3(odp_packet_t pkt);
+
+/**
+ * Return the byte offset from the packet buffer to the L3 packet
+ *
+ * @param pkt Packet handle
+ *
+ * @return L3 byte offset or ODP_PACKET_OFFSET_INVALID if not found
+ */
+size_t odp_packet_l3_offset(odp_packet_t pkt);
+
+/**
+ * Set the byte offset to the L3 packet
+ *
+ * @param pkt Packet handle
+ * @param offset L3 byte offset
+ */
+void odp_packet_set_l3_offset(odp_packet_t pkt, size_t offset);
+
+
+/**
+ * Get pointer to the start of the L4 packet
+ *
+ * @param pkt Packet handle
+ *
+ * @return Pointer to L4 packet or NULL if not found
+ *
+ */
+uint8_t *odp_packet_l4(odp_packet_t pkt);
+
+/**
+ * Return the byte offset from the packet buffer to the L4 packet
+ *
+ * @param pkt Packet handle
+ *
+ * @return L4 byte offset or ODP_PACKET_OFFSET_INVALID if not found
+ */
+size_t odp_packet_l4_offset(odp_packet_t pkt);
+
+/**
+ * Set the byte offset to the L4 packet
+ *
+ * @param pkt Packet handle
+ * @param offset L4 byte offset
+ */
+void odp_packet_set_l4_offset(odp_packet_t pkt, size_t offset);
+
+/**
+ * Print (debug) information about the packet
+ *
+ * @param pkt Packet handle
+ */
+void odp_packet_print(odp_packet_t pkt);
+
+/**
+ * Copy contents and metadata from pkt_src to pkt_dst
+ * Useful when creating copies of packets
+ *
+ * @param pkt_dst Destination packet
+ * @param pkt_src Source packet
+ *
+ * @return 0 if successful
+ */
+int odp_packet_copy(odp_packet_t pkt_dst, odp_packet_t pkt_src);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/platform/linux-dpdk/include/api/odp_pktio_types.h b/platform/linux-dpdk/include/api/odp_pktio_types.h
new file mode 100644
index 000000000..b23e6da92
--- /dev/null
+++ b/platform/linux-dpdk/include/api/odp_pktio_types.h
@@ -0,0 +1,45 @@
+
+/* Copyright (c) 2013, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef ODP_PKTIO_TYPES_H
+#define ODP_PKTIO_TYPES_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* We should ensure that future enum values will never overlap, otherwise
+ * applications that want netmap suport might get in trouble if the odp lib
+ * was not built with netmap support and there are more types define below
+ */
+
+typedef enum {
+ ODP_PKTIO_TYPE_SOCKET_BASIC = 0x1,
+ ODP_PKTIO_TYPE_SOCKET_MMSG,
+ ODP_PKTIO_TYPE_SOCKET_MMAP,
+ ODP_PKTIO_TYPE_NETMAP,
+ ODP_PKTIO_TYPE_DPDK,
+} odp_pktio_type_t;
+
+#include <odp_pktio_socket.h>
+#ifdef ODP_HAVE_NETMAP
+#include <odp_pktio_netmap.h>
+#endif
+
+typedef union odp_pktio_params_t {
+ odp_pktio_type_t type;
+ socket_params_t sock_params;
+#ifdef ODP_HAVE_NETMAP
+ netmap_params_t nm_params;
+#endif
+} odp_pktio_params_t;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/platform/linux-dpdk/include/odp_buffer_internal.h b/platform/linux-dpdk/include/odp_buffer_internal.h
new file mode 100644
index 000000000..f87ec806a
--- /dev/null
+++ b/platform/linux-dpdk/include/odp_buffer_internal.h
@@ -0,0 +1,72 @@
+/* Copyright (c) 2013, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+
+/**
+ * @file
+ *
+ * ODP buffer descriptor - implementation internal
+ */
+
+#ifndef ODP_BUFFER_INTERNAL_H_
+#define ODP_BUFFER_INTERNAL_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <odp_std_types.h>
+#include <odp_atomic.h>
+#include <odp_buffer_pool.h>
+#include <odp_buffer.h>
+#include <odp_debug.h>
+#include <odp_align.h>
+#include <rte_mbuf.h>
+
+/* TODO: move these to correct files */
+
+typedef uint64_t odp_phys_addr_t;
+
+#define ODP_BUFFER_MAX_INDEX (ODP_BUFFER_MAX_BUFFERS - 2)
+#define ODP_BUFFER_INVALID_INDEX (ODP_BUFFER_MAX_BUFFERS - 1)
+
+#define ODP_BUFS_PER_CHUNK 16
+#define ODP_BUFS_PER_SCATTER 4
+
+#define ODP_BUFFER_TYPE_CHUNK 0xffff
+
+
+#define ODP_BUFFER_POOL_BITS 4
+#define ODP_BUFFER_INDEX_BITS (32 - ODP_BUFFER_POOL_BITS)
+#define ODP_BUFFER_MAX_POOLS (1 << ODP_BUFFER_POOL_BITS)
+#define ODP_BUFFER_MAX_BUFFERS (1 << ODP_BUFFER_INDEX_BITS)
+
+typedef union odp_buffer_bits_t {
+ uint32_t u32;
+ odp_buffer_t handle;
+
+ struct {
+ uint32_t pool:ODP_BUFFER_POOL_BITS;
+ uint32_t index:ODP_BUFFER_INDEX_BITS;
+ };
+} odp_buffer_bits_t;
+
+
+/* forward declaration */
+struct odp_buffer_hdr_t;
+
+
+typedef struct rte_mbuf odp_buffer_hdr_t;
+
+
+int odp_buffer_snprint(char *str, size_t n, odp_buffer_t buf);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/platform/linux-dpdk/include/odp_buffer_pool_internal.h b/platform/linux-dpdk/include/odp_buffer_pool_internal.h
new file mode 100644
index 000000000..1a3665591
--- /dev/null
+++ b/platform/linux-dpdk/include/odp_buffer_pool_internal.h
@@ -0,0 +1,90 @@
+/* Copyright (c) 2013, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+
+/**
+ * @file
+ *
+ * ODP buffer pool - internal header
+ */
+
+#ifndef ODP_BUFFER_POOL_INTERNAL_H_
+#define ODP_BUFFER_POOL_INTERNAL_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <odp_std_types.h>
+#include <odp_buffer_pool.h>
+#include <odp_buffer_internal.h>
+#include <odp_align.h>
+#include <odp_hints.h>
+#include <odp_config.h>
+#include <odp_debug.h>
+
+/* for DPDK */
+#include <rte_mempool.h>
+
+/* Use ticketlock instead of spinlock */
+#define POOL_USE_TICKETLOCK
+
+/* Extra error checks */
+/* #define POOL_ERROR_CHECK */
+
+
+#ifdef POOL_USE_TICKETLOCK
+#include <odp_ticketlock.h>
+#else
+#include <odp_spinlock.h>
+#endif
+
+
+struct pool_entry_s {
+#ifdef POOL_USE_TICKETLOCK
+ odp_ticketlock_t lock ODP_ALIGNED_CACHE;
+#else
+ odp_spinlock_t lock ODP_ALIGNED_CACHE;
+#endif
+
+ uint64_t free_bufs;
+ char name[ODP_BUFFER_POOL_NAME_LEN];
+
+
+ odp_buffer_pool_t pool ODP_ALIGNED_CACHE;
+ uintptr_t buf_base;
+ size_t buf_size;
+ size_t buf_offset;
+ uint64_t num_bufs;
+ void *pool_base_addr;
+ uint64_t pool_size;
+ size_t payload_size;
+ size_t payload_align;
+ int buf_type;
+ size_t hdr_size;
+};
+
+
+extern void *pool_entry_ptr[];
+
+
+static inline void *get_pool_entry(odp_buffer_pool_t pool_id)
+{
+ return pool_entry_ptr[pool_id];
+}
+
+
+static inline odp_buffer_hdr_t *odp_buf_to_hdr(odp_buffer_t buf)
+{
+ return (odp_buffer_hdr_t *)buf;
+}
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/platform/linux-dpdk/include/odp_packet_dpdk.h b/platform/linux-dpdk/include/odp_packet_dpdk.h
new file mode 100644
index 000000000..bcbe9e80f
--- /dev/null
+++ b/platform/linux-dpdk/include/odp_packet_dpdk.h
@@ -0,0 +1,87 @@
+/* Copyright (c) 2013, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+#ifndef ODP_PACKET_DPDK_H
+#define ODP_PACKET_DPDK_H
+
+#include <stdint.h>
+#include <net/if.h>
+
+#include <helper/odp_eth.h>
+#include <helper/odp_packet_helper.h>
+#include <odp_align.h>
+#include <odp_debug.h>
+#include <odp_packet.h>
+#include <odp_packet_internal.h>
+#include <odp_buffer_pool.h>
+#include <odp_buffer_pool_internal.h>
+#include <odp_buffer_internal.h>
+#include <odp_std_types.h>
+
+#include <rte_config.h>
+#include <rte_memory.h>
+#include <rte_memzone.h>
+#include <rte_launch.h>
+#include <rte_tailq.h>
+#include <rte_eal.h>
+#include <rte_per_lcore.h>
+#include <rte_lcore.h>
+#include <rte_branch_prediction.h>
+#include <rte_prefetch.h>
+#include <rte_cycles.h>
+#include <rte_errno.h>
+#include <rte_debug.h>
+#include <rte_log.h>
+#include <rte_byteorder.h>
+#include <rte_pci.h>
+#include <rte_random.h>
+#include <rte_ether.h>
+#include <rte_ethdev.h>
+#include <rte_hash.h>
+#include <rte_jhash.h>
+#include <rte_hash_crc.h>
+
+
+#define ODP_DPDK_MODE_HW 0
+#define ODP_DPDK_MODE_SW 1
+
+#define DPDK_BLOCKING_IO
+
+/** Packet socket using dpdk mmaped rings for both Rx and Tx */
+typedef struct {
+ odp_buffer_pool_t pool;
+
+ /********************************/
+ char ifname[32];
+ uint8_t portid;
+ uint16_t queueid;
+} pkt_dpdk_t;
+
+/**
+ * Configure an interface to work in dpdk mode
+ */
+int setup_pkt_dpdk(pkt_dpdk_t * const pkt_dpdk, const char *netdev,
+ odp_buffer_pool_t pool);
+
+/**
+ * Switch interface from dpdk mode to normal mode
+ */
+int close_pkt_dpdk(pkt_dpdk_t * const pkt_dpdk);
+
+/**
+ * Receive packets using dpdk
+ */
+int recv_pkt_dpdk(pkt_dpdk_t * const pkt_dpdk, odp_packet_t pkt_table[],
+ unsigned len);
+
+/**
+ * Send packets using dpdk
+ */
+int send_pkt_dpdk(pkt_dpdk_t * const pkt_dpdk, odp_packet_t pkt_table[],
+ unsigned len);
+
+int odp_init_dpdk(void);
+#endif
diff --git a/platform/linux-dpdk/include/odp_packet_internal.h b/platform/linux-dpdk/include/odp_packet_internal.h
new file mode 100644
index 000000000..0f798c14d
--- /dev/null
+++ b/platform/linux-dpdk/include/odp_packet_internal.h
@@ -0,0 +1,139 @@
+/* Copyright (c) 2014, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+
+/**
+ * @file
+ *
+ * ODP packet descriptor - implementation internal
+ */
+
+#ifndef ODP_PACKET_INTERNAL_H_
+#define ODP_PACKET_INTERNAL_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <odp_align.h>
+#include <odp_debug.h>
+#include <odp_buffer_internal.h>
+#include <odp_buffer_pool_internal.h>
+#include <odp_packet.h>
+#include <odp_packet_io.h>
+
+/**
+ * Packet input & protocol flags
+ */
+typedef union {
+ /* All input flags */
+ uint32_t all;
+
+ struct {
+ /* Bitfield flags for each protocol */
+ uint32_t l2:1; /**< known L2 protocol present */
+ uint32_t l3:1; /**< known L3 protocol present */
+ uint32_t l4:1; /**< known L4 protocol present */
+
+ uint32_t eth:1; /**< Ethernet */
+ uint32_t jumbo:1; /**< Jumbo frame */
+ uint32_t vlan:1; /**< VLAN hdr found */
+ uint32_t vlan_qinq:1; /**< Stacked VLAN found, QinQ */
+
+ uint32_t arp:1; /**< ARP */
+
+ uint32_t ipv4:1; /**< IPv4 */
+ uint32_t ipv6:1; /**< IPv6 */
+ uint32_t ipfrag:1; /**< IP fragment */
+ uint32_t ipopt:1; /**< IP optional headers */
+ uint32_t ipsec:1; /**< IPSec decryption may be needed */
+
+ uint32_t udp:1; /**< UDP */
+ uint32_t tcp:1; /**< TCP */
+ uint32_t sctp:1; /**< SCTP */
+ uint32_t icmp:1; /**< ICMP */
+ };
+} input_flags_t;
+
+ODP_ASSERT(sizeof(input_flags_t) == sizeof(uint32_t), INPUT_FLAGS_SIZE_ERROR);
+
+/**
+ * Packet error flags
+ */
+typedef union {
+ /* All error flags */
+ uint32_t all;
+
+ struct {
+ /* Bitfield flags for each detected error */
+ uint32_t frame_len:1; /**< Frame length error */
+ uint32_t l2_chksum:1; /**< L2 checksum error, checks TBD */
+ uint32_t ip_err:1; /**< IP error, checks TBD */
+ uint32_t tcp_err:1; /**< TCP error, checks TBD */
+ uint32_t udp_err:1; /**< UDP error, checks TBD */
+ };
+} error_flags_t;
+
+ODP_ASSERT(sizeof(error_flags_t) == sizeof(uint32_t), ERROR_FLAGS_SIZE_ERROR);
+
+/**
+ * Packet output flags
+ */
+typedef union {
+ /* All output flags */
+ uint32_t all;
+
+ struct {
+ /* Bitfield flags for each output option */
+ uint32_t l4_chksum:1; /**< Request L4 checksum calculation */
+ };
+} output_flags_t;
+
+ODP_ASSERT(sizeof(output_flags_t) == sizeof(uint32_t), OUTPUT_FLAGS_SIZE_ERROR);
+
+/**
+ * Internal Packet header
+ */
+typedef struct {
+ /* common buffer header */
+ odp_buffer_hdr_t buf_hdr;
+
+ input_flags_t input_flags;
+ error_flags_t error_flags;
+ output_flags_t output_flags;
+
+ uint32_t frame_offset; /**< offset to start of frame, even on error */
+ uint32_t l2_offset; /**< offset to L2 hdr, e.g. Eth */
+ uint32_t l3_offset; /**< offset to L3 hdr, e.g. IPv4, IPv6 */
+ uint32_t l4_offset; /**< offset to L4 hdr (TCP, UDP, SCTP, also ICMP) */
+
+ uint32_t frame_len;
+
+ odp_pktio_t input;
+
+ uint32_t pad;
+ uint8_t payload[];
+
+} odp_packet_hdr_t;
+
+/**
+ * Return the packet header
+ */
+static inline odp_packet_hdr_t *odp_packet_hdr(odp_packet_t pkt)
+{
+ return (odp_packet_hdr_t *)pkt;
+}
+
+/**
+ * Parse packet and set internal metadata
+ */
+void odp_packet_parse(odp_packet_t pkt, size_t len, size_t l2_offset);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/platform/linux-dpdk/include/odp_packet_io_internal.h b/platform/linux-dpdk/include/odp_packet_io_internal.h
new file mode 100644
index 000000000..08abea7a3
--- /dev/null
+++ b/platform/linux-dpdk/include/odp_packet_io_internal.h
@@ -0,0 +1,51 @@
+/* Copyright (c) 2013, Linaro Limited
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: BSD-3-Clause
+ */
+
+
+/**
+ * @file
+ *
+ * ODP packet IO - implementation internal
+ */
+
+#ifndef ODP_PACKET_IO_INTERNAL_H_
+#define ODP_PACKET_IO_INTERNAL_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <odp_spinlock.h>
+#include <odp_packet_socket.h>
+#ifdef ODP_HAVE_NETMAP
+#include <odp_packet_netmap.h>
+#endif
+#include <odp_packet_dpdk.h>
+
+struct pktio_entry {
+ odp_spinlock_t lock; /**< entry spinlock */
+ int taken; /**< is entry taken(1) or free(0) */
+ odp_queue_t inq_default; /**< default input queue, if set */
+ odp_queue_t outq_default; /**< default out queue */
+ odp_pktio_params_t params; /**< pktio parameters */
+ pkt_sock_t pkt_sock; /**< using socket API for IO */
+ pkt_sock_mmap_t pkt_sock_mmap; /**< using socket mmap API for IO */
+#ifdef ODP_HAVE_NETMAP
+ pkt_netmap_t pkt_nm; /**< using netmap API for IO */
+#endif
+ pkt_dpdk_t pkt_dpdk; /**< using DPDK API for IO */
+};
+
+typedef union {
+ struct pktio_entry s;
+ uint8_t pad[ODP_CACHE_LINE_SIZE_ROUNDUP(sizeof(struct pktio_entry))];
+} pktio_entry_t;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif