Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/66316/?format=api
http://patchwork.dpdk.org/api/patches/66316/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/patch/20200306055609.11734-1-praveen.shetty@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": "<20200306055609.11734-1-praveen.shetty@intel.com>", "list_archive_url": "https://inbox.dpdk.org/dev/20200306055609.11734-1-praveen.shetty@intel.com", "date": "2020-03-06T05:56:09", "name": "[v1] examples/ipsec-secgw: load/unload esp-ah DDP file", "commit_ref": null, "pull_url": null, "state": "changes-requested", "archived": true, "hash": "f36150da1b08814357b255b26384d0466c7b0165", "submitter": { "id": 1521, "url": "http://patchwork.dpdk.org/api/people/1521/?format=api", "name": "Shetty, Praveen", "email": "praveen.shetty@intel.com" }, "delegate": { "id": 6690, "url": "http://patchwork.dpdk.org/api/users/6690/?format=api", "username": "akhil", "first_name": "akhil", "last_name": "goyal", "email": "gakhil@marvell.com" }, "mbox": "http://patchwork.dpdk.org/project/dpdk/patch/20200306055609.11734-1-praveen.shetty@intel.com/mbox/", "series": [ { "id": 8807, "url": "http://patchwork.dpdk.org/api/series/8807/?format=api", "web_url": "http://patchwork.dpdk.org/project/dpdk/list/?series=8807", "date": "2020-03-06T05:56:09", "name": "[v1] examples/ipsec-secgw: load/unload esp-ah DDP file", "version": 1, "mbox": "http://patchwork.dpdk.org/series/8807/mbox/" } ], "comments": "http://patchwork.dpdk.org/api/patches/66316/comments/", "check": "fail", "checks": "http://patchwork.dpdk.org/api/patches/66316/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<dev-bounces@dpdk.org>", "X-Original-To": "patchwork@inbox.dpdk.org", "Delivered-To": "patchwork@inbox.dpdk.org", "Received": [ "from dpdk.org (dpdk.org [92.243.14.124])\n\tby inbox.dpdk.org (Postfix) with ESMTP id 71324A056A;\n\tFri, 6 Mar 2020 06:56:18 +0100 (CET)", "from [92.243.14.124] (localhost [127.0.0.1])\n\tby dpdk.org (Postfix) with ESMTP id ADB801BFBB;\n\tFri, 6 Mar 2020 06:56:17 +0100 (CET)", "from mga05.intel.com (mga05.intel.com [192.55.52.43])\n by dpdk.org (Postfix) with ESMTP id 18E393B5\n for <dev@dpdk.org>; Fri, 6 Mar 2020 06:56:15 +0100 (CET)", "from orsmga002.jf.intel.com ([10.7.209.21])\n by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384;\n 05 Mar 2020 21:56:14 -0800", "from silpixa00399416.ir.intel.com (HELO\n silpixa00399416.ger.corp.intel.com) ([10.237.223.137])\n by orsmga002.jf.intel.com with ESMTP; 05 Mar 2020 21:56:12 -0800" ], "X-Amp-Result": "SKIPPED(no attachment in message)", "X-Amp-File-Uploaded": "False", "X-ExtLoop1": "1", "X-IronPort-AV": "E=Sophos;i=\"5.70,518,1574150400\"; d=\"scan'208\";a=\"259458378\"", "From": "Praveen Shetty <praveen.shetty@intel.com>", "To": "dev@dpdk.org, declan.doherty@intel.com, bernard.iremonger@intel.com,\n konstantin.ananyev@intel.com", "Date": "Fri, 6 Mar 2020 05:56:09 +0000", "Message-Id": "<20200306055609.11734-1-praveen.shetty@intel.com>", "X-Mailer": "git-send-email 2.17.1", "Subject": "[dpdk-dev] [PATCH v1] examples/ipsec-secgw: load/unload esp-ah DDP\n\tfile", "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 <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 <mailto:dev-request@dpdk.org?subject=subscribe>", "Errors-To": "dev-bounces@dpdk.org", "Sender": "\"dev\" <dev-bounces@dpdk.org>" }, "content": "Modified Secuirty gateway application to support load/unload\nesp-ah ddp package on i40e NIC from ipsec-secgw application.\n\nSigned-off-by: Praveen Shetty <praveen.shetty@intel.com>\n---\n examples/ipsec-secgw/ipsec-secgw.c | 67 +++++++++++-\n examples/ipsec-secgw/ipsec.c | 158 +++++++++++++++++++++++++++++\n examples/ipsec-secgw/ipsec.h | 6 +-\n 3 files changed, 228 insertions(+), 3 deletions(-)", "diff": "diff --git a/examples/ipsec-secgw/ipsec-secgw.c b/examples/ipsec-secgw/ipsec-secgw.c\nindex 4799bc90c..214b8a625 100644\n--- a/examples/ipsec-secgw/ipsec-secgw.c\n+++ b/examples/ipsec-secgw/ipsec-secgw.c\n@@ -198,7 +198,10 @@ struct app_sa_prm app_sa_prm = {\n \t\t\t.cache_sz = SA_CACHE_SZ\n \t\t};\n static const char *cfgfile;\n-\n+static const char *ddp_file;\n+static const char *ddp_bkp_file;\n+static uint16_t fdir_portid;\n+static int16_t ddp_unload_flag;\n struct lcore_rx_queue {\n \tuint16_t port_id;\n \tuint8_t queue_id;\n@@ -1286,6 +1289,8 @@ print_usage(const char *prgname)\n \t\t\" [-e]\"\n \t\t\" [-a]\"\n \t\t\" [-c]\"\n+\t\t\" [-L (portid,ddp_file_path,ddp_backup_file_path)]\"\n+\t\t\" [-U (portid,ddp_backup_file_path)]\"\n \t\t\" -f CONFIG_FILE\"\n \t\t\" --config (port,queue,lcore)[,(port,queue,lcore)]\"\n \t\t\" [--single-sa SAIDX]\"\n@@ -1307,6 +1312,8 @@ print_usage(const char *prgname)\n \t\t\" -a enables SA SQN atomic behaviour\\n\"\n \t\t\" -c specifies inbound SAD cache size,\\n\"\n \t\t\" zero value disables the cache (default value: 128)\\n\"\n+\t\t\" -L To load ddp profile on NIC\\n\"\n+\t\t\" -U To unload ddp profile from NIC\\n\"\n \t\t\" -f CONFIG_FILE: Configuration file\\n\"\n \t\t\" --config (port,queue,lcore): Rx queue configuration\\n\"\n \t\t\" --single-sa SAIDX: Use single SA index for outbound traffic,\\n\"\n@@ -1379,6 +1386,33 @@ parse_decimal(const char *str)\n \treturn num;\n }\n \n+static int32_t\n+parse_ddp_load_args(char *str)\n+{\n+\tint16_t num_args = 0;\n+\tchar *file_fld[3];\n+\tnum_args = rte_strsplit(str, strlen(str), file_fld, 3, ',');\n+\tif (num_args != 3)\n+\t\treturn -1;\n+\tfdir_portid = atoi(file_fld[0]);\n+\tddp_file = file_fld[1];\n+\tddp_bkp_file = file_fld[2];\n+\treturn 0;\n+}\n+\n+static int32_t\n+parse_ddp_unload_args(char *str)\n+{\n+\tint16_t num_args = 0;\n+\tchar *file_fld[2];\n+\tnum_args = rte_strsplit(str, strlen(str), file_fld, 2, ',');\n+\tif (num_args != 2)\n+\t\treturn -1;\n+\tfdir_portid = atoi(file_fld[0]);\n+\tddp_bkp_file = file_fld[1];\n+\treturn 0;\n+}\n+\n static int32_t\n parse_config(const char *q_arg)\n {\n@@ -1459,7 +1493,7 @@ parse_args(int32_t argc, char **argv)\n \n \targvopt = argv;\n \n-\twhile ((opt = getopt_long(argc, argvopt, \"aelp:Pu:f:j:w:c:\",\n+\twhile ((opt = getopt_long(argc, argvopt, \"aelp:Pu:L:U:f:j:w:c:\",\n \t\t\t\tlgopts, &option_index)) != EOF) {\n \n \t\tswitch (opt) {\n@@ -1483,6 +1517,25 @@ parse_args(int32_t argc, char **argv)\n \t\t\t\treturn -1;\n \t\t\t}\n \t\t\tbreak;\n+\t\tcase 'L':\n+\t\t\tprintf(\"Loading ddp package selected\\n\");\n+\t\t\tret = parse_ddp_load_args(optarg);\n+\t\t\tif (ret < 0) {\n+\t\t\t\tprintf(\"Invalid ddp load args: %s\\n\", optarg);\n+\t\t\t\tprint_usage(prgname);\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t\tbreak;\n+\t\tcase 'U':\n+\t\t\tprintf(\"Unloading ddp package selected\\n\");\n+\t\t\tret = parse_ddp_unload_args(optarg);\n+\t\t\tif (ret < 0) {\n+\t\t\t\tprintf(\"Invalid ddp unload args: %s\\n\", optarg);\n+\t\t\t\tprint_usage(prgname);\n+\t\t\t\treturn -1;\n+\t\t\t}\n+\t\t\tddp_unload_flag = 1;\n+\t\t\tbreak;\n \t\tcase 'f':\n \t\t\tif (f_present == 1) {\n \t\t\t\tprintf(\"\\\"-f\\\" option present more than \"\n@@ -2505,6 +2558,16 @@ main(int32_t argc, char **argv)\n \t\tsa_check_offloads(portid, &req_rx_offloads, &req_tx_offloads);\n \t\tport_init(portid, req_rx_offloads, req_tx_offloads);\n \t}\n+\tif (ddp_file != NULL && ddp_bkp_file != NULL) {\n+\t\tret = load_ddp_esp_package(fdir_portid, ddp_file, ddp_bkp_file);\n+\t\tif (ret < 0)\n+\t\t\tprintf(\"loading ddp package failed\\n\");\n+\t}\n+\tif (ddp_unload_flag && ddp_bkp_file != NULL) {\n+\t\tret = unload_ddp_esp_package(fdir_portid, ddp_bkp_file);\n+\t\tif (ret < 0)\n+\t\t\tprintf(\"unloading ddp package failed\\n\");\n+\t}\n \n \tcryptodevs_init();\n \ndiff --git a/examples/ipsec-secgw/ipsec.c b/examples/ipsec-secgw/ipsec.c\nindex 6e8120702..3840a0848 100644\n--- a/examples/ipsec-secgw/ipsec.c\n+++ b/examples/ipsec-secgw/ipsec.c\n@@ -4,6 +4,9 @@\n #include <sys/types.h>\n #include <netinet/in.h>\n #include <netinet/ip.h>\n+#include <sys/stat.h>\n+#include <fcntl.h>\n+#include <unistd.h>\n \n #include <rte_branch_prediction.h>\n #include <rte_log.h>\n@@ -14,6 +17,9 @@\n #include <rte_ethdev.h>\n #include <rte_mbuf.h>\n #include <rte_hash.h>\n+#ifdef RTE_LIBRTE_I40E_PMD\n+#include <rte_pmd_i40e.h>\n+#endif\n \n #include \"ipsec.h\"\n #include \"esp.h\"\n@@ -155,6 +161,158 @@ create_lookaside_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa,\n \treturn 0;\n }\n \n+static int\n+close_file(uint8_t *buf)\n+{\n+\tif (buf) {\n+\t\tfree((void *)buf);\n+\t\treturn 0;\n+\t}\n+\n+\treturn -1;\n+}\n+\n+static uint8_t *\n+open_file(const char *file_path, uint32_t *size)\n+{\n+\tint fd = open(file_path, O_RDONLY);\n+\toff_t pkg_size;\n+\tuint8_t *buf = NULL;\n+\tint ret = 0;\n+\tstruct stat st_buf;\n+\n+\tif (size)\n+\t\t*size = 0;\n+\n+\tif (fd == -1) {\n+\t\tprintf(\"%s: Failed to open %s\\n\", __func__, file_path);\n+\t\treturn buf;\n+\t}\n+\n+\tif ((fstat(fd, &st_buf) != 0) || (!S_ISREG(st_buf.st_mode))) {\n+\t\tclose(fd);\n+\t\tprintf(\"%s: File operations failed\\n\", __func__);\n+\t\treturn buf;\n+\t}\n+\n+\tpkg_size = st_buf.st_size;\n+\tif (pkg_size < 0) {\n+\t\tclose(fd);\n+\t\tprintf(\"%s: File operations failed\\n\", __func__);\n+\t\treturn buf;\n+\t}\n+\n+\tbuf = (uint8_t *)malloc(pkg_size);\n+\tif (!buf) {\n+\t\tclose(fd);\n+\t\tprintf(\"%s: Failed to malloc memory\\n\",\t__func__);\n+\t\treturn buf;\n+\t}\n+\n+\tret = read(fd, buf, pkg_size);\n+\tif (ret < 0) {\n+\t\tclose(fd);\n+\t\tprintf(\"%s: File read operation failed\\n\", __func__);\n+\t\tclose_file(buf);\n+\t\treturn NULL;\n+\t}\n+\n+\tif (size)\n+\t\t*size = pkg_size;\n+\n+\tclose(fd);\n+\n+\treturn buf;\n+}\n+\n+static int\n+save_file(const char *file_path, uint8_t *buf, uint32_t size)\n+{\n+\tFILE *fh = fopen(file_path, \"wb\");\n+\n+\tif (fh == NULL) {\n+\t\tprintf(\"%s: Failed to open %s\\n\", __func__, file_path);\n+\t\treturn -1;\n+\t}\n+\n+\tif (fwrite(buf, 1, size, fh) != size) {\n+\t\tfclose(fh);\n+\t\tprintf(\"%s: File write operation failed\\n\", __func__);\n+\t\treturn -1;\n+\t}\n+\n+\tfclose(fh);\n+\n+\treturn 0;\n+}\n+\n+/* Load dynamic device personalization profile */\n+int\n+load_ddp_esp_package(uint16_t fdir_portid, const char *ddp_file,\n+\t\tconst char *ddp_bkp_file)\n+{\n+\tuint8_t *buff;\n+\tuint32_t size;\n+\tint ret = -ENOTSUP;\n+\n+\tbuff = open_file(ddp_file, &size);\n+\tif (!buff)\n+\t\treturn -1;\n+\n+#ifdef RTE_LIBRTE_I40E_PMD\n+\tret = rte_pmd_i40e_process_ddp_package(fdir_portid,\n+\t\t\t\t\t buff, size,\n+\t\t\t\t\t RTE_PMD_I40E_PKG_OP_WR_ADD);\n+#endif\n+\n+\tif (ret == -EEXIST)\n+\t\tprintf(\"Profile has already existed.\\n\");\n+\telse if (ret < 0) {\n+\t\tprintf(\"Failed to load profile.\\n\");\n+\t\tclose_file(buff);\n+\t\treturn -1;\n+\t} else\n+\t\tprintf(\"loading ddp profile success\\n\");\n+\tif (ddp_bkp_file != NULL)\n+\t\tsave_file(ddp_bkp_file, buff, size);\n+\n+\tclose_file(buff);\n+\treturn 0;\n+}\n+\n+/* Unload dynamic device personalization profile */\n+int\n+unload_ddp_esp_package(uint16_t fdir_portid, const char *ddp_bkp_file)\n+{\n+\n+\tuint8_t *buff;\n+\tuint32_t size;\n+\tint ret = -ENOTSUP;\n+\n+\tbuff = open_file(ddp_bkp_file, &size);\n+\tif (!buff)\n+\t\treturn -1;\n+\n+#ifdef RTE_LIBRTE_I40E_PMD\n+\tret = rte_pmd_i40e_process_ddp_package(fdir_portid,\n+\t\t\t\t\t buff, size,\n+\t\t\t\t\t RTE_PMD_I40E_PKG_OP_WR_DEL);\n+#endif\n+\n+\tif (ret == -EACCES) {\n+\t\tprintf(\"Profile does not exist.\\n\");\n+\t\tclose_file(buff);\n+\t\treturn -1;\n+\t} else if (ret < 0) {\n+\t\tprintf(\"Failed to delete profile.\\n\");\n+\t\tclose_file(buff);\n+\t\treturn -1;\n+\t} else\n+\t\tprintf(\"ddp profile deleted successfully\\n\");\n+\tclose_file(buff);\n+\treturn 0;\n+}\n+\n int\n create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa,\n \t\tstruct rte_ipsec_session *ips)\ndiff --git a/examples/ipsec-secgw/ipsec.h b/examples/ipsec-secgw/ipsec.h\nindex 4f2fd6184..73eec47ab 100644\n--- a/examples/ipsec-secgw/ipsec.h\n+++ b/examples/ipsec-secgw/ipsec.h\n@@ -383,5 +383,9 @@ create_lookaside_session(struct ipsec_ctx *ipsec_ctx, struct ipsec_sa *sa,\n int\n create_inline_session(struct socket_ctx *skt_ctx, struct ipsec_sa *sa,\n \t\tstruct rte_ipsec_session *ips);\n-\n+int\n+load_ddp_esp_package(uint16_t fdir_portid, const char *ddp_file,\n+\t\tconst char *ddp_bkp_file);\n+int\n+unload_ddp_esp_package(uint16_t fdir_portid, const char *ddp_bkp_file);\n #endif /* __IPSEC_H__ */\n", "prefixes": [ "v1" ] }{ "id": 66316, "url": "