From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0082.outbound.protection.outlook.com [104.47.32.82]) by dpdk.org (Postfix) with ESMTP id 690FD2C55 for ; Tue, 4 Sep 2018 06:03:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=B+jfvW/tphfxK2WAByrrj4CRyIP4H7pcPAsx1d9brF4=; b=FP5raG6byal2KSp6SvkhbwhPepmidWimvw+O2xTGX/HvPaqh6+OxyRIhbwrYT1+KVikRq1EBgGzAxckcxxMKh0U8pHLTMZpBY1Adh5k3eLef30jfQJmR8lG6kc9bQGgFnhSeouT+GQwYfzAFfhIekU1akv3kIZtLJk+j3jDawKw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Anoob.Joseph@cavium.com; Received: from ajoseph83.caveonetworks.com.com (115.113.156.2) by BYAPR07MB4902.namprd07.prod.outlook.com (2603:10b6:a02:ef::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1101.15; Tue, 4 Sep 2018 04:02:30 +0000 From: Anoob Joseph To: Akhil Goyal , Pablo de Lara , Thomas Monjalon Cc: Murthy NSSR , Jerin Jacob , Narayana Prasad , dev@dpdk.org, Ankur Dwivedi , Anoob Joseph , Nithin Dabilpuram , Ragothaman Jayaraman , Srisivasubramanian S , Tejasree Kondoj Date: Tue, 4 Sep 2018 09:28:58 +0530 Message-Id: <1536033560-21541-12-git-send-email-ajoseph@caviumnetworks.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536033560-21541-1-git-send-email-ajoseph@caviumnetworks.com> References: <1528476325-15585-1-git-send-email-anoob.joseph@caviumnetworks.com> <1536033560-21541-1-git-send-email-ajoseph@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [115.113.156.2] X-ClientProxiedBy: BMXPR01CA0023.INDPRD01.PROD.OUTLOOK.COM (2603:1096:b00:d::33) To BYAPR07MB4902.namprd07.prod.outlook.com (2603:10b6:a02:ef::25) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 02d4ec1a-2e43-47e9-a1bc-08d6121b3e9e X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989137)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:BYAPR07MB4902; X-Microsoft-Exchange-Diagnostics: 1; BYAPR07MB4902; 3:2j5vgcfagvJEd0eOhQn2O7YehKXOr1ZyOu7OxpAE4tXT1CbMaKR6f4ryaGN9hUdkSZgSF0RxXqqEFWDFUDvrnIabNlwLaaNkQNcyNzSsabyasbBxlNJwZVm2LJLT4VdQtpgHtRWVPCaIULSDLzOJBS9zkpDUDGHq7G6MEckhp5TV9FWDCk5ESUK8xX+1NiWYle8qWxUunpzWR5ud1zgovVqpmvwE74kBsjNuSApHYzHdgXk2aRZ42vvEW3Nygs+3; 25:d+PklkNjiC4T6i6yWP8dds+XobN9W3cxzNJZDm2C76NxD1gGy9QOI+JepqfhhNX2fLpskALTpnx/JfWrRDkuOsGA2vQnnHf9+fr2yVjC4HbmJjatG68jFzW/KuW2zPfZFy5PLkdGRF6286M6fG1JaRMvKtf3+msMP/zqDXRL+39Xd7P0raS23O4Cp7xb268hp9Lq7+cKxdVu/oBymNyxUD8X27Nq35hYOMAgvjy6G7ufUtVvnUe5NR7+tJOaLpCCk1C6NZwC2OJ2RmlrAJlbv3m01OmGdBAKzqbbOnv+wr9R01BtasyudOJNN0HK6yotLpnULJv/42x8cLfIys+obQ==; 31:kX6UysNM8QToLOY4yXnXt2AgNXnrF1yndHkmAD0MuDxUVXM2IGkdatOCF+qgjNzjNc+3GtrDgHd+AmUCaz0U7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Gv26qPhZKgVf+O1nDsT+kTm4Rz1v0oe4QYAHHQpl8fCw== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(10201501046)(93006095)(3231311)(944501410)(52105095)(3002001)(149027)(150027)(6041310)(20161123562045)(20161123564045)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699016); SRVR:BYAPR07MB4902; BCL:0; PCL:0; RULEID:; SRVR:BYAPR07MB4902; X-Forefront-PRVS: 0785459C39 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(396003)(136003)(346002)(376002)(39860400002)(199004)(189003)(26005)(51416003)(52116002)(76176011)(81166006)(305945005)(81156014)(7736002)(105586002)(316002)(6506007)(106356001)(6512007)(8936002)(446003)(54906003)(25786009)(6666003)(68736007)(50226002)(110136005)(53936002)(16586007)(42882007)(386003)(5660300001)(2906002)(72206003)(50466002)(6486002)(36756003)(6116002)(107886003)(2616005)(14444005)(186003)(3846002)(478600001)(66066001)(476003)(8676002)(47776003)(486006)(956004)(48376002)(11346002)(4326008)(97736004)(16526019); DIR:OUT; SFP:1101; SCL:1; SRVR:BYAPR07MB4902; H:ajoseph83.caveonetworks.com.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BYAPR07MB4902; 23:eryDDbmFayPYMexcLNJnn5/yeYi2YKbm0n4+yRXzv?= =?us-ascii?Q?M2dYV10IVH/0dnubGCudwuNRQGYwbTIsMkcwRA4AR1l7TS+EmLZxTXXH4/ZI?= =?us-ascii?Q?w2MyLRN6EdHJIHpbC9zWQ+4enu66A/cEtj5xzx+5MnNjLdtSuj6YTdj45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a5oUBB4CMRiShP9Gz?= =?us-ascii?Q?RoiyTlLbDwlFQbrbYMm2fzWy+lRJ2qZpKy8E1p7KnKGA/rJx/X0WClTl7lsA?= =?us-ascii?Q?wO2ph7zZPEV5epL2CZVogWH2qpTbTUeT0m6UIG7G1Kc9H3LbcyWZzPc8LWwk?= =?us-ascii?Q?E+DjTP4elgP8anhphIEQShXfuaPEWqEUefvFv0HpFyOI99a4Lqgxr3L+6Ohp?= =?us-ascii?Q?ASDS2TW63E46SICfG0=3D?= X-Microsoft-Antispam-Message-Info: UFamUQ5i9a/2owxpTO0MaHTE41VXmmuHyhxeL/pYmbrow23wV7npIkQYyE52WOFwFnIkUsmw4kf3kYaOh07yzVivrtL1FsdJ14pMwhtUC12KPu+/PvKa1t7DspCopwpjAa2m5mVhSC4ZSdKGrvkkfK1U60flQyw0ZZ7EWNNHF7QoJWaXaCockP6SIwpkfWNi6AZ2wcfrivW9b3+240Il1JIkdIJJ+0HhqAYZdnseduBdlUhEHFDUHgwArVW3TMUXh+fjvQUDZrI9ZNK/l96SB4h/2TATulh5+Lyzn1JduznOWjglX4xjuNIddxX/AZ66mGqKbnWbEK3XznYEMjRoBWnypLz0qYVcSvEPfiV2GII= X-Microsoft-Exchange-Diagnostics: 1; BYAPR07MB4902; 6:NPXeGt22wqt+7AkVJbiIaGTz5ivFDA83Vy8Umviu12y2txn59qQ1MztuEqFaYl5qv4UDDW8FMU+6w7TbQlPNCY084JDHJOl+dAADrJXZH90YJNzT1CMChTXwHyn8nl79xWGGuuDISvoHYuWhPCos6+CaRoYBIpBz6BS8MTujZ8CaUMS63JsiVjmkE7xgguUXMXno++wHuY9IDY5Ofe6JnzsqU06laujr59Hw3Kt6UFrwvsRAro18WNa++WqfeyqASk9WeeISp1vY6UlUyWUqtGrt3ZJYn74iIbKhdmH3IciLuR5Z//uTVJ6/uMnjt1BoNiDEuiACS/B/gjfb0cbeemQdIn23BXdUoxK4KvFAKPwsUUtBRmJXNmso4uUn+zbhvANgNvoPWFjpv0LHAZjcSkQqQmKcziKsSwWrm+HIaNAlZPHCsq0B6QlV3hdNUMwHnJa9pA7VDrHtuFkCXH0D4w==; 5:saSdV/zHxjeNgI6S9w0m7O9RhnPt3uN3bfwmDVHQ9fpAa605hk+5+C7qEKEGQySFuL46Q5aT431XIQNYhEcn+S7QX68Furb10mMXz+AtpUwAfh2WBQSKXnrEDJvkk5c74u9nMZxuFWlaZOz/7kks1VEmUzXq7LMh2oQhcEOTcz0=; 7:WVM1HLZZZl5UYrStIL64ZfFSs0sGgqglEPg59NypNrEJxbnwa1C+zKtbsRKvj1CqLG6AnMNo/gv/+nfglfOA8dBaozQpphrbVLYp5SoH2sPY34HoLVCE9/GJmJJ/OILXBE3JHbmvCcAbN/5/KFUCDAsbRqLwkrZCfxfl8dKhF2DwQVIv25I1DIJOgXSaLpP7wF21rQNyl3Xxl0PEe3j26NwxvWVjElh73Ntruc1tYi0esJ8UKjneOKr7Apolixll SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Sep 2018 04:02:30.5223 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 02d4ec1a-2e43-47e9-a1bc-08d6121b3e9e X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR07MB4902 Subject: [dpdk-dev] [PATCH v2 11/33] crypto/octeontx: add global resource init X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Sep 2018 04:03:08 -0000 From: Murthy NSSR Adding initialization of global resources. This will be saved as metadata in cptvf and would be used by common code. Exit path for failure case is also added along with the new routines. Signed-off-by: Ankur Dwivedi Signed-off-by: Anoob Joseph Signed-off-by: Murthy NSSR Signed-off-by: Nithin Dabilpuram Signed-off-by: Ragothaman Jayaraman Signed-off-by: Srisivasubramanian S Signed-off-by: Tejasree Kondoj --- drivers/crypto/octeontx/Makefile | 1 + drivers/crypto/octeontx/meson.build | 3 +- drivers/crypto/octeontx/otx_cryptodev.c | 3 + drivers/crypto/octeontx/otx_cryptodev_hw_access.c | 11 +++ drivers/crypto/octeontx/otx_cryptodev_hw_access.h | 3 + drivers/crypto/octeontx/otx_cryptodev_ops.c | 90 +++++++++++++++++++++++ drivers/crypto/octeontx/otx_cryptodev_ops.h | 3 + 7 files changed, 113 insertions(+), 1 deletion(-) diff --git a/drivers/crypto/octeontx/Makefile b/drivers/crypto/octeontx/Makefile index 4582540..064c9b0 100644 --- a/drivers/crypto/octeontx/Makefile +++ b/drivers/crypto/octeontx/Makefile @@ -16,6 +16,7 @@ CFLAGS += $(WERROR_FLAGS) LDLIBS += -lrte_eal -lrte_mbuf -lrte_mempool -lrte_ring LDLIBS += -lrte_cryptodev LDLIBS += -lrte_pci -lrte_bus_pci +LDLIBS += -lrte_common_cpt VPATH += $(RTE_SDK)/drivers/crypto/octeontx diff --git a/drivers/crypto/octeontx/meson.build b/drivers/crypto/octeontx/meson.build index eca1cf1..60ffc97 100644 --- a/drivers/crypto/octeontx/meson.build +++ b/drivers/crypto/octeontx/meson.build @@ -5,11 +5,12 @@ if host_machine.system() != 'linux' endif deps += ['bus_pci'] +deps += ['common_cpt'] name = 'octeontx_crypto' sources = files('otx_cryptodev.c', 'otx_cryptodev_hw_access.c', 'otx_cryptodev_ops.c') -cflags += '-DCPT_MODEL=CRYPTO_OCTEONTX' includes += include_directories('../../common/cpt') +cflags += '-DCPT_MODEL=CRYPTO_OCTEONTX' diff --git a/drivers/crypto/octeontx/otx_cryptodev.c b/drivers/crypto/octeontx/otx_cryptodev.c index df88a84..ed1a3a1 100644 --- a/drivers/crypto/octeontx/otx_cryptodev.c +++ b/drivers/crypto/octeontx/otx_cryptodev.c @@ -113,6 +113,9 @@ otx_cpt_pci_remove(struct rte_pci_device *pci_dev) cryptodev->device->driver = NULL; cryptodev->data = NULL; + /* free metapool memory */ + cleanup_global_resources(); + return 0; } diff --git a/drivers/crypto/octeontx/otx_cryptodev_hw_access.c b/drivers/crypto/octeontx/otx_cryptodev_hw_access.c index 02ec3ce..f8b6005 100644 --- a/drivers/crypto/octeontx/otx_cryptodev_hw_access.c +++ b/drivers/crypto/octeontx/otx_cryptodev_hw_access.c @@ -241,3 +241,14 @@ otx_cpt_hw_init(struct cpt_vf *cptvf, void *pdev, void *reg_base, char *name) return 0; } + +int +otx_cpt_deinit_device(void *dev) +{ + struct cpt_vf *cptvf = (struct cpt_vf *)dev; + + /* Do misc work one last time */ + otx_cpt_poll_misc(cptvf); + + return 0; +} diff --git a/drivers/crypto/octeontx/otx_cryptodev_hw_access.h b/drivers/crypto/octeontx/otx_cryptodev_hw_access.h index f3c7a45..82d8255 100644 --- a/drivers/crypto/octeontx/otx_cryptodev_hw_access.h +++ b/drivers/crypto/octeontx/otx_cryptodev_hw_access.h @@ -147,4 +147,7 @@ otx_cpt_poll_misc(struct cpt_vf *cptvf); int otx_cpt_hw_init(struct cpt_vf *cptvf, void *pdev, void *reg_base, char *name); +int +otx_cpt_deinit_device(void *dev); + #endif /* _OTX_CRYPTODEV_HW_ACCESS_H_ */ diff --git a/drivers/crypto/octeontx/otx_cryptodev_ops.c b/drivers/crypto/octeontx/otx_cryptodev_ops.c index cc0030e..d109159 100644 --- a/drivers/crypto/octeontx/otx_cryptodev_ops.c +++ b/drivers/crypto/octeontx/otx_cryptodev_ops.c @@ -8,6 +8,7 @@ #include #include "cpt_pmd_logs.h" +#include "cpt_pmd_ops_helper.h" #include "otx_cryptodev.h" #include "otx_cryptodev_capabilities.h" @@ -19,6 +20,63 @@ static const struct rte_cryptodev_capabilities otx_capabilities[] = { RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST() }; +static int otx_cryptodev_probe_count; +static rte_spinlock_t otx_probe_count_lock = RTE_SPINLOCK_INITIALIZER; + +static struct rte_mempool *otx_cpt_meta_pool; +static int otx_cpt_op_mlen; +static int otx_cpt_op_sb_mlen; + +/* + * Initializes global variables used by fast-path code + * + * @return + * - 0 on success, errcode on error + */ +static int +init_global_resources(void) +{ + /* Get meta len for scatter gather mode */ + otx_cpt_op_mlen = cpt_pmd_ops_helper_get_mlen_sg_mode(); + + /* Extra 4B saved for future considerations */ + otx_cpt_op_mlen += 4 * sizeof(uint64_t); + + otx_cpt_meta_pool = rte_mempool_create("cpt_metabuf-pool", 4096 * 16, + otx_cpt_op_mlen, 512, 0, + NULL, NULL, NULL, NULL, + SOCKET_ID_ANY, 0); + if (!otx_cpt_meta_pool) { + CPT_LOG_ERR("cpt metabuf pool not created"); + return -ENOMEM; + } + + /* Get meta len for direct mode */ + otx_cpt_op_sb_mlen = cpt_pmd_ops_helper_get_mlen_direct_mode(); + + /* Extra 4B saved for future considerations */ + otx_cpt_op_sb_mlen += 4 * sizeof(uint64_t); + + return 0; +} + +void +cleanup_global_resources(void) +{ + /* Take lock */ + rte_spinlock_lock(&otx_probe_count_lock); + + /* Decrement the cryptodev count */ + otx_cryptodev_probe_count--; + + /* Free buffers */ + if (otx_cpt_meta_pool && otx_cryptodev_probe_count == 0) + rte_mempool_free(otx_cpt_meta_pool); + + /* Free lock */ + rte_spinlock_unlock(&otx_probe_count_lock); +} + /* Alarm routines */ static void @@ -37,6 +95,20 @@ otx_cpt_periodic_alarm_start(void *arg) otx_cpt_alarm_cb, arg); } +static int +otx_cpt_periodic_alarm_stop(void *arg) +{ + return rte_eal_alarm_cancel(otx_cpt_alarm_cb, arg); +} + +static void +otx_cpt_common_vars_init(struct cpt_vf *cptvf) +{ + cptvf->meta_info.cptvf_meta_pool = otx_cpt_meta_pool; + cptvf->meta_info.cptvf_op_mlen = otx_cpt_op_mlen; + cptvf->meta_info.cptvf_op_sb_mlen = otx_cpt_op_sb_mlen; +} + int otx_cpt_dev_create(struct rte_cryptodev *c_dev) { @@ -84,6 +156,20 @@ otx_cpt_dev_create(struct rte_cryptodev *c_dev) /* Start off timer for mailbox interrupts */ otx_cpt_periodic_alarm_start(cptvf); + rte_spinlock_lock(&otx_probe_count_lock); + if (!otx_cryptodev_probe_count) { + ret = init_global_resources(); + if (ret) { + rte_spinlock_unlock(&otx_probe_count_lock); + goto init_fail; + } + } + otx_cryptodev_probe_count++; + rte_spinlock_unlock(&otx_probe_count_lock); + + /* Initialize data path variables used by common code */ + otx_cpt_common_vars_init(cptvf); + c_dev->dev_ops = NULL; c_dev->enqueue_burst = NULL; @@ -98,6 +184,10 @@ otx_cpt_dev_create(struct rte_cryptodev *c_dev) return 0; +init_fail: + otx_cpt_periodic_alarm_stop(cptvf); + otx_cpt_deinit_device(cptvf); + fail: if (cptvf) { /* Free private data allocated */ diff --git a/drivers/crypto/octeontx/otx_cryptodev_ops.h b/drivers/crypto/octeontx/otx_cryptodev_ops.h index 3f2d829..ac88fa5 100644 --- a/drivers/crypto/octeontx/otx_cryptodev_ops.h +++ b/drivers/crypto/octeontx/otx_cryptodev_ops.h @@ -5,6 +5,9 @@ #ifndef _OTX_CRYPTODEV_OPS_H_ #define _OTX_CRYPTODEV_OPS_H_ +void +cleanup_global_resources(void); + int otx_cpt_dev_create(struct rte_cryptodev *c_dev); -- 2.7.4