aboutsummaryrefslogtreecommitdiff
path: root/platform/linux-dpdk/include/api
diff options
context:
space:
mode:
authorVenkatesh Vivekanandan <venkatesh.vivekanandan@linaro.org>2014-10-06 14:00:52 +0530
committerVenkatesh Vivekanandan <venkatesh.vivekanandan@linaro.org>2014-10-06 14:00:52 +0530
commit7d0090a443072ed354cc9e1cd81d16aacb26d64a (patch)
treeb85c8cd81b2271ef58fa042a42fab9e31b7f4eb8 /platform/linux-dpdk/include/api
parent885542fb76691c49fd61f279f07d3d92841c249b (diff)
Revert "git split: delete dpdk"
This reverts commit d8cda8b0f395d00902a50690fee3679f65780013.
Diffstat (limited to 'platform/linux-dpdk/include/api')
-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.h246
-rw-r--r--platform/linux-dpdk/include/api/odp_pktio_types.h45
4 files changed, 484 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..64a92e88b
--- /dev/null
+++ b/platform/linux-dpdk/include/api/odp_packet.h
@@ -0,0 +1,246 @@
+/* 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 odp_buffer_t 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);
+
+/**
+ * Set packet user context
+ *
+ * @param buf Packet handle
+ * @param ctx User context
+ *
+ */
+void odp_packet_set_ctx(odp_packet_t buf, const void *ctx);
+
+/**
+ * Get packet user context
+ *
+ * @param buf Packet handle
+ *
+ * @return User context
+ */
+void *odp_packet_get_ctx(odp_packet_t buf);
+
+/**
+ * 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