get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/45782/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 45782,
    "url": "http://patches.dpdk.org/api/patches/45782/?format=api",
    "web_url": "http://patches.dpdk.org/project/dpdk/patch/1538400427-20164-3-git-send-email-tomaszx.jozwiak@intel.com/",
    "project": {
        "id": 1,
        "url": "http://patches.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": "<1538400427-20164-3-git-send-email-tomaszx.jozwiak@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1538400427-20164-3-git-send-email-tomaszx.jozwiak@intel.com",
    "date": "2018-10-01T13:27:06",
    "name": "[2/3] app/compress-perf: add performance measurement",
    "commit_ref": null,
    "pull_url": null,
    "state": "superseded",
    "archived": true,
    "hash": "119dfd49188952bc6422ce03fbec7a4755e1db14",
    "submitter": {
        "id": 949,
        "url": "http://patches.dpdk.org/api/people/949/?format=api",
        "name": "Tomasz Jozwiak",
        "email": "tomaszx.jozwiak@intel.com"
    },
    "delegate": {
        "id": 6690,
        "url": "http://patches.dpdk.org/api/users/6690/?format=api",
        "username": "akhil",
        "first_name": "akhil",
        "last_name": "goyal",
        "email": "gakhil@marvell.com"
    },
    "mbox": "http://patches.dpdk.org/project/dpdk/patch/1538400427-20164-3-git-send-email-tomaszx.jozwiak@intel.com/mbox/",
    "series": [
        {
            "id": 1615,
            "url": "http://patches.dpdk.org/api/series/1615/?format=api",
            "web_url": "http://patches.dpdk.org/project/dpdk/list/?series=1615",
            "date": "2018-10-01T13:27:04",
            "name": "app: add initial version of compress-perf",
            "version": 1,
            "mbox": "http://patches.dpdk.org/series/1615/mbox/"
        }
    ],
    "comments": "http://patches.dpdk.org/api/patches/45782/comments/",
    "check": "warning",
    "checks": "http://patches.dpdk.org/api/patches/45782/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 [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id 392761B397;\n\tMon,  1 Oct 2018 15:28:18 +0200 (CEST)",
            "from mga11.intel.com (mga11.intel.com [192.55.52.93])\n\tby dpdk.org (Postfix) with ESMTP id E19661B0FB\n\tfor <dev@dpdk.org>; Mon,  1 Oct 2018 15:28:15 +0200 (CEST)",
            "from fmsmga002.fm.intel.com ([10.253.24.26])\n\tby fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n\t01 Oct 2018 06:28:12 -0700",
            "from tjozwiax-mobl.ger.corp.intel.com (HELO localhost.localdomain)\n\t([10.103.104.44])\n\tby fmsmga002.fm.intel.com with ESMTP; 01 Oct 2018 06:27:14 -0700"
        ],
        "X-Amp-Result": "SKIPPED(no attachment in message)",
        "X-Amp-File-Uploaded": "False",
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.54,327,1534834800\"; d=\"scan'208\";a=\"91103217\"",
        "From": "Tomasz Jozwiak <tomaszx.jozwiak@intel.com>",
        "To": "dev@dpdk.org, fiona.trahe@intel.com, tomaszx.jozwiak@intel.com,\n\takhil.goyal@nxp.com, pablo.de.lara.guarch@intel.com",
        "Cc": "De@dpdk.org, Lara@dpdk.org, Guarch@dpdk.org",
        "Date": "Mon,  1 Oct 2018 15:27:06 +0200",
        "Message-Id": "<1538400427-20164-3-git-send-email-tomaszx.jozwiak@intel.com>",
        "X-Mailer": "git-send-email 2.7.4",
        "In-Reply-To": "<1538400427-20164-1-git-send-email-tomaszx.jozwiak@intel.com>",
        "References": "<1538400427-20164-1-git-send-email-tomaszx.jozwiak@intel.com>",
        "Subject": "[dpdk-dev] [PATCH 2/3] app/compress-perf: add performance\n\tmeasurement",
        "X-BeenThere": "dev@dpdk.org",
        "X-Mailman-Version": "2.1.15",
        "Precedence": "list",
        "List-Id": "DPDK patches and discussions <dev.dpdk.org>",
        "List-Unsubscribe": "<https://mails.dpdk.org/options/dev>,\n\t<mailto:dev-request@dpdk.org?subject=unsubscribe>",
        "List-Archive": "<http://mails.dpdk.org/archives/dev/>",
        "List-Post": "<mailto:dev@dpdk.org>",
        "List-Help": "<mailto:dev-request@dpdk.org?subject=help>",
        "List-Subscribe": "<https://mails.dpdk.org/listinfo/dev>,\n\t<mailto:dev-request@dpdk.org?subject=subscribe>",
        "Errors-To": "dev-bounces@dpdk.org",
        "Sender": "\"dev\" <dev-bounces@dpdk.org>"
    },
    "content": "Added performance measurement part into compression perf. test.\n\nSigned-off-by: De Lara Guarch, Pablo <pablo.de.lara.guarch@intel.com>\nSigned-off-by: Tomasz Jozwiak <tomaszx.jozwiak@intel.com>\n---\n app/test-compress-perf/main.c | 844 ++++++++++++++++++++++++++++++++++++++++++\n 1 file changed, 844 insertions(+)",
    "diff": "diff --git a/app/test-compress-perf/main.c b/app/test-compress-perf/main.c\nindex f52b98d..093dfaf 100644\n--- a/app/test-compress-perf/main.c\n+++ b/app/test-compress-perf/main.c\n@@ -5,13 +5,721 @@\n #include <rte_malloc.h>\n #include <rte_eal.h>\n #include <rte_log.h>\n+#include <rte_cycles.h>\n #include <rte_compressdev.h>\n \n #include \"comp_perf_options.h\"\n \n+#define NUM_MAX_XFORMS 16\n+#define NUM_MAX_INFLIGHT_OPS 512\n+#define EXPANSE_RATIO 1.05\n+#define MIN_ISAL_SIZE 8\n+\n+#define DIV_CEIL(a, b)  ((a) / (b) + ((a) % (b) != 0))\n+\n+static int\n+param_range_check(uint16_t size, const struct rte_param_log2_range *range)\n+{\n+\tunsigned int next_size;\n+\n+\t/* Check lower/upper bounds */\n+\tif (size < range->min)\n+\t\treturn -1;\n+\n+\tif (size > range->max)\n+\t\treturn -1;\n+\n+\t/* If range is actually only one value, size is correct */\n+\tif (range->increment == 0)\n+\t\treturn 0;\n+\n+\t/* Check if value is one of the supported sizes */\n+\tfor (next_size = range->min; next_size <= range->max;\n+\t\t\tnext_size += range->increment)\n+\t\tif (size == next_size)\n+\t\t\treturn 0;\n+\n+\treturn -1;\n+}\n+\n+static int\n+comp_perf_check_capabilities(struct comp_test_data *test_data)\n+{\n+\tconst struct rte_compressdev_capabilities *cap;\n+\n+\tcap = rte_compressdev_capability_get(test_data->cdev_id,\n+\t\t\t\t\t     RTE_COMP_ALGO_DEFLATE);\n+\n+\tif (cap == NULL) {\n+\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\"Compress device does not support DEFLATE\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\tuint64_t comp_flags = cap->comp_feature_flags;\n+\n+\t/* Huffman enconding */\n+\tif (test_data->huffman_enc == RTE_COMP_HUFFMAN_FIXED &&\n+\t\t\t(comp_flags & RTE_COMP_FF_HUFFMAN_FIXED) == 0) {\n+\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\"Compress device does not supported Fixed Huffman\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\tif (test_data->huffman_enc == RTE_COMP_HUFFMAN_DYNAMIC &&\n+\t\t\t(comp_flags & RTE_COMP_FF_HUFFMAN_DYNAMIC) == 0) {\n+\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\"Compress device does not supported Dynamic Huffman\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\t/* Window size */\n+\tif (test_data->window_sz != -1) {\n+\t\tif (param_range_check(test_data->window_sz, &cap->window_size)\n+\t\t\t\t< 0) {\n+\t\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\t\"Compress device does not support \"\n+\t\t\t\t\"this window size\\n\");\n+\t\t\treturn -1;\n+\t\t}\n+\t} else\n+\t\t/* Set window size to PMD maximum if none was specified */\n+\t\ttest_data->window_sz = cap->window_size.max;\n+\n+\t/* Check if chained mbufs is supported */\n+\tif (test_data->max_sgl_segs > 1  &&\n+\t\t\t(comp_flags & RTE_COMP_FF_OOP_SGL_IN_SGL_OUT) == 0) {\n+\t\tRTE_LOG(INFO, USER1, \"Compress device does not support \"\n+\t\t\t\t\"chained mbufs. Max SGL segments set to 1\\n\");\n+\t\ttest_data->max_sgl_segs = 1;\n+\t}\n+\n+\t/* Level 0 support */\n+\tif (test_data->level.min == 0 &&\n+\t\t\t(comp_flags & RTE_COMP_FF_NONCOMPRESSED_BLOCKS) == 0) {\n+\t\tRTE_LOG(ERR, USER1, \"Compress device does not support \"\n+\t\t\t\t\"level 0 (no compression)\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static int\n+comp_perf_allocate_memory(struct comp_test_data *test_data)\n+{\n+\t/* Number of segments for input and output\n+\t * (compression and decompression)\n+\t */\n+\tuint32_t total_segs = DIV_CEIL(test_data->input_data_sz,\n+\t\t\ttest_data->seg_sz);\n+\ttest_data->comp_buf_pool = rte_pktmbuf_pool_create(\"comp_buf_pool\",\n+\t\t\t\ttotal_segs,\n+\t\t\t\t0, 0, test_data->seg_sz + RTE_PKTMBUF_HEADROOM,\n+\t\t\t\trte_socket_id());\n+\tif (test_data->comp_buf_pool == NULL) {\n+\t\tRTE_LOG(ERR, USER1, \"Mbuf mempool could not be created\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\ttest_data->decomp_buf_pool = rte_pktmbuf_pool_create(\"decomp_buf_pool\",\n+\t\t\t\ttotal_segs,\n+\t\t\t\t0, 0, test_data->seg_sz + RTE_PKTMBUF_HEADROOM,\n+\t\t\t\trte_socket_id());\n+\tif (test_data->decomp_buf_pool == NULL) {\n+\t\tRTE_LOG(ERR, USER1, \"Mbuf mempool could not be created\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\ttest_data->total_bufs = DIV_CEIL(total_segs, test_data->max_sgl_segs);\n+\n+\ttest_data->op_pool = rte_comp_op_pool_create(\"op_pool\",\n+\t\t\t\t  test_data->total_bufs,\n+\t\t\t\t  0, 0, rte_socket_id());\n+\tif (test_data->op_pool == NULL) {\n+\t\tRTE_LOG(ERR, USER1, \"Comp op mempool could not be created\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\t/*\n+\t * Compressed data might be a bit larger than input data,\n+\t * if data cannot be compressed\n+\t */\n+\ttest_data->compressed_data = rte_zmalloc_socket(NULL,\n+\t\t\t\ttest_data->input_data_sz * EXPANSE_RATIO\n+\t\t\t\t\t\t\t+ MIN_ISAL_SIZE, 0,\n+\t\t\t\trte_socket_id());\n+\tif (test_data->compressed_data == NULL) {\n+\t\tRTE_LOG(ERR, USER1, \"Memory to hold the data from the input \"\n+\t\t\t\t\"file could not be allocated\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\ttest_data->decompressed_data = rte_zmalloc_socket(NULL,\n+\t\t\t\ttest_data->input_data_sz, 0,\n+\t\t\t\trte_socket_id());\n+\tif (test_data->decompressed_data == NULL) {\n+\t\tRTE_LOG(ERR, USER1, \"Memory to hold the data from the input \"\n+\t\t\t\t\"file could not be allocated\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\ttest_data->comp_bufs = rte_zmalloc_socket(NULL,\n+\t\t\ttest_data->total_bufs * sizeof(struct rte_mbuf *),\n+\t\t\t0, rte_socket_id());\n+\tif (test_data->comp_bufs == NULL) {\n+\t\tRTE_LOG(ERR, USER1, \"Memory to hold the compression mbufs\"\n+\t\t\t\t\" could not be allocated\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\ttest_data->decomp_bufs = rte_zmalloc_socket(NULL,\n+\t\t\ttest_data->total_bufs * sizeof(struct rte_mbuf *),\n+\t\t\t0, rte_socket_id());\n+\tif (test_data->decomp_bufs == NULL) {\n+\t\tRTE_LOG(ERR, USER1, \"Memory to hold the decompression mbufs\"\n+\t\t\t\t\" could not be allocated\\n\");\n+\t\treturn -1;\n+\t}\n+\treturn 0;\n+}\n+\n+static int\n+comp_perf_dump_input_data(struct comp_test_data *test_data)\n+{\n+\tFILE *f = fopen(test_data->input_file, \"r\");\n+\n+\tif (f == NULL) {\n+\t\tRTE_LOG(ERR, USER1, \"Input file could not be opened\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\tif (fseek(f, 0, SEEK_END) != 0) {\n+\t\tRTE_LOG(ERR, USER1, \"Size of input could not be calculated\\n\");\n+\t\tgoto err;\n+\t}\n+\tsize_t actual_file_sz = ftell(f);\n+\t/* If extended input data size has not been set,\n+\t * input data size = file size\n+\t */\n+\n+\tif (test_data->input_data_sz == 0)\n+\t\ttest_data->input_data_sz = actual_file_sz;\n+\n+\tif (fseek(f, 0, SEEK_SET) != 0) {\n+\t\tRTE_LOG(ERR, USER1, \"Size of input could not be calculated\\n\");\n+\t\tgoto err;\n+\t}\n+\n+\ttest_data->input_data = rte_zmalloc_socket(NULL,\n+\t\t\t\ttest_data->input_data_sz, 0, rte_socket_id());\n+\n+\tif (test_data->input_data == NULL) {\n+\t\tRTE_LOG(ERR, USER1, \"Memory to hold the data from the input \"\n+\t\t\t\t\"file could not be allocated\\n\");\n+\t\tgoto err;\n+\t}\n+\n+\tsize_t remaining_data = test_data->input_data_sz;\n+\tuint8_t *data = test_data->input_data;\n+\n+\twhile (remaining_data > 0) {\n+\t\tsize_t data_to_read = RTE_MIN(remaining_data, actual_file_sz);\n+\n+\t\tif (fread(data, data_to_read, 1, f) != 1) {\n+\t\t\tRTE_LOG(ERR, USER1, \"Input file could not be read\\n\");\n+\t\t\tgoto err;\n+\t\t}\n+\t\tif (fseek(f, 0, SEEK_SET) != 0) {\n+\t\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\t\"Size of input could not be calculated\\n\");\n+\t\t\tgoto err;\n+\t\t}\n+\t\tremaining_data -= data_to_read;\n+\t\tdata += data_to_read;\n+\t}\n+\n+\tif (test_data->input_data_sz > actual_file_sz)\n+\t\tRTE_LOG(INFO, USER1,\n+\t\t  \"%zu bytes read from file %s, extending the file %.2f times\\n\",\n+\t\t\ttest_data->input_data_sz, test_data->input_file,\n+\t\t\t(double)test_data->input_data_sz/actual_file_sz);\n+\telse\n+\t\tRTE_LOG(INFO, USER1,\n+\t\t\t\"%zu bytes read from file %s\\n\",\n+\t\t\ttest_data->input_data_sz, test_data->input_file);\n+\n+\tfclose(f);\n+\n+\treturn 0;\n+\n+err:\n+\tfclose(f);\n+\trte_free(test_data->input_data);\n+\ttest_data->input_data = NULL;\n+\n+\treturn -1;\n+}\n+\n+static int\n+comp_perf_initialize_compressdev(struct comp_test_data *test_data)\n+{\n+\tuint8_t enabled_cdev_count;\n+\tuint8_t enabled_cdevs[RTE_COMPRESS_MAX_DEVS];\n+\n+\tenabled_cdev_count = rte_compressdev_devices_get(test_data->driver_name,\n+\t\t\tenabled_cdevs, RTE_COMPRESS_MAX_DEVS);\n+\tif (enabled_cdev_count == 0) {\n+\t\tRTE_LOG(ERR, USER1, \"No compress devices type %s available\\n\",\n+\t\t\t\ttest_data->driver_name);\n+\t\treturn -EINVAL;\n+\t}\n+\n+\tif (enabled_cdev_count > 1)\n+\t\tRTE_LOG(INFO, USER1,\n+\t\t\t\"Only the first compress device will be used\\n\");\n+\n+\ttest_data->cdev_id = enabled_cdevs[0];\n+\n+\tif (comp_perf_check_capabilities(test_data) < 0)\n+\t\treturn -1;\n+\n+\t/* Configure compressdev (one device, one queue pair) */\n+\tstruct rte_compressdev_config config = {\n+\t\t.socket_id = rte_socket_id(),\n+\t\t.nb_queue_pairs = 1,\n+\t\t.max_nb_priv_xforms = NUM_MAX_XFORMS,\n+\t\t.max_nb_streams = 0\n+\t};\n+\n+\tif (rte_compressdev_configure(test_data->cdev_id, &config) < 0) {\n+\t\tRTE_LOG(ERR, USER1, \"Device configuration failed\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\tif (rte_compressdev_queue_pair_setup(test_data->cdev_id, 0,\n+\t\t\tNUM_MAX_INFLIGHT_OPS, rte_socket_id()) < 0) {\n+\t\tRTE_LOG(ERR, USER1, \"Queue pair setup failed\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\tif (rte_compressdev_start(test_data->cdev_id) < 0) {\n+\t\tRTE_LOG(ERR, USER1, \"Device could not be started\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static int\n+prepare_bufs(struct comp_test_data *test_data)\n+{\n+\tuint32_t remaining_data = test_data->input_data_sz;\n+\tuint8_t *input_data_ptr = test_data->input_data;\n+\tsize_t data_sz;\n+\tuint8_t *data_addr;\n+\tuint32_t i, j;\n+\n+\tfor (i = 0; i < test_data->total_bufs; i++) {\n+\t\t/* Allocate data in input mbuf and copy data from input file */\n+\t\ttest_data->decomp_bufs[i] =\n+\t\t\trte_pktmbuf_alloc(test_data->decomp_buf_pool);\n+\t\tif (test_data->decomp_bufs[i] == NULL) {\n+\t\t\tRTE_LOG(ERR, USER1, \"Could not allocate mbuf\\n\");\n+\t\t\treturn -1;\n+\t\t}\n+\n+\t\tdata_sz = RTE_MIN(remaining_data, test_data->seg_sz);\n+\t\tdata_addr = (uint8_t *) rte_pktmbuf_append(\n+\t\t\t\t\ttest_data->decomp_bufs[i], data_sz);\n+\t\tif (data_addr == NULL) {\n+\t\t\tRTE_LOG(ERR, USER1, \"Could not append data\\n\");\n+\t\t\treturn -1;\n+\t\t}\n+\t\trte_memcpy(data_addr, input_data_ptr, data_sz);\n+\n+\t\tinput_data_ptr += data_sz;\n+\t\tremaining_data -= data_sz;\n+\n+\t\t/* Already one segment in the mbuf */\n+\t\tuint16_t segs_per_mbuf = 1;\n+\n+\t\t/* Chain mbufs if needed for input mbufs */\n+\t\twhile (segs_per_mbuf < test_data->max_sgl_segs\n+\t\t\t\t&& remaining_data > 0) {\n+\t\t\tstruct rte_mbuf *next_seg =\n+\t\t\t\trte_pktmbuf_alloc(test_data->decomp_buf_pool);\n+\n+\t\t\tif (next_seg == NULL) {\n+\t\t\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\t\t\"Could not allocate mbuf\\n\");\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\n+\t\t\tdata_sz = RTE_MIN(remaining_data, test_data->seg_sz);\n+\t\t\tdata_addr = (uint8_t *)rte_pktmbuf_append(next_seg,\n+\t\t\t\tdata_sz);\n+\n+\t\t\tif (data_addr == NULL) {\n+\t\t\t\tRTE_LOG(ERR, USER1, \"Could not append data\\n\");\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\n+\t\t\trte_memcpy(data_addr, input_data_ptr, data_sz);\n+\t\t\tinput_data_ptr += data_sz;\n+\t\t\tremaining_data -= data_sz;\n+\n+\t\t\tif (rte_pktmbuf_chain(test_data->decomp_bufs[i],\n+\t\t\t\t\tnext_seg) < 0) {\n+\t\t\t\tRTE_LOG(ERR, USER1, \"Could not chain mbufs\\n\");\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t\tsegs_per_mbuf++;\n+\t\t}\n+\n+\t\t/* Allocate data in output mbuf */\n+\t\ttest_data->comp_bufs[i] =\n+\t\t\trte_pktmbuf_alloc(test_data->comp_buf_pool);\n+\t\tif (test_data->comp_bufs[i] == NULL) {\n+\t\t\tRTE_LOG(ERR, USER1, \"Could not allocate mbuf\\n\");\n+\t\t\treturn -1;\n+\t\t}\n+\t\tdata_addr = (uint8_t *) rte_pktmbuf_append(\n+\t\t\t\t\ttest_data->comp_bufs[i],\n+\t\t\t\t\ttest_data->seg_sz);\n+\t\tif (data_addr == NULL) {\n+\t\t\tRTE_LOG(ERR, USER1, \"Could not append data\\n\");\n+\t\t\treturn -1;\n+\t\t}\n+\n+\t\t/* Chain mbufs if needed for output mbufs */\n+\t\tfor (j = 1; j < segs_per_mbuf; j++) {\n+\t\t\tstruct rte_mbuf *next_seg =\n+\t\t\t\trte_pktmbuf_alloc(test_data->comp_buf_pool);\n+\n+\t\t\tif (next_seg == NULL) {\n+\t\t\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\t\t\"Could not allocate mbuf\\n\");\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\n+\t\t\tdata_addr = (uint8_t *)rte_pktmbuf_append(next_seg,\n+\t\t\t\ttest_data->seg_sz);\n+\n+\t\t\tif (data_addr == NULL) {\n+\t\t\t\tRTE_LOG(ERR, USER1, \"Could not append data\\n\");\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\n+\t\t\tif (rte_pktmbuf_chain(test_data->comp_bufs[i],\n+\t\t\t\t\tnext_seg) < 0) {\n+\t\t\t\tRTE_LOG(ERR, USER1, \"Could not chain mbufs\\n\");\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t}\n+\t}\n+\n+\treturn 0;\n+}\n+\n+static void\n+free_bufs(struct comp_test_data *test_data)\n+{\n+\tuint32_t i;\n+\n+\tfor (i = 0; i < test_data->total_bufs; i++) {\n+\t\trte_pktmbuf_free(test_data->comp_bufs[i]);\n+\t\trte_pktmbuf_free(test_data->decomp_bufs[i]);\n+\t}\n+\trte_free(test_data->comp_bufs);\n+\trte_free(test_data->decomp_bufs);\n+}\n+\n+static int\n+main_loop(struct comp_test_data *test_data, uint8_t level,\n+\t\t\tenum rte_comp_xform_type type,\n+\t\t\tuint8_t *output_data_ptr,\n+\t\t\tsize_t *output_data_sz,\n+\t\t\tunsigned int benchmarking)\n+{\n+\tuint8_t dev_id = test_data->cdev_id;\n+\tuint32_t i, iter, num_iter;\n+\tstruct rte_comp_op **ops, **deq_ops;\n+\tvoid *priv_xform = NULL;\n+\tstruct rte_comp_xform xform;\n+\tsize_t output_size = 0;\n+\tstruct rte_mbuf **input_bufs, **output_bufs;\n+\tint res = 0;\n+\tint allocated = 0;\n+\n+\tif (test_data == NULL || !test_data->burst_sz) {\n+\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\"Unknow burst size\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\tops = rte_zmalloc_socket(NULL,\n+\t\t2 * test_data->total_bufs * sizeof(struct rte_comp_op *),\n+\t\t0, rte_socket_id());\n+\n+\tif (ops == NULL) {\n+\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\"Can't allocate memory for ops strucures\\n\");\n+\t\treturn -1;\n+\t}\n+\n+\tdeq_ops = &ops[test_data->total_bufs];\n+\n+\tif (type == RTE_COMP_COMPRESS) {\n+\t\txform = (struct rte_comp_xform) {\n+\t\t\t.type = RTE_COMP_COMPRESS,\n+\t\t\t.compress = {\n+\t\t\t\t.algo = RTE_COMP_ALGO_DEFLATE,\n+\t\t\t\t.deflate.huffman = test_data->huffman_enc,\n+\t\t\t\t.level = level,\n+\t\t\t\t.window_size = test_data->window_sz,\n+\t\t\t\t.chksum = RTE_COMP_CHECKSUM_NONE,\n+\t\t\t\t.hash_algo = RTE_COMP_HASH_ALGO_NONE\n+\t\t\t}\n+\t\t};\n+\t\tinput_bufs = test_data->decomp_bufs;\n+\t\toutput_bufs = test_data->comp_bufs;\n+\t} else {\n+\t\txform = (struct rte_comp_xform) {\n+\t\t\t.type = RTE_COMP_DECOMPRESS,\n+\t\t\t.decompress = {\n+\t\t\t\t.algo = RTE_COMP_ALGO_DEFLATE,\n+\t\t\t\t.chksum = RTE_COMP_CHECKSUM_NONE,\n+\t\t\t\t.window_size = test_data->window_sz,\n+\t\t\t\t.hash_algo = RTE_COMP_HASH_ALGO_NONE\n+\t\t\t}\n+\t\t};\n+\t\tinput_bufs = test_data->comp_bufs;\n+\t\toutput_bufs = test_data->decomp_bufs;\n+\t}\n+\n+\t/* Create private xform */\n+\tif (rte_compressdev_private_xform_create(dev_id, &xform,\n+\t\t\t&priv_xform) < 0) {\n+\t\tRTE_LOG(ERR, USER1, \"Private xform could not be created\\n\");\n+\t\tres = -1;\n+\t\tgoto end;\n+\t}\n+\n+\tuint64_t tsc_start, tsc_end, tsc_duration;\n+\n+\ttsc_start = tsc_end = tsc_duration = 0;\n+\tif (benchmarking) {\n+\t\ttsc_start = rte_rdtsc();\n+\t\tnum_iter = test_data->num_iter;\n+\t} else\n+\t\tnum_iter = 1;\n+\n+\tfor (iter = 0; iter < num_iter; iter++) {\n+\t\tuint32_t total_ops = test_data->total_bufs;\n+\t\tuint32_t remaining_ops = test_data->total_bufs;\n+\t\tuint32_t total_deq_ops = 0;\n+\t\tuint32_t total_enq_ops = 0;\n+\t\tuint16_t ops_unused = 0;\n+\t\tuint16_t num_enq = 0;\n+\t\tuint16_t num_deq = 0;\n+\n+\t\toutput_size = 0;\n+\n+\t\twhile (remaining_ops > 0) {\n+\t\t\tuint16_t num_ops = RTE_MIN(remaining_ops,\n+\t\t\t\t\t\t   test_data->burst_sz);\n+\t\t\tuint16_t ops_needed = num_ops - ops_unused;\n+\n+\t\t\t/*\n+\t\t\t * Move the unused operations from the previous\n+\t\t\t * enqueue_burst call to the front, to maintain order\n+\t\t\t */\n+\t\t\tif ((ops_unused > 0) && (num_enq > 0)) {\n+\t\t\t\tsize_t nb_b_to_mov =\n+\t\t\t\t      ops_unused * sizeof(struct rte_comp_op *);\n+\n+\t\t\t\tmemmove(ops, &ops[num_enq], nb_b_to_mov);\n+\t\t\t}\n+\n+\t\t\t/* Allocate compression operations */\n+\t\t\tif (ops_needed && !rte_comp_op_bulk_alloc(\n+\t\t\t\t\t\ttest_data->op_pool,\n+\t\t\t\t\t\t&ops[ops_unused],\n+\t\t\t\t\t\tops_needed)) {\n+\t\t\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\t      \"Could not allocate enough operations\\n\");\n+\t\t\t\tres = -1;\n+\t\t\t\tgoto end;\n+\t\t\t}\n+\t\t\tallocated += ops_needed;\n+\n+\t\t\tfor (i = 0; i < ops_needed; i++) {\n+\t\t\t\t/*\n+\t\t\t\t * Calculate next buffer to attach to operation\n+\t\t\t\t */\n+\t\t\t\tuint32_t buf_id = total_enq_ops + i +\n+\t\t\t\t\t\tops_unused;\n+\t\t\t\tuint16_t op_id = ops_unused + i;\n+\t\t\t\t/* Reset all data in output buffers */\n+\t\t\t\tstruct rte_mbuf *m = output_bufs[buf_id];\n+\n+\t\t\t\tm->pkt_len = test_data->seg_sz * m->nb_segs;\n+\t\t\t\twhile (m) {\n+\t\t\t\t\tm->data_len = m->buf_len - m->data_off;\n+\t\t\t\t\tm = m->next;\n+\t\t\t\t}\n+\t\t\t\tops[op_id]->m_src = input_bufs[buf_id];\n+\t\t\t\tops[op_id]->m_dst = output_bufs[buf_id];\n+\t\t\t\tops[op_id]->src.offset = 0;\n+\t\t\t\tops[op_id]->src.length =\n+\t\t\t\t\trte_pktmbuf_pkt_len(input_bufs[buf_id]);\n+\t\t\t\tops[op_id]->dst.offset = 0;\n+\t\t\t\tops[op_id]->flush_flag = RTE_COMP_FLUSH_FINAL;\n+\t\t\t\tops[op_id]->input_chksum = buf_id;\n+\t\t\t\tops[op_id]->private_xform = priv_xform;\n+\t\t\t}\n+\n+\t\t\tnum_enq = rte_compressdev_enqueue_burst(dev_id, 0, ops,\n+\t\t\t\t\t\t\t\tnum_ops);\n+\t\t\tops_unused = num_ops - num_enq;\n+\t\t\tremaining_ops -= num_enq;\n+\t\t\ttotal_enq_ops += num_enq;\n+\n+\t\t\tnum_deq = rte_compressdev_dequeue_burst(dev_id, 0,\n+\t\t\t\t\t\t\t   deq_ops,\n+\t\t\t\t\t\t\t   test_data->burst_sz);\n+\t\t\ttotal_deq_ops += num_deq;\n+\t\t\tif (benchmarking == 0) {\n+\t\t\t\tfor (i = 0; i < num_deq; i++) {\n+\t\t\t\t\tstruct rte_comp_op *op = deq_ops[i];\n+\t\t\t\t\tconst void *read_data_addr =\n+\t\t\t\t\t\trte_pktmbuf_read(op->m_dst, 0,\n+\t\t\t\t\t\top->produced, output_data_ptr);\n+\t\t\t\t\tif (read_data_addr == NULL) {\n+\t\t\t\t\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\t      \"Could not copy buffer in destination\\n\");\n+\t\t\t\t\t\tres = -1;\n+\t\t\t\t\t\tgoto end;\n+\t\t\t\t\t}\n+\n+\t\t\t\t\tif (read_data_addr != output_data_ptr)\n+\t\t\t\t\t\trte_memcpy(output_data_ptr,\n+\t\t\t\t\t\t\trte_pktmbuf_mtod(\n+\t\t\t\t\t\t\t  op->m_dst, uint8_t *),\n+\t\t\t\t\t\t\top->produced);\n+\t\t\t\t\toutput_data_ptr += op->produced;\n+\t\t\t\t\toutput_size += op->produced;\n+\n+\t\t\t\t}\n+\t\t\t}\n+\n+\t\t\tif (iter == num_iter - 1) {\n+\t\t\t\tfor (i = 0; i < num_deq; i++) {\n+\t\t\t\t\tstruct rte_comp_op *op = deq_ops[i];\n+\t\t\t\t\tstruct rte_mbuf *m = op->m_dst;\n+\n+\t\t\t\t\tm->pkt_len = op->produced;\n+\t\t\t\t\tuint32_t remaining_data = op->produced;\n+\t\t\t\t\tuint16_t data_to_append;\n+\n+\t\t\t\t\twhile (remaining_data > 0) {\n+\t\t\t\t\t\tdata_to_append =\n+\t\t\t\t\t\t\tRTE_MIN(remaining_data,\n+\t\t\t\t\t\t\t     test_data->seg_sz);\n+\t\t\t\t\t\tm->data_len = data_to_append;\n+\t\t\t\t\t\tremaining_data -=\n+\t\t\t\t\t\t\t\tdata_to_append;\n+\t\t\t\t\t\tm = m->next;\n+\t\t\t\t\t}\n+\t\t\t\t}\n+\t\t\t}\n+\t\t\trte_mempool_put_bulk(test_data->op_pool,\n+\t\t\t\t\t     (void **)deq_ops, num_deq);\n+\t\t\tallocated -= num_deq;\n+\t\t}\n+\n+\t\t/* Dequeue the last operations */\n+\t\twhile (total_deq_ops < total_ops) {\n+\t\t\tnum_deq = rte_compressdev_dequeue_burst(dev_id, 0,\n+\t\t\t\t\t\tdeq_ops, test_data->burst_sz);\n+\t\t\ttotal_deq_ops += num_deq;\n+\t\t\tif (benchmarking == 0) {\n+\t\t\t\tfor (i = 0; i < num_deq; i++) {\n+\t\t\t\t\tstruct rte_comp_op *op = deq_ops[i];\n+\t\t\t\t\tconst void *read_data_addr =\n+\t\t\t\t\t\trte_pktmbuf_read(op->m_dst, 0,\n+\t\t\t\t\t\top->produced, output_data_ptr);\n+\t\t\t\t\tif (read_data_addr == NULL) {\n+\t\t\t\t\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\t      \"Could not copy buffer in destination\\n\");\n+\t\t\t\t\t\tres = -1;\n+\t\t\t\t\t\tgoto end;\n+\t\t\t\t\t}\n+\n+\t\t\t\t\tif (read_data_addr != output_data_ptr)\n+\t\t\t\t\t\trte_memcpy(output_data_ptr,\n+\t\t\t\t\t\t\trte_pktmbuf_mtod(\n+\t\t\t\t\t\t\top->m_dst, uint8_t *),\n+\t\t\t\t\t\t\top->produced);\n+\t\t\t\t\toutput_data_ptr += op->produced;\n+\t\t\t\t\toutput_size += op->produced;\n+\n+\t\t\t\t}\n+\t\t\t}\n+\n+\t\t\tif (iter == num_iter - 1) {\n+\t\t\t\tfor (i = 0; i < num_deq; i++) {\n+\t\t\t\t\tstruct rte_comp_op *op = deq_ops[i];\n+\t\t\t\t\tstruct rte_mbuf *m = op->m_dst;\n+\n+\t\t\t\t\tm->pkt_len = op->produced;\n+\t\t\t\t\tuint32_t remaining_data = op->produced;\n+\t\t\t\t\tuint16_t data_to_append;\n+\n+\t\t\t\t\twhile (remaining_data > 0) {\n+\t\t\t\t\t\tdata_to_append =\n+\t\t\t\t\t\tRTE_MIN(remaining_data,\n+\t\t\t\t\t\t\ttest_data->seg_sz);\n+\t\t\t\t\t\tm->data_len = data_to_append;\n+\t\t\t\t\t\tremaining_data -=\n+\t\t\t\t\t\t\t\tdata_to_append;\n+\t\t\t\t\t\tm = m->next;\n+\t\t\t\t\t}\n+\t\t\t\t}\n+\t\t\t}\n+\t\t\trte_mempool_put_bulk(test_data->op_pool,\n+\t\t\t\t\t     (void **)deq_ops, num_deq);\n+\t\t\tallocated -= num_deq;\n+\t\t}\n+\t}\n+\n+\tif (benchmarking) {\n+\t\ttsc_end = rte_rdtsc();\n+\t\ttsc_duration = tsc_end - tsc_start;\n+\n+\t\tif (type == RTE_COMP_COMPRESS)\n+\t\t\ttest_data->comp_tsc_duration[level] =\n+\t\t\t\t\ttsc_duration / num_iter;\n+\t\telse\n+\t\t\ttest_data->decomp_tsc_duration[level] =\n+\t\t\t\t\ttsc_duration / num_iter;\n+\t}\n+\n+\tif (benchmarking == 0 && output_data_sz)\n+\t\t*output_data_sz = output_size;\n+end:\n+\trte_mempool_put_bulk(test_data->op_pool, (void **)ops, allocated);\n+\trte_compressdev_private_xform_free(dev_id, priv_xform);\n+\trte_free(ops);\n+\treturn res;\n+}\n+\n int\n main(int argc, char **argv)\n {\n+\tuint8_t level, level_idx = 0;\n+\tuint8_t i;\n \tint ret;\n \tstruct comp_test_data *test_data;\n \n@@ -43,9 +751,145 @@ main(int argc, char **argv)\n \t\tgoto err;\n \t}\n \n+\tif (comp_perf_initialize_compressdev(test_data) < 0) {\n+\t\tret = EXIT_FAILURE;\n+\t\tgoto err;\n+\t}\n+\n+\tif (comp_perf_dump_input_data(test_data) < 0) {\n+\t\tret = EXIT_FAILURE;\n+\t\tgoto err;\n+\t}\n+\n+\tif (comp_perf_allocate_memory(test_data) < 0) {\n+\t\tret = EXIT_FAILURE;\n+\t\tgoto err;\n+\t}\n+\n+\tif (prepare_bufs(test_data) < 0) {\n+\t\tret = EXIT_FAILURE;\n+\t\tgoto err;\n+\t}\n+\n+\tif (test_data->level.inc != 0)\n+\t\tlevel = test_data->level.min;\n+\telse\n+\t\tlevel = test_data->level.list[0];\n+\n+\tsize_t comp_data_sz;\n+\tsize_t decomp_data_sz;\n+\n+\tprintf(\"Burst size = %u\\n\", test_data->burst_sz);\n+\tprintf(\"File size = %zu\\n\", test_data->input_data_sz);\n+\n+\tprintf(\"%6s%12s%17s%19s%21s%15s%21s%23s%16s\\n\",\n+\t\t\"Level\", \"Comp size\", \"Comp ratio [%]\",\n+\t\t\"Comp [Cycles/it]\", \"Comp [Cycles/Byte]\", \"Comp [Gbps]\",\n+\t\t\"Decomp [Cycles/it]\", \"Decomp [Cycles/Byte]\", \"Decomp [Gbps]\");\n+\n+\twhile (level <= test_data->level.max) {\n+\t\t/*\n+\t\t * Run a first iteration, to verify compression and\n+\t\t * get the compression ratio for the level\n+\t\t */\n+\t\tif (main_loop(test_data, level, RTE_COMP_COMPRESS,\n+\t\t\t      test_data->compressed_data,\n+\t\t\t      &comp_data_sz, 0) < 0) {\n+\t\t\tret = EXIT_FAILURE;\n+\t\t\tgoto err;\n+\t\t}\n+\n+\t\tif (main_loop(test_data, level, RTE_COMP_DECOMPRESS,\n+\t\t\t      test_data->decompressed_data,\n+\t\t\t      &decomp_data_sz, 0) < 0) {\n+\t\t\tret = EXIT_FAILURE;\n+\t\t\tgoto err;\n+\t\t}\n+\n+\t\tif (decomp_data_sz != test_data->input_data_sz) {\n+\t\t\tRTE_LOG(ERR, USER1,\n+\t\t   \"Decompressed data length not equal to input data length\\n\");\n+\t\t\tRTE_LOG(ERR, USER1,\n+\t\t\t\t\"Decompressed size = %zu, expected = %zu\\n\",\n+\t\t\t\tdecomp_data_sz, test_data->input_data_sz);\n+\t\t\tret = EXIT_FAILURE;\n+\t\t\tgoto err;\n+\t\t} else {\n+\t\t\tif (memcmp(test_data->decompressed_data,\n+\t\t\t\t\ttest_data->input_data,\n+\t\t\t\t\ttest_data->input_data_sz) != 0) {\n+\t\t\t\tRTE_LOG(ERR, USER1,\n+\t\t\t    \"Decompressed data is not the same as file data\\n\");\n+\t\t\t\tret = EXIT_FAILURE;\n+\t\t\t\tgoto err;\n+\t\t\t}\n+\t\t}\n+\n+\t\tdouble ratio = (double) comp_data_sz /\n+\t\t\t\t\t\ttest_data->input_data_sz * 100;\n+\n+\t\t/*\n+\t\t * Run the tests twice, discarding the first performance\n+\t\t * results, before the cache is warmed up\n+\t\t */\n+\t\tfor (i = 0; i < 2; i++) {\n+\t\t\tif (main_loop(test_data, level, RTE_COMP_COMPRESS,\n+\t\t\t\t\tNULL, NULL, 1) < 0) {\n+\t\t\t\tret = EXIT_FAILURE;\n+\t\t\t\tgoto err;\n+\t\t\t}\n+\t\t}\n+\n+\t\tfor (i = 0; i < 2; i++) {\n+\t\t\tif (main_loop(test_data, level, RTE_COMP_DECOMPRESS,\n+\t\t\t\t\tNULL, NULL, 1) < 0) {\n+\t\t\t\tret = EXIT_FAILURE;\n+\t\t\t\tgoto err;\n+\t\t\t}\n+\t\t}\n+\n+\t\tuint64_t comp_tsc_duration =\n+\t\t\t\ttest_data->comp_tsc_duration[level];\n+\t\tdouble comp_tsc_byte = (double)comp_tsc_duration /\n+\t\t\t\t\t\ttest_data->input_data_sz;\n+\t\tdouble comp_gbps = rte_get_tsc_hz() / comp_tsc_byte * 8 /\n+\t\t\t\t1000000000;\n+\t\tuint64_t decomp_tsc_duration =\n+\t\t\t\ttest_data->decomp_tsc_duration[level];\n+\t\tdouble decomp_tsc_byte = (double)decomp_tsc_duration /\n+\t\t\t\t\t\ttest_data->input_data_sz;\n+\t\tdouble decomp_gbps = rte_get_tsc_hz() / decomp_tsc_byte * 8 /\n+\t\t\t\t1000000000;\n+\n+\t\tprintf(\"%6u%12zu%17.2f%19\"PRIu64\"%21.2f\"\n+\t\t\t\t\t\"%15.2f%21\"PRIu64\"%23.2f%16.2f\\n\",\n+\t\t       level, comp_data_sz, ratio, comp_tsc_duration,\n+\t\t       comp_tsc_byte, comp_gbps, decomp_tsc_duration,\n+\t\t       decomp_tsc_byte, decomp_gbps);\n+\n+\t\tif (test_data->level.inc != 0)\n+\t\t\tlevel += test_data->level.inc;\n+\t\telse {\n+\t\t\tif (++level_idx == test_data->level.count)\n+\t\t\t\tbreak;\n+\t\t\tlevel = test_data->level.list[level_idx];\n+\t\t}\n+\t}\n+\n \tret = EXIT_SUCCESS;\n \n err:\n+\tif (test_data->cdev_id != -1)\n+\t\trte_compressdev_stop(test_data->cdev_id);\n+\n+\tfree_bufs(test_data);\n+\trte_free(test_data->compressed_data);\n+\trte_free(test_data->decompressed_data);\n+\trte_free(test_data->input_data);\n+\trte_mempool_free(test_data->comp_buf_pool);\n+\trte_mempool_free(test_data->decomp_buf_pool);\n+\trte_mempool_free(test_data->op_pool);\n+\n \trte_free(test_data);\n \n \treturn ret;\n",
    "prefixes": [
        "2/3"
    ]
}