Allow the same pool name for master and slave processes.

Signed-off-by: Maxim Uvarov <maxim.uva...@linaro.org>
---
 .../linux-generic/include/odp_packet_io_ipc_internal.h  |  2 --
 platform/linux-generic/pktio/ipc.c                      | 17 +++++++----------
 test/linux-generic/pktio_ipc/ipc_common.h               |  3 +++
 test/linux-generic/pktio_ipc/pktio_ipc1.c               |  2 +-
 test/linux-generic/pktio_ipc/pktio_ipc2.c               |  2 +-
 5 files changed, 12 insertions(+), 14 deletions(-)

diff --git a/platform/linux-generic/include/odp_packet_io_ipc_internal.h 
b/platform/linux-generic/include/odp_packet_io_ipc_internal.h
index 0ad2b22..1190e1e 100644
--- a/platform/linux-generic/include/odp_packet_io_ipc_internal.h
+++ b/platform/linux-generic/include/odp_packet_io_ipc_internal.h
@@ -28,8 +28,6 @@ struct pktio_info {
        struct {
                /* number of buffer in remote pool */
                int shm_pool_bufs_num;
-               /* size of remote pool */
-               size_t shm_pkt_pool_size;
                /* size of packet/segment in remote pool */
                uint32_t shm_pkt_size;
                /* offset from shared memory block start
diff --git a/platform/linux-generic/pktio/ipc.c 
b/platform/linux-generic/pktio/ipc.c
index a322f51..490abc5 100644
--- a/platform/linux-generic/pktio/ipc.c
+++ b/platform/linux-generic/pktio/ipc.c
@@ -17,7 +17,7 @@
 /* MAC address for the "ipc" interface */
 static const char pktio_ipc_mac[] = {0x12, 0x12, 0x12, 0x12, 0x12, 0x12};
 
-static void *_ipc_map_remote_pool(const char *name, size_t size, int pid);
+static void *_ipc_map_remote_pool(const char *name, int pid);
 
 static const char *_ipc_odp_buffer_pool_shm_name(odp_pool_t pool_hdl)
 {
@@ -44,7 +44,6 @@ static int _ipc_master_start(pktio_entry_t *pktio_entry)
                return -1;
 
        ipc_pool_base = _ipc_map_remote_pool(pinfo->slave.pool_name,
-                                            pinfo->master.shm_pkt_pool_size,
                                             pinfo->slave.pid);
        if (ipc_pool_base == NULL) {
                ODP_DBG("no pool file %s for pid %d\n",
@@ -147,7 +146,6 @@ static int _ipc_init_master(pktio_entry_t *pktio_entry,
        }
 
        memcpy(pinfo->master.pool_name, pool_name, strlen(pool_name));
-       pinfo->master.shm_pkt_pool_size = pool_entry->s.pool_size;
        pinfo->master.shm_pool_bufs_num = pool_entry->s.buf_num;
        pinfo->master.shm_pkt_size = pool_entry->s.seg_size;
        pinfo->master.mdata_offset =  pool_entry->s.pool_mdata_addr -
@@ -192,23 +190,23 @@ static void _ipc_export_pool(struct pktio_info *pinfo,
                                    pool_entry->s.pool_base_addr;
 }
 
-static void *_ipc_map_remote_pool(const char *name, size_t size, int pid)
+static void *_ipc_map_remote_pool(const char *name, int pid)
 {
        odp_shm_t shm;
        void *addr;
+       char rname[ODP_SHM_NAME_LEN];
 
-       ODP_DBG("Mapping remote pool %s, size %ld\n", name, size);
-
+       snprintf(rname, ODP_SHM_NAME_LEN, "remote-%s", name);
        shm = odp_shm_reserve_exported(name, pid,
-                                      name, 4096, 0);
+                                      rname, 4096, 0);
        if (shm == ODP_SHM_INVALID) {
                ODP_ERR("unable map %s\n", name);
                return NULL;
        }
 
        addr = odp_shm_addr(shm);
-       ODP_DBG("MAP master: %p - %p size %ld, pool %s\n",
-               addr, (char *)addr + size, size, name);
+
+       ODP_DBG("Mapped remote pool %s to local %s\n", name, rname);
        return addr;
 }
 
@@ -302,7 +300,6 @@ static int _ipc_slave_start(pktio_entry_t *pktio_entry)
        /* Get info about remote pool */
        pinfo = pktio_entry->s.ipc.pinfo;
        ipc_pool_base = _ipc_map_remote_pool(pinfo->master.pool_name,
-                                            pinfo->master.shm_pkt_pool_size,
                                             pid);
        pktio_entry->s.ipc.pool_mdata_base = (char *)ipc_pool_base +
                                             pinfo->master.mdata_offset;
diff --git a/test/linux-generic/pktio_ipc/ipc_common.h 
b/test/linux-generic/pktio_ipc/ipc_common.h
index 5cc1cb4..430d7b6 100644
--- a/test/linux-generic/pktio_ipc/ipc_common.h
+++ b/test/linux-generic/pktio_ipc/ipc_common.h
@@ -49,6 +49,9 @@
 #define TEST_IPC_PKTIO_NAME    "ipc:ipktio"
 #define TEST_IPC_PKTIO_PID_NAME "ipc:%d:ipktio"
 
+/** Can be any name, same or not the same. */
+#define TEST_IPC_POOL_NAME "ipc_packet_pool"
+
 /** magic number and sequence at start of packet payload */
 typedef struct ODP_PACKED {
        odp_u32be_t magic;
diff --git a/test/linux-generic/pktio_ipc/pktio_ipc1.c 
b/test/linux-generic/pktio_ipc/pktio_ipc1.c
index e646fcf..654b506 100644
--- a/test/linux-generic/pktio_ipc/pktio_ipc1.c
+++ b/test/linux-generic/pktio_ipc/pktio_ipc1.c
@@ -312,7 +312,7 @@ int main(int argc, char *argv[])
        params.pkt.num     = SHM_PKT_POOL_SIZE;
        params.type        = ODP_POOL_PACKET;
 
-       pool = odp_pool_create("packet_pool1", &params);
+       pool = odp_pool_create(TEST_IPC_POOL_NAME, &params);
        if (pool == ODP_POOL_INVALID) {
                EXAMPLE_ERR("Error: packet pool create failed.\n");
                exit(EXIT_FAILURE);
diff --git a/test/linux-generic/pktio_ipc/pktio_ipc2.c 
b/test/linux-generic/pktio_ipc/pktio_ipc2.c
index ce2fd04..74cc137 100644
--- a/test/linux-generic/pktio_ipc/pktio_ipc2.c
+++ b/test/linux-generic/pktio_ipc/pktio_ipc2.c
@@ -40,7 +40,7 @@ static int ipc_second_process(int master_pid)
        params.pkt.num     = SHM_PKT_POOL_SIZE;
        params.type        = ODP_POOL_PACKET;
 
-       pool = odp_pool_create("packet_pool2", &params);
+       pool = odp_pool_create(TEST_IPC_POOL_NAME, &params);
        if (pool == ODP_POOL_INVALID) {
                EXAMPLE_ERR("Error: packet pool create failed.\n");
                exit(EXIT_FAILURE);
-- 
2.7.1.250.gff4ea60

Reply via email to