aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBalasubramanian Manoharan <bala.manoharan@linaro.org>2014-12-08 17:32:55 +0530
committerMaxim Uvarov <maxim.uvarov@linaro.org>2014-12-10 15:55:12 +0300
commit08c99facf9962c0dd2d0ef2e4b4e21cee2d6735c (patch)
tree766a6410bf9c6d8bd6767b6f41f947a9b0e48905
parent08796a4634fd40e558425752bd2352176e70f10d (diff)
linux-generic:pktio:move static inline functions to header
Moves static inline access functions in pktio module to header file. This changes is required as these functions are accessed by classification module Signed-off-by: Balasubramanian Manoharan <bala.manoharan@linaro.org> Reviewed-by: Bill Fischofer <bill.fischofer@linaro.org> Reviewed-by: Ciprian Barbu <ciprian.barbu@linaro.org> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
-rw-r--r--platform/linux-generic/include/odp_packet_io_internal.h17
-rw-r--r--platform/linux-generic/odp_packet_io.c38
2 files changed, 31 insertions, 24 deletions
diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h
index 7819dc7c1..d129f2259 100644
--- a/platform/linux-generic/include/odp_packet_io_internal.h
+++ b/platform/linux-generic/include/odp_packet_io_internal.h
@@ -22,6 +22,8 @@ extern "C" {
#include <odp_packet_socket.h>
#include <odp_align_internal.h>
+#include <odp_config.h>
+#include <odp_hints.h>
#include <linux/if.h>
/**
@@ -50,6 +52,21 @@ typedef union {
uint8_t pad[ODP_CACHE_LINE_SIZE_ROUNDUP(sizeof(struct pktio_entry))];
} pktio_entry_t;
+typedef struct {
+ pktio_entry_t entries[ODP_CONFIG_PKTIO_ENTRIES];
+} pktio_table_t;
+
+extern void *pktio_entry_ptr[];
+
+
+static inline pktio_entry_t *get_pktio_entry(odp_pktio_t id)
+{
+ if (odp_unlikely(id == ODP_PKTIO_INVALID ||
+ id > ODP_CONFIG_PKTIO_ENTRIES))
+ return NULL;
+
+ return pktio_entry_ptr[id - 1];
+}
#ifdef __cplusplus
}
#endif
diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c
index 7e3eca286..19b9eeab2 100644
--- a/platform/linux-generic/odp_packet_io.c
+++ b/platform/linux-generic/odp_packet_io.c
@@ -22,21 +22,10 @@
#include <string.h>
#include <sys/ioctl.h>
-typedef struct {
- pktio_entry_t entries[ODP_CONFIG_PKTIO_ENTRIES];
-} pktio_table_t;
-
static pktio_table_t *pktio_tbl;
-
-static pktio_entry_t *get_entry(odp_pktio_t id)
-{
- if (odp_unlikely(id == ODP_PKTIO_INVALID ||
- id > ODP_CONFIG_PKTIO_ENTRIES))
- return NULL;
-
- return &pktio_tbl->entries[id - 1];
-}
+/* pktio pointer entries ( for inlines) */
+void *pktio_entry_ptr[ODP_CONFIG_PKTIO_ENTRIES];
int odp_pktio_init_global(void)
{
@@ -58,10 +47,11 @@ int odp_pktio_init_global(void)
memset(pktio_tbl, 0, sizeof(pktio_table_t));
for (id = 1; id <= ODP_CONFIG_PKTIO_ENTRIES; ++id) {
- pktio_entry = get_entry(id);
+ pktio_entry = &pktio_tbl->entries[id - 1];
odp_spinlock_init(&pktio_entry->s.lock);
+ pktio_entry_ptr[id - 1] = pktio_entry;
/* Create a default output queue for each pktio resource */
snprintf(name, sizeof(name), "%i-pktio_outq_default", (int)id);
name[ODP_QUEUE_NAME_LEN-1] = '\0';
@@ -140,7 +130,7 @@ static odp_pktio_t alloc_lock_pktio_entry(void)
static int free_pktio_entry(odp_pktio_t id)
{
- pktio_entry_t *entry = get_entry(id);
+ pktio_entry_t *entry = get_pktio_entry(id);
if (entry == NULL)
return -1;
@@ -164,7 +154,7 @@ odp_pktio_t odp_pktio_open(const char *dev, odp_buffer_pool_t pool)
}
/* if successful, alloc_pktio_entry() returns with the entry locked */
- pktio_entry = get_entry(id);
+ pktio_entry = get_pktio_entry(id);
if (!pktio_entry)
return ODP_PKTIO_INVALID;
@@ -216,7 +206,7 @@ int odp_pktio_close(odp_pktio_t id)
pktio_entry_t *entry;
int res = -1;
- entry = get_entry(id);
+ entry = get_pktio_entry(id);
if (entry == NULL)
return -1;
@@ -255,7 +245,7 @@ odp_pktio_t odp_pktio_get_input(odp_packet_t pkt)
int odp_pktio_recv(odp_pktio_t id, odp_packet_t pkt_table[], unsigned len)
{
- pktio_entry_t *pktio_entry = get_entry(id);
+ pktio_entry_t *pktio_entry = get_pktio_entry(id);
int pkts;
int i;
@@ -293,7 +283,7 @@ int odp_pktio_recv(odp_pktio_t id, odp_packet_t pkt_table[], unsigned len)
int odp_pktio_send(odp_pktio_t id, odp_packet_t pkt_table[], unsigned len)
{
- pktio_entry_t *pktio_entry = get_entry(id);
+ pktio_entry_t *pktio_entry = get_pktio_entry(id);
int pkts;
if (pktio_entry == NULL)
@@ -323,7 +313,7 @@ int odp_pktio_send(odp_pktio_t id, odp_packet_t pkt_table[], unsigned len)
int odp_pktio_inq_setdef(odp_pktio_t id, odp_queue_t queue)
{
- pktio_entry_t *pktio_entry = get_entry(id);
+ pktio_entry_t *pktio_entry = get_pktio_entry(id);
queue_entry_t *qentry;
if (pktio_entry == NULL || queue == ODP_QUEUE_INVALID)
@@ -355,7 +345,7 @@ int odp_pktio_inq_remdef(odp_pktio_t id)
odp_queue_t odp_pktio_inq_getdef(odp_pktio_t id)
{
- pktio_entry_t *pktio_entry = get_entry(id);
+ pktio_entry_t *pktio_entry = get_pktio_entry(id);
if (pktio_entry == NULL)
return ODP_QUEUE_INVALID;
@@ -365,7 +355,7 @@ odp_queue_t odp_pktio_inq_getdef(odp_pktio_t id)
odp_queue_t odp_pktio_outq_getdef(odp_pktio_t id)
{
- pktio_entry_t *pktio_entry = get_entry(id);
+ pktio_entry_t *pktio_entry = get_pktio_entry(id);
if (pktio_entry == NULL)
return ODP_QUEUE_INVALID;
@@ -495,7 +485,7 @@ int odp_pktio_set_mtu(odp_pktio_t id, int mtu)
return -1;
}
- entry = get_entry(id);
+ entry = get_pktio_entry(id);
if (entry == NULL) {
ODP_DBG("pktio entry %d does not exist\n", id);
return -1;
@@ -525,7 +515,7 @@ int odp_pktio_mtu(odp_pktio_t id)
struct ifreq ifr;
int ret;
- entry = get_entry(id);
+ entry = get_pktio_entry(id);
if (entry == NULL) {
ODP_DBG("pktio entry %d does not exist\n", id);
return -1;