This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "".
The branch, master has been updated via 07201e1277cfeb885c7ee2a666575ec9dc8c8d7c (commit) via 617d56864581c2c26dd03158aa5b60c7f845da4c (commit) via ff8eea5c2a9f5283a46376d3bb1bbedd8dd034a4 (commit) via 7cc7193c74553b5f46db482b6d8c7af599d0464a (commit) via 27de124db6343381c25335e611853b487880e9fc (commit) via a3e0a9ddf57e165e682700263f1e0a6e65037c04 (commit) via 9dd6633189cf15ca554cc4ae21996f7db91c6901 (commit) via bcb01a637648278bbbefcd6cdc3014a98de8ed4f (commit) via 8460c9c1b5afab84f4279e6e04cfb1e012965c14 (commit) via 09406916470553a85f30fc14889127443cc4a09b (commit) via ffc3f2bd0059664273425eb0c34411ac5cd88c3e (commit) from 6582ff6158b7e8380536f83da9b0fc25659e3c36 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- commit 07201e1277cfeb885c7ee2a666575ec9dc8c8d7c Author: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Date: Thu May 31 00:52:45 2018 +0300
linux-gen: pktio: drop now-unused union definition
Union, that previously contained different private data items, now has only generic private data array. Drop surrounding union to make code simpler.
Signed-off-by: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index f42e8f0c..69a3072d 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -65,9 +65,7 @@ struct pktio_entry { uint8_t cls_enabled; /**< classifier enabled */ uint8_t chksum_insert_ena; /**< pktout checksum offload enabled */ odp_pktio_t handle; /**< pktio handle */ - union { - unsigned char ODP_ALIGNED_CACHE pkt_priv[PKTIO_PRIVATE_SIZE]; - }; + unsigned char ODP_ALIGNED_CACHE pkt_priv[PKTIO_PRIVATE_SIZE]; enum { /* Not allocated */ PKTIO_STATE_FREE = 0,
commit 617d56864581c2c26dd03158aa5b60c7f845da4c Author: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Date: Wed May 30 19:14:36 2018 +0300
linux-gen: pktio: make null use generic private data field
Signed-off-by: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index c6f1bafd..8670450f 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -111,7 +111,6 @@ noinst_HEADERS = \ include/odp_packet_io_internal.h \ include/odp_packet_io_ipc_internal.h \ include/odp_packet_io_ring_internal.h \ - include/odp_packet_null.h \ include/odp_packet_socket.h \ include/odp_pcapng.h \ include/odp_pkt_queue_internal.h \ diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index b2948e1d..f42e8f0c 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -34,7 +34,6 @@ extern "C" {
#define PKTIO_MAX_QUEUES 64 #include <odp_packet_socket.h> -#include <odp_packet_null.h>
#define PKTIO_NAME_LEN 256
@@ -67,7 +66,6 @@ struct pktio_entry { uint8_t chksum_insert_ena; /**< pktout checksum offload enabled */ odp_pktio_t handle; /**< pktio handle */ union { - pkt_null_t pkt_null; /**< using null for IO */ unsigned char ODP_ALIGNED_CACHE pkt_priv[PKTIO_PRIVATE_SIZE]; }; enum { diff --git a/platform/linux-generic/include/odp_packet_null.h b/platform/linux-generic/include/odp_packet_null.h deleted file mode 100644 index bd9036f1..00000000 --- a/platform/linux-generic/include/odp_packet_null.h +++ /dev/null @@ -1,16 +0,0 @@ -/* Copyright (c) 2018-2018, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef ODP_PACKET_NULL_H_ -#define ODP_PACKET_NULL_H_ - -#include <odp/api/pool.h> - -typedef struct { - int promisc; /**< whether promiscuous mode is on */ -} pkt_null_t; - -#endif diff --git a/platform/linux-generic/pktio/null.c b/platform/linux-generic/pktio/null.c index 49500cab..2f1757b6 100644 --- a/platform/linux-generic/pktio/null.c +++ b/platform/linux-generic/pktio/null.c @@ -8,7 +8,18 @@
#include <odp_api.h> #include <odp_packet_io_internal.h> -#include <odp_packet_null.h> + +typedef struct { + int promisc; /**< whether promiscuous mode is on */ +} pkt_null_t; + +ODP_STATIC_ASSERT(PKTIO_PRIVATE_SIZE >= sizeof(pkt_null_t), + "PKTIO_PRIVATE_SIZE too small"); + +static inline pkt_null_t *pkt_priv(pktio_entry_t *pktio_entry) +{ + return (pkt_null_t *)(uintptr_t)(pktio_entry->s.pkt_priv); +}
static int null_close(pktio_entry_t *pktio_entry ODP_UNUSED) { @@ -21,7 +32,7 @@ static int null_open(odp_pktio_t id ODP_UNUSED, { if (strncmp(devname, "null:", 5) != 0) return -1; - pktio_entry->s.pkt_null.promisc = 0; + pkt_priv(pktio_entry)->promisc = 0; return 0; }
@@ -103,13 +114,13 @@ static int null_mac_addr_get(pktio_entry_t *pktio_entry ODP_UNUSED,
static int null_promisc_mode_set(pktio_entry_t *pktio_entry, odp_bool_t enable) { - pktio_entry->s.pkt_null.promisc = !!enable; + pkt_priv(pktio_entry)->promisc = !!enable; return 0; }
static int null_promisc_mode_get(pktio_entry_t *pktio_entry) { - return pktio_entry->s.pkt_null.promisc; + return pkt_priv(pktio_entry)->promisc; }
static int null_capability(pktio_entry_t *pktio_entry ODP_UNUSED,
commit ff8eea5c2a9f5283a46376d3bb1bbedd8dd034a4 Author: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Date: Wed May 30 19:14:36 2018 +0300
linux-gen: pktio: make ipc use generic private data field
Signed-off-by: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index 702b34f9..b2948e1d 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -50,44 +50,6 @@ extern "C" { /* Forward declaration */ struct pktio_if_ops;
-typedef struct { - /* TX */ - struct { - _ring_t *send; /**< ODP ring for IPC msg packets - indexes transmitted to shared - memory */ - _ring_t *free; /**< ODP ring for IPC msg packets - indexes already processed by remote - process */ - } tx; - /* RX */ - struct { - _ring_t *recv; /**< ODP ring for IPC msg packets - indexes received from shared - memory (from remote process) */ - _ring_t *free; /**< odp ring for ipc msg packets - indexes already processed by - current process */ - _ring_t *cache; /**< local cache to keep packet order right */ - } rx; /* slave */ - void *pool_base; /**< Remote pool base addr */ - void *pool_mdata_base; /**< Remote pool mdata base addr */ - uint64_t pkt_size; /**< Packet size in remote pool */ - odp_pool_t pool; /**< Pool of main process */ - enum { - PKTIO_TYPE_IPC_MASTER = 0, /**< Master is the process which - creates shm */ - PKTIO_TYPE_IPC_SLAVE /**< Slave is the process which - connects to shm */ - } type; /**< define if it's master or slave process */ - odp_atomic_u32_t ready; /**< 1 - pktio is ready and can recv/send - packet, 0 - not yet ready */ - void *pinfo; - odp_shm_t pinfo_shm; - odp_shm_t remote_pool_shm; /**< shm of remote pool get with - _ipc_map_remote_pool() */ -} _ipc_pktio_t; - #if defined(ODP_NETMAP) #define PKTIO_PRIVATE_SIZE 74752 #elif defined(ODP_PKTIO_DPDK) @@ -105,7 +67,6 @@ struct pktio_entry { uint8_t chksum_insert_ena; /**< pktout checksum offload enabled */ odp_pktio_t handle; /**< pktio handle */ union { - _ipc_pktio_t ipc; /**< IPC pktio data */ pkt_null_t pkt_null; /**< using null for IO */ unsigned char ODP_ALIGNED_CACHE pkt_priv[PKTIO_PRIVATE_SIZE]; }; diff --git a/platform/linux-generic/pktio/ipc.c b/platform/linux-generic/pktio/ipc.c index d1e30ab8..3b54962f 100644 --- a/platform/linux-generic/pktio/ipc.c +++ b/platform/linux-generic/pktio/ipc.c @@ -25,6 +25,52 @@ ODP_DBG(fmt, ##__VA_ARGS__);\ } while (0)
+typedef struct { + /* TX */ + struct { + _ring_t *send; /**< ODP ring for IPC msg packets + indexes transmitted to shared + memory */ + _ring_t *free; /**< ODP ring for IPC msg packets + indexes already processed by remote + process */ + } tx; + /* RX */ + struct { + _ring_t *recv; /**< ODP ring for IPC msg packets + indexes received from shared + memory (from remote process) */ + _ring_t *free; /**< odp ring for ipc msg packets + indexes already processed by + current process */ + _ring_t *cache; /**< local cache to keep packet order right */ + } rx; /* slave */ + void *pool_base; /**< Remote pool base addr */ + void *pool_mdata_base; /**< Remote pool mdata base addr */ + uint64_t pkt_size; /**< Packet size in remote pool */ + odp_pool_t pool; /**< Pool of main process */ + enum { + PKTIO_TYPE_IPC_MASTER = 0, /**< Master is the process which + creates shm */ + PKTIO_TYPE_IPC_SLAVE /**< Slave is the process which + connects to shm */ + } type; /**< define if it's master or slave process */ + odp_atomic_u32_t ready; /**< 1 - pktio is ready and can recv/send + packet, 0 - not yet ready */ + void *pinfo; + odp_shm_t pinfo_shm; + odp_shm_t remote_pool_shm; /**< shm of remote pool get with + _ipc_map_remote_pool() */ +} pkt_ipc_t; + +ODP_STATIC_ASSERT(PKTIO_PRIVATE_SIZE >= sizeof(pkt_ipc_t), + "PKTIO_PRIVATE_SIZE too small"); + +static inline pkt_ipc_t *pkt_priv(pktio_entry_t *pktio_entry) +{ + return (pkt_ipc_t *)(uintptr_t)(pktio_entry->s.pkt_priv); +} + /* MAC address for the "ipc" interface */ static const char pktio_ipc_mac[] = {0x12, 0x12, 0x12, 0x12, 0x12, 0x12};
@@ -46,7 +92,7 @@ static const char *_ipc_odp_buffer_pool_shm_name(odp_pool_t pool_hdl)
static int _ipc_master_start(pktio_entry_t *pktio_entry) { - struct pktio_info *pinfo = pktio_entry->s.ipc.pinfo; + struct pktio_info *pinfo = pkt_priv(pktio_entry)->pinfo; odp_shm_t shm;
if (pinfo->slave.init_done == 0) @@ -60,11 +106,11 @@ static int _ipc_master_start(pktio_entry_t *pktio_entry) return -1; }
- pktio_entry->s.ipc.remote_pool_shm = shm; - pktio_entry->s.ipc.pool_base = odp_shm_addr(shm); - pktio_entry->s.ipc.pool_mdata_base = (char *)odp_shm_addr(shm); + pkt_priv(pktio_entry)->remote_pool_shm = shm; + pkt_priv(pktio_entry)->pool_base = odp_shm_addr(shm); + pkt_priv(pktio_entry)->pool_mdata_base = (char *)odp_shm_addr(shm);
- odp_atomic_store_u32(&pktio_entry->s.ipc.ready, 1); + odp_atomic_store_u32(&pkt_priv(pktio_entry)->ready, 1);
IPC_ODP_DBG("%s started.\n", pktio_entry->s.name); return 0; @@ -91,62 +137,62 @@ static int _ipc_init_master(pktio_entry_t *pktio_entry, * to be processed packets ring. */ snprintf(ipc_shm_name, sizeof(ipc_shm_name), "%s_m_prod", dev); - pktio_entry->s.ipc.tx.send = _ring_create(ipc_shm_name, + pkt_priv(pktio_entry)->tx.send = _ring_create(ipc_shm_name, PKTIO_IPC_ENTRIES, _RING_SHM_PROC | _RING_NO_LIST); - if (!pktio_entry->s.ipc.tx.send) { + if (!pkt_priv(pktio_entry)->tx.send) { ODP_ERR("pid %d unable to create ipc ring %s name\n", getpid(), ipc_shm_name); return -1; } ODP_DBG("Created IPC ring: %s, count %d, free %d\n", - ipc_shm_name, _ring_count(pktio_entry->s.ipc.tx.send), - _ring_free_count(pktio_entry->s.ipc.tx.send)); + ipc_shm_name, _ring_count(pkt_priv(pktio_entry)->tx.send), + _ring_free_count(pkt_priv(pktio_entry)->tx.send));
/* generate name in shm like ipc_pktio_p for * already processed packets */ snprintf(ipc_shm_name, sizeof(ipc_shm_name), "%s_m_cons", dev); - pktio_entry->s.ipc.tx.free = _ring_create(ipc_shm_name, + pkt_priv(pktio_entry)->tx.free = _ring_create(ipc_shm_name, PKTIO_IPC_ENTRIES, _RING_SHM_PROC | _RING_NO_LIST); - if (!pktio_entry->s.ipc.tx.free) { + if (!pkt_priv(pktio_entry)->tx.free) { ODP_ERR("pid %d unable to create ipc ring %s name\n", getpid(), ipc_shm_name); goto free_m_prod; } ODP_DBG("Created IPC ring: %s, count %d, free %d\n", - ipc_shm_name, _ring_count(pktio_entry->s.ipc.tx.free), - _ring_free_count(pktio_entry->s.ipc.tx.free)); + ipc_shm_name, _ring_count(pkt_priv(pktio_entry)->tx.free), + _ring_free_count(pkt_priv(pktio_entry)->tx.free));
snprintf(ipc_shm_name, sizeof(ipc_shm_name), "%s_s_prod", dev); - pktio_entry->s.ipc.rx.recv = _ring_create(ipc_shm_name, + pkt_priv(pktio_entry)->rx.recv = _ring_create(ipc_shm_name, PKTIO_IPC_ENTRIES, _RING_SHM_PROC | _RING_NO_LIST); - if (!pktio_entry->s.ipc.rx.recv) { + if (!pkt_priv(pktio_entry)->rx.recv) { ODP_ERR("pid %d unable to create ipc ring %s name\n", getpid(), ipc_shm_name); goto free_m_cons; } ODP_DBG("Created IPC ring: %s, count %d, free %d\n", - ipc_shm_name, _ring_count(pktio_entry->s.ipc.rx.recv), - _ring_free_count(pktio_entry->s.ipc.rx.recv)); + ipc_shm_name, _ring_count(pkt_priv(pktio_entry)->rx.recv), + _ring_free_count(pkt_priv(pktio_entry)->rx.recv));
snprintf(ipc_shm_name, sizeof(ipc_shm_name), "%s_s_cons", dev); - pktio_entry->s.ipc.rx.free = _ring_create(ipc_shm_name, + pkt_priv(pktio_entry)->rx.free = _ring_create(ipc_shm_name, PKTIO_IPC_ENTRIES, _RING_SHM_PROC | _RING_NO_LIST); - if (!pktio_entry->s.ipc.rx.free) { + if (!pkt_priv(pktio_entry)->rx.free) { ODP_ERR("pid %d unable to create ipc ring %s name\n", getpid(), ipc_shm_name); goto free_s_prod; } ODP_DBG("Created IPC ring: %s, count %d, free %d\n", - ipc_shm_name, _ring_count(pktio_entry->s.ipc.rx.free), - _ring_free_count(pktio_entry->s.ipc.rx.free)); + ipc_shm_name, _ring_count(pkt_priv(pktio_entry)->rx.free), + _ring_free_count(pkt_priv(pktio_entry)->rx.free));
/* Set up pool name for remote info */ - pinfo = pktio_entry->s.ipc.pinfo; + pinfo = pkt_priv(pktio_entry)->pinfo; pool_name = _ipc_odp_buffer_pool_shm_name(pool_hdl); if (strlen(pool_name) > ODP_POOL_NAME_LEN) { ODP_ERR("pid %d ipc pool name %s is too big %d\n", @@ -159,7 +205,7 @@ static int _ipc_init_master(pktio_entry_t *pktio_entry, pinfo->slave.pid = 0; pinfo->slave.init_done = 0;
- pktio_entry->s.ipc.pool = pool_hdl; + pkt_priv(pktio_entry)->pool = pool_hdl;
ODP_DBG("Pre init... DONE.\n"); pinfo->master.init_done = 1; @@ -228,7 +274,7 @@ static int _ipc_init_slave(const char *dev, if (strlen(dev) > (ODP_POOL_NAME_LEN - sizeof("_slave_r"))) ODP_ABORT("too big ipc name\n");
- pktio_entry->s.ipc.pool = pool; + pkt_priv(pktio_entry)->pool = pool; return 0; }
@@ -249,61 +295,61 @@ static int _ipc_slave_start(pktio_entry_t *pktio_entry) sprintf(dev, "ipc:%s", tail);
snprintf(ipc_shm_name, sizeof(ipc_shm_name), "%s_m_prod", dev); - pktio_entry->s.ipc.rx.recv = _ipc_shm_map(ipc_shm_name, pid); - if (!pktio_entry->s.ipc.rx.recv) { + pkt_priv(pktio_entry)->rx.recv = _ipc_shm_map(ipc_shm_name, pid); + if (!pkt_priv(pktio_entry)->rx.recv) { ODP_DBG("pid %d unable to find ipc ring %s name\n", getpid(), dev); sleep(1); return -1; } ODP_DBG("Connected IPC ring: %s, count %d, free %d\n", - ipc_shm_name, _ring_count(pktio_entry->s.ipc.rx.recv), - _ring_free_count(pktio_entry->s.ipc.rx.recv)); + ipc_shm_name, _ring_count(pkt_priv(pktio_entry)->rx.recv), + _ring_free_count(pkt_priv(pktio_entry)->rx.recv));
snprintf(ipc_shm_name, sizeof(ipc_shm_name), "%s_m_cons", dev); - pktio_entry->s.ipc.rx.free = _ipc_shm_map(ipc_shm_name, pid); - if (!pktio_entry->s.ipc.rx.free) { + pkt_priv(pktio_entry)->rx.free = _ipc_shm_map(ipc_shm_name, pid); + if (!pkt_priv(pktio_entry)->rx.free) { ODP_ERR("pid %d unable to find ipc ring %s name\n", getpid(), dev); goto free_m_prod; } ODP_DBG("Connected IPC ring: %s, count %d, free %d\n", - ipc_shm_name, _ring_count(pktio_entry->s.ipc.rx.free), - _ring_free_count(pktio_entry->s.ipc.rx.free)); + ipc_shm_name, _ring_count(pkt_priv(pktio_entry)->rx.free), + _ring_free_count(pkt_priv(pktio_entry)->rx.free));
snprintf(ipc_shm_name, sizeof(ipc_shm_name), "%s_s_prod", dev); - pktio_entry->s.ipc.tx.send = _ipc_shm_map(ipc_shm_name, pid); - if (!pktio_entry->s.ipc.tx.send) { + pkt_priv(pktio_entry)->tx.send = _ipc_shm_map(ipc_shm_name, pid); + if (!pkt_priv(pktio_entry)->tx.send) { ODP_ERR("pid %d unable to find ipc ring %s name\n", getpid(), dev); goto free_m_cons; } ODP_DBG("Connected IPC ring: %s, count %d, free %d\n", - ipc_shm_name, _ring_count(pktio_entry->s.ipc.tx.send), - _ring_free_count(pktio_entry->s.ipc.tx.send)); + ipc_shm_name, _ring_count(pkt_priv(pktio_entry)->tx.send), + _ring_free_count(pkt_priv(pktio_entry)->tx.send));
snprintf(ipc_shm_name, sizeof(ipc_shm_name), "%s_s_cons", dev); - pktio_entry->s.ipc.tx.free = _ipc_shm_map(ipc_shm_name, pid); - if (!pktio_entry->s.ipc.tx.free) { + pkt_priv(pktio_entry)->tx.free = _ipc_shm_map(ipc_shm_name, pid); + if (!pkt_priv(pktio_entry)->tx.free) { ODP_ERR("pid %d unable to find ipc ring %s name\n", getpid(), dev); goto free_s_prod; } ODP_DBG("Connected IPC ring: %s, count %d, free %d\n", - ipc_shm_name, _ring_count(pktio_entry->s.ipc.tx.free), - _ring_free_count(pktio_entry->s.ipc.tx.free)); + ipc_shm_name, _ring_count(pkt_priv(pktio_entry)->tx.free), + _ring_free_count(pkt_priv(pktio_entry)->tx.free));
/* Get info about remote pool */ - pinfo = pktio_entry->s.ipc.pinfo; + pinfo = pkt_priv(pktio_entry)->pinfo; shm = _ipc_map_remote_pool(pinfo->master.pool_name, pid); - pktio_entry->s.ipc.remote_pool_shm = shm; - pktio_entry->s.ipc.pool_mdata_base = (char *)odp_shm_addr(shm); - pktio_entry->s.ipc.pkt_size = pinfo->master.block_size; + pkt_priv(pktio_entry)->remote_pool_shm = shm; + pkt_priv(pktio_entry)->pool_mdata_base = (char *)odp_shm_addr(shm); + pkt_priv(pktio_entry)->pkt_size = pinfo->master.block_size;
- _ipc_export_pool(pinfo, pktio_entry->s.ipc.pool); + _ipc_export_pool(pinfo, pkt_priv(pktio_entry)->pool);
- odp_atomic_store_u32(&pktio_entry->s.ipc.ready, 1); + odp_atomic_store_u32(&pkt_priv(pktio_entry)->ready, 1); pinfo->slave.init_done = 1;
ODP_DBG("%s started.\n", pktio_entry->s.name); @@ -342,17 +388,17 @@ static int ipc_pktio_open(odp_pktio_t id ODP_UNUSED, if (strncmp(dev, "ipc", 3)) return -1;
- odp_atomic_init_u32(&pktio_entry->s.ipc.ready, 0); + odp_atomic_init_u32(&pkt_priv(pktio_entry)->ready, 0);
- pktio_entry->s.ipc.rx.cache = _ring_create("ipc_rx_cache", + pkt_priv(pktio_entry)->rx.cache = _ring_create("ipc_rx_cache", PKTIO_IPC_ENTRIES, _RING_NO_LIST); - if (!pktio_entry->s.ipc.rx.cache) + if (!pkt_priv(pktio_entry)->rx.cache) return -1;
/* Shared info about remote pktio */ if (sscanf(dev, "ipc:%d:%s", &pid, tail) == 2) { - pktio_entry->s.ipc.type = PKTIO_TYPE_IPC_SLAVE; + pkt_priv(pktio_entry)->type = PKTIO_TYPE_IPC_SLAVE;
snprintf(name, sizeof(name), "ipc:%s_info", tail); IPC_ODP_DBG("lookup for name %s for pid %d\n", name, pid); @@ -368,12 +414,12 @@ static int ipc_pktio_open(odp_pktio_t id ODP_UNUSED, _ring_destroy("ipc_rx_cache"); return -1; } - pktio_entry->s.ipc.pinfo = pinfo; - pktio_entry->s.ipc.pinfo_shm = shm; + pkt_priv(pktio_entry)->pinfo = pinfo; + pkt_priv(pktio_entry)->pinfo_shm = shm; ODP_DBG("process %d is slave\n", getpid()); ret = _ipc_init_slave(name, pktio_entry, pool); } else { - pktio_entry->s.ipc.type = PKTIO_TYPE_IPC_MASTER; + pkt_priv(pktio_entry)->type = PKTIO_TYPE_IPC_MASTER; snprintf(name, sizeof(name), "%s_info", dev); shm = odp_shm_reserve(name, sizeof(struct pktio_info), ODP_CACHE_LINE_SIZE, @@ -387,8 +433,8 @@ static int ipc_pktio_open(odp_pktio_t id ODP_UNUSED, pinfo = odp_shm_addr(shm); pinfo->master.init_done = 0; pinfo->master.pool_name[0] = 0; - pktio_entry->s.ipc.pinfo = pinfo; - pktio_entry->s.ipc.pinfo_shm = shm; + pkt_priv(pktio_entry)->pinfo = pinfo; + pkt_priv(pktio_entry)->pinfo_shm = shm; ODP_DBG("process %d is master\n", getpid()); ret = _ipc_init_master(pktio_entry, dev, pool); } @@ -408,7 +454,7 @@ static void _ipc_free_ring_packets(pktio_entry_t *pktio_entry, _ring_t *r) if (!r) return;
- pool = pool_entry_from_hdl(pktio_entry->s.ipc.pool); + pool = pool_entry_from_hdl(pkt_priv(pktio_entry)->pool); addr = odp_shm_addr(pool->shm);
rbuf_p = (void *)&offsets; @@ -442,16 +488,16 @@ static int ipc_pktio_recv_lockless(pktio_entry_t *pktio_entry, uint32_t ready; int pkts_ring;
- ready = odp_atomic_load_u32(&pktio_entry->s.ipc.ready); + ready = odp_atomic_load_u32(&pkt_priv(pktio_entry)->ready); if (odp_unlikely(!ready)) { IPC_ODP_DBG("start pktio is missing before usage?\n"); return 0; }
- _ipc_free_ring_packets(pktio_entry, pktio_entry->s.ipc.tx.free); + _ipc_free_ring_packets(pktio_entry, pkt_priv(pktio_entry)->tx.free);
/* rx from cache */ - r = pktio_entry->s.ipc.rx.cache; + r = pkt_priv(pktio_entry)->rx.cache; pkts = _ring_mc_dequeue_burst(r, ipcbufs_p, len); if (odp_unlikely(pkts < 0)) ODP_ABORT("internal error dequeue\n"); @@ -459,7 +505,7 @@ static int ipc_pktio_recv_lockless(pktio_entry_t *pktio_entry, /* rx from other app */ if (pkts == 0) { ipcbufs_p = (void *)&offsets[0]; - r = pktio_entry->s.ipc.rx.recv; + r = pkt_priv(pktio_entry)->rx.recv; pkts = _ring_mc_dequeue_burst(r, ipcbufs_p, len); if (odp_unlikely(pkts < 0)) ODP_ABORT("internal error dequeue\n"); @@ -477,10 +523,11 @@ static int ipc_pktio_recv_lockless(pktio_entry_t *pktio_entry, uint64_t data_pool_off; void *rmt_data_ptr;
- phdr = (void *)((uint8_t *)pktio_entry->s.ipc.pool_mdata_base + + phdr = (void *)((uint8_t *)pkt_priv(pktio_entry)-> + pool_mdata_base + offsets[i]);
- pool = pktio_entry->s.ipc.pool; + pool = pkt_priv(pktio_entry)->pool; if (odp_unlikely(pool == ODP_POOL_INVALID)) ODP_ABORT("invalid pool");
@@ -505,10 +552,11 @@ static int ipc_pktio_recv_lockless(pktio_entry_t *pktio_entry, if (odp_unlikely(!pkt_data)) ODP_ABORT("unable to map pkt_data ipc_slave %d\n", (PKTIO_TYPE_IPC_SLAVE == - pktio_entry->s.ipc.type)); + pkt_priv(pktio_entry)->type));
/* Copy packet data from shared pool to local pool. */ - rmt_data_ptr = (uint8_t *)pktio_entry->s.ipc.pool_mdata_base + + rmt_data_ptr = (uint8_t *)pkt_priv(pktio_entry)-> + pool_mdata_base + data_pool_off; memcpy(pkt_data, rmt_data_ptr, phdr->frame_len);
@@ -528,7 +576,7 @@ static int ipc_pktio_recv_lockless(pktio_entry_t *pktio_entry, /* put back to rx ring dequed but not processed packets*/ if (pkts != i) { ipcbufs_p = (void *)&offsets[i]; - r_p = pktio_entry->s.ipc.rx.cache; + r_p = pkt_priv(pktio_entry)->rx.cache; pkts_ring = _ring_mp_enqueue_burst(r_p, ipcbufs_p, pkts - i);
if (pkts_ring != (pkts - i)) @@ -543,7 +591,7 @@ static int ipc_pktio_recv_lockless(pktio_entry_t *pktio_entry, pkts = i;
/* Now tell other process that we no longer need that buffers.*/ - r_p = pktio_entry->s.ipc.rx.free; + r_p = pkt_priv(pktio_entry)->rx.free;
repeat:
@@ -591,7 +639,8 @@ static int ipc_pktio_send_lockless(pktio_entry_t *pktio_entry, void **rbuf_p; int ret; int i; - uint32_t ready = odp_atomic_load_u32(&pktio_entry->s.ipc.ready); + uint32_t ready = odp_atomic_load_u32(&pkt_priv(pktio_entry)->ready); + pool_t *ipc_pool = pool_entry_from_hdl(pkt_priv(pktio_entry)->pool); odp_packet_t pkt_table_mapped[num]; /**< Ready to send packet has to be * in memory mapped pool. */ uintptr_t offsets[num]; @@ -599,14 +648,13 @@ static int ipc_pktio_send_lockless(pktio_entry_t *pktio_entry, if (odp_unlikely(!ready)) return 0;
- _ipc_free_ring_packets(pktio_entry, pktio_entry->s.ipc.tx.free); + _ipc_free_ring_packets(pktio_entry, pkt_priv(pktio_entry)->tx.free);
/* Copy packets to shm shared pool if they are in different * pool, or if they are references (we can't share across IPC). */ for (i = 0; i < num; i++) { odp_packet_t pkt = pkt_table[i]; - pool_t *ipc_pool = pool_entry_from_hdl(pktio_entry->s.ipc.pool); odp_packet_hdr_t *pkt_hdr; pool_t *pool;
@@ -617,7 +665,8 @@ static int ipc_pktio_send_lockless(pktio_entry_t *pktio_entry, odp_packet_has_ref(pkt)) { odp_packet_t newpkt;
- newpkt = odp_packet_copy(pkt, pktio_entry->s.ipc.pool); + newpkt = odp_packet_copy(pkt, + pkt_priv(pktio_entry)->pool); if (newpkt == ODP_PACKET_INVALID) ODP_ABORT("Unable to copy packet\n");
@@ -650,17 +699,17 @@ static int ipc_pktio_send_lockless(pktio_entry_t *pktio_entry, pkt_hdr, pkt_hdr->buf_hdr.ipc_data_offset, offsets[i], odp_shm_addr(pool->shm), odp_shm_addr(pool_entry_from_hdl( - pktio_entry->s.ipc.pool)->shm)); + pkt_priv(pktio_entry)->pool)->shm)); }
/* Put packets to ring to be processed by other process. */ rbuf_p = (void *)&offsets[0]; - r = pktio_entry->s.ipc.tx.send; + r = pkt_priv(pktio_entry)->tx.send; ret = _ring_mp_enqueue_burst(r, rbuf_p, num); if (odp_unlikely(ret < 0)) { ODP_ERR("pid %d odp_ring_mp_enqueue_bulk fail, ipc_slave %d, ret %d\n", getpid(), - (PKTIO_TYPE_IPC_SLAVE == pktio_entry->s.ipc.type), + (PKTIO_TYPE_IPC_SLAVE == pkt_priv(pktio_entry)->type), ret); ODP_ERR("odp_ring_full: %d, odp_ring_count %d, _ring_free_count %d\n", _ring_full(r), _ring_count(r), @@ -700,14 +749,14 @@ static int ipc_mac_addr_get(pktio_entry_t *pktio_entry ODP_UNUSED,
static int ipc_start(pktio_entry_t *pktio_entry) { - uint32_t ready = odp_atomic_load_u32(&pktio_entry->s.ipc.ready); + uint32_t ready = odp_atomic_load_u32(&pkt_priv(pktio_entry)->ready);
if (ready) { ODP_ABORT("%s Already started\n", pktio_entry->s.name); return -1; }
- if (pktio_entry->s.ipc.type == PKTIO_TYPE_IPC_MASTER) + if (pkt_priv(pktio_entry)->type == PKTIO_TYPE_IPC_MASTER) return _ipc_master_start(pktio_entry); else return _ipc_slave_start(pktio_entry); @@ -717,20 +766,22 @@ static int ipc_stop(pktio_entry_t *pktio_entry) { unsigned tx_send = 0, tx_free = 0;
- odp_atomic_store_u32(&pktio_entry->s.ipc.ready, 0); + odp_atomic_store_u32(&pkt_priv(pktio_entry)->ready, 0);
- if (pktio_entry->s.ipc.tx.send) - _ipc_free_ring_packets(pktio_entry, pktio_entry->s.ipc.tx.send); + if (pkt_priv(pktio_entry)->tx.send) + _ipc_free_ring_packets(pktio_entry, + pkt_priv(pktio_entry)->tx.send); /* other process can transfer packets from one ring to * other, use delay here to free that packets. */ sleep(1); - if (pktio_entry->s.ipc.tx.free) - _ipc_free_ring_packets(pktio_entry, pktio_entry->s.ipc.tx.free); - - if (pktio_entry->s.ipc.tx.send) - tx_send = _ring_count(pktio_entry->s.ipc.tx.send); - if (pktio_entry->s.ipc.tx.free) - tx_free = _ring_count(pktio_entry->s.ipc.tx.free); + if (pkt_priv(pktio_entry)->tx.free) + _ipc_free_ring_packets(pktio_entry, + pkt_priv(pktio_entry)->tx.free); + + if (pkt_priv(pktio_entry)->tx.send) + tx_send = _ring_count(pkt_priv(pktio_entry)->tx.send); + if (pkt_priv(pktio_entry)->tx.free) + tx_free = _ring_count(pkt_priv(pktio_entry)->tx.free); if (tx_send | tx_free) { ODP_DBG("IPC rings: tx send %d tx free %d\n", tx_send, tx_free); @@ -749,7 +800,7 @@ static int ipc_close(pktio_entry_t *pktio_entry)
ipc_stop(pktio_entry);
- odp_shm_free(pktio_entry->s.ipc.remote_pool_shm); + odp_shm_free(pkt_priv(pktio_entry)->remote_pool_shm);
if (sscanf(dev, "ipc:%d:%s", &pid, tail) == 2) snprintf(name, sizeof(name), "ipc:%s", tail); @@ -757,7 +808,7 @@ static int ipc_close(pktio_entry_t *pktio_entry) snprintf(name, sizeof(name), "%s", dev);
/* unlink this pktio info for both master and slave */ - odp_shm_free(pktio_entry->s.ipc.pinfo_shm); + odp_shm_free(pkt_priv(pktio_entry)->pinfo_shm);
/* destroy rings */ snprintf(ipc_shm_name, sizeof(ipc_shm_name), "%s_s_cons", name);
commit 7cc7193c74553b5f46db482b6d8c7af599d0464a Author: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Date: Wed May 30 19:14:36 2018 +0300
linux-gen: pktio: make tap use generic private data field
Signed-off-by: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index ae87d222..c6f1bafd 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -113,7 +113,6 @@ noinst_HEADERS = \ include/odp_packet_io_ring_internal.h \ include/odp_packet_null.h \ include/odp_packet_socket.h \ - include/odp_packet_tap.h \ include/odp_pcapng.h \ include/odp_pkt_queue_internal.h \ include/odp_pool_internal.h \ diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index 216d7185..702b34f9 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -34,7 +34,6 @@ extern "C" {
#define PKTIO_MAX_QUEUES 64 #include <odp_packet_socket.h> -#include <odp_packet_tap.h> #include <odp_packet_null.h>
#define PKTIO_NAME_LEN 256 @@ -106,7 +105,6 @@ struct pktio_entry { uint8_t chksum_insert_ena; /**< pktout checksum offload enabled */ odp_pktio_t handle; /**< pktio handle */ union { - pkt_tap_t pkt_tap; /**< using TAP for IO */ _ipc_pktio_t ipc; /**< IPC pktio data */ pkt_null_t pkt_null; /**< using null for IO */ unsigned char ODP_ALIGNED_CACHE pkt_priv[PKTIO_PRIVATE_SIZE]; diff --git a/platform/linux-generic/include/odp_packet_tap.h b/platform/linux-generic/include/odp_packet_tap.h deleted file mode 100644 index a90bfbce..00000000 --- a/platform/linux-generic/include/odp_packet_tap.h +++ /dev/null @@ -1,21 +0,0 @@ -/* Copyright (c) 2015, Ilya Maximets i.maximets@samsung.com - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef ODP_PACKET_TAP_H_ -#define ODP_PACKET_TAP_H_ - -#include <odp/api/pool.h> - -typedef struct { - int fd; /**< file descriptor for tap interface*/ - int skfd; /**< socket descriptor */ - uint32_t mtu; /**< cached mtu */ - unsigned char if_mac[ETH_ALEN]; /**< MAC address of pktio side (not a - MAC address of kernel interface)*/ - odp_pool_t pool; /**< pool to alloc packets from */ -} pkt_tap_t; - -#endif diff --git a/platform/linux-generic/pktio/tap.c b/platform/linux-generic/pktio/tap.c index a3587f10..12a1945d 100644 --- a/platform/linux-generic/pktio/tap.c +++ b/platform/linux-generic/pktio/tap.c @@ -51,6 +51,23 @@
#define BUF_SIZE 65536
+typedef struct { + int fd; /**< file descriptor for tap interface*/ + int skfd; /**< socket descriptor */ + uint32_t mtu; /**< cached mtu */ + unsigned char if_mac[ETH_ALEN]; /**< MAC address of pktio side (not a + MAC address of kernel interface)*/ + odp_pool_t pool; /**< pool to alloc packets from */ +} pkt_tap_t; + +ODP_STATIC_ASSERT(PKTIO_PRIVATE_SIZE >= sizeof(pkt_tap_t), + "PKTIO_PRIVATE_SIZE too small"); + +static inline pkt_tap_t *pkt_priv(pktio_entry_t *pktio_entry) +{ + return (pkt_tap_t *)(uintptr_t)(pktio_entry->s.pkt_priv); +} + static int gen_random_mac(unsigned char *mac) { mac[0] = 0x7a; /* not multicast and local assignment bit is set */ @@ -91,7 +108,7 @@ static int tap_pktio_open(odp_pktio_t id ODP_UNUSED, int fd, skfd, flags; uint32_t mtu; struct ifreq ifr; - pkt_tap_t *tap = &pktio_entry->s.pkt_tap; + pkt_tap_t *tap = pkt_priv(pktio_entry);
if (strncmp(devname, "tap:", 4) != 0) return -1; @@ -175,7 +192,7 @@ tap_err: static int tap_pktio_start(pktio_entry_t *pktio_entry) { struct ifreq ifr; - pkt_tap_t *tap = &pktio_entry->s.pkt_tap; + pkt_tap_t *tap = pkt_priv(pktio_entry);
odp_memset(&ifr, 0, sizeof(ifr)); snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", @@ -206,7 +223,7 @@ sock_err: static int tap_pktio_stop(pktio_entry_t *pktio_entry) { struct ifreq ifr; - pkt_tap_t *tap = &pktio_entry->s.pkt_tap; + pkt_tap_t *tap = pkt_priv(pktio_entry);
odp_memset(&ifr, 0, sizeof(ifr)); snprintf(ifr.ifr_name, IF_NAMESIZE, "%s", @@ -237,7 +254,7 @@ sock_err: static int tap_pktio_close(pktio_entry_t *pktio_entry) { int ret = 0; - pkt_tap_t *tap = &pktio_entry->s.pkt_tap; + pkt_tap_t *tap = pkt_priv(pktio_entry);
if (tap->fd != -1 && close(tap->fd) != 0) { __odp_errno = errno; @@ -264,13 +281,13 @@ static odp_packet_t pack_odp_pkt(pktio_entry_t *pktio_entry, const void *data,
if (pktio_cls_enabled(pktio_entry)) { if (cls_classify_packet(pktio_entry, data, len, len, - &pktio_entry->s.pkt_tap.pool, + &pkt_priv(pktio_entry)->pool, &parsed_hdr, true)) { return ODP_PACKET_INVALID; } }
- num = packet_alloc_multi(pktio_entry->s.pkt_tap.pool, len, &pkt, 1); + num = packet_alloc_multi(pkt_priv(pktio_entry)->pool, len, &pkt, 1);
if (num != 1) return ODP_PACKET_INVALID; @@ -302,7 +319,7 @@ static int tap_pktio_recv(pktio_entry_t *pktio_entry, int index ODP_UNUSED, ssize_t retval; int i; uint8_t buf[BUF_SIZE]; - pkt_tap_t *tap = &pktio_entry->s.pkt_tap; + pkt_tap_t *tap = pkt_priv(pktio_entry); odp_time_t ts_val; odp_time_t *ts = NULL;
@@ -342,7 +359,7 @@ static int tap_pktio_send_lockless(pktio_entry_t *pktio_entry, int i, n; uint32_t pkt_len; uint8_t buf[BUF_SIZE]; - pkt_tap_t *tap = &pktio_entry->s.pkt_tap; + pkt_tap_t *tap = pkt_priv(pktio_entry);
for (i = 0; i < num; i++) { pkt_len = odp_packet_len(pkts[i]); @@ -405,10 +422,10 @@ static uint32_t tap_mtu_get(pktio_entry_t *pktio_entry) { uint32_t ret;
- ret = mtu_get_fd(pktio_entry->s.pkt_tap.skfd, + ret = mtu_get_fd(pkt_priv(pktio_entry)->skfd, pktio_entry->s.name + 4); if (ret > 0) - pktio_entry->s.pkt_tap.mtu = ret; + pkt_priv(pktio_entry)->mtu = ret;
return ret; } @@ -416,25 +433,25 @@ static uint32_t tap_mtu_get(pktio_entry_t *pktio_entry) static int tap_promisc_mode_set(pktio_entry_t *pktio_entry, odp_bool_t enable) { - return promisc_mode_set_fd(pktio_entry->s.pkt_tap.skfd, + return promisc_mode_set_fd(pkt_priv(pktio_entry)->skfd, pktio_entry->s.name + 4, enable); }
static int tap_promisc_mode_get(pktio_entry_t *pktio_entry) { - return promisc_mode_get_fd(pktio_entry->s.pkt_tap.skfd, + return promisc_mode_get_fd(pkt_priv(pktio_entry)->skfd, pktio_entry->s.name + 4); }
static int tap_mac_addr_get(pktio_entry_t *pktio_entry, void *mac_addr) { - memcpy(mac_addr, pktio_entry->s.pkt_tap.if_mac, ETH_ALEN); + memcpy(mac_addr, pkt_priv(pktio_entry)->if_mac, ETH_ALEN); return ETH_ALEN; }
static int tap_mac_addr_set(pktio_entry_t *pktio_entry, const void *mac_addr) { - pkt_tap_t *tap = &pktio_entry->s.pkt_tap; + pkt_tap_t *tap = pkt_priv(pktio_entry);
memcpy(tap->if_mac, mac_addr, ETH_ALEN);
@@ -444,7 +461,7 @@ static int tap_mac_addr_set(pktio_entry_t *pktio_entry, const void *mac_addr)
static int tap_link_status(pktio_entry_t *pktio_entry) { - return link_status_fd(pktio_entry->s.pkt_tap.skfd, + return link_status_fd(pkt_priv(pktio_entry)->skfd, pktio_entry->s.name + 4); }
commit 27de124db6343381c25335e611853b487880e9fc Author: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Date: Wed May 30 19:14:36 2018 +0300
linux-gen: pktio: make pcap use generic private data field
Signed-off-by: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index a4b2fed7..216d7185 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -51,21 +51,6 @@ extern "C" { /* Forward declaration */ struct pktio_if_ops;
-#ifdef HAVE_PCAP -typedef struct { - char *fname_rx; /**< name of pcap file for rx */ - char *fname_tx; /**< name of pcap file for tx */ - void *rx; /**< rx pcap handle */ - void *tx; /**< tx pcap handle */ - void *tx_dump; /**< tx pcap dumper handle */ - odp_pool_t pool; /**< rx pool */ - unsigned char *buf; /**< per-pktio temp buffer */ - int loops; /**< number of times to loop rx pcap */ - int loop_cnt; /**< number of loops completed */ - odp_bool_t promisc; /**< promiscuous mode state */ -} pkt_pcap_t; -#endif - typedef struct { /* TX */ struct { @@ -121,9 +106,6 @@ struct pktio_entry { uint8_t chksum_insert_ena; /**< pktout checksum offload enabled */ odp_pktio_t handle; /**< pktio handle */ union { -#ifdef HAVE_PCAP - pkt_pcap_t pkt_pcap; /**< Using pcap for IO */ -#endif pkt_tap_t pkt_tap; /**< using TAP for IO */ _ipc_pktio_t ipc; /**< IPC pktio data */ pkt_null_t pkt_null; /**< using null for IO */ diff --git a/platform/linux-generic/pktio/pcap.c b/platform/linux-generic/pktio/pcap.c index f1662930..c6a817fc 100644 --- a/platform/linux-generic/pktio/pcap.c +++ b/platform/linux-generic/pktio/pcap.c @@ -49,6 +49,27 @@ #include <pcap/pcap.h> #include <pcap/bpf.h>
+typedef struct { + char *fname_rx; /**< name of pcap file for rx */ + char *fname_tx; /**< name of pcap file for tx */ + void *rx; /**< rx pcap handle */ + void *tx; /**< tx pcap handle */ + void *tx_dump; /**< tx pcap dumper handle */ + odp_pool_t pool; /**< rx pool */ + unsigned char *buf; /**< per-pktio temp buffer */ + int loops; /**< number of times to loop rx pcap */ + int loop_cnt; /**< number of loops completed */ + odp_bool_t promisc; /**< promiscuous mode state */ +} pkt_pcap_t; + +ODP_STATIC_ASSERT(PKTIO_PRIVATE_SIZE >= sizeof(pkt_pcap_t), + "PKTIO_PRIVATE_SIZE too small"); + +static inline pkt_pcap_t *pkt_priv(pktio_entry_t *pktio_entry) +{ + return (pkt_pcap_t *)(uintptr_t)(pktio_entry->s.pkt_priv); +} + #define PKTIO_PCAP_MTU (64 * 1024) static const char pcap_mac[] = {0x02, 0xe9, 0x34, 0x80, 0x73, 0x04};
@@ -139,7 +160,7 @@ static int _pcapif_init_tx(pkt_pcap_t *pcap) static int pcapif_init(odp_pktio_t id ODP_UNUSED, pktio_entry_t *pktio_entry, const char *devname, odp_pool_t pool) { - pkt_pcap_t *pcap = &pktio_entry->s.pkt_pcap; + pkt_pcap_t *pcap = pkt_priv(pktio_entry); int ret;
memset(pcap, 0, sizeof(pkt_pcap_t)); @@ -166,7 +187,7 @@ static int pcapif_init(odp_pktio_t id ODP_UNUSED, pktio_entry_t *pktio_entry,
static int pcapif_close(pktio_entry_t *pktio_entry) { - pkt_pcap_t *pcap = &pktio_entry->s.pkt_pcap; + pkt_pcap_t *pcap = pkt_priv(pktio_entry);
if (pcap->tx_dump) pcap_dump_close(pcap->tx_dump); @@ -213,7 +234,7 @@ static int pcapif_recv_pkt(pktio_entry_t *pktio_entry, int index ODP_UNUSED, odp_packet_t pkt; odp_packet_hdr_t *pkt_hdr; uint32_t pkt_len; - pkt_pcap_t *pcap = &pktio_entry->s.pkt_pcap; + pkt_pcap_t *pcap = pkt_priv(pktio_entry); odp_time_t ts_val; odp_time_t *ts = NULL;
@@ -297,7 +318,7 @@ static int _pcapif_dump_pkt(pkt_pcap_t *pcap, odp_packet_t pkt) static int pcapif_send_pkt(pktio_entry_t *pktio_entry, int index ODP_UNUSED, const odp_packet_t pkts[], int num) { - pkt_pcap_t *pcap = &pktio_entry->s.pkt_pcap; + pkt_pcap_t *pcap = pkt_priv(pktio_entry); int i;
odp_ticketlock_lock(&pktio_entry->s.txl); @@ -365,7 +386,7 @@ static int pcapif_promisc_mode_set(pktio_entry_t *pktio_entry, { char filter_exp[64] = {0}; struct bpf_program bpf; - pkt_pcap_t *pcap = &pktio_entry->s.pkt_pcap; + pkt_pcap_t *pcap = pkt_priv(pktio_entry);
if (!pcap->rx) { pcap->promisc = enable; @@ -405,7 +426,7 @@ static int pcapif_promisc_mode_set(pktio_entry_t *pktio_entry,
static int pcapif_promisc_mode_get(pktio_entry_t *pktio_entry) { - return pktio_entry->s.pkt_pcap.promisc; + return pkt_priv(pktio_entry)->promisc; }
static int pcapif_stats_reset(pktio_entry_t *pktio_entry)
commit a3e0a9ddf57e165e682700263f1e0a6e65037c04 Author: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Date: Wed May 30 19:14:36 2018 +0300
linux-gen: pktio: make dpdk use generic private data field
Signed-off-by: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/include/odp_packet_dpdk.h b/platform/linux-generic/include/odp_packet_dpdk.h index 020c2b97..d457cfa3 100644 --- a/platform/linux-generic/include/odp_packet_dpdk.h +++ b/platform/linux-generic/include/odp_packet_dpdk.h @@ -8,70 +8,10 @@ #define ODP_PACKET_DPDK_H
#include <odp/api/packet_io.h> -#include <odp/api/pool.h> -#include <odp/api/ticketlock.h>
-#include <net/if.h> - -#ifdef ODP_PKTIO_DPDK -#include <rte_config.h> -#include <rte_mbuf.h> - -#define DPDK_MEMORY_MB 512 -#define DPDK_NB_MBUF 16384 -#define DPDK_MBUF_BUF_SIZE RTE_MBUF_DEFAULT_BUF_SIZE -#define DPDK_MEMPOOL_CACHE_SIZE 64 - -ODP_STATIC_ASSERT((DPDK_NB_MBUF % DPDK_MEMPOOL_CACHE_SIZE == 0) && - (DPDK_MEMPOOL_CACHE_SIZE <= RTE_MEMPOOL_CACHE_MAX_SIZE) && - (DPDK_MEMPOOL_CACHE_SIZE <= DPDK_MBUF_BUF_SIZE * 10 / 15) - , "DPDK mempool cache size failure"); -#endif - -/* Minimum RX burst size */ -#define DPDK_MIN_RX_BURST 4 - -/** DPDK runtime configuration options */ -typedef struct { - int num_rx_desc; - int num_tx_desc; - int rx_drop_en; -} dpdk_opt_t; +struct rte_mbuf;
/** Cache for storing packets */ -struct pkt_cache_t { - /** array for storing extra RX packets */ - struct rte_mbuf *pkt[DPDK_MIN_RX_BURST]; - unsigned idx; /**< head of cache */ - unsigned count; /**< packets in cache */ -}; - -typedef union ODP_ALIGNED_CACHE { - struct pkt_cache_t s; - uint8_t pad[ROUNDUP_CACHE_LINE(sizeof(struct pkt_cache_t))]; -} pkt_cache_t; - -/** Packet IO using DPDK interface */ -typedef struct ODP_ALIGNED_CACHE { - odp_pool_t pool; /**< pool to alloc packets from */ - struct rte_mempool *pkt_pool; /**< DPDK packet pool */ - uint32_t data_room; /**< maximum packet length */ - unsigned min_rx_burst; /**< minimum RX burst size */ - odp_pktin_hash_proto_t hash; /**< Packet input hash protocol */ - uint16_t mtu; /**< maximum transmission unit */ - uint16_t port_id; /**< DPDK port identifier */ - /** Use system call to get/set vdev promisc mode */ - uint8_t vdev_sysc_promisc; - uint8_t lockless_rx; /**< no locking for rx */ - uint8_t lockless_tx; /**< no locking for tx */ - /** RX queue locks */ - odp_ticketlock_t ODP_ALIGNED_CACHE rx_lock[PKTIO_MAX_QUEUES]; - odp_ticketlock_t tx_lock[PKTIO_MAX_QUEUES]; /**< TX queue locks */ - /** cache for storing extra RX packets */ - pkt_cache_t rx_cache[PKTIO_MAX_QUEUES]; - dpdk_opt_t opt; -} pkt_dpdk_t; - /** Packet parser using DPDK interface */ int dpdk_packet_parse_common(packet_parser_t *pkt_hdr, const uint8_t *ptr, diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index 600fdd36..a4b2fed7 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -36,7 +36,6 @@ extern "C" { #include <odp_packet_socket.h> #include <odp_packet_tap.h> #include <odp_packet_null.h> -#include <odp_packet_dpdk.h>
#define PKTIO_NAME_LEN 256
@@ -107,6 +106,8 @@ typedef struct {
#if defined(ODP_NETMAP) #define PKTIO_PRIVATE_SIZE 74752 +#elif defined(ODP_PKTIO_DPDK) +#define PKTIO_PRIVATE_SIZE 5632 #else #define PKTIO_PRIVATE_SIZE 384 #endif @@ -120,7 +121,6 @@ struct pktio_entry { uint8_t chksum_insert_ena; /**< pktout checksum offload enabled */ odp_pktio_t handle; /**< pktio handle */ union { - pkt_dpdk_t pkt_dpdk; /**< using DPDK for IO */ #ifdef HAVE_PCAP pkt_pcap_t pkt_pcap; /**< Using pcap for IO */ #endif diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c index 8d93b873..34847f9c 100644 --- a/platform/linux-generic/pktio/dpdk.c +++ b/platform/linux-generic/pktio/dpdk.c @@ -33,6 +33,7 @@ #include <protocols/udp.h>
#include <rte_config.h> +#include <rte_mbuf.h> #include <rte_malloc.h> #if __GNUC__ >= 7 #pragma GCC diagnostic push @@ -74,6 +75,67 @@ ODP_STATIC_ASSERT(PKT_EXTRA_LEN >= sizeof(struct rte_mbuf), #define IXGBE_DRV_NAME "net_ixgbe" #define I40E_DRV_NAME "net_i40e"
+#define DPDK_MEMORY_MB 512 +#define DPDK_NB_MBUF 16384 +#define DPDK_MBUF_BUF_SIZE RTE_MBUF_DEFAULT_BUF_SIZE +#define DPDK_MEMPOOL_CACHE_SIZE 64 + +ODP_STATIC_ASSERT((DPDK_NB_MBUF % DPDK_MEMPOOL_CACHE_SIZE == 0) && + (DPDK_MEMPOOL_CACHE_SIZE <= RTE_MEMPOOL_CACHE_MAX_SIZE) && + (DPDK_MEMPOOL_CACHE_SIZE <= DPDK_MBUF_BUF_SIZE * 10 / 15) + , "DPDK mempool cache size failure"); + +/* Minimum RX burst size */ +#define DPDK_MIN_RX_BURST 4 + +/** DPDK runtime configuration options */ +typedef struct { + int num_rx_desc; + int num_tx_desc; + int rx_drop_en; +} dpdk_opt_t; + +struct pkt_cache_t { + /** array for storing extra RX packets */ + struct rte_mbuf *pkt[DPDK_MIN_RX_BURST]; + unsigned int idx; /**< head of cache */ + unsigned int count; /**< packets in cache */ +}; + +typedef union ODP_ALIGNED_CACHE { + struct pkt_cache_t s; + uint8_t pad[ROUNDUP_CACHE_LINE(sizeof(struct pkt_cache_t))]; +} pkt_cache_t; + +/** Packet IO using DPDK interface */ +typedef struct ODP_ALIGNED_CACHE { + odp_pool_t pool; /**< pool to alloc packets from */ + struct rte_mempool *pkt_pool; /**< DPDK packet pool */ + uint32_t data_room; /**< maximum packet length */ + unsigned int min_rx_burst; /**< minimum RX burst size */ + odp_pktin_hash_proto_t hash; /**< Packet input hash protocol */ + uint16_t mtu; /**< maximum transmission unit */ + uint16_t port_id; /**< DPDK port identifier */ + /** Use system call to get/set vdev promisc mode */ + uint8_t vdev_sysc_promisc; + uint8_t lockless_rx; /**< no locking for rx */ + uint8_t lockless_tx; /**< no locking for tx */ + /** RX queue locks */ + odp_ticketlock_t ODP_ALIGNED_CACHE rx_lock[PKTIO_MAX_QUEUES]; + odp_ticketlock_t tx_lock[PKTIO_MAX_QUEUES]; /**< TX queue locks */ + /** cache for storing extra RX packets */ + pkt_cache_t rx_cache[PKTIO_MAX_QUEUES]; + dpdk_opt_t opt; +} pkt_dpdk_t; + +ODP_STATIC_ASSERT(PKTIO_PRIVATE_SIZE >= sizeof(pkt_dpdk_t), + "PKTIO_PRIVATE_SIZE too small"); + +static inline pkt_dpdk_t *pkt_priv(pktio_entry_t *pktio_entry) +{ + return (pkt_dpdk_t *)(uintptr_t)(pktio_entry->s.pkt_priv); +} + static int disable_pktio; /** !0 this pktio disabled, 0 enabled */
/* Has dpdk_pktio_init() been called */ @@ -121,7 +183,7 @@ static int lookup_opt(const char *opt_name, const char *drv_name, int *val) static int init_options(pktio_entry_t *pktio_entry, const struct rte_eth_dev_info *dev_info) { - dpdk_opt_t *opt = &pktio_entry->s.pkt_dpdk.opt; + dpdk_opt_t *opt = &pkt_priv(pktio_entry)->opt;
if (!lookup_opt("num_rx_desc", dev_info->driver_name, &opt->num_rx_desc)) @@ -149,7 +211,7 @@ static int init_options(pktio_entry_t *pktio_entry, opt->rx_drop_en = !!opt->rx_drop_en;
ODP_PRINT("DPDK interface (%s): %" PRIu16 "\n", dev_info->driver_name, - pktio_entry->s.pkt_dpdk.port_id); + pkt_priv(pktio_entry)->port_id); ODP_PRINT(" num_rx_desc: %d\n", opt->num_rx_desc); ODP_PRINT(" num_tx_desc: %d\n", opt->num_tx_desc); ODP_PRINT(" rx_drop_en: %d\n", opt->rx_drop_en); @@ -434,13 +496,13 @@ static inline int mbuf_to_pkt(pktio_entry_t *pktio_entry, int i, j; int nb_pkts = 0; int alloc_len, num; - odp_pool_t pool = pktio_entry->s.pkt_dpdk.pool; + odp_pool_t pool = pkt_priv(pktio_entry)->pool; odp_pktin_config_opt_t pktin_cfg = pktio_entry->s.config.pktin; odp_proto_layer_t parse_layer = pktio_entry->s.config.parser.layer; odp_pktio_t input = pktio_entry->s.handle;
/* Allocate maximum sized packets */ - alloc_len = pktio_entry->s.pkt_dpdk.data_room; + alloc_len = pkt_priv(pktio_entry)->data_room;
num = packet_alloc_multi(pool, alloc_len, pkt_table, mbuf_num); if (num != mbuf_num) { @@ -637,7 +699,7 @@ static inline int pkt_to_mbuf(pktio_entry_t *pktio_entry, struct rte_mbuf *mbuf_table[], const odp_packet_t pkt_table[], uint16_t num) { - pkt_dpdk_t *pkt_dpdk = &pktio_entry->s.pkt_dpdk; + pkt_dpdk_t *pkt_dpdk = pkt_priv(pktio_entry); int i, j; char *data; uint16_t pkt_len; @@ -693,7 +755,7 @@ static inline int mbuf_to_pkt_zero(pktio_entry_t *pktio_entry, void *data; int i; int nb_pkts = 0; - odp_pool_t pool = pktio_entry->s.pkt_dpdk.pool; + odp_pool_t pool = pkt_priv(pktio_entry)->pool; odp_pktin_config_opt_t pktin_cfg = pktio_entry->s.config.pktin; odp_proto_layer_t parse_layer = pktio_entry->s.config.parser.layer; odp_pktio_t input = pktio_entry->s.handle; @@ -768,7 +830,7 @@ static inline int pkt_to_mbuf_zero(pktio_entry_t *pktio_entry, const odp_packet_t pkt_table[], uint16_t num, uint16_t *copy_count) { - pkt_dpdk_t *pkt_dpdk = &pktio_entry->s.pkt_dpdk; + pkt_dpdk_t *pkt_dpdk = pkt_priv(pktio_entry); odp_pktout_config_opt_t *pktout_cfg = &pktio_entry->s.config.pktout; odp_pktout_config_opt_t *pktout_capa = &pktio_entry->s.capa.config.pktout; @@ -864,7 +926,7 @@ static uint32_t dpdk_vdev_mtu_get(uint16_t port_id)
static uint32_t dpdk_mtu_get(pktio_entry_t *pktio_entry) { - pkt_dpdk_t *pkt_dpdk = &pktio_entry->s.pkt_dpdk; + pkt_dpdk_t *pkt_dpdk = pkt_priv(pktio_entry); uint32_t mtu = 0;
if (rte_eth_dev_get_mtu(pkt_dpdk->port_id, (uint16_t *)&mtu)) @@ -885,7 +947,7 @@ static uint32_t dpdk_mtu_get(pktio_entry_t *pktio_entry)
static uint32_t dpdk_frame_maxlen(pktio_entry_t *pktio_entry) { - pkt_dpdk_t *pkt_dpdk = &pktio_entry->s.pkt_dpdk; + pkt_dpdk_t *pkt_dpdk = pkt_priv(pktio_entry);
return pkt_dpdk->mtu; } @@ -964,7 +1026,7 @@ static void rss_conf_to_hash_proto(struct rte_eth_rss_conf *rss_conf, static int dpdk_setup_port(pktio_entry_t *pktio_entry) { int ret; - pkt_dpdk_t *pkt_dpdk = &pktio_entry->s.pkt_dpdk; + pkt_dpdk_t *pkt_dpdk = pkt_priv(pktio_entry); struct rte_eth_rss_conf rss_conf; uint16_t hw_ip_checksum = 0;
@@ -1012,7 +1074,7 @@ static int dpdk_setup_port(pktio_entry_t *pktio_entry)
static int dpdk_close(pktio_entry_t *pktio_entry) { - pkt_dpdk_t *pkt_dpdk = &pktio_entry->s.pkt_dpdk; + pkt_dpdk_t *pkt_dpdk = pkt_priv(pktio_entry); unsigned idx; unsigned i, j;
@@ -1207,9 +1269,9 @@ static int dpdk_input_queues_config(pktio_entry_t *pktio_entry, lockless = 0;
if (p->hash_enable && p->num_queues > 1) - pktio_entry->s.pkt_dpdk.hash = p->hash_proto; + pkt_priv(pktio_entry)->hash = p->hash_proto;
- pktio_entry->s.pkt_dpdk.lockless_rx = lockless; + pkt_priv(pktio_entry)->lockless_rx = lockless;
return 0; } @@ -1217,7 +1279,7 @@ static int dpdk_input_queues_config(pktio_entry_t *pktio_entry, static int dpdk_output_queues_config(pktio_entry_t *pktio_entry, const odp_pktout_queue_param_t *p) { - pkt_dpdk_t *pkt_dpdk = &pktio_entry->s.pkt_dpdk; + pkt_dpdk_t *pkt_dpdk = pkt_priv(pktio_entry); uint8_t lockless;
if (p->op_mode == ODP_PKTIO_OP_MT_UNSAFE) @@ -1233,7 +1295,7 @@ static int dpdk_output_queues_config(pktio_entry_t *pktio_entry, static void dpdk_init_capability(pktio_entry_t *pktio_entry, struct rte_eth_dev_info *dev_info) { - pkt_dpdk_t *pkt_dpdk = &pktio_entry->s.pkt_dpdk; + pkt_dpdk_t *pkt_dpdk = pkt_priv(pktio_entry); odp_pktio_capability_t *capa = &pktio_entry->s.capa; int ptype_cnt; int ptype_l3_ipv4 = 0; @@ -1324,7 +1386,7 @@ static int dpdk_open(odp_pktio_t id ODP_UNUSED, const char *netdev, odp_pool_t pool) { - pkt_dpdk_t *pkt_dpdk = &pktio_entry->s.pkt_dpdk; + pkt_dpdk_t *pkt_dpdk = pkt_priv(pktio_entry); struct rte_eth_dev_info dev_info; struct rte_mempool *pkt_pool; char pool_name[RTE_MEMPOOL_NAMESIZE]; @@ -1442,7 +1504,7 @@ static int dpdk_start(pktio_entry_t *pktio_entry) { struct rte_eth_dev_info dev_info; struct rte_eth_rxconf *rxconf; - pkt_dpdk_t *pkt_dpdk = &pktio_entry->s.pkt_dpdk; + pkt_dpdk_t *pkt_dpdk = pkt_priv(pktio_entry); uint16_t port_id = pkt_dpdk->port_id; int ret; unsigned i; @@ -1536,7 +1598,7 @@ static int dpdk_start(pktio_entry_t *pktio_entry)
static int dpdk_stop(pktio_entry_t *pktio_entry) { - rte_eth_dev_stop(pktio_entry->s.pkt_dpdk.port_id); + rte_eth_dev_stop(pkt_priv(pktio_entry)->port_id);
return 0; } @@ -1544,7 +1606,7 @@ static int dpdk_stop(pktio_entry_t *pktio_entry) static int dpdk_recv(pktio_entry_t *pktio_entry, int index, odp_packet_t pkt_table[], int num) { - pkt_dpdk_t *pkt_dpdk = &pktio_entry->s.pkt_dpdk; + pkt_dpdk_t *pkt_dpdk = pkt_priv(pktio_entry); pkt_cache_t *rx_cache = &pkt_dpdk->rx_cache[index]; odp_time_t ts_val; odp_time_t *ts = NULL; @@ -1576,7 +1638,7 @@ static int dpdk_recv(pktio_entry_t *pktio_entry, int index, } else if ((unsigned)num < pkt_dpdk->min_rx_burst) { struct rte_mbuf *new_mbufs[pkt_dpdk->min_rx_burst];
- nb_rx = rte_eth_rx_burst(pktio_entry->s.pkt_dpdk.port_id, index, + nb_rx = rte_eth_rx_burst(pkt_priv(pktio_entry)->port_id, index, new_mbufs, pkt_dpdk->min_rx_burst); rx_cache->s.idx = 0; for (i = 0; i < nb_rx; i++) { @@ -1591,7 +1653,7 @@ static int dpdk_recv(pktio_entry_t *pktio_entry, int index, nb_rx = RTE_MIN(num, nb_rx);
} else { - nb_rx = rte_eth_rx_burst(pktio_entry->s.pkt_dpdk.port_id, index, + nb_rx = rte_eth_rx_burst(pkt_priv(pktio_entry)->port_id, index, rx_mbufs, num); }
@@ -1619,7 +1681,7 @@ static int dpdk_send(pktio_entry_t *pktio_entry, int index, const odp_packet_t pkt_table[], int num) { struct rte_mbuf *tx_mbufs[num]; - pkt_dpdk_t *pkt_dpdk = &pktio_entry->s.pkt_dpdk; + pkt_dpdk_t *pkt_dpdk = pkt_priv(pktio_entry); uint16_t copy_count = 0; int tx_pkts; int i; @@ -1682,16 +1744,16 @@ static int dpdk_send(pktio_entry_t *pktio_entry, int index,
static int dpdk_mac_addr_get(pktio_entry_t *pktio_entry, void *mac_addr) { - rte_eth_macaddr_get(pktio_entry->s.pkt_dpdk.port_id, + rte_eth_macaddr_get(pkt_priv(pktio_entry)->port_id, (struct ether_addr *)mac_addr); return ETH_ALEN; }
static int dpdk_promisc_mode_set(pktio_entry_t *pktio_entry, odp_bool_t enable) { - uint16_t port_id = pktio_entry->s.pkt_dpdk.port_id; + uint16_t port_id = pkt_priv(pktio_entry)->port_id;
- if (pktio_entry->s.pkt_dpdk.vdev_sysc_promisc) + if (pkt_priv(pktio_entry)->vdev_sysc_promisc) return dpdk_vdev_promisc_mode_set(port_id, enable);
if (enable) @@ -1704,9 +1766,9 @@ static int dpdk_promisc_mode_set(pktio_entry_t *pktio_entry, odp_bool_t enable)
static int dpdk_promisc_mode_get(pktio_entry_t *pktio_entry) { - uint16_t port_id = pktio_entry->s.pkt_dpdk.port_id; + uint16_t port_id = pkt_priv(pktio_entry)->port_id;
- if (pktio_entry->s.pkt_dpdk.vdev_sysc_promisc) + if (pkt_priv(pktio_entry)->vdev_sysc_promisc) return dpdk_vdev_promisc_mode_get(port_id); else return rte_eth_promiscuous_get(port_id); @@ -1725,7 +1787,7 @@ static int dpdk_link_status(pktio_entry_t *pktio_entry)
memset(&link, 0, sizeof(struct rte_eth_link));
- rte_eth_link_get_nowait(pktio_entry->s.pkt_dpdk.port_id, &link); + rte_eth_link_get_nowait(pkt_priv(pktio_entry)->port_id, &link);
return link.link_status; } @@ -1747,7 +1809,7 @@ static int dpdk_stats(pktio_entry_t *pktio_entry, odp_pktio_stats_t *stats) int ret; struct rte_eth_stats rte_stats;
- ret = rte_eth_stats_get(pktio_entry->s.pkt_dpdk.port_id, &rte_stats); + ret = rte_eth_stats_get(pkt_priv(pktio_entry)->port_id, &rte_stats);
if (ret == 0) { stats_convert(&rte_stats, stats); @@ -1758,7 +1820,7 @@ static int dpdk_stats(pktio_entry_t *pktio_entry, odp_pktio_stats_t *stats)
static int dpdk_stats_reset(pktio_entry_t *pktio_entry) { - rte_eth_stats_reset(pktio_entry->s.pkt_dpdk.port_id); + rte_eth_stats_reset(pkt_priv(pktio_entry)->port_id); return 0; }
commit 9dd6633189cf15ca554cc4ae21996f7db91c6901 Author: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Date: Wed May 30 19:14:36 2018 +0300
linux-gen: pktio: make netmap use generic private data field
Signed-off-by: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index 8709e713..ae87d222 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -111,7 +111,6 @@ noinst_HEADERS = \ include/odp_packet_io_internal.h \ include/odp_packet_io_ipc_internal.h \ include/odp_packet_io_ring_internal.h \ - include/odp_packet_netmap.h \ include/odp_packet_null.h \ include/odp_packet_socket.h \ include/odp_packet_tap.h \ diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index 946f4578..600fdd36 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -34,7 +34,6 @@ extern "C" {
#define PKTIO_MAX_QUEUES 64 #include <odp_packet_socket.h> -#include <odp_packet_netmap.h> #include <odp_packet_tap.h> #include <odp_packet_null.h> #include <odp_packet_dpdk.h> @@ -106,7 +105,11 @@ typedef struct { _ipc_map_remote_pool() */ } _ipc_pktio_t;
+#if defined(ODP_NETMAP) +#define PKTIO_PRIVATE_SIZE 74752 +#else #define PKTIO_PRIVATE_SIZE 384 +#endif
struct pktio_entry { const struct pktio_if_ops *ops; /**< Implementation specific methods */ @@ -117,7 +120,6 @@ struct pktio_entry { uint8_t chksum_insert_ena; /**< pktout checksum offload enabled */ odp_pktio_t handle; /**< pktio handle */ union { - pkt_netmap_t pkt_nm; /**< using netmap API for IO */ pkt_dpdk_t pkt_dpdk; /**< using DPDK for IO */ #ifdef HAVE_PCAP pkt_pcap_t pkt_pcap; /**< Using pcap for IO */ diff --git a/platform/linux-generic/include/odp_packet_netmap.h b/platform/linux-generic/include/odp_packet_netmap.h deleted file mode 100644 index bd3efdcf..00000000 --- a/platform/linux-generic/include/odp_packet_netmap.h +++ /dev/null @@ -1,73 +0,0 @@ -/* Copyright (c) 2015-2018, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef ODP_PACKET_NETMAP_H -#define ODP_PACKET_NETMAP_H - -#include <odp/api/align.h> -#include <odp/api/debug.h> -#include <odp/api/packet_io.h> -#include <odp/api/pool.h> -#include <odp/api/ticketlock.h> -#include <odp_align_internal.h> - -#include <linux/if_ether.h> -#include <net/if.h> - -#define NM_MAX_DESC 64 - -/** netmap runtime configuration options */ -typedef struct { - int nr_rx_slots; - int nr_tx_slots; -} netmap_opt_t; - -/** Ring for mapping pktin/pktout queues to netmap descriptors */ -struct netmap_ring_t { - unsigned first; /**< Index of first netmap descriptor */ - unsigned last; /**< Index of last netmap descriptor */ - unsigned num; /**< Number of netmap descriptors */ - /** Netmap metadata for the device */ - struct nm_desc *desc[NM_MAX_DESC]; - unsigned cur; /**< Index of current netmap descriptor */ - odp_ticketlock_t lock; /**< Queue lock */ -}; - -typedef union ODP_ALIGNED_CACHE { - struct netmap_ring_t s; - uint8_t pad[ROUNDUP_CACHE_LINE(sizeof(struct netmap_ring_t))]; -} netmap_ring_t; - -/** Netmap ring slot */ -typedef struct { - char *buf; /**< Slot buffer pointer */ - uint16_t len; /**< Slot length */ -} netmap_slot_t; - -/** Packet socket using netmap mmaped rings for both Rx and Tx */ -typedef struct { - odp_pool_t pool; /**< pool to alloc packets from */ - uint32_t if_flags; /**< interface flags */ - uint32_t mtu; /**< maximum transmission unit */ - int sockfd; /**< control socket */ - unsigned char if_mac[ETH_ALEN]; /**< eth mac address */ - char nm_name[IF_NAMESIZE + 7]; /**< netmap:<ifname> */ - char if_name[IF_NAMESIZE]; /**< interface name used in ioctl */ - odp_bool_t is_virtual; /**< nm virtual port (VALE/pipe) */ - uint32_t num_rx_rings; /**< number of nm rx rings */ - uint32_t num_tx_rings; /**< number of nm tx rings */ - unsigned num_rx_desc_rings; /**< number of rx descriptor rings */ - unsigned num_tx_desc_rings; /**< number of tx descriptor rings */ - odp_bool_t lockless_rx; /**< no locking for rx */ - odp_bool_t lockless_tx; /**< no locking for tx */ - /** mapping of pktin queues to netmap rx descriptors */ - netmap_ring_t rx_desc_ring[PKTIO_MAX_QUEUES]; - /** mapping of pktout queues to netmap tx descriptors */ - netmap_ring_t tx_desc_ring[PKTIO_MAX_QUEUES]; - netmap_opt_t opt; /**< options */ -} pkt_netmap_t; - -#endif diff --git a/platform/linux-generic/pktio/netmap.c b/platform/linux-generic/pktio/netmap.c index 86a40229..a8498aa1 100644 --- a/platform/linux-generic/pktio/netmap.c +++ b/platform/linux-generic/pktio/netmap.c @@ -16,7 +16,6 @@ #include <odp/api/plat/time_inlines.h>
#include <odp_packet_io_internal.h> -#include <odp_packet_netmap.h> #include <odp_packet_socket.h> #include <odp_debug_internal.h> #include <odp_errno_define.h> @@ -48,6 +47,67 @@ #define NM_WAIT_TIMEOUT 10 /* netmap_wait_for_link() timeout in seconds */ #define NM_INJECT_RETRIES 10
+#define NM_MAX_DESC 64 + +/** netmap runtime configuration options */ +typedef struct { + int nr_rx_slots; + int nr_tx_slots; +} netmap_opt_t; + +/** Ring for mapping pktin/pktout queues to netmap descriptors */ +struct netmap_ring_t { + unsigned int first; /**< Index of first netmap descriptor */ + unsigned int last; /**< Index of last netmap descriptor */ + unsigned int num; /**< Number of netmap descriptors */ + /** Netmap metadata for the device */ + struct nm_desc *desc[NM_MAX_DESC]; + unsigned int cur; /**< Index of current netmap descriptor */ + odp_ticketlock_t lock; /**< Queue lock */ +}; + +typedef union ODP_ALIGNED_CACHE { + struct netmap_ring_t s; + uint8_t pad[ROUNDUP_CACHE_LINE(sizeof(struct netmap_ring_t))]; +} netmap_ring_t; + +/** Netmap ring slot */ +typedef struct { + char *buf; /**< Slot buffer pointer */ + uint16_t len; /**< Slot length */ +} netmap_slot_t; + +/** Packet socket using netmap mmaped rings for both Rx and Tx */ +typedef struct { + odp_pool_t pool; /**< pool to alloc packets from */ + uint32_t if_flags; /**< interface flags */ + uint32_t mtu; /**< maximum transmission unit */ + int sockfd; /**< control socket */ + unsigned char if_mac[ETH_ALEN]; /**< eth mac address */ + char nm_name[IF_NAMESIZE + 7]; /**< netmap:<ifname> */ + char if_name[IF_NAMESIZE]; /**< interface name used in ioctl */ + odp_bool_t is_virtual; /**< nm virtual port (VALE/pipe) */ + uint32_t num_rx_rings; /**< number of nm rx rings */ + uint32_t num_tx_rings; /**< number of nm tx rings */ + unsigned int num_rx_desc_rings; /**< number of rx descriptor rings */ + unsigned int num_tx_desc_rings; /**< number of tx descriptor rings */ + odp_bool_t lockless_rx; /**< no locking for rx */ + odp_bool_t lockless_tx; /**< no locking for tx */ + /** mapping of pktin queues to netmap rx descriptors */ + netmap_ring_t rx_desc_ring[PKTIO_MAX_QUEUES]; + /** mapping of pktout queues to netmap tx descriptors */ + netmap_ring_t tx_desc_ring[PKTIO_MAX_QUEUES]; + netmap_opt_t opt; /**< options */ +} pkt_netmap_t; + +ODP_STATIC_ASSERT(PKTIO_PRIVATE_SIZE >= sizeof(pkt_netmap_t), + "PKTIO_PRIVATE_SIZE too small"); + +static inline pkt_netmap_t *pkt_priv(pktio_entry_t *pktio_entry) +{ + return (pkt_netmap_t *)(uintptr_t)(pktio_entry->s.pkt_priv); +} + static int disable_pktio; /** !0 this pktio disabled, 0 enabled */ static int netmap_stats_reset(pktio_entry_t *pktio_entry);
@@ -66,7 +126,7 @@ static int lookup_opt(const char *opt_name, const char *drv_name, int *val)
static int init_options(pktio_entry_t *pktio_entry) { - netmap_opt_t *opt = &pktio_entry->s.pkt_nm.opt; + netmap_opt_t *opt = &pkt_priv(pktio_entry)->opt;
if (!lookup_opt("nr_rx_slots", "virt", &opt->nr_rx_slots)) @@ -87,7 +147,7 @@ static int init_options(pktio_entry_t *pktio_entry) }
ODP_PRINT("netmap interface: %s\n", - pktio_entry->s.pkt_nm.if_name); + pkt_priv(pktio_entry)->if_name); ODP_PRINT(" num_rx_desc: %d\n", opt->nr_rx_slots); ODP_PRINT(" num_tx_desc: %d\n", opt->nr_tx_slots);
@@ -97,7 +157,7 @@ static int init_options(pktio_entry_t *pktio_entry) static int netmap_do_ioctl(pktio_entry_t *pktio_entry, unsigned long cmd, int subcmd) { - pkt_netmap_t *pkt_nm = &pktio_entry->s.pkt_nm; + pkt_netmap_t *pkt_nm = pkt_priv(pktio_entry); struct ethtool_value eval; struct ifreq ifr; int err; @@ -105,7 +165,7 @@ static int netmap_do_ioctl(pktio_entry_t *pktio_entry, unsigned long cmd,
memset(&ifr, 0, sizeof(ifr)); snprintf(ifr.ifr_name, sizeof(ifr.ifr_name), "%s", - pktio_entry->s.pkt_nm.if_name); + pkt_priv(pktio_entry)->if_name);
switch (cmd) { case SIOCSIFFLAGS: @@ -184,7 +244,7 @@ static inline void map_netmap_rings(netmap_ring_t *rings, static int netmap_input_queues_config(pktio_entry_t *pktio_entry, const odp_pktin_queue_param_t *p) { - pkt_netmap_t *pkt_nm = &pktio_entry->s.pkt_nm; + pkt_netmap_t *pkt_nm = pkt_priv(pktio_entry); odp_pktin_mode_t mode = pktio_entry->s.param.in_mode; unsigned num_queues = p->num_queues; odp_bool_t lockless; @@ -197,8 +257,8 @@ static int netmap_input_queues_config(pktio_entry_t *pktio_entry, lockless = (p->op_mode == ODP_PKTIO_OP_MT_UNSAFE);
if (p->hash_enable && num_queues > 1) { - if (rss_conf_set_fd(pktio_entry->s.pkt_nm.sockfd, - pktio_entry->s.pkt_nm.if_name, + if (rss_conf_set_fd(pkt_priv(pktio_entry)->sockfd, + pkt_priv(pktio_entry)->if_name, &p->hash_proto)) { ODP_ERR("Failed to configure input hash\n"); return -1; @@ -213,7 +273,7 @@ static int netmap_input_queues_config(pktio_entry_t *pktio_entry, static int netmap_output_queues_config(pktio_entry_t *pktio_entry, const odp_pktout_queue_param_t *p) { - pkt_netmap_t *pkt_nm = &pktio_entry->s.pkt_nm; + pkt_netmap_t *pkt_nm = pkt_priv(pktio_entry);
pkt_nm->lockless_tx = (p->op_mode == ODP_PKTIO_OP_MT_UNSAFE);
@@ -230,7 +290,7 @@ static int netmap_output_queues_config(pktio_entry_t *pktio_entry, static inline void netmap_close_descriptors(pktio_entry_t *pktio_entry) { int i, j; - pkt_netmap_t *pkt_nm = &pktio_entry->s.pkt_nm; + pkt_netmap_t *pkt_nm = pkt_priv(pktio_entry);
for (i = 0; i < PKTIO_MAX_QUEUES; i++) { for (j = 0; j < NM_MAX_DESC; j++) { @@ -253,7 +313,7 @@ static inline void netmap_close_descriptors(pktio_entry_t *pktio_entry)
static int netmap_close(pktio_entry_t *pktio_entry) { - pkt_netmap_t *pkt_nm = &pktio_entry->s.pkt_nm; + pkt_netmap_t *pkt_nm = pkt_priv(pktio_entry);
netmap_close_descriptors(pktio_entry);
@@ -267,11 +327,11 @@ static int netmap_close(pktio_entry_t *pktio_entry)
static int netmap_link_status(pktio_entry_t *pktio_entry) { - if (pktio_entry->s.pkt_nm.is_virtual) + if (pkt_priv(pktio_entry)->is_virtual) return 1;
- return link_status_fd(pktio_entry->s.pkt_nm.sockfd, - pktio_entry->s.pkt_nm.if_name); + return link_status_fd(pkt_priv(pktio_entry)->sockfd, + pkt_priv(pktio_entry)->if_name); }
/** @@ -298,12 +358,12 @@ static inline int netmap_wait_for_link(pktio_entry_t *pktio_entry) * until the opposing end's interface comes back up again. In * this case without the additional sleep pktio validation * tests fail. */ - if (!pktio_entry->s.pkt_nm.is_virtual) + if (!pkt_priv(pktio_entry)->is_virtual) sleep(1); if (ret == 1) return 1; } - ODP_DBG("%s link is down\n", pktio_entry->s.pkt_nm.if_name); + ODP_DBG("%s link is down\n", pkt_priv(pktio_entry)->if_name); return 0; }
@@ -314,7 +374,7 @@ static inline int netmap_wait_for_link(pktio_entry_t *pktio_entry) */ static void netmap_init_capability(pktio_entry_t *pktio_entry) { - pkt_netmap_t *pkt_nm = &pktio_entry->s.pkt_nm; + pkt_netmap_t *pkt_nm = pkt_priv(pktio_entry); odp_pktio_capability_t *capa = &pktio_entry->s.capa;
memset(capa, 0, sizeof(odp_pktio_capability_t)); @@ -381,7 +441,7 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED, pktio_entry_t *pktio_entry, const char *prefix; uint32_t mtu; uint32_t buf_size; - pkt_netmap_t *pkt_nm = &pktio_entry->s.pkt_nm; + pkt_netmap_t *pkt_nm = pkt_priv(pktio_entry); struct nm_desc *desc; struct netmap_ring *ring; odp_pktin_hash_proto_t hash_proto; @@ -470,7 +530,7 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED, pktio_entry_t *pktio_entry,
/* Use either interface MTU or netmap buffer size as MTU, whichever is * smaller. */ - mtu = mtu_get_fd(pktio_entry->s.pkt_nm.sockfd, pkt_nm->if_name); + mtu = mtu_get_fd(pkt_priv(pktio_entry)->sockfd, pkt_nm->if_name); if (mtu == 0) { ODP_ERR("Unable to read interface MTU\n"); goto error; @@ -494,7 +554,7 @@ static int netmap_open(odp_pktio_t id ODP_UNUSED, pktio_entry_t *pktio_entry, goto error;
/* netmap uses only ethtool to get statistics counters */ - err = ethtool_stats_get_fd(pktio_entry->s.pkt_nm.sockfd, + err = ethtool_stats_get_fd(pkt_priv(pktio_entry)->sockfd, pkt_nm->if_name, &cur_stats); if (err) { ODP_ERR("netmap pktio %s does not support statistics counters\n", @@ -515,7 +575,7 @@ error:
static int netmap_start(pktio_entry_t *pktio_entry) { - pkt_netmap_t *pkt_nm = &pktio_entry->s.pkt_nm; + pkt_netmap_t *pkt_nm = pkt_priv(pktio_entry); netmap_ring_t *desc_ring; struct nm_desc *desc_ptr; unsigned i; @@ -580,11 +640,11 @@ static int netmap_start(pktio_entry_t *pktio_entry)
base_desc.self = &base_desc; base_desc.mem = NULL; - if (pktio_entry->s.pkt_nm.is_virtual) { + if (pkt_priv(pktio_entry)->is_virtual) { base_desc.req.nr_rx_slots = - pktio_entry->s.pkt_nm.opt.nr_rx_slots; + pkt_priv(pktio_entry)->opt.nr_rx_slots; base_desc.req.nr_tx_slots = - pktio_entry->s.pkt_nm.opt.nr_tx_slots; + pkt_priv(pktio_entry)->opt.nr_tx_slots; } base_desc.req.nr_ringid = 0; if ((base_desc.req.nr_flags & NR_REG_MASK) == NR_REG_ALL_NIC || @@ -599,7 +659,7 @@ static int netmap_start(pktio_entry_t *pktio_entry) /* Only the first rx descriptor does mmap */ desc_ring = pkt_nm->rx_desc_ring; flags = NM_OPEN_IFNAME | NETMAP_NO_TX_POLL; - if (pktio_entry->s.pkt_nm.is_virtual) + if (pkt_priv(pktio_entry)->is_virtual) flags |= NM_OPEN_RING_CFG; desc_ring[0].s.desc[0] = nm_open(pkt_nm->nm_name, NULL, flags, &base_desc); @@ -609,7 +669,7 @@ static int netmap_start(pktio_entry_t *pktio_entry) } /* Open rest of the rx descriptors (one per netmap ring) */ flags = NM_OPEN_IFNAME | NETMAP_NO_TX_POLL | NM_OPEN_NO_MMAP; - if (pktio_entry->s.pkt_nm.is_virtual) + if (pkt_priv(pktio_entry)->is_virtual) flags |= NM_OPEN_RING_CFG; for (i = 0; i < pktio_entry->s.num_in_queue; i++) { for (j = desc_ring[i].s.first; j <= desc_ring[i].s.last; j++) { @@ -632,7 +692,7 @@ static int netmap_start(pktio_entry_t *pktio_entry) /* Open tx descriptors */ desc_ring = pkt_nm->tx_desc_ring; flags = NM_OPEN_IFNAME | NM_OPEN_NO_MMAP; - if (pktio_entry->s.pkt_nm.is_virtual) + if (pkt_priv(pktio_entry)->is_virtual) flags |= NM_OPEN_RING_CFG;
if ((base_desc.req.nr_flags & NR_REG_MASK) == NR_REG_ALL_NIC) { @@ -684,7 +744,7 @@ static inline int netmap_pkt_to_odp(pktio_entry_t *pktio_entry, odp_time_t *ts) { odp_packet_t pkt; - odp_pool_t pool = pktio_entry->s.pkt_nm.pool; + odp_pool_t pool = pkt_priv(pktio_entry)->pool; odp_packet_hdr_t *pkt_hdr; odp_packet_hdr_t parsed_hdr; int i; @@ -692,7 +752,7 @@ static inline int netmap_pkt_to_odp(pktio_entry_t *pktio_entry, int alloc_len;
/* Allocate maximum sized packets */ - alloc_len = pktio_entry->s.pkt_nm.mtu; + alloc_len = pkt_priv(pktio_entry)->mtu;
num = packet_alloc_multi(pool, alloc_len, pkt_tbl, slot_num);
@@ -750,7 +810,7 @@ static inline int netmap_recv_desc(pktio_entry_t *pktio_entry, netmap_slot_t slot_tbl[num]; char *buf; uint32_t slot_id; - uint32_t mtu = pktio_entry->s.pkt_nm.mtu; + uint32_t mtu = pkt_priv(pktio_entry)->mtu; int i; int ring_id = desc->cur_rx_ring; int num_rx = 0; @@ -795,7 +855,7 @@ static inline int netmap_recv_desc(pktio_entry_t *pktio_entry, static int netmap_fd_set(pktio_entry_t *pktio_entry, int index, fd_set *readfds) { struct nm_desc *desc; - pkt_netmap_t *pkt_nm = &pktio_entry->s.pkt_nm; + pkt_netmap_t *pkt_nm = pkt_priv(pktio_entry); unsigned first_desc_id = pkt_nm->rx_desc_ring[index].s.first; unsigned last_desc_id = pkt_nm->rx_desc_ring[index].s.last; unsigned desc_id; @@ -834,7 +894,7 @@ static int netmap_recv(pktio_entry_t *pktio_entry, int index, odp_packet_t pkt_table[], int num) { struct nm_desc *desc; - pkt_netmap_t *pkt_nm = &pktio_entry->s.pkt_nm; + pkt_netmap_t *pkt_nm = pkt_priv(pktio_entry); unsigned first_desc_id = pkt_nm->rx_desc_ring[index].s.first; unsigned last_desc_id = pkt_nm->rx_desc_ring[index].s.last; unsigned desc_id; @@ -957,7 +1017,7 @@ static int netmap_recv_mq_tmo(pktio_entry_t *pktio_entry[], int index[], static int netmap_send(pktio_entry_t *pktio_entry, int index, const odp_packet_t pkt_table[], int num) { - pkt_netmap_t *pkt_nm = &pktio_entry->s.pkt_nm; + pkt_netmap_t *pkt_nm = pkt_priv(pktio_entry); struct pollfd polld; struct nm_desc *desc; struct netmap_ring *ring; @@ -1032,34 +1092,34 @@ static int netmap_send(pktio_entry_t *pktio_entry, int index,
static int netmap_mac_addr_get(pktio_entry_t *pktio_entry, void *mac_addr) { - memcpy(mac_addr, pktio_entry->s.pkt_nm.if_mac, ETH_ALEN); + memcpy(mac_addr, pkt_priv(pktio_entry)->if_mac, ETH_ALEN); return ETH_ALEN; }
static uint32_t netmap_mtu_get(pktio_entry_t *pktio_entry) { - return pktio_entry->s.pkt_nm.mtu; + return pkt_priv(pktio_entry)->mtu; }
static int netmap_promisc_mode_set(pktio_entry_t *pktio_entry, odp_bool_t enable) { - if (pktio_entry->s.pkt_nm.is_virtual) { + if (pkt_priv(pktio_entry)->is_virtual) { __odp_errno = ENOTSUP; return -1; }
- return promisc_mode_set_fd(pktio_entry->s.pkt_nm.sockfd, - pktio_entry->s.pkt_nm.if_name, enable); + return promisc_mode_set_fd(pkt_priv(pktio_entry)->sockfd, + pkt_priv(pktio_entry)->if_name, enable); }
static int netmap_promisc_mode_get(pktio_entry_t *pktio_entry) { - if (pktio_entry->s.pkt_nm.is_virtual) + if (pkt_priv(pktio_entry)->is_virtual) return 0;
- return promisc_mode_get_fd(pktio_entry->s.pkt_nm.sockfd, - pktio_entry->s.pkt_nm.if_name); + return promisc_mode_get_fd(pkt_priv(pktio_entry)->sockfd, + pkt_priv(pktio_entry)->if_name); }
static int netmap_capability(pktio_entry_t *pktio_entry, @@ -1079,7 +1139,7 @@ static int netmap_stats(pktio_entry_t *pktio_entry,
return sock_stats_fd(pktio_entry, stats, - pktio_entry->s.pkt_nm.sockfd); + pkt_priv(pktio_entry)->sockfd); }
static int netmap_stats_reset(pktio_entry_t *pktio_entry) @@ -1091,15 +1151,15 @@ static int netmap_stats_reset(pktio_entry_t *pktio_entry) }
return sock_stats_reset_fd(pktio_entry, - pktio_entry->s.pkt_nm.sockfd); + pkt_priv(pktio_entry)->sockfd); }
static void netmap_print(pktio_entry_t *pktio_entry) { odp_pktin_hash_proto_t hash_proto;
- if (rss_conf_get_fd(pktio_entry->s.pkt_nm.sockfd, - pktio_entry->s.pkt_nm.if_name, &hash_proto)) + if (rss_conf_get_fd(pkt_priv(pktio_entry)->sockfd, + pkt_priv(pktio_entry)->if_name, &hash_proto)) rss_conf_print(&hash_proto); }
commit bcb01a637648278bbbefcd6cdc3014a98de8ed4f Author: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Date: Wed May 30 19:14:36 2018 +0300
linux-gen: pktio: make socket_mmap use generic private data field
Signed-off-by: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index 3dbeb2be..946f4578 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -117,8 +117,6 @@ struct pktio_entry { uint8_t chksum_insert_ena; /**< pktout checksum offload enabled */ odp_pktio_t handle; /**< pktio handle */ union { - pkt_sock_mmap_t pkt_sock_mmap; /**< using socket mmap - * API for IO */ pkt_netmap_t pkt_nm; /**< using netmap API for IO */ pkt_dpdk_t pkt_dpdk; /**< using DPDK for IO */ #ifdef HAVE_PCAP diff --git a/platform/linux-generic/include/odp_packet_socket.h b/platform/linux-generic/include/odp_packet_socket.h index 7774db80..f77248f0 100644 --- a/platform/linux-generic/include/odp_packet_socket.h +++ b/platform/linux-generic/include/odp_packet_socket.h @@ -57,24 +57,6 @@ struct ring { ODP_STATIC_ASSERT(offsetof(struct ring, mm_space) <= ODP_CACHE_LINE_SIZE, "ERR_STRUCT_RING");
-/** Packet socket using mmap rings for both Rx and Tx */ -typedef struct { - /** Packet mmap ring for Rx */ - struct ring ODP_ALIGNED_CACHE rx_ring; - /** Packet mmap ring for Tx */ - struct ring ODP_ALIGNED_CACHE tx_ring; - - int ODP_ALIGNED_CACHE sockfd; - odp_pool_t pool; - int mtu; /**< maximum transmission unit */ - size_t frame_offset; /**< frame start offset from start of pkt buf */ - uint8_t *mmap_base; - unsigned mmap_len; - unsigned char if_mac[ETH_ALEN]; - struct sockaddr_ll ll; - int fanout; -} pkt_sock_mmap_t; - static inline void ethaddr_copy(unsigned char mac_dst[], unsigned char mac_src[]) { diff --git a/platform/linux-generic/pktio/socket_mmap.c b/platform/linux-generic/pktio/socket_mmap.c index eff22a7b..8ec2198b 100644 --- a/platform/linux-generic/pktio/socket_mmap.c +++ b/platform/linux-generic/pktio/socket_mmap.c @@ -49,6 +49,32 @@ /* Maximum number of packets to store in each RX/TX block */ #define MAX_PKTS_PER_BLOCK 512
+/** Packet socket using mmap rings for both Rx and Tx */ +typedef struct { + /** Packet mmap ring for Rx */ + struct ring ODP_ALIGNED_CACHE rx_ring; + /** Packet mmap ring for Tx */ + struct ring ODP_ALIGNED_CACHE tx_ring; + + int ODP_ALIGNED_CACHE sockfd; + odp_pool_t pool; + int mtu; /**< maximum transmission unit */ + size_t frame_offset; /**< frame start offset from start of pkt buf */ + uint8_t *mmap_base; + unsigned int mmap_len; + unsigned char if_mac[ETH_ALEN]; + struct sockaddr_ll ll; + int fanout; +} pkt_sock_mmap_t; + +ODP_STATIC_ASSERT(PKTIO_PRIVATE_SIZE >= sizeof(pkt_sock_mmap_t), + "PKTIO_PRIVATE_SIZE too small"); + +static inline pkt_sock_mmap_t *pkt_priv(pktio_entry_t *pktio_entry) +{ + return (pkt_sock_mmap_t *)(uintptr_t)(pktio_entry->s.pkt_priv); +} + static int disable_pktio; /** !0 this pktio disabled, 0 enabled */
static int set_pkt_sock_fanout_mmap(pkt_sock_mmap_t *const pkt_sock, @@ -534,7 +560,7 @@ static int mmap_bind_sock(pkt_sock_mmap_t *pkt_sock, const char *netdev)
static int sock_mmap_close(pktio_entry_t *entry) { - pkt_sock_mmap_t *const pkt_sock = &entry->s.pkt_sock_mmap; + pkt_sock_mmap_t *const pkt_sock = pkt_priv(entry); int ret;
ret = mmap_unmap_sock(pkt_sock); @@ -563,7 +589,7 @@ static int sock_mmap_open(odp_pktio_t id ODP_UNUSED, if (disable_pktio) return -1;
- pkt_sock_mmap_t *const pkt_sock = &pktio_entry->s.pkt_sock_mmap; + pkt_sock_mmap_t *const pkt_sock = pkt_priv(pktio_entry); int fanout = 1;
/* Init pktio entry */ @@ -622,7 +648,7 @@ static int sock_mmap_open(odp_pktio_t id ODP_UNUSED, goto error; }
- ret = ethtool_stats_get_fd(pktio_entry->s.pkt_sock_mmap.sockfd, + ret = ethtool_stats_get_fd(pkt_priv(pktio_entry)->sockfd, pktio_entry->s.name, &cur_stats); if (ret != 0) { @@ -639,7 +665,7 @@ static int sock_mmap_open(odp_pktio_t id ODP_UNUSED, }
ret = sock_stats_reset_fd(pktio_entry, - pktio_entry->s.pkt_sock_mmap.sockfd); + pkt_priv(pktio_entry)->sockfd); if (ret != 0) goto error;
@@ -653,7 +679,7 @@ error: static int sock_mmap_fd_set(pktio_entry_t *pktio_entry, int index ODP_UNUSED, fd_set *readfds) { - pkt_sock_mmap_t *const pkt_sock = &pktio_entry->s.pkt_sock_mmap; + pkt_sock_mmap_t *const pkt_sock = pkt_priv(pktio_entry); int fd;
odp_ticketlock_lock(&pktio_entry->s.rxl); @@ -667,7 +693,7 @@ static int sock_mmap_fd_set(pktio_entry_t *pktio_entry, int index ODP_UNUSED, static int sock_mmap_recv(pktio_entry_t *pktio_entry, int index ODP_UNUSED, odp_packet_t pkt_table[], int num) { - pkt_sock_mmap_t *const pkt_sock = &pktio_entry->s.pkt_sock_mmap; + pkt_sock_mmap_t *const pkt_sock = pkt_priv(pktio_entry); int ret;
odp_ticketlock_lock(&pktio_entry->s.rxl); @@ -767,7 +793,7 @@ static int sock_mmap_send(pktio_entry_t *pktio_entry, int index ODP_UNUSED, const odp_packet_t pkt_table[], int num) { int ret; - pkt_sock_mmap_t *const pkt_sock = &pktio_entry->s.pkt_sock_mmap; + pkt_sock_mmap_t *const pkt_sock = pkt_priv(pktio_entry);
odp_ticketlock_lock(&pktio_entry->s.txl); ret = pkt_mmap_v2_tx(pkt_sock->tx_ring.sock, &pkt_sock->tx_ring, @@ -779,32 +805,32 @@ static int sock_mmap_send(pktio_entry_t *pktio_entry, int index ODP_UNUSED,
static uint32_t sock_mmap_mtu_get(pktio_entry_t *pktio_entry) { - return mtu_get_fd(pktio_entry->s.pkt_sock_mmap.sockfd, + return mtu_get_fd(pkt_priv(pktio_entry)->sockfd, pktio_entry->s.name); }
static int sock_mmap_mac_addr_get(pktio_entry_t *pktio_entry, void *mac_addr) { - memcpy(mac_addr, pktio_entry->s.pkt_sock_mmap.if_mac, ETH_ALEN); + memcpy(mac_addr, pkt_priv(pktio_entry)->if_mac, ETH_ALEN); return ETH_ALEN; }
static int sock_mmap_promisc_mode_set(pktio_entry_t *pktio_entry, odp_bool_t enable) { - return promisc_mode_set_fd(pktio_entry->s.pkt_sock_mmap.sockfd, + return promisc_mode_set_fd(pkt_priv(pktio_entry)->sockfd, pktio_entry->s.name, enable); }
static int sock_mmap_promisc_mode_get(pktio_entry_t *pktio_entry) { - return promisc_mode_get_fd(pktio_entry->s.pkt_sock_mmap.sockfd, + return promisc_mode_get_fd(pkt_priv(pktio_entry)->sockfd, pktio_entry->s.name); }
static int sock_mmap_link_status(pktio_entry_t *pktio_entry) { - return link_status_fd(pktio_entry->s.pkt_sock_mmap.sockfd, + return link_status_fd(pkt_priv(pktio_entry)->sockfd, pktio_entry->s.name); }
@@ -833,7 +859,7 @@ static int sock_mmap_stats(pktio_entry_t *pktio_entry,
return sock_stats_fd(pktio_entry, stats, - pktio_entry->s.pkt_sock_mmap.sockfd); + pkt_priv(pktio_entry)->sockfd); }
static int sock_mmap_stats_reset(pktio_entry_t *pktio_entry) @@ -845,7 +871,7 @@ static int sock_mmap_stats_reset(pktio_entry_t *pktio_entry) }
return sock_stats_reset_fd(pktio_entry, - pktio_entry->s.pkt_sock_mmap.sockfd); + pkt_priv(pktio_entry)->sockfd); }
static int sock_mmap_init_global(void)
commit 8460c9c1b5afab84f4279e6e04cfb1e012965c14 Author: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Date: Wed May 30 19:14:36 2018 +0300
linux-gen: pktio: make socket use generic private data field
Signed-off-by: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index 9d8de4c6..3dbeb2be 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -117,7 +117,6 @@ struct pktio_entry { uint8_t chksum_insert_ena; /**< pktout checksum offload enabled */ odp_pktio_t handle; /**< pktio handle */ union { - pkt_sock_t pkt_sock; /**< using socket API for IO */ pkt_sock_mmap_t pkt_sock_mmap; /**< using socket mmap * API for IO */ pkt_netmap_t pkt_nm; /**< using netmap API for IO */ diff --git a/platform/linux-generic/include/odp_packet_socket.h b/platform/linux-generic/include/odp_packet_socket.h index f5612222..7774db80 100644 --- a/platform/linux-generic/include/odp_packet_socket.h +++ b/platform/linux-generic/include/odp_packet_socket.h @@ -37,13 +37,6 @@ #define PACKET_FANOUT_HASH 0 #endif /* PACKET_FANOUT */
-typedef struct { - int sockfd; /**< socket descriptor */ - odp_pool_t pool; /**< pool to alloc packets from */ - uint32_t mtu; /**< maximum transmission unit */ - unsigned char if_mac[ETH_ALEN]; /**< IF eth mac addr */ -} pkt_sock_t; - /** packet mmap ring */ struct ring { struct iovec *rd; diff --git a/platform/linux-generic/pktio/socket.c b/platform/linux-generic/pktio/socket.c index 5be240ec..93613e54 100644 --- a/platform/linux-generic/pktio/socket.c +++ b/platform/linux-generic/pktio/socket.c @@ -52,6 +52,21 @@ #define MAX_SEGS CONFIG_PACKET_MAX_SEGS #define PACKET_JUMBO_LEN (9 * 1024)
+typedef struct { + int sockfd; /**< socket descriptor */ + odp_pool_t pool; /**< pool to alloc packets from */ + uint32_t mtu; /**< maximum transmission unit */ + unsigned char if_mac[ETH_ALEN]; /**< IF eth mac addr */ +} pkt_sock_t; + +ODP_STATIC_ASSERT(PKTIO_PRIVATE_SIZE >= sizeof(pkt_sock_t), + "PKTIO_PRIVATE_SIZE too small"); + +static inline pkt_sock_t *pkt_priv(pktio_entry_t *pktio_entry) +{ + return (pkt_sock_t *)(uintptr_t)(pktio_entry->s.pkt_priv); +} + static int disable_pktio; /** !0 this pktio disabled, 0 enabled */
static int sock_stats_reset(pktio_entry_t *pktio_entry); @@ -458,7 +473,8 @@ void rss_conf_print(const odp_pktin_hash_proto_t *hash_proto) */ static int sock_close(pktio_entry_t *pktio_entry) { - pkt_sock_t *pkt_sock = &pktio_entry->s.pkt_sock; + pkt_sock_t *pkt_sock = pkt_priv(pktio_entry); + if (pkt_sock->sockfd != -1 && close(pkt_sock->sockfd) != 0) { __odp_errno = errno; ODP_ERR("close(sockfd): %s\n", strerror(errno)); @@ -480,7 +496,7 @@ static int sock_setup_pkt(pktio_entry_t *pktio_entry, const char *netdev, struct ifreq ethreq; struct sockaddr_ll sa_ll; char shm_name[ODP_SHM_NAME_LEN]; - pkt_sock_t *pkt_sock = &pktio_entry->s.pkt_sock; + pkt_sock_t *pkt_sock = pkt_priv(pktio_entry); odp_pktio_stats_t cur_stats;
/* Init pktio entry */ @@ -533,7 +549,7 @@ static int sock_setup_pkt(pktio_entry_t *pktio_entry, const char *netdev, goto error; }
- err = ethtool_stats_get_fd(pktio_entry->s.pkt_sock.sockfd, + err = ethtool_stats_get_fd(pkt_priv(pktio_entry)->sockfd, pktio_entry->s.name, &cur_stats); if (err != 0) { @@ -604,7 +620,7 @@ static uint32_t _rx_pkt_to_iovec(odp_packet_t pkt, static int sock_mmsg_recv(pktio_entry_t *pktio_entry, int index ODP_UNUSED, odp_packet_t pkt_table[], int num) { - pkt_sock_t *pkt_sock = &pktio_entry->s.pkt_sock; + pkt_sock_t *pkt_sock = pkt_priv(pktio_entry); odp_pool_t pool = pkt_sock->pool; odp_time_t ts_val; odp_time_t *ts = NULL; @@ -704,7 +720,7 @@ static int sock_mmsg_recv(pktio_entry_t *pktio_entry, int index ODP_UNUSED, static int sock_fd_set(pktio_entry_t *pktio_entry, int index ODP_UNUSED, fd_set *readfds) { - pkt_sock_t *pkt_sock = &pktio_entry->s.pkt_sock; + pkt_sock_t *pkt_sock = pkt_priv(pktio_entry); const int sockfd = pkt_sock->sockfd;
FD_SET(sockfd, readfds); @@ -807,7 +823,7 @@ static uint32_t _tx_pkt_to_iovec(odp_packet_t pkt, static int sock_mmsg_send(pktio_entry_t *pktio_entry, int index ODP_UNUSED, const odp_packet_t pkt_table[], int num) { - pkt_sock_t *pkt_sock = &pktio_entry->s.pkt_sock; + pkt_sock_t *pkt_sock = pkt_priv(pktio_entry); struct mmsghdr msgvec[num]; struct iovec iovecs[num][MAX_SEGS]; int ret; @@ -853,7 +869,7 @@ static int sock_mmsg_send(pktio_entry_t *pktio_entry, int index ODP_UNUSED, */ static uint32_t sock_mtu_get(pktio_entry_t *pktio_entry) { - return pktio_entry->s.pkt_sock.mtu; + return pkt_priv(pktio_entry)->mtu; }
/* @@ -862,7 +878,7 @@ static uint32_t sock_mtu_get(pktio_entry_t *pktio_entry) static int sock_mac_addr_get(pktio_entry_t *pktio_entry, void *mac_addr) { - memcpy(mac_addr, pktio_entry->s.pkt_sock.if_mac, ETH_ALEN); + memcpy(mac_addr, pkt_priv(pktio_entry)->if_mac, ETH_ALEN); return ETH_ALEN; }
@@ -872,7 +888,7 @@ static int sock_mac_addr_get(pktio_entry_t *pktio_entry, static int sock_promisc_mode_set(pktio_entry_t *pktio_entry, odp_bool_t enable) { - return promisc_mode_set_fd(pktio_entry->s.pkt_sock.sockfd, + return promisc_mode_set_fd(pkt_priv(pktio_entry)->sockfd, pktio_entry->s.name, enable); }
@@ -881,13 +897,13 @@ static int sock_promisc_mode_set(pktio_entry_t *pktio_entry, */ static int sock_promisc_mode_get(pktio_entry_t *pktio_entry) { - return promisc_mode_get_fd(pktio_entry->s.pkt_sock.sockfd, + return promisc_mode_get_fd(pkt_priv(pktio_entry)->sockfd, pktio_entry->s.name); }
static int sock_link_status(pktio_entry_t *pktio_entry) { - return link_status_fd(pktio_entry->s.pkt_sock.sockfd, + return link_status_fd(pkt_priv(pktio_entry)->sockfd, pktio_entry->s.name); }
@@ -916,7 +932,7 @@ static int sock_stats(pktio_entry_t *pktio_entry,
return sock_stats_fd(pktio_entry, stats, - pktio_entry->s.pkt_sock.sockfd); + pkt_priv(pktio_entry)->sockfd); }
static int sock_stats_reset(pktio_entry_t *pktio_entry) @@ -928,7 +944,7 @@ static int sock_stats_reset(pktio_entry_t *pktio_entry) }
return sock_stats_reset_fd(pktio_entry, - pktio_entry->s.pkt_sock.sockfd); + pkt_priv(pktio_entry)->sockfd); }
static int sock_init_global(void)
commit 09406916470553a85f30fc14889127443cc4a09b Author: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Date: Wed May 30 19:14:36 2018 +0300
linux-gen: pktio: make loop use generic private data field
Signed-off-by: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index dfcb1bcf..9d8de4c6 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -53,12 +53,6 @@ extern "C" { /* Forward declaration */ struct pktio_if_ops;
-typedef struct { - odp_queue_t loopq; /**< loopback queue for "loop" device */ - odp_bool_t promisc; /**< promiscuous mode state */ - uint8_t idx; /**< index of "loop" device */ -} pkt_loop_t; - #ifdef HAVE_PCAP typedef struct { char *fname_rx; /**< name of pcap file for rx */ @@ -123,7 +117,6 @@ struct pktio_entry { uint8_t chksum_insert_ena; /**< pktout checksum offload enabled */ odp_pktio_t handle; /**< pktio handle */ union { - pkt_loop_t pkt_loop; /**< Using loopback for IO */ pkt_sock_t pkt_sock; /**< using socket API for IO */ pkt_sock_mmap_t pkt_sock_mmap; /**< using socket mmap * API for IO */ diff --git a/platform/linux-generic/pktio/loop.c b/platform/linux-generic/pktio/loop.c index 0bd1835c..faaef3ab 100644 --- a/platform/linux-generic/pktio/loop.c +++ b/platform/linux-generic/pktio/loop.c @@ -30,6 +30,20 @@ #define MAX_LOOP 16 #define LOOP_MTU (64 * 1024)
+typedef struct { + odp_queue_t loopq; /**< loopback queue for "loop" device */ + odp_bool_t promisc; /**< promiscuous mode state */ + uint8_t idx; /**< index of "loop" device */ +} pkt_loop_t; + +ODP_STATIC_ASSERT(PKTIO_PRIVATE_SIZE >= sizeof(pkt_loop_t), + "PKTIO_PRIVATE_SIZE too small"); + +static inline pkt_loop_t *pkt_priv(pktio_entry_t *pktio_entry) +{ + return (pkt_loop_t *)(uintptr_t)(pktio_entry->s.pkt_priv); +} + /* MAC address for the "loop" interface */ static const char pktio_loop_mac[] = {0x02, 0xe9, 0x34, 0x80, 0x73, 0x01};
@@ -56,11 +70,11 @@ static int loopback_open(odp_pktio_t id, pktio_entry_t *pktio_entry,
snprintf(loopq_name, sizeof(loopq_name), "%" PRIu64 "-pktio_loopq", odp_pktio_to_u64(id)); - pktio_entry->s.pkt_loop.loopq = + pkt_priv(pktio_entry)->loopq = odp_queue_create(loopq_name, NULL); - pktio_entry->s.pkt_loop.idx = idx; + pkt_priv(pktio_entry)->idx = idx;
- if (pktio_entry->s.pkt_loop.loopq == ODP_QUEUE_INVALID) + if (pkt_priv(pktio_entry)->loopq == ODP_QUEUE_INVALID) return -1;
loopback_stats_reset(pktio_entry); @@ -71,7 +85,7 @@ static int loopback_open(odp_pktio_t id, pktio_entry_t *pktio_entry,
static int loopback_close(pktio_entry_t *pktio_entry) { - return odp_queue_destroy(pktio_entry->s.pkt_loop.loopq); + return odp_queue_destroy(pkt_priv(pktio_entry)->loopq); }
static int loopback_recv(pktio_entry_t *pktio_entry, int index ODP_UNUSED, @@ -92,7 +106,7 @@ static int loopback_recv(pktio_entry_t *pktio_entry, int index ODP_UNUSED,
odp_ticketlock_lock(&pktio_entry->s.rxl);
- queue = queue_fn->from_ext(pktio_entry->s.pkt_loop.loopq); + queue = queue_fn->from_ext(pkt_priv(pktio_entry)->loopq); nbr = queue_fn->deq_multi(queue, hdr_tbl, num);
if (pktio_entry->s.config.pktin.bit.ts_all || @@ -310,7 +324,7 @@ static int loopback_send(pktio_entry_t *pktio_entry, int index ODP_UNUSED,
odp_ticketlock_lock(&pktio_entry->s.txl);
- queue = queue_fn->from_ext(pktio_entry->s.pkt_loop.loopq); + queue = queue_fn->from_ext(pkt_priv(pktio_entry)->loopq); ret = queue_fn->enq_multi(queue, hdr_tbl, nb_tx);
if (ret > 0) { @@ -335,7 +349,7 @@ static int loopback_mac_addr_get(pktio_entry_t *pktio_entry ODP_UNUSED, void *mac_addr) { memcpy(mac_addr, pktio_loop_mac, ETH_ALEN); - ((uint8_t *)mac_addr)[ETH_ALEN - 1] += pktio_entry->s.pkt_loop.idx; + ((uint8_t *)mac_addr)[ETH_ALEN - 1] += pkt_priv(pktio_entry)->idx; return ETH_ALEN; }
@@ -387,13 +401,13 @@ static int loopback_capability(pktio_entry_t *pktio_entry ODP_UNUSED, static int loopback_promisc_mode_set(pktio_entry_t *pktio_entry, odp_bool_t enable) { - pktio_entry->s.pkt_loop.promisc = enable; + pkt_priv(pktio_entry)->promisc = enable; return 0; }
static int loopback_promisc_mode_get(pktio_entry_t *pktio_entry) { - return pktio_entry->s.pkt_loop.promisc ? 1 : 0; + return pkt_priv(pktio_entry)->promisc ? 1 : 0; }
static int loopback_stats(pktio_entry_t *pktio_entry,
commit ffc3f2bd0059664273425eb0c34411ac5cd88c3e Author: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Date: Wed May 30 19:13:50 2018 +0300
linux-gen: pktio: add abstract pktio private data storage
In order to encapsulate PktIO private data, add common private data storage to pktio_entry_t.
Signed-off-by: Dmitry Eremin-Solenikov dmitry.ereminsolenikov@linaro.org Reviewed-by: Bill Fischofer bill.fischofer@linaro.org Signed-off-by: Maxim Uvarov maxim.uvarov@linaro.org
diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index 880237a5..dfcb1bcf 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -112,6 +112,8 @@ typedef struct { _ipc_map_remote_pool() */ } _ipc_pktio_t;
+#define PKTIO_PRIVATE_SIZE 384 + struct pktio_entry { const struct pktio_if_ops *ops; /**< Implementation specific methods */ /* These two locks together lock the whole pktio device */ @@ -133,6 +135,7 @@ struct pktio_entry { pkt_tap_t pkt_tap; /**< using TAP for IO */ _ipc_pktio_t ipc; /**< IPC pktio data */ pkt_null_t pkt_null; /**< using null for IO */ + unsigned char ODP_ALIGNED_CACHE pkt_priv[PKTIO_PRIVATE_SIZE]; }; enum { /* Not allocated */
-----------------------------------------------------------------------
Summary of changes: platform/linux-generic/Makefile.am | 3 - platform/linux-generic/include/odp_packet_dpdk.h | 62 +----- .../linux-generic/include/odp_packet_io_internal.h | 82 +------- platform/linux-generic/include/odp_packet_netmap.h | 73 ------- platform/linux-generic/include/odp_packet_null.h | 16 -- platform/linux-generic/include/odp_packet_socket.h | 25 --- platform/linux-generic/include/odp_packet_tap.h | 21 -- platform/linux-generic/pktio/dpdk.c | 122 ++++++++--- platform/linux-generic/pktio/ipc.c | 225 +++++++++++++-------- platform/linux-generic/pktio/loop.c | 32 ++- platform/linux-generic/pktio/netmap.c | 150 +++++++++----- platform/linux-generic/pktio/null.c | 19 +- platform/linux-generic/pktio/pcap.c | 33 ++- platform/linux-generic/pktio/socket.c | 42 ++-- platform/linux-generic/pktio/socket_mmap.c | 54 +++-- platform/linux-generic/pktio/tap.c | 47 +++-- 16 files changed, 509 insertions(+), 497 deletions(-) delete mode 100644 platform/linux-generic/include/odp_packet_netmap.h delete mode 100644 platform/linux-generic/include/odp_packet_null.h delete mode 100644 platform/linux-generic/include/odp_packet_tap.h
hooks/post-receive