Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/13909/?format=api
http://patchwork.dpdk.org/api/patches/13909/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/1466080236-112618-3-git-send-email-david.hunt@intel.com/", "project": { "id": 1, "url": "http://patchwork.dpdk.org/api/projects/1/?format=api", "name": "DPDK", "link_name": "dpdk", "list_id": "dev.dpdk.org", "list_email": "dev@dpdk.org", "web_url": "http://core.dpdk.org", "scm_url": "git://dpdk.org/dpdk", "webscm_url": "http://git.dpdk.org/dpdk", "list_archive_url": "https://inbox.dpdk.org/dev", "list_archive_url_format": "https://inbox.dpdk.org/dev/{}", "commit_url_format": "" }, "msgid": "<1466080236-112618-3-git-send-email-david.hunt@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/1466080236-112618-3-git-send-email-david.hunt@intel.com", "date": "2016-06-16T12:30:35", "name": "[dpdk-dev,v13,2/3] app/test: test external mempool manager", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": true, "hash": "8ed60a5863bd512f5c5ff43b7a567ffbfbee6cfb", "submitter": { "id": 342, "url": "http://patchwork.dpdk.org/api/people/342/?format=api", "name": "Hunt, David", "email": "david.hunt@intel.com" }, "delegate": { "id": 1, "url": "http://patchwork.dpdk.org/api/users/1/?format=api", "username": "tmonjalo", "first_name": "Thomas", "last_name": "Monjalon", "email": "thomas@monjalon.net" }, "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/1466080236-112618-3-git-send-email-david.hunt@intel.com/mbox/", "series": [], "comments": "http://patchwork.dpdk.org/api/patches/13909/comments/", "check": "pending", "checks": "http://patchwork.dpdk.org/api/patches/13909/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@dpdk.org", "Delivered-To": "patchwork@dpdk.org", "Received": [ "from [92.243.14.124] (localhost [IPv6:::1])\n\tby dpdk.org (Postfix) with ESMTP id C47E4C6CE;\n\tThu, 16 Jun 2016 14:30:53 +0200 (CEST)", "from mga09.intel.com (mga09.intel.com [134.134.136.24])\n\tby dpdk.org (Postfix) with ESMTP id A9E89C6B2\n\tfor <dev@dpdk.org>; Thu, 16 Jun 2016 14:30:44 +0200 (CEST)", "from fmsmga003.fm.intel.com ([10.253.24.29])\n\tby orsmga102.jf.intel.com with ESMTP; 16 Jun 2016 05:30:44 -0700", "from sie-lab-214-251.ir.intel.com (HELO silpixa373510.ir.intel.com)\n\t([10.237.214.251])\n\tby FMSMGA003.fm.intel.com with ESMTP; 16 Jun 2016 05:30:42 -0700" ], "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.26,480,1459839600\"; d=\"scan'208\";a=\"720053738\"", "From": "David Hunt <david.hunt@intel.com>", "To": "dev@dpdk.org", "Cc": "olivier.matz@6wind.com, viktorin@rehivetech.com,\n\tjerin.jacob@caviumnetworks.com, shreyansh.jain@nxp.com,\n\tDavid Hunt <david.hunt@intel.com>", "Date": "Thu, 16 Jun 2016 13:30:35 +0100", "Message-Id": "<1466080236-112618-3-git-send-email-david.hunt@intel.com>", "X-Mailer": "git-send-email 2.5.5", "In-Reply-To": "<1466080236-112618-1-git-send-email-david.hunt@intel.com>", "References": "<1465976824-83823-1-git-send-email-david.hunt@intel.com>\n\t<1466080236-112618-1-git-send-email-david.hunt@intel.com>", "Subject": "[dpdk-dev] [PATCH v13 2/3] app/test: test external mempool manager", "X-BeenThere": "dev@dpdk.org", "X-Mailman-Version": "2.1.15", "Precedence": "list", "List-Id": "patches and discussions about DPDK <dev.dpdk.org>", "List-Unsubscribe": "<http://dpdk.org/ml/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>", "List-Archive": "<http://dpdk.org/ml/archives/dev/>", "List-Post": "<mailto:dev@dpdk.org>", "List-Help": "<mailto:dev-request@dpdk.org?subject=help>", "List-Subscribe": "<http://dpdk.org/ml/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "Use a minimal custom mempool external ops and check that it also\npasses basic mempool autotests.\n\nSigned-off-by: Olivier Matz <olivier.matz@6wind.com>\nSigned-off-by: David Hunt <david.hunt@intel.com>\nAcked-by: Shreyansh Jain <shreyansh.jain@nxp.com>\nAcked-by: Olivier Matz <olivier.matz@6wind.com>\n---\n app/test/test_mempool.c | 122 +++++++++++++++++++++++++++++++++++++++++++++++-\n 1 file changed, 120 insertions(+), 2 deletions(-)", "diff": "diff --git a/app/test/test_mempool.c b/app/test/test_mempool.c\nindex b586249..31582d8 100644\n--- a/app/test/test_mempool.c\n+++ b/app/test/test_mempool.c\n@@ -83,6 +83,99 @@\n static rte_atomic32_t synchro;\n \n /*\n+ * Simple example of custom mempool structure. Holds pointers to all the\n+ * elements which are simply malloc'd in this example.\n+ */\n+struct custom_mempool {\n+\trte_spinlock_t lock;\n+\tunsigned count;\n+\tunsigned size;\n+\tvoid *elts[];\n+};\n+\n+/*\n+ * Loop through all the element pointers and allocate a chunk of memory, then\n+ * insert that memory into the ring.\n+ */\n+static int\n+custom_mempool_alloc(struct rte_mempool *mp)\n+{\n+\tstruct custom_mempool *cm;\n+\n+\tcm = rte_zmalloc(\"custom_mempool\",\n+\t\tsizeof(struct custom_mempool) + mp->size * sizeof(void *), 0);\n+\tif (cm == NULL)\n+\t\treturn -ENOMEM;\n+\n+\trte_spinlock_init(&cm->lock);\n+\tcm->count = 0;\n+\tcm->size = mp->size;\n+\tmp->pool_data = cm;\n+\treturn 0;\n+}\n+\n+static void\n+custom_mempool_free(struct rte_mempool *mp)\n+{\n+\trte_free((void *)(mp->pool_data));\n+}\n+\n+static int\n+custom_mempool_enqueue(struct rte_mempool *mp, void * const *obj_table,\n+\t\tunsigned n)\n+{\n+\tstruct custom_mempool *cm = (struct custom_mempool *)(mp->pool_data);\n+\tint ret = 0;\n+\n+\trte_spinlock_lock(&cm->lock);\n+\tif (cm->count + n > cm->size) {\n+\t\tret = -ENOBUFS;\n+\t} else {\n+\t\tmemcpy(&cm->elts[cm->count], obj_table, sizeof(void *) * n);\n+\t\tcm->count += n;\n+\t}\n+\trte_spinlock_unlock(&cm->lock);\n+\treturn ret;\n+}\n+\n+\n+static int\n+custom_mempool_dequeue(struct rte_mempool *mp, void **obj_table, unsigned n)\n+{\n+\tstruct custom_mempool *cm = (struct custom_mempool *)(mp->pool_data);\n+\tint ret = 0;\n+\n+\trte_spinlock_lock(&cm->lock);\n+\tif (n > cm->count) {\n+\t\tret = -ENOENT;\n+\t} else {\n+\t\tcm->count -= n;\n+\t\tmemcpy(obj_table, &cm->elts[cm->count], sizeof(void *) * n);\n+\t}\n+\trte_spinlock_unlock(&cm->lock);\n+\treturn ret;\n+}\n+\n+static unsigned\n+custom_mempool_get_count(const struct rte_mempool *mp)\n+{\n+\tstruct custom_mempool *cm = (struct custom_mempool *)(mp->pool_data);\n+\n+\treturn cm->count;\n+}\n+\n+static struct rte_mempool_ops mempool_ops_custom = {\n+\t.name = \"custom_handler\",\n+\t.alloc = custom_mempool_alloc,\n+\t.free = custom_mempool_free,\n+\t.enqueue = custom_mempool_enqueue,\n+\t.dequeue = custom_mempool_dequeue,\n+\t.get_count = custom_mempool_get_count,\n+};\n+\n+MEMPOOL_REGISTER_OPS(mempool_ops_custom);\n+\n+/*\n * save the object number in the first 4 bytes of object data. All\n * other bytes are set to 0.\n */\n@@ -292,12 +385,14 @@ static int test_mempool_single_consumer(void)\n * test function for mempool test based on singple consumer and single producer,\n * can run on one lcore only\n */\n-static int test_mempool_launch_single_consumer(__attribute__((unused)) void *arg)\n+static int\n+test_mempool_launch_single_consumer(__attribute__((unused)) void *arg)\n {\n \treturn test_mempool_single_consumer();\n }\n \n-static void my_mp_init(struct rte_mempool * mp, __attribute__((unused)) void * arg)\n+static void\n+my_mp_init(struct rte_mempool *mp, __attribute__((unused)) void *arg)\n {\n \tprintf(\"mempool name is %s\\n\", mp->name);\n \t/* nothing to be implemented here*/\n@@ -477,6 +572,7 @@ test_mempool(void)\n {\n \tstruct rte_mempool *mp_cache = NULL;\n \tstruct rte_mempool *mp_nocache = NULL;\n+\tstruct rte_mempool *mp_ext = NULL;\n \n \trte_atomic32_init(&synchro);\n \n@@ -505,6 +601,27 @@ test_mempool(void)\n \t\tgoto err;\n \t}\n \n+\t/* create a mempool with an external handler */\n+\tmp_ext = rte_mempool_create_empty(\"test_ext\",\n+\t\tMEMPOOL_SIZE,\n+\t\tMEMPOOL_ELT_SIZE,\n+\t\tRTE_MEMPOOL_CACHE_MAX_SIZE, 0,\n+\t\tSOCKET_ID_ANY, 0);\n+\n+\tif (mp_ext == NULL) {\n+\t\tprintf(\"cannot allocate mp_ext mempool\\n\");\n+\t\tgoto err;\n+\t}\n+\tif (rte_mempool_set_ops_byname(mp_ext, \"custom_handler\", NULL) < 0) {\n+\t\tprintf(\"cannot set custom handler\\n\");\n+\t\tgoto err;\n+\t}\n+\tif (rte_mempool_populate_default(mp_ext) < 0) {\n+\t\tprintf(\"cannot populate mp_ext mempool\\n\");\n+\t\tgoto err;\n+\t}\n+\trte_mempool_obj_iter(mp_ext, my_obj_init, NULL);\n+\n \t/* retrieve the mempool from its name */\n \tif (rte_mempool_lookup(\"test_nocache\") != mp_nocache) {\n \t\tprintf(\"Cannot lookup mempool from its name\\n\");\n@@ -545,6 +662,7 @@ test_mempool(void)\n err:\n \trte_mempool_free(mp_nocache);\n \trte_mempool_free(mp_cache);\n+\trte_mempool_free(mp_ext);\n \treturn -1;\n }\n \n", "prefixes": [ "dpdk-dev", "v13", "2/3" ] }{ "id": 13909, "url": "