From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BN3-obe.outbound.protection.outlook.com (mail-bn3nam01on0086.outbound.protection.outlook.com [104.47.33.86]) by dpdk.org (Postfix) with ESMTP id 6A0831B0F9 for ; Fri, 5 Oct 2018 15:01:00 +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=3UHgqztJoAMFV9ZT76L4szySdxNPfWP+TgDOSSJ8CQc=; b=MEa+JYlNG5vwc6B+5gIRBgx1UNIQmO1CrytO3jI4ia3/S8qSwzL7/iJZjpDt+Q3I0Umo2/sFQfzERQec31LywzCQCszqH3LmmHe1rpLxgKSqAriZpQyvmzwbGJyFl5Js2ouoongDG9R7l38/3Gv/51pC64jWm52t0RTX1XZoOdE= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Anoob.Joseph@cavium.com; Received: from ajoseph83.caveonetworks.com.com (115.113.156.2) by SN6PR07MB4910.namprd07.prod.outlook.com (2603:10b6:805:39::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1207.21; Fri, 5 Oct 2018 13:00:53 +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: Fri, 5 Oct 2018 18:29:01 +0530 Message-Id: <1538744363-30340-11-git-send-email-anoob.joseph@caviumnetworks.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1538744363-30340-1-git-send-email-anoob.joseph@caviumnetworks.com> References: <1536033560-21541-1-git-send-email-ajoseph@caviumnetworks.com> <1538744363-30340-1-git-send-email-anoob.joseph@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [115.113.156.2] X-ClientProxiedBy: MA1PR0101CA0036.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:22::22) To SN6PR07MB4910.namprd07.prod.outlook.com (2603:10b6:805:39::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 73bf5b72-cf63-4951-75f0-08d62ac29868 X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:SN6PR07MB4910; X-Microsoft-Exchange-Diagnostics: 1; SN6PR07MB4910; 3:Ji4K5g8YZfZYFonipqqRjoyuIBRFKfC1+kZPvs9ebxuZo+5pZk4SyAJsXlsBH4j4sHJbO3PIxL34nkwHdQ5jcpMcgIvtzMYWru8DEvXe3bQrTObE4id8x+lI16JV9zAfh48U0XD6B5rjU9nTpZIxwT71p1z5gmozUN8WoiLU2ex2utq9rxGGJPg0fxE4E66XWMZzQ42fhts+a08fBb3uDHNv59bC7dqAmhr9vNHqEuLNnmscceo5fHJmR3Xl42l/; 25:As2ZhZkN+sxUBR66luGYAMFW97Hqh+PbBSINQ4FFQ1OsVtxZWDcNmvFQvpKFNppjD+CilEwWTQ9Bkq/Bsr39NdlRgkC43a7fe3VopG1kuqMyqCUjd3po6stymp+TeHts8Errm3//MxJBj/Lk7LoBOlpQm8xkKCQZEYR1xJJHZGIq4ZHhArkXJ4zVz6FOcxr+7YuAyh7wTx1e97R8S0JE01GozxiYbOxH4AL8JngiQejc8EJzjWQMSrsZ63E9x0WNACyZRiAyg6A8x5xyVU0SSgdhM3AhjALjwGaZJeINwW1aoo3w5tj9P6jpbuA8K6wbspdf1Vj4N8/Rys04noCs2Q==; 31:XcUfX5Gl5ohe6Ot8koP/utN2tb+Mvnq92W5nx7dqKso+mOyKfe08x2Mld5zPhM2hzSfOK/aF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FQaIUqKSIXzfC/cKMZLYTFFngGvlcQY0yQvXdNWeXSg0kKn+pZe+MiL7w== 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)(3002001)(3231355)(944501410)(52105095)(10201501046)(93006095)(149066)(150057)(6041310)(20161123564045)(20161123558120)(20161123560045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(201708071742011)(7699051); SRVR:SN6PR07MB4910; BCL:0; PCL:0; RULEID:; SRVR:SN6PR07MB4910; X-Forefront-PRVS: 0816F1D86E X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(979002)(376002)(39860400002)(346002)(136003)(396003)(366004)(199004)(189003)(51416003)(76176011)(11346002)(50226002)(25786009)(8936002)(48376002)(305945005)(186003)(16526019)(110136005)(6486002)(3846002)(446003)(52116002)(6116002)(81156014)(8676002)(575784001)(97736004)(5660300001)(50466002)(4326008)(956004)(42882007)(2616005)(68736007)(478600001)(54906003)(7736002)(81166006)(6666003)(16586007)(107886003)(26005)(55236004)(66066001)(386003)(47776003)(6512007)(72206003)(44832011)(476003)(316002)(14444005)(36756003)(105586002)(106356001)(486006)(6506007)(2906002)(53936002)(969003)(989001)(999001)(1009001)(1019001); DIR:OUT; SFP:1101; SCL:1; SRVR:SN6PR07MB4910; 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; SN6PR07MB4910; 23:iegQ+EtakyBxUemF9rQbQAit+xy3CUfyH5ngBAuq5?= =?us-ascii?Q?P2KOvL62BaxhhTTDQnXb4zeWiRLdO2VnTM4PBKrYKxVsm4GQ9G2N3NOdsp1k?= =?us-ascii?Q?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O6rAfH7F7PAS0n1I7M8lGYP/sHahzWgzw4sQozUzEFKUIgh5xa5hhhC7G+mrbQZMQnhiC1Z/vzq+IX9BZaeH1FsUzKwgOZY5RCt4TmAjiC72JdfNgV/YWbaoWbZv5kRpRfxt2VDTuQh4BLuM9Yi22zvcz32c1dTa3zJzDsl0Aog+Ml5/+y67xAW5rJ3XwpJyjOLTUbUCMd1WiAKaur7/WJUnCzi3H+/tUujewmuaNv/lhpNZ80v48Xj1xEqWhXr2RIffuwHRIQQrkxvAiEQrxIqT8Cp/18sZcgBIm0HOtY+lQ1chsDh4xr4tfFp8N2aHIMR9rGnlSYoXHaOBM/1jymEJk7RyOr0h/Llszo/Wfsf0aRWF1fBdqFQTCQCmSkfEWvULR/BIDw==; 5:jbf4fhMCA39o0R0EFaOv4XNtf8tqXZxhEdAaD50hexS+dhfLwVB+uHgTaTXs+I4rvQcIp0/dsoQia4dc5cpMRbJvHWHnyXqgHEwd6z4CUwipu7PIkUBpD+ethdEFHYNmqLw8coQ5V99ZcQGVnFjfW8WFxqoa2JJeLJQe4gzonE8=; 7:qwLZcT12A7e3YcwGKzbYlKYuOYYKeZlkspQWqPZIUpS2I07RPM7eZDxYeH2IPMFDq5Sk/LMEyojj5F/SKUE0GRZjV4gU5g7ICgYhgFSUAnLeSE3u2iALLZkrNcpJIAoBowEgxSRjQekjxIrw1PNtlJ6kTWsWVJlBu/NqT8A6rTSwdol7LEUGfkWUqj/UGd/e7fzH8spSuZwFOvQrcvJEdDTiw/7HhmNJG35vCxC8Z3uHRrEcJVS6yBHdzQS2v93k SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2018 13:00:53.9312 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 73bf5b72-cf63-4951-75f0-08d62ac29868 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR07MB4910 Subject: [dpdk-dev] [PATCH v3 10/32] 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: Fri, 05 Oct 2018 13:01:00 -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 d755441..1808244 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 4c5a40c..7f65476 100644 --- a/drivers/crypto/octeontx/meson.build +++ b/drivers/crypto/octeontx/meson.build @@ -5,6 +5,7 @@ if host_machine.system() != 'linux' endif deps += ['bus_pci'] +deps += ['common_cpt'] name = 'octeontx_crypto' sources = files('otx_cryptodev.c', @@ -12,5 +13,5 @@ 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 43933dd..269f045 100644 --- a/drivers/crypto/octeontx/otx_cryptodev.c +++ b/drivers/crypto/octeontx/otx_cryptodev.c @@ -104,6 +104,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 369d62b..e8a2b0b 100644 --- a/drivers/crypto/octeontx/otx_cryptodev_hw_access.c +++ b/drivers/crypto/octeontx/otx_cryptodev_hw_access.c @@ -236,3 +236,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 73473ed..6e5731a 100644 --- a/drivers/crypto/octeontx/otx_cryptodev_hw_access.h +++ b/drivers/crypto/octeontx/otx_cryptodev_hw_access.h @@ -142,4 +142,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 3bf6cd2..68c6b92 100644 --- a/drivers/crypto/octeontx/otx_cryptodev_ops.c +++ b/drivers/crypto/octeontx/otx_cryptodev_ops.c @@ -8,11 +8,69 @@ #include #include "cpt_pmd_logs.h" +#include "cpt_pmd_ops_helper.h" #include "otx_cryptodev.h" #include "otx_cryptodev_hw_access.h" #include "otx_cryptodev_ops.h" +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 @@ -31,6 +89,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) { @@ -78,6 +150,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; @@ -95,6 +181,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