get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

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

{
    "id": 11438,
    "url": "http://patchwork.dpdk.org/api/patches/11438/?format=api",
    "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/1457654571-17432-4-git-send-email-pablo.de.lara.guarch@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": "<1457654571-17432-4-git-send-email-pablo.de.lara.guarch@intel.com>",
    "list_archive_url": "https://inbox.dpdk.org/dev/1457654571-17432-4-git-send-email-pablo.de.lara.guarch@intel.com",
    "date": "2016-03-11T00:02:48",
    "name": "[dpdk-dev,3/6] l2fwd-crypto: implement parse_key function",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": true,
    "hash": "ed4a5c7d36ab5e73bb356b7d1d0ec34559bd5599",
    "submitter": {
        "id": 9,
        "url": "http://patchwork.dpdk.org/api/people/9/?format=api",
        "name": "De Lara Guarch, Pablo",
        "email": "pablo.de.lara.guarch@intel.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/1457654571-17432-4-git-send-email-pablo.de.lara.guarch@intel.com/mbox/",
    "series": [],
    "comments": "http://patchwork.dpdk.org/api/patches/11438/comments/",
    "check": "pending",
    "checks": "http://patchwork.dpdk.org/api/patches/11438/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 3FC954A65;\n\tFri, 11 Mar 2016 01:00:43 +0100 (CET)",
            "from mga03.intel.com (mga03.intel.com [134.134.136.65])\n\tby dpdk.org (Postfix) with ESMTP id 2AB6F379B\n\tfor <dev@dpdk.org>; Fri, 11 Mar 2016 01:00:39 +0100 (CET)",
            "from fmsmga004.fm.intel.com ([10.253.24.48])\n\tby orsmga103.jf.intel.com with ESMTP; 10 Mar 2016 16:00:39 -0800",
            "from sie-lab-212-116.ir.intel.com ([10.237.212.116])\n\tby fmsmga004.fm.intel.com with ESMTP; 10 Mar 2016 16:00:37 -0800"
        ],
        "X-ExtLoop1": "1",
        "X-IronPort-AV": "E=Sophos;i=\"5.24,317,1455004800\"; d=\"scan'208\";a=\"63916673\"",
        "From": "Pablo de Lara <pablo.de.lara.guarch@intel.com>",
        "To": "dev@dpdk.org",
        "Date": "Fri, 11 Mar 2016 00:02:48 +0000",
        "Message-Id": "<1457654571-17432-4-git-send-email-pablo.de.lara.guarch@intel.com>",
        "X-Mailer": "git-send-email 2.5.0",
        "In-Reply-To": "<1457654571-17432-1-git-send-email-pablo.de.lara.guarch@intel.com>",
        "References": "<1457654571-17432-1-git-send-email-pablo.de.lara.guarch@intel.com>",
        "Subject": "[dpdk-dev] [PATCH 3/6] l2fwd-crypto: implement parse_key function",
        "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": "Implement key parsing functionality, so user can provide\nauth and cipher keys, plus IV, from the command line.\n\nSigned-off-by: Pablo de Lara <pablo.de.lara.guarch@intel.com>\n---\n examples/l2fwd-crypto/main.c | 123 +++++++++++++++++++++++++++----------------\n 1 file changed, 78 insertions(+), 45 deletions(-)",
    "diff": "diff --git a/examples/l2fwd-crypto/main.c b/examples/l2fwd-crypto/main.c\nindex d1e05d9..bc37746 100644\n--- a/examples/l2fwd-crypto/main.c\n+++ b/examples/l2fwd-crypto/main.c\n@@ -76,6 +76,7 @@\n \n #define NB_MBUF   8192\n \n+#define MAX_KEY_SIZE 128\n #define MAX_PKT_BURST 32\n #define BURST_TX_DRAIN_US 100 /* TX drain every ~100us */\n \n@@ -136,13 +137,13 @@ struct l2fwd_crypto_options {\n \tenum l2fwd_crypto_xform_chain xform_chain;\n \n \tstruct rte_crypto_sym_xform cipher_xform;\n-\tuint8_t ckey_data[32];\n+\tunsigned ckey_param;\n \n-\tstruct l2fwd_key iv_key;\n-\tuint8_t ivkey_data[16];\n+\tstruct l2fwd_key iv;\n+\tunsigned iv_param;\n \n \tstruct rte_crypto_sym_xform auth_xform;\n-\tuint8_t akey_data[128];\n+\tuint8_t akey_param;\n };\n \n /** l2fwd crypto lcore params */\n@@ -152,7 +153,7 @@ struct l2fwd_crypto_params {\n \n \tunsigned digest_length;\n \tunsigned block_size;\n-\tstruct l2fwd_key iv_key;\n+\tstruct l2fwd_key iv;\n \tstruct rte_cryptodev_sym_session *session;\n };\n \n@@ -172,6 +173,8 @@ struct lcore_queue_conf lcore_queue_conf[RTE_MAX_LCORE];\n \n static const struct rte_eth_conf port_conf = {\n \t.rxmode = {\n+\t\t.mq_mode = ETH_MQ_RX_NONE,\n+\t\t.max_rx_pkt_len = ETHER_MAX_LEN,\n \t\t.split_hdr_size = 0,\n \t\t.header_split   = 0, /**< Header Split disabled */\n \t\t.hw_ip_checksum = 0, /**< IP checksum offload disabled */\n@@ -397,9 +400,9 @@ l2fwd_simple_crypto_enqueue(struct rte_mbuf *m,\n \top->sym->auth.data.length = data_len;\n \n \n-\top->sym->cipher.iv.data = cparams->iv_key.data;\n-\top->sym->cipher.iv.phys_addr = cparams->iv_key.phys_addr;\n-\top->sym->cipher.iv.length = cparams->iv_key.length;\n+\top->sym->cipher.iv.data = cparams->iv.data;\n+\top->sym->cipher.iv.phys_addr = cparams->iv.phys_addr;\n+\top->sym->cipher.iv.length = cparams->iv.length;\n \n \top->sym->cipher.data.offset = ipdata_offset;\n \top->sym->cipher.data.length = data_len;\n@@ -546,13 +549,12 @@ l2fwd_main_loop(struct l2fwd_crypto_options *options)\n \t\tport_cparams[i].block_size = 64;\n \t\tport_cparams[i].digest_length = 20;\n \n-\t\tport_cparams[i].iv_key.data =\n-\t\t\t\t(uint8_t *)rte_malloc(NULL, 16, 8);\n-\t\tport_cparams[i].iv_key.length = 16;\n-\t\tport_cparams[i].iv_key.phys_addr = rte_malloc_virt2phy(\n-\t\t\t\t(void *)port_cparams[i].iv_key.data);\n-\t\tgenerate_random_key(port_cparams[i].iv_key.data,\n-\t\t\t\tsizeof(cparams[i].iv_key.length));\n+\t\tport_cparams[i].iv.length = 16;\n+\t\tport_cparams[i].iv.data = options->iv.data;\n+\t\tport_cparams[i].iv.phys_addr = options->iv.phys_addr;\n+\t\tif (!options->iv_param)\n+\t\t\tgenerate_random_key(options->iv.data,\n+\t\t\t\t\tport_cparams[i].iv.length);\n \n \t\tport_cparams[i].session = initialize_crypto_session(options,\n \t\t\t\tport_cparams[i].dev_id);\n@@ -762,11 +764,24 @@ parse_cipher_op(enum rte_crypto_cipher_operation *op, char *optarg)\n \n /** Parse crypto key command line argument */\n static int\n-parse_key(struct l2fwd_key *key __rte_unused,\n-\t\tunsigned length __rte_unused, char *arg __rte_unused)\n+parse_key(uint8_t *data, char *input_arg)\n {\n-\tprintf(\"Currently an unsupported argument!\\n\");\n-\treturn -1;\n+\tunsigned byte_count;\n+\tchar *token;\n+\n+\tfor (byte_count = 0, token = strtok(input_arg, \":\");\n+\t\t\t(byte_count < MAX_KEY_SIZE) && (token != NULL);\n+\t\t\ttoken = strtok(NULL, \":\")) {\n+\n+\t\tint number = (int)strtol(token, NULL, 16);\n+\n+\t\tif (errno == EINVAL || errno == ERANGE || number > 0xFF)\n+\t\t\treturn -1;\n+\n+\t\tdata[byte_count++] = (uint8_t)number;\n+\t}\n+\n+\treturn 0;\n }\n \n /** Parse crypto cipher operation command line argument */\n@@ -833,18 +848,14 @@ l2fwd_crypto_parse_args_long_options(struct l2fwd_crypto_options *options,\n \t\t\t\toptarg);\n \n \telse if (strcmp(lgopts[option_index].name, \"cipher_key\") == 0) {\n-\t\tstruct l2fwd_key key = { 0 };\n-\t\tint retval = 0;\n-\n-\t\tretval = parse_key(&key, sizeof(options->ckey_data), optarg);\n-\n-\t\toptions->cipher_xform.cipher.key.data = key.data;\n-\t\toptions->cipher_xform.cipher.key.length = key.length;\n+\t\toptions->ckey_param = 1;\n+\t\treturn parse_key(options->cipher_xform.cipher.key.data, optarg);\n+\t}\n \n-\t\treturn retval;\n-\t} else if (strcmp(lgopts[option_index].name, \"iv\") == 0)\n-\t\treturn parse_key(&options->iv_key, sizeof(options->ivkey_data),\n-\t\t\t\toptarg);\n+\telse if (strcmp(lgopts[option_index].name, \"iv\") == 0) {\n+\t\toptions->iv_param = 1;\n+\t\treturn parse_key(options->iv.data, optarg);\n+\t}\n \n \t/* Authentication options */\n \telse if (strcmp(lgopts[option_index].name, \"auth_algo\") == 0)\n@@ -856,16 +867,11 @@ l2fwd_crypto_parse_args_long_options(struct l2fwd_crypto_options *options,\n \t\t\t\toptarg);\n \n \telse if (strcmp(lgopts[option_index].name, \"auth_key\") == 0) {\n-\t\tstruct l2fwd_key key = { 0 };\n-\t\tint retval = 0;\n-\n-\t\tretval = parse_key(&key, sizeof(options->akey_data), optarg);\n-\n-\t\toptions->auth_xform.auth.key.data = key.data;\n-\t\toptions->auth_xform.auth.key.length = key.length;\n+\t\toptions->akey_param = 1;\n+\t\treturn parse_key(options->auth_xform.auth.key.data, optarg);\n+\t}\n \n-\t\treturn retval;\n-\t} else if (strcmp(lgopts[option_index].name, \"sessionless\") == 0) {\n+\telse if (strcmp(lgopts[option_index].name, \"sessionless\") == 0) {\n \t\toptions->sessionless = 1;\n \t\treturn 0;\n \t}\n@@ -962,19 +968,19 @@ l2fwd_crypto_default_options(struct l2fwd_crypto_options *options)\n \t/* Cipher Data */\n \toptions->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;\n \toptions->cipher_xform.next = NULL;\n+\toptions->ckey_param = 0;\n+\toptions->iv_param = 0;\n \n \toptions->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;\n \toptions->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;\n \n-\tgenerate_random_key(options->ckey_data, sizeof(options->ckey_data));\n-\n-\toptions->cipher_xform.cipher.key.data = options->ckey_data;\n \toptions->cipher_xform.cipher.key.length = 16;\n \n \n \t/* Authentication Data */\n \toptions->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;\n \toptions->auth_xform.next = NULL;\n+\toptions->akey_param = 0;\n \n \toptions->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;\n \toptions->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;\n@@ -982,9 +988,6 @@ l2fwd_crypto_default_options(struct l2fwd_crypto_options *options)\n \toptions->auth_xform.auth.add_auth_data_length = 0;\n \toptions->auth_xform.auth.digest_length = 20;\n \n-\tgenerate_random_key(options->akey_data, sizeof(options->akey_data));\n-\n-\toptions->auth_xform.auth.key.data = options->akey_data;\n \toptions->auth_xform.auth.key.length = 20;\n }\n \n@@ -1333,6 +1336,26 @@ initialize_ports(struct l2fwd_crypto_options *options)\n \treturn enabled_portcount;\n }\n \n+static void\n+reserve_key_memory(struct l2fwd_crypto_options *options)\n+{\n+\toptions->cipher_xform.cipher.key.data = rte_malloc(\"crypto key\",\n+\t\t\t\t\t\tMAX_KEY_SIZE, 0);\n+\tif (options->cipher_xform.cipher.key.data == NULL)\n+\t\trte_exit(EXIT_FAILURE, \"Failed to allocate memory for cipher key\");\n+\n+\n+\toptions->auth_xform.auth.key.data = rte_malloc(\"auth key\",\n+\t\t\t\t\t\tMAX_KEY_SIZE, 0);\n+\tif (options->auth_xform.auth.key.data == NULL)\n+\t\trte_exit(EXIT_FAILURE, \"Failed to allocate memory for auth key\");\n+\n+\toptions->iv.data = rte_malloc(\"iv\", MAX_KEY_SIZE, 0);\n+\tif (options->iv.data == NULL)\n+\t\trte_exit(EXIT_FAILURE, \"Failed to allocate memory for IV\");\n+\toptions->iv.phys_addr = rte_malloc_virt2phy(options->iv.data);\n+}\n+\n int\n main(int argc, char **argv)\n {\n@@ -1350,6 +1373,9 @@ main(int argc, char **argv)\n \targc -= ret;\n \targv += ret;\n \n+\t/* reserve memory for Cipher/Auth key and IV */\n+\treserve_key_memory(&options);\n+\n \t/* parse application arguments (after the EAL ones) */\n \tret = l2fwd_crypto_parse_args(&options, argc, argv);\n \tif (ret < 0)\n@@ -1463,6 +1489,13 @@ main(int argc, char **argv)\n \t\t\t\t(unsigned)cdev_id);\n \t}\n \n+\tif (!options.akey_param)\n+\t\tgenerate_random_key(options.auth_xform.auth.key.data,\n+\t\t\t\toptions.auth_xform.auth.key.length);\n+\n+\tif (!options.ckey_param)\n+\t\tgenerate_random_key(options.cipher_xform.cipher.key.data,\n+\t\t\t\toptions.cipher_xform.cipher.key.length);\n \n \n \t/* launch per-lcore init on every lcore */\n",
    "prefixes": [
        "dpdk-dev",
        "3/6"
    ]
}